languageinterworkingfw/servicehandler/inc/liwservicehandlerimpl.h
changeset 57 61b27eec6533
parent 45 7aa6007702af
equal deleted inserted replaced
45:7aa6007702af 57:61b27eec6533
     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 the License "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 CLiwServiceHandler. 
       
    15 *                See also LiwServiceHandler.h.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 #ifndef LIW_SERVICE_HANDLER_IMPL_H
       
    26 #define LIW_SERVICE_HANDLER_IMPL_H
       
    27 
       
    28 // INCLUDES
       
    29 #include <ecom/ecom.h>
       
    30 #include <barsread.h> 
       
    31 #include <liwcommon.h>
       
    32 #include "liwtlsdata.h"
       
    33 #include <eikmobs.h> 
       
    34 #include <e32capability.h>
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // MACROS
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 class CLiwMenuBinding;
       
    44 class CLiwMenuPane;
       
    45 class CLiwServiceIfMenu;
       
    46 class CLiwServiceIfBase;
       
    47 class CLiwEcomMonitor;
       
    48 class CRTSecMgrScriptSession;
       
    49 
       
    50 // CLASS DECLARATION
       
    51 
       
    52 /**
       
    53 * Internal implementation class for CLiwServiceHandler. 
       
    54 *
       
    55 * Contains the actual implementation logic for Service Handler, whereas the
       
    56 * CLiwServiceHandler class provides only the public API. 
       
    57 *
       
    58 * @see CLiwServiceHandler for API documentation.
       
    59 * @since Series 60 2.6
       
    60 */
       
    61 NONSHARABLE_CLASS(CLiwServiceHandlerImpl) :
       
    62     public CBase,
       
    63     public MLiwNotifyCallback,
       
    64     public MEikMenuObserver,
       
    65     public MLiwMenuLaunchObserver
       
    66     {
       
    67     public:  // Construction & destruction
       
    68         /**
       
    69         * Constructs CLiwServiceHandlerImpl instance.
       
    70         *
       
    71         * @return Pointer to the new instance.
       
    72         */
       
    73         static CLiwServiceHandlerImpl* NewL();
       
    74 
       
    75         /** 
       
    76         * Destructor.
       
    77         */
       
    78         virtual ~CLiwServiceHandlerImpl();
       
    79         
       
    80     public:  // Management
       
    81         /**
       
    82         * @see CLiwServiceHandler::Reset()
       
    83         */
       
    84         void Reset();
       
    85 
       
    86         /**
       
    87         * @see CLiwServiceHandler::NbrOfProviders() 
       
    88         */
       
    89         TInt NbrOfProviders(const CLiwCriteriaItem* aCriteria);
       
    90         
       
    91         
       
    92         
       
    93     public:  // Interest handling
       
    94         /**
       
    95         * @see CLiwServiceHandler::AttachL() 
       
    96         */
       
    97         void AttachL(TInt aInterestResourceId);
       
    98 
       
    99         /**
       
   100         * @see CLiwServiceHandler::AttachL() 
       
   101         */
       
   102         TInt AttachL(const RCriteriaArray& aInterest);
       
   103         
       
   104         TInt AttachL(const RCriteriaArray& aInterest,CRTSecMgrScriptSession* aSecMgrScriptSession);
       
   105         /**
       
   106         * @see CLiwServiceHandler::QueryImplementationL() 
       
   107         */
       
   108         void QueryImplementationL(CLiwCriteriaItem* aItem, RCriteriaArray& aProviderList);
       
   109 		void GetCapabilitiesL(RArray<TCapability>& secMgrCapList,CLiwGenericParamList* pMetaData);
       
   110         /**
       
   111         * @see CLiwServiceHandler::GetProviderResourceFile() 
       
   112         */
       
   113         void GetProviderResourceFile(TDes& aFilePath, CLiwGenericParamList* pMetaData);
       
   114         
       
   115         /**
       
   116         * @see CLiwServiceHandler::GetInterest()
       
   117         */
       
   118         void GetInterest(RCriteriaArray& aInterest);
       
   119 
       
   120         /**
       
   121         * @see CLiwServiceHandler::DetachL()
       
   122         */
       
   123         void DetachL(const RCriteriaArray& aInterest);
       
   124 
       
   125         /**
       
   126         * @see CLiwServiceHandler::DetachL()
       
   127         */
       
   128         void DetachL(TInt aInterestResourceId); 
       
   129         
       
   130         /**
       
   131         * @see CLiwServiceHandler::GetCriteria()
       
   132         */
       
   133         const CLiwCriteriaItem* GetCriteria(TInt aId);
       
   134 
       
   135         /**
       
   136         * @see CLiwServiceHandler::InParamListL()
       
   137         */
       
   138         CLiwGenericParamList& InParamListL();
       
   139 
       
   140         /**
       
   141         * @see CLiwServiceHandler::OutParamListL()
       
   142         */
       
   143         CLiwGenericParamList& OutParamListL();
       
   144         
       
   145     public:  // Menu handling
       
   146         /**
       
   147         * @see CLiwServiceHandler::InitializeMenuPaneL()
       
   148         */
       
   149         void InitializeMenuPaneL(
       
   150             CEikMenuPane& aMenuPane,
       
   151             TInt aMenuResourceId,
       
   152             TInt aBaseMenuCmdId,
       
   153             const CLiwGenericParamList& aInParamList);
       
   154         /**
       
   155         * @see CLiwServiceHandler::InitializeMenuPaneL()
       
   156         */
       
   157         void InitializeMenuPaneL(
       
   158             CEikMenuPane& aMenuPane,
       
   159             TInt aMenuResourceId,
       
   160             TInt aBaseMenuCmdId,
       
   161             const CLiwGenericParamList& aInParamList,
       
   162             TBool aUseSubmenuTextsIfAvailable);            
       
   163         
       
   164         /**
       
   165         * @see CLiwServiceHandler::ServiceCmdByMenuCmd()
       
   166         */
       
   167         TInt ServiceCmdByMenuCmd(TInt aMenuCmdId) const;
       
   168 
       
   169         /**
       
   170         * @see CLiwServiceHandler::ExecuteMenuCmdL()
       
   171         */
       
   172         void ExecuteMenuCmdL(
       
   173             TInt aMenuCmdId,
       
   174             const CLiwGenericParamList& aInParamList,
       
   175             CLiwGenericParamList& aOutParamList,
       
   176             TUint aCmdOptions = 0,
       
   177             MLiwNotifyCallback* aCallback= NULL);
       
   178 
       
   179         /**
       
   180         * @see CLiwServiceHandler::AttachMenuL()
       
   181         */
       
   182         void AttachMenuL(TInt aMenuResourceId, TInt aInterestResourceId);
       
   183 
       
   184         /**
       
   185         * @see CLiwServiceHandler::AttachMenuL()
       
   186         */
       
   187         void AttachMenuL(TInt aMenuResourceId, TResourceReader& aReader);
       
   188         
       
   189         /**
       
   190         * @see CLiwServiceHandler::AttachMenuL()
       
   191         */
       
   192         void AttachMenuL(TInt aMenuResourceId, const RCriteriaArray& aInterest);
       
   193         
       
   194         /**
       
   195         * Attach menu related criteria items to given menu.
       
   196         *
       
   197         * @param aMenuEntries     List of menu command ids.
       
   198         * @param aMenuResourceId  Menu to be attached.
       
   199         * @param aInterest        Interest list.
       
   200         */
       
   201         void AttachMenuL(RArray<TInt>& aMenuEntries, TInt aMenuResourceId, RCriteriaArray& aInterest);        
       
   202 
       
   203         /**
       
   204         * Attach menu related criteria items to given menu.
       
   205         *
       
   206         * @param aMenuResourceId    Resource reader pointing
       
   207         *                           to menu to be attached.
       
   208         */
       
   209         
       
   210         //void AttachMenuL(TResourceReader& aReader, TInt aMenuId, RCriteriaArray& aInterest);
       
   211 
       
   212         /**
       
   213         * @see CLiwServiceHandler::DetachMenu()
       
   214         */
       
   215         void DetachMenu(TInt aMenuResourceId, TInt aInterestResourceId);
       
   216 
       
   217         /**
       
   218         * @see CLiwServiceHandler::IsSubMenuEmpty()
       
   219         */
       
   220         TBool IsSubMenuEmpty(TInt aSubMenuId);
       
   221 
       
   222         /**
       
   223         * @see CLiwServiceHandler::IsLiwMenu()
       
   224         */
       
   225         TBool IsLiwMenu(TInt aMenuResourceId);
       
   226 
       
   227         /**
       
   228         * @see CLiwServiceHandler::HandleSubmenuL()
       
   229         */
       
   230         TBool HandleSubmenuL(CEikMenuPane& aPane);
       
   231 
       
   232     public:  // Generic service command handling
       
   233         /**
       
   234         * @see CLiwServiceHandler::ExecuteServiceCmdL()
       
   235         */
       
   236         void ExecuteServiceCmdL(
       
   237             const TInt& aCmdId,
       
   238             const CLiwGenericParamList& aInParamList,
       
   239             CLiwGenericParamList& aOutParamList,
       
   240             TUint aCmdOptions = 0,
       
   241             MLiwNotifyCallback* aCallback = 0);
       
   242         
       
   243         /**
       
   244         * @see CLiwServiceHandler::ExecuteServiceCmdL()
       
   245         */
       
   246         void ExecuteServiceCmdL(                        
       
   247             const CLiwCriteriaItem& aCmd,
       
   248             const CLiwGenericParamList& aInParamList,
       
   249             CLiwGenericParamList& aOutParamList,
       
   250             TUint aCmdOptions = 0,
       
   251             MLiwNotifyCallback* aCallback = 0);
       
   252 
       
   253         /**
       
   254         * @see CLiwServiceHandler::MenuCmdId()
       
   255         */
       
   256         TInt MenuCmdId(TInt aMenuCmdId) const;            
       
   257 
       
   258     public:  // Other new methods
       
   259         /** 
       
   260         * Called by CLiwEcomMonitor.
       
   261         *
       
   262         * @param aImpl An object representing this class.
       
   263         * @return An error code. KErrNone if successful.
       
   264         */ 
       
   265         static TInt SynchronizeCallBack(TAny* aImpl);
       
   266         
       
   267     public: // From MLiwNotifyCallback
       
   268         TInt HandleNotifyL(
       
   269             TInt aCmdId,
       
   270             TInt aEventId,
       
   271             CLiwGenericParamList& aEventParamList,
       
   272             const CLiwGenericParamList& aInParamList);
       
   273 
       
   274     public: // From MEikMenuObserver
       
   275         void SetEmphasis(CCoeControl* aMenuControl,TBool aEmphasis);
       
   276 
       
   277     public: // From MEikCommandObserver (via MEikMenuObserver)
       
   278         void ProcessCommandL(TInt aCommandId);
       
   279 
       
   280 	    void GetProviderCapability(CLiwCriteriaItem* aItem,RCriteriaArray& aOutItem);
       
   281 	
       
   282     private: // From MLiwMenuLaunchObserver
       
   283         void MenuLaunched();
       
   284 
       
   285     private:
       
   286         // Possible placeholder types.
       
   287         enum TLiwPlaceholderType
       
   288             {
       
   289             ELiwPlaceholderNormal,
       
   290             ELiwPlaceholderCascade,     
       
   291             ELiwPlaceholderIntelligentCascade
       
   292             };
       
   293 
       
   294     private:
       
   295         CLiwServiceHandlerImpl();
       
   296         void ConstructL();
       
   297 
       
   298         // Attach menu related criteria items to given menu. 
       
   299         void DoAttachMenuL(TResourceReader& aReader, TInt aMenuId, RCriteriaArray& aInterest);
       
   300 
       
   301         TInt DoAttachL(const RCriteriaArray& aInterest,CRTSecMgrScriptSession* aScriptSession);
       
   302         void DoAttachL(const RCriteriaArray& aInterest);
       
   303         
       
   304         void ReadInterestListL(TResourceReader& aReader, RPointerArray<CLiwCriteriaItem>& aResult);
       
   305         TInt ResolveProvidersL(CLiwBinding* aBinding, CLiwCriteriaItem* aItem, CRTSecMgrScriptSession* aScriptSession);
       
   306         TInt ResolveProvidersL(CLiwBinding* aBinding, CLiwCriteriaItem* aItem);
       
   307         
       
   308         TBool IsCached(CLiwServiceIfBase* aProvider);
       
   309         
       
   310         CLiwMenuPane* CreateEmptyLiwMenuPaneL(TInt aBaseMenuCmdId, TInt aResourceId);
       
   311         void DeleteLiwMenuPane(CLiwMenuPane* aLiwPane);
       
   312         
       
   313         TInt ResourceIdForNextFreeSlot();
       
   314         void CopyMenuItemsL(CLiwMenuPane* aSource, CEikMenuPane& aDest, TInt aStartIndex, 
       
   315             TBool aIsSubmenu);
       
   316         TInt SlotItemCmd(CEikMenuPane& aPane);
       
   317         CLiwMenuPane* MenuPaneForSlotCmd(TInt aCmdId);
       
   318         TLiwPlaceholderType PlaceholderType(CEikMenuPane& aPane, TInt aCmd, TBool& aTitleLocked);
       
   319         void ConvertPlaceholderL(CEikMenuPane& aPane, TInt aCmd, CLiwMenuPane& aLiwPane, 
       
   320             const TDesC& aTitle);
       
   321         void UnCascadeL(CEikMenuPane& aPane, TInt aCmd, CLiwMenuPane& aLiwPane);
       
   322         void SkipMenuFields(TResourceReader& aReader);
       
   323         TBool IsInLastInitialized(CLiwMenuPane* liwPane) const;
       
   324         TBool GetSubmenuTitle(CEikMenuPane& aPane, TDes& aResult);
       
   325         TBool IsCriteriaAlreadyInInterest(CLiwCriteriaItem& aItem, 
       
   326             RPointerArray<CLiwCriteriaItem>& aInterest) const;
       
   327         CLiwCriteriaItem* ConvertCriteriaItemPointerL(CLiwCriteriaItem* aCandidate);
       
   328         void FilterInterestListL(RPointerArray<CLiwCriteriaItem>& aOrginal,
       
   329             RPointerArray<CLiwCriteriaItem>& aFiltered);
       
   330         void FilterInfoArray(RImplInfoPtrArray& aArray, RArray<TInt32>& aArrayPlugin,
       
   331             CLiwCriteriaItem* aItem);   
       
   332         CLiwMenuBinding* AlreadyBound(TInt aMenuId, TInt aMenuCmd, TInt aMenuItemIndex) const;
       
   333         void SynchronizeDbL();
       
   334         void ListProvidersForCriteriaL(RArray<TInt>& aResult, CLiwCriteriaItem& aItem);
       
   335         void HandleRemovedProviders(RArray<TInt>& aInMemory, RImplInfoPtrArray& aOnSystem);
       
   336         void HandleNewProvidersL(RArray<TInt>& aInMemory, RImplInfoPtrArray& aOnSystem, 
       
   337             CLiwCriteriaItem* aItem);
       
   338         void RemoveProvider(TInt aImplUid);
       
   339         void AddProviderL(TUid aImplUid, CLiwCriteriaItem* aItem);
       
   340         inline void ClearMenuPaneArray();
       
   341         void AttachServiceManagerPluginsL();
       
   342         void ServiceManagerPlugin_ListImplementationsL(RArray<TInt32>& aArray, CLiwCriteriaItem* aItem);
       
   343         CLiwServiceIfBase* ServiceManagerPlugin_CreateImplementationL(TInt32 aImplUid);
       
   344         TInt NumAlreadyInitializedPaneIdsL() const;
       
   345 
       
   346         // Leaving helper method. Handler cleanupstack issues and calls ReadInterestListL().
       
   347         void ReadInterestL(RCriteriaArray& aInterest, TInt aInterestResourceId);
       
   348 
       
   349         // Detaches all items from given menu.        
       
   350         void DoDetachMenu(TInt aMenuResourceId);
       
   351 
       
   352         // Detaches only those items from a given menu, which match the given interest.
       
   353 
       
   354 
       
   355         void DoDetachMenu(TInt aMenuResourceId, RCriteriaArray& aInterest);
       
   356         
       
   357         // Removes unnecessary criteria items from Service Handler.
       
   358         void RemoveObsoleteCriteriaItems();
       
   359         
       
   360         // Removes unnecessary providers from Service Handler.
       
   361         void RemoveObsoleteProviders();
       
   362         
       
   363         /* Parses the metadata information stored in the opaque_data field
       
   364 		 * of service provider registration information \c REGISTRY_INFO.
       
   365 		 *
       
   366 		 * The metadata information is seprated from the service command definition 
       
   367 		 * in the opaque_data field using a separator "::".
       
   368 		 *
       
   369 		 * @param aOpaque	the opaque_data values specified in the registration information
       
   370 		 * @param aMetaData the parsed metadata entries will be stored in this variable
       
   371 		 * 
       
   372 		 */
       
   373 		void ParseMetaData(const TDesC8& aOpaque, TDes8& aMetaData);
       
   374 		
       
   375 		//To fetch the infoArray
       
   376         void QueryImplementationL(CLiwCriteriaItem* aItem, RImplInfoPtrArray& aInfoArray);
       
   377 
       
   378   		TCapability GetServiceCapability(const TDesC& aCapName);
       
   379 		
       
   380 		//To fetch the version range specified by the consumer while creating Criteria
       
   381 		TBool GetVersionRange(CLiwCriteriaItem* aItem,TReal& aMinVersion, TReal& aMaxVersion);
       
   382 		
       
   383 		//To fetch the version range specified by the consumer while creating Criteria
       
   384 		TBool GetVersion (CLiwCriteriaItem* aItem,TReal& aVersion);
       
   385 		
       
   386 		//To fetch the implementation version specified in provider metadata
       
   387 		void ComputeIntfVersion(CLiwServiceData* pProvMetaData,TReal& aIntfVersion);
       
   388 		
       
   389     private:
       
   390         // Pointer to the control environment.
       
   391         CCoeEnv* iCoeEnv;
       
   392         
       
   393         // Owns all the attached criteria items.
       
   394         RPointerArray<CLiwCriteriaItem> iInterestList;  
       
   395         
       
   396         // Criteria -> provider bindings for base service providers.
       
   397         RPointerArray<CLiwBinding>      iBaseBindings;  
       
   398         
       
   399         // Criteria -> provider bindings for menu service providers.
       
   400         RPointerArray<CLiwMenuBinding>  iMenuBindings;  
       
   401         
       
   402         // Contains the LIW menu panes.
       
   403         RPointerArray<CLiwMenuPane>     iMenuPanes;     
       
   404 
       
   405         // Input parameter list which can be given to the consumer application.
       
   406         CLiwGenericParamList* iInParams;
       
   407         
       
   408         // Output parameter list which can be given to the consumer application.
       
   409         CLiwGenericParamList* iOutParams; 
       
   410         
       
   411         // Resource offset for LiwServiceHandler.rsc.
       
   412         TInt iResourceOffset;
       
   413         
       
   414         // Owns all the providers currently in memory.
       
   415         RPointerArray<CLiwServiceIfBase> iProviders;  
       
   416           
       
   417         TInt                             iNextFreeSlot;
       
   418         RPointerArray<CLiwMenuPane>      iLastInitialized;
       
   419         CLiwMenuPane*                    iSubmenu;
       
   420         TInt                             iSubmenuCmd;
       
   421         CLiwEcomMonitor*                 iEcomMonitor;
       
   422         TBool                            iTlsDataOpened;
       
   423     };
       
   424 
       
   425 
       
   426 inline void CLiwServiceHandlerImpl::ClearMenuPaneArray()
       
   427     {
       
   428     iMenuPanes.ResetAndDestroy();
       
   429     }
       
   430 
       
   431 #endif // LIW_SERVICE_HANDLER_IMPL_H
       
   432 
       
   433 // END of File
       
   434 
       
   435