134 |
134 |
135 TN_DEBUG1( "CThumbAGDaemon::InitializeL() - connect to MDS" ); |
135 TN_DEBUG1( "CThumbAGDaemon::InitializeL() - connect to MDS" ); |
136 |
136 |
137 if(iMdESession) |
137 if(iMdESession) |
138 { |
138 { |
139 TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); |
139 TRAP_IGNORE( iMdESession->RemoveObjectObserverWithUriL( *this ) ); |
140 TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); |
|
141 TRAP_IGNORE( iMdESession->RemoveObjectObserverL( *this ) ); |
|
142 TRAP_IGNORE( iMdESession->RemoveObjectPresentObserverL( * this )); |
140 TRAP_IGNORE( iMdESession->RemoveObjectPresentObserverL( * this )); |
143 |
141 |
144 // connect to MDS |
142 // connect to MDS |
145 delete iMdESession; |
143 delete iMdESession; |
146 iMdESession = NULL; |
144 iMdESession = NULL; |
147 } |
145 } |
148 |
146 |
149 iMdESession = CMdESession::NewL( *this ); |
147 iMdESession = CMdESession::NewL( *this ); |
|
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); |
150 } |
165 } |
151 else |
166 else |
152 { |
167 { |
153 // no error here, but need to shutdown daemon neatly |
168 // no error here, but need to shutdown daemon neatly |
154 User::Leave(KErrNone); |
169 User::Leave(KErrNone); |
162 // |
177 // |
163 CThumbAGDaemon::~CThumbAGDaemon() |
178 CThumbAGDaemon::~CThumbAGDaemon() |
164 { |
179 { |
165 TN_DEBUG1( "CThumbAGDaemon::~CThumbAGDaemon() - begin" ); |
180 TN_DEBUG1( "CThumbAGDaemon::~CThumbAGDaemon() - begin" ); |
166 |
181 |
167 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; |
168 |
195 |
169 delete iMDSShutdownObserver; |
196 delete iMDSShutdownObserver; |
170 delete iShutdownObserver; |
197 delete iShutdownObserver; |
171 |
198 |
172 if(iReconnect) |
199 if(iReconnect) |
257 { |
282 { |
258 TN_DEBUG1( "CThumbAGDaemon::HandleSessionOpened"); |
283 TN_DEBUG1( "CThumbAGDaemon::HandleSessionOpened"); |
259 |
284 |
260 if (aError == KErrNone) |
285 if (aError == KErrNone) |
261 { |
286 { |
262 iProcessor->SetMdESession(iMdESession); |
287 TRAPD(err, iProcessor->SetMdESessionL(iMdESession)); |
263 |
288 |
264 TRAPD( err, AddObserversL() ); |
289 TRAP( err, AddObserversL() ); |
265 if (err != KErrNone) |
290 if (err != KErrNone) |
266 { |
291 { |
267 TN_DEBUG2( "CThumbAGDaemon::HandleSessionOpened, AddObserversL error == %d", err ); |
292 TN_DEBUG2( "CThumbAGDaemon::HandleSessionOpened, AddObserversL error == %d", err ); |
268 } |
293 } |
269 } |
294 } |
278 // ----------------------------------------------------------------------------- |
303 // ----------------------------------------------------------------------------- |
279 // |
304 // |
280 void CThumbAGDaemon::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
305 void CThumbAGDaemon::HandleSessionError( CMdESession& /*aSession*/, TInt aError ) |
281 { |
306 { |
282 TN_DEBUG2( "CThumbAGDaemon::HandleSessionError == %d", aError ); |
307 TN_DEBUG2( "CThumbAGDaemon::HandleSessionError == %d", aError ); |
283 if (aError != KErrNone) |
308 if (aError != KErrNone && !iShutdown && !iSessionError) |
284 { |
309 { |
|
310 iSessionError = ETrue; |
|
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 |
285 // kill processor right away, because it also has MdESession |
324 // kill processor right away, because it also has MdESession |
286 if(iProcessor) |
325 if(iProcessor) |
287 { |
326 { |
|
327 iProcessor->Shutdown(); |
288 delete iProcessor; |
328 delete iProcessor; |
289 iProcessor = NULL; |
329 iProcessor = NULL; |
290 } |
330 } |
291 |
331 |
292 if (!iShutdown) |
332 if (!iReconnect->IsActive()) |
293 { |
333 { |
294 if (!iReconnect->IsActive()) |
334 iReconnect->Start( KMdEReconnect, KMdEReconnect, |
295 { |
335 TCallBack(ReconnectCallBack, this)); |
296 iReconnect->Start( KMdEReconnect, KMdEReconnect, |
336 |
297 TCallBack(ReconnectCallBack, this)); |
337 TN_DEBUG1( "CThumbAGDaemon::HandleSessionError() - reconnect timer started" ); |
298 |
|
299 TN_DEBUG1( "CThumbAGDaemon::HandleSessionError() - reconnect timer started" ); |
|
300 } |
|
301 } |
338 } |
302 |
339 |
303 } |
340 } |
304 } |
341 } |
305 |
342 |
314 const RArray<TItemId>& aObjectIdArray, |
351 const RArray<TItemId>& aObjectIdArray, |
315 const RPointerArray<HBufC>& aObjectUriArray) |
352 const RPointerArray<HBufC>& aObjectUriArray) |
316 { |
353 { |
317 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - begin" ); |
354 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - begin" ); |
318 |
355 |
|
356 if(!iProcessor || iShutdown) |
|
357 { |
|
358 return; |
|
359 } |
|
360 |
319 if(aType == ENotifyRemove) |
361 if(aType == ENotifyRemove) |
320 { |
362 { |
321 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - removed"); |
363 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - removed"); |
322 TInt err(0); |
364 TInt err(0); |
323 TRAP(err, iProcessor->AddToQueueL(aType, aObjectIdArray, aObjectUriArray, EFalse)); |
365 TRAP(err, iProcessor->AddToQueueL(aType, EGenerationItemTypeAny, aObjectIdArray, aObjectUriArray, EFalse)); |
324 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGDaemon::HandleUriObjectNotification()"), err)); |
366 __ASSERT_DEBUG((err==KErrNone), User::Panic(_L("CThumbAGDaemon::HandleUriObjectNotification()"), err)); |
|
367 |
325 err = KErrNone; |
368 err = KErrNone; |
326 } |
369 } |
327 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - end" ); |
370 TN_DEBUG1( "CThumbAGDaemon::HandleUriObjectNotification() - end" ); |
328 } |
371 } |
329 #endif |
372 #endif |
343 { |
386 { |
344 return; |
387 return; |
345 } |
388 } |
346 |
389 |
347 #ifdef _DEBUG |
390 #ifdef _DEBUG |
348 if (aType == ENotifyAdd) |
391 if (aType == ENotifyRemove) |
349 { |
|
350 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); |
|
351 iAddCounter = aObjectIdArray.Count(); |
|
352 } |
|
353 else if (aType == ENotifyModify) |
|
354 { |
|
355 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyModify %d", aObjectIdArray.Count() ); |
|
356 iModCounter = aObjectIdArray.Count(); |
|
357 } |
|
358 else if (aType == ENotifyRemove) |
|
359 { |
392 { |
360 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyRemove %d", aObjectIdArray.Count() ); |
393 TN_DEBUG2( "CThumbAGDaemon::HandleObjectNotification() - ENotifyRemove %d", aObjectIdArray.Count() ); |
361 iDelCounter = aObjectIdArray.Count(); |
394 iDelCounter = aObjectIdArray.Count(); |
362 } |
395 } |
363 #endif |
396 #endif |
364 |
397 |
365 if ( (aType == ENotifyAdd || aType == ENotifyModify || aType == ENotifyRemove) && |
398 if ( aType == ENotifyRemove && aObjectIdArray.Count() > 0 ) |
366 (aObjectIdArray.Count() > 0) ) |
|
367 { |
399 { |
368 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - AddToQueueL" ); |
400 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - AddToQueueL" ); |
369 |
401 |
370 // If delete event, remove IDs from Modify and Add queues |
402 // If delete event, remove IDs from Modify and Add queues |
371 if ( aType == ENotifyRemove ) |
403 iProcessor->RemoveFromQueues( aObjectIdArray, EFalse); |
372 { |
|
373 iProcessor->RemoveFromQueues( aObjectIdArray, EFalse); |
|
374 } |
|
375 |
404 |
376 // Add event to processing queue by type and enable force run |
405 // Add event to processing queue by type and enable force run |
377 RPointerArray<HBufC> dummyArray; |
406 RPointerArray<HBufC> dummyArray; |
378 TRAPD(err, iProcessor->AddToQueueL(aType, aObjectIdArray, dummyArray, EFalse)); |
407 TRAPD(err, iProcessor->AddToQueueL(aType, EGenerationItemTypeAny, aObjectIdArray, dummyArray, EFalse)); |
379 if (err != KErrNone) |
408 if (err != KErrNone) |
380 { |
409 { |
381 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - error adding to queue" ); |
410 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - error adding to queue" ); |
382 } |
411 } |
383 } |
412 } |
385 { |
414 { |
386 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - bad notification" ); |
415 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - bad notification" ); |
387 } |
416 } |
388 |
417 |
389 #ifdef _DEBUG |
418 #ifdef _DEBUG |
390 TN_DEBUG4( "CThumbAGDaemon::IN-COUNTERS---------- Add = %d Modify = %d Delete = %d", |
419 TN_DEBUG2( "CThumbAGDaemon::IN-COUNTERS---------- Delete = %d", iDelCounter ); |
391 iAddCounter, iModCounter, iDelCounter ); |
|
392 iModCounter = 0; |
|
393 iDelCounter = 0; |
420 iDelCounter = 0; |
394 iAddCounter = 0; |
|
395 |
|
396 #endif |
421 #endif |
397 |
422 |
398 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - end" ); |
423 TN_DEBUG1( "CThumbAGDaemon::HandleObjectNotification() - end" ); |
399 } |
424 } |
400 |
425 |
420 { |
445 { |
421 if ( aObjectIdArray.Count() > 0) |
446 if ( aObjectIdArray.Count() > 0) |
422 { |
447 { |
423 // do not force run of these items |
448 // do not force run of these items |
424 RPointerArray<HBufC> dummyArray; |
449 RPointerArray<HBufC> dummyArray; |
425 TRAP(err, iProcessor->AddToQueueL(ENotifyAdd, aObjectIdArray, dummyArray, ETrue)); |
450 TRAP(err, iProcessor->AddToQueueL(ENotifyAdd, EGenerationItemTypeUnknown, aObjectIdArray, dummyArray, ETrue)); |
426 |
451 |
427 TN_DEBUG2( "CThumbAGDaemon::HandleObjectPresentNotification() - ENotifyAdd %d", aObjectIdArray.Count() ); |
452 TN_DEBUG2( "CThumbAGDaemon::HandleObjectPresentNotification() - ENotifyAdd unknown items %d", aObjectIdArray.Count() ); |
428 |
|
429 #ifdef _DEBUG |
453 #ifdef _DEBUG |
430 iAddCounter = aObjectIdArray.Count(); |
454 iAddCounter = aObjectIdArray.Count(); |
431 if (err != KErrNone) |
455 if (err != KErrNone) |
432 { |
456 { |
433 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - error adding to queue" ); |
457 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - error adding to queue" ); |
455 iProcessor->RemoveFromQueues( aObjectIdArray, ETrue ); |
479 iProcessor->RemoveFromQueues( aObjectIdArray, ETrue ); |
456 } |
480 } |
457 } |
481 } |
458 |
482 |
459 #ifdef _DEBUG |
483 #ifdef _DEBUG |
460 TN_DEBUG4( "CThumbAGDaemon::IN-COUNTERS---------- Add = %d Modify = %d Delete = %d", |
484 TN_DEBUG3( "CThumbAGDaemon::IN-COUNTERS---------- Add = %d Delete = %d", iAddCounter, iDelCounter ); |
461 iAddCounter, iModCounter, iDelCounter ); |
|
462 iModCounter = 0; |
|
463 iDelCounter = 0; |
485 iDelCounter = 0; |
464 iAddCounter = 0; |
486 iAddCounter = 0; |
465 #endif |
487 #endif |
466 |
488 |
467 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - end" ); |
489 TN_DEBUG1( "CThumbAGDaemon::HandleObjectPresentNotification() - end" ); |
468 } |
490 } |
469 |
491 |
488 // |
510 // |
489 void CThumbAGDaemon::AddObserversL() |
511 void CThumbAGDaemon::AddObserversL() |
490 { |
512 { |
491 TN_DEBUG1( "CThumbAGDaemon::AddObserversL() - begin" ); |
513 TN_DEBUG1( "CThumbAGDaemon::AddObserversL() - begin" ); |
492 |
514 |
493 CMdENamespaceDef& defaultNamespace = iMdESession->GetDefaultNamespaceDefL(); |
|
494 CMdEObjectDef& imageDef = defaultNamespace.GetObjectDefL( MdeConstants::Image::KImageObject ); |
|
495 CMdEObjectDef& videoDef = defaultNamespace.GetObjectDefL( MdeConstants::Video::KVideoObject ); |
|
496 CMdEObjectDef& audioDef = defaultNamespace.GetObjectDefL( MdeConstants::Audio::KAudioObject ); |
|
497 |
|
498 // set observing conditions |
|
499 CMdELogicCondition* addCondition = CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); |
|
500 addCondition->AddObjectConditionL( imageDef ); |
|
501 addCondition->AddObjectConditionL( videoDef ); |
|
502 addCondition->AddObjectConditionL( audioDef ); |
|
503 CleanupStack::Pop( addCondition ); |
|
504 |
|
505 CMdELogicCondition* modifyCondition = CMdELogicCondition::NewLC( ELogicConditionOperatorOr ); |
|
506 modifyCondition->AddObjectConditionL( imageDef ); |
|
507 modifyCondition->AddObjectConditionL( videoDef ); |
|
508 modifyCondition->AddObjectConditionL( audioDef ); |
|
509 CleanupStack::Pop( modifyCondition ); |
|
510 |
|
511 // add observer |
|
512 iMdESession->AddObjectObserverL( *this, addCondition, ENotifyAdd ); |
|
513 |
|
514 // modify observer |
|
515 #ifdef MDS_MODIFY_OBSERVER |
|
516 iMdESession->AddObjectObserverL( *this, modifyCondition, ENotifyModify ); |
|
517 #endif |
|
518 |
515 |
519 #ifdef MDS_URI_OBSERVER |
516 #ifdef MDS_URI_OBSERVER |
520 // remove observer with uri |
517 // remove observer with uri |
521 iMdESession->AddObjectObserverWithUriL( *this, NULL, ENotifyRemove ); |
518 iMdESession->AddObjectObserverWithUriL( *this, NULL, ENotifyRemove ); |
522 #endif |
519 #endif |