67 // ConstructL |
67 // ConstructL |
68 // --------------------------------------------------------------------------- |
68 // --------------------------------------------------------------------------- |
69 // |
69 // |
70 void CMdSServerSession::ConstructL() |
70 void CMdSServerSession::ConstructL() |
71 { |
71 { |
72 iServer.IncrementSessions(); |
|
73 } |
72 } |
74 |
73 |
75 // --------------------------------------------------------------------------- |
74 // --------------------------------------------------------------------------- |
76 // Default constructor |
75 // Default constructor |
77 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
90 iFindEngines.ResetAndDestroy(); |
89 iFindEngines.ResetAndDestroy(); |
91 iFindEngines.Close(); |
90 iFindEngines.Close(); |
92 |
91 |
93 iServer.LockList().UnlockBySession( *this ); |
92 iServer.LockList().UnlockBySession( *this ); |
94 iServer.Notifier().RemoveEntriesBySession( *this ); |
93 iServer.Notifier().RemoveEntriesBySession( *this ); |
95 iServer.DecrementSessions(); |
|
96 |
94 |
97 // purge any pending notifications |
95 // purge any pending notifications |
98 iNotificationCache.ResetAndDestroy(); |
96 iNotificationCache.ResetAndDestroy(); |
99 iNotificationCache.Close(); |
97 iNotificationCache.Close(); |
100 } |
98 } |
103 // Service the server message |
101 // Service the server message |
104 // --------------------------------------------------------------------------- |
102 // --------------------------------------------------------------------------- |
105 // |
103 // |
106 void CMdSServerSession::ServiceL( const RMessage2& aMessage ) |
104 void CMdSServerSession::ServiceL( const RMessage2& aMessage ) |
107 { |
105 { |
108 __LOG2( ELogServer, "ServiceL message: %d uid: %.8x", |
106 __LOG2( ELogServer, "ServiceL message: %d uid: %d", |
109 aMessage.Function(), |
107 aMessage.Function(), |
110 aMessage.Identity()); |
108 aMessage.Identity().iUid); |
111 |
109 |
112 if( iServer.BackupOrRestoreRunning() ) |
110 if( iServer.BackupOrRestoreRunning() ) |
113 { |
111 { |
|
112 // Open client applications are closed during backup/restore, |
|
113 // thus registered observers that would be removed during |
|
114 // shutdown on clients, must be allowed to be removed even |
|
115 // if backup/restore is running |
|
116 if( aMessage.Function() == EUnregister ) |
|
117 { |
|
118 TRAPD( err, ServiceFunctionL( aMessage ) ); |
|
119 if( err != KErrNone ) |
|
120 { |
|
121 aMessage.Complete( err ); |
|
122 } |
|
123 return; |
|
124 } |
114 aMessage.Complete( KErrServerBusy ); |
125 aMessage.Complete( KErrServerBusy ); |
115 return; |
126 return; |
116 } |
127 } |
117 |
128 |
118 if( iServer.ShutdownInProgress() ) |
129 if( iServer.ShutdownInProgress() ) |
955 const TInt notifierId = aMsg.Int0(); |
966 const TInt notifierId = aMsg.Int0(); |
956 __LOG1( ELogServer, "-> Listen %d", notifierId ); |
967 __LOG1( ELogServer, "-> Listen %d", notifierId ); |
957 |
968 |
958 CMdSNotifier::TEntry& entry = iServer.Notifier().FindEntryL( notifierId ); |
969 CMdSNotifier::TEntry& entry = iServer.Notifier().FindEntryL( notifierId ); |
959 entry.SetupForCallback( aMsg, 1 ); |
970 entry.SetupForCallback( aMsg, 1 ); |
|
971 |
|
972 const TInt entryId = entry.Id(); |
|
973 |
|
974 TInt low( 0 ); |
|
975 TInt high( iNotificationCache.Count() ); |
960 |
976 |
961 const TInt count = iNotificationCache.Count(); |
977 while( low < high ) |
962 for( TInt i = 0; i < count; ++i ) |
978 { |
963 { |
979 TInt mid( (low+high)>>1 ); |
964 const TInt notificationCacheId = iNotificationCache[i]->iId; |
980 |
965 const TInt entryId = entry.Id(); |
981 const TInt compare( entryId - iNotificationCache[mid]->iId ); |
966 |
982 if( compare == 0 ) |
967 if( notificationCacheId == entryId ) |
983 { |
968 { |
984 // The cache holds a new notification for this notifier, trigger it |
969 // The cache holds a new notification for this notifier, trigger it |
985 CNotificationCacheItem* item = iNotificationCache[mid]; |
970 CNotificationCacheItem* item = iNotificationCache[i]; |
986 iNotificationCache.Remove(mid); |
971 iNotificationCache.Remove(i); |
987 |
972 |
988 CleanupStack::PushL( item ); |
973 CleanupStack::PushL( item ); |
989 |
974 |
990 entry.TriggerCachedL( item->iCode, item->iData ); |
975 entry.TriggerCachedL( item->iCode, item->iData ); |
991 |
976 |
992 // take ownership of iData from item and delete it |
977 // take ownership of iData from item and delete it |
993 item->iData = NULL; |
978 item->iData = NULL; |
994 CleanupStack::PopAndDestroy( item ); |
979 CleanupStack::PopAndDestroy( item ); |
995 |
980 |
996 return; |
981 return; |
997 } |
982 } |
998 else if( compare > 0 ) |
983 } |
999 { |
|
1000 low = mid + 1; |
|
1001 } |
|
1002 else |
|
1003 { |
|
1004 high = mid; |
|
1005 } |
|
1006 } |
984 } |
1007 } |
985 |
1008 |
986 // --------------------------------------------------------------------------- |
1009 // --------------------------------------------------------------------------- |
987 // UnregisterL |
1010 // UnregisterL |
988 // --------------------------------------------------------------------------- |
1011 // --------------------------------------------------------------------------- |
1178 CNotificationCacheItem* item = |
1201 CNotificationCacheItem* item = |
1179 new (ELeave) CNotificationCacheItem( aId, aCompleteCode, aData ); |
1202 new (ELeave) CNotificationCacheItem( aId, aCompleteCode, aData ); |
1180 CleanupStack::Pop( aData ); |
1203 CleanupStack::Pop( aData ); |
1181 CleanupStack::PushL( item ); |
1204 CleanupStack::PushL( item ); |
1182 |
1205 |
1183 iNotificationCache.AppendL( item ); |
1206 iNotificationCache.InsertInOrderAllowRepeats( item, |
|
1207 TLinearOrder<CNotificationCacheItem>(CMdSServerSession::ComparePropertiesCacheItem)); |
1184 |
1208 |
1185 CleanupStack::Pop( item ); |
1209 CleanupStack::Pop( item ); |
1186 } |
1210 } |
1187 |
1211 |
1188 CMdSServer& CMdSServerSession::GetServer() const |
1212 CMdSServer& CMdSServerSession::GetServer() const |