idlehomescreen/widgetmanager/src/wmconfiguration.cpp
changeset 4 4d54b72983ae
parent 2 08c6ee43b396
child 9 f966699dea19
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
    25 #include <widgetmanager.mbg>
    25 #include <widgetmanager.mbg>
    26 #include "wmconfiguration.h"
    26 #include "wmconfiguration.h"
    27 #include "wmresourceloader.h"
    27 #include "wmresourceloader.h"
    28 #include "wmcrkeys.h"
    28 #include "wmcrkeys.h"
    29 
    29 
    30 // CONSTANTS
    30 // some constants regarging the central repository localised section.
    31 const TInt KMaxIconDescriptorLength = 256;
    31 // these will ensure CR localisation section compatibility even if
       
    32 // new strings are added
       
    33 const TInt KLangOffsetOviStoreUrl = KOviStoreBrowserUrl0 - KLangId0;
       
    34 const TInt KLangOffsetOperatorUrl = KOperatorButtonUrl0 - KLangId0;
       
    35 const TInt KLangOffsetOperatorText = KOperatorButtonText0 - KLangId0;
       
    36 const TInt KLangGroupSize = KLangId1 - KLangId0;
       
    37 const TUint32 KLastLangId = KLangId9;
       
    38 
    32 
    39 
    33 // ---------------------------------------------------------
    40 // ---------------------------------------------------------
    34 // CWmConfiguration::NewL
    41 // CWmConfiguration::NewL
    35 // ---------------------------------------------------------
    42 // ---------------------------------------------------------
    36 //
    43 //
    50 //
    57 //
    51 CWmConfiguration::CWmConfiguration(
    58 CWmConfiguration::CWmConfiguration(
    52         CWmResourceLoader& aResourceLoader )
    59         CWmResourceLoader& aResourceLoader )
    53     : iResourceLoader( aResourceLoader )
    60     : iResourceLoader( aResourceLoader )
    54 	{
    61 	{
    55     iOviStoreText = NULL;
    62     iRepository = NULL;
    56     iOviStoreIcon = NULL;
    63     iOviStoreBundleId = NULL;
    57 	iRepository = NULL;
    64     iOviStoreClientParam = NULL;
    58 	iOviStoreBundleId = NULL;
    65     iOviButtonTitle = NULL;
    59 	iOviStoreClientParam = NULL;
    66     iOviButtonIcon = NULL;
    60     iOviStoreUrl = NULL;
    67     iOviButtonUrl = NULL;
       
    68     iOperatorButtonTitle = NULL;
       
    69     iOperatorButtonIcon = NULL;
       
    70     iOperatorButtonUrl = NULL;
    61 	}
    71 	}
    62 
    72 
    63 // ---------------------------------------------------------
    73 // ---------------------------------------------------------
    64 // CWmConfiguration::~CWmConfiguration()
    74 // CWmConfiguration::~CWmConfiguration()
    65 // ---------------------------------------------------------
    75 // ---------------------------------------------------------
    66 //
    76 //
    67 CWmConfiguration::~CWmConfiguration()
    77 CWmConfiguration::~CWmConfiguration()
    68 	{
    78 	{
    69     delete iOviStoreText;
    79     delete iRepository;
    70     delete iOviStoreIcon;
       
    71 	delete iRepository;
       
    72     delete iOviStoreBundleId;
    80     delete iOviStoreBundleId;
    73     delete iOviStoreClientParam;
    81     delete iOviStoreClientParam;
    74     delete iOviStoreUrl;
    82     delete iOviButtonTitle;
       
    83     delete iOviButtonIcon;
       
    84     delete iOviButtonUrl;
       
    85     delete iOperatorButtonTitle;
       
    86     delete iOperatorButtonIcon;
       
    87     delete iOperatorButtonUrl;
    75 	}
    88 	}
    76 
    89 
    77 // ---------------------------------------------------------
    90 // ---------------------------------------------------------
    78 // CWmConfiguration::ConstructL
    91 // CWmConfiguration::ConstructL
    79 // ---------------------------------------------------------
    92 // ---------------------------------------------------------
    80 //
    93 //
    81 void CWmConfiguration::ConstructL()
    94 void CWmConfiguration::ConstructL()
    82 	{
    95 	{
    83 	// localised ovistore button text
    96 	// localised ovistore button text
    84     iOviStoreText = StringLoader::LoadL( R_QTN_WM_GO_TO_OVI_STORE );
    97     iOviButtonTitle = StringLoader::LoadL( R_QTN_WM_GO_TO_OVI_STORE );
    85 
    98 
    86     // ovistore icon descriptor. It will look something like this:
    99     // ovistore icon descriptor. It will look something like this:
    87     // skin( 0x101f86e3 0x23f6 ):mif( z:\resource\apps\widgetmanager.mif 16388 16389 )
   100     // skin( 0x101f86e3 0x23f6 ):mif( z:\resource\apps\widgetmanager.mif 16388 16389 )
       
   101     _LIT( KSkinMifIconFormat, "skin( 0x%x 0x%x ):mif( %S %d %d )");
       
   102     const TInt KMaxIconDescriptorLength = 256;
    88     TBuf<KMaxIconDescriptorLength> buf;
   103     TBuf<KMaxIconDescriptorLength> buf;
    89     _LIT( KSkinMifIconFormat, "skin( 0x%x 0x%x ):mif( %S %d %d )");
       
    90     buf.Format( KSkinMifIconFormat(),
   104     buf.Format( KSkinMifIconFormat(),
    91              EAknsMajorGeneric, EAknsMinorGenericQgnMenuOviStore,
   105              EAknsMajorGeneric, EAknsMinorGenericQgnMenuOviStore,
    92              &iResourceLoader.IconFilePath(),
   106              &iResourceLoader.IconFilePath(),
    93              EMbmWidgetmanagerQgn_menu_ovistore,
   107              EMbmWidgetmanagerQgn_menu_ovistore,
    94              EMbmWidgetmanagerQgn_menu_ovistore_mask );
   108              EMbmWidgetmanagerQgn_menu_ovistore_mask );
    95     iOviStoreIcon = buf.AllocL();
   109     iOviButtonIcon = buf.AllocL();
    96 
   110 
    97     // read data from repository
   111     // read data from repository
    98     TRAP_IGNORE(
   112     TRAP_IGNORE( LoadConfigurationL(); );
    99         iRepository = CRepository::NewL( 
   113 
   100                 TUid::Uid( KCrWidgetManagerm ) );
       
   101     
       
   102         iLanguageIndex = FindCorrectLanguageId();
       
   103         iOviStoreBundleId = ReadParameterL( KOviStoreBunbleId );
       
   104         iOviStoreClientParam = ReadParameterL( KOviStoreClientParam );
       
   105         iOviStoreUrl = ReadLocalisedParameterL( KOviStoreBrowserUrlOffset );
       
   106         );
       
   107 	}
   114 	}
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CWmConfiguration::LoadConfigurationL
       
   118 // ---------------------------------------------------------
       
   119 //
       
   120 void CWmConfiguration::LoadConfigurationL()
       
   121     {
       
   122     iRepository = CRepository::NewL( 
       
   123             TUid::Uid( KCrWidgetManagerm ) );
       
   124 
       
   125     // read fixed parameters
       
   126     iOviStoreBundleId = ReadParameterL( KOviStoreBundleId );
       
   127     iOviStoreClientParam = ReadParameterL( KOviStoreClientParam );
       
   128     // determine language and read localised parameters
       
   129     iLanguageIndex = FindCorrectLanguageId();
       
   130     iOviButtonUrl = ReadLocalisedParameterL( KLangOffsetOviStoreUrl );
       
   131     iOperatorButtonTitle = ReadLocalisedParameterL( KLangOffsetOperatorText );
       
   132     iOperatorButtonUrl = ReadLocalisedParameterL( KLangOffsetOperatorUrl );
       
   133 
       
   134     if ( iOperatorButtonUrl && iOperatorButtonUrl->Length() > 0 )
       
   135         {
       
   136         // construct the operator button icon.
       
   137         iOperatorButtonIcon = ReadParameterL( KOperatorButtonIcon );
       
   138         }
       
   139 
       
   140     delete iRepository;
       
   141     iRepository = NULL;
       
   142     }
   108 
   143 
   109 // ---------------------------------------------------------
   144 // ---------------------------------------------------------
   110 // CWmConfiguration::FindCorrectLanguageId
   145 // CWmConfiguration::FindCorrectLanguageId
   111 // ---------------------------------------------------------
   146 // ---------------------------------------------------------
   112 //
   147 //
   116     TInt englishIndex = KErrNotFound; // english
   151     TInt englishIndex = KErrNotFound; // english
   117     TInt anyIndex = KErrNotFound; // backup - any existing
   152     TInt anyIndex = KErrNotFound; // backup - any existing
   118     TLanguage sysLang = User::Language();
   153     TLanguage sysLang = User::Language();
   119     
   154     
   120     //read language id's from cenrep, find a match
   155     //read language id's from cenrep, find a match
   121     for( TUint32 i=KLangId0; i<=KLangId9 && languageIndex<0; i+=KLangGroupSize )
   156     for( TUint32 i=KLangId0; i<=KLastLangId && languageIndex<0; i+=KLangGroupSize )
   122         {
   157         {
   123         TInt crLang = 0;
   158         TInt crLang = 0;
   124         if ( iRepository->Get( i, crLang ) == KErrNone )
   159         if ( iRepository->Get( i, crLang ) == KErrNone )
   125             {
   160             {
   126             if ( crLang == sysLang && languageIndex < 0 )
   161             if ( crLang == sysLang && languageIndex < 0 )
   189 // ---------------------------------------------------------
   224 // ---------------------------------------------------------
   190 // CWmConfiguration::PortalButtonCount
   225 // CWmConfiguration::PortalButtonCount
   191 // ---------------------------------------------------------
   226 // ---------------------------------------------------------
   192 //
   227 //
   193 TInt CWmConfiguration::PortalButtonCount()
   228 TInt CWmConfiguration::PortalButtonCount()
   194 	{
   229     {
   195 	return 1;
   230     if ( iOperatorButtonUrl && iOperatorButtonUrl->Length() > 0 )
   196 	}
   231         return 2;
       
   232     return 1;
       
   233     }
   197 
   234 
   198 // ---------------------------------------------------------
   235 // ---------------------------------------------------------
   199 // CWmConfiguration::PortalButtonText
   236 // CWmConfiguration::PortalButtonText
   200 // ---------------------------------------------------------
   237 // ---------------------------------------------------------
   201 //
   238 //
   202 const TDesC& CWmConfiguration::PortalButtonText( TInt aIndex )
   239 const TDesC& CWmConfiguration::PortalButtonText( TInt aIndex )
   203     {
   240     {
   204     if ( aIndex == 0 && iOviStoreText ) return *iOviStoreText;
   241     IndexConversion( aIndex );
       
   242     if ( aIndex == 0 && iOviButtonTitle )
       
   243         return *iOviButtonTitle;
       
   244     if ( aIndex == 1 && iOperatorButtonTitle )
       
   245         return *iOperatorButtonTitle;
   205     return KNullDesC;
   246     return KNullDesC;
   206     }
   247     }
   207 
   248 
   208 // ---------------------------------------------------------
   249 // ---------------------------------------------------------
   209 // CWmConfiguration::PortalButtonIcon
   250 // CWmConfiguration::PortalButtonIcon
   210 // ---------------------------------------------------------
   251 // ---------------------------------------------------------
   211 //
   252 //
   212 const TDesC& CWmConfiguration::PortalButtonIcon( TInt aIndex )
   253 const TDesC& CWmConfiguration::PortalButtonIcon( TInt aIndex )
   213     {
   254     {
   214     if ( aIndex == 0 && iOviStoreIcon ) return *iOviStoreIcon;
   255     IndexConversion( aIndex );
   215     return KNullDesC;
   256     if ( aIndex == 0 && iOviButtonIcon )
   216     }
   257         return *iOviButtonIcon;
   217 
   258     if ( aIndex == 1 && iOperatorButtonIcon )
   218 // ---------------------------------------------------------
   259         return *iOperatorButtonIcon;
   219 // CWmConfiguration::PortalButtonBundleId
   260     return KNullDesC;
   220 // ---------------------------------------------------------
   261     }
   221 //
       
   222 const TDesC&
       
   223     CWmConfiguration::PortalButtonBundleId( TInt aIndex )
       
   224     {
       
   225     if ( aIndex == 0 && iOviStoreBundleId ) return *iOviStoreBundleId;
       
   226     return KNullDesC;
       
   227     }
       
   228 
       
   229 
   262 
   230 // ---------------------------------------------------------
   263 // ---------------------------------------------------------
   231 // CWmConfiguration::PortalButtonPrimaryMethod
   264 // CWmConfiguration::PortalButtonPrimaryMethod
   232 // ---------------------------------------------------------
   265 // ---------------------------------------------------------
   233 //
   266 //
   234 CWmConfiguration::TMethod
   267 CWmConfiguration::TMethod
   235     CWmConfiguration::PortalButtonPrimaryMethod( TInt aIndex )
   268     CWmConfiguration::PortalButtonPrimaryMethod( TInt aIndex )
   236     {
   269     {
   237     if ( aIndex == 0 && iOviStoreClientParam ) return EWidget;
   270     IndexConversion( aIndex );
       
   271     if ( aIndex == 0 && iOviStoreBundleId && iOviStoreBundleId->Length() > 0 )
       
   272         return EWidget;
       
   273     if ( aIndex == 1 && iOperatorButtonUrl && iOperatorButtonUrl->Length() > 0 )
       
   274         return EHttp;
   238     return ENone;
   275     return ENone;
       
   276     }
       
   277 
       
   278 // ---------------------------------------------------------
       
   279 // CWmConfiguration::PortalButtonPrimaryService
       
   280 // ---------------------------------------------------------
       
   281 //
       
   282 const TDesC&
       
   283     CWmConfiguration::PortalButtonPrimaryService( TInt aIndex )
       
   284     {
       
   285     IndexConversion( aIndex );
       
   286     if ( aIndex == 0 && iOviStoreBundleId && iOviStoreBundleId->Length() > 0 )
       
   287         return *iOviStoreBundleId;
       
   288     return KNullDesC;
   239     }
   289     }
   240 
   290 
   241 // ---------------------------------------------------------
   291 // ---------------------------------------------------------
   242 // CWmConfiguration::PortalButtonPrimaryParams
   292 // CWmConfiguration::PortalButtonPrimaryParams
   243 // ---------------------------------------------------------
   293 // ---------------------------------------------------------
   244 //
   294 //
   245 const TDesC&
   295 const TDesC&
   246     CWmConfiguration::PortalButtonPrimaryParams( TInt aIndex )
   296     CWmConfiguration::PortalButtonPrimaryParams( TInt aIndex )
   247     {
   297     {
   248     if ( aIndex == 0 && iOviStoreClientParam ) return *iOviStoreClientParam;
   298     IndexConversion( aIndex );
       
   299     if ( aIndex == 0 && iOviStoreClientParam )
       
   300         return *iOviStoreClientParam;
       
   301     if ( aIndex == 1 && iOperatorButtonUrl )
       
   302         return *iOperatorButtonUrl;
   249     return KNullDesC;
   303     return KNullDesC;
   250     }
   304     }
   251 
   305 
   252 
   306 
   253 // ---------------------------------------------------------
   307 // ---------------------------------------------------------
   255 // ---------------------------------------------------------
   309 // ---------------------------------------------------------
   256 //
   310 //
   257 CWmConfiguration::TMethod
   311 CWmConfiguration::TMethod
   258     CWmConfiguration::PortalButtonSecondaryMethod( TInt aIndex )
   312     CWmConfiguration::PortalButtonSecondaryMethod( TInt aIndex )
   259     {
   313     {
   260     if ( aIndex == 0 && iOviStoreUrl ) return EHttp;
   314     IndexConversion( aIndex );
       
   315     if ( aIndex == 0 && iOviButtonUrl && iOviButtonUrl->Length() > 0 )
       
   316         return EHttp;
   261     return ENone;
   317     return ENone;
       
   318     }
       
   319 
       
   320 // ---------------------------------------------------------
       
   321 // CWmConfiguration::PortalButtonSecondaryService
       
   322 // ---------------------------------------------------------
       
   323 //
       
   324 const TDesC&
       
   325     CWmConfiguration::PortalButtonSecondaryService( TInt aIndex )
       
   326     {
       
   327     IndexConversion( aIndex );
       
   328     return KNullDesC;
   262     }
   329     }
   263 
   330 
   264 // ---------------------------------------------------------
   331 // ---------------------------------------------------------
   265 // CWmConfiguration::PortalButtonSecondaryParams
   332 // CWmConfiguration::PortalButtonSecondaryParams
   266 // ---------------------------------------------------------
   333 // ---------------------------------------------------------
   267 //
   334 //
   268 const TDesC&
   335 const TDesC&
   269     CWmConfiguration::PortalButtonSecondaryParams( TInt aIndex )
   336     CWmConfiguration::PortalButtonSecondaryParams( TInt aIndex )
   270     {
   337     {
   271     if ( aIndex == 0 && iOviStoreUrl ) return *iOviStoreUrl;
   338     IndexConversion( aIndex );
   272     return KNullDesC;
   339     if ( aIndex == 0 && iOviButtonUrl )
       
   340         return *iOviButtonUrl;
       
   341     return KNullDesC;
       
   342     }
       
   343 
       
   344 // ---------------------------------------------------------
       
   345 // CWmConfiguration::IndexConversion
       
   346 // ---------------------------------------------------------
       
   347 //
       
   348 void CWmConfiguration::IndexConversion( TInt& /*aIndex*/ )
       
   349     {
       
   350     // if there is a need to configure switching button places
       
   351     // (operator button left, then OVI button) then this method
       
   352     // would have something like this:
       
   353     
       
   354     // if ( iSwitchButtons ) aIndex = 1 - aIndex;
       
   355     
       
   356     // but for now, this method is empty.
   273     }
   357     }
   274 
   358 
   275 
   359 
   276 
   360 
   277 
   361