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

List:       kmail-devel
Subject:    PATCH: Remove libkab dependecies from KMail
From:       Cornelius Schumacher <schumacher () kde ! org>
Date:       2002-02-26 13:32:58
[Download RAW message or body]

The attached patch removes the dependencies on libkab from KMail. It also 
disables the option to use kab as address book client until this is also 
ported to the new addressbook API. Is it ok to commit?

-- 
Cornelius Schumacher <schumacher@kde.org>


["removelibkab.patch" (text/x-diff)]

? removelibkab.patch
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdenetwork/kmail/Makefile.am,v
retrieving revision 1.134
diff -u -p -r1.134 Makefile.am
--- Makefile.am	2002/02/19 23:48:21	1.134
+++ Makefile.am	2002/02/26 13:22:00
@@ -28,7 +28,7 @@ kmail_SOURCES = kmmessage.cpp kmmainwin.
 		kmscoring.cpp kmfawidgets.cpp kmfoldermbox.cpp kmfolderimap.cpp \
 		kmfoldermaildir.cpp kmacctexppop.cpp colorlistbox.cpp \
                 kmkernel.cpp kmailIface.skel kmailIface.stub main.cpp \
-		accountdialog.cpp kmfldsearch.cpp addtoaddressbook.cpp \
+		accountdialog.cpp kmfldsearch.cpp \
 		kmdisplayvcard.cpp vcard.cpp \
 		kmpopheaders.cpp kmpopfiltercnfrmdlg.cpp \
 		mailinglist-magic.cpp kmrecentaddr.cpp kmacctmaildir.cpp \
Index: configuredialog.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/configuredialog.cpp,v
retrieving revision 1.214
diff -u -p -r1.214 configuredialog.cpp
--- configuredialog.cpp	2002/02/21 18:34:05	1.214
+++ configuredialog.cpp	2002/02/26 13:22:00
@@ -3616,10 +3616,12 @@ static const struct {
   const char * label;
   const char * description;
 } addressBooks[] = {
+#if 0
   { I18N_NOOP("KAB"),
     I18N_NOOP("The KDE Address Book graphical interface (KAB) using the "
 	      "standard KDE Address Book (KAB) database. Requires the "
 	      "kdeutils package to be installed.") },
+#endif
   { I18N_NOOP("KAddressbook"),
     I18N_NOOP("The new KDE Address Book graphical interface "
 	      "(KAddressbook) using the standard KDE Address Book (KAB) "
Index: kmaddrbook.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmaddrbook.cpp,v
retrieving revision 1.49
diff -u -p -r1.49 kmaddrbook.cpp
--- kmaddrbook.cpp	2002/02/16 18:58:55	1.49
+++ kmaddrbook.cpp	2002/02/26 13:22:00
@@ -15,143 +15,15 @@
 #include <kstandarddirs.h>
 #include <kmessagebox.h>
 
-#include "kmkernel.h" // for KabBridge
-#include "kmmessage.h" // for KabBridge
+#include "kmkernel.h" // for KabcBridge
+#include "kmmessage.h" // for KabcBridge
 #include "kmaddrbookdlg.h" // for kmaddrbookexternal
 #include <krun.h> // for kmaddrbookexternal
 #include <kprocess.h>
-#include "addtoaddressbook.h"
 #include <kabc/stdaddressbook.h>
 #include <kabc/distributionlist.h>
 
 
-//-----------------------------------------------------------------------------
-void KabBridge::addresses(QStringList* result, QValueList<KabKey> *keys)
-{
-  QString addr;
-  QString email;
-  KabKey key;
-  AddressBook::Entry entry;
-  if (keys)
-    keys->clear();
-  int num = kernel->KABaddrBook()->addressbook()->noOfEntries();
-
-  for (int i = 0; i < num; ++i) {
-    if (AddressBook::NoError !=
-	kernel->KABaddrBook()->addressbook()->getKey( i, key ))
-      continue;
-    if (AddressBook::NoError !=
-	kernel->KABaddrBook()->addressbook()->getEntry( key, entry ))
-      continue;
-    unsigned int emails_count;
-    for( emails_count = 0; emails_count < entry.emails.count(); emails_count++ ) {
-      if (!entry.emails[emails_count].isEmpty()) {
-	if (entry.fn.isEmpty() || (entry.emails[0].find( "<" ) != -1))
-	  addr = "";
-	else { /* do we really need quotes around this name ? */
-	  if (entry.fn.find(QRegExp("[^ 0-9A-Za-z\\x0080-\\xFFFF]")) != -1)
-		addr = "\"" + entry.fn + "\" ";
-	  else
-		addr = entry.fn + " ";
-	}
-	email = entry.emails[emails_count];
-	if (!addr.isEmpty() && (email.find( "<" ) == -1)
-	    && (email.find( ">" ) == -1)
-	    && (email.find( "," ) == -1))
-	    addr += "<" + email + ">";
-	else
-	    addr += email;
-	addr.stripWhiteSpace();
-	result->append( addr );
-	if (keys)
-	  keys->append( key );
-      }
-    }
-  }
-}
-
-QString KabBridge::fn(QString address)
-{
-  return KMMessage::stripEmailAddr( address );
-}
-
-QString KabBridge::email(QString address)
-{
-  int i = address.find( "<" );
-  if (i < 0)
-    return "";
-  int j = address.find( ">", i );
-  if (j < 0)
-    return "";
-  return address.mid( i + 1, j - i - 1 );
-}
-
-bool KabBridge::add(QString address, KabKey &kabkey)
-{
-  AddressBook::Entry entry;
-  if (entry.emails.count() < 1)
-    entry.emails.append( "" );
-  entry.emails[0] = email(address);
-  entry.fn = fn(address);
-
-  if (kernel->KABaddrBook()->addressbook()->add( entry, kabkey, true ) !=
-      AddressBook::NoError) {
-    kdDebug(5006) << "Error occurred trying to update database: operation insert.0" << endl;
-    return false;
-  }
-  if (kernel->KABaddrBook()->addressbook()->save("", true) !=
-      AddressBook::NoError) {
-    kdDebug(5006) << "Error occurred trying to update database: opeation insert.1" << endl;
-    return false;
-  }
-  return true;
-}
-
-bool KabBridge::remove(KabKey kabKey)
-{
-  if (kernel->KABaddrBook()->addressbook()->remove( kabKey ) !=
-      AddressBook::NoError) {
-    kdDebug(5006) << "Error occurred trying to update database: operation remove.0" << endl;
-    return false;
-  }
-
-  if (kernel->KABaddrBook()->addressbook()->save("", true) !=
-      AddressBook::NoError) {
-    kdDebug(5006) << "Error occurred trying to update database: operation remove.1" << endl;
-    return false;
-  }
-  return true;
-}
-
-bool KabBridge::replace(QString address, KabKey kabKey)
-{
-  AddressBook::Entry old;
-  if (AddressBook::NoError !=
-      kernel->KABaddrBook()->addressbook()->getEntry( kabKey, old )) {
-    kdDebug(5006) << "Error occurred trying to update database: operation replace.0" << endl;
-    return false;
-  }
-
-  if (old.emails.count() < 1)
-    old.emails.append( "" );
-  old.emails[0] = email(address);
-  old.fn = fn(address);
-
-  if (kernel->KABaddrBook()->addressbook()->change( kabKey, old ) !=
-      AddressBook::NoError) {
-    kdDebug(5006) << "Error occurred trying to update database: operation replace.1" << endl;
-    return false;
-  }
-
-  if (kernel->KABaddrBook()->addressbook()->save("", true) !=
-      AddressBook::NoError) {
-    kdDebug(5006) << "Error occurred trying to update database: operation replace.2" << endl;
-    return false;
-  }
-  return true;
-}
-
-//-----------------------------------------------------------------------------
 void KabcBridge::addresses(QStringList* result) // includes lists
 {
   QString addr, email;
@@ -279,32 +151,29 @@ QString KabcBridge::expandDistributionLi
 }
 
 //-----------------------------------------------------------------------------
-void KMAddrBookExternal::addEmail(QString addr, QWidget *parent) {
-  if (useKABC())
+void KMAddrBookExternal::addEmail(QString addr, QWidget *) {
+  if (useKAddressbook())
   {
     KRun::runCommand( "kaddressbook -a \"" + addr.replace(QRegExp("\""), "")
       + "\"" );
     return;
   }
-  AddToKabDialog dialog(addr, kernel->KABaddrBook(), parent);
-  dialog.exec();
+  
+  // TODO: Start a simple add-to-addressbook-dialog, or just add the address
+  // silently to kabc.
 }
 
 void KMAddrBookExternal::launch(QWidget *) {
-  KConfig *config = kapp->config();
-  KConfigGroupSaver saver(config, "General");
-  int ab = config->readNumEntry("addressbook", 3);
-  switch (ab)
-  {
-  case 0:
+  if ( useKab() ) {
     KRun::runCommand("kab");
-    break;
-  default:
+  } else if ( useKAddressbook() ) {
     KRun::runCommand("kaddressbook");
+  } else {
+    // TODO: some default action, e.g. a simple address book dialog.
   }
 }
 
-bool KMAddrBookExternal::useKAB()
+bool KMAddrBookExternal::useKab()
 {
   KConfig *config = kapp->config();
   KConfigGroupSaver saver(config, "General");
@@ -312,7 +181,7 @@ bool KMAddrBookExternal::useKAB()
   return (ab == 0);
 }
 
-bool KMAddrBookExternal::useKABC()
+bool KMAddrBookExternal::useKAddressbook()
 {
   KConfig *config = kapp->config();
   KConfigGroupSaver saver(config, "General");
Index: kmaddrbook.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmaddrbook.h,v
retrieving revision 1.13
diff -u -p -r1.13 kmaddrbook.h
--- kmaddrbook.h	2001/12/20 16:31:41	1.13
+++ kmaddrbook.h	2002/02/26 13:22:00
@@ -6,19 +6,8 @@
 #define KMAddrBook_h
 
 #include <qstringlist.h>
-#include <qvaluelist.h>  // for KabBridge
-#include <kabapi.h> // for KabBridge
+#include <qwidget.h>
 
-class KabBridge {
-public:
-  static void addresses(QStringList* result, QValueList<KabKey> *keys=0);
-  static QString fn(QString address);
-  static QString email(QString address);
-  static bool add(QString address, KabKey &kabkey);
-  static bool remove(KabKey);
-  static bool replace(QString address, KabKey);
-};
-
 class KabcBridge {
 public:
   static void addresses(QStringList* result);
@@ -29,8 +18,8 @@ class KMAddrBookExternal {
 public:
   static void addEmail(QString addr, QWidget *parent);
   static void launch(QWidget *parent);
-  static bool useKAB();
-  static bool useKABC();
+  static bool useKab();
+  static bool useKAddressbook();
 };
 
 #endif /*KMAddrBook_h*/
Index: kmaddrbookdlg.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmaddrbookdlg.cpp,v
retrieving revision 1.37
diff -u -p -r1.37 kmaddrbookdlg.cpp
--- kmaddrbookdlg.cpp	2001/12/20 16:31:41	1.37
+++ kmaddrbookdlg.cpp	2002/02/26 13:22:00
@@ -76,16 +76,9 @@ void KMAddrBookSelDlg::showAddresses( in
   mListBox->clear();
 
   if ( addressTypes & AddressBookAddresses ) {
-    if (KMAddrBookExternal::useKABC()) {
-      QStringList addresses;
-      KabcBridge::addresses(&addresses);
-      mListBox->insertStringList(addresses);
-    }
-    else if (KMAddrBookExternal::useKAB()) {
-      QStringList addresses;
-      KabBridge::addresses(&addresses);
-      mListBox->insertStringList(addresses);
-    }
+    QStringList addresses;
+    KabcBridge::addresses(&addresses);
+    mListBox->insertStringList(addresses);
   }
   mListBox->sort();
 
Index: kmcomposewin.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmcomposewin.cpp,v
retrieving revision 1.471
diff -u -p -r1.471 kmcomposewin.cpp
--- kmcomposewin.cpp	2002/02/19 08:40:01	1.471
+++ kmcomposewin.cpp	2002/02/26 13:22:01
@@ -2979,20 +2979,11 @@ void KMLineEdit::loadAddresses()
     for ( ; it != recent.end(); ++it )
         s_completion->addItem( *it );
 
-    if (KMAddrBookExternal::useKABC()) {
-        QStringList addresses;
-        KabcBridge::addresses(&addresses);
-        QStringList::Iterator it = addresses.begin();
-        for (; it != addresses.end(); ++it)
-            s_completion->addItem( *it );	
-    }
-    else if (KMAddrBookExternal::useKAB()) {
-        QStringList addresses;
-        KabBridge::addresses(&addresses);
-        QStringList::Iterator it = addresses.begin();
-        for (; it != addresses.end(); ++it)
-            s_completion->addItem( *it );
-    }
+    QStringList addresses;
+    KabcBridge::addresses(&addresses);
+    QStringList::Iterator it2 = addresses.begin();
+    for (; it2 != addresses.end(); ++it2)
+    	s_completion->addItem( *it2 );	    
 }
 
 
Index: kmkernel.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.cpp,v
retrieving revision 1.97
diff -u -p -r1.97 kmkernel.cpp
--- kmkernel.cpp	2002/02/19 17:53:38	1.97
+++ kmkernel.cpp	2002/02/26 13:22:01
@@ -64,7 +64,6 @@ KMKernel::KMKernel (QObject *parent, con
   the_filterMgr = 0;
   the_popFilterMgr = 0;
   the_filterActionDict = 0;
-  the_KAB_addrBook = 0;
   the_msgSender = 0;
   the_msgDict = 0;
 
@@ -541,7 +540,6 @@ void KMKernel::init()
   the_filterMgr     = new KMFilterMgr();
   the_popFilterMgr     = new KMFilterMgr(true);
   the_filterActionDict = new KMFilterActionDict;
-  the_KAB_addrBook  = 0;
 
   initFolders(cfg);
   the_acctMgr->readConfig();
@@ -816,24 +814,6 @@ void KMKernel::slotResult(KIO::Job *job)
     else job->showErrorDialog();
   }
   mPutJobs.remove(it);
-}
-
-KabAPI* KMKernel::KABaddrBook()
-{
-  if (the_KAB_addrBook)
-    return the_KAB_addrBook;
-
-  the_KAB_addrBook = new KabAPI; // KabApi is a dialog;
-  if(KABaddrBook()->init()!=AddressBook::NoError)
-  { // this connects to the default address book and opens it:
-    kdDebug(5006) << "Error initializing the connection to your KAB address book." << endl;
-    the_KAB_addrBook=0;
-  }
-  else {
-    kdDebug(5006) << "KMKernel::init: KabApi initialized." << endl;
-  }
-
-  return the_KAB_addrBook;
 }
 
 void KMKernel::notClosedByUser()
Index: kmkernel.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.h,v
retrieving revision 1.32
diff -u -p -r1.32 kmkernel.h
--- kmkernel.h	2002/02/12 17:39:04	1.32
+++ kmkernel.h	2002/02/26 13:22:01
@@ -19,7 +19,6 @@ class KMUndoStack;
 class KMAcctMgr;
 class KMFilterMgr;
 class KMFilterActionDict;
-class KabAPI;
 class KMSender;
 class KMIdentity;
 class KMKernel;
@@ -115,7 +114,6 @@ public:
   inline KMFilterMgr *filterMgr() { return the_filterMgr; }
   inline KMFilterMgr *popFilterMgr() { return the_popFilterMgr; }
   inline KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
-  KabAPI *KABaddrBook();
   inline KMSender *msgSender() { return the_msgSender; }
   inline KMMsgDict *msgDict() { return the_msgDict; }
 
@@ -150,7 +148,6 @@ private:
   KMFilterMgr *the_filterMgr;
   KMFilterMgr *the_popFilterMgr;
   KMFilterActionDict *the_filterActionDict;
-  KabAPI *the_KAB_addrBook;
   KMSender *the_msgSender;
   KMMsgDict *the_msgDict;
   struct putData

_______________________________________________
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