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" +// ----- : +// #include "kmaddrbookdlg.h" +// #include "kmaddrbook.h" +#include +// ----- #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 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) + // ----- : + /* + 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; + } + } + } + // ----- } //----------------------------------------------------------------------------- void KMComposeWin::slotAddrBook() { - KMAddrBookEditDlg dlg(kernel->addrBook()); - dlg.exec(); + // ----- : + // KMAddrBookEditDlg dlg(kernel->addrBook()); + // dlg.exec(); + // ----- } @@ -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" +// ----- : replaced by KabApi: +// KMAddrBook *the_addrBook; +// #include "kmaddrbook.h" +#include +// ----- #include @@ -330,16 +334,29 @@ the_acctMgr = new KMAcctMgr(acctPath); the_filterMgr = new KMFilterMgr; the_filterActionDict = new KMFilterActionDict; - the_addrBook = new KMAddrBook; - + // ----- : 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."); + } + // ----- 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; +// ----- : replaced by KabApi: +// class KMAddrBook; +class KabAPI; +// ----- 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; } + // ----- : replaced by a KabApi object: + // inline KMAddrBook *addrBook() { return the_addrBook; } + inline KabAPI* addrBook() { return the_addrBook; } + // ----- 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; + // ----- : replaced by KabApi: + // KMAddrBook *the_addrBook; + KabAPI *the_addrBook; + // ----- KMSender *the_msgSender; bool the_firstStart; // is this the first start? read from config