summaryrefslogtreecommitdiffabout
path: root/pluginopiekabc/opieaddressbookplugin.cpp
Unidiff
Diffstat (limited to 'pluginopiekabc/opieaddressbookplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--pluginopiekabc/opieaddressbookplugin.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/pluginopiekabc/opieaddressbookplugin.cpp b/pluginopiekabc/opieaddressbookplugin.cpp
new file mode 100644
index 0000000..0b22289
--- a/dev/null
+++ b/pluginopiekabc/opieaddressbookplugin.cpp
@@ -0,0 +1,71 @@
1#include <stdio.h>
2#include <qwidget.h>
3#include <qlayout.h>
4#include <qlistbox.h>
5#include <opie/ocontact.h>
6#include <opie/orecordlist.h>
7#include "opieaddressbookplugin.h"
8#include "opieaddressee.h"
9
10OpieAddressBookPlugin::OpieAddressBookPlugin() : ref(0) {
11
12 access = new OContactAccess("OpieAddressBookPlugin");
13
14}
15
16KABC::Addressee::List OpieAddressBookPlugin::getAddressees() {
17 KABC::Addressee::List results;
18 OContactAccess access("OpieAddressBookPlugin");
19 OContactAccess::List::Iterator it;
20 ORecordList<OContact> accessList = access.sorted(true,0,0,0);
21 for(it = accessList.begin(); it != accessList.end(); ++it ) {
22 OpieAddressee addressee( *it );
23 results.append(addressee);
24 }
25 return results;
26}
27
28QString OpieAddressBookPlugin::name() {
29 return QString::QString("OpieAddressBookPlugin");
30}
31
32
33KABC::Addressee::List OpieAddressBookPlugin::findByEmail(const QString &email) {
34printf("OpieAddressBookPlugin::findByEmail: email=%s\n", email.ascii());
35 KABC::Addressee::List results;
36
37 ORecordList<OContact> accessList = access->sorted(true,0,0,0);
38 OContactAccess::List::Iterator it;
39 for(it = accessList.begin(); it != accessList.end(); ++it ) {
40 OContact contact = *it;
41 QStringList emailList = contact.emailList();
42 QStringList foundEmails = emailList.grep(email,false);
43 if (foundEmails.count() >= 1) {
44 OpieAddressee a(contact);
45 printf("Found Contact %s\n", a.formattedName().ascii());
46 results.append(a);
47 }
48 }
49 return results;
50
51}
52
53QRESULT OpieAddressBookPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
54{
55printf("Start: OpieAddressBookPlugin::queryInterface\n");
56 *iface = 0;
57 if ( uuid == IID_QUnknown )
58 *iface = this;
59 else if ( uuid == IID_KOAddressBookInterface )
60 *iface = this;
61 if ( *iface )
62 (*iface)->addRef();
63 return QS_OK;
64printf("End: OpieAddressBookPlugin::queryInterface\n");
65}
66
67Q_EXPORT_INTERFACE()
68{
69 Q_CREATE_INSTANCE( OpieAddressBookPlugin )
70}
71