114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <liwcommon.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
#include <escapeutils.h>
|
|
22 |
|
|
23 |
#include "cpserverdatamanager.h"
|
|
24 |
#include "ccontentmap.h"
|
|
25 |
#include "cpublisherregistrymap.h"
|
|
26 |
#include "cpstorage.h"
|
|
27 |
#include "cpdebug.h"
|
|
28 |
#include "cpstoragefactory.h"
|
|
29 |
#include "cpglobals.h"
|
|
30 |
#include "cpserversession.h"
|
|
31 |
#include "cpnotificationhandler.h"
|
|
32 |
|
|
33 |
using namespace LIW;
|
|
34 |
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
// C++ destructor
|
|
37 |
// ---------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
CCPDataManager::~CCPDataManager()
|
|
40 |
{
|
|
41 |
delete iActionDataCache;
|
|
42 |
iNotificationsArray.Close( );
|
|
43 |
delete iStorage;
|
|
44 |
}
|
|
45 |
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
CCPDataManager* CCPDataManager::NewL(TLiwVariant& aDataMapCache, TBool aBool)
|
|
51 |
{
|
|
52 |
CCPDataManager* self = CCPDataManager::NewLC( aDataMapCache, aBool );
|
|
53 |
CleanupStack::Pop( self );
|
|
54 |
return self;
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CCPDataManager* CCPDataManager::NewLC(TLiwVariant& aDataMapCache, TBool aBool)
|
|
62 |
{
|
|
63 |
CCPDataManager* self = new( ELeave ) CCPDataManager();
|
|
64 |
CleanupStack::PushL( self );
|
|
65 |
self->ConstructL( aDataMapCache, aBool );
|
|
66 |
return self;
|
|
67 |
}
|
|
68 |
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
// C++ constructor.
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CCPDataManager::CCPDataManager()
|
|
74 |
{
|
|
75 |
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// Standard 2nd phase constructor.
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
//
|
|
82 |
void CCPDataManager::ConstructL(TLiwVariant& aDataMapCache, TBool aBool)
|
|
83 |
{
|
|
84 |
CP_DEBUG( _L8("CCPDataManager::ConstructL()") );
|
|
85 |
if ( !aBool )
|
|
86 |
{
|
|
87 |
iStorage = StorageFactory::NewDatabaseL( aDataMapCache );
|
|
88 |
}
|
|
89 |
iActionDataCache = CCPActionDataCache::NewL();
|
|
90 |
}
|
|
91 |
|
|
92 |
// ---------------------------------------------------------------------------
|
|
93 |
//
|
|
94 |
// ---------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
TUint CCPDataManager::AddDataL( CCPLiwMap& aMap )
|
|
97 |
{
|
|
98 |
CP_DEBUG( _L8("CCPDataManager::AddDataL()") );
|
|
99 |
__ASSERT_DEBUG( iStorage , User::Panic( _L("cpserver"), 0 ) );
|
|
100 |
|
|
101 |
CCPLiwMap* getlistmap = CreateMapForGetlistLC( aMap );
|
|
102 |
|
|
103 |
iActionDataCache->HandleCacheRemoveL( &aMap );
|
|
104 |
|
|
105 |
TBool activateMap = aMap.GetActivateInfo();
|
|
106 |
TBool activateDB ( EFalse );
|
|
107 |
TBool activateSupport =aMap.ActivateActionSupport( );
|
|
108 |
|
|
109 |
if( activateSupport )
|
|
110 |
{
|
|
111 |
activateDB = GetActivateInfoL( getlistmap );
|
|
112 |
}
|
|
113 |
|
|
114 |
TInt id = iStorage->AddL( &aMap );
|
|
115 |
|
|
116 |
if( activateSupport )
|
|
117 |
{
|
|
118 |
if ( activateMap && !activateDB )
|
|
119 |
{
|
|
120 |
// append action trigger for activate
|
|
121 |
aMap.InsertL( KActionTrigger, TLiwVariant( KActivateTrigger ) );
|
|
122 |
}
|
|
123 |
if ( !activateMap && activateDB )
|
|
124 |
{
|
|
125 |
// append action trigger for deactivate
|
|
126 |
aMap.InsertL( KActionTrigger, TLiwVariant( KDeactivateTrigger ) );
|
|
127 |
}
|
|
128 |
//remove flag from map ( needed because map will be used in getlist
|
|
129 |
//operation )
|
|
130 |
aMap.Remove( KFlag );
|
|
131 |
}
|
|
132 |
|
|
133 |
CleanupStack::PopAndDestroy( getlistmap );
|
|
134 |
|
|
135 |
return id;
|
|
136 |
}
|
|
137 |
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
// ---------------------------------------------------------------------------
|
|
141 |
//
|
|
142 |
void CCPDataManager::AddNonPersistentDataL( const CCPLiwMap* aMap )
|
|
143 |
{
|
|
144 |
CLiwDefaultList* notificationList = CLiwDefaultList::NewLC( );
|
|
145 |
BuildChangeInfoForAddL( aMap, notificationList );
|
|
146 |
HandleChangeL( notificationList );
|
|
147 |
CleanupStack::PopAndDestroy( notificationList );
|
|
148 |
}
|
|
149 |
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
// ---------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
void CCPDataManager::GetListL( const CCPLiwMap& aMap,
|
|
155 |
CLiwGenericParamList& aOutParamList )
|
|
156 |
{
|
|
157 |
CP_DEBUG( _L8("CCPDataManager::GetListL()") );
|
|
158 |
__ASSERT_DEBUG( iStorage , User::Panic( _L("cpserver"), 0 ) );
|
|
159 |
iStorage->GetListL( &aMap, aOutParamList );
|
|
160 |
}
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
TInt CCPDataManager::GetActionsL( const CCPLiwMap& aMap, TBool aEnableCache,
|
|
166 |
CLiwGenericParamList& aOutParamList, CLiwDefaultList* aNotificationList )
|
|
167 |
{
|
|
168 |
CP_DEBUG( _L8("CCPDataManager::GetActionL()") );
|
|
169 |
__ASSERT_DEBUG( iStorage , User::Panic( _L("cpserver"), 0 ) );
|
|
170 |
|
|
171 |
CLiwGenericParamList* paramList = CLiwGenericParamList::NewLC( );
|
|
172 |
TInt result( KErrNone );
|
|
173 |
|
|
174 |
CLiwDefaultList* actionTriggers = aMap.GetActionTriggersLC();
|
|
175 |
|
|
176 |
if ( actionTriggers )
|
|
177 |
{
|
|
178 |
TBool cacheable = iActionDataCache->IsCacheableL( &aMap );
|
|
179 |
if (aEnableCache && cacheable && iActionDataCache->ExistL( &aMap ))
|
|
180 |
{
|
|
181 |
iActionDataCache->GetL( &aMap, paramList );
|
|
182 |
}
|
|
183 |
else
|
|
184 |
{
|
|
185 |
TRAP( result, iStorage->GetListL( &aMap, *paramList ) );
|
|
186 |
if ( aEnableCache && cacheable )
|
|
187 |
{
|
|
188 |
if ( result == KErrNone )
|
|
189 |
{
|
|
190 |
iActionDataCache->AppendL(paramList);
|
|
191 |
}
|
|
192 |
else if ( result == KErrNotFound )
|
|
193 |
{
|
|
194 |
iActionDataCache->AppendEmptyL(&aMap);
|
|
195 |
}
|
|
196 |
}
|
|
197 |
}
|
|
198 |
|
|
199 |
const TLiwGenericParam* param;
|
|
200 |
TInt pos( 0);
|
|
201 |
|
|
202 |
param = paramList->FindFirst( pos, KListMap );
|
|
203 |
//at least one param should be valid to preceed
|
|
204 |
if ( !param || pos == KErrNotFound )
|
|
205 |
{
|
|
206 |
BuildDefaultChangeInfoL(&aMap, actionTriggers, aNotificationList);
|
|
207 |
}
|
|
208 |
|
|
209 |
//iteration through paramList items
|
|
210 |
while ( param && pos != KErrNotFound )
|
|
211 |
{
|
|
212 |
RBuf8 actionBinaries;
|
|
213 |
actionBinaries.CleanupClosePushL();
|
|
214 |
ExtractActionL( param, actionBinaries );
|
|
215 |
RDesReadStream str(actionBinaries);
|
|
216 |
CleanupClosePushL( str );
|
|
217 |
CLiwDefaultMap* actionMap = CLiwDefaultMap::NewLC( str );
|
|
218 |
BuildChangeInfoL( &aMap, actionTriggers, param, actionMap,
|
|
219 |
aNotificationList );
|
|
220 |
FillActionParamListL( aOutParamList, actionMap, actionTriggers );
|
|
221 |
param = paramList->FindNext( pos, KListMap );
|
|
222 |
CleanupStack::PopAndDestroy( actionMap );
|
|
223 |
CleanupStack::PopAndDestroy( &str );
|
|
224 |
CleanupStack::PopAndDestroy( &actionBinaries );
|
|
225 |
}
|
|
226 |
if (aNotificationList->Count() == 0)
|
|
227 |
{
|
|
228 |
User::Leave(KErrNotFound);
|
|
229 |
}
|
|
230 |
}
|
|
231 |
else
|
|
232 |
{
|
|
233 |
User::Leave( KErrNotFound );
|
|
234 |
}
|
|
235 |
|
|
236 |
CleanupStack::PopAndDestroy( actionTriggers );
|
|
237 |
CleanupStack::PopAndDestroy( paramList );
|
|
238 |
return result;
|
|
239 |
}
|
|
240 |
|
|
241 |
|
|
242 |
// ---------------------------------------------------------------------------
|
|
243 |
//
|
|
244 |
// ---------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void CCPDataManager::FillActionParamListL(
|
|
247 |
CLiwGenericParamList& aOutParamList,
|
|
248 |
const CLiwDefaultMap* aActionMap,
|
|
249 |
const CLiwDefaultList* aActionTriggers)
|
|
250 |
{
|
|
251 |
CP_DEBUG( _L8("CCPDataManager::FillActionParamListL()") );
|
|
252 |
__ASSERT_DEBUG( iStorage , User::Panic( _L("cpserver"), 0 ) );
|
|
253 |
TLiwVariant trigger;
|
|
254 |
trigger.PushL();
|
|
255 |
TInt count = aActionTriggers->Count();
|
|
256 |
for ( TInt i = 0; i<count; i++ )
|
|
257 |
{
|
|
258 |
trigger.Reset();
|
|
259 |
aActionTriggers->AtL( i,trigger );
|
|
260 |
ExtractTriggerL( aOutParamList, aActionMap, trigger.AsData());
|
|
261 |
}
|
|
262 |
CleanupStack::PopAndDestroy(&trigger);
|
|
263 |
}
|
|
264 |
|
|
265 |
// ---------------------------------------------------------------------------
|
|
266 |
//
|
|
267 |
// ---------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
void CCPDataManager::GetActivePublishersL( CLiwGenericParamList* aResultList )
|
|
270 |
{
|
|
271 |
CCPLiwMap *map = CPublisherRegistryMap::NewLC();
|
|
272 |
map->InsertL( KFlag, TLiwVariant( TUint( 0 | EActivate ) ) );
|
|
273 |
iStorage->GetListL( map, *aResultList );
|
|
274 |
CleanupStack::PopAndDestroy(map);
|
|
275 |
}
|
|
276 |
|
|
277 |
|
|
278 |
// ---------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
void CCPDataManager::ExtractTriggerL( CLiwGenericParamList& aOutParamList,
|
|
283 |
const CLiwDefaultMap* aMap, const TDesC8& aTrigger )
|
|
284 |
{
|
|
285 |
CP_DEBUG( _L8("CCPDataManager::GetActionL()") );
|
|
286 |
CLiwDefaultMap* targetMap = CLiwDefaultMap::NewLC( );
|
|
287 |
TLiwVariant variant;
|
|
288 |
variant.PushL( );
|
|
289 |
if ( aMap->FindL( aTrigger, variant ) )
|
|
290 |
{
|
|
291 |
targetMap->InsertL( KActionMap, variant );
|
|
292 |
TLiwGenericParam result( KListMap, TLiwVariant( targetMap ));
|
|
293 |
aOutParamList.AppendL( result );
|
|
294 |
}
|
|
295 |
CleanupStack::PopAndDestroy( &variant );
|
|
296 |
CleanupStack::PopAndDestroy( targetMap );
|
|
297 |
}
|
|
298 |
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
// ---------------------------------------------------------------------------
|
|
302 |
//
|
|
303 |
void CCPDataManager::RemoveDataL( const CCPLiwMap& aMap )
|
|
304 |
{
|
|
305 |
CP_DEBUG( _L8("CCPDataManager::RemoveData()") );
|
|
306 |
__ASSERT_DEBUG( iStorage , User::Panic( _L("cpserver"), 0 ) );
|
|
307 |
iActionDataCache->HandleCacheRemoveL( &aMap );
|
|
308 |
iStorage->RemoveL( &aMap );
|
|
309 |
}
|
|
310 |
|
|
311 |
// ---------------------------------------------------------------------------
|
|
312 |
//
|
|
313 |
// ---------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
void CCPDataManager::AddObserverL(
|
|
316 |
CCPNotificationHandler* aNotificationHandler )
|
|
317 |
{
|
|
318 |
CP_DEBUG( _L8("CCPDataManager::AddObserverL()") );
|
|
319 |
__ASSERT_DEBUG( iStorage , User::Panic( _L("cpserver"), 0 ) );
|
|
320 |
iNotificationsArray.AppendL( aNotificationHandler );
|
|
321 |
if ( iNotificationsArray.Count( ) == 1 )
|
|
322 |
{
|
|
323 |
iStorage->SetCallback( this );
|
|
324 |
}
|
|
325 |
}
|
|
326 |
|
|
327 |
// ---------------------------------------------------------------------------
|
|
328 |
//
|
|
329 |
// ---------------------------------------------------------------------------
|
|
330 |
//
|
|
331 |
void CCPDataManager::RemoveObserver(
|
|
332 |
CCPNotificationHandler* aNotificationHandler )
|
|
333 |
{
|
|
334 |
CP_DEBUG( _L8("CCPDataManager::RemoveObserver()") );
|
|
335 |
TInt index = iNotificationsArray.Find( aNotificationHandler );
|
|
336 |
if (index != KErrNotFound)
|
|
337 |
{
|
|
338 |
iNotificationsArray.Remove( index );
|
|
339 |
if ( iNotificationsArray.Count( ) == 0 )
|
|
340 |
{
|
|
341 |
iStorage->SetCallback( 0 );
|
|
342 |
}
|
|
343 |
}
|
|
344 |
}
|
|
345 |
|
|
346 |
// ---------------------------------------------------------------------------
|
|
347 |
//
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
//
|
|
350 |
void CCPDataManager::HandleChangeL( CLiwDefaultList* aListOfMaps )
|
|
351 |
{
|
|
352 |
CP_DEBUG( _L8("CCPDataManager::HandleChangeL()") );
|
|
353 |
//for every session
|
|
354 |
for ( TInt i = 0; i<iNotificationsArray.Count( ); i++ )
|
|
355 |
{
|
|
356 |
TRAPD(error, SendNotificationL(aListOfMaps, i));
|
|
357 |
if ( error )
|
|
358 |
{
|
|
359 |
iNotificationsArray[i]->ErrorComplete( error );
|
|
360 |
}
|
|
361 |
}
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
// ---------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
void CCPDataManager::CloseDatabase()
|
|
369 |
{
|
|
370 |
CP_DEBUG( _L8("CCPDataManager::CloseDatabase()") );
|
|
371 |
delete iStorage;
|
|
372 |
iStorage = NULL;
|
|
373 |
}
|
|
374 |
|
|
375 |
// ---------------------------------------------------------------------------
|
|
376 |
//
|
|
377 |
// ---------------------------------------------------------------------------
|
|
378 |
//
|
|
379 |
void CCPDataManager::OpenDatabaseL(TLiwVariant& aDataMapCache)
|
|
380 |
{
|
|
381 |
CP_DEBUG( _L8("CCPDataManager::OpenDatabaseL()") );
|
|
382 |
if ( !iStorage )
|
|
383 |
{
|
|
384 |
iStorage = StorageFactory::NewDatabaseL( aDataMapCache );
|
|
385 |
|
|
386 |
// Restore storage observers
|
|
387 |
if ( iNotificationsArray.Count() > 0 )
|
|
388 |
{
|
|
389 |
iStorage->SetCallback( this );
|
|
390 |
}
|
|
391 |
}
|
|
392 |
}
|
|
393 |
// ---------------------------------------------------------------------------
|
|
394 |
//
|
|
395 |
// ---------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
void CCPDataManager::SendNotificationL( CLiwDefaultList* aListOfMaps,
|
|
398 |
TInt aIndex )
|
|
399 |
{
|
|
400 |
CP_DEBUG( _L8("CCPDataManager::SendNotificationL()") );
|
|
401 |
iNotificationsArray[aIndex]->SendNotificationL( aListOfMaps );
|
|
402 |
}
|
|
403 |
|
|
404 |
// ---------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
// ---------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
void CCPDataManager::ExtractActionL( const TLiwGenericParam* aParam, RBuf8& aAction )
|
|
409 |
{
|
|
410 |
CP_DEBUG( _L8("CCPDataManager::ExtractActionL()") );
|
|
411 |
if ( aParam->Value().TypeId() != EVariantTypeMap )
|
|
412 |
{
|
|
413 |
User::Leave( KErrArgument );
|
|
414 |
}
|
|
415 |
|
|
416 |
TLiwVariant variant; variant.PushL( );
|
|
417 |
TPtrC8 tempBuf( KNullDesC8 );
|
|
418 |
if ( aParam->Value().AsMap()->FindL( KActionMap, variant )
|
|
419 |
&& variant.Get( tempBuf ) )
|
|
420 |
{
|
|
421 |
aAction.CreateL( tempBuf );
|
|
422 |
}
|
|
423 |
else
|
|
424 |
{
|
|
425 |
User::Leave( KErrArgument );
|
|
426 |
}
|
|
427 |
|
|
428 |
CleanupStack::PopAndDestroy( &variant );
|
|
429 |
}
|
|
430 |
|
|
431 |
// -----------------------------------------------------------------------------
|
|
432 |
//
|
|
433 |
// -----------------------------------------------------------------------------
|
|
434 |
//
|
|
435 |
CCPLiwMap* CCPDataManager::CreateMapForGetlistLC( const CCPLiwMap& aMap )
|
|
436 |
{
|
|
437 |
CCPLiwMap *resultmap = CPublisherRegistryMap::NewLC();
|
|
438 |
RBuf publisher;
|
|
439 |
publisher.CleanupClosePushL();
|
|
440 |
RBuf content_type;
|
|
441 |
content_type.CleanupClosePushL();
|
|
442 |
RBuf content_id;
|
|
443 |
content_id.CleanupClosePushL();
|
|
444 |
aMap.GetPropertyL( KContentType, content_type );
|
|
445 |
aMap.GetPropertyL( KContentId, content_id );
|
|
446 |
aMap.GetPropertyL( KPublisherId, publisher );
|
|
447 |
resultmap->InsertL( KPublisherId, TLiwVariant( publisher ));
|
|
448 |
resultmap->InsertL( KContentId, TLiwVariant( content_id ));
|
|
449 |
resultmap->InsertL( KContentType, TLiwVariant( content_type ));
|
|
450 |
CleanupStack::PopAndDestroy( &content_id );
|
|
451 |
CleanupStack::PopAndDestroy( &content_type );
|
|
452 |
CleanupStack::PopAndDestroy( &publisher );
|
|
453 |
return resultmap;
|
|
454 |
}
|
|
455 |
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
// -----------------------------------------------------------------------------
|
|
459 |
//
|
|
460 |
TBool CCPDataManager::GetActivateInfoL( const CCPLiwMap* aMap )
|
|
461 |
{
|
|
462 |
TBool result( EFalse );
|
|
463 |
CLiwGenericParamList* outList = CLiwGenericParamList::NewLC();
|
|
464 |
TRAPD(err,GetListL(*aMap,*outList));
|
|
465 |
if (err == KErrNone)
|
|
466 |
{
|
|
467 |
TInt pos( 0 );
|
|
468 |
outList->FindFirst( pos, KListMap );
|
|
469 |
if( pos != KErrNotFound )
|
|
470 |
{
|
|
471 |
TLiwVariant variant = (*outList)[pos].Value();
|
|
472 |
if ( variant.TypeId() == EVariantTypeMap )
|
|
473 |
{
|
|
474 |
if (variant.AsMap()->FindL( KFlag, variant ))
|
|
475 |
{
|
|
476 |
TUint flag;
|
|
477 |
variant.Get( flag );
|
|
478 |
result = flag & EActivate;
|
|
479 |
}
|
|
480 |
}
|
|
481 |
variant.Reset();
|
|
482 |
}
|
|
483 |
}
|
|
484 |
CleanupStack::PopAndDestroy( outList );
|
|
485 |
return result;
|
|
486 |
}
|
|
487 |
|
|
488 |
// -----------------------------------------------------------------------------
|
|
489 |
//
|
|
490 |
// -----------------------------------------------------------------------------
|
|
491 |
//
|
|
492 |
void CCPDataManager::BuildChangeInfoL( const CCPLiwMap* aMap,
|
|
493 |
const CLiwDefaultList* aActionTriggers,
|
|
494 |
const TLiwGenericParam* aParam,
|
|
495 |
const CLiwDefaultMap* aActionMap,
|
|
496 |
CLiwDefaultList* aChangeInfoList )
|
|
497 |
{
|
|
498 |
TLiwVariant resultVar = aParam->Value();
|
|
499 |
resultVar.PushL();
|
|
500 |
if ( resultVar.TypeId() == EVariantTypeMap )
|
|
501 |
{
|
|
502 |
for ( TInt i = 0; i<aActionTriggers->Count(); i++ )
|
|
503 |
{
|
|
504 |
TLiwVariant dummyVariant;
|
|
505 |
dummyVariant.PushL();
|
|
506 |
TLiwVariant trigger;
|
|
507 |
trigger.PushL();
|
|
508 |
aActionTriggers->AtL(i,trigger);
|
|
509 |
if (aActionMap->FindL( trigger.AsData(), dummyVariant ))
|
|
510 |
{
|
|
511 |
CLiwDefaultMap* changeInfoMap = CLiwDefaultMap::NewLC();
|
|
512 |
CopyVariantL(KId, resultVar.AsMap(), changeInfoMap);
|
|
513 |
CopyVariantL(KPublisherId, resultVar.AsMap(), changeInfoMap);
|
|
514 |
CopyVariantL(KContentType, resultVar.AsMap(), changeInfoMap);
|
|
515 |
CopyVariantL(KContentId, resultVar.AsMap(), changeInfoMap);
|
|
516 |
CopyVariantL(KFlag, resultVar.AsMap(), changeInfoMap);
|
|
517 |
CopyVariantL(KType, aMap, changeInfoMap);
|
|
518 |
changeInfoMap->InsertL(KActionTrigger, trigger);
|
|
519 |
CopyActionTrigger16L(trigger, changeInfoMap);
|
|
520 |
changeInfoMap->InsertL(KOperation, TLiwVariant(
|
|
521 |
KOperationExecute));
|
|
522 |
aChangeInfoList->AppendL(TLiwVariant(changeInfoMap));
|
|
523 |
CleanupStack::PopAndDestroy(changeInfoMap);
|
|
524 |
}
|
|
525 |
CleanupStack::PopAndDestroy(&trigger);
|
|
526 |
CleanupStack::PopAndDestroy(&dummyVariant);
|
|
527 |
}
|
|
528 |
}
|
|
529 |
CleanupStack::PopAndDestroy( &resultVar );
|
|
530 |
}
|
|
531 |
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
// -----------------------------------------------------------------------------
|
|
535 |
//
|
|
536 |
void CCPDataManager::BuildDefaultChangeInfoL( const CCPLiwMap* aMap,
|
|
537 |
const CLiwDefaultList* aActionTriggers,
|
|
538 |
CLiwDefaultList* aChangeInfoList )
|
|
539 |
{
|
|
540 |
for ( TInt i = 0; i<aActionTriggers->Count(); i++ )
|
|
541 |
{
|
|
542 |
CLiwDefaultMap* changeInfoMap = CLiwDefaultMap::NewLC();
|
|
543 |
|
|
544 |
CopyVariantL(KId, aMap, changeInfoMap );
|
|
545 |
CopyVariantL(KPublisherId, aMap, changeInfoMap );
|
|
546 |
CopyVariantL(KContentType, aMap, changeInfoMap );
|
|
547 |
CopyVariantL(KContentId, aMap, changeInfoMap );
|
|
548 |
CopyVariantL(KFlag, aMap, changeInfoMap );
|
|
549 |
CopyVariantL(KType, aMap, changeInfoMap );
|
|
550 |
|
|
551 |
TLiwVariant trigger;
|
|
552 |
trigger.PushL();
|
|
553 |
aActionTriggers->AtL(i,trigger);
|
|
554 |
changeInfoMap->InsertL(KActionTrigger, trigger);
|
|
555 |
CopyActionTrigger16L(trigger,changeInfoMap);
|
|
556 |
CleanupStack::PopAndDestroy(&trigger);
|
|
557 |
|
|
558 |
changeInfoMap->InsertL( KOperation, TLiwVariant( KOperationExecute ) );
|
|
559 |
|
|
560 |
aChangeInfoList->AppendL( TLiwVariant( changeInfoMap ) );
|
|
561 |
CleanupStack::PopAndDestroy( changeInfoMap );
|
|
562 |
}
|
|
563 |
}
|
|
564 |
|
|
565 |
// -----------------------------------------------------------------------------
|
|
566 |
//
|
|
567 |
// -----------------------------------------------------------------------------
|
|
568 |
//
|
|
569 |
void CCPDataManager::BuildChangeInfoForAddL( const CCPLiwMap* aMap,
|
|
570 |
CLiwDefaultList* aChangeInfoList )
|
|
571 |
{
|
|
572 |
CLiwDefaultMap* changeInfoMap = CLiwDefaultMap::NewLC();
|
|
573 |
|
|
574 |
CopyVariantL(KId, aMap, changeInfoMap );
|
|
575 |
CopyVariantL(KPublisherId, aMap, changeInfoMap );
|
|
576 |
CopyVariantL(KContentType, aMap, changeInfoMap );
|
|
577 |
CopyVariantL(KContentId, aMap, changeInfoMap );
|
|
578 |
CopyVariantL(KFlag, aMap, changeInfoMap );
|
|
579 |
CopyVariantL(KType, aMap, changeInfoMap );
|
|
580 |
CopyVariantL(KActionTrigger, aMap, changeInfoMap );
|
|
581 |
CopyVariantL(KDataMap, aMap, changeInfoMap );
|
|
582 |
CopyActionTrigger16L( aMap, changeInfoMap );
|
|
583 |
|
|
584 |
changeInfoMap->InsertL( KOperation, TLiwVariant( KOperationAdd ) );
|
|
585 |
|
|
586 |
aChangeInfoList->AppendL( TLiwVariant( changeInfoMap ) );
|
|
587 |
CleanupStack::PopAndDestroy( changeInfoMap );
|
|
588 |
}
|
|
589 |
|
|
590 |
// -----------------------------------------------------------------------------
|
|
591 |
//
|
|
592 |
// -----------------------------------------------------------------------------
|
|
593 |
//
|
|
594 |
void CCPDataManager::CopyVariantL(const TDesC8& aKey,
|
|
595 |
const CLiwMap* aInMap, CLiwDefaultMap* aOutMap )
|
|
596 |
{
|
|
597 |
TLiwVariant variant;
|
|
598 |
variant.PushL();
|
|
599 |
if ( aInMap->FindL( aKey, variant ) )
|
|
600 |
{
|
|
601 |
aOutMap->InsertL( aKey, variant );
|
|
602 |
}
|
|
603 |
CleanupStack::PopAndDestroy( &variant );
|
|
604 |
}
|
|
605 |
|
|
606 |
// -----------------------------------------------------------------------------
|
|
607 |
//
|
|
608 |
// -----------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
void CCPDataManager::CopyActionTrigger16L(
|
|
611 |
const CLiwMap* aInMap, CLiwDefaultMap* aOutMap )
|
|
612 |
{
|
|
613 |
TLiwVariant variant;
|
|
614 |
variant.PushL();
|
|
615 |
if ( aInMap->FindL( KActionTrigger(), variant ) )
|
|
616 |
{
|
|
617 |
CopyActionTrigger16L(variant,aOutMap);
|
|
618 |
}
|
|
619 |
CleanupStack::PopAndDestroy( &variant );
|
|
620 |
}
|
|
621 |
|
|
622 |
// -----------------------------------------------------------------------------
|
|
623 |
//
|
|
624 |
// -----------------------------------------------------------------------------
|
|
625 |
//
|
|
626 |
void CCPDataManager::CopyActionTrigger16L( const TLiwVariant& aVariant,
|
|
627 |
CLiwDefaultMap* aOutMap )
|
|
628 |
{
|
|
629 |
if( aVariant.TypeId() == EVariantTypeDesC8 )
|
|
630 |
{
|
|
631 |
TLiwVariant variant;
|
|
632 |
variant.PushL();
|
|
633 |
RBuf desc16;
|
|
634 |
desc16.CleanupClosePushL();
|
|
635 |
desc16.Assign(
|
|
636 |
EscapeUtils::ConvertToUnicodeFromUtf8L( aVariant.AsData()) );
|
|
637 |
variant.Set( desc16 );
|
|
638 |
aOutMap->InsertL(KActionTrigger16(),variant);
|
|
639 |
CleanupStack::PopAndDestroy( &desc16 );
|
|
640 |
CleanupStack::PopAndDestroy( &variant );
|
|
641 |
}
|
|
642 |
}
|
|
643 |
|