menufw/hierarchynavigator/hnmetadatamodel/inc/hnmdmodel.h
changeset 0 f72a12da539e
child 1 5315654608de
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     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_HNMDMODEL_H
       
    21 #define C_HNMDMODEL_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <xmlengelement.h> 
       
    25 #include <liwgenericparam.h>
       
    26 #include <eikenv.h>
       
    27 #include "hnglobals.h"
       
    28 
       
    29 class CHnMdLocalization;
       
    30 class CHnSuiteModelContainer;
       
    31 class CHnFilter;
       
    32 class THnIdGenerator;
       
    33 class CHnMdSuite;
       
    34 class CHnMdModel;
       
    35 class CHnItemId;
       
    36 class MHnSuiteObserver;
       
    37 class CHnXmlModelProvider;
       
    38 class CHnMdModel;
       
    39 class MHnMdModelEventObserver;
       
    40 class CHnSuiteModel;
       
    41 class CHnRepositoryObserver;
       
    42 class MHnEditModeInterface;
       
    43 class CHnBitmapIdCache;
       
    44 
       
    45 /**
       
    46  * Type of the property.
       
    47  * 
       
    48  * @ingroup group_hnmetadatamodel
       
    49  */
       
    50 enum TPropertyType
       
    51     {
       
    52     EUndefined = 0,
       
    53     EGenre,
       
    54     EVisualItemCount    
       
    55     };
       
    56 
       
    57 /**
       
    58  * Mode type.
       
    59  * 
       
    60  * @ingroup group_hnmetadatamodel
       
    61  */
       
    62 enum TMdMode
       
    63     {
       
    64     EMdModeNormal = 0,
       
    65     EMdModeEdit
       
    66     };
       
    67 
       
    68 /**
       
    69  * Common pointers.
       
    70  *
       
    71  * @since S60 5.0
       
    72  * @ingroup group_hnmetadatamodel 
       
    73  */
       
    74 struct THnMdCommonPointers
       
    75     {    
       
    76     /**
       
    77      * Not own - Localization.
       
    78      */
       
    79     CHnMdLocalization* iLocalization;
       
    80       
       
    81     /**
       
    82      * Not own - Query generator.
       
    83      */
       
    84     THnIdGenerator* iIdGenerator;
       
    85     
       
    86     /**
       
    87      * Not own - Suite model container.
       
    88      */
       
    89     CHnSuiteModelContainer* iContainer;
       
    90     
       
    91     /**
       
    92      * Not own - Meta data model.
       
    93      */
       
    94     CHnMdModel* iModel;
       
    95       
       
    96     /**
       
    97      * Not own - Xml model provider.
       
    98      */
       
    99     CHnXmlModelProvider* iXmlModelProvider;
       
   100     
       
   101     /**
       
   102      * Not own - Cache for bitmap and mask ids.
       
   103      */
       
   104     CHnBitmapIdCache* iBitmapIdCache;
       
   105     
       
   106     /**
       
   107      * Not own - Model event observer.
       
   108      */
       
   109     MHnMdModelEventObserver* iModelEventObserver;
       
   110     
       
   111     /**
       
   112      * Not own - Edit mode interface.
       
   113      */
       
   114     MHnEditModeInterface* iEditModeInterface;
       
   115     
       
   116     /**
       
   117      * Not own - Handler to file server session;
       
   118      */    
       
   119     RFs& iFs;
       
   120     
       
   121     /**
       
   122      * Gets static pointer from TLS.
       
   123      */
       
   124     static THnMdCommonPointers* Static() {return (THnMdCommonPointers*)Dll::Tls(); }
       
   125     
       
   126     /**
       
   127      * Sets pointer to TLS.
       
   128      * 
       
   129      * @param aCmnPtrs Pointer to set
       
   130      */
       
   131     static void SetStatic( THnMdCommonPointers* aCmnPtrs ) {  Dll::SetTls(aCmnPtrs); }
       
   132     
       
   133   private: 
       
   134 
       
   135     // only model can create it
       
   136     friend class CHnMdModel;  
       
   137     
       
   138     /**
       
   139      * Standard C++ consturctor.
       
   140      */
       
   141     THnMdCommonPointers() : iFs( CEikonEnv::Static()->FsSession() )
       
   142         {
       
   143         iLocalization = NULL;
       
   144         iIdGenerator = NULL;
       
   145         iContainer = NULL;
       
   146         iModel = NULL;
       
   147         iXmlModelProvider = NULL;
       
   148         iModelEventObserver = NULL;
       
   149         iEditModeInterface = NULL;
       
   150         }
       
   151 
       
   152     /**
       
   153      * Copy constructor declared as private to disallow copying.
       
   154      * 
       
   155      * @param aCmnPtrs Pointer to set.
       
   156      */
       
   157     THnMdCommonPointers( const THnMdCommonPointers& aCmnPtrs ):iFs( aCmnPtrs.iFs ) { }
       
   158     
       
   159     /**
       
   160      * Assignment operator
       
   161      */
       
   162     THnMdCommonPointers& operator=( const THnMdCommonPointers& ){return *this;}
       
   163     };
       
   164     
       
   165 /**
       
   166  *  Id generator.
       
   167  *
       
   168  *  @lib ?library
       
   169  *  @since S60 5.0
       
   170  *  @ingroup group_hnmetadatamodel 
       
   171  */
       
   172 struct THnIdGenerator
       
   173     {        
       
   174     /**
       
   175      * Standatrd C++ constructor.
       
   176      */
       
   177     THnIdGenerator()
       
   178         {
       
   179         iId = 0;
       
   180         }
       
   181 
       
   182     /**
       
   183      * Gets next id.
       
   184      * @return Next id.
       
   185      */
       
   186     TInt GetNextId()
       
   187         {
       
   188         return iId++;
       
   189         }
       
   190     private:
       
   191   
       
   192     /**
       
   193      * Copy constructor declared as private to disallow copying.
       
   194      * @param aGenerator Id generator;
       
   195      */
       
   196     THnIdGenerator(const THnIdGenerator& aGenerator);
       
   197 
       
   198     /**
       
   199      * Assignment operator.
       
   200      */
       
   201     THnIdGenerator& operator=(const THnIdGenerator&);
       
   202     
       
   203     /**
       
   204      * Id
       
   205      */
       
   206     TInt iId;            
       
   207     };
       
   208 
       
   209 /**
       
   210  * Model event observer.
       
   211  *
       
   212  * @since S60 5.0 
       
   213  * @ingroup group_hnmetadatamodel
       
   214  */
       
   215 class MHnMdModelEventObserver
       
   216     {
       
   217     public:
       
   218   
       
   219      /**
       
   220      * Handles modlde event.
       
   221      *
       
   222      * @since S60 5.0
       
   223      * @param aEventName Event name.
       
   224      * @param aParams Parameters.
       
   225      */
       
   226      virtual TInt HandleModelEventL( const TDesC& aEventName, 
       
   227              CLiwGenericParamList& aParams ) = 0;
       
   228     };
       
   229 
       
   230 /**
       
   231  * Meta data model
       
   232  *
       
   233  * This is the main class of the Meta Data Model component.
       
   234  * 
       
   235  * This class is the entry point for building the meta data model
       
   236  * and for evaluation.
       
   237  * 
       
   238  * @since S60 5.0
       
   239  * @ingroup group_hnmetadatamodel
       
   240  */
       
   241 NONSHARABLE_CLASS( CHnMdModel ) : public CBase
       
   242     {
       
   243 public:
       
   244     enum TForegroundGainTriggeringEvent
       
   245         {
       
   246         EWhenAnySuiteIsEvaluated,
       
   247         EWhenCurrentTopSuiteIsEvaluated,
       
   248         ENever
       
   249         };
       
   250 public:
       
   251 
       
   252     /**
       
   253      * Two-phase constructor.
       
   254      *
       
   255      * @since S60 5.0
       
   256      * @param aModelObserver Model observer.
       
   257      * @param aSuiteModelContainer Suite model container.
       
   258      * @return Fully constructed object.
       
   259      */
       
   260     IMPORT_C static CHnMdModel* NewL( MHnMdModelEventObserver* aModelObserver,
       
   261             CHnSuiteModelContainer * aSuiteModelContainer );
       
   262 
       
   263     /**
       
   264      * Two-phase constructor.
       
   265      *
       
   266      * @since S60 5.0
       
   267      * @param aModelObserver Model observer.
       
   268      * @param aSuiteModelContainer Suite model container.
       
   269      * @return Fully constructed object.
       
   270      */
       
   271     IMPORT_C static CHnMdModel* NewLC( MHnMdModelEventObserver* aModelObserver,
       
   272             CHnSuiteModelContainer * aSuiteModelContainer );
       
   273 
       
   274     /**
       
   275      * Standard C++ virtual destructor.
       
   276      *
       
   277      * @since S60 5.0
       
   278      */
       
   279     virtual ~CHnMdModel();
       
   280     
       
   281     /**
       
   282      * Evaluates the model. Takes filter as a parameter.
       
   283      *
       
   284      * @since S60 5.0
       
   285      * @param aFilter Filter.
       
   286      */
       
   287     IMPORT_C void EvaluateL( CHnFilter& aFilter );
       
   288 
       
   289     /**
       
   290      * Manages evaluation lock.
       
   291      * 
       
   292      * @param aLock Locks evaluation if set to ETrue.
       
   293      * @param aEvaluate Runs evaluation if aEvaluate == ETrue.
       
   294      */
       
   295     IMPORT_C void SetEvaluationLockL( TBool aLock, TBool aEvaluate = ETrue );
       
   296           
       
   297     /**
       
   298      * Evaluates the model.
       
   299      *
       
   300      * @since S60 5.0
       
   301      */
       
   302     IMPORT_C void EvaluateL();
       
   303     
       
   304     /**
       
   305      * Switches between edit mode and normal mode
       
   306      *
       
   307      * @since S60 5.0
       
   308      * @param aMode Suite model container.
       
   309      */
       
   310     IMPORT_C void SetModeL( TMdMode aMode );
       
   311     
       
   312     
       
   313     /**
       
   314      * Gets suite's meta data model.
       
   315      *
       
   316      * @since S60 5.0
       
   317      * @return Suite meta data model.
       
   318      */
       
   319     IMPORT_C CHnMdSuite* GetLastSuite();
       
   320     
       
   321     /**
       
   322      * Gets suite's meta data model.
       
   323      *
       
   324      * @since S60 5.0
       
   325      * @param aPosition Position of the suite in the stack.
       
   326      * @return Suite meta data model.
       
   327      */
       
   328     CHnMdSuite* GetSuite( TInt aPosition );
       
   329     
       
   330     /**
       
   331      * Gets suite's parameters..
       
   332      *
       
   333      * @since S60 5.0
       
   334      * @param aPosition Position of the suite in the stack,
       
   335      *        from which gets parameters.
       
   336      * @return Suite meta data model.
       
   337      */
       
   338     IMPORT_C CLiwGenericParamList& GetSuiteParameters( TInt aPosition );
       
   339     
       
   340            
       
   341     /**
       
   342      * Handles back event.
       
   343      * 
       
   344      * @since S60 v3.2
       
   345      * @param aMulContainer Suite model container.
       
   346      * @param aGenre Name of the suite.
       
   347      * @param aIterations Number of iterations.
       
   348      * @return Error code.
       
   349      */  
       
   350     IMPORT_C TInt HandleBackEventL( CHnSuiteModelContainer* aMulContainer,
       
   351             const TDesC& aGenre, TInt aIterations = KModelCountForRoot );
       
   352     
       
   353     /**
       
   354      * Handles sis installation event.
       
   355      * 
       
   356      * @since S60 v3.2
       
   357      * @param aMulContainer Suite model container.
       
   358      */  
       
   359     IMPORT_C void HandleSisInstallationEventL( 
       
   360             CHnSuiteModelContainer* aMulContainer );
       
   361     
       
   362     /**
       
   363      * Loads a suite from xml data.
       
   364      * 
       
   365      * @since S60 v5.0
       
   366      * @param aGenre Name of the suite.
       
   367      * @param aSuiteParams Suite parameters.
       
   368      * @return Error code.
       
   369      */  
       
   370     IMPORT_C TInt LoadSuiteL( const TDesC& aGenre, CLiwGenericParamList* aSuiteParams = NULL );
       
   371     
       
   372     /**
       
   373      * Check if suite model exists.
       
   374      *
       
   375      * @since S60 5.0
       
   376      * @param aSuiteModel Suite model name.
       
   377      * @return ETrue if suite model exists, otherwise EFalse.
       
   378      */
       
   379     IMPORT_C TBool SuiteModelExistsL( const TDesC8& aSuiteModel );
       
   380     
       
   381     /**
       
   382      * Gets suite's meta data model.
       
   383      *
       
   384      * @since S60 5.0
       
   385      * @param aUri Current ui.
       
   386      * @return Suite meta data model.
       
   387      */
       
   388     IMPORT_C void GetCurrentUriL( TDes& aUri );
       
   389 
       
   390     /**
       
   391      * Deletes last loaded suite model from data model.
       
   392      *
       
   393      * @since S60 5.0
       
   394      */
       
   395     IMPORT_C void DeleteLastSuite();
       
   396     
       
   397     
       
   398     /**
       
   399      * Realeses localization files.
       
   400      *
       
   401      * @since S60 5.0
       
   402      */
       
   403     IMPORT_C void ReleaseLocalization();
       
   404     
       
   405     /**
       
   406      * Reloads localization.
       
   407      *
       
   408      * @since S60 5.0
       
   409      */
       
   410     IMPORT_C void ReloadLocalizationL();
       
   411     
       
   412     /**
       
   413      * Informs metadatamodel to ignore evaluations or
       
   414      * to performing evaluations, according to the
       
   415      * given parameter.
       
   416      *
       
   417      * @since S60 5.0
       
   418      * @param aIgnore Metadatamodel ignores evaluations when set to ETrue.
       
   419      */
       
   420     IMPORT_C void IgnoreEvaluations( TBool aIgnore );
       
   421     
       
   422     /**
       
   423      * Request that menu goes to foreground when evaluation completes.
       
   424      *
       
   425      * Default behavior is not to go to foreground when evaluation
       
   426      * completes. A change of this behavior requested with this method is
       
   427      * only effective until the menu is sent to foreground (once). Then the
       
   428      * default behavior is assumed again.
       
   429      * Subsequent calls override previous changes.
       
   430      *
       
   431      * @since S60 5.0
       
   432      * @param aWhen Determines when the foreground should be gained.
       
   433      *              Possible values are defined in the
       
   434      *              TForegroundGainTriggeringEvent enum. The value ENever
       
   435      *              simply means not to bring menu to foreground.
       
   436      */
       
   437     IMPORT_C void QueueForeground( TForegroundGainTriggeringEvent aWhen );
       
   438     
       
   439     /**
       
   440      * Is there a queue for foreground gain.
       
   441      *
       
   442      * @since S60 5.0
       
   443      * @return should foreground be gained after evaluation.
       
   444      */
       
   445     IMPORT_C TBool IsForegroundQueued() const;
       
   446     
       
   447     /**
       
   448      * Notifies this metadata model that suite evaluation has completed.
       
   449      *
       
   450      * @param aJustEvaluatedSuite pointer to the suite whose evaluation
       
   451      *                            has completed
       
   452      */
       
   453     void SuiteModelReadyToShowL( CHnSuiteModel* aJustEvaluatedSuite );
       
   454     
       
   455     /**
       
   456      * Causes all of the loades suites except for the suite at the bottom
       
   457      * of the stack to be reloaded from their corresponding xml file
       
   458      * definitions.
       
   459      *
       
   460      * @since S60 5.0
       
   461      * @param aIgnore aModelContainer Model container object.
       
   462      */
       
   463     void ReloadStackSuitesL( CHnSuiteModelContainer* aModelContainer );
       
   464     
       
   465     /**
       
   466      * Counts number of loaded suites.
       
   467      * 
       
   468      * @since S60 5.0
       
   469      * @return Number of loaded suites
       
   470      */
       
   471     TInt LoadedSuitesCount();
       
   472 
       
   473     /**
       
   474      * Evaluates the suite model on top of the stack.
       
   475      *
       
   476      * @since S60 5.0
       
   477      */
       
   478     void EvaluateTopSuiteL();
       
   479     
       
   480 private:
       
   481 
       
   482     /**
       
   483      * Standard C++ constructor.
       
   484      *
       
   485      * @since S60 5.0
       
   486      */
       
   487     CHnMdModel( );
       
   488 
       
   489     /**
       
   490      * Standard symbian 2nd pahse constructor.
       
   491      *
       
   492      * @since S60 5.0
       
   493      * @param aModelObserver Model observer.
       
   494      * @param aSuiteModelContainer Model container.
       
   495      */
       
   496     void ConstructL( MHnMdModelEventObserver* aModelObserver,
       
   497             CHnSuiteModelContainer * aSuiteModelContainer );
       
   498 
       
   499 private: // data
       
   500     
       
   501     /**
       
   502      * Id generator.
       
   503      */
       
   504     THnIdGenerator iIdGenerator; 
       
   505       
       
   506     /**
       
   507      * Own - Localization.
       
   508      */
       
   509     CHnMdLocalization* iLocalization;
       
   510     
       
   511     /**
       
   512      * Own - Xml model provider.
       
   513      */
       
   514     CHnXmlModelProvider* iXmlModelProvider;
       
   515     
       
   516     /**
       
   517      * Own - bitmap and mask ids cache.
       
   518      */
       
   519     CHnBitmapIdCache* iBitmapIdCache;
       
   520     
       
   521     /**
       
   522      * Not Own - Event observer.
       
   523      */
       
   524     MHnMdModelEventObserver* iModelEventObserver;
       
   525      
       
   526     /**
       
   527      * Stores pointers to common objects in the system
       
   528      * This object is shared throut the whole system.
       
   529      */ 
       
   530     THnMdCommonPointers iCmnPtrs;
       
   531      
       
   532     /**
       
   533      * Stores information about mode.
       
   534      */
       
   535     TMdMode iMode;
       
   536      
       
   537     /**
       
   538      * Loaded Suites stack.
       
   539      * Object and content owned.
       
   540      */
       
   541     RPointerArray<CHnMdSuite> iLoadedSuites;
       
   542      
       
   543     /**
       
   544      * Repository widget type observer.
       
   545      */
       
   546     CHnRepositoryObserver* iRepositoryWidgetTypeObserver;
       
   547      
       
   548     /**
       
   549      * Repository folder change observer.
       
   550      */
       
   551     CHnRepositoryObserver* iRepositoryShowFolderObserver;
       
   552      
       
   553     /**
       
   554      * Repository folder change observer.
       
   555      */
       
   556     CHnRepositoryObserver* iRepositoryZoomObserver;
       
   557      
       
   558     /**
       
   559      * When set, forces metadatamodel to skip evaluations.
       
   560      */
       
   561     TBool iIgnoreEvaluations;
       
   562      
       
   563     /**
       
   564      * Queues foreground gain action.
       
   565      */
       
   566     TBool iForegroundQueued;
       
   567      
       
   568     /**
       
   569      * Not own - pointer to the suite model that must be evaluated
       
   570      * before matrix menu can be brought to foreground.
       
   571      * 
       
   572      * When NULL, then any suite evaluation brings menu to foreground.
       
   573      * It is only meaningful when iForegroundQueued is ETrue.
       
   574      */
       
   575     CHnSuiteModel* iForegroundTriggeringSuite;
       
   576                    
       
   577     };
       
   578 
       
   579 #endif // C_HNMDMODEL_H