omads/omadsappui/OmaDsAppUiPlugin/src/OmaDsAppUiPluginInterface.cpp
changeset 19 2691f6aa1921
parent 4 e6e896426eac
child 20 e1de7d03f843
equal deleted inserted replaced
4:e6e896426eac 19:2691f6aa1921
     1 /*
       
     2 * Copyright (c) 2002 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:  Nsml DS settings Ecom plugin Impln.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //System Includes
       
    20 #include <e32std.h>
       
    21 #include <implementationproxy.h>
       
    22 #include <StringLoader.h>
       
    23 #include <bautils.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <gulicon.h>
       
    26 #include <akntitle.h>
       
    27 
       
    28 // Required only for embedded app
       
    29 #include <AknNullService.h>
       
    30 #include <apgtask.h>
       
    31 
       
    32 // User includes
       
    33 #include "OmaDsAppUiPluginInterface.h"
       
    34 #include "gsprivatepluginproviderids.h"
       
    35 #include <nsmldssync.mbg>
       
    36 #include "NsmlDSGSPluginResource.rsg"
       
    37 
       
    38 
       
    39 _LIT(KNsmlDsIconFileName, "Z:\\resource\\apps\\nsmldssync.mif");
       
    40 _LIT(KNsmlDsResFileName,  "Z:\\resource\\NsmlDSGSPluginResource.rsc" );
       
    41 
       
    42 // ---------------------------------------------------------------------------------------------
       
    43 // COmaDsAppUiPluginInterface::NewLC
       
    44 // returns an object of COmaDsAppUiPluginInterface
       
    45 // ---------------------------------------------------------------------------------------------
       
    46 //
       
    47 CGSPluginInterface* COmaDsAppUiPluginInterface::NewL()
       
    48     {
       
    49 	COmaDsAppUiPluginInterface* self = new(ELeave) COmaDsAppUiPluginInterface();
       
    50     CleanupStack::PushL(self);
       
    51     self->ConstructL();
       
    52 	CleanupStack::Pop(self);
       
    53 	return (CGSPluginInterface*) self;
       
    54 	}
       
    55 
       
    56 // ---------------------------------------------------------------------------------------------
       
    57 // COmaDsAppUiPluginInterface::Id()
       
    58 // returns the view id
       
    59 // ---------------------------------------------------------------------------------------------
       
    60 //
       
    61 TUid COmaDsAppUiPluginInterface::Id() const
       
    62 	{
       
    63 	return TUid::Uid( KUidNsmlDSGSPluginDll );	
       
    64 	}
       
    65 
       
    66 // ---------------------------------------------------------------------------------------------
       
    67 // COmaDsAppUiPluginInterface::ConstructL
       
    68 // ---------------------------------------------------------------------------------------------
       
    69 //	
       
    70 void COmaDsAppUiPluginInterface::ConstructL()
       
    71 	{
       
    72 	BaseConstructL(); 
       
    73 	
       
    74     env = CEikonEnv::Static();
       
    75 
       
    76 	TFileName fileName(KNsmlDsResFileName);
       
    77 	
       
    78 	BaflUtils::NearestLanguageFile(env->FsSession(), fileName);
       
    79 
       
    80 	iResId = env->AddResourceFileL(fileName);
       
    81 	}
       
    82 
       
    83 
       
    84 // ---------------------------------------------------------------------------------------------
       
    85 // COmaDsAppUiPluginInterface::COmaDsAppUiPluginInterface
       
    86 // ---------------------------------------------------------------------------------------------
       
    87 //    
       
    88 COmaDsAppUiPluginInterface::COmaDsAppUiPluginInterface() : iNullService( NULL )
       
    89 	{
       
    90 	// Nothing
       
    91 	}
       
    92 
       
    93 // ---------------------------------------------------------------------------------------------
       
    94 // COmaDsAppUiPluginInterface::~COmaDsAppUiPluginInterface
       
    95 // ---------------------------------------------------------------------------------------------
       
    96 //
       
    97 COmaDsAppUiPluginInterface::~COmaDsAppUiPluginInterface()
       
    98 	{
       
    99 	if (iResId)
       
   100 		{
       
   101     	env->DeleteResourceFile(iResId);
       
   102 		}	
       
   103 	if ( iNullService )
       
   104         {
       
   105             delete iNullService;
       
   106             iNullService = NULL;
       
   107         }
       
   108 	}
       
   109 
       
   110 // ---------------------------------------------------------------------------------------------
       
   111 // COmaDsAppUiPluginInterface::GetCaptionL
       
   112 // returns the caption to be shown in GS view
       
   113 // ---------------------------------------------------------------------------------------------
       
   114 //
       
   115 void COmaDsAppUiPluginInterface::GetCaptionL( TDes& aCaption ) const
       
   116     {
       
   117     StringLoader::Load( aCaption, R_DS_GS_TITLE);
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------------------------
       
   121 // COmaDsAppUiPluginInterface::CreateIconL
       
   122 // returns the icon to be shown in GS view
       
   123 // ---------------------------------------------------------------------------------------------
       
   124 //
       
   125 CGulIcon* COmaDsAppUiPluginInterface::CreateIconL( const TUid /*aIconType*/ )
       
   126 	{
       
   127 	CFbsBitmap* bitmap = NULL;
       
   128     CFbsBitmap* mask = NULL;                                               
       
   129  
       
   130     MAknsSkinInstance* instance = AknsUtils::SkinInstance();    
       
   131     AknsUtils::CreateIconL(instance, KAknsIIDQgnPropCpConnDatasync, bitmap, mask,
       
   132     					KNsmlDsIconFileName,
       
   133     					EMbmNsmldssyncQgn_prop_cp_conn_datasync,
       
   134     					EMbmNsmldssyncQgn_prop_cp_conn_datasync_mask);
       
   135 
       
   136     CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   137     icon->SetBitmapsOwnedExternally( EFalse );
       
   138     bitmap = NULL;
       
   139     mask = NULL;      
       
   140     return icon;    
       
   141 	}
       
   142 	
       
   143 // -----------------------------------------------------------------------------
       
   144 // COmaDsAppUiPluginInterface::HandleSelection()
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 void COmaDsAppUiPluginInterface::HandleSelection(
       
   148     	const TGSSelectionTypes /*aSelectionType*/ )
       
   149 	{
       
   150 		TRAP_IGNORE(LaunchDsAppL());
       
   151 	}
       
   152     
       
   153 // ---------------------------------------------------------------------------------------------
       
   154 // COmaDsAppUiPluginInterface::LaunchDsAppL
       
   155 // ---------------------------------------------------------------------------------------------
       
   156 //
       
   157 void COmaDsAppUiPluginInterface::LaunchDsAppL()
       
   158 	{
       
   159 	TUid KAppUid( TUid::Uid( KDsAppUid ) );
       
   160 
       
   161 	RWsSession ws;
       
   162     User::LeaveIfError( ws.Connect() );
       
   163     CleanupClosePushL( ws );
       
   164     
       
   165 	TApaTaskList taskList( ws );
       
   166     TApaTask task = taskList.FindApp( KAppUid );
       
   167 
       
   168     if ( task.Exists() )
       
   169    		{
       
   170     	task.BringToForeground();
       
   171     	}
       
   172     else
       
   173     	{
       
   174         // Launch application as embedded.
       
   175         if ( iNullService )
       
   176         	{
       
   177             delete iNullService;
       
   178             iNullService = NULL;
       
   179         	}
       
   180         iNullService = CAknNullService::NewL( KAppUid, this );
       
   181     	}
       
   182     
       
   183 	CleanupStack::PopAndDestroy();
       
   184   	}
       
   185 	
       
   186 // ---------------------------------------------------------------------------------------------
       
   187 // COmaDsAppUiPluginInterface::DoActivateL
       
   188 // ---------------------------------------------------------------------------------------------
       
   189 //
       
   190 void COmaDsAppUiPluginInterface::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
       
   191 											 TUid /*aCustomMessageId*/,
       
   192 											 const TDesC8& /*aCustomMessage*/)
       
   193 	{
       
   194 	// Nothing
       
   195 	}
       
   196 
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // COmaDsAppUiPluginInterface::PluginProviderCategory
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 TInt COmaDsAppUiPluginInterface::PluginProviderCategory() const
       
   203 	{
       
   204     return KGSPluginProviderInternal;
       
   205 	}
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // COmaDsAppUiPluginInterface::ItemType()
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 TGSListboxItemTypes COmaDsAppUiPluginInterface::ItemType()
       
   212 	{
       
   213     return EGSItemTypeSettingDialog;
       
   214 	}
       
   215 
       
   216 // ---------------------------------------------------------------------------------------------
       
   217 // COmaDsAppUiPluginInterface::DoDeactivate
       
   218 // ---------------------------------------------------------------------------------------------
       
   219 //	
       
   220 void COmaDsAppUiPluginInterface::DoDeactivate()
       
   221 	{
       
   222 	// Nothing
       
   223 	}
       
   224 
       
   225 // End of File