applicationinterworkingfw/ServiceHandler/inc/AiwServiceHandlerImpl.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2003-2005 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:     Implementation class for CAiwServiceHandler. 
       
    15 *                See also AiwServiceHandler.h.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef AIW_SERVICE_HANDLER_IMPL_H
       
    24 #define AIW_SERVICE_HANDLER_IMPL_H
       
    25 
       
    26 // INCLUDES
       
    27 #include <ecom/ecom.h>
       
    28 #include <barsread.h> 
       
    29 #include <AiwCommon.h>
       
    30 #include "AiwTlsData.h"
       
    31 #include <eikmobs.h> 
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // FUNCTION PROTOTYPES
       
    38 
       
    39 // FORWARD DECLARATIONS
       
    40 class CAiwMenuBinding;
       
    41 class CAiwMenuPane;
       
    42 class CAiwServiceIfMenu;
       
    43 class CAiwServiceIfBase;
       
    44 class CAiwEcomMonitor;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 * Internal implementation class for CAiwServiceHandler. 
       
    50 *
       
    51 * Contains the actual implementation logic for Service Handler, whereas the
       
    52 * CAiwServiceHandler class provides only the public API. 
       
    53 *
       
    54 * @see CAiwServiceHandler for API documentation.
       
    55 * @since Series 60 2.6
       
    56 */
       
    57 NONSHARABLE_CLASS(CAiwServiceHandlerImpl) :
       
    58     public CBase,
       
    59     public MAiwNotifyCallback,
       
    60     public MEikMenuObserver,
       
    61     public MAiwMenuLaunchObserver
       
    62     {
       
    63     public:  // Construction & destruction
       
    64         /**
       
    65         * Constructs CAiwServiceHandlerImpl instance.
       
    66         *
       
    67         * @return Pointer to the new instance.
       
    68         */
       
    69         static CAiwServiceHandlerImpl* NewL();
       
    70 
       
    71         /** 
       
    72         * Destructor.
       
    73         */
       
    74         virtual ~CAiwServiceHandlerImpl();
       
    75         
       
    76     public:  // Management
       
    77         /**
       
    78         * @see CAiwServiceHandler::Reset()
       
    79         */
       
    80         void Reset();
       
    81 
       
    82         /**
       
    83         * @see CAiwServiceHandler::NbrOfProviders() 
       
    84         */
       
    85         TInt NbrOfProviders(const CAiwCriteriaItem* aCriteria);
       
    86         
       
    87     public:  // Interest handling
       
    88         /**
       
    89         * @see CAiwServiceHandler::AttachL() 
       
    90         */
       
    91         void AttachL(TInt aInterestResourceId);
       
    92 
       
    93         /**
       
    94         * @see CAiwServiceHandler::AttachL() 
       
    95         */
       
    96         void AttachL(const RCriteriaArray& aInterest);
       
    97 
       
    98         /**
       
    99         * @see CAiwServiceHandler::GetInterest()
       
   100         */
       
   101         void GetInterest(RCriteriaArray& aInterest);
       
   102 
       
   103         /**
       
   104         * @see CAiwServiceHandler::DetachL()
       
   105         */
       
   106         void DetachL(const RCriteriaArray& aInterest);
       
   107 
       
   108         /**
       
   109         * @see CAiwServiceHandler::DetachL()
       
   110         */
       
   111         void DetachL(TInt aInterestResourceId); 
       
   112         
       
   113         /**
       
   114         * @see CAiwServiceHandler::GetCriteria()
       
   115         */
       
   116         const CAiwCriteriaItem* GetCriteria(TInt aId);
       
   117 
       
   118         /**
       
   119         * @see CAiwServiceHandler::InParamListL()
       
   120         */
       
   121         CAiwGenericParamList& InParamListL();
       
   122 
       
   123         /**
       
   124         * @see CAiwServiceHandler::OutParamListL()
       
   125         */
       
   126         CAiwGenericParamList& OutParamListL();
       
   127         
       
   128     public:  // Menu handling
       
   129         /**
       
   130         * @see CAiwServiceHandler::InitializeMenuPaneL()
       
   131         */
       
   132         void InitializeMenuPaneL(
       
   133             CEikMenuPane& aMenuPane,
       
   134             TInt aMenuResourceId,
       
   135             TInt aBaseMenuCmdId,
       
   136             const CAiwGenericParamList& aInParamList);
       
   137             
       
   138         /**
       
   139         * @see CAiwServiceHandler::InitializeMenuPaneL()
       
   140         */
       
   141         void InitializeMenuPaneL(
       
   142             CEikMenuPane& aMenuPane,
       
   143             TInt aMenuResourceId,
       
   144             TInt aBaseMenuCmdId,
       
   145             const CAiwGenericParamList& aInParamList,
       
   146             TBool aUseSubmenuTextsIfAvailable);            
       
   147 
       
   148         /**
       
   149         * @see CAiwServiceHandler::InitializeMenuPaneL()
       
   150         */
       
   151         void InitializeMenuPaneL(
       
   152             CEikMenuPane& aMenuPane,
       
   153             TInt aMenuResourceId,
       
   154             TInt aBaseMenuCmdId,
       
   155             const CAiwGenericParamList& aInParamList,
       
   156             TBool aUseSubmenuTextsIfAvailable,
       
   157             TBool aSetAsItemSpecific );
       
   158         
       
   159         /**
       
   160         * @see CAiwServiceHandler::ServiceCmdByMenuCmd()
       
   161         */
       
   162         TInt ServiceCmdByMenuCmd(TInt aMenuCmdId) const;
       
   163 
       
   164         /**
       
   165         * @see CAiwServiceHandler::ExecuteMenuCmdL()
       
   166         */
       
   167         void ExecuteMenuCmdL(
       
   168             TInt aMenuCmdId,
       
   169             const CAiwGenericParamList& aInParamList,
       
   170             CAiwGenericParamList& aOutParamList,
       
   171             TUint aCmdOptions = 0,
       
   172             MAiwNotifyCallback* aCallback= NULL);
       
   173 
       
   174         /**
       
   175         * @see CAiwServiceHandler::AttachMenuL()
       
   176         */
       
   177         void AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId);
       
   178 
       
   179         /**
       
   180         * @see CAiwServiceHandler::AttachMenuL()
       
   181         */
       
   182         void AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader);
       
   183         
       
   184         /**
       
   185         * @see CAiwServiceHandler::AttachMenuL()
       
   186         */
       
   187         void AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest);           
       
   188         
       
   189         /**
       
   190         * @see CAiwServiceHandler::DetachMenu()
       
   191         */
       
   192         void DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId);
       
   193 
       
   194         /**
       
   195         * @see CAiwServiceHandler::IsSubMenuEmpty()
       
   196         */
       
   197         TBool IsSubMenuEmpty(TInt aSubMenuId);
       
   198 
       
   199         /**
       
   200         * @see CAiwServiceHandler::IsAiwMenu()
       
   201         */
       
   202         TBool IsAiwMenu(TInt aMenuResourceId);
       
   203 
       
   204         /**
       
   205         * @see CAiwServiceHandler::HandleSubmenuL()
       
   206         */
       
   207         TBool HandleSubmenuL(CEikMenuPane& aPane);
       
   208 
       
   209     public:  // Generic service command handling
       
   210         /**
       
   211         * @see CAiwServiceHandler::ExecuteServiceCmdL()
       
   212         */
       
   213         void ExecuteServiceCmdL(
       
   214             const TInt& aCmdId,
       
   215             const CAiwGenericParamList& aInParamList,
       
   216             CAiwGenericParamList& aOutParamList,
       
   217             TUint aCmdOptions = 0,
       
   218             MAiwNotifyCallback* aCallback = 0);
       
   219 
       
   220     public:  // Other new methods
       
   221         /** 
       
   222         * Called by CAiwEcomMonitor.
       
   223         *
       
   224         * @param aImpl An object representing this class.
       
   225         * @return An error code. KErrNone if successful.
       
   226         */ 
       
   227         static TInt SynchronizeCallBack(TAny* aImpl);
       
   228         
       
   229     public: // From MAiwNotifyCallback
       
   230         TInt HandleNotifyL(
       
   231             TInt aCmdId,
       
   232             TInt aEventId,
       
   233             CAiwGenericParamList& aEventParamList,
       
   234             const CAiwGenericParamList& aInParamList);
       
   235 
       
   236     public: // From MEikMenuObserver
       
   237         void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis);
       
   238 
       
   239     public: // From MEikCommandObserver (via MEikMenuObserver)
       
   240         void ProcessCommandL(TInt aCommandId);
       
   241 
       
   242     private: // From MAiwMenuLaunchObserver
       
   243         void MenuLaunched();
       
   244 
       
   245     private:
       
   246         // Possible placeholder types.
       
   247         enum TAiwPlaceholderType
       
   248             {
       
   249             EAiwPlaceholderNormal,
       
   250             EAiwPlaceholderCascade,     
       
   251             EAiwPlaceholderIntelligentCascade
       
   252             };
       
   253 
       
   254     private:
       
   255         CAiwServiceHandlerImpl();
       
   256         void ConstructL();
       
   257 
       
   258         // Attach menu related criteria items to given menu. 
       
   259         void DoAttachMenuL(TResourceReader& aReader, TInt aMenuId, RCriteriaArray& aInterest);
       
   260 
       
   261         void DoAttachL(const RCriteriaArray& aInterest);
       
   262         void ReadInterestListL(TResourceReader& aReader, RPointerArray<CAiwCriteriaItem>& aResult);
       
   263         TInt ResolveProvidersL(CAiwBinding* aBinding, CAiwCriteriaItem* aItem);
       
   264         TBool IsCached(CAiwServiceIfBase* aProvider);
       
   265         
       
   266         CAiwMenuPane* CreateEmptyAiwMenuPaneL(TInt aBaseMenuCmdId, TInt aResourceId);
       
   267         void DeleteAiwMenuPane(CAiwMenuPane* aAiwPane);
       
   268         
       
   269         TInt ResourceIdForNextFreeSlot();
       
   270         void CopyMenuItemsL(CAiwMenuPane* aSource, CEikMenuPane& aDest, TInt aStartIndex, 
       
   271             TBool aIsSubmenu, TBool aSetAsItemSpecific);
       
   272         TInt SlotItemCmd(CEikMenuPane& aPane);
       
   273         CAiwMenuPane* MenuPaneForSlotCmd(TInt aCmdId);
       
   274         TAiwPlaceholderType PlaceholderType(CEikMenuPane& aPane, TInt aCmd, TBool& aTitleLocked);
       
   275         void ConvertPlaceholderL(CEikMenuPane& aPane, TInt aCmd, CAiwMenuPane& aAiwPane, 
       
   276             const TDesC& aTitle, TBool aSetAsItemSpecific);
       
   277         void UnCascadeL(CEikMenuPane& aPane, TInt aCmd, CAiwMenuPane& aAiwPane,
       
   278             TBool aSetAsItemSpecific);
       
   279         void SkipMenuFields(TResourceReader& aReader);
       
   280         TBool IsInLastInitialized(CAiwMenuPane* aiwPane) const;
       
   281         TBool GetSubmenuTitle(CEikMenuPane& aPane, TDes& aResult);
       
   282         TBool IsCriteriaAlreadyInInterest(CAiwCriteriaItem& aItem, 
       
   283             RPointerArray<CAiwCriteriaItem>& aInterest) const;
       
   284         CAiwCriteriaItem* ConvertCriteriaItemPointerL(CAiwCriteriaItem* aCandidate);
       
   285         void FilterInterestListL(RPointerArray<CAiwCriteriaItem>& aOriginal,
       
   286             RPointerArray<CAiwCriteriaItem>& aFiltered);
       
   287         void FilterInfoArray(RImplInfoPtrArray& aArray, CAiwCriteriaItem* aItem);
       
   288         CAiwMenuBinding* AlreadyBound(TInt aMenuId, TInt aMenuCmd, TInt aMenuItemIndex) const;
       
   289         void SynchronizeDbL();
       
   290         void ListProvidersForCriteriaL(RArray<TInt>& aResult, CAiwCriteriaItem& aItem);
       
   291         void HandleRemovedProviders(RArray<TInt>& aInMemory, RImplInfoPtrArray& aOnSystem);
       
   292         void HandleNewProvidersL(RArray<TInt>& aInMemory, RImplInfoPtrArray& aOnSystem, 
       
   293             CAiwCriteriaItem* aItem);
       
   294         void RemoveProvider(TInt aImplUid);
       
   295         void AddProviderL(TUid aImplUid, CAiwCriteriaItem* aItem);
       
   296         inline void ClearMenuPaneArray();
       
   297         TInt NumAlreadyInitializedPaneIdsL() const;
       
   298 
       
   299         // Leaving helper method. Handler cleanupstack issues and calls ReadInterestListL().
       
   300         void ReadInterestL(RCriteriaArray& aInterest, TInt aInterestResourceId);
       
   301 
       
   302         // Detaches all items from given menu.        
       
   303         void DoDetachMenu(TInt aMenuResourceId);
       
   304 
       
   305         // Detaches only those items from a given menu, which match the given interest.
       
   306         void DoDetachMenu(TInt aMenuResourceId, RCriteriaArray& aInterest);
       
   307         
       
   308         // Removes unnecessary criteria items from Service Handler.
       
   309         void RemoveObsoleteCriteriaItems();
       
   310         
       
   311         // Removes unnecessary providers from Service Handler.
       
   312         void RemoveObsoleteProviders();
       
   313 
       
   314     private:
       
   315         // Pointer to the control environment.
       
   316         CCoeEnv* iCoeEnv;
       
   317         
       
   318         // Owns all the attached criteria items.
       
   319         RPointerArray<CAiwCriteriaItem> iInterestList;  
       
   320         
       
   321         // Criteria -> provider bindings for base service providers.
       
   322         RPointerArray<CAiwBinding>      iBaseBindings;  
       
   323         
       
   324         // Criteria -> provider bindings for menu service providers.
       
   325         RPointerArray<CAiwMenuBinding>  iMenuBindings;  
       
   326         
       
   327         // Contains the AIW menu panes.
       
   328         RPointerArray<CAiwMenuPane>     iMenuPanes;     
       
   329 
       
   330         // Input parameter list which can be given to the consumer application.
       
   331         CAiwGenericParamList* iInParams;
       
   332         
       
   333         // Output parameter list which can be given to the consumer application.
       
   334         CAiwGenericParamList* iOutParams; 
       
   335         
       
   336         // Resource offset for AiwServiceHandler.rsc.
       
   337         TInt iResourceOffset;
       
   338         
       
   339         // Owns all the providers currently in memory.
       
   340         RPointerArray<CAiwServiceIfBase> iProviders;  
       
   341           
       
   342         TInt                             iNextFreeSlot;
       
   343         RPointerArray<CAiwMenuPane>      iLastInitialized;
       
   344         CAiwMenuPane*                    iSubmenu;
       
   345         TInt                             iSubmenuCmd;
       
   346         CAiwEcomMonitor*                 iEcomMonitor;
       
   347         TBool                            iTlsDataOpened;
       
   348     };
       
   349 
       
   350 
       
   351 inline void CAiwServiceHandlerImpl::ClearMenuPaneArray()
       
   352     {
       
   353     iMenuPanes.ResetAndDestroy();
       
   354     }
       
   355 
       
   356 #endif // AIW_SERVICE_HANDLER_IMPL_H
       
   357 
       
   358 // END of File
       
   359 
       
   360