summaryrefslogtreecommitdiffabout
path: root/libkabcwrap/koaddresspluginloader.cpp
Side-by-side diff
Diffstat (limited to 'libkabcwrap/koaddresspluginloader.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkabcwrap/koaddresspluginloader.cpp56
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;
+
+}