deviceencryption/DevEncGsPlugin/src/devencgsplugin.cpp
changeset 14 1957042d8c7e
parent 1 d1daf54a55b5
child 16 ada7962b4308
equal deleted inserted replaced
1:d1daf54a55b5 14:1957042d8c7e
     1 /*
       
     2 * Copyright (c) 2005 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:  GSProfilesPlugin implementation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // User includes
       
    20 #include    "devencgsplugin.h"
       
    21 #include    <GSParentPlugin.h>
       
    22 #include    <GSCommon.hrh>
       
    23 #include    <devencgspluginrsc.rsg> // GUI Resource
       
    24 //#include    <DevEncUi.rsg>
       
    25 #include    <devencgsplugin.mbg>
       
    26 #include    <GSPrivatePluginProviderIds.h>
       
    27 #include    <hwrmvibrasdkcrkeys.h>
       
    28 #include    <AknLaunchAppService.h>
       
    29 #include    <AiwCommon.h>
       
    30 // System includes
       
    31 #include    <AknNullService.h>
       
    32 #include    <bautils.h>
       
    33 #include    <StringLoader.h>
       
    34 
       
    35 // ========================= MEMBER FUNCTIONS ================================
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CDeviceEncryptionGsPlugin::CDeviceEncryptionGsPlugin
       
    39 //
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CDeviceEncryptionGsPlugin::CDeviceEncryptionGsPlugin()
       
    43     : iResources( *iCoeEnv ), iNullService(NULL)
       
    44     {
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CDeviceEncryptionGsPlugin::~CDeviceEncryptionGsPlugin
       
    50 //
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CDeviceEncryptionGsPlugin::~CDeviceEncryptionGsPlugin()
       
    54     {
       
    55     iResources.Close();
       
    56 
       
    57     if ( iNullService )
       
    58         {
       
    59         delete iNullService;
       
    60         }
       
    61     }
       
    62 
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CDeviceEncryptionGsPlugin::ConstructL
       
    66 //
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 void CDeviceEncryptionGsPlugin::ConstructL()
       
    70     {
       
    71     OpenLocalizedResourceFileL( KDeviceEncryptionGsPluginResourceFileName, iResources );
       
    72     }
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CDeviceEncryptionGsPlugin::NewL
       
    77 //
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CDeviceEncryptionGsPlugin* CDeviceEncryptionGsPlugin::NewL( TAny* /*aInitParams*/ )
       
    81     {
       
    82     CDeviceEncryptionGsPlugin* self = new ( ELeave ) CDeviceEncryptionGsPlugin();
       
    83     CleanupStack::PushL(self);
       
    84     self->ConstructL();
       
    85     CleanupStack::Pop(self);
       
    86     return self;
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CDeviceEncryptionGsPlugin::Id (from CGSPluginInterface)
       
    92 //
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 TUid CDeviceEncryptionGsPlugin::Id() const
       
    96     {
       
    97     return KDeviceEncryptionGsPluginImplUID;
       
    98     }
       
    99 
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CDeviceEncryptionGsPlugin::DoActivateL (from CGSPluginInterface)
       
   103 //
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 void CDeviceEncryptionGsPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
       
   107                                   TUid /*aCustomMessageId*/,
       
   108                                   const TDesC8& /*aCustomMessage*/ )
       
   109     {
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CDeviceEncryptionGsPlugin::DoDeactivate (from CGSPluginInterface)
       
   115 //
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CDeviceEncryptionGsPlugin::DoDeactivate()
       
   119     {
       
   120     }
       
   121 
       
   122 
       
   123 
       
   124 // -----------------------------------------------------------------------------
       
   125 // CDeviceEncryptionGsPlugin::GetCaptionL (from CGSPluginInterface)
       
   126 //
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CDeviceEncryptionGsPlugin::GetCaptionL( TDes& aCaption ) const
       
   130     {
       
   131 //    HBufC* result = iEikonEnv->AllocReadResourceAsDes16L( R_GS_DE_PLUGIN_CAPTION );
       
   132     HBufC* result = StringLoader::LoadL( R_GS_DE_PLUGIN_CAPTION );
       
   133     
       
   134     if (result->Des().Length() < aCaption.MaxLength())
       
   135         {
       
   136         aCaption.Copy( *result );
       
   137         }
       
   138     else
       
   139         {
       
   140         aCaption = KNullDesC;
       
   141         }
       
   142    
       
   143     delete result;
       
   144 //    aCaption.Copy( _L("Device Encryption") );
       
   145     }
       
   146 
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CDeviceEncryptionGsPlugin::PluginProviderCategory (from CGSPluginInterface)
       
   150 //
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 TInt CDeviceEncryptionGsPlugin::PluginProviderCategory() const
       
   154     {
       
   155     return KGSPluginProviderInternal;
       
   156     }
       
   157 
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CDeviceEncryptionGsPlugin::ItemType (from CGSPluginInterface)
       
   161 //
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 TGSListboxItemTypes CDeviceEncryptionGsPlugin::ItemType()
       
   165     {
       
   166     return EGSItemTypeSettingDialog;
       
   167     }
       
   168 
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // CDeviceEncryptionGsPlugin::GetValue (from CGSPluginInterface)
       
   172 //
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 void CDeviceEncryptionGsPlugin::GetValue( const TGSPluginValueKeys /*aKey*/,
       
   176                                       TDes& /*aValue*/ )
       
   177     {
       
   178     }
       
   179 
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CDeviceEncryptionGsPlugin::HandleSelection (from CGSPluginInterface)
       
   183 //
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 void CDeviceEncryptionGsPlugin::HandleSelection(
       
   187     const TGSSelectionTypes /*aSelectionType*/ )
       
   188     {
       
   189     //TRAP_IGNORE( LaunchDEAppL() );
       
   190     LaunchDEAppL();
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------------------------
       
   194 // CDeviceEncryptionGsPlugin::CreateIconL (from CGSPluginInterface)
       
   195 //
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 
       
   199 CGulIcon* CDeviceEncryptionGsPlugin::CreateIconL( const TUid aIconType )
       
   200     {
       
   201     CGulIcon* icon;
       
   202     TParse* fp = new ( ELeave ) TParse();
       
   203     CleanupStack::PushL( fp );
       
   204     fp->Set( KDeviceEncryptionGsPluginIconDirAndName, &KDC_BITMAP_DIR, NULL );
       
   205 
       
   206     if ( aIconType == KGSIconTypeLbxItem )
       
   207         {
       
   208         icon = AknsUtils::CreateGulIconL(
       
   209         AknsUtils::SkinInstance(),
       
   210         KAknsIIDQgnPropCpPersoProf,
       
   211         //KAknsIIDQgnPropCpDevenc,
       
   212         fp->FullName(),
       
   213         EMbmDevencgspluginQgn_prop_cp_devenc,
       
   214         EMbmDevencgspluginQgn_prop_cp_devenc_mask );
       
   215         }    
       
   216     else
       
   217         {
       
   218         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   219         }
       
   220 
       
   221     CleanupStack::PopAndDestroy( fp );
       
   222 
       
   223     return icon;
       
   224     }
       
   225 
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CDeviceEncryptionGsPlugin::OpenLocalizedResourceFileL
       
   229 //
       
   230 // -----------------------------------------------------------------------------
       
   231 
       
   232 void CDeviceEncryptionGsPlugin::OpenLocalizedResourceFileL(
       
   233     const TDesC& aResourceFileName,
       
   234     RConeResourceLoader& aResourceLoader )
       
   235     {
       
   236     RFs fsSession;
       
   237     User::LeaveIfError( fsSession.Connect() );
       
   238     CleanupClosePushL(fsSession);
       
   239 
       
   240     // Find the resource file:
       
   241     TParse parse;
       
   242     parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL );
       
   243     TFileName fileName( parse.FullName() );
       
   244 
       
   245     // Get language of resource file:
       
   246     BaflUtils::NearestLanguageFile( fsSession, fileName );
       
   247 
       
   248     // Open resource file:
       
   249     aResourceLoader.OpenL( fileName );
       
   250 
       
   251     CleanupStack::PopAndDestroy(&fsSession);
       
   252     }
       
   253 
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // CDeviceEncryptionGsPlugin::LaunchProfilesAppL
       
   257 //
       
   258 // -----------------------------------------------------------------------------
       
   259 //
       
   260 void CDeviceEncryptionGsPlugin::LaunchDEAppL()
       
   261     {
       
   262     // Get the correct application data
       
   263     RWsSession ws;
       
   264     User::LeaveIfError(ws.Connect());
       
   265     CleanupClosePushL(ws);
       
   266 
       
   267     // Find the task with uid
       
   268     TApaTaskList taskList(ws);
       
   269     TApaTask task = taskList.FindApp( KDeviceEncryptionAppUid );
       
   270 
       
   271     if ( task.Exists() )
       
   272         {
       
   273         task.BringToForeground();
       
   274         }
       
   275     else
       
   276         {
       
   277         //Launch application as embedded
       
   278         TAppInfo app( KDeviceEncryptionAppUid, KDeviceEncryptionApp );
       
   279         iEmbedded=NULL;
       
   280         EmbedAppL( app );
       
   281         }
       
   282     CleanupStack::PopAndDestroy(&ws);
       
   283     }
       
   284 
       
   285 
       
   286 // -----------------------------------------------------------------------------
       
   287 // CDeviceEncryptionGsPlugin::EmbedAppL
       
   288 //
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 void CDeviceEncryptionGsPlugin::EmbedAppL( const TAppInfo& aApp )
       
   292     {
       
   293     if ( iNullService )
       
   294         {
       
   295         delete iNullService;
       
   296         iNullService = NULL;
       
   297         }
       
   298     iNullService = CAknNullService::NewL( aApp.iUid, this );
       
   299     }
       
   300 
       
   301 // End of file