smf/smfservermodule/smfserver/server/smfserver.h
changeset 18 013a02bf2bb0
parent 14 a469c0e6e7fb
child 25 a180113055cb
equal deleted inserted replaced
17:106a4bfcb866 18:013a02bf2bb0
     1 /**
     1 /**
     2 * Copyright (c) 2010 Sasken Communication Technologies Ltd.
     2  * Copyright (c) 2010 Sasken Communication Technologies Ltd.
     3 * All rights reserved.
     3  * All rights reserved.
     4 * This component and the accompanying materials are made available
     4  * This component and the accompanying materials are made available
     5 * under the terms of the "{License}"
     5  * under the terms of the "Eclipse Public License v1.0"
     6 * which accompanies  this distribution, and is available
     6  * which accompanies  this distribution, and is available
     7 * at the URL "{LicenseUrl}".
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html"
     8 *
     8  *
     9 * Initial Contributors:
     9  * Initial Contributors:
    10 * Manasij Roy, Sasken Communication Technologies Ltd - Initial contribution
    10  * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution
    11 *
    11  *
    12 * Contributors:
    12  * Contributors:
    13 *
    13  * Manasij Roy, Nalina Hariharan
    14 * Description:
    14  * 
    15 * SMF Server component which handles the client requests and delegates them propoerly to the appropriate component
    15  * Description:
    16 *
    16  * SMF Server component which handles the client requests and delegates 
    17 */
    17  * them propoerly to the appropriate component
       
    18  * 
       
    19  */
    18 
    20 
    19 #ifndef SMFSERVER_H
    21 #ifndef SMFSERVER_H
    20 #define SMFSERVER_H
    22 #define SMFSERVER_H
       
    23 
    21 #include <QObject>
    24 #include <QObject>
    22 #include<QMap>
    25 #include <QMap>
    23 //SMF wide global const and macros, to be shared among SMF components as well as SMF aware apps
    26 #include <smfglobal.h>
    24 #include "smfglobal.h"
    27 #include <smfcredmgrclientglobal.h>
    25 #include "smfprovider.h"
    28 #ifdef CLIENT_SERVER_TEST
    26 #include "smftransportmanager.h" // Transport Manager
    29 	#include <QTimer>
    27 #include <SmfCredMgrClientGlobal.h>
    30 	#include <QTextStream>
    28 /*
    31 #endif
    29 * Forward declarations
    32 
    30 * Other components of the SMF
    33 #include "smfserverglobal.h"
    31 */
    34 
       
    35 // Forward declarations(Other components of the SMF)
    32 class SmfTransportManager;
    36 class SmfTransportManager;
    33 class SmfPluginManager;
    37 class SmfPluginManager;
    34 class SmfDataStoreManager;
       
    35 class SmfSettingsAuthManager;
       
    36 class SmfClient;
       
    37 class SmfCredMgrClient;
    38 class SmfCredMgrClient;
       
    39 class SmfProvider;
       
    40 //Private implementation for different platforms
       
    41 #ifdef Q_OS_SYMBIAN
       
    42 	class SmfServerSymbian;
       
    43 	class SmfServerSymbianSession;
       
    44 #else
       
    45 	class SmfServerQt;
       
    46 	class SmfServerQtSession;
       
    47 #endif
       
    48 
       
    49 
    38 //For the time being, need to change later
    50 //For the time being, need to change later
    39 typedef QString SmfInterfaceID;
    51 typedef QString SmfInterfaceID;
    40 //For the time being, need to change later
    52 //For the time being, need to change later
    41 typedef QString SmfPluginID;
    53 typedef QString SmfPluginID;
    42 //TODO:- define proper enums after consulting with CM owner
    54 //TODO:- define proper enums after consulting with CM owner
    43 typedef int NotificationType;
    55 typedef int NotificationType;
    44 //Private implementation for different platforms
    56 
    45 #ifdef Q_OS_SYMBIAN
    57 	
    46 class SmfServerSymbian;
       
    47 class SmfServerSymbianSession;
       
    48 #else
       
    49 class SmfServerQt;
       
    50 class SmfServerQtSession;
       
    51 #endif
       
    52 #include "smfcontact.h"
       
    53 #ifdef NO_OTHER_MODULES
       
    54 #include <QTimer>
       
    55 #include <QTextStream>
       
    56 #endif
       
    57 /**
    58 /**
    58  * SmfServer manages the client requests and delegates them to the appropriate SMF component,
    59  * SmfServer manages the client requests and delegates them to the appropriate SMF component,
    59  * service the clients asymchronously
    60  * service the clients synchronously or asynchronously
    60  *
       
    61  */
    61  */
    62 class SmfServer : public QObject
    62 class SmfServer : public QObject
    63 {
    63 	{
    64   Q_OBJECT
    64 	Q_OBJECT
    65 
    65 	
    66 public:
    66 public:
    67 
    67 	SmfServer(QObject* parent = 0);
    68   SmfServer(QObject* parent = 0);
    68 	~SmfServer();
    69   
    69 	
    70   /**
    70 	/**
    71    * Does the following,-
    71 	 * Does the following,-
    72    *First it'll check whether server is already running, if already running it'll
    72 	 * First it'll check whether server is already running, if already 
    73    *simply return
    73 	 * running it'll simply return
    74    *else
    74 	 * else it'll start the server exe and initialize all other SMF 
    75    *it'll start the server exe and initialize all other SMF components
    75 	 * components returns whether server is started successfully or not
    76    *returns whether server is started successfully or not  
    76 	 */
    77    */
    77 	bool startServer();
    78   bool startServer();
    78 	
    79   
       
    80   ~SmfServer();
       
    81 
       
    82 public:
    79 public:
    83   /*
    80 	/**
    84    * Requests Plugin Manager to get a list of plugin IDs who implement
    81 	 * Requests Plugin Manager to get a list of plugin IDs who implement
    85    * the interface interfaceID.
    82 	 * the interface interfaceID.
    86    * This is used got SmfClient::GetServices () where we need a list of plugins
    83 	 * This is used for SmfClient::GetServices () where we need a list of plugins
    87    */
    84 	 */
    88   void getPlugins(SmfInterfaceID interfaceID, QMap<SmfPluginID,SmfProvider>& pluginIDMap);
    85 	void getPlugins ( const SmfInterfaceID& interfaceID, 
    89   /**
    86 			QMap<SmfPluginID,SmfProvider>& pluginIDMap);
    90    * Same as above, except this is used for rest of the requests where we need
    87 	
    91    * a particular plugin
    88 	/**
    92    */
    89 	 * Same as above, except this is used for rest of the requests where we need
    93   SmfPluginID getPlugin(SmfInterfaceID interfaceID,SmfProvider provider);
    90 	 * a particular plugin
    94   
    91 	 */
    95   /*
    92 	SmfPluginID getPlugin ( const SmfInterfaceID& interfaceID, SmfProvider provider);
    96    * Requests the Credential Manager to filter out non-authorized plugin IDs
    93 	
    97    * from the list and get authorized plugins into authList. 
    94 	/**
    98    */
    95 	 * Requests the Credential Manager to filter out non-authorized plugin IDs
    99   void getAuthorizedPlugins(QList<SmfPluginID>& list,QList<SmfPluginID>& authList);
    96 	 * from the list and get authorized plugins into authList.
   100 
    97 	 */
   101   /**
    98 	void getAuthorizedPlugins ( QList<SmfPluginID>& list, QList<SmfPluginID>& authList );
   102    * Request CM API to get the list of authenticated plugins
    99 	
   103    * @see SmfCredMgrClient::authenticatedPluginList()
   100 	/**
   104    */
   101 	 * Request CM API to get the list of authenticated plugins
   105   QStringList getAuthenticatedPluginList(QString RegistrationToken);
   102 	 * @see SmfCredMgrClient::authenticatedPluginList()
   106 
   103 	 */
   107 
   104 	QStringList getAuthenticatedPluginList ( QString RegistrationToken );
   108   SmfTransportInitializeResult prepareTransport();
   105 	
   109   /**
   106 	/**
   110    * DEbugging purpose only
   107 	 * Request the Plugin manager to get the data.
   111    */
   108 	 * @param requestID Corresponds to a client's session
   112   //void writeLog(QString log) const;
   109 	 * @param pluginID Plugin for which the request is intended
   113   /**
   110 	 * @param interfaceID Interface name
   114    * Request the Plugin manager to get the data.
   111 	 * @param dataForPlugin Data to be sent for this request
   115    * @param requestID Corresponds to a client's session
   112 	 */
   116    * @param pluginID Plugin for which the request is intended
   113 	void sendToPluginManager ( int requestID, SmfPluginID pluginID, 
   117    * @param interfaceID Interface name
   114 			SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID,
   118    * @param dataForPlugin Data to be sent for this request
   115 			QByteArray dataForPlugin = QByteArray() );
   119    * 
   116 	
   120    */
   117 	/**
   121   void sendToPluginManager(int requestID,SmfPluginID pluginID,SmfInterfaceID interfaceID,SmfRequestTypeID requestTypeID,QByteArray dataForPlugin = QByteArray(), int pageNo=-1,int perpage=-1);
   118 	 * Request the Plugin manager to get the data.
   122   /**
   119 	 * @param requestID Corresponds to a client's session
   123    * Delegates the request to DSM and receives data synshronously.
   120 	 * @param pluginID Plugin for which the request is intended
   124    * @param qtdataForDSM Data to be passed to DSM
   121 	 * @param interfaceID Interface name
   125    * @param opcode Opcode
   122 	 * @param dataForPlugin Data to be sent for this request
   126    * @param qtdataFromDSM Data received from DSM
   123 	 */
   127    * @return Error value returned from DSM
   124 	SmfError sendToPluginManager ( SmfPluginID pluginID, 
   128    */
   125 			SmfInterfaceID interfaceID, SmfRequestTypeID requestTypeID,
   129   SmfError sendToDSM(QByteArray qtdataForDSM,SmfRequestTypeID opcode,QByteArray& qtdataFromDSM);
   126 			QByteArray dataForPlugin, QByteArray &outputData);
       
   127 	
       
   128 	/**
       
   129 	 * Delegates the request to DSM and receives data synshronously.
       
   130 	 * @param qtdataForDSM Data to be passed to DSM
       
   131 	 * @param opcode Opcode
       
   132 	 * @param qtdataFromDSM Data received from DSM
       
   133 	 * @return Error value returned from DSM
       
   134 	 */
       
   135 	SmfError sendToDSM ( QByteArray qtdataForDSM, SmfRequestTypeID opcode,
       
   136 			QByteArray& qtdataFromDSM );
       
   137 	
   130 public slots:
   138 public slots:
   131 
   139 	/**
   132 	/*
       
   133 	 * This slot is called when Credential Manager is done with the autherizing
   140 	 * This slot is called when Credential Manager is done with the autherizing
   134 	 * the client for the first time. See isClientAuthorized() and authorizeClient().
   141 	 * the client for the first time. See isClientAuthorized() and authorizeClient().
   135 	 * success specifies the success of the authorization, authID is the authentication
   142 	 * success specifies the success of the authorization, authID is the authentication
   136 	 * ID in case its not same as SID of the client.
   143 	 * ID in case its not same as SID of the client.
   137 	 */
   144 	 */
   138 	void clientAuthorizationFinished(bool success,SmfClientAuthID authID );
   145 	void clientAuthorizationFinished ( bool success, SmfClientAuthID authID );
   139 
   146 	
   140 	/*
   147 	/**
   141 	 * This slot is called as a result of trigger from Plugin manager when the 
   148 	 * This slot is called as a result of trigger from Plugin manager when the 
   142 	 * parsed data is available.
   149 	 * parsed data is available.
   143 	 * @param requestID The request ID for which result is available
   150 	 * @param requestID The request ID for which result is available
   144 	 * @param parsedData Serialized data
   151 	 * @param parsedData Serialized data
   145 	 */
   152 	 */
   146 	void resultsAvailable(int requestID,QByteArray* parsedData,SmfError error);
   153 	void resultsAvailable ( int requestID, QByteArray* parsedData, SmfError error );
   147 
   154 
   148 	/*
   155 #ifdef CLIENT_SERVER_TEST
       
   156 	/**
   149 	 * Services the client request by sending the requested data.
   157 	 * Services the client request by sending the requested data.
   150 	 * Note:- This will be handled by private implementation.
   158 	 * Note:- This will be handled by private implementation.
   151 	 */
   159 	 */
   152 	void serviceClient(QByteArray* parsedData);
   160 /*	void serviceClient ( QByteArray* parsedData );*/
   153 	
   161 		
   154 	
   162 	/**
   155 	/*
       
   156 	 * This slot is called for every cleanup timer expiry, in this slot, we need
   163 	 * This slot is called for every cleanup timer expiry, in this slot, we need
   157 	 * to call SmfDataStoreManager's API to refresh data store
   164 	 * to call SmfDataStoreManager's API to refresh data store
   158 	 */
   165 	 */
   159 	void timerExpired(){};
   166 	void timerExpired ( ) {}
   160 	
   167 	
   161 	/*
   168 	/**
   162 	 * This method is called every time timerExpired slot is trigerred
   169 	 * This method is called every time timerExpired slot is trigerred
   163 	 * Fetches the last saved requests through Transport Manager and Plugin Manager
   170 	 * Fetches the last saved requests through Transport Manager and Plugin Manager
   164 	 * Who will save the last request (Tranport Manager or Data Store Manager) TBD later
   171 	 * Who will save the last request (Tranport Manager or Data Store Manager) TBD later
   165 	 * 
   172 	 */
   166 	 */
   173 	void runSavedRequest ( ) {}
   167 	void runSavedRequest(){};
   174 #endif
   168 	
   175 	/**
   169 	/*
       
   170 	 * This slot is called when the data store updates are available as a result of
   176 	 * This slot is called when the data store updates are available as a result of
   171 	 * "runSavedRequest()".
   177 	 * "runSavedRequest()".
   172 	 * Note:- The "10.4.1.11	updateDatastore" can be merged with this 
   178 	 * Note:- The "10.4.1.11	updateDatastore" can be merged with this 
   173 	 */
   179 	 */
   174 	void dataStoreUpdateAvailable(QByteArray* respData){Q_UNUSED(respData)};
   180 	void dataStoreUpdateAvailable ( QByteArray* respData ){ Q_UNUSED(respData) }
   175 	
   181 	
   176 	/**
   182 	/**
   177 	 * Server calls this method when it receives message from the CM
   183 	 * Server calls this method when it receives message from the CM
   178 	 * that authentication keys for the pluginID has expired
   184 	 * that authentication keys for the pluginID has expired
   179 	 */
   185 	 */
   180 	void authenticationKeysExpired(NotificationType type,SmfPluginID id);
   186 	void authenticationKeysExpired ( NotificationType type, SmfPluginID id );
   181 signals:
   187 
   182   //None at the moment
   188 private:
       
   189 	SmfTransportInitializeResult prepareTransport();
       
   190 
   183 private:
   191 private:
   184 	//private impl
   192 	//private impl
   185 #ifdef Q_OS_SYMBIAN
   193 #ifdef Q_OS_SYMBIAN
   186 	SmfServerSymbian* m_SmfServerPrivate;
   194 	SmfServerSymbian* m_SmfServerPrivate;
   187 #else
   195 #else
   188 	SmfServerQt* m_SmfServerPrivate;
   196 	SmfServerQt* m_SmfServerPrivate;
   189 #endif
   197 #endif
   190 	//Handles of other SMF components
   198 	//Handles of other SMF components
   191 	SmfTransportManager* m_transportManager;
   199 	SmfTransportManager* m_transportManager;
   192 	SmfPluginManager* m_pluginManager;
   200 	SmfPluginManager* m_pluginManager;
   193 	SmfDataStoreManager* m_dataStoreManager;
       
   194 	SmfSettingsAuthManager* m_settingsAuthManager;
       
   195 	SmfClient* m_smfClient;
       
   196 	SmfCredMgrClient* m_credentialMngr;
   201 	SmfCredMgrClient* m_credentialMngr;
   197 };
   202 	};
       
   203 
   198 #ifdef CLIENT_SERVER_TEST
   204 #ifdef CLIENT_SERVER_TEST
   199 class dummyPM : public QObject
   205 class dummyPM : public QObject
   200 	{
   206 	{
   201 		Q_OBJECT
   207 		Q_OBJECT
   202 public:
   208 public: