author | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-26 19:01:18 (UTC) |
commit | b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (side-by-side diff) | |
tree | 2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /libkabcwrap | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
-rw-r--r-- | libkabcwrap/README | 30 | ||||
-rw-r--r-- | libkabcwrap/addresseedialog.cpp | 69 | ||||
-rw-r--r-- | libkabcwrap/addresseedialog.h | 17 | ||||
-rw-r--r-- | libkabcwrap/kabcaddressbookplugin.cpp | 84 | ||||
-rw-r--r-- | libkabcwrap/kabcaddressbookplugin.h | 18 | ||||
-rw-r--r-- | libkabcwrap/koaddressbookinterface.h | 21 | ||||
-rw-r--r-- | libkabcwrap/koaddressbookpluginloader.h | 18 | ||||
-rw-r--r-- | libkabcwrap/koaddresspluginloader.cpp | 56 | ||||
-rw-r--r-- | libkabcwrap/libkabcwrapE.pro | 31 | ||||
-rw-r--r-- | libkabcwrap/select_addressee_base.cpp | 50 | ||||
-rw-r--r-- | libkabcwrap/select_addressee_base.h | 34 | ||||
-rw-r--r-- | libkabcwrap/select_addressee_base.ui | 68 |
12 files changed, 496 insertions, 0 deletions
diff --git a/libkabcwrap/README b/libkabcwrap/README new file mode 100644 index 0000000..366d58c --- a/dev/null +++ b/libkabcwrap/README @@ -0,0 +1,30 @@ +KAddressbook-Wrapper für Opie/Qtopia + +Bietet eine transparente Möglichkeit, auf die bekannten +Klassen StdAddressBook und AddresseeDialog zuzugreifen, +während im Hintergrund entsprechende Plugins durch Ansprechen +der Qtopia- bzw. Opie-PIM-API die Adressedaten aufbereiten +und laden. + +Einbinden in KO/Pi: + +In korganizerE.pro: + +- Die Definition KORG_NOKABC entfernen. +- In die INCLUDEPATH den Pfad zum Quellverzeichnis des Wrapper eintragen. +- -lkabc zu den LIBS hinzufügen + +In den Quelldateien incomingdialog.cpp, koeventviewer.cpp und publishdialog.cpp: +- Alle Aufrufe von addressList.size() durch addressList.count() ersetzen. + Beispielsweise durch + perl -i -p -e 's/addressList\.size/addressList.count/g' + +Der Pluginlader erwartet bislang zwei Plugins +libopiekabc.so und libqtopiakabc.so +im Verzeichnis /opt/Qtopia/plugins/korganizer. +Erst wird versucht, libopiekabc.so, dann libqtopiakabc.so zu laden. + +TODOs: +- Fixen Pfad "/opt/Qtopia" rausnehmen. +- AddresseeDialog::getAddressees wird momentan durch <plugin>::getAddressee + ersetzt, weshalb nur ein Adressat auswählbar ist. diff --git a/libkabcwrap/addresseedialog.cpp b/libkabcwrap/addresseedialog.cpp new file mode 100644 index 0000000..e0fe354 --- a/dev/null +++ b/libkabcwrap/addresseedialog.cpp @@ -0,0 +1,69 @@ +#include <qlistview.h> +#include <qmessagebox.h> +#include <qapplication.h> +#include "addresseedialog.h" +#include "select_addressee_base.h" + +using namespace KABC; + +Addressee AddresseeDialog::getAddressee( QWidget *parent ) { + + Addressee result; + if (!getInterface()) { + QMessageBox::warning(parent,"Plugin missing", "Plugins for Qtopia/Opie\naddressbook missing.\nPlease install\nlibqtopiakabc.so/libopiekabc.so\nunder $QPEDIR/plugins/korganizer.\nQtopia-plugin needs libqpepim.", 0L ); + } else { + + // qDebug("Start: AddresseeDialog::getAddressee"); + + Addressee::List list = getAddresseesFromPlugin(); + + SelectAddressee *selAddressee = new SelectAddressee(parent,"SelectAddressee", true); + QListView *contactList = selAddressee->contactList; + contactList->setSelectionMode(QListView::Single); + if (!contactList) { + Addressee emptyAddressee; + return emptyAddressee; + } + + for (uint i=0; i < list.count(); i++) { + Addressee a = list[i]; + QString fullName = a.formattedName(); + QString defaultEmail = a.preferredEmail(); + //qDebug("Adding " + fullName); + QListViewItem *item = new QListViewItem(contactList, fullName, defaultEmail); + } + if ( QApplication::desktop()->width() < 480 ) { + selAddressee->setMinimumWidth( 220 ); + } else { + selAddressee->setMinimumWidth( 440 ); + } + if (selAddressee->exec()) { + QListViewItem *selectedItem = contactList->selectedItem(); + if (selectedItem) { + uint i=0; + for (i=0; i < list.count() && (list[i].formattedName() != selectedItem->text(0)); i++); + if (i<list.count()) { + result = list[i]; + } + } + } + delete selAddressee; + //qDebug("End: AddresseeDialog::getAddressee"); +} + return result; + +} + +Addressee::List AddresseeDialog::getAddressees( QWidget *parent ) { + //qDebug("Start: AddresseeDialog::getAddressees"); + + KOAddressBookInterface *iface = getInterface(); + + Addressee::List results; + if (iface) { + Addressee a = getAddressee(parent); + results.append(a); + } + //qDebug("End: AddresseeDialog::getAddressees"); + return results; +} diff --git a/libkabcwrap/addresseedialog.h b/libkabcwrap/addresseedialog.h new file mode 100644 index 0000000..400214e --- a/dev/null +++ b/libkabcwrap/addresseedialog.h @@ -0,0 +1,17 @@ +#ifndef ADDRESSEE_DIALOG +#define ADDRESSEE_DIALOG + +#include "addressee.h" +#include "koaddressbookpluginloader.h" + +namespace KABC { + +class AddresseeDialog : public KOAddressBookPluginLoader { + + public: + static Addressee getAddressee( QWidget *parent ); + static Addressee::List getAddressees( QWidget *parent ); + +}; +} +#endif diff --git a/libkabcwrap/kabcaddressbookplugin.cpp b/libkabcwrap/kabcaddressbookplugin.cpp new file mode 100644 index 0000000..25f51d3 --- a/dev/null +++ b/libkabcwrap/kabcaddressbookplugin.cpp @@ -0,0 +1,84 @@ +/*US +#include <qwidget.h> +#include <qlayout.h> +#include <qlistbox.h> +#include <opie/ocontact.h> +#include <opie/orecordlist.h> +#include "opieaddressee.h" +*/ +#include <stdio.h> +#include "kabcaddressbookplugin.h" + +KABCAddressBookPlugin::KABCAddressBookPlugin() : ref(0) { + +//US access = new OContactAccess("OpieAddressBookPlugin"); + +} + +KABC::Addressee::List KABCAddressBookPlugin::getAddressees() { + KABC::Addressee::List results; + + +/*US + OContactAccess access("OpieAddressBookPlugin"); + OContactAccess::List::Iterator it; + ORecordList<OContact> accessList = access.sorted(true,0,0,0); + for(it = accessList.begin(); it != accessList.end(); ++it ) { + OpieAddressee addressee( *it ); + results.append(addressee); + } +*/ + qDebug("KABCAddressBookPlugin::getAddressees has to be implemented"); + + return results; +} + +QString KABCAddressBookPlugin::name() { + return QString::QString("KABCAddressBookPlugin"); +} + + +KABC::Addressee::List KABCAddressBookPlugin::findByEmail(const QString &email) { + +printf("KABCAddressBookPlugin::findByEmail: email=%s\n", email.ascii()); + KABC::Addressee::List results; +/*US + + ORecordList<OContact> accessList = access->sorted(true,0,0,0); + OContactAccess::List::Iterator it; + for(it = accessList.begin(); it != accessList.end(); ++it ) { + OContact contact = *it; + QStringList emailList = contact.emailList(); + QStringList foundEmails = emailList.grep(email,false); + if (foundEmails.count() >= 1) { + OpieAddressee a(contact); + printf("Found Contact %s\n", a.formattedName().ascii()); + results.append(a); + } + } +*/ + qDebug("KABCAddressBookPlugin::findByEmail has to be implemented"); + + return results; + +} + +QRESULT KABCAddressBookPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) +{ +printf("Start: KABCAddressBookPlugin::queryInterface\n"); + *iface = 0; + if ( uuid == IID_QUnknown ) + *iface = this; + else if ( uuid == IID_KOAddressBookInterface ) + *iface = this; + if ( *iface ) + (*iface)->addRef(); + return QS_OK; +printf("End: KABCAddressBookPlugin::queryInterface\n"); +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( KABCAddressBookPlugin ) +} + diff --git a/libkabcwrap/kabcaddressbookplugin.h b/libkabcwrap/kabcaddressbookplugin.h new file mode 100644 index 0000000..0f82744 --- a/dev/null +++ b/libkabcwrap/kabcaddressbookplugin.h @@ -0,0 +1,18 @@ +#include <qwidget.h> +#include <koaddressbookinterface.h> +#include <addressee.h> + +struct KABCAddressBookPlugin : public KOAddressBookInterface { + + public: + + KABCAddressBookPlugin::KABCAddressBookPlugin(); + QString name(); + KABC::Addressee::List getAddressees(); + KABC::Addressee::List findByEmail(const QString &email); + QRESULT queryInterface( const QUuid&, QUnknownInterface** ); + Q_REFCOUNT + protected: +// OContactAccess *access; + ulong ref; +}; diff --git a/libkabcwrap/koaddressbookinterface.h b/libkabcwrap/koaddressbookinterface.h new file mode 100644 index 0000000..3889d2a --- a/dev/null +++ b/libkabcwrap/koaddressbookinterface.h @@ -0,0 +1,21 @@ +#ifndef KO_ADDRESS_BOOK_INTERFACE_H +#define KO_ADDRESS_BOOK_INTERFACE_H + +#include <qwidget.h> +#include <qpe/qcom.h> +#include "addressee.h" + +#ifndef QT_NO_COMPONENT +#ifndef IID_KOAddressBookInterface +#define IID_KOAddressBookInterface QUuid( 0x7505e192, 0x4977, 0x465a, 0xb7, 0x2f, 0x0a, 0x8d, 0xd4, 0x91, 0xcf, 0x43) +#endif +#endif + +struct KOAddressBookInterface : public QUnknownInterface { + + virtual QString name() = 0; + virtual KABC::Addressee::List getAddressees() = 0; + +}; +#endif + diff --git a/libkabcwrap/koaddressbookpluginloader.h b/libkabcwrap/koaddressbookpluginloader.h new file mode 100644 index 0000000..0182b29 --- a/dev/null +++ b/libkabcwrap/koaddressbookpluginloader.h @@ -0,0 +1,18 @@ +#ifndef KO_ADDRESS_BOOK_PLUGIN_LOADER_H +#define KO_ADDRESS_BOOK_PLUGIN_LOADER_H + +#include "addressee.h" +#include "koaddressbookinterface.h" + +class KOAddressBookPluginLoader { + + public: + static KOAddressBookInterface *getInterface(); + static KABC::Addressee::List getAddresseesFromPlugin(); + + private: + static KOAddressBookInterface *iface; + static KABC::Addressee::List addresseeList; +}; + +#endif diff --git a/libkabcwrap/koaddresspluginloader.cpp b/libkabcwrap/koaddresspluginloader.cpp new file mode 100644 index 0000000..d329262 --- a/dev/null +++ b/libkabcwrap/koaddresspluginloader.cpp @@ -0,0 +1,56 @@ +#include <stdio.h> +#include <qtopia/qlibrary.h> +#include <qpe/qpeapplication.h> +#include "koaddressbookpluginloader.h" +#include "kabcaddressbookplugin.h" + +KOAddressBookInterface *KOAddressBookPluginLoader::iface = 0; +KABC::Addressee::List KOAddressBookPluginLoader::addresseeList; + +KOAddressBookInterface *KOAddressBookPluginLoader::getInterface() { + + qDebug("Start: KOAddressBookPluginLoader::getInterface"); + + if (!iface) { + + const QString & qpeDir = QPEApplication::qpeDir(); + QLibrary *lib = new QLibrary( qpeDir + "/plugins/korganizer/libopiekabc.so", QLibrary::Immediately ); + QRESULT q = lib->queryInterface( IID_QUnknown, (QUnknownInterface**)&iface ); + if ( q != QS_OK ) { + lib = new QLibrary( qpeDir + "/plugins/korganizer/libqtopiakabc.so", QLibrary::Immediately ); + QRESULT q = lib->queryInterface( IID_QUnknown, (QUnknownInterface**)&iface ); + // we checked now for all known external interfaces. If no were found, use the default KABC interface + if ( q != QS_OK ) { + iface = new KABCAddressBookPlugin(); + } + } + } + + qDebug("End: KOAddressBookPluginLoader::getInterface"); + return iface; + +} + +KABC::Addressee::List KOAddressBookPluginLoader::getAddresseesFromPlugin() { + + qDebug("Start: KOAddressBookPluginLoader::getAddresseesFromPlugin"); + addresseeList.clear(); + if (!(addresseeList.count() > 0)) { + qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: no addresses loaded. Loading..."); + if (!iface) { + qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: no interface loaded. Loading..."); + iface = getInterface(); + } + if (iface) { + qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: interface is " + iface->name()); + addresseeList = iface->getAddressees(); + } else { + qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: No interface found!"); + } + } + + + qDebug("End: KOAddressBookPluginLoader::getAddresseesFromPlugin"); + return addresseeList; + +} diff --git a/libkabcwrap/libkabcwrapE.pro b/libkabcwrap/libkabcwrapE.pro new file mode 100644 index 0000000..c0f1fe5 --- a/dev/null +++ b/libkabcwrap/libkabcwrapE.pro @@ -0,0 +1,31 @@ +TEMPLATE = lib +CONFIG += qt warn_on release + +TARGET = microkabcwrap +OBJECTS_DIR = obj/$(PLATFORM) +MOC_DIR = moc +DESTDIR=$(QPEDIR)/lib +INCLUDEPATH += . $(QPEDIR)/include ../kabc ../microkde ../microkde/kdecore +DEFINES += +LIBS += -lmicrokabc +LIBS += -L$(QPEDIR)/lib +#US LIBS += -lqpe +#US LIBS += -lqte + +INTERFACES += select_addressee_base.ui + +HEADERS = \ + addresseedialog.h \ + koaddressbookinterface.h \ + kabcaddressbookplugin.h + +# kabc/addressee.h \ +# kabc/addressbook.h \ +# kabc/stdaddressbook.h \ + +SOURCES = \ + addresseedialog.cpp \ + koaddresspluginloader.cpp \ + kabcaddressbookplugin.cpp +# addressee.cpp \ +# stdaddressbook.cpp \ diff --git a/libkabcwrap/select_addressee_base.cpp b/libkabcwrap/select_addressee_base.cpp new file mode 100644 index 0000000..1b846e2 --- a/dev/null +++ b/libkabcwrap/select_addressee_base.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** Form implementation generated from reading ui file 'select_addressee_base.ui' +** +** Created: Fri Feb 6 04:58:15 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#include "select_addressee_base.h" + +#include <qheader.h> +#include <qlistview.h> +#include <qpushbutton.h> +#include <qlayout.h> +#include <qvariant.h> +#include <qtooltip.h> +#include <qwhatsthis.h> + +/* + * Constructs a SelectAddressee which is a child of 'parent', with the + * name 'name' and widget flags set to 'f' + * + * The dialog will by default be modeless, unless you set 'modal' to + * TRUE to construct a modal dialog. + */ +SelectAddressee::SelectAddressee( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + if ( !name ) + setName( "SelectAddressee" ); + resize( 208, 267 ); + setCaption( tr( "Select adressee" ) ); + SelectAddresseeLayout = new QVBoxLayout( this ); + SelectAddresseeLayout->setSpacing( 6 ); + SelectAddresseeLayout->setMargin( 11 ); + + contactList = new QListView( this, "contactList" ); + contactList->addColumn( tr( "Name" ) ); + contactList->addColumn( tr( "Email" ) ); + SelectAddresseeLayout->addWidget( contactList ); +} + +/* + * Destroys the object and frees any allocated resources + */ +SelectAddressee::~SelectAddressee() +{ + // no need to delete child widgets, Qt does it all for us +} + diff --git a/libkabcwrap/select_addressee_base.h b/libkabcwrap/select_addressee_base.h new file mode 100644 index 0000000..d77b44e --- a/dev/null +++ b/libkabcwrap/select_addressee_base.h @@ -0,0 +1,34 @@ +/**************************************************************************** +** Form interface generated from reading ui file 'select_addressee_base.ui' +** +** Created: Fri Feb 6 04:58:14 2004 +** by: The User Interface Compiler (uic) +** +** WARNING! All changes made in this file will be lost! +****************************************************************************/ +#ifndef SELECTADDRESSEE_H +#define SELECTADDRESSEE_H + +#include <qvariant.h> +#include <qdialog.h> +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QListView; +class QListViewItem; + +class SelectAddressee : public QDialog +{ + Q_OBJECT + +public: + SelectAddressee( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SelectAddressee(); + + QListView* contactList; + +protected: + QVBoxLayout* SelectAddresseeLayout; +}; + +#endif // SELECTADDRESSEE_H diff --git a/libkabcwrap/select_addressee_base.ui b/libkabcwrap/select_addressee_base.ui new file mode 100644 index 0000000..d145b0d --- a/dev/null +++ b/libkabcwrap/select_addressee_base.ui @@ -0,0 +1,68 @@ +<!DOCTYPE UI><UI> +<class>SelectAddressee</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>SelectAddressee</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>208</width> + <height>267</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Select adressee</string> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Name</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Email</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <property stdset="1"> + <name>name</name> + <cstring>contactList</cstring> + </property> + </widget> + </vbox> +</widget> +</UI> |