IMAP flags (Was: Re: Release schedule reminder)

Bo Thorsen bo at sonofthor.dk
Mon Oct 7 12:45:03 BST 2002


On Monday 07 October 2002 12:36, Michael Häckel wrote:
> On Wednesday 02 October 2002 09:08, Bo Thorsen wrote:
> > In kdebase/kioslave/imap4/imapinfo.h there is a flags encoding - an enum
> > - of the imap slave. These are used for changing the IMAP style flags "\\
> > SEEN \\ DELETED" and so to a single number. Unfortunately this encoding
> > isn't put in any header file, so any app using the IMAP flags must use
> > magic numbers. KMail does this and I assume konqueror also does.
> >
> > This patch moves the flags to a new header file. Can this go into 3.1? If
> > someone commits this with the necessary Makefile.am hackery to install
> > imap4_slave_flags.h into $INCLUDE/kio, I will make a patch for kmail
> > asap.
>
> I don't know where you want to put this file in. I consider putting IMAP
> specific code into kdelibs a bad idea. Putting into kdebase is also bad,
> because this creates a compile time dependency that is currently not there.

Ahh, of course. I missed the fact that KMail doesn't need the IMAP ioslave to 
compile (/me changes the compilescript).

Okay, in this case there is no good solution:

1) Use the header I made and make KMail compilation depend on kdebase install
2) Keep using the magic numbers for the IMAP flags in KMail
3) Code duplication: Install the file in both the IMAP slave and in KMail

None of these are acceptable, but one has to be chosen. 1) is out of the 
question. 2) (present situation) is really bad. 3) is usable but can 
potentially go bad if someone forgets to commit to both files.

It's clear that I would prefer 3) since this is the less error-prone - I mean, 
this enum probably haven't changed since the very first implementation of the 
IMAP slave.

Would this patch be acceptable (note that I haven't changed any usage of the 
IMAP slave yet, this can come after 3.1):

Index: imap4_slave_flags.h
===================================================================
RCS file: imap4_slave_flags.h
diff -N imap4_slave_flags.h
--- /dev/null	Fri Feb  1 11:53:05 2002
+++ imap4_slave_flags.h	Mon Oct  7 13:42:14 2002
@@ -0,0 +1,39 @@
+#ifndef _IMAP4_SLAVE_FLAGS_H
+#define _IMAP4_SLAVE_FLAGS_H "$Id:$"
+
+/**********************************************************************
+ *
+ *   imap4_slave_flags.h  - IMAP4rev1 flags encoding
+ *   Copyright (C) 2002 Bo Thorsen <bo at klaralvdalens-datakonsult.se>
+ *
+ *   WARNING: This file is also in kdenetwork/kmail/imap4_slave_flags.h.
+ *   Do *NOT* change one without changing the other!
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *********************************************************************/
+
+enum ImapMessageFlags {
+  ImapSeen = 1 << 0,
+  ImapAnswered = 1 << 1,
+  ImapFlagged = 1 << 2,
+  ImapDeleted = 1 << 3,
+  ImapDraft = 1 << 4,
+  ImapRecent = 1 << 5,
+  ImapUser = 1 << 6
+};
+
+
+#endif
Index: imapinfo.cc
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/imapinfo.cc,v
retrieving revision 1.8
diff -u -p -r1.8 imapinfo.cc
--- imapinfo.cc	2001/11/26 19:24:39	1.8
+++ imapinfo.cc	2002/10/07 11:42:14
@@ -232,19 +232,19 @@ ulong imapInfo::_flags (const QString & 
     entry = imapParser::b2c(imapParser::parseOneWord (flagsString));
 
     if (0 != entry.contains ("\\Seen", false))
-      flags ^= Seen;
+      flags ^= ImapSeen;
     else if (0 != entry.contains ("\\Answered", false))
-      flags ^= Answered;
+      flags ^= ImapAnswered;
     else if (0 != entry.contains ("\\Flagged", false))
-      flags ^= Flagged;
+      flags ^= ImapFlagged;
     else if (0 != entry.contains ("\\Deleted", false))
-      flags ^= Deleted;
+      flags ^= ImapDeleted;
     else if (0 != entry.contains ("\\Draft", false))
-      flags ^= Draft;
+      flags ^= ImapDraft;
     else if (0 != entry.contains ("\\Recent", false))
-      flags ^= Recent;
+      flags ^= ImapRecent;
     else if (0 != entry.contains ("\\*", false))
-      flags ^= User;
+      flags ^= ImapUser;
     else if (entry.isEmpty ())
       flagsString.clear();
     else
Index: imapinfo.h
===================================================================
RCS file: /home/kde/kdebase/kioslave/imap4/imapinfo.h,v
retrieving revision 1.5
diff -u -p -r1.5 imapinfo.h
--- imapinfo.h	2001/08/07 20:04:28	1.5
+++ imapinfo.h	2002/10/07 11:42:14
@@ -26,24 +26,13 @@
 #include <qstringlist.h>
 #include <qstring.h>
 
+#include "imap4_slave_flags.h"
+
+
 //class handling the info we get on EXAMINE and SELECT
 class imapInfo
 {
 public:
-
-
-  enum MessageAttribute
-  {
-    Seen = 1 << 0,
-    Answered = 1 << 1,
-    Flagged = 1 << 2,
-    Deleted = 1 << 3,
-    Draft = 1 << 4,
-    Recent = 1 << 5,
-    User = 1 << 6
-  };
-
-
     imapInfo ();
     imapInfo (const QStringList &);
     imapInfo (const imapInfo &);

And this:

Index: imap4_slave_flags.h
===================================================================
RCS file: imap4_slave_flags.h
diff -N imap4_slave_flags.h
--- /dev/null	Fri Feb  1 11:53:05 2002
+++ imap4_slave_flags.h	Mon Oct  7 13:42:04 2002
@@ -0,0 +1,39 @@
+#ifndef _IMAP4_SLAVE_FLAGS_H
+#define _IMAP4_SLAVE_FLAGS_H "$Id:$"
+
+/**********************************************************************
+ *
+ *   imap4_slave_flags.h  - IMAP4rev1 flags encoding
+ *   Copyright (C) 2002 Bo Thorsen <bo at klaralvdalens-datakonsult.se>
+ *
+ *   WARNING: This file is also in kdebase/kioslave/imap/imap4_slave_flags.h.
+ *   Do *NOT* change one without changing the other!
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *********************************************************************/
+
+enum ImapMessageFlags {
+  ImapSeen = 1 << 0,
+  ImapAnswered = 1 << 1,
+  ImapFlagged = 1 << 2,
+  ImapDeleted = 1 << 3,
+  ImapDraft = 1 << 4,
+  ImapRecent = 1 << 5,
+  ImapUser = 1 << 6
+};
+
+
+#endif


-- 

     Bo Thorsen                 |   Praestevejen 4
     Senior Software Engineer   |   5290 Marslev
     Klarälvdalens Datakonsult  |   Denmark



More information about the kde-core-devel mailing list