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 | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | pluginopiekabc/opieaddressbook.cpp | 33 | ||||
-rw-r--r-- | pluginopiekabc/opieaddressbook.h | 63 | ||||
-rw-r--r-- | pluginopiekabc/opieaddressbookplugin.cpp | 71 | ||||
-rw-r--r-- | pluginopiekabc/opieaddressbookplugin.h | 19 | ||||
-rw-r--r-- | pluginopiekabc/opieaddressee.cpp | 21 | ||||
-rw-r--r-- | pluginopiekabc/opieaddressee.h | 16 | ||||
-rw-r--r-- | pluginopiekabc/pluginopiekabcE.pro | 27 |
7 files changed, 250 insertions, 0 deletions
diff --git a/pluginopiekabc/opieaddressbook.cpp b/pluginopiekabc/opieaddressbook.cpp new file mode 100644 index 0000000..ff0ef63 --- a/dev/null +++ b/pluginopiekabc/opieaddressbook.cpp | |||
@@ -0,0 +1,33 @@ | |||
1 | #include "opieaddressbook.h" | ||
2 | #include <qstringlist.h> | ||
3 | #include <opie/ocontact.h> | ||
4 | #include <opie/orecordlist.h> | ||
5 | #include <stdio.h> | ||
6 | |||
7 | using namespace KABC; | ||
8 | |||
9 | OpieAddressBook *StdOpieAddressBook::mSelf = 0; | ||
10 | |||
11 | OpieAddressBook::OpieAddressBook() { | ||
12 | access = new OContactAccess("Addressbook"); | ||
13 | } | ||
14 | |||
15 | OpieAddressBook::~OpieAddressBook() { | ||
16 | } | ||
17 | |||
18 | |||
19 | StdOpieAddressBook::StdOpieAddressBook() { | ||
20 | access = new OContactAccess("Addressbook"); | ||
21 | } | ||
22 | |||
23 | StdOpieAddressBook::~StdOpieAddressBook() { | ||
24 | } | ||
25 | |||
26 | OpieAddressBook *StdOpieAddressBook::self() { | ||
27 | if ( !mSelf ) { | ||
28 | mSelf = new StdOpieAddressBook(); | ||
29 | } | ||
30 | return mSelf; | ||
31 | } | ||
32 | |||
33 | \ No newline at end of file | ||
diff --git a/pluginopiekabc/opieaddressbook.h b/pluginopiekabc/opieaddressbook.h new file mode 100644 index 0000000..d2a3b38 --- a/dev/null +++ b/pluginopiekabc/opieaddressbook.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of libkabc. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Library General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Library General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Library General Public License | ||
16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef KABC_STDADDRESSBOOK_H | ||
22 | #define KABC_STDADDRESSBOOK_H | ||
23 | |||
24 | #include <opie/ocontactaccess.h> | ||
25 | #include "opieaddressee.h" | ||
26 | #include "opieaddress.h" | ||
27 | |||
28 | namespace KABC { | ||
29 | |||
30 | class AddressBook { | ||
31 | |||
32 | public: | ||
33 | AddressBook(); | ||
34 | ~AddressBook(); | ||
35 | Addressee::List findByEmail( const QString & ); | ||
36 | |||
37 | protected: | ||
38 | OContactAccess *access; | ||
39 | }; | ||
40 | |||
41 | |||
42 | class StdAddressBook : public AddressBook | ||
43 | { | ||
44 | public: | ||
45 | /** | ||
46 | Return the standard addressbook object. | ||
47 | */ | ||
48 | static AddressBook *self(); | ||
49 | |||
50 | |||
51 | protected: | ||
52 | StdAddressBook(); | ||
53 | ~StdAddressBook(); | ||
54 | |||
55 | void init( bool onlyFastResources ); | ||
56 | |||
57 | private: | ||
58 | static AddressBook *mSelf; | ||
59 | static bool mAutomaticSave; | ||
60 | }; | ||
61 | |||
62 | } | ||
63 | #endif | ||
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 | |||
diff --git a/pluginopiekabc/opieaddressbookplugin.h b/pluginopiekabc/opieaddressbookplugin.h new file mode 100644 index 0000000..1ad1c15 --- a/dev/null +++ b/pluginopiekabc/opieaddressbookplugin.h | |||
@@ -0,0 +1,19 @@ | |||
1 | #include <qwidget.h> | ||
2 | #include <kabc/koaddressbookinterface.h> | ||
3 | #include <kabc/addressee.h> | ||
4 | #include <opie/ocontactaccess.h> | ||
5 | |||
6 | struct OpieAddressBookPlugin : public KOAddressBookInterface { | ||
7 | |||
8 | public: | ||
9 | |||
10 | OpieAddressBookPlugin::OpieAddressBookPlugin(); | ||
11 | QString name(); | ||
12 | KABC::Addressee::List getAddressees(); | ||
13 | KABC::Addressee::List findByEmail(const QString &email); | ||
14 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | ||
15 | Q_REFCOUNT | ||
16 | protected: | ||
17 | OContactAccess *access; | ||
18 | ulong ref; | ||
19 | }; | ||
diff --git a/pluginopiekabc/opieaddressee.cpp b/pluginopiekabc/opieaddressee.cpp new file mode 100644 index 0000000..3325152 --- a/dev/null +++ b/pluginopiekabc/opieaddressee.cpp | |||
@@ -0,0 +1,21 @@ | |||
1 | #include <stdio.h> | ||
2 | #include "opieaddressee.h" | ||
3 | |||
4 | OpieAddressee::OpieAddressee(const OContact & ocontact) { | ||
5 | setOContact(ocontact); | ||
6 | } | ||
7 | |||
8 | OpieAddressee::OpieAddressee() { | ||
9 | empty = true; | ||
10 | } | ||
11 | |||
12 | void OpieAddressee::setOContact(const OContact & ocontact) { | ||
13 | contact = ocontact; | ||
14 | QString id; | ||
15 | id.setNum(contact.uid()); | ||
16 | fName = contact.lastName() + ", " + contact.firstName(); | ||
17 | rName = contact.fullName(); | ||
18 | pEmail = contact.defaultEmail(); | ||
19 | empty = false; | ||
20 | } | ||
21 | |||
diff --git a/pluginopiekabc/opieaddressee.h b/pluginopiekabc/opieaddressee.h new file mode 100644 index 0000000..b0e8b0d --- a/dev/null +++ b/pluginopiekabc/opieaddressee.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #include <opie/ocontact.h> | ||
2 | #include <kabc/addressee.h> | ||
3 | |||
4 | class OpieAddressee : public KABC::Addressee { | ||
5 | |||
6 | public: | ||
7 | |||
8 | OpieAddressee::OpieAddressee(const OContact & contact); | ||
9 | OpieAddressee::OpieAddressee(); | ||
10 | void setOContact(const OContact & contact); | ||
11 | |||
12 | private: | ||
13 | OContact contact; | ||
14 | QString id; | ||
15 | bool empty; | ||
16 | }; | ||
diff --git a/pluginopiekabc/pluginopiekabcE.pro b/pluginopiekabc/pluginopiekabcE.pro new file mode 100644 index 0000000..52adaf1 --- a/dev/null +++ b/pluginopiekabc/pluginopiekabcE.pro | |||
@@ -0,0 +1,27 @@ | |||
1 | TEMPLATE= lib | ||
2 | CONFIG += qt warn_on release | ||
3 | |||
4 | TARGET = opiekabc | ||
5 | OBJECTS_DIR = obj/$(PLATFORM) | ||
6 | MOC_DIR = moc | ||
7 | DESTDIR=$(QPEDIR)/plugins/korganizer | ||
8 | INCLUDEPATH += $(QPEDIR)/include ../libkabcwrap $(OPIEDIR)/include | ||
9 | DEFINES += | ||
10 | LIBS += -L$(QPEDIR)/lib | ||
11 | LIBS += -lmicrokabc | ||
12 | LIBS += -lopie | ||
13 | LIBS += -lqpe | ||
14 | LIBS += -lqte | ||
15 | |||
16 | INTERFACES = \ | ||
17 | |||
18 | #select_attendee_base.ui | ||
19 | |||
20 | HEADERS = \ | ||
21 | opieaddressbookplugin.h \ | ||
22 | opieaddressee.h | ||
23 | |||
24 | SOURCES = \ | ||
25 | opieaddressbookplugin.cpp \ | ||
26 | opieaddressee.cpp | ||
27 | |||