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

List:       kmail-devel
Subject:    Mailinglist-aware folders : a springtime patch
From:       Guillaume Laurent <glaurent () telegraph-road ! org>
Date:       2000-08-29 23:07:52
[Download RAW message or body]

So I really had to sink my teeth into this. And I also wanted to get a 
different taste of KDE programming with a full-fledged app. This was 
impressively easy.

For after the feature-freeze, of course, if anybody is interested.

The attached patch is a first start at implementing "mailing-list aware" 
folders. Using the Folder->Modify dialog, you can set if a folder holds a 
mailing-list, and specify the posting and admin addresses.

So far, only the posting address is used : when doing a reply-all to a 
message from a folder which holds a mailing-list, the To: field will be set 
to the mailing-list's posting address. This is better than this broken, ugly 
"Reply-To" hack which too many mailing-lists seem to use :-).

Two nice features to add, if I (or anyone else) have the time :

- pseudo-"post" : when creating a new message, if a mailing-list folder is 
selected, use the posting address.

- auto-(un)subscribe : have a menu item which would send "(un)subscribe" to 
admin address. Very convenient when going on  / coming back from vacations.

-- 
					Guillaume.
					http://www.telegraph-road.org


["kmail_mailing_list_folder_patch" (text/plain)]

Only in kmail: .libs
Only in kmail: kmail
Only in kmail: kmailIface.kidl
Only in kmail: kmailIface_skel.cpp
Only in kmail: kmailIface_stub.cpp
Only in kmail: kmailIface_stub.h
Only in kmail: kmail_meta_unload.cpp
diff -x *.moc -x *.sniffdir -x *.o -x *.proj -x *~ -x Makefile -b -u -r \
                kmail.old/kmfolder.cpp kmail/kmfolder.cpp
--- kmail.old/kmfolder.cpp	Thu Aug 17 10:09:34 2000
+++ kmail/kmfolder.cpp	Wed Aug 30 00:23:07 2000
@@ -2,6 +2,7 @@
 // Author: Stefan Taferner <taferner@alpin.or.at>
 
 #include <qfileinfo.h>
+#include <qtextstream.h>
 
 #include "kmglobal.h"
 #include "kmfolder.h"
@@ -102,9 +103,8 @@
 //-----------------------------------------------------------------------------
 const QString KMFolder::location() const
 {
-  QString sLocation;
+  QString sLocation(path());
 
-  sLocation = path().copy();
   if (!sLocation.isEmpty()) sLocation += '/';
   sLocation += name();
 
@@ -115,9 +115,8 @@
 //-----------------------------------------------------------------------------
 const QString KMFolder::indexLocation() const
 {
-  QString sLocation;
+  QString sLocation(path());
 
-  sLocation = path().copy();
   if (!sLocation.isEmpty()) sLocation += '/';
   sLocation += '.';
   sLocation += name();
@@ -129,9 +128,8 @@
 //-----------------------------------------------------------------------------
 const QString KMFolder::subdirLocation() const
 {
-  QString sLocation;
+  QString sLocation(path());
 
-  sLocation = path().copy();
   if (!sLocation.isEmpty()) sLocation += '/';
   sLocation += '.';
   sLocation += name();
@@ -591,7 +589,6 @@
   return 0;
 }
 
-
 //-----------------------------------------------------------------------------
 void KMFolder::setAutoCreateIndex(bool autoIndex)
 {
@@ -663,7 +660,6 @@
   }
 }
 
-
 //-----------------------------------------------------------------------------
 void KMFolder::markNewAsUnread()
 {
@@ -1369,6 +1365,8 @@
   KConfig* config = kapp->config();
   config->setGroup("Folder-" + idString());
   unreadMsgs = config->readNumEntry("UnreadMsgs", -1);
+  mMailingListPostingAddress = config->readEntry("MailingListPostingAddress");
+  mMailingListAdminAddress = config->readEntry("MailingListAdminAddress");
 }
 
 //-----------------------------------------------------------------------------
@@ -1377,6 +1375,8 @@
   KConfig* config = kapp->config();
   config->setGroup("Folder-" + idString());
   config->writeEntry("UnreadMsgs", countUnread());
+  config->writeEntry("MailingListPostingAddress", mMailingListPostingAddress);
+  config->writeEntry("MailingListAdminAddress", mMailingListAdminAddress);
 }
 
 //-----------------------------------------------------------------------------
diff -x *.moc -x *.sniffdir -x *.o -x *.proj -x *~ -x Makefile -b -u -r \
                kmail.old/kmfolder.h kmail/kmfolder.h
--- kmail.old/kmfolder.h	Sun May 21 08:37:14 2000
+++ kmail/kmfolder.h	Wed Aug 30 00:39:02 2000
@@ -212,6 +212,14 @@
   /** Returns TRUE if accounts are associated with this folder. */
   bool hasAccounts() const { return (mAcctList != NULL); }
 
+  /** Returns TRUE if this folder is associated with a mailing-list. */
+  bool isMailingList() const { return (mMailingListPostingAddress != QString::null) \
&& !mMailingListPostingAddress.isEmpty(); } +  void setMailingListPostAddress(const \
QString &address) { mMailingListPostingAddress = address; } +  const QString& \
mailingListPostAddress() const { return mMailingListPostingAddress; } +
+  void setMailingListAdminAddress(const QString &address) { mMailingListAdminAddress \
= address; } +  const QString& mailingListAdminAddress() const { return \
mMailingListAdminAddress; } +  
   /** Tell the folder that a header field that is usually used for
     the index (subject, from, ...) has changed of given message. 
     This method is usually called from within KMMessage::setSubject/set... */
@@ -306,6 +314,10 @@
   QString mWhoField; // name of the field that is used for "From" in listbox
   bool mIsSystemFolder;
   KMAcctList* mAcctList;
+
+  QString mMailingListPostingAddress;
+  QString mMailingListAdminAddress;
+
   long unreadMsgs; // number of unread messages, -1 if not yet set
   bool needsCompact; //sven: true if on destruct folder needs to be compacted.
   KMFolderDir* mChild;
diff -x *.moc -x *.sniffdir -x *.o -x *.proj -x *~ -x Makefile -b -u -r \
                kmail.old/kmfolderdia.cpp kmail/kmfolderdia.cpp
--- kmail.old/kmfolderdia.cpp	Sat Jul 15 12:03:47 2000
+++ kmail/kmfolderdia.cpp	Wed Aug 30 00:40:34 2000
@@ -2,6 +2,7 @@
 
 #include <assert.h>
 
+#include <qcheckbox.h>
 #include <qdir.h>
 #include <qfile.h>
 #include <qlabel.h>
@@ -11,9 +12,11 @@
 #include <qpushbutton.h>
 #include <qstring.h>
 #include <qtextstream.h>
+#include <qvbox.h>
 
 #include <klocale.h>
 #include <kmessagebox.h>
+#include <kdebug.h>
 
 #include "kmmainwin.h"
 #include "kmglobal.h"
@@ -28,12 +31,22 @@
 //-----------------------------------------------------------------------------
 KMFolderDialog::KMFolderDialog(KMFolder* aFolder, KMFolderDir *aFolderDir,
 			       QWidget *aParent, const QString& aCap):
-  KMFolderDialogInherited( aParent, "KMFolderDialog", TRUE,
-			   aCap,  KDialogBase::Ok|KDialogBase::Cancel ),
+//   KMFolderDialogInherited( aParent, "KMFolderDialog", TRUE,
+// 			   aCap,  KDialogBase::Ok|KDialogBase::Cancel ),
+  KMFolderDialogInherited( KDialogBase::Tabbed,
+                           aCap, KDialogBase::Ok|KDialogBase::Cancel,
+                           KDialogBase::Ok, aParent, "KMFolderDialog", TRUE ),
   folder((KMAcctFolder*)aFolder),mFolderDir( aFolderDir )
 {
-  QWidget *page = new QWidget(this);
-  setMainWidget( page );
+
+//   QWidget *page = new QWidget(this);
+//   setMainWidget( page );
+//   QVBoxLayout *topLayout =  new QVBoxLayout( page, 0, spacingHint() );
+
+  // Main tab
+  //
+  QFrame *page = addPage(i18n("Folder Position"), i18n("Where the folder is located \
in the tree") ); +
   QVBoxLayout *topLayout =  new QVBoxLayout( page, 0, spacingHint() );
 
   QHBoxLayout *hl = new QHBoxLayout();
@@ -78,6 +91,56 @@
     if (curFolder->child() == aFolderDir)
       fileInFolder->setCurrentItem( i );
   }
+
+  // Mailing-list data tab
+  //
+  page = addPage(i18n("Associated Mailing List"), i18n("Email addresses of the \
mailing-list related to this folder") ); +
+  topLayout =  new QVBoxLayout( page, 0, spacingHint() );
+
+  hl = new QHBoxLayout();
+  topLayout->addSpacing( spacingHint()*2 );
+
+  holdsMailingList = new QCheckBox( i18n("folder holds a mailing-list"), page);
+  QObject::connect(holdsMailingList, SIGNAL(toggled(bool)),
+                   this, SLOT(slotHoldsML(bool)));
+
+  topLayout->addWidget(holdsMailingList);
+
+  topLayout->addSpacing( spacingHint()*2 );
+  topLayout->addLayout( hl );
+  topLayout->addSpacing( spacingHint()*2 );
+
+  
+  label = new QLabel( i18n("Post Address:"), page );
+  hl->addWidget( label );
+  mailingListPostAddress = new QLineEdit( page );
+  mailingListPostAddress->setMinimumSize(mailingListPostAddress->sizeHint());
+  hl->addWidget( mailingListPostAddress );
+
+  hl = new QHBoxLayout();
+  topLayout->addLayout( hl );
+
+  label = new QLabel( i18n("Admin Address:"), page );
+  hl->addWidget( label );
+  mailingListAdminAddress = new QLineEdit( page );
+  mailingListAdminAddress->setMinimumSize(mailingListAdminAddress->sizeHint());
+  hl->addWidget( mailingListAdminAddress );
+
+  if (folder && folder->isMailingList())
+  {
+    mailingListPostAddress->setText(folder->mailingListPostAddress());
+    mailingListAdminAddress->setText(folder->mailingListAdminAddress());
+
+    mailingListPostAddress->setEnabled(true);
+    mailingListAdminAddress->setEnabled(true);
+    holdsMailingList->setChecked(true);
+  }
+  else {
+    mailingListPostAddress->setEnabled(false);
+    mailingListAdminAddress->setEnabled(false);
+    holdsMailingList->setChecked(false);
+  }
 }
 
 
@@ -145,5 +208,33 @@
       kernel->folderMgr()->contentsChanged();
     }
 
+  if (holdsMailingList->isChecked())
+  {
+    folder->setMailingListPostAddress(mailingListPostAddress->text());
+    folder->setMailingListAdminAddress(mailingListAdminAddress->text());
+  } else 
+  {
+    folder->setMailingListPostAddress(QString::null);
+    folder->setMailingListAdminAddress(QString::null);
+  }
+
   KMFolderDialogInherited::slotOk();
 }
+
+//-----------------------------------------------------------------------------
+void KMFolderDialog::slotHoldsML( bool holdsML )
+{
+  if ( holdsML )
+  {
+    mailingListPostAddress->setEnabled(true);
+    mailingListAdminAddress->setEnabled(true);
+  }
+  else
+  {
+    mailingListPostAddress->clear();
+    mailingListAdminAddress->clear();
+    mailingListPostAddress->setEnabled(false);
+    mailingListAdminAddress->setEnabled(false);
+  }
+}
+
diff -x *.moc -x *.sniffdir -x *.o -x *.proj -x *~ -x Makefile -b -u -r \
                kmail.old/kmfolderdia.h kmail/kmfolderdia.h
--- kmail.old/kmfolderdia.h	Sun Jul  2 18:53:11 2000
+++ kmail/kmfolderdia.h	Tue Aug 29 02:20:11 2000
@@ -7,6 +7,7 @@
 #include <qlist.h>
 
 class KMAcctFolder;
+class QCheckBox;
 class QPushButton;
 class QLineEdit;
 class QListBox;
@@ -25,6 +26,7 @@
 
 protected slots:
   virtual void slotOk( void );
+  virtual void slotHoldsML( bool );
 
 protected:
   QComboBox *fileInFolder;
@@ -32,6 +34,10 @@
   KMAcctFolder* folder;
   KMFolderDir* mFolderDir;
   QValueList<QGuardedPtr<KMFolder> > mFolders;
+
+  QCheckBox *holdsMailingList;
+  QLineEdit *mailingListPostAddress;
+  QLineEdit *mailingListAdminAddress;
 };
 
 #endif /*__KMFOLDERDIA*/
diff -x *.moc -x *.sniffdir -x *.o -x *.proj -x *~ -x Makefile -b -u -r \
                kmail.old/kmmessage.cpp kmail/kmmessage.cpp
--- kmail.old/kmmessage.cpp	Thu Aug 17 10:09:35 2000
+++ kmail/kmmessage.cpp	Tue Aug 29 00:20:04 2000
@@ -669,6 +669,14 @@
 
   if (replyToAll)
   {
+    // glaurent - check if the folder holds a mailing-list
+    if (parent()->isMailingList())
+    {
+      // Reply to mailing-list posting address
+      toStr = parent()->mailingListPostAddress();
+    }
+    else // normal reply
+    {        
     int i;
     // sanders only include the replyTo address if it's != to the from address
     QString rep = replyToStr;
@@ -720,6 +728,7 @@
           ccStr.truncate(ccStr.length()-1);
 	msg->setCc(ccStr);
       }
+    }
 
   }
   else



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

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