2
* This file is part of buteo-syncfw package
4
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.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
25
#ifndef SYNCHRONIZER_H
26
#define SYNCHRONIZER_H
28
#include "SyncDBusInterface.h"
29
#include "SyncQueue.h"
30
#include "StorageBooker.h"
31
#include "SyncScheduler.h"
33
#include "SyncCommonDefs.h"
34
#include "ProfileManager.h"
35
#include "PluginManager.h"
36
#include "PluginCbInterface.h"
37
#include "ClientPlugin.h"
41
#include <QCoreApplication>
46
class ContextProperty;
48
/*! \mainpage Harmattan Sync Framework
50
* The Synchronization framework subsystem provides a generic framework for
51
* application developers wanting to develop Synchronization plug-ins for any
52
* synchronization service. It provides a plug-in API for the client, server and the storage
53
* plug-ins in the framework. It also provides services like profile management, sync
54
* controller functionality for sequencing simultaneous sync requests, a sync daemon and
55
* other common sync related functionality. This subsystem also provides an
56
* implementation of the OMA DS SyncML specification. The SyncML engine is provided as a
57
* public API for application developers. It also provides an implementation of the MTP 1.0
58
* specification, but this library interface is not open.
65
class ServerPluginRunner;
66
class TransportTracker;
67
class ServerActivator;
70
/// \brief The main entry point to the synchronization framework.
72
/// This class manages other components and connects them to provide
73
/// the fully functioning synchronization framework.
74
class Synchronizer : public SyncDBusInterface, // Derived from QObject
75
public PluginCbInterface
81
/// \brief The contructor.
82
Synchronizer(QCoreApplication *aApplication);
85
virtual ~Synchronizer();
92
// From PluginCbInterface
93
// ---------------------------------------------------------------------------
95
virtual bool requestStorage(const QString &aStorageName,
96
const SyncPluginBase *aCaller);
98
virtual void releaseStorage(const QString &aStorageName,
99
const SyncPluginBase *aCaller);
101
virtual StoragePlugin* createStorage(const QString &aPluginName);
103
virtual void destroyStorage(StoragePlugin *aStorage);
105
virtual bool isConnectivityAvailable( Sync::ConnectivityType aType );
108
// From SyncDBusInterface
109
// --------------------------------------------------------------------------
113
//! \see SyncDBusInterface::startSync
114
virtual bool startSync(QString aProfileName);
116
//! \see SyncDBusInterface::abortSync
117
virtual void abortSync(QString aProfileName);
119
//! \see SyncDBusInterface::profileChanged
120
virtual void profileChanged(QString aProfileName);
122
//! \see SyncDBusInterface::profileDeleted
123
virtual void profileDeleted(QString aProfileName);
125
//! \see SyncDBusInterface::requestStorages
126
virtual bool requestStorages(QStringList aStorageNames);
128
//! \see SyncDBusInterface::releaseStorages
129
virtual void releaseStorages(QStringList aStorageNames);
131
//! \see SyncDBusInterface::runningSyncs
132
virtual QStringList runningSyncs();
134
// --------------------------------------------------------------------------
136
bool startScheduledSync(QString aProfileName);
140
void storageReleased();
144
/*! \brief Handler for storage released signal.
146
* Tries to start the next sync in queue, which may have been blocked
147
* earlier by storage reservations.
149
void onStorageReleased();
151
void onTransferProgress( const QString &aProfileName,
152
Sync::TransferDatabase aDatabase, Sync::TransferType aType,
153
const QString &aMimeType );
155
void onSessionFinished( const QString &aProfileName,
156
Sync::SyncStatus aStatus, const QString &aMessage, int aErrorCode );
158
void onStorageAccquired(const QString &aProfileName, const QString &aMimeType);
162
void onNewSession(const QString &aDestination);
164
/*! \brief Starts a server plug-in
166
* @param aProfileName Server profile name
168
void startServer(const QString &aProfileName);
170
/*! \brief Stops a server plug-in
172
* @param aProfileName Server profile name
174
void stopServer(const QString &aProfileName);
178
bool startSync(const QString &aProfileName, bool aScheduled);
180
/*! \brief Starts a sync with the given profile.
182
* \param aProfile Profile to use in sync. Ownership is transferred.
183
* The profile is automatically deleted when the sync finishes.
185
bool startSyncNow(SyncSession *aSession);
187
/*! \brief Tries to starts next sync request from the sync queue.
189
* \return Is it possible to try starting more syncs by calling this
190
* function again. Will be true if the first sync request in the queue
191
* is not blocked by already reserved storages.
193
bool startNextSync();
195
void cleanupSession(SyncSession *aSession);
197
/*! \brief Start all server plug-ins
202
/*! \brief Stop all server plug-ins
207
/*! \brief Adds a profile to sync scheduler
209
* @param aProfileName Name of the profile to schedule.
211
void reschedule(const QString &aProfileName);
213
bool isTransportAvailable(const SyncSession *aSession);
215
QMap<QString, SyncSession*> iActiveSessions;
217
QMap<QString, ServerPluginRunner*> iServers;
219
PluginManager iPluginManager;
221
ProfileManager iProfileManager;
223
SyncQueue iSyncQueue;
225
StorageBooker iStorageBooker;
227
SyncScheduler *iSyncScheduler;
229
TransportTracker *iTransportTracker;
231
ServerActivator *iServerActivator;
233
AccountsHelper *iAccounts;
235
ContextProperty *iLowPower;
239
friend class SynchronizerTest;
244
#endif // SYNCHRONIZER_H