idlefw/plugins/shortcutplugin/inc/caiscuttarget.h
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 all shortcut targets.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CAISCUTTARGET_H
       
    20 #define CAISCUTTARGET_H
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 #include "taiscutparser.h"
       
    25 #include "aiscutdefs.h"
       
    26 #include <AknsItemID.h>
       
    27 
       
    28 class CAiScutEngine;
       
    29 class CGulIcon;
       
    30 
       
    31 _LIT(KBitmapFile, "aiscutplugin.mif");
       
    32 
       
    33 /**
       
    34  *  Base class for shortcut targets
       
    35  *
       
    36  *  @since S60 v3.2
       
    37  */
       
    38 class CAiScutTarget : public CBase
       
    39 {
       
    40 
       
    41 public:
       
    42 
       
    43     virtual ~CAiScutTarget();
       
    44 
       
    45     /**
       
    46      * Returns the shortcut definition string.
       
    47      *
       
    48      * @since S60 v3.2
       
    49      * @return Shortcut definition string
       
    50      */
       
    51     virtual TPtrC Definition() const = 0;
       
    52 
       
    53     /**
       
    54      * Returns the shortcut target caption.
       
    55      * Caption can be either a descriptor or a resource id.
       
    56      * If the return value has a non-zero value, it is the resource id.
       
    57      * Zero indicates that the descriptor reference parameter is used.
       
    58      * Default implementation returns KErrNotSupported;
       
    59      *
       
    60      * Getting the target caption and icon utilizes the "lazy evaluation" idiom
       
    61      * which means they are created only when they are first needed. This is because
       
    62      * there are (atleast) two scenarios where they are never needed:
       
    63      * 1. The active theme does not support shortcut captions or icons.
       
    64      * 2. Shortcuts launched using LaunchByValue are never published.
       
    65      *
       
    66      * @since S60 v3.2
       
    67      * @param aDes On return, the descriptor if used
       
    68      * @return The resource id or zero to indicate that the descriptor is used.
       
    69      */
       
    70     virtual TInt GetCaption( TPtrC& aDes, TAiScutAppTitleType aTitleType ) const;
       
    71 
       
    72     /**
       
    73      * Returns the shortcut target icon.
       
    74      * Icon can be either an icon pointer or a resource id.
       
    75      * If the return value has a non-zero value, it is the resource id.
       
    76      * Zero indicates that the icon pointer is used.
       
    77      * Default implementation returns the icon that has possibly
       
    78      * been set with @c SetOverrideIcon() and returns
       
    79      * KErrNotSupported if no override icon has been set.
       
    80      *
       
    81      * Uses the "lazy evaluation" idiom to get the icon. See Caption()
       
    82      *
       
    83      * @since S60 v3.2
       
    84      * @param aIcon On return, the icon pointer if used
       
    85      * @return The resource id or zero to indicate that the icon pointer is used.
       
    86      */
       
    87     virtual TInt GetIcon( CGulIcon*& aIcon ) const;
       
    88     
       
    89      /**
       
    90      * Returns the shortcut icon that can be published to softkeys
       
    91      * Icon can be either an icon pointer or a resource id.
       
    92      * If the return value has a non-zero value, it is the resource id.
       
    93      * Zero indicates that the icon pointer is used.
       
    94      * Default implementation returns the icon that has possibly
       
    95      * been set with @c SetSoftkeyIcon() and returns
       
    96      * KErrNotSupported if no softkey icon has been set.
       
    97      *
       
    98      * Uses the "lazy evaluation" idiom to get the icon. See Caption()
       
    99      *
       
   100      * @since S60 v3.2
       
   101      * @param aIcon On return, the icon pointer if used
       
   102      * @return The resource id or zero to indicate that the icon pointer is used.
       
   103      */
       
   104     virtual TInt GetSoftkeyIcon( CGulIcon*& aIcon ) const;
       
   105 
       
   106      /**
       
   107      * Returns the shortcut icon that can be published to toolbar
       
   108      * Icon can be either an icon pointer or a resource id.
       
   109      * If the return value has a non-zero value, it is the resource id.
       
   110      * Zero indicates that the icon pointer is used.
       
   111      * Default implementation returns the icon that has possibly
       
   112      * been set with @c SetSoftkeyIcon() and returns
       
   113      * KErrNotSupported if no softkey icon has been set.
       
   114      *
       
   115      * Uses the "lazy evaluation" idiom to get the icon. See Caption()
       
   116      *
       
   117      * @since S60 v3.2
       
   118      * @param aIcon On return, the icon pointer if used
       
   119      * @return The resource id or zero to indicate that the icon pointer is used.
       
   120      */
       
   121     virtual TInt GetToolbarIcon( CGulIcon*& aIcon ) const;
       
   122 
       
   123     /**
       
   124      * Checks if the shortcut target is accessible.
       
   125      *
       
   126      * @since S60 v3.2
       
   127      * @param aCheckType Specifies which kind of shortcuts should check its access
       
   128      * @return ETrue if accessible, EFalse if not
       
   129      */
       
   130     virtual TBool IsAccessibleL( TInt aCheckType ) = 0;
       
   131 
       
   132     /**
       
   133      * Launches the shortcut.
       
   134      *
       
   135      * @since S60 v3.2
       
   136      */
       
   137     virtual void LaunchL() = 0;
       
   138 
       
   139     /**
       
   140      * Launches the shortcut.
       
   141      *
       
   142      * @since S60 v5.1
       
   143      * @param aMessage A message to pass
       
   144      */
       
   145     virtual void LaunchL(const TDesC8& aMessage) { (void)aMessage; };
       
   146 
       
   147     /**
       
   148      * Return application uid this target launches.
       
   149      *
       
   150      * @since S60 v3.2
       
   151      */
       
   152     virtual TUid AppUid() const = 0;
       
   153 
       
   154     /**
       
   155      * Return an additional id this target may use when 
       
   156      * launching. Default implementation return TUid(-1)
       
   157      *
       
   158      * @since S60 v3.2
       
   159      */
       
   160     virtual TUid AdditionalUid() const;
       
   161 
       
   162     /**
       
   163      * Return shortcut type.
       
   164      *
       
   165      * @since S60 v3.2
       
   166      */
       
   167     TShortcutType Type() const;
       
   168     
       
   169     /**
       
   170      * Starts a full screen effect.
       
   171      */
       
   172     void BeginEffectL();
       
   173 
       
   174     /**
       
   175      * Set the icon that overrides the shortcut default
       
   176      * icon. Instead of fetching the icon from for example an
       
   177      * application the icon defined here can be used. The shortcut
       
   178      * can use the @c GetIcon() to fetch the 
       
   179      * icon defined here. Currently we support
       
   180      * icon loading from skin or from MIF/MBM-file. 
       
   181      * The file must reside under z:\resource altough
       
   182      * it can be under some subdirectory. 
       
   183      *
       
   184      * @since S60 v3.2
       
   185      * @param aIcon The overriding icon
       
   186      */
       
   187     void SetOverrideIcon(TAiScutIcon aIcon);
       
   188     
       
   189     /**
       
   190      * Set the icon that is to be published to softkeys
       
   191      * The @c GetSoftkeyIcon() can be used to fetch the 
       
   192      * icon defined here. Currently we support
       
   193      * icon loading from skin or from MIF/MBM-file. 
       
   194      * The file must reside under z:\resource altough
       
   195      * it can be under some subdirectory. 
       
   196      *
       
   197      * @since S60 v3.2
       
   198      * @param aIcon The softkey icon
       
   199      */
       
   200     void SetSoftkeyIcon(TAiScutIcon aIcon);
       
   201 
       
   202     /**
       
   203      * Set the icon that is to be published to touch toolbar
       
   204      * The @c GetSoftkeyIcon() can be used to fetch the 
       
   205      * icon defined here. Currently we support
       
   206      * icon loading from skin or from mif-file. 
       
   207      * The mif-file must reside under z:\resource altough
       
   208      * it can be under some subdirectory. 
       
   209      *
       
   210      * @since S60 v5.0
       
   211      * @param aIcon The softkey icon
       
   212      */
       
   213     void SetToolbarIcon(TAiScutIcon aIcon);
       
   214     
       
   215 protected:
       
   216 
       
   217     CAiScutTarget( CAiScutEngine& aEngine, TShortcutType aType );
       
   218 
       
   219 private:
       
   220     
       
   221     /**
       
   222      * Returns the icon defined in aIconToLoads. Loads the icon
       
   223      * from MIF/MBM-file or from skin.
       
   224      *
       
   225      * @return KErrNone if no error
       
   226     */
       
   227     TInt GetIcon(const TAiScutIcon &aIconToLoad, CGulIcon *&aIcon ) const;
       
   228     
       
   229     /**
       
   230     * Loads an icon defined in aIconToLoad from skin
       
   231     *
       
   232     * @return KErrNone if no error
       
   233     */
       
   234     void LoadIconFromSkinL(const TAiScutIcon &aIconToLoad, CGulIcon*& aIcon) const;
       
   235     
       
   236     /**
       
   237     * Loads an icon defined in aIconToLoad from MIF/MBM-file
       
   238     * The file must reside under z:\resource. It can be under
       
   239     * some subdirectory.
       
   240     *
       
   241     * @return KErrNone if no error
       
   242     */
       
   243     void LoadIconFromFileL(const TAiScutIcon &aIconToLoad, CGulIcon*& aIcon) const;
       
   244 
       
   245 
       
   246 protected:  // data
       
   247 
       
   248     /**
       
   249      * Reference to shortcut plug-in engine.
       
   250      */
       
   251     CAiScutEngine&  iEngine;
       
   252 
       
   253     /**
       
   254      * Shortcut type.
       
   255      */
       
   256     TShortcutType   iType;
       
   257     
       
   258     /**
       
   259     * Icon that is meant to override the default icon
       
   260     */
       
   261     TAiScutIcon iOverrideIcon;
       
   262    
       
   263     /**
       
   264     * Icon that is to be published to softkeys
       
   265     */
       
   266     TAiScutIcon     iSoftkeyIcon;
       
   267     
       
   268    /**
       
   269     * Icon that is to be published to toolbar
       
   270     */
       
   271     TAiScutIcon     iToolbarIcon;
       
   272    
       
   273 };
       
   274 
       
   275 #endif // CAISCUTTARGET_H
       
   276 
       
   277 // End of File.