metadataengine/server/src/mdsserversession.cpp
branchRCL_3
changeset 8 50de4d668bb6
parent 7 3cebc1a84278
child 9 82c0024438c8
equal deleted inserted replaced
7:3cebc1a84278 8:50de4d668bb6
   113 		{
   113 		{
   114 		aMessage.Complete( KErrServerBusy );
   114 		aMessage.Complete( KErrServerBusy );
   115 		return;
   115 		return;
   116 		}
   116 		}
   117 
   117 
       
   118     if( iServer.ShutdownInProgress() )
       
   119         {
       
   120         aMessage.Complete( KErrServerTerminated );
       
   121         return;
       
   122         }
       
   123 	
   118     TRAPD( err, ServiceFunctionL( aMessage ) );
   124     TRAPD( err, ServiceFunctionL( aMessage ) );
   119     if( err != KErrNone )
   125     if( err != KErrNone )
   120         {
   126         {
   121         aMessage.Complete( err );
   127         aMessage.Complete( err );
   122         }
   128         }
   949     const TInt notifierId = aMsg.Int0();
   955     const TInt notifierId = aMsg.Int0();
   950     __LOG1( ELogServer, "-> Listen %d", notifierId );
   956     __LOG1( ELogServer, "-> Listen %d", notifierId );
   951 
   957 
   952     CMdSNotifier::TEntry& entry = iServer.Notifier().FindEntryL( notifierId );
   958     CMdSNotifier::TEntry& entry = iServer.Notifier().FindEntryL( notifierId );
   953     entry.SetupForCallback( aMsg, 1 );
   959     entry.SetupForCallback( aMsg, 1 );
       
   960 
       
   961     const TInt entryId = entry.Id();    
       
   962 
       
   963     TInt low( 0 );
       
   964     TInt high( iNotificationCache.Count() );
   954     
   965     
   955 	const TInt count = iNotificationCache.Count();
   966     while( low < high )
   956 	for( TInt i = 0; i < count; ++i )
   967         {
   957 		{
   968         TInt mid( (low+high)>>1 );
   958 		const TInt notificationCacheId = iNotificationCache[i]->iId;
   969         
   959 		const TInt entryId = entry.Id();
   970         const TInt compare( entryId - iNotificationCache[mid]->iId );
   960 
   971         if( compare == 0 )
   961 		if( notificationCacheId == entryId )
   972             {
   962 			{
   973             // The cache holds a new notification for this notifier, trigger it
   963 			// The cache holds a new notification for this notifier, trigger it
   974             CNotificationCacheItem* item = iNotificationCache[mid];
   964 			CNotificationCacheItem* item = iNotificationCache[i];
   975             iNotificationCache.Remove(mid);
   965 			iNotificationCache.Remove(i);
   976 
   966 
   977             CleanupStack::PushL( item );
   967 			CleanupStack::PushL( item );
   978 
   968 
   979             entry.TriggerCachedL( item->iCode, item->iData );
   969 			entry.TriggerCachedL( item->iCode, item->iData );
   980         
   970 			
   981             // take ownership of iData from item and delete it
   971 			// take ownership of iData from item and delete it
   982             item->iData = NULL;
   972 			item->iData = NULL;
   983             CleanupStack::PopAndDestroy( item );
   973 			CleanupStack::PopAndDestroy( item );
   984         
   974 			
   985             return;
   975 			return;
   986             }
   976 			}
   987         else if( compare > 0 )
   977 		}
   988             {
       
   989             low = mid + 1;
       
   990             }
       
   991         else
       
   992             {
       
   993             high = mid;
       
   994             }
       
   995         }
   978     }
   996     }
   979 
   997 
   980 // ---------------------------------------------------------------------------
   998 // ---------------------------------------------------------------------------
   981 // UnregisterL 
   999 // UnregisterL 
   982 // ---------------------------------------------------------------------------
  1000 // ---------------------------------------------------------------------------
  1172 	CNotificationCacheItem* item = 
  1190 	CNotificationCacheItem* item = 
  1173 		new (ELeave) CNotificationCacheItem( aId, aCompleteCode, aData );
  1191 		new (ELeave) CNotificationCacheItem( aId, aCompleteCode, aData );
  1174 	CleanupStack::Pop( aData );
  1192 	CleanupStack::Pop( aData );
  1175 	CleanupStack::PushL( item );
  1193 	CleanupStack::PushL( item );
  1176 
  1194 
  1177 	iNotificationCache.AppendL( item );
  1195 	iNotificationCache.InsertInOrderAllowRepeats( item, 
       
  1196 	                              TLinearOrder<CNotificationCacheItem>(CMdSServerSession::ComparePropertiesCacheItem)); 
  1178 
  1197 
  1179 	CleanupStack::Pop( item );
  1198 	CleanupStack::Pop( item );
  1180 	}
  1199 	}
  1181 	
  1200 	
  1182 CMdSServer& CMdSServerSession::GetServer() const
  1201 CMdSServer& CMdSServerSession::GetServer() const
  1632 	CleanupStack::PopAndDestroy( &objectIds );
  1651 	CleanupStack::PopAndDestroy( &objectIds );
  1633 
  1652 
  1634 	return KErrNone;
  1653 	return KErrNone;
  1635 	}
  1654 	}
  1636 
  1655 
       
  1656 TInt CMdSServerSession::ComparePropertiesCacheItem(const CNotificationCacheItem& aFirst, const CNotificationCacheItem& aSecond)
       
  1657     {
       
  1658     return aFirst.iId - aSecond.iId;
       
  1659     }
       
  1660