smf/smfservermodule/smfserver/server/smfserver.cpp
changeset 26 83d6a149c755
parent 25 a180113055cb
equal deleted inserted replaced
25:a180113055cb 26:83d6a149c755
   153 	{
   153 	{
   154 	qDebug()<<"Inside SmfServer::getAuthorizedPlugins()";
   154 	qDebug()<<"Inside SmfServer::getAuthorizedPlugins()";
   155 	authList.clear();
   155 	authList.clear();
   156 	for(int i=0;i<list.count();i++)
   156 	for(int i=0;i<list.count();i++)
   157 		{
   157 		{
   158 		bool isAuthorized = m_credentialMngr->CheckPluginAuthentication(list[i]);
   158 		bool isAuthorized = false;
       
   159 		isAuthorized = m_credentialMngr->CheckPluginAuthentication(list[i]);
   159 		if(isAuthorized)
   160 		if(isAuthorized)
   160 			authList.append(list[i]);
   161 			authList.append(list[i]);
   161 		}
   162 		}
   162 	}
   163 	}
   163 
   164 
   218 
   219 
   219 SmfError SmfServer::sendToDSM ( QByteArray qtdataForDSM, SmfRequestTypeID opcode,
   220 SmfError SmfServer::sendToDSM ( QByteArray qtdataForDSM, SmfRequestTypeID opcode,
   220 		QByteArray& qtdataFromDSM )
   221 		QByteArray& qtdataFromDSM )
   221 	{
   222 	{
   222 	qDebug()<<"Inside SmfServer::sendToDSM()";
   223 	qDebug()<<"Inside SmfServer::sendToDSM()";
   223 	
   224 	SmfError err = SmfNoError;
   224 	DataStoreManager* dsm = DataStoreManager::getDataStoreManager();
   225 	DataStoreManager* dsm = DataStoreManager::getDataStoreManager();
   225 	
   226 	
   226 	//Note:- deserialization and formation of user profile and social profile are done by server
   227 	//Note:- deserialization and formation of user profile and social profile are done by server
   227 	QDataStream readStream(&qtdataForDSM,QIODevice::ReadOnly);
   228 	QDataStream readStream(&qtdataForDSM,QIODevice::ReadOnly);
   228 	QDataStream writeStream(&qtdataFromDSM,QIODevice::WriteOnly);
   229 	QDataStream writeStream(&qtdataFromDSM,QIODevice::WriteOnly);
   248 			else 
   249 			else 
   249 				{
   250 				{
   250 				delete contact;
   251 				delete contact;
   251 				contact = NULL;
   252 				contact = NULL;
   252 				}
   253 				}
   253 			SmfRelationId relnId = dsm->create(provider,contact);
   254 			SmfRelationId relnId;
       
   255 			relnId.clear();
       
   256 			err = dsm->create(relnId,provider,contact);
   254 			writeStream<<relnId;
   257 			writeStream<<relnId;
   255 			if(provider != NULL)
   258 			if(provider != NULL)
   256 				delete provider;
   259 				delete provider;
   257 			if(contact != NULL)
   260 			if(contact != NULL)
   258 				delete contact;
   261 				delete contact;
   279 				{
   282 				{
   280 				delete provider;
   283 				delete provider;
   281 				provider = NULL;
   284 				provider = NULL;
   282 				}
   285 				}
   283 
   286 
   284 			QString snsName = provider->serviceName();
   287 			err = dsm->associate(relnId,contact,provider);
   285 			QString snsUrl = (provider->serviceUrl()).toString();
       
   286 			QString snsDesc = provider->description();
       
   287 			
       
   288 			SmfError err = dsm->associate(relnId,contact,provider);
       
   289 			int errInt = err;
   288 			int errInt = err;
   290 			writeStream<<errInt;
   289 			writeStream<<errInt;
   291 			if(contact != NULL)
   290 			if(contact != NULL)
   292 				delete contact;
   291 				delete contact;
   293 			if(provider != NULL)
   292 			if(provider != NULL)
   305 			else 
   304 			else 
   306 				{
   305 				{
   307 				delete contact;
   306 				delete contact;
   308 				contact = NULL;
   307 				contact = NULL;
   309 				}
   308 				}
   310 			SmfError err = dsm->remove(relnId, contact);
   309 			err = dsm->remove(relnId, contact);
   311 			int errInt = err;
   310 			int errInt = err;
   312 			writeStream<<errInt;
   311 			writeStream<<errInt;
   313 			if(NULL != contact)
   312 			if(NULL != contact)
   314 				delete contact;
   313 				delete contact;
   315 			break;
   314 			break;
   387 			break;
   386 			break;
   388 		case SmfRelationDeleteRelation:
   387 		case SmfRelationDeleteRelation:
   389 			{
   388 			{
   390 			SmfRelationId relnId;
   389 			SmfRelationId relnId;
   391 			readStream>>relnId;
   390 			readStream>>relnId;
   392 			SmfError err = dsm->deleteRelation(relnId);
   391 			err = dsm->deleteRelation(relnId);
   393 			int errInt = err;
   392 			int errInt = err;
   394 			writeStream<<errInt;
   393 			writeStream<<errInt;
   395 			break;
   394 			break;
   396 			}
   395 			}
   397 		default:
   396 		default:
   398 			break;
   397 			break;
   399 		}
   398 		}
   400 	return SmfNoError;
   399 	return err;
   401 	}
   400 	}
   402 
   401 
       
   402 #ifdef Q_FOR_FUTURE 
   403 /**
   403 /**
   404  * This slot is invoked when CM finishes the authorization of the client.
   404  * This slot is invoked when CM finishes the authorization of the client.
   405  * @param authID As it contains the session ptr, sever directly invokes the session's API to notify success
   405  * @param authID As it contains the session ptr, sever directly invokes the session's API to notify success
   406  */
   406  */
   407 void SmfServer::clientAuthorizationFinished(bool success,SmfClientAuthID authID )
   407 void SmfServer::clientAuthorizationFinished(bool success,SmfClientAuthID authID )
   410 	//TODO:- implement this api in session class
   410 	//TODO:- implement this api in session class
   411 	//note:- in case success is false client completes the request with SmfErrClientAuthFailed
   411 	//note:- in case success is false client completes the request with SmfErrClientAuthFailed
   412 	//TODO:- define set of smf wide error after consulting with other module owners
   412 	//TODO:- define set of smf wide error after consulting with other module owners
   413 	authID.session->clientAuthorizationFinished(success);
   413 	authID.session->clientAuthorizationFinished(success);
   414 	}
   414 	}
       
   415 #endif
   415 
   416 
   416 /**
   417 /**
   417  * This API is called by PM once its done with request and parsing
   418  * This API is called by PM once its done with request and parsing
   418  * @param requestID The request id which is completed
   419  * @param requestID The request id which is completed
   419  * @param parsedData Serialized data(as per request type) filled by PM
   420  * @param parsedData Serialized data(as per request type) filled by PM
   453 	Q_UNUSED(id)
   454 	Q_UNUSED(id)
   454 	//resend the notify request
   455 	//resend the notify request
   455 	//CMclient->requestAuthExpiryNotify();
   456 	//CMclient->requestAuthExpiryNotify();
   456 	}
   457 	}
   457 
   458 
   458 #ifdef CLIENT_SERVER_TEST
       
   459 /**
       
   460  * Seems reduntant
       
   461  */
       
   462 /*void SmfServer::serviceClient(QByteArray* parsedData)
       
   463 	{
       
   464 	Q_UNUSED(parsedData)
       
   465 	}*/
       
   466 
       
   467 dummyPM::dummyPM(SmfServer* server,QObject* parent)
       
   468 : m_server(server),QObject(parent)
       
   469 	{
       
   470 	m_timer = new QTimer(this);
       
   471 	connect(m_timer, SIGNAL(timeout()), this, SLOT(responseAvailable()));
       
   472 	}
       
   473 SmfError dummyPM::createRequest ( const quint32& aSessionID, 
       
   474 		const QString& aPluginID, 
       
   475 		const SmfRequestTypeID& aOperation, 
       
   476 		QByteArray& aInputData )
       
   477 	{
       
   478 	qDebug()<<QString::number(aSessionID);
       
   479 	qDebug()<<aPluginID;
       
   480 	qDebug()<<QString::number(aOperation);
       
   481 	qDebug()<<QString::number(aInputData.size());
       
   482 	m_timer->start(1000);
       
   483 	}
       
   484 void dummyPM::responseAvailable()
       
   485 	{
       
   486 	
       
   487 	}
       
   488 #endif