From b9aad1f15dc600e4dbe4c62d3fcced6363188ba3 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 26 Jun 2004 19:01:18 +0000 Subject: Initial revision --- (limited to 'pluginopiekabc/opieaddressbookplugin.cpp') 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 @@ +#include +#include +#include +#include +#include +#include +#include "opieaddressbookplugin.h" +#include "opieaddressee.h" + +OpieAddressBookPlugin::OpieAddressBookPlugin() : ref(0) { + + access = new OContactAccess("OpieAddressBookPlugin"); + +} + +KABC::Addressee::List OpieAddressBookPlugin::getAddressees() { + KABC::Addressee::List results; + OContactAccess access("OpieAddressBookPlugin"); + OContactAccess::List::Iterator it; + ORecordList accessList = access.sorted(true,0,0,0); + for(it = accessList.begin(); it != accessList.end(); ++it ) { + OpieAddressee addressee( *it ); + results.append(addressee); + } + return results; +} + +QString OpieAddressBookPlugin::name() { + return QString::QString("OpieAddressBookPlugin"); +} + + +KABC::Addressee::List OpieAddressBookPlugin::findByEmail(const QString &email) { +printf("OpieAddressBookPlugin::findByEmail: email=%s\n", email.ascii()); + KABC::Addressee::List results; + + ORecordList 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); + } + } + return results; + +} + +QRESULT OpieAddressBookPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) +{ +printf("Start: OpieAddressBookPlugin::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: OpieAddressBookPlugin::queryInterface\n"); +} + +Q_EXPORT_INTERFACE() +{ + Q_CREATE_INSTANCE( OpieAddressBookPlugin ) +} + -- cgit v0.9.0.2