Buteo Synchronization Framework: SyncPluginBase.h Source File

Buteo Synchronization Framework

SyncPluginBase.h
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 #ifndef SYNCPLUGINBASE_H
24 #define SYNCPLUGINBASE_H
25
26 #include "SyncCommonDefs.h"
27 #include "SyncResults.h"
28 #include "ButeoPluginIface.h"
29
30 #include <QString>
31 #include <QMetaType>
32 #include <QObject>
33 #include <QMap>
34
35 #define DBUS_SERVICE_NAME_PREFIX "com.buteo.msyncd.plugin."
36 #define DBUS_SERVICE_OBJ_PATH "/"
37
38 namespace Buteo {
39
40 class PluginCbInterface;
41
45 class SyncPluginBase : public QObject
46 {
47 Q_OBJECT
48
49 public:
56 SyncPluginBase(const QString &aPluginName,
57 const QString &aProfileName,
58 PluginCbInterface *aCbInterface);
59
64 QString getPluginName() const;
65
70 QString getProfileName() const;
71
80 virtual bool init() = 0;
81
86 virtual bool uninit() = 0;
87
95 virtual void abortSync(Sync::SyncStatus aStatus = Sync::SYNC_ABORTED)
96 {
97 Q_UNUSED(aStatus);
98 }
99
106 virtual bool cleanUp() = 0;
107
116 virtual SyncResults getSyncResults() const;
117
118 signals:
119
129 void transferProgress(const QString &aProfileName, Sync::TransferDatabase aDatabase,
130 Sync::TransferType aType, const QString &aMimeType, int aCommittedItems);
131
139 void error(const QString &aProfileName, const QString &aMessage, SyncResults::MinorCode aErrorCode);
140
146 void success(const QString &aProfileName, const QString &aMessage);
147
152 void accquiredStorage(const QString &aMimeType);
153
159 void syncProgressDetail(const QString &aProfileName, int aProgressDetail);
160
161 public slots:
162
169 virtual void connectivityStateChanged(Sync::ConnectivityType aType, bool aState) = 0;
170
171 protected:
173 PluginCbInterface *iCbInterface;
174
175 struct ReceivedItemDetails {
176 int added;
177 int deleted;
178 int modified;
179 int error;
180 QString mime;
181 };
182
183 QMap<QString, ReceivedItemDetails> receivedItems;
184
185 ButeoPluginIface *iOopPluginIface;
186
187 private:
188 QString iPluginName;
189 QString iProfileName;
190 };
191
192 }
193
194 #endif // SYNCPLUGINBASE_H
ButeoPluginIface
Definition: ButeoPluginIface.h:29
Buteo::PluginCbInterface
Interface which client and server plugins can use to communicate with synchronization daemon.
Definition: PluginCbInterface.h:39
Buteo::SyncPluginBase
Base class for client and server plugins.
Definition: SyncPluginBase.h:46
Buteo::SyncPluginBase::transferProgress
void transferProgress(const QString &aProfileName, Sync::TransferDatabase aDatabase, Sync::TransferType aType, const QString &aMimeType, int aCommittedItems)
Emitted when progress has been made in synchronization in transferring items between local and remote...
Definition: moc_SyncPluginBase.cpp:221
Buteo::SyncPluginBase::syncProgressDetail
void syncProgressDetail(const QString &aProfileName, int aProgressDetail)
Emitted during Sync Progress to indicate the detail of the current ongoing sync.
Definition: moc_SyncPluginBase.cpp:249
Buteo::SyncPluginBase::getPluginName
QString getPluginName() const
Returns the name of this plugin.
Definition: SyncPluginBase.cpp:46
Buteo::SyncPluginBase::success
void success(const QString &aProfileName, const QString &aMessage)
Emitted when synchronization has been finished successfully.
Definition: moc_SyncPluginBase.cpp:235
Buteo::SyncPluginBase::getProfileName
QString getProfileName() const
Returns profile name.
Definition: SyncPluginBase.cpp:51
Buteo::SyncPluginBase::connectivityStateChanged
virtual void connectivityStateChanged(Sync::ConnectivityType aType, bool aState)=0
Slot that is invoked by sync framework when changes occur in connectivity domains.
Buteo::SyncPluginBase::SyncPluginBase
SyncPluginBase(const QString &aPluginName, const QString &aProfileName, PluginCbInterface *aCbInterface)
Constructor.
Definition: SyncPluginBase.cpp:29
Buteo::SyncPluginBase::init
virtual bool init()=0
Initializes the plugin.
Buteo::SyncPluginBase::error
void error(const QString &aProfileName, const QString &aMessage, SyncResults::MinorCode aErrorCode)
Emitted when error has occurred in synchronization and it cannot be continued.
Definition: moc_SyncPluginBase.cpp:228
Buteo::SyncPluginBase::accquiredStorage
void accquiredStorage(const QString &aMimeType)
Emitted when a storage is requested and accquired.
Definition: moc_SyncPluginBase.cpp:242
Buteo::SyncPluginBase::abortSync
virtual void abortSync(Sync::SyncStatus aStatus=Sync::SYNC_ABORTED)
Aborts synchronization.
Definition: SyncPluginBase.h:95
Buteo::SyncPluginBase::getSyncResults
virtual SyncResults getSyncResults() const
Gets the results of the last completed sync session.
Definition: SyncPluginBase.cpp:56
Buteo::SyncPluginBase::uninit
virtual bool uninit()=0
Uninitializes the plugin.
Buteo::SyncPluginBase::cleanUp
virtual bool cleanUp()=0
Cleans up any sync related stuff (e.g sync anchors etc) when the profile is deleted.
Buteo::SyncPluginBase::iCbInterface
PluginCbInterface * iCbInterface
Pointer to synchronizer.
Definition: SyncPluginBase.h:173
Buteo::SyncResults
Contains information about a completed synchronization session.
Definition: SyncResults.h:59
Buteo::SyncResults::MinorCode
MinorCode
enum value
Definition: SyncResults.h:77
QMap
Definition: SyncBackupAdaptor.h:41
Buteo::SyncPluginBase::ReceivedItemDetails
Definition: SyncPluginBase.h:175