65 } |
65 } |
66 } |
66 } |
67 |
67 |
68 bool SmfServer::startServer() |
68 bool SmfServer::startServer() |
69 { |
69 { |
70 qDebug()<<"Inside SmfServer::startServer()"; |
|
71 |
|
72 bool success = false; |
70 bool success = false; |
73 |
71 |
74 //Initialize all the component handles |
72 //Initialize all the component handles |
75 SmfTransportInitializeResult networkStatus = prepareTransport(); |
73 SmfTransportInitializeResult networkStatus = prepareTransport(); |
76 |
74 |
77 qDebug()<<"Before m_pluginManager construction"; |
|
78 m_pluginManager = SmfPluginManager::getInstance(this); |
75 m_pluginManager = SmfPluginManager::getInstance(this); |
79 qDebug()<<"After m_pluginManager construction"; |
76 qDebug()<<"After m_pluginManager construction"; |
80 |
77 |
81 // m_dataStoreManager = new SmfDataStoreManager(); |
78 // m_dataStoreManager = new SmfDataStoreManager(); |
82 |
79 |
164 } |
161 } |
165 } |
162 } |
166 |
163 |
167 SmfTransportInitializeResult SmfServer::prepareTransport() |
164 SmfTransportInitializeResult SmfServer::prepareTransport() |
168 { |
165 { |
169 qDebug()<<"Inside SmfServer::prepareTransport()"; |
|
170 m_transportManager = SmfTransportManager::getInstance(); |
166 m_transportManager = SmfTransportManager::getInstance(); |
171 |
167 |
172 //checking the network status |
168 //checking the network status |
173 SmfTransportInitializeResult networkStatus = m_transportManager->initializeTransport(); |
169 SmfTransportInitializeResult networkStatus = m_transportManager->initializeTransport(); |
174 qDebug()<<"m_transportManager->initializeTransport() return = "<<networkStatus; |
170 qDebug()<<"m_transportManager->initializeTransport() return = "<<networkStatus; |
175 return networkStatus; |
171 return networkStatus; |
176 } |
172 } |
177 |
173 |
178 void SmfServer::sendToPluginManager ( int requestID, SmfPluginID pluginID, |
174 SmfError SmfServer::sendToPluginManager ( int requestID, SmfPluginID pluginID, |
179 SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID, |
175 SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID, |
180 QByteArray dataForPlugin ) |
176 QByteArray dataForPlugin ) |
181 { |
177 { |
182 qDebug()<<"Inside SmfServer::sendToPluginManager()"; |
178 qDebug()<<"Inside SmfServer::sendToPluginManager()"; |
|
179 Q_UNUSED(interfaceID) |
|
180 #ifdef DETAILEDDEBUGGING |
183 qDebug()<<"Request ID = "<<requestID; |
181 qDebug()<<"Request ID = "<<requestID; |
184 qDebug()<<"PluginID = "<<pluginID; |
182 qDebug()<<"PluginID = "<<pluginID; |
185 qDebug()<<"Interface = "<<interfaceID; |
183 qDebug()<<"Interface = "<<interfaceID; |
186 qDebug()<<"RequestType = "<<requestTypeID; |
184 qDebug()<<"RequestType = "<<requestTypeID; |
187 |
185 #endif |
|
186 |
188 //TODO:-PM should take page info too |
187 //TODO:-PM should take page info too |
189 SmfError err = m_pluginManager->createRequest(requestID,pluginID,requestTypeID,dataForPlugin); |
188 SmfError err = m_pluginManager->createRequest(requestID,pluginID,requestTypeID,dataForPlugin); |
190 qDebug()<<"m_pluginManager->createRequest() = "<<err; |
189 qDebug()<<"m_pluginManager->createRequest() ret value = "<<err; |
|
190 |
|
191 return err; |
191 } |
192 } |
192 |
193 |
193 /** |
194 /** |
194 * Request the Plugin manager to get the data. |
195 * Request the Plugin manager to get the data. |
195 * @param requestID Corresponds to a client's session |
196 * @param requestID Corresponds to a client's session |
200 SmfError SmfServer::sendToPluginManager ( SmfPluginID pluginID, |
201 SmfError SmfServer::sendToPluginManager ( SmfPluginID pluginID, |
201 SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID, |
202 SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID, |
202 QByteArray dataForPlugin, QByteArray &outputData) |
203 QByteArray dataForPlugin, QByteArray &outputData) |
203 { |
204 { |
204 qDebug()<<"Inside SmfServer::sendToPluginManager() for sync req"; |
205 qDebug()<<"Inside SmfServer::sendToPluginManager() for sync req"; |
|
206 Q_UNUSED(interfaceID) |
|
207 #ifdef DETAILEDDEBUGGING |
205 qDebug()<<"PluginID = "<<pluginID; |
208 qDebug()<<"PluginID = "<<pluginID; |
206 qDebug()<<"Interface = "<<interfaceID; |
209 qDebug()<<"Interface = "<<interfaceID; |
207 qDebug()<<"RequestType = "<<requestTypeID; |
210 qDebug()<<"RequestType = "<<requestTypeID; |
|
211 #endif |
208 |
212 |
209 //TODO:-PM should take page info too |
213 //TODO:-PM should take page info too |
210 SmfError err = m_pluginManager->createSyncRequest(pluginID,requestTypeID,dataForPlugin, outputData); |
214 SmfError err = m_pluginManager->createSyncRequest(pluginID,requestTypeID,dataForPlugin, outputData); |
211 qDebug()<<"m_pluginManager->createSyncRequest() = "<<err; |
215 qDebug()<<"m_pluginManager->createSyncRequest() = "<<err; |
212 return err; |
216 return err; |
219 |
223 |
220 DataStoreManager* dsm = DataStoreManager::getDataStoreManager(); |
224 DataStoreManager* dsm = DataStoreManager::getDataStoreManager(); |
221 |
225 |
222 //Note:- deserialization and formation of user profile and social profile are done by server |
226 //Note:- deserialization and formation of user profile and social profile are done by server |
223 QDataStream readStream(&qtdataForDSM,QIODevice::ReadOnly); |
227 QDataStream readStream(&qtdataForDSM,QIODevice::ReadOnly); |
224 QDataStream writeStream(&qtdataFromDSM,QIODevice::ReadOnly); |
228 QDataStream writeStream(&qtdataFromDSM,QIODevice::WriteOnly); |
225 quint8 flag = 0; |
229 quint8 flag = 0; |
226 switch(opcode) |
230 switch(opcode) |
227 { |
231 { |
228 case SmfRelationCreate: |
232 case SmfRelationCreate: |
229 { |
233 { |
230 //read the incoming data |
234 //read the incoming data |
231 SmfProvider provider; |
235 SmfProvider *provider = new SmfProvider(); |
232 SmfContact contact; |
236 SmfContact *contact = new SmfContact(); |
233 readStream>>flag; |
237 readStream>>flag; |
234 if(flag) |
238 if(flag) |
235 readStream>>provider; |
239 readStream>>*provider; |
|
240 else |
|
241 { |
|
242 delete provider; |
|
243 provider = NULL; |
|
244 } |
236 readStream>>flag; |
245 readStream>>flag; |
237 if(flag) |
246 if(flag) |
238 readStream>>contact; |
247 readStream>>*contact; |
239 |
248 else |
240 SmfRelationId relnId = dsm->create(&provider,&contact); |
249 { |
|
250 delete contact; |
|
251 contact = NULL; |
|
252 } |
|
253 SmfRelationId relnId = dsm->create(provider,contact); |
241 writeStream<<relnId; |
254 writeStream<<relnId; |
|
255 if(provider != NULL) |
|
256 delete provider; |
|
257 if(contact != NULL) |
|
258 delete contact; |
242 } |
259 } |
243 break; |
260 break; |
244 case SmfRelationAssociate: |
261 case SmfRelationAssociate: |
245 { |
262 { |
246 SmfRelationId relnId; |
263 SmfRelationId relnId; |
247 SmfContact contact; |
264 SmfContact *contact = new SmfContact(); |
248 SmfProvider provider; |
265 SmfProvider *provider = new SmfProvider(); |
249 readStream>>relnId; |
266 readStream>>relnId; |
250 readStream>>flag; |
267 readStream>>flag; |
251 if(flag) |
268 if(flag) |
252 readStream>>contact; |
269 readStream>>*contact; |
|
270 else |
|
271 { |
|
272 delete contact; |
|
273 contact = NULL; |
|
274 } |
253 readStream>>flag; |
275 readStream>>flag; |
254 if(flag) |
276 if(flag) |
255 readStream>>provider; |
277 readStream>>*provider; |
256 |
278 else |
257 SmfError err = dsm->associate(relnId,&contact,&provider); |
279 { |
|
280 delete provider; |
|
281 provider = NULL; |
|
282 } |
|
283 |
|
284 QString snsName = provider->serviceName(); |
|
285 QString snsUrl = (provider->serviceUrl()).toString(); |
|
286 QString snsDesc = provider->description(); |
|
287 |
|
288 SmfError err = dsm->associate(relnId,contact,provider); |
258 int errInt = err; |
289 int errInt = err; |
259 writeStream<<errInt; |
290 writeStream<<errInt; |
|
291 if(contact != NULL) |
|
292 delete contact; |
|
293 if(provider != NULL) |
|
294 delete provider; |
260 } |
295 } |
261 break; |
296 break; |
262 case SmfRelationRemove: |
297 case SmfRelationRemove: |
263 { |
298 { |
264 SmfRelationId relnId; |
299 SmfRelationId relnId; |
265 SmfContact contact; |
300 SmfContact *contact = new SmfContact(); |
266 readStream>>relnId; |
301 readStream>>relnId; |
267 readStream>>flag; |
302 readStream>>flag; |
268 if(flag) |
303 if(flag) |
269 readStream>>contact; |
304 readStream>>*contact; |
270 |
305 else |
271 SmfError err = dsm->remove(relnId, &contact); |
306 { |
|
307 delete contact; |
|
308 contact = NULL; |
|
309 } |
|
310 SmfError err = dsm->remove(relnId, contact); |
272 int errInt = err; |
311 int errInt = err; |
273 writeStream<<errInt; |
312 writeStream<<errInt; |
|
313 if(NULL != contact) |
|
314 delete contact; |
274 break; |
315 break; |
275 } |
316 } |
276 case SmfRelationSearchById: |
317 case SmfRelationSearchById: |
277 { |
318 { |
278 SmfRelationId relnId; |
319 SmfRelationId relnId; |
380 * TODO:- should use smf wide global errors instead |
421 * TODO:- should use smf wide global errors instead |
381 */ |
422 */ |
382 void SmfServer::resultsAvailable ( int requestID, QByteArray* parsedData, SmfError error ) |
423 void SmfServer::resultsAvailable ( int requestID, QByteArray* parsedData, SmfError error ) |
383 { |
424 { |
384 qDebug()<<"Inside SmfServer::resultsAvailable()"; |
425 qDebug()<<"Inside SmfServer::resultsAvailable()"; |
|
426 #ifdef DETAILEDDEBUGGING |
385 qDebug()<<"requestID = "<<requestID; |
427 qDebug()<<"requestID = "<<requestID; |
386 qDebug()<<"parsedData->size() = "<<parsedData->size(); |
428 qDebug()<<"parsedData->size() = "<<parsedData->size(); |
387 qDebug()<<"Error = "<<error; |
429 qDebug()<<"Error = "<<error; |
388 |
430 #endif |
|
431 |
389 //Serialize error followed by actual data |
432 //Serialize error followed by actual data |
390 QByteArray dataWithError; |
433 QByteArray dataWithError; |
391 QDataStream writer(&dataWithError,QIODevice::WriteOnly); |
434 QDataStream writer(&dataWithError,QIODevice::WriteOnly); |
392 writer<<error; |
435 writer<<error; |
393 if(parsedData->size()) |
436 if(parsedData->size()) |