~renatofilho/buteo-sync-plugins-contacts/solve-eds-conflict

« back to all changes in this revision

Viewing changes to buteo-contact-client/UAbstractRemoteSource.h

  • Committer: CI Train Bot
  • Author(s): Renato Araujo Oliveira Filho
  • Date: 2015-09-24 17:50:44 UTC
  • mfrom: (1.3.53 initial-vr)
  • Revision ID: ci-train-bot@canonical.com-20150924175044-rp0akjs0h1xwxmpj
Implemented buteo contacts sync plugin for google, heavily based on:
  - https://github.com/nemomobile-graveyard/buteo-sync-plugins-google
  - https://github.com/nemomobile/buteo-sync-plugins-social
Approved by: Michael Sheldon

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of buteo-sync-plugins-contacts package
 
3
 *
 
4
 * Copyright (C) 2015 Canonical Ltd
 
5
 *
 
6
 * Contributors: Renato Araujo Oliveira Filho <renato.filho@canonical.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
 
 
24
#ifndef UABSTRACTREMOTESOURCE_H
 
25
#define UABSTRACTREMOTESOURCE_H
 
26
 
 
27
#include <QObject>
 
28
#include <QDateTime>
 
29
#include <QVariantMap>
 
30
 
 
31
#include <QtContacts/QContact>
 
32
 
 
33
#include <SyncCommonDefs.h>
 
34
 
 
35
class UAbstractRemoteSourcePrivate;
 
36
 
 
37
class UAbstractRemoteSource : public QObject
 
38
{
 
39
    Q_OBJECT
 
40
    Q_DECLARE_PRIVATE(UAbstractRemoteSource)
 
41
 
 
42
public:
 
43
 
 
44
    UAbstractRemoteSource(QObject *parent = 0);
 
45
    ~UAbstractRemoteSource();
 
46
 
 
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;
 
50
 
 
51
    /*!
 
52
     * \brief Begins a transaction on the remote database.
 
53
     */
 
54
    void transaction();
 
55
 
 
56
    /*!
 
57
     * \brief Commits a transaction to the remote database.
 
58
     */
 
59
    bool commit();
 
60
 
 
61
    /*!
 
62
     * \brief Rolls back a transaction on the remote database.
 
63
     */
 
64
    bool rollback();
 
65
 
 
66
    virtual void saveContacts(const QList<QtContacts::QContact> &contacts);
 
67
    virtual void removeContacts(const QList<QtContacts::QContact> &contacts);
 
68
 
 
69
signals:
 
70
    void contactsFetched(const QList<QtContacts::QContact> &contacts,
 
71
                         Sync::SyncStatus status,
 
72
                         qreal progress);
 
73
 
 
74
    /*!
 
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
 
78
     */
 
79
    void contactsCreated(const QList<QtContacts::QContact> &contacts, Sync::SyncStatus status);
 
80
 
 
81
    /*!
 
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
 
85
     */
 
86
    void contactsChanged(const QList<QtContacts::QContact> &contacts, Sync::SyncStatus status);
 
87
 
 
88
    /*!
 
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
 
92
     */
 
93
    void contactsRemoved(const QStringList &ids, Sync::SyncStatus status);
 
94
 
 
95
    /*!
 
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
 
104
     */
 
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);
 
110
 
 
111
protected:
 
112
    virtual void batch(const QList<QtContacts::QContact> &contactsToCreate,
 
113
                       const QList<QtContacts::QContact> &contactsToUpdate,
 
114
                       const QList<QtContacts::QContact> &contactsToRemove) = 0;
 
115
 
 
116
    virtual void saveContactsNonBatch(const QList<QtContacts::QContact> contacts) = 0;
 
117
    virtual void removeContactsNonBatch(const QList<QtContacts::QContact> contacts) = 0;
 
118
 
 
119
private:
 
120
    QScopedPointer<UAbstractRemoteSourcePrivate> d_ptr;
 
121
};
 
122
 
 
123
Q_DECLARE_METATYPE(QList<QtContacts::QContact>)
 
124
 
 
125
#endif // UABSTRACTREMOTESOURCE_H