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

List:       kmail-devel
Subject:    Re: KMail addressbook broken
From:       Don Sanders <don () sanders ! org>
Date:       2000-05-14 3:06:28
[Download RAW message or body]

I did unfortunately have to revert Mirko's commits. KMail can't be left in a 
state where numerous error dialogs pop up every time you start, and breaking 
existing functionality is discouraged most strenously, even adding new 
functionality that is not functionally complete is not encouraged.

Maybe I can modify and recommit Mirko changes in a way that doesn't have adverse 
effects.

I forgot to include the error dialogs, I was receiving nine of them everytime I 
started up KMail. Here are the first two.

"Cannot find kab's configuration template file
kab cannot be configured"


"Your local kab configuration file
"/home/dsanders/.kde/share/apps/kab/kab.config"
could not be created. kab will probably not
work correctly without it.
Make usre you did not remvoe writing permssion
from your local kde directory."

I attach a diff of all Mirko's changes so that any one who wants to comment can 
do so from an informed position.

BFN,
DOn.

On Sun, 14 May 2000, Don Sanders wrote:
> Mirko has checked in some changes to cvs that have broken the address book 
> functionality completely and are causing numerous errors at start up :-(
> 
> I think I'm going to revert his commits.
> 
> Mirko please don't check in stuff that breaks existing functionality. Perhaps 
> it's better if you just leave the address book stuff to me.
> 
> This is what broke.
> 
> I receive numerous error dialogs at start up (see attached lists).
> 
> Auto-completion of email address is broken.
> 
> Cannot access existing address book GUI (support the existing GUI must be 
> retained until it ready to be removed, this is the way things were done for 
> the configuration dialog and the way things are being done for the new pop 
> account).
> 
> BFN,
> Don.

["mirko.diff" (text/plain)]

Index: Makefile.am
===================================================================
RCS file: /home/kde/kdenetwork/kmail/Makefile.am,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -r1.88 -r1.89
--- Makefile.am	2000/05/10 14:11:28	1.88
+++ Makefile.am	2000/05/13 21:49:55	1.89
@@ -1,7 +1,7 @@
 
 SUBDIRS = pics
 INCLUDES = $(all_includes)
-LDADD	= $(LIB_KHTML) -lkspell -lmimelib $(LIB_KFILE)
+LDADD	= $(LIB_KHTML) -lkspell -lmimelib -lkab $(LIB_KFILE)
 
 bin_PROGRAMS = kmail
 
@@ -26,7 +26,8 @@
 		kmundostack.cpp kmbroadcaststatus.cpp \
 		kmacctexppop.cpp configuredialog.cpp colorlistbox.cpp \
                 kmkernel.cpp kmailIface.skel kmailIface.stub main.cpp \
-		accountdialog.cpp
+		accountdialog.cpp \
+		addtoaddressbook.cpp
 
 METASOURCES = kmmainwin.moc kmfolderdia.moc kmfolder.moc \
 		kmfoldertree.moc kmheaders.moc \
Index: kmcomposewin.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmcomposewin.cpp,v
retrieving revision 1.197
retrieving revision 1.198
diff -u -r1.197 -r1.198
--- kmcomposewin.cpp	2000/05/10 14:11:28	1.197
+++ kmcomposewin.cpp	2000/05/13 21:49:55	1.198
@@ -20,8 +20,11 @@
 #include "kbusyptr.h"
 #include "kmmsgpartdlg.h"
 #include "kpgp.h"
-#include "kmaddrbookdlg.h"
-#include "kmaddrbook.h"
+// ----- <mirko>:
+// #include "kmaddrbookdlg.h"
+// #include "kmaddrbook.h"
+#include <kabapi.h>
+// ----- </mirko>
 #include "kfontutils.h"
 #include "kmidentity.h"
 
@@ -83,7 +86,7 @@
 extern KBusyPtr *kbp;
 extern KRNSender *msgSender;
 extern KMIdentity *identity;
-extern KMAddrBook *addrBook;
+extern KabApi *addrBook;
 typedef QList<QWidget> WindowList;
 WindowList* windowList=new WindowList;
 #define aboutText "KRN"
@@ -1310,31 +1313,93 @@
 //-----------------------------------------------------------------------------
 void KMComposeWin::addrBookSelInto(KMLineEdit* aLineEdit)
 {
-  KMAddrBookSelDlg dlg(kernel->addrBook());
-  QString txt;
-
-  //assert(aLineEdit!=NULL);
-  if(!aLineEdit)
+  // ----- <mirko>:
+  /*
+    KMAddrBookSelDlg dlg(kernel->addrBook());
+    QString txt;
+    
+    // assert(aLineEdit!=NULL);
+    if(!aLineEdit)
     {
-      debug("KMComposeWin::addrBookSelInto() : aLineEdit == NULL\n");
-      return;
+    debug("KMComposeWin::addrBookSelInto() : aLineEdit == NULL\n");
+    return;
     }
-  if (dlg.exec()==QDialog::Rejected) return;
-  txt = QString(aLineEdit->text()).stripWhiteSpace();
-  if (!txt.isEmpty())
-  {
+    if (dlg.exec()==QDialog::Rejected) return;
+    txt = QString(aLineEdit->text()).stripWhiteSpace();
+    if (!txt.isEmpty())
+    {
     if (txt.right(1).at(0)!=',') txt += ", ";
     else txt += ' ';
-  }
-  aLineEdit->setText(txt + dlg.address());
+    }
+    aLineEdit->setText(txt + dlg.address());
+  */
+  if(kernel->addrBook()!=0)
+    {
+      if(kernel->addrBook()->addressbook()->noOfEntries()==0)
+	{
+	  KMessageBox::information
+	    (this,
+	     i18n("Your address book does not contain entries."),
+	     i18n("No addresses"));
+	} else {
+	  QString address;
+	  AddressBook::Entry entry;
+	  KabKey key;
+	  for(;;)
+	    {
+	      if(!kernel->addrBook()->exec()) break; // rejected
+	      switch(kernel->addrBook()->getEntry(entry, key))
+		{
+		case AddressBook::NoError: // an entry has been selected
+		  // ----- a test:
+		  if(entry.emails.isEmpty())
+		    { // may be allow to enter one?
+		      KMessageBox::information
+			(this,
+			 i18n("This address has no email address.\n"
+			      "Please try another one."),
+			 i18n("No email addresses"));
+		      continue;
+		    } else {
+		      // ----- assemble address string:
+		      // here you see how to use the AddressBook
+		      // object from the KabApi:
+		      kernel->addrBook()->addressbook()->literalName
+			(entry, address); 
+		      if(entry.emails.count()>1)
+			{ // select one of the addresses:
+			  // ... WORK_TO_DO
+			  // append selected address to address:
+			  address=address + " <" + entry.emails.first()
+			    +">";
+			} else {
+			  address=address + " <" + entry.emails.first()
+			    +">";
+			}
+		      aLineEdit->setText(address);
+		    }
+		  break;
+		default:
+		  KMessageBox::information
+		    (this,
+		     i18n("Some error occured while browsing the address book."),
+		     i18n("Error"));
+		}
+	      break;
+	    }
+	}
+    }
+  // ----- </mirko>
 }
 
 
 //-----------------------------------------------------------------------------
 void KMComposeWin::slotAddrBook()
 {
-  KMAddrBookEditDlg dlg(kernel->addrBook());
-  dlg.exec();
+  // ----- <mirko>:
+  // KMAddrBookEditDlg dlg(kernel->addrBook());
+  // dlg.exec();
+  // ----- </mirko>
 }
 
 
@@ -2206,6 +2271,7 @@
 //-----------------------------------------------------------------------------
 void KMLineEdit::slotCompletion()
 {
+  /*
   QString t;
   QString Name(name());
 
@@ -2269,6 +2335,7 @@
 
   setFocus();
   cursorAtEnd();
+  */
 }
 
 //-----------------------------------------------------------------------------
Index: kmkernel.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- kmkernel.cpp	2000/05/04 07:50:37	1.7
+++ kmkernel.cpp	2000/05/13 21:49:55	1.8
@@ -28,7 +28,11 @@
 #include "kmidentity.h"
 #include "kmacctmgr.h"
 #include "kbusyptr.h"
-#include "kmaddrbook.h"
+// ----- <mirko>: replaced by KabApi:
+// KMAddrBook *the_addrBook;
+// #include "kmaddrbook.h"
+#include <kabapi.h>
+// ----- </mirko>
 
 #include <X11/Xlib.h>
 
@@ -330,16 +334,29 @@
   the_acctMgr   = new KMAcctMgr(acctPath);
   the_filterMgr = new KMFilterMgr;
   the_filterActionDict = new KMFilterActionDict;
-  the_addrBook  = new KMAddrBook;
-
+  // ----- <mirko>: replaced by KabApi:
+  // the_addrBook  = new KMAddrBook;
+  the_addrBook=new KabAPI; // KabApi is a dialog
+  CHECK_PTR(the_addrBook);
+  if(addrBook()->init()!=AddressBook::NoError)
+    { // this connects to the default address book and opens it:
+      KMessageBox::information
+	(0, i18n("Error initializing the connection to your address book.\n"
+		    "The address book will not be available."),
+	 i18n("Error"));
+      the_addrBook=0;
+    } else {
+      debug ("KMKernel::init: KabApi initialized.");
+    }
+  // ----- </mirko>
   initFolders(cfg);
   the_acctMgr->readConfig();
   the_filterMgr->readConfig();
-  the_addrBook->readConfig();
-  if(the_addrBook->load() == IO_FatalError)
-  {
-      KMessageBox::sorry(0, i18n("The addressbook could not be loaded."));
-  }
+  // the_addrBook->readConfig();
+  // if(the_addrBook->load() == IO_FatalError)
+  // {
+  //    KMessageBox::sorry(0, i18n("The addressbook could not be loaded."));
+  // }
   KMMessage::readConfig();
   the_msgSender = new KMSender;
 
Index: kmkernel.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmkernel.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- kmkernel.h	2000/04/22 13:57:35	1.3
+++ kmkernel.h	2000/05/13 21:49:55	1.4
@@ -18,7 +18,10 @@
 class KMAcctMgr;
 class KMFilterMgr;
 class KMFilterActionDict;
-class KMAddrBook;
+// ----- <mirko>: replaced by KabApi:
+// class KMAddrBook;
+class KabAPI;
+// ----- </mirko>
 class KMSender;
 class KMIdentity;
 class KMKernel;
@@ -71,7 +74,10 @@
   inline KMAcctMgr *acctMgr() { return the_acctMgr; }
   inline KMFilterMgr *filterMgr() { return the_filterMgr; }
   inline KMFilterActionDict *filterActionDict() { return the_filterActionDict; }
-  inline KMAddrBook *addrBook() { return the_addrBook; }
+  // ----- <mirko>: replaced by a KabApi object:
+  // inline KMAddrBook *addrBook() { return the_addrBook; }
+  inline KabAPI* addrBook() { return the_addrBook; }
+  // ----- </mirko>
   inline KMSender *msgSender() { return the_msgSender; }
 
   inline bool firstStart() { return the_firstStart; }
@@ -91,7 +97,10 @@
   KMAcctMgr *the_acctMgr;
   KMFilterMgr *the_filterMgr;
   KMFilterActionDict *the_filterActionDict;
-  KMAddrBook *the_addrBook;
+  // ----- <mirko>: replaced by KabApi:
+  // KMAddrBook *the_addrBook;
+  KabAPI *the_addrBook;
+  // ----- </mirko>
   KMSender *the_msgSender;
 
   bool the_firstStart;          // is this the first start?  read from config


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

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