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>
1767 +#include "kcookiejar.h"
1768 +#include "kcookiewin.h"
1769 +#include "kcookieserver.h"
1771 // Cookie field indexes
1772 enum CookieDetails { CF_DOMAIN=0, CF_PATH, CF_NAME, CF_HOST,
1774 DCOPClientTransaction *transaction;
1780 template class QList<CookieRequest>;
1783 mCookieJar = new KCookieJar;
1784 mPendingCookies = new KHttpCookieList;
1785 + mPendingCookies->setAutoDelete(true);
1786 mRequestList = new RequestList;
1787 mAdvicePending = false;
1789 - mCookieJar->loadConfig( kapp->config());
1790 + mCookieJar->loadConfig( kapp->config() );
1792 QString filename = locateLocal("appdata", "cookies");
1796 mCookieJar->loadCookies( filename);
1799 + QWidget *wid = qApp->desktop();
1800 + mBigScreen = (wid->width() > 320 || wid->height() > 320);
1803 KCookieServer::~KCookieServer()
1805 if (mCookieJar->changed())
1810 delete mPendingCookies;
1815 -bool KCookieServer::cookiesPending( const QString &url )
1816 +bool KCookieServer::cookiesPending( const QString &url, KHttpCookieList *cookieList )
1819 QStringList domains;
1820 @@ -136,109 +143,152 @@
1821 if (!KCookieJar::parseURL(url, fqdn, path))
1824 - KCookieJar::extractDomains( fqdn, domains );
1825 + mCookieJar->extractDomains( fqdn, domains );
1826 for( KHttpCookie *cookie = mPendingCookies->first();
1828 cookie = mPendingCookies->next())
1830 if (cookie->match( fqdn, domains, path))
1835 + cookieList->append(cookie);
1841 + return cookieList->isEmpty();
1844 void KCookieServer::addCookies( const QString &url, const QCString &cookieHeader,
1845 long windowId, bool useDOMFormat )
1847 - KHttpCookiePtr cookie = 0;
1848 + KHttpCookieList cookieList;
1850 - cookie = mCookieJar->makeDOMCookies(url, cookieHeader, windowId);
1851 + cookieList = mCookieJar->makeDOMCookies(url, cookieHeader, windowId);
1853 - cookie = mCookieJar->makeCookies(url, cookieHeader, windowId);
1854 + cookieList = mCookieJar->makeCookies(url, cookieHeader, windowId);
1856 - if (mAdvicePending)
1858 - checkCookies(cookie, true);
1861 + checkCookies(&cookieList);
1863 + for(KHttpCookiePtr cookie = cookieList.first(); cookie; cookie = cookieList.first())
1864 + mPendingCookies->append(cookieList.take());
1866 + if (!mAdvicePending)
1868 mAdvicePending = true;
1870 - checkCookies(cookie, false);
1871 - cookie = mPendingCookies->count() ? mPendingCookies->take(0) : 0;
1872 + while (!mPendingCookies->isEmpty())
1877 mAdvicePending = false;
1882 -void KCookieServer::checkCookies( KHttpCookie *cookie, bool queue )
1883 +void KCookieServer::checkCookies( KHttpCookieList *cookieList)
1886 - KCookieAdvice userAdvice = KCookieDunno;
1887 - if (cookie) host = cookie->host();
1888 + KHttpCookieList *list;
1891 + list = cookieList;
1893 + list = mPendingCookies;
1895 + KHttpCookiePtr cookie = list->first();
1898 - KHttpCookiePtr next_cookie = cookie->next();
1899 KCookieAdvice advice = mCookieJar->cookieAdvice(cookie);
1900 - if ((advice == KCookieAsk) || (advice == KCookieDunno))
1902 - // We only ask the user once, even if we get multiple
1903 - // cookies from the same site.
1904 - if (userAdvice == KCookieDunno)
1908 - mPendingCookies->append(cookie);
1913 - mPendingCookies->prepend(cookie);
1914 - KCookieWin *kw = new KCookieWin( 0L, cookie,
1915 - mCookieJar->defaultRadioButton,
1916 - mCookieJar->showCookieDetails );
1917 - userAdvice = kw->advice(mCookieJar, cookie);
1919 - mPendingCookies->take(0);
1920 - // Save the cookie config if it has changed
1921 - mCookieJar->saveConfig( kapp->config() );
1924 - advice = userAdvice;
1930 mCookieJar->addCookie(cookie);
1931 + cookie = list->current();
1938 + cookie = list->current();
1942 + cookie = list->next();
1945 - cookie = next_cookie;
1946 - if (!cookie && !queue)
1949 + if (cookieList || list->isEmpty())
1952 + KHttpCookiePtr currentCookie = mPendingCookies->first();
1954 + KHttpCookieList currentList;
1955 + currentList.append(currentCookie);
1956 + QString currentHost = currentCookie->host();
1958 + cookie = mPendingCookies->next();
1961 + if (cookie->host() == currentHost)
1963 - // Check if there are cookies on the pending list from the
1965 - for( cookie = mPendingCookies->first();
1967 - cookie = mPendingCookies->next())
1969 - if (cookie->host() == host)
1973 + currentList.append(cookie);
1975 + cookie = mPendingCookies->next();
1979 + KScrolledCookieWin *skw= 0L;
1982 + skw = new KScrolledCookieWin(0L, currentList,
1983 + mCookieJar->preferredDefaultPolicy(),
1984 + mCookieJar->showCookieDetails() );
1985 + kw = skw->cookieWindow();
1987 + kw = new KCookieWin( 0L, currentList,
1988 + mCookieJar->preferredDefaultPolicy(),
1989 + mCookieJar->showCookieDetails() );
1991 + KCookieAdvice userAdvice = kw->advice(mCookieJar, currentCookie);
1994 + // Save the cookie config if it has changed
1995 + mCookieJar->saveConfig( kapp->config() );
1997 + // Apply the user's choice to all cookies that are currently
1998 + // queued for this host.
1999 + cookie = mPendingCookies->first();
2002 + if (cookie->host() == currentHost)
2004 + switch(userAdvice)
2006 - // Found a matching cookie, remove it from the pending list.
2007 - cookie = mPendingCookies->take();
2008 + case KCookieAccept:
2009 + mPendingCookies->take();
2010 + mCookieJar->addCookie(cookie);
2011 + cookie = mPendingCookies->current();
2014 + case KCookieReject:
2015 + mPendingCookies->take();
2017 + cookie = mPendingCookies->current();
2021 + cookie = mPendingCookies->next();
2027 + cookie = mPendingCookies->next();
2032 // Check if we can handle any request
2033 for ( CookieRequest *request = mRequestList->first(); request;)
2035 @@ -246,13 +296,13 @@
2038 QByteArray replyData;
2039 - QString res = mCookieJar->findCookies( request->url, request->DOM );
2040 + QString res = mCookieJar->findCookies( request->url, request->DOM, request->windowId );
2042 QDataStream stream2(replyData, IO_WriteOnly);
2044 replyType = "QString";
2045 dcopClient()->endTransaction( request->transaction,
2046 - replyType, replyData);
2047 + replyType, replyData);
2048 CookieRequest *tmp = request;
2049 request = mRequestList->next();
2050 mRequestList->removeRef( tmp );
2055 - QString filename = locateLocal("appdata", "cookies");
2056 + QString filename = locateLocal("data", "kcookiejar/cookies");
2057 mCookieJar->saveCookies(filename);
2062 ((hasDomain && c->domain() == domain) ||
2063 fqdn == c->host()) &&
2064 - (c->path() == path) &&
2065 - (c->name() == name);
2066 + (c->path() == path) &&
2067 + (c->name() == name) &&
2068 + (!c->isExpired(time(0)));
2072 @@ -343,16 +394,30 @@
2074 KCookieServer::findCookies(QString url)
2076 + return findCookies(url, 0);
2081 +KCookieServer::findCookies(QString url, long windowId)
2083 if (cookiesPending(url))
2085 CookieRequest *request = new CookieRequest;
2086 request->transaction = dcopClient()->beginTransaction();
2088 request->DOM = false;
2089 + request->windowId = windowId;
2090 mRequestList->append( request );
2091 return QString::null; // Talk to you later :-)
2093 - return mCookieJar->findCookies(url, false);
2095 + QString cookies = mCookieJar->findCookies(url, false, windowId);
2097 + if (mCookieJar->changed() && !mTimer)
2104 @@ -409,16 +474,20 @@
2106 KCookieServer::findDOMCookies(QString url)
2108 - if (cookiesPending(url))
2110 - CookieRequest *request = new CookieRequest;
2111 - request->transaction = dcopClient()->beginTransaction();
2112 - request->url = url;
2113 - request->DOM = true;
2114 - mRequestList->append( request );
2115 - return QString::null; // Talk to you later :-)
2117 - return mCookieJar->findCookies(url, true);
2118 + return findDOMCookies(url, 0);
2123 +KCookieServer::findDOMCookies(QString url, long windowId)
2125 + // We don't wait for pending cookies because it locks up konqueror
2126 + // which can cause a deadlock if it happens to have a popup-menu up.
2127 + // Instead we just return pending cookies as if they had been accepted already.
2128 + KHttpCookieList pendingCookies;
2129 + cookiesPending(url, &pendingCookies);
2131 + return mCookieJar->findCookies(url, true, windowId, &pendingCookies);
2135 @@ -459,18 +528,27 @@
2142 -KCookieServer::deleteSessionCookies( long winId )
2143 +KCookieServer::slotDeleteSessionCookies( long windowId )
2145 - mCookieJar->eatSessionCookies( winId );
2146 + deleteSessionCookies(windowId);
2151 +KCookieServer::deleteSessionCookies( long windowId )
2153 + mCookieJar->eatSessionCookies( windowId );
2159 -KCookieServer::deleteSessionCookiesFor(QString fqdn, long winId)
2160 +KCookieServer::deleteSessionCookiesFor(QString fqdn, long windowId)
2162 - mCookieJar->eatSessionCookies( fqdn, winId );
2163 + mCookieJar->eatSessionCookies( fqdn, windowId );
2168 if (KCookieJar::parseURL(url, fqdn, dummy))
2170 QStringList domains;
2171 - KCookieJar::extractDomains(fqdn, domains);
2172 + mCookieJar->extractDomains(fqdn, domains);
2173 mCookieJar->setDomainAdvice(domains[0],
2174 KCookieJar::strToAdvice(advice));
2177 if (KCookieJar::parseURL(url, fqdn, dummy))
2179 QStringList domains;
2180 - KCookieJar::extractDomains(fqdn, domains);
2181 + mCookieJar->extractDomains(fqdn, domains);
2182 advice = mCookieJar->getDomainAdvice(domains[0]);
2184 return KCookieJar::adviceToStr(advice);
2187 KCookieServer::shutdown()
2193 #include "kcookieserver.moc"
2194 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver.h~kcookiejar-merge.patch
2195 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver.h
2197 //----------------------------------------------------------------------------
2199 // KDE Cookie Server
2200 -// $Id: kcookieserver.h,v 1.15.2.1 2001/09/08 22:03:49 adawit Exp $
2201 +// $Id: kcookieserver.h,v 1.24 2003/06/09 10:56:42 waba Exp $
2203 #ifndef KCOOKIESERVER_H
2204 #define KCOOKIESERVER_H
2211 class KCookieServer : public KUniqueApplication
2216 QString findCookies(QString);
2217 + QString findCookies(QString, long);
2218 QStringList findDomains();
2219 QStringList findCookies(QValueList<int>,QString,QString,QString,QString);
2220 QString findDOMCookies(QString);
2221 + QString findDOMCookies(QString, long);
2222 void addCookies(QString, QCString, long);
2223 void deleteCookie(QString, QString, QString, QString);
2224 void deleteCookiesFromDomain(QString);
2229 - bool cookiesPending(const QString &url);
2230 + bool cookiesPending(const QString &url, KHttpCookieList *cookieList=0);
2231 void addCookies(const QString &url, const QCString &cookieHeader,
2232 long windowId, bool useDOMFormat);
2233 - void checkCookies(KHttpCookie *cookie, bool queue);
2234 + void checkCookies(KHttpCookieList *cookieList);
2238 + void slotDeleteSessionCookies(long);
2241 KCookieJar *mCookieJar;
2243 bool cookieMatches(KHttpCookie*, QString, QString, QString, QString);
2244 void putCookie(QStringList&, KHttpCookie*, const QValueList<int>&);
2245 void saveCookieJar();
2246 + bool mBigScreen : 1;
2250 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.cpp~kcookiejar-merge.patch
2251 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.cpp
2254 This file is part of KDE
2256 - Copyright (C) 2000 Waldo Bastian <bastian@kde.org>
2257 - Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
2258 + Copyright (C) 2000- Waldo Bastian <bastian@kde.org>
2259 + Copyright (C) 2000- Dawit Alemayehu <adawit@kde.org>
2261 Permission is hereby granted, free of charge, to any person obtaining a copy
2262 of this software and associated documentation files (the "Software"), to deal
2264 //----------------------------------------------------------------------------
2266 // KDE File Manager -- HTTP Cookie Dialogs
2267 -// $Id: kcookiewin.cpp,v 1.26 2001/05/13 23:36:48 adawit Exp $
2268 +// $Id: kcookiewin.cpp,v 1.55 2004/07/07 15:18:43 waba Exp $
2270 // The purpose of the QT_NO_TOOLTIP and QT_NO_WHATSTHIS ifdefs is because
2271 // this file is also used in Konqueror/Embedded. One of the aims of
2273 #include <qpushbutton.h>
2274 #include <qradiobutton.h>
2275 #include <qvbuttongroup.h>
2276 +#include <qscrollview.h>
2278 +#ifndef QT_NO_TOOLTIP
2279 +#include <qtooltip.h>
2282 +#ifndef QT_NO_WHATSTHIS
2283 +#include <qwhatsthis.h>
2288 #include <klocale.h>
2289 #include <kglobal.h>
2290 #include <kurllabel.h>
2291 +#include <qlineedit.h>
2292 #include <kiconloader.h>
2294 +#ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
2295 +#include <X11/Xlib.h>
2297 +#include <qpe/qpeapplication.h>
2300 #include "kcookiejar.h"
2301 #include "kcookiewin.h"
2303 -KCookieWin::KCookieWin( QWidget *parent, KHttpCookie* cookie,
2304 +KCookieWin::KCookieWin( QWidget *parent, KHttpCookieList cookieList,
2305 int defaultButton, bool showDetails )
2306 :KDialog( parent, "cookiealert", true )
2308 - KWin::setState( winId(), NET::StaysOnTop );
2309 - KWin::setOnDesktop(winId(), KWin::currentDesktop());
2310 +#ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
2311 setCaption( i18n("Cookie Alert") );
2312 setIcon( SmallIcon("cookie") );
2314 + // all cookies in the list should have the same window at this time, so let's take the first
2315 + if( cookieList.first()->windowIds().count() > 0 )
2316 + XSetTransientForHint( qt_xdisplay(), winId(), cookieList.first()->windowIds().first());
2318 // Main widget's layout manager...
2319 QVBoxLayout* vlayout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
2320 vlayout->setResizeMode( QLayout::Fixed );
2322 QHBox* hBox = new QHBox( this );
2323 hBox->setSpacing( KDialog::spacingHint() );
2324 QLabel* icon = new QLabel( hBox );
2325 - icon->setPixmap( QMessageBox::standardIcon(QMessageBox::Warning, kapp->style().guiStyle()) );
2326 + icon->setPixmap( QMessageBox::standardIcon(QMessageBox::Warning, kapp->style().guiStyle() ) );
2327 icon->setAlignment( Qt::AlignCenter );
2328 icon->setFixedSize( 2*icon->sizeHint() );
2331 - KHttpCookie* nextCookie = cookie;
2332 - while ( nextCookie )
2335 - nextCookie = nextCookie->next();
2337 + int count = cookieList.count();
2339 QVBox* vBox = new QVBox( hBox );
2340 - QString txt = (count == 1) ? i18n("You received a cookie from"):
2341 - i18n("You received %1 cookies from").arg(count);
2342 + QString txt = i18n("You received a cookie from",
2343 + "You received %n cookies from", count);
2344 QLabel* lbl = new QLabel( txt, vBox );
2345 lbl->setAlignment( Qt::AlignCenter );
2346 + KHttpCookiePtr cookie = cookieList.first();
2347 txt = i18n("<b>%1</b>").arg( cookie->host() );
2348 + if (cookie->isCrossDomain())
2349 + txt += i18n(" <b>[Cross Domain!]</b>");
2350 lbl = new QLabel( txt, vBox );
2351 lbl->setAlignment( Qt::AlignCenter );
2352 - lbl = new QLabel( i18n("Do you want to accept or reject ?"), vBox );
2353 + lbl = new QLabel( i18n("Do you want to accept or reject?"), vBox );
2354 lbl->setAlignment( Qt::AlignCenter );
2355 vlayout->addWidget( hBox, 0, Qt::AlignLeft );
2357 // Cookie Details dialog...
2358 - m_detailView = new KCookieDetail( cookie, count, this );
2359 + m_detailView = new KCookieDetail( cookieList, count, this );
2360 vlayout->addWidget( m_detailView );
2361 m_showDetails = showDetails;
2362 m_showDetails ? m_detailView->show():m_detailView->hide();
2364 // Cookie policy choice...
2365 - m_btnGrp = new QVButtonGroup( i18n("Apply choice to"), this );
2366 + m_btnGrp = new QVButtonGroup( i18n("Apply Choice To"), this );
2367 m_btnGrp->setRadioButtonExclusive( true );
2369 txt = (count == 1)? i18n("&Only this cookie") : i18n("&Only these cookies");
2371 #ifndef QT_NO_WHATSTHIS
2372 QWhatsThis::add( rb, i18n("Select this option to accept/reject all cookies from "
2373 "this site. Choosing this option will add a new policy for "
2374 - "the site this cookie originated from. This policy will be "
2375 + "the site this cookie originated from. This policy will be "
2376 "permanent until you manually change it from the Control Center "
2377 "<em>(see WebBrowsing/Cookies in the Control Center)</em>.") );
2380 if ( defaultButton > -1 && defaultButton < 3 )
2381 m_btnGrp->setButton( defaultButton );
2383 - m_btnGrp->setButton( 0 );
2384 + m_btnGrp->setButton( 1 );
2386 // Accept/Reject buttons
2387 QWidget* bbox = new QWidget( this );
2388 @@ -154,25 +168,27 @@
2389 bbLay->setSpacing( KDialog::spacingHint() );
2390 QPushButton* btn = new QPushButton( i18n("&Accept"), bbox );
2391 btn->setDefault( true );
2393 connect( btn, SIGNAL(clicked()), SLOT(accept()) );
2394 bbLay->addWidget( btn );
2395 btn = new QPushButton( i18n("&Reject"), bbox );
2396 connect( btn, SIGNAL(clicked()), SLOT(reject()) );
2397 bbLay->addWidget( btn );
2398 - bbLay->addStretch( 1 );
2399 - m_button = new QPushButton( bbox );
2400 - m_button->setText( m_showDetails ? i18n("&Details <<"):i18n("&Details >>") );
2401 - connect( m_button, SIGNAL(clicked()), SLOT(slotCookieDetails()) );
2402 - bbLay->addWidget( m_button );
2403 + bbLay->addStretch( 1 );
2405 QAccel* a = new QAccel( this );
2406 a->connectItem( a->insertItem(Qt::Key_Escape), btn, SLOT(animateClick()) );
2410 + m_button = new QPushButton( bbox );
2411 + m_button->setText( m_showDetails ? i18n("&Details <<"):i18n("&Details >>") );
2412 + connect( m_button, SIGNAL(clicked()), SLOT(slotCookieDetails()) );
2413 + bbLay->addWidget( m_button );
2414 #ifndef QT_NO_WHATSTHIS
2415 - QWhatsThis::add( btn, i18n("See or modify the cookie information") );
2416 + QWhatsThis::add( m_button, i18n("See or modify the cookie information") );
2420 vlayout->addWidget( bbox );
2421 setFixedSize( sizeHint() );
2423 @@ -203,11 +219,20 @@
2425 KCookieAdvice KCookieWin::advice( KCookieJar *cookiejar, KHttpCookie* cookie )
2428 + int result = QPEApplication::execDialog(this);
2430 int result = exec();
2433 + cookiejar->setShowCookieDetails ( m_showDetails );
2435 KCookieAdvice advice = (result==QDialog::Accepted) ? KCookieAccept:KCookieReject;
2436 - cookiejar->defaultRadioButton = m_btnGrp->id( m_btnGrp->selected() );
2437 - cookiejar->showCookieDetails = m_showDetails;
2438 - switch ( cookiejar->defaultRadioButton )
2440 + int preferredPolicy = m_btnGrp->id( m_btnGrp->selected() );
2441 + cookiejar->setPreferredDefaultPolicy( preferredPolicy );
2443 + switch ( preferredPolicy )
2446 cookiejar->setGlobalAdvice( advice );
2447 @@ -222,11 +247,11 @@
2451 -KCookieDetail::KCookieDetail( KHttpCookie* cookie, int cookieCount,
2452 +KCookieDetail::KCookieDetail( KHttpCookieList cookieList, int cookieCount,
2453 QWidget* parent, const char* name )
2454 :QGroupBox( parent, name )
2456 - setTitle( i18n("Cookie details") );
2457 + setTitle( i18n("Cookie Details") );
2458 QGridLayout* grid = new QGridLayout( this, 9, 2,
2459 KDialog::spacingHint(),
2460 KDialog::marginHint() );
2462 grid->addWidget( label, 1, 0 );
2463 m_name = new QLineEdit( this );
2464 m_name->setReadOnly( true );
2465 - m_name->setText( cookie->name() );
2466 - m_name->setMaximumWidth( fontMetrics().width('W') * 25 );
2467 + m_name->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2468 grid->addWidget( m_name, 1 ,1 );
2471 @@ -246,46 +270,35 @@
2472 grid->addWidget( label, 2, 0 );
2473 m_value = new QLineEdit( this );
2474 m_value->setReadOnly( true );
2475 - m_value->setText( cookie->value() );
2476 - m_value->setMaximumWidth( fontMetrics().width('W') * 25 );
2477 + m_value->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2478 grid->addWidget( m_value, 2, 1);
2480 label = new QLabel( i18n("Expires:"), this );
2481 grid->addWidget( label, 3, 0 );
2482 m_expires = new QLineEdit( this );
2483 m_expires->setReadOnly( true );
2484 - QDateTime cookiedate;
2485 - cookiedate.setTime_t( cookie->expireDate() );
2486 - if ( cookie->expireDate() )
2487 - m_expires->setText( KGlobal::locale()->formatDateTime(cookiedate) );
2489 - m_expires->setText( i18n("Not specified") );
2490 - m_expires->setMaximumWidth(fontMetrics().width('W') * 25 );
2491 + m_expires->setMaximumWidth(fontMetrics().maxWidth() * 25 );
2492 grid->addWidget( m_expires, 3, 1);
2494 label = new QLabel( i18n("Path:"), this );
2495 grid->addWidget( label, 4, 0 );
2496 m_path = new QLineEdit( this );
2497 m_path->setReadOnly( true );
2498 - m_path->setText( cookie->path() );
2499 - m_path->setMaximumWidth( fontMetrics().width('W') * 25 );
2500 + m_path->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2501 grid->addWidget( m_path, 4, 1);
2503 label = new QLabel( i18n("Domain:"), this );
2504 grid->addWidget( label, 5, 0 );
2505 m_domain = new QLineEdit( this );
2506 m_domain->setReadOnly( true );
2507 - QString val = cookie->domain();
2508 - m_domain->setText( val.isEmpty()?i18n("Not specified"):val );
2509 - m_domain->setMaximumWidth( fontMetrics().width('W') * 25 );
2510 + m_domain->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2511 grid->addWidget( m_domain, 5, 1);
2513 - label = new QLabel( i18n("Is Secure:"), this );
2514 + label = new QLabel( i18n("Exposure:"), this );
2515 grid->addWidget( label, 6, 0 );
2516 m_secure = new QLineEdit( this );
2517 m_secure->setReadOnly( true );
2518 - m_secure->setText( cookie->isSecure() ? i18n("True"):i18n("False") );
2519 - m_secure->setMaximumWidth( fontMetrics().width('W') * 25 );
2520 + m_secure->setMaximumWidth( fontMetrics().maxWidth() * 25 );
2521 grid->addWidget( m_secure, 6, 1 );
2523 if ( cookieCount > 1 )
2525 QToolTip::add( btnNext, i18n("Show details of the next cookie") );
2528 - m_cookie = cookie;
2529 - m_cookie_orig = cookie;
2530 + m_cookieList = cookieList;
2535 KCookieDetail::~KCookieDetail()
2536 @@ -308,9 +322,19 @@
2538 void KCookieDetail::slotNextCookie()
2540 - m_cookie = m_cookie->next();
2542 - m_cookie = m_cookie_orig;
2543 + KHttpCookiePtr cookie = m_cookieList.first();
2544 + if (m_cookie) while(cookie)
2546 + if (cookie == m_cookie)
2548 + cookie = m_cookieList.next();
2551 + cookie = m_cookieList.next();
2553 + m_cookie = cookie;
2555 + m_cookie = m_cookieList.first();
2559 @@ -326,9 +350,47 @@
2560 if ( m_cookie->expireDate() )
2561 m_expires->setText( KGlobal::locale()->formatDateTime(cookiedate) );
2563 - m_expires->setText( i18n("Not specified") );
2564 - m_secure->setText( m_cookie->isSecure() ? i18n("True"):i18n("False") );
2565 + m_expires->setText( i18n("End of Session") );
2567 + if (m_cookie->isSecure())
2569 + if (m_cookie->isHttpOnly())
2570 + sec = i18n("Secure servers only");
2572 + sec = i18n("Secure servers, page scripts");
2576 + if (m_cookie->isHttpOnly())
2577 + sec = i18n("Servers");
2579 + sec = i18n("Servers, page scripts");
2581 + m_secure->setText( sec );
2590 +KScrolledCookieWin::KScrolledCookieWin( QWidget *parent, KHttpCookieList cookieList,
2591 + int defaultButton, bool showDetails )
2592 + : KDialog( parent, "scrolled_cookiealert", true )
2594 + QVBoxLayout *layout = new QVBoxLayout( this );
2595 + QScrollView *view = new QScrollView( this, "cookie_view" );
2596 + m_cookieWin = new KCookieWin( view->viewport(), cookieList, defaultButton,
2598 + view->addChild( m_cookieWin );
2599 + layout->addWidget( view );
2602 +KCookieWin* KScrolledCookieWin::cookieWindow()const
2604 + return m_cookieWin;
2608 #include "kcookiewin.moc"
2609 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.h~kcookiejar-merge.patch
2610 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookiewin.h
2613 This file is part of the KDE File Manager
2615 - Copyright (C) 1998-2000 Waldo Bastian (bastian@kde.org)
2616 - Copyright (C) 2000 Dawit Alemayehu (adawit@kde.org)
2617 + Copyright (C) 1998- Waldo Bastian (bastian@kde.org)
2618 + Copyright (C) 2000- Dawit Alemayehu (adawit@kde.org)
2620 This library is free software; you can redistribute it and/or
2621 modify it under the terms of the GNU General Public License
2623 //----------------------------------------------------------------------------
2625 // KDE File Manager -- HTTP Cookie Dialogs
2626 -// $Id: kcookiewin.h,v 1.9 2001/04/26 23:45:12 waba Exp $
2627 +// $Id: kcookiewin.h,v 1.12 2002/05/20 05:35:37 adawit Exp $
2629 #ifndef _KCOOKIEWIN_H_
2630 #define _KCOOKIEWIN_H_
2635 - KCookieDetail( KHttpCookie* cookie, int cookieCount, QWidget *parent=0,
2636 + KCookieDetail( KHttpCookieList cookieList, int cookieCount, QWidget *parent=0,
2637 const char *name=0 );
2642 QLineEdit* m_secure;
2644 - KHttpCookie* m_cookie;
2645 - KHttpCookie* m_cookie_orig;
2646 + KHttpCookieList m_cookieList;
2647 + KHttpCookiePtr m_cookie;
2650 void slotNextCookie();
2655 - KCookieWin( QWidget *parent, KHttpCookie* cookie, int defaultButton=0,
2656 + KCookieWin( QWidget *parent, KHttpCookieList cookieList, int defaultButton=0,
2657 bool showDetails=false );
2662 void slotCookieDetails();
2666 + * A small Scrolled Adapter for KCookieWin
2667 + * to be used on big screen
2669 +class KScrolledCookieWin : public KDialog
2674 + KScrolledCookieWin( QWidget *parent, KHttpCookieList cookieList, int defaultButton=0,
2675 + bool showDetails=false );
2676 + KCookieWin* cookieWindow()const;
2679 + KCookieWin *m_cookieWin;
2682 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver_skel.cpp~kcookiejar-merge.patch
2683 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/kcookiejar/kcookieserver_skel.cpp
2686 *****************************************************************************/
2688 -#include "./kcookieserver.h"
2689 +#include "kcookieserver.h"
2691 #include <kdatastream.h>
2692 #include <qasciidict.h>
2695 -static const int KCookieServer_fhash = 17;
2696 -static const char* const KCookieServer_ftable[16][3] = {
2697 +static const int KCookieServer_fhash = 19;
2698 +static const char* const KCookieServer_ftable[18][3] = {
2699 { "QString", "findCookies(QString)", "findCookies(QString)" },
2700 + { "QString", "findCookies(QString,long int)", "findCookies(QString,long int)" },
2701 { "QStringList", "findDomains()", "findDomains()" },
2702 { "QStringList", "findCookies(QValueList<int>,QString,QString,QString,QString)", "findCookies(QValueList<int>,QString,QString,QString,QString)" },
2703 { "QString", "findDOMCookies(QString)", "findDOMCookies(QString)" },
2704 + { "QString", "findDOMCookies(QString,long int)", "findDOMCookies(QString,long int)" },
2705 { "void", "addCookies(QString,QCString,long int)", "addCookies(QString,QCString,long int)" },
2706 { "void", "deleteCookie(QString,QString,QString,QString)", "deleteCookie(QString,QString,QString,QString)" },
2707 { "void", "deleteCookiesFromDomain(QString)", "deleteCookiesFromDomain(QString)" },
2709 QDataStream _replyStream( replyData, IO_WriteOnly );
2710 _replyStream << findCookies(arg0 );
2712 - case 1: { // QStringList findDomains()
2713 + case 1: { // QString findCookies(QString,long int)
2716 + QDataStream arg( data, IO_ReadOnly );
2719 replyType = KCookieServer_ftable[1][0];
2720 QDataStream _replyStream( replyData, IO_WriteOnly );
2721 + _replyStream << findCookies(arg0, arg1 );
2723 + case 2: { // QStringList findDomains()
2724 + replyType = KCookieServer_ftable[2][0];
2725 + QDataStream _replyStream( replyData, IO_WriteOnly );
2726 _replyStream << findDomains( );
2728 - case 2: { // QStringList findCookies(QValueList<int>,QString,QString,QString,QString)
2729 + case 3: { // QStringList findCookies(QValueList<int>,QString,QString,QString,QString)
2730 QValueList<int> arg0;
2737 - replyType = KCookieServer_ftable[2][0];
2738 + replyType = KCookieServer_ftable[3][0];
2739 QDataStream _replyStream( replyData, IO_WriteOnly );
2740 _replyStream << findCookies(arg0, arg1, arg2, arg3, arg4 );
2742 - case 3: { // QString findDOMCookies(QString)
2743 + case 4: { // QString findDOMCookies(QString)
2745 QDataStream arg( data, IO_ReadOnly );
2747 - replyType = KCookieServer_ftable[3][0];
2748 + replyType = KCookieServer_ftable[4][0];
2749 QDataStream _replyStream( replyData, IO_WriteOnly );
2750 _replyStream << findDOMCookies(arg0 );
2752 - case 4: { // void addCookies(QString,QCString,long int)
2753 + case 5: { // QString findDOMCookies(QString,long int)
2756 + QDataStream arg( data, IO_ReadOnly );
2759 + replyType = KCookieServer_ftable[5][0];
2760 + QDataStream _replyStream( replyData, IO_WriteOnly );
2761 + _replyStream << findDOMCookies(arg0, arg1 );
2763 + case 6: { // void addCookies(QString,QCString,long int)
2767 @@ -87,10 +109,10 @@
2771 - replyType = KCookieServer_ftable[4][0];
2772 + replyType = KCookieServer_ftable[6][0];
2773 addCookies(arg0, arg1, arg2 );
2775 - case 5: { // void deleteCookie(QString,QString,QString,QString)
2776 + case 7: { // void deleteCookie(QString,QString,QString,QString)
2780 @@ -100,37 +122,37 @@
2784 - replyType = KCookieServer_ftable[5][0];
2785 + replyType = KCookieServer_ftable[7][0];
2786 deleteCookie(arg0, arg1, arg2, arg3 );
2788 - case 6: { // void deleteCookiesFromDomain(QString)
2789 + case 8: { // void deleteCookiesFromDomain(QString)
2791 QDataStream arg( data, IO_ReadOnly );
2793 - replyType = KCookieServer_ftable[6][0];
2794 + replyType = KCookieServer_ftable[8][0];
2795 deleteCookiesFromDomain(arg0 );
2797 - case 7: { // void deleteSessionCookies(long int)
2798 + case 9: { // void deleteSessionCookies(long int)
2800 QDataStream arg( data, IO_ReadOnly );
2802 - replyType = KCookieServer_ftable[7][0];
2803 + replyType = KCookieServer_ftable[9][0];
2804 deleteSessionCookies(arg0 );
2806 - case 8: { // void deleteSessionCookiesFor(QString,long int)
2807 + case 10: { // void deleteSessionCookiesFor(QString,long int)
2810 QDataStream arg( data, IO_ReadOnly );
2813 - replyType = KCookieServer_ftable[8][0];
2814 + replyType = KCookieServer_ftable[10][0];
2815 deleteSessionCookiesFor(arg0, arg1 );
2817 - case 9: { // void deleteAllCookies()
2818 - replyType = KCookieServer_ftable[9][0];
2819 + case 11: { // void deleteAllCookies()
2820 + replyType = KCookieServer_ftable[11][0];
2821 deleteAllCookies( );
2823 - case 10: { // void addDOMCookies(QString,QCString,long int)
2824 + case 12: { // void addDOMCookies(QString,QCString,long int)
2828 @@ -138,38 +160,38 @@
2832 - replyType = KCookieServer_ftable[10][0];
2833 + replyType = KCookieServer_ftable[12][0];
2834 addDOMCookies(arg0, arg1, arg2 );
2836 - case 11: { // void setDomainAdvice(QString,QString)
2837 + case 13: { // void setDomainAdvice(QString,QString)
2840 QDataStream arg( data, IO_ReadOnly );
2843 - replyType = KCookieServer_ftable[11][0];
2844 + replyType = KCookieServer_ftable[13][0];
2845 setDomainAdvice(arg0, arg1 );
2847 - case 12: { // QString getDomainAdvice(QString)
2848 + case 14: { // QString getDomainAdvice(QString)
2850 QDataStream arg( data, IO_ReadOnly );
2852 - replyType = KCookieServer_ftable[12][0];
2853 + replyType = KCookieServer_ftable[14][0];
2854 QDataStream _replyStream( replyData, IO_WriteOnly );
2855 _replyStream << getDomainAdvice(arg0 );
2857 - case 13: { // void reloadPolicy()
2858 - replyType = KCookieServer_ftable[13][0];
2859 + case 15: { // void reloadPolicy()
2860 + replyType = KCookieServer_ftable[15][0];
2863 - case 14: { // void shutdown()
2864 - replyType = KCookieServer_ftable[14][0];
2865 + case 16: { // void shutdown()
2866 + replyType = KCookieServer_ftable[16][0];
2870 return KUniqueApplication::process( fun, data, replyType, replyData );
2876 QCStringList KCookieServer::interfaces()
2877 --- konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/http.cc~kcookiejar-merge.patch
2878 +++ konqueror-embedded-snapshot-20030705/konq-embed/kdesrc/kio/http/http.cc
2880 kdDebug(7103) << "(" << getpid() << ") Proxy URL is now: " << m_proxyURL.url() << endl;
2883 - m_bUseCookiejar = config()->readBoolEntry("Cookies");
2884 - m_bUseCache = config()->readBoolEntry("UseCache");
2885 - m_strCacheDir = config()->readEntry("CacheDir");
2886 + m_bUseCookiejar = config()->readBoolEntry("Cookies", true);
2887 + m_bUseCache = config()->readBoolEntry("UseCache", true);
2888 + m_strCacheDir = config()->readEntry("CacheDir", "/tmp/");
2889 m_maxCacheAge = config()->readNumEntry("MaxCacheAge");
2890 m_request.window = config()->readEntry("window-id");