locationmapnavfw/aiwprovider/inc/mnaiwprovider.h
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2005-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:  Map and Navigation AIW Provider menu class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef MN_AIW_PROVIDER_H
       
    20 #define MN_AIW_PROVIDER_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <AiwServiceIfMenu.h>
       
    24 #include "mnaiwcommandhandlerbase.h"
       
    25 
       
    26 /**
       
    27  * CMnAiwProvider implements CAiwServiceIfMenu interface to
       
    28  * allow Map and Navigation functionality to be called via AIW.
       
    29  */
       
    30 class CMnAiwProvider : 
       
    31 	public CAiwServiceIfMenu, 
       
    32 	public MMnAsyncAiwCmdHandlerCallback,
       
    33 	public MMnProviderExitCallback
       
    34     {
       
    35     public:
       
    36         static CMnAiwProvider* NewL();
       
    37         ~CMnAiwProvider();
       
    38         
       
    39     protected:
       
    40         
       
    41         /** Retrieves command id from client's parameters list */
       
    42         TInt GetAiwServiceCommandIdL( const CAiwGenericParamList& aInParamList );
       
    43 
       
    44         /** Verifies if there is at least one provider application for
       
    45          *  requested command
       
    46          *  @param aAiwCommandId AIW service command ID
       
    47          *  @return ETrue if any provider is found for the command
       
    48          */
       
    49         TBool IsServiceAvailableL( TInt aAiwCommandId );
       
    50         
       
    51         /** Searches for already open handler for specified command, 
       
    52          *  provider and execution mode. This function returns
       
    53          *  pointer to command handler, which matches all given criteria.
       
    54          *  @param aAiwCommandId Command ID criterion.
       
    55          *  @param aProvider Provider criterion.
       
    56          *  @param aRunMode Execution mode criterion.
       
    57          */ 
       
    58         CMnAiwCommandHandlerBase* FindWorkingHandler( 
       
    59             TInt aAiwCommandId,
       
    60             const CMnProvider& aProvider, 
       
    61             CMnAiwCommandHandlerBase::TRunMode aRunMode );
       
    62         
       
    63         /** Deletes command handler from internal list 
       
    64          *  @param[in] aHandler The handler to remove */
       
    65         void CloseHandler( CMnAiwCommandHandlerBase* aHandler );
       
    66 
       
    67         /** Updates internal list of known provider applications */
       
    68         void UpdateProvidersListL();
       
    69 
       
    70 		/** Closes and removes all handlers working with 
       
    71 		 *  specified provider.
       
    72 		 *  @param aProvider Handlers using this provider will be closed. */
       
    73 		void CloseHandlers( const CMnProvider* aProvider );
       
    74 
       
    75 		/** Closes and removes all handlers. This method is used by destructor. */
       
    76 		void CloseAllHandlers();
       
    77 
       
    78         /** Find suitable providers for a given command */
       
    79         void GetSuitableProvidersL( 
       
    80             TInt aAiwCommandId, 
       
    81             RPointerArray<CMnProvider>& aProviders );
       
    82 
       
    83         /** Finds amount of providers available for given command */
       
    84         TInt NumSuitableProviders( TInt aAiwCommandId );
       
    85 
       
    86         /** Returns preferred provider application for a given command
       
    87          *  This may involve asking user via list query popup if several 
       
    88          *  suitable providers found.
       
    89          *  @leave KErrCancel if user cancels selection
       
    90          *  @leave KErrNotFound if no providers available
       
    91          */
       
    92         CMnProvider& SelectProviderL( 
       
    93             TInt aAiwCommandId,
       
    94             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams );
       
    95         
       
    96         /** Pops up list query dialog for user to select preferred Provider Application */
       
    97         void ExecuteSelectionDialogL( 
       
    98             TInt& aIndex, 
       
    99             RPointerArray<CMnProvider>& aProviders );
       
   100 
       
   101         /** Verifies result of a command. Checks whether command may be completed. 
       
   102          *  Pops up error note if error happened and restarts command if more than one
       
   103          *  provider is available for this command
       
   104          */
       
   105         void ProcessAiwCommandResultL( 
       
   106             TInt aAiwCommandId, 
       
   107             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams,
       
   108             TInt aResult, TBool& aStop );
       
   109         
       
   110         /** Executes synchronous command */
       
   111         void ProcessSyncAiwCommandL(
       
   112             TInt aCommandId, 
       
   113             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams );
       
   114             
       
   115         /** Attempts to start execution of asynchronous command until success
       
   116          *  or user refuses to continue
       
   117          */
       
   118         void StartAsyncAiwCommandL(
       
   119             TInt aCommandId,    
       
   120             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams );
       
   121 
       
   122         /** Starts execution of asynchronous command */
       
   123         CMnAiwCommandHandlerBase* DoStartAsyncAiwCommandL(
       
   124             TInt aCommandId,    
       
   125             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams,
       
   126             TBool& aProviderFound );
       
   127 
       
   128         /** Finds running handler, or creates new */
       
   129         CMnAiwCommandHandlerBase* HandlerL(
       
   130             TInt aCommandId,
       
   131             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams );
       
   132 
       
   133         /** Informs AIW observer about completion of async command */
       
   134         void NotifyAiwObserver( 
       
   135             TInt aCommandId,
       
   136             CMnAiwCommandHandlerBase::TAiwParameters& aAiwParams, 
       
   137             TInt aResult );
       
   138 
       
   139         /** Shows error note with text specified by parameter */            
       
   140         void ErrorNote( TInt aResourceId );
       
   141         void DoErrorNoteL( TInt aResourceId );
       
   142         
       
   143     private:
       
   144         /**
       
   145         * C++ default constructor.
       
   146         */
       
   147         CMnAiwProvider();
       
   148 
       
   149         /**
       
   150         * By default Symbian OS constructor is private.
       
   151         */
       
   152         void ConstructL();
       
   153         
       
   154     public: // from CAiwServiceIfBase
       
   155 
       
   156         void InitialiseL( 
       
   157             MAiwNotifyCallback& aFrameworkCallback, 
       
   158             const RCriteriaArray& aInterest );
       
   159 
       
   160         void HandleServiceCmdL(
       
   161             const TInt& aCmdId,
       
   162             const CAiwGenericParamList& aInParamList,
       
   163             CAiwGenericParamList& aOutParamList,
       
   164             TUint aCmdOptions = 0,
       
   165             const MAiwNotifyCallback* aCallback = NULL);
       
   166 
       
   167     public: // from CAiwServiceIfMenu
       
   168 
       
   169         void InitializeMenuPaneL(
       
   170             CAiwMenuPane& aMenuPane,
       
   171             TInt aIndex,
       
   172             TInt aCascadeId,
       
   173             const CAiwGenericParamList& aInParamList);
       
   174 
       
   175         void HandleMenuCmdL(
       
   176             TInt aMenuCmdId,
       
   177             const CAiwGenericParamList& aInParamList,
       
   178             CAiwGenericParamList& aOutParamList,
       
   179             TUint aCmdOptions = 0,
       
   180             const MAiwNotifyCallback* aCallback = NULL);
       
   181             
       
   182     public: // from MMnAsyncAiwCmdHandlerCallback
       
   183     
       
   184         void HandleAsyncAiwCmdCompletedL( CMnAiwCommandHandlerBase* aHandler, TInt aResult );
       
   185 
       
   186     public: // from MMnChainedAiwCmdHandlerCallback
       
   187     
       
   188         void HandleProviderExit( CMnAiwCommandHandlerBase* aHandler );
       
   189 
       
   190     private:
       
   191         RPointerArray<CMnAiwCommandHandlerBase> iHandlers;
       
   192         RPointerArray<CMnProvider>  			iMnProviders;
       
   193         
       
   194         CAiwGenericParamList*       			iEventList;
       
   195         
       
   196         // not-owned shortcut
       
   197         CEikonEnv*                  			iEikon;
       
   198         TInt                        			iResourceOffset;
       
   199         TFileName                   			iResourceFilename;
       
   200     };
       
   201     
       
   202 
       
   203 #endif  // MN_AIW_PROVIDER_H
       
   204