135 |
134 |
136 TN_DEBUG1( "CThumbAGDaemon::InitializeL() - connect to MDS" ); |
135 TN_DEBUG1( "CThumbAGDaemon::InitializeL() - connect to MDS" ); |
137 |
136 |
138 if(iMdESession) |
137 if(iMdESession) |
139 { |
138 { |
140 TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); |
139 TRAP_IGNORE( iMdESession->RemoveObjectObserverWithUriL( *this ) ); |
141 TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); |
|
142 TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); |
|
143 TRAP_IGNORE( iMdESession->RemoveObjectPresentObserverL( * this )); |
140 TRAP_IGNORE( iMdESession->RemoveObjectPresentObserverL( * this )); |
144 |
141 |
145 // connect to MDS |
142 // connect to MDS |
146 delete iMdESession; |
143 delete iMdESession; |
147 iMdESession = NULL; |
144 iMdESession = NULL; |
148 } |
145 } |
149 |
146 |
150 iMdESession = CMdESession::NewL( *this ); |
147 iMdESession = CMdESession::NewL( *this ); |
151 iSessionError = EFalse; |
148 iSessionError = EFalse; |
|
149 |
|
150 delete iImageObserver; |
|
151 iImageObserver = NULL; |
|
152 iImageObserver = CThumbAGImageObserver::NewL(iProcessor); |
|
153 |
|
154 delete iCameraObserver; |
|
155 iCameraObserver = NULL; |
|
156 iCameraObserver = CThumbAGCameraObserver::NewL(iProcessor); |
|
157 |
|
158 delete iAudioObserver; |
|
159 iAudioObserver = NULL; |
|
160 iAudioObserver = CThumbAGAudioObserver::NewL(iProcessor); |
|
161 |
|
162 delete iVideoObserver; |
|
163 iVideoObserver = NULL; |
|
164 iVideoObserver = CThumbAGVideoObserver::NewL(iProcessor); |
152 } |
165 } |
153 else |
166 else |
154 { |
167 { |
155 // no error here, but need to shutdown daemon neatly |
168 // no error here, but need to shutdown daemon neatly |
156 User::Leave(KErrNone); |
169 User::Leave(KErrNone); |
164 // |
177 // |
165 CThumbAGDaemon::~CThumbAGDaemon() |
178 CThumbAGDaemon::~CThumbAGDaemon() |
166 { |
179 { |
167 TN_DEBUG1( "CThumbAGDaemon::~CThumbAGDaemon() - begin" ); |
180 TN_DEBUG1( "CThumbAGDaemon::~CThumbAGDaemon() - begin" ); |
168 |
181 |
169 iShutdown = ETrue; |
182 iShutdown = ETrue; |
|
183 |
|
184 delete iImageObserver; |
|
185 iImageObserver = NULL; |
|
186 |
|
187 delete iCameraObserver; |
|
188 iCameraObserver = NULL; |
|
189 |
|
190 delete iVideoObserver; |
|
191 iVideoObserver = NULL; |
|
192 |
|
193 delete iAudioObserver; |
|
194 iAudioObserver = NULL; |
170 |
195 |
171 delete iMDSShutdownObserver; |
196 delete iMDSShutdownObserver; |
172 delete iShutdownObserver; |
197 delete iShutdownObserver; |
173 |
198 |
174 if(iReconnect) |
199 if(iReconnect) |
260 { |
282 { |
261 TN_DEBUG1( "CThumbAGDaemon::HandleSessionOpened"); |
283 TN_DEBUG1( "CThumbAGDaemon::HandleSessionOpened"); |
262 |
284 |
263 if (aError == KErrNone) |
285 if (aError == KErrNone) |
264 { |
286 { |
265 iProcessor->SetMdESession(iMdESession); |
287 TRAPD(err, iProcessor->SetMdESessionL(iMdESession)); |
266 |
288 |
267 TRAPD( err, AddObserversL() ); |
289 TRAP( err, AddObserversL() ); |
268 if (err != KErrNone) |
290 if (err != KErrNone) |
269 { |
291 { |
270 TN_DEBUG2( "CThumbAGDaemon::HandleSessionOpened, AddObserversL error == %d", err ); |
292 TN_DEBUG2( "CThumbAGDaemon::HandleSessionOpened, AddObserversL error == %d", err ); |
271 } |
293 } |
272 } |
294 } |
285 TN_DEBUG2( "CThumbAGDaemon::HandleSessionError == %d", aError ); |
307 TN_DEBUG2( "CThumbAGDaemon::HandleSessionError == %d", aError ); |
286 if (aError != KErrNone && !iShutdown && !iSessionError) |
308 if (aError != KErrNone && !iShutdown && !iSessionError) |
287 { |
309 { |
288 iSessionError = ETrue; |
310 iSessionError = ETrue; |
289 |
311 |
|
312 delete iImageObserver; |
|
313 iImageObserver = NULL; |
|
314 |
|
315 delete iCameraObserver; |
|
316 iCameraObserver = NULL; |
|
317 |
|
318 delete iVideoObserver; |
|
319 iVideoObserver = NULL; |
|
320 |
|
321 delete iAudioObserver; |
|
322 iAudioObserver = NULL; |
|
323 |
290 // kill processor right away, because it also has MdESession |
324 // kill processor right away, because it also has MdESession |
291 if(iProcessor) |
325 if(iProcessor) |
292 { |
326 { |
293 iProcessor->Shutdown(); |
327 iProcessor->Shutdown(); |
294 delete iProcessor; |
328 delete iProcessor; |
326 |
360 |
327 if(aType == ENotifyRemove) |
361 if(aType == ENotifyRemove) |
328 { |
362 { |
329 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - removed"); |
363 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - removed"); |
330 TInt err(0); |
364 TInt err(0); |
331 TRAP(err, iProcessor->AddToQueueL(aType, aObjectIdArray, aObjectUriArray, EFalse)); |
365 TRAP(err, iProcessor->AddToQueueL(aType, EGenerationItemTypeAny, aObjectIdArray, aObjectUriArray, EFalse)); |
332 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGDaemon::HandleUriObjectNotification()"), err)); |
366 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGDaemon::HandleUriObjectNotification()"), err)); |
|
367 |
333 err = KErrNone; |
368 err = KErrNone; |
334 } |
369 } |
335 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - end" ); |
370 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - end" ); |
336 } |
371 } |
337 #endif |
372 #endif |
351 { |
386 { |
352 return; |
387 return; |
353 } |
388 } |
354 |
389 |
355 #ifdef _DEBUG |
390 #ifdef _DEBUG |
356 if (aType == ENotifyAdd) |
391 if (aType == ENotifyRemove) |
357 { |
|
358 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); |
|
359 iAddCounter = aObjectIdArray.Count(); |
|
360 } |
|
361 else if (aType == ENotifyModify) |
|
362 { |
|
363 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyModify %d", aObjectIdArray.Count() ); |
|
364 iModCounter = aObjectIdArray.Count(); |
|
365 } |
|
366 else if (aType == ENotifyRemove) |
|
367 { |
392 { |
368 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyRemove %d", aObjectIdArray.Count() ); |
393 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyRemove %d", aObjectIdArray.Count() ); |
369 iDelCounter = aObjectIdArray.Count(); |
394 iDelCounter = aObjectIdArray.Count(); |
370 } |
395 } |
371 #endif |
396 #endif |
372 |
397 |
373 if ( (aType == ENotifyAdd || aType == ENotifyModify || aType == ENotifyRemove) && |
398 if ( aType == ENotifyRemove && aObjectIdArray.Count() > 0 ) |
374 (aObjectIdArray.Count() > 0) ) |
|
375 { |
399 { |
376 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - AddToQueueL" ); |
400 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - AddToQueueL" ); |
377 |
401 |
378 // If delete event, remove IDs from Modify and Add queues |
402 // If delete event, remove IDs from Modify and Add queues |
379 if ( aType == ENotifyRemove ) |
403 iProcessor->RemoveFromQueues( aObjectIdArray, EFalse); |
380 { |
|
381 iProcessor->RemoveFromQueues( aObjectIdArray, EFalse); |
|
382 } |
|
383 |
404 |
384 // Add event to processing queue by type and enable force run |
405 // Add event to processing queue by type and enable force run |
385 RPointerArray<HBufC> dummyArray; |
406 RPointerArray<HBufC> dummyArray; |
386 TRAPD(err, iProcessor->AddToQueueL(aType, aObjectIdArray, dummyArray, EFalse)); |
407 TRAPD(err, iProcessor->AddToQueueL(aType, EGenerationItemTypeAny, aObjectIdArray, dummyArray, EFalse)); |
387 if (err != KErrNone) |
408 if (err != KErrNone) |
388 { |
409 { |
389 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - error adding to queue" ); |
410 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - error adding to queue" ); |
390 } |
411 } |
391 } |
412 } |
393 { |
414 { |
394 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - bad notification" ); |
415 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - bad notification" ); |
395 } |
416 } |
396 |
417 |
397 #ifdef _DEBUG |
418 #ifdef _DEBUG |
398 TN_DEBUG4( "CThumbAGDaemon::IN-COUNTERS---------- Add = %d Modify = %d Delete = %d", |
419 TN_DEBUG2( "CThumbAGDaemon::IN-COUNTERS---------- Delete = %d", iDelCounter ); |
399 iAddCounter, iModCounter, iDelCounter ); |
|
400 iModCounter = 0; |
|
401 iDelCounter = 0; |
420 iDelCounter = 0; |
402 iAddCounter = 0; |
|
403 |
|
404 #endif |
421 #endif |
405 |
422 |
406 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - end" ); |
423 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - end" ); |
407 } |
424 } |
408 |
425 |
428 { |
445 { |
429 if ( aObjectIdArray.Count() > 0) |
446 if ( aObjectIdArray.Count() > 0) |
430 { |
447 { |
431 // do not force run of these items |
448 // do not force run of these items |
432 RPointerArray<HBufC> dummyArray; |
449 RPointerArray<HBufC> dummyArray; |
433 TRAP(err, iProcessor->AddToQueueL(ENotifyAdd, aObjectIdArray, dummyArray, ETrue)); |
450 TRAP(err, iProcessor->AddToQueueL(ENotifyAdd, EGenerationItemTypeUnknown, aObjectIdArray, dummyArray, ETrue)); |
434 |
451 |
435 TN_DEBUG2( "CThumbAGDaemon::HandleObjectPresentNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); |
452 TN_DEBUG2( "CThumbAGDaemon::HandleObjectPresentNotification() - ENotifyAdd unknown items %d", aObjectIdArray.Count() ); |
436 |
|
437 #ifdef _DEBUG |
453 #ifdef _DEBUG |
438 iAddCounter = aObjectIdArray.Count(); |
454 iAddCounter = aObjectIdArray.Count(); |
439 if (err != KErrNone) |
455 if (err != KErrNone) |
440 { |
456 { |
441 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - error adding to queue" ); |
457 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - error adding to queue" ); |
463 iProcessor->RemoveFromQueues( aObjectIdArray, ETrue ); |
479 iProcessor->RemoveFromQueues( aObjectIdArray, ETrue ); |
464 } |
480 } |
465 } |
481 } |
466 |
482 |
467 #ifdef _DEBUG |
483 #ifdef _DEBUG |
468 TN_DEBUG4( "CThumbAGDaemon::IN-COUNTERS---------- Add = %d Modify = %d Delete = %d", |
484 TN_DEBUG3( "CThumbAGDaemon::IN-COUNTERS---------- Add = %d Delete = %d", iAddCounter, iDelCounter ); |
469 iAddCounter, iModCounter, iDelCounter ); |
|
470 iModCounter = 0; |
|
471 iDelCounter = 0; |
485 iDelCounter = 0; |
472 iAddCounter = 0; |
486 iAddCounter = 0; |
473 #endif |
487 #endif |
474 |
488 |
475 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - end" ); |
489 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - end" ); |
476 } |
490 } |
477 |
491 |
496 // |
510 // |
497 void CThumbAGDaemon::AddObserversL() |
511 void CThumbAGDaemon::AddObserversL() |
498 { |
512 { |
499 TN_DEBUG1( "CThumbAGDaemon::AddObserversL() - begin" ); |
513 TN_DEBUG1( "CThumbAGDaemon::AddObserversL() - begin" ); |
500 |
514 |
501 CMdENamespaceDef& defaultNamespace = iMdESession->GetDefaultNamespaceDefL(); |
|
502 CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
503 CMdEObjectDef& videoDef = defaultNamespace.GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
504 CMdEObjectDef& audioDef = defaultNamespace.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
505 |
|
506 // set observing conditions |
|
507 CMdELogicCondition* addCondition = CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); |
|
508 addCondition->AddObjectConditionL( imageDef ); |
|
509 addCondition->AddObjectConditionL( videoDef ); |
|
510 addCondition->AddObjectConditionL( audioDef ); |
|
511 CleanupStack::Pop( addCondition ); |
|
512 |
|
513 CMdELogicCondition* modifyCondition = CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); |
|
514 modifyCondition->AddObjectConditionL( imageDef ); |
|
515 modifyCondition->AddObjectConditionL( videoDef ); |
|
516 modifyCondition->AddObjectConditionL( audioDef ); |
|
517 CleanupStack::Pop( modifyCondition ); |
|
518 |
|
519 // add observer |
|
520 iMdESession->AddObjectObserverL( *this, addCondition, ENotifyAdd ); |
|
521 |
|
522 // modify observer |
|
523 #ifdef MDS_MODIFY_OBSERVER |
|
524 iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify ); |
|
525 #endif |
|
526 |
515 |
527 #ifdef MDS_URI_OBSERVER |
516 #ifdef MDS_URI_OBSERVER |
528 // remove observer with uri |
517 // remove observer with uri |
529 iMdESession->AddObjectObserverWithUriL( *this, NULL, ENotifyRemove ); |
518 iMdESession->AddObjectObserverWithUriL( *this, NULL, ENotifyRemove ); |
530 #endif |
519 #endif |