equal
deleted
inserted
replaced
327 if ( !found ) |
327 if ( !found ) |
328 { |
328 { |
329 THarvesterEventQueue* msgQueue = new (ELeave) THarvesterEventQueue; |
329 THarvesterEventQueue* msgQueue = new (ELeave) THarvesterEventQueue; |
330 CleanupStack::PushL( msgQueue ); |
330 CleanupStack::PushL( msgQueue ); |
331 |
331 |
332 TInt err = msgQueue->Open( aMessage, 1 ); |
332 User::LeaveIfError( msgQueue->Open( aMessage, 1 ) ); |
333 |
333 |
334 User::LeaveIfError( err ); |
334 User::LeaveIfError( iEventQueues.InsertInOrderAllowRepeats(msgQueue, |
335 |
335 TLinearOrder<THarvesterEventQueue>(CHarvesterEventManager::CompareProperties))); |
336 iEventQueues.AppendL( msgQueue ); |
|
337 observerInfo->iQueuePtr = msgQueue; |
336 observerInfo->iQueuePtr = msgQueue; |
338 |
337 |
339 CleanupStack::Pop( msgQueue ); |
338 CleanupStack::Pop( msgQueue ); |
340 } |
339 } |
341 |
340 |
394 { |
393 { |
395 // Remove the queue if removed observer |
394 // Remove the queue if removed observer |
396 // was the last observer which used it |
395 // was the last observer which used it |
397 if( !otherObserverFound ) |
396 if( !otherObserverFound ) |
398 { |
397 { |
399 for(TInt i = iEventQueues.Count(); --i >= 0;) |
398 TInt low( 0 ); |
400 { |
399 TInt high( iEventQueues.Count() ); |
401 THarvesterEventQueue* queue = iEventQueues[i]; |
400 |
402 if( queue->Handle() == serverQueueHandle ) |
401 while( low < high ) |
403 { |
402 { |
404 iEventQueues.Remove( i ); |
403 TInt mid( (low+high)>>1 ); |
405 queue->Close(); |
404 |
406 delete queue; |
405 const TInt compare( serverQueueHandle - iEventQueues[mid]->Handle() ); |
407 break; |
406 if( compare == 0 ) |
408 } |
407 { |
409 } |
408 THarvesterEventQueue* queue = iEventQueues[mid]; |
|
409 iEventQueues.Remove( mid ); |
|
410 queue->Close(); |
|
411 delete queue; |
|
412 break; |
|
413 } |
|
414 else if( compare > 0 ) |
|
415 { |
|
416 low = mid + 1; |
|
417 } |
|
418 else |
|
419 { |
|
420 high = mid; |
|
421 } |
|
422 } |
410 iEventQueues.Compress(); |
423 iEventQueues.Compress(); |
411 } |
424 } |
412 |
425 |
413 iRegisteredObservers.Compress(); |
426 iRegisteredObservers.Compress(); |
414 return KErrNone; |
427 return KErrNone; |
458 EXPORT_C TUint CHarvesterEventManager::GetLastClientId() |
471 EXPORT_C TUint CHarvesterEventManager::GetLastClientId() |
459 { |
472 { |
460 // deprecated method, just return something |
473 // deprecated method, just return something |
461 return 0; |
474 return 0; |
462 } |
475 } |
|
476 |
|
477 TInt CHarvesterEventManager::CompareProperties(const THarvesterEventQueue& aFirst, const THarvesterEventQueue& aSecond) |
|
478 { |
|
479 return aFirst.Handle() - aSecond.Handle(); |
|
480 } |
|
481 |