diff -r 106a4bfcb866 -r 013a02bf2bb0 smf/smfservermodule/smfserver/server/smfserversymbian.cpp --- a/smf/smfservermodule/smfserver/server/smfserversymbian.cpp Thu Aug 05 16:46:37 2010 +0530 +++ b/smf/smfservermodule/smfserver/server/smfserversymbian.cpp Thu Aug 05 16:48:48 2010 +0530 @@ -12,18 +12,15 @@ * Contributors: * Manasij Roy, Nalina Hariharan * - * - * Description: Private implementation for Symbian OS + * Description: + * SMF Server private implementation for Symbian * */ -#ifdef WRITE_LOG -#include -#include -#endif + #include -#include -#include +#include #include + #include "smfserversymbian_p.h" @@ -32,20 +29,28 @@ SmfServerSymbian* self = new(ELeave) SmfServerSymbian(aActiveObjectPriority,aWrapper); CleanupStack::PushL(self); self->ConstructL(); - CleanupStack::Pop(); // self + CleanupStack::Pop(); return self; } + void SmfServerSymbian::ConstructL() { } + SmfServerSymbian::SmfServerSymbian( CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper ) : CPolicyServer(0,myPolicy, ESharableSessions), iWrapper(aWrapper) { Q_UNUSED(aActiveObjectPriority) } + +SmfServerSymbian::~SmfServerSymbian() + { + } + TInt SmfServerSymbian::addToSessionMap(SmfServerSymbianSession* aSession,const RMessage2& aMsg) { - qDebug()<<("SmfServerSymbian::addToSessionMap"); + qDebug()<<"Inside SmfServerSymbian::addToSessionMap()"; + if(iSessionCount) { //The key generation @@ -66,66 +71,55 @@ return (-1); } + TInt SmfServerSymbian::removeFromSessionMap(SmfServerSymbianSession* aSession,RMessage2& aMsg) { + //To be implemented Q_UNUSED(aSession) -Q_UNUSED(aMsg) -//To be implemented + Q_UNUSED(aMsg) return 0; } -//TODO - change this to a macro using qdebug to avoid file opening and closing -/*void SmfServerSymbian::writeLog(QString log) const - { -#ifdef WRITE_LOG - QFile file("c:\\data\\SmfServerLogs.txt"); - if (!file.open(QIODevice::Append | QIODevice::Text)) - return; - QTextStream out(&file); - out << log << "\n"; - file.close(); -#else - Q_UNUSED(log) -#endif - }*/ -SmfServerSymbian::~SmfServerSymbian() - { - } SmfServer* SmfServerSymbian::wrapper() { return iWrapper; } + CSession2* SmfServerSymbian::NewSessionL(const TVersion& aVersion, const RMessage2& /*aMessage*/) const { + qDebug()<<"Inside SmfServerSymbian::NewSessionL()"; + Q_UNUSED(aVersion) // Check that the version is OK // TVersion v( 0, 1, 0 ); // if (!User::QueryVersionSupported( v, aVersion )) - // User::Leave( KErrNotSupported ); + // User::Leave( KErrNotSupported ); + // Create the session. - QString log("New session created"); - qDebug()<<(log); + qDebug()<<"New session created"; return new (ELeave) SmfServerSymbianSession( const_cast(this) ); } + SmfServerSymbianSession* SmfServerSymbian::findSession(TInt id) { - qDebug()<<("SmfServerSymbian::findSession"); + qDebug()<<"Inside SmfServerSymbian::findSession()"; CSessionStruct* sessionStruct = iMap.Find(id); if(sessionStruct) { - qDebug()<<("Session id found"); + qDebug()<<"Session id found"; return sessionStruct->iSession; } else { - qDebug()<<("Session id not found"); + qDebug()<<"Session id not found"; return NULL; } } + TInt SmfServerSymbian::findAndServiceclient(TInt requestID,QByteArray* parsedData,SmfError error) { - qDebug()<<("SmfServerSymbian::findAndServiceclient"); + qDebug()<<"Inside SmfServerSymbian::findAndServiceclient()"; SmfServerSymbianSession* sessionToservice = findSession(requestID); if(sessionToservice) { @@ -133,23 +127,30 @@ } return 0; } + + + SmfServerSymbianSession::SmfServerSymbianSession(SmfServerSymbian* aServer): iServer(aServer),iPtrToBuf(NULL,0) , - iIntfNmaeSymbian(NULL,0), iProviderSymbian(NULL,0), - iIntfNameSymbian16(NULL,0) ,iXtraDataPtr(NULL,0), - iPtrToDataForClient(NULL,0) ,iPtrDataForDSM(NULL,0),iPtrDataFromDSM(NULL,0) + iIntfNameSymbian8(NULL,0), iProviderSymbian8(NULL,0), + iIntfNameSymbian(NULL,0) ,iXtraDataPtr8(NULL,0), + iPtrToDataForClient(NULL,0) ,iPtr8DataForDSM(NULL,0),iPtr8DataFromDSM(NULL,0) { + qDebug()<<"Inside SmfServerSymbianSession::SmfServerSymbianSession()"; iServer->iSessionCount++; } + SmfServerSymbianSession::~SmfServerSymbianSession() { + qDebug()<<"Inside SmfServerSymbianSession::~SmfServerSymbianSession()"; //cleanup of client resources iServer->iSessionCount--; } - -void SmfServerSymbianSession::clientathorizationFinished(bool success) +void SmfServerSymbianSession::clientAuthorizationFinished(bool success) { + qDebug()<<"Inside SmfServerSymbianSession::clientAuthorizationFinished() = "<removeFromSessionMap(this,iMessage); @@ -181,34 +184,30 @@ iPtrToDataForClient.Copy(reinterpret_cast(parsedData->constData()),parsedData->length()); TInt writeErr = iMessage.Write(2,iPtrToDataForClient); - qDebug()<<("Write="); - QString wrErr = QString::number(writeErr); - qDebug()<<(wrErr); + qDebug()<<"iMessage.Write() = "<Des()); - TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); - + iData8ForDSM = HBufC8::New(maxSmfRelationIdSize); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); } break; case SmfRelationAssociate: { int maxAlloc = 100; - iDataForDSM = HBufC8::New(maxAlloc); - iPtrDataForDSM.Set(iDataForDSM->Des()); - TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); } break; + case SmfRelationRemove: + { + iData8ForDSM = HBufC8::New(100); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); + break; + } case SmfRelationSearchById: { int maxAlloc = MaxSmfContactSize; - iDataForDSM = HBufC8::New(maxAlloc); - iPtrDataForDSM.Set(iDataForDSM->Des()); - TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); + } + break; + case SmfRelationSearchByContact: + { + int maxAlloc = 500; // hard coded in relation manager + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); } break; case SmfRelationCount: { int maxAlloc = 100; - iDataForDSM = HBufC8::New(maxAlloc); - iPtrDataForDSM.Set(iDataForDSM->Des()); - TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); } break; case SmfRelationGet: { int maxAlloc = maxSmfRelationItemSize*maxRelationItems; - iDataForDSM = HBufC8::New(maxAlloc); - iPtrDataForDSM.Set(iDataForDSM->Des()); - TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); } break; case SmfRelationGetAll: { int maxAlloc = maxSmfRelationItemSize*maxRelationItems; - iDataForDSM = HBufC8::New(maxAlloc); - iPtrDataForDSM.Set(iDataForDSM->Des()); - TInt readerr0 = aMessage.Read(0,iPtrDataForDSM); + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); } break; + case SmfRelationGetAllRelations: + { + int maxAlloc = maxSmfRelationItemSize*maxRelationItems; + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); + break; + } + case SmfRelationDeleteRelation: + { + int maxAlloc = 100; + iData8ForDSM = HBufC8::New(maxAlloc); + iPtr8DataForDSM.Set(iData8ForDSM->Des()); + TInt readerr0 = aMessage.Read(0,iPtr8DataForDSM); + break; + } default: break; } //Convert into QByteArray - QByteArray qtdataForDSM(reinterpret_cast(iPtrDataForDSM.Ptr()),iPtrDataForDSM.Length()) ; + QByteArray qtdataForDSM(reinterpret_cast(iPtr8DataForDSM.Ptr()),iPtr8DataForDSM.Length()) ; QByteArray qtdataFromDSM; SmfRequestTypeID opcode = (SmfRequestTypeID)iLastRequest; SmfError dsmErr = iServer->wrapper()->sendToDSM(qtdataForDSM,opcode,qtdataFromDSM); @@ -313,15 +350,15 @@ { if(qtdataFromDSM.size()) { - if(iDataFromDSM) + if(iData8FromDSM) { - delete iDataFromDSM; - iDataFromDSM = NULL; + delete iData8FromDSM; + iData8FromDSM = NULL; } - iDataFromDSM = HBufC8::NewL(qtdataFromDSM.size()); - iPtrDataFromDSM.Set(iDataFromDSM->Des()); - iPtrDataFromDSM.Copy(reinterpret_cast(qtdataFromDSM.constData()),qtdataFromDSM.length()); - TInt writeErr = aMessage.Write(1,iPtrDataFromDSM); + iData8FromDSM = HBufC8::NewL(qtdataFromDSM.size()); + iPtr8DataFromDSM.Set(iData8FromDSM->Des()); + iPtr8DataFromDSM.Copy(reinterpret_cast(qtdataFromDSM.constData()),qtdataFromDSM.length()); + TInt writeErr = aMessage.Write(1,iPtr8DataFromDSM); } } else @@ -332,46 +369,137 @@ TInt writeErr = aMessage.Write(2,iDSMErr); } } -void SmfServerSymbianSession::HandleGetService(const RMessage2 & aMessage) + + +void SmfServerSymbianSession::HandleSyncServiceL(const RMessage2 & aMessage) { - qDebug()<<("SmfServerSymbianSession::HandleGetService"); + qDebug()<<"Inside SmfServerSymbianSession::HandleSyncServiceL()"; + + // Following is the data format sent by client + // 1. SmfProvider +PageInfo flag+ aPageNum + aPerPage (if pageinfoflag is set) + XtraInfo flag(size of xtra data) Serialized + // 2. Interface name as string ("org.symbian.smf.client.gallery") + // 3. Data pointer to be filled by serialized data(eg: QList) + // 4. Input Data if xtra flag is set - /** - * Note:- client sends message for this opcode in the following format,- - * Slot 0:- Interface Name buffer - * Slot 1:- Ptr to data block to be filled with SmfProvideList* serialized into QByteArray - * Slot 2:- Max data size allocated in the client side - * TODO:- What if size of SmfProviderList to be passed to client is greater than - * this size??? - */ + TInt intfNameSize = aMessage.GetDesLength(1); + if(iIntfNameBuf8) + { + delete iIntfNameBuf8; + iIntfNameBuf8 = NULL; + } + iIntfNameBuf8 = HBufC8::NewL(intfNameSize); + iIntfNameSymbian8.Set(iIntfNameBuf8->Des()); + + //read it into iIntfNameSymbian8 + aMessage.ReadL(1,iIntfNameSymbian8); - iInterfaceNametbuf.Zero(); - TInt readerr = aMessage.Read(0,iInterfaceNametbuf); - qDebug()<<(QString::number(readerr)); - QByteArray bytearray(reinterpret_cast(iInterfaceNametbuf.Ptr()),iInterfaceNametbuf.Length()) ; - QDataStream stream3(&bytearray,QIODevice::ReadOnly); - stream3>>iInterfaceID; - qDebug()<<("iInterfaceID="); - qDebug()<<(iInterfaceID); + QByteArray intfName(reinterpret_cast(iIntfNameSymbian8.Ptr()),iIntfNameSymbian8.Length()) ; + QDataStream readIntfNameStream(&intfName,QIODevice::ReadOnly); + iInterfaceID.clear(); + readIntfNameStream>>iInterfaceID; + qDebug()<<"After de-serializing into iInterfaceID = "<wrapper()->getPlugins(iInterfaceID,iPluginIDMap); + + // for get services + if(SmfGetService == aMessage.Function()) + HandleGetService(aMessage, iInterfaceID); + + // for other services + else + { + // read provider info + TInt providerSize = aMessage.GetDesLength(0); + if(iProviderBuf8) + { + delete iProviderBuf8; + iProviderBuf8 = NULL; + } + iProviderBuf8 = HBufC8::NewL(providerSize); + iProviderSymbian8.Set(iProviderBuf8->Des()); + + //read it into iProviderSymbian8 + aMessage.ReadL(0,iProviderSymbian8); + + //convert SmfProvider info from Symbian into bytearray + QByteArray providerBufQt(reinterpret_cast(iProviderSymbian8.Ptr()),iProviderSymbian8.Length()); + qDebug()<<"providerBufQt.size = "<>provider; + QByteArray XtraBufQt; + readProviderStream>>XtraBufQt; + + //Get the plugin ID who matches provider info for a given intf name + SmfPluginID pluginID = iServer->wrapper()->getPlugin(iInterfaceID,provider); + qDebug()<<"pluginID from PM = "<wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); + + if(iAuthList.contains(pluginID)) + { + //Plugin ID is authorised, service the request + //Generate request id only if the plugin ID is authorised + //request PM to get the data + SmfRequestTypeID opcode = (SmfRequestTypeID)aMessage.Function(); + resultData.clear(); + SmfError err = iServer->wrapper()->sendToPluginManager(pluginID,iInterfaceID,opcode,XtraBufQt, resultData); + + if(resultData.size()) + { + TPtrC8 resultPtr8(reinterpret_cast(resultData.constData()),resultData.length()); + + TInt writeErr = aMessage.Write(2,resultPtr8); + qDebug()<<"aMessage.Write(2) = "<wrapper()->getPlugins(aInterfaceID,iPluginIDMap); + //form the plugin id list from the map - QMapIterator iter(iPluginIDMap); iPluginIDList.clear(); - while (iter.hasNext()) - { - iter.next(); - iPluginIDList<wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); - //iPluginIDMap now contains SmfProvider info to return to the client - //No need to add this to session map, as we are not requesting PM for this + // iPluginIDMap now contains SmfProvider info to return to the client + // No need to add this to session map, as we are not requesting PM for this QMap tempMap; QMapIterator i(iPluginIDMap); - while (i.hasNext()) + while(i.hasNext()) { i.next(); if(iAuthList.contains(i.key())) @@ -379,37 +507,35 @@ tempMap.insert(i.key(),i.value()); } } - //now tempMapcontains the info to be passed to the client + //now tempMap contains the info to be passed to the client iPluginIDMap.clear(); iPluginIDMap = tempMap; + //form list of smfprovider from this map,- - QList providerList; - i = iPluginIDMap; - while(i.hasNext()) - { - i.next(); - providerList.append(i.value()); - } + QList providerList = iPluginIDMap.values(); + //now serialize this list into bytearray - byteArrayToClnt.clear(); - QDataStream stream(&byteArrayToClnt,QIODevice::WriteOnly); + resultData.clear(); + QDataStream stream(&resultData,QIODevice::WriteOnly); stream<(byteArrayToClnt.constData()),byteArrayToClnt.length()); - qDebug()<<("After providerListSymbian"); - TInt writeErr = aMessage.Write(1,providerListSymbian); - qDebug()<<("Write="); - QString wrErr = QString::number(writeErr); - qDebug()<<(wrErr); + TPtrC8 providerListSymbian(reinterpret_cast(resultData.constData()),resultData.length()); + qDebug()<<"After providerListSymbian"; + + TInt writeErr = aMessage.Write(2,providerListSymbian); + qDebug()<<"aMessage.Write(2) = "<wrapper()->getPlugin(iInterfaceID,provider); - qDebug()<<("pluginID from PM="); - qDebug()<<(pluginID); + qDebug()<<"pluginID from PM = "<wrapper()->getAuthorizedPlugins(iPluginIDList,iAuthList); @@ -502,24 +607,8 @@ TInt id = iServer->addToSessionMap(this,aMessage); //request PM to get the data SmfRequestTypeID opcode = (SmfRequestTypeID)iLastRequest; - if(isXtraData) - { - if(iXtraDataBuf) - { - delete iXtraDataBuf; - iXtraDataBuf = NULL; - } - iXtraDataBuf = HBufC8::NewL(XtraInfoFlag); - iXtraDataPtr.Set(iXtraDataBuf->Des()); - QByteArray XtraBufQt(reinterpret_cast(iXtraDataPtr.Ptr()),iXtraDataPtr.Length()); - qDebug()<<("XtraBufQt size="); - qDebug()<<(QString::number(XtraBufQt.size())); - iServer->wrapper()->sendToPluginManager(id,pluginID,iInterfaceID,opcode,XtraBufQt); - } - else - { - iServer->wrapper()->sendToPluginManager(id,pluginID,iInterfaceID,opcode); - } + + iServer->wrapper()->sendToPluginManager(id,pluginID,iInterfaceID,opcode,XtraBufQt); } else { @@ -528,6 +617,4 @@ iErrBuf.AppendNum(err); iMessage.Write(2,iErrBuf); } - - }