[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [RFC] Remove Traditional KMail addressbook (2)
From: Don Sanders <sanders () trolltech ! com>
Date: 2001-11-17 15:28:51
[Download RAW message or body]
If anyone is interested I attach some changes so that KMail
uses kabc when KAddressbook is the chosen addressbook. Only
two changes were required, one, the "..." dialog in the
composer (KMAddrBookSelDlg) uses kabc and shows
distribution lists. Two the completion in the lineedits in
the compser uses kabc and includes distribution lists.
Todo:
Write the distribution list expansion code.
Write code to insert entries from the traditional address
book backend into kabc.
Remove the traditional addressbook gui, (KMAddrBookEditDlg).
Unless someone wants it kept, anyone?
Port KAB (the app) and the KAB specific
right-click-in-the-readerwindow-to-add-an-email-to-the-addressbook
functionality to kabc.
I consider this last one outside the scope of what I want to
do. I guess if KAB (the app) isn't ported to kabc, we
should disable support for it in KMail. I want to strip out
all libkab related code in KMail and alll traditional
backend code. This will simplify the code a little.
The patch attached complements the KAddressbook patch I gave
earlier.
Oh, kabc is outputting really way to much debug info, it
slows it down noticeable.
Don.
["distribution.diff" (text/x-diff)]
? kmcomposewin.cpp.org
? kmsender.cpp.mod
? distribution.diff
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdenetwork/kmail/Makefile.am,v
retrieving revision 1.125
diff -d -u -b -r1.125 Makefile.am
--- Makefile.am 2001/11/02 09:32:23 1.125
+++ Makefile.am 2001/11/17 15:10:08
@@ -2,7 +2,7 @@
SUBDIRS = . about pics
INCLUDES = -I$(top_srcdir)/libkdenetwork -I$(top_srcdir)/mimelib $(all_includes)
-LDADD = $(LIB_KHTML) ../libkdenetwork/libkdenetwork.la -lkspell \
../mimelib/libmimelib.la $(LIB_KAB) +LDADD = $(LIB_KHTML) \
../libkdenetwork/libkdenetwork.la -lkspell ../mimelib/libmimelib.la $(LIB_KAB) -lkabc \
bin_PROGRAMS = kmail
Index: kmaddrbook.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmaddrbook.cpp,v
retrieving revision 1.42
diff -d -u -b -r1.42 kmaddrbook.cpp
--- kmaddrbook.cpp 2001/10/11 14:14:59 1.42
+++ kmaddrbook.cpp 2001/11/17 15:10:08
@@ -19,6 +19,8 @@
#include "kmaddrbookdlg.h" // for kmaddrbookexternal
#include <krun.h> // for kmaddrbookexternal
#include "addtoaddressbook.h"
+#include <kabc/stdaddressbook.h>
+#include <kabc/distributionlist.h>
//-----------------------------------------------------------------------------
KMAddrBook::KMAddrBook(): KMAddrBookInherited()
@@ -321,8 +323,60 @@
return true;
}
+//-----------------------------------------------------------------------------
+void KabcBridge::addresses(QStringList* result) // includes lists
+{
+ QString addr, email;
+ KABC::AddressBook *addressBook = KABC::StdAddressBook::self();
+ KABC::AddressBook::Iterator it;
+ for( it = addressBook->begin(); it != addressBook->end(); ++it ) {
+ QStringList emails = (*it).emails();
+ QString n = (*it).prefix() + " " +
+ (*it).givenName() + " " +
+ (*it).additionalName() + " " +
+ (*it).familyName() + " " +
+ (*it).suffix();
+ n = n.simplifyWhiteSpace();
+ for( unsigned int i = 0; i < emails.count(); ++i ) {
+ if (!emails[i].isEmpty()) {
+ if (n.isEmpty() || (emails[i].find( "<" ) != -1))
+ addr = "";
+ else { /* do we really need quotes around this name ? */
+ if (n.find(QRegExp("[^ 0-9A-Za-z\\x0080-\\xFFFF]")) != -1)
+ addr = "\"" + n + "\" ";
+ else
+ addr = n + " ";
+ }
+ email = emails[i];
+ if (!addr.isEmpty() && (email.find( "<" ) == -1)
+ && (email.find( ">" ) == -1)
+ && (email.find( "," ) == -1))
+ addr += "<" + email + ">";
+ else
+ addr += email;
+ addr.stripWhiteSpace();
+ result->append( addr );
+ }
+ }
+ }
+ KABC::DistributionListManager manager( addressBook );
+ manager.load();
+ qDebug( "listNames.count() %d", manager.listNames().count() );
+ QStringList names = manager.listNames();
+ QStringList::Iterator jt;
+ for ( jt = names.begin(); jt != names.end(); ++jt)
+ result->append( *jt );
+ result->sort();
+}
+
//-----------------------------------------------------------------------------
+QString KabcBridge::expandList(QString list)
+{
+ return list;
+}
+
+//-----------------------------------------------------------------------------
void KMAddrBookExternal::addEmail(QString addr, QWidget *parent) {
KConfig *config = kapp->config();
KConfigGroupSaver saver(config, "General");
@@ -375,6 +429,19 @@
int ab = config->readNumEntry("addressbook", 3);
if (ab <= 0)
return false;
+ if (ab == 3)
+ return false;
+ return true;
+}
+
+bool KMAddrBookExternal::useKABC()
+{
+ KConfig *config = kapp->config();
+ KConfigGroupSaver saver(config, "General");
+ int ab = config->readNumEntry("addressbook", 3);
+ if (ab == 3) // or 1?
return true;
+ return false;
}
+
Index: kmaddrbook.h
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmaddrbook.h,v
retrieving revision 1.11
diff -d -u -b -r1.11 kmaddrbook.h
--- kmaddrbook.h 2001/06/09 02:18:31 1.11
+++ kmaddrbook.h 2001/11/17 15:10:08
@@ -78,11 +78,18 @@
static bool replace(QString address, KabKey);
};
+class KabcBridge {
+public:
+ static void addresses(QStringList* result);
+ static QString expandList(QString list);
+};
+
class KMAddrBookExternal {
public:
static void addEmail(QString addr, QWidget *parent);
static void launch(QWidget *parent);
static bool useKAB();
+ static bool useKABC();
};
#endif /*KMAddrBook_h*/
Index: kmaddrbookdlg.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmaddrbookdlg.cpp,v
retrieving revision 1.35
diff -d -u -b -r1.35 kmaddrbookdlg.cpp
--- kmaddrbookdlg.cpp 2001/10/12 14:17:10 1.35
+++ kmaddrbookdlg.cpp 2001/11/17 15:10:09
@@ -78,15 +78,20 @@
mListBox->clear();
if ( addressTypes & AddressBookAddresses ) {
- if (!KMAddrBookExternal::useKAB()) {
- QStringList::ConstIterator it = mAddrBook->begin();
- for ( ; it != mAddrBook->end(); ++it)
- mListBox->insertItem(*it);
+ if (KMAddrBookExternal::useKABC()) {
+ QStringList addresses;
+ KabcBridge::addresses(&addresses);
+ mListBox->insertStringList(addresses);
}
- else {
+ else if (KMAddrBookExternal::useKAB()) {
QStringList addresses;
KabBridge::addresses(&addresses);
mListBox->insertStringList(addresses);
+ }
+ else {
+ QStringList::ConstIterator it = mAddrBook->begin();
+ for ( ; it != mAddrBook->end(); ++it)
+ mListBox->insertItem(*it);
}
}
mListBox->sort();
Index: kmcomposewin.cpp
===================================================================
RCS file: /home/kde/kdenetwork/kmail/kmcomposewin.cpp,v
retrieving revision 1.426
diff -d -u -b -r1.426 kmcomposewin.cpp
--- kmcomposewin.cpp 2001/11/15 22:23:38 1.426
+++ kmcomposewin.cpp 2001/11/17 15:10:12
@@ -2774,18 +2774,23 @@
if(adb.load() == IO_FatalError)
return;
-
- if (!KMAddrBookExternal::useKAB()) {
- QStringList::ConstIterator it = adb.begin();
- for ( ; it != adb.end(); ++it )
+ if (KMAddrBookExternal::useKABC()) {
+ QStringList addresses;
+ KabcBridge::addresses(&addresses);
+ QStringList::Iterator it = addresses.begin();
+ for (; it != addresses.end(); ++it)
s_completion->addItem( *it );
}
-
- else {
+ else if (KMAddrBookExternal::useKAB()) {
QStringList addresses;
KabBridge::addresses(&addresses);
QStringList::Iterator it = addresses.begin();
for (; it != addresses.end(); ++it)
+ s_completion->addItem( *it );
+ }
+ else {
+ QStringList::ConstIterator it = adb.begin();
+ for ( ; it != adb.end(); ++it )
s_completion->addItem( *it );
}
}
_______________________________________________
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