[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdebase/kioslave/imap4
From:       Carsten Burghardt <cb () magic-shop ! de>
Date:       2004-04-08 13:56:28
Message-ID: 20040408135628.B993E99E8 () office ! kde ! org
[Download RAW message or body]

CVS commit by burghard: 

Do not fire a LIST command for every single box. Speeds up folder listing a lot.
The hierarchy delimiter gets cached because this is the only information listDir really needs
from the server. The type of the box is not interesting in this case.


  M +47 -32    imap4.cc   1.152
  M +2 -1      imap4.h   1.43


--- kdebase/kioslave/imap4/imap4.cc  #1.151:1.152
@@ -136,4 +136,5 @@ IMAP4Protocol::IMAP4Protocol (const QCSt
   cacheOutput = false;
   mTimeOfLastNoop = QDateTime();
+  mHierarchyDelim.clear();
 }
 
@@ -328,5 +329,5 @@ void
 IMAP4Protocol::listDir (const KURL & _url)
 {
-  kdDebug(7116) << "IMAP4::listDir - " << _url.prettyURL() << endl;
+  kdDebug(7116) << " IMAP4::listDir - " << _url.prettyURL() << endl;
 
   if (_url.path().isEmpty())
@@ -340,7 +341,8 @@ IMAP4Protocol::listDir (const KURL & _ur
 
   QString myBox, mySequence, myLType, mySection, myValidity, myDelimiter;
+  // parseURL with caching
   enum IMAP_TYPE myType =
     parseURL (_url, myBox, mySection, myLType, mySequence, myValidity,
-      myDelimiter);
+      myDelimiter, true);
 
   if (!makeLogin()) return;
@@ -541,4 +543,5 @@ IMAP4Protocol::setHost (const QString & 
     myUser = _user;
     myPass = _pass;
+    mHierarchyDelim.clear();
   }
 }
@@ -1576,5 +1579,5 @@ bool IMAP4Protocol::makeLogin ()
         if (tlsrc == 1)
         {
-          kdDebug() << "TLS mode has been enabled." << endl;
+          kdDebug(7116) << "TLS mode has been enabled." << endl;
           imapCommand *cmd2 = doCommand (new imapCommand ("CAPABILITY", ""));
           for (QStringList::Iterator it = imapCapabilities.begin ();
@@ -1585,5 +1588,5 @@ bool IMAP4Protocol::makeLogin ()
           completeQueue.removeRef (cmd2);
         } else {
-          kdDebug() << "TLS mode setup has failed.  Aborting." << endl;
+          kdWarning(7116) << "TLS mode setup has failed.  Aborting." << endl;
           error (ERR_COULD_NOT_LOGIN, i18n("Starting TLS failed."));
           closeConnection();
@@ -1864,5 +1867,6 @@ enum IMAP_TYPE
 IMAP4Protocol::parseURL (const KURL & _url, QString & _box,
                          QString & _section, QString & _type, QString & _uid,
-                         QString & _validity, QString & _hierarchyDelimiter)
+                         QString & _validity, QString & _hierarchyDelimiter,
+                         bool cache)
 {
   enum IMAP_TYPE retVal;
@@ -1888,4 +1892,12 @@ IMAP4Protocol::parseURL (const KURL & _u
       if (getCurrentBox () != _box || _type == "LIST" || _type == "LSUB")
       {
+        QString myNamespace = QString::null; // until namespace is supported
+        if (cache && mHierarchyDelim.contains(myNamespace))
+        {
+          _hierarchyDelimiter = mHierarchyDelim[myNamespace];
+          retVal = ITYPE_DIR;
+          kdDebug(7116) << "IMAP4::parseURL - got delimiter from cache:" << _hierarchyDelimiter << endl;
+        } else
+        {
         imapCommand *cmd;
 
@@ -1900,4 +1912,6 @@ IMAP4Protocol::parseURL (const KURL & _u
             {
               _hierarchyDelimiter = (*it).hierarchyDelimiter();
+                if (!mHierarchyDelim.contains(myNamespace))
+                  mHierarchyDelim[myNamespace] = _hierarchyDelimiter;
               if ((*it).noSelect ())
               {
@@ -1922,4 +1936,5 @@ IMAP4Protocol::parseURL (const KURL & _u
         }
         completeQueue.removeRef (cmd);
+        } // cache
       }
       else

--- kdebase/kioslave/imap4/imap4.h  #1.42:1.43
@@ -117,5 +117,5 @@ protected:
   parseURL (const KURL & _url, QString & _box, QString & _section,
             QString & _type, QString & _uid, QString & _validity,
-            QString & _hierarchyDelimiter);
+            QString & _hierarchyDelimiter, bool cache = false);
   QString getMimeType (enum IMAP_TYPE);
 
@@ -149,4 +149,5 @@ private:
   int readSize;
   QDateTime mTimeOfLastNoop;
+  QMap<QString, QString> mHierarchyDelim;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic