idlehomescreen/widgetmanager/src/wmconfiguration.cpp
branchRCL_3
changeset 11 ff572dfe6d86
parent 9 f966699dea19
child 18 d05a55b217df
equal deleted inserted replaced
9:f966699dea19 11:ff572dfe6d86
    28 #include "wmcrkeys.h"
    28 #include "wmcrkeys.h"
    29 
    29 
    30 // some constants regarging the central repository localised section.
    30 // some constants regarging the central repository localised section.
    31 // these will ensure CR localisation section compatibility even if
    31 // these will ensure CR localisation section compatibility even if
    32 // new strings are added
    32 // new strings are added
    33 const TInt KLangOffsetOviStoreUrl = KOviStoreBrowserUrl0 - KLangId0;
       
    34 const TInt KLangOffsetOperatorUrl = KOperatorButtonUrl0 - KLangId0;
    33 const TInt KLangOffsetOperatorUrl = KOperatorButtonUrl0 - KLangId0;
    35 const TInt KLangOffsetOperatorText = KOperatorButtonText0 - KLangId0;
    34 const TInt KLangOffsetOperatorText = KOperatorButtonText0 - KLangId0;
    36 const TInt KLangGroupSize = KLangId1 - KLangId0;
    35 const TInt KLangGroupSize = KLangId1 - KLangId0;
    37 const TUint32 KLastLangId = KLangId9;
    36 const TUint32 KLastLangId = KLangId9;
    38 
    37 
    58 CWmConfiguration::CWmConfiguration(
    57 CWmConfiguration::CWmConfiguration(
    59         CWmResourceLoader& aResourceLoader )
    58         CWmResourceLoader& aResourceLoader )
    60     : iResourceLoader( aResourceLoader )
    59     : iResourceLoader( aResourceLoader )
    61 	{
    60 	{
    62     iRepository = NULL;
    61     iRepository = NULL;
    63     iOviStoreBundleId = NULL;
    62     iOviStoreUid = KNullUid;
    64     iOviStoreClientParam = NULL;
    63     iOviStoreClientParam = NULL;
    65     iOviButtonTitle = NULL;
    64     iOviButtonTitle = NULL;
    66     iOviButtonIcon = NULL;
    65     iOviButtonIcon = NULL;
    67     iOviButtonUrl = NULL;
       
    68     iOperatorButtonTitle = NULL;
    66     iOperatorButtonTitle = NULL;
    69     iOperatorButtonIcon = NULL;
    67     iOperatorButtonIcon = NULL;
    70     iOperatorButtonUrl = NULL;
    68     iOperatorButtonUrl = NULL;
    71 	}
    69 	}
    72 
    70 
    75 // ---------------------------------------------------------
    73 // ---------------------------------------------------------
    76 //
    74 //
    77 CWmConfiguration::~CWmConfiguration()
    75 CWmConfiguration::~CWmConfiguration()
    78 	{
    76 	{
    79     delete iRepository;
    77     delete iRepository;
    80     delete iOviStoreBundleId;
       
    81     delete iOviStoreClientParam;
    78     delete iOviStoreClientParam;
    82     delete iOviButtonTitle;
    79     delete iOviButtonTitle;
    83     delete iOviButtonIcon;
    80     delete iOviButtonIcon;
    84     delete iOviButtonUrl;
       
    85     delete iOperatorButtonTitle;
    81     delete iOperatorButtonTitle;
    86     delete iOperatorButtonIcon;
    82     delete iOperatorButtonIcon;
    87     delete iOperatorButtonUrl;
    83     delete iOperatorButtonUrl;
    88 	}
    84 	}
    89 
    85 
   121     {
   117     {
   122     iRepository = CRepository::NewL( 
   118     iRepository = CRepository::NewL( 
   123             TUid::Uid( KCrWidgetManagerm ) );
   119             TUid::Uid( KCrWidgetManagerm ) );
   124 
   120 
   125     // read fixed parameters
   121     // read fixed parameters
   126     iOviStoreBundleId = ReadParameterL( KOviStoreBundleId );
   122     ReadIntParameter( KOviStoreUid, iOviStoreUid.iUid );
   127     iOviStoreClientParam = ReadParameterL( KOviStoreClientParam );
   123     iOviStoreClientParam = ReadDescParameterL( KOviStoreClientParam ); 
   128     // determine language and read localised parameters
   124     // determine language and read localised parameters
   129     iLanguageIndex = FindCorrectLanguageId();
   125     iLanguageIndex = FindCorrectLanguageId();
   130     iOviButtonUrl = ReadLocalisedParameterL( KLangOffsetOviStoreUrl );
       
   131     iOperatorButtonTitle = ReadLocalisedParameterL( KLangOffsetOperatorText );
   126     iOperatorButtonTitle = ReadLocalisedParameterL( KLangOffsetOperatorText );
   132     iOperatorButtonUrl = ReadLocalisedParameterL( KLangOffsetOperatorUrl );
   127     iOperatorButtonUrl = ReadLocalisedParameterL( KLangOffsetOperatorUrl );
   133 
   128 
   134     if ( iOperatorButtonUrl && iOperatorButtonUrl->Length() > 0 )
   129     if ( iOperatorButtonUrl && iOperatorButtonUrl->Length() > 0 )
   135         {
   130         {
   136         // construct the operator button icon.
   131         // construct the operator button icon.
   137         iOperatorButtonIcon = ReadParameterL( KOperatorButtonIcon );
   132         iOperatorButtonIcon = ReadDescParameterL( KOperatorButtonIcon );
   138         }
   133         }
   139 
   134 
   140     delete iRepository;
   135     delete iRepository;
   141     iRepository = NULL;
   136     iRepository = NULL;
   142     }
   137     }
   176     
   171     
   177     return languageIndex;
   172     return languageIndex;
   178     }
   173     }
   179 
   174 
   180 // ---------------------------------------------------------
   175 // ---------------------------------------------------------
   181 // CWmConfiguration::ReadParameterL
   176 // CWmConfiguration::ReadDescParameterL
   182 // ---------------------------------------------------------
   177 // ---------------------------------------------------------
   183 //
   178 //
   184 HBufC* CWmConfiguration::ReadParameterL( TInt aKey )
   179 HBufC* CWmConfiguration::ReadDescParameterL( TInt aKey )
   185     {
   180     {
   186     TBuf<NCentralRepositoryConstants::KMaxUnicodeStringLength> buf;
   181     TBuf<NCentralRepositoryConstants::KMaxUnicodeStringLength> buf;
   187     TInt err = iRepository->Get( aKey, buf );
   182     TInt err = iRepository->Get( aKey, buf );
   188 
   183 
   189     HBufC* heapBuffer = NULL;
   184     HBufC* heapBuffer = NULL;
   191         {
   186         {
   192         heapBuffer = HBufC::NewL( buf.Length() );
   187         heapBuffer = HBufC::NewL( buf.Length() );
   193         heapBuffer->Des().Copy( buf );
   188         heapBuffer->Des().Copy( buf );
   194         }
   189         }
   195     return heapBuffer;
   190     return heapBuffer;
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------
       
   194 // CWmConfiguration::ReadIntParameterIntL
       
   195 // ---------------------------------------------------------
       
   196 //
       
   197 void CWmConfiguration::ReadIntParameter( TInt aKey, TInt32& aValue )
       
   198     {
       
   199     TInt read = KErrNone;
       
   200     TInt err = iRepository->Get( aKey, read );
       
   201     if( err == KErrNone )
       
   202         {
       
   203         aValue = read;
       
   204         }
   196     }
   205     }
   197 
   206 
   198 // ---------------------------------------------------------
   207 // ---------------------------------------------------------
   199 // CWmConfiguration::ReadLocalisedParameterL
   208 // CWmConfiguration::ReadLocalisedParameterL
   200 // ---------------------------------------------------------
   209 // ---------------------------------------------------------
   264 // CWmConfiguration::PortalButtonBrowserUrl
   273 // CWmConfiguration::PortalButtonBrowserUrl
   265 // ---------------------------------------------------------
   274 // ---------------------------------------------------------
   266 //
   275 //
   267 const TDesC& CWmConfiguration::PortalButtonBrowserUrl( TInt aIndex )
   276 const TDesC& CWmConfiguration::PortalButtonBrowserUrl( TInt aIndex )
   268     {
   277     {
   269     if ( aIndex == 0 && iOviButtonUrl )
   278     if ( aIndex == 1 && iOperatorButtonUrl )
   270         return *iOviButtonUrl;
       
   271     else if ( aIndex == 1 && iOperatorButtonUrl )
       
   272         return *iOperatorButtonUrl;
   279         return *iOperatorButtonUrl;
   273 
       
   274     return KNullDesC;
   280     return KNullDesC;
   275     }
   281     }
   276 
   282 
   277 // ---------------------------------------------------------
   283 // ---------------------------------------------------------
   278 // CWmConfiguration::PortalButtonClientUid
   284 // CWmConfiguration::PortalButtonClientUid
   279 // ---------------------------------------------------------
   285 // ---------------------------------------------------------
   280 //
   286 //
   281 TUid CWmConfiguration::PortalButtonClientUid( TInt aIndex )
   287 TUid CWmConfiguration::PortalButtonClientUid( TInt aIndex )
   282     {
   288     {
   283     if ( aIndex == 0 && iOviStoreBundleId )
   289     if ( aIndex == 0 )
   284         {
   290         {
   285         // idea: change iOviStoreBundleId to UID of laucher in cenrep
   291         return iOviStoreUid;
   286         return TUid::Uid( 0x2002D07F );
   292         } 
   287         }
       
   288     // Operator client uid not supported. 
   293     // Operator client uid not supported. 
   289     // If operator client is a widget we can use widget registry 
   294     // If operator client is a widget we can use widget registry 
   290     // to fetch uid of operator widget save it to member and return that here
   295     // to fetch uid of operator widget save it to member and return that here
       
   296     
   291     return KNullUid;
   297     return KNullUid;
   292     }
   298     }
   293 
   299 
   294 // ---------------------------------------------------------
   300 // ---------------------------------------------------------
   295 // CWmConfiguration::PortalButtonClientParam
   301 // CWmConfiguration::PortalButtonClientParam