~ubuntu-branches/debian/sid/kdelibs/sid

« back to all changes in this revision

Viewing changes to kioslave/http/kcookiejar/kcookieserver.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-10-09 09:37:39 UTC
  • Revision ID: james.westby@ubuntu.com-20071009093739-rnmkeaxkf30pazqg
Tags: upstream-3.5.8
ImportĀ upstreamĀ versionĀ 3.5.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
//----------------------------------------------------------------------------
24
24
//
25
25
// KDE Cookie Server
26
 
// $Id: kcookieserver.cpp 393950 2005-02-28 23:13:52Z waba $
 
26
// $Id: kcookieserver.cpp 707375 2007-09-01 17:19:13Z adawit $
27
27
 
28
28
#define SAVE_DELAY 3 // Save after 3 minutes
29
29
 
86
86
   mPendingCookies->setAutoDelete(true);
87
87
   mRequestList = new RequestList;
88
88
   mAdvicePending = false;
89
 
   mTimer = 0;
 
89
   mTimer = new QTimer();
 
90
   connect( mTimer, SIGNAL( timeout()), SLOT( slotSave()));
90
91
   mConfig = new KConfig("kcookiejarrc");
91
92
   mCookieJar->loadConfig( mConfig );
92
93
 
186
187
    KHttpCookiePtr cookie = list->first();
187
188
    while (cookie)
188
189
    {
 
190
        kdDebug(7104) << "checkCookies: Asking cookie advice for " << cookie->host() << endl;
189
191
        KCookieAdvice advice = mCookieJar->cookieAdvice(cookie);
190
192
        switch(advice)
191
193
        {
256
258
               break;
257
259
 
258
260
           default:
259
 
               qWarning(__FILE__":%d Problen!", __LINE__);
 
261
               qWarning(__FILE__":%d Problem!", __LINE__);
260
262
               cookie = mPendingCookies->next();
261
263
               break;
262
264
           }
292
294
          request = mRequestList->next();
293
295
        }
294
296
    }
295
 
    if (mCookieJar->changed() && !mTimer)
 
297
    if (mCookieJar->changed())
296
298
        saveCookieJar();
297
299
}
298
300
 
299
301
void KCookieServer::slotSave()
300
302
{
301
 
   delete mTimer;
302
 
   mTimer = 0;
303
303
   QString filename = locateLocal("data", "kcookiejar/cookies");
304
304
   mCookieJar->saveCookies(filename);
305
305
}
306
306
 
307
307
void KCookieServer::saveCookieJar()
308
308
{
309
 
    if( mTimer )
 
309
    if( mTimer->isActive() )
310
310
        return;
311
311
 
312
 
    mTimer = new QTimer();
313
 
    connect( mTimer, SIGNAL( timeout()), SLOT( slotSave()));
314
 
    mTimer->start( 1000*60*SAVE_DELAY );
 
312
    mTimer->start( 1000*60*SAVE_DELAY, true );
315
313
}
316
314
 
317
315
void KCookieServer::putCookie( QStringList& out, KHttpCookie *cookie,
391
389
      mRequestList->append( request );
392
390
      return QString::null; // Talk to you later :-)
393
391
   }
394
 
   
 
392
 
395
393
   QString cookies = mCookieJar->findCookies(url, false, windowId);
396
 
   
397
 
   if (mCookieJar->changed() && !mTimer)
 
394
 
 
395
   if (mCookieJar->changed())
398
396
      saveCookieJar();
399
 
   
 
397
 
400
398
   return cookies;
401
399
}
402
400
 
491
489
         if( cookieMatches(it.current(), domain, fqdn, path, name) )
492
490
         {
493
491
            mCookieJar->eatCookie( it.current() );
494
 
            if (!mTimer)
495
 
               saveCookieJar();
 
492
            saveCookieJar();
496
493
            break;
497
494
         }
498
495
      }
504
501
KCookieServer::deleteCookiesFromDomain(QString domain)
505
502
{
506
503
   mCookieJar->eatCookiesForDomain(domain);
507
 
   if (!mTimer)
508
 
      saveCookieJar();
 
504
   saveCookieJar();
509
505
}
510
506
 
511
507
 
521
517
KCookieServer::deleteSessionCookies( long windowId )
522
518
{
523
519
  mCookieJar->eatSessionCookies( windowId );
524
 
  if(!mTimer)
525
 
    saveCookieJar();
 
520
  saveCookieJar();
526
521
}
527
522
 
528
523
void
529
524
KCookieServer::deleteSessionCookiesFor(QString fqdn, long windowId)
530
525
{
531
526
  mCookieJar->eatSessionCookies( fqdn, windowId );
532
 
  if(!mTimer)
533
 
    saveCookieJar();
 
527
  saveCookieJar();
534
528
}
535
529
 
536
530
// DCOP function
538
532
KCookieServer::deleteAllCookies()
539
533
{
540
534
   mCookieJar->eatAllCookies();
541
 
   if (!mTimer)
542
 
      saveCookieJar();
 
535
   saveCookieJar();
543
536
}
544
537
 
545
538
// DCOP function