23
|
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: class to publish the data into widget
|
|
15 |
*
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include "cservicewidgetcontentpublisher.h"
|
|
20 |
|
|
21 |
#include <liwservicehandler.h>
|
|
22 |
#include <liwvariant.h>
|
|
23 |
#include <liwgenericparam.h>
|
|
24 |
#include <avkon.hrh>
|
|
25 |
#include <aknnotewrappers.h>
|
|
26 |
#include "swpdebugtrace.h"
|
|
27 |
|
|
28 |
#include <liwcommon.h>
|
|
29 |
#include "servicewidgetcpglobals.h"
|
|
30 |
#include <servicewidgetpluginres.rsg>
|
|
31 |
#include <StringLoader.h>
|
|
32 |
|
|
33 |
#include <spsettings.h>
|
|
34 |
#include <spentry.h>
|
|
35 |
|
|
36 |
#define KSW_LIST_GRANULARITY 8
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
// CServiceWidgetContentPublisher::CServiceWidgetContentPublisher
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
//
|
|
42 |
CServiceWidgetContentPublisher::CServiceWidgetContentPublisher(MServiceWidgetEventObserver& aObserver )
|
|
43 |
:iObserver( aObserver )
|
|
44 |
{
|
|
45 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::CServiceWidgetContentPublisher") );
|
|
46 |
}
|
|
47 |
|
|
48 |
// ---------------------------------------------------------------------------
|
|
49 |
// CServiceWidgetContentPublisher::NewL
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CServiceWidgetContentPublisher* CServiceWidgetContentPublisher::NewL(MServiceWidgetEventObserver& aObserver)
|
|
53 |
{
|
|
54 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::NewL() start") );
|
|
55 |
CServiceWidgetContentPublisher* self = NewLC(aObserver);
|
|
56 |
CleanupStack::Pop(self);
|
|
57 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::NewL() End") );
|
|
58 |
return self;
|
|
59 |
}
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// CServiceWidgetContentPublisher::NewLC
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
CServiceWidgetContentPublisher* CServiceWidgetContentPublisher::NewLC(MServiceWidgetEventObserver& aObserver)
|
|
66 |
{
|
|
67 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::NewLC() start") );
|
|
68 |
CServiceWidgetContentPublisher* self =
|
|
69 |
new (ELeave) CServiceWidgetContentPublisher(aObserver);
|
|
70 |
CleanupStack::PushL(self);
|
|
71 |
self->ConstructL();
|
|
72 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::NewLC() End") );
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
// ---------------------------------------------------------------------------
|
|
77 |
// CServiceWidgetContentPublisher::ConstructL
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// ConstructL is called by the application framework
|
|
80 |
void CServiceWidgetContentPublisher::ConstructL()
|
|
81 |
{
|
|
82 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::ConstructL() start") );
|
|
83 |
iMsgInterface = GetMessagingInterfaceL();
|
|
84 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::ConstructL() End") );
|
|
85 |
}
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
// CServiceWidgetContentPublisher::~CServiceWidgetContentPublisher
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
CServiceWidgetContentPublisher::~CServiceWidgetContentPublisher()
|
|
90 |
{
|
|
91 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::~CServiceWidgetContentPublisher() start") );
|
|
92 |
if( iMsgInterface )
|
|
93 |
{
|
|
94 |
iMsgInterface->Close();
|
|
95 |
iMsgInterface = NULL;
|
|
96 |
}
|
|
97 |
if( iServiceHandler )
|
|
98 |
{
|
|
99 |
iServiceHandler->Reset();
|
|
100 |
delete iServiceHandler;
|
|
101 |
iServiceHandler = NULL;
|
|
102 |
}
|
|
103 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::~CServiceWidgetContentPublisher() End") );
|
|
104 |
}
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
// CServiceWidgetContentPublisher::GetMessagingInterfaceL
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
|
|
110 |
MLiwInterface* CServiceWidgetContentPublisher::GetMessagingInterfaceL( )
|
|
111 |
{
|
|
112 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::GetMessagingInterfaceL() start") );
|
|
113 |
if( !iServiceHandler )
|
|
114 |
{
|
|
115 |
iServiceHandler = CLiwServiceHandler::NewL();
|
|
116 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::GetMessagingInterfaceL() CLiwServiceHandler created") );
|
|
117 |
}
|
|
118 |
CLiwGenericParamList* inParam = CLiwGenericParamList::NewL();
|
|
119 |
CleanupStack::PushL( inParam );
|
|
120 |
CLiwGenericParamList* outParam = CLiwGenericParamList::NewL();
|
|
121 |
CleanupStack::PushL( outParam );
|
|
122 |
CLiwCriteriaItem* crit = CLiwCriteriaItem::NewL( KLiwCmdAsStr, KCPContentInterface,
|
|
123 |
KCPService );
|
|
124 |
crit->SetServiceClass( TUid::Uid(KLiwClassBase) );
|
|
125 |
|
|
126 |
RCriteriaArray array;
|
|
127 |
array.AppendL(crit);
|
|
128 |
iServiceHandler->AttachL(array);
|
|
129 |
iServiceHandler->ExecuteServiceCmdL( *crit, *inParam, *outParam );
|
|
130 |
delete crit;
|
|
131 |
array.Reset();
|
|
132 |
|
|
133 |
// find service interface
|
|
134 |
TInt pos = 0;
|
|
135 |
MLiwInterface* msgInterface = NULL;
|
|
136 |
outParam->FindFirst( pos, KCPContentInterface );
|
|
137 |
if ( pos != KErrNotFound )
|
|
138 |
{
|
|
139 |
msgInterface = (*outParam)[pos].Value().AsInterface();
|
|
140 |
}
|
|
141 |
outParam->Reset();
|
|
142 |
inParam->Reset();
|
|
143 |
CleanupStack::PopAndDestroy( outParam );
|
|
144 |
CleanupStack::PopAndDestroy( inParam );
|
|
145 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::GetMessagingInterfaceL() End") );
|
|
146 |
return msgInterface;
|
|
147 |
}
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
// CServiceWidgetContentPublisher::HandleNotifyL
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
TInt CServiceWidgetContentPublisher::HandleNotifyL( TInt aCmdId, TInt /*aEventId*/,
|
|
153 |
CLiwGenericParamList& aEventParamList,
|
|
154 |
const CLiwGenericParamList& /*aInParamList*/
|
|
155 |
)
|
|
156 |
{
|
|
157 |
TRACE_SWP( TXT("CServiceWidgetContentPublisher::HandleNotifyL() start") );
|
|
158 |
TInt pos(0);
|
|
159 |
aEventParamList.FindFirst(pos, KChangeInfo);
|
|
160 |
|
|
161 |
if (pos != KErrNotFound)
|
|
162 |
{
|
|
163 |
TLiwVariant variant = (aEventParamList)[pos].Value();
|
|
164 |
variant.PushL();
|
|
165 |
const CLiwList* changeMapsList = variant.AsList();
|
|
166 |
HBufC16* publisher = NULL;
|
|
167 |
HBufC8* trigger = NULL;
|
|
168 |
const TInt KSAPIContentNameMaxLength = 255;
|
|
169 |
TBuf<KSAPIContentNameMaxLength> InstId;
|
|
170 |
|
|
171 |
for (TInt i = 0; i < changeMapsList->Count(); ++i)
|
|
172 |
{
|
|
173 |
if ( changeMapsList->AtL(i, variant) )
|
|
174 |
{
|
|
175 |
const CLiwMap* map = variant.AsMap();
|
|
176 |
if( map->FindL( KActionTrigger, variant) )
|
|
177 |
{
|
|
178 |
trigger = variant.AsData().AllocLC(); // trigger name
|
|
179 |
// In template case trigger name can be
|
|
180 |
// active , resume , suspend ,inactive, deactive or item names.
|
|
181 |
}
|
|
182 |
if( map->FindL( KPublisherId, variant) )
|
|
183 |
{
|
|
184 |
publisher = variant.AsDes().AllocLC(); // ai3templatedwidget
|
|
185 |
}
|
|
186 |
if( map->FindL( KContentId, variant) )
|
|
187 |
{
|
|
188 |
variant.Get( InstId );
|
|
189 |
}
|
|
190 |
if( trigger && publisher )
|
|
191 |
{
|
|
192 |
iObserver.HandleServiceEventL( *publisher, *trigger, InstId);
|
|
193 |
}//
|
|
194 |
if ( publisher )
|
|
195 |
{
|
|
196 |
CleanupStack::PopAndDestroy( publisher );
|
|
197 |
publisher = NULL;
|
|
198 |
}
|
|
199 |
if ( trigger )
|
|
200 |
{
|
|
201 |
CleanupStack::PopAndDestroy( trigger );
|
|
202 |
trigger = NULL;
|
|
203 |
}
|
|
204 |
}
|
|
205 |
}// loop
|
|
206 |
CleanupStack::Pop(&variant); //variant
|
|
207 |
variant.Reset();
|
|
208 |
}//if (pos != KErrNotFound)
|
|
209 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::HandleNotifyL() end") );
|
|
210 |
return aCmdId;
|
|
211 |
}//End HandleNotifyL
|
|
212 |
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
// CServiceWidgetContentPublisher::RegisterWidgetL
|
|
215 |
// ---------------------------------------------------------------------------
|
|
216 |
//
|
|
217 |
void CServiceWidgetContentPublisher::RegisterWidgetL(const TDesC& aPublisherId,
|
|
218 |
TInt aBitmapHandle,
|
|
219 |
TInt aMaskHandle )
|
|
220 |
{
|
|
221 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::RegisterWidgetL() start") );
|
|
222 |
if( iMsgInterface )
|
|
223 |
{
|
|
224 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL());
|
|
225 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
|
|
226 |
|
|
227 |
TLiwGenericParam type( KType, TLiwVariant( KPublisher ));
|
|
228 |
inparam->AppendL( type );
|
|
229 |
|
|
230 |
CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
|
|
231 |
CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC();
|
|
232 |
CLiwDefaultMap* mapAction = CLiwDefaultMap::NewLC();
|
|
233 |
|
|
234 |
cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
|
|
235 |
cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget ));
|
|
236 |
cpdatamap->InsertL( KContentId, TLiwVariant( KAll ));
|
|
237 |
//Take widget name as "service name"
|
|
238 |
//Give widget name here which will be displayed in HomeScreen Add Content menu
|
|
239 |
datamap->InsertL( KWidgetName, TLiwVariant( aPublisherId.Left( aPublisherId.Length()-KThemeUid().Length() ) ) );
|
|
240 |
datamap->InsertL( KTemplateType, TLiwVariant( KServiceWidget ));
|
|
241 |
|
|
242 |
//To publish logo and widget description
|
|
243 |
HBufC* text = NULL;
|
|
244 |
text = StringLoader::LoadLC( R_QTN_SERVTAB_WIDGET_SERVDESC );
|
|
245 |
datamap->InsertL(KWidgetDesc, TLiwVariant( *text ));
|
|
246 |
CleanupStack::PopAndDestroy(text);//text
|
|
247 |
datamap->InsertL(KWidgetLogo , TLiwVariant( aBitmapHandle ) ); // key - aKey, value - map (stringsMap)
|
|
248 |
// append mask
|
|
249 |
// create mask key for the data item. Format is the image key with the '_mask' postfix.
|
|
250 |
HBufC8* maskResult = HBufC8::NewLC( KWidgetLogo().Length() + KMask().Length() );
|
|
251 |
TPtr8 maskResultPtr = maskResult ->Des();
|
|
252 |
maskResultPtr .Append( KWidgetLogo );
|
|
253 |
maskResultPtr .Append( KMask );
|
|
254 |
datamap->InsertL( maskResultPtr, TLiwVariant( aMaskHandle ) ); // key - aKey, value - map (stringsMap)
|
|
255 |
CleanupStack::PopAndDestroy(maskResult);//maskResult
|
|
256 |
|
|
257 |
cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) );
|
|
258 |
|
|
259 |
mapAction->InsertL(KActive, TLiwVariant(KTriggerMap));
|
|
260 |
mapAction->InsertL(KDeActive, TLiwVariant(KTriggerMap));
|
|
261 |
mapAction->InsertL(KSuspend, TLiwVariant(KTriggerMap));
|
|
262 |
mapAction->InsertL(KInactive, TLiwVariant(KTriggerMap));
|
|
263 |
mapAction->InsertL(KResume, TLiwVariant(KTriggerMap));
|
|
264 |
// this will be called after clicking on widget, and generate "selected" event
|
|
265 |
mapAction->InsertL( KSelected, TLiwVariant( KTriggerMap ) );
|
|
266 |
cpdatamap->InsertL( KActionMap, TLiwVariant(mapAction) );
|
|
267 |
|
|
268 |
TLiwGenericParam textItem( KItem, TLiwVariant( cpdatamap ));
|
|
269 |
inparam->AppendL( textItem );
|
|
270 |
iMsgInterface->ExecuteCmdL( KAdd , *inparam, *outparam);
|
|
271 |
CleanupStack::PopAndDestroy(mapAction);
|
|
272 |
CleanupStack::PopAndDestroy(datamap);
|
|
273 |
CleanupStack::PopAndDestroy(cpdatamap);
|
|
274 |
|
|
275 |
textItem.Reset();
|
|
276 |
outparam->Reset();
|
|
277 |
inparam->Reset();
|
|
278 |
|
|
279 |
// request for active/deactive/suspend/resume notification
|
|
280 |
CLiwDefaultMap* reqFilter = CLiwDefaultMap::NewLC();
|
|
281 |
reqFilter->InsertL(KPublisherId, TLiwVariant( aPublisherId ));
|
|
282 |
reqFilter->InsertL(KContentType, TLiwVariant( KAll ));
|
|
283 |
reqFilter->InsertL( KContentId, TLiwVariant( KAll ));
|
|
284 |
reqFilter->InsertL(KOperation, TLiwVariant(KExecute));
|
|
285 |
|
|
286 |
// fill in input list for RequestNotification command
|
|
287 |
inparam->AppendL(TLiwGenericParam(KType, TLiwVariant(KPublisher)));
|
|
288 |
inparam->AppendL(TLiwGenericParam(KFilter, TLiwVariant(reqFilter)));
|
|
289 |
|
|
290 |
iMsgInterface->ExecuteCmdL( KRequestNotification,
|
|
291 |
*inparam,
|
|
292 |
*outparam,
|
|
293 |
0,
|
|
294 |
this ) ;
|
|
295 |
|
|
296 |
CleanupStack::PopAndDestroy(reqFilter );
|
|
297 |
outparam->Reset();
|
|
298 |
inparam->Reset();
|
|
299 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::RegisterWidgetL() Registered widget %s"), &aPublisherId );
|
|
300 |
}
|
|
301 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::RegisterWidgetL() end") );
|
|
302 |
}
|
|
303 |
|
|
304 |
// ---------------------------------------------------------------------------
|
|
305 |
// CServiceWidgetContentPublisher::UnregisterWidgetL
|
|
306 |
// ---------------------------------------------------------------------------
|
|
307 |
//
|
|
308 |
void CServiceWidgetContentPublisher::UnregisterWidgetL(const TDesC& aPublisherId )
|
|
309 |
{
|
|
310 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidgetL() start") );
|
|
311 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidgetL() ServiceName %S"), &aPublisherId);
|
|
312 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL());
|
|
313 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
|
|
314 |
CLiwDefaultMap* cpdatamap= CLiwDefaultMap::NewLC();
|
|
315 |
|
|
316 |
cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
|
|
317 |
cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget ));
|
|
318 |
cpdatamap->InsertL( KContentId, TLiwVariant( KAll ));
|
|
319 |
// fill in input list for RequestNotification command
|
|
320 |
inparam->AppendL(TLiwGenericParam(KType, TLiwVariant(KPublisher)));
|
|
321 |
inparam->AppendL(TLiwGenericParam(KData, TLiwVariant(cpdatamap)));
|
|
322 |
|
|
323 |
iMsgInterface->ExecuteCmdL(KDelete, *inparam, *outparam, 0, this );
|
|
324 |
|
|
325 |
CleanupStack::PopAndDestroy(cpdatamap);
|
|
326 |
outparam->Reset();
|
|
327 |
inparam->Reset();
|
|
328 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidget() end") );
|
|
329 |
}//end UnregisterWidget
|
|
330 |
|
|
331 |
// ---------------------------------------------------------------------------
|
|
332 |
// CServiceWidgetContentPublisher::UnregisterAllWidgetsL
|
|
333 |
// ---------------------------------------------------------------------------
|
|
334 |
//
|
|
335 |
void CServiceWidgetContentPublisher::UnregisterAllWidgetsL(RArray<TInt>* aServiceArray)
|
|
336 |
{
|
|
337 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() start") );
|
|
338 |
CDesC16ArrayFlat* servicesExisting = new (ELeave) CDesC16ArrayFlat( KSW_LIST_GRANULARITY );
|
|
339 |
CleanupStack::PushL( servicesExisting );
|
|
340 |
if(aServiceArray && aServiceArray->Count() > 0)
|
|
341 |
{
|
|
342 |
CSPSettings* settings = CSPSettings::NewLC();
|
|
343 |
for(TInt i=0; i<aServiceArray->Count();i++)
|
|
344 |
{
|
|
345 |
CSPEntry* entry = CSPEntry::NewLC();
|
|
346 |
settings->FindEntryL( (*aServiceArray)[i], *entry ) ;
|
|
347 |
servicesExisting->AppendL(entry->GetServiceName());
|
|
348 |
CleanupStack::PopAndDestroy(entry);
|
|
349 |
}
|
|
350 |
CleanupStack::PopAndDestroy(settings);
|
|
351 |
}
|
|
352 |
|
|
353 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL());
|
|
354 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
|
|
355 |
CLiwDefaultMap* cpdatamap= CLiwDefaultMap::NewLC();
|
|
356 |
|
|
357 |
cpdatamap->InsertL( KPublisherId, TLiwVariant( KAll ));
|
|
358 |
cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget ));
|
|
359 |
cpdatamap->InsertL( KContentId, TLiwVariant( KAll ));
|
|
360 |
|
|
361 |
// fill in input list for GetList command
|
|
362 |
inparam->AppendL(TLiwGenericParam(KType, TLiwVariant(KPublisher)));
|
|
363 |
inparam->AppendL(TLiwGenericParam(KData, TLiwVariant(cpdatamap)));
|
|
364 |
|
|
365 |
iMsgInterface->ExecuteCmdL(KGetList, *inparam, *outparam, 0, this );
|
|
366 |
CDesC16ArrayFlat* serviceNames = new (ELeave) CDesC16ArrayFlat( KSW_LIST_GRANULARITY );
|
|
367 |
CleanupStack::PushL( serviceNames );
|
|
368 |
|
|
369 |
if(outparam)
|
|
370 |
{
|
|
371 |
TInt pos(0);
|
|
372 |
outparam->FindFirst(pos,KResults);
|
|
373 |
if(pos != KErrNotFound)
|
|
374 |
{
|
|
375 |
HBufC* uidStr = KThemeUid().AllocLC();
|
|
376 |
TLiwVariant variant = (*outparam)[pos].Value();
|
|
377 |
variant.PushL();
|
|
378 |
|
|
379 |
CLiwIterable* iterable = variant.AsIterable();
|
|
380 |
iterable->Reset();
|
|
381 |
|
|
382 |
while ( iterable->NextL( variant ) )
|
|
383 |
{
|
|
384 |
CLiwDefaultMap *map = CLiwDefaultMap::NewLC();
|
|
385 |
variant.Get( *map );
|
|
386 |
if ( map->FindL( KPublisherId, variant) )
|
|
387 |
{
|
|
388 |
if(variant.AsDes().Length() >= KThemeUid().Length())
|
|
389 |
{
|
|
390 |
TPtrC tempUidStr;
|
|
391 |
tempUidStr.Set(variant.AsDes().Right(KThemeUid().Length()));
|
|
392 |
if( 0 == tempUidStr.Compare(uidStr->Des()))
|
|
393 |
{
|
|
394 |
//If publisher id has KThemeUid, then this services is
|
|
395 |
//registered by this component
|
|
396 |
TBool serviceExisting = EFalse;
|
|
397 |
if(servicesExisting && servicesExisting->Count() > 0)
|
|
398 |
{
|
|
399 |
for(TInt i=0; i<servicesExisting->Count(); i++)
|
|
400 |
{
|
|
401 |
TPtrC serviceName;
|
|
402 |
serviceName.Set(variant.AsDes().Left(variant.AsDes().Length()-KThemeUid().Length()));
|
|
403 |
if(serviceName.Compare((*servicesExisting)[i]) == 0)
|
|
404 |
{
|
|
405 |
serviceExisting = ETrue;
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
}
|
|
409 |
}
|
|
410 |
if(!serviceExisting)
|
|
411 |
{
|
|
412 |
serviceNames->AppendL(variant.AsDes());
|
|
413 |
}
|
|
414 |
}
|
|
415 |
}
|
|
416 |
}
|
|
417 |
CleanupStack::PopAndDestroy( map );
|
|
418 |
} //End of while
|
|
419 |
|
|
420 |
CleanupStack::PopAndDestroy( &variant );
|
|
421 |
CleanupStack::PopAndDestroy( uidStr );
|
|
422 |
} //End of if(pos != KErrNotFound)
|
|
423 |
}
|
|
424 |
|
|
425 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL():ServiceCountForDeletion %d"), serviceNames->Count());
|
|
426 |
for(TInt i=0; i<serviceNames->Count();i++)
|
|
427 |
{
|
|
428 |
UnregisterWidgetL((*serviceNames)[i]);
|
|
429 |
}
|
|
430 |
|
|
431 |
CleanupStack::PopAndDestroy(serviceNames);
|
|
432 |
CleanupStack::PopAndDestroy(cpdatamap);
|
|
433 |
CleanupStack::PopAndDestroy(servicesExisting);
|
|
434 |
outparam->Reset();
|
|
435 |
inparam->Reset();
|
|
436 |
|
|
437 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() end") );
|
|
438 |
}
|
|
439 |
|
|
440 |
|
|
441 |
// ---------------------------------------------------------------------------
|
|
442 |
// CServiceWidgetContentPublisher::RemoveWidgetDataL
|
|
443 |
// ---------------------------------------------------------------------------
|
|
444 |
//
|
|
445 |
void CServiceWidgetContentPublisher::RemoveWidgetDataL(const TDesC& aPublisherId, const TDesC& aInstId)
|
|
446 |
{
|
|
447 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::RemoveWidgetData() start") );
|
|
448 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL());
|
|
449 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
|
|
450 |
|
|
451 |
CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
|
|
452 |
|
|
453 |
cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
|
|
454 |
cpdatamap->InsertL( KContentType, TLiwVariant( KAll ));
|
|
455 |
cpdatamap->InsertL( KContentId, TLiwVariant( aInstId ));
|
|
456 |
|
|
457 |
// fill in input list for RequestNotification command
|
|
458 |
inparam->AppendL(TLiwGenericParam(KType, TLiwVariant(KCpData)));
|
|
459 |
inparam->AppendL(TLiwGenericParam(KData, TLiwVariant(cpdatamap)));
|
|
460 |
|
|
461 |
TInt err = KErrNone;
|
|
462 |
// if you have only one combination of publisher,content_type, contenid
|
|
463 |
// then all the items will be remove from your widget
|
|
464 |
TRAP(err,iMsgInterface->ExecuteCmdL( KDelete , *inparam, *outparam, 0 , this));
|
|
465 |
|
|
466 |
CleanupStack::PopAndDestroy( cpdatamap );
|
|
467 |
outparam->Reset();
|
|
468 |
inparam->Reset();
|
|
469 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::RemoveWidgetData() end") );
|
|
470 |
}
|
|
471 |
// ---------------------------------------------------------------------------
|
|
472 |
// CServiceWidgetContentPublisher::PublishDataWithActionL
|
|
473 |
// ---------------------------------------------------------------------------
|
|
474 |
//
|
|
475 |
void CServiceWidgetContentPublisher::PublishDataWithActionL( const TDesC& aPublisherId,
|
|
476 |
const TDesC& aInstId,
|
|
477 |
const TDesC& aOwnTextToAdd,
|
|
478 |
const TDesC& aStatusTextToAdd,
|
|
479 |
TInt aBitmapHandle,
|
|
480 |
TInt aMaskHandle,
|
|
481 |
TInt aSericonbitmapHandle,
|
|
482 |
TInt aSericonmaskHandle
|
|
483 |
)
|
|
484 |
{
|
|
485 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::PublishDataWithActionL() start") );
|
|
486 |
|
|
487 |
CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL());
|
|
488 |
CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
|
|
489 |
inparam->Reset();
|
|
490 |
outparam->Reset();
|
|
491 |
|
|
492 |
if( iMsgInterface )
|
|
493 |
{
|
|
494 |
TLiwGenericParam type( KType,TLiwVariant(KCpData));
|
|
495 |
inparam->AppendL( type );
|
|
496 |
|
|
497 |
CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC();
|
|
498 |
CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC();
|
|
499 |
|
|
500 |
cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId ));
|
|
501 |
cpdatamap->InsertL( KContentType, TLiwVariant( KAll ));
|
|
502 |
cpdatamap->InsertL( KContentId, TLiwVariant( aInstId ));
|
|
503 |
|
|
504 |
//adding data to the map
|
|
505 |
//add service icon data
|
|
506 |
datamap->InsertL(KServiceImageKey , TLiwVariant( aSericonbitmapHandle ) ); // key - aKey, value - map (stringsMap)
|
|
507 |
// append mask
|
|
508 |
// create mask key for the data item. Format is the image key with the '_mask' postfix.
|
|
509 |
HBufC8* maskResult1 = HBufC8::NewLC( KServiceImageKey().Length() + KMask().Length() );
|
|
510 |
TPtr8 maskResultPtr1 = maskResult1 ->Des();
|
|
511 |
maskResultPtr1.Append( KServiceImageKey );
|
|
512 |
maskResultPtr1.Append( KMask );
|
|
513 |
datamap->InsertL( maskResultPtr1, TLiwVariant( aSericonmaskHandle ) ); // key - aKey, value - map (stringsMap)
|
|
514 |
CleanupStack::PopAndDestroy(maskResult1);//maskResult
|
|
515 |
//Add status icon data
|
|
516 |
datamap->InsertL(KStatusIconKey , TLiwVariant( aBitmapHandle ) ); // key - aKey, value - map (stringsMap)
|
|
517 |
// append mask
|
|
518 |
// create mask key for the data item. Format is the image key with the '_mask' postfix.
|
|
519 |
HBufC8* maskResult = HBufC8::NewLC( KStatusIconKey().Length() + KMask().Length() );
|
|
520 |
TPtr8 maskResultPtr = maskResult ->Des();
|
|
521 |
maskResultPtr .Append( KStatusIconKey );
|
|
522 |
maskResultPtr .Append( KMask );
|
|
523 |
datamap->InsertL( maskResultPtr, TLiwVariant( aMaskHandle ) ); // key - aKey, value - map (stringsMap)
|
|
524 |
CleanupStack::PopAndDestroy(maskResult);//maskResult
|
|
525 |
//add data for first text row and second text row
|
|
526 |
datamap->InsertL(KOwnTextKey, TLiwVariant(aOwnTextToAdd));
|
|
527 |
datamap->InsertL(KMessageTextKey, TLiwVariant(aStatusTextToAdd));
|
|
528 |
cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) );
|
|
529 |
|
|
530 |
TLiwGenericParam item( KItem, TLiwVariant( cpdatamap ));
|
|
531 |
inparam->AppendL( item );
|
|
532 |
iMsgInterface->ExecuteCmdL( KAdd, *inparam, *outparam );
|
|
533 |
item.Reset();
|
|
534 |
type.Reset();
|
|
535 |
CleanupStack::PopAndDestroy(datamap); // datamap
|
|
536 |
CleanupStack::PopAndDestroy(cpdatamap);
|
|
537 |
TRACE_SWP(TXT("CServiceWidgetContentPublisher::PublishDataWithActionL() success") );
|
|
538 |
}
|
|
539 |
}
|
|
540 |
|
|
541 |
// end of file
|