8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
10 * Chandradeep Gandhi, Sasken Communication Technologies Ltd - Initial contribution |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * Manasij Roy, Nalina Hariharan* |
13 * Manasij Roy, Nalina Hariharan |
|
14 * |
14 * Description: |
15 * Description: |
15 * SMF Server private implementation for Symbian |
16 * SMF Server private implementation for Symbian |
16 * |
17 * |
17 **/ |
18 */ |
18 |
19 |
19 #ifndef SMFSERVERSYMBIAN_H |
20 #ifndef SMFSERVERSYMBIAN_H |
20 #define SMFSERVERSYMBIAN_H |
21 #define SMFSERVERSYMBIAN_H |
|
22 |
21 #include <QObject> |
23 #include <QObject> |
22 #include <e32hashtab.h> |
24 #include <e32hashtab.h> |
23 #include <e32base.h> |
25 #include <e32base.h> |
24 #include <QByteArray> |
26 #include <QByteArray> |
25 #include <QString> |
27 #include <QString> |
26 //testing -start |
28 |
27 #include "smfprovider.h" |
29 #include "smfserver.h" |
28 //end |
30 |
29 //SMF wide global const and macros, to be shared among SMF components as well as SMF aware apps |
|
30 //#include <smf/smfGlobal.h> |
|
31 |
|
32 //#include "clientGlobal.h" |
|
33 |
|
34 #include "SmfServer.h" |
|
35 //Forward declarations |
31 //Forward declarations |
36 class SmfServerSymbianSession; |
32 class SmfServerSymbianSession; |
|
33 class SmfProvider; |
|
34 |
37 |
35 |
38 /** |
36 /** |
39 * Stores session and request information. |
37 * Stores session and request information. |
40 * For now storing RMessage2 is reduntant as we are allowing only one outstanding request per session |
38 * For now storing RMessage2 is reduntant as we are allowing only one outstanding request per session |
41 */ |
39 */ |
42 struct CSessionStruct |
40 struct CSessionStruct |
43 { |
41 { |
44 SmfServerSymbianSession* iSession; |
42 SmfServerSymbianSession* iSession; |
45 RMessage2 iMsg; |
43 RMessage2 iMsg; |
46 }; |
44 }; |
47 |
|
48 |
45 |
49 |
46 |
50 //Policy table---start |
47 //Policy table---start |
51 //note capabilities are yet to be finalized |
48 //note capabilities are yet to be finalized |
52 //46 services as of 15th apr |
49 //46 services as of 15th apr |
105 myRanges, |
102 myRanges, |
106 myElementsIndex, |
103 myElementsIndex, |
107 myElements, |
104 myElements, |
108 }; |
105 }; |
109 //Policy table---end |
106 //Policy table---end |
110 /** |
107 |
111 * Our server class - an active object - and therefore derived ultimately from CActive. |
108 |
112 * It accepts requests from client threads and forwards |
109 /** |
113 * them to the client session to be dealt with. It also handles the creation |
110 * Our server class - an active object - and therefore derived ultimately from CActive. |
114 * of the server-side client session. |
111 * It accepts requests from client threads and forwards |
115 **/ |
112 * them to the client session to be dealt with. It also handles the creation |
|
113 * of the server-side client session. |
|
114 */ |
116 class SmfServerSymbian : public CPolicyServer |
115 class SmfServerSymbian : public CPolicyServer |
117 { |
116 { |
118 |
|
119 public: |
117 public: |
120 /** |
118 static SmfServerSymbian * NewL(CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper); |
121 * Creates a new session with the server; the function |
|
122 * implements the pure virtutal function |
|
123 * defined in class CServer2 |
|
124 */ |
|
125 SmfServerSymbian(CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper); |
|
126 static SmfServerSymbian * NewL(CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper); |
|
127 ~SmfServerSymbian(); |
119 ~SmfServerSymbian(); |
128 CSession2 * NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
120 CSession2 * NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
129 |
121 |
130 /** |
122 /** |
131 * Returns SmfServer |
123 * Returns SmfServer |
132 */ |
124 */ |
133 SmfServer* wrapper(); |
125 SmfServer* wrapper(); |
|
126 |
134 /** |
127 /** |
135 * Adds session info to the currently active session map iMap. This map is used to |
128 * Adds session info to the currently active session map iMap. This map is used to |
136 * retreive the corresponding session to be serviced. The keys for this map is sent |
129 * retreive the corresponding session to be serviced. The keys for this map is sent |
137 * alongwith the request to other components |
130 * alongwith the request to other components |
138 * @param aSession Session to be added |
131 * @param aSession Session to be added |
139 * @param aMsg Currently redundant |
132 * @param aMsg Currently redundant |
140 */ |
133 */ |
141 TInt addToSessionMap(SmfServerSymbianSession* aSession,const RMessage2& aMsg); |
134 TInt addToSessionMap(SmfServerSymbianSession* aSession,const RMessage2& aMsg); |
|
135 |
142 /** |
136 /** |
143 * Removes the session from the active list of session map |
137 * Removes the session from the active list of session map |
144 * @param aSession Session to be removed. |
138 * @param aSession Session to be removed. |
145 * @param aMsg Currently redundant |
139 * @param aMsg Currently redundant |
146 */ |
140 */ |
147 TInt removeFromSessionMap(SmfServerSymbianSession* aSession,RMessage2& aMsg); |
141 TInt removeFromSessionMap(SmfServerSymbianSession* aSession,RMessage2& aMsg); |
|
142 |
148 /** |
143 /** |
149 * Returns a symbian session for the given key from the iMap. |
144 * Returns a symbian session for the given key from the iMap. |
150 * @param id Session ID in the SmfServer Session map |
145 * @param id Session ID in the SmfServer Session map |
151 */ |
146 */ |
152 SmfServerSymbianSession* findSession(TInt id); |
147 SmfServerSymbianSession* findSession(TInt id); |
|
148 |
153 /** |
149 /** |
154 * Finds the given session and services it with the data. |
150 * Finds the given session and services it with the data. |
155 * @param requestID Session ID |
151 * @param requestID Session ID |
156 * @param parsedData Parsed and serialized data to be sent to client. |
152 * @param parsedData Parsed and serialized data to be sent to client. |
157 * @param error Error code |
153 * @param error Error code |
158 */ |
154 */ |
159 TInt findAndServiceclient(TInt requestID,QByteArray* parsedData,SmfError error); |
155 TInt findAndServiceclient(TInt requestID,QByteArray* parsedData,SmfError error); |
160 /** |
156 |
161 * Debugging |
157 private: |
162 */ |
158 /** |
163 //void writeLog(QString log)const; |
159 * Creates a new session with the server. The function |
164 //private: |
160 * implements the pure virtual function |
|
161 * defined in class CServer2 |
|
162 */ |
|
163 SmfServerSymbian(CActive::TPriority aActiveObjectPriority,SmfServer* aWrapper); |
|
164 |
165 void ConstructL(); |
165 void ConstructL(); |
|
166 |
|
167 private: |
|
168 friend class SmfServerSymbianSession; |
|
169 |
166 SmfServer* iWrapper; |
170 SmfServer* iWrapper; |
167 |
171 |
168 /** |
172 /** |
169 * Keeps track of the requests sent by each session |
173 * Keeps track of the requests sent by each session |
170 */ |
174 */ |
171 RHashMap<TInt,CSessionStruct> iMap; |
175 RHashMap<TInt,CSessionStruct> iMap; |
172 |
176 |
173 /** |
|
174 * The key in the iMap. |
|
175 * Its sent to the wrapper |
|
176 */ |
|
177 TInt iRequestID; |
|
178 |
|
179 TInt iSessionCount; |
177 TInt iSessionCount; |
180 }; |
178 }; |
|
179 |
181 |
180 |
182 /** |
181 /** |
183 This class represents a session with the Smf server. |
182 This class represents a session with the Smf server. |
184 Functions are provided to respond appropriately to client messages. |
183 Functions are provided to respond appropriately to client messages. |
185 */ |
184 */ |
186 class SmfServerSymbianSession : public CSession2 |
185 class SmfServerSymbianSession : public CSession2 |
187 { |
186 { |
188 public: |
187 public: |
189 /** |
188 /** |
190 * Creates a session. |
189 * Creates a session. |
191 * @param aServer The server handle |
190 * @param aServer The server handle |
192 */ |
191 */ |
193 SmfServerSymbianSession(SmfServerSymbian* aServer); |
192 SmfServerSymbianSession(SmfServerSymbian* aServer); |
194 ~SmfServerSymbianSession(); |
193 ~SmfServerSymbianSession(); |
|
194 |
195 /** |
195 /** |
196 * From CSession2 |
196 * From CSession2 |
197 */ |
197 */ |
198 void ServiceL(const RMessage2 & aMessage); |
198 void ServiceL(const RMessage2 & aMessage); |
|
199 |
199 /** |
200 /** |
200 * Called by the SmfServerSymbian when results are available |
201 * Called by the SmfServerSymbian when results are available |
201 * @param parsedData Parsed serialized data |
202 * @param parsedData Parsed serialized data |
202 * @param error Smf Error code |
203 * @param error Smf Error code |
203 */ |
204 */ |
204 void resultsAvailable(QByteArray* parsedData,SmfError error); |
205 void resultsAvailable(QByteArray* parsedData,SmfError error); |
|
206 |
205 /** |
207 /** |
206 * Called by the SmfServer when client authorization finishes. |
208 * Called by the SmfServer when client authorization finishes. |
207 * @param success success of the authorization |
209 * @param success success of the authorization |
208 */ |
210 */ |
209 void clientathorizationFinished(bool success); |
211 void clientAuthorizationFinished(bool success); |
|
212 |
210 protected: |
213 protected: |
211 //TMessageParams ReadMessageAndRetrieveParams (const RMessage2 & aMessage); |
214 //TMessageParams ReadMessageAndRetrieveParams (const RMessage2 & aMessage); |
|
215 |
212 void PanicClient(const RMessage2 & aMessage, TInt aPanic) const; |
216 void PanicClient(const RMessage2 & aMessage, TInt aPanic) const; |
|
217 |
213 /** |
218 /** |
214 * Called by ServiceL() |
219 * Called by ServiceL() |
215 * It tests the function code and then delegates to |
220 * It tests the function code and then delegates to |
216 * the appropriate function. |
221 * the appropriate function. |
217 */ |
222 */ |
218 void HandleClientMessageL(const RMessage2 & aMessage); |
223 void HandleClientMessageL(const RMessage2 & aMessage); |
219 |
224 |
|
225 private: |
220 //Following are for handling specific client requests |
226 //Following are for handling specific client requests |
221 /** |
227 /** |
222 * ESmfGetService |
228 * ESmfGetService |
223 */ |
229 */ |
224 void HandleGetService(const RMessage2 & aMessage); |
230 void HandleGetService(const RMessage2 & aMessage, const SmfInterfaceID& aInterfaceID); |
|
231 |
|
232 /** |
|
233 * Handles all synchronous services |
|
234 */ |
|
235 void HandleSyncServiceL(const RMessage2 & aMessage); |
225 |
236 |
226 /** |
237 /** |
227 * Handles all the opcodes except ESmfGetService |
238 * Handles all the opcodes except ESmfGetService |
228 */ |
239 */ |
229 void HandleCommonServiceL(const RMessage2 & aMessage); |
240 void HandleCommonServiceL(const RMessage2 & aMessage); |
232 * Handles all DSM related messages |
243 * Handles all DSM related messages |
233 */ |
244 */ |
234 void HandleDSMServiceL(const RMessage2 & aMessage); |
245 void HandleDSMServiceL(const RMessage2 & aMessage); |
235 |
246 |
236 |
247 |
237 //private: |
248 private: |
238 SmfServerSymbian* iServer; |
249 SmfServerSymbian* iServer; |
239 RMessage2 iMessage; |
250 RMessage2 iMessage; |
240 TBuf<100> iErrBuf; |
251 TBuf<100> iErrBuf; |
241 //this interface id will be provided by Smf client, will map Smf Client |
252 //this interface id will be provided by Smf client, will map Smf Client |
242 // interface hierarchy |
253 // interface hierarchy |
243 SmfInterfaceID iInterfaceID; |
254 SmfInterfaceID iInterfaceID; |
244 TPtr8 iIntfNmaeSymbian; |
255 TPtr iIntfNameSymbian; |
245 TPtr iIntfNameSymbian16; |
256 TPtr8 iIntfNameSymbian8; |
|
257 |
246 TBuf8<125> iInterfaceNametbuf; |
258 TBuf8<125> iInterfaceNametbuf; |
247 TPtr8 iProviderSymbian; |
259 TPtr8 iProviderSymbian8; |
248 TPtr8 iXtraDataPtr; |
260 TPtr8 iXtraDataPtr8; |
249 HBufC8* iDataForDSM; |
261 HBufC8* iData8ForDSM; |
250 TPtr8 iPtrDataForDSM; |
262 TPtr8 iPtr8DataForDSM; |
251 HBufC8* iDataFromDSM; |
263 HBufC8* iData8FromDSM; |
252 TPtr8 iPtrDataFromDSM; |
264 TPtr8 iPtr8DataFromDSM; |
253 TBuf<100> iDSMErr; |
265 TBuf<100> iDSMErr; |
254 TBuf<100> iMaxSize; |
266 HBufC8* iProviderBuf8; |
255 HBufC8* iProviderBuf; |
267 HBufC8* iXtraDataBuf8; |
256 HBufC8* iXtraDataBuf; |
268 HBufC8* iIntfNameBuf8; |
257 HBufC8* iIntfNameBuf; |
|
258 QMap<SmfPluginID,SmfProvider> iPluginIDMap; |
269 QMap<SmfPluginID,SmfProvider> iPluginIDMap; |
259 QList<SmfPluginID> iPluginIDList; |
270 QList<SmfPluginID> iPluginIDList; |
260 QList<SmfPluginID> iAuthList; |
271 QList<SmfPluginID> iAuthList; |
261 |
272 |
262 /** |
273 /** |