Buteo Synchronization Framework
PluginRunner.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 
24 #ifndef PLUGINRUNNER_H
25 #define PLUGINRUNNER_H
26 
27 #include <SyncResults.h>
28 #include "SyncCommonDefs.h"
29 #include "SyncPluginBase.h"
30 #include <QObject>
31 #include <QString>
32 
33 namespace Buteo {
34 
35 class PluginManager;
36 class PluginCbInterface;
37 
44 class PluginRunner : public QObject
45 {
46  Q_OBJECT
47 
48 public:
49 
51  enum PluginType {
52  PLUGIN_CLIENT,
53  PLUGIN_SERVER
54  };
55 
65  PluginRunner(PluginType aPluginType, const QString &aPluginName,
66  PluginManager *aPluginMgr, PluginCbInterface *aPluginCbIf,
67  QObject *aParent = 0);
68 
75  virtual bool init() = 0;
76 
81  virtual bool start() = 0;
82 
87  virtual void stop() = 0;
88 
95  virtual void abort(Sync::SyncStatus aStatus = Sync::SYNC_ABORTED) = 0;
96 
103  virtual SyncResults syncResults() = 0;
104 
105 
110  virtual bool cleanUp() = 0;
111 
116  PluginType pluginType() const;
117 
122  QString pluginName() const;
123 
128  virtual SyncPluginBase *plugin() = 0;
129 
130 signals:
132  void transferProgress(const QString &aProfileName,
133  Sync::TransferDatabase aDatabase, Sync::TransferType aType,
134  const QString &aMimeType, int aCommittedItems);
135 
137  void error(const QString &aProfileName, const QString &aMessage, SyncResults::MinorCode aErrorCode);
138 
140  void success(const QString &aProfileName, const QString &aMessage);
141 
143  void storageAccquired (const QString &aMimeType);
144 
146  void syncProgressDetail(const QString &aProfileName, int aProgressDetail);
147 
152  void done();
153 
155  void newSession(const QString &aDestination);
156 
158  void connectivityStateChanged(Sync::ConnectivityType aType, bool aState);
159 
160 protected:
161 
164 
167 
170 
173 
175  QString iPluginName;
176 
177 private:
178 
179 #ifdef SYNCFW_UNIT_TESTS
180  friend class PluginRunnerTest;
181 #endif
182 
183 };
184 
185 }
186 
187 #endif // PLUGINRUNNER_H
Interface which client and server plugins can use to communicate with synchronization daemon.
Definition: PluginCbInterface.h:39
Manages plugins.
Definition: PluginManager.h:56
Base class for running sync plug-ins.
Definition: PluginRunner.h:45
virtual SyncPluginBase * plugin()=0
Gets the plug-in associated with this plug-in runner.
PluginType
Plug-in type: client or server.
Definition: PluginRunner.h:51
virtual bool start()=0
Starts running the plug-in.
PluginType iType
type of the plugin
Definition: PluginRunner.h:172
QString iPluginName
name of the plugin
Definition: PluginRunner.h:175
PluginManager * iPluginMgr
pointer to an instance of plugin manager
Definition: PluginRunner.h:166
void success(const QString &aProfileName, const QString &aMessage)
Definition: moc_PluginRunner.cpp:262
void storageAccquired(const QString &aMimeType)
Definition: moc_PluginRunner.cpp:269
void connectivityStateChanged(Sync::ConnectivityType aType, bool aState)
Definition: moc_PluginRunner.cpp:296
virtual bool cleanUp()=0
Calls the cleanup for the plugin.
void syncProgressDetail(const QString &aProfileName, int aProgressDetail)
Definition: moc_PluginRunner.cpp:276
void done()
Signal sent when the plug-in runner has finished.
Definition: moc_PluginRunner.cpp:283
virtual void abort(Sync::SyncStatus aStatus=Sync::SYNC_ABORTED)=0
Aborts running the plug-in.
virtual SyncResults syncResults()=0
Gets the sync results from the plug-in.
PluginType pluginType() const
Gets the plug-in type.
Definition: PluginRunner.cpp:51
QString pluginName() const
Gets the plug-in name.
Definition: PluginRunner.cpp:58
void transferProgress(const QString &aProfileName, Sync::TransferDatabase aDatabase, Sync::TransferType aType, const QString &aMimeType, int aCommittedItems)
Definition: moc_PluginRunner.cpp:248
void error(const QString &aProfileName, const QString &aMessage, SyncResults::MinorCode aErrorCode)
Definition: moc_PluginRunner.cpp:255
virtual void stop()=0
Stops running the plug-in.
PluginCbInterface * iPluginCbIf
pointer to an instance of synchronizer
Definition: PluginRunner.h:169
void newSession(const QString &aDestination)
Definition: moc_PluginRunner.cpp:289
virtual bool init()=0
Initializes the plug-in runner.
bool iInitialized
Initialization status of the plugin.
Definition: PluginRunner.h:163
PluginRunner(PluginType aPluginType, const QString &aPluginName, PluginManager *aPluginMgr, PluginCbInterface *aPluginCbIf, QObject *aParent=0)
Constructor.
Definition: PluginRunner.cpp:30
Base class for client and server plugins.
Definition: SyncPluginBase.h:46
Contains information about a completed synchronization session.
Definition: SyncResults.h:59
MinorCode
enum value
Definition: SyncResults.h:77