menufw/hierarchynavigator/hnengine/inc/hnengine.h
branchv5backport
changeset 14 1abc632eb502
parent 13 6205fd287e8a
child 20 636d517f67e6
equal deleted inserted replaced
13:6205fd287e8a 14:1abc632eb502
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_HNENGINE_H
       
    21 #define C_HNENGINE_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <eikenv.h>
       
    25 #include <hwrmlight.h>
       
    26 
       
    27 #include "hnglobals.h"
       
    28 #include "hninterface.h"
       
    29 #include "hnmdmodel.h"
       
    30 #include "hninstallnotifier.h"
       
    31 
       
    32 class CHnMdModel;
       
    33 class CHnSuiteModelContainer;
       
    34 class MHnControllerInterface;
       
    35 class MHnSuiteObserver;
       
    36 
       
    37 /**
       
    38  * @ingroup group_hnengine
       
    39  *  Hierarchy Navigator engine - used by Multimedia Menu
       
    40  *  to fetch data models. The most commonly used exported method is TriggerHnEventL, 
       
    41  *  which offers event execution for the framework. This functionality is implemented
       
    42  *  through the MHnEventGenerator interface. The class owns the meta data model ( CHnMdModel ) 
       
    43  *  and suite container ( CHnSuiteModelContainer ) to manage them. The engine manages 
       
    44  *  the model by processing model events ( HandleModelEventL ) or reseting the models
       
    45  *  ( ResetModelsL ).
       
    46  *
       
    47  * @lib hnengine
       
    48  * @since S60 v3.2
       
    49  */
       
    50 NONSHARABLE_CLASS( CHnEngine ) : public CHnInterface,
       
    51                   public MHnMdModelEventObserver,
       
    52                   public MHnInstallNotifierCallback,
       
    53                   public MHWRMLightObserver
       
    54     {
       
    55 public:
       
    56     /**
       
    57      * Standard factory method.
       
    58      *
       
    59      * @since S60 v5.0
       
    60      * @param aController Controller handler.
       
    61      * @return Fully constructed object.
       
    62      */
       
    63     IMPORT_C static CHnEngine* NewL( MHnControllerInterface& aController );
       
    64 
       
    65     /**
       
    66      * Standard factory method.
       
    67      *
       
    68      * @since S60 v5.0
       
    69      * @param aController Controller handler.
       
    70      * @return Fully constructed object.
       
    71      */    
       
    72     IMPORT_C static CHnEngine* NewLC( MHnControllerInterface& aController );
       
    73 
       
    74     /**
       
    75      * Standard C++ destructor.
       
    76      * 
       
    77      * @since S60 v5.0
       
    78      */    
       
    79     ~CHnEngine();
       
    80 
       
    81     // from CHnInterface
       
    82     
       
    83     /**
       
    84      * Fetches and constructs data structres, needed by Multimedia
       
    85      * Menu to display suites.
       
    86      *
       
    87      * @since S60 v5.0
       
    88      * @return Filled suite model object from the stack.
       
    89      */
       
    90     CHnSuiteModel* GetLastSuiteModelL();
       
    91     
       
    92     /**
       
    93      * Fetches and constructs data structres, needed by Multimedia
       
    94      * Menu to display suites.
       
    95      *
       
    96      * @since S60 v5.0
       
    97      * @return Filled suite model object from the stack.
       
    98      */
       
    99     CHnSuiteModel* GetParentSuiteModelL();
       
   100    
       
   101     /**
       
   102      * Get count of suite models on the stack.
       
   103      * 
       
   104      * @since S60 v5.0
       
   105      * @return Count of suite models on the stack.
       
   106      */
       
   107     virtual TInt GetSuiteModelsCountL();
       
   108     
       
   109     /**
       
   110      * Checks if suite model is loaded.
       
   111      * 
       
   112      * @since S60 v5.0
       
   113      * @return ETrue if suite model is loaded, otherwise EFalse.
       
   114      */
       
   115     TBool SuiteModelLoadedL( TInt aId );
       
   116     
       
   117     /**
       
   118      * Loads suite hierarchy specified in URI.
       
   119      *
       
   120      * @since S60 v5.0
       
   121      * @param aUri The URI contained suite(s) to load.
       
   122      */
       
   123     IMPORT_C void LoadSuitesFromUriL( const TDesC8& aUri );
       
   124 
       
   125 public:
       
   126     // from MHnMdModelEventObserver
       
   127     
       
   128      /**
       
   129      * Handle model event.
       
   130      *
       
   131      * @since S60 v5.0
       
   132      * @param aEventName Event's name to perform.
       
   133      * @param aParams Event specific parameters used to perform action.
       
   134      */
       
   135      TInt HandleModelEventL( const TDesC& aEventName, CLiwGenericParamList& aParams );
       
   136      
       
   137     // from CHnInterface
       
   138      
       
   139     /**
       
   140      * Handle back event.
       
   141      *
       
   142      * @since S60 v5.0
       
   143      * @param aGenre Suite given by the name genre.
       
   144      * @param aIterations Number of iterations.
       
   145      * @return Status code.
       
   146      */
       
   147      TInt HandleBackEventL( const TDesC& aGenre,
       
   148              TInt aIterations = KModelCountForRoot );
       
   149 
       
   150     // from MHNMulModelInstallNotifierCallback
       
   151 
       
   152      /**
       
   153       * InstallChangeL is called when the subscribed key has been changed.
       
   154       * 
       
   155       * @since S60 v5.0
       
   156       * @param aStatus Status of the installation event.
       
   157       */
       
   158     virtual void InstallChangeL( TInt aStatus );
       
   159     
       
   160     
       
   161     /**
       
   162      * Loads default root suite
       
   163      * 
       
   164      * @since S60 v5.0
       
   165      * @param aSuiteParams Suite parameters.
       
   166      * @return Status error code.
       
   167      */
       
   168     IMPORT_C TInt InitializeL( CLiwGenericParamList& aSuiteParams );
       
   169     
       
   170     // from MHnEventGenerator
       
   171     
       
   172     /**
       
   173      * Triggers an event inside hierarchy navigator.
       
   174      * 
       
   175      * Used by UI to notify hierarchy navigator of its events,
       
   176      * as well as for hierarchy navigator components to notify
       
   177      * the module of certain events (such as OnSuiteLoaded etc).
       
   178      *
       
   179      * @since S60 v5.0
       
   180      * @param aHnEventId Internal id of an event (Event names are 
       
   181      *                    mapped to ids).
       
   182      * @param aRecipientId The id of the recipient item.
       
   183      * @param aEventParameters Event specific parameter.
       
   184      * @return Status code.
       
   185      */
       
   186      IMPORT_C TInt TriggerHnEventL( const TInt aHnEventId,
       
   187              const TInt aRecipientId, CLiwGenericParamList* aEventParameters = NULL );
       
   188      
       
   189      /**
       
   190       * Splits the source descriptor by a separatos
       
   191       * 
       
   192       * @since S60 v5.0
       
   193       * @param aSource Source descriptor intended to split.
       
   194       * @param aSeparator Separator used to split.
       
   195       * @return Array of descriptors. 
       
   196       */
       
   197      RPointerArray< HBufC8 > SplitL( const TDesC8& aSource,
       
   198              const TDesC8& aSeparator );
       
   199      
       
   200      /**
       
   201       * Generate param list according to query param.
       
   202       * 
       
   203       * @param aUriQuery Descriptor consist of param(s) to split
       
   204       * @param aUriFragment Descriptor containing an uri fragment.
       
   205       * @param aSuiteName The suite's name.  
       
   206       * @return Filled generic param list.
       
   207       */
       
   208      CLiwGenericParamList* UriQueryToLiwListLC( const TDesC8& aUriQuery,
       
   209              const TDesC8& aUriFragment, const TDesC8& aSuiteName );
       
   210      
       
   211      /**
       
   212       * Resets MD Model and Suite Container.
       
   213       *
       
   214       * @since S60 v5.0
       
   215       */
       
   216      IMPORT_C void ResetModelsL();
       
   217      
       
   218      // from MHnEditModeInterface 
       
   219      
       
   220      /**
       
   221       * Sets edit mode.
       
   222       * 
       
   223       * @since S60 v5.0
       
   224       * @param aEditMode Set edit mode member to false/true.
       
   225       */
       
   226      void SetEditModeL( TBool aEditMode );
       
   227 
       
   228     /**
       
   229      * Enables to issue a request to Hn engine.
       
   230      * 
       
   231      * @since S60 v5.0
       
   232      * @param aParam Input Parameters.
       
   233      * @param aOutput Target list for output.  
       
   234      */
       
   235      IMPORT_C void HandleRequestL( const CLiwGenericParamList& aParam, 
       
   236                          CLiwGenericParamList* aOutput = NULL);
       
   237 
       
   238     //    from MHWRMLightObserver
       
   239     /**
       
   240      * Called when the device light status changes.
       
   241      * Note that if the light status for certain target changes
       
   242      * very rapidly, some state transitions might be missed.
       
   243      * It is however guaranteed that latest state is always obtained.
       
   244      *
       
   245      * @param aTarget Indicates target(s) the new status applies to.
       
   246      * @param aStatus Indicates light request status.
       
   247      */
       
   248     virtual void LightStatusChanged(TInt aTarget,
       
   249             CHWRMLight::TLightStatus aStatus);
       
   250 
       
   251 private:
       
   252     /**
       
   253      * Default constructor.
       
   254      * 
       
   255      * @since S60 v5.0
       
   256      * @param aController Controller handler.
       
   257      */
       
   258     CHnEngine( MHnControllerInterface& aController );
       
   259     
       
   260     /**
       
   261      * Standard 2nd phase constructor.
       
   262      * 
       
   263      * @since S60 v5.0
       
   264      */
       
   265     void ConstructL();
       
   266          
       
   267     /**
       
   268      * Handle new suite loaded event.
       
   269      *
       
   270      * @since S60 v5.0
       
   271      * @param aParams Event specific parameters.
       
   272      * @return Status code.
       
   273      */
       
   274     TInt HandleNewSuiteLoadedEventL( CLiwGenericParamList& aParams );
       
   275 
       
   276     /**
       
   277      * Handle open suit event.
       
   278      *
       
   279      * @since S60 v5.0
       
   280      * @param aParams Event specific parameters that hold liw packed filter.
       
   281      * @return Status code.
       
   282      */
       
   283     TInt HandleReevaluateEventL( CLiwGenericParamList& aParams );
       
   284 
       
   285     /**
       
   286      * Handles widget change.
       
   287      *
       
   288      * @since S60 v5.0
       
   289      * @param aParams Event specific parameters consist of target widget type.
       
   290      * @return Status code.
       
   291       */
       
   292     TInt HandleWidgetChangeL( CLiwGenericParamList& aParams );
       
   293 
       
   294     /**
       
   295      * Handles SetFocus event.
       
   296      *
       
   297      * @since S60 v5.0
       
   298      * @param aParams Event specific parameters consist of target widget type.
       
   299      * @return Status code.
       
   300      */
       
   301     TInt HandleSetFocusEventL( const CLiwGenericParamList& aParams );
       
   302     
       
   303     /**
       
   304      * Handles MoveFocusBeforeDelete event.
       
   305      *
       
   306      * @since S60 v5.0
       
   307      * @param aParams Event specific parameters consist of target widget type.
       
   308      * @return Status code.
       
   309      */
       
   310     TInt HandleMoveFocusBeforeDeleteEventL(
       
   311             const CLiwGenericParamList& aParams );
       
   312     
       
   313     /**
       
   314      * Handles RefreshIcons event.
       
   315      *
       
   316      * @since S60 v5.0
       
   317      * @param aParams Event specific parameters (ignored)
       
   318      * @return Status code.
       
   319      */
       
   320     TInt HandleRefreshIconsEventL( const CLiwGenericParamList& aParams );
       
   321 
       
   322     /**
       
   323      * Handles DisableActionsForItem event.
       
   324      * 
       
   325      * @since S60 v5.0
       
   326      * @param aParams Event specific parameters - contains custom item id
       
   327      * @return Status code.
       
   328      */
       
   329     TInt HandleDisableActionsForItemL( const CLiwGenericParamList& aParams );
       
   330 
       
   331      /**
       
   332       *  Store widget type to repository.
       
   333       *
       
   334       * @since S60 v5.0
       
   335       * @param aSuiteName Suite name to that set widget type. 
       
   336       * @param aType Widget type to store in repository.
       
   337       * @return Status code.
       
   338       */    
       
   339     TInt HandleWidgetChangeL( const TDesC& aSuiteName,
       
   340             THnSuiteWidgetType aType );
       
   341      
       
   342          
       
   343      /**
       
   344       * Parse URI path component containing Suites to be loaded.
       
   345       *
       
   346       * @since S60 v5.0
       
   347       * @param aUriPath Descriptor URI path which consist of suites' names.
       
   348       * @param aOutput Array on output containes parsed suite names.
       
   349       */
       
   350      void ParseSuiteUriPathL( const TDesC8& aUriPath, 
       
   351          CDesC8ArrayFlat& aOutput );
       
   352    
       
   353      
       
   354      /**
       
   355       * Checks if only root configuration is loaded.
       
   356       * Used to decide if reloading models is needed.
       
   357       *
       
   358       * @since S60 v5.0
       
   359       * @return Return ETrue if only root configuration is loaded
       
   360       *         otherwise EFalse.
       
   361       */
       
   362      TBool IsOnlyRootConfLoaded();
       
   363      
       
   364      /**
       
   365       * Resets loaded resources.
       
   366       *
       
   367       * @since S60 5.0
       
   368       */
       
   369      void ResetLocalization();
       
   370      
       
   371      /**
       
   372       * Loads suite with given suite name with parameters
       
   373       * from uri query. 
       
   374       *
       
   375       * @since S60 5.0
       
   376       * @param aSuiteName Name of the suite to load. 
       
   377       * @param aUriQuery Descriptor containig parsed part of the uri.
       
   378       * @param aUriFragment Descriptor containig parsed part (fragment) of the uri.
       
   379       * @return Error code when loading suite.
       
   380       */
       
   381      TInt LoadSuiteFromUriL( const TDesC8& aSuiteName, 
       
   382          const TDesC8& aUriQuery, const TDesC8& aUriFragment );
       
   383      
       
   384      /**
       
   385       * Reads highlight position from uri fragment 
       
   386       * and sets it on the suite model.
       
   387       *
       
   388       * @since S60 5.0
       
   389       * @param aUriFragment Descriptor containig parsed part of the uri.
       
   390       */
       
   391      void HighlightPlacementFromUriL( const TDesC8& aUriFragment );
       
   392     
       
   393      
       
   394      /**
       
   395       * Loads folder and sets focus through CR.
       
   396       * 
       
   397       * @since S60 v5.0
       
   398       */
       
   399      void LoadFromCrL( const TDesC8& aUri );
       
   400      
       
   401      /**
       
   402       * Handles loading suite from uri if suites names' are the same.
       
   403       * 
       
   404       * @param aNextExists ETrue if the next suite's name exists in uri.
       
   405       * @param aUri The URI's parameters passed to the suite. 
       
   406       */
       
   407      void HandleTheSameSuitesL( TBool aNextExists, const TDesC8& aParams );
       
   408      
       
   409      /**
       
   410       * Checks if suites have the same names.
       
   411       * 
       
   412       * @param aLastSuiteName The last suite's name on the stack.
       
   413       * @param aFirstSuiteName The first suite's name in uri.
       
   414       * @return ETrue if names are equal
       
   415       */
       
   416      TBool SuitesAreTheSameL( const TDesC& aLastSuiteName, const TDesC8& aFirstSuiteName );
       
   417 
       
   418      /**
       
   419       * Decides whether to hide menu depending on current state and uri parameters
       
   420       * 
       
   421       * @param aUri The Uri to parse for exit procedure.
       
   422       * @return ETrue If exit was consumed.
       
   423       */
       
   424      TBool HandleActionL( const TDesC8& aUri );
       
   425      
       
   426      /**
       
   427       * Loads suites from uri.
       
   428       * 
       
   429       * @param aUri The uri to parse
       
   430       */
       
   431      void LoadSuitesL( const TDesC8& aUri );
       
   432      
       
   433 private: // data
       
   434         
       
   435     /**
       
   436      * Own - Meta data model.
       
   437      */
       
   438     CHnMdModel* iMetaDataModel;
       
   439     
       
   440     /**
       
   441      * Own - Suite container.
       
   442      */
       
   443     CHnSuiteModelContainer* iSuiteContainer;
       
   444        
       
   445     /**
       
   446      * Not own.
       
   447      * EikonEnv for displaying popup messages. 
       
   448      */
       
   449     CEikonEnv* iEEnv;
       
   450     
       
   451     /**
       
   452      * Not own - Suite observer.
       
   453      */
       
   454     MHnControllerInterface& iControllerInterface;
       
   455     
       
   456     /**
       
   457      * Installation observer.
       
   458      * Own.
       
   459      */
       
   460     CHnInstallNotifier* iInstObserver;
       
   461     
       
   462     /**
       
   463      * Edit mode
       
   464      */
       
   465     TBool iEditMode;
       
   466     
       
   467     /**
       
   468      * Light status observer
       
   469      */
       
   470     CHWRMLight* iLight;
       
   471     };
       
   472 
       
   473 #endif //C_HNENGINE_H