phoneplugins/telbranding/src/telbranding.cpp
changeset 0 5f000ab63145
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:  Sets brand according service id.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  Include Files
       
    20 #include <telbubbleextensionobserver.h>
       
    21 #include <telbubbleextensiondata.h>
       
    22 #include <telbubblecustomelement.h>
       
    23 #include <utf.h>
       
    24 
       
    25 #include "telbranding.h"	// Ctelbranding
       
    26 #include "telbrandingsettingshandler.h"
       
    27 #include "telbrandingserverhandler.h"
       
    28 #include "telbrandingbubble.h"
       
    29 
       
    30 //  Member Functions
       
    31 
       
    32 // ---------------------------------------------------------
       
    33 // CTelBranding::NewL
       
    34 // ---------------------------------------------------------
       
    35 //
       
    36 CTelBranding* CTelBranding::NewL()
       
    37     {
       
    38     CTelBranding* self = new (ELeave) CTelBranding();
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop( self );
       
    42     return self;
       
    43     }
       
    44 
       
    45 // ---------------------------------------------------------
       
    46 // CTelBranding::CTelBranding
       
    47 // ---------------------------------------------------------
       
    48 //
       
    49 CTelBranding::CTelBranding()
       
    50     {
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------
       
    54 // CTelBranding::ConstructL
       
    55 // ---------------------------------------------------------
       
    56 //
       
    57 void CTelBranding::ConstructL()
       
    58     {
       
    59     iSettings = CTelBrandingSettingsHandler::NewL();
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CTelBranding:::~CTelBranding
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 CTelBranding::~CTelBranding()
       
    67     {
       
    68     delete iSettings;
       
    69     iBubbleArray.ResetAndDestroy();
       
    70     iBubbleArray.Close();
       
    71     }
       
    72 
       
    73 // ---------------------------------------------------------
       
    74 // CTelBranding::InitializeL
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 void CTelBranding::InitializeL( MTelBubbleExtensionObserver& aBubbles )
       
    78     {
       
    79     iObserver = &aBubbles;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CTelBranding::StartCustomizedBubble
       
    84 // ---------------------------------------------------------
       
    85 //
       
    86 void CTelBranding::StartCustomizedBubble(
       
    87     MTelBubbleExtensionData& aCallData  )
       
    88     {
       
    89     TRAP_IGNORE( LoadBrandingL( aCallData ) );
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CTelBranding::StopCustomizedBubble
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 void CTelBranding::StopCustomizedBubble(
       
    97     MTelBubbleExtensionData& aCallData  )
       
    98     {
       
    99     for( TInt i = 0; i < iBubbleArray.Count(); i++ )
       
   100         {
       
   101         if( iBubbleArray[i]->BubbleId() == aCallData.BubbleId() )
       
   102             {
       
   103             iBubbleArray[i]->DetechElements( *iObserver );
       
   104 
       
   105             delete iBubbleArray[i];
       
   106             iBubbleArray.Remove(i);
       
   107             i--;
       
   108             }
       
   109         }
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------
       
   113 // CTelBranding::BubbleUpdating
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 void CTelBranding::BubbleUpdating()
       
   117     {
       
   118     // Do nothing
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------
       
   122 // CTelBranding::LoadBrandingL
       
   123 // ---------------------------------------------------------
       
   124 //
       
   125 void CTelBranding::LoadBrandingL( MTelBubbleExtensionData& aCallData )
       
   126     {
       
   127     HBufC* brandid = iSettings->BrandIdLC( aCallData.ServiceId() );
       
   128     HBufC8* brandid8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *brandid );
       
   129     CleanupStack::PopAndDestroy( brandid );
       
   130     CleanupStack::PushL( brandid8 );
       
   131     
       
   132     CTelBrandingServerHandler* bserver = 
       
   133         CTelBrandingServerHandler::NewLC( *brandid8 );
       
   134     
       
   135     CTelBrandingBubble* bubble = 
       
   136         CTelBrandingBubble::NewLC( aCallData, *bserver );
       
   137         
       
   138     iBubbleArray.AppendL( bubble );
       
   139     
       
   140     CleanupStack::Pop( bubble );
       
   141     CleanupStack::PopAndDestroy( bserver );
       
   142     CleanupStack::PopAndDestroy( brandid8 );
       
   143     
       
   144     bubble->AttachElements( *iObserver );
       
   145     }
       
   146 
       
   147 // end of file