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

List:       kmail-devel
Subject:    Re: [Patch] Improved threading (by references and subject)
From:       Till Adam <till () adam-lilienthal ! de>
Date:       2003-03-09 14:27:05
[Download RAW message or body]

On Sunday 09 March 2003 11:21, Ingo Klöcker wrote:
> On Sunday 09 March 2003 09:38, Till Adam wrote:
> > How about that imap patch, has someone seen problems with that?
>
> The additions to parseBody seem to be okay. But I'm not sure about the
> change
> -    retVal = parseOneWord(inWords);
> +    retVal = parseOneWord(inWords, TRUE);
> in parseLiteral. It was probably intentionally called with FALSE (the
> default value). Therefore you should add a stopAtBracket parameter with
> a default value of false to parseLiteral.

Like so?

Till
["references2.diff" (text/x-diff)]

Index: imap4.cc
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/imap4.cc,v
retrieving revision 1.127
diff -u -3 -p -r1.127 imap4.cc
--- imap4.cc    21 Feb 2003 11:45:48 -0000      1.127
+++ imap4.cc    9 Mar 2003 14:22:36 -0000
@@ -191,6 +191,7 @@ IMAP4Protocol::get (const KURL & _url)
     else if (aSection.find ("ENVELOPE", 0, false) != -1)
     {
       aSection = "UID ENVELOPE";
+      aSection += " BODY.PEEK[HEADER.FIELDS (REFERENCES)]";
     }
     else
     {
Index: imapparser.cc
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/imapparser.cc,v
retrieving revision 1.45
diff -u -3 -p -r1.45 imapparser.cc
--- imapparser.cc       18 Jan 2003 17:43:31 -0000      1.45
+++ imapparser.cc       9 Mar 2003 14:22:37 -0000
@@ -1036,13 +1036,13 @@ void imapParser::parseBody (parseString 
   if (inWords[0] == '[')
   {
     QByteArray specifier;
+    QByteArray label;
     inWords.pos++;
 
     specifier = parseOneWord (inWords, TRUE);
-
+    
     if (inWords[0] == '(')
     {
-      QByteArray label;
       inWords.pos++;
 
       while (!inWords.isEmpty () && inWords[0] != ')')
@@ -1082,6 +1082,41 @@ void imapParser::parseBody (parseString 
 
       }
     }
+    else if (qstrncmp(specifier, "HEADER.FIELDS", specifier.size()) == 0)
+    {
+      // BODY[HEADER.FIELDS (References)] {n} 
+      kdDebug(7116) << "imapParser::parseBody - HEADER.FIELDS: " 
+       << QCString(label.data(), label.size()+1) << endl;
+      if (qstrncmp(label, "REFERENCES", label.size()) == 0)
+      {
+       mailHeader *envelope = NULL;
+       if (lastHandled)
+         envelope = lastHandled->getHeader ();
+
+       if (!envelope || seenUid.isEmpty ())
+       {
+         kdDebug(7116) << "imapParser::parseBody - discarding " << envelope << " " << seenUid.ascii () << endl;
+         // don't know where to put it, throw it away
+         parseLiteral (inWords, true);
+       }
+       else
+       {
+         QByteArray res = parseLiteral (inWords, true);
+         QCString references = QCString(res.data(), res.size()+1);
+         int start = references.find ('<');
+         int end = references.findRev ('>');
+         if (start < end)
+                 references = references.mid (start, end - start + 1);
+
+         references = references.stripWhiteSpace();
+         envelope->setReferences(references);
+       }
+      }
+      else
+      { // not a header we care about throw it away
+        parseLiteral (inWords, true);
+      }
+    }
     else
     {
       // throw it away
@@ -1130,7 +1165,8 @@ void imapParser::parseFetch (ulong value
       parseSentence (inWords);
     else
     {
-      QString word = parseLiteral (inWords);
+      QString word = parseLiteral (inWords, false, true);
+
       switch (word[0].latin1 ())
       {
       case 'E':
@@ -1334,7 +1370,6 @@ int imapParser::parseLoop ()
   else
   {
     imapCommand *current = sentQueue.at (0);
-
     switch (result[0])
     {
     case '*':
@@ -1477,7 +1512,7 @@ void imapParser::skipWS (parseString & i
   }
 }
 
-QByteArray imapParser::parseLiteral (parseString & inWords, bool relay)
+QByteArray imapParser::parseLiteral (parseString & inWords, bool relay, bool stopAtBracket)
 {
   QByteArray retVal;
 
@@ -1523,7 +1558,7 @@ QByteArray imapParser::parseLiteral (par
   }
   else
   {
-    retVal = parseOneWord(inWords);
+    retVal = parseOneWord(inWords, stopAtBracket);
   }
   skipWS (inWords);
   return retVal;
Index: imapparser.h
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/imapparser.h,v
retrieving revision 1.21
diff -u -3 -p -r1.21 imapparser.h
--- imapparser.h        7 Mar 2003 22:05:30 -0000       1.21
+++ imapparser.h        9 Mar 2003 14:22:37 -0000
@@ -259,7 +259,8 @@ public:
   void parseSentence (parseString & inWords);
 
   // parse a literal or word, may require more data
-  QByteArray parseLiteral (parseString & inWords, bool relay = false);
+  QByteArray parseLiteral (parseString & inWords, bool relay = false, 
+                           bool stopAtBracket = false);
 
   // static parser routines, can be used elsewhere
 
Index: mailheader.cc
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/mailheader.cc,v
retrieving revision 1.10
diff -u -3 -p -r1.10 mailheader.cc
--- mailheader.cc       18 Jan 2003 17:43:31 -0000      1.10
+++ mailheader.cc       9 Mar 2003 14:22:38 -0000
@@ -148,6 +148,11 @@ mailHeader::outputHeader (mimeIO & useIO
     useIO.
       outputMimeLine (mimeHdrLine::
                       truncateLine (QCString ("In-Reply-To: ") + inReplyTo));
+  if (!references.isEmpty ())
+    useIO.
+      outputMimeLine (mimeHdrLine::
+                      truncateLine (QCString ("References: ") + references));
+
   if (!mDate.isEmpty())
     useIO.outputMimeLine (QCString ("Date: ") + mDate);
   mimeHeader::outputHeader (useIO);
Index: mailheader.h
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/mailheader.h,v
retrieving revision 1.10
diff -u -3 -p -r1.10 mailheader.h
--- mailheader.h        12 Feb 2002 17:40:26 -0000      1.10
+++ mailheader.h        9 Mar 2003 14:22:38 -0000
@@ -89,6 +89,15 @@ public:
     inReplyTo = _str;
   };
 
+  QCString getReferences ()
+  {
+    return references;
+  };
+  void setReferences (const QCString & _str)
+  {
+    references = _str;
+  };
+
   // set a unicode subject
   void setSubject (const QString & _str)
   {
@@ -166,6 +175,7 @@ private:
   int gmt_offset;
   QCString messageID;
   QCString inReplyTo;
+  QCString references;
 };
 
 #endif

_______________________________________________
KMail Developers mailing list
kmail@mail.kde.org
http://mail.kde.org/mailman/listinfo/kmail

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

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