2
* This file is part of buteo-sync-plugins-contacts package
4
* Copyright (C) 2015 Canonical Ltd
6
* Contributors: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
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.
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.
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
24
#ifndef UABSTRACTREMOTESOURCE_H
25
#define UABSTRACTREMOTESOURCE_H
29
#include <QVariantMap>
31
#include <QtContacts/QContact>
33
#include <SyncCommonDefs.h>
35
class UAbstractRemoteSourcePrivate;
37
class UAbstractRemoteSource : public QObject
40
Q_DECLARE_PRIVATE(UAbstractRemoteSource)
44
UAbstractRemoteSource(QObject *parent = 0);
45
~UAbstractRemoteSource();
47
virtual void abort() = 0;
48
virtual bool init(const QVariantMap &properties) = 0;
49
virtual void fetchContacts(const QDateTime &since, bool includeDeleted, bool fetchAvatar = true) = 0;
52
* \brief Begins a transaction on the remote database.
57
* \brief Commits a transaction to the remote database.
62
* \brief Rolls back a transaction on the remote database.
66
virtual void saveContacts(const QList<QtContacts::QContact> &contacts);
67
virtual void removeContacts(const QList<QtContacts::QContact> &contacts);
70
void contactsFetched(const QList<QtContacts::QContact> &contacts,
71
Sync::SyncStatus status,
75
* \brief This signal is emitted, when a remote contact is created
76
* \param contacts A list of created contacts
77
* \param status The operation status
79
void contactsCreated(const QList<QtContacts::QContact> &contacts, Sync::SyncStatus status);
82
* \brief This signal is emitted, when a remote contact is changed
83
* \param contacts A list of changed contacts
84
* \param status The operation status
86
void contactsChanged(const QList<QtContacts::QContact> &contacts, Sync::SyncStatus status);
89
* \brief This signal is emitted, when a remote contact is removed
90
* \param ids A list with remoteId of removed contacts
91
* \param status The operation status
93
void contactsRemoved(const QStringList &ids, Sync::SyncStatus status);
96
* \brief This signal is emitted, when a batch operation finishes
97
* \param createdContacts A list of created contacts
98
* \param updatedContacts A list of updated contacts
99
* \param removedContacts A list with remoteId of removed contacts
100
* \param errorMap A map with the list of errors found during the batch operation
101
* the key value contains the contact local id and the value is a int based
102
* on QContactManager::Error enum
103
* \param status The operation status
105
void transactionCommited(const QList<QtContacts::QContact> &createdContacts,
106
const QList<QtContacts::QContact> &updatedContacts,
107
const QStringList &removedContacts,
108
const QMap<QString, int> &errorMap,
109
Sync::SyncStatus status);
112
virtual void batch(const QList<QtContacts::QContact> &contactsToCreate,
113
const QList<QtContacts::QContact> &contactsToUpdate,
114
const QList<QtContacts::QContact> &contactsToRemove) = 0;
116
virtual void saveContactsNonBatch(const QList<QtContacts::QContact> contacts) = 0;
117
virtual void removeContactsNonBatch(const QList<QtContacts::QContact> contacts) = 0;
120
QScopedPointer<UAbstractRemoteSourcePrivate> d_ptr;
123
Q_DECLARE_METATYPE(QList<QtContacts::QContact>)
125
#endif // UABSTRACTREMOTESOURCE_H