phonebookui/Speeddial/speeddialgsplugin/src/speeddialgsplugin.cpp
changeset 0 e686773b3f54
child 3 04ab22b956c2
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     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:     Source file for CSpeeddialGsPlugin class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #include <aknViewAppUi.h>
       
    23 #include <ConeResLoader.h>
       
    24 #include <barsread.h>       // For TResourceReader
       
    25 #include <StringLoader.h>
       
    26 #include <apgcli.h>
       
    27 #include <AknLaunchAppService.h>
       
    28 #include <bautils.h>
       
    29 
       
    30 // Includes from GS framework:
       
    31 #include <gsfwviewuids.h>
       
    32 #include <GSPrivatePluginProviderIds.h>
       
    33 
       
    34 #include <AknNullService.h>
       
    35 // Plugin includes:
       
    36 #include <speeddialgspluginrsc.rsg>
       
    37 #include <speeddialgsplugin.mbg>
       
    38 
       
    39 // Includes
       
    40 #include "speeddialgsplugin.h"
       
    41 
       
    42 #define SPEEDDIALAPPUID 0x1000590A
       
    43 
       
    44 // CONSTANTS
       
    45 const TUid KSpeeddialGSPluginUid = { 0x1028339F };
       
    46 
       
    47 // svg file
       
    48 _LIT( KGSSecPluginIconFileName, "\\resource\\apps\\speeddialgsplugin.mif");
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CSpeeddialGsPlugin::CSpeeddialGsPlugin()
       
    52 //
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 CSpeeddialGsPlugin::CSpeeddialGsPlugin(): iNullService( NULL )
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CSpeeddialGsPlugin::~CSpeeddialGsPlugin()
       
    61 //
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CSpeeddialGsPlugin::~CSpeeddialGsPlugin()
       
    65     {
       
    66     if (iResId)
       
    67 	{
       
    68         env->DeleteResourceFile(iResId);
       
    69 	}
       
    70     if ( iNullService )
       
    71         {
       
    72             delete iNullService;
       
    73             iNullService=NULL;
       
    74         }
       
    75     }
       
    76 
       
    77 // ---------------------------------------------------------------------------
       
    78 // CSpeeddialGsPlugin::ConstructL()
       
    79 //
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CSpeeddialGsPlugin::ConstructL()
       
    83     {
       
    84     BaseConstructL( );   
       
    85     TFileName resourceFileName;
       
    86     TPtrC driveLetter = TParsePtrC( RProcess().FileName() ).Drive();
       
    87     _LIT( KResoureFileName, "speeddialgspluginrsc.rsc" );
       
    88           
       
    89     resourceFileName.Copy( driveLetter );  
       
    90     resourceFileName.Append( KDC_ECOM_RESOURCE_DIR );
       
    91     resourceFileName.Append( KResoureFileName );
       
    92             
       
    93     env = CEikonEnv::Static();
       
    94 
       
    95     TFileName fileName(resourceFileName);
       
    96 	
       
    97     BaflUtils::NearestLanguageFile(env->FsSession(), fileName);
       
    98 
       
    99     iResId = env->AddResourceFileL(fileName); 
       
   100      }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CSpeeddialGsPlugin::NewL()
       
   104 //
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 CGSPluginInterface* CSpeeddialGsPlugin::NewL( TAny* /*aInitParams*/ )
       
   108   {
       
   109   	CSpeeddialGsPlugin* self = new( ELeave ) CSpeeddialGsPlugin();
       
   110   	CleanupStack::PushL( self );
       
   111   	self->ConstructL();
       
   112   	CleanupStack::Pop( self );
       
   113   	return (CGSPluginInterface*)self;
       
   114   }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // CGSParentPlugin::Id()
       
   118 //
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 TUid CSpeeddialGsPlugin::Id() const
       
   122     {
       
   123  	   return KSpeeddialGSPluginUid;
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // CGSParentPlugin::DoActivateL()
       
   128 //
       
   129 // ---------------------------------------------------------------------------
       
   130 //
       
   131 void CSpeeddialGsPlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   132                                      TUid aCustomMessageId,
       
   133                                      const TDesC8& aCustomMessage )
       
   134     {
       
   135     // nothing
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CGSParentPlugin::DoDeactivate()
       
   140 //
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 void CSpeeddialGsPlugin::DoDeactivate()
       
   144     {
       
   145     // nothing
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CSpeeddialGsPlugin::UpperLevelViewUid()
       
   150 //
       
   151 // ---------------------------------------------------------------------------
       
   152 //
       
   153 TUid CSpeeddialGsPlugin::UpperLevelViewUid()
       
   154     {
       
   155     return KGSTelPluginUid;
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CSpeeddialGsPlugin::GetHelpContext()
       
   160 //
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void CSpeeddialGsPlugin::GetHelpContext( TCoeHelpContext& aContext )
       
   164     {
       
   165     aContext.iMajor = KUidGS;
       
   166     aContext.iContext = NULL;
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CSpeeddialGsPlugin::GetCaptionL()
       
   171 //
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 void CSpeeddialGsPlugin::GetCaptionL( TDes& aCaption ) const
       
   175     {
       
   176     StringLoader::Load( aCaption, R_GS_SPEEDDIAL_VIEW_CAPTION);
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CSpeeddialGsPlugin::PluginProviderCategory()
       
   181 //
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 TInt CSpeeddialGsPlugin::PluginProviderCategory() const
       
   185     {
       
   186    	 return KGSPluginProviderInternal;
       
   187     }
       
   188 
       
   189 
       
   190 // ---------------------------------------------------------------------------
       
   191 // CSpeeddialGsPlugin::CreateIconL
       
   192 // Return the icon, if has one.
       
   193 // ---------------------------------------------------------------------------
       
   194 //
       
   195 CGulIcon* CSpeeddialGsPlugin::CreateIconL( const TUid aIconType )
       
   196     {
       
   197     CGulIcon* icon;
       
   198 
       
   199     if( aIconType == KGSIconTypeLbxItem )
       
   200         {
       
   201         icon = AknsUtils::CreateGulIconL(
       
   202         AknsUtils::SkinInstance(),
       
   203         KAknsIIDQgnPropCpTeleSpeed,
       
   204         KGSSecPluginIconFileName,
       
   205         EMbmSpeeddialgspluginQgn_prop_cp_tele_speed,
       
   206         EMbmSpeeddialgspluginQgn_prop_cp_tele_speed_mask );
       
   207         }
       
   208      else
       
   209         {
       
   210         icon = CGSPluginInterface::CreateIconL( aIconType );
       
   211         }
       
   212 
       
   213     return icon;
       
   214     }
       
   215 
       
   216 
       
   217 // -----------------------------------------------------------------------------
       
   218 // CSpeeddialGsPlugin::ListBoxType()
       
   219 //
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 TGSListboxTypes CSpeeddialGsPlugin::ListBoxType()
       
   223     {
       
   224     return EGSListBoxTypeSettings;
       
   225     }
       
   226     
       
   227 
       
   228 // -----------------------------------------------------------------------------
       
   229 // CSpeeddialGsPlugin::HandleSelection()
       
   230 // -----------------------------------------------------------------------------
       
   231 //
       
   232 void CSpeeddialGsPlugin::HandleSelection(
       
   233     const TGSSelectionTypes /*aSelectionType*/ )
       
   234 {
       
   235     TRAP_IGNORE(LaunchEasAppL());
       
   236 }
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // CSpeeddialGsPlugin::ItemType()
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 TGSListboxItemTypes CSpeeddialGsPlugin::ItemType()
       
   243 {
       
   244     return EGSItemTypeSettingDialog;
       
   245 }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CEasGSPlugin::LaunchEasAppL()
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CSpeeddialGsPlugin::LaunchEasAppL()
       
   252 {
       
   253     // UID belongs easapp.exe
       
   254     const TUid KAppUid = { SPEEDDIALAPPUID };
       
   255     
       
   256     RWsSession ws;
       
   257     User::LeaveIfError( ws.Connect() );
       
   258     CleanupClosePushL( ws );
       
   259 
       
   260     // Find the task with uid
       
   261     TApaTaskList taskList(ws);
       
   262     TApaTask task = taskList.FindApp( KAppUid );
       
   263 
       
   264     if ( task.Exists() )
       
   265     {
       
   266         task.BringToForeground();
       
   267     }
       
   268     else
       
   269     {
       
   270         // Launch application as embedded.
       
   271         if ( iNullService )
       
   272         {
       
   273             delete iNullService;
       
   274             iNullService = NULL;
       
   275         }
       
   276         iNullService = CAknNullService::NewL( KAppUid, NULL );
       
   277     } 
       
   278     ws.Close();
       
   279     CleanupStack::PopAndDestroy();
       
   280 }
       
   281 
       
   282 void CSpeeddialGsPlugin::HandleServerAppExit( TInt aReason )
       
   283     {
       
   284     if ( aReason != EEikCmdExit )
       
   285         {
       
   286         MAknServerAppExitObserver::HandleServerAppExit( aReason );
       
   287         }
       
   288     }
       
   289 //End of File
       
   290