photosgallery/viewframework/commandhandlers/commoncommandhandlers/inc/glxaiwservicehandler.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Photos AIW Service handler Proxy class for the CAiwServiceHandler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef _GLXAIWSERVICEHANDLER_H
       
    22 #define _GLXAIWSERVICEHANDLER_H
       
    23 
       
    24 /**
       
    25  * CGlxAiwServiceHandler
       
    26  * Proxy class for the CAiwServiceHandler
       
    27  *
       
    28  * @author Rowland Cook
       
    29  * @internal reviewed Aki Vanhatalo 20/08/2007
       
    30  */
       
    31 
       
    32 #include <e32base.h>
       
    33 #include <eikmenup.h>
       
    34 
       
    35 class TAiwGenericParam;
       
    36 class CAiwServiceHandler;
       
    37 class CAiwGenericParamList;
       
    38 class MAiwNotifyCallback;
       
    39 class CGlxAiwMedia;
       
    40 class TGlxMediaId;
       
    41 class t_CGlxAiwServiceHandler;
       
    42 
       
    43 /**
       
    44  *  CGlxAiwServiceHandler class
       
    45  *  This class is a proxy for the CAiwServiceHandler.
       
    46  *  It is Singleton.
       
    47  */
       
    48 NONSHARABLE_CLASS(CGlxAiwServiceHandler) : public CBase 
       
    49     {
       
    50     friend class t_CGlxAiwServiceHandler;
       
    51 public:
       
    52     /**
       
    53      * Obtain the instance of the Singleton
       
    54      */ 
       
    55     static CGlxAiwServiceHandler* InstanceL();
       
    56     
       
    57     /**
       
    58      * Close
       
    59      */
       
    60     void Close();
       
    61 
       
    62     /**
       
    63      *  Destructor
       
    64      */
       
    65     ~CGlxAiwServiceHandler();
       
    66     
       
    67     /**
       
    68      *  Adds a TAiwGenericParam to the InParams
       
    69      * @param aParam The parameter to append to this list. This object takes
       
    70      *               an own copy of the data in aParam.
       
    71      */
       
    72     void AddParamL(const TGlxMediaId& aId, const TAiwGenericParam& aParam );
       
    73 
       
    74     /**
       
    75      *  Initialises the Meu Pane
       
    76      * @param aMenuPane Handle of the menu pane to initialise.
       
    77      * @param aMenuResourceId The menu to be attached.
       
    78      * @param aBaseMenuCmdId Base ID for the Service Handler to generate 
       
    79      *                       menu IDs for placeholders.
       
    80      * @leave KErrNotSupported CCoeEnv is not accessible.
       
    81      * @leave KErrOverflow Consumer application has too many AIW placeholders in its menu. 
       
    82      *                     Currently, maximum 16 is supported.
       
    83      *  
       
    84      */
       
    85     void InitializeMenuPaneL(CEikMenuPane& aMenuPane, TInt aResourceId, TInt aBaseMenuCmdId);
       
    86     
       
    87     /**
       
    88      * Attach menu related criteria items to the given menu.
       
    89      * If a provider leaves during initialization, it is trapped by the Service Handler. 
       
    90      *
       
    91      * @param aMenuResourceId      Menu to be attached.
       
    92      * @param aInterestResourceId  Resource id for the interest list.
       
    93      * @leave KErrNotSupported     CCoeEnv is not accessible.
       
    94      */
       
    95     void AttachMenuL(TInt aMenuResource, TInt aAiwInterestResource);
       
    96     
       
    97     /**
       
    98      * Identifies is a menu command Id belongs to an Aiw Menu
       
    99      * @param aCommand The command to handle
       
   100      * @param aAiwCommandId The AIW command.
       
   101      * @return ETrue if they are the same, otherwise EFalse.
       
   102      */
       
   103     TBool IsSameCommand(TInt aCommandId, TInt aAiwCommandId);
       
   104     
       
   105     /**
       
   106      * Executes a menu command.
       
   107      * Not supported if calling outside UI framework. 
       
   108      *
       
   109      * @param aMenuCmdId The menu command to be executed.
       
   110      * @param aCmdOptions Options for the command, see TAiwServiceCmdOptions in AiwCommon.hrh.
       
   111      * @param aCallback Callback for asynchronous command handling, parameter checking, etc.
       
   112      * @leave KErrArgument Callback is missing when required.
       
   113      * @leave KErrNotSupported No cmd matches given menu command or CCoeEnv is not accessible.
       
   114      */
       
   115     void ExecuteMenuCmdL(TInt aMenuCmdId, TUint aCmdOptions = 0, MAiwNotifyCallback* aCallback = NULL);
       
   116     
       
   117     /**
       
   118      * Handles AIW submenus. This method should be called from consumer application's 
       
   119      * DynInitMenuPaneL.
       
   120      *
       
   121      * @param  aPane  Menu pane to be handled.
       
   122      * @return ETrue  if aPane was an AIW submenu and it was handled. 
       
   123      *                Consumer's DynInitMenuPaneL pane may now return.
       
   124      *         EFalse if aPane was not an AIW submenu and DynInitMenuPaneL should
       
   125      *                continue normally.
       
   126      */
       
   127     TBool HandleSubmenuL(CEikMenuPane& aPane);
       
   128 
       
   129     /**
       
   130      * Returns boolean value indicating whether the given menu contains
       
   131      * currently attached placeholders.
       
   132      *
       
   133      * @param   aMenuResourceId  Resource id of the menu to be queried.
       
   134      * @return  ETrue  if aMenuResource contains currently attached placeholders.
       
   135      *          EFalse otherwise. 
       
   136      */
       
   137     TBool IsAiwMenu(TInt aMenuResourceId);
       
   138     
       
   139     /**
       
   140      * Iterates through the Id Array and appends any AIW parameters
       
   141      * associated with that Id to the InParams list.
       
   142      */
       
   143     void AppendInParamsL();
       
   144     
       
   145     /**
       
   146     * Reset menu initialisation flag
       
   147     */
       
   148     void ResetMenuInitialisedFlag();
       
   149 
       
   150 private:
       
   151     /**
       
   152      *  Instantiate the class.
       
   153      *  This must be private.
       
   154      *  To obtain an Instance on this class call the static method InstanceL().
       
   155      *  @return pointer to the CGlxAiwServiceHandler
       
   156      */
       
   157     static CGlxAiwServiceHandler* NewL();
       
   158     
       
   159     /**
       
   160      *  Constructor
       
   161      */
       
   162     CGlxAiwServiceHandler();
       
   163     
       
   164     /**
       
   165      * 2nd phase constructor
       
   166      */
       
   167     void ConstructL();
       
   168     
       
   169     /**
       
   170      * Finds the Index for a given Id
       
   171      * @param TGlxMediaId of the index to find.
       
   172      * @return index of aId or KErrNotFound.
       
   173      */
       
   174     TInt FindId(const TGlxMediaId& aId);
       
   175     
       
   176     /**
       
   177      * Function for comparing two CGlxAiwMedia classes 
       
   178      * Used from ordering iAiwMediaArray by media id
       
   179      * @param aAiwMedia1 The CGlxAiwMedia to compare against aAiwMedia2
       
   180      * @param aAiwMedia2 The second item to compare
       
   181      * @return -1 if aAiwMedia1.Id() < aAiwMedia2.Id(); 1 if aAiwMedia1.Id() > aAiwMedia2.Id(); 0 if aAiwMedia1.Id() == aAiwMedia2.Id()
       
   182      */
       
   183     static TInt AiwMediaOrderById( const CGlxAiwMedia& aAiwMedia1, const CGlxAiwMedia& aAiwMedia2 );
       
   184 
       
   185     /**
       
   186      * Function for comparing a TGlxMediaId with a CGlxAiwMedia class 
       
   187      * Used from ordering iAiwMediaArray by media id
       
   188      * @param aMediaId The TGlxMediaId to compare against aAiwMedia2
       
   189      * @param aAiwMedia2 The second item to compare
       
   190      * @return -1 if aMediaId < aAiwMedia2.Id(); 1 if aMediaId > aAiwMedia2.Id(); 0 if aMediaId == aAiwMedia2.Id()
       
   191      */
       
   192     static TInt AiwMediaOrderByMediaId( const TGlxMediaId* aMediaId, const CGlxAiwMedia& aAiwMedia );
       
   193     
       
   194     /**
       
   195      * Gets the InParameters. This method is for testing only
       
   196      * @return a reference to the CAiwGenericParamList pointer to by iInParams
       
   197      */
       
   198      CAiwGenericParamList& GetInParams();
       
   199 
       
   200 private:
       
   201     // Pointer to the real AiwServiceHandler (Owned).
       
   202     CAiwServiceHandler*             iAiwServiceHandler;
       
   203 
       
   204 	//Enum for menu state    
       
   205     enum TMenuState 
       
   206     	{
       
   207     	ENotInitialised,
       
   208     	ESubMenuInitialised,
       
   209     	EMainMenuInitialised
       
   210     	};
       
   211     // Keeps track of the menu being initialised and inParams being 
       
   212     // deleted by the AiwServiceHandler
       
   213     TMenuState iInitialisedMenu;
       
   214     
       
   215     // The inParams generated to initialise the menu with
       
   216     CAiwGenericParamList*           iInParams;
       
   217     
       
   218     // Array of CGlxAiwMedia
       
   219     RPointerArray<CGlxAiwMedia>     iAiwMediaArray;
       
   220     };
       
   221 
       
   222 #endif
       
   223