phonebookui/Phonebook2/ccapplication/ccapp/inc/ccaappview.h
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007 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:  A class responsible handling the views
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CCAAPPVIEW_H
       
    20 #define C_CCAAPPVIEW_H
       
    21 
       
    22 #include <e32base.h>                             
       
    23 #include <coedef.h>
       
    24 #include <w32std.h>
       
    25 
       
    26 #include <mccacontactobserver.h>
       
    27 #include <mccappengine.h>
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CCCAppStatusPaneHandler;
       
    31 class CCCAAppAppUi;
       
    32 class MVPbkStoreContact;
       
    33 class MCCAppPluginsContactObserver;
       
    34 
       
    35 /**
       
    36  *  CCCAppView
       
    37  *
       
    38  *  @code
       
    39  *  @endcode
       
    40  *
       
    41  *  @lib ccaapp
       
    42  *  @since S60 v5.0
       
    43  */
       
    44 class CCCAppView : 
       
    45     public CBase,
       
    46     public MCCAppContactFieldDataObserver,
       
    47     public MCCAppEngine
       
    48 	{
       
    49 #ifdef __CCAPPUNITTESTMODE
       
    50     friend class ut_CCCAppView;
       
    51 #endif// __CCAPPUNITTESTMODE  
       
    52     
       
    53 public:
       
    54 	/**
       
    55 	 * Two-phased constructor.
       
    56 	 */
       
    57     static CCCAppView* NewL( CCCAAppAppUi& aAppUi );
       
    58     
       
    59     /**
       
    60      * Destructor.
       
    61      */
       
    62     ~CCCAppView();
       
    63 
       
    64     
       
    65 public: // From MCCAppEngine
       
    66     
       
    67     /**
       
    68      * From MCCAppEngine
       
    69      */ 
       
    70     void CCAppContactEventL();
       
    71     
       
    72     /**
       
    73      * From MCCAppEngine
       
    74      */ 
       
    75     void AddObserverL( MCCAppPluginsContactObserver& aObserver );
       
    76     
       
    77     /**
       
    78      * From MCCAppEngine
       
    79      */ 
       
    80     void RemoveObserver( MCCAppPluginsContactObserver& aObserver );
       
    81     
       
    82     /**
       
    83      * From MCCAppEngine
       
    84      */ 
       
    85     MCCAParameter& Parameter();
       
    86 
       
    87     /**
       
    88      * From MCCAppEngine
       
    89      */ 
       
    90     void ShowPluginL( TUid aUid ); 
       
    91 
       
    92     /**
       
    93      * From MCCAppEngine
       
    94      */ 
       
    95     void HidePluginL( TUid aUid );    
       
    96 
       
    97 private:// from MCCAppContactFieldDataObserver
       
    98 
       
    99 	/**
       
   100 	 * from MCCAppContactFieldDataObserver
       
   101 	 */
       
   102     void ContactFieldDataObserverNotifyL( 
       
   103         MCCAppContactFieldDataObserver::TParameter& aParameter );    
       
   104 
       
   105 	/**
       
   106 	 * from MCCAppContactFieldDataObserver
       
   107 	 */
       
   108     void ContactFieldDataObserverHandleErrorL( 
       
   109         TInt aState, TInt aError );
       
   110 
       
   111 private:
       
   112 	/**
       
   113 	 * Constructor.
       
   114 	 */        
       
   115     CCCAppView( CCCAAppAppUi& aAppUi );    
       
   116     void ConstructL();
       
   117 
       
   118 public: // Implementation
       
   119 
       
   120 	/**
       
   121      * Activates the plugin view.
       
   122      * AppUi exits in case it receives error.
       
   123 	 *
       
   124 	 * @since S60 v5.0
       
   125 	 * @param aUid is the uid of the plugin preferred to be visible 1st
       
   126 	 * @return possible error code
       
   127 	 */
       
   128     TInt StartView( const TUid aUid );    
       
   129 
       
   130 	/**
       
   131 	 * Changes the plugin view.
       
   132      * AppUi exits in case it receives error.
       
   133 	 *
       
   134 	 * @since S60 v5.0
       
   135 	 * @param aForward next/previous plugin
       
   136      * @return possible error code
       
   137 	 */
       
   138     TInt ChangeView( TBool aForward );
       
   139 
       
   140     /**
       
   141      * TabChangedL is called after the tab is
       
   142      * succesfully changed by CAknTabGroup.
       
   143      * TabChangedL activates corresponding plugin.
       
   144      *
       
   145      * @since S60 v5.0
       
   146      * @param aIndex of plugin to be activated
       
   147      */    
       
   148     void TabChangedL( TInt aIndex );
       
   149     
       
   150     /**
       
   151 	 * Returns the AppUi reference
       
   152 	 *
       
   153 	 * @since S60 v5.0
       
   154 	 * @return reference to CCCAAppAppUi
       
   155 	 */    
       
   156     CCCAAppAppUi& AppUi();
       
   157 
       
   158 	/**
       
   159 	 * Returns the Eikon Enviroment reference
       
   160 	 *
       
   161 	 * @since S60 v5.0
       
   162 	 * @return reference to CEikonEnv
       
   163 	 */ 
       
   164     CEikonEnv& EikonEnv();
       
   165 
       
   166 	/**
       
   167 	 * Returns the CCCAppPluginLoader reference
       
   168 	 *
       
   169 	 * @since S60 v5.0
       
   170 	 * @return reference to CCCAppPluginLoader
       
   171 	 */ 
       
   172     CCCAppPluginLoader& PluginLoader();
       
   173 
       
   174     /**
       
   175      * Tries to handle most of the cases when plugin 
       
   176      * leaves in critical point. Panics are out of our
       
   177      * reach.
       
   178      * 
       
   179      * In practise "bad boy" is removed from plugin 
       
   180      * array and the 1st plugin in the array is then 
       
   181      * activated.
       
   182      * 
       
   183      * Handles the cases if leave occurs in one of the 
       
   184      * following plugin methods:
       
   185      * - NewL / ConstructL
       
   186      * - PreparePluginViewL
       
   187      * - NewContainerL
       
   188      * - DoActivateL
       
   189      * 
       
   190      * DoActivateL call happens in Avkon fw and by
       
   191      * default the last working view is set to be
       
   192      * active. To keep the functionality similar
       
   193      * (and simple) in most cases, CIdle callback
       
   194      * ResetViewL() is used.
       
   195      * 
       
   196      * Since recovering should not be everyday use case,
       
   197      * implementation is a compromise. Recovering 
       
   198      * functionality is not recursive. If the plugin
       
   199      * failing is the 1st one, application is closed. 
       
   200      *
       
   201      * @since S60 v5.0
       
   202      */
       
   203     void RecoverFromBadPluginL();
       
   204     
       
   205     /**
       
   206      * @return ETrue if active plug-in is busy with some processing,
       
   207      *         EFalse otherwise
       
   208      */
       
   209     TBool CurrentPluginBusy();
       
   210 
       
   211 private: //New
       
   212 
       
   213 	/**
       
   214 	 * Activates plugin itself
       
   215 	 *
       
   216 	 * @since S60 v5.0
       
   217 	 * @param aPluginDataInFocus is the data of plugin to be activated
       
   218 	 */ 
       
   219     void ActivatePluginL( CCCAppPluginData& aPluginDataInFocus );
       
   220 
       
   221 	/**
       
   222 	 * Updates the titlepane based on contact data notifications.
       
   223 	 * See also ContactFieldDataObserverNotifyL.
       
   224 	 *
       
   225 	 * @since S60 v5.0
       
   226 	 * @param aContactField is contact data field
       
   227 	 */
       
   228     void ContactFieldFetchedNotifyL( 
       
   229         CCmsContactField& aContactField );       
       
   230 
       
   231     /**
       
   232      * Activates the plugin view. Leaves in case of errors.
       
   233      *
       
   234      * @since S60 v5.0
       
   235      * @param aUid is the uid of the plugin preferred to be visible 1st
       
   236      */    
       
   237     void StartViewL( const TUid aUid );    
       
   238 
       
   239     /**
       
   240      * Changes the plugin view. Leaves in case of errors.
       
   241      *
       
   242      * @since S60 v5.0
       
   243      * @param aForward next/previous plugin
       
   244      */    
       
   245     void ChangeViewL( TBool aForward );    
       
   246     
       
   247     /**
       
   248      * CIdle-callback for resetting the view.
       
   249      * See RecoverFromBadPluginL.
       
   250      *
       
   251      * @since S60 v5.0
       
   252      */
       
   253     static TInt ResetViewL( TAny* aSelf );    
       
   254 
       
   255     /**
       
   256      * Check other plugin visibilities.
       
   257      *
       
   258      * @since S60 v5.0
       
   259      */    
       
   260     void CheckOtherPluginVisibilitiesL();    
       
   261 
       
   262     /**
       
   263      * Check other plugin visibilities.
       
   264      *
       
   265      * @since S60 v5.0
       
   266      * @param aPluginToFocus 
       
   267      */    
       
   268     void StartPluginL(TInt aPluginToFocus);    
       
   269 
       
   270     /**
       
   271      * Shows plugin.
       
   272      *
       
   273      * @since S60 v5.0
       
   274      * @param aUid 
       
   275      */    
       
   276     void PerformShowPluginL( TUid aUid ); 
       
   277     
       
   278     /**
       
   279      * Hides plugin.
       
   280      *
       
   281      * @since S60 v5.0
       
   282      * @param aUid 
       
   283      */    
       
   284     void PerformHidePluginL( TUid aUid );    
       
   285     
       
   286     /**
       
   287      * Callback function for CIdle object that calls ConstructDelayedL().
       
   288      *
       
   289      * @since S60 v5.0
       
   290      * @param aContainer 
       
   291      */    
       
   292     static TInt ConstructDelayedCallbackL( TAny* aContainer );
       
   293 
       
   294     /**
       
   295      * Performs time consuming construction operations once.
       
   296      *
       
   297      * @since S60 v5.0
       
   298      */    
       
   299     void DoConstructDelayedL();    
       
   300     
       
   301     
       
   302     /**
       
   303      * Performs the synch between the tabs & the Visible Plugins
       
   304      *
       
   305      * @since S60 v5.0
       
   306      */
       
   307     void SynchPluginVisibilityWithTabAfterDelayedStartL();
       
   308 
       
   309 private: //Data
       
   310 
       
   311 	/**
       
   312 	 * Status pane handler.
       
   313 	 * Own.  
       
   314 	 */    
       
   315     CCCAppStatusPaneHandler* iPaneHandler; 
       
   316 
       
   317     /**
       
   318      * Reference to AppUi
       
   319      * Not own.
       
   320      */
       
   321     CCCAAppAppUi& iAppUi;
       
   322 
       
   323     /**
       
   324      * Pointer to pluginloader
       
   325      * Own.
       
   326      */
       
   327     CCCAppPluginLoader* iPluginLoader;
       
   328 
       
   329     /**
       
   330      * Boolean for monitoring is view change currently in progress.
       
   331      * Own.
       
   332      */
       
   333     TBool iViewChangeInProgress;
       
   334      
       
   335     /**
       
   336      * Pointer to CMS contact fetcher wrapper
       
   337      * Own.
       
   338      */      
       
   339      CCCAppCmsContactFetcherWrapper* iCmsWrapper;
       
   340 
       
   341      /**
       
   342       * Pointer to CIdle in cases of recovering
       
   343       * Own.
       
   344       */      
       
   345      CIdle* iViewResetter;
       
   346      
       
   347      /**
       
   348       * Pointer to observers.
       
   349       * Not owed.
       
   350       */
       
   351      RPointerArray<MCCAppPluginsContactObserver> iObservers;
       
   352 
       
   353      /**
       
   354       * Members and pointers for functionality to control delayed
       
   355       * lazy plugin initialisation during construction.
       
   356       */
       
   357      CIdle* iDelayedConstructor;     
       
   358      TBool iDelayedStarting;
       
   359      
       
   360      enum TDelayState
       
   361          {
       
   362          EDelayedCreateTabs = 0,
       
   363          EDelayedCheckVisibilities,
       
   364          EDelayedCheckVisibilitiesOk,
       
   365          EDelayedFinish
       
   366          };
       
   367      TInt iDelayState;
       
   368      TInt iDelayedPluginVisibilityCheck;
       
   369      TBool iDelayedVisibilityChanged;
       
   370      
       
   371      //has a list of plugins which needs tobe synched
       
   372      RArray <TUid> iPluginUidToBeSynchd;
       
   373 	};
       
   374 
       
   375 #endif // C_CCAAPPVIEW_H
       
   376