homescreensrv_plat/hs_widget_publisher_api/src/hswidgetpublisherimpl.cpp
branchRCL_3
changeset 27 2c7f27287390
parent 23 ace62b58f4b2
equal deleted inserted replaced
25:9e077f9a342c 27:2c7f27287390
    81 //
    81 //
    82 HsWidget& HsWidgetPublisherImpl::CreateWidget( std::string& aTemplateName, 
    82 HsWidget& HsWidgetPublisherImpl::CreateWidget( std::string& aTemplateName, 
    83 	std::string& aWidgetName, std::string& aIdentifier,
    83 	std::string& aWidgetName, std::string& aIdentifier,
    84 	std::string& aDescription, std::string& aIconLocation)
    84 	std::string& aDescription, std::string& aIconLocation)
    85 	{
    85 	{
       
    86     aTemplateName = TemplateName( aTemplateName );
    86 	if( CheckIfWidgetExist( aTemplateName, aWidgetName, aIdentifier, EFalse ) )
    87 	if( CheckIfWidgetExist( aTemplateName, aWidgetName, aIdentifier, EFalse ) )
    87 		{
    88 		{
    88 		throw HsException( KErrAlreadyExists );
    89 		throw HsException( KErrAlreadyExists );
    89 		}
    90 		}
    90 	HsWidget* widget= new HsWidget( aTemplateName, aWidgetName, 
    91 	HsWidget* widget= new HsWidget( aTemplateName, aWidgetName, 
   541 //
   542 //
   542 void HsWidgetPublisherImpl::RemoveWidget( std::string& aTemplateName, 
   543 void HsWidgetPublisherImpl::RemoveWidget( std::string& aTemplateName, 
   543 	std::string& aWidgetName,
   544 	std::string& aWidgetName,
   544 	std::string& aIdentifier )
   545 	std::string& aIdentifier )
   545 	{
   546 	{
       
   547     aTemplateName = TemplateName( aTemplateName );
   546 	HsWidget* ret( 0 );
   548 	HsWidget* ret( 0 );
   547 	int count = mWidgets.size();
   549 	int count = mWidgets.size();
   548 	for (int index = 0; index < count; index++)
   550 	for (int index = 0; index < count; index++)
   549 		{
   551 		{
   550 		HsWidget* const widget = mWidgets.at( index );
   552 		HsWidget* const widget = mWidgets.at( index );
   635 //
   637 //
   636 HsWidget& HsWidgetPublisherImpl::GetWidget( std::string& aTemplateName, 
   638 HsWidget& HsWidgetPublisherImpl::GetWidget( std::string& aTemplateName, 
   637 	std::string& aWidgetName,
   639 	std::string& aWidgetName,
   638 	std::string& aIdentifier )
   640 	std::string& aIdentifier )
   639 	{
   641 	{
       
   642     aTemplateName = TemplateName( aTemplateName );
   640 	HsWidget* ret( 0 );
   643 	HsWidget* ret( 0 );
   641 	int count = mWidgets.size();
   644 	int count = mWidgets.size();
   642 	for (int index = 0; index < count; index++)
   645 	for (int index = 0; index < count; index++)
   643 		{
   646 		{
   644 		HsWidget* const widget = mWidgets.at( index );
   647 		HsWidget* const widget = mWidgets.at( index );
   814 //
   817 //
   815 void HsWidgetPublisherImpl::InsertWidgetInfoL( HsWidget& aWidget,
   818 void HsWidgetPublisherImpl::InsertWidgetInfoL( HsWidget& aWidget,
   816 	CLiwDefaultMap* aDataMap )
   819 	CLiwDefaultMap* aDataMap )
   817     {
   820     {
   818     __ASSERT_ALWAYS( aDataMap, User::Invariant() );
   821     __ASSERT_ALWAYS( aDataMap, User::Invariant() );
   819 
   822     HBufC* templateType = StdStringToUnicodeLC( TemplateName (aWidget.getTemplateName()) );
   820     HBufC* templateType = StdStringToUnicodeLC( aWidget.getTemplateName() );
       
   821     HBufC* widgetName = StdStringToUnicodeLC( aWidget.getWidgetName() );
   823     HBufC* widgetName = StdStringToUnicodeLC( aWidget.getWidgetName() );
   822 	    
   824 	    
   823 	aDataMap->InsertL( KTemplateType, TLiwVariant( *templateType ) );
   825 	aDataMap->InsertL( KTemplateType, TLiwVariant( *templateType ) );
   824 	aDataMap->InsertL( KWidgetName, TLiwVariant( *widgetName ) );
   826 	aDataMap->InsertL( KWidgetName, TLiwVariant( *widgetName ) );
   825     aDataMap->InsertL( KWidgetMaxInstance, TLiwVariant( 1 ) );
   827     aDataMap->InsertL( KWidgetMaxInstance, TLiwVariant( 1 ) );
  1084     {
  1086     {
  1085     TPtrC8 srcDescriptor = reinterpret_cast<const TUint8*>(
  1087     TPtrC8 srcDescriptor = reinterpret_cast<const TUint8*>(
  1086             aSrcString.c_str() );
  1088             aSrcString.c_str() );
  1087     return Utf8ToUnicodeLC( srcDescriptor );
  1089     return Utf8ToUnicodeLC( srcDescriptor );
  1088     }
  1090     }
       
  1091 
       
  1092 // ---------------------------------------------------------------------------
       
  1093 // 
       
  1094 // ---------------------------------------------------------------------------
       
  1095 //
       
  1096 std::string HsWidgetPublisherImpl::TemplateName(const std::string &aSrcTemplate)
       
  1097     {
       
  1098     // In 9.2 HS wideimage template is reserved for wrt and cwrt widget.
       
  1099     // to support backward(5.0) compatability posterwideimage template 
       
  1100     // will be usedfor wideimage template
       
  1101     if (aSrcTemplate == std::string("wideimage") )
       
  1102         {
       
  1103         return std::string("posterwideimage");
       
  1104         }
       
  1105     return aSrcTemplate;
       
  1106     }