csxhelp/AiwHelpProvider/src/AiwHelpProvider.cpp
branchRCL_3
changeset 17 12f60d9a73b3
parent 16 0d1adf67ec1b
child 18 cbffe13eac63
equal deleted inserted replaced
16:0d1adf67ec1b 17:12f60d9a73b3
     1 /*
       
     2 * Copyright (c) 2002 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:  source file.
       
    15 *                Write all source code here, all the implementations
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <eikmenup.h>
       
    21 #include "AiwHelpProvider.h"
       
    22 #include <AiwMenu.h>
       
    23 #include <barsread.h>
       
    24 #include <eikenv.h>
       
    25 #include <AiwHelpProviderPlugin.rsg>
       
    26 #include <ImplementationProxy.h>
       
    27 #include "AiwHelpProvider.rh"
       
    28 #include <AiwServiceIfMenu.h>
       
    29 #include <AiwCommon.h>
       
    30 #include <hlplch.h>
       
    31 #include <coemain.h>
       
    32 #include <avkon.hrh>
       
    33 
       
    34 
       
    35 _LIT(KResFileName, "\\resource\\apps\\AiwHelpProviderPlugin.rsc");
       
    36 
       
    37 #define KImplementationId 0x10207465
       
    38 
       
    39 
       
    40 
       
    41 /******************************************************************
       
    42 ===================================================================
       
    43 						NewL of the Provider
       
    44 ===================================================================
       
    45 *******************************************************************/						
       
    46 CAiwHelpProvider* CAiwHelpProvider::NewL()
       
    47     {
       
    48     return new (ELeave) CAiwHelpProvider();
       
    49     }
       
    50 
       
    51 
       
    52     
       
    53 /******************************************************************
       
    54 ===================================================================
       
    55 						Constructor of the Provider
       
    56 ===================================================================
       
    57 *******************************************************************/
       
    58 CAiwHelpProvider::CAiwHelpProvider()
       
    59     {
       
    60     }
       
    61 
       
    62 
       
    63 
       
    64 /******************************************************************
       
    65 ===================================================================
       
    66 					Destructor of the Provider
       
    67 ===================================================================
       
    68 *******************************************************************/
       
    69 CAiwHelpProvider::~CAiwHelpProvider()
       
    70     {
       
    71     }
       
    72     
       
    73     
       
    74     
       
    75 /**
       
    76         * Called by the Handler framework to initialise provider with
       
    77         * necessary information from Handler.
       
    78         * @param aFrameworkCallback Framework provided callback for
       
    79         *        provider to send events to framework
       
    80         * @param aInterest List of criteria items which invoked the provider.
       
    81         * @exception Symbian OS error code
       
    82         */
       
    83 void CAiwHelpProvider::InitialiseL(MAiwNotifyCallback& /*aFrameworkCallback*/,
       
    84     const RCriteriaArray& /*aInterest*/)
       
    85     {
       
    86     
       
    87     }
       
    88 
       
    89 
       
    90 /**
       
    91         * Executes generic service commands included in criteria.
       
    92         * @param aCmdId Command to be executed
       
    93         * @param aInParamList Input parameters, can be an empty list
       
    94         * @param aOutParamList Output parameters, can be an empty list
       
    95         * @param aCmdOptions Options for the command, see KAiwOpt* constants in AiwCommon.hrh.
       
    96         * @param aCallback callback for asynchronous command handling, parameter checking, etc.
       
    97         * @see enum TAiwServiceCmdOptions in AiwCommon.hrh
       
    98         * @exception KErrArgument if callback is missing when required.
       
    99         * @exception KErrNotSupported if no provider support service
       
   100         */
       
   101 void CAiwHelpProvider::HandleServiceCmdL(const TInt& /*aCmdId*/,
       
   102     const CAiwGenericParamList& /*aInParamList*/,
       
   103     CAiwGenericParamList& /*aOutParamList*/,
       
   104     TUint aCmdOptions,
       
   105     const MAiwNotifyCallback* /*aCallback*/)
       
   106     {
       
   107  	// Cancel bit must always be checked. 
       
   108     if(aCmdOptions & KAiwOptCancel)
       
   109         {
       
   110         return;
       
   111         }
       
   112     }
       
   113 /**
       
   114         * Initialises menu pane by adding provider specific menu items.
       
   115         * The AIW Framework gives the parameters to be used in addition.
       
   116         * @param aMenuPane Menu pane handle
       
   117         * @param aIndex position of item where to add menu items.
       
   118         * @param aCascadeId ID of cascade menu item.
       
   119         * @param aInParamList input parameter list for provider's parameters checking
       
   120         */
       
   121         
       
   122 void CAiwHelpProvider::InitializeMenuPaneL(CAiwMenuPane& aMenuPane,
       
   123     TInt aIndex,
       
   124     TInt /*aCascadeId*/,
       
   125     const CAiwGenericParamList& /*aInParamList*/)
       
   126     {
       
   127     TFileName resFile(KResFileName);
       
   128     TFileName dllName;
       
   129     Dll::FileName(dllName);
       
   130     TBuf<2> drive = dllName.Left(2);
       
   131     resFile.Insert(0, drive);
       
   132     aMenuPane.AddMenuItemsL(resFile, R_AIWHELPPROVIDER_MENU, KAiwCmdHelp, aIndex);
       
   133     }
       
   134 
       
   135 /**
       
   136         * Handle a menu command invoked by the Handler.
       
   137         * @param aMenuCmdId Command ID for the menu command,
       
   138         *        defined by the provider when adding the menu commands.
       
   139         * @param aInParamList Input parameters, could be empty list
       
   140         * @param aOutParamList Output parameters, could be empty list
       
   141         * @param aCmdOptions Options for the command, see KAiwCmdOpt* constants.
       
   142         * @param aCallback callback if asynchronous command handling is wanted by consumer.
       
   143         *    The provider may or may not support this, leaves with KErrNotSupported, it not.
       
   144         */
       
   145 void CAiwHelpProvider::HandleMenuCmdL(TInt aMenuCmdId,
       
   146     const CAiwGenericParamList& aInParamList,
       
   147     CAiwGenericParamList& /*aOutParamList*/,
       
   148     TUint aCmdOptions,
       
   149     const MAiwNotifyCallback* /*aCallback*/)
       
   150     {
       
   151     // Cancel bit must always be checked.
       
   152     if(aCmdOptions & KAiwOptCancel)
       
   153         {
       
   154         return;
       
   155         }
       
   156            
       
   157     switch (aMenuCmdId)
       
   158 	    {
       
   159 	    case EAiwShowHelpCmd:
       
   160 	    case EAknCmdHelp:
       
   161 		    {
       
   162 		    TCoeHelpContext helpContext;
       
   163 		    TInt index;
       
   164 		        
       
   165 		    // Get the UID of the Help context i.e. the UID of the CS Help file containing 
       
   166 		    // the topic information.
       
   167 
       
   168 		    index = 0;
       
   169 		    const TAiwGenericParam* uidParam = aInParamList.FindFirst(index, EGenericParamHelpItem, 
       
   170 		        EVariantTypeTUid);
       
   171 
       
   172 		    if(index >= 0)
       
   173 		        {
       
   174 		        // Get the data.
       
   175 		        const TAiwVariant& val = uidParam->Value();
       
   176 		        helpContext.iMajor = val.AsTUid();
       
   177 		        }
       
   178 		    else
       
   179 		        {
       
   180 		        // UID param not found. Error handling could be added here.
       
   181 		        }            
       
   182 		        
       
   183 		    // Get the context of Help i.e. the name of the help context. This is the literal 
       
   184 		    // descriptor generated from a context string by the CSHelp compiler.          
       
   185 
       
   186 		    index = 0;
       
   187 		    const TAiwGenericParam* contextParam = aInParamList.FindFirst(index, EGenericParamHelpItem, 
       
   188 		        EVariantTypeDesC);
       
   189 
       
   190 		    if(index >= 0)
       
   191 		        {
       
   192 		        // Get the data.
       
   193 		        const TAiwVariant& val = contextParam->Value();
       
   194 		        helpContext.iContext = val.AsDes();
       
   195 		        }
       
   196 		    else
       
   197 		        {
       
   198 		        // Context param not found. Error handling could be added here.
       
   199 		        }             
       
   200 		                            
       
   201 		    CArrayFix<TCoeHelpContext>* contextList = new (ELeave) CArrayFixFlat<TCoeHelpContext>(1);
       
   202 		    contextList->AppendL(helpContext);
       
   203 		    
       
   204 		    //Get the Window server session
       
   205 		    RWsSession wsSession;
       
   206 		    User::LeaveIfError(wsSession.Connect());
       
   207 		    CleanupClosePushL(wsSession);
       
   208 		    HlpLauncher::LaunchHelpApplicationL(wsSession,contextList);
       
   209 		    CleanupStack::PopAndDestroy();
       
   210 		    break;
       
   211 		    }
       
   212         default:
       
   213             break;
       
   214         }
       
   215     }
       
   216 
       
   217 //
       
   218 // Rest of the file is for ECom initialization. 
       
   219 //
       
   220 
       
   221 // Map the interface UIDs to implementation factory functions
       
   222 const TImplementationProxy ImplementationTable[] =
       
   223     {
       
   224         IMPLEMENTATION_PROXY_ENTRY(KImplementationId, CAiwHelpProvider::NewL)
       
   225     };
       
   226 
       
   227 // ---------------------------------------------------------
       
   228 // Exported proxy for instantiation method resolution
       
   229 // ---------------------------------------------------------
       
   230 //
       
   231 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   232     {
       
   233     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   234     return ImplementationTable;
       
   235     }
       
   236