HarmattanSyncApplications
ContactsBackend.h
1/*
2 * This file is part of buteo-sync-plugins package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 *
6 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA
21 *
22 */
23#ifndef CONTACTSBACKEND_H_
24#define CONTACTSBACKEND_H_
25
26#include <QContactManager>
27#include <QContact>
28#include <QContactChangeLogFilter>
29#include <QContactId>
30#include <QVersitDocument>
31#include <QStringList>
32
33using namespace QtContacts;
34using namespace QtVersit;
35#define QContactLocalId QContactId
36
37enum VCARD_VERSION { VCARD_VERSION21, VCARD_VERSION30 };
38
40{
41 QString id;
42 QContactManager::Error errorCode;
43};
44
50{
51
52public:
53
58 ContactsBackend(QVersitDocument::VersitType aVerType,
59 const QString &syncTarget,
60 const QString &originId);
61
62
67
72 bool init();
73
78 bool uninit();
79
84 QList<QContactLocalId> getAllContactIds();
85
91 QList<QContactLocalId> getAllNewContactIds(const QDateTime& aTimeStamp);
92
98 QList<QContactLocalId> getAllModifiedContactIds(const QDateTime& aTimeStamp);
99
100
106 QList<QContactLocalId> getAllDeletedContactIds(const QDateTime& aTimeStamp);
107
113 void getContact(const QContactLocalId& aContactId,
114 QContact& aContact);
115
116
122 void getContacts(const QList<QContactLocalId> &aContactIDs,
123 QMap<QString,QString>& aContactData );
129 void getContacts(const QList<QContactLocalId>& aContactIds,
130 QList<QContact>& aContacts);
131
138 bool addContacts( const QStringList &aContactDataList,
139 QMap<int, ContactsStatus> &aStatusMap );
140
141 // Functions for modifying contacts
142
149 QContactManager::Error modifyContact(const QString &id, const QString &contactdata);
150
157 QMap<int, ContactsStatus> modifyContacts(const QStringList &aContactDataList,
158 const QStringList &aContactsIdList);
159
165 QMap<int, ContactsStatus> deleteContacts(const QStringList &aContactIDList);
166
167
172 inline bool batchUpdatesEnabled() { return true; }
173
179 QDateTime lastModificationTime(const QContactLocalId &aContactId);
180
186 QDateTime getCreationTime( const QContact& aContact );
187
193 QList<QDateTime> getCreationTimes( const QList<QContactLocalId>& aContactIds );
194
195
201 QString convertQContactToVCard(const QContact &aContact);
202private: // functions
203
204 QMap<QString, QString> convertQContactListToVCardList \
205 (const QList<QContact> &aContactList);
206 QList<QVersitDocument> convertVCardListToVersitDocumentList \
207 (const QStringList &aVCardList);
208 void prepareContactSave(QList<QContact> *contactList);
209
216 void getSpecifiedContactIds(const QContactChangeLogFilter::EventType aEventType,
217 const QDateTime &aTimeStamp,
218 QList<QContactLocalId> &aIdList);
219
220private: // data
221
222 QContactManager *iReadMgr;
223 QContactManager *iWriteMgr;
224
225 QVersitDocument::VersitType iVCardVer;
226
227 QString iSyncTarget;
228 QString iOriginId;
229};
230
231
232
233
234
235#endif /* CONTACTSBACKEND_H_ */
Harmattan Contact storage plugin backend interface class.
Definition ContactsBackend.h:50
void getContact(const QContactLocalId &aContactId, QContact &aContact)
Get contact data for a given gontact ID as a QContact object.
bool batchUpdatesEnabled()
Tells if batch updates are enabled.
Definition ContactsBackend.h:172
QString convertQContactToVCard(const QContact &aContact)
Converts a QContact to a VCard.
QList< QDateTime > getCreationTimes(const QList< QContactLocalId > &aContactIds)
Returns creation times of the contacts.
QContactManager::Error modifyContact(const QString &id, const QString &contactdata)
Modify a contact that whose data and ID are given as Input.
QDateTime lastModificationTime(const QContactLocalId &aContactId)
Returns the last time the contact was modified.
bool init()
Searches for available storage plugins and sets the manager to that plugin.
void getContacts(const QList< QContactLocalId > &aContactIDs, QMap< QString, QString > &aContactData)
Get multiple contacts at once as vcards.
QList< QContactLocalId > getAllDeletedContactIds(const QDateTime &aTimeStamp)
Return all deleted contacts ids in a QList of QStrings.
bool addContacts(const QStringList &aContactDataList, QMap< int, ContactsStatus > &aStatusMap)
Batch addition of contacts.
QDateTime getCreationTime(const QContact &aContact)
Return creation time of single contact.
QList< QContactLocalId > getAllModifiedContactIds(const QDateTime &aTimeStamp)
Return all modified contact ids in a QList of QStrings.
~ContactsBackend()
Destructor.
bool uninit()
releases the resources held.
ContactsBackend(QVersitDocument::VersitType aVerType, const QString &syncTarget, const QString &originId)
Constructor.
QMap< int, ContactsStatus > deleteContacts(const QStringList &aContactIDList)
Batch deletion of contacts.
QList< QContactLocalId > getAllContactIds()
Return ids of all contacts retrieved from the backend.
QMap< int, ContactsStatus > modifyContacts(const QStringList &aContactDataList, const QStringList &aContactsIdList)
Batch modification.
QList< QContactLocalId > getAllNewContactIds(const QDateTime &aTimeStamp)
Return all new contacts ids in a QList of QStrings.
void getContacts(const QList< QContactLocalId > &aContactIds, QList< QContact > &aContacts)
Get multiple contacts at once as QContact objects.
Definition ContactsBackend.h:40