diff -r 106a4bfcb866 -r 013a02bf2bb0 smf/smfservermodule/smfserver/server/smfserver.cpp --- a/smf/smfservermodule/smfserver/server/smfserver.cpp Thu Aug 05 16:46:37 2010 +0530 +++ b/smf/smfservermodule/smfserver/server/smfserver.cpp Thu Aug 05 16:48:48 2010 +0530 @@ -2,7 +2,7 @@ * Copyright (c) 2010 Sasken Communication Technologies Ltd. * All rights reserved. * This component and the accompanying materials are made available - * under the terms of the "Eclipse Public License v1.0" + * under the terms of the "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html" * @@ -11,82 +11,93 @@ * * Contributors: * Manasij Roy, Nalina Hariharan + * + * Description: + * SMF Server component which handles the client requests and delegates + * them properly to the appropriate component + * */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + #include "smfserver.h" #include "smfpluginmanager.h" #include "smftransportmanager.h" #include "dsm.h" -#include "smfclientglobal.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifdef Q_OS_SYMBIAN + #include "smfserversymbian_p.h" +#else + #include "smfserverqt_p.h" + #include "smfserverqtsession.h" +#endif -#ifdef Q_OS_SYMBIAN -#include "smfserversymbian_p.h" -#else -#include "smfserverqt_p.h" -#include "smfserverqtsession.h" -#endif SmfServer::SmfServer(QObject* parent) : QObject(parent) { + m_transportManager = NULL; + m_pluginManager = NULL; + m_credentialMngr = NULL; } SmfServer::~SmfServer() -{ + { + qDebug()<<"Inside Smfserver::~SmfServer()"; + if(m_transportManager) + delete m_transportManager; + if(m_pluginManager) + delete m_pluginManager; + if(m_credentialMngr) + delete m_credentialMngr; if(m_SmfServerPrivate) { delete m_SmfServerPrivate; m_SmfServerPrivate = NULL; } - -} + } bool SmfServer::startServer() { + qDebug()<<"Inside SmfServer::startServer()"; + bool success = false; + //Initialize all the component handles - SmfTransportInitializeResult networkStatus = prepareTransport(); - qDebug()<<("Before m_pluginManager construction"); + + qDebug()<<"Before m_pluginManager construction"; m_pluginManager = SmfPluginManager::getInstance(this); - qDebug()<<("After m_pluginManager construction"); + qDebug()<<"After m_pluginManager construction"; + // m_dataStoreManager = new SmfDataStoreManager(); + +#ifdef Q_OS_SYMBIAN //Initialize private implementation - #ifdef Q_OS_SYMBIAN TRAPD(err, m_SmfServerPrivate = SmfServerSymbian::NewL(CActive::EPriorityStandard,this)); - QString log("SmfServer::startServer="); - int errorQ = err ; - log += errorQ; - qDebug()<<(log); + qDebug()<<"SmfServerSymbian::NewL() = "<Start( KSmfServerName ); + qDebug()<<"m_SmfServerPrivate->Start = "<Start="); - log += QString::number(error); - qDebug()<<(log); + if( KErrNone == error ) { success = true; @@ -96,18 +107,20 @@ //error return success; } - #else - m_SmfServerPrivate = new SmfServerQt(this); +#else + // For non-symbian platforms + m_SmfServerPrivate = new SmfServerQt(this); success = m_SmfServerPrivate->start(); if (!success) { return success; } - #endif +#endif m_credentialMngr = new SmfCredMgrClient(); return success; } + //Note:- Almost all the following APIs are called by private impl via the handle /** * This API is called by the private impl when client is authorized @@ -117,22 +130,20 @@ * It calls PM to get the list. Note:- PM may return SmfProviderBase which is superset of SmfProvider. * TODO:- session should store this map for future ref? */ -void SmfServer::getPlugins(SmfInterfaceID interfaceID, QMap& pluginIDMap) +void SmfServer::getPlugins(const SmfInterfaceID& interfaceID, QMap& pluginIDMap) { - pluginIDMap.clear(); + qDebug()<<"Inside SmfServer::getPlugins()"; m_pluginManager->getPlugins(interfaceID,pluginIDMap); } -SmfPluginID SmfServer::getPlugin(SmfInterfaceID interfaceID,SmfProvider provider) +SmfPluginID SmfServer::getPlugin(const SmfInterfaceID& interfaceID,SmfProvider provider) { - //TODO:- do it properly as per PM implementation - //return PM->getplugin(interfaceID,provider); - //TODO:- PM is not yet ready + qDebug()<<"Inside SmfServer::getPlugin()"; SmfPluginID id; m_pluginManager->getPluginId(interfaceID,provider, id); return id; - //testing purpose only } + /** * This API is called by the private impl to get a list of authorized plugins from CM * @param list List of plugins to be filtered @@ -143,44 +154,75 @@ */ void SmfServer::getAuthorizedPlugins(QList& list,QList& authList) { - //TODO:-Uncomment the following once authorization flow of plugin is implemented -/* authList.clear(); + qDebug()<<"Inside SmfServer::getAuthorizedPlugins()"; + authList.clear(); for(int i=0;iCheckPluginAuthentication(list[i]); if(isAuthorized) - { authList.append(list[i]); - } - }*/ - authList = list; + } } + SmfTransportInitializeResult SmfServer::prepareTransport() { - qDebug()<<("Before SmfTransportManager::getInstance"); + qDebug()<<"Inside SmfServer::prepareTransport()"; m_transportManager = SmfTransportManager::getInstance(); - qDebug()<<("Before m_transportManager->initializeTransport"); + //checking the network status SmfTransportInitializeResult networkStatus = m_transportManager->initializeTransport(); - qDebug()<<("m_transportManager->initializeTransport return = ")<initializeTransport() return = "<createRequest() = "<createSyncRequest() = "<>provider; - readStream>>contact; + readStream>>flag; + if(flag) + readStream>>provider; + readStream>>flag; + if(flag) + readStream>>contact; SmfRelationId relnId = dsm->create(&provider,&contact); writeStream<>relnId; - readStream>>contact; - readStream>>provider; + readStream>>flag; + if(flag) + readStream>>contact; + readStream>>flag; + if(flag) + readStream>>provider; SmfError err = dsm->associate(relnId,&contact,&provider); int errInt = err; writeStream<>relnId; + readStream>>flag; + if(flag) + readStream>>contact; + + SmfError err = dsm->remove(relnId, &contact); + int errInt = err; + writeStream<>relnId; SmfRelationItem* relnItem = dsm->searchById(relnId); - writeStream<<*(relnItem); + quint8 flag = 1; + if(relnItem) + { + writeStream<>contact; + + SmfRelationId relnId = dsm->searchByContact(contact); + writeStream<>relationId; readStream>>index; SmfRelationItem* relnItem = dsm->getContact(relationId,index); - writeStream<>relnId; + SmfError err = dsm->deleteRelation(relnId); + int errInt = err; + writeStream<clientathorizationFinished(success); + authID.session->clientAuthorizationFinished(success); } + /** * This API is called by PM once its done with request and parsing * @param requestID The request id which is completed @@ -274,15 +379,13 @@ * @param error Error occured * TODO:- should use smf wide global errors instead */ -void SmfServer::resultsAvailable(int requestID,QByteArray* parsedData,SmfError error) +void SmfServer::resultsAvailable ( int requestID, QByteArray* parsedData, SmfError error ) { - qDebug()<<("SmfServer::resultsAvailable"); - qDebug()<<("requestID="); - qDebug()<<(QString::number(requestID)); - qDebug()<<("parsedData->size()="); - qDebug()<<(QString::number(parsedData->size())); - qDebug()<<("Error="); - qDebug()<<(QString::number(error)); + qDebug()<<"Inside SmfServer::resultsAvailable()"; + qDebug()<<"requestID = "<size() = "<size(); + qDebug()<<"Error = "<findAndServiceclient(requestID,&dataWithError,error); } -/** - * Seems reduntant - */ -void SmfServer::serviceClient(QByteArray* parsedData) - { - Q_UNUSED(parsedData) - } + /** * This is called when CMclient notifies client expiry. * @param type notification type, set of enums for future expansion @@ -313,20 +411,16 @@ //resend the notify request //CMclient->requestAuthExpiryNotify(); } -/*void SmfServer::writeLog(QString log) const + +#ifdef CLIENT_SERVER_TEST +/** + * Seems reduntant + */ +/*void SmfServer::serviceClient(QByteArray* parsedData) { -#ifdef WRITE_LOG - QFile file("c:\\data\\SmfServerLogs.txt"); - if (!file.open(QIODevice::Append | QIODevice::Text)) - ; - QTextStream out(&file); - out << log << "\n"; - file.close(); -#else - Q_UNUSED(log) -#endif + Q_UNUSED(parsedData) }*/ -//#ifdef CLIENT_SERVER_TEST + dummyPM::dummyPM(SmfServer* server,QObject* parent) : m_server(server),QObject(parent) { @@ -348,4 +442,4 @@ { } -//#endif +#endif