convergedcallengine/serviceselector/src/cssbshandler.cpp
changeset 51 12bc758d6a02
parent 48 78df25012fda
child 53 25b8d29b7c59
equal deleted inserted replaced
48:78df25012fda 51:12bc758d6a02
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This module contains the implementation of 
       
    15 *              : CSsBsHandler class.
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <mbsaccess.h>
       
    21 #include <cbsfactory.h>
       
    22 #include <mbselement.h>
       
    23 #include <cbsbitmap.h>
       
    24 #include <coemain.h>
       
    25 #include <AknsItemID.h> 
       
    26 #include <AknsSkinInstance.h> 
       
    27 #include <AknsUtils.h> 
       
    28 
       
    29 #include "cssiconfileprovider.h"
       
    30 #include "cssbshandler.h"
       
    31 #include "csslogger.h"
       
    32 
       
    33 // EXTERNAL DATA STRUCTURES
       
    34 // None
       
    35 
       
    36 // EXTERNAL FUNCTION PROTOTYPES
       
    37 // None
       
    38 
       
    39 // CONSTANTS
       
    40 // Branding server & data constants.
       
    41 const TInt KSsBrandingIconSize  = 21;         // icon size
       
    42 
       
    43 _LIT8( KSsBSApplicationId, "xsp" );                 // application id
       
    44 _LIT8( KSsUiBSIconId, "default_brand_image" ); // icon id
       
    45 
       
    46 // MACROS
       
    47 // None
       
    48 
       
    49 // LOCAL CONSTANTS AND MACROS
       
    50 // None
       
    51 
       
    52 // MODULE DATA STRUCTURES
       
    53 // None
       
    54 
       
    55 // LOCAL FUNCTION PROTOTYPES
       
    56 // None
       
    57 
       
    58 // FORWARD DECLARATIONS
       
    59 // None
       
    60 
       
    61 // ============================= LOCAL FUNCTIONS =============================
       
    62 
       
    63 // ============================ MEMBER FUNCTIONS =============================
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CSsBsHandler::CSsBsHandler
       
    67 // C++ default constructor can NOT contain any code, that might leave.
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CSsBsHandler::CSsBsHandler()
       
    71     {
       
    72     // No implementation required
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CSsBsHandler::ConstructL
       
    77 // Symbian 2nd phase constructor can leave.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CSsBsHandler::ConstructL()
       
    81     {
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // CSsBsHandler::NewL
       
    86 // Two-phased constructor.
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CSsBsHandler* CSsBsHandler::NewL( )
       
    90     {
       
    91     CSsBsHandler* self = CSsBsHandler::NewLC();
       
    92     CleanupStack::Pop( self );
       
    93     return self;
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CSsBsHandler::NewLC
       
    98 // Two-phased constructor.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CSsBsHandler* CSsBsHandler::NewLC()
       
   102     {
       
   103     CSsBsHandler* self = new (ELeave) CSsBsHandler();
       
   104     CleanupStack::PushL( self );
       
   105     self->ConstructL();
       
   106     return self;
       
   107     }
       
   108 
       
   109 // Destructor
       
   110 CSsBsHandler::~CSsBsHandler()
       
   111     {
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CSsBsHandler::GetBrandedIconL
       
   116 // (other items were commented in a header).
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 void CSsBsHandler::GetBrandedIconL(
       
   120     const TDesC8& aBrandingId,
       
   121     CFbsBitmap*& aBrandedBitmap,
       
   122     CFbsBitmap*& aBrandedBitmapMask ) const
       
   123     {
       
   124     CSSLOGSTRING( "CSSelector::CreateBrandedBitmapL: =>" );
       
   125 
       
   126     // Create branding server factory and access to branding data.
       
   127     CBSFactory* factory = CBSFactory::NewL(
       
   128         aBrandingId, KSsBSApplicationId );
       
   129     CleanupStack::PushL( factory );
       
   130 
       
   131     MBSAccess* access = factory->CreateAccessL(
       
   132         aBrandingId, ELangInternationalEnglish );
       
   133     CleanupClosePushL( *access );
       
   134 
       
   135     // Get structure which contains bitmap information.
       
   136     MBSElement* element = access->GetStructureL( KSsUiBSIconId );
       
   137     CleanupClosePushL( *element );
       
   138     const CBSBitmap& bitmap = element->BitmapDataL();
       
   139 
       
   140     // Open file which contains branded bitmaps.
       
   141     RFile file;
       
   142     CleanupClosePushL( file );
       
   143     access->GetFileL( bitmap.BitmapFileId(), file );
       
   144 
       
   145     // Try to load a skinned bitmap.
       
   146     if ( CCoeEnv::Static() )
       
   147         {
       
   148         TAknsItemID itemId;
       
   149         itemId.Set( bitmap.SkinIdMajor(), bitmap.SkinIdMinor() );
       
   150         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   151         TRAP_IGNORE( ( aBrandedBitmap =
       
   152             AknsUtils::CreateBitmapL( skin, itemId ) ) );
       
   153         }
       
   154 
       
   155     // If skinned bitmaps was not found, try to load bitmaps manually.
       
   156     if ( !aBrandedBitmap )
       
   157         {
       
   158         CSsIconFileProvider* fileProvider =
       
   159             CSsIconFileProvider::NewL( file );
       
   160 
       
   161         AknIconUtils::CreateIconL(
       
   162             aBrandedBitmap,
       
   163             aBrandedBitmapMask,
       
   164             *fileProvider,
       
   165             bitmap.BitmapId(),
       
   166             bitmap.BitmapMaskId() );
       
   167          }
       
   168 
       
   169     // Set sizes.
       
   170     const TInt iconSize( KSsBrandingIconSize );
       
   171     AknIconUtils::SetSize( aBrandedBitmap, TSize( iconSize, iconSize ) );
       
   172     AknIconUtils::SetSize( aBrandedBitmapMask, TSize( iconSize, iconSize ) );
       
   173 
       
   174     // Destroy some items.
       
   175     CleanupStack::PopAndDestroy( &file );
       
   176     CleanupStack::PopAndDestroy( element );
       
   177     CleanupStack::PopAndDestroy( access );
       
   178     CleanupStack::PopAndDestroy( factory );
       
   179 
       
   180     CSSLOGSTRING( "CSSelector::CreateBrandedBitmapL: <=" );
       
   181     }
       
   182 
       
   183 // ========================== OTHER EXPORTED FUNCTIONS =======================
       
   184 
       
   185 //  End of File