convergedcallengine/serviceselector/src/cssuiutilities.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 *              : CSsUiUtilities class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 //  INCLUDE FILES
       
    21 #include "cssuiutilities.h"
       
    22 #include "cssnotedialog.h"
       
    23 #include "csslistquerydialog.h"
       
    24 #include "csslogger.h"
       
    25 #include <eikdialg.h>
       
    26 #include <coemain.h>
       
    27 #include <bautils.h>
       
    28 #include <data_caging_path_literals.hrh> // For resource dir definations
       
    29 #include <StringLoader.h> 
       
    30 #include <AknsUtils.h> 
       
    31 #include <avkon.mbg>
       
    32 
       
    33 // CONSTANTS
       
    34 // Resource file drive
       
    35 _LIT(KSsResourceFileDrive, "Z:");
       
    36 // Resource file name
       
    37 _LIT(KSsResourceFileName, "serviceselector.rsc");
       
    38 // Bitmap path definations
       
    39 #define KPluginBitmapPath KDC_APP_BITMAP_DIR
       
    40 _LIT( KBitmapFile, "avkon2.mif" );
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================================
       
    43 
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CSsUiUtilities::CSsUiUtilities
       
    47 // C++ default constructor can NOT contain any code, that
       
    48 // might leave.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CSsUiUtilities::CSsUiUtilities
       
    52         (
       
    53         // None
       
    54         )
       
    55     : iResourceFileOffset( 0 )
       
    56     {
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CSsUiUtilities::ConstructL
       
    61 // Symbian 2nd phase constructor can leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 void CSsUiUtilities::ConstructL()
       
    65     {
       
    66     /*
       
    67      Code scanner warning "performance: Using CEikonEnv::Static"
       
    68      We have to load resources or we cannot show any
       
    69      notes nor queries. Warning ignored. 
       
    70      */
       
    71     
       
    72     // A Service selector instance can be created also when CCoeEnv is not 
       
    73     // available (e.g. from server applications). In this case, the methods 
       
    74     // needing CCoeEnv/CEikonEnv will leave with KErrNotSupported.
       
    75     iCoeEnv = CEikonEnv::Static();
       
    76     
       
    77     if ( iCoeEnv )
       
    78         {
       
    79         LoadResourceL();
       
    80         }
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CSsConnectionHandler::NewL
       
    85 // Two-phased constructor.
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 CSsUiUtilities* CSsUiUtilities::NewL()
       
    89     {
       
    90     CSsUiUtilities* self = new ( ELeave ) CSsUiUtilities();
       
    91     CleanupStack::PushL( self );
       
    92     self->ConstructL();
       
    93     CleanupStack::Pop( self );
       
    94     return self;
       
    95     }
       
    96 
       
    97 // Destructor
       
    98 CSsUiUtilities::~CSsUiUtilities()
       
    99     {
       
   100     delete iDlg;
       
   101     iDlg = NULL;
       
   102     
       
   103     if ( iResourceFileOffset )
       
   104         {
       
   105         iCoeEnv->DeleteResourceFile( iResourceFileOffset );
       
   106         iResourceFileOffset = 0;
       
   107         }
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CSsUiUtilities::ShowInformationNoteL
       
   112 // Shows a information note.
       
   113 // -----------------------------------------------------------------------------
       
   114 //
       
   115 void CSsUiUtilities::ShowInformationNoteL 
       
   116         ( 
       
   117         TInt aResource
       
   118         )
       
   119     {
       
   120     if ( !iCoeEnv )
       
   121         {
       
   122         // No CCoeEnv/CEikonEnv, leave
       
   123         User::Leave( KErrNotSupported );
       
   124         }
       
   125     
       
   126     CSsNoteDialog* dlg = new(ELeave) CSsNoteDialog( &iDlg );    
       
   127     iDlg = dlg;
       
   128     
       
   129     dlg->RunDialogLD( aResource );
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CSsUiUtilities::ShowListQueryL
       
   134 // Shows a list query.
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 TBool CSsUiUtilities::ShowListQueryL 
       
   138         (
       
   139         TInt& aIndex,
       
   140         TInt aResource,
       
   141         MDesCArray* aItemTextArray,
       
   142         CArrayPtr<CGulIcon>* aIcons
       
   143         )
       
   144     {
       
   145     if ( !iCoeEnv )
       
   146         {
       
   147         // No CCoeEnv/CEikonEnv, leave
       
   148         User::Leave( KErrNotSupported );
       
   149         }
       
   150     
       
   151     CSsListQueryDialog* dlg = new(ELeave) CSsListQueryDialog( &iDlg, aIndex );   
       
   152     iDlg = dlg;
       
   153     
       
   154     TInt ret = dlg->ExecuteListLD( aResource, aItemTextArray, aIcons );
       
   155     
       
   156     // Return true if query not canceled ( ret = 0, if canceled )
       
   157     // and the index is on the correct range.
       
   158     return ( 0 != ret && KErrNotFound < aIndex && 
       
   159              aIndex < aItemTextArray->MdcaCount() );
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CSsUiUtilities::LoadDefaultIconL
       
   164 // Loads default list box icon.
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CSsUiUtilities::LoadDefaultIconL
       
   168         ( 
       
   169         CArrayPtr<CGulIcon>& aIcons 
       
   170         )
       
   171     {
       
   172     if ( !iCoeEnv )
       
   173         {
       
   174         // No CCoeEnv/CEikonEnv, leave
       
   175         User::Leave( KErrNotSupported );
       
   176         }
       
   177     
       
   178     CFbsBitmap* brandedBitmap = NULL;
       
   179     CFbsBitmap* brandedBitmapMask = NULL;
       
   180     
       
   181     TFindFile finder( CEikonEnv::Static()->FsSession() );
       
   182     User::LeaveIfError( finder.FindByDir( KBitmapFile,
       
   183                                  KPluginBitmapPath ) );
       
   184     TFileName bitmapFileName = finder.File();
       
   185 
       
   186     //default VoIP icon
       
   187     AknsUtils::CreateIconL( AknsUtils::SkinInstance(),
       
   188                              KAknsIIDQgnPropNrtypVoip,
       
   189                              brandedBitmap,
       
   190                              brandedBitmapMask,
       
   191                              bitmapFileName,
       
   192                              EMbmAvkonQgn_prop_nrtyp_voip,
       
   193                              EMbmAvkonQgn_prop_nrtyp_voip_mask );
       
   194     
       
   195     aIcons.AppendL( CGulIcon::NewL( brandedBitmap, brandedBitmapMask ) );
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CSsUiUtilities::LoadResourceL
       
   200 // Loads the resources needed for queries and confirmation notes
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 void CSsUiUtilities::LoadResourceL()
       
   204     {
       
   205     CSSLOGSTRING("CSSelector::LoadResources");
       
   206     TFileName fileName;
       
   207     fileName += KSsResourceFileDrive;
       
   208     fileName += KDC_RESOURCE_FILES_DIR;
       
   209     fileName += KSsResourceFileName;
       
   210     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   211     iResourceFileOffset = iCoeEnv->AddResourceFileL( fileName );
       
   212     }
       
   213 
       
   214 // ================= OTHER EXPORTED FUNCTIONS ===============================
       
   215 
       
   216 //  End of File