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 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <qtopia/qlibrary.h> | ||
3 | #include <qpe/qpeapplication.h> | ||
4 | #include "koaddressbookpluginloader.h" | ||
5 | #include "kabcaddressbookplugin.h" | ||
6 | |||
7 | KOAddressBookInterface *KOAddressBookPluginLoader::iface = 0; | ||
8 | KABC::Addressee::List KOAddressBookPluginLoader::addresseeList; | ||
9 | |||
10 | KOAddressBookInterface *KOAddressBookPluginLoader::getInterface() { | ||
11 | |||
12 | qDebug("Start: KOAddressBookPluginLoader::getInterface"); | ||
13 | |||
14 | if (!iface) { | ||
15 | |||
16 | const QString & qpeDir = QPEApplication::qpeDir(); | ||
17 | QLibrary *lib = new QLibrary( qpeDir + "/plugins/korganizer/libopiekabc.so", QLibrary::Immediately ); | ||
18 | QRESULT q = lib->queryInterface( IID_QUnknown, (QUnknownInterface**)&iface ); | ||
19 | if ( q != QS_OK ) { | ||
20 | lib = new QLibrary( qpeDir + "/plugins/korganizer/libqtopiakabc.so", QLibrary::Immediately ); | ||
21 | QRESULT q = lib->queryInterface( IID_QUnknown, (QUnknownInterface**)&iface ); | ||
22 | // we checked now for all known external interfaces. If no were found, use the default KABC interface | ||
23 | if ( q != QS_OK ) { | ||
24 | iface = new KABCAddressBookPlugin(); | ||
25 | } | ||
26 | } | ||
27 | } | ||
28 | |||
29 | qDebug("End: KOAddressBookPluginLoader::getInterface"); | ||
30 | return iface; | ||
31 | |||
32 | } | ||
33 | |||
34 | KABC::Addressee::List KOAddressBookPluginLoader::getAddresseesFromPlugin() { | ||
35 | |||
36 | qDebug("Start: KOAddressBookPluginLoader::getAddresseesFromPlugin"); | ||
37 | addresseeList.clear(); | ||
38 | if (!(addresseeList.count() > 0)) { | ||
39 | qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: no addresses loaded. Loading..."); | ||
40 | if (!iface) { | ||
41 | qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: no interface loaded. Loading..."); | ||
42 | iface = getInterface(); | ||
43 | } | ||
44 | if (iface) { | ||
45 | qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: interface is " + iface->name()); | ||
46 | addresseeList = iface->getAddressees(); | ||
47 | } else { | ||
48 | qDebug("KOAddressBookPluginLoader::getAddresseesFromPlugin: No interface found!"); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | |||
53 | qDebug("End: KOAddressBookPluginLoader::getAddresseesFromPlugin"); | ||
54 | return addresseeList; | ||
55 | |||
56 | } | ||