idlefw/plugins/shortcutplugin/src/caiscuttarget.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-2006 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:  Base class for shortcut target
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "caiscutengine.h"
       
    20 #include "caiscuttarget.h"
       
    21 #include <AknIconUtils.h>
       
    22 #include <AknsUtils.h>          // For AknsUtils
       
    23 #include <mifconvdefs.h>
       
    24 #include <gulicon.h>
       
    25 #include <bautils.h>
       
    26 #include <AknTaskList.h>        // For CAknTaskList
       
    27 #include <apgwgnam.h>           // For CApaWindowGroupName
       
    28 #include <gfxtranseffect/gfxtranseffect.h>		// For Transition effect
       
    29 #include <akntranseffect.h>
       
    30 #include <akntransitionutils.h>
       
    31 
       
    32 // ======== MEMBER FUNCTIONS ========
       
    33 _LIT(KFileLoadDir,"z:\\resource\\");
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CAiScutTarget::CAiScutTarget(CAiScutEngine& aEngine, TShortcutType aType)
       
    39     : iEngine(aEngine)
       
    40     , iType(aType)
       
    41 {
       
    42 }
       
    43 
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 // ---------------------------------------------------------------------------
       
    47 //
       
    48 CAiScutTarget::~CAiScutTarget()
       
    49 {
       
    50     
       
    51 }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // Returns the shortcut target caption.
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 TInt CAiScutTarget::GetCaption(TPtrC& /*aDes*/, TAiScutAppTitleType /*aTitleType*/) const
       
    58 {
       
    59     // Default implementation.
       
    60     return KErrNotSupported;
       
    61 }
       
    62 
       
    63 TUid CAiScutTarget::AdditionalUid() const
       
    64     {
       
    65     return TUid::Uid(-1);
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // Returns the shortcut target icon.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 TInt CAiScutTarget::GetIcon(const TAiScutIcon &aIconToLoad, CGulIcon*& aIcon ) const
       
    73 {   
       
    74     TInt err = KErrNotSupported;
       
    75     
       
    76     if ( aIconToLoad.iType == EScutIconSkin )
       
    77         {
       
    78         TRAP(err, LoadIconFromSkinL(aIconToLoad, aIcon));
       
    79         }
       
    80     else if ( aIconToLoad.iType == EScutIconMif )
       
    81         {
       
    82         TRAP(err, LoadIconFromFileL(aIconToLoad, aIcon));
       
    83         }
       
    84     else if ( aIconToLoad.iType == EScutIconMbm )
       
    85         {
       
    86         TRAP(err, LoadIconFromFileL(aIconToLoad, aIcon));
       
    87         }
       
    88     
       
    89     return err;
       
    90 }
       
    91 
       
    92 TInt CAiScutTarget::GetIcon(CGulIcon*& aIcon) const
       
    93     {
       
    94     return GetIcon(iOverrideIcon, aIcon);
       
    95     }
       
    96 
       
    97 TInt CAiScutTarget::GetSoftkeyIcon(CGulIcon*& aIcon) const
       
    98     {
       
    99     return GetIcon(iSoftkeyIcon, aIcon);
       
   100     }
       
   101 
       
   102 TInt CAiScutTarget::GetToolbarIcon(CGulIcon*& aIcon) const
       
   103     {
       
   104     return GetIcon(iToolbarIcon, aIcon);
       
   105     }
       
   106     
       
   107 void CAiScutTarget::SetOverrideIcon(TAiScutIcon aIcon)
       
   108     {
       
   109     iOverrideIcon = aIcon;
       
   110     }
       
   111 
       
   112 void CAiScutTarget::SetSoftkeyIcon(TAiScutIcon aIcon)
       
   113     {
       
   114     iSoftkeyIcon = aIcon;
       
   115     }
       
   116 
       
   117 void CAiScutTarget::SetToolbarIcon(TAiScutIcon aIcon)
       
   118     {
       
   119     iToolbarIcon = aIcon;
       
   120     }
       
   121 
       
   122 void CAiScutTarget::LoadIconFromSkinL(const TAiScutIcon &aIconToLoad, CGulIcon*& aIcon) const
       
   123     {
       
   124     CFbsBitmap* bitmap = NULL;
       
   125 	CFbsBitmap* bitmapMask = NULL;
       
   126 	
       
   127     // With colour group support
       
   128     if ( aIconToLoad.iColourGroup >= EAknsCIQsnTextColorsCG1 &&
       
   129            aIconToLoad.iColourGroup <= EAknsCIQsnTextColorsCG62)
       
   130         {
       
   131         
       
   132         AknsUtils::CreateColorIconLC(
       
   133             AknsUtils::SkinInstance(),
       
   134             aIconToLoad.iSkinId,
       
   135             KAknsIIDQsnTextColors,
       
   136             aIconToLoad.iColourGroup,
       
   137             bitmap,
       
   138             bitmapMask,
       
   139             KNullDesC,  /* no backup */
       
   140             0,          /* no backup */
       
   141             0,          /* no backup */
       
   142             KRgbBlack );
       
   143             
       
   144         if ( bitmap )
       
   145             {
       
   146             aIcon = CGulIcon::NewL( bitmap, bitmapMask );              
       
   147             }
       
   148         CleanupStack::Pop( 2 ); // bitmap, bitmapMask
       
   149         }
       
   150     // no colour group support
       
   151     else
       
   152         {
       
   153         aIcon = AknsUtils::CreateGulIconL( AknsUtils::SkinInstance(), aIconToLoad.iSkinId, KNullDesC, 0, 0 );
       
   154         }
       
   155     if ( !aIcon )
       
   156         {
       
   157         User::Leave( KErrNotFound );
       
   158         }
       
   159     }
       
   160 
       
   161 void CAiScutTarget::LoadIconFromFileL(const TAiScutIcon &aIconToLoad, CGulIcon*& aIcon) const 
       
   162     {
       
   163     CFbsBitmap* bitmap = NULL;
       
   164 	CFbsBitmap* bitmapMask = NULL;
       
   165     TFileName actualPath;
       
   166     TInt iconIndexStart = 0;
       
   167     
       
   168     if ( aIconToLoad.iType == EScutIconMif )
       
   169         {
       
   170         iconIndexStart = KMifIdFirst;
       
   171         }
       
   172     actualPath.Append(KFileLoadDir);
       
   173     actualPath.Append(aIconToLoad.iPath);
       
   174     
       
   175     RFs fs; fs.Connect();
       
   176 	if ( aIconToLoad.iIconId < 0 || !BaflUtils::FileExists(fs, actualPath))
       
   177 		{
       
   178 		fs.Close();
       
   179 		User::Leave( KErrNotFound );
       
   180 		}
       
   181     fs.Close();
       
   182 	// Mask is next after bitmap
       
   183     AknIconUtils::CreateIconLC(bitmap,bitmapMask, actualPath,
       
   184         aIconToLoad.iIconId+iconIndexStart, aIconToLoad.iIconId+iconIndexStart+1);
       
   185       
       
   186 
       
   187     aIcon = CGulIcon::NewL(bitmap, bitmapMask);
       
   188 
       
   189     CleanupStack::Pop(bitmapMask);    
       
   190     CleanupStack::Pop(bitmap);
       
   191     
       
   192     if ( !aIcon )
       
   193         {
       
   194         User::Leave( KErrNotFound );        
       
   195         }
       
   196     
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // Returns the shortcut target type.
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 TShortcutType CAiScutTarget::Type() const
       
   204 {
       
   205     return iType;
       
   206 }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // Determines which effect should be shown, and starts it.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 void CAiScutTarget::BeginEffectL()
       
   213 	{
       
   214 	RWsSession& aWs = iEngine.Env()->WsSession();
       
   215 	TUid appUid = AppUid();
       
   216 	TInt effectType = AknTransEffect::EApplicationStart;
       
   217 	CAknTaskList* taskList = CAknTaskList::NewL( aWs );
       
   218 	TApaTask task = taskList->FindRootApp( appUid );
       
   219 	delete taskList;
       
   220 	
       
   221 	if ( task.Exists() )
       
   222 		{
       
   223 		TBool inHiddenList = iEngine.IsHiddenFromFSW(appUid);
       
   224 		CApaWindowGroupName* wgName = CApaWindowGroupName::NewL( aWs, task.WgId() );
       
   225 		wgName->SetAppUid( appUid );
       
   226 		const TBool isHidden = wgName->Hidden() || inHiddenList;
       
   227 		delete wgName;
       
   228 				
       
   229 		if (!isHidden)
       
   230 			{
       
   231 			effectType = AknTransEffect::EApplicationStartSwitchRect;
       
   232 			}
       
   233 		
       
   234 		//start a full screen effect
       
   235 		GfxTransEffect::BeginFullScreen( effectType,
       
   236 		TRect(0,0,0,0), 
       
   237 		AknTransEffect::EParameterType, 
       
   238 		AknTransEffect::GfxTransParam( appUid, 
       
   239 		AknTransEffect::TParameter::EActivateExplicitContinue ) );
       
   240 		}
       
   241 	}
       
   242 
       
   243 // End of File.