author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /pluginopiekabc/opieaddressbookplugin.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'pluginopiekabc/opieaddressbookplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | pluginopiekabc/opieaddressbookplugin.cpp | 71 |
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 | |||
10 | OpieAddressBookPlugin::OpieAddressBookPlugin() : ref(0) { | ||
11 | |||
12 | access = new OContactAccess("OpieAddressBookPlugin"); | ||
13 | |||
14 | } | ||
15 | |||
16 | KABC::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 | |||
28 | QString OpieAddressBookPlugin::name() { | ||
29 | return QString::QString("OpieAddressBookPlugin"); | ||
30 | } | ||
31 | |||
32 | |||
33 | KABC::Addressee::List OpieAddressBookPlugin::findByEmail(const QString &email) { | ||
34 | printf("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 | |||
53 | QRESULT OpieAddressBookPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | ||
54 | { | ||
55 | printf("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; | ||
64 | printf("End: OpieAddressBookPlugin::queryInterface\n"); | ||
65 | } | ||
66 | |||
67 | Q_EXPORT_INTERFACE() | ||
68 | { | ||
69 | Q_CREATE_INSTANCE( OpieAddressBookPlugin ) | ||
70 | } | ||
71 | |||