vtengines/vtmediatorplugin/inc/cvtmediatorplugin.h
changeset 0 ed9695c8bcbe
child 3 b1602a5ab0a3
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     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:  Video Telephony mediator plugin header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_VTMEDIATORPLUGIN_H
       
    20 #define C_VTMEDIATORPLUGIN_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <mediatorpluginbase.h>
       
    24 #include <mediatornotifications.h>
       
    25 #include <mediatoreventconsumer.h>
       
    26 #include <mediatoreventprovider.h>
       
    27 #include <mediatorcommandresponder.h>
       
    28 #include <vtinternalmediatorapi.h>
       
    29 #include <mediatoreventsfromtelephonyapi.h>
       
    30 #include <mediatorcommandinitiator.h>
       
    31 #include <w32std.h>
       
    32 
       
    33 
       
    34 
       
    35 using namespace TelephonyMediator;
       
    36 using namespace MediatorService;
       
    37 
       
    38 class TelephonyMediator::TTelephonyCallDataParam;
       
    39 class CMediatorCommandInitiator;
       
    40 /**
       
    41 * Mediator plugin for CS video telephony. Fullfills responsibilities:
       
    42 *   - launches Video Telephone application
       
    43 *   - caches CLI and Dataport information for VT app for time between
       
    44 *     the data is broadcasted to time VT is ready to receive it.                                                                 
       
    45 * @since S60 5.0
       
    46 */
       
    47 
       
    48 class CVtMediatorPlugin : public CMediatorPluginBase, 
       
    49                             public MMediatorNotifications,
       
    50                             public MMediatorEventObserver,
       
    51                             public MMediatorCommandObserver,
       
    52                             public MMediatorCommandResponseObserver
       
    53 	{
       
    54 public:          
       
    55        
       
    56      static CMediatorPluginBase* NewL();
       
    57      
       
    58     /**
       
    59      * Destructor.
       
    60      */
       
    61     ~CVtMediatorPlugin();
       
    62     
       
    63 public: // From Base class
       
    64     
       
    65     virtual void StartL();
       
    66     
       
    67 public: // From MMediatorNotifications
       
    68 
       
    69     /**
       
    70     * Raises VT specific CLI/dataport event when event is registered by VT app,
       
    71     * or when the information is available
       
    72     *
       
    73     * @since Series 60 3.1
       
    74     * @param aDomain    The identifier of the domain.
       
    75     * @param aCategory  The identifier of the category.
       
    76     * @param aEvents    The list of events that have been registered.
       
    77     * @return None.
       
    78     */
       
    79     virtual void MediatorEventsAddedL( TUid aDomain, 
       
    80                                        TUid aCategory, 
       
    81                                        const REventList& aEvents );
       
    82 
       
    83     /**
       
    84     * New commands have been registered. The commands can now be subscribed.
       
    85     * The list can contain 1-n new commands into the category.
       
    86     *
       
    87     * @since Series 60 3.1
       
    88     * @param aDomain    The identifier of the domain.
       
    89     * @param aCategory  The identifier of the category.
       
    90     * @param aCommands  List of commands that have been registered.
       
    91     * @return None.
       
    92     */
       
    93     virtual void MediatorCommandsAddedL( TUid aDomain, 
       
    94                                          TUid aCategory,
       
    95                                          const RCommandList& aCommands );
       
    96      
       
    97     /**
       
    98     * A category has been removed. All subscriptions are cancelled.
       
    99     *
       
   100     * @since Series 60 3.1
       
   101     * @param aDomain    The identifier of the domain.
       
   102     * @param aCategory  The identifier of the category.        
       
   103     * @return None.
       
   104     */
       
   105     virtual void MediatorCategoryRemovedL( TUid aDomain, TUid aCategory );
       
   106 
       
   107     /**
       
   108     * List of events has been removed. All subscriptions are cancelled.
       
   109     * List can contain 1-n events from the specified category.
       
   110     *
       
   111     * @since Series 60 3.1
       
   112     * @param aDomain    The identifier of the domain.
       
   113     * @param aCategory  The identifier of the category.
       
   114     * @param aEvents    The list of events removed.
       
   115     * @return None.
       
   116     */
       
   117     virtual void MediatorEventsRemovedL( TUid aDomain, 
       
   118                                          TUid aCategory,
       
   119                                          const REventList& aEvents );
       
   120                                          
       
   121     /**
       
   122     * List of commands have been removed. All subscriptions are cancelled.
       
   123     * List can contain 1-n commands from the specified category.
       
   124     *
       
   125     * @since Series 60 3.1
       
   126     * @param aDomain    The identifier of the domain.
       
   127     * @param aCategory  The identifier of the category.
       
   128     * @param aCommands  The list of commands removed
       
   129     * @return None.
       
   130     */
       
   131     virtual void MediatorCommandsRemovedL( TUid aDomain, 
       
   132                                            TUid aCategory,
       
   133                                            const MediatorService::RCommandList& aCommands ); 
       
   134          
       
   135 public: // from MMediatorCommandObserver
       
   136     
       
   137     /**
       
   138     * @see MMediatorCommandObserver::MediatorCommandL       
       
   139     */
       
   140     virtual void MediatorCommandL( TUid aDomain,
       
   141                                  TUid aCategory, 
       
   142                                  TInt aCommandId,
       
   143                                  TVersion aVersion, 
       
   144                                  const TDesC8& aData );
       
   145     
       
   146     /**
       
   147     * @see MMediatorCommandObserver::CancelMediatorCommand       
       
   148     */
       
   149     virtual void CancelMediatorCommand( TUid aDomain,
       
   150                                       TUid aCategory, 
       
   151                                       TInt aCommandId );
       
   152     
       
   153 public:// from MMediatorCommandResponseObserver
       
   154     /**
       
   155     * @see MMediatorCommandResponseObserver::CommandResponseL
       
   156     */
       
   157      virtual void CommandResponseL( TUid aDomain,
       
   158                                    TUid aCategory, 
       
   159                                    TInt aCommandId,
       
   160                                    TInt aStatus, 
       
   161                                    const TDesC8& aData );  
       
   162                                                
       
   163 public: // from MMediatorEventObserver
       
   164                                                    
       
   165         /**
       
   166         * A Mediator Service event.
       
   167         *
       
   168         * @since Series 60 3.1        
       
   169         * @param aDomain    The identifier of the domain.
       
   170         * @param aCategory  The identifier of the category.
       
   171         * @param aEventId   The identifier of the event.
       
   172         * @param aData      The parameters of the event.
       
   173         * @return None.
       
   174         */
       
   175         virtual void MediatorEventL( TUid aDomain,
       
   176                                      TUid aCategory, 
       
   177                                      TInt aEventId, 
       
   178                                      const TDesC8& aData );                                               
       
   179 
       
   180 public: // new
       
   181     static TInt EventRaiserCallback( TAny* aAny );
       
   182     
       
   183 private: // constructors
       
   184     
       
   185     CVtMediatorPlugin();      void ConstructL();
       
   186 
       
   187     enum TInternalState {
       
   188         /** 
       
   189          * Waiting for video call state to reach value that is suitable
       
   190          * for launching Video Telephone application. In this state
       
   191          * video call is not ongoing.
       
   192          */
       
   193         EWaitingAppLaunch,
       
   194         
       
   195         /** 
       
   196          * Waiting for VT application's readiness to receive video call info
       
   197          * events. In this state video call is ongoing and VT application
       
   198          * is starting up.
       
   199          */
       
   200         EWaitingEventRegistration,
       
   201         
       
   202         /** 
       
   203          * VT application is ready to receive video call info events.
       
   204          */
       
   205         EReady
       
   206     };
       
   207     
       
   208 private: // new functions    
       
   209     void ChangeCallDataEventSubscriptionL(
       
   210         const REventList& aEvents,
       
   211         const TBool aEventRegistered );
       
   212     
       
   213     void HandleVtCommandUnregistrationL();
       
   214     
       
   215     void HandleVtCommandRegistrationL();
       
   216     
       
   217     void LaunchVtAppL();
       
   218     
       
   219     void SaveCallData( const TelephonyMediator::TTelephonyCallDataParam& aData, TVtVideoTelephonyCallInformation& iVtCallInfo);
       
   220                          
       
   221     void HandleDataportCommandL( const TDesC8& aData );
       
   222                              
       
   223     void ClearData(TVtVideoTelephonyCallInformation& aVtCallInfo, TCallState& aCallState);
       
   224     
       
   225     void RegisterVtInternalEventL();
       
   226     //test
       
   227     void RegisterVtInternalEvent_2L();
       
   228     
       
   229     void RegisterDataportCommandL();
       
   230     
       
   231     void RaiseVtEventL();    
       
   232                                     
       
   233     /**
       
   234      * Starts VT application if video call state transition is suitable.
       
   235      */                                    
       
   236     void HandleCallStateChangeL( const TelephonyMediator::TTelephonyCallDataParam& aData ); 
       
   237     
       
   238     TBool IsEnoughMemory();
       
   239     
       
   240     void FreeRam();
       
   241     
       
   242     void StopDeathActiveL();
       
   243     
       
   244 private: 
       
   245     // for detecting subscription to video call information from VT app.
       
   246     CMediatorNotifications* iMediatorNotifications;
       
   247 
       
   248     // for sending video call information events
       
   249     CMediatorEventProvider* iEventProvider;
       
   250                                                             
       
   251     // for receiving CLI from Telephony
       
   252     CMediatorEventConsumer* iEventConsumer;
       
   253 
       
   254     // for responding to dataport/releasedataport command from Telephony
       
   255     CMediatorCommandResponder* iCommandResponder;
       
   256     
       
   257     // for issue command to vt app
       
   258     CMediatorCommandInitiator* iCommandInitiator;
       
   259     
       
   260     // supported mediator commands
       
   261     MediatorService::RCommandList iCommandList;
       
   262     
       
   263     // plugin's internal state 
       
   264     TInternalState iState;
       
   265     
       
   266     // cached active video call state (from last call data event from Telephony)                    
       
   267     TCallState iActiveVideoCallState;
       
   268         
       
   269     TVtVideoTelephonyCallInformation iActiveVideoCallInfo;
       
   270     
       
   271     // cached waiting video call state (from last call data event from Telephony)                    
       
   272     TCallState iWaitingVideoCallState;
       
   273            
       
   274     TVtVideoTelephonyCallInformation iWaitingVideoCallInfo;
       
   275     
       
   276     // for raising event to VT asynchronously when it starts up
       
   277     CAsyncCallBack* iCallBack;
       
   278     
       
   279     class CAppDeathActive;
       
   280     // Owned application death waiter.
       
   281     CAppDeathActive* iAppDeathActive;
       
   282     
       
   283     // Owned application thread.
       
   284     RThread iAppThread;    
       
   285     
       
   286     // Application thread id.
       
   287     TThreadId iAppThreadId;
       
   288     
       
   289     // Owned window server session.
       
   290     RWsSession iWsSession;
       
   291     /**
       
   292         * Active object for waiting thread death.
       
   293         *
       
   294         * @since 2.6
       
   295         * @lib videotelcomms.lib
       
   296         */
       
   297     NONSHARABLE_CLASS( CAppDeathActive ) : public CActive
       
   298          {
       
   299          public: // Constructors
       
   300               
       
   301              /**
       
   302              * Constructor.
       
   303              */
       
   304              CAppDeathActive( CVtMediatorPlugin& aMediatorPlugin, 
       
   305                      RThread& aAppThread );
       
   306               
       
   307              /**
       
   308              * Destructor.
       
   309              */
       
   310              ~CAppDeathActive();
       
   311 
       
   312          public: // New functions
       
   313 
       
   314              /**
       
   315              * Starts active object.
       
   316              */
       
   317              void Start();
       
   318 
       
   319          public: // From base classes
       
   320 
       
   321              /**
       
   322              * @see CActive::RunL.
       
   323              */
       
   324              virtual void RunL();
       
   325                 
       
   326              /**
       
   327              * @see CActive::DoCancel.
       
   328              */
       
   329              virtual void DoCancel();
       
   330                 
       
   331              /**
       
   332              * @see CActive::RunError.
       
   333              */
       
   334              virtual TInt RunError( TInt aError );
       
   335 
       
   336          private:
       
   337 
       
   338              // Reference to starter.
       
   339              CVtMediatorPlugin& iMediatorPlugin;
       
   340 
       
   341              // Reference to thread.
       
   342              RThread& iAppThread;
       
   343 
       
   344          };
       
   345     
       
   346     };
       
   347 
       
   348 #endif // C_VTMEDIATORPLUGIN_H
       
   349