|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "{License}" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "{LicenseUrl}". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Manasij Roy, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * SMF Server component which handles the client requests and delegates them propoerly to the appropriate component |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef SMFSERVER_H |
|
20 #define SMFSERVER_H |
|
21 #include <QObject> |
|
22 #include<QMap> |
|
23 //SMF wide global const and macros, to be shared among SMF components as well as SMF aware apps |
|
24 #include "smfglobal.h" |
|
25 #include "smfprovider.h" |
|
26 #include "smftransportmanager.h" // Transport Manager |
|
27 /* |
|
28 * Forward declarations |
|
29 * Other components of the SMF |
|
30 */ |
|
31 class SmfTransportManager; |
|
32 class SmfPluginManager; |
|
33 class SmfDataStoreManager; |
|
34 class SmfSettingsAuthManager; |
|
35 class SmfClient; |
|
36 |
|
37 //For the time being, need to change later |
|
38 typedef QString SmfInterfaceID; |
|
39 //For the time being, need to change later |
|
40 typedef QString SmfPluginID; |
|
41 //TODO:- define proper enums after consulting with CM owner |
|
42 typedef int NotificationType; |
|
43 //Private implementation for different platforms |
|
44 #ifdef Q_OS_SYMBIAN |
|
45 class SmfServerSymbian; |
|
46 class SmfServerSymbianSession; |
|
47 #else |
|
48 class SmfServerQt; |
|
49 class SmfServerQtSession; |
|
50 #endif |
|
51 #include "smfcontact.h" |
|
52 #ifdef NO_OTHER_MODULES |
|
53 #include <QTimer> |
|
54 #include <QTextStream> |
|
55 #endif |
|
56 /** |
|
57 * SmfServer manages the client requests and delegates them to the appropriate SMF component, |
|
58 * service the clients asymchronously |
|
59 * |
|
60 */ |
|
61 class SmfServer : public QObject |
|
62 { |
|
63 Q_OBJECT |
|
64 |
|
65 public: |
|
66 |
|
67 SmfServer(QObject* parent = 0); |
|
68 |
|
69 /** |
|
70 * Does the following,- |
|
71 *First it'll check whether server is already running, if already running it'll |
|
72 *simply return |
|
73 *else |
|
74 *it'll start the server exe and initialize all other SMF components |
|
75 *returns whether server is started successfully or not |
|
76 */ |
|
77 bool startServer(); |
|
78 |
|
79 ~SmfServer(){} |
|
80 |
|
81 public: |
|
82 /* |
|
83 * Request the Credential and Settings manager to check whether client has |
|
84 * been authorized previously. |
|
85 * SmfClientAuthID may be same as SID of the client which can be retrieved |
|
86 * if using Symbian Client-Server private implementation. Not supported for |
|
87 * other platforms |
|
88 */ |
|
89 bool isClientAuthorized(SmfClientAuthID clientID); |
|
90 |
|
91 /* |
|
92 * In case the client is yet to be authorized, it starts the authorization |
|
93 * process by triggering Credential Manager. |
|
94 * The SLOT clientAuthorizationFinished is called once its done. |
|
95 * SmfClientAuthID may be same as SID of the client which can be retrieved |
|
96 * if using Symbian Client-Server private implementation. Not supported for |
|
97 * other platforms. |
|
98 */ |
|
99 void authorizeClient(SmfClientAuthID clientID); |
|
100 |
|
101 /* |
|
102 * Requests Plugin Manager to get a list of plugin IDs who implement |
|
103 * the interface interfaceID. |
|
104 * This is used got SmfClient::GetServices () where we need a list of plugins |
|
105 */ |
|
106 void getPlugins(SmfInterfaceID interfaceID, QMap<SmfPluginID,SmfProvider>& pluginIDMap); |
|
107 /** |
|
108 * Same as above, except this is used for rest of the requests where we need |
|
109 * a particular plugin |
|
110 */ |
|
111 SmfPluginID getPlugin(SmfInterfaceID interfaceID,SmfProvider provider); |
|
112 |
|
113 /* |
|
114 * Requests the Credential Manager to filter out non-authorized plugin IDs |
|
115 * from the list and get authorized plugins into authList. |
|
116 */ |
|
117 void getAuthorizedPlugins(QList<SmfPluginID>& list,QList<SmfPluginID>& authList); |
|
118 |
|
119 /* |
|
120 * Prepares the transport. |
|
121 * What it'll do is not yet clear |
|
122 */ |
|
123 void prepareTransport(); |
|
124 /** |
|
125 * DEbugging purpose only |
|
126 */ |
|
127 void writeLog(QString log) const; |
|
128 /* |
|
129 * Delegates the request of the client (to get the data from SN sites) |
|
130 * to the Plugin Manager. |
|
131 * Once the Plugin Manager gets parsed response data it calls the SLOT |
|
132 * resultsAvailable(). |
|
133 * pluginID is the Plugin to be used. |
|
134 * requestTypeID is the function codes(opcodes) used for message passing |
|
135 * betn clien-server. |
|
136 * Note:- Should there be an overloaded function which takes |
|
137 * list of SmfPluginID ? |
|
138 * Note:- SmfPluginManager will invoke resultsAvailable on session object once |
|
139 * it receives parsed data. |
|
140 */ |
|
141 #ifdef Q_OS_SYMBIAN |
|
142 /** |
|
143 * Request the Plugin manager to get the data. |
|
144 * @param requestID Corresponds to a client's session |
|
145 * @param pluginID Plugin for which the request is intended |
|
146 * @param interfaceID Interface name |
|
147 * @param dataForPlugin Data to be sent for this request |
|
148 * |
|
149 */ |
|
150 void getRequestedData(int requestID,SmfPluginID pluginID,SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID,QByteArray dataForPlugin = QByteArray()); |
|
151 #else |
|
152 void getRequestedData(SmfServerQtSession* session,SmfPluginID pluginID, SmfRequestTypeID requestTypeID); |
|
153 #endif |
|
154 |
|
155 public slots: |
|
156 |
|
157 /* |
|
158 * This slot is called when Credential Manager is done with the autherizing |
|
159 * the client for the first time. See isClientAuthorized() and authorizeClient(). |
|
160 * success specifies the success of the authorization, authID is the authentication |
|
161 * ID in case its not same as SID of the client. |
|
162 */ |
|
163 void clientAuthorizationFinished(bool success,SmfClientAuthID authID ); |
|
164 |
|
165 /* |
|
166 * This slot is called as a result of trigger from Plugin manager when the |
|
167 * parsed data is available. |
|
168 * @param requestID The request ID for which result is available |
|
169 * @param parsedData Serialized data |
|
170 */ |
|
171 void resultsAvailable(int requestID,QByteArray* parsedData,SmfError error); |
|
172 |
|
173 /* |
|
174 * Services the client request by sending the requested data. |
|
175 * Note:- This will be handled by private implementation. |
|
176 */ |
|
177 void serviceClient(QByteArray* parsedData); |
|
178 |
|
179 |
|
180 /* |
|
181 * This slot is called for every cleanup timer expiry, in this slot, we need |
|
182 * to call SmfDataStoreManager's API to refresh data store |
|
183 */ |
|
184 void timerExpired(){}; |
|
185 |
|
186 /* |
|
187 * This method is called every time timerExpired slot is trigerred |
|
188 * Fetches the last saved requests through Transport Manager and Plugin Manager |
|
189 * Who will save the last request (Tranport Manager or Data Store Manager) TBD later |
|
190 * |
|
191 */ |
|
192 void runSavedRequest(){}; |
|
193 |
|
194 /* |
|
195 * This slot is called when the data store updates are available as a result of |
|
196 * "runSavedRequest()". |
|
197 * Note:- The "10.4.1.11 updateDatastore" can be merged with this |
|
198 */ |
|
199 void dataStoreUpdateAvailable(QByteArray* respData){Q_UNUSED(respData)}; |
|
200 |
|
201 /** |
|
202 * Request the CM to get the authentication keys for the given pluginID |
|
203 */ |
|
204 void getAuthenticationKeys(int pluginID,QStringList& keys,QStringList& urls); |
|
205 |
|
206 /** |
|
207 * Server calls this method when it receives message from the CM |
|
208 * that authentication keys for the pluginID has expired |
|
209 */ |
|
210 void authenticationKeysExpired(NotificationType type,SmfPluginID id); |
|
211 signals: |
|
212 //None at the moment |
|
213 private: |
|
214 /* |
|
215 * Starts the clean-up timer for data store refresh, called from the "startServer()" |
|
216 * timeOutValue should be picked out from SmfSettingsAuthManager's API |
|
217 */ |
|
218 bool startCleanupTimer(int timeOutValue){Q_UNUSED(timeOutValue) return true;}; |
|
219 |
|
220 |
|
221 private: |
|
222 //private impl |
|
223 #ifdef Q_OS_SYMBIAN |
|
224 SmfServerSymbian* m_SmfServerPrivate; |
|
225 #else |
|
226 SmfServerQt* m_SmfServerPrivate; |
|
227 #endif |
|
228 //Handles of other SMF components |
|
229 SmfTransportManager* m_transportManager; |
|
230 SmfPluginManager* m_pluginManager; |
|
231 SmfDataStoreManager* m_dataStoreManager; |
|
232 SmfSettingsAuthManager* m_settingsAuthManager; |
|
233 SmfClient* m_smfClient; |
|
234 }; |
|
235 |
|
236 |
|
237 #endif // SMFSERVER_H |