servicewidget/servicewidgetdatapublisher/src/cservicewidgetcontentpublisher.cpp
branchRCL_3
changeset 13 76f25fb7a6a1
parent 12 36d367c62acb
equal deleted inserted replaced
12:36d367c62acb 13:76f25fb7a6a1
    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 #include <spsettings.h> 
       
    34 #include <spentry.h>
    32 
    35 
    33 #define KSW_LIST_GRANULARITY 8
    36 #define KSW_LIST_GRANULARITY 8
    34 
    37 
    35 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    36 // CServiceWidgetContentPublisher::CServiceWidgetContentPublisher
    39 // CServiceWidgetContentPublisher::CServiceWidgetContentPublisher
   327 
   330 
   328 // ---------------------------------------------------------------------------
   331 // ---------------------------------------------------------------------------
   329 // CServiceWidgetContentPublisher::UnregisterAllWidgetsL
   332 // CServiceWidgetContentPublisher::UnregisterAllWidgetsL
   330 // ---------------------------------------------------------------------------
   333 // ---------------------------------------------------------------------------
   331 //
   334 //
   332 void CServiceWidgetContentPublisher::UnregisterAllWidgetsL()
   335 void CServiceWidgetContentPublisher::UnregisterAllWidgetsL(RArray<TInt>* aServiceArray)
   333     {
   336     {
   334     TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() start") );
   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     	}
   335     
   352     
   336     CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); 
   353     CLiwGenericParamList* inparam = &(iServiceHandler->InParamListL()); 
   337     CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
   354     CLiwGenericParamList* outparam = &(iServiceHandler->OutParamListL());
   338     CLiwDefaultMap*  cpdatamap= CLiwDefaultMap::NewLC();    
   355     CLiwDefaultMap*  cpdatamap= CLiwDefaultMap::NewLC();    
   339 
   356 
   349     CDesC16ArrayFlat* serviceNames = new (ELeave) CDesC16ArrayFlat( KSW_LIST_GRANULARITY );
   366     CDesC16ArrayFlat* serviceNames = new (ELeave) CDesC16ArrayFlat( KSW_LIST_GRANULARITY );
   350     CleanupStack::PushL( serviceNames );
   367     CleanupStack::PushL( serviceNames );
   351     
   368     
   352     if(outparam)
   369     if(outparam)
   353 		{		
   370 		{		
   354 		TInt pos(0);
   371 		TInt pos(0);		
   355 		const TLiwGenericParam* param = NULL;
   372 		outparam->FindFirst(pos,KResults);
   356 		param = outparam->FindFirst(pos,KResults);
       
   357 		if(pos != KErrNotFound)
   373 		if(pos != KErrNotFound)
   358 			{
   374 			{
   359 			HBufC* uidStr = KThemeUid().AllocLC();
   375 			HBufC* uidStr = KThemeUid().AllocLC();
   360 			TLiwVariant variant = (*outparam)[pos].Value();
   376 			TLiwVariant variant = (*outparam)[pos].Value();
   361 			variant.PushL();
   377 			variant.PushL();
   375 					  tempUidStr.Set(variant.AsDes().Right(KThemeUid().Length()));
   391 					  tempUidStr.Set(variant.AsDes().Right(KThemeUid().Length()));
   376 					  if( 0 == tempUidStr.Compare(uidStr->Des()))
   392 					  if( 0 == tempUidStr.Compare(uidStr->Des()))
   377 						  {
   393 						  {
   378 						  //If publisher id has KThemeUid, then this services is 
   394 						  //If publisher id has KThemeUid, then this services is 
   379 						  //registered by this component
   395 						  //registered by this component
   380 						  serviceNames->AppendL(variant.AsDes());
   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 							  }
   381 						  }
   414 						  }
   382 					  }
   415 					  }
   383 				  }
   416 				  }
   384 				  CleanupStack::PopAndDestroy( map );
   417 				  CleanupStack::PopAndDestroy( map );
   385 				 } //End of while
   418 				 } //End of while
   394 		{		
   427 		{		
   395 		UnregisterWidgetL((*serviceNames)[i]);
   428 		UnregisterWidgetL((*serviceNames)[i]);
   396 		}
   429 		}
   397     
   430     
   398     CleanupStack::PopAndDestroy(serviceNames);
   431     CleanupStack::PopAndDestroy(serviceNames);
   399     CleanupStack::PopAndDestroy(cpdatamap);      
   432     CleanupStack::PopAndDestroy(cpdatamap);
       
   433     CleanupStack::PopAndDestroy(servicesExisting);
   400     outparam->Reset();
   434     outparam->Reset();
   401     inparam->Reset();
   435     inparam->Reset();
   402     
   436     
   403     TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() end") );
   437     TRACE_SWP(TXT("CServiceWidgetContentPublisher::UnregisterAllWidgetsL() end") );
   404     }
   438     }