1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: cbssession.h |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CBSSESSION_H__ |
|
20 #define __CBSSESSION_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <s32mem.h> |
|
24 #include "rbsobjowningptrarray.h" |
|
25 #include "bsserverdefs.h" |
|
26 #include "mbsbackupobserver.h" |
|
27 |
|
28 class CBSServer; |
|
29 class CBSBrandHandler; |
|
30 class MBSElement; |
|
31 class CBSStorageManager; |
|
32 |
|
33 /** |
|
34 * Service side session. |
|
35 * |
|
36 * @lib |
|
37 * @since |
|
38 */ |
|
39 class CBSSession : public CSession2, |
|
40 public MBSBackupObserver |
|
41 { |
|
42 |
|
43 |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Class for encapsulating the session information. |
|
48 */ |
|
49 NONSHARABLE_CLASS( CBSSessionInfo ): public CBase |
|
50 { |
|
51 public: |
|
52 |
|
53 /** |
|
54 * Creates a new CBSSessionInfo |
|
55 * |
|
56 * @param aFileName the filename of the process, that created |
|
57 * this session |
|
58 * @param aCaption a caption of the process, that created this |
|
59 * session |
|
60 * @param aThreadId thread id where this session was created |
|
61 * @param aProcessId processId of the process, that created |
|
62 * this session |
|
63 * @return a new CBSSessionInfo instance |
|
64 */ |
|
65 static CBSSessionInfo* NewL( const TDesC& aFileName, |
|
66 const TDesC& aCaption, |
|
67 TThreadId aThreadId, |
|
68 TProcessId aProcessId ); |
|
69 /** |
|
70 * Destructor. |
|
71 */ |
|
72 ~CBSSessionInfo(); |
|
73 |
|
74 private: |
|
75 |
|
76 /** |
|
77 * Symbian second-phase constructor |
|
78 * |
|
79 * @param aFileName the filename of the process, that created |
|
80 * this session |
|
81 * @param aCaption a caption of the process, that created this |
|
82 * session |
|
83 */ |
|
84 void ConstructL( const TDesC& aFileName, |
|
85 const TDesC& aCaption ); |
|
86 |
|
87 /** |
|
88 * Constructor. |
|
89 * |
|
90 * @param aThreadId thread id where this session was created |
|
91 * @param aProcessId processId of the process, that created |
|
92 * this session |
|
93 */ |
|
94 CBSSessionInfo( TThreadId aThreadId, TProcessId aProcessId ); |
|
95 |
|
96 public: |
|
97 |
|
98 /** |
|
99 * Returns the filename of the process, that created this |
|
100 * session. |
|
101 * |
|
102 * @return a filename |
|
103 */ |
|
104 const TDesC& FileName(); |
|
105 |
|
106 /** |
|
107 * Returns the caption of the process, that created this |
|
108 * session. |
|
109 * |
|
110 * @return a caption |
|
111 */ |
|
112 const TDesC& Caption(); |
|
113 |
|
114 /** |
|
115 * Returns the thread id where this session was created. |
|
116 * |
|
117 * @return a thread id |
|
118 */ |
|
119 TThreadId ThreadId(); |
|
120 |
|
121 /** |
|
122 * Returns the processId of the process, that created |
|
123 * this session. |
|
124 * |
|
125 * @return a process id |
|
126 */ |
|
127 TProcessId ProcessId(); |
|
128 |
|
129 private: // data |
|
130 |
|
131 /** |
|
132 * Filename |
|
133 * Own. |
|
134 */ |
|
135 HBufC* iFileName; |
|
136 |
|
137 /** |
|
138 * Caption |
|
139 * Own. |
|
140 */ |
|
141 HBufC* iCaption; |
|
142 |
|
143 /** |
|
144 * Thread Id. |
|
145 */ |
|
146 TThreadId iThreadId; |
|
147 |
|
148 /** |
|
149 * Process Id. |
|
150 */ |
|
151 TProcessId iProcessId; |
|
152 }; |
|
153 |
|
154 |
|
155 public: // Constructors and destructors |
|
156 static CBSSession* NewL(); |
|
157 virtual ~CBSSession(); |
|
158 |
|
159 |
|
160 protected: // C++ constructors |
|
161 /** |
|
162 * C++ default constructor. |
|
163 */ |
|
164 CBSSession(); |
|
165 |
|
166 /** |
|
167 * Symbian OS constructor |
|
168 */ |
|
169 void ConstructL(); |
|
170 |
|
171 public: // Methods derived from CSession2 |
|
172 /** |
|
173 * From CSession2 |
|
174 */ |
|
175 void CreateL(); |
|
176 /** |
|
177 * From CSession2 |
|
178 */ |
|
179 void ServiceL( const RMessage2 &aMessage ); |
|
180 /** |
|
181 * From CSession2 |
|
182 */ |
|
183 void ServiceError( const RMessage2& aMessage, |
|
184 TInt aError ); |
|
185 |
|
186 public: // From MBSBackupObserver |
|
187 |
|
188 /* |
|
189 * @see MBSBackupObserver |
|
190 */ |
|
191 void HandleBackupStateL( TBackupState aState ); |
|
192 |
|
193 public: // New methods |
|
194 |
|
195 /** |
|
196 * |
|
197 */ |
|
198 CBSServer* Server() { return (CBSServer*) CSession2::Server(); } |
|
199 |
|
200 |
|
201 TBool MatchSessionL( const TDesC& aApplicationId, |
|
202 const TDesC& aBrandId, |
|
203 TLanguage aLanguageId, |
|
204 TInt aReserved ); |
|
205 |
|
206 TBool MatchSessionUninstallL( const TDesC& aApplicationId, |
|
207 const TDesC& aBrandId); |
|
208 |
|
209 void BrandUpdatedL( const TDesC& aApplicationId, |
|
210 const TDesC& aBrandId, |
|
211 TLanguage aLanguageId, |
|
212 TInt aReserved ); |
|
213 |
|
214 |
|
215 |
|
216 /** |
|
217 * Returns the filename of the process, that created this |
|
218 * session. |
|
219 * |
|
220 * @return a filename |
|
221 */ |
|
222 const TDesC& FileName(); |
|
223 |
|
224 /** |
|
225 * Returns the caption of the process, that created this |
|
226 * session. |
|
227 * |
|
228 * @return a caption |
|
229 */ |
|
230 const TDesC& Caption(); |
|
231 |
|
232 /** |
|
233 * Returns the thread id where this session was created. |
|
234 * |
|
235 * @return a thread id |
|
236 */ |
|
237 TInt ThreadId( TThreadId& aThreadId ); |
|
238 |
|
239 /** |
|
240 * Returns the processId of the process, that created |
|
241 * this session. |
|
242 * |
|
243 * @return a process id |
|
244 */ |
|
245 TInt ProcessId( TProcessId& aProcessId ); |
|
246 |
|
247 /** |
|
248 * Returns, if the session info for this object is available. |
|
249 * |
|
250 * @return ETrue, if information about this object is available; |
|
251 * EFalse otherwise |
|
252 */ |
|
253 TBool InfoAvailable(); |
|
254 |
|
255 |
|
256 private: // New methods |
|
257 |
|
258 /** |
|
259 * Dispatch clients message |
|
260 * |
|
261 * @since |
|
262 * @param aMessage client's message |
|
263 */ |
|
264 TBool DispatchMessageL( const RMessage2 &aMessage ); |
|
265 |
|
266 |
|
267 /** |
|
268 * Initializes the server |
|
269 * @param aMessage client's message |
|
270 */ |
|
271 void InitUpdateL( const RMessage2 &aMessage, TTransactionType aType ); |
|
272 |
|
273 /** |
|
274 * Initializes the server |
|
275 * @param aMessage client's message |
|
276 */ |
|
277 void InitAccessL( const RMessage2 &aMessage ); |
|
278 |
|
279 |
|
280 /** |
|
281 * Get text type branding item |
|
282 * @param aMessage client's message |
|
283 */ |
|
284 void GetTextL( const RMessage2 &aMessage ); |
|
285 |
|
286 /** |
|
287 * Get text type branding item |
|
288 * @param aMessage client's message |
|
289 */ |
|
290 void GetBufferL( const RMessage2 &aMessage ); |
|
291 |
|
292 /** |
|
293 * Get integer type branding item |
|
294 * @param aMessage client's message |
|
295 */ |
|
296 void GetIntL( const RMessage2 &aMessage ); |
|
297 |
|
298 /** |
|
299 * Get file type branding item |
|
300 * @param aMessage client's message |
|
301 */ |
|
302 void GetFileL( const RMessage2 &aMessage ); |
|
303 |
|
304 /** |
|
305 * Prepares several textual type branding items. |
|
306 * These have to be fetched with GetSeveralText. |
|
307 * @param aMessage client's message |
|
308 */ |
|
309 void PrepareSeveralL( const RMessage2 &aMessage ); |
|
310 |
|
311 /** |
|
312 * Gets the several textual branding items |
|
313 * previously prepared. |
|
314 * @param aMessage client's message |
|
315 */ |
|
316 void GetSeveralL( const RMessage2 &aMessage ); |
|
317 |
|
318 |
|
319 /** |
|
320 * Prepares several structure type branding items. |
|
321 * These have to be fetched with GetStructure. |
|
322 * @param aMessage client's message |
|
323 */ |
|
324 void PrepareStructureL( const RMessage2 &aMessage ); |
|
325 |
|
326 /** |
|
327 * Gets the several structure type branding items |
|
328 * previously prepared. |
|
329 * @param aMessage client's message |
|
330 */ |
|
331 void GetStructureL( const RMessage2 &aMessage ); |
|
332 |
|
333 void isBrandUpdateRequiredL (const RMessage2 &aMessage); |
|
334 |
|
335 |
|
336 |
|
337 /** |
|
338 * |
|
339 * |
|
340 * @param aMessage client's message |
|
341 */ |
|
342 void InstallL( const RMessage2 &aMessage ); |
|
343 |
|
344 /** |
|
345 * |
|
346 * |
|
347 * @param aMessage client's message |
|
348 */ |
|
349 void ReplaceL( const RMessage2 &aMessage ); |
|
350 |
|
351 |
|
352 /** |
|
353 * |
|
354 * |
|
355 * @param aMessage client's message |
|
356 */ |
|
357 void AppendL( const RMessage2 &aMessage ); |
|
358 |
|
359 /** |
|
360 * |
|
361 * |
|
362 * @param aMessage client's message |
|
363 */ |
|
364 MBSElement* InternalizeElementL( RReadStream& aStream, TBool aAppending = EFalse ); |
|
365 |
|
366 |
|
367 /** |
|
368 * Cancels the transaction |
|
369 */ |
|
370 void StartTransactionL( const RMessage2 &aMessage ); |
|
371 |
|
372 |
|
373 /** |
|
374 * Cancels the transaction |
|
375 */ |
|
376 void CancelTransactionL( const RMessage2 &aMessage ); |
|
377 |
|
378 /** |
|
379 * Finishes the transaction |
|
380 */ |
|
381 void StopTransactionL( const RMessage2 &aMessage ); |
|
382 |
|
383 |
|
384 /** |
|
385 * Internalize element ids |
|
386 */ |
|
387 void InternalizeElementIdsL( RReadStream& aStream, RBSObjOwningPtrArray<HBufC8>& aArray ); |
|
388 |
|
389 /** |
|
390 * |
|
391 * |
|
392 * @param aMessage client's message |
|
393 */ |
|
394 void RemoveBrandL( const RMessage2 &aMessage ); |
|
395 |
|
396 |
|
397 /** |
|
398 * |
|
399 * |
|
400 * @param aMessage client's message |
|
401 */ |
|
402 void RemoveApplicationL( const RMessage2 &aMessage ); |
|
403 |
|
404 void PrepareAppendL(); |
|
405 |
|
406 void PrepareReplaceL(); |
|
407 |
|
408 TInt GetNewVersionL(); |
|
409 |
|
410 |
|
411 /** |
|
412 * Extracts some information from the specified RMessage2 |
|
413 * and saves it. |
|
414 * |
|
415 * @param aMessage a message from a client |
|
416 */ |
|
417 void ExtractInfoL( const RMessage2& aMessage ); |
|
418 |
|
419 private: // Data |
|
420 TBool iInitialized; |
|
421 TBool iAppending; |
|
422 TBool iAccessInit; |
|
423 TBool iWriteNeeded; |
|
424 |
|
425 // is backup process currently active |
|
426 TBool iBackupActive; |
|
427 |
|
428 HBufC* iBrandId; |
|
429 HBufC* iDefaultBrandId; |
|
430 HBufC* iApplicationId; |
|
431 TLanguage iLanguageId; |
|
432 |
|
433 TInt iValue; |
|
434 HBufC* iText; |
|
435 CBSBrandHandler* iBranding; |
|
436 CBufFlat* iSeveralData; |
|
437 HBufC8* iBuffer; |
|
438 TBool iMessageCompleted; |
|
439 |
|
440 CBSStorageManager* iStorageManager; |
|
441 |
|
442 TBool iObserverActive; |
|
443 RMessage2 iObserverMessage; |
|
444 |
|
445 // To send backup event to client |
|
446 TBool iIsBackup ; |
|
447 TInt iReserved; |
|
448 |
|
449 /** |
|
450 * Contains information about this object. |
|
451 * Own. |
|
452 */ |
|
453 CBSSessionInfo* iSessionInfo; |
|
454 |
|
455 }; |
|
456 |
|
457 #endif // __CBSSESSION_H__ |
|
458 |
|
459 |
|
460 // END OF FILE |
|
461 |
|