99 break; |
102 break; |
100 } |
103 } |
101 return type; |
104 return type; |
102 } |
105 } |
103 |
106 |
|
107 |
|
108 // --------------------------------------------------------------------------- |
|
109 // CGlxMDSShutdownObserver::NewL() |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 CGlxMDSShutdownObserver* CGlxMDSShutdownObserver::NewL( MGlxMDSShutdownObserver& aObserver, |
|
113 const TUid& aKeyCategory, |
|
114 const TInt aPropertyKey, |
|
115 TBool aDefineKey) |
|
116 { |
|
117 TRACER("CGlxMDSShutdownObserver* CGlxMDSShutdownObserver::NewL"); |
|
118 CGlxMDSShutdownObserver* self = new( ELeave )CGlxMDSShutdownObserver( aObserver, |
|
119 aKeyCategory, |
|
120 aPropertyKey, |
|
121 aDefineKey); |
|
122 CleanupStack::PushL( self ); |
|
123 self->ConstructL(); |
|
124 CleanupStack::Pop( self ); |
|
125 return self; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CGlxMDSShutdownObserver::CGlxMDSShutdownObserver() |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 CGlxMDSShutdownObserver::CGlxMDSShutdownObserver( MGlxMDSShutdownObserver& aObserver, |
|
133 const TUid& aKeyCategory, |
|
134 const TInt aPropertyKey, |
|
135 TBool aDefineKey) |
|
136 : CActive( CActive::EPriorityStandard ), iObserver( aObserver ), |
|
137 iKeyCategory( aKeyCategory ), iPropertyKey(aPropertyKey), iDefineKey( aDefineKey ) |
|
138 { |
|
139 TRACER("CGlxMDSShutdownObserver::CGlxMDSShutdownObserver()"); |
|
140 CActiveScheduler::Add( this ); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CGlxMDSShutdownObserver::ConstructL() |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void CGlxMDSShutdownObserver::ConstructL() |
|
148 { |
|
149 TRACER("void CGlxMDSShutdownObserver::ConstructL()"); |
|
150 // define P&S property types |
|
151 if (iDefineKey) |
|
152 { |
|
153 RProperty::Define(iKeyCategory,iPropertyKey, |
|
154 RProperty::EInt,KAllowAllPolicy,KPowerMgmtPolicy); |
|
155 } |
|
156 |
|
157 // attach to the property |
|
158 TInt err = iProperty.Attach(iKeyCategory,iPropertyKey,EOwnerThread); |
|
159 User::LeaveIfError(err); |
|
160 |
|
161 // wait for the previously attached property to be updated |
|
162 iProperty.Subscribe(iStatus); |
|
163 SetActive(); |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CGlxMDSShutdownObserver::~CGlxMDSShutdownObserver() |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 CGlxMDSShutdownObserver::~CGlxMDSShutdownObserver() |
|
171 { |
|
172 TRACER("CGlxMDSShutdownObserver::~CGlxMDSShutdownObserver()"); |
|
173 Cancel(); |
|
174 iProperty.Close(); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CGlxMDSShutdownObserver::RunL() |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CGlxMDSShutdownObserver::RunL() |
|
182 { |
|
183 TRACER("void CGlxMDSShutdownObserver::RunL()"); |
|
184 |
|
185 // resubscribe before processing new value to prevent missing updates |
|
186 iProperty.Subscribe(iStatus); |
|
187 SetActive(); |
|
188 |
|
189 // retrieve the value |
|
190 TInt value = 0; |
|
191 TInt err = iProperty.Get(value); |
|
192 GLX_DEBUG2("CGlxMDSShutdownObserver::RunL(): iProperty.Get(value); returns %d", err); |
|
193 |
|
194 User::LeaveIfError(err); |
|
195 |
|
196 iObserver.ShutdownNotification(value); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CGlxMDSShutdownObserver::DoCancel() |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CGlxMDSShutdownObserver::DoCancel() |
|
204 { |
|
205 TRACER("void CGlxMDSShutdownObserver::DoCancel()"); |
|
206 iProperty.Cancel(); |
|
207 } |
|
208 |
|
209 |
|
210 |
104 // ============================ MEMBER FUNCTIONS ============================== |
211 // ============================ MEMBER FUNCTIONS ============================== |
105 |
212 |
106 // --------------------------------------------------------------------------- |
213 // --------------------------------------------------------------------------- |
107 // NewL() |
214 // NewL() |
108 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
141 { |
248 { |
142 iThumbnailCreator->Close(iThumbnailDatabase); |
249 iThumbnailCreator->Close(iThumbnailDatabase); |
143 } |
250 } |
144 delete iThumbnailDatabase; |
251 delete iThumbnailDatabase; |
145 #endif |
252 #endif |
146 |
|
147 iFs.Close(); |
253 iFs.Close(); |
|
254 iHC.Close(); |
148 RFbsSession::Disconnect(); |
255 RFbsSession::Disconnect(); |
149 iMonthArray.Close(); |
256 iMonthArray.Close(); |
150 iMonthList.Close(); |
257 iMonthList.Close(); |
151 iUpdateData.Close(); |
258 iUpdateData.Close(); |
|
259 iAddedItems.Reset(); |
|
260 iAddedItems.Close(); |
152 delete iUpdateCallback; |
261 delete iUpdateCallback; |
153 delete iCreateSessionCallback; |
262 delete iCreateSessionCallback; |
|
263 delete iMDSShutdownObserver ; |
154 } |
264 } |
155 |
265 |
156 // --------------------------------------------------------------------------- |
266 // --------------------------------------------------------------------------- |
157 // CGlxDataSourceMde() |
267 // CGlxDataSourceMde() |
158 // --------------------------------------------------------------------------- |
268 // --------------------------------------------------------------------------- |
159 // |
269 // |
160 CGlxDataSourceMde::CGlxDataSourceMde() |
270 CGlxDataSourceMde::CGlxDataSourceMde() |
161 { |
271 { |
162 TRACER("CGlxDataSourceMde::CGlxDataSourceMde()") |
272 TRACER("CGlxDataSourceMde::CGlxDataSourceMde()"); |
163 //No Implementation |
273 //No Implementation |
164 } |
274 } |
165 |
275 |
166 // --------------------------------------------------------------------------- |
276 // --------------------------------------------------------------------------- |
167 // ConstructL() |
277 // ConstructL() |
168 // --------------------------------------------------------------------------- |
278 // --------------------------------------------------------------------------- |
169 // |
279 // |
170 void CGlxDataSourceMde::ConstructL() |
280 void CGlxDataSourceMde::ConstructL() |
171 { |
281 { |
172 TRACER("CGlxDataSourceMde::ConstructL()") |
282 TRACER("CGlxDataSourceMde::ConstructL()"); |
173 |
283 |
174 iDataSourceReady = EFalse; |
284 iDataSourceReady = EFalse; |
175 User::LeaveIfError(iFs.Connect()); |
285 User::LeaveIfError(iFs.Connect()); |
176 iSession = CMdESession::NewL( *this ); |
286 iSession = CMdESession::NewL( *this ); |
177 |
287 |
178 User::LeaveIfError(RFbsSession::Connect()); |
288 User::LeaveIfError(RFbsSession::Connect()); |
179 |
289 |
180 #ifdef USE_S60_TNM |
290 #ifdef USE_S60_TNM |
181 iTnEngine = CThumbnailManager::NewL( *this); |
291 iTnEngine = CThumbnailManager::NewL( *this); |
182 iTnEngine->SetFlagsL(CThumbnailManager::EAllowAnySize); |
292 iTnEngine->SetDisplayModeL( EColor16M ); |
183 iTnEngine->SetDisplayModeL( EColor64K ); |
|
184 iTnRequestInProgress = EFalse; |
293 iTnRequestInProgress = EFalse; |
185 #else |
294 #else |
186 iThumbnailCreator = CGlxtnThumbnailCreator::InstanceL(); |
295 iThumbnailCreator = CGlxtnThumbnailCreator::InstanceL(); |
187 iThumbnailDatabase = CGlxtnThumbnailDatabase::NewL( |
296 iThumbnailDatabase = CGlxtnThumbnailDatabase::NewL( |
188 KGlxMdeDataSourceThumbnailDatabase, this); |
297 KGlxMdeDataSourceThumbnailDatabase, this); |
189 #endif |
298 #endif |
190 |
299 |
191 iCreateSessionCallback = new ( ELeave ) |
300 iCreateSessionCallback = new ( ELeave ) |
192 CAsyncCallBack( TCallBack( CreateSession, this ), CActive::EPriorityHigh ); |
301 CAsyncCallBack( TCallBack( CreateSession, this ), CActive::EPriorityHigh ); |
|
302 |
|
303 iMDSShutdownObserver = CGlxMDSShutdownObserver::NewL( *this, KHarvesterPSShutdown, KMdSShutdown, EFalse ); |
|
304 |
193 iUpdateCallback = new ( ELeave ) |
305 iUpdateCallback = new ( ELeave ) |
194 CAsyncCallBack( TCallBack( ProcessItemUpdate, this ), CActive::EPriorityLow ); |
306 CAsyncCallBack( TCallBack( ProcessItemUpdate, this ), CActive::EPriorityLow ); |
195 iUpdateData.Reserve(100); // ignore if it fails |
307 iUpdateData.Reserve(100); // ignore if it fails |
|
308 |
|
309 User::LeaveIfError(iHC.Connect()); |
|
310 iHC.AddHarvesterEventObserver(*this, EHEObserverTypePlaceholder, KHarvestUpdateChunkSize); |
|
311 |
|
312 iHarvestingOngoing = EFalse; |
196 } |
313 } |
197 |
314 |
198 // ---------------------------------------------------------------------------- |
315 // ---------------------------------------------------------------------------- |
199 // from MMdESessionObserver |
316 // from MMdESessionObserver |
200 // CMPXCollectionMdEPlugin::HandleSessionOpened |
317 // CMPXCollectionMdEPlugin::HandleSessionOpened |
201 // ---------------------------------------------------------------------------- |
318 // ---------------------------------------------------------------------------- |
202 // |
319 // |
203 void CGlxDataSourceMde::HandleSessionOpened( CMdESession& aSession, TInt aError ) |
320 void CGlxDataSourceMde::HandleSessionOpened( CMdESession& aSession, TInt aError ) |
204 { |
321 { |
205 TRACER("CGlxDataSourceMde::HandleSessionOpened(CMdESession& aSession, TInt aError)") |
322 TRACER("CGlxDataSourceMde::HandleSessionOpened(CMdESession& aSession, TInt aError)"); |
206 if( KErrNone != aError ) |
323 if( KErrNone != aError ) |
207 { |
324 { |
208 HandleSessionError(aSession, aError); |
325 HandleSessionError(aSession, aError); |
209 } |
326 } |
210 TRAPD(err, DoSessionInitL()); |
327 TRAPD(err, DoSessionInitL()); |
211 if( KErrNone != err ) |
328 if (KErrNone == err) |
|
329 { |
|
330 iSessionOpen = ETrue; |
|
331 iDataSourceReady = ETrue; |
|
332 TryStartTask(ETrue); |
|
333 } |
|
334 else |
212 { |
335 { |
213 HandleSessionError(aSession, err); |
336 HandleSessionError(aSession, err); |
214 } |
337 } |
215 |
|
216 iSessionOpen = ETrue; |
|
217 iDataSourceReady = ETrue; |
|
218 TryStartTask(ETrue); |
|
219 } |
338 } |
220 |
339 |
221 // ---------------------------------------------------------------------------- |
340 // ---------------------------------------------------------------------------- |
222 // from MMdESessionObserver |
341 // from MMdESessionObserver |
223 // CMPXCollectionMdEPlugin::HandleSessionError |
342 // CMPXCollectionMdEPlugin::HandleSessionError |
224 // ---------------------------------------------------------------------------- |
343 // ---------------------------------------------------------------------------- |
225 // |
344 // |
226 void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/ ) |
345 void CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError ) |
227 { |
346 { |
228 TRACER("CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt /*aError*/)") |
347 TRACER("CGlxDataSourceMde::HandleSessionError(CMdESession& /*aSession*/, TInt aError)") |
229 delete iSession; |
348 GLX_DEBUG2("void CGlxDataSourceMde::HandleSessionError() aError(%d)", aError); |
230 iSession = NULL; |
349 |
231 iDataSourceReady = EFalse; |
350 iDataSourceReady = EFalse; |
232 iSessionOpen = EFalse; |
351 iSessionOpen = EFalse; |
233 iCreateSessionCallback->CallBack(); |
352 |
234 } |
353 // We wait till MDS restarts before starting the session if the current session is locked. |
235 |
354 // that is handled separately by the MDS Shutdown PUB SUB Framework. |
|
355 // for everything else we use the generic method and continue. |
|
356 if ( (KErrLocked != aError) && ( KErrServerTerminated != aError) ) |
|
357 { |
|
358 iCreateSessionCallback->CallBack(); |
|
359 } |
|
360 } |
236 |
361 |
237 // --------------------------------------------------------------------------- |
362 // --------------------------------------------------------------------------- |
238 // CreateTaskL |
363 // CreateTaskL |
239 // --------------------------------------------------------------------------- |
364 // --------------------------------------------------------------------------- |
240 // |
365 // |
241 CGlxDataSourceTask* CGlxDataSourceMde::CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver) |
366 CGlxDataSourceTask* CGlxDataSourceMde::CreateTaskL(CGlxRequest* aRequest, |
242 { |
367 MGlxDataSourceRequestObserver& aObserver) |
243 TRACER("CGlxDataSourceTask* CGlxDataSourceMde::CreateTaskL(CGlxRequest* aRequest, MGlxDataSourceRequestObserver& aObserver)") |
368 { |
|
369 TRACER("CGlxDataSourceTask* CGlxDataSourceMde::CreateTaskL(CGlxRequest* aRequest,MGlxDataSourceRequestObserver& aObserver)") ; |
244 if(dynamic_cast<CGlxCommandRequest*>(aRequest)) |
370 if(dynamic_cast<CGlxCommandRequest*>(aRequest)) |
245 { |
371 { |
246 CleanupStack::PushL(aRequest); |
372 CleanupStack::PushL(aRequest); |
247 CGlxDataSourceTaskMdeCommand* task = new (ELeave) CGlxDataSourceTaskMdeCommand(static_cast<CGlxCommandRequest*>(aRequest), aObserver, this); |
373 CGlxDataSourceTaskMdeCommand* task = new (ELeave) |
|
374 CGlxDataSourceTaskMdeCommand(static_cast<CGlxCommandRequest*>(aRequest), |
|
375 aObserver, this); |
248 CleanupStack::Pop(aRequest); // now owned by task |
376 CleanupStack::Pop(aRequest); // now owned by task |
249 CleanupStack::PushL(task); |
377 CleanupStack::PushL(task); |
250 task->ConstructL(); |
378 task->ConstructL(); |
251 CleanupStack::Pop(task); |
379 CleanupStack::Pop(task); |
252 return task; |
380 return task; |
253 } |
381 } |
254 else if (dynamic_cast< CGlxGetRequest *>(aRequest)) |
382 else if (dynamic_cast< CGlxGetRequest *>(aRequest)) |
255 { |
383 { |
256 GLX_LOG_INFO("==> CGlxDataSourceMde::CreateTaskL - CGlxDataSourceTaskMdeAttributeMde+"); |
|
257 #ifdef _DEBUG |
|
258 _LIT( KFormatTimeStamp, "[%H:%T:%S.%*C5]"); |
|
259 TTime time; |
|
260 time.HomeTime(); // Get home time |
|
261 TBuf<32> timeStampBuf; |
|
262 time.FormatL(timeStampBuf, KFormatTimeStamp); |
|
263 RDebug::Print(_L("%S"), &timeStampBuf); |
|
264 #endif |
|
265 CleanupStack::PushL(aRequest); |
384 CleanupStack::PushL(aRequest); |
266 CGlxDataSourceTaskMdeAttributeMde* task = new (ELeave) CGlxDataSourceTaskMdeAttributeMde(static_cast<CGlxGetRequest*>(aRequest), aObserver, this); |
385 CGlxDataSourceTaskMdeAttributeMde* task = new (ELeave) |
|
386 CGlxDataSourceTaskMdeAttributeMde(static_cast<CGlxGetRequest*>(aRequest), |
|
387 aObserver, this); |
267 CleanupStack::Pop(aRequest); // now owned by task |
388 CleanupStack::Pop(aRequest); // now owned by task |
268 CleanupStack::PushL(task); |
389 CleanupStack::PushL(task); |
269 task->ConstructL(); |
390 task->ConstructL(); |
270 CleanupStack::Pop(task); |
391 CleanupStack::Pop(task); |
271 return task; |
392 return task; |
272 } |
393 } |
273 else if (dynamic_cast< CGlxIdListRequest *>(aRequest)) |
394 else if (dynamic_cast< CGlxIdListRequest *>(aRequest)) |
274 { |
395 { |
275 CleanupStack::PushL(aRequest); |
396 CleanupStack::PushL(aRequest); |
276 CGlxDataSourceTaskMdeIdList* task = new (ELeave) CGlxDataSourceTaskMdeIdList(static_cast<CGlxIdListRequest*>(aRequest), aObserver, this); |
397 CGlxDataSourceTaskMdeIdList* task = new (ELeave) |
|
398 CGlxDataSourceTaskMdeIdList(static_cast<CGlxIdListRequest*>(aRequest), |
|
399 aObserver, this); |
277 CleanupStack::Pop(aRequest); // now owned by task |
400 CleanupStack::Pop(aRequest); // now owned by task |
278 CleanupStack::PushL(task); |
401 CleanupStack::PushL(task); |
279 task->ConstructL(); |
402 task->ConstructL(); |
280 CleanupStack::Pop(task); |
403 CleanupStack::Pop(task); |
281 return task; |
404 return task; |
282 } |
405 } |
283 else if (dynamic_cast< CGlxThumbnailRequest *>(aRequest)) |
406 else if (dynamic_cast< CGlxThumbnailRequest *>(aRequest)) |
284 { |
407 { |
285 GLX_LOG_INFO("==> CGlxDataSourceMde::CreateTaskL - CGlxDataSourceTaskMdeThumbnail+"); |
|
286 #ifdef _DEBUG |
|
287 _LIT( KFormatTimeStamp, "[%H:%T:%S.%*C5]"); |
|
288 TTime time; |
|
289 time.HomeTime(); // Get home time |
|
290 TBuf<32> timeStampBuf; |
|
291 time.FormatL(timeStampBuf, KFormatTimeStamp); |
|
292 RDebug::Print(_L("%S"), &timeStampBuf); |
|
293 #endif |
|
294 CleanupStack::PushL(aRequest); |
408 CleanupStack::PushL(aRequest); |
295 CGlxDataSourceTaskMdeThumbnail* task = new (ELeave) CGlxDataSourceTaskMdeThumbnail(static_cast<CGlxThumbnailRequest*>(aRequest), aObserver, this); |
409 CGlxDataSourceTaskMdeThumbnail* task = new (ELeave) |
|
410 CGlxDataSourceTaskMdeThumbnail(static_cast<CGlxThumbnailRequest*>(aRequest), |
|
411 aObserver, this); |
296 CleanupStack::Pop(aRequest); // now owned by task |
412 CleanupStack::Pop(aRequest); // now owned by task |
297 CleanupStack::PushL(task); |
413 CleanupStack::PushL(task); |
298 task->ConstructL(); |
414 task->ConstructL(); |
299 CleanupStack::Pop(task); |
415 CleanupStack::Pop(task); |
300 return task; |
416 return task; |
309 #ifndef USE_S60_TNM |
425 #ifndef USE_S60_TNM |
310 // --------------------------------------------------------------------------- |
426 // --------------------------------------------------------------------------- |
311 // ThumbnailAvailable |
427 // ThumbnailAvailable |
312 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
313 // |
429 // |
314 void CGlxDataSourceMde::ThumbnailAvailable(const TGlxMediaId& /*aId*/, const TSize& /*aSize*/) |
430 void CGlxDataSourceMde::ThumbnailAvailable(const TGlxMediaId& |
315 { |
431 /*aId*/, const TSize& /*aSize*/) |
316 TRACER("CGlxDataSourceMde::ThumbnailAvailable(const TGlxMediaId& /*aId*/, const TSize& /*aSize*/)") |
432 { |
|
433 TRACER("CGlxDataSourceMde::ThumbnailAvailable(const TGlxMediaId& /*aId*/, const TSize& /*aSize*/)"); |
317 //No implementation |
434 //No implementation |
318 } |
435 } |
319 |
436 |
320 // --------------------------------------------------------------------------- |
437 // --------------------------------------------------------------------------- |
321 // BackgroundThumbnailError |
438 // BackgroundThumbnailError |
322 // --------------------------------------------------------------------------- |
439 // --------------------------------------------------------------------------- |
323 // |
440 // |
324 void CGlxDataSourceMde::BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError) |
441 void CGlxDataSourceMde::BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError) |
325 { |
442 { |
326 TRACER("CGlxDataSourceMde::BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError)") |
443 TRACER("CGlxDataSourceMde::BackgroundThumbnailError(const TGlxMediaId& aId, TInt aError)"); |
327 TSize size(0, 0); |
444 TSize size(0, 0); |
328 TRAP_IGNORE(BackgroundThumbnailMessageL(aId, size, aError)); |
445 TRAP_IGNORE(BackgroundThumbnailMessageL(aId, size, aError)); |
329 } |
446 } |
330 #endif |
447 #endif |
331 |
448 |
332 // --------------------------------------------------------------------------- |
449 // --------------------------------------------------------------------------- |
333 // BackgroundThumbnailMessageL |
450 // BackgroundThumbnailMessageL |
334 // --------------------------------------------------------------------------- |
451 // --------------------------------------------------------------------------- |
335 // |
452 // |
336 void CGlxDataSourceMde::BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError) |
453 void CGlxDataSourceMde::BackgroundThumbnailMessageL(const TGlxMediaId& aId, |
337 { |
454 const TSize& aSize, TInt aError) |
338 TRACER("CGlxDataSourceMde::BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError)") |
455 { |
|
456 TRACER("CGlxDataSourceMde::BackgroundThumbnailMessageL(const TGlxMediaId& aId, const TSize& aSize, TInt aError)"); |
339 CMPXMessage* message = CMPXMessage::NewL(); |
457 CMPXMessage* message = CMPXMessage::NewL(); |
340 CleanupStack::PushL(message); |
458 CleanupStack::PushL(message); |
341 message->SetTObjectValueL(KMPXMessageGeneralId, KGlxMessageIdBackgroundThumbnail); |
459 message->SetTObjectValueL(KMPXMessageGeneralId, KGlxMessageIdBackgroundThumbnail); |
342 message->SetTObjectValueL<TMPXItemId>(KGlxBackgroundThumbnailMediaId, aId.Value()); |
460 message->SetTObjectValueL<TMPXItemId>(KGlxBackgroundThumbnailMediaId, aId.Value()); |
343 message->SetTObjectValueL(KGlxBackgroundThumbnailSize, aSize); |
461 message->SetTObjectValueL(KGlxBackgroundThumbnailSize, aSize); |
411 ///@todo AB test this |
540 ///@todo AB test this |
412 void CGlxDataSourceMde::HandleObjectNotification(CMdESession& /*aSession*/, |
541 void CGlxDataSourceMde::HandleObjectNotification(CMdESession& /*aSession*/, |
413 TObserverNotificationType aType, |
542 TObserverNotificationType aType, |
414 const RArray<TItemId>& aObjectIdArray) |
543 const RArray<TItemId>& aObjectIdArray) |
415 { |
544 { |
416 TRACER("CGlxDataSourceMde::HandleObjectNotification()") |
545 TRACER("CGlxDataSourceMde::HandleObjectNotification()"); |
|
546 GLX_LOG_INFO3("CGlxDataSourceMde::HandleObjectNotification() aType=%d, aObjectIdArray.Count()=%d, iHarvestingOngoing=%d", |
|
547 aType, aObjectIdArray.Count(), |
|
548 iHarvestingOngoing); |
|
549 if (ENotifyAdd == aType) |
|
550 { |
|
551 for ( TInt i = 0; i < aObjectIdArray.Count(); i++ ) |
|
552 { |
|
553 iAddedItems.Append(aObjectIdArray[i]); |
|
554 } |
|
555 GLX_LOG_INFO1("ENotifyAdd - iAddedItems.Count()=%d", iAddedItems.Count()); |
|
556 } |
|
557 |
|
558 if (ENotifyModify == aType) |
|
559 { |
|
560 for ( TInt i = 0; i < aObjectIdArray.Count(); i++ ) |
|
561 { |
|
562 if (iAddedItems.Find(aObjectIdArray[i]) != KErrNotFound) |
|
563 { |
|
564 if (!iHarvestingOngoing) |
|
565 { |
|
566 GLX_LOG_INFO("ENotifyModify - Harvesting Completed - " |
|
567 "Reset iAddedItems array"); |
|
568 iAddedItems.Reset(); |
|
569 break; |
|
570 } |
|
571 GLX_LOG_INFO("ENotifyModify - Id found in iAddedItems array, DO NOT PROCESS"); |
|
572 return; |
|
573 } |
|
574 } |
|
575 } |
|
576 |
|
577 GLX_LOG_INFO("ProcessUpdateArray"); |
417 ProcessUpdateArray(aObjectIdArray, MPXChangeEventType(aType), ETrue); |
578 ProcessUpdateArray(aObjectIdArray, MPXChangeEventType(aType), ETrue); |
418 #ifndef USE_S60_TNM |
579 #ifndef USE_S60_TNM |
419 if(MPXChangeEventType(aType) == EMPXItemDeleted ) |
580 if(MPXChangeEventType(aType) == EMPXItemDeleted ) |
420 { |
581 { |
421 TInt count = aObjectIdArray.Count(); |
582 TInt count = aObjectIdArray.Count(); |
422 iDeletedCount += count; |
583 iDeletedCount += count; |
|
584 GLX_LOG_INFO2("EMPXItemDeleted - aObjectIdArray.Count()=%d, iDeletedCount=%d", |
|
585 count, iDeletedCount); |
423 if(iDeletedCount > KGlxThumbnailCleanupAfterDeletions) |
586 if(iDeletedCount > KGlxThumbnailCleanupAfterDeletions) |
424 { |
587 { |
425 TRAPD(err, ThumbnailCreator().CleanupThumbnailsL(iThumbnailDatabase)); |
588 TRAPD(err, ThumbnailCreator().CleanupThumbnailsL(iThumbnailDatabase)); |
426 if(!err) |
589 if(!err) |
427 { |
590 { |
428 iDeletedCount = 0; |
591 iDeletedCount = 0; |
429 } |
592 } |
430 } |
593 } |
431 } |
594 } |
|
595 |
|
596 if(MPXChangeEventType(aType) == EMPXItemModified ) |
|
597 { |
|
598 GLX_LOG_INFO("EMPXItemModified"); |
|
599 TRAP_IGNORE(ThumbnailCreator().CleanupThumbnailsL(iThumbnailDatabase)); |
|
600 } |
432 #endif |
601 #endif |
433 } |
602 } |
434 |
|
435 |
603 |
436 // --------------------------------------------------------------------------- |
604 // --------------------------------------------------------------------------- |
437 // CGlxDataSourceMde::HandleObjectPresentNotification |
605 // CGlxDataSourceMde::HandleObjectPresentNotification |
438 // --------------------------------------------------------------------------- |
606 // --------------------------------------------------------------------------- |
439 // |
607 // |
440 ///@todo AB test this |
608 ///@todo AB test this |
441 void CGlxDataSourceMde::HandleObjectPresentNotification(CMdESession& /*aSession*/, |
609 void CGlxDataSourceMde::HandleObjectPresentNotification(CMdESession& /*aSession*/, |
442 TBool aPresent, const RArray<TItemId>& aObjectIdArray) |
610 TBool aPresent, const RArray<TItemId>& aObjectIdArray) |
443 { |
611 { |
444 TRACER("CGlxDataSourceMde::HandleObjectPresentNotification()") |
612 TRACER("CGlxDataSourceMde::HandleObjectPresentNotification()"); |
445 if (aPresent) |
613 if (aPresent) |
446 { |
614 { |
447 ProcessUpdateArray(aObjectIdArray, EMPXItemInserted, ETrue); |
615 ProcessUpdateArray(aObjectIdArray, EMPXItemInserted, ETrue); |
448 } |
616 } |
449 else |
617 else |
773 { |
959 { |
774 TTime monthEnd = monthStart + KGlxOneMonth - KGlxOneMicrosecond; |
960 TTime monthEnd = monthStart + KGlxOneMonth - KGlxOneMicrosecond; |
775 month = iSession->NewObjectLC(*iMonthDef, title); |
961 month = iSession->NewObjectLC(*iMonthDef, title); |
776 |
962 |
777 // A title property def of type text is required. |
963 // A title property def of type text is required. |
778 CMdEPropertyDef& titlePropertyDef = iObjectDef->GetPropertyDefL(KPropertyDefNameTitle); |
964 CMdEPropertyDef& titlePropertyDef = iObjectDef->GetPropertyDefL( |
|
965 KPropertyDefNameTitle); |
779 if (titlePropertyDef.PropertyType() != EPropertyText) |
966 if (titlePropertyDef.PropertyType() != EPropertyText) |
780 { |
967 { |
781 User::Leave(KErrCorrupt); |
968 User::Leave(KErrCorrupt); |
782 } |
969 } |
783 // Set the object title. |
970 // Set the object title. |
784 month->AddTextPropertyL (titlePropertyDef, title); |
971 month->AddTextPropertyL (titlePropertyDef, title); |
785 |
972 |
786 // A size property is required. |
973 // A size property is required. |
787 CMdEPropertyDef& sizePropertyDef = iObjectDef->GetPropertyDefL(KPropertyDefNameSize); |
974 CMdEPropertyDef& sizePropertyDef = iObjectDef->GetPropertyDefL( |
|
975 KPropertyDefNameSize); |
788 if (sizePropertyDef.PropertyType() != EPropertyUint32) |
976 if (sizePropertyDef.PropertyType() != EPropertyUint32) |
789 { |
977 { |
790 User::Leave(KErrCorrupt); |
978 User::Leave(KErrCorrupt); |
791 } |
979 } |
792 month->AddUint32PropertyL(sizePropertyDef,0); |
980 month->AddUint32PropertyL(sizePropertyDef,0); |
793 |
981 |
794 |
982 |
795 // A creation date property is required. |
983 // A creation date property is required. |
796 CMdEPropertyDef& creationDateDef = iObjectDef->GetPropertyDefL(KPropertyDefNameCreationDate); |
984 CMdEPropertyDef& creationDateDef = iObjectDef->GetPropertyDefL( |
|
985 KPropertyDefNameCreationDate); |
797 if (creationDateDef.PropertyType() != EPropertyTime) |
986 if (creationDateDef.PropertyType() != EPropertyTime) |
798 { |
987 { |
799 User::Leave(KErrCorrupt); |
988 User::Leave(KErrCorrupt); |
800 } |
989 } |
801 month->AddTimePropertyL(creationDateDef, monthStart); |
990 month->AddTimePropertyL(creationDateDef, monthStart); |
802 |
991 |
803 // A last modified date property is required. |
992 // A last modified date property is required. |
804 CMdEPropertyDef& lmDateDef = iObjectDef->GetPropertyDefL(KPropertyDefNameLastModifiedDate); |
993 CMdEPropertyDef& lmDateDef = iObjectDef->GetPropertyDefL( |
|
994 KPropertyDefNameLastModifiedDate); |
805 if (lmDateDef.PropertyType() != EPropertyTime) |
995 if (lmDateDef.PropertyType() != EPropertyTime) |
806 { |
996 { |
807 User::Leave(KErrCorrupt); |
997 User::Leave(KErrCorrupt); |
808 } |
998 } |
809 |
999 |
863 { |
1053 { |
864 iPauseUpdate = ETrue; |
1054 iPauseUpdate = ETrue; |
865 } |
1055 } |
866 |
1056 |
867 #ifdef USE_S60_TNM |
1057 #ifdef USE_S60_TNM |
868 void CGlxDataSourceMde::FetchThumbnailL(CGlxRequest* aRequest, MThumbnailFetchRequestObserver& aObserver) |
1058 void CGlxDataSourceMde::FetchThumbnailL(CGlxRequest* aRequest, |
869 { |
1059 MThumbnailFetchRequestObserver& aObserver) |
|
1060 { |
|
1061 TRACER("CGlxDataSourceMde::FetchThumbnailL()"); |
|
1062 #ifdef _DEBUG |
|
1063 iStartTime.HomeTime(); // Get home time |
|
1064 #endif |
|
1065 |
870 iTnFetchObserver = &aObserver; |
1066 iTnFetchObserver = &aObserver; |
871 |
1067 |
872 CGlxThumbnailRequest* request = static_cast<CGlxThumbnailRequest*>(aRequest); |
1068 CGlxThumbnailRequest* request = static_cast<CGlxThumbnailRequest*>(aRequest); |
873 |
1069 |
874 TGlxThumbnailRequest tnReq; |
1070 TGlxThumbnailRequest tnReq; |
875 request->ThumbnailRequest(tnReq); |
1071 request->ThumbnailRequest(tnReq); |
876 User::LeaveIfNull(request->ThumbnailInfo()); |
1072 User::LeaveIfNull(request->ThumbnailInfo()); |
877 |
1073 |
878 iTnHandle = tnReq.iBitmapHandle; |
1074 iTnHandle = tnReq.iBitmapHandle; |
879 iMediaId = tnReq.iId; |
1075 iMediaId = tnReq.iId; |
880 if (tnReq.iSizeClass.iWidth < KMaxGridThumbnailWidth) |
1076 if (tnReq.iSizeClass.iWidth < KMaxGridThumbnailWidth) |
881 { |
1077 { |
882 iTnEngine->SetFlagsL(CThumbnailManager::ECropToAspectRatio); |
1078 iTnEngine->SetFlagsL(CThumbnailManager::ECropToAspectRatio); |
883 iTnEngine->SetThumbnailSizeL(EGridThumbnailSize); |
1079 iTnEngine->SetThumbnailSizeL(EGridThumbnailSize); |
884 GLX_LOG_INFO("CGlxDataSourceMde::FetchThumbnailL() - Fetch TN attrib - EGridThumbnailSize"); |
1080 GLX_LOG_INFO("CGlxDataSourceMde::FetchThumbnailL() - Fetch TN attrib -" |
885 } |
1081 " EGridThumbnailSize"); |
|
1082 } |
886 else |
1083 else |
887 { |
1084 { |
888 iTnEngine->SetFlagsL(CThumbnailManager::EDefaultFlags); |
1085 iTnEngine->SetFlagsL(CThumbnailManager::EDefaultFlags); |
889 iTnEngine->SetThumbnailSizeL(EFullScreenThumbnailSize); |
1086 iTnEngine->SetThumbnailSizeL(EFullScreenThumbnailSize); |
890 GLX_LOG_INFO("CGlxDataSourceMde::FetchThumbnailL() - Fetch TN attrib - EFullScreenThumbnailSize"); |
1087 GLX_LOG_INFO("CGlxDataSourceMde::FetchThumbnailL() - Fetch TN attrib - " |
891 } |
1088 "EFullScreenThumbnailSize"); |
892 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC(request->ThumbnailInfo()->FilePath(), 0); |
1089 } |
893 #ifdef _DEBUG |
1090 |
894 iStartTime.UniversalTime(); |
1091 if (tnReq.iPriorityMode == TGlxThumbnailRequest::EPrioritizeQuality) |
895 #endif |
1092 { |
|
1093 iTnEngine->SetQualityPreferenceL(CThumbnailManager::EOptimizeForQuality); |
|
1094 GLX_LOG_INFO("CGlxDataSourceMde::FetchThumbnailL() - Fetch TN attrib -" |
|
1095 " EOptimizeForQuality"); |
|
1096 } |
|
1097 else |
|
1098 { |
|
1099 iTnEngine->SetQualityPreferenceL(CThumbnailManager::EOptimizeForQualityWithPreview); |
|
1100 GLX_LOG_INFO("CGlxDataSourceMde::FetchThumbnailL() - Fetch TN attrib -" |
|
1101 " EOptimizeForQualityWithPreview"); |
|
1102 } |
|
1103 |
|
1104 CThumbnailObjectSource* source = CThumbnailObjectSource::NewLC( |
|
1105 request->ThumbnailInfo()->FilePath(), 0); |
896 iTnThumbnailCbId = iTnEngine->GetThumbnailL(*source); |
1106 iTnThumbnailCbId = iTnEngine->GetThumbnailL(*source); |
|
1107 CleanupStack::PopAndDestroy(source); |
|
1108 |
897 iTnRequestInProgress = ETrue; |
1109 iTnRequestInProgress = ETrue; |
898 CleanupStack::PopAndDestroy(); |
|
899 } |
1110 } |
900 |
1111 |
901 TInt CGlxDataSourceMde::CancelFetchThumbnail() |
1112 TInt CGlxDataSourceMde::CancelFetchThumbnail() |
902 { |
1113 { |
|
1114 TRACER("CGlxDataSourceMde::CancelFetchThumbnail"); |
903 TInt ret = KErrNone; |
1115 TInt ret = KErrNone; |
904 if (iTnRequestInProgress) |
1116 if (iTnRequestInProgress) |
905 { |
1117 { |
906 ret = iTnEngine->CancelRequest(iTnThumbnailCbId); |
1118 ret = iTnEngine->CancelRequest(iTnThumbnailCbId); |
|
1119 iTnRequestInProgress = EFalse; |
|
1120 iTnFetchObserver->ThumbnailFetchComplete(KErrCancel,EFalse); |
907 } |
1121 } |
908 return ret; |
1122 return ret; |
909 } |
1123 } |
910 |
1124 |
911 void CGlxDataSourceMde::ThumbnailPreviewReady(MThumbnailData& /*aThumbnail*/, |
1125 // Called when preview thumbnail is created |
912 TThumbnailRequestId /*aId*/) |
1126 void CGlxDataSourceMde::ThumbnailPreviewReady(MThumbnailData& aThumbnail, |
913 { |
1127 TThumbnailRequestId aId) |
|
1128 { |
|
1129 TRACER("CGlxDataSourceMde::ThumbnailPreviewReady()"); |
|
1130 |
|
1131 TInt error = KErrNotSupported; |
|
1132 if ( aThumbnail.Bitmap() ) |
|
1133 { |
|
1134 GLX_DEBUG1("CGlxDataSourceMde::ThumbnailPreviewReady preview aval"); |
|
1135 error = KErrNone; |
|
1136 } |
|
1137 //This function is called number of times as a callback , |
|
1138 //hence not trapping the leaving function which costs time and memory. |
|
1139 //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions. |
|
1140 ThumbnailReadyL(error, aThumbnail, aId, EFalse); |
914 } |
1141 } |
915 |
1142 |
916 // Called when real thumbnail is created |
1143 // Called when real thumbnail is created |
917 void CGlxDataSourceMde::ThumbnailReady(TInt aError, |
1144 void CGlxDataSourceMde::ThumbnailReady(TInt aError, |
918 MThumbnailData& aThumbnail, TThumbnailRequestId aId) |
1145 MThumbnailData& aThumbnail, TThumbnailRequestId aId) |
919 { |
1146 { |
920 if (iTnThumbnailCbId == aId) |
1147 TRACER("CGlxDataSourceMde::ThumbnailReady"); |
921 { |
1148 GLX_DEBUG2("GlxDataSourceMde::ThumbnailReady aError=%d", aError); |
922 iTnRequestInProgress = EFalse; |
1149 //This function is called number of times as a callback , |
|
1150 //hence not trapping the leaving function which costs time and memory. |
|
1151 //Ignoring this for code scanner warnings - Leaving functions called in non-leaving functions. |
|
1152 ThumbnailReadyL(aError,aThumbnail, aId, ETrue); |
|
1153 } |
|
1154 |
|
1155 // --------------------------------------------------------------------------- |
|
1156 // ThumbnailReadyL |
|
1157 // --------------------------------------------------------------------------- |
|
1158 // |
|
1159 void CGlxDataSourceMde::ThumbnailReadyL(TInt aError, |
|
1160 MThumbnailData& aThumbnail, TThumbnailRequestId aId, TBool aQuality) |
|
1161 { |
|
1162 TRACER("CGlxDataSourceMde::ThumbnailReadyL()"); |
|
1163 GLX_DEBUG3("CGlxDataSourceMde::ThumbnailReadyL aError=%d, aQuality=%d", |
|
1164 aError, aQuality); |
923 #ifdef _DEBUG |
1165 #ifdef _DEBUG |
924 iStopTime.UniversalTime(); |
1166 iStopTime.HomeTime(); // Get home time |
925 GLX_LOG_INFO1("==> S60 TNMan fetch took <%d> us", (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
1167 GLX_DEBUG2("=>CGlxDataSourceMde::ThumbnailReadyL - TN Fetch took <%d> us", |
|
1168 (TInt)iStopTime.MicroSecondsFrom(iStartTime).Int64()); |
926 #endif |
1169 #endif |
927 if (aError == KErrNone && iTnHandle) |
1170 |
928 { |
1171 if (iTnThumbnailCbId == aId) |
929 if (iTnHandle == KGlxMessageIdBackgroundThumbnail) |
1172 { |
930 { |
1173 if (aError == KErrNone && iTnHandle) |
931 BackgroundThumbnailMessageL(iMediaId, TSize(), aError); |
1174 { |
932 } |
1175 if (iTnHandle == KGlxMessageIdBackgroundThumbnail) |
933 else |
1176 { |
934 { |
1177 BackgroundThumbnailMessageL(iMediaId, TSize(), aError); |
|
1178 } |
|
1179 else |
|
1180 { |
935 delete iTnThumbnail; |
1181 delete iTnThumbnail; |
936 iTnThumbnail = NULL; |
1182 iTnThumbnail = NULL; |
937 iTnThumbnail = aThumbnail.DetachBitmap(); |
1183 iTnThumbnail = aThumbnail.DetachBitmap(); |
938 |
1184 |
939 delete iThumbnail; |
1185 delete iThumbnail; |
940 iThumbnail = NULL; |
1186 iThumbnail = NULL; |
941 iThumbnail = new (ELeave) CFbsBitmap(); |
1187 iThumbnail = new (ELeave) CFbsBitmap(); |
942 User::LeaveIfError( iThumbnail->Duplicate(iTnHandle)); |
1188 User::LeaveIfError( iThumbnail->Duplicate(iTnHandle)); |
946 CFbsBitGc* context = NULL; |
1192 CFbsBitGc* context = NULL; |
947 User::LeaveIfError(device->CreateContext(context)); |
1193 User::LeaveIfError(device->CreateContext(context)); |
948 CleanupStack::PushL(context); |
1194 CleanupStack::PushL(context); |
949 context->BitBlt( TPoint(), iTnThumbnail); |
1195 context->BitBlt( TPoint(), iTnThumbnail); |
950 CleanupStack::PopAndDestroy(context); |
1196 CleanupStack::PopAndDestroy(context); |
951 CleanupStack::PopAndDestroy(device); |
1197 CleanupStack::PopAndDestroy(device); |
952 } |
1198 } |
953 } |
1199 } |
954 |
1200 } |
955 if (iTnFetchObserver) |
1201 |
956 { |
1202 if (iTnFetchObserver && iTnRequestInProgress) |
957 iTnFetchObserver->ThumbnailFetchComplete(aError); |
1203 { |
958 iTnHandle = KErrNone; |
1204 iTnFetchObserver->ThumbnailFetchComplete(aError, aQuality); |
959 } |
1205 iTnHandle = KErrNone; |
960 } |
1206 iTnRequestInProgress = EFalse; |
961 } |
1207 } |
|
1208 } |
962 #endif |
1209 #endif |
|
1210 |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // CGlxDataSourceMde |
|
1213 // HarvestingUpdated |
|
1214 // --------------------------------------------------------------------------- |
|
1215 // |
|
1216 void CGlxDataSourceMde::HarvestingUpdated( |
|
1217 HarvesterEventObserverType /*aHEObserverType*/, |
|
1218 HarvesterEventState aHarvesterEventState, |
|
1219 TInt /*aItemsLeft*/) |
|
1220 { |
|
1221 TRACER("void CGlxDataSourceMde::HarvestingUpdated()"); |
|
1222 GLX_LOG_INFO1("CGlxDataSourceMde::HarvestingUpdated() aHarvesterEventState=%d", |
|
1223 aHarvesterEventState); |
|
1224 |
|
1225 switch(aHarvesterEventState) |
|
1226 { |
|
1227 case EHEStateStarted: |
|
1228 GLX_LOG_INFO("CGlxDataSourceMde::HarvestingUpdated() - EHEStateStarted"); |
|
1229 case EHEStateResumed: |
|
1230 case EHEStateHarvesting: |
|
1231 { |
|
1232 iHarvestingOngoing = ETrue; |
|
1233 } |
|
1234 break; |
|
1235 case EHEStatePaused: |
|
1236 case EHEStateFinished: |
|
1237 { |
|
1238 iHarvestingOngoing = EFalse; |
|
1239 GLX_LOG_INFO("CGlxDataSourceMde::HarvestingUpdated() - EHEStateFinished"); |
|
1240 } |
|
1241 break; |
|
1242 default: |
|
1243 break; |
|
1244 } |
|
1245 } |
|
1246 |
|
1247 // --------------------------------------------------------------------------- |
|
1248 // ShutdownNotification |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // |
|
1251 void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState) |
|
1252 { |
|
1253 TRACER("void CGlxDataSourceMde::ShutdownNotification(TInt aShutdownState)") |
|
1254 GLX_DEBUG2("CGlxDataSourceMde::ShutdownNotification(aShutdownState=%d)", |
|
1255 aShutdownState); |
|
1256 |
|
1257 if (!iDataSourceReady && 0 == aShutdownState) |
|
1258 { |
|
1259 GLX_DEBUG1("Photos MdS ShutdownNotification - MdS Server restarted!"); |
|
1260 CreateSession(); |
|
1261 } |
|
1262 |
|
1263 if (iDataSourceReady && 1 == aShutdownState) |
|
1264 { |
|
1265 GLX_DEBUG1("Photos MdS ShutdownNotification - MdS Server Shutdown!"); |
|
1266 HandleSessionError(*iSession, KErrServerTerminated); |
|
1267 } |
|
1268 } |