23 #include <tqptrlist.h>
26 #include <kstaticdeleter.h>
30 #include "ksslconfig_win.h"
32 #include "ksslconfig.h"
35 #include "ksslcsessioncache.h"
53 #define MAX_ENTRIES 32
57 typedef TQPair<TQString,TQString> KSSLCSession;
58 typedef TQPtrList<KSSLCSession> KSSLCSessions;
60 static KSSLCSessions *sessions = 0L;
61 static KStaticDeleter<KSSLCSessions> med;
64 static TQString URLtoKey(
const KURL &kurl) {
65 return kurl.host() +
":" + kurl.protocol() +
":" + TQString::number(kurl.port());
70 KSSLCSessions *ses =
new KSSLCSessions;
71 ses->setAutoDelete(
true);
72 med.setObject(sessions, ses);
77 TQString KSSLCSessionCache::getSessionForURL(
const KURL &kurl) {
79 if (!sessions)
return TQString::null;
80 TQString key = URLtoKey(kurl);
82 for(KSSLCSession *it = sessions->first(); it; it=sessions->next()) {
83 if (it->first == key) {
85 sessions->prepend(it);
92 kdDebug(7029) <<
"Negative caching " <<key <<endl;
93 if (sessions->count() >= MAX_ENTRIES) sessions->removeLast();
94 sessions->prepend(
new KSSLCSession(key, TQString::null));
98 return TQString::null;
102 void KSSLCSessionCache::putSessionForURL(
const KURL &kurl,
const TQString &session) {
104 if (!sessions) setup();
105 TQString key = URLtoKey(kurl);
108 for(it = sessions->first(); it && it->first != key; it=sessions->next());
112 it->second = session;
114 it =
new KSSLCSession(key, session);
115 if (sessions->count() >= MAX_ENTRIES) sessions->removeLast();
118 sessions->prepend(it);