defaultapplicationsettings/gsplugin/src/gs_das.cpp
changeset 0 254040eb3b7d
equal deleted inserted replaced
-1:000000000000 0:254040eb3b7d
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Implements a (minimal) GS Plugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // Includes
       
    20 #include <aknViewAppUi.h>
       
    21 #include <StringLoader.h>
       
    22 #include <bautils.h>
       
    23 
       
    24 #include <gsdasplugin_rsc.rsg> // Plugin's own  UI resources
       
    25 #include <gsdasplugin.mbg>
       
    26 
       
    27 #include "gs_das.h"
       
    28 
       
    29 #include <das_client.h>
       
    30 
       
    31 
       
    32 // Constants
       
    33 
       
    34 #ifdef __SCALABLE_ICONS
       
    35   // svg file
       
    36   _LIT( KGSDasPluginIconFileName, "\\resource\\apps\\GSDasPlugin.mif");
       
    37 #else
       
    38   // bitmap
       
    39   _LIT( KGSDasPluginIconFileName, "\\resource\\apps\\GSDasPlugin.mbm");
       
    40 #endif // __SCALABLE_ICONS
       
    41 
       
    42 
       
    43 // ========================= MEMBER FUNCTIONS ================================
       
    44 
       
    45 
       
    46 // ---------------------------------------------------------------------------
       
    47 // CDefaultAppGSPlugin::CDefaultAppGSPlugin()
       
    48 // Constructor
       
    49 //
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CDefaultAppGSPlugin::CDefaultAppGSPlugin( )
       
    53     : iResources( *iCoeEnv ), iClient(NULL)
       
    54     {
       
    55     
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CDefaultAppGSPlugin::~CDefaultAppGSPlugin()
       
    60 // Destructor
       
    61 //
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CDefaultAppGSPlugin::~CDefaultAppGSPlugin()
       
    65     {
       
    66     iResources.Close();
       
    67     if(iClient)
       
    68         delete iClient;
       
    69     if( iEmptyContainer )
       
    70         {
       
    71         AppUi()->RemoveFromViewStack( *this, iEmptyContainer );
       
    72         delete iEmptyContainer;
       
    73         };
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CDefaultAppGSPlugin::ConstructL()
       
    78 // Symbian OS two-phased constructor
       
    79 // 
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CDefaultAppGSPlugin::ConstructL()
       
    83     {
       
    84     // Find the resource file:
       
    85     TParse parse;
       
    86     parse.Set( KDefaultAppGSPluginResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
    87     TFileName fileName( parse.FullName() );
       
    88 
       
    89     // Get language of resource file:
       
    90     BaflUtils::NearestLanguageFile( CEikonEnv::Static()->FsSession(), fileName );
       
    91 
       
    92     // Open resource file:
       
    93     iResources.OpenL( fileName );
       
    94     
       
    95     //We can call this after opening the resource file ...
       
    96     BaseConstructL( R_GS_DEFAULTAPP_VIEW );
       
    97     }
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CDefaultAppGSPlugin::NewL()
       
   101 // Static constructor
       
   102 //
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 CDefaultAppGSPlugin* CDefaultAppGSPlugin::NewL( TAny* /*aInitParams*/ )
       
   106     {
       
   107     CDefaultAppGSPlugin* self = new( ELeave ) CDefaultAppGSPlugin( );
       
   108     CleanupStack::PushL( self );
       
   109     self->ConstructL();
       
   110     CleanupStack::Pop( self );
       
   111     return self;
       
   112     }
       
   113 
       
   114 
       
   115 // ========================= From CAknView ==================
       
   116 
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // From class CAknView.
       
   120 // Returns the UID of the plugin (see base class)
       
   121 // ---------------------------------------------------------------------------
       
   122 //
       
   123 TUid CDefaultAppGSPlugin::Id() const
       
   124     {
       
   125     return KDefaultAppGSPluginUid;
       
   126     }
       
   127 
       
   128 
       
   129 // ---------------------------------------------------------------------------
       
   130 // From class CAknView.
       
   131 // Activates the plugin (see base class)
       
   132 // See das_servmimeapps.h for possible values of the flags (useful for R&D)
       
   133 // -0x00010000 : 
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void CDefaultAppGSPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   137                                   TUid /*aCustomMessageId*/,
       
   138                                   const TDesC8& /*aCustomMessage*/ )
       
   139     {
       
   140     iPrevViewId = aPrevViewId;
       
   141     
       
   142     TInt flags(0); //See das_servmimeapps.h for possible values of the flags (useful for R&D)
       
   143     
       
   144     if( !iClient )
       
   145         {
       
   146         iClient=CDefaultAppClient::NewL(this);
       
   147         }
       
   148     
       
   149     iClient->ChangeDefaultsL( flags );
       
   150     
       
   151     //construct an empty control, so we avoid the screen flickering
       
   152     if( !iEmptyContainer )
       
   153         {
       
   154         iEmptyContainer = CCEmptyContainer::NewL( ClientRect(),NULL );
       
   155         iEmptyContainer->SetMopParent(this);
       
   156         AppUi()->AddToStackL(*this, iEmptyContainer);
       
   157         };
       
   158     }
       
   159 
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // From class CAknView.
       
   163 // Deactivates the Plugin (see base class)
       
   164 // ---------------------------------------------------------------------------
       
   165 //
       
   166 void CDefaultAppGSPlugin::DoDeactivate()
       
   167     {
       
   168     if(iEmptyContainer)
       
   169         {
       
   170     	AppUi()->RemoveFromViewStack(*this, iEmptyContainer);
       
   171     	delete iEmptyContainer;
       
   172     	iEmptyContainer=NULL;
       
   173         };
       
   174     }
       
   175 
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // From class CAknView.
       
   179 // Handles a menu command (see base class)
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 void CDefaultAppGSPlugin::HandleCommandL( TInt aCommand )
       
   183     {
       
   184     switch ( aCommand )
       
   185         {
       
   186         case EAknSoftkeyBack:
       
   187             AppUi()->ActivateLocalViewL( iPrevViewId.iViewUid );
       
   188             break;
       
   189         case EAknCmdExit:
       
   190         case EEikCmdExit:
       
   191             AppUi()->RunAppShutter();
       
   192             break;
       
   193         default:
       
   194             AppUi()->HandleCommandL( aCommand ); //also handles EAknCmdExit 
       
   195             break;
       
   196         }
       
   197     }
       
   198 // ========================= From CGSPluginInterface ==================
       
   199 
       
   200 
       
   201 
       
   202 // ---------------------------------------------------------------------------
       
   203 // From class CGSPluginInterface.
       
   204 // Returns the Plugin Caption (see base class)
       
   205 // ---------------------------------------------------------------------------
       
   206 //
       
   207 void CDefaultAppGSPlugin::GetCaptionL( TDes& aCaption ) const
       
   208     {
       
   209     HBufC* result = StringLoader::LoadL( R_GS_DEFAULTAPP_CAPTION );
       
   210     aCaption.Copy( *result );
       
   211     delete result;
       
   212     }
       
   213 
       
   214 // ---------------------------------------------------------------------------
       
   215 // From class CGSPluginInterface.
       
   216 // Return the icon, if has one.
       
   217 // ---------------------------------------------------------------------------
       
   218 //
       
   219 CGulIcon* CDefaultAppGSPlugin::CreateIconL( const TUid aIconType )
       
   220     {
       
   221     //EMbm<Mbm_file_name><Bitmap_name>
       
   222     CGulIcon* icon;    
       
   223 
       
   224     if( aIconType == KGSIconTypeLbxItem )
       
   225         {
       
   226         icon = AknsUtils::CreateGulIconL(
       
   227         AknsUtils::SkinInstance(),
       
   228         KAknsIIDQgnPropCpDevDef,
       
   229         KGSDasPluginIconFileName,
       
   230         EMbmGsdaspluginQgn_prop_cp_dev_def,
       
   231         EMbmGsdaspluginQgn_prop_cp_dev_def_mask );    
       
   232         }
       
   233        else
       
   234         {
       
   235         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   236         };
       
   237 
       
   238     return icon;
       
   239     }
       
   240 
       
   241 // ========================= From MAknServerAppExitObserver ==================
       
   242 
       
   243 // ---------------------------------------------------------------------------
       
   244 // From class MAknServerAppExitObserver.
       
   245 // Handles server exits
       
   246 // ---------------------------------------------------------------------------
       
   247 //
       
   248 void CDefaultAppGSPlugin::HandleServerAppExit( TInt aReason)
       
   249     {
       
   250     delete iClient;
       
   251     iClient=NULL;
       
   252     TRAP_IGNORE(HandleCommandL(aReason));//do not care why it leaved
       
   253     }
       
   254 
       
   255 // End of file