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/koaddresspluginloader.cpp | |
download | kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2 |
Initial revision
Diffstat (limited to 'libkabcwrap/koaddresspluginloader.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkabcwrap/koaddresspluginloader.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
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; + +} |