emailuis/gsemailsettings/src/GSEmailSettingsView.cpp
changeset 0 8466d47a6819
child 8 e1b6206813b4
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Email plugin for s60 general settings
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // SYSTEM INCLUDES
       
    20 #include "emailtrace.h"
       
    21 #include <f32file.h>
       
    22 #include <e32cmn.h>
       
    23 #include <bautils.h>
       
    24 #include <data_caging_path_literals.hrh>
       
    25 #include <StringLoader.h>
       
    26 #include <GSEmailSettingsPlugin.rsg>
       
    27 //<cmail>
       
    28 #include "CFSMailCommon.h"
       
    29 #include "FreestyleEmailUiConstants.h" // email enumerations
       
    30 //</cmail>
       
    31 #include <freestyleemailui.mbg> // icons
       
    32 #include <gsfwviewuids.h>
       
    33 
       
    34 // LOCAL INCLUDES
       
    35 #include "GSEmailSettingsView.h"
       
    36 #include "GSEmailSettings.hrh"
       
    37 #include "FreestyleEmailUiConstants.h"
       
    38 
       
    39 // CONSTANTS
       
    40 _LIT( KEmailSettingsAppResourceFile,"GSEmailSettingsPlugin.RSC");
       
    41 _LIT( KIconPath,"FreestyleEmailUi_aif.mif" );
       
    42 
       
    43 // -----------------------------------------------------------------------------
       
    44 // CGSEmailSettingsView::NewL()
       
    45 // Two-phased constructor.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CGSEmailSettingsView* CGSEmailSettingsView::NewL()
       
    49 	{
       
    50     FUNC_LOG;
       
    51 	CGSEmailSettingsView* self = CGSEmailSettingsView::NewLC();
       
    52 	CleanupStack::Pop( self );
       
    53 	return self;
       
    54     }
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CGSEmailSettingsView::NewLC()
       
    58 // Creates a CGSEmailSettingsView object.
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 CGSEmailSettingsView* CGSEmailSettingsView::NewLC()
       
    62     {
       
    63     FUNC_LOG;
       
    64     CGSEmailSettingsView* self = new ( ELeave ) CGSEmailSettingsView;
       
    65     CleanupStack::PushL( self );
       
    66     self->ConstructL();
       
    67     return self;
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CGSEmailSettingsView::CGSEmailSettingsView()
       
    72 // Default Constructor
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C CGSEmailSettingsView::CGSEmailSettingsView()
       
    76 	: iResourceLoader( *iCoeEnv  )
       
    77 	{
       
    78     FUNC_LOG;
       
    79 	}
       
    80 
       
    81 // -----------------------------------------------------------------------------
       
    82 // CGSEmailSettingsView::~MySetFrmWrkView()
       
    83 // Destroy the object and release all memory objects
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 CGSEmailSettingsView::~CGSEmailSettingsView()
       
    87 	{
       
    88     FUNC_LOG;
       
    89     iResourceLoader.Close(); 
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CGSEmailSettingsView::ConstructL()
       
    94 // Symbian OS default constructor.
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CGSEmailSettingsView::ConstructL()
       
    98 	{
       
    99     FUNC_LOG;
       
   100 	TFileName resFile;
       
   101 	resFile.Append( KDC_APP_RESOURCE_DIR );
       
   102 	resFile.Append( KEmailSettingsAppResourceFile );
       
   103 	RProcess process;
       
   104 	TFileName exeFileName = process.FileName();
       
   105 	TParse parse;
       
   106 	            
       
   107 	User::LeaveIfError( parse.Set( resFile, &exeFileName, NULL ) );
       
   108 	TFileName fileName( parse.FullName() );
       
   109     // Get language of resource file
       
   110     BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
       
   111     // Open resource file
       
   112     TRAP_IGNORE( iResourceLoader.OpenL( fileName ) ); 
       
   113 
       
   114     BaseConstructL( R_EMAIL_GS_SETTING_LIST_VIEW );	
       
   115 	}
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CGSEmailSettingsView::GetCaptionL()
       
   119 // Functionality for getting the Caption of the Plugin
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CGSEmailSettingsView::GetCaptionL( TDes& aCaption ) const
       
   123     {
       
   124     FUNC_LOG;
       
   125 
       
   126     HBufC* text = StringLoader::LoadLC( R_FS_EMAIL_GS_APP_SHORT_NAME  );
       
   127     aCaption.Copy( *text );
       
   128     CleanupStack::PopAndDestroy( text );
       
   129 
       
   130     }
       
   131     
       
   132 // -----------------------------------------------------------------------------
       
   133 // CGSEmailSettingsView::Visible()
       
   134 // This function could be used to hide the plugin dynamically
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 TBool CGSEmailSettingsView::Visible() const
       
   138     {
       
   139     FUNC_LOG;
       
   140     return ETrue;
       
   141     }
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CGSEmailSettingsView::ItemType()
       
   145 // Get the type of this GS plugin
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 TGSListboxItemTypes CGSEmailSettingsView::ItemType()
       
   149     {
       
   150     FUNC_LOG;
       
   151     return EGSItemTypeSingleLargeDialog;
       
   152     }
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // CGSEmailSettingsView::HandleSelection()
       
   156 // Called when user selects Email settings from GS
       
   157 // ---------------------------------------------------------------------------
       
   158 //
       
   159 void CGSEmailSettingsView::HandleSelection( const TGSSelectionTypes /*aSelectionType*/ )
       
   160     {
       
   161     FUNC_LOG;
       
   162     TInt tmp = 1;
       
   163     const TPckgBuf<TInt> pkgBuf( tmp );
       
   164     TVwsViewId pluginViewId = TVwsViewId( KFSEmailUiUid, SettingsViewId );
       
   165     // <cmail>
       
   166     TRAP_IGNORE( ActivateViewL(
       
   167         pluginViewId, TUid::Uid(KOpenMailSettingsFromGS), pkgBuf ) );
       
   168     // </cmail>
       
   169     }
       
   170 
       
   171 // ---------------------------------------------------------------------------
       
   172 // CGSEmailSettingsView::CreateIconL()
       
   173 // ---------------------------------------------------------------------------
       
   174 //
       
   175 CGulIcon* CGSEmailSettingsView::CreateIconL( const TUid aIconType )
       
   176 	{
       
   177     FUNC_LOG;
       
   178 	CGulIcon* icon;
       
   179 	if ( aIconType == KGSIconTypeLbxItem )
       
   180 	    {
       
   181 	    TFileName resFile;
       
   182         resFile.Append( KDC_BITMAP_DIR );
       
   183         resFile.Append( KIconPath );
       
   184         RProcess process;
       
   185         TFileName exeFileName = process.FileName();
       
   186         TParse parse;
       
   187 	                    
       
   188         User::LeaveIfError( parse.Set( resFile, &exeFileName, NULL ) );
       
   189         TFileName iconFileName( parse.FullName() );
       
   190 	    
       
   191 	    CFbsBitmap* bitmap(0);
       
   192 	    CFbsBitmap* bitmap_mask(0);
       
   193 
       
   194 	    TInt bitmapId = 0;
       
   195 	    TInt maskId = 0;
       
   196 	    AknIconUtils::ValidateLogicalAppIconId( iconFileName, bitmapId, maskId );
       
   197 	    AknIconUtils::CreateIconLC( bitmap, bitmap_mask, iconFileName, bitmapId, maskId );
       
   198 
       
   199 	    // create icon from bitmaps
       
   200 	    icon = CGulIcon::NewL( bitmap, bitmap_mask );
       
   201 	    CleanupStack::Pop( bitmap_mask );
       
   202 	    CleanupStack::Pop( bitmap );
       
   203 	    }
       
   204 	else
       
   205 	    {
       
   206 	    icon = CGSPluginInterface::CreateIconL( aIconType );
       
   207 	    }
       
   208 	return icon;
       
   209 	}
       
   210  
       
   211 // -----------------------------------------------------------------------------
       
   212 // CGSEmailSettingsView::Id()
       
   213 // From CAknView, returns the views id.
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 TUid CGSEmailSettingsView::Id() const
       
   217     {
       
   218     FUNC_LOG;
       
   219     return KGSEmailSettingsPluginUid;
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CGSEmailSettingsView::DoActivateL()
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CGSEmailSettingsView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
   227                                   TUid /*aCustomMessageId*/,
       
   228                                   const TDesC8& /*aCustomMessage*/ )
       
   229     {
       
   230     FUNC_LOG;
       
   231     // not view-type-plugin => implementation not needed
       
   232     }
       
   233 
       
   234 // ---------------------------------------------------------------------------
       
   235 // CGSEmailSettingsView::DoDeactivate()
       
   236 // ---------------------------------------------------------------------------
       
   237 //
       
   238 void CGSEmailSettingsView::DoDeactivate()
       
   239     {
       
   240     FUNC_LOG;
       
   241     // not view-type-plugin => implementation not needed
       
   242     }
       
   243 
       
   244 // end of file
       
   245