HarmattanSyncApplications
SyncMLServer.h
1/*
2* This file is part of buteo-sync-plugins package
3*
4* Copyright (C) 2013 Jolla Ltd. and/or its subsidiary(-ies).
5*
6* Author: Sateesh Kavuri <sateesh.kavuri@gmail.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#ifndef SYNCMLSERVER_H
23#define SYNCMLSERVER_H
24
25#include "syncmlserver_global.h"
26#include "USBConnection.h"
27#include "BTConnection.h"
28#include "SyncMLStorageProvider.h"
29
30#include <buteosyncfw5/ServerPlugin.h>
31#include <buteosyncfw5/SyncPluginLoader.h>
32#include <buteosyncfw5/SyncCommonDefs.h>
33#include <buteosyncfw5/SyncResults.h>
34#include <buteosyncml5/StorageProvider.h>
35#include <buteosyncml5/SyncAgent.h>
36#include <buteosyncml5/Transport.h>
37#include <buteosyncml5/SyncAgentConfig.h>
38#include <buteosyncml5/OBEXTransport.h>
39
40namespace Buteo {
41 class ServerPlugin;
42 class Profile;
43}
44
45namespace DataSync {
46 class SyncAgent;
47 class Transport;
48}
49class SYNCMLSERVERSHARED_EXPORT SyncMLServer : public Buteo::ServerPlugin
50{
51 Q_OBJECT
52
53public:
54 SyncMLServer (const QString& pluginName,
55 const Buteo::Profile profile,
56 Buteo::PluginCbInterface *cbInterface);
57
58 virtual ~SyncMLServer ();
59
60 virtual bool init ();
61
62 virtual bool uninit ();
63
64 virtual void abortSync (Sync::SyncStatus status = Sync::SYNC_ABORTED);
65
66 virtual bool cleanUp ();
67
68 virtual Buteo::SyncResults getSyncResults () const;
69
70 virtual bool startListen ();
71
72 virtual void stopListen ();
73
74 virtual void suspend ();
75
76 virtual void resume ();
77
78signals:
79
80 void syncFinished (Sync::SyncStatus);
81
82 void sessionInProgress (Sync::ConnectivityType);
83
84
85public slots:
86
87 virtual void connectivityStateChanged (Sync::ConnectivityType type, bool state);
88
89protected slots:
90
91 void handleUSBConnected (int fd);
92
93 void handleBTConnected (int fd, QString btAddr);
94
95 void handleSyncFinished (DataSync::SyncState state);
96
97 void handleStateChanged (DataSync::SyncState state);
98
99 void handleStorageAccquired (QString storageType);
100
101 void handleItemProcessed (DataSync::ModificationType modificationType,
102 DataSync::ModifiedDatabase modifiedDb,
103 QString localDb,
104 QString dbType, int committedItems);
105private:
106
107 bool initSyncAgent ();
108
109 void closeSyncAgent ();
110
111 void closeUSBTransport ();
112
113 void closeBTTransport ();
114
115 DataSync::SyncAgentConfig *initSyncAgentConfig ();
116
117 void closeSyncAgentConfig ();
118
119 bool initStorageProvider ();
120
121 bool createUSBTransport ();
122
123 bool createBTTransport ();
124
125 bool startNewSession (QString address);
126
127 void generateResults (bool success);
128
129 QMap<QString, QString> mProperties;
130
131 DataSync::SyncAgent* mAgent;
132
133 DataSync::SyncAgentConfig* mConfig;
134
135 USBConnection mUSBConnection;
136
137 BTConnection mBTConnection;
138
139 DataSync::Transport* mTransport;
140
141 Buteo::SyncResults mResults;
142
143 SyncMLStorageProvider mStorageProvider;
144
145 qint32 mCommittedItems;
146
150 Sync::ConnectivityType mConnectionType;
151
155 bool mIsSessionInProgress;
156
160 bool mBTActive;
161
165 bool mUSBActive;
166};
167
168class SyncMLServerLoader : public Buteo::SyncPluginLoader
169{
170 Q_OBJECT
171 Q_PLUGIN_METADATA(IID "com.buteo.plugins.sync.SyncMLServerLoader")
172 Q_INTERFACES(Buteo::SyncPluginLoader)
173
174public:
182 Buteo::ServerPlugin* createServerPlugin(const QString& pluginName,
183 const Buteo::Profile& profile,
184 Buteo::PluginCbInterface* cbInterface) override;
185};
186
187
188
189#endif // SYNCMLSERVER_H
Class for creating a connection to another device over Bluetooth for libmeegosyncml.
Definition clientplugins/syncmlclient/BTConnection.h:45
Definition SyncMLServer.h:169
Buteo::ServerPlugin * createServerPlugin(const QString &pluginName, const Buteo::Profile &profile, Buteo::PluginCbInterface *cbInterface) override
Creates SyncML server plugin.
Definition SyncMLServer.h:50
Module that provides storages to libmeegosyncml in syncml client/server plugins.
Definition debian/tmp/usr/include/syncmlcommon/SyncMLStorageProvider.h:44
Class for creating connection to a PC that acts as a USB host for synchronization of data using buteo...
Definition USBConnection.h:41