voiceui/vccontrolpanelplugin/src/vccontrolpanelplugin.cpp
branchRCL_3
changeset 19 e36f3802f733
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     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:  VCommand control panel plugin implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // GS Framework and this plugin.
       
    20 #include    "vccontrolpanelplugin.h"
       
    21 #include    <vccontrolpanelplugin.mbg>
       
    22 #include    <gsparentplugin.h>
       
    23 #include    <gscommon.hrh>
       
    24 #include    <vccontrolpanelpluginrsc.rsg>
       
    25 #include    <gsprivatepluginproviderids.h>
       
    26 #include    <gsfwviewuids.h>
       
    27 #include    <AknsUtils.h> 
       
    28 
       
    29 // General services.
       
    30 #include    <AknNullService.h>
       
    31 #include    <bautils.h>
       
    32 #include    <StringLoader.h>
       
    33 
       
    34 // This application's resource file.
       
    35 _LIT( KVcControlPanelPluginResourceFileName, "z:vccontrolpanelpluginrsc.rsc" );
       
    36 _LIT( KIconFileName, "z:vccontrolpanelplugin.mif");
       
    37 
       
    38 // ========================= MEMBER FUNCTIONS ================================
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // Constructor
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 CVcControlPanelPlugin::CVcControlPanelPlugin() : iResources( *iCoeEnv ), iNullService( NULL )
       
    45     {
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // Destructor
       
    50 // ---------------------------------------------------------------------------
       
    51 //
       
    52 CVcControlPanelPlugin::~CVcControlPanelPlugin()
       
    53     {
       
    54     iResources.Close();
       
    55 
       
    56     if ( iNullService )
       
    57         {
       
    58         delete iNullService;
       
    59         }
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // Symbian OS two-phased constructor
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 void CVcControlPanelPlugin::ConstructL()
       
    67     {
       
    68     OpenLocalizedResourceFileL( KVcControlPanelPluginResourceFileName, iResources );    
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------------------------
       
    72 // Static constructor
       
    73 // ---------------------------------------------------------------------------
       
    74 //
       
    75 CVcControlPanelPlugin* CVcControlPanelPlugin::NewL( TAny* /*aInitParams*/ )
       
    76     {
       
    77     CVcControlPanelPlugin* self = new( ELeave ) CVcControlPanelPlugin();
       
    78     CleanupStack::PushL( self );
       
    79     self->ConstructL();
       
    80     CleanupStack::Pop( self );
       
    81     return self;
       
    82     }
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CVcControlPanelPlugin::Id
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 TUid CVcControlPanelPlugin::Id() const
       
    89     {
       
    90     return KDllTUid;
       
    91     }
       
    92 
       
    93 // -----------------------------------------------------------------------------
       
    94 // CVcControlPanelPlugin::DoActivateL
       
    95 // -----------------------------------------------------------------------------
       
    96 //
       
    97 void CVcControlPanelPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
    98                                   TUid /*aCustomMessageId*/,
       
    99                                   const TDesC8& /*aCustomMessage*/ )
       
   100     {
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CVcControlPanelPlugin::DoDeactivate
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 void CVcControlPanelPlugin::DoDeactivate()
       
   108     {
       
   109     }
       
   110 
       
   111 // ========================= From CGSPluginInterface ==================
       
   112 // -----------------------------------------------------------------------------
       
   113 // CVcControlPanelPlugin::GetCaptionL
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 void CVcControlPanelPlugin::GetCaptionL( TDes& aCaption ) const
       
   117     {
       
   118     HBufC* result = StringLoader::LoadL( R_VCOMMAND_CONTROL_PANEL_PLUGIN_CAPTION );
       
   119     aCaption.Copy( *result );
       
   120     delete result;
       
   121     }
       
   122     
       
   123 // ---------------------------------------------------------
       
   124 // CVcControlPanelPlugin::CreateIconL
       
   125 // ---------------------------------------------------------
       
   126 //    
       
   127 CGulIcon* CVcControlPanelPlugin::CreateIconL( const TUid aIconType )
       
   128     {
       
   129     CGulIcon* icon;
       
   130     
       
   131     TParse parse;
       
   132     parse.Set( KIconFileName, &KDC_BITMAP_DIR, NULL );
       
   133     TFileName fileName( parse.FullName() );
       
   134 
       
   135     if ( aIconType == KGSIconTypeLbxItem )
       
   136         {
       
   137         icon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), KAknsIIDQgnPropCpDevVc, fileName,
       
   138                                           EMbmVccontrolpanelpluginQgn_prop_cp_dev_vc,
       
   139                                           EMbmVccontrolpanelpluginQgn_prop_cp_dev_vc_mask );
       
   140         }
       
   141     else
       
   142         {
       
   143         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   144         }
       
   145 
       
   146     return icon;
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CVcControlPanelPlugin::PluginProviderCategory
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TInt CVcControlPanelPlugin::PluginProviderCategory() const
       
   154     {
       
   155     return KGSPluginProviderInternal;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CVcControlPanelPlugin::ItemType()
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 TGSListboxItemTypes CVcControlPanelPlugin::ItemType()
       
   163     {
       
   164     return EGSItemTypeSettingDialog;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CVcControlPanelPlugin::GetValue()
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CVcControlPanelPlugin::GetValue( const TGSPluginValueKeys /*aKey*/,
       
   172                                       TDes& /*aValue*/ )
       
   173     {
       
   174     }
       
   175 
       
   176 // -----------------------------------------------------------------------------
       
   177 // CVcControlPanelPlugin::HandleSelection()
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CVcControlPanelPlugin::HandleSelection(
       
   181     const TGSSelectionTypes /*aSelectionType*/ )
       
   182     {
       
   183     TRAP_IGNORE( LaunchVCommandAppL() );
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CVcControlPanelPlugin::OpenLocalizedResourceFileL()
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 void CVcControlPanelPlugin::OpenLocalizedResourceFileL(
       
   191     const TDesC& aResourceFileName,
       
   192     RConeResourceLoader& aResourceLoader )
       
   193     {
       
   194     // Find the resource file:
       
   195     TParse* parse = new (ELeave) TParse;
       
   196     CleanupStack::PushL( parse );
       
   197     parse->Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
   198     TFileName* fileName = new (ELeave) TFileName( parse->FullName() );
       
   199     CleanupStack::PushL( fileName );
       
   200 
       
   201     // Open resource file:
       
   202     aResourceLoader.OpenL( *fileName );
       
   203     
       
   204     CleanupStack::PopAndDestroy( fileName );
       
   205     CleanupStack::PopAndDestroy( parse );
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CVcControlPanelPlugin::LaunchVCommandAppL()
       
   210 // -----------------------------------------------------------------------------
       
   211 //
       
   212 void CVcControlPanelPlugin::LaunchVCommandAppL()
       
   213     {
       
   214     // Get the correct application data
       
   215     RWsSession ws;
       
   216     User::LeaveIfError( ws.Connect() );
       
   217     CleanupClosePushL( ws );
       
   218 
       
   219     // Find the task with uid
       
   220     TApaTaskList taskList(ws);
       
   221     TApaTask task = taskList.FindApp( KVCommandAppTUid );
       
   222 
       
   223     if ( task.Exists() )
       
   224         {
       
   225         task.BringToForeground();
       
   226         }
       
   227     // Launch VCommand as embedded.
       
   228     else
       
   229         {
       
   230         if ( iNullService )
       
   231             {
       
   232             delete iNullService;
       
   233             iNullService = NULL;
       
   234             }
       
   235         // Catch the pointer to prevent a memory leak
       
   236         iNullService = CAknNullService::NewL( KVCommandAppTUid, this );
       
   237         }
       
   238     CleanupStack::PopAndDestroy();  // ws
       
   239     }
       
   240 
       
   241 // End of file