24 #include "cpdebug.h" |
24 #include "cpdebug.h" |
25 #include "cpliwmap.h" |
25 #include "cpliwmap.h" |
26 #include "cpglobals.h" |
26 #include "cpglobals.h" |
27 #include "cpserverdef.h" |
27 #include "cpserverdef.h" |
28 |
28 |
|
29 static const int KMaxKeyLength = 256; |
29 using namespace LIW; |
30 using namespace LIW; |
30 // ======== MEMBER FUNCTIONS ======== |
31 // ======== MEMBER FUNCTIONS ======== |
31 |
32 |
32 // --------------------------------------------------------------------------- |
33 // --------------------------------------------------------------------------- |
33 // |
34 // |
34 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
35 // |
36 // |
36 CCPNotificationHandler::CCPNotificationHandler() |
37 CCPNotificationHandler::CCPNotificationHandler( TLiwVariant& aDataMapCache ): |
|
38 iDataMapCache(aDataMapCache) |
37 { |
39 { |
38 |
40 |
39 } |
41 } |
40 |
42 |
41 // --------------------------------------------------------------------------- |
43 // --------------------------------------------------------------------------- |
55 |
57 |
56 // --------------------------------------------------------------------------- |
58 // --------------------------------------------------------------------------- |
57 // |
59 // |
58 // --------------------------------------------------------------------------- |
60 // --------------------------------------------------------------------------- |
59 // |
61 // |
60 CCPNotificationHandler* CCPNotificationHandler::NewL( |
62 CCPNotificationHandler* CCPNotificationHandler::NewL(RPointerArray< |
61 RPointerArray<CLiwDefaultList>& aNotifications ) |
63 CLiwDefaultList>& aNotifications, TLiwVariant& aDataMapCache) |
62 { |
64 { |
63 CCPNotificationHandler* self = CCPNotificationHandler::NewLC( |
65 CCPNotificationHandler* self = CCPNotificationHandler::NewLC( |
64 aNotifications ); |
66 aNotifications, aDataMapCache); |
65 CleanupStack::Pop( self ); |
67 CleanupStack::Pop( self ); |
66 return self; |
68 return self; |
67 } |
69 } |
68 |
70 |
69 // --------------------------------------------------------------------------- |
71 // --------------------------------------------------------------------------- |
70 // |
72 // |
71 // --------------------------------------------------------------------------- |
73 // --------------------------------------------------------------------------- |
72 // |
74 // |
73 CCPNotificationHandler* CCPNotificationHandler::NewLC( |
75 CCPNotificationHandler* CCPNotificationHandler::NewLC(RPointerArray< |
74 RPointerArray<CLiwDefaultList>& aNotifications ) |
76 CLiwDefaultList>& aNotifications, TLiwVariant& aDataMapCache) |
75 { |
77 { |
76 CCPNotificationHandler* self = new( ELeave ) CCPNotificationHandler; |
78 CCPNotificationHandler* self = new (ELeave) CCPNotificationHandler( |
|
79 aDataMapCache); |
77 CleanupStack::PushL( self ); |
80 CleanupStack::PushL( self ); |
78 self->ConstructL( aNotifications ); |
81 self->ConstructL( aNotifications ); |
79 return self; |
82 return self; |
80 } |
83 } |
81 |
84 |
129 RDesReadStream datastrm( *buffer); |
133 RDesReadStream datastrm( *buffer); |
130 CleanupClosePushL( datastrm ); |
134 CleanupClosePushL( datastrm ); |
131 CCPLiwMap* filterMap = CCPLiwMap::NewL( datastrm ); |
135 CCPLiwMap* filterMap = CCPLiwMap::NewL( datastrm ); |
132 CleanupStack::PushL( filterMap ); |
136 CleanupStack::PushL( filterMap ); |
133 iFilters.InsertL( transactionId, filterMap ); |
137 iFilters.InsertL( transactionId, filterMap ); |
|
138 TUint options = static_cast<TUint> (aMessage.Int2()); // 2 == KOptionsPosition |
|
139 iExtendedFlags.InsertL(transactionId, options |
|
140 & KExtendedNotifications); |
134 CleanupStack::Pop( filterMap ); |
141 CleanupStack::Pop( filterMap ); |
135 CleanupStack::PopAndDestroy( &datastrm ); |
142 CleanupStack::PopAndDestroy( &datastrm ); |
136 CleanupStack::PopAndDestroy( buffer ); |
143 CleanupStack::PopAndDestroy( buffer ); |
137 } |
144 } |
138 } |
145 } |
158 RDesReadStream datastrm( *buffer); |
165 RDesReadStream datastrm( *buffer); |
159 CleanupClosePushL( datastrm ); |
166 CleanupClosePushL( datastrm ); |
160 CCPLiwMap* filterMap = CCPLiwMap::NewL( datastrm ); |
167 CCPLiwMap* filterMap = CCPLiwMap::NewL( datastrm ); |
161 CleanupStack::PushL( filterMap ); |
168 CleanupStack::PushL( filterMap ); |
162 iFilters.InsertL( transactionId, filterMap ); |
169 iFilters.InsertL( transactionId, filterMap ); |
|
170 TUint options = static_cast<TUint> (aMessage.Int2()); // 2 == KOptionsPosition |
|
171 iExtendedFlags.InsertL(transactionId, options |
|
172 & KExtendedNotifications); |
163 CleanupStack::Pop( filterMap ); |
173 CleanupStack::Pop( filterMap ); |
164 CleanupStack::PopAndDestroy( &datastrm ); |
174 CleanupStack::PopAndDestroy( &datastrm ); |
165 CleanupStack::PopAndDestroy( buffer ); |
175 CleanupStack::PopAndDestroy( buffer ); |
166 } |
176 } |
167 } |
177 } |
175 TInt32 transactionId = aMessage.Int3(); |
185 TInt32 transactionId = aMessage.Int3(); |
176 CCPLiwMap* filter = iFilters.FindL( transactionId );// leaves if not found |
186 CCPLiwMap* filter = iFilters.FindL( transactionId );// leaves if not found |
177 filter->Reset(); |
187 filter->Reset(); |
178 filter->Close(); |
188 filter->Close(); |
179 iFilters.Remove( transactionId ); |
189 iFilters.Remove( transactionId ); |
|
190 iExtendedFlags.Remove( transactionId ); |
180 } |
191 } |
181 |
192 |
182 // ----------------------------------------------------------------------------- |
193 // ----------------------------------------------------------------------------- |
183 // |
194 // |
184 // ----------------------------------------------------------------------------- |
195 // ----------------------------------------------------------------------------- |
295 //for every observer in session |
306 //for every observer in session |
296 THashMapIter<TInt32, CCPLiwMap*> iter( iFilters ); |
307 THashMapIter<TInt32, CCPLiwMap*> iter( iFilters ); |
297 const CCPLiwMap*const* filter = iter.NextValue( ); |
308 const CCPLiwMap*const* filter = iter.NextValue( ); |
298 while( filter ) |
309 while( filter ) |
299 { |
310 { |
300 |
|
301 CLiwDefaultList* listOfMatchingMaps = CLiwDefaultList::NewLC( ); |
311 CLiwDefaultList* listOfMatchingMaps = CLiwDefaultList::NewLC( ); |
302 TInt count = aListOfMaps->Count( ); |
312 TInt count = aListOfMaps->Count( ); |
303 //for every item in the input list |
313 //for every item in the input list |
304 for ( TInt j = 0; j < count; j++ ) |
314 for ( TInt j = 0; j < count; j++ ) |
305 { |
315 { |
306 TLiwVariant variant; |
316 TLiwVariant variant; |
307 variant.PushL( ); |
317 variant.PushL( ); |
308 aListOfMaps->AtL( j, variant ); |
318 aListOfMaps->AtL( j, variant ); |
309 if ( variant.TypeId() == EVariantTypeMap ) |
319 if ( variant.TypeId() == EVariantTypeMap ) |
310 { |
320 { |
311 if ( IsProperForFilterL( *variant.AsMap(), **filter ) ) |
321 const CLiwMap* map = variant.AsMap(); |
|
322 if ( IsProperForFilterL( *map, **filter ) ) |
312 { |
323 { |
313 listOfMatchingMaps->AppendL( variant ); |
324 if (iExtendedFlags.FindL(*iter.CurrentKey()) |
|
325 && (iDataMapCache.TypeId() == EVariantTypeDesC8)) |
|
326 { |
|
327 //extended notifications - append data map |
|
328 CLiwDefaultMap* extendedMap = CLiwDefaultMap::NewLC(); |
|
329 TInt count = map->Count(); |
|
330 for(TInt i=0; i<count;i++) |
|
331 { |
|
332 TLiwVariant temporary; |
|
333 temporary.PushL(); |
|
334 TBuf8<KMaxKeyLength> key; |
|
335 map->AtL(i,key); |
|
336 map->FindL(key, temporary); |
|
337 extendedMap->InsertL(key,temporary); |
|
338 CleanupStack::PopAndDestroy(&temporary); |
|
339 } |
|
340 extendedMap->InsertL(KDataMap,iDataMapCache); |
|
341 listOfMatchingMaps->AppendL( TLiwVariant(extendedMap) ); |
|
342 CleanupStack::PopAndDestroy(extendedMap); |
|
343 } |
|
344 else |
|
345 { |
|
346 listOfMatchingMaps->AppendL( variant ); |
|
347 } |
314 } |
348 } |
315 } |
349 } |
316 CleanupStack::PopAndDestroy( &variant ); |
350 CleanupStack::PopAndDestroy( &variant ); |
317 } |
351 } |
318 if ( listOfMatchingMaps->Count( ) ) |
352 if ( listOfMatchingMaps->Count( ) ) |
323 TLiwVariant( listOfMatchingMaps ) ) ); |
357 TLiwVariant( listOfMatchingMaps ) ) ); |
324 } |
358 } |
325 CleanupStack::PopAndDestroy( listOfMatchingMaps ); |
359 CleanupStack::PopAndDestroy( listOfMatchingMaps ); |
326 filter = iter.NextValue( ); |
360 filter = iter.NextValue( ); |
327 } |
361 } |
328 |
|
329 if( iChangeInfoList->Count( ) ) |
362 if( iChangeInfoList->Count( ) ) |
330 { |
363 { |
331 TPckgBuf<TInt> sizeDes( iChangeInfoList->Size( ) ); |
364 TPckgBuf<TInt> sizeDes( iChangeInfoList->Size( ) ); |
332 TInt err = iMessage.Write( KReturnPosition, sizeDes ); |
365 TInt err = iMessage.Write( KReturnPosition, sizeDes ); |
333 iMessage.Complete( err ); |
366 iMessage.Complete( err ); |