phoneapp/phonemediatorcenter/inc/cphonemediatorsender.h
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     1 /*
       
     2 * Copyright (c) 2008 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: 
       
    15 *     Sends Events and Commands via Mediator component.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CPHONEMEDIATORSENDER_H
       
    21 #define CPHONEMEDIATORSENDER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <coemain.h>
       
    26 #include <MediatorEventProvider.h>
       
    27 #include <MediatorCommandInitiator.h>
       
    28 #include <mediatoreventsfromtelephonyapi.h>
       
    29 #include "phoneviewcommanddefinitions.h"
       
    30 #include "tphonecommandparam.h"
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class CMediatorEventProvider;
       
    34 class MPhoneEngineMessageSender;
       
    35 class MPhoneShutdownCommand;
       
    36 
       
    37 using namespace TelephonyMediator;
       
    38 
       
    39 /**
       
    40 * Struct for buffering mediator command.
       
    41 * In a case when several commands are sent to Mediator
       
    42 * we resend the last used command after receiving a
       
    43 * Mediator response.
       
    44 */
       
    45 struct TPhoneCommandBuffer
       
    46     {
       
    47     TInt iCommandId;
       
    48     TUid iDomainUid;
       
    49     TUid iCategoryUid;
       
    50     TVersion iVersion;        
       
    51     };
       
    52 
       
    53 // CLASS DECLARATION
       
    54 
       
    55 class CPhoneMediatorSender : public CCoeStatic, private MMediatorCommandResponseObserver
       
    56     {
       
    57     public:  
       
    58 
       
    59         /**
       
    60         * First call initializes the singleton object. Subsequent calls return
       
    61         * instance.
       
    62         * @param None.
       
    63         * @return Pointer to the one and only instance of Phone Mediator 
       
    64         *         Sender -object.
       
    65         */
       
    66         IMPORT_C static CPhoneMediatorSender* Instance();
       
    67 
       
    68         /**
       
    69          * Destructor.
       
    70          */
       
    71         virtual ~CPhoneMediatorSender();
       
    72                         
       
    73         /**
       
    74          * Sends event to the Mediator.
       
    75          * @param aCommandId - command to be sent as an event
       
    76          */
       
    77         IMPORT_C void SendEvent( const TPhoneViewCommandId aCommandId ) const;
       
    78         
       
    79         /**
       
    80          * Sends event to the Mediator.
       
    81          * @param aCommandId - command to be sent as an event
       
    82          * @param aCallId - command's call id
       
    83          */
       
    84         IMPORT_C void SendEvent( const TPhoneViewCommandId aCommandId, const TInt aCallId ) const;
       
    85         
       
    86         /**
       
    87          * Sends event to the Mediator.
       
    88          * @param aCommandId - command to be sent as an event
       
    89          * @param aCommandParam - Reference to command parameter
       
    90          */
       
    91         IMPORT_C void SendEvent( const TPhoneViewCommandId aCommandId, 
       
    92             TPhoneCommandParam& aCommandParam );
       
    93 
       
    94         /**
       
    95          * Sends event to the Mediator.
       
    96          * @param aCommandId - command to be sent as an event
       
    97          * @param aCallId - command's call id
       
    98          * @param aCommandParam - Reference to command parameter
       
    99          */
       
   100         IMPORT_C void SendEvent( const TPhoneViewCommandId aCommandId, 
       
   101             const TInt aCallId, 
       
   102             TPhoneCommandParam& aCommandParam ) const;
       
   103 
       
   104         /**
       
   105          * Sends event to the Mediator.
       
   106          * @param aCommandId - command to be sent as an event
       
   107          * @param aCallId - command's call id
       
   108          * @param aCommandParam - Pointer to TDesC16
       
   109          */
       
   110         IMPORT_C void SendEvent( const TPhoneViewCommandId aCommandId, 
       
   111             const TInt aCallId, 
       
   112             const TDesC* aMessage ) const;
       
   113 
       
   114         /**
       
   115         * Issue a Mediator Service command.
       
   116         * 
       
   117         * @param aDomain    The identifier of the domain     
       
   118         * @param aCategory  The identifier of the category.
       
   119         * @param aCommandId The identifier of the command.
       
   120         * @param aVersion   The version information for the command.
       
   121         * @param aData      The parameters of the command.
       
   122         * @return TInt      an error code
       
   123         */
       
   124         IMPORT_C TInt IssueCommand( const TUid aDomain, 
       
   125                                     const TUid aCategory, 
       
   126                                     const TInt aCommandId,
       
   127                                     const TVersion aVersion, 
       
   128                                     const TDesC8& aData,
       
   129                                     MPhoneShutdownCommand* aShutdownCommand = NULL );
       
   130 
       
   131         /**
       
   132         * A response to a Mediator Service command.
       
   133         *
       
   134         * @param aDomain    The identifier of the domain          
       
   135         * @param aCategory  The identifier of the category.
       
   136         * @param aCommandId The identifier of the command.
       
   137         * @param aStatus    Standard Symbian error code indicating the
       
   138         *                   success of the command.
       
   139         * @param aData      The parameters of the response.
       
   140         */
       
   141         void CommandResponseL( TUid aDomain,
       
   142                                TUid aCategory, 
       
   143                                TInt aCommandId,
       
   144                                TInt aStatus, 
       
   145                                const TDesC8& aData );     
       
   146 
       
   147     private:
       
   148 
       
   149         /**
       
   150         * Instantiates this class and returns a pointer to us
       
   151         */
       
   152         static CPhoneMediatorSender* NewL();
       
   153 
       
   154         /**    
       
   155          * Protected constructor because of Singleton Pattern
       
   156          */    
       
   157         CPhoneMediatorSender();  
       
   158         
       
   159         /**
       
   160          * By default EPOC constructor is private.
       
   161          */
       
   162         void ConstructL();
       
   163                
       
   164         /**
       
   165         * Registers generic Mediator Events sent via this interface.
       
   166         */
       
   167         void RegisterGenericEvents();
       
   168         
       
   169         /**
       
   170         * Reacts to Video Telephony specific Mediator Command reponse.
       
   171         * @param aCommandId - Command to react for.
       
   172         */
       
   173         void VideoTelephonyCommandResponse( TInt aCommandId );
       
   174         
       
   175         /**
       
   176         * Maps Phone Engine call state to the ones defined in our Mediator API.
       
   177         * @param aCallState - Phone Engine's call state which to map
       
   178         * @return TCallState
       
   179         */
       
   180         TCallState MapCallState( const TInt aCallState ) const;
       
   181 
       
   182         /**
       
   183         * Maps Phone Engine call type to the ones defined in our Mediator API.
       
   184         * @param aCallTypr - Phone Engine's call type which to map
       
   185         * @return TCallType
       
   186         */
       
   187         TCallType MapCallType( const TInt aCallType ) const;
       
   188         
       
   189         /**
       
   190         * Resets the values of used TPhoneCommandBuffer.
       
   191         */
       
   192         void ResetCommandBuffer();
       
   193                 
       
   194         
       
   195     private:
       
   196         
       
   197         /**
       
   198          * Interface for sending events to Mediator
       
   199          */
       
   200         CMediatorEventProvider* iEventSender;
       
   201         
       
   202         /**
       
   203          * List of events - used for registering events we provide
       
   204          */
       
   205         MediatorService::REventList iEvents;
       
   206         
       
   207         /**
       
   208         * List of generic events - used for registering events we provide
       
   209         */
       
   210         MediatorService::REventList iGenericEvents;
       
   211 
       
   212         /**
       
   213         * Interface for sending commands to Mediator
       
   214         */        
       
   215         CMediatorCommandInitiator* iCommandInitiator;
       
   216     
       
   217         /**
       
   218         * Buffer for re-sending command after received Mediator response
       
   219         */
       
   220         TPhoneCommandBuffer iCommandBuffer;
       
   221 
       
   222         /**
       
   223         * Pointer for executing command related to Video Telephony shutdown.
       
   224         */
       
   225         MPhoneShutdownCommand* iShutdownCommand;
       
   226     };
       
   227     
       
   228 #endif // CPHONEMEDIATORSENDER_H
       
   229 
       
   230 // End of File