multimediacommsengine/mmcesrv/mmceserver/inc/mcesipevent.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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 "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 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef CMCESIPEVENT_H
       
    22 #define CMCESIPEVENT_H
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 #include "mcesrv.h"
       
    27 #include "mcecssubsession.h"
       
    28 #include "mcesipmanager.h"
       
    29 #include "mceevents.h"
       
    30 #include "mcerefer.h"
       
    31 #include "mceevent.h"
       
    32 
       
    33 //  FORWARD DECLARATION
       
    34 class CMceSipStateMachine;
       
    35 class CMceComSession;
       
    36 class CMceState;
       
    37 class TMceActionSet;
       
    38 class CMceComEvent;
       
    39 class CIdle;
       
    40 class CMceMsgSIPEvent;
       
    41 class CMceMsgSIPData;
       
    42 class CSIPProfile;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 enum TEventStateType 
       
    47     {
       
    48 	EMoSubscribe=1,  
       
    49 	EMtSubscribe,
       
    50 	EMoRefer,
       
    51 	EMtRefer,  
       
    52 	};    
       
    53 	
       
    54 
       
    55 const TUint KMceDefaultSubscrExpire = 3600;
       
    56 
       
    57 _LIT8(KStateActive, "active");
       
    58 _LIT8(KStateTerminated, "terminated");
       
    59 
       
    60 	
       
    61 /**
       
    62 *  MCE SIP session.
       
    63 *
       
    64 *  @lib 
       
    65 *  @since
       
    66 */
       
    67 class CMceSipEvent : public CMceCsSubSession
       
    68     {
       
    69 	
       
    70 public: // Constructors and destructor
       
    71 
       
    72 	/**
       
    73 	* Two-phased constructor.
       
    74 	* @param aClientSession, reference to client session.
       
    75 	* @param aSIPConnection, reference to sip connection 
       
    76 	*/
       
    77 	static CMceSipEvent* NewL (CMceCsSession& aClientSession, 
       
    78 							   CMceSipConnection& aSIPConnection,
       
    79 							   CSIPProfile& aProfile);
       
    80 
       
    81 	/**
       
    82 	* Two-phased constructor.
       
    83 	* @param aClientSession, reference to session.
       
    84 	* @param aSIPConnection, reference to sip connection 
       
    85 	*/
       
    86 	static CMceSipEvent* NewLC (CMceCsSession& aClientSession, 
       
    87 							   CMceSipConnection& aSIPConnection,
       
    88 							   CSIPProfile& aProfile);
       
    89 	
       
    90 	/**
       
    91 	* Destructor.
       
    92 	*/
       
    93 	~CMceSipEvent();
       
    94     
       
    95 public: // New Functions
       
    96 
       
    97     /**
       
    98 	* Handles the incoming SUBSCRIBE or REFER request that caused this
       
    99 	* event to be created.
       
   100 	* @param aTransaction The received server transaction
       
   101 	*/
       
   102 	void EventRequestedL( CSIPServerTransaction* aTransaction );
       
   103 	
       
   104 public: // from CMceCsSubSession
       
   105 
       
   106     /**
       
   107     * Creates new incoming dialog
       
   108     * @param aInitialRequest request causing creation
       
   109     * @return created dialog
       
   110     */
       
   111     CSIPDialogAssocBase* CreateIncomingDialogL( CSIPServerTransaction& aInitialRequest );
       
   112 
       
   113     /**
       
   114     * Creates outgoing dialog from existing dialog
       
   115     * @param aDialogType type of new dialog
       
   116     * @param aParams parameters
       
   117     * @param aExistingDialog existing dialog
       
   118     * @return created dialog
       
   119     */
       
   120     CSIPDialogAssocBase* CreateOutgoingDialogL( TMceDialogType aDialogType, 
       
   121                                                 CDesC8Array& aParams,
       
   122                                                 CSIPDialog& aExistingDialog );
       
   123 
       
   124     /**
       
   125     * Creates outgoing dialog based on given parameters 
       
   126     * @param aDialogType type of new dialog
       
   127     * @param aParams parameters
       
   128     * @return created dialog
       
   129     */
       
   130     CSIPDialogAssocBase* CreateOutgoingDialogL( TMceDialogType aDialogType,
       
   131                                                         CDesC8Array& aParams );
       
   132 
       
   133     /**
       
   134 	* Provides services of MCE server subsession
       
   135 	* @param aIds, ids from the client.
       
   136 	* @param aFunction, function from the client.
       
   137 	* @return aReturnMessage, return message for client
       
   138 	*/
       
   139     HBufC8* DoServiceL( TMceIds& aIds, 
       
   140                         TMceItcFunctions aFunction );
       
   141 
       
   142 	/**
       
   143 	* Provides services of MCE server subsession
       
   144 	* @param aIds, ids from the client.
       
   145 	* @param aFunction, function from the client.
       
   146 	* @param aMessage, encoded message from the client.
       
   147 	*/
       
   148     void DoServiceL( TMceIds& aIds, 
       
   149                    TMceItcFunctions aFunction, 
       
   150      	           const TDesC8& aMessage );
       
   151 
       
   152 
       
   153 	/**
       
   154 	* Provides services of MCE server subsession
       
   155 	* @param aIds, ids from the client.
       
   156 	* @param aFunction, function from the client.
       
   157 	* @param aMessage, message from the client.
       
   158 	*/
       
   159     void DoServiceL( TMceIds& aIds, 
       
   160                    TMceItcFunctions aFunction, 
       
   161      	           CMceMsgBase& aMessage );
       
   162 	
       
   163 	
       
   164 	/**
       
   165 	* Returns ETrue, if session can be deleted
       
   166 	* @return ETrue, if session can be deleted
       
   167 	*/
       
   168     TBool CanDispose();
       
   169 
       
   170     /**
       
   171     * Called when session is forced to terminate
       
   172     * @return ETrue, if can be disposed
       
   173     */
       
   174     TBool Terminate();
       
   175 
       
   176 	/**
       
   177 	* Initializes incoming dialog
       
   178 	* @param aTransaction, server transaction containing the request
       
   179 	*/
       
   180     void DoInitializeIncomingDialogL( CSIPServerTransaction& aTransaction );
       
   181 			 
       
   182     /**
       
   183     * Called when error has been occured within dialog
       
   184     * @param aError error code
       
   185     */
       
   186     void ErrorOccured( TInt aError );
       
   187     
       
   188    /**
       
   189     * Called when error has been occured 
       
   190     * @param aError error code
       
   191     * @param aTransaction the transaction
       
   192     */
       
   193     void DoErrorOccured( TInt aError, CSIPTransactionBase& aTransaction );
       
   194      
       
   195     
       
   196     /**
       
   197     * Called when connection state has been changed
       
   198     * @param aIsActive ETrue, if connection is active
       
   199     */
       
   200     void DoConnectionStateChanged( TBool aIsActive );
       
   201 
       
   202     /**
       
   203     * Called when dialog has been cancelled
       
   204     */
       
   205     void Canceled();
       
   206     
       
   207     TEventStateType EventStateType() const;
       
   208     
       
   209     void IncomingSubscribeL(
       
   210 					CDesC8Array* aHeaders,
       
   211                     HBufC8* aContentType,
       
   212 					HBufC8* aBody);
       
   213 									
       
   214     void IncomingReferL(
       
   215 					HBufC8* aReferTo,
       
   216 					CDesC8Array* aHeaders,
       
   217                     HBufC8* aContentType,
       
   218 					HBufC8* aBody);
       
   219 	
       
   220 	void ClientStateChangedL( CMceRefer::TState aState, TBool aIsResponse );
       
   221 	
       
   222 	void ClientStateChangedL( CMceEvent::TState aState, TBool aIsResponse );
       
   223 		
       
   224 	void NotifyReceivedL(			CDesC8Array* aHeaders,
       
   225                     				HBufC8* aContentType,
       
   226 									HBufC8* aBody) ;
       
   227     
       
   228     void SuppressedReferTerminated();
       
   229 
       
   230 protected: //CMceCsSubSession
       
   231 
       
   232 
       
   233 	/**
       
   234 	* Returns ETrue, if session accepts transaction
       
   235 	* @param aTransaction the pending transaction
       
   236 	* @return ETrue, if session will accepts the transaction
       
   237 	*/
       
   238     TBool AcceptDialogTransaction( CSIPServerTransaction& aTransaction );
       
   239 
       
   240 	/**
       
   241 	* Returns ETrue, if session accepts transaction
       
   242 	* @param aTransaction the pending transaction
       
   243 	* @return ETrue, if session will accepts the transaction
       
   244 	*/
       
   245     TBool AcceptDialogTransactionL( CSIPServerTransaction& aTransaction );
       
   246     
       
   247     /**
       
   248     * Checks if session accepts method containing in incoming request
       
   249     * @param aMethod the method
       
   250     * @return ETrue, if accepted
       
   251     */
       
   252     TBool AcceptMethod( RStringF aMethod );
       
   253 
       
   254     /**
       
   255     * Called when request has been received. 
       
   256     * Request can be obtained by calling Request() method
       
   257     * @param aInsideDialog tells whether request was received inside dialog
       
   258     * @param aDialog Dialog for which request is received
       
   259     */
       
   260     void RequestReceived( TBool aInsideDialog, CSIPDialog& aDialog);
       
   261     
       
   262     /**
       
   263     * Called when response (2XX) has been received to pending transaction.
       
   264     * Response can be obtained by calling Response() method
       
   265     */
       
   266     void ResponseReceived();
       
   267     
       
   268     /**
       
   269     * Called when response (1XX) has been received to pending transaction.
       
   270     * Response can be obtained by calling Response() method
       
   271     */
       
   272     void ProvisionalResponseReceived();
       
   273     
       
   274     /**
       
   275     * Called when response (3XX) has been received to pending transaction.
       
   276     * Response can be obtained by calling Response() method
       
   277     */
       
   278     void RedirectionResponseReceived();
       
   279      
       
   280     /**
       
   281     * Called when error response (4XX-7XX) has been received to pending transaction.
       
   282     * Response can be obtained by calling Response() method
       
   283     */
       
   284     void ErrorResponseReceived();
       
   285     
       
   286     /**
       
   287     * Called when stand-alone request has been received.
       
   288     * method must return ETrue, if session consumes the request 
       
   289     * Request can be obtained by calling Request() method
       
   290     *@return TConsumeStatus
       
   291     */
       
   292     void StandAloneRequestReceived();
       
   293     
       
   294     /**
       
   295     * Called when stand-alone response (any) has been received to pending transaction.
       
   296     * Response can be obtained by calling Response() method
       
   297     * @param aResponseType response type
       
   298     */
       
   299     void StandAloneResponseReceived( TMceSipResponseType aResponseType );
       
   300     
       
   301     
       
   302 private:
       
   303 
       
   304 	CMceSipEvent ( CMceCsSession& aClientSession, 
       
   305 				   CMceSipConnection& aSIPConnection,
       
   306 				   CSIPProfile& aProfile);
       
   307 
       
   308 	void ConstructL ( CMceCsSession& aClientSession );
       
   309 	
       
   310     void HandleSIPEvent( TMceSipEventCode aEventCode );
       
   311     
       
   312     void SetEventStateType(const TEventStateType aEventStateType );
       
   313    
       
   314     void DoClientStateChangedL( TUint32 aState, TBool aIsResponse );
       
   315     
       
   316     void ClearDataL();
       
   317     
       
   318     void UpdateDataL( TMceItcFunctions aFunction, 
       
   319                       CMceMsgSIPData& aMessage );
       
   320     
       
   321     void DoInitializeL( TMceItcFunctions aFunction, CMceMsgSIPEvent& aMessage );
       
   322     
       
   323     void LocalDoServiceL( TMceIds& aIds, 
       
   324                      TMceItcFunctions aFunction );
       
   325     
       
   326     void LocalDoServiceL( TMceIds& aIds, 
       
   327                      TMceItcFunctions aFunction,
       
   328                      CMceMsgSIPData& aMessage );
       
   329     
       
   330     static TInt Idle( TAny* aObject );
       
   331 
       
   332     CDesC8Array* CopyArrayLC( const CDesC8Array* aArray );
       
   333     
       
   334     HBufC8* CopyBufferLC( const HBufC8* aBuffer );
       
   335 
       
   336 private: // Own Data
       
   337 
       
   338     CMceComEvent* iEvent;
       
   339 	TEventStateType iStateType;
       
   340 	CIdle* iIdle;
       
   341     friend class TMceActionSet;
       
   342     
       
   343 	// Definitions for unit testing
       
   344 	MCESRV_UT_DEFINITIONS    
       
   345 	};
       
   346 
       
   347 #endif
       
   348 
       
   349 // End of File