summaryrefslogtreecommitdiffabout
path: root/pluginqtopiakabc/qtopiaaddressbookplugin.cpp
blob: 59d78815df6db6414e5aa717778e262f6e82c306 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <qwidget.h>
#include <qlayout.h>
#include <qlistbox.h>
#include <qpe/pim/contact.h>
#include <select_addressee_base.h>
#include "qtopiaaddressbookplugin.h"
#include "qtopiaaddressee.h"

QtopiaAddressBookPlugin::QtopiaAddressBookPlugin() : ref(0) {
  qDebug("QtopiaAddressBookPlugin::QtopiaAddressBookPlugin");
  access = new AddressBookAccess();
}

QtopiaAddressBookPlugin::~QtopiaAddressBookPlugin() {
  qDebug("QtopiaAddressBookPlugin::~QtopiaAddressBookPlugin");
  delete &access;
}

KABC::Addressee::List QtopiaAddressBookPlugin::getAddressees() {
  
  qDebug("Start: QtopiaAddressBookPlugin::getAddressees");

  AddressBookIterator it(*access);
  const PimContact *contact;
  KABC::Addressee::List result;

  for (contact=it.toFirst(); it.current(); ++it) {
    contact = it.current();
    result.append(QtopiaAddressee(*contact)); 
  }
  
  qDebug("End: QtopiaAddressBookPlugin::getAddressees");
  
  return result;
}

QString QtopiaAddressBookPlugin::name() {
  return "Qtopia addressbook plugin";
}

QRESULT QtopiaAddressBookPlugin::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
    *iface = 0;
    if ( uuid == IID_QUnknown )
      *iface = this;
    else if ( uuid == IID_KOAddressBookInterface )
      *iface = this;
    if ( *iface )
      (*iface)->addRef();
    return QS_OK;
}

Q_EXPORT_INTERFACE()
{
    Q_CREATE_INSTANCE( QtopiaAddressBookPlugin )
}