phonesettings/pslncallimageplugin/src/PslnCallImagePlugin.cpp
changeset 0 5f000ab63145
child 1 838b0a10d15b
equal deleted inserted replaced
-1:000000000000 0:5f000ab63145
       
     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:  View for Phone Application skinning.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 // This plugin specific.
       
    22 #include <PslnCallImagePluginRsc.rsg>
       
    23 #include <pslncallimageplugin.mbg>
       
    24 #include "PslnCallImagePlugin.h"
       
    25 #include "PslnCallImagePluginContainer.h"
       
    26 #include "PslnCallImagePluginDRM.h"
       
    27 
       
    28 // General services.
       
    29 #include <gulicon.h>
       
    30 #include <bautils.h>
       
    31 #include <eikfrlbd.h>
       
    32 #include <StringLoader.h>
       
    33 #include <aknViewAppUi.h>
       
    34 #include <featmgr.h>
       
    35 #include <ConeResLoader.h>
       
    36 #include <pslninternalcrkeys.h>
       
    37 #include <AknsSrvClient.h>
       
    38 #include <aknnotewrappers.h>
       
    39 #include <AknsWallpaperUtils.h>
       
    40 
       
    41 // Psln Framework specific.
       
    42 #include <pslnfwviewuids.h>
       
    43 #include <psln.hrh>
       
    44 #include <pslncommon.rsg>
       
    45 
       
    46 // General services
       
    47 #include <MGFetch.h>
       
    48 
       
    49 // Resources
       
    50 #include <psln.rsg>
       
    51 
       
    52 // Logging
       
    53 #include "PslnCallImagePluginLogger.h"
       
    54 
       
    55 // CONSTANTS
       
    56 
       
    57 // Path to mbm file.
       
    58 _LIT( KPslnPhoneApplicationIconFileName, "z:PslnCallImagePlugin.mbm");
       
    59 
       
    60 // Path to compiled resource file.
       
    61 _LIT( KPslnCallImagePluginResourceFileName, "z:PslnCallImagePluginRsc.rsc" );
       
    62 
       
    63 // Path to common personalization resources. This resource file is meant for 
       
    64 // shared resources between application and plugins.
       
    65 _LIT( KPslnCommonResourceFileName, "z:pslncommon.rsc" );
       
    66 
       
    67 // Path to Psln application resource file. Plugin uses some localized texts from Psln's
       
    68 // resources,
       
    69 _LIT( KPslnApplicationResourceFileName, "z:Psln.rsc" );
       
    70 
       
    71 // Extension for scalable vector graphics file.
       
    72 _LIT( KAknsSkinSrvSvgFileExt, ".svg" );
       
    73 
       
    74 // Selected file.
       
    75 const TInt KPslnSelectedFile = 0;
       
    76 
       
    77 // Location of this plugin view within Psln's tab group.
       
    78 const TInt KPslnApplicationPhonePluginLocation = 5;
       
    79 
       
    80 const TInt KPslnFileArrayGranularity = 3;
       
    81 
       
    82 // Middle Softkey control ID.
       
    83 const TInt KPslnMSKControlId = 3;
       
    84 
       
    85 // ========================= MEMBER FUNCTIONS ================================
       
    86 
       
    87 // ----------------------------------------------------------------------------
       
    88 // CPslnCallImagePlugin::CPslnCallImagePlugin()
       
    89 // 
       
    90 // Constructor
       
    91 // ----------------------------------------------------------------------------
       
    92 //
       
    93 CPslnCallImagePlugin::CPslnCallImagePlugin( CAknViewAppUi* aAppUi )
       
    94   : iResourceLoader( *iCoeEnv ), iResourceLoaderCommon( *iCoeEnv ), 
       
    95     iResourceLoaderPsln( *iCoeEnv ), iAppUi ( aAppUi )
       
    96     {
       
    97     }    
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CPslnCallImagePlugin::NewL()
       
   101 // 
       
   102 // Symbian OS default constructor
       
   103 // ---------------------------------------------------------------------------
       
   104 CPslnCallImagePlugin* CPslnCallImagePlugin::NewL( TAny* aAppUi )
       
   105     {
       
   106     __CALLLOGSTRING("CPslnCallImagePlugin::NewL");
       
   107     CAknViewAppUi* appUi = reinterpret_cast<CAknViewAppUi*>( aAppUi );
       
   108     CPslnCallImagePlugin* self = new( ELeave ) CPslnCallImagePlugin ( appUi );
       
   109     
       
   110     CleanupStack::PushL( self );
       
   111     self->ConstructL();    
       
   112     CleanupStack::Pop();
       
   113     
       
   114     return self;
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CPslnCallImagePlugin::ConstructL()
       
   119 // 
       
   120 // Symbian OS two-phased constructor
       
   121 // ---------------------------------------------------------------------------
       
   122 void CPslnCallImagePlugin::ConstructL()
       
   123     {
       
   124     // Find the resource file:
       
   125     TParse parse;
       
   126     parse.Set( KPslnCommonResourceFileName, &KDC_APP_RESOURCE_DIR, NULL );      
       
   127     TFileName* fileName = new (ELeave) TFileName( parse.FullName() );
       
   128     CleanupStack::PushL( fileName );
       
   129 	
       
   130     // Open resource file:
       
   131     iResourceLoaderCommon.OpenL( *fileName );
       
   132     
       
   133     // Find the resource file:
       
   134     parse.Set( KPslnApplicationResourceFileName, &KDC_APP_RESOURCE_DIR, NULL );
       
   135     
       
   136 	OpenLocalizedResourceFileL( 
       
   137         KPslnCallImagePluginResourceFileName, 
       
   138         iResourceLoader );
       
   139 
       
   140     CleanupStack::PopAndDestroy( fileName );
       
   141 
       
   142     BaseConstructL( R_PSLN_CALL_IMAGE_VIEW );    
       
   143     
       
   144     __CALLLOGSTRING("CPslnCallImagePlugin::ConstructL -> METHOD COMPLETED");
       
   145     }
       
   146 
       
   147 // ----------------------------------------------------------------------------
       
   148 // CPslnCallImagePlugin::~CPslnCallImagePlugin
       
   149 // 
       
   150 // Destructor
       
   151 // ----------------------------------------------------------------------------
       
   152 CPslnCallImagePlugin::~CPslnCallImagePlugin()
       
   153     {
       
   154     __CALLLOGSTRING("CPslnCallImagePlugin::~CPslnCallImagePlugin -> START");
       
   155     iResourceLoaderCommon.Close();
       
   156     iResourceLoaderPsln.Close();
       
   157     iResourceLoader.Close();
       
   158     __CALLLOGSTRING("CPslnCallImagePlugin::~CPslnCallImagePlugin -> METHOD COMPLETED");
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // TUid CPslnCallImagePlugin::Id()
       
   163 // 
       
   164 // Returns view's ID.
       
   165 // ---------------------------------------------------------------------------
       
   166 TUid CPslnCallImagePlugin::Id() const
       
   167     {
       
   168     __CALLLOGSTRING("CPslnCallImagePlugin::Id");
       
   169     return KPslnCallImagePluginUid;
       
   170     }
       
   171 
       
   172 // ----------------------------------------------------------------------------
       
   173 // CPslnCallImagePlugin::GetCaption
       
   174 // 
       
   175 // Return application/view caption.
       
   176 // ----------------------------------------------------------------------------
       
   177 //
       
   178 void CPslnCallImagePlugin::GetCaptionL( TDes& aCaption ) const
       
   179     {
       
   180     __CALLLOGSTRING("CPslnCallImagePlugin::GetCaptionL");
       
   181     
       
   182        // the resource file is already opened.
       
   183     HBufC* result = StringLoader::LoadL( R_PSLN_CI_LIST_VIEW_CAPTION );
       
   184     if ( aCaption.MaxLength() >= result->Length() )
       
   185         {
       
   186         aCaption.Copy( *result );
       
   187         }
       
   188     delete result;
       
   189     }    
       
   190 
       
   191 // ----------------------------------------------------------------------------
       
   192 // CPslnCallImagePlugin::GetTabTextL
       
   193 // 
       
   194 // Return application/view caption.
       
   195 // ----------------------------------------------------------------------------
       
   196 //
       
   197 void CPslnCallImagePlugin::GetTabTextL( TDes& aCaption ) const
       
   198     {
       
   199     __CALLLOGSTRING("CPslnCallImagePlugin::GetTabTextL");
       
   200     
       
   201     // the resource file is already opened.
       
   202     HBufC* result = StringLoader::LoadL( R_PSLN_CI_TAB_NAME );
       
   203     if ( aCaption.MaxLength() >= result->Length() )
       
   204         {
       
   205         aCaption.Copy( *result );
       
   206         }
       
   207     delete result;
       
   208     }
       
   209 
       
   210 // ----------------------------------------------------------------------------
       
   211 // CPslnCallImagePlugin::CreateIconL
       
   212 // 
       
   213 // Creates Main view icon.
       
   214 // ----------------------------------------------------------------------------
       
   215 //    
       
   216 CGulIcon* CPslnCallImagePlugin::CreateIconL()
       
   217     {
       
   218     __CALLLOGSTRING("CPslnCallImagePlugin::CreateIconL");
       
   219 
       
   220     // Find the resource file:
       
   221     TParse parse;
       
   222     parse.Set( KPslnPhoneApplicationIconFileName, &KDC_APP_BITMAP_DIR, NULL );
       
   223     TFileName fileName( parse.FullName() );
       
   224     
       
   225     CGulIcon* icon = AknsUtils::CreateGulIconL(
       
   226         AknsUtils::SkinInstance(), 
       
   227         KAknsIIDQgnPropPslnCimageSub, 
       
   228         fileName,
       
   229         EMbmPslncallimagepluginQgn_prop_psln_cimage_sub,
       
   230         EMbmPslncallimagepluginQgn_prop_psln_cimage_sub_mask
       
   231         );
       
   232 
       
   233     return icon;
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CPslnCallImagePlugin::GetLocationTypeAndIndex()
       
   238 //
       
   239 //
       
   240 // -----------------------------------------------------------------------------
       
   241 //
       
   242 void CPslnCallImagePlugin::GetLocationTypeAndIndex( 
       
   243             TPslnFWLocationType& aType, 
       
   244             TInt& aIndex ) const
       
   245     {
       
   246     __CALLLOGSTRING("CPslnCallImagePlugin::GetLocationTypeAndIndex");
       
   247     aType = CPslnFWPluginInterface::EPslnFWSpecified;
       
   248     aIndex = KPslnApplicationPhonePluginLocation;
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // CPslnCallImagePlugin::HandleCommandL(TInt aCommand)
       
   253 // 
       
   254 // Handles commands directed to this class.
       
   255 // ---------------------------------------------------------------------------
       
   256 //
       
   257 void CPslnCallImagePlugin::HandleCommandL( TInt aCommand )
       
   258     {
       
   259     __CALLLOGSTRING("CPslnCallImagePlugin::HandleCommandL -> START");
       
   260     switch ( aCommand )
       
   261         {
       
   262         case EPslnCmdAppDownload:
       
   263         case EPslnCmdAppActivate:
       
   264         case EAknSoftkeyOk:
       
   265             if ( iContainer->iListBox->CurrentItemIndex() == 
       
   266                  EPlsnCallImageThemeImage )
       
   267                 {
       
   268                 SetCallImageSettingL( EPlsnCRThemeImage );
       
   269                 }
       
   270         	else if ( iContainer->iListBox->CurrentItemIndex() == 
       
   271         	          EPlsnCallImageUserDefinedImage )
       
   272             	{
       
   273             	// Don't launch more than one image selection at time
       
   274             	if ( !iVerifier )
       
   275             	    {
       
   276             	    __CALLLOGSTRING("CPslnCallImagePlugin::HandleCommandL -> SetCallImage");
       
   277                     SetCallImageL();
       
   278             	    }
       
   279            		}
       
   280            	else // EPlsnCallImageNone
       
   281            		{
       
   282            		TInt imageError = SetCallImagePath( KNullDesC );
       
   283 	            if ( imageError != KErrNone )
       
   284 	                {
       
   285 	                __CALLLOGSTRING1("CPslnCallImagePlugin::HandleCommandL -> SetCallImagePath error: %d", imageError);
       
   286 	        		HandleImageErrorsL( imageError );
       
   287 	                }
       
   288 	            SetCallImageSettingL( EPlsnCRCallImageNone );
       
   289            		}           		 	
       
   290            	// Update container.
       
   291         	static_cast<CPslnCallImagePluginContainer*>
       
   292         		(iContainer)->UpdateListBoxL();
       
   293         	CheckMiddleSoftkeyLabelL();
       
   294         	break;
       
   295         case EAknSoftkeyBack:
       
   296             if ( iAppUi->View( KPslnMainViewUid ) )
       
   297                 {
       
   298                 __CALLLOGSTRING("CPslnCallImagePlugin::HandleCommandL -> Activate PSLN");
       
   299                 iAppUi->ActivateLocalViewL( KPslnMainViewUid );
       
   300                 }
       
   301             else
       
   302                 {
       
   303                 iAppUi->HandleCommandL( aCommand );
       
   304                 }
       
   305             break;
       
   306         case EPslnCmdAppHelp:
       
   307         case EAknCmdHelp:
       
   308             CPslnFWBaseView::HandleCommandL( aCommand );
       
   309             break;
       
   310         default:
       
   311             // Help and Exit are handled by AppUi.
       
   312             iAppUi->HandleCommandL( aCommand );
       
   313             break;
       
   314         }
       
   315     __CALLLOGSTRING("CPslnCallImagePlugin::HandleCommandL -> METHOD COMPLETED");
       
   316     }
       
   317 
       
   318 // ----------------------------------------------------------------------------
       
   319 // CPslnCallImagePlugin::DynInitMenuPaneL
       
   320 //
       
   321 //
       
   322 // -----------------------------------------------------------------------------
       
   323 //
       
   324 void CPslnCallImagePlugin::DynInitMenuPaneL(  
       
   325 			TInt aResourceId, CEikMenuPane* aMenuPane  )
       
   326     {
       
   327     __CALLLOGSTRING("CPslnCallImagePlugin::DynInitMenuPaneL -> START");
       
   328     if ( aResourceId == R_PSLN_GEN_VIEW_MENUPANE )
       
   329     	{
       
   330         // Since this is common resource it contains download - set it off.
       
   331         aMenuPane->SetItemDimmed( EPslnCmdAppDownload, ETrue );
       
   332         // Since this is common resource it contains activate - set it off.
       
   333         aMenuPane->SetItemDimmed( EPslnCmdAppActivate, ETrue );      	         
       
   334     	}
       
   335    else if ( aResourceId == R_PSLN_CI_BASIC_MENUPANE )
       
   336     	{
       
   337     	TInt active = static_cast<CPslnCallImagePluginContainer*>
       
   338                     (iContainer)->CurrentSelectionIndexL();
       
   339         // Set menu item as Apply, if:
       
   340         // a) 'None' is selected
       
   341         // b) highlight is on inactive selection
       
   342     	if ( active != iContainer->iListBox->CurrentItemIndex() && 
       
   343     	    ( active == EPlsnCallImageNone || 
       
   344     	      active ==  EPlsnCallImageThemeImage ) )
       
   345         	{
       
   346         	aMenuPane->SetItemDimmed( EPslnCmdAppActivate, EFalse );
       
   347         	aMenuPane->SetItemDimmed( EPslnCmdAppDownload, ETrue );
       
   348         	}
       
   349         else if ( ( active == iContainer->iListBox->CurrentItemIndex() ) && 
       
   350             ( active == EPlsnCallImageNone ||
       
   351               active == EPlsnCallImageThemeImage ) )
       
   352         	{
       
   353         	aMenuPane->SetItemDimmed( EPslnCmdAppActivate, ETrue );
       
   354         	aMenuPane->SetItemDimmed( EPslnCmdAppDownload, ETrue );
       
   355         	}
       
   356         else
       
   357         	{
       
   358         	aMenuPane->SetItemDimmed( EPslnCmdAppActivate, ETrue );
       
   359         	aMenuPane->SetItemDimmed( EPslnCmdAppDownload, EFalse );
       
   360         	}	
       
   361 	
       
   362     	if( !FeatureManager::FeatureSupported( KFeatureIdHelp ) )
       
   363             {
       
   364             // Disable help if not supported
       
   365             aMenuPane->SetItemDimmed( EPslnCmdAppHelp, ETrue );
       
   366             }
       
   367     	}
       
   368     __CALLLOGSTRING("CPslnCallImagePlugin::DynInitMenuPaneL <- END");
       
   369     }
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // CPslnCallImagePlugin::SetBoolL
       
   373 // 
       
   374 // Sets boolean to KCRUidThemes key.
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 void CPslnCallImagePlugin::SetCallImageSettingL( const TInt aValue )
       
   378 	{
       
   379 	CRepository* setting = CRepository::NewL ( KCRUidThemes ); 
       
   380 	CleanupStack::PushL( setting );     
       
   381 	setting->Set( KThemesCallImageSetting, aValue );
       
   382 	CleanupStack::PopAndDestroy( setting );
       
   383 	}
       
   384 
       
   385 // ---------------------------------------------------------------------------
       
   386 // CPslnCallImagePlugin::SetPathL
       
   387 // 
       
   388 // Sets path to KCRUidThemes key.
       
   389 // ---------------------------------------------------------------------------
       
   390 //
       
   391 TInt CPslnCallImagePlugin::SetPathL( const TDesC& aPath )
       
   392 	{
       
   393 	CRepository* pathCen = CRepository::NewL ( KCRUidThemes ); 
       
   394 	CleanupStack::PushL( pathCen );    
       
   395 	TInt error = pathCen->Set( KThemesCallImagePath, aPath );
       
   396 	CleanupStack::PopAndDestroy( pathCen );
       
   397 	return error;
       
   398 	}
       
   399 	
       
   400 // ---------------------------------------------------------------------------
       
   401 // CPslnCallImagePlugin::SetCallImageL
       
   402 // 
       
   403 // Sets call image.
       
   404 // ---------------------------------------------------------------------------
       
   405 //
       
   406 void CPslnCallImagePlugin::SetCallImageL()
       
   407 	{
       
   408 	__CALLLOGSTRING("CPslnCallImagePlugin::SetCallImage -> START");
       
   409 	
       
   410 	TInt retVal( KErrNone );
       
   411 	CDesCArrayFlat* files = 
       
   412     	new (ELeave) CDesCArrayFlat( KPslnFileArrayGranularity );
       
   413 	CleanupStack::PushL( files );
       
   414 	// Create DRM verifier
       
   415 	iVerifier = CPslnCallImagePluginDRM::NewL();
       
   416 	// Show images to user to select one	
       
   417 
       
   418 	TBool selectedItem = MGFetch::RunL( *files, EImageFile, EFalse, iVerifier );
       
   419 
       
   420 	if ( !iVerifier )
       
   421 		{
       
   422         __CALLLOGSTRING("CPslnCallImagePlugin::SetCallImage DRM Error");
       
   423 		retVal = KErrCancel;
       
   424 	    }	    
       
   425 	else if( selectedItem && ( files->MdcaCount() > 0 ) )
       
   426 		{
       
   427 	    __CALLLOGSTRING("CPslnCallImagePlugin::SetCallImage Fetch successful");
       
   428 	    retVal = SetCallImagePath( files->MdcaPoint( KPslnSelectedFile ) );
       
   429 	    if ( retVal != KErrNone )
       
   430 	    	{
       
   431 	    	__CALLLOGSTRING1("CPslnCallImagePlugin::SetCallImage -> SetCallImagePath error: %d", retVal );
       
   432 	        HandleImageErrorsL( retVal );
       
   433 	        }
       
   434 	    }
       
   435 	else
       
   436 	   {
       
   437        __CALLLOGSTRING("CPslnCallImagePlugin::SetCallImage Fetch cancelled");
       
   438 	   retVal = KErrCancel;
       
   439 	   }
       
   440 	   
       
   441 	if ( retVal == KErrNone )
       
   442 	    {
       
   443 	    // no way currently of checking corrupted svg:s
       
   444 	    if ( ( files->MdcaPoint( KPslnSelectedFile ).Right( 4 ) ).CompareF( KAknsSkinSrvSvgFileExt ) )
       
   445 	    	{
       
   446 	    	//Before setting image, check is the image corrputed
       
   447 	    	RAknsSrvSession skinsrv;
       
   448 	    	User::LeaveIfError( skinsrv.Connect() );
       
   449 	    	CleanupClosePushL( skinsrv );
       
   450 	    	CFbsBitmap* bmp = NULL;
       
   451 	    	CFbsBitmap* mask = NULL;
       
   452 			// (-1, -1) means that image is just decoded, not used    	
       
   453 	   	 	TRAP( retVal, skinsrv.DecodeWallpaperImageL( files->MdcaPoint( KPslnSelectedFile ), TSize(-1,-1), bmp, mask ) );
       
   454 	        CleanupStack::PopAndDestroy(); // skinsrv
       
   455 	    	}
       
   456 
       
   457 	    if( retVal == KErrNone )
       
   458 	        {
       
   459 	        // If image set without problems update setting.
       
   460 	        SetCallImageSettingL( EPlsnCRUserDefinedImage );
       
   461 	        }
       
   462 	   	else
       
   463 	   	     {
       
   464              //File is corrupted
       
   465              HandleImageErrorsL( retVal );
       
   466 	   	     }
       
   467 		}
       
   468 	
       
   469 	CleanupStack::PopAndDestroy( files );
       
   470 	
       
   471 	if ( iVerifier )
       
   472 	    {
       
   473 	    delete iVerifier;
       
   474 	    iVerifier = NULL;
       
   475 	    }
       
   476 	__CALLLOGSTRING("CPslnCallImagePlugin::SetCallImage -> METHOD COMPLETED");
       
   477 	}
       
   478 // ---------------------------------------------------------------------------
       
   479 // CPslnCallImagePlugin::HandleImageErrorsL
       
   480 // 
       
   481 // Handles image setting errors.
       
   482 // ---------------------------------------------------------------------------
       
   483 //
       
   484 void CPslnCallImagePlugin::HandleImageErrorsL( TInt aError )
       
   485     {
       
   486     __CALLLOGSTRING1("CPslnCallImagePlugin::HandleImageError aError: %d -> START", aError );    
       
   487     TInt resourceId = KErrNone;
       
   488     if ( aError == KErrNoMemory )
       
   489         {
       
   490         // Out of memory when handling the image,
       
   491         User::Leave( aError );
       
   492         }    
       
   493     else
       
   494         {
       
   495         // Image is corrupted or in wrong format
       
   496         resourceId = R_PSLN_IMAGE_CORRUPTED;        
       
   497         }
       
   498 
       
   499     // Show information note
       
   500     HBufC* prompt = iCoeEnv->AllocReadResourceLC( resourceId );
       
   501     CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
       
   502     note->ExecuteLD( *prompt );
       
   503     CleanupStack::PopAndDestroy( prompt );
       
   504     __CALLLOGSTRING("CPslnCallImagePlugin::HandleImageError -> METHOD COMPLETED");
       
   505     }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // CPslnCallImagePlugin::SetCallImagePath
       
   509 // Set call image path.
       
   510 // (other items were commented in a header).
       
   511 // -----------------------------------------------------------------------------
       
   512 //
       
   513 TInt CPslnCallImagePlugin::SetCallImagePath( const TDesC& aImagePath )
       
   514     {
       
   515     __CALLLOGSTRING("CPslnCallImagePlugin::SetCallImagePath -> START");
       
   516     TInt retVal(KErrNone);
       
   517     // If CentralRepository set fails caller will handle the error code.
       
   518     if( aImagePath.Length() >= 0 )
       
   519         {
       
   520         retVal = SetPathL( aImagePath );    
       
   521         }
       
   522     else
       
   523     	{
       
   524     	retVal = KErrPathNotFound;
       
   525     	}
       
   526     	
       
   527 	__CALLLOGSTRING("CPslnCallImagePlugin::SetCallImage -> METHOD COMPLETED");
       
   528     return retVal;
       
   529     }
       
   530 
       
   531 // ----------------------------------------------------------------------------
       
   532 // CPslnCallImagePlugin::Container
       
   533 // 
       
   534 // Return handle to container class.
       
   535 // ----------------------------------------------------------------------------
       
   536 //
       
   537 CPslnCallImagePluginContainer* CPslnCallImagePlugin::Container()
       
   538     {
       
   539     return static_cast<CPslnCallImagePluginContainer*>( iContainer );
       
   540     }
       
   541 
       
   542 // ----------------------------------------------------------------------------
       
   543 // CPslnCallImagePlugin::DoActivateL
       
   544 // 
       
   545 // First method called by the Avkon framwork to invoke a view.
       
   546 // ----------------------------------------------------------------------------
       
   547 //
       
   548 void CPslnCallImagePlugin::DoActivateL( const TVwsViewId& aPrevViewId,
       
   549                                      TUid aCustomMessageId,
       
   550                                      const TDesC8& aCustomMessage )
       
   551     {
       
   552     __CALLLOGSTRING("CPslnCallImagePlugin::DoActivateL");
       
   553     CPslnFWBaseView::DoActivateL( aPrevViewId, aCustomMessageId, aCustomMessage );    
       
   554 
       
   555     // If called from Psln - set tab group location.
       
   556     if ( iAppUi->View( KPslnMainViewUid ) )
       
   557         {
       
   558         // This tries to set the plugin to the given location in Tab.
       
   559         CPslnFWBaseView::SetTabIndex( KPslnApplicationPhonePluginLocation );
       
   560         // This is the location that PslnFW actually put the plugin into. 
       
   561         TInt ciRealLocation = CPslnFWBaseView::GetTabIndex();
       
   562         CPslnFWBaseView::SetNaviPaneL( ciRealLocation );
       
   563         }
       
   564     else
       
   565         {
       
   566         CPslnFWBaseView::SetNaviPaneL();
       
   567         }
       
   568         
       
   569     if ( iContainer )
       
   570         {
       
   571         TInt currentItem = static_cast<CPslnCallImagePluginContainer*>
       
   572                     (iContainer)->CurrentSelectionIndexL();
       
   573         // Set highlight to selected item.
       
   574         iContainer->iListBox->SetCurrentItemIndexAndDraw( currentItem );
       
   575         }
       
   576     // Check middle softkey.    
       
   577     CheckMiddleSoftkeyLabelL();
       
   578     }
       
   579                                 
       
   580 // ----------------------------------------------------------------------------
       
   581 // CPslnCallImagePlugin::DoDeactivate
       
   582 // 
       
   583 // Called by the Avkon view framework when closing.
       
   584 // ----------------------------------------------------------------------------
       
   585 //
       
   586 void CPslnCallImagePlugin::DoDeactivate()
       
   587     {
       
   588     __CALLLOGSTRING("CPslnCallImagePlugin::DoDeactivate");
       
   589     CPslnFWBaseView::DoDeactivate();
       
   590     }
       
   591 
       
   592 // ---------------------------------------------------------------------------
       
   593 // CPslnCallImagePlugin::NewContainerL()
       
   594 // 
       
   595 // Creates new iContainer.
       
   596 // ---------------------------------------------------------------------------
       
   597 //
       
   598 void CPslnCallImagePlugin::NewContainerL()
       
   599     {
       
   600     __CALLLOGSTRING("CPslnCallImagePlugin::NewContainerL");
       
   601     iContainer = new( ELeave ) CPslnCallImagePluginContainer;
       
   602     iContainer->SetMiddleSoftkeyObserver( this );
       
   603     }
       
   604 
       
   605 // ---------------------------------------------------------------------------
       
   606 // CPslnCallImagePlugin::HandleListBoxSelectionL()
       
   607 // 
       
   608 // Handles events raised through a rocker key.
       
   609 // ---------------------------------------------------------------------------
       
   610 //
       
   611 void CPslnCallImagePlugin::HandleListBoxSelectionL()
       
   612     {
       
   613     __CALLLOGSTRING("CPslnCallImagePlugin::HandleListBoxSelectionL");
       
   614     HandleCommandL( EAknSoftkeyOk );
       
   615     }
       
   616 
       
   617 // ---------------------------------------------------------------------------
       
   618 // CPslnCallImagePlugin::CheckMiddleSoftkeyLabelL()
       
   619 // 
       
   620 // 
       
   621 // ---------------------------------------------------------------------------
       
   622 //
       
   623 void CPslnCallImagePlugin::CheckMiddleSoftkeyLabelL()
       
   624     {  
       
   625     // First remove any prevous commands.
       
   626     RemoveCommandFromMSK();
       
   627 
       
   628     if ( iContainer )
       
   629         {
       
   630         TInt currentlyActive = static_cast<CPslnCallImagePluginContainer*>
       
   631                     (iContainer)->CurrentSelectionIndexL();
       
   632         TInt currentItem = iContainer->iListBox->CurrentItemIndex();
       
   633         // Set MSK label.
       
   634         if ( currentlyActive != currentItem && 
       
   635              ( currentItem == EPlsnCallImageNone ||
       
   636                currentItem == EPlsnCallImageThemeImage ) )  
       
   637             {
       
   638             // Set middle softkey as Apply, if:
       
   639             // a) 'None' is selected
       
   640             // b) highlight is on inactive selection
       
   641             CPslnFWBaseView::SetMiddleSoftKeyLabelL( 
       
   642                 R_PSLN_MSK_ACTIVATE,
       
   643                 EPslnCmdAppActivate );
       
   644             }
       
   645         else if( ( currentlyActive == currentItem ) && 
       
   646             ( currentlyActive == EPlsnCallImageNone ||
       
   647                 currentlyActive == EPlsnCallImageThemeImage ) )
       
   648             {
       
   649             CPslnFWBaseView::SetMiddleSoftKeyLabelL( 
       
   650                 R_TEXT_SOFTKEY_EMPTY, 
       
   651                 EPslnCmdEmptyCommand );
       
   652             }
       
   653         else
       
   654             {
       
   655             // Otherwise set middle softkey as Change. 
       
   656             CPslnFWBaseView::SetMiddleSoftKeyLabelL( 
       
   657                 R_PSLN_MSK_CHANGE,
       
   658                 EPslnCmdAppDownload );
       
   659             }
       
   660         }
       
   661     }
       
   662 
       
   663 // ---------------------------------------------------------------------------
       
   664 // CPslnCallImagePlugin::RemoveCommandFromMSK()
       
   665 // 
       
   666 // 
       
   667 // ---------------------------------------------------------------------------
       
   668 //
       
   669 void CPslnCallImagePlugin::RemoveCommandFromMSK()
       
   670     {
       
   671     CEikButtonGroupContainer* cbaGroup = Cba();
       
   672     if ( cbaGroup )
       
   673         {
       
   674         cbaGroup->RemoveCommandFromStack( KPslnMSKControlId, EPslnCmdAppActivate );
       
   675         cbaGroup->RemoveCommandFromStack( KPslnMSKControlId, EPslnCmdAppDownload );
       
   676         }
       
   677     }
       
   678     
       
   679 // ---------------------------------------------------------------------------
       
   680 // CPslnCallImagePlugin::SetTitlePaneL()
       
   681 // 
       
   682 // Gives resource ID to be used as plugin view title.
       
   683 // ---------------------------------------------------------------------------
       
   684 //  
       
   685 void CPslnCallImagePlugin::SetTitlePaneL( TInt& aResourceId )
       
   686     {
       
   687 #ifdef RD_CONTROL_PANEL
       
   688     aResourceId = R_PSLN_TITLE_PANE_CALLIMAGE;
       
   689 #endif // RD_CONTROL_PANEL
       
   690     }
       
   691     
       
   692 // End of File