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: Processor |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef THUMBAGPROCESSOR_H |
|
20 #define THUMBAGPROCESSOR_H |
|
21 |
|
22 #include <thumbnailmanager.h> |
|
23 #include <thumbnailmanagerobserver.h> |
|
24 #include <thumbnaildata.h> |
|
25 #include <mdesession.h> |
|
26 #include <mdccommon.h> |
|
27 #include <mdeobjectquery.h> |
|
28 #include "thumbnaillog.h" |
|
29 #include <harvesterclient.h> |
|
30 #include <e32property.h> |
|
31 #include <mpxcollectionobserver.h> |
|
32 #include "tmactivitymanager.h" |
|
33 #include "tmformatobserver.h" |
|
34 #include "tmrpropertyobserver.h" |
|
35 #include "thumbnailmanagerconstants.h" |
|
36 |
|
37 //FORWARD DECLARATIONS |
|
38 class MMPXCollectionUtility; |
|
39 |
|
40 |
|
41 enum TThumbnailGenerationItemType |
|
42 { |
|
43 EGenerationItemTypeUnknown, |
|
44 EGenerationItemTypeNotFound, |
|
45 EGenerationItemTypeCamera, |
|
46 EGenerationItemTypeAny, |
|
47 EGenerationItemTypeAudio, |
|
48 EGenerationItemTypeVideo, |
|
49 EGenerationItemTypeImage, |
|
50 EGenerationItemTypeItemCount |
|
51 }; |
|
52 |
|
53 enum TThumbnailGenerationItemAction |
|
54 { |
|
55 EGenerationItemActionAdd, |
|
56 EGenerationItemActionDelete, |
|
57 EGenerationItemActionModify, |
|
58 EGenerationItemAction2ndAdd, |
|
59 EGenerationItemActionResolveType, |
|
60 EGenerationItemActionCount |
|
61 }; |
|
62 |
|
63 struct TThumbnailGenerationItem |
|
64 { |
|
65 inline TThumbnailGenerationItem(): iItemId( KErrNotFound ), iItemType(EGenerationItemTypeUnknown), |
|
66 iItemAction(EGenerationItemActionAdd), iPlaceholder(EFalse), iUri(NULL){} |
|
67 inline ~TThumbnailGenerationItem(){delete iUri; iUri = NULL;} |
|
68 |
|
69 TItemId iItemId; |
|
70 TThumbnailGenerationItemType iItemType; |
|
71 TThumbnailGenerationItemAction iItemAction; |
|
72 TBool iPlaceholder; |
|
73 HBufC* iUri; |
|
74 }; |
|
75 |
|
76 /** |
|
77 * Processor object for handling thumb generation |
|
78 * |
|
79 * @since S60 v5.0 |
|
80 */ |
|
81 class CThumbAGProcessor: public CActive, |
|
82 public MThumbnailManagerObserver, |
|
83 public MThumbnailManagerRequestObserver, |
|
84 public MMdEQueryObserver, |
|
85 public MHarvesterEventObserver, |
|
86 public MMPXCollectionObserver, |
|
87 public MTMActivityManagerObserver, |
|
88 public MTMFormatObserver, |
|
89 public MTMRPropertyObserver |
|
90 { |
|
91 public: |
|
92 |
|
93 /** |
|
94 * Two-phased constructor. |
|
95 * |
|
96 * @since S60 v5.0 |
|
97 * @return Instance of CThumbAGProcessor. |
|
98 */ |
|
99 static CThumbAGProcessor* NewL(); |
|
100 |
|
101 /** |
|
102 * Destructor |
|
103 * |
|
104 * @since S60 v5.0 |
|
105 */ |
|
106 virtual ~CThumbAGProcessor(); |
|
107 |
|
108 public: |
|
109 |
|
110 // From MMdEQueryObserver |
|
111 void HandleQueryNewResults( CMdEQuery& aQuery, |
|
112 TInt aFirstNewItemIndex, |
|
113 TInt aNewItemCount ); |
|
114 void HandleQueryCompleted( CMdEQuery& aQuery, TInt aError ); |
|
115 |
|
116 // from MThumbnailManagerObserver |
|
117 void ThumbnailPreviewReady( MThumbnailData& aThumbnail, TThumbnailRequestId aId ); |
|
118 void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId ); |
|
119 // from MThumbnailManagerRequestObserver |
|
120 void ThumbnailRequestReady( TInt aError, TThumbnailRequestType aRequestType, TThumbnailRequestId aId ); |
|
121 |
|
122 // from MHarvesterEventObserver |
|
123 void HarvestingUpdated( |
|
124 HarvesterEventObserverType aHEObserverType, |
|
125 HarvesterEventState aHarvesterEventState, |
|
126 TInt aItemsLeft ); |
|
127 |
|
128 //From MTMFormatObserver |
|
129 void FormatNotification(TBool aFormat); |
|
130 |
|
131 private: |
|
132 // From MMPXCollectionObserver |
|
133 /// See @ref MMPXCollectionObserver::HandleCollectionMessageL |
|
134 void HandleCollectionMessage( CMPXMessage* aMessage, TInt aError ); |
|
135 |
|
136 /// See @ref MMPXCollectionObserver::HandleOpenL |
|
137 void HandleOpenL(const CMPXMedia& aEntries, TInt aIndex, TBool aComplete, TInt aError); |
|
138 |
|
139 /// See @ref MMPXCollectionObserver::HandleOpenL |
|
140 void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist, TInt aError); |
|
141 |
|
142 /// See @ref MMPXCollectionObserver::HandleCollectionMediaL |
|
143 void HandleCollectionMediaL( const CMPXMedia& aMedia, TInt aError ); |
|
144 |
|
145 private: //From MTMActivityManagerObserver |
|
146 void ActivityChanged(const TBool aActive); |
|
147 |
|
148 private: //From MTMRPropertyObserver |
|
149 void RPropertyNotification(const TInt aError, const TUid aKeyCategory, const TUint aPropertyKey, const TInt aValue); |
|
150 |
|
151 public: |
|
152 |
|
153 /** |
|
154 * Sets MdE Session |
|
155 * |
|
156 * @since S60 v5.0 |
|
157 * @param aMdESession MdE Session |
|
158 */ |
|
159 void SetMdESessionL( CMdESession* aMdESession ); |
|
160 |
|
161 /** |
|
162 * Adds new IDs to queue |
|
163 * |
|
164 * @since S60 v5.0 |
|
165 * @param aType TObserverNotificationType |
|
166 * @param TThumbnailGenerationItemType |
|
167 * @param aIDArray IDs for thumbnail creation |
|
168 * @param aForce pass ETrue if processor is forced to run without waiting harvesting complete |
|
169 */ |
|
170 void AddToQueueL( TObserverNotificationType aType, TThumbnailGenerationItemType aItemType, |
|
171 const RArray<TItemId>& aIDArray, const RPointerArray<HBufC>& aObjectUriArray, |
|
172 TBool aPresent ); |
|
173 |
|
174 /** |
|
175 * Calls Thumbnail Manager to create thumbnails |
|
176 * |
|
177 * @since S60 v5.0 |
|
178 * @param aObject MdEObject |
|
179 */ |
|
180 void CreateThumbnailsL( const CMdEObject* aObject ); |
|
181 |
|
182 /** |
|
183 * Remove IDs from queue |
|
184 * |
|
185 * @since S60 v5.0 |
|
186 * @param aIDArray IDs for thumbnail creation |
|
187 */ |
|
188 void RemoveFromQueues( const RArray<TItemId>& aIDArray, const TBool aRemoveFromDelete = EFalse); |
|
189 |
|
190 void SetForceRun( const TBool aForceRun ); |
|
191 |
|
192 //prepare processor for shutdown |
|
193 void Shutdown(); |
|
194 |
|
195 protected: |
|
196 |
|
197 void QueryAllItemsL(); |
|
198 |
|
199 /** |
|
200 * QueryL |
|
201 * |
|
202 * @since S60 v5.0 |
|
203 * @param TThumbnailGenerationItemAction |
|
204 */ |
|
205 void QueryL( TThumbnailGenerationItemAction aType); |
|
206 |
|
207 /** |
|
208 * QueryPlaceholdersL |
|
209 * |
|
210 * @since S60 v5.0 |
|
211 * @param aPresent item should not be present item |
|
212 */ |
|
213 void QueryPlaceholdersL(const TBool aPresent); |
|
214 |
|
215 /** |
|
216 * DeleteAndCancelQuery |
|
217 * |
|
218 * @since Symbian^3 |
|
219 * @param aRemoveItems restore IDs back to original queue, default = ETrue |
|
220 */ |
|
221 void DeleteAndCancelQuery(TBool aRestoreItems); |
|
222 |
|
223 protected: |
|
224 |
|
225 /** |
|
226 * Handles an active object's request completion event. |
|
227 * |
|
228 * @since S60 v5.0 |
|
229 */ |
|
230 void RunL(); |
|
231 |
|
232 /** |
|
233 * Implements cancellation of an outstanding request. |
|
234 * |
|
235 * @since S60 v5.0 |
|
236 */ |
|
237 void DoCancel(); |
|
238 |
|
239 /** |
|
240 * Implements RunL error handling. |
|
241 * |
|
242 * @since S60 v5.0 |
|
243 */ |
|
244 TInt RunError(TInt aError); |
|
245 |
|
246 private: |
|
247 |
|
248 /** |
|
249 * C++ default constructor |
|
250 * |
|
251 * @since S60 v5.0 |
|
252 * @return Instance of CThumbAGProcessor. |
|
253 */ |
|
254 CThumbAGProcessor(); |
|
255 |
|
256 /** |
|
257 * Symbian 2nd phase constructor can leave. |
|
258 * |
|
259 * @since S60 v5.0 |
|
260 */ |
|
261 void ConstructL(); |
|
262 |
|
263 /** |
|
264 * Activate AO |
|
265 * |
|
266 * @since S60 v5.0 |
|
267 */ |
|
268 void ActivateAO(); |
|
269 |
|
270 /** |
|
271 * Callback for harvesting complete timer |
|
272 * |
|
273 * @since S60 v5.0 |
|
274 */ |
|
275 static TInt PeriodicTimerCallBack(TAny* aAny); |
|
276 |
|
277 /** |
|
278 * Check auto creation values from cenrep |
|
279 * |
|
280 * @since S60 v5.0 |
|
281 */ |
|
282 void CheckAutoCreateValuesL(); |
|
283 |
|
284 /** |
|
285 * Start timeout timer |
|
286 * |
|
287 * @since S60 v5.0 |
|
288 */ |
|
289 void StartTimeout(); |
|
290 |
|
291 /** |
|
292 * Cancel timeout timer |
|
293 * |
|
294 * @since S60 v5.0 |
|
295 */ |
|
296 void CancelTimeout(); |
|
297 |
|
298 /** |
|
299 * Update KItemsLeft PS value |
|
300 * |
|
301 * @since S60 v5.0 |
|
302 * @param aDefine (re)define PS key before setting value |
|
303 */ |
|
304 void UpdatePSValues(const TBool aDefine, const TBool aForce); |
|
305 |
|
306 /** |
|
307 * Comparison function for logaritmic use of queue arrays |
|
308 * |
|
309 * @since S60 S^3 |
|
310 */ |
|
311 static TInt Compare(const TThumbnailGenerationItem& aLeft, const TThumbnailGenerationItem& aRight); |
|
312 |
|
313 /** |
|
314 * Comparison function for logaritmic use of queue arrays |
|
315 * |
|
316 * @since S60 S^3 |
|
317 */ |
|
318 static TInt CompareId(const TItemId& aLeft, const TItemId& aRight); |
|
319 |
|
320 /** |
|
321 * Recalculate item counts |
|
322 * |
|
323 * @since S60 S^3 |
|
324 */ |
|
325 void UpdateItemCounts(); |
|
326 |
|
327 /** |
|
328 * Callback for mount timeout |
|
329 * |
|
330 * @since S60 v5.0 |
|
331 */ |
|
332 static TInt MountTimerCallBack(TAny* aAny); |
|
333 |
|
334 /** |
|
335 * Set item's action from type |
|
336 * |
|
337 * @since S^3 |
|
338 */ |
|
339 void SetGenerationItemAction( TThumbnailGenerationItem& aGenerationItem, const TThumbnailGenerationItemType aItemType ); |
|
340 |
|
341 /** |
|
342 * Set item type property from TDedIf |
|
343 * @param aGenerationItem TThumbnailGenerationItem |
|
344 * @param aItemType TThumbnailGenerationItemType |
|
345 * @since S^3 |
|
346 */ |
|
347 void SetGenerationItemType( TThumbnailGenerationItem& aGenerationItem, const TDefId aDefId ); |
|
348 |
|
349 /** |
|
350 * Append item to processing queue or update existing |
|
351 * @param aGenerationItem modified TThumbnailGenerationItem |
|
352 * @param aDefId items MDS object definition ID |
|
353 * @since S^3 |
|
354 */ |
|
355 void AppendProcessingQueue(TThumbnailGenerationItem& item ); |
|
356 |
|
357 private: |
|
358 |
|
359 // not own |
|
360 CMdESession* iMdESession; |
|
361 CMdENamespaceDef* iDefNamespace; |
|
362 |
|
363 // own |
|
364 CThumbnailManager* iTMSession; |
|
365 CMdEObjectQuery* iQuery; |
|
366 CMdEObjectQuery* iQueryAllItems; |
|
367 CMdEObjectQuery* iQueryPlaceholders; |
|
368 |
|
369 RArray<TThumbnailGenerationItem> iGenerationQueue; |
|
370 //RPointerArray<HBufC> iRemoveQueue; |
|
371 RArray<TItemId> iQueryQueue; |
|
372 |
|
373 //background generation state |
|
374 // EFalse = 1st round, create only grid size thumbnail for images and videos |
|
375 // ETrue = 2nds round, create all missing sizes for all media items |
|
376 TBool i2ndRound; |
|
377 |
|
378 // query state |
|
379 // EFalse = normal mode |
|
380 // ETrue = querying unknown items |
|
381 TBool iUnknown; |
|
382 |
|
383 //MDS query issues |
|
384 TBool iQueryActive; |
|
385 //MDS query complete |
|
386 TBool iQueryReady; |
|
387 |
|
388 //Processing MDS itens which are modified |
|
389 TBool iModify; |
|
390 TUint iProcessingCount; |
|
391 |
|
392 //MDS harvester's overall state |
|
393 TBool iHarvesting; |
|
394 TBool iHarvestingTemp; |
|
395 |
|
396 //MDS Harvester's placeholder harvesting state |
|
397 TBool iPHHarvesting; |
|
398 TBool iPHHarvestingTemp; |
|
399 |
|
400 //MDS Harvester's SD card harvesting state |
|
401 TBool iMMCHarvesting; |
|
402 TBool iMMCHarvestingTemp; |
|
403 |
|
404 CPeriodic* iPeriodicTimer; |
|
405 CPeriodic* iMountTimer; |
|
406 |
|
407 //MDS Harvester client |
|
408 RHarvesterClient iHarvesterClient; |
|
409 |
|
410 //Set when running RunL() first time |
|
411 TBool iInit; |
|
412 |
|
413 //2nd phase init after MDE session is open |
|
414 TBool iInit2; |
|
415 |
|
416 // auto create values from centrep |
|
417 TBool iAutoImage; |
|
418 TBool iAutoVideo; |
|
419 TBool iAutoAudio; |
|
420 |
|
421 // in case of modified files force TN update |
|
422 TBool iForceRun; |
|
423 // controlled by Photos application to run TN generation on foreground |
|
424 TBool iForegroundRun; |
|
425 //request pending in TNM side |
|
426 |
|
427 CTMFormatObserver* iFormatObserver; |
|
428 |
|
429 //formating started |
|
430 TBool iFormatting; |
|
431 //TNM server session died |
|
432 TBool iSessionDied; |
|
433 |
|
434 //pending request count |
|
435 TUint iActiveCount; |
|
436 |
|
437 MMPXCollectionUtility* iCollectionUtility; // own |
|
438 |
|
439 //Flag is MPX harvesting or MTP synchronisation in progress |
|
440 TBool iMPXHarvesting; |
|
441 |
|
442 //overall status of device |
|
443 TBool iIdle; |
|
444 |
|
445 //monitors device activity |
|
446 CTMActivityManager* iActivityManager; |
|
447 |
|
448 //Observer foreground generation |
|
449 CTMRPropertyObserver* iForegroundGenerationObserver; |
|
450 |
|
451 //Previously notified amount of items in processing queues (add/modify) |
|
452 TInt iPreviousItemsLeft; |
|
453 TBool iPreviousDaemonProcessing; |
|
454 //set ETrue when QueryAllItems needs to be run after placeholder query |
|
455 TBool iDoQueryAllItems; |
|
456 |
|
457 TBool iShutdown; |
|
458 |
|
459 //item counts |
|
460 TUint32 iModifyItemCount; |
|
461 TUint32 iImageItemCount; |
|
462 TUint32 iVideoItemCount; |
|
463 TUint32 iAudioItemCount; |
|
464 TUint32 iDeleteItemCount; |
|
465 TUint32 iAddItemCount; |
|
466 TUint32 iCameraItemCount; |
|
467 TUint32 iUnknownItemCount; |
|
468 TUint32 i2ndAddItemCount; |
|
469 TUint32 iPlaceholderItemCount; |
|
470 |
|
471 //for book keeping previous items left count got from MDS harvester |
|
472 TUint32 iMMCHarvestingItemsLeftTemp; |
|
473 TUint32 iPHHarvestingItemsLeftTemp; |
|
474 |
|
475 //MdE object definitons used in query |
|
476 CMdEObjectDef* iImageObjectDef; |
|
477 CMdEObjectDef* iVideoObjectDef; |
|
478 CMdEObjectDef* iAudioObjectDef; |
|
479 TBool iHarvesterActivated; |
|
480 }; |
|
481 |
|
482 #endif // THUMBAGPROCESSOR_H |
|