~renatofilho/buteo-syncfw/more-verbose

« back to all changes in this revision

Viewing changes to msyncd/SyncDBusInterface.h

  • Committer: Sergey Gerasimenko
  • Date: 2010-06-29 12:51:21 UTC
  • Revision ID: git-v1:cd8dab07b102ac96752ece4f3cde5fc62697d717
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of buteo-syncfw 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
 
 
24
 
 
25
#ifndef SYNCDBUSINTERFACE_H
 
26
#define SYNCDBUSINTERFACE_H
 
27
 
 
28
#include <QtDBus>
 
29
#include <QObject>
 
30
#include <QString>
 
31
 
 
32
namespace Buteo {
 
33
 
 
34
/*!
 
35
 * \brief Defines a D-Bus interface for the sync daemon.
 
36
 *
 
37
 * A XML file describing the interface can be generated from this class using
 
38
 * qdbuscpp2xml tool. This XML file can then be used to generate interface
 
39
 * adaptor and proxy classes using qdbusxml2cpp tool.
 
40
 */
 
41
class SyncDBusInterface : public QObject
 
42
{
 
43
    Q_OBJECT
 
44
    Q_CLASSINFO("D-Bus Interface", "com.nokia.msyncd")
 
45
 
 
46
public:
 
47
 
 
48
signals:
 
49
 
 
50
    /*!
 
51
     * \brief Notifies about a change in synchronization status.
 
52
     *
 
53
     * \param aProfileName Name of the profile used in the sync session whose
 
54
     *  status has changed.
 
55
     * \param aStatus The new status. One of the following:
 
56
     *      0 (QUEUED): Sync request has been queued or was already in the
 
57
     *          queue when sync start was requested.
 
58
     *      1 (STARTED): Sync session has been started.
 
59
     *      2 (PROGRESS): Sync session is progressing.
 
60
     *      3 (ERROR): Sync session has encountered an error and has been stopped,
 
61
     *          or the session could not be started at all.
 
62
     *      4 (DONE): Sync session was successfully completed.
 
63
     *      5 (ABORTED): Sync session was aborted.
 
64
     *  Statuses 3-5 are final, no more status changes will be sent from the
 
65
     *  same sync session.
 
66
     * \param aMessage A message describing the status change in detail. This
 
67
     *  can for example be shown to the user or written to a log
 
68
     * \param aErrorCode When aStatus is ERROR, this parameter contains a
 
69
     *  specific error code.
 
70
     */
 
71
    void syncStatus(QString aProfileName, int aStatus,
 
72
                    QString aMessage, int aErrorCode);
 
73
 
 
74
    /*! \brief Notifies about progress in transferring items
 
75
     *
 
76
     * \param aProfileName Name of the profile where progress has occurred
 
77
     * \param aTransferDatabase Database to which transfer was made. One of the following:
 
78
     *      0 (LOCAL_DATABASE): Transfer was made from remote database to local database
 
79
     *      1 (REMOTE_DATABASE): Transfer was made from local database to remote database
 
80
     * \param aTransferType Type of transfer that was made. One of the following:
 
81
     *      0 (ADDITION): Addition was made to database
 
82
     *      1 (MODIFICATION): Modification was made to database
 
83
     *      2 (DELETION): Deletion was made to database
 
84
     *      3 (ERROR): Addition/Modification/Deletion was attempted, but it failed
 
85
     * \param aMimeType Mime type of the processed item
 
86
     */
 
87
    void transferProgress(QString aProfileName, int aTransferDatabase,
 
88
                          int aTransferType , QString aMimeType);
 
89
 
 
90
    /*! \brief Notifies about a change in profile.
 
91
     *
 
92
     * This signal is sent when the profile data is modified or when a profile
 
93
     * is added or deleted in msyncd.
 
94
     * \param aProfileName Name of the changed profile.
 
95
     * \param aChangeType
 
96
     *      0 (ADDITION): Profile was added.
 
97
     *      1 (MODIFICATION): Profile was modified.
 
98
     *      2 (DELETION): Profile was deleted.
 
99
     */
 
100
    void signalProfileChanged(QString aProfileName, int aChangeType);
 
101
 
 
102
public slots:
 
103
 
 
104
    /*!
 
105
     * \brief Requests to starts synchronizing using a profile with the given
 
106
     *        name.
 
107
     *
 
108
     * A status change signal (QUEUED, STARTED or ERROR) will be sent by the
 
109
     * daemon when the request is processed. If there is a sync already in
 
110
     * progress using the same resources that are needed by the given profile,
 
111
     * adds the sync request to a sync queue. Otherwise a sync session is
 
112
     * started immediately.
 
113
     *
 
114
     * \param aProfileName Name of the profile to use in sync.
 
115
     * \return True if a profile with the given name was found. Otherwise
 
116
     *  false and no status change signals will follow from this request.
 
117
     */
 
118
    virtual bool startSync(QString aProfileName) = 0;
 
119
 
 
120
    /*!
 
121
     * \brief Stops synchronizing the profile with the given name.
 
122
     *
 
123
     * If the sync request is still in queue and not yet started, the queue
 
124
     * entry is removed.
 
125
     *
 
126
     * \param aProfileName Name of the profile to stop syncing.
 
127
     */
 
128
    virtual Q_NOREPLY void abortSync(QString aProfileName) = 0;
 
129
 
 
130
    /*!
 
131
     * \brief This function should be called when sync profile information has
 
132
     *  been changed by someone else than the sync daemon.
 
133
     *
 
134
     * This way the daemon knows to update its information and for example
 
135
     * verify if automatic synchronization settings have changed and take
 
136
     * appropriate actions. Call this function also if a profile is deleted or
 
137
     * a new profile is added.
 
138
     *
 
139
     * \param aProfileName Name of the modified profile. If this is empty, sync
 
140
     *  daemon should refresh information of all profiles.
 
141
     */
 
142
    virtual Q_NOREPLY void profileChanged(QString aProfileName) = 0;
 
143
 
 
144
    /*!
 
145
     * \brief Requests sync daemon to reserve storages for the caller.
 
146
     *
 
147
     * This function must be called if an external sync entity (like Active
 
148
     * Sync engine) wants to use the same storages that the sync daemon uses,
 
149
     * because concurrent access might lead to data corruption. If none of the
 
150
     * requested storages is currently used by the sync daemon, they are all
 
151
     * marked as reserved and can not be used by the daemon until the storages
 
152
     * are freed by calling releaseStorages. If one or more of the requested
 
153
     * storages is already in use, none of them is reserved.
 
154
     *
 
155
     * \param aStorageNames Names of the storages to reserve.
 
156
     * \return Success indicator. True if all requested storages were
 
157
     *  successfully reserved. False if request failed and no storages were
 
158
     *  reserved.
 
159
     */
 
160
    virtual bool requestStorages(QStringList aStorageNames) = 0;
 
161
 
 
162
    /*!
 
163
     * \brief Releases the given storages so that sync daemon can again use
 
164
     *  them freely.
 
165
     *
 
166
     * This function must be called after a successful requestStorages call,
 
167
     * when the reserved storages are not used by the caller any more.
 
168
     */
 
169
    virtual Q_NOREPLY void releaseStorages(QStringList aStorageNames) = 0;
 
170
 
 
171
    /*!
 
172
     * \brief Gets the list of profile names of currently running syncs.
 
173
     *
 
174
     * \return Profile name list.
 
175
     */
 
176
    virtual QStringList runningSyncs() = 0;
 
177
 
 
178
};
 
179
 
 
180
}
 
181
 
 
182
#endif // SYNCDBUSINTERFACE_H