idlehomescreen/widgetmanager/src/wmconfiguration.cpp
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
--- a/idlehomescreen/widgetmanager/src/wmconfiguration.cpp	Wed Sep 15 12:00:00 2010 +0300
+++ b/idlehomescreen/widgetmanager/src/wmconfiguration.cpp	Wed Oct 13 14:18:30 2010 +0300
@@ -27,15 +27,14 @@
 #include "wmconfiguration.h"
 #include "wmresourceloader.h"
 #include "wmcrkeys.h"
-#include "wmstore.h"
 
 // some constants regarging the central repository localised section.
 // these will ensure CR localisation section compatibility even if
 // new strings are added
-const TInt KLangOffsetStoreUrl = KUrl_0 - KLangId_0;
-const TInt KLangOffsetStoreText = KTitle_0 - KLangId_0;
-const TInt KLangGroupSize = KLangId_1 - KLangId_0;
-const TUint32 KLastLangId = KLangId_9;
+const TInt KLangOffsetOperatorUrl = KOperatorButtonUrl0 - KLangId0;
+const TInt KLangOffsetOperatorText = KOperatorButtonText0 - KLangId0;
+const TInt KLangGroupSize = KLangId1 - KLangId0;
+const TUint32 KLastLangId = KLangId9;
 
 _LIT( KOpAppTypeS60, "s60" );
 _LIT( KOpAppTypeCwrt, "cwrt" );
@@ -43,7 +42,7 @@
 _LIT( KOpAppTypeJava, "java" );
 _LIT( KOpAppTypeQt, "qt" );
 _LIT( KSeparator, ":" );
-_LIT( KStoreIconFormat, "uid(%d)");
+_LIT( KOperatorIcon, "uid(%d)");
 _LIT( KHexPrefix, "0x" );
 
 // ---------------------------------------------------------
@@ -68,7 +67,15 @@
         CWmResourceLoader& aResourceLoader )
     : iResourceLoader( aResourceLoader )
 	{
-    
+
+    // ovi
+    iOviStoreUid = KNullUid;
+
+    // operator
+    iOperatorAppIdUid = KNullUid;
+    iOperatorAppType = EUnknown;
+    iOperatorButtonEnabled = EFalse;
+    iButtonsMirrored = EFalse;
 	}
 
 // ---------------------------------------------------------
@@ -77,8 +84,17 @@
 //
 CWmConfiguration::~CWmConfiguration()
 	{
-    delete iRepository;    
-    iConfItems.ResetAndDestroy();
+    delete iRepository;
+    // ovi
+    delete iOviStoreClientParam;
+    delete iOviButtonTitle;
+    delete iOviButtonIcon;
+    // operator
+    delete iOperatorButtonTitle;
+    delete iOperatorButtonIcon;
+    delete iOperatorButtonUrl;
+    delete iOperatorParam;
+    delete iOperatorAppIdStr;
 	}
 
 // ---------------------------------------------------------
@@ -87,8 +103,24 @@
 //
 void CWmConfiguration::ConstructL()
 	{
+	// localised ovistore button text
+    iOviButtonTitle = StringLoader::LoadL( R_QTN_WM_GO_TO_OVI_STORE );
+
+    // ovistore icon descriptor. It will look something like this:
+    // skin( 0x101f86e3 0x23f6 ):mif( z:\resource\apps\widgetmanager.mif 16388 16389 )
+    _LIT( KSkinMifIconFormat, "skin( 0x%x 0x%x ):mif( %S %d %d )");
+    const TInt KMaxIconDescriptorLength = 256;
+    TBuf<KMaxIconDescriptorLength> buf;
+    buf.Format( KSkinMifIconFormat(),
+             EAknsMajorGeneric, EAknsMinorGenericQgnMenuOviStore,
+             &iResourceLoader.IconFilePath(),
+             EMbmWidgetmanagerQgn_menu_ovistore,
+             EMbmWidgetmanagerQgn_menu_ovistore_mask );
+    iOviButtonIcon = buf.AllocL();
+
     // read data from repository
     TRAP_IGNORE( LoadConfigurationL(); );
+
 	}
 
 // ---------------------------------------------------------
@@ -98,75 +130,25 @@
 void CWmConfiguration::LoadConfigurationL()
     {
     iRepository = CRepository::NewL( 
-            TUid::Uid( KCrWidgetManager ) );
-    
-    TLinearOrder<CWmConfItem> order 
-        = CWmConfiguration::CompareStoreOrder;
+            TUid::Uid( KCrWidgetManagerm ) );
 
     // read Ovi parameters
-    TInt oviEnabled;
-    ReadIntParameter( KOviStoreEnabled, oviEnabled );
-    if ( oviEnabled )
+    ReadInt32Parameter( KOviStoreUid, iOviStoreUid.iUid );
+    iOviStoreClientParam = ReadDescParameterL( KOviStoreClientParam ); 
+    
+    // read operator parameters if operator button enabled
+    ReadIntParameter( KOperatorButtonEnabled, iOperatorButtonEnabled );
+    if ( iOperatorButtonEnabled )
         {
-        CWmConfItem* ovi = CWmConfItem::NewLC();
-        ovi->iId = CWmStore::EOvi;
-        
-        // localised ovistore text
-        _LIT( KFormatStr, "%S\t%S");
-        HBufC* title = StringLoader::LoadLC( R_QTN_WM_OVI_STORE_TITLE );
-        HBufC* desc = StringLoader::LoadLC( R_QTN_WM_OVI_STORE_DESC );
-        
-        ovi->iTitle = HBufC::NewL( title->Des().Length() +
-                                   desc->Des().Length() + 
-                                   KFormatStr().Length() );
-
-        ovi->iTitle->Des().Format( KFormatStr(), title, desc );
-        
-        CleanupStack::PopAndDestroy( desc );
-        CleanupStack::PopAndDestroy( title );
-        
-        // ovistore icon descriptor. It will look something like this:
-        // skin( 0x101f86e3 0x23f6 ):mif( z:\resource\apps\widgetmanager.mif 16388 16389 )
-        _LIT( KSkinMifIconFormat, "skin( 0x%x 0x%x ):mif( %S %d %d )");
-        const TInt KMaxIconDescriptorLength = 256;
-        TBuf<KMaxIconDescriptorLength> buf;
-        buf.Format( KSkinMifIconFormat(),
-                 EAknsMajorGeneric, EAknsMinorGenericQgnMenuOviStore,
-                 &iResourceLoader.IconFilePath(),
-                 EMbmWidgetmanagerQgn_menu_ovistore,
-                 EMbmWidgetmanagerQgn_menu_ovistore_mask );
-        ovi->iIcon = buf.AllocL();
-        
-        ReadIntParameter( KOviOrder, ovi->iOrder );
-        ReadInt32Parameter( KOviUid, ovi->iAppUid.iUid );
-        ovi->iAppParam = ReadDescParameterL( KOviAppParam );
-
-        // Item to Array
-        iConfItems.InsertInOrderL( ovi, order );
-        CleanupStack::Pop( ovi );
-        }
-    
-    // read Store parameters if Store enabled
-    TInt storeEnabled = 0;
-    ReadIntParameter( KStoreEnabled, storeEnabled );
-    if ( storeEnabled )
-        {
+        // determine language and read localised parameters
         iLanguageIndex = FindCorrectLanguageId();
-        
-        CWmConfItem* op = CWmConfItem::NewLC();
-        op->iId = CWmStore::EStore1;
-        
-        op->iTitle = ReadLocalisedParameterL( KLangOffsetStoreText );
-        op->iUrl = ReadLocalisedParameterL( KLangOffsetStoreUrl );
+        iOperatorButtonTitle = ReadLocalisedParameterL( KLangOffsetOperatorText );
+        iOperatorButtonUrl = ReadLocalisedParameterL( KLangOffsetOperatorUrl );
         // read non-localised parameters
-        op->iIcon = ReadDescParameterL( KIcon );
-        ReadApplicationInfoL( KAppTypeAndId, *op );
-        op->iAppParam = ReadDescParameterL( KAppParam );        
-        ReadIntParameter( KOrder, op->iOrder );
-        
-        // Item to Array
-        iConfItems.InsertInOrderL( op, order );
-        CleanupStack::Pop( op );
+        iOperatorButtonIcon = ReadDescParameterL( KOperatorButtonIcon );
+        ReadOperatorApplicationInfoL();
+        iOperatorParam = ReadDescParameterL( KOperatorParam );
+        ReadIntParameter( KOperatorButtonHigherPriority, iButtonsMirrored );
         }
 
     delete iRepository;
@@ -185,7 +167,7 @@
     TLanguage sysLang = User::Language();
     
     //read language id's from cenrep, find a match
-    for( TUint32 i=KLangId_0; i<=KLastLangId && languageIndex<0; i+=KLangGroupSize )
+    for( TUint32 i=KLangId0; i<=KLastLangId && languageIndex<0; i+=KLangGroupSize )
         {
         TInt crLang = 0;
         if ( iRepository->Get( i, crLang ) == KErrNone )
@@ -264,7 +246,7 @@
     if ( err != KErrNone || buf.Length() == 0 )
         {
         // This language is empty. Try default language (index 0)
-        err = iRepository->Get( KLangId_0 + aOffset, buf );
+        err = iRepository->Get( KLangId0 + aOffset, buf );
         }
 
     // construct string in heap
@@ -277,13 +259,12 @@
     }
 
 // ---------------------------------------------------------
-// CWmConfiguration::ReadApplicationInfoL
+// CWmConfiguration::ReadOperatorApplicationInfoL
 // ---------------------------------------------------------
 //
-void CWmConfiguration::ReadApplicationInfoL( 
-        TInt aKey, CWmConfItem& aConfItem )
+void CWmConfiguration::ReadOperatorApplicationInfoL()
     {
-    HBufC* applicationInfo = ReadDescParameterL( aKey );
+    HBufC* applicationInfo = ReadDescParameterL( KOperatorAppTypeAndId );
     if ( applicationInfo && applicationInfo->Des().Length() > 0 )
         {
         CleanupStack::PushL( applicationInfo );
@@ -299,32 +280,34 @@
             
             if ( !type.Compare( KOpAppTypeS60 ) )
                 {
-                aConfItem.iAppType = ES60;
-                aConfItem.iAppUid = StringToUid( appId );
-                SetStoreIconL( aConfItem );
+                iOperatorAppType = ES60;
+                iOperatorAppIdUid = StringToUid( appId );
+                SetOperatorIconL( iOperatorAppIdUid );
                 }
             else if ( !type.Compare( KOpAppTypeCwrt ) )
                 {
-                aConfItem.iAppType = ECwrt;
-                aConfItem.iAppUid = FetchWidgetUidFromRegistryL( appId );
-                SetStoreIconL( aConfItem );
+                iOperatorAppType = ECwrt;
+                iOperatorAppIdUid = FetchWidgetUidFromRegistryL( appId );
+                SetOperatorIconL( iOperatorAppIdUid );
                 }
             else if ( !type.Compare( KOpAppTypeWrt ) )
                 {
-                aConfItem.iAppType = EWrt;
-                aConfItem.iAppUid = FetchWidgetUidFromRegistryL( appId );
-                SetStoreIconL( aConfItem );
+                iOperatorAppType = EWrt;
+                iOperatorAppIdUid = FetchWidgetUidFromRegistryL( appId );
+                SetOperatorIconL( iOperatorAppIdUid );
                 }
             else if ( !type.Compare( KOpAppTypeJava ) )
                 {
-                // java support is not fully implemented
+                //TODO: java support is not fully implemented
                 User::Leave( KErrGeneral );
+                iOperatorAppType = EJava;
+                iOperatorAppIdStr = appId.AllocL();
                 }
             else if ( !type.Compare( KOpAppTypeQt ) )
                 {
-                aConfItem.iAppType = EQt;
-                aConfItem.iAppUid = StringToUid( appId );
-                SetStoreIconL( aConfItem );
+                iOperatorAppType = EQt;
+                iOperatorAppIdUid = StringToUid( appId );
+                SetOperatorIconL( iOperatorAppIdUid );
                 }
             }
         CleanupStack::PopAndDestroy( applicationInfo );
@@ -332,21 +315,20 @@
     }
 
 // ---------------------------------------------------------
-// CWmConfiguration::SetStoreIcon
+// CWmConfiguration::SetOperatorIcon
 // ---------------------------------------------------------
 //
-void CWmConfiguration::SetStoreIconL( CWmConfItem& aConfItem )
+void CWmConfiguration::SetOperatorIconL( TUid aUid )
     {
-    if ( aConfItem.iIcon &&
-        !aConfItem.iIcon->Des().Length() )
+    if ( iOperatorButtonIcon &&
+        !iOperatorButtonIcon->Des().Length() )
         {
-        delete aConfItem.iIcon;
-        aConfItem.iIcon = NULL;
-        
-        aConfItem.iIcon = HBufC::NewL(
-                KMaxUidName + KStoreIconFormat().Length() );
-        aConfItem.iIcon->Des().Format(
-                KStoreIconFormat(), aConfItem.iAppUid );
+        delete iOperatorButtonIcon;
+        iOperatorButtonIcon = NULL;
+        iOperatorButtonIcon = HBufC::NewL(
+                KMaxUidName + KOperatorIcon().Length() );
+        iOperatorButtonIcon->Des().Format(
+                KOperatorIcon(), aUid );
         }
     }
 
@@ -365,6 +347,137 @@
     CleanupStack::PopAndDestroy( &clientSession );
     return TUid::Uid( ret );
     }
+     
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonCount
+// ---------------------------------------------------------
+//
+TInt CWmConfiguration::PortalButtonCount()
+    {
+    return ( iOperatorButtonEnabled ? 2 : 1 );
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonText
+// ---------------------------------------------------------
+//
+const TDesC& CWmConfiguration::PortalButtonText( TInt aIndex )
+    {
+    if ( aIndex == 0 && iOviButtonTitle )
+        return *iOviButtonTitle;
+    if ( aIndex == 1 && iOperatorButtonTitle && iOperatorButtonEnabled )
+        return *iOperatorButtonTitle;
+    return KNullDesC;
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonIcon
+// ---------------------------------------------------------
+//
+const TDesC& CWmConfiguration::PortalButtonIcon( TInt aIndex )
+    {
+    if ( aIndex == 0 && iOviButtonIcon )
+        return *iOviButtonIcon;
+    if ( aIndex == 1 && iOperatorButtonIcon && iOperatorButtonEnabled )
+        return *iOperatorButtonIcon;
+    return KNullDesC;
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonBrowserUrl
+// ---------------------------------------------------------
+//
+const TDesC& CWmConfiguration::PortalButtonBrowserUrl( TInt aIndex )
+    {
+    // No support for ovi here
+    if ( aIndex == 1 && iOperatorButtonUrl && iOperatorButtonEnabled )
+        return *iOperatorButtonUrl;
+    return KNullDesC;
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonClientUid
+// ---------------------------------------------------------
+//
+TUid CWmConfiguration::PortalButtonClientUid( TInt aIndex )
+    {
+    if ( aIndex == 0 )
+        {
+        return iOviStoreUid;
+        } 
+    // operator not supported. Get operator data using 
+    // PortalButtonApplicationInfoL
+    return KNullUid;
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonClientParam
+// ---------------------------------------------------------
+//
+const TDesC& CWmConfiguration::PortalButtonClientParam( TInt aIndex )
+    {
+    if ( aIndex == 0 && iOviStoreClientParam )
+        {
+        return *iOviStoreClientParam;
+        }
+    if ( aIndex == 1 && iOperatorParam && iOperatorButtonEnabled )
+        {
+        return *iOperatorParam;
+        }
+    return KNullDesC;
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonsMirrored
+// ---------------------------------------------------------
+//
+TBool CWmConfiguration::PortalButtonsMirrored()
+    {
+    return iButtonsMirrored;
+    } 
+   
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonApplicationType
+// ---------------------------------------------------------
+//
+CWmConfiguration::TOpAppType CWmConfiguration::PortalButtonApplicationType( 
+        TInt aIndex )
+    {
+    if ( aIndex == 1 )
+        {
+        return iOperatorAppType;
+        }
+    // no support for ovi
+    return EUnknown;
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonApplicationId
+// ---------------------------------------------------------
+//
+void CWmConfiguration::PortalButtonApplicationId( 
+        TInt aIndex, TDes& aOperatorAppId )
+    {
+    if ( aIndex == 1 )
+        {
+        aOperatorAppId.Copy( *iOperatorAppIdStr );
+        }
+    // no support for ovi
+    }
+
+// ---------------------------------------------------------
+// CWmConfiguration::PortalButtonApplicationId
+// ---------------------------------------------------------
+//
+void CWmConfiguration::PortalButtonApplicationId( 
+        TInt aIndex, TUid& aOperatorAppId )
+    {
+    if ( aIndex == 1 )
+        {
+        aOperatorAppId = iOperatorAppIdUid; 
+        }
+    // no support for ovi
+    }
 
 // ---------------------------------------------------------
 // CWmConfiguration::StringToUid
@@ -394,168 +507,6 @@
     return KNullUid;
     }
 
-// ---------------------------------------------------------
-// CWmConfiguration::CompareStoreOrder
-// ---------------------------------------------------------
-//
-TInt CWmConfiguration::CompareStoreOrder( 
-        const CWmConfItem& aItemOne, const CWmConfItem& aItemTwo )
-    {
-    // 1. zero, if the two objects are equal.
-    // 2. a negative value, if the first object is less than the second.
-    // 3. a positive value, if the first object is greater than the second.
-    TInt ret = 0;
-    if ( aItemOne.iOrder < aItemTwo.iOrder )
-        {
-        ret = -1;
-        }
-    if ( aItemOne.iOrder > aItemTwo.iOrder )
-        {
-        ret = 1;
-        }
-    return ret;
-    }
-	
-// ---------------------------------------------------------
-// CWmConfiguration::StoreConfArray
-// ---------------------------------------------------------
-//
-const RPointerArray<CWmConfItem>& CWmConfiguration::StoreConfArray()
-    {
-    return iConfItems;
-    }
-
-// ---------------------------------------------------------
-// CWmConfiguration::StoreCount
-// ---------------------------------------------------------
-//
-TInt CWmConfiguration::StoreCount()
-    {
-    return iConfItems.Count();
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::NewL
-// ---------------------------------------------------------
-//
-CWmConfItem* CWmConfItem::NewL()
-    {
-    CWmConfItem* self = CWmConfItem::NewLC();
-    CleanupStack::Pop(); // self;
-    return self;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::NewLC
-// ---------------------------------------------------------
-//
-CWmConfItem* CWmConfItem::NewLC()
-    {
-    CWmConfItem* self = new ( ELeave ) CWmConfItem();
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    return self;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::~CWmConfItem
-// ---------------------------------------------------------
-//
-CWmConfItem::~CWmConfItem()
-    {
-    delete iTitle;
-    delete iIcon;
-    delete iUrl;              
-    delete iAppParam;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::CWmConfItem
-// ---------------------------------------------------------
-//
-CWmConfItem::CWmConfItem()
-    {
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::ConstructL
-// ---------------------------------------------------------
-//
-void CWmConfItem::ConstructL()
-    {
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::Id
-// ---------------------------------------------------------
-//
-CWmStore::TStoreId CWmConfItem::Id()
-    {
-    return iId;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::Title
-// ---------------------------------------------------------
-//
-const TDesC& CWmConfItem::Title()
-    {
-    return ( iTitle ? *iTitle : KNullDesC() );
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::Icon
-// ---------------------------------------------------------
-//
-const TDesC& CWmConfItem::Icon()
-    {
-    return ( iIcon ? *iIcon : KNullDesC() );
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::Order
-// ---------------------------------------------------------
-//
-TInt CWmConfItem::Order()
-    {
-    return iOrder;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::BrowserUrl
-// ---------------------------------------------------------
-//
-const TDesC& CWmConfItem::BrowserUrl() 
-    {
-    return ( iUrl ? *iUrl : KNullDesC() );
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::AppType
-// ---------------------------------------------------------
-//
-CWmConfiguration::TStoreAppType CWmConfItem::AppType()
-    {
-    return iAppType;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::AppUid
-// ---------------------------------------------------------
-//
-TUid CWmConfItem::AppUid()
-    {
-    return iAppUid;
-    }
-
-// ---------------------------------------------------------
-// CWmConfItem::AppParam
-// ---------------------------------------------------------
-//
-const TDesC& CWmConfItem::AppParam()
-    {
-    return ( iAppParam ? *iAppParam : KNullDesC() );
-    }
 
 // End of File