29 #include <tqstringlist.h>
31 #include <tqptrlist.h>
37 class KHttpCookieList;
39 typedef KHttpCookie *KHttpCookiePtr;
51 friend class KCookieJar;
52 friend class KHttpCookieList;
66 TQValueList<long> mWindowIds;
68 TQString cookieStr(
bool useDOMFormat);
71 KHttpCookie(
const TQString &_host=TQString::null,
72 const TQString &_domain=TQString::null,
73 const TQString &_path=TQString::null,
74 const TQString &_name=TQString::null,
75 const TQString &_value=TQString::null,
77 int _protocolVersion=0,
79 bool _httpOnly =
false,
80 bool _explicitPath =
false);
82 TQString domain(
void) {
return mDomain; }
83 TQString host(
void) {
return mHost; }
84 TQString path(
void) {
return mPath; }
85 TQString name(
void) {
return mName; }
86 TQString value(
void) {
return mValue; }
87 TQValueList<long> &windowIds(
void) {
return mWindowIds; }
88 void fixDomain(
const TQString &domain) { mDomain = domain; }
89 time_t expireDate(
void) {
return mExpireDate; }
90 int protocolVersion(
void) {
return mProtocolVersion; }
91 bool isSecure(
void) {
return mSecure; }
92 bool isExpired(time_t currentDate);
93 bool isCrossDomain(
void) {
return mCrossDomain; }
94 bool isHttpOnly(
void) {
return mHttpOnly; }
95 bool hasExplicitPath(
void) {
return mExplicitPath; }
96 bool match(
const TQString &fqdn,
const TQStringList &domainList,
const TQString &path);
99 class KHttpCookieList :
public TQPtrList<KHttpCookie>
102 KHttpCookieList() : TQPtrList<KHttpCookie>(), advice( KCookieDunno )
104 virtual ~KHttpCookieList() { }
106 virtual int compareItems(
void * item1,
void * item2);
107 KCookieAdvice getAdvice(
void) {
return advice; }
108 void setAdvice(KCookieAdvice _advice) { advice = _advice; }
111 KCookieAdvice advice;
134 bool changed()
const {
return m_cookiesChanged || m_configChanged; }
139 bool saveCookies(
const TQString &_filename);
144 bool loadCookies(
const TQString &_filename);
149 void saveConfig(TDEConfig *_config);
154 void loadConfig(TDEConfig *_config,
bool reparse =
false);
167 TQString findCookies(
const TQString &_url,
bool useDOMFormat,
long windowId, KHttpCookieList *pendingCookies=0);
177 KHttpCookieList makeCookies(
const TQString &_url,
const TQCString &cookie_headers,
long windowId);
187 KHttpCookieList makeDOMCookies(
const TQString &_url,
const TQCString &cookie_domstr,
long windowId);
194 void addCookie(KHttpCookiePtr &cookiePtr);
205 KCookieAdvice cookieAdvice(KHttpCookiePtr cookiePtr);
216 KCookieAdvice getDomainAdvice(
const TQString &_domain);
228 void setDomainAdvice(
const TQString &_domain, KCookieAdvice _advice);
240 void setDomainAdvice(KHttpCookiePtr _cookie, KCookieAdvice _advice);
252 KCookieAdvice getGlobalAdvice() {
return m_globalAdvice; }
264 void setGlobalAdvice(KCookieAdvice _advice);
272 const TQStringList& getDomainList();
277 const KHttpCookieList *getCookieList(
const TQString & _domain,
278 const TQString& _fqdn );
287 void eatCookie(KHttpCookiePtr cookiePtr);
292 void eatCookiesForDomain(
const TQString &domain);
297 void eatAllCookies();
303 void eatSessionCookies(
long windowId );
309 void eatSessionCookies(
const TQString& fqdn,
long windowId,
bool isFQDN =
true );
314 static bool parseURL(
const TQString &_url,
323 void extractDomains(
const TQString &_fqdn,
324 TQStringList &_domainList);
326 static TQString adviceToStr(KCookieAdvice _advice);
327 static KCookieAdvice strToAdvice(
const TQString &_str);
330 int preferredDefaultPolicy()
const {
return m_preferredPolicy; }
333 bool showCookieDetails ()
const {
return m_showCookieDetails; }
338 void setPreferredDefaultPolicy (
int value) { m_preferredPolicy = value; }
344 void setShowCookieDetails (
bool value) { m_showCookieDetails = value; }
347 void stripDomain(
const TQString &_fqdn, TQString &_domain);
348 TQString stripDomain( KHttpCookiePtr cookiePtr);
351 TQStringList m_domainList;
352 KCookieAdvice m_globalAdvice;
353 TQDict<KHttpCookieList> m_cookieDomains;
354 TQDict<int> m_twoLevelTLD;
356 bool m_configChanged;
357 bool m_cookiesChanged;
358 bool m_showCookieDetails;
359 bool m_rejectCrossDomainCookies;
360 bool m_autoAcceptSessionCookies;
361 bool m_ignoreCookieExpirationDate;
363 int m_preferredPolicy;