2
* This file is part of buteo-sync-plugins-contacts package
4
* Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
7
* Contributors: Sateesh Kavuri <sateesh.kavuri@gmail.com>
8
* Mani Chandrasekar <maninc@gmail.com>
9
* Renato Araujo Oliveira Filho <renato.filho@canonical.com>
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public License
13
* version 2.1 as published by the Free Software Foundation.
15
* This library is distributed in the hope that it will be useful, but
16
* WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
* Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public
21
* License along with this library; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27
#include "GContactStream.h"
29
#include <UAbstractRemoteSource.h>
32
#include <QScopedPointer>
36
class GRemoteSource : public UAbstractRemoteSource
40
GRemoteSource(QObject *parent = 0);
43
// UAbstractRemoteSource
44
bool init(const QVariantMap &properties);
46
void fetchContacts(const QDateTime &since, bool includeDeleted, bool fetchAvatar = true);
49
const GTransport *transport() const;
53
void saveContactsNonBatch(const QList<QtContacts::QContact> contacts);
54
void removeContactsNonBatch(const QList<QtContacts::QContact> contacts);
56
void batch(const QList<QtContacts::QContact> &contactsToCreate,
57
const QList<QtContacts::QContact> &contactsToUpdate,
58
const QList<QtContacts::QContact> &contactsToRemove);
61
void networkRequestFinished();
62
void networkError(int errorCode);
67
STATE_FETCHING_CONTACTS,
72
QScopedPointer<GTransport> mTransport;
80
QMap<QString, QPair<QString, QUrl> > mLocalIdToAvatar;
81
QMap<QString, QContact> mLocalIdToContact;
82
QMultiMap<GoogleContactStream::UpdateType, QPair<QtContacts::QContact, QStringList> > mPendingBatchOps;
84
void fetchAvatars(QList<QtContacts::QContact> *contacts);
85
void uploadAvatars(QList<QContact> *contacts);
86
void fetchRemoteContacts(const QDateTime &since, bool includeDeleted, int startIndex);
87
void batchOperationContinue();
88
int parseErrorReponse(const GoogleContactAtom::BatchOperationResponse &response);
89
void emitTransactionCommited(const QList<QtContacts::QContact> &created,
90
const QList<QtContacts::QContact> &changed,
91
const QList<QContact> &removed,
92
const QMap<QString, int> &errorMap,
93
Sync::SyncStatus status);