1 /* |
|
2 * Copyright (c) 2006-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: Server side session for thumbnail engine |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef THUMBNAILSERVERSESSION_H |
|
20 #define THUMBNAILSERVERSESSION_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32capability.h> |
|
24 |
|
25 #include "thumbnailmanagerconstants.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CThumbnailServer; |
|
29 |
|
30 /** |
|
31 * Server side session for thumbnail engine. |
|
32 * |
|
33 * @since S60 v5.0 |
|
34 */ |
|
35 NONSHARABLE_CLASS( CThumbnailServerSession ): public CSession2 |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Constructor. |
|
41 * |
|
42 * @since S60 v5.0 |
|
43 * @return New CThumbnailServerSession session. |
|
44 */ |
|
45 CThumbnailServerSession(); |
|
46 |
|
47 /** |
|
48 * Destructor |
|
49 * |
|
50 * @since S60 v5.0 |
|
51 */ |
|
52 virtual ~CThumbnailServerSession(); |
|
53 |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Message dispatcher. |
|
58 * |
|
59 * @since S60 v5.0 |
|
60 * @param aMessage Message to be passed. |
|
61 * @return Error code. |
|
62 */ |
|
63 TInt DispatchMessageL( const RMessage2& aMessage ); |
|
64 |
|
65 public: |
|
66 // Functions from base classes |
|
67 |
|
68 /** |
|
69 * CreateL |
|
70 * |
|
71 * @since S60 v5.0 |
|
72 */ |
|
73 void CreateL(); |
|
74 |
|
75 /** |
|
76 * From CSharableSession (pure virtual). |
|
77 * Handles service request messages from clients. |
|
78 * |
|
79 * @since S60 v5.0 |
|
80 * @param aMessage message from client. |
|
81 */ |
|
82 void ServiceL( const RMessage2& aMessage ); |
|
83 |
|
84 public: |
|
85 // New functions |
|
86 |
|
87 /** |
|
88 * Returns the server pointer. |
|
89 * |
|
90 * @since S60 v5.0 |
|
91 * @return Server pointer. |
|
92 */ |
|
93 CThumbnailServer* Server(); |
|
94 |
|
95 /** |
|
96 * Cancellation method. |
|
97 * |
|
98 * @since S60 v5.0 |
|
99 */ |
|
100 void Cancel(); |
|
101 |
|
102 /** |
|
103 * Converts SQL error to E32 error. |
|
104 * |
|
105 * @since S60 v5.0 |
|
106 * @param aReason Request message complete value which may be SQL error |
|
107 * @return Request message complete value but not SQL error |
|
108 */ |
|
109 static TInt ConvertSqlErrToE32Err( TInt aReason ); |
|
110 |
|
111 void ResolveMimeTypeL( RFile64* aFile ); |
|
112 |
|
113 void ModifyThumbnailSize( TInt aSourceType ); |
|
114 |
|
115 private: |
|
116 |
|
117 /** |
|
118 * RequestThumbByFileHandleAsyncL |
|
119 * |
|
120 * @since S60 v5.0 |
|
121 * @param aMessage Message. |
|
122 */ |
|
123 void RequestThumbByFileHandleAsyncL( const RMessage2& aMessage ); |
|
124 |
|
125 /** |
|
126 * RequestThumbByPathAsyncL |
|
127 * |
|
128 * @since S60 v5.0 |
|
129 * @param aMessage Message. |
|
130 */ |
|
131 void RequestThumbByPathAsyncL( const RMessage2& aMessage ); |
|
132 |
|
133 /** |
|
134 * RequestThumbByIdAsyncL |
|
135 * |
|
136 * @since S60 v5.0 |
|
137 * @param aMessage Message. |
|
138 */ |
|
139 void RequestThumbByIdAsyncL( const RMessage2& aMessage ); |
|
140 |
|
141 /** |
|
142 * RequestSetThumbnailByBufferL |
|
143 * |
|
144 * @since S60 v5.0 |
|
145 * @param aMessage Message. |
|
146 */ |
|
147 void RequestSetThumbnailByBufferL( const RMessage2& aMessage ); |
|
148 |
|
149 /** |
|
150 * RequestSetThumbnailByBitmapL |
|
151 * |
|
152 * @since S60 v5.0 |
|
153 * @param aMessage Message. |
|
154 */ |
|
155 void RequestSetThumbnailByBitmapL( const RMessage2& aMessage ); |
|
156 |
|
157 /** |
|
158 * Fetch thumbnail data from database. |
|
159 * |
|
160 * @since S60 v5.0 |
|
161 */ |
|
162 void FetchThumbnailL(); |
|
163 |
|
164 /** |
|
165 * Create a task to generate a new thumbnail |
|
166 * |
|
167 * @since S60 v5.0 |
|
168 * @param aFile File handle |
|
169 */ |
|
170 void CreateGenerateTaskFromFileHandleL( RFile64* aFile); |
|
171 |
|
172 /** |
|
173 * Create a task to generate a new thumbnail |
|
174 * |
|
175 * @since S60 v5.0 |
|
176 * @param aBuffer Source image buffer to be set |
|
177 */ |
|
178 void CreateGenerateTaskFromBufferL( TDesC8* aBuffer ); |
|
179 |
|
180 /** |
|
181 * Process a fetched bitmap by creating scale tasks |
|
182 * or by returning the bitmap as such. |
|
183 * |
|
184 * @since S60 v5.0 |
|
185 */ |
|
186 void ProcessBitmapL(); |
|
187 |
|
188 /** |
|
189 * ReleaseBitmap() |
|
190 * |
|
191 * @since S60 v5.0 |
|
192 * @param aMessage Message. |
|
193 */ |
|
194 void ReleaseBitmap( const RMessage2& aMessage ); |
|
195 |
|
196 /** |
|
197 * Cancels pending request. |
|
198 * |
|
199 * @since S60 v5.0 |
|
200 * @param aMessage Message. |
|
201 * @return Error code. |
|
202 */ |
|
203 TInt CancelRequest( const RMessage2& aMessage ); |
|
204 |
|
205 /** |
|
206 * Changes priority of pending request. |
|
207 * |
|
208 * @since S60 v5.0 |
|
209 * @param aMessage Message. |
|
210 * @return Error code. |
|
211 */ |
|
212 TInt ChangePriority( const RMessage2& aMessage ); |
|
213 |
|
214 /** |
|
215 * Delete thumbnails. |
|
216 * |
|
217 * @since S60 v5.0 |
|
218 * @param aMessage Message. |
|
219 */ |
|
220 void DeleteThumbnailsL( const RMessage2& aMessage ); |
|
221 |
|
222 /** |
|
223 * Delete thumbnails by Id. |
|
224 * |
|
225 * @since S60 v5.0 |
|
226 * @param aMessage Message. |
|
227 */ |
|
228 void DeleteThumbnailsByIdL( const RMessage2& aMessage ); |
|
229 |
|
230 /** |
|
231 * Get the required size (in characters) for a buffer that contains the |
|
232 * list of supported MIME types |
|
233 * |
|
234 * @since S60 v5.0 |
|
235 * @param aMessage Message. |
|
236 */ |
|
237 void GetMimeTypeBufferSizeL( const RMessage2& aMessage ); |
|
238 |
|
239 /** |
|
240 * Get the list of supported MIME types and store them in the buffer |
|
241 * allocated by the client. |
|
242 * |
|
243 * @since S60 v5.0 |
|
244 * @param aMessage Message. |
|
245 */ |
|
246 void GetMimeTypeListL( const RMessage2& aMessage ); |
|
247 |
|
248 /** |
|
249 * Update thumbnails by Thumbnail ID. |
|
250 * |
|
251 * @since S60 v5.0 |
|
252 * @param aMessage Message. |
|
253 */ |
|
254 void UpdateThumbnailsL( const RMessage2& aMessage ); |
|
255 |
|
256 /** |
|
257 * Rename thumbnails. |
|
258 * |
|
259 * @since S60 v5.0 |
|
260 * @param aMessage Message. |
|
261 */ |
|
262 void RenameThumbnailsL( const RMessage2& aMessage ); |
|
263 |
|
264 /** |
|
265 * Checks if client thread is still alive and RMessage2 handle valid. |
|
266 * |
|
267 * @since S60 v5.0 |
|
268 */ |
|
269 TBool ClientThreadAlive(); |
|
270 |
|
271 private: |
|
272 // data |
|
273 /** |
|
274 * Temporary store for any bitmaps fetched from the store. |
|
275 * Own. |
|
276 */ |
|
277 CFbsBitmap* iBitmap; |
|
278 |
|
279 /** |
|
280 * Temporary store for thumbnail request parameters as received |
|
281 * from the client. |
|
282 */ |
|
283 TThumbnailRequestParamsPckgBuf iRequestParams; |
|
284 |
|
285 /** |
|
286 * Message from client. This is kept in a member variable to make |
|
287 * sure the message is completed if a leave occurs while handling |
|
288 * the request. |
|
289 */ |
|
290 RMessage2 iMessage; |
|
291 |
|
292 /** |
|
293 * Size of the original object. Only valid if a stored thumbnail |
|
294 * was found when processing a request. |
|
295 */ |
|
296 TSize iOriginalSize; |
|
297 |
|
298 /** |
|
299 * Temporary store for any jpegs fetched from the store. |
|
300 * Own. |
|
301 */ |
|
302 TDesC8* iBuffer; |
|
303 |
|
304 TInt iBitmapHandle; |
|
305 |
|
306 // client thread from RMessage2 |
|
307 RThread iClientThread; |
|
308 }; |
|
309 |
|
310 #endif // THUMBNAILSERVERSESSION_H |
|