1 /* |
|
2 * Copyright (c) 2007-2007 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: Symbian OS server session. |
|
15 * libraries : |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef DIAGRESULTSDBSESSION_H |
|
21 #define DIAGRESULTSDBSESSION_H |
|
22 |
|
23 class CDiagResultsDbServer; |
|
24 class CDiagResultsDbTestRecord; |
|
25 |
|
26 #include "diagresultsdbstore.h" |
|
27 |
|
28 //System includes |
|
29 #include <e32cmn.h> //TUid |
|
30 #include <e32base.h> |
|
31 |
|
32 /** |
|
33 * Server session. Represents a session (version 2) |
|
34 * for a client thread on the server-side. |
|
35 * |
|
36 * @since S60 v5.0 |
|
37 **/ |
|
38 class CDiagResultsDbSession : |
|
39 public CSession2, |
|
40 public MRecordLoadingObserver |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Destructor. |
|
46 **/ |
|
47 ~CDiagResultsDbSession(); |
|
48 |
|
49 /** |
|
50 * NewL. |
|
51 * |
|
52 * @param aServer Server object. |
|
53 * @return DB session. |
|
54 **/ |
|
55 static CDiagResultsDbSession* NewL(CDiagResultsDbServer * aServer); |
|
56 |
|
57 public: // From CSession |
|
58 |
|
59 /** |
|
60 * Handles the servicing of a client request that has been |
|
61 * passed to the server. |
|
62 * |
|
63 * @param aMessage The message containing the details of the client request. |
|
64 **/ |
|
65 void ServiceL(const RMessage2 &aMessage); |
|
66 |
|
67 public: // New methods |
|
68 |
|
69 /** |
|
70 * Handle the client message. |
|
71 * |
|
72 * @param aMessage Details of the client request. |
|
73 * @return ETrue if client request is asynchronous, EFalse is synchronous. |
|
74 **/ |
|
75 TBool DispatchMessageL(const RMessage2 &aMessage); |
|
76 |
|
77 /** |
|
78 * Create a new subsession. |
|
79 * |
|
80 * @param aTestRecord Test record that represents the subsession. |
|
81 **/ |
|
82 void CreateSubsessionL(CDiagResultsDbTestRecordHandle* aTestRecordHandle, |
|
83 TBool aReadonly ); |
|
84 |
|
85 /** |
|
86 * Close the subsession. |
|
87 **/ |
|
88 void CloseSubsessionL(); |
|
89 |
|
90 /** |
|
91 * Returns the Uid of the results database file. |
|
92 * |
|
93 * @return TUid of the database file. |
|
94 **/ |
|
95 TUid DbUid() const; |
|
96 |
|
97 /** |
|
98 * Returns the results store. |
|
99 * |
|
100 * @return Results store. |
|
101 **/ |
|
102 CDiagResultsDbStore& Store(); |
|
103 |
|
104 /** |
|
105 * Helper function to read buffer from client side. |
|
106 * |
|
107 * @param aMessage Details of the client request. |
|
108 * @param aParam Message argument number. |
|
109 * @param aBuffer Buffer that is filled with client side data. |
|
110 **/ |
|
111 void ReadBufferL(const RMessage2& aMessage, TInt aParam, |
|
112 CBufFlat*& aBuffer); |
|
113 |
|
114 /** |
|
115 * Subsession must tell to the session has it written data. |
|
116 **/ |
|
117 void HasWritten(); |
|
118 |
|
119 /** |
|
120 * Indicates has the session wrote any data. |
|
121 * @return ETrue if session has wrote data, EFalse otherwise. |
|
122 **/ |
|
123 TBool SessionHasWritten() const; |
|
124 |
|
125 /** |
|
126 * Turn off compacting. For example KErrDiskFull causes compacting to fail. |
|
127 **/ |
|
128 void DoNotCompact(); |
|
129 |
|
130 |
|
131 public: //From MRecordLoadingObserver |
|
132 |
|
133 /** |
|
134 * Returns an array of test records. Contains all test records |
|
135 * from a single database file. |
|
136 * |
|
137 * @param aError Indicates if there were any errors. |
|
138 * @param aArray An array of test records. Ownership is transferred. |
|
139 **/ |
|
140 void ExistingRecordsL( TInt aError, |
|
141 RPointerArray<CDiagResultsDbTestRecord>* aArray ); |
|
142 |
|
143 protected: // service functions for client requests |
|
144 // Look at DiagResultsDatabaseCommon.h for the client requests. |
|
145 |
|
146 void ConnectSubsessionL( const RMessage2 &aMessage ); |
|
147 |
|
148 void CreateNewRecordL ( const RMessage2 &aMessage ); |
|
149 |
|
150 void GetLastRecordL( const RMessage2 &aMessage ); |
|
151 |
|
152 void GetLastNotCompletedRecordL( const RMessage2 &aMessage ); |
|
153 |
|
154 void GetRecordListL( const RMessage2 &aMessage ); |
|
155 |
|
156 void GetRecordInfoListL( const RMessage2 &aMessage ); |
|
157 |
|
158 void GetLastResultsL( const RMessage2 &aMessage ); |
|
159 |
|
160 void CancelLastResultsL(const RMessage2 &aMessage); |
|
161 |
|
162 void GetSingleLastResultL( const RMessage2 &aMessage ); |
|
163 |
|
164 private: |
|
165 |
|
166 /** |
|
167 * Constructor. |
|
168 * |
|
169 * @param aServer Server object. |
|
170 **/ |
|
171 CDiagResultsDbSession(CDiagResultsDbServer * aServer); |
|
172 |
|
173 /** |
|
174 * ConstructL. |
|
175 **/ |
|
176 void ConstructL(); |
|
177 |
|
178 /** |
|
179 * Find database item from the array based on uid. |
|
180 * |
|
181 * @param aUid Uid of the database item. |
|
182 * @param aArray Pointer array that contains test records. |
|
183 * @return Database item or NULL if not found. |
|
184 **/ |
|
185 CDiagResultsDatabaseItem* FindDatabaseItemL( |
|
186 TUid aUid, |
|
187 RPointerArray<CDiagResultsDbTestRecord>* aArray ); |
|
188 |
|
189 /** |
|
190 * Search for the newest test results. |
|
191 * |
|
192 * @param aUidArray Contains the uids to be searched. |
|
193 * @param aTestRecordArray Contains all test records. |
|
194 * @param aResultsArray Contains the found results or NULL if the test |
|
195 * result was not found. |
|
196 **/ |
|
197 void SearchLastResultsL( |
|
198 const CArrayFixFlat<TUid>& aUidArray, |
|
199 RPointerArray<CDiagResultsDbTestRecord>& aTestRecordArray, |
|
200 RPointerArray<CDiagResultsDatabaseItem>& aResultsArray ); |
|
201 |
|
202 /** |
|
203 * Reads uids that are searched from the buffer and creates the test result array. |
|
204 * |
|
205 * @param aArray Contains all test records. |
|
206 **/ |
|
207 void FindLastResultsL( RPointerArray<CDiagResultsDbTestRecord>& aArray ); |
|
208 |
|
209 /** |
|
210 * Read last results buffer if there would be any additional test results. |
|
211 * |
|
212 * @param aUidArray Test results to be searched. |
|
213 * @param aResultsArray results array. Found test results are appended into this. |
|
214 **/ |
|
215 void CheckLastResultsBufferL( |
|
216 const CArrayFixFlat<TUid>& aUidArray, |
|
217 RPointerArray<CDiagResultsDatabaseItem>& aResultsArray ); |
|
218 |
|
219 /** |
|
220 * Read last results buffer if there would be any additional test results. |
|
221 * |
|
222 * @param aTestUid UID to be searched from the last buffer. |
|
223 * @param aResult Returns the last result if found. Otherwise NULL. |
|
224 **/ |
|
225 void CheckLastResultsBufferL( |
|
226 TUid aTestUid, |
|
227 CDiagResultsDatabaseItem*& aResult ); |
|
228 |
|
229 |
|
230 private: // Data |
|
231 |
|
232 // Server pointer. |
|
233 CDiagResultsDbServer *iServer; |
|
234 |
|
235 // Counts subsession. |
|
236 CObjectCon* iSubsessionContainer; |
|
237 |
|
238 // Index to the container. |
|
239 CObjectIx* iSubsessionIndex; |
|
240 |
|
241 // Client request details. |
|
242 RMessage2 iMsg; |
|
243 |
|
244 //Indicates are we handling InitiateGetLastResults or InitiateGetLastResult |
|
245 TInt iLastResultCommand; |
|
246 |
|
247 // This is needed when InitiateGetLastResults is called. |
|
248 RMessage2 iLastResultsMsg; |
|
249 |
|
250 // This is needed when InitiateGetLastResult is called. |
|
251 RMessage2 iLastSingleResultsMsg; |
|
252 |
|
253 // Database uid. |
|
254 TUid iDbUid; |
|
255 |
|
256 // Contains the permanent file store. |
|
257 CDiagResultsDbStore* iStore; |
|
258 |
|
259 // GetLastResultsL operation needs this. |
|
260 RPointerArray<CDiagResultsDatabaseItem>* iBufferedLastResults; |
|
261 |
|
262 // Contains buffered test result. |
|
263 // |
|
264 CDiagResultsDatabaseItem* iBufferedSingleResult; |
|
265 |
|
266 // Indicates has this session wrote any data. |
|
267 TBool iHasWrittenData; |
|
268 |
|
269 // Dynamic flat buffer for transmitting data across IPC. |
|
270 CBufFlat* iBuffer; |
|
271 }; |
|
272 |
|
273 #endif // DIAGRESULTSDBSESSION_H |
|