]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/konqueror/konqueror-embedded-20030705/kcookiejar-merge.patch
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / konqueror / konqueror-embedded-20030705 / kcookiejar-merge.patch
1
2 #
3 # Patch managed by http://www.holgerschurig.de/patcher.html
4 #
5
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
8 @@ -1,8 +1,8 @@
9  /* This file is part of the KDE File Manager
10  
11 -   Copyright (C) 1998,1999,2000,2001 Waldo Bastian (bastian@kde.org)
12 -   Copyright (C) 2000,2001           Dawit Alemayehu (adawit@kde.org)
13 -   
14 +   Copyright (C) 1998-2000 Waldo Bastian (bastian@kde.org)
15 +   Copyright (C) 2000,2001 Dawit Alemayehu (adawit@kde.org)
16 +
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
20 @@ -22,17 +22,18 @@
21  */
22  //----------------------------------------------------------------------------
23  //
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 $
28  
29  //
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.
36 +//
37 +// We assume cookies do not contain any spaces (Netscape spec.)
38 +// According to RFC2109 this is allowed though.
39  //
40 -// We assume cookies do not contain any spaces (Netscape spec.)  According to 
41 -// RFC2109 this is allowed though.
42 -
43  
44  #include <config.h>
45  #include <sys/types.h>
46 @@ -44,12 +45,23 @@
47  #include <unistd.h>
48  #include <stdio.h>
49  #include <string.h>
50 +
51 +#ifdef USE_SOLARIS
52 +#include <strings.h>
53 +#endif
54 +
55  #include <stdlib.h>
56  
57 +//#include <netinet/in.h>
58 +//#include <arpa/inet.h>
59 +
60  #include <qstring.h>
61  #include <qstrlist.h>
62  #include <qlist.h>
63  #include <qdict.h>
64 +#include <qfile.h>
65 +#include <qdir.h>
66 +#include <qregexp.h>
67  
68  #include <kurl.h>
69  #include <krfcdate.h>
70 @@ -61,6 +73,13 @@
71  
72  #define READ_BUFFER_SIZE 8192
73  
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.
77 +
78 +// L1 is used to indicate latin1 constants
79 +#define L1(x) QString::fromLatin1(x)
80 +
81  template class QList<KHttpCookie>;
82  template class QDict<KHttpCookieList>;
83  
84 @@ -68,10 +87,10 @@
85  {
86      switch( _advice )
87      {
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");
96      }
97  }
98  
99 @@ -80,7 +99,7 @@
100      if (_str.isEmpty())
101          return KCookieDunno;
102  
103 -    QString advice = _str.lower();
104 +    QCString advice = _str.lower().latin1();
105  
106      if (advice == "accept")
107          return KCookieAccept;
108 @@ -105,17 +124,20 @@
109                   const QString &_value,
110                   time_t _expireDate,
111                   int _protocolVersion,
112 -                 bool _secure) :
113 +                 bool _secure,
114 +                 bool _httpOnly,
115 +                 bool _explicitPath) :
116         mHost(_host),
117         mDomain(_domain),
118 -       mPath(_path),
119 +       mPath(_path.isEmpty() ? QString::null : _path),
120         mName(_name),
121         mValue(_value),
122         mExpireDate(_expireDate),
123         mProtocolVersion(_protocolVersion),
124 -       mSecure(_secure)
125 +       mSecure(_secure),
126 +       mHttpOnly(_httpOnly),
127 +       mExplicitPath(_explicitPath)
128  {
129 -    nextCookie = 0;
130  }
131  
132  //
133 @@ -135,16 +157,17 @@
134  
135      if (useDOMFormat || (mProtocolVersion == 0))
136      {
137 -        result = mName + "=" + mValue;
138 +        if ( !mName.isEmpty() )
139 +           result = mName + '=';
140 +        result += mValue;
141      }
142      else
143      {
144 -        result.sprintf("$Version=\"%d\"; ", mProtocolVersion);
145 -        result += mName + "=\"" + mValue + "\"";
146 -        if (!mPath.isEmpty())
147 -            result += "; $Path=\""+ mPath + "\"";
148 +        result = mName + '=' + mValue;
149 +        if (mExplicitPath)
150 +            result += L1("; $Path=\"") + mPath + L1("\"");
151          if (!mDomain.isEmpty())
152 -            result += "; $Domain=\""+ mDomain + "\"";
153 +            result += L1("; $Domain=\"") + mDomain + L1("\"");
154      }
155      return result;
156  }
157 @@ -157,8 +180,7 @@
158      // Cookie domain match check
159      if (mDomain.isEmpty())
160      {
161 -        // No domain set, check hostname.
162 -        if (fqdn != mHost)
163 +       if (fqdn != mHost)
164            return false;
165      }
166      else if (!domains.contains(mDomain))
167 @@ -167,17 +189,30 @@
168              return false;
169  
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 )
175              return false;
176      }
177  
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())
182 +        return true;
183  
184 -    return true;
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
189 +
190 +    if( path.startsWith(mPath) &&
191 +        (
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.
195 +         ))
196 +        return true; // Path of URL starts with cookie-path
197 +
198 +    return false;
199  }
200  
201  // KHttpCookieList
202 @@ -188,9 +223,9 @@
203      int pathLen1 = ((KHttpCookie *)item1)->path().length();
204      int pathLen2 = ((KHttpCookie *)item2)->path().length();
205      if (pathLen1 > pathLen2)
206 -        return 1;
207 -    if (pathLen1 < pathLen2)
208          return -1;
209 +    if (pathLen1 < pathLen2)
210 +        return 1;
211      return 0;
212  }
213  
214 @@ -205,10 +240,18 @@
215  //
216  KCookieJar::KCookieJar()
217  {
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;
226 +
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)
231 +    {
232 +       m_twoLevelTLD.replace(*it, (int *) 1);
233 +    }
234  }
235  
236  //
237 @@ -221,89 +264,184 @@
238      // Not much to do here
239  }
240  
241 +static void removeDuplicateFromList(KHttpCookieList *list, KHttpCookie *cookiePtr, bool nameMatchOnly=false, bool updateWindowId=false)
242 +{
243 +    QString domain1 = cookiePtr->domain();
244 +    if (domain1.isEmpty())
245 +       domain1 = cookiePtr->host();
246 +
247 +    for ( KHttpCookiePtr cookie=list->first(); cookie != 0; )
248 +    {
249 +       QString domain2 = cookie->domain();
250 +       if (domain2.isEmpty())
251 +          domain2 = cookie->host();
252 +
253 +       if (
254 +            (cookiePtr->name() == cookie->name()) &&
255 +            (
256 +              nameMatchOnly ||
257 +              ( (domain1 == domain2) && (cookiePtr->path() == cookie->path()) )
258 +            )
259 +          )
260 +       {
261 +          if (updateWindowId)
262 +          {
263 +            for(QValueList<long>::ConstIterator it = cookie->windowIds().begin();
264 +                it != cookie->windowIds().end(); ++it)
265 +            {
266 +               long windowId = *it;
267 +               if (windowId && (cookiePtr->windowIds().find(windowId) == cookiePtr->windowIds().end()))
268 +               {
269 +                  cookiePtr->windowIds().append(windowId);
270 +               }
271 +            }
272 +          }
273 +          KHttpCookiePtr old_cookie = cookie;
274 +          cookie = list->next();
275 +          list->removeRef( old_cookie );
276 +          break;
277 +       }
278 +       else
279 +       {
280 +          cookie = list->next();
281 +       }
282 +    }
283 +}
284 +
285 +
286  //
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.
290  //
291 -QString KCookieJar::findCookies(const QString &_url, bool useDOMFormat)
292 +QString KCookieJar::findCookies(const QString &_url, bool useDOMFormat, long windowId, KHttpCookieList *pendingCookies)
293  {
294      QString cookieStr;
295      QStringList domains;
296      QString fqdn;
297      QString path;
298      KHttpCookiePtr cookie;
299 -    int protVersion = 1;
300 -    int cookieCount = 0;
301 +    KCookieAdvice advice = m_globalAdvice;
302  
303      if (!parseURL(_url, fqdn, path))
304 -    {
305          return cookieStr;
306 -    }
307 +
308 +    bool secureRequest = (_url.find( L1("https://"), 0, false) == 0 ||
309 +                          _url.find( L1("webdavs://"), 0, false) == 0);
310  
311      extractDomains(fqdn, domains);
312 -    bool secureRequest = (_url.find( "https://", 0, false) == 0);
313 +
314 +    KHttpCookieList allCookies;
315 +
316      for(QStringList::ConstIterator it = domains.begin();
317 -        it != domains.end();
318 +        true;
319          ++it)
320      {
321 -       KHttpCookieList *cookieList = cookieDomains[(*it)]; 
322 +       KHttpCookieList *cookieList;
323 +       if (it == domains.end())
324 +       {
325 +          cookieList = pendingCookies; // Add pending cookies
326 +          pendingCookies = 0;
327 +          if (!cookieList)
328 +             break;
329 +       }
330 +       else
331 +       {
332 +          QString key = (*it).isNull() ? L1("") : (*it);
333 +          cookieList = m_cookieDomains[key];
334 +          if (!cookieList)
335 +             continue; // No cookies for this domain
336 +       }
337  
338 -       if (!cookieList)
339 -          continue; // No cookies for this domain
340 +       if (cookieList->getAdvice() != KCookieDunno)
341 +          advice = cookieList->getAdvice();
342 +
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))
348 +       {
349 +          if (it == domains.end())
350 +             break; // Finished.
351 +          continue;
352 +       }
353  
354         for ( cookie=cookieList->first(); cookie != 0; cookie=cookieList->next() )
355         {
356 -          if (!cookie->match(fqdn, domains, path) && cookie->domain().isEmpty())
357 -          {
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 );
365 -             
366 -             int fqdnCount = domains.count();             
367 -             int cookieDomainCount = cookieDomainList.count();
368 -             
369 -             if ( domains[fqdnCount-2] != cookieDomainList[cookieDomainCount-2] &&
370 -                  domains[fqdnCount-1] != cookieDomainList[cookieDomainCount-1] )
371 -                continue;
372 -          }
373 +          if (!cookie->match(fqdn, domains, path))
374 +             continue;
375  
376            if( cookie->isSecure() && !secureRequest )
377               continue;
378  
379 -          // Use first cookie to determine protocol version
380 -          if (cookieCount == 0)
381 +          if( cookie->isHttpOnly() && useDOMFormat )
382 +             continue;
383 +
384 +          // Do not send expired cookies.
385 +          if ( cookie->isExpired (time(0)) )
386            {
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;
393 +             continue;
394            }
395 -          if (useDOMFormat)
396 +
397 +          if (windowId && (cookie->windowIds().find(windowId) == cookie->windowIds().end()))
398            {
399 -             if (cookieCount > 0)
400 -                cookieStr += "; ";
401 -             cookieStr += cookie->cookieStr(true);
402 +             cookie->windowIds().append(windowId);
403            }
404 -          else if (protVersion == 0)
405 +
406 +          if (it == domains.end()) // Only needed when processing pending cookies
407 +             removeDuplicateFromList(&allCookies, cookie);
408 +
409 +          allCookies.append(cookie);
410 +       }
411 +       if (it == domains.end())
412 +          break; // Finished.
413 +    }
414 +
415 +
416 +    int cookieCount = 0;
417 +
418 +    int protVersion=0;
419 +    for ( cookie=allCookies.first(); cookie != 0; cookie=allCookies.next() )
420 +    {
421 +       if (cookie->protocolVersion() > protVersion)
422 +          protVersion = cookie->protocolVersion();
423 +    }
424 +
425 +    for ( cookie=allCookies.first(); cookie != 0; cookie=allCookies.next() )
426 +    {
427 +       if (useDOMFormat)
428 +       {
429 +          if (cookieCount > 0)
430 +             cookieStr += L1("; ");
431 +          cookieStr += cookie->cookieStr(true);
432 +       }
433 +       else
434 +       {
435 +          if (cookieCount == 0)
436            {
437 -             if (cookieCount == 0)
438 -                cookieStr += "Cookie: ";
439 -             else
440 -                cookieStr += "; ";
441 -             cookieStr += cookie->cookieStr(false);
442 +             cookieStr += L1("Cookie: ");
443 +             if (protVersion > 0)
444 +             {
445 +                QString version;
446 +                version.sprintf("$Version=%d; ", protVersion); // Without quotes
447 +                cookieStr += version;
448 +             }
449            }
450            else
451            {
452 -             if (cookieCount > 0)
453 -                cookieStr += "\r\n";
454 -             cookieStr += "Cookie: ";
455 -             cookieStr += cookie->cookieStr(false);
456 +             cookieStr += L1("; ");
457            }
458 -          cookieCount++;
459 +          cookieStr += cookie->cookieStr(false);
460         }
461 +       cookieCount++;
462      }
463 +
464      return cookieStr;
465  }
466  
467 @@ -323,17 +461,17 @@
468                                    bool keepQuotes=false)
469  {
470      const char *s = header;
471 -
472      // Parse 'my_name' part
473      for(; (*s != '='); s++)
474      {
475          if ((*s=='\0') || (*s==';') || (*s=='\n'))
476          {
477 -            // End of Name
478 -            Value = "";
479 -            Name = header;
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)
484 +            Name = "";
485 +            Value = QString::fromLatin1(header);
486 +            Value.truncate( s - header );
487 +            Value = Value.stripWhiteSpace();
488              return (s);
489          }
490      }
491 @@ -366,12 +504,12 @@
492              if ((*s=='\0') || (*s=='\n'))
493              {
494                  // End of Name
495 -                Value = header;
496 +                Value = QString::fromLatin1(header);
497                  Value.truncate(s - header);
498                  return (s);
499              }
500          }
501 -        Value = header;
502 +        Value = QString::fromLatin1(header);
503          Value.truncate( s - header );
504  
505          // *s == '\"';
506 @@ -390,7 +528,7 @@
507          while ((*s != '\0') && (*s != ';') && (*s != '\n'))
508              s++;
509          // End of Name
510 -        Value = header;
511 +        Value = QString::fromLatin1(header);
512          Value.truncate( s - header );
513          Value = Value.stripWhiteSpace();
514      }
515 @@ -398,14 +536,14 @@
516  
517  }
518  
519 -static void stripDomain(const QString &_fqdn, QString &_domain)
520 +void KCookieJar::stripDomain(const QString &_fqdn, QString &_domain)
521  {
522     QStringList domains;
523 -   KCookieJar::extractDomains(_fqdn, domains);
524 +   extractDomains(_fqdn, domains);
525     _domain = domains[0];
526  }
527  
528 -static QString stripDomain( KHttpCookiePtr cookiePtr)
529 +QString KCookieJar::stripDomain( KHttpCookiePtr cookiePtr)
530  {
531      QString domain; // We file the cookie under this domain.
532      if (cookiePtr->domain().isEmpty())
533 @@ -420,10 +558,18 @@
534                            QString &_path)
535  {
536      KURL kurl(_url);
537 -    if (kurl.isMalformed())
538 +    if (!kurl.isValid())
539         return false;
540  
541      _fqdn = kurl.host().lower();
542 +    if (kurl.port())
543 +    {
544 +       if (((kurl.protocol() == L1("http")) && (kurl.port() != 80)) ||
545 +           ((kurl.protocol() == L1("https")) && (kurl.port() != 443)))
546 +       {
547 +          _fqdn = L1("%1:%2").arg(kurl.port()).arg(_fqdn);
548 +       }
549 +    }
550  
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 @@
554  
555      _path = kurl.path();
556      if (_path.isEmpty())
557 -       _path = "/";
558 +       _path = L1("/");
559 +
560 +    QRegExp exp(L1("[\\\\/]\\.\\.[\\\\/]"));
561 +    // Weird path, cookie stealing attempt?
562 +    if (_path.find(exp) != -1) {
563 +       return false; // Deny everything!!
564 +    }
565 +
566      return true;
567  }
568  
569  void KCookieJar::extractDomains(const QString &_fqdn,
570                                  QStringList &_domains)
571  {
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] == '[')
576      {
577         _domains.append( _fqdn );
578         return;
579      }
580 +    // Return numeric IPv4 addresses as is...
581 +    if ((_fqdn[0] >= '0') && (_fqdn[0] <= '9'))
582 +    {
583 +       bool allNumeric = true;
584 +       for(int i = _fqdn.length(); i--;)
585 +       {
586 +          if (!strchr("0123456789:.", _fqdn[i].latin1()))
587 +          {
588 +             allNumeric = false;
589 +             break;
590 +          }
591 +       }
592 +       if (allNumeric)
593 +       {
594 +          _domains.append( _fqdn );
595 +          return;
596 +       }
597 +    }
598  
599      QStringList partList = QStringList::split('.', _fqdn, false);
600  
601 @@ -458,29 +629,36 @@
602      {
603         if (partList.count() == 1)
604           break; // We only have a TLD left.
605 -       if (partList.count() == 2)
606 +
607 +       if ((partList.count() == 2) && (m_twoLevelTLD[partList[1].lower()]))
608 +       {
609 +          // This domain uses two-level TLDs in the form xxxx.yy
610 +          break;
611 +       }
612 +
613 +       if ((partList.count() == 2) && (partList[1].length() == 2))
614         {
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.
621 +
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"))
626 +              break;
627         }
628 -       QString domain = partList.join(".");
629 -       _domains.append("." + domain);
630 +
631 +       QString domain = partList.join(L1("."));
632 +       _domains.append('.' + domain);
633         _domains.append(domain);
634         partList.remove(partList.begin()); // Remove part
635      }
636  
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 );
643 -
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 );
648  }
649  
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.
653  //
654 -KHttpCookiePtr KCookieJar::makeCookies(const QString &_url,
655 +KHttpCookieList KCookieJar::makeCookies(const QString &_url,
656                                         const QCString &cookie_headers,
657                                         long windowId)
658  {
659 -    KHttpCookiePtr cookieChain = 0;
660 +    KHttpCookieList cookieList;
661 +    KHttpCookieList cookieList2;
662      KHttpCookiePtr lastCookie = 0;
663      const char *cookieStr = cookie_headers.data();
664      QString Name;
665      QString Value;
666      QString fqdn;
667      QString path;
668 +    bool crossDomain = false;
669  
670      if (!parseURL(_url, fqdn, path))
671      {
672          // Error parsing _url
673 -        return 0;
674 +        return KHttpCookieList();
675      }
676 +    QString defaultPath;
677 +    int i = path.findRev('/');
678 +    if (i > 0)
679 +       defaultPath = path.left(i);
680  
681      //  The hard stuff :)
682      for(;;)
683      {
684          // check for "Set-Cookie"
685 -        if (strncasecmp(cookieStr, "Set-Cookie:", 11) == 0)
686 +        if (strncmp(cookieStr, "Cross-Domain\n", 13) == 0)
687 +        {
688 +            cookieStr += 13;
689 +            crossDomain = true;
690 +        }
691 +        else if (strncasecmp(cookieStr, "Set-Cookie:", 11) == 0)
692          {
693              cookieStr = parseNameValue(cookieStr+11, Name, Value, true);
694  
695 -            if (Name.isEmpty())
696 -                continue;
697 -
698              // Host = FQDN
699              // Default domain = ""
700 -            // Default path = ""
701 -            KHttpCookie *cookie = new KHttpCookie(fqdn, "", "", Name, Value);
702 -            cookie->mWindowId = windowId;
703 +            // Default path according to rfc2109
704 +
705 +            KHttpCookie *cookie = new KHttpCookie(fqdn, L1(""), defaultPath, Name, Value);
706 +            if (windowId)
707 +               cookie->mWindowIds.append(windowId);
708 +            cookie->mCrossDomain = crossDomain;
709  
710              // Insert cookie in chain
711 -            if (lastCookie)
712 -               lastCookie->nextCookie = cookie;
713 -            else
714 -               cookieChain = cookie;
715 +            cookieList.append(cookie);
716              lastCookie = cookie;
717          }
718 -        else if (lastCookie && (strncasecmp(cookieStr, "Set-Cookie2:", 12) == 0))
719 +        else if (strncasecmp(cookieStr, "Set-Cookie2:", 12) == 0)
720          {
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!
724 -            cookieStr +=12;
725 -            // Continue with lastCookie
726 +            // Attempt to follow rfc2965
727 +            cookieStr = parseNameValue(cookieStr+12, Name, Value, true);
728 +
729 +            // Host = FQDN
730 +            // Default domain = ""
731 +            // Default path according to rfc2965
732 +
733 +            KHttpCookie *cookie = new KHttpCookie(fqdn, L1(""), defaultPath, Name, Value);
734 +            if (windowId)
735 +               cookie->mWindowIds.append(windowId);
736 +            cookie->mCrossDomain = crossDomain;
737 +
738 +            // Insert cookie in chain
739 +            cookieList2.append(cookie);
740 +            lastCookie = cookie;
741          }
742          else
743          {
744 @@ -564,13 +760,12 @@
745              // Name-Value pair follows
746              cookieStr = parseNameValue(cookieStr, Name, Value);
747  
748 -            Name = Name.lower();
749 -
750 -            if (Name == "domain")
751 +            QCString cName = Name.lower().latin1();
752 +            if (cName == "domain")
753              {
754                  lastCookie->mDomain = Value.lower();
755              }
756 -            else if (Name == "max-age")
757 +            else if (cName == "max-age")
758              {
759                  int max_age = Value.toInt();
760                  if (max_age == 0)
761 @@ -578,23 +773,33 @@
762                  else
763                      lastCookie->mExpireDate = time(0)+max_age;
764              }
765 -            else if (Name == "expires")
766 +            else if (cName == "expires")
767              {
768                  // Parse brain-dead netscape cookie-format
769                  lastCookie->mExpireDate = KRFCDate::parseDate(Value);
770              }
771 -            else if (Name == "path")
772 +            else if (cName == "path")
773              {
774 -                lastCookie->mPath = Value;
775 +                if (Value.isEmpty())
776 +                   lastCookie->mPath = QString::null; // Catch "" <> QString::null
777 +                else
778 +                   lastCookie->mPath = KURL::decode_string(Value);
779 +                lastCookie->mExplicitPath = true;
780              }
781 -            else if (Name == "version")
782 +            else if (cName == "version")
783              {
784                  lastCookie->mProtocolVersion = Value.toInt();
785              }
786 -            else if (Name == "secure")
787 +            else if ((cName == "secure") ||
788 +                     (cName.isEmpty() && Value.lower() == L1("secure")))
789              {
790                  lastCookie->mSecure = true;
791              }
792 +            else if ((cName == "httponly") ||
793 +                     (cName.isEmpty() && Value.lower() == L1("httponly")))
794 +            {
795 +                lastCookie->mHttpOnly = true;
796 +            }
797          }
798  
799          if (*cookieStr == '\0')
800 @@ -604,7 +809,14 @@
801          cookieStr++;
802      }
803  
804 -    return cookieChain;
805 +    // RFC2965 cookies come last so that they override netscape cookies.
806 +    while( !cookieList2.isEmpty() && (lastCookie = cookieList2.take(0)) )
807 +    {
808 +       removeDuplicateFromList(&cookieList, lastCookie, true);
809 +       cookieList.append(lastCookie);
810 +    }
811 +
812 +    return cookieList;
813  }
814  
815  /**
816 @@ -613,12 +825,12 @@
817  * pairs. Any whitespace before "name" or around '=' is discarded.
818  * If no cookies are found, 0 is returned.
819  */
820 -KHttpCookiePtr KCookieJar::makeDOMCookies(const QString &_url,
821 +KHttpCookieList KCookieJar::makeDOMCookies(const QString &_url,
822                                            const QCString &cookie_domstring,
823                                            long windowId)
824  {
825      // A lot copied from above
826 -    KHttpCookiePtr cookieChain = 0;
827 +    KHttpCookieList cookieList;
828      KHttpCookiePtr lastCookie = 0;
829  
830      const char *cookieStr = cookie_domstring.data();
831 @@ -630,7 +842,7 @@
832      if (!parseURL(_url, fqdn, path))
833      {
834          // Error parsing _url
835 -        return 0;
836 +        return KHttpCookieList();
837      }
838  
839      //  This time it's easy
840 @@ -638,35 +850,25 @@
841      {
842          cookieStr = parseNameValue(cookieStr, Name, Value);
843  
844 -        if (Name.isEmpty()) {
845 -            if (*cookieStr != '\0')
846 -                cookieStr++;         // Skip ';' or '\n'
847 -
848 -            continue;
849 -        }
850 -
851          // Host = FQDN
852          // Default domain = ""
853          // Default path = ""
854          KHttpCookie *cookie = new KHttpCookie(fqdn, QString::null, QString::null,
855                                  Name, Value );
856 -        cookie->mWindowId = windowId;
857 -
858 -        // Insert cookie in chain
859 -        if (lastCookie)
860 -            lastCookie->nextCookie = cookie;
861 -        else
862 -            cookieChain = cookie;
863 +        if (windowId)
864 +            cookie->mWindowIds.append(windowId);
865  
866 +        cookieList.append(cookie);
867          lastCookie = cookie;
868  
869          if (*cookieStr != '\0')
870              cookieStr++;         // Skip ';' or '\n'
871       }
872  
873 -     return cookieChain;
874 +     return cookieList;
875  }
876  
877 +
878  //
879  // This function hands a KHttpCookie object over to the cookie jar.
880  //
881 @@ -674,7 +876,6 @@
882  //
883  void KCookieJar::addCookie(KHttpCookiePtr &cookiePtr)
884  {
885 -    QString domain;
886      QStringList domains;
887      KHttpCookieList *cookieList = 0L;
888  
889 @@ -686,42 +887,31 @@
890            (it != domains.end() && !cookieList);
891            ++it )
892      {
893 -        KHttpCookieList *list= cookieDomains[(*it)];
894 +        QString key = (*it).isNull() ? L1("") : (*it);
895 +        KHttpCookieList *list= m_cookieDomains[key];
896          if ( !list ) continue;
897  
898 -        for ( KHttpCookiePtr cookie=list->first(); cookie != 0; )
899 -        {
900 -            if ( cookiePtr->name() == cookie->name() &&
901 -                 cookie->match(cookiePtr->host(),domains,cookiePtr->path()) )
902 -            {
903 -                KHttpCookiePtr old_cookie = cookie;
904 -                cookie = list->next();
905 -                list->removeRef( old_cookie );
906 -                break;
907 -            }
908 -            else
909 -            {
910 -                cookie = list->next();
911 -            }
912 -        }
913 +        removeDuplicateFromList(list, cookiePtr, false, true);
914      }
915  
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 ];
921      if (!cookieList)
922      {
923          // Make a new cookie list
924          cookieList = new KHttpCookieList();
925 +        cookieList->setAutoDelete(true);
926  
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 );
931  
932 -        cookieDomains.insert( domain, cookieList);
933 +        m_cookieDomains.insert( domain, cookieList);
934  
935          // Update the list of domains
936 -        domainList.append(domain);
937 +        m_domainList.append(domain);
938      }
939  
940      // Add the cookie to the cookie list
941 @@ -729,7 +919,7 @@
942      if (!cookiePtr->isExpired(time(0)))
943      {
944          cookieList->inSort( cookiePtr );
945 -        cookiesChanged = true;
946 +        m_cookiesChanged = true;
947      }
948      else
949      {
950 @@ -745,12 +935,20 @@
951  KCookieAdvice KCookieJar::cookieAdvice(KHttpCookiePtr cookiePtr)
952  {
953      QStringList domains;
954 +
955 +    if (m_rejectCrossDomainCookies && cookiePtr->isCrossDomain())
956 +       return KCookieReject;
957 +
958 +    if (m_autoAcceptSessionCookies && (cookiePtr->expireDate() == 0 ||
959 +        m_ignoreCookieExpirationDate))
960 +       return KCookieAccept;
961 +
962      extractDomains(cookiePtr->host(), domains);
963 -    bool isEmptyDomain = cookiePtr->domain().isEmpty();
964  
965 -    if (!isEmptyDomain )
966 +    // If the cookie specifies a domain, check whether it is valid and
967 +    // correct otherwise.
968 +    if (!cookiePtr->domain().isEmpty())
969      {
970 -       // Cookie specifies a domain. Check whether it is valid.
971         bool valid = false;
972  
973         // This checks whether the cookie is valid based on
974 @@ -764,42 +962,34 @@
975         if (!valid)
976         {
977            // Maybe the domain doesn't start with a "."
978 -          QString domain = "."+cookiePtr->domain();
979 +          QString domain = '.' + cookiePtr->domain();
980            if (domains.contains(domain))
981               valid = true;
982         }
983  
984         if (!valid)
985         {
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;
990         }
991      }
992  
993 -    // For empty domain use the FQDN to find a
994 -    // matching advice for the pending cookie.
995 -    QString domain;
996 -    if ( isEmptyDomain )
997 -       domain = domains[0];
998 -    else
999 -       domain = cookiePtr->domain();
1000 +    KCookieAdvice advice = KCookieDunno;
1001  
1002 -    KHttpCookieList *cookieList = cookieDomains[domain];
1003 -    KCookieAdvice advice;
1004 -    if (cookieList)
1005 -    {
1006 -        advice = cookieList->getAdvice();
1007 -        if (advice == KCookieDunno)
1008 -        {
1009 -           advice = globalAdvice;
1010 -        }
1011 -    }
1012 -    else
1013 +    QStringList::Iterator it = domains.fromLast(); // Start with FQDN which is last in the list.
1014 +    while( (advice == KCookieDunno) && (it != domains.end()))
1015      {
1016 -        advice = globalAdvice;
1017 +       QString domain = *it;
1018 +       // Check if a policy for the FQDN/domain is set.
1019 +       KHttpCookieList *cookieList = m_cookieDomains[domain];
1020 +       if (cookieList)
1021 +          advice = cookieList->getAdvice();
1022 +       domains.remove(it);
1023 +       it = domains.begin(); // Continue from begin of remaining list
1024      }
1025 +
1026 +    if (advice == KCookieDunno)
1027 +        advice = m_globalAdvice;
1028 +
1029      return advice;
1030  }
1031  
1032 @@ -809,7 +999,7 @@
1033  //
1034  KCookieAdvice KCookieJar::getDomainAdvice(const QString &_domain)
1035  {
1036 -    KHttpCookieList *cookieList = cookieDomains[_domain];
1037 +    KHttpCookieList *cookieList = m_cookieDomains[_domain];
1038      KCookieAdvice advice;
1039  
1040      if (cookieList)
1041 @@ -831,13 +1021,13 @@
1042  void KCookieJar::setDomainAdvice(const QString &_domain, KCookieAdvice _advice)
1043  {
1044      QString domain(_domain);
1045 -    KHttpCookieList *cookieList = cookieDomains[domain];
1046 +    KHttpCookieList *cookieList = m_cookieDomains[domain];
1047  
1048      if (cookieList)
1049      {
1050 -        if (cookieList->getAdvice() != _advice);
1051 +        if (cookieList->getAdvice() != _advice)
1052          {
1053 -           configChanged = true;
1054 +           m_configChanged = true;
1055             // domain is already known
1056             cookieList->setAdvice( _advice);
1057          }
1058 @@ -846,8 +1036,8 @@
1059              (_advice == KCookieDunno))
1060          {
1061              // This deletes cookieList!
1062 -            cookieDomains.remove(domain);                      
1063 -            domainList.remove(domain);
1064 +            m_cookieDomains.remove(domain);
1065 +            m_domainList.remove(domain);
1066          }
1067      }
1068      else
1069 @@ -856,13 +1046,14 @@
1070          if (_advice != KCookieDunno)
1071          {
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);
1084          }
1085      }
1086  }
1087 @@ -883,9 +1074,9 @@
1088  //
1089  void KCookieJar::setGlobalAdvice(KCookieAdvice _advice)
1090  {
1091 -    if (globalAdvice != _advice)
1092 -       configChanged = true;
1093 -    globalAdvice = _advice;
1094 +    if (m_globalAdvice != _advice)
1095 +       m_configChanged = true;
1096 +    m_globalAdvice = _advice;
1097  }
1098  
1099  //
1100 @@ -893,7 +1084,7 @@
1101  //
1102  const QStringList& KCookieJar::getDomainList()
1103  {
1104 -    return domainList;
1105 +    return m_domainList;
1106  }
1107  
1108  //
1109 @@ -909,7 +1100,7 @@
1110      else
1111          domain = _domain;
1112  
1113 -    return cookieDomains[domain];
1114 +    return m_cookieDomains[domain];
1115  }
1116  
1117  //
1118 @@ -919,86 +1110,97 @@
1119  void KCookieJar::eatCookie(KHttpCookiePtr cookiePtr)
1120  {
1121      QString domain = stripDomain(cookiePtr); // We file the cookie under this domain.
1122 -    KHttpCookieList *cookieList = cookieDomains[domain];
1123 +    KHttpCookieList *cookieList = m_cookieDomains[domain];
1124  
1125      if (cookieList)
1126      {
1127          // This deletes cookiePtr!
1128          if (cookieList->removeRef( cookiePtr ))
1129 -           cookiesChanged = true;
1130 +           m_cookiesChanged = true;
1131  
1132          if ((cookieList->isEmpty()) &&
1133              (cookieList->getAdvice() == KCookieDunno))
1134          {
1135              // This deletes cookieList!
1136 -            cookieDomains.remove(domain);
1137 +            m_cookieDomains.remove(domain);
1138  
1139 -            domainList.remove(domain);
1140 +            m_domainList.remove(domain);
1141          }
1142      }
1143  }
1144  
1145  void KCookieJar::eatCookiesForDomain(const QString &domain)
1146  {
1147 -   KHttpCookieList *cookieList = cookieDomains[domain];
1148 +   KHttpCookieList *cookieList = m_cookieDomains[domain];
1149     if (!cookieList || cookieList->isEmpty()) return;
1150  
1151     cookieList->clear();
1152     if (cookieList->getAdvice() == KCookieDunno)
1153     {
1154         // This deletes cookieList!
1155 -       cookieDomains.remove(domain);
1156 -       domainList.remove(domain);
1157 +       m_cookieDomains.remove(domain);
1158 +       m_domainList.remove(domain);
1159     }
1160 -   cookiesChanged = true;
1161 +   m_cookiesChanged = true;
1162  }
1163  
1164 -void KCookieJar::eatSessionCookies( int winId )
1165 +void KCookieJar::eatSessionCookies( long windowId )
1166  {
1167 -    QStringList::Iterator it=domainList.begin();
1168 -    for ( ; it != domainList.end(); ++it )
1169 -        eatSessionCookies( *it, winId, false );
1170 +    if (!windowId)
1171 +        return;
1172 +
1173 +    QStringList::Iterator it=m_domainList.begin();
1174 +    for ( ; it != m_domainList.end(); ++it )
1175 +        eatSessionCookies( *it, windowId, false );
1176  }
1177  
1178 -void KCookieJar::eatSessionCookies( const QString& fqdn, int winId,
1179 +void KCookieJar::eatAllCookies()
1180 +{
1181 +    for ( QStringList::Iterator it=m_domainList.begin();
1182 +          it != m_domainList.end();)
1183 +    {
1184 +        QString domain = *it++;
1185 +        // This might remove domain from domainList!
1186 +        eatCookiesForDomain(domain);
1187 +    }
1188 +}
1189 +
1190 +void KCookieJar::eatSessionCookies( const QString& fqdn, long windowId,
1191                                      bool isFQDN )
1192  {
1193      KHttpCookieList* cookieList;
1194 -    if ( isFQDN )
1195 +    if ( !isFQDN )
1196 +        cookieList = m_cookieDomains[fqdn];
1197 +    else
1198      {
1199          QString domain;
1200          stripDomain( fqdn, domain );
1201 -        cookieList = cookieDomains[domain];
1202 +        cookieList = m_cookieDomains[domain];
1203      }
1204 -    else
1205 -        cookieList = cookieDomains[fqdn];
1206  
1207      if ( cookieList )
1208      {
1209          KHttpCookiePtr cookie=cookieList->first();
1210          for (; cookie != 0;)
1211          {
1212 -            if (cookie->windowId() == winId &&
1213 -                (cookie->expireDate() == 0))
1214 +            if ((cookie->expireDate() != 0) && !m_ignoreCookieExpirationDate)
1215              {
1216 -                KHttpCookiePtr old_cookie = cookie;
1217 -                cookie = cookieList->next();
1218 -                cookieList->removeRef( old_cookie );
1219 +               cookie = cookieList->next();
1220 +               continue;
1221              }
1222 -            else
1223 -                cookie = cookieList->next();
1224 -        }
1225 -    }
1226 -}
1227 -
1228  
1229 -void KCookieJar::eatAllCookies()
1230 -{
1231 -    for ( QStringList::Iterator it=domainList.begin();
1232 -          it != domainList.end();)
1233 -    {
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())
1240 +            {
1241 +               cookie = cookieList->next();
1242 +               continue;
1243 +            }
1244 +            KHttpCookiePtr old_cookie = cookie;
1245 +            cookie = cookieList->next();
1246 +            cookieList->removeRef( old_cookie );
1247 +        }
1248      }
1249  }
1250  
1251 @@ -1008,7 +1210,7 @@
1252  // On failure 'false' is returned.
1253  bool KCookieJar::saveCookies(const QString &_filename)
1254  {
1255 -    KSaveFile saveFile(_filename);
1256 +    KSaveFile saveFile(_filename, 0600);
1257  
1258      if (saveFile.status() != 0)
1259         return false;
1260 @@ -1017,31 +1219,31 @@
1261  
1262      time_t curTime = time(0);
1263  
1264 -    fprintf(fStream, "# KDE Cookie File\n#\n");
1265 +    fprintf(fStream, "# KDE Cookie File v2\n#\n");
1266  
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");
1272  
1273 -    for ( QStringList::Iterator it=domainList.begin();
1274 -         it != domainList.end();
1275 -         it++)
1276 +    for ( QStringList::Iterator it=m_domainList.begin(); it != m_domainList.end();
1277 +          it++ )
1278      {
1279          const QString &domain = *it;
1280          bool domainPrinted = false;
1281  
1282 -       KHttpCookieList *cookieList = cookieDomains[domain];
1283 +        KHttpCookieList *cookieList = m_cookieDomains[domain];
1284          KHttpCookiePtr cookie=cookieList->first();
1285  
1286 -       for (; cookie != 0;)
1287 +        for (; cookie != 0;)
1288          {
1289              if (cookie->isExpired(curTime))
1290 -           {
1291 -               // Delete expired cookies
1292 +            {
1293 +                // Delete expired cookies
1294                  KHttpCookiePtr old_cookie = cookie;
1295                  cookie = cookieList->next();
1296                  cookieList->removeRef( old_cookie );
1297 -           }
1298 -           else if (cookie->expireDate() != 0)
1299 +            }
1300 +            else if (cookie->expireDate() != 0 && !m_ignoreCookieExpirationDate)
1301              {
1302                  if (!domainPrinted)
1303                  {
1304 @@ -1049,25 +1251,26 @@
1305                      fprintf(fStream, "[%s]\n", domain.local8Bit().data());
1306                  }
1307                  // Store persistent cookies
1308 -                QString path("\"");
1309 +                QString path = L1("\"");
1310                  path += cookie->path();
1311 -                path += "\"";
1312 -                QString domain("\"");
1313 +                path += '"';
1314 +                QString domain = L1("\"");
1315                  domain += cookie->domain();
1316 -                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();
1323 -           }
1324 -           else
1325 -           {
1326 -               // Skip session-only cookies
1327 -               cookie = cookieList->next();
1328 -           }
1329 -       }
1330 +                domain += '"';
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();
1338 +            }
1339 +            else
1340 +            {
1341 +                // Skip session-only cookies
1342 +                cookie = cookieList->next();
1343 +            }
1344 +        }
1345      }
1346  
1347      return saveFile.close();
1348 @@ -1080,26 +1283,27 @@
1349      char *result;
1350      if (!keepQuotes && (*buffer == '\"'))
1351      {
1352 -       // Find terminating "
1353 +        // Find terminating "
1354          buffer++;
1355          result = buffer;
1356          while((*buffer != '\"') && (*buffer))
1357 -           buffer++;
1358 +            buffer++;
1359      }
1360      else
1361      {
1362          // Find first white space
1363          result = buffer;
1364          while((*buffer != ' ') && (*buffer != '\t') && (*buffer != '\n') && (*buffer))
1365 -           buffer++;
1366 +            buffer++;
1367      }
1368 +
1369      if (!*buffer)
1370 -       return result; //
1371 +        return result; //
1372      *buffer++ = '\0';
1373  
1374      // Skip white-space
1375      while((*buffer == ' ') || (*buffer == '\t') || (*buffer == '\n'))
1376 -       buffer++;
1377 +        buffer++;
1378  
1379      return result;
1380  }
1381 @@ -1124,7 +1328,18 @@
1382      bool err = false;
1383      err = (fgets(buffer, READ_BUFFER_SIZE, fStream) == 0);
1384  
1385 -    err = err || (strcmp(buffer, "# KDE Cookie File\n") != 0);
1386 +    int version = 1;
1387 +    if (!err)
1388 +    {
1389 +        if (strcmp(buffer, "# KDE Cookie File\n") == 0)
1390 +        {
1391 +          // version 1
1392 +        }
1393 +        else if (sscanf(buffer, "# KDE Cookie File v%d\n", &version) != 1)
1394 +        {
1395 +          err = true;
1396 +        }
1397 +    }
1398  
1399      if (!err)
1400      {
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))
1411              {
1412 -                protVer -= 100;
1413 -                keepQuotes = true;
1414 +                if (protVer >= 200)
1415 +                    protVer -= 200;
1416 +                int i = atoi( parseField(line) );
1417 +                secure = i & 1;
1418 +                httpOnly = i & 2;
1419 +                explicitPath = i & 4;
1420 +                line[strlen(line)-1] = '\0'; // Strip LF.
1421 +                value = line;
1422 +            }
1423 +            else
1424 +            {
1425 +                if (protVer >= 100)
1426 +                {
1427 +                    protVer -= 100;
1428 +                    keepQuotes = true;
1429 +                }
1430 +                value = parseField(line, keepQuotes);
1431 +                secure = atoi( parseField(line) );
1432              }
1433 -            const char *value( parseField(line, keepQuotes) );
1434 -            bool secure = atoi( parseField(line) );
1435  
1436              // Parse error
1437              if (!value) continue;
1438 @@ -1161,15 +1394,18 @@
1439              if ((expDate == 0) || (expDate < curTime))
1440                  continue;
1441  
1442 -            KHttpCookie *cookie = new KHttpCookie(host, domain, path, name,
1443 -                                                  value, expDate, protVer,
1444 -                                                  secure);
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),
1452 +                                                  expDate, protVer,
1453 +                                                  secure, httpOnly, explicitPath);
1454 +            addCookie(cookie);
1455          }
1456      }
1457      delete [] buffer;
1458 -    cookiesChanged = false;
1459 +    m_cookiesChanged = false;
1460  
1461      fclose( fStream);
1462      return err;
1463 @@ -1181,19 +1417,18 @@
1464  
1465  void KCookieJar::saveConfig(KConfig *_config)
1466  {
1467 -    if (!configChanged)
1468 +    if (!m_configChanged)
1469          return;
1470  
1471 -    _config->setGroup(QString::null);
1472 -    _config->writeEntry("DefaultRadioButton", defaultRadioButton);
1473 -    _config->writeEntry("ShowCookieDetails", showCookieDetails );
1474 -
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));
1482  
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();
1488            it++ )
1489      {
1490           const QString &domain = *it;
1491 @@ -1208,6 +1443,7 @@
1492      }
1493      _config->writeEntry("CookieDomainAdvice", domainSettings);
1494      _config->sync();
1495 +    m_configChanged = false;
1496  }
1497  
1498  
1499 @@ -1217,23 +1453,23 @@
1500  
1501  void KCookieJar::loadConfig(KConfig *_config, bool reparse )
1502  {
1503 -    QString value;
1504 -    QStringList domainSettings;
1505 -
1506      if ( reparse )
1507          _config->reparseConfiguration();
1508  
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 );
1515  
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);
1526  
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(); )
1530      {
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);
1535      }
1536  
1537 -    // Now apply the
1538 +    // Now apply the domain settings read from config file...
1539      for ( QStringList::Iterator it=domainSettings.begin();
1540            it != domainSettings.end(); )
1541      {
1542          const QString &value = *it++;
1543 +
1544          int sepPos = value.find(':');
1545 -        if (sepPos <= 0) { continue; }
1546 +
1547 +        if (sepPos <= 0)
1548 +          continue;
1549 +
1550          QString domain(value.left(sepPos));
1551          KCookieAdvice advice = strToAdvice( value.mid(sepPos + 1) );
1552          setDomainAdvice(domain, advice);
1553      }
1554  }
1555 -
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
1558 @@ -20,7 +20,7 @@
1559  //----------------------------------------------------------------------------
1560  //
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 $
1564  
1565  #ifndef KCOOKIEJAR_H
1566  #define KCOOKIEJAR_H
1567 @@ -59,10 +59,12 @@
1568      QString mValue;
1569      time_t  mExpireDate;
1570      int     mProtocolVersion;
1571 -    long    mWindowId;
1572      bool    mSecure;
1573 +    bool    mCrossDomain;
1574 +    bool    mHttpOnly;
1575 +    bool    mExplicitPath;
1576 +    QValueList<long> mWindowIds;
1577  
1578 -    KHttpCookiePtr nextCookie;
1579      QString cookieStr(bool useDOMFormat);
1580  
1581  public:
1582 @@ -73,28 +75,32 @@
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);
1590  
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; }
1608  };
1609  
1610  class KHttpCookieList : public QList<KHttpCookie>
1611  {
1612  public:
1613      KHttpCookieList() : QList<KHttpCookie>(), advice( KCookieDunno )
1614 -    { setAutoDelete(true); }
1615 +    { }
1616      virtual ~KHttpCookieList() { }
1617  
1618      virtual int compareItems( void * item1, void * item2);
1619 @@ -125,7 +131,7 @@
1620      /**
1621       * Returns whether the cookiejar has been changed
1622       */
1623 -    bool changed() { return cookiesChanged || configChanged; }
1624 +    bool changed() const { return m_cookiesChanged || m_configChanged; }
1625  
1626      /**
1627       * Store all the cookies in a safe(?) place
1628 @@ -154,8 +160,11 @@
1629       *
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
1634 +     * none the less.
1635       */
1636 -    QString findCookies(const QString &_url, bool useDOMFormat);
1637 +    QString findCookies(const QString &_url, bool useDOMFormat, long windowId, KHttpCookieList *pendingCookies=0);
1638  
1639      /**
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.
1644       */
1645 -    KHttpCookiePtr makeCookies(const QString &_url, const QCString &cookie_headers, long windowId);
1646 +    KHttpCookieList makeCookies(const QString &_url, const QCString &cookie_headers, long windowId);
1647  
1648      /**
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.
1652       *
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 ';'.
1656       */
1657 -    KHttpCookiePtr makeDOMCookies(const QString &_url, const QCString &cookie_domstr, long windowId);
1658 +    KHttpCookieList makeDOMCookies(const QString &_url, const QCString &cookie_domstr, long windowId);
1659  
1660      /**
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.
1665       */
1666 -    void eatSessionCookies( int windId );
1667 +    void eatSessionCookies( long windowId );
1668  
1669      /**
1670       * Removes all end of session cookies set by the
1671       * session @p windId.
1672       */
1673 -    void eatSessionCookies( const QString& fqdn, int windId, bool isFQDN = true );
1674 +    void eatSessionCookies( const QString& fqdn, long windowId, bool isFQDN = true );
1675  
1676      /**
1677       * Parses _url and returns the FQDN (_fqdn) and path (_path).
1678 @@ -297,21 +306,46 @@
1679      /**
1680       * Returns a list of domains (_domainList) relevant for this host.
1681       */
1682 -    static void extractDomains(const QString &_fqdn,
1683 -                               QStringList &_domainList);
1684 +    void extractDomains(const QString &_fqdn,
1685 +                        QStringList &_domainList);
1686  
1687      static QString adviceToStr(KCookieAdvice _advice);
1688      static KCookieAdvice strToAdvice(const QString &_str);
1689  
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; }
1695 +
1696 +    /** Returns the */
1697 +    bool showCookieDetails () const { return m_showCookieDetails; }
1698 +
1699 +     /**
1700 +      * Sets the user's default preference cookie policy.
1701 +      */
1702 +     void setPreferredDefaultPolicy (int value) { m_preferredPolicy = value; }
1703 +
1704 +     /**
1705 +      * Sets the user's preference of level of detail displayed
1706 +      * by the cookie dialog.
1707 +      */
1708 +     void setShowCookieDetails (bool value) { m_showCookieDetails = value; }
1709  
1710  protected:
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);
1718 +
1719 +protected:
1720 +    QStringList m_domainList;
1721 +    KCookieAdvice m_globalAdvice;
1722 +    QDict<KHttpCookieList> m_cookieDomains;
1723 +    QDict<int> m_twoLevelTLD;
1724 +
1725 +    bool m_configChanged;
1726 +    bool m_cookiesChanged;
1727 +    bool m_showCookieDetails;
1728 +    bool m_rejectCrossDomainCookies;
1729 +    bool m_autoAcceptSessionCookies;
1730 +    bool m_ignoreCookieExpirationDate;
1731 +
1732 +    int m_preferredPolicy;
1733  };
1734  #endif
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
1737 @@ -23,25 +23,30 @@
1738  //----------------------------------------------------------------------------
1739  //
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 $
1743  
1744  #define SAVE_DELAY 3 // Save after 3 minutes
1745  
1746 -#include "kcookieserver.h"
1747 -#include "kcookiejar.h"
1748 -#include "kcookiewin.h"
1749 +#include <unistd.h>
1750  
1751 -#include <kdebug.h>
1752 -#include <kapp.h>
1753 -#include <kcmdlineargs.h>
1754 -#include <kstddirs.h>
1755  #include <qtimer.h>
1756 -#include <unistd.h>
1757  #include <qlist.h>
1758  #include <qfile.h>
1759  
1760  #include <dcopclient.h>
1761 +
1762  #include <kconfig.h>
1763 +#include <kdebug.h>
1764 +#include <kcmdlineargs.h>
1765 +#include <kstddirs.h>
1766 +
1767 +#ifdef _QT_QPE_
1768 +#include <qpe/qpeapplication.h>
1769 +#endif
1770 +
1771 +#include "kcookiejar.h"
1772 +#include "kcookiewin.h"
1773 +#include "kcookieserver.h"
1774  
1775  // Cookie field indexes
1776  enum CookieDetails { CF_DOMAIN=0, CF_PATH, CF_NAME, CF_HOST,
1777 @@ -53,6 +58,7 @@
1778     DCOPClientTransaction *transaction;
1779     QString url;
1780     bool DOM;
1781 +   long windowId;
1782  };
1783  
1784  template class  QList<CookieRequest>;
1785 @@ -68,10 +74,11 @@
1786  {
1787     mCookieJar = new KCookieJar;
1788     mPendingCookies = new KHttpCookieList;
1789 +   mPendingCookies->setAutoDelete(true);
1790     mRequestList = new RequestList;
1791     mAdvicePending = false;
1792     mTimer = 0;
1793 -   mCookieJar->loadConfig( kapp->config());
1794 +   mCookieJar->loadConfig( kapp->config() );
1795  
1796     QString filename = locateLocal("appdata", "cookies");
1797  
1798 @@ -89,12 +96,16 @@
1799     {
1800        mCookieJar->loadCookies( filename);
1801     }
1802 +
1803 +   QWidget *wid = qApp->desktop();
1804 +   mBigScreen = (wid->width() > 320 || wid->height() > 320);
1805  }
1806  
1807  KCookieServer::~KCookieServer()
1808  {
1809     if (mCookieJar->changed())
1810        slotSave();
1811 +
1812     delete mCookieJar;
1813     delete mTimer;
1814     delete mPendingCookies;
1815 @@ -125,7 +136,7 @@
1816     return 0;
1817  }
1818  
1819 -bool KCookieServer::cookiesPending( const QString &url )
1820 +bool KCookieServer::cookiesPending( const QString &url, KHttpCookieList *cookieList )
1821  {
1822    QString fqdn;
1823    QStringList domains;
1824 @@ -136,109 +147,161 @@
1825    if (!KCookieJar::parseURL(url, fqdn, path))
1826       return false;
1827  
1828 -  KCookieJar::extractDomains( fqdn, domains );
1829 +  mCookieJar->extractDomains( fqdn, domains );
1830    for( KHttpCookie *cookie = mPendingCookies->first();
1831         cookie != 0L;
1832         cookie = mPendingCookies->next())
1833    {
1834         if (cookie->match( fqdn, domains, path))
1835 -          return true;
1836 +       {
1837 +          if (!cookieList)
1838 +             return true;
1839 +          cookieList->append(cookie);
1840 +       }
1841    }
1842 -  return false;
1843 +  if (!cookieList)
1844 +     return false;
1845 +  return cookieList->isEmpty();
1846  }
1847  
1848  void KCookieServer::addCookies( const QString &url, const QCString &cookieHeader,
1849                                 long windowId, bool useDOMFormat )
1850  {
1851 -    KHttpCookiePtr cookie = 0;
1852 +    KHttpCookieList cookieList;
1853      if (useDOMFormat)
1854 -       cookie = mCookieJar->makeDOMCookies(url, cookieHeader, windowId);
1855 +       cookieList = mCookieJar->makeDOMCookies(url, cookieHeader, windowId);
1856      else
1857 -       cookie = mCookieJar->makeCookies(url, cookieHeader, windowId);
1858 +       cookieList = mCookieJar->makeCookies(url, cookieHeader, windowId);
1859  
1860 -    if (mAdvicePending)
1861 -    {
1862 -       checkCookies(cookie, true);
1863 -    }
1864 -    else
1865 +    checkCookies(&cookieList);
1866 +
1867 +    for(KHttpCookiePtr cookie = cookieList.first(); cookie; cookie = cookieList.first())
1868 +       mPendingCookies->append(cookieList.take());
1869 +
1870 +    if (!mAdvicePending)
1871      {
1872         mAdvicePending = true;
1873 -       do {
1874 -          checkCookies(cookie, false);
1875 -          cookie = mPendingCookies->count() ? mPendingCookies->take(0) : 0;
1876 +       while (!mPendingCookies->isEmpty())
1877 +       {
1878 +          checkCookies(0);
1879         }
1880 -       while (cookie);
1881         mAdvicePending = false;
1882      }
1883 -
1884  }
1885  
1886 -void KCookieServer::checkCookies( KHttpCookie *cookie, bool queue )
1887 +void KCookieServer::checkCookies( KHttpCookieList *cookieList)
1888  {
1889 -    QString host;
1890 -    KCookieAdvice userAdvice = KCookieDunno;
1891 -    if (cookie) host = cookie->host();
1892 +    KHttpCookieList *list;
1893 +
1894 +    if (cookieList)
1895 +       list = cookieList;
1896 +    else
1897 +       list = mPendingCookies;
1898 +
1899 +    KHttpCookiePtr cookie = list->first();
1900      while (cookie)
1901      {
1902 -        KHttpCookiePtr next_cookie = cookie->next();
1903          KCookieAdvice advice = mCookieJar->cookieAdvice(cookie);
1904 -        if ((advice == KCookieAsk) || (advice == KCookieDunno))
1905 -        {
1906 -            // We only ask the user once, even if we get multiple
1907 -            // cookies from the same site.
1908 -            if (userAdvice == KCookieDunno)
1909 -            {
1910 -                if (queue)
1911 -                {
1912 -                    mPendingCookies->append(cookie);
1913 -                    return;
1914 -                }
1915 -                else
1916 -                {
1917 -                    mPendingCookies->prepend(cookie);
1918 -                    KCookieWin *kw = new KCookieWin( 0L, cookie,
1919 -                                                     mCookieJar->defaultRadioButton,
1920 -                                                     mCookieJar->showCookieDetails );
1921 -                    userAdvice = kw->advice(mCookieJar, cookie);
1922 -                    delete kw;
1923 -                    mPendingCookies->take(0);
1924 -                    // Save the cookie config if it has changed
1925 -                    mCookieJar->saveConfig( kapp->config() );
1926 -                }
1927 -            }
1928 -            advice = userAdvice;
1929 -        }
1930          switch(advice)
1931          {
1932          case KCookieAccept:
1933 +            list->take();
1934              mCookieJar->addCookie(cookie);
1935 +            cookie = list->current();
1936              break;
1937  
1938          case KCookieReject:
1939 -        default:
1940 +            list->take();
1941              delete cookie;
1942 +            cookie = list->current();
1943 +            break;
1944 +
1945 +        default:
1946 +            cookie = list->next();
1947              break;
1948          }
1949 -        cookie = next_cookie;
1950 -        if (!cookie && !queue)
1951 +    }
1952 +
1953 +    if (cookieList || list->isEmpty())
1954 +       return;
1955 +
1956 +    KHttpCookiePtr currentCookie = mPendingCookies->first();
1957 +
1958 +    KHttpCookieList currentList;
1959 +    currentList.append(currentCookie);
1960 +    QString currentHost = currentCookie->host();
1961 +
1962 +    cookie = mPendingCookies->next();
1963 +    while (cookie)
1964 +    {
1965 +        if (cookie->host() == currentHost)
1966          {
1967 -           // Check if there are cookies on the pending list from the
1968 -           // same host.
1969 -           for( cookie = mPendingCookies->first();
1970 -                cookie;
1971 -                cookie = mPendingCookies->next())
1972 -           {
1973 -               if (cookie->host() == host)
1974 -                  break;
1975 -           }
1976 -           if (cookie)
1977 +            currentList.append(cookie);
1978 +        }
1979 +        cookie = mPendingCookies->next();
1980 +    }
1981 +
1982 +    KCookieWin *kw;
1983 +    KScrolledCookieWin *skw= 0L;
1984 +
1985 +    if(!mBigScreen) {
1986 +        qWarning( "Using Scrolled Cookie WIn" );
1987 +        skw = new KScrolledCookieWin(0L, currentList,
1988 +                                     mCookieJar->preferredDefaultPolicy(),
1989 +                                     mCookieJar->showCookieDetails() );
1990 +        kw = skw->cookieWindow();
1991 +    }else
1992 +       kw = new KCookieWin( 0L, currentList,
1993 +                             mCookieJar->preferredDefaultPolicy(),
1994 +                             mCookieJar->showCookieDetails() );
1995 +
1996 +#ifdef _QT_QPE_
1997 +    int result = QPEApplication::execDialog( !mBigScreen ?
1998 +                                             static_cast<QDialog*>( skw ) :
1999 +                                             static_cast<QDialog*>( kw  ) );
2000 +#else
2001 +    int result = !mBigScreen ? skw->exec() : kw->exec();
2002 +#endif
2003 +
2004 +    KCookieAdvice userAdvice = kw->advice( result, mCookieJar, currentCookie);
2005 +    delete kw;
2006 +    delete skw;
2007 +    // Save the cookie config if it has changed
2008 +    mCookieJar->saveConfig( kapp->config() );
2009 +
2010 +    // Apply the user's choice to all cookies that are currently
2011 +    // queued for this host.
2012 +    cookie = mPendingCookies->first();
2013 +    while (cookie)
2014 +    {
2015 +        if (cookie->host() == currentHost)
2016 +        {
2017 +           switch(userAdvice)
2018             {
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();
2025 +               break;
2026 +
2027 +           case KCookieReject:
2028 +               mPendingCookies->take();
2029 +               delete cookie;
2030 +               cookie = mPendingCookies->current();
2031 +               break;
2032 +
2033 +           default:
2034 +               cookie = mPendingCookies->next();
2035 +               break;
2036             }
2037          }
2038 +        else
2039 +        {
2040 +            cookie = mPendingCookies->next();
2041 +        }
2042      }
2043  
2044 +
2045      // Check if we can handle any request
2046      for ( CookieRequest *request = mRequestList->first(); request;)
2047      {
2048 @@ -246,13 +309,13 @@
2049          {
2050             QCString replyType;
2051             QByteArray replyData;
2052 -           QString res = mCookieJar->findCookies( request->url, request->DOM );
2053 +           QString res = mCookieJar->findCookies( request->url, request->DOM, request->windowId );
2054  
2055             QDataStream stream2(replyData, IO_WriteOnly);
2056             stream2 << res;
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 );
2064 @@ -271,7 +334,7 @@
2065  {
2066     delete mTimer;
2067     mTimer = 0;
2068 -   QString filename = locateLocal("appdata", "cookies");
2069 +   QString filename = locateLocal("data", "kcookiejar/cookies");
2070     mCookieJar->saveCookies(filename);
2071  }
2072  
2073 @@ -333,8 +396,9 @@
2074          return
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)));
2082      }
2083      return false;
2084  }
2085 @@ -343,16 +407,30 @@
2086  QString
2087  KCookieServer::findCookies(QString url)
2088  {
2089 +  return findCookies(url, 0);
2090 +}
2091 +
2092 +// DCOP function
2093 +QString
2094 +KCookieServer::findCookies(QString url, long windowId)
2095 +{
2096     if (cookiesPending(url))
2097     {
2098        CookieRequest *request = new CookieRequest;
2099        request->transaction = dcopClient()->beginTransaction();
2100        request->url = url;
2101        request->DOM = false;
2102 +      request->windowId = windowId;
2103        mRequestList->append( request );
2104        return QString::null; // Talk to you later :-)
2105     }
2106 -   return mCookieJar->findCookies(url, false);
2107 +
2108 +   QString cookies = mCookieJar->findCookies(url, false, windowId);
2109 +
2110 +   if (mCookieJar->changed() && !mTimer)
2111 +      saveCookieJar();
2112 +
2113 +   return cookies;
2114  }
2115  
2116  // DCOP function
2117 @@ -409,16 +487,20 @@
2118  QString
2119  KCookieServer::findDOMCookies(QString url)
2120  {
2121 -   if (cookiesPending(url))
2122 -   {
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 :-)
2129 -   }
2130 -   return mCookieJar->findCookies(url, true);
2131 +   return findDOMCookies(url, 0);
2132 +}
2133 +
2134 +// DCOP function
2135 +QString
2136 +KCookieServer::findDOMCookies(QString url, long windowId)
2137 +{
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);
2143 +
2144 +   return mCookieJar->findCookies(url, true, windowId, &pendingCookies);
2145  }
2146  
2147  // DCOP function
2148 @@ -459,18 +541,27 @@
2149        saveCookieJar();
2150  }
2151  
2152 +
2153 +// Qt function
2154  void
2155 -KCookieServer::deleteSessionCookies( long winId )
2156 +KCookieServer::slotDeleteSessionCookies( long windowId )
2157  {
2158 -  mCookieJar->eatSessionCookies( winId );
2159 +   deleteSessionCookies(windowId);
2160 +}
2161 +
2162 +// DCOP function
2163 +void
2164 +KCookieServer::deleteSessionCookies( long windowId )
2165 +{
2166 +  mCookieJar->eatSessionCookies( windowId );
2167    if(!mTimer)
2168      saveCookieJar();
2169  }
2170  
2171  void
2172 -KCookieServer::deleteSessionCookiesFor(QString fqdn, long winId)
2173 +KCookieServer::deleteSessionCookiesFor(QString fqdn, long windowId)
2174  {
2175 -  mCookieJar->eatSessionCookies( fqdn, winId );
2176 +  mCookieJar->eatSessionCookies( fqdn, windowId );
2177    if(!mTimer)
2178      saveCookieJar();
2179  }
2180 @@ -500,7 +591,7 @@
2181     if (KCookieJar::parseURL(url, fqdn, dummy))
2182     {
2183        QStringList domains;
2184 -      KCookieJar::extractDomains(fqdn, domains);
2185 +      mCookieJar->extractDomains(fqdn, domains);
2186        mCookieJar->setDomainAdvice(domains[0],
2187                                    KCookieJar::strToAdvice(advice));
2188     }
2189 @@ -516,7 +607,7 @@
2190     if (KCookieJar::parseURL(url, fqdn, dummy))
2191     {
2192        QStringList domains;
2193 -      KCookieJar::extractDomains(fqdn, domains);
2194 +      mCookieJar->extractDomains(fqdn, domains);
2195        advice = mCookieJar->getDomainAdvice(domains[0]);
2196     }
2197     return KCookieJar::adviceToStr(advice);
2198 @@ -533,7 +624,7 @@
2199  void
2200  KCookieServer::shutdown()
2201  {
2202 -   quit();
2203 +    quit();
2204  }
2205  
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
2209 @@ -20,7 +20,7 @@
2210  //----------------------------------------------------------------------------
2211  //
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 $
2215  
2216  #ifndef KCOOKIESERVER_H
2217  #define KCOOKIESERVER_H
2218 @@ -33,6 +33,7 @@
2219  class KHttpCookie;
2220  class QTimer;
2221  class RequestList;
2222 +class KConfig;
2223  
2224  class KCookieServer : public KUniqueApplication
2225  {
2226 @@ -46,9 +47,11 @@
2227  
2228  k_dcop:
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);
2238 @@ -62,13 +65,14 @@
2239    void shutdown();
2240  
2241  public:
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);
2248  
2249  public slots:
2250    void slotSave();
2251 +  void slotDeleteSessionCookies(long);
2252  
2253  protected:
2254    KCookieJar *mCookieJar;
2255 @@ -82,6 +86,7 @@
2256    bool cookieMatches(KHttpCookie*, QString, QString, QString, QString);
2257    void putCookie(QStringList&, KHttpCookie*, const QValueList<int>&);
2258    void saveCookieJar();
2259 +  bool mBigScreen : 1;
2260  };
2261  
2262  #endif
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
2265 @@ -1,8 +1,8 @@
2266  /*
2267  This file is part of KDE
2268  
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>
2273  
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
2276 @@ -24,7 +24,7 @@
2277  //----------------------------------------------------------------------------
2278  //
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 $
2282  
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
2285 @@ -54,66 +54,77 @@
2286  #include <qpushbutton.h>
2287  #include <qradiobutton.h>
2288  #include <qvbuttongroup.h>
2289 +#include <qscrollview.h>
2290 +
2291 +#ifndef QT_NO_TOOLTIP
2292 +#include <qtooltip.h>
2293 +#endif
2294 +
2295 +#ifndef QT_NO_WHATSTHIS
2296 +#include <qwhatsthis.h>
2297 +#endif
2298  
2299 -#include <kapp.h>
2300  #include <kwin.h>
2301  #include <klocale.h>
2302  #include <kglobal.h>
2303  #include <kurllabel.h>
2304 +#include <qlineedit.h>
2305  #include <kiconloader.h>
2306  
2307 +#ifndef Q_WS_QWS //FIXME(E): Implement for Qt Embedded
2308 +#include <X11/Xlib.h>
2309 +#endif
2310 +
2311  #include "kcookiejar.h"
2312  #include "kcookiewin.h"
2313  
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 )
2320  {
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") );
2326 -
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());
2330 +#endif
2331      // Main widget's layout manager...
2332      QVBoxLayout* vlayout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
2333 -    vlayout->setResizeMode( QLayout::Fixed );
2334  
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() );
2343  
2344 -    int count = 0;
2345 -    KHttpCookie* nextCookie = cookie;
2346 -    while ( nextCookie )
2347 -    {
2348 -        count++;
2349 -        nextCookie = nextCookie->next();
2350 -    }
2351 +    int count = cookieList.count();
2352  
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 );
2370  
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();
2377  
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 );
2382  
2383      txt = (count == 1)? i18n("&Only this cookie") : i18n("&Only these cookies");
2384 @@ -128,7 +139,7 @@
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>.") );
2392  #endif
2393 @@ -146,35 +157,42 @@
2394      if ( defaultButton > -1 && defaultButton < 3 )
2395          m_btnGrp->setButton( defaultButton );
2396      else
2397 -        m_btnGrp->setButton( 0 );
2398 +        m_btnGrp->setButton( 1 );
2399  
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()) );
2408 +    btn->setFocus();
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 );
2421  #ifndef QT_NO_ACCEL
2422      QAccel* a = new QAccel( this );
2423      a->connectItem( a->insertItem(Qt::Key_Escape), btn, SLOT(animateClick()) );
2424  #endif
2425 -    
2426  
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") );
2434  #endif
2435 +
2436 +
2437      vlayout->addWidget( bbox );
2438 -    setFixedSize( sizeHint() );
2439 +
2440 +    if ( !parent ) {
2441 +        vlayout->setResizeMode( QLayout::Fixed );
2442 +        setFixedSize( sizeHint() );
2443 +    }
2444  }
2445  
2446  KCookieWin::~KCookieWin()
2447 @@ -201,13 +219,16 @@
2448      }
2449  }
2450  
2451 -KCookieAdvice KCookieWin::advice( KCookieJar *cookiejar, KHttpCookie* cookie )
2452 +KCookieAdvice KCookieWin::advice( int result, KCookieJar *cookiejar, KHttpCookie* cookie )
2453  {
2454 -    int result = exec();
2455 +    cookiejar->setShowCookieDetails ( m_showDetails );
2456 +
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 )
2461 +
2462 +    int preferredPolicy = m_btnGrp->id( m_btnGrp->selected() );
2463 +    cookiejar->setPreferredDefaultPolicy( preferredPolicy );
2464 +
2465 +    switch ( preferredPolicy )
2466      {
2467          case 2:
2468              cookiejar->setGlobalAdvice( advice );
2469 @@ -222,11 +243,11 @@
2470      return advice;
2471  }
2472  
2473 -KCookieDetail::KCookieDetail( KHttpCookie* cookie, int cookieCount,
2474 +KCookieDetail::KCookieDetail( KHttpCookieList cookieList, int cookieCount,
2475                                QWidget* parent, const char* name )
2476                :QGroupBox( parent, name )
2477  {
2478 -    setTitle( i18n("Cookie details") );
2479 +    setTitle( i18n("Cookie Details") );
2480      QGridLayout* grid = new QGridLayout( this, 9, 2,
2481                                           KDialog::spacingHint(),
2482                                           KDialog::marginHint() );
2483 @@ -237,8 +258,7 @@
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 );
2491  
2492      //Add the value
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);
2501  
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) );
2510 -    else
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);
2515  
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);
2524  
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);
2534  
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 );
2544  
2545      if ( cookieCount > 1 )
2546 @@ -298,8 +307,9 @@
2547          QToolTip::add( btnNext, i18n("Show details of the next cookie") );
2548  #endif
2549      }
2550 -    m_cookie = cookie;
2551 -    m_cookie_orig = cookie;
2552 +    m_cookieList = cookieList;
2553 +    m_cookie = 0;
2554 +    slotNextCookie();
2555  }
2556  
2557  KCookieDetail::~KCookieDetail()
2558 @@ -308,9 +318,19 @@
2559  
2560  void KCookieDetail::slotNextCookie()
2561  {
2562 -    m_cookie = m_cookie->next();
2563 -    if ( !m_cookie )
2564 -        m_cookie = m_cookie_orig;
2565 +    KHttpCookiePtr cookie = m_cookieList.first();
2566 +    if (m_cookie) while(cookie)
2567 +    {
2568 +       if (cookie == m_cookie)
2569 +       {
2570 +          cookie = m_cookieList.next();
2571 +          break;
2572 +       }
2573 +       cookie = m_cookieList.next();
2574 +    }
2575 +    m_cookie = cookie;
2576 +    if (!m_cookie)
2577 +        m_cookie = m_cookieList.first();
2578  
2579      if ( m_cookie )
2580      {
2581 @@ -326,9 +346,52 @@
2582          if ( m_cookie->expireDate() )
2583            m_expires->setText( KGlobal::locale()->formatDateTime(cookiedate) );
2584          else
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") );
2588 +        QString sec;
2589 +        if (m_cookie->isSecure())
2590 +        {
2591 +          if (m_cookie->isHttpOnly())
2592 +            sec = i18n("Secure servers only");
2593 +          else
2594 +            sec = i18n("Secure servers, page scripts");
2595 +        }
2596 +        else
2597 +        {
2598 +          if (m_cookie->isHttpOnly())
2599 +            sec = i18n("Servers");
2600 +          else
2601 +            sec = i18n("Servers, page scripts");
2602 +        }
2603 +        m_secure->setText( sec );
2604      }
2605  }
2606  
2607 +
2608 +////////////
2609 +/// The Adapter
2610 +///
2611 +///////////
2612 +KScrolledCookieWin::KScrolledCookieWin( QWidget *parent, KHttpCookieList cookieList,
2613 +                                        int defaultButton, bool showDetails )
2614 +    : KDialog( parent, "scrolled_cookiealert", true )
2615 +{
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 );
2621 +
2622 +    view->setResizePolicy( QScrollView::AutoOneFit );
2623 +    view->setFrameShape( QFrame::NoFrame );
2624 +    view->addChild( m_cookieWin );
2625 +
2626 +    layout->addWidget( view );
2627 +}
2628 +
2629 +KCookieWin* KScrolledCookieWin::cookieWindow()const
2630 +{
2631 +    return m_cookieWin;
2632 +}
2633 +
2634 +
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
2638 @@ -1,8 +1,8 @@
2639  /*
2640      This file is part of the KDE File Manager
2641  
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)
2646  
2647      This library is free software; you can redistribute it and/or
2648      modify it under the terms of the GNU General Public License
2649 @@ -22,7 +22,7 @@
2650  //----------------------------------------------------------------------------
2651  //
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 $
2655  
2656  #ifndef _KCOOKIEWIN_H_
2657  #define _KCOOKIEWIN_H_
2658 @@ -42,7 +42,7 @@
2659      Q_OBJECT
2660  
2661  public :
2662 -    KCookieDetail( KHttpCookie* cookie, int cookieCount, QWidget *parent=0,
2663 +    KCookieDetail( KHttpCookieList cookieList, int cookieCount, QWidget *parent=0,
2664                     const char *name=0 );
2665      ~KCookieDetail();
2666  
2667 @@ -54,8 +54,8 @@
2668      QLineEdit*   m_path;
2669      QLineEdit*   m_secure;
2670  
2671 -    KHttpCookie* m_cookie;
2672 -    KHttpCookie* m_cookie_orig;
2673 +    KHttpCookieList m_cookieList;
2674 +    KHttpCookiePtr m_cookie;
2675  
2676  private slots:
2677      void slotNextCookie();
2678 @@ -66,11 +66,11 @@
2679      Q_OBJECT
2680  
2681  public :
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 );
2686      ~KCookieWin();
2687  
2688 -    KCookieAdvice advice( KCookieJar *cookiejar, KHttpCookie* cookie );
2689 +    KCookieAdvice advice( int result, KCookieJar *cookiejar, KHttpCookie* cookie );
2690  
2691  private :
2692      QPushButton*   m_button;
2693 @@ -81,4 +81,21 @@
2694  private slots:
2695      void slotCookieDetails();
2696  };
2697 +
2698 +/**
2699 + * A small Scrolled Adapter for KCookieWin
2700 + * to be used on big screen
2701 + */
2702 +class KScrolledCookieWin : public KDialog
2703 +{
2704 +    Q_OBJECT
2705 +
2706 +public:
2707 +    KScrolledCookieWin( QWidget *parent, KHttpCookieList cookieList, int defaultButton=0,
2708 +               bool showDetails=false );
2709 +    KCookieWin* cookieWindow()const;
2710 +
2711 +private:
2712 +    KCookieWin *m_cookieWin;
2713 +};
2714  #endif
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
2717 @@ -6,18 +6,20 @@
2718  **
2719  *****************************************************************************/
2720  
2721 -#include "./kcookieserver.h"
2722 +#include "kcookieserver.h"
2723  
2724  #include <kdatastream.h>
2725  #include <qasciidict.h>
2726  
2727  
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)" },
2741 @@ -50,12 +52,22 @@
2742         QDataStream _replyStream( replyData, IO_WriteOnly );
2743         _replyStream << findCookies(arg0 );
2744      } break;
2745 -    case 1: { // QStringList findDomains()
2746 +    case 1: { // QString findCookies(QString,long int)
2747 +       QString arg0;
2748 +       long int arg1;
2749 +       QDataStream arg( data, IO_ReadOnly );
2750 +       arg >> arg0;
2751 +       arg >> arg1;
2752         replyType = KCookieServer_ftable[1][0]; 
2753         QDataStream _replyStream( replyData, IO_WriteOnly );
2754 +       _replyStream << findCookies(arg0, arg1 );
2755 +    } break;
2756 +    case 2: { // QStringList findDomains()
2757 +       replyType = KCookieServer_ftable[2][0]; 
2758 +       QDataStream _replyStream( replyData, IO_WriteOnly );
2759         _replyStream << findDomains( );
2760      } break;
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;
2764         QString arg1;
2765         QString arg2;
2766 @@ -67,19 +79,29 @@
2767         arg >> arg2;
2768         arg >> arg3;
2769         arg >> arg4;
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 );
2774      } break;
2775 -    case 3: { // QString findDOMCookies(QString)
2776 +    case 4: { // QString findDOMCookies(QString)
2777         QString arg0;
2778         QDataStream arg( data, IO_ReadOnly );
2779         arg >> arg0;
2780 -       replyType = KCookieServer_ftable[3][0]; 
2781 +       replyType = KCookieServer_ftable[4][0]; 
2782         QDataStream _replyStream( replyData, IO_WriteOnly );
2783         _replyStream << findDOMCookies(arg0 );
2784      } break;
2785 -    case 4: { // void addCookies(QString,QCString,long int)
2786 +    case 5: { // QString findDOMCookies(QString,long int)
2787 +       QString arg0;
2788 +       long int arg1;
2789 +       QDataStream arg( data, IO_ReadOnly );
2790 +       arg >> arg0;
2791 +       arg >> arg1;
2792 +       replyType = KCookieServer_ftable[5][0]; 
2793 +       QDataStream _replyStream( replyData, IO_WriteOnly );
2794 +       _replyStream << findDOMCookies(arg0, arg1 );
2795 +    } break;
2796 +    case 6: { // void addCookies(QString,QCString,long int)
2797         QString arg0;
2798         QCString arg1;
2799         long int arg2;
2800 @@ -87,10 +109,10 @@
2801         arg >> arg0;
2802         arg >> arg1;
2803         arg >> arg2;
2804 -       replyType = KCookieServer_ftable[4][0]; 
2805 +       replyType = KCookieServer_ftable[6][0]; 
2806         addCookies(arg0, arg1, arg2 );
2807      } break;
2808 -    case 5: { // void deleteCookie(QString,QString,QString,QString)
2809 +    case 7: { // void deleteCookie(QString,QString,QString,QString)
2810         QString arg0;
2811         QString arg1;
2812         QString arg2;
2813 @@ -100,37 +122,37 @@
2814         arg >> arg1;
2815         arg >> arg2;
2816         arg >> arg3;
2817 -       replyType = KCookieServer_ftable[5][0]; 
2818 +       replyType = KCookieServer_ftable[7][0]; 
2819         deleteCookie(arg0, arg1, arg2, arg3 );
2820      } break;
2821 -    case 6: { // void deleteCookiesFromDomain(QString)
2822 +    case 8: { // void deleteCookiesFromDomain(QString)
2823         QString arg0;
2824         QDataStream arg( data, IO_ReadOnly );
2825         arg >> arg0;
2826 -       replyType = KCookieServer_ftable[6][0]; 
2827 +       replyType = KCookieServer_ftable[8][0]; 
2828         deleteCookiesFromDomain(arg0 );
2829      } break;
2830 -    case 7: { // void deleteSessionCookies(long int)
2831 +    case 9: { // void deleteSessionCookies(long int)
2832         long int arg0;
2833         QDataStream arg( data, IO_ReadOnly );
2834         arg >> arg0;
2835 -       replyType = KCookieServer_ftable[7][0]; 
2836 +       replyType = KCookieServer_ftable[9][0]; 
2837         deleteSessionCookies(arg0 );
2838      } break;
2839 -    case 8: { // void deleteSessionCookiesFor(QString,long int)
2840 +    case 10: { // void deleteSessionCookiesFor(QString,long int)
2841         QString arg0;
2842         long int arg1;
2843         QDataStream arg( data, IO_ReadOnly );
2844         arg >> arg0;
2845         arg >> arg1;
2846 -       replyType = KCookieServer_ftable[8][0]; 
2847 +       replyType = KCookieServer_ftable[10][0]; 
2848         deleteSessionCookiesFor(arg0, arg1 );
2849      } break;
2850 -    case 9: { // void deleteAllCookies()
2851 -       replyType = KCookieServer_ftable[9][0]; 
2852 +    case 11: { // void deleteAllCookies()
2853 +       replyType = KCookieServer_ftable[11][0]; 
2854         deleteAllCookies( );
2855      } break;
2856 -    case 10: { // void addDOMCookies(QString,QCString,long int)
2857 +    case 12: { // void addDOMCookies(QString,QCString,long int)
2858         QString arg0;
2859         QCString arg1;
2860         long int arg2;
2861 @@ -138,38 +160,38 @@
2862         arg >> arg0;
2863         arg >> arg1;
2864         arg >> arg2;
2865 -       replyType = KCookieServer_ftable[10][0]; 
2866 +       replyType = KCookieServer_ftable[12][0]; 
2867         addDOMCookies(arg0, arg1, arg2 );
2868      } break;
2869 -    case 11: { // void setDomainAdvice(QString,QString)
2870 +    case 13: { // void setDomainAdvice(QString,QString)
2871         QString arg0;
2872         QString arg1;
2873         QDataStream arg( data, IO_ReadOnly );
2874         arg >> arg0;
2875         arg >> arg1;
2876 -       replyType = KCookieServer_ftable[11][0]; 
2877 +       replyType = KCookieServer_ftable[13][0]; 
2878         setDomainAdvice(arg0, arg1 );
2879      } break;
2880 -    case 12: { // QString getDomainAdvice(QString)
2881 +    case 14: { // QString getDomainAdvice(QString)
2882         QString arg0;
2883         QDataStream arg( data, IO_ReadOnly );
2884         arg >> arg0;
2885 -       replyType = KCookieServer_ftable[12][0]; 
2886 +       replyType = KCookieServer_ftable[14][0]; 
2887         QDataStream _replyStream( replyData, IO_WriteOnly );
2888         _replyStream << getDomainAdvice(arg0 );
2889      } break;
2890 -    case 13: { // void reloadPolicy()
2891 -       replyType = KCookieServer_ftable[13][0]; 
2892 +    case 15: { // void reloadPolicy()
2893 +       replyType = KCookieServer_ftable[15][0]; 
2894         reloadPolicy( );
2895      } break;
2896 -    case 14: { // void shutdown()
2897 -       replyType = KCookieServer_ftable[14][0]; 
2898 +    case 16: { // void shutdown()
2899 +       replyType = KCookieServer_ftable[16][0]; 
2900         shutdown( );
2901      } break;
2902      default: 
2903         return KUniqueApplication::process( fun, data, replyType, replyData );
2904      }
2905 -    return TRUE;
2906 +    return true;
2907  }
2908  
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
2912 @@ -200,9 +200,9 @@
2913      kdDebug(7103) << "(" << getpid() << ") Proxy URL is now: " << m_proxyURL.url() << endl;
2914    }
2915  
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");
2924