27 |
27 |
28 #include <liwcommon.h> |
28 #include <liwcommon.h> |
29 #include "servicewidgetcpglobals.h" |
29 #include "servicewidgetcpglobals.h" |
30 #include <servicewidgetpluginres.rsg> |
30 #include <servicewidgetpluginres.rsg> |
31 #include <StringLoader.h> |
31 #include <StringLoader.h> |
|
32 |
|
33 #define KSW_LIST_GRANULARITY 8 |
32 |
34 |
33 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
34 // CServiceWidgetContentPublisher::CServiceWidgetContentPublisher |
36 // CServiceWidgetContentPublisher::CServiceWidgetContentPublisher |
35 // --------------------------------------------------------------------------- |
37 // --------------------------------------------------------------------------- |
36 // |
38 // |
228 |
230 |
229 cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId )); |
231 cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId )); |
230 cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget )); |
232 cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget )); |
231 cpdatamap->InsertL( KContentId, TLiwVariant( KAll )); |
233 cpdatamap->InsertL( KContentId, TLiwVariant( KAll )); |
232 //Take widget name as "service name" |
234 //Take widget name as "service name" |
233 //Give widget name here which will be displayed in HomeScreen Add Content menu |
235 //Give widget name here which will be displayed in HomeScreen Add Content menu |
234 datamap->InsertL( KWidgetName, TLiwVariant( aPublisherId )); |
236 datamap->InsertL( KWidgetName, TLiwVariant( aPublisherId.Left( aPublisherId.Length()-KThemeUid().Length() ) ) ); |
235 datamap->InsertL( KTemplateType, TLiwVariant( KServiceWidget )); |
237 datamap->InsertL( KTemplateType, TLiwVariant( KServiceWidget )); |
236 |
238 |
237 //To publish logo and widget description |
239 //To publish logo and widget description |
238 HBufC* text = NULL; |
240 HBufC* text = NULL; |
239 text = StringLoader::LoadLC( R_QTN_SERVTAB_WIDGET_SERVDESC ); |
241 text = StringLoader::LoadLC( R_QTN_SERVTAB_WIDGET_SERVDESC ); |
300 // CServiceWidgetContentPublisher::UnregisterWidgetL |
302 // CServiceWidgetContentPublisher::UnregisterWidgetL |
301 // --------------------------------------------------------------------------- |
303 // --------------------------------------------------------------------------- |
302 // |
304 // |
303 void CServiceWidgetContentPublisher::UnregisterWidgetL(const TDesC& aPublisherId ) |
305 void CServiceWidgetContentPublisher::UnregisterWidgetL(const TDesC& aPublisherId ) |
304 { |
306 { |
305 TRACE_SWP(TXT("CServiceWidgetContentPublisher::RegisterForObserverL() start") ); |
307 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidgetL() start") ); |
306 |
308 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidgetL() ServiceName %S"), &aPublisherId); |
307 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
309 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
308 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
310 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
309 CLiwDefaultMap* cpdatamap= CLiwDefaultMap::NewLC(); |
311 CLiwDefaultMap* cpdatamap= CLiwDefaultMap::NewLC(); |
310 |
312 |
311 cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId )); |
313 cpdatamap->InsertL( KPublisherId, TLiwVariant( aPublisherId )); |
320 CleanupStack::PopAndDestroy(cpdatamap); |
322 CleanupStack::PopAndDestroy(cpdatamap); |
321 outparam->Reset(); |
323 outparam->Reset(); |
322 inparam->Reset(); |
324 inparam->Reset(); |
323 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidget() end") ); |
325 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterWidget() end") ); |
324 }//end UnregisterWidget |
326 }//end UnregisterWidget |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CServiceWidgetContentPublisher::UnregisterAllWidgetsL |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 void CServiceWidgetContentPublisher::UnregisterAllWidgetsL() |
|
333 { |
|
334 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() start") ); |
|
335 |
|
336 CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); |
|
337 CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL()); |
|
338 CLiwDefaultMap* cpdatamap= CLiwDefaultMap::NewLC(); |
|
339 |
|
340 cpdatamap->InsertL( KPublisherId, TLiwVariant( KAll )); |
|
341 cpdatamap->InsertL( KContentType, TLiwVariant( KTemplateWidget )); |
|
342 cpdatamap->InsertL( KContentId, TLiwVariant( KAll )); |
|
343 |
|
344 // fill in input list for GetList command |
|
345 inparam->AppendL(TLiwGenericParam(KType, TLiwVariant(KPublisher))); |
|
346 inparam->AppendL(TLiwGenericParam(KData, TLiwVariant(cpdatamap))); |
|
347 |
|
348 iMsgInterface->ExecuteCmdL(KGetList, *inparam, *outparam, 0, this ); |
|
349 CDesC16ArrayFlat* serviceNames = new (ELeave) CDesC16ArrayFlat( KSW_LIST_GRANULARITY ); |
|
350 CleanupStack::PushL( serviceNames ); |
|
351 |
|
352 if(outparam) |
|
353 { |
|
354 TInt pos(0); |
|
355 const TLiwGenericParam* param = NULL; |
|
356 param = outparam->FindFirst(pos,KResults); |
|
357 if(pos != KErrNotFound) |
|
358 { |
|
359 HBufC* uidStr = KThemeUid().AllocLC(); |
|
360 TLiwVariant variant = (*outparam)[pos].Value(); |
|
361 variant.PushL(); |
|
362 |
|
363 CLiwIterable* iterable = variant.AsIterable(); |
|
364 iterable->Reset(); |
|
365 |
|
366 while ( iterable->NextL( variant ) ) |
|
367 { |
|
368 CLiwDefaultMap *map = CLiwDefaultMap::NewLC(); |
|
369 variant.Get( *map ); |
|
370 if ( map->FindL( KPublisherId, variant) ) |
|
371 { |
|
372 if(variant.AsDes().Length() >= KThemeUid().Length()) |
|
373 { |
|
374 TPtrC tempUidStr; |
|
375 tempUidStr.Set(variant.AsDes().Right(KThemeUid().Length())); |
|
376 if( 0 == tempUidStr.Compare(uidStr->Des())) |
|
377 { |
|
378 //If publisher id has KThemeUid, then this services is |
|
379 //registered by this component |
|
380 serviceNames->AppendL(variant.AsDes()); |
|
381 } |
|
382 } |
|
383 } |
|
384 CleanupStack::PopAndDestroy( map ); |
|
385 } //End of while |
|
386 |
|
387 CleanupStack::PopAndDestroy( &variant ); |
|
388 CleanupStack::PopAndDestroy( uidStr ); |
|
389 } //End of if(pos != KErrNotFound) |
|
390 } |
|
391 |
|
392 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL():ServiceCountForDeletion %d"), serviceNames->Count()); |
|
393 for(TInt i=0; i<serviceNames->Count();i++) |
|
394 { |
|
395 UnregisterWidgetL((*serviceNames)[i]); |
|
396 } |
|
397 |
|
398 CleanupStack::PopAndDestroy(serviceNames); |
|
399 CleanupStack::PopAndDestroy(cpdatamap); |
|
400 outparam->Reset(); |
|
401 inparam->Reset(); |
|
402 |
|
403 TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() end") ); |
|
404 } |
|
405 |
325 |
406 |
326 // --------------------------------------------------------------------------- |
407 // --------------------------------------------------------------------------- |
327 // CServiceWidgetContentPublisher::RemoveWidgetDataL |
408 // CServiceWidgetContentPublisher::RemoveWidgetDataL |
328 // --------------------------------------------------------------------------- |
409 // --------------------------------------------------------------------------- |
329 // |
410 // |