3 # Patch managed by http://www.holgerschurig.de/patcher.html
6 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiejar.cpp~kcookiejar-merge.patch
7 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiejar.cpp
9 /* This file is part of the KDE File Manager
11 - Copyright (C) 1998,1999,2000,2001 Waldo Bastian (bastian@kde.org)
12 - Copyright (C) 2000,2001 Dawit Alemayehu (adawit@kde.org)
14 + Copyright (C) 1998-2000 Waldo Bastian (bastian@kde.org)
15 + Copyright (C) 2000,2001 Dawit Alemayehu (adawit@kde.org)
17 Permission is hereby granted, free of charge, to any person obtaining a copy
18 of this software and associated documentation files (the "Software"), to deal
19 in the Software without restriction, including without limitation the rights
22 //----------------------------------------------------------------------------
24 -// KDE HTTP Cookie Manager
25 -// $Id: kcookiejar.cpp,v 1.58.2.5 2001/11/04 04:21:39 adawit Exp $
26 +// KDE File Manager -- HTTP Cookies
27 +// $Id: kcookiejar.cpp,v 1.117 2004/07/20 15:29:24 waba Exp $
30 // The cookie protocol is a mess. RFC2109 is a joke since nobody seems to
31 -// use it. Apart from that it is badly written. We try to implement Netscape
32 -// Cookies and try to behave according to RFC2109 as much as we can.
33 +// use it. Apart from that it is badly written.
34 +// We try to implement Netscape Cookies and try to behave us according to
35 +// RFC2109 as much as we can.
37 +// We assume cookies do not contain any spaces (Netscape spec.)
38 +// According to RFC2109 this is allowed though.
40 -// We assume cookies do not contain any spaces (Netscape spec.) According to
41 -// RFC2109 this is allowed though.
45 #include <sys/types.h>
57 +//#include <netinet/in.h>
58 +//#include <arpa/inet.h>
72 #define READ_BUFFER_SIZE 8192
74 +// Note with respect to QString::fromLatin1( )
75 +// Cookies are stored as 8 bit data and passed to kio_http as
76 +// latin1 regardless of their actual encoding.
78 +// L1 is used to indicate latin1 constants
79 +#define L1(x) QString::fromLatin1(x)
81 template class QList<KHttpCookie>;
82 template class QDict<KHttpCookieList>;
88 - case KCookieAccept: return "Accept";
89 - case KCookieReject: return "Reject";
90 - case KCookieAsk: return "Ask";
91 - default: return "Dunno";
92 + case KCookieAccept: return L1("Accept");
93 + case KCookieReject: return L1("Reject");
94 + case KCookieAsk: return L1("Ask");
95 + default: return L1("Dunno");
103 - QString advice = _str.lower();
104 + QCString advice = _str.lower().latin1();
106 if (advice == "accept")
107 return KCookieAccept;
108 @@ -105,17 +124,20 @@
109 const QString &_value,
111 int _protocolVersion,
115 + bool _explicitPath) :
119 + mPath(_path.isEmpty() ? QString::null : _path),
122 mExpireDate(_expireDate),
123 mProtocolVersion(_protocolVersion),
126 + mHttpOnly(_httpOnly),
127 + mExplicitPath(_explicitPath)
133 @@ -135,16 +157,17 @@
135 if (useDOMFormat || (mProtocolVersion == 0))
137 - result = mName + "=" + mValue;
138 + if ( !mName.isEmpty() )
139 + result = mName + '=';
144 - result.sprintf("$Version=\"%d\"; ", mProtocolVersion);
145 - result += mName + "=\"" + mValue + "\"";
146 - if (!mPath.isEmpty())
147 - result += "; $Path=\""+ mPath + "\"";
148 + result = mName + '=' + mValue;
150 + result += L1("; $Path=\"") + mPath + L1("\"");
151 if (!mDomain.isEmpty())
152 - result += "; $Domain=\""+ mDomain + "\"";
153 + result += L1("; $Domain=\"") + mDomain + L1("\"");
158 // Cookie domain match check
159 if (mDomain.isEmpty())
161 - // No domain set, check hostname.
166 else if (!domains.contains(mDomain))
167 @@ -167,17 +189,30 @@
170 // Maybe the domain needs an extra dot.
171 - QString domain = "." + mDomain;
172 + QString domain = '.' + mDomain;
173 if ( !domains.contains( domain ) )
174 if ( fqdn != mDomain )
178 // Cookie path match check
179 - if( !path.isEmpty() && !path.startsWith(mPath) )
180 - return false; // Path of URL does not start with cookie-path
181 + if (mPath.isEmpty())
185 + // According to the netscape spec both http://www.acme.com/foobar,
186 + // http://www.acme.com/foo.bar and http://www.acme.com/foo/bar
187 + // match http://www.acme.com/foo.
188 + // We only match http://www.acme.com/foo/bar
190 + if( path.startsWith(mPath) &&
192 + (path.length() == mPath.length() ) || // Paths are exact match
193 + (path[mPath.length()-1] == '/') || // mPath ended with a slash
194 + (path[mPath.length()] == '/') // A slash follows.
196 + return true; // Path of URL starts with cookie-path
203 int pathLen1 = ((KHttpCookie *)item1)->path().length();
204 int pathLen2 = ((KHttpCookie *)item2)->path().length();
205 if (pathLen1 > pathLen2)
207 - if (pathLen1 < pathLen2)
209 + if (pathLen1 < pathLen2)
214 @@ -205,10 +240,18 @@
216 KCookieJar::KCookieJar()
218 - cookieDomains.setAutoDelete( true );
219 - globalAdvice = KCookieDunno;
220 - configChanged = false;
221 - cookiesChanged = false;
222 + m_cookieDomains.setAutoDelete( true );
223 + m_globalAdvice = KCookieDunno;
224 + m_configChanged = false;
225 + m_cookiesChanged = false;
227 + QString twoLevelTLD="name,ai,au,bd,bh,ck,eg,et,fk,il,in,kh,kr,mk,mt,na,np,nz,pg,pk,qa,sa,sb,sg,sv,ua,ug,uk,uy,vn,za,zw";
228 + QStringList countries = QStringList::split(',', twoLevelTLD);
229 + for(QStringList::ConstIterator it = countries.begin();
230 + it != countries.end(); ++it)
232 + m_twoLevelTLD.replace(*it, (int *) 1);
237 @@ -221,89 +264,184 @@
238 // Not much to do here
241 +static void removeDuplicateFromList(KHttpCookieList *list, KHttpCookie *cookiePtr, bool nameMatchOnly=false, bool updateWindowId=false)
243 + QString domain1 = cookiePtr->domain();
244 + if (domain1.isEmpty())
245 + domain1 = cookiePtr->host();
247 + for ( KHttpCookiePtr cookie=list->first(); cookie != 0; )
249 + QString domain2 = cookie->domain();
250 + if (domain2.isEmpty())
251 + domain2 = cookie->host();
254 + (cookiePtr->name() == cookie->name()) &&
257 + ( (domain1 == domain2) && (cookiePtr->path() == cookie->path()) )
261 + if (updateWindowId)
263 + for(QValueList<long>::ConstIterator it = cookie->windowIds().begin();
264 + it != cookie->windowIds().end(); ++it)
266 + long windowId = *it;
267 + if (windowId && (cookiePtr->windowIds().find(windowId) == cookiePtr->windowIds().end()))
269 + cookiePtr->windowIds().append(windowId);
273 + KHttpCookiePtr old_cookie = cookie;
274 + cookie = list->next();
275 + list->removeRef( old_cookie );
280 + cookie = list->next();
287 // Looks for cookies in the cookie jar which are appropriate for _url.
288 // Returned is a string containing all appropriate cookies in a format
289 // which can be added to a HTTP-header without any additional processing.
291 -QString KCookieJar::findCookies(const QString &_url, bool useDOMFormat)
292 +QString KCookieJar::findCookies(const QString &_url, bool useDOMFormat, long windowId, KHttpCookieList *pendingCookies)
298 KHttpCookiePtr cookie;
299 - int protVersion = 1;
300 - int cookieCount = 0;
301 + KCookieAdvice advice = m_globalAdvice;
303 if (!parseURL(_url, fqdn, path))
308 + bool secureRequest = (_url.find( L1("https://"), 0, false) == 0 ||
309 + _url.find( L1("webdavs://"), 0, false) == 0);
311 extractDomains(fqdn, domains);
312 - bool secureRequest = (_url.find( "https://", 0, false) == 0);
314 + KHttpCookieList allCookies;
316 for(QStringList::ConstIterator it = domains.begin();
317 - it != domains.end();
321 - KHttpCookieList *cookieList = cookieDomains[(*it)];
322 + KHttpCookieList *cookieList;
323 + if (it == domains.end())
325 + cookieList = pendingCookies; // Add pending cookies
326 + pendingCookies = 0;
332 + QString key = (*it).isNull() ? L1("") : (*it);
333 + cookieList = m_cookieDomains[key];
335 + continue; // No cookies for this domain
339 - continue; // No cookies for this domain
340 + if (cookieList->getAdvice() != KCookieDunno)
341 + advice = cookieList->getAdvice();
343 + // Do not send cookies for this domain if policy is set to reject
344 + // and we are not setup to automatically accept all cookies as
345 + // session cookies...
346 + if (advice == KCookieReject &&
347 + !(m_ignoreCookieExpirationDate && m_autoAcceptSessionCookies))
349 + if (it == domains.end())
350 + break; // Finished.
354 for ( cookie=cookieList->first(); cookie != 0; cookie=cookieList->next() )
356 - if (!cookie->match(fqdn, domains, path) && cookie->domain().isEmpty())
358 - // The following code is added because RFC 2109 is completely
359 - // ambigious when it comes what needs to be done when cookies
360 - // with empty "domain=" fields are present! The following code
361 - // makes such cookies available to all the domains/hosts under
362 - // the TLD of the cookie in question!
363 - QStringList cookieDomainList;
364 - extractDomains( cookie->host(), cookieDomainList );
366 - int fqdnCount = domains.count();
367 - int cookieDomainCount = cookieDomainList.count();
369 - if ( domains[fqdnCount-2] != cookieDomainList[cookieDomainCount-2] &&
370 - domains[fqdnCount-1] != cookieDomainList[cookieDomainCount-1] )
373 + if (!cookie->match(fqdn, domains, path))
376 if( cookie->isSecure() && !secureRequest )
379 - // Use first cookie to determine protocol version
380 - if (cookieCount == 0)
381 + if( cookie->isHttpOnly() && useDOMFormat )
384 + // Do not send expired cookies.
385 + if ( cookie->isExpired (time(0)) )
387 - protVersion = cookie->protocolVersion();
388 + // Note there is no need to actually delete the cookie here
389 + // since the cookieserver will invoke ::saveCookieJar because
390 + // of the state change below. This will then do the job of
391 + // deleting the cookie for us.
392 + m_cookiesChanged = true;
397 + if (windowId && (cookie->windowIds().find(windowId) == cookie->windowIds().end()))
399 - if (cookieCount > 0)
401 - cookieStr += cookie->cookieStr(true);
402 + cookie->windowIds().append(windowId);
404 - else if (protVersion == 0)
406 + if (it == domains.end()) // Only needed when processing pending cookies
407 + removeDuplicateFromList(&allCookies, cookie);
409 + allCookies.append(cookie);
411 + if (it == domains.end())
412 + break; // Finished.
416 + int cookieCount = 0;
419 + for ( cookie=allCookies.first(); cookie != 0; cookie=allCookies.next() )
421 + if (cookie->protocolVersion() > protVersion)
422 + protVersion = cookie->protocolVersion();
425 + for ( cookie=allCookies.first(); cookie != 0; cookie=allCookies.next() )
429 + if (cookieCount > 0)
430 + cookieStr += L1("; ");
431 + cookieStr += cookie->cookieStr(true);
435 + if (cookieCount == 0)
437 - if (cookieCount == 0)
438 - cookieStr += "Cookie: ";
441 - cookieStr += cookie->cookieStr(false);
442 + cookieStr += L1("Cookie: ");
443 + if (protVersion > 0)
446 + version.sprintf("$Version=%d; ", protVersion); // Without quotes
447 + cookieStr += version;
452 - if (cookieCount > 0)
453 - cookieStr += "\r\n";
454 - cookieStr += "Cookie: ";
455 - cookieStr += cookie->cookieStr(false);
456 + cookieStr += L1("; ");
459 + cookieStr += cookie->cookieStr(false);
467 @@ -323,17 +461,17 @@
468 bool keepQuotes=false)
470 const char *s = header;
472 // Parse 'my_name' part
473 for(; (*s != '='); s++)
475 if ((*s=='\0') || (*s==';') || (*s=='\n'))
480 - Name.truncate( s - header );
481 - Name = Name.stripWhiteSpace();
482 + // No '=' sign -> use string as the value, name is empty
483 + // (behavior found in Mozilla and IE)
485 + Value = QString::fromLatin1(header);
486 + Value.truncate( s - header );
487 + Value = Value.stripWhiteSpace();
491 @@ -366,12 +504,12 @@
492 if ((*s=='\0') || (*s=='\n'))
496 + Value = QString::fromLatin1(header);
497 Value.truncate(s - header);
502 + Value = QString::fromLatin1(header);
503 Value.truncate( s - header );
507 while ((*s != '\0') && (*s != ';') && (*s != '\n'))
511 + Value = QString::fromLatin1(header);
512 Value.truncate( s - header );
513 Value = Value.stripWhiteSpace();
515 @@ -398,14 +536,14 @@
519 -static void stripDomain(const QString &_fqdn, QString &_domain)
520 +void KCookieJar::stripDomain(const QString &_fqdn, QString &_domain)
523 - KCookieJar::extractDomains(_fqdn, domains);
524 + extractDomains(_fqdn, domains);
525 _domain = domains[0];
528 -static QString stripDomain( KHttpCookiePtr cookiePtr)
529 +QString KCookieJar::stripDomain( KHttpCookiePtr cookiePtr)
531 QString domain; // We file the cookie under this domain.
532 if (cookiePtr->domain().isEmpty())
533 @@ -420,10 +558,18 @@
537 - if (kurl.isMalformed())
538 + if (!kurl.isValid())
541 _fqdn = kurl.host().lower();
544 + if (((kurl.protocol() == L1("http")) && (kurl.port() != 80)) ||
545 + ((kurl.protocol() == L1("https")) && (kurl.port() != 443)))
547 + _fqdn = L1("%1:%2").arg(kurl.port()).arg(_fqdn);
551 // Cookie spoofing protection. Since there is no way a path separator
552 // or escape encoded character is allowed in the hostname according
553 @@ -435,19 +581,44 @@
560 + QRegExp exp(L1("[\\\\/]\\.\\.[\\\\/]"));
561 + // Weird path, cookie stealing attempt?
562 + if (_path.find(exp) != -1) {
563 + return false; // Deny everything!!
569 void KCookieJar::extractDomains(const QString &_fqdn,
570 QStringList &_domains)
572 - // Use fqdn only if the fqdn consists of numbers.
573 - if ((_fqdn[0] >= '0') && (_fqdn[0] <= '9'))
574 + // Return numeric IPv6 addresses as is...
575 + if (_fqdn[0] == '[')
577 _domains.append( _fqdn );
580 + // Return numeric IPv4 addresses as is...
581 + if ((_fqdn[0] >= '0') && (_fqdn[0] <= '9'))
583 + bool allNumeric = true;
584 + for(int i = _fqdn.length(); i--;)
586 + if (!strchr("0123456789:.", _fqdn[i].latin1()))
588 + allNumeric = false;
594 + _domains.append( _fqdn );
599 QStringList partList = QStringList::split('.', _fqdn, false);
601 @@ -458,29 +629,36 @@
603 if (partList.count() == 1)
604 break; // We only have a TLD left.
605 - if (partList.count() == 2)
607 + if ((partList.count() == 2) && (m_twoLevelTLD[partList[1].lower()]))
609 + // This domain uses two-level TLDs in the form xxxx.yy
613 + if ((partList.count() == 2) && (partList[1].length() == 2))
615 // If this is a TLD, we should stop. (e.g. co.uk)
616 // We assume this is a TLD if it ends with .xx.yy or .x.yy
617 - if ((partList[0].length() <= 2) &&
618 - (partList[1].length() == 2))
619 + if (partList[0].length() <= 2)
620 break; // This is a TLD.
622 + // Catch some TLDs that we miss with the previous check
623 + // e.g. com.au, org.uk, mil.co
624 + QCString t = partList[0].lower().utf8();
625 + if ((t == "com") || (t == "net") || (t == "org") || (t == "gov") || (t == "edu") || (t == "mil") || (t == "int"))
628 - QString domain = partList.join(".");
629 - _domains.append("." + domain);
631 + QString domain = partList.join(L1("."));
632 + _domains.append('.' + domain);
633 _domains.append(domain);
634 partList.remove(partList.begin()); // Remove part
637 - // Only URLs that would get in here are of type
638 - // "host.foo" or "host.co.fo" so simply append
639 - // a '.' on top to make sure they are stored under
640 - // the proper cookie domain.
641 - if (_domains.isEmpty())
642 - _domains.append( "." + _fqdn );
644 // Always add the FQDN at the end of the list for
645 // hostname == cookie-domainname checks!
646 + _domains.append( '.' + _fqdn );
647 _domains.append( _fqdn );
650 @@ -492,55 +670,73 @@
651 // cookie_headers should be a concatenation of all lines of a HTTP-header
652 // which start with "Set-Cookie". The lines should be separated by '\n's.
654 -KHttpCookiePtr KCookieJar::makeCookies(const QString &_url,
655 +KHttpCookieList KCookieJar::makeCookies(const QString &_url,
656 const QCString &cookie_headers,
659 - KHttpCookiePtr cookieChain = 0;
660 + KHttpCookieList cookieList;
661 + KHttpCookieList cookieList2;
662 KHttpCookiePtr lastCookie = 0;
663 const char *cookieStr = cookie_headers.data();
668 + bool crossDomain = false;
670 if (!parseURL(_url, fqdn, path))
672 // Error parsing _url
674 + return KHttpCookieList();
676 + QString defaultPath;
677 + int i = path.findRev('/');
679 + defaultPath = path.left(i);
684 // check for "Set-Cookie"
685 - if (strncasecmp(cookieStr, "Set-Cookie:", 11) == 0)
686 + if (strncmp(cookieStr, "Cross-Domain\n", 13) == 0)
689 + crossDomain = true;
691 + else if (strncasecmp(cookieStr, "Set-Cookie:", 11) == 0)
693 cookieStr = parseNameValue(cookieStr+11, Name, Value, true);
695 - if (Name.isEmpty())
699 // Default domain = ""
700 - // Default path = ""
701 - KHttpCookie *cookie = new KHttpCookie(fqdn, "", "", Name, Value);
702 - cookie->mWindowId = windowId;
703 + // Default path according to rfc2109
705 + KHttpCookie *cookie = new KHttpCookie(fqdn, L1(""), defaultPath, Name, Value);
707 + cookie->mWindowIds.append(windowId);
708 + cookie->mCrossDomain = crossDomain;
710 // Insert cookie in chain
712 - lastCookie->nextCookie = cookie;
714 - cookieChain = cookie;
715 + cookieList.append(cookie);
718 - else if (lastCookie && (strncasecmp(cookieStr, "Set-Cookie2:", 12) == 0))
719 + else if (strncasecmp(cookieStr, "Set-Cookie2:", 12) == 0)
721 - // What the fuck is this?
722 - // Does anyone invent his own headers these days?
723 - // Read the fucking RFC guys! This header is not there!
725 - // Continue with lastCookie
726 + // Attempt to follow rfc2965
727 + cookieStr = parseNameValue(cookieStr+12, Name, Value, true);
730 + // Default domain = ""
731 + // Default path according to rfc2965
733 + KHttpCookie *cookie = new KHttpCookie(fqdn, L1(""), defaultPath, Name, Value);
735 + cookie->mWindowIds.append(windowId);
736 + cookie->mCrossDomain = crossDomain;
738 + // Insert cookie in chain
739 + cookieList2.append(cookie);
740 + lastCookie = cookie;
744 @@ -564,13 +760,12 @@
745 // Name-Value pair follows
746 cookieStr = parseNameValue(cookieStr, Name, Value);
748 - Name = Name.lower();
750 - if (Name == "domain")
751 + QCString cName = Name.lower().latin1();
752 + if (cName == "domain")
754 lastCookie->mDomain = Value.lower();
756 - else if (Name == "max-age")
757 + else if (cName == "max-age")
759 int max_age = Value.toInt();
761 @@ -578,23 +773,33 @@
763 lastCookie->mExpireDate = time(0)+max_age;
765 - else if (Name == "expires")
766 + else if (cName == "expires")
768 // Parse brain-dead netscape cookie-format
769 lastCookie->mExpireDate = KRFCDate::parseDate(Value);
771 - else if (Name == "path")
772 + else if (cName == "path")
774 - lastCookie->mPath = Value;
775 + if (Value.isEmpty())
776 + lastCookie->mPath = QString::null; // Catch "" <> QString::null
778 + lastCookie->mPath = KURL::decode_string(Value);
779 + lastCookie->mExplicitPath = true;
781 - else if (Name == "version")
782 + else if (cName == "version")
784 lastCookie->mProtocolVersion = Value.toInt();
786 - else if (Name == "secure")
787 + else if ((cName == "secure") ||
788 + (cName.isEmpty() && Value.lower() == L1("secure")))
790 lastCookie->mSecure = true;
792 + else if ((cName == "httponly") ||
793 + (cName.isEmpty() && Value.lower() == L1("httponly")))
795 + lastCookie->mHttpOnly = true;
799 if (*cookieStr == '\0')
804 - return cookieChain;
805 + // RFC2965 cookies come last so that they override netscape cookies.
806 + while( !cookieList2.isEmpty() && (lastCookie = cookieList2.take(0)) )
808 + removeDuplicateFromList(&cookieList, lastCookie, true);
809 + cookieList.append(lastCookie);
816 @@ -613,12 +825,12 @@
817 * pairs. Any whitespace before "name" or around '=' is discarded.
818 * If no cookies are found, 0 is returned.
820 -KHttpCookiePtr KCookieJar::makeDOMCookies(const QString &_url,
821 +KHttpCookieList KCookieJar::makeDOMCookies(const QString &_url,
822 const QCString &cookie_domstring,
825 // A lot copied from above
826 - KHttpCookiePtr cookieChain = 0;
827 + KHttpCookieList cookieList;
828 KHttpCookiePtr lastCookie = 0;
830 const char *cookieStr = cookie_domstring.data();
832 if (!parseURL(_url, fqdn, path))
834 // Error parsing _url
836 + return KHttpCookieList();
839 // This time it's easy
840 @@ -638,35 +850,25 @@
842 cookieStr = parseNameValue(cookieStr, Name, Value);
844 - if (Name.isEmpty()) {
845 - if (*cookieStr != '\0')
846 - cookieStr++; // Skip ';' or '\n'
852 // Default domain = ""
854 KHttpCookie *cookie = new KHttpCookie(fqdn, QString::null, QString::null,
856 - cookie->mWindowId = windowId;
858 - // Insert cookie in chain
860 - lastCookie->nextCookie = cookie;
862 - cookieChain = cookie;
864 + cookie->mWindowIds.append(windowId);
866 + cookieList.append(cookie);
869 if (*cookieStr != '\0')
870 cookieStr++; // Skip ';' or '\n'
873 - return cookieChain;
879 // This function hands a KHttpCookie object over to the cookie jar.
883 void KCookieJar::addCookie(KHttpCookiePtr &cookiePtr)
887 KHttpCookieList *cookieList = 0L;
889 @@ -686,42 +887,31 @@
890 (it != domains.end() && !cookieList);
893 - KHttpCookieList *list= cookieDomains[(*it)];
894 + QString key = (*it).isNull() ? L1("") : (*it);
895 + KHttpCookieList *list= m_cookieDomains[key];
896 if ( !list ) continue;
898 - for ( KHttpCookiePtr cookie=list->first(); cookie != 0; )
900 - if ( cookiePtr->name() == cookie->name() &&
901 - cookie->match(cookiePtr->host(),domains,cookiePtr->path()) )
903 - KHttpCookiePtr old_cookie = cookie;
904 - cookie = list->next();
905 - list->removeRef( old_cookie );
910 - cookie = list->next();
913 + removeDuplicateFromList(list, cookiePtr, false, true);
916 - domain = stripDomain( cookiePtr );
917 - cookieList = cookieDomains[ domain ];
918 + QString domain = stripDomain( cookiePtr );
919 + QString key = domain.isNull() ? L1("") : domain;
920 + cookieList = m_cookieDomains[ key ];
923 // Make a new cookie list
924 cookieList = new KHttpCookieList();
925 + cookieList->setAutoDelete(true);
927 // All cookies whose domain is not already
928 // known to us should be added with KCookieDunno.
929 // KCookieDunno means that we use the global policy.
930 cookieList->setAdvice( KCookieDunno );
932 - cookieDomains.insert( domain, cookieList);
933 + m_cookieDomains.insert( domain, cookieList);
935 // Update the list of domains
936 - domainList.append(domain);
937 + m_domainList.append(domain);
940 // Add the cookie to the cookie list
942 if (!cookiePtr->isExpired(time(0)))
944 cookieList->inSort( cookiePtr );
945 - cookiesChanged = true;
946 + m_cookiesChanged = true;
950 @@ -745,12 +935,20 @@
951 KCookieAdvice KCookieJar::cookieAdvice(KHttpCookiePtr cookiePtr)
955 + if (m_rejectCrossDomainCookies && cookiePtr->isCrossDomain())
956 + return KCookieReject;
958 + if (m_autoAcceptSessionCookies && (cookiePtr->expireDate() == 0 ||
959 + m_ignoreCookieExpirationDate))
960 + return KCookieAccept;
962 extractDomains(cookiePtr->host(), domains);
963 - bool isEmptyDomain = cookiePtr->domain().isEmpty();
965 - if (!isEmptyDomain )
966 + // If the cookie specifies a domain, check whether it is valid and
967 + // correct otherwise.
968 + if (!cookiePtr->domain().isEmpty())
970 - // Cookie specifies a domain. Check whether it is valid.
973 // This checks whether the cookie is valid based on
974 @@ -764,42 +962,34 @@
977 // Maybe the domain doesn't start with a "."
978 - QString domain = "."+cookiePtr->domain();
979 + QString domain = '.' + cookiePtr->domain();
980 if (domains.contains(domain))
986 - qWarning("WARNING: Host %s tries to set cookie for domain %s",
987 - cookiePtr->host().latin1(), cookiePtr->domain().latin1());
988 cookiePtr->fixDomain(QString::null);
989 - isEmptyDomain = true;
993 - // For empty domain use the FQDN to find a
994 - // matching advice for the pending cookie.
996 - if ( isEmptyDomain )
997 - domain = domains[0];
999 - domain = cookiePtr->domain();
1000 + KCookieAdvice advice = KCookieDunno;
1002 - KHttpCookieList *cookieList = cookieDomains[domain];
1003 - KCookieAdvice advice;
1006 - advice = cookieList->getAdvice();
1007 - if (advice == KCookieDunno)
1009 - advice = globalAdvice;
1013 + QStringList::Iterator it = domains.fromLast(); // Start with FQDN which is last in the list.
1014 + while( (advice == KCookieDunno) && (it != domains.end()))
1016 - advice = globalAdvice;
1017 + QString domain = *it;
1018 + // Check if a policy for the FQDN/domain is set.
1019 + KHttpCookieList *cookieList = m_cookieDomains[domain];
1021 + advice = cookieList->getAdvice();
1022 + domains.remove(it);
1023 + it = domains.begin(); // Continue from begin of remaining list
1026 + if (advice == KCookieDunno)
1027 + advice = m_globalAdvice;
1034 KCookieAdvice KCookieJar::getDomainAdvice(const QString &_domain)
1036 - KHttpCookieList *cookieList = cookieDomains[_domain];
1037 + KHttpCookieList *cookieList = m_cookieDomains[_domain];
1038 KCookieAdvice advice;
1041 @@ -831,13 +1021,13 @@
1042 void KCookieJar::setDomainAdvice(const QString &_domain, KCookieAdvice _advice)
1044 QString domain(_domain);
1045 - KHttpCookieList *cookieList = cookieDomains[domain];
1046 + KHttpCookieList *cookieList = m_cookieDomains[domain];
1050 - if (cookieList->getAdvice() != _advice);
1051 + if (cookieList->getAdvice() != _advice)
1053 - configChanged = true;
1054 + m_configChanged = true;
1055 // domain is already known
1056 cookieList->setAdvice( _advice);
1058 @@ -846,8 +1036,8 @@
1059 (_advice == KCookieDunno))
1061 // This deletes cookieList!
1062 - cookieDomains.remove(domain);
1063 - domainList.remove(domain);
1064 + m_cookieDomains.remove(domain);
1065 + m_domainList.remove(domain);
1069 @@ -856,13 +1046,14 @@
1070 if (_advice != KCookieDunno)
1072 // We should create a domain entry
1073 - configChanged = true;
1074 + m_configChanged = true;
1075 // Make a new cookie list
1076 cookieList = new KHttpCookieList();
1077 + cookieList->setAutoDelete(true);
1078 cookieList->setAdvice( _advice);
1079 - cookieDomains.insert( domain, cookieList);
1080 + m_cookieDomains.insert( domain, cookieList);
1081 // Update the list of domains
1082 - domainList.append( domain);
1083 + m_domainList.append( domain);
1087 @@ -883,9 +1074,9 @@
1089 void KCookieJar::setGlobalAdvice(KCookieAdvice _advice)
1091 - if (globalAdvice != _advice)
1092 - configChanged = true;
1093 - globalAdvice = _advice;
1094 + if (m_globalAdvice != _advice)
1095 + m_configChanged = true;
1096 + m_globalAdvice = _advice;
1100 @@ -893,7 +1084,7 @@
1102 const QStringList& KCookieJar::getDomainList()
1104 - return domainList;
1105 + return m_domainList;
1109 @@ -909,7 +1100,7 @@
1113 - return cookieDomains[domain];
1114 + return m_cookieDomains[domain];
1118 @@ -919,86 +1110,97 @@
1119 void KCookieJar::eatCookie(KHttpCookiePtr cookiePtr)
1121 QString domain = stripDomain(cookiePtr); // We file the cookie under this domain.
1122 - KHttpCookieList *cookieList = cookieDomains[domain];
1123 + KHttpCookieList *cookieList = m_cookieDomains[domain];
1127 // This deletes cookiePtr!
1128 if (cookieList->removeRef( cookiePtr ))
1129 - cookiesChanged = true;
1130 + m_cookiesChanged = true;
1132 if ((cookieList->isEmpty()) &&
1133 (cookieList->getAdvice() == KCookieDunno))
1135 // This deletes cookieList!
1136 - cookieDomains.remove(domain);
1137 + m_cookieDomains.remove(domain);
1139 - domainList.remove(domain);
1140 + m_domainList.remove(domain);
1145 void KCookieJar::eatCookiesForDomain(const QString &domain)
1147 - KHttpCookieList *cookieList = cookieDomains[domain];
1148 + KHttpCookieList *cookieList = m_cookieDomains[domain];
1149 if (!cookieList || cookieList->isEmpty()) return;
1151 cookieList->clear();
1152 if (cookieList->getAdvice() == KCookieDunno)
1154 // This deletes cookieList!
1155 - cookieDomains.remove(domain);
1156 - domainList.remove(domain);
1157 + m_cookieDomains.remove(domain);
1158 + m_domainList.remove(domain);
1160 - cookiesChanged = true;
1161 + m_cookiesChanged = true;
1164 -void KCookieJar::eatSessionCookies( int winId )
1165 +void KCookieJar::eatSessionCookies( long windowId )
1167 - QStringList::Iterator it=domainList.begin();
1168 - for ( ; it != domainList.end(); ++it )
1169 - eatSessionCookies( *it, winId, false );
1173 + QStringList::Iterator it=m_domainList.begin();
1174 + for ( ; it != m_domainList.end(); ++it )
1175 + eatSessionCookies( *it, windowId, false );
1178 -void KCookieJar::eatSessionCookies( const QString& fqdn, int winId,
1179 +void KCookieJar::eatAllCookies()
1181 + for ( QStringList::Iterator it=m_domainList.begin();
1182 + it != m_domainList.end();)
1184 + QString domain = *it++;
1185 + // This might remove domain from domainList!
1186 + eatCookiesForDomain(domain);
1190 +void KCookieJar::eatSessionCookies( const QString& fqdn, long windowId,
1193 KHttpCookieList* cookieList;
1196 + cookieList = m_cookieDomains[fqdn];
1200 stripDomain( fqdn, domain );
1201 - cookieList = cookieDomains[domain];
1202 + cookieList = m_cookieDomains[domain];
1205 - cookieList = cookieDomains[fqdn];
1209 KHttpCookiePtr cookie=cookieList->first();
1210 for (; cookie != 0;)
1212 - if (cookie->windowId() == winId &&
1213 - (cookie->expireDate() == 0))
1214 + if ((cookie->expireDate() != 0) && !m_ignoreCookieExpirationDate)
1216 - KHttpCookiePtr old_cookie = cookie;
1217 - cookie = cookieList->next();
1218 - cookieList->removeRef( old_cookie );
1219 + cookie = cookieList->next();
1223 - cookie = cookieList->next();
1229 -void KCookieJar::eatAllCookies()
1231 - for ( QStringList::Iterator it=domainList.begin();
1232 - it != domainList.end();)
1234 - QString domain = *it++;
1235 - eatCookiesForDomain(domain); // This might remove domain from domainList!
1236 + QValueList<long> &ids = cookie->windowIds();
1237 + bool empty = (ids.find(windowId) == ids.end() );
1238 + ids.remove(windowId);
1239 + if (!empty || !ids.isEmpty())
1241 + cookie = cookieList->next();
1244 + KHttpCookiePtr old_cookie = cookie;
1245 + cookie = cookieList->next();
1246 + cookieList->removeRef( old_cookie );
1251 @@ -1008,7 +1210,7 @@
1252 // On failure 'false' is returned.
1253 bool KCookieJar::saveCookies(const QString &_filename)
1255 - KSaveFile saveFile(_filename);
1256 + KSaveFile saveFile(_filename, 0600);
1258 if (saveFile.status() != 0)
1260 @@ -1017,31 +1219,31 @@
1262 time_t curTime = time(0);
1264 - fprintf(fStream, "# KDE Cookie File\n#\n");
1265 + fprintf(fStream, "# KDE Cookie File v2\n#\n");
1267 - fprintf(fStream, "%-20s %-20s %-12s %-9s %-4s %-10s %s %-4s\n",
1268 - "# Host", "Domain", "Path", "Exp.date", "Prot", "Name", "Value", "Secure");
1269 + fprintf(fStream, "%-20s %-20s %-12s %-10s %-4s %-20s %-4s %s\n",
1270 + "# Host", "Domain", "Path", "Exp.date", "Prot",
1271 + "Name", "Sec", "Value");
1273 - for ( QStringList::Iterator it=domainList.begin();
1274 - it != domainList.end();
1276 + for ( QStringList::Iterator it=m_domainList.begin(); it != m_domainList.end();
1279 const QString &domain = *it;
1280 bool domainPrinted = false;
1282 - KHttpCookieList *cookieList = cookieDomains[domain];
1283 + KHttpCookieList *cookieList = m_cookieDomains[domain];
1284 KHttpCookiePtr cookie=cookieList->first();
1286 - for (; cookie != 0;)
1287 + for (; cookie != 0;)
1289 if (cookie->isExpired(curTime))
1291 - // Delete expired cookies
1293 + // Delete expired cookies
1294 KHttpCookiePtr old_cookie = cookie;
1295 cookie = cookieList->next();
1296 cookieList->removeRef( old_cookie );
1298 - else if (cookie->expireDate() != 0)
1300 + else if (cookie->expireDate() != 0 && !m_ignoreCookieExpirationDate)
1304 @@ -1049,25 +1251,26 @@
1305 fprintf(fStream, "[%s]\n", domain.local8Bit().data());
1307 // Store persistent cookies
1308 - QString path("\"");
1309 + QString path = L1("\"");
1310 path += cookie->path();
1312 - QString domain("\"");
1314 + QString domain = L1("\"");
1315 domain += cookie->domain();
1317 - fprintf(fStream, "%-20s %-20s %-12s %9lu %2d %-10s %s %-4i\n",
1318 - cookie->host().local8Bit().data(), domain.local8Bit().data(), path.local8Bit().data(),
1319 - (unsigned long) cookie->expireDate(), cookie->protocolVersion()+100,
1320 - cookie->name().local8Bit().data(), cookie->value().local8Bit().data(),
1321 - cookie->isSecure());
1322 - cookie = cookieList->next();
1326 - // Skip session-only cookies
1327 - cookie = cookieList->next();
1331 + fprintf(fStream, "%-20s %-20s %-12s %10lu %3d %-20s %-4i %s\n",
1332 + cookie->host().latin1(), domain.latin1(),
1333 + path.latin1(), (unsigned long) cookie->expireDate(),
1334 + cookie->protocolVersion(), cookie->name().latin1(),
1335 + (cookie->isSecure() ? 1 : 0) + (cookie->isHttpOnly() ? 2 : 0) + (cookie->hasExplicitPath() ? 4 : 0),
1336 + cookie->value().latin1());
1337 + cookie = cookieList->next();
1341 + // Skip session-only cookies
1342 + cookie = cookieList->next();
1347 return saveFile.close();
1348 @@ -1080,26 +1283,27 @@
1350 if (!keepQuotes && (*buffer == '\"'))
1352 - // Find terminating "
1353 + // Find terminating "
1356 while((*buffer != '\"') && (*buffer))
1362 // Find first white space
1364 while((*buffer != ' ') && (*buffer != '\t') && (*buffer != '\n') && (*buffer))
1375 while((*buffer == ' ') || (*buffer == '\t') || (*buffer == '\n'))
1381 @@ -1124,7 +1328,18 @@
1383 err = (fgets(buffer, READ_BUFFER_SIZE, fStream) == 0);
1385 - err = err || (strcmp(buffer, "# KDE Cookie File\n") != 0);
1389 + if (strcmp(buffer, "# KDE Cookie File\n") == 0)
1393 + else if (sscanf(buffer, "# KDE Cookie File v%d\n", &version) != 1)
1401 @@ -1146,13 +1361,31 @@
1402 int protVer = (time_t) strtoul(verStr, 0, 10);
1403 const char *name( parseField(line) );
1404 bool keepQuotes = false;
1405 - if (protVer >= 100)
1406 + bool secure = false;
1407 + bool httpOnly = false;
1408 + bool explicitPath = false;
1409 + const char *value = 0;
1410 + if ((version == 2) || (protVer >= 200))
1413 - keepQuotes = true;
1414 + if (protVer >= 200)
1416 + int i = atoi( parseField(line) );
1419 + explicitPath = i & 4;
1420 + line[strlen(line)-1] = '\0'; // Strip LF.
1425 + if (protVer >= 100)
1428 + keepQuotes = true;
1430 + value = parseField(line, keepQuotes);
1431 + secure = atoi( parseField(line) );
1433 - const char *value( parseField(line, keepQuotes) );
1434 - bool secure = atoi( parseField(line) );
1437 if (!value) continue;
1438 @@ -1161,15 +1394,18 @@
1439 if ((expDate == 0) || (expDate < curTime))
1442 - KHttpCookie *cookie = new KHttpCookie(host, domain, path, name,
1443 - value, expDate, protVer,
1445 - if ( cookieAdvice( cookie ) )
1446 - addCookie(cookie);
1447 + KHttpCookie *cookie = new KHttpCookie(QString::fromLatin1(host),
1448 + QString::fromLatin1(domain),
1449 + QString::fromLatin1(path),
1450 + QString::fromLatin1(name),
1451 + QString::fromLatin1(value),
1453 + secure, httpOnly, explicitPath);
1454 + addCookie(cookie);
1458 - cookiesChanged = false;
1459 + m_cookiesChanged = false;
1463 @@ -1181,19 +1417,18 @@
1465 void KCookieJar::saveConfig(KConfig *_config)
1467 - if (!configChanged)
1468 + if (!m_configChanged)
1471 - _config->setGroup(QString::null);
1472 - _config->writeEntry("DefaultRadioButton", defaultRadioButton);
1473 - _config->writeEntry("ShowCookieDetails", showCookieDetails );
1475 - QStringList domainSettings;
1476 + _config->setGroup("Cookie Dialog");
1477 + _config->writeEntry("PreferredPolicy", m_preferredPolicy);
1478 + _config->writeEntry("ShowCookieDetails", m_showCookieDetails );
1479 _config->setGroup("Cookie Policy");
1480 - _config->writeEntry("CookieGlobalAdvice", adviceToStr( globalAdvice));
1481 + _config->writeEntry("CookieGlobalAdvice", adviceToStr( m_globalAdvice));
1483 - for ( QStringList::Iterator it=domainList.begin();
1484 - it != domainList.end();
1485 + QStringList domainSettings;
1486 + for ( QStringList::Iterator it=m_domainList.begin();
1487 + it != m_domainList.end();
1490 const QString &domain = *it;
1491 @@ -1208,6 +1443,7 @@
1493 _config->writeEntry("CookieDomainAdvice", domainSettings);
1495 + m_configChanged = false;
1499 @@ -1217,23 +1453,23 @@
1501 void KCookieJar::loadConfig(KConfig *_config, bool reparse )
1504 - QStringList domainSettings;
1507 _config->reparseConfiguration();
1509 - _config->setGroup(QString::null);
1510 - defaultRadioButton = _config->readNumEntry( "DefaultRadioButton", 0 );
1511 - showCookieDetails = _config->readBoolEntry( "ShowCookieDetails" );
1512 + _config->setGroup("Cookie Dialog");
1513 + m_showCookieDetails = _config->readBoolEntry( "ShowCookieDetails" );
1514 + m_preferredPolicy = _config->readNumEntry( "PreferredPolicy", 0 );
1516 _config->setGroup("Cookie Policy");
1517 - value = _config->readEntry("CookieGlobalAdvice", "Ask");
1518 - globalAdvice = strToAdvice(value);
1519 - domainSettings = _config->readListEntry("CookieDomainAdvice");
1520 + QStringList domainSettings = _config->readListEntry("CookieDomainAdvice");
1521 + m_rejectCrossDomainCookies = _config->readBoolEntry( "RejectCrossDomainCookies", true );
1522 + m_autoAcceptSessionCookies = _config->readBoolEntry( "AcceptSessionCookies", true );
1523 + m_ignoreCookieExpirationDate = _config->readBoolEntry( "IgnoreExpirationDate", false );
1524 + QString value = _config->readEntry("CookieGlobalAdvice", L1("Ask"));
1525 + m_globalAdvice = strToAdvice(value);
1527 // Reset current domain settings first.
1528 - for ( QStringList::Iterator it=domainList.begin(); it != domainList.end(); )
1529 + for ( QStringList::Iterator it=m_domainList.begin(); it != m_domainList.end(); )
1531 // Make sure to update iterator before calling setDomainAdvice()
1532 // setDomainAdvice() might delete the domain from domainList.
1533 @@ -1241,16 +1477,19 @@
1534 setDomainAdvice(domain, KCookieDunno);
1538 + // Now apply the domain settings read from config file...
1539 for ( QStringList::Iterator it=domainSettings.begin();
1540 it != domainSettings.end(); )
1542 const QString &value = *it++;
1544 int sepPos = value.find(':');
1545 - if (sepPos <= 0) { continue; }
1550 QString domain(value.left(sepPos));
1551 KCookieAdvice advice = strToAdvice( value.mid(sepPos + 1) );
1552 setDomainAdvice(domain, advice);
1556 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiejar.h~kcookiejar-merge.patch
1557 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiejar.h
1559 //----------------------------------------------------------------------------
1561 // KDE File Manager -- HTTP Cookies
1562 -// $Id: kcookiejar.h,v 1.21.2.1 2001/09/08 22:03:49 adawit Exp $
1563 +// $Id: kcookiejar.h,v 1.34 2004/07/20 15:29:24 waba Exp $
1565 #ifndef KCOOKIEJAR_H
1566 #define KCOOKIEJAR_H
1570 int mProtocolVersion;
1573 + bool mCrossDomain;
1575 + bool mExplicitPath;
1576 + QValueList<long> mWindowIds;
1578 - KHttpCookiePtr nextCookie;
1579 QString cookieStr(bool useDOMFormat);
1583 const QString &_value=QString::null,
1584 time_t _expireDate=0,
1585 int _protocolVersion=0,
1586 - bool _secure = false);
1587 + bool _secure = false,
1588 + bool _httpOnly = false,
1589 + bool _explicitPath = false);
1591 QString domain(void) { return mDomain; }
1592 QString host(void) { return mHost; }
1593 QString path(void) { return mPath; }
1594 QString name(void) { return mName; }
1595 QString value(void) { return mValue; }
1596 - long windowId(void) { return mWindowId; }
1597 + QValueList<long> &windowIds(void) { return mWindowIds; }
1598 void fixDomain(const QString &domain) { mDomain = domain; }
1599 time_t expireDate(void) { return mExpireDate; }
1600 int protocolVersion(void) { return mProtocolVersion; }
1601 bool isSecure(void) { return mSecure; }
1602 bool isExpired(time_t currentDate);
1603 + bool isCrossDomain(void) { return mCrossDomain; }
1604 + bool isHttpOnly(void) { return mHttpOnly; }
1605 + bool hasExplicitPath(void) { return mExplicitPath; }
1606 bool match(const QString &fqdn, const QStringList &domainList, const QString &path);
1607 - KHttpCookiePtr next() { return nextCookie; }
1610 class KHttpCookieList : public QList<KHttpCookie>
1613 KHttpCookieList() : QList<KHttpCookie>(), advice( KCookieDunno )
1614 - { setAutoDelete(true); }
1616 virtual ~KHttpCookieList() { }
1618 virtual int compareItems( void * item1, void * item2);
1621 * Returns whether the cookiejar has been changed
1623 - bool changed() { return cookiesChanged || configChanged; }
1624 + bool changed() const { return m_cookiesChanged || m_configChanged; }
1627 * Store all the cookies in a safe(?) place
1628 @@ -154,8 +160,11 @@
1630 * If @p useDOMFormat is true, the string is formatted in a format
1631 * in compliance with the DOM standard.
1632 + * @p pendingCookies contains a list of cookies that have not been
1633 + * approved yet by the user but that will be included in the result
1636 - QString findCookies(const QString &_url, bool useDOMFormat);
1637 + QString findCookies(const QString &_url, bool useDOMFormat, long windowId, KHttpCookieList *pendingCookies=0);
1640 * This function parses cookie_headers and returns a linked list of
1641 @@ -165,17 +174,17 @@
1642 * cookie_headers should be a concatenation of all lines of a HTTP-header
1643 * which start with "Set-Cookie". The lines should be separated by '\n's.
1645 - KHttpCookiePtr makeCookies(const QString &_url, const QCString &cookie_headers, long windowId);
1646 + KHttpCookieList makeCookies(const QString &_url, const QCString &cookie_headers, long windowId);
1649 * This function parses cookie_headers and returns a linked list of
1650 * valid KHttpCookie objects for all cookies found in cookie_headers.
1651 * If no cookies could be found 0 is returned.
1653 - * cookie_domstr should be a concatenation of "name=value" pairs, seperated
1654 + * cookie_domstr should be a concatenation of "name=value" pairs, separated
1655 * by a semicolon ';'.
1657 - KHttpCookiePtr makeDOMCookies(const QString &_url, const QCString &cookie_domstr, long windowId);
1658 + KHttpCookieList makeDOMCookies(const QString &_url, const QCString &cookie_domstr, long windowId);
1661 * This function hands a KHttpCookie object over to the cookie jar.
1662 @@ -279,13 +288,13 @@
1663 * Removes all end of session cookies set by the
1664 * session @p windId.
1666 - void eatSessionCookies( int windId );
1667 + void eatSessionCookies( long windowId );
1670 * Removes all end of session cookies set by the
1671 * session @p windId.
1673 - void eatSessionCookies( const QString& fqdn, int windId, bool isFQDN = true );
1674 + void eatSessionCookies( const QString& fqdn, long windowId, bool isFQDN = true );
1677 * Parses _url and returns the FQDN (_fqdn) and path (_path).
1678 @@ -297,21 +306,46 @@
1680 * Returns a list of domains (_domainList) relevant for this host.
1682 - static void extractDomains(const QString &_fqdn,
1683 - QStringList &_domainList);
1684 + void extractDomains(const QString &_fqdn,
1685 + QStringList &_domainList);
1687 static QString adviceToStr(KCookieAdvice _advice);
1688 static KCookieAdvice strToAdvice(const QString &_str);
1690 - // Save this in the config file...
1691 - int defaultRadioButton; // 0 = This cookie, 1 = domain, 2 = all cookies
1692 - bool showCookieDetails; // true, false
1693 + /** Returns the */
1694 + int preferredDefaultPolicy() const { return m_preferredPolicy; }
1696 + /** Returns the */
1697 + bool showCookieDetails () const { return m_showCookieDetails; }
1700 + * Sets the user's default preference cookie policy.
1702 + void setPreferredDefaultPolicy (int value) { m_preferredPolicy = value; }
1705 + * Sets the user's preference of level of detail displayed
1706 + * by the cookie dialog.
1708 + void setShowCookieDetails (bool value) { m_showCookieDetails = value; }
1711 - QDict<KHttpCookieList> cookieDomains;
1712 - QStringList domainList;
1713 - KCookieAdvice globalAdvice;
1714 - bool configChanged;
1715 - bool cookiesChanged;
1716 + void stripDomain(const QString &_fqdn, QString &_domain);
1717 + QString stripDomain( KHttpCookiePtr cookiePtr);
1720 + QStringList m_domainList;
1721 + KCookieAdvice m_globalAdvice;
1722 + QDict<KHttpCookieList> m_cookieDomains;
1723 + QDict<int> m_twoLevelTLD;
1725 + bool m_configChanged;
1726 + bool m_cookiesChanged;
1727 + bool m_showCookieDetails;
1728 + bool m_rejectCrossDomainCookies;
1729 + bool m_autoAcceptSessionCookies;
1730 + bool m_ignoreCookieExpirationDate;
1732 + int m_preferredPolicy;
1735 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver.cpp~kcookiejar-merge.patch
1736 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver.cpp
1738 //----------------------------------------------------------------------------
1740 // KDE Cookie Server
1741 -// $Id: kcookieserver.cpp,v 1.33.2.1 2001/09/08 22:03:49 adawit Exp $
1742 +// $Id: kcookieserver.cpp,v 1.52 2004/08/16 14:04:40 lunakl Exp $
1744 #define SAVE_DELAY 3 // Save after 3 minutes
1746 -#include "kcookieserver.h"
1747 -#include "kcookiejar.h"
1748 -#include "kcookiewin.h"
1749 +#include <unistd.h>
1751 -#include <kdebug.h>
1753 -#include <kcmdlineargs.h>
1754 -#include <kstddirs.h>
1756 -#include <unistd.h>
1760 #include <dcopclient.h>
1762 #include <kconfig.h>
1763 +#include <kdebug.h>
1764 +#include <kcmdlineargs.h>
1765 +#include <kstddirs.h>
1768 +#include <qpe/qpeapplication.h>
1771 +#include "kcookiejar.h"
1772 +#include "kcookiewin.h"
1773 +#include "kcookieserver.h"
1775 // Cookie field indexes
1776 enum CookieDetails { CF_DOMAIN=0, CF_PATH, CF_NAME, CF_HOST,
1778 DCOPClientTransaction *transaction;
1784 template class QList<CookieRequest>;
1787 mCookieJar = new KCookieJar;
1788 mPendingCookies = new KHttpCookieList;
1789 + mPendingCookies->setAutoDelete(true);
1790 mRequestList = new RequestList;
1791 mAdvicePending = false;
1793 - mCookieJar->loadConfig( kapp->config());
1794 + mCookieJar->loadConfig( kapp->config() );
1796 QString filename = locateLocal("appdata", "cookies");
1800 mCookieJar->loadCookies( filename);
1803 + QWidget *wid = qApp->desktop();
1804 + mBigScreen = (wid->width() > 320 || wid->height() > 320);
1807 KCookieServer::~KCookieServer()
1809 if (mCookieJar->changed())
1814 delete mPendingCookies;
1819 -bool KCookieServer::cookiesPending( const QString &url )
1820 +bool KCookieServer::cookiesPending( const QString &url, KHttpCookieList *cookieList )
1823 QStringList domains;
1824 @@ -136,109 +147,161 @@
1825 if (!KCookieJar::parseURL(url, fqdn, path))
1828 - KCookieJar::extractDomains( fqdn, domains );
1829 + mCookieJar->extractDomains( fqdn, domains );
1830 for( KHttpCookie *cookie = mPendingCookies->first();
1832 cookie = mPendingCookies->next())
1834 if (cookie->match( fqdn, domains, path))
1839 + cookieList->append(cookie);
1845 + return cookieList->isEmpty();
1848 void KCookieServer::addCookies( const QString &url, const QCString &cookieHeader,
1849 long windowId, bool useDOMFormat )
1851 - KHttpCookiePtr cookie = 0;
1852 + KHttpCookieList cookieList;
1854 - cookie = mCookieJar->makeDOMCookies(url, cookieHeader, windowId);
1855 + cookieList = mCookieJar->makeDOMCookies(url, cookieHeader, windowId);
1857 - cookie = mCookieJar->makeCookies(url, cookieHeader, windowId);
1858 + cookieList = mCookieJar->makeCookies(url, cookieHeader, windowId);
1860 - if (mAdvicePending)
1862 - checkCookies(cookie, true);
1865 + checkCookies(&cookieList);
1867 + for(KHttpCookiePtr cookie = cookieList.first(); cookie; cookie = cookieList.first())
1868 + mPendingCookies->append(cookieList.take());
1870 + if (!mAdvicePending)
1872 mAdvicePending = true;
1874 - checkCookies(cookie, false);
1875 - cookie = mPendingCookies->count() ? mPendingCookies->take(0) : 0;
1876 + while (!mPendingCookies->isEmpty())
1881 mAdvicePending = false;
1886 -void KCookieServer::checkCookies( KHttpCookie *cookie, bool queue )
1887 +void KCookieServer::checkCookies( KHttpCookieList *cookieList)
1890 - KCookieAdvice userAdvice = KCookieDunno;
1891 - if (cookie) host = cookie->host();
1892 + KHttpCookieList *list;
1895 + list = cookieList;
1897 + list = mPendingCookies;
1899 + KHttpCookiePtr cookie = list->first();
1902 - KHttpCookiePtr next_cookie = cookie->next();
1903 KCookieAdvice advice = mCookieJar->cookieAdvice(cookie);
1904 - if ((advice == KCookieAsk) || (advice == KCookieDunno))
1906 - // We only ask the user once, even if we get multiple
1907 - // cookies from the same site.
1908 - if (userAdvice == KCookieDunno)
1912 - mPendingCookies->append(cookie);
1917 - mPendingCookies->prepend(cookie);
1918 - KCookieWin *kw = new KCookieWin( 0L, cookie,
1919 - mCookieJar->defaultRadioButton,
1920 - mCookieJar->showCookieDetails );
1921 - userAdvice = kw->advice(mCookieJar, cookie);
1923 - mPendingCookies->take(0);
1924 - // Save the cookie config if it has changed
1925 - mCookieJar->saveConfig( kapp->config() );
1928 - advice = userAdvice;
1934 mCookieJar->addCookie(cookie);
1935 + cookie = list->current();
1942 + cookie = list->current();
1946 + cookie = list->next();
1949 - cookie = next_cookie;
1950 - if (!cookie && !queue)
1953 + if (cookieList || list->isEmpty())
1956 + KHttpCookiePtr currentCookie = mPendingCookies->first();
1958 + KHttpCookieList currentList;
1959 + currentList.append(currentCookie);
1960 + QString currentHost = currentCookie->host();
1962 + cookie = mPendingCookies->next();
1965 + if (cookie->host() == currentHost)
1967 - // Check if there are cookies on the pending list from the
1969 - for( cookie = mPendingCookies->first();
1971 - cookie = mPendingCookies->next())
1973 - if (cookie->host() == host)
1977 + currentList.append(cookie);
1979 + cookie = mPendingCookies->next();
1983 + KScrolledCookieWin *skw= 0L;
1986 + qWarning( "Using Scrolled Cookie WIn" );
1987 + skw = new KScrolledCookieWin(0L, currentList,
1988 + mCookieJar->preferredDefaultPolicy(),
1989 + mCookieJar->showCookieDetails() );
1990 + kw = skw->cookieWindow();
1992 + kw = new KCookieWin( 0L, currentList,
1993 + mCookieJar->preferredDefaultPolicy(),
1994 + mCookieJar->showCookieDetails() );
1997 + int result = QPEApplication::execDialog( !mBigScreen ?
1998 + static_cast<QDialog*>( skw ) :
1999 + static_cast<QDialog*>( kw ) );
2001 + int result = !mBigScreen ? skw->exec() : kw->exec();
2004 + KCookieAdvice userAdvice = kw->advice( result, mCookieJar, currentCookie);
2007 + // Save the cookie config if it has changed
2008 + mCookieJar->saveConfig( kapp->config() );
2010 + // Apply the user's choice to all cookies that are currently
2011 + // queued for this host.
2012 + cookie = mPendingCookies->first();
2015 + if (cookie->host() == currentHost)
2017 + switch(userAdvice)
2019 - // Found a matching cookie, remove it from the pending list.
2020 - cookie = mPendingCookies->take();
2021 + case KCookieAccept:
2022 + mPendingCookies->take();
2023 + mCookieJar->addCookie(cookie);
2024 + cookie = mPendingCookies->current();
2027 + case KCookieReject:
2028 + mPendingCookies->take();
2030 + cookie = mPendingCookies->current();
2034 + cookie = mPendingCookies->next();
2040 + cookie = mPendingCookies->next();
2045 // Check if we can handle any request
2046 for ( CookieRequest *request = mRequestList->first(); request;)
2048 @@ -246,13 +309,13 @@
2051 QByteArray replyData;
2052 - QString res = mCookieJar->findCookies( request->url, request->DOM );
2053 + QString res = mCookieJar->findCookies( request->url, request->DOM, request->windowId );
2055 QDataStream stream2(replyData, IO_WriteOnly);
2057 replyType = "QString";
2058 dcopClient()->endTransaction( request->transaction,
2059 - replyType, replyData);
2060 + replyType, replyData);
2061 CookieRequest *tmp = request;
2062 request = mRequestList->next();
2063 mRequestList->removeRef( tmp );
2068 - QString filename = locateLocal("appdata", "cookies");
2069 + QString filename = locateLocal("data", "kcookiejar/cookies");
2070 mCookieJar->saveCookies(filename);
2075 ((hasDomain && c->domain() == domain) ||
2076 fqdn == c->host()) &&
2077 - (c->path() == path) &&
2078 - (c->name() == name);
2079 + (c->path() == path) &&
2080 + (c->name() == name) &&
2081 + (!c->isExpired(time(0)));
2085 @@ -343,16 +407,30 @@
2087 KCookieServer::findCookies(QString url)
2089 + return findCookies(url, 0);
2094 +KCookieServer::findCookies(QString url, long windowId)
2096 if (cookiesPending(url))
2098 CookieRequest *request = new CookieRequest;
2099 request->transaction = dcopClient()->beginTransaction();
2101 request->DOM = false;
2102 + request->windowId = windowId;
2103 mRequestList->append( request );
2104 return QString::null; // Talk to you later :-)
2106 - return mCookieJar->findCookies(url, false);
2108 + QString cookies = mCookieJar->findCookies(url, false, windowId);
2110 + if (mCookieJar->changed() && !mTimer)
2117 @@ -409,16 +487,20 @@
2119 KCookieServer::findDOMCookies(QString url)
2121 - if (cookiesPending(url))
2123 - CookieRequest *request = new CookieRequest;
2124 - request->transaction = dcopClient()->beginTransaction();
2125 - request->url = url;
2126 - request->DOM = true;
2127 - mRequestList->append( request );
2128 - return QString::null; // Talk to you later :-)
2130 - return mCookieJar->findCookies(url, true);
2131 + return findDOMCookies(url, 0);
2136 +KCookieServer::findDOMCookies(QString url, long windowId)
2138 + // We don't wait for pending cookies because it locks up konqueror
2139 + // which can cause a deadlock if it happens to have a popup-menu up.
2140 + // Instead we just return pending cookies as if they had been accepted already.
2141 + KHttpCookieList pendingCookies;
2142 + cookiesPending(url, &pendingCookies);
2144 + return mCookieJar->findCookies(url, true, windowId, &pendingCookies);
2148 @@ -459,18 +541,27 @@
2155 -KCookieServer::deleteSessionCookies( long winId )
2156 +KCookieServer::slotDeleteSessionCookies( long windowId )
2158 - mCookieJar->eatSessionCookies( winId );
2159 + deleteSessionCookies(windowId);
2164 +KCookieServer::deleteSessionCookies( long windowId )
2166 + mCookieJar->eatSessionCookies( windowId );
2172 -KCookieServer::deleteSessionCookiesFor(QString fqdn, long winId)
2173 +KCookieServer::deleteSessionCookiesFor(QString fqdn, long windowId)
2175 - mCookieJar->eatSessionCookies( fqdn, winId );
2176 + mCookieJar->eatSessionCookies( fqdn, windowId );
2181 if (KCookieJar::parseURL(url, fqdn, dummy))
2183 QStringList domains;
2184 - KCookieJar::extractDomains(fqdn, domains);
2185 + mCookieJar->extractDomains(fqdn, domains);
2186 mCookieJar->setDomainAdvice(domains[0],
2187 KCookieJar::strToAdvice(advice));
2190 if (KCookieJar::parseURL(url, fqdn, dummy))
2192 QStringList domains;
2193 - KCookieJar::extractDomains(fqdn, domains);
2194 + mCookieJar->extractDomains(fqdn, domains);
2195 advice = mCookieJar->getDomainAdvice(domains[0]);
2197 return KCookieJar::adviceToStr(advice);
2200 KCookieServer::shutdown()
2206 #include "kcookieserver.moc"
2207 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver.h~kcookiejar-merge.patch
2208 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver.h
2210 //----------------------------------------------------------------------------
2212 // KDE Cookie Server
2213 -// $Id: kcookieserver.h,v 1.15.2.1 2001/09/08 22:03:49 adawit Exp $
2214 +// $Id: kcookieserver.h,v 1.24 2003/06/09 10:56:42 waba Exp $
2216 #ifndef KCOOKIESERVER_H
2217 #define KCOOKIESERVER_H
2224 class KCookieServer : public KUniqueApplication
2229 QString findCookies(QString);
2230 + QString findCookies(QString, long);
2231 QStringList findDomains();
2232 QStringList findCookies(QValueList<int>,QString,QString,QString,QString);
2233 QString findDOMCookies(QString);
2234 + QString findDOMCookies(QString, long);
2235 void addCookies(QString, QCString, long);
2236 void deleteCookie(QString, QString, QString, QString);
2237 void deleteCookiesFromDomain(QString);
2242 - bool cookiesPending(const QString &url);
2243 + bool cookiesPending(const QString &url, KHttpCookieList *cookieList=0);
2244 void addCookies(const QString &url, const QCString &cookieHeader,
2245 long windowId, bool useDOMFormat);
2246 - void checkCookies(KHttpCookie *cookie, bool queue);
2247 + void checkCookies(KHttpCookieList *cookieList);
2251 + void slotDeleteSessionCookies(long);
2254 KCookieJar *mCookieJar;
2256 bool cookieMatches(KHttpCookie*, QString, QString, QString, QString);
2257 void putCookie(QStringList&, KHttpCookie*, const QValueList<int>&);
2258 void saveCookieJar();
2259 + bool mBigScreen : 1;
2263 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.cpp~kcookiejar-merge.patch
2264 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.cpp
2267 This file is part of KDE
2269 - Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
2270 - Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
2271 + Copyright (C) 2000- Waldo Bastian <bastian@kde.org>
2272 + Copyright (C) 2000- Dawit Alemayehu <adawit@kde.org>
2274 Permission is hereby granted, free of charge, to any person obtaining a copy
2275 of this software and associated documentation files (the "Software"), to deal
2277 //----------------------------------------------------------------------------
2279 // KDE File Manager -- HTTP Cookie Dialogs
2280 -// $Id: kcookiewin.cpp,v 1.26 2001/05/13 23:36:48 adawit Exp $
2281 +// $Id: kcookiewin.cpp,v 1.55 2004/07/07 15:18:43 waba Exp $
2283 // The purpose of the QT_NO_TOOLTIP and QT_NO_WHATSTHIS ifdefs is because
2284 // this file is also used in Konqueror/Embedded. One of the aims of
2286 #include <qpushbutton.h>
2287 #include <qradiobutton.h>
2288 #include <qvbuttongroup.h>
2289 +#include <qscrollview.h>
2291 +#ifndef QT_NO_TOOLTIP
2292 +#include <qtooltip.h>
2295 +#ifndef QT_NO_WHATSTHIS
2296 +#include <qwhatsthis.h>
2301 #include <klocale.h>
2302 #include <kglobal.h>
2303 #include <kurllabel.h>
2304 +#include <qlineedit.h>
2305 #include <kiconloader.h>
2307 +#ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
2308 +#include <X11/Xlib.h>
2311 #include "kcookiejar.h"
2312 #include "kcookiewin.h"
2314 -KCookieWin::KCookieWin( QWidget *parent, KHttpCookie* cookie,
2315 - int defaultButton, bool showDetails )
2316 - :KDialog( parent, "cookiealert", true )
2317 +KCookieWin::KCookieWin( QWidget *parent, KHttpCookieList cookieList,
2318 + int defaultButton, bool showDetails, bool modal )
2319 + :KDialog( parent, "cookiealert", modal )
2321 - KWin::setState( winId(), NET::StaysOnTop );
2322 - KWin::setOnDesktop(winId(), KWin::currentDesktop());
2323 +#ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
2324 setCaption( i18n("Cookie Alert") );
2325 setIcon( SmallIcon("cookie") );
2327 + // all cookies in the list should have the same window at this time, so let's take the first
2328 + if( cookieList.first()->windowIds().count() > 0 )
2329 + XSetTransientForHint( qt_xdisplay(), winId(), cookieList.first()->windowIds().first());
2331 // Main widget's layout manager...
2332 QVBoxLayout* vlayout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
2333 - vlayout->setResizeMode( QLayout::Fixed );
2335 // Cookie image and message to user
2336 QHBox* hBox = new QHBox( this );
2337 hBox->setSpacing( KDialog::spacingHint() );
2338 QLabel* icon = new QLabel( hBox );
2339 - icon->setPixmap( QMessageBox::standardIcon(QMessageBox::Warning, kapp->style().guiStyle()) );
2340 + icon->setPixmap( QMessageBox::standardIcon(QMessageBox::Warning, kapp->style().guiStyle() ) );
2341 icon->setAlignment( Qt::AlignCenter );
2342 icon->setFixedSize( 2*icon->sizeHint() );
2345 - KHttpCookie* nextCookie = cookie;
2346 - while ( nextCookie )
2349 - nextCookie = nextCookie->next();
2351 + int count = cookieList.count();
2353 QVBox* vBox = new QVBox( hBox );
2354 - QString txt = (count == 1) ? i18n("You received a cookie from"):
2355 - i18n("You received %1 cookies from").arg(count);
2356 + QString txt = i18n("You received a cookie from",
2357 + "You received %n cookies from", count);
2358 QLabel* lbl = new QLabel( txt, vBox );
2359 lbl->setAlignment( Qt::AlignCenter );
2360 + KHttpCookiePtr cookie = cookieList.first();
2361 txt = i18n("<b>%1</b>").arg( cookie->host() );
2362 + if (cookie->isCrossDomain())
2363 + txt += i18n(" <b>[Cross Domain!]</b>");
2364 lbl = new QLabel( txt, vBox );
2365 lbl->setAlignment( Qt::AlignCenter );
2366 - lbl = new QLabel( i18n("Do you want to accept or reject ?"), vBox );
2367 + lbl = new QLabel( i18n("Do you want to accept or reject?"), vBox );
2368 lbl->setAlignment( Qt::AlignCenter );
2369 vlayout->addWidget( hBox, 0, Qt::AlignLeft );
2371 // Cookie Details dialog...
2372 - m_detailView = new KCookieDetail( cookie, count, this );
2373 + m_detailView = new KCookieDetail( cookieList, count, this );
2374 vlayout->addWidget( m_detailView );
2375 m_showDetails = showDetails;
2376 m_showDetails ? m_detailView->show():m_detailView->hide();
2378 // Cookie policy choice...
2379 - m_btnGrp = new QVButtonGroup( i18n("Apply choice to"), this );
2380 + m_btnGrp = new QVButtonGroup( i18n("Apply Choice To"), this );
2381 m_btnGrp->setRadioButtonExclusive( true );
2383 txt = (count == 1)? i18n("&Only this cookie") : i18n("&Only these cookies");
2385 #ifndef QT_NO_WHATSTHIS
2386 QWhatsThis::add( rb, i18n("Select this option to accept/reject all cookies from "
2387 "this site. Choosing this option will add a new policy for "
2388 - "the site this cookie originated from. This policy will be "
2389 + "the site this cookie originated from. This policy will be "
2390 "permanent until you manually change it from the Control Center "
2391 "<em>(see WebBrowsing/Cookies in the Control Center)</em>.") );
2393 @@ -146,35 +157,42 @@
2394 if ( defaultButton > -1 && defaultButton < 3 )
2395 m_btnGrp->setButton( defaultButton );
2397 - m_btnGrp->setButton( 0 );
2398 + m_btnGrp->setButton( 1 );
2400 // Accept/Reject buttons
2401 + QWidget* receiver = parent ? parent : this;
2402 QWidget* bbox = new QWidget( this );
2403 QBoxLayout* bbLay = new QHBoxLayout( bbox );
2404 bbLay->setSpacing( KDialog::spacingHint() );
2405 QPushButton* btn = new QPushButton( i18n("&Accept"), bbox );
2406 btn->setDefault( true );
2407 - connect( btn, SIGNAL(clicked()), SLOT(accept()) );
2409 + connect( btn, SIGNAL(clicked()), receiver, SLOT(accept()) );
2410 bbLay->addWidget( btn );
2411 btn = new QPushButton( i18n("&Reject"), bbox );
2412 - connect( btn, SIGNAL(clicked()), SLOT(reject()) );
2413 + connect( btn, SIGNAL(clicked()), receiver, SLOT(reject()) );
2414 bbLay->addWidget( btn );
2415 - bbLay->addStretch( 1 );
2416 - m_button = new QPushButton( bbox );
2417 - m_button->setText( m_showDetails ? i18n("&Details <<"):i18n("&Details >>") );
2418 - connect( m_button, SIGNAL(clicked()), SLOT(slotCookieDetails()) );
2419 - bbLay->addWidget( m_button );
2420 + bbLay->addStretch( 1 );
2422 QAccel* a = new QAccel( this );
2423 a->connectItem( a->insertItem(Qt::Key_Escape), btn, SLOT(animateClick()) );
2427 + m_button = new QPushButton( bbox );
2428 + m_button->setText( m_showDetails ? i18n("&Details <<"):i18n("&Details >>") );
2429 + connect( m_button, SIGNAL(clicked()), SLOT(slotCookieDetails()) );
2430 + bbLay->addWidget( m_button );
2431 #ifndef QT_NO_WHATSTHIS
2432 - QWhatsThis::add( btn, i18n("See or modify the cookie information") );
2433 + QWhatsThis::add( m_button, i18n("See or modify the cookie information") );
2437 vlayout->addWidget( bbox );
2438 - setFixedSize( sizeHint() );
2441 + vlayout->setResizeMode( QLayout::Fixed );
2442 + setFixedSize( sizeHint() );
2446 KCookieWin::~KCookieWin()
2447 @@ -201,13 +219,16 @@
2451 -KCookieAdvice KCookieWin::advice( KCookieJar *cookiejar, KHttpCookie* cookie )
2452 +KCookieAdvice KCookieWin::advice( int result, KCookieJar *cookiejar, KHttpCookie* cookie )
2454 - int result = exec();
2455 + cookiejar->setShowCookieDetails ( m_showDetails );
2457 KCookieAdvice advice = (result==QDialog::Accepted) ? KCookieAccept:KCookieReject;
2458 - cookiejar->defaultRadioButton = m_btnGrp->id( m_btnGrp->selected() );
2459 - cookiejar->showCookieDetails = m_showDetails;
2460 - switch ( cookiejar->defaultRadioButton )
2462 + int preferredPolicy = m_btnGrp->id( m_btnGrp->selected() );
2463 + cookiejar->setPreferredDefaultPolicy( preferredPolicy );
2465 + switch ( preferredPolicy )
2468 cookiejar->setGlobalAdvice( advice );
2469 @@ -222,11 +243,11 @@
2473 -KCookieDetail::KCookieDetail( KHttpCookie* cookie, int cookieCount,
2474 +KCookieDetail::KCookieDetail( KHttpCookieList cookieList, int cookieCount,
2475 QWidget* parent, const char* name )
2476 :QGroupBox( parent, name )
2478 - setTitle( i18n("Cookie details") );
2479 + setTitle( i18n("Cookie Details") );
2480 QGridLayout* grid = new QGridLayout( this, 9, 2,
2481 KDialog::spacingHint(),
2482 KDialog::marginHint() );
2484 grid->addWidget( label, 1, 0 );
2485 m_name = new QLineEdit( this );
2486 m_name->setReadOnly( true );
2487 - m_name->setText( cookie->name() );
2488 - m_name->setMaximumWidth( fontMetrics().width('W') * 25 );
2489 + m_name->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2490 grid->addWidget( m_name, 1 ,1 );
2493 @@ -246,46 +266,35 @@
2494 grid->addWidget( label, 2, 0 );
2495 m_value = new QLineEdit( this );
2496 m_value->setReadOnly( true );
2497 - m_value->setText( cookie->value() );
2498 - m_value->setMaximumWidth( fontMetrics().width('W') * 25 );
2499 + m_value->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2500 grid->addWidget( m_value, 2, 1);
2502 label = new QLabel( i18n("Expires:"), this );
2503 grid->addWidget( label, 3, 0 );
2504 m_expires = new QLineEdit( this );
2505 m_expires->setReadOnly( true );
2506 - QDateTime cookiedate;
2507 - cookiedate.setTime_t( cookie->expireDate() );
2508 - if ( cookie->expireDate() )
2509 - m_expires->setText( KGlobal::locale()->formatDateTime(cookiedate) );
2511 - m_expires->setText( i18n("Not specified") );
2512 - m_expires->setMaximumWidth(fontMetrics().width('W') * 25 );
2513 + m_expires->setMaximumWidth(fontMetrics().maxWidth() * 25 );
2514 grid->addWidget( m_expires, 3, 1);
2516 label = new QLabel( i18n("Path:"), this );
2517 grid->addWidget( label, 4, 0 );
2518 m_path = new QLineEdit( this );
2519 m_path->setReadOnly( true );
2520 - m_path->setText( cookie->path() );
2521 - m_path->setMaximumWidth( fontMetrics().width('W') * 25 );
2522 + m_path->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2523 grid->addWidget( m_path, 4, 1);
2525 label = new QLabel( i18n("Domain:"), this );
2526 grid->addWidget( label, 5, 0 );
2527 m_domain = new QLineEdit( this );
2528 m_domain->setReadOnly( true );
2529 - QString val = cookie->domain();
2530 - m_domain->setText( val.isEmpty()?i18n("Not specified"):val );
2531 - m_domain->setMaximumWidth( fontMetrics().width('W') * 25 );
2532 + m_domain->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2533 grid->addWidget( m_domain, 5, 1);
2535 - label = new QLabel( i18n("Is Secure:"), this );
2536 + label = new QLabel( i18n("Exposure:"), this );
2537 grid->addWidget( label, 6, 0 );
2538 m_secure = new QLineEdit( this );
2539 m_secure->setReadOnly( true );
2540 - m_secure->setText( cookie->isSecure() ? i18n("True"):i18n("False") );
2541 - m_secure->setMaximumWidth( fontMetrics().width('W') * 25 );
2542 + m_secure->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2543 grid->addWidget( m_secure, 6, 1 );
2545 if ( cookieCount > 1 )
2547 QToolTip::add( btnNext, i18n("Show details of the next cookie") );
2550 - m_cookie = cookie;
2551 - m_cookie_orig = cookie;
2552 + m_cookieList = cookieList;
2557 KCookieDetail::~KCookieDetail()
2558 @@ -308,9 +318,19 @@
2560 void KCookieDetail::slotNextCookie()
2562 - m_cookie = m_cookie->next();
2564 - m_cookie = m_cookie_orig;
2565 + KHttpCookiePtr cookie = m_cookieList.first();
2566 + if (m_cookie) while(cookie)
2568 + if (cookie == m_cookie)
2570 + cookie = m_cookieList.next();
2573 + cookie = m_cookieList.next();
2575 + m_cookie = cookie;
2577 + m_cookie = m_cookieList.first();
2581 @@ -326,9 +346,52 @@
2582 if ( m_cookie->expireDate() )
2583 m_expires->setText( KGlobal::locale()->formatDateTime(cookiedate) );
2585 - m_expires->setText( i18n("Not specified") );
2586 - m_secure->setText( m_cookie->isSecure() ? i18n("True"):i18n("False") );
2587 + m_expires->setText( i18n("End of Session") );
2589 + if (m_cookie->isSecure())
2591 + if (m_cookie->isHttpOnly())
2592 + sec = i18n("Secure servers only");
2594 + sec = i18n("Secure servers, page scripts");
2598 + if (m_cookie->isHttpOnly())
2599 + sec = i18n("Servers");
2601 + sec = i18n("Servers, page scripts");
2603 + m_secure->setText( sec );
2612 +KScrolledCookieWin::KScrolledCookieWin( QWidget *parent, KHttpCookieList cookieList,
2613 + int defaultButton, bool showDetails )
2614 + : KDialog( parent, "scrolled_cookiealert", true )
2616 + setCaption( i18n("Cookie Alert") );
2617 + QVBoxLayout *layout = new QVBoxLayout( this );
2618 + QScrollView *view = new QScrollView( this, "cookie_view" );
2619 + m_cookieWin = new KCookieWin( this, cookieList, defaultButton,
2620 + showDetails, false );
2622 + view->setResizePolicy( QScrollView::AutoOneFit );
2623 + view->setFrameShape( QFrame::NoFrame );
2624 + view->addChild( m_cookieWin );
2626 + layout->addWidget( view );
2629 +KCookieWin* KScrolledCookieWin::cookieWindow()const
2631 + return m_cookieWin;
2635 #include "kcookiewin.moc"
2636 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.h~kcookiejar-merge.patch
2637 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.h
2640 This file is part of the KDE File Manager
2642 - Copyright (C) 1998-2000 Waldo Bastian (bastian@kde.org)
2643 - Copyright (C) 2000 Dawit Alemayehu (adawit@kde.org)
2644 + Copyright (C) 1998- Waldo Bastian (bastian@kde.org)
2645 + Copyright (C) 2000- Dawit Alemayehu (adawit@kde.org)
2647 This library is free software; you can redistribute it and/or
2648 modify it under the terms of the GNU General Public License
2650 //----------------------------------------------------------------------------
2652 // KDE File Manager -- HTTP Cookie Dialogs
2653 -// $Id: kcookiewin.h,v 1.9 2001/04/26 23:45:12 waba Exp $
2654 +// $Id: kcookiewin.h,v 1.12 2002/05/20 05:35:37 adawit Exp $
2656 #ifndef _KCOOKIEWIN_H_
2657 #define _KCOOKIEWIN_H_
2662 - KCookieDetail( KHttpCookie* cookie, int cookieCount, QWidget *parent=0,
2663 + KCookieDetail( KHttpCookieList cookieList, int cookieCount, QWidget *parent=0,
2664 const char *name=0 );
2669 QLineEdit* m_secure;
2671 - KHttpCookie* m_cookie;
2672 - KHttpCookie* m_cookie_orig;
2673 + KHttpCookieList m_cookieList;
2674 + KHttpCookiePtr m_cookie;
2677 void slotNextCookie();
2682 - KCookieWin( QWidget *parent, KHttpCookie* cookie, int defaultButton=0,
2683 - bool showDetails=false );
2684 + KCookieWin( QWidget *parent, KHttpCookieList cookieList, int defaultButton=0,
2685 + bool showDetails=false, bool modal = true );
2688 - KCookieAdvice advice( KCookieJar *cookiejar, KHttpCookie* cookie );
2689 + KCookieAdvice advice( int result, KCookieJar *cookiejar, KHttpCookie* cookie );
2692 QPushButton* m_button;
2695 void slotCookieDetails();
2699 + * A small Scrolled Adapter for KCookieWin
2700 + * to be used on big screen
2702 +class KScrolledCookieWin : public KDialog
2707 + KScrolledCookieWin( QWidget *parent, KHttpCookieList cookieList, int defaultButton=0,
2708 + bool showDetails=false );
2709 + KCookieWin* cookieWindow()const;
2712 + KCookieWin *m_cookieWin;
2715 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver_skel.cpp~kcookiejar-merge.patch
2716 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver_skel.cpp
2719 *****************************************************************************/
2721 -#include "./kcookieserver.h"
2722 +#include "kcookieserver.h"
2724 #include <kdatastream.h>
2725 #include <qasciidict.h>
2728 -static const int KCookieServer_fhash = 17;
2729 -static const char* const KCookieServer_ftable[16][3] = {
2730 +static const int KCookieServer_fhash = 19;
2731 +static const char* const KCookieServer_ftable[18][3] = {
2732 { "QString", "findCookies(QString)", "findCookies(QString)" },
2733 + { "QString", "findCookies(QString,long int)", "findCookies(QString,long int)" },
2734 { "QStringList", "findDomains()", "findDomains()" },
2735 { "QStringList", "findCookies(QValueList<int>,QString,QString,QString,QString)", "findCookies(QValueList<int>,QString,QString,QString,QString)" },
2736 { "QString", "findDOMCookies(QString)", "findDOMCookies(QString)" },
2737 + { "QString", "findDOMCookies(QString,long int)", "findDOMCookies(QString,long int)" },
2738 { "void", "addCookies(QString,QCString,long int)", "addCookies(QString,QCString,long int)" },
2739 { "void", "deleteCookie(QString,QString,QString,QString)", "deleteCookie(QString,QString,QString,QString)" },
2740 { "void", "deleteCookiesFromDomain(QString)", "deleteCookiesFromDomain(QString)" },
2742 QDataStream _replyStream( replyData, IO_WriteOnly );
2743 _replyStream << findCookies(arg0 );
2745 - case 1: { // QStringList findDomains()
2746 + case 1: { // QString findCookies(QString,long int)
2749 + QDataStream arg( data, IO_ReadOnly );
2752 replyType = KCookieServer_ftable[1][0];
2753 QDataStream _replyStream( replyData, IO_WriteOnly );
2754 + _replyStream << findCookies(arg0, arg1 );
2756 + case 2: { // QStringList findDomains()
2757 + replyType = KCookieServer_ftable[2][0];
2758 + QDataStream _replyStream( replyData, IO_WriteOnly );
2759 _replyStream << findDomains( );
2761 - case 2: { // QStringList findCookies(QValueList<int>,QString,QString,QString,QString)
2762 + case 3: { // QStringList findCookies(QValueList<int>,QString,QString,QString,QString)
2763 QValueList<int> arg0;
2770 - replyType = KCookieServer_ftable[2][0];
2771 + replyType = KCookieServer_ftable[3][0];
2772 QDataStream _replyStream( replyData, IO_WriteOnly );
2773 _replyStream << findCookies(arg0, arg1, arg2, arg3, arg4 );
2775 - case 3: { // QString findDOMCookies(QString)
2776 + case 4: { // QString findDOMCookies(QString)
2778 QDataStream arg( data, IO_ReadOnly );
2780 - replyType = KCookieServer_ftable[3][0];
2781 + replyType = KCookieServer_ftable[4][0];
2782 QDataStream _replyStream( replyData, IO_WriteOnly );
2783 _replyStream << findDOMCookies(arg0 );
2785 - case 4: { // void addCookies(QString,QCString,long int)
2786 + case 5: { // QString findDOMCookies(QString,long int)
2789 + QDataStream arg( data, IO_ReadOnly );
2792 + replyType = KCookieServer_ftable[5][0];
2793 + QDataStream _replyStream( replyData, IO_WriteOnly );
2794 + _replyStream << findDOMCookies(arg0, arg1 );
2796 + case 6: { // void addCookies(QString,QCString,long int)
2800 @@ -87,10 +109,10 @@
2804 - replyType = KCookieServer_ftable[4][0];
2805 + replyType = KCookieServer_ftable[6][0];
2806 addCookies(arg0, arg1, arg2 );
2808 - case 5: { // void deleteCookie(QString,QString,QString,QString)
2809 + case 7: { // void deleteCookie(QString,QString,QString,QString)
2813 @@ -100,37 +122,37 @@
2817 - replyType = KCookieServer_ftable[5][0];
2818 + replyType = KCookieServer_ftable[7][0];
2819 deleteCookie(arg0, arg1, arg2, arg3 );
2821 - case 6: { // void deleteCookiesFromDomain(QString)
2822 + case 8: { // void deleteCookiesFromDomain(QString)
2824 QDataStream arg( data, IO_ReadOnly );
2826 - replyType = KCookieServer_ftable[6][0];
2827 + replyType = KCookieServer_ftable[8][0];
2828 deleteCookiesFromDomain(arg0 );
2830 - case 7: { // void deleteSessionCookies(long int)
2831 + case 9: { // void deleteSessionCookies(long int)
2833 QDataStream arg( data, IO_ReadOnly );
2835 - replyType = KCookieServer_ftable[7][0];
2836 + replyType = KCookieServer_ftable[9][0];
2837 deleteSessionCookies(arg0 );
2839 - case 8: { // void deleteSessionCookiesFor(QString,long int)
2840 + case 10: { // void deleteSessionCookiesFor(QString,long int)
2843 QDataStream arg( data, IO_ReadOnly );
2846 - replyType = KCookieServer_ftable[8][0];
2847 + replyType = KCookieServer_ftable[10][0];
2848 deleteSessionCookiesFor(arg0, arg1 );
2850 - case 9: { // void deleteAllCookies()
2851 - replyType = KCookieServer_ftable[9][0];
2852 + case 11: { // void deleteAllCookies()
2853 + replyType = KCookieServer_ftable[11][0];
2854 deleteAllCookies( );
2856 - case 10: { // void addDOMCookies(QString,QCString,long int)
2857 + case 12: { // void addDOMCookies(QString,QCString,long int)
2861 @@ -138,38 +160,38 @@
2865 - replyType = KCookieServer_ftable[10][0];
2866 + replyType = KCookieServer_ftable[12][0];
2867 addDOMCookies(arg0, arg1, arg2 );
2869 - case 11: { // void setDomainAdvice(QString,QString)
2870 + case 13: { // void setDomainAdvice(QString,QString)
2873 QDataStream arg( data, IO_ReadOnly );
2876 - replyType = KCookieServer_ftable[11][0];
2877 + replyType = KCookieServer_ftable[13][0];
2878 setDomainAdvice(arg0, arg1 );
2880 - case 12: { // QString getDomainAdvice(QString)
2881 + case 14: { // QString getDomainAdvice(QString)
2883 QDataStream arg( data, IO_ReadOnly );
2885 - replyType = KCookieServer_ftable[12][0];
2886 + replyType = KCookieServer_ftable[14][0];
2887 QDataStream _replyStream( replyData, IO_WriteOnly );
2888 _replyStream << getDomainAdvice(arg0 );
2890 - case 13: { // void reloadPolicy()
2891 - replyType = KCookieServer_ftable[13][0];
2892 + case 15: { // void reloadPolicy()
2893 + replyType = KCookieServer_ftable[15][0];
2896 - case 14: { // void shutdown()
2897 - replyType = KCookieServer_ftable[14][0];
2898 + case 16: { // void shutdown()
2899 + replyType = KCookieServer_ftable[16][0];
2903 return KUniqueApplication::process( fun, data, replyType, replyData );
2909 QCStringList KCookieServer::interfaces()
2910 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/http.cc~kcookiejar-merge.patch
2911 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/http.cc
2913 kdDebug(7103) << "(" << getpid() << ") Proxy URL is now: " << m_proxyURL.url() << endl;
2916 - m_bUseCookiejar = config()->readBoolEntry("Cookies");
2917 - m_bUseCache = config()->readBoolEntry("UseCache");
2918 - m_strCacheDir = config()->readEntry("CacheDir");
2919 + m_bUseCookiejar = config()->readBoolEntry("Cookies", true);
2920 + m_bUseCache = config()->readBoolEntry("UseCache", true);
2921 + m_strCacheDir = config()->readEntry("CacheDir", "/tmp/");
2922 m_maxCacheAge = config()->readNumEntry("MaxCacheAge");
2923 m_request.window = config()->readEntry("window-id");