sipvoipprovider/inc/svpcontroller.h
branchRCL_3
changeset 22 d38647835c2e
parent 0 a4daefaec16c
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Handles all common logic for SVP and handles sessions.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef SVPCONTROLLER_H
       
    19 #define SVPCONTROLLER_H
       
    20 
       
    21 #include <mcemanager.h>
       
    22 #include <mcesessionobserver.h>
       
    23 #include <mcedtmfobserver.h>
       
    24 #include <mceinsessionobserver.h>
       
    25 #include <mceinreferobserver.h>
       
    26 #include <mceeventobserver.h>
       
    27 #include <mcestreamobserver.h>
       
    28 #include <mcereferobserver.h>
       
    29 #include <mcetransactiondatacontainer.h>
       
    30 
       
    31 #include <cconvergedcallprovider.h>
       
    32 #include <mccpobserver.h> 
       
    33 #include <mccpssobserver.h>
       
    34 #include <mccpdtmfprovider.h>
       
    35 
       
    36 #include <wlanmgmtclient.h>
       
    37 
       
    38 #include "svpsessionobserver.h"
       
    39 #include "svpemergencysession.h"
       
    40 #include "svpconsts.h"
       
    41 #include "svputdefs.h"
       
    42 
       
    43 #include "svpsupplementaryservices.h"
       
    44 #include "cipappphoneutils.h"               // KSVPMaxTerminalTypeLength
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 class CSVPRtpObserver;
       
    48 class CWlanMgmtClient;
       
    49 
       
    50 /**
       
    51  *  SVP controller
       
    52  *
       
    53  *  Handles all common logic for SVP and handles sessions.
       
    54  *
       
    55  *  @lib svp.dll
       
    56  *  @since S60 3.2 
       
    57  */
       
    58 class CSVPController : public CConvergedCallProvider,
       
    59                        public MSVPSessionObserver, 
       
    60                        public MMceSessionObserver,
       
    61                        public MMceEventObserver,
       
    62                        public MMceReferObserver,
       
    63                        public MMceInSessionObserver,
       
    64                        public MMceInReferObserver,
       
    65                        public MMceStreamObserver,
       
    66                        public MMceDtmfObserver,
       
    67                        public MCCPDTMFProvider, 
       
    68                        public MSIPObserver,
       
    69                        public MSIPProfileRegistryObserver
       
    70     {
       
    71 
       
    72 public: // new functions
       
    73 
       
    74     /**
       
    75     * Two-phased constructor.
       
    76     */
       
    77     static CSVPController* NewL();
       
    78   
       
    79     /**
       
    80     * Destructor.
       
    81     */
       
    82     virtual ~CSVPController();
       
    83    
       
    84 public: // functions from base classes
       
    85 
       
    86     /**
       
    87     * From SVPSessionObserver. Removes session from session array
       
    88     * @since S60 3.2
       
    89     * @param aSession Session to be removed from session array
       
    90     */
       
    91     void RemoveFromArray( CSVPSessionBase &aSession );
       
    92     
       
    93     /**
       
    94     * From SVPSessionObserver. Handles session cleanup
       
    95     * when Mt session creation fails in early stages
       
    96     * @since S60 3.2
       
    97     * @param aSession Session to be removed
       
    98     */
       
    99     void TerminateSession( CMceInSession &aSession );
       
   100 
       
   101     /**
       
   102     * From MMceSessionObserver. The state of the session has changed.
       
   103     * @since Series 60 3.2
       
   104     * @param aSession, the session that has changed.
       
   105     * @param aContainer, if present, holds details of
       
   106     *        transaction causing state change.
       
   107     */
       
   108     void SessionStateChanged(
       
   109     			CMceSession& aSession,
       
   110     			TMceTransactionDataContainer* aContainer );
       
   111 
       
   112     /**
       
   113     * From MMceSessionObserver.The state of the connection used by the session has changed.
       
   114     * @since Series 60 3.2
       
   115     * @param aSession, the session that has changed.
       
   116     * @param aActive, ETrue if connection active, EFalse if connection inactive.
       
   117     */
       
   118     void SessionConnectionStateChanged(
       
   119                 CMceSession& aSession,
       
   120                 TBool aActive );
       
   121     
       
   122     /**
       
   123     * From MMceSessionObserver.An error has occurred concerning a specific session.
       
   124     * Note, that each error causes the session state to be ETerminated.
       
   125     * @since Series 60 3.2
       
   126     * @param aSession, The session raising the error.
       
   127     * @param aError, Error code
       
   128     */
       
   129 	void Failed( CMceSession& aSession, TInt aError );
       
   130 
       
   131 	/**
       
   132     * From MMceSessionObserver.An session update has been failed concerning a specific session.
       
   133     * Note, that each error causes the session state to be ETerminated.
       
   134     * @since Series 60 3.2
       
   135     * @param aSession, The session raising the error.
       
   136     * @param aContainer, if present, holds details of
       
   137     *        transaction causing update.
       
   138     */
       
   139 	void UpdateFailed(
       
   140     			CMceSession& aSession,
       
   141     			TMceTransactionDataContainer* aContainer );
       
   142     			
       
   143      /**
       
   144     * From MMceEventObserver. The state of the event has changed.
       
   145     * @since Series 60 3.2
       
   146     * @param aEvent, the event that has changed.
       
   147     * @param aContainer, if present, holds details of
       
   148     *        transaction causing state change.
       
   149     */
       
   150     void EventStateChanged(
       
   151     			CMceEvent& aEvent,
       
   152 				TMceTransactionDataContainer* aContainer );
       
   153 
       
   154 	/**
       
   155 	* From MMceEventObserver. The state of the event has changed.
       
   156 	* @since Series 60 3.2
       
   157 	* @param aEvent, event received notification.
       
   158     * @param aContainer, if present, holds details of
       
   159     *        transaction causing state change.
       
   160 	*/
       
   161 	void NotifyReceived(
       
   162 				CMceEvent& aEvent,
       
   163 				TMceTransactionDataContainer* aContainer );
       
   164 				
       
   165 				
       
   166     /**
       
   167     * From MMceEventObserver. The state of the event used by the refer has changed.
       
   168     * @since Series 60 3.2
       
   169     * @param aEvent, the event that has changed.
       
   170     * @param aActive, ETrue if connection active, EFalse if connection inactive.
       
   171     */
       
   172     void EventConnectionStateChanged(
       
   173                 CMceEvent& aEvent,
       
   174                 TBool aActive );
       
   175     
       
   176 	/**
       
   177 	* From MMceEventObserver. An error has occurred concerning a specific SIP event.
       
   178 	* Note, that each error causes the event state to be ETerminated.
       
   179 	* @param aEvent, The event raising the error.
       
   180 	* @param aError, Error code
       
   181 	*/
       
   182     void Failed(CMceEvent& aEvent, TInt aError );
       
   183 	
       
   184 	/**
       
   185     * From MMceInSessionObserver. Incoming session invitation. 
       
   186     * The CMceInSession is given to the
       
   187 	* application as a callback.
       
   188     * @since Series 60 3.2
       
   189     * @param aSession, pointer to the incoming session. Ownership is
       
   190 	*	     transferred.
       
   191     * @param aContainer, if present, holds details of
       
   192     *        transaction causing state change.
       
   193     */
       
   194 	void IncomingSession(
       
   195                 CMceInSession* aSession,
       
   196 				TMceTransactionDataContainer* aContainer );
       
   197 				
       
   198 				
       
   199     /**
       
   200     * From MMceInSessionObserver.Incoming session update. 
       
   201     * The new updated CMceInSession is given to the
       
   202 	* application as a callback.
       
   203     * @since Series 60 3.2
       
   204     * @param aOrigSession, the original session to be updated. 
       
   205     *        This instance cannot be used anymore, 
       
   206     *        all actions done using aUpdatedSession instance.
       
   207     * @param aUpdatedSession, pointer to the new updated session. Ownership is
       
   208 	*	     transferred.
       
   209     * @param aContainer, if present, holds details of
       
   210     *        update transaction.
       
   211     */
       
   212 	void IncomingUpdate(
       
   213 				CMceSession& aOrigSession, 
       
   214 				CMceInSession* aUpdatedSession,
       
   215 				TMceTransactionDataContainer* aContainer );
       
   216 				
       
   217 	/**
       
   218     * From MMceInReferObserver. New incoming refer received.
       
   219 	* @since Series 60 3.2
       
   220 	* @param aRefer, the new inbound refer. Ownership is
       
   221 	*		 transferred.
       
   222     * @param aReferTo SIP specific Refer-to header 
       
   223     * @param aContainer, if present, holds details of
       
   224     *        transaction causing state change.
       
   225     */
       
   226     void IncomingRefer(
       
   227 				CMceInRefer* aRefer,
       
   228 				const TDesC8& aReferTo,
       
   229 				TMceTransactionDataContainer* aContainer );
       
   230 				
       
   231 	/**
       
   232     * From MMceStreamObserver. The state of the stream has changed.
       
   233     * @since Series 60 3.2
       
   234     * @param aStream, the stream that has changed.
       
   235     */
       
   236     void StreamStateChanged( 
       
   237                    CMceMediaStream& aStream);
       
   238 
       
   239     /**
       
   240     * From MMceStreamObserver. The state of the sink has changed.
       
   241     * @since Series 60 3.2
       
   242     * @param aStream, the stream that uses the sink.
       
   243     * @param aSink, the sink that has changed.
       
   244     */
       
   245     void StreamStateChanged(
       
   246                     CMceMediaStream& aStream,
       
   247                     CMceMediaSink& aSink );
       
   248 
       
   249     /**
       
   250     * From MMceStreamObserver. The state of the source has changed.
       
   251     * @since Series 60 3.2
       
   252     * @param aStream, the stream that uses the source.
       
   253     * @param aSource, the source that has changed.
       
   254     */
       
   255     void StreamStateChanged(
       
   256                     CMceMediaStream& aStream,
       
   257                     CMceMediaSource& aSource );
       
   258     
       
   259     
       
   260     /**
       
   261     * From MMceReferObserver. state of the refer has changed.
       
   262     * @param aRefer, the refer that has changed.
       
   263     * @param aContainer, if present, holds details of
       
   264     *        transaction causing state change.
       
   265     */
       
   266     void ReferStateChanged(
       
   267     			CMceRefer& aRefer,
       
   268 				TMceTransactionDataContainer* aContainer );
       
   269 		
       
   270     /**
       
   271     * From MMceReferObserver. The state of the connection used by the refer has changed.
       
   272     * @param aRefer, the refer that has changed.
       
   273     * @param aActive, ETrue if connection active, EFalse if connection inactive.
       
   274     */
       
   275     void ReferConnectionStateChanged(
       
   276                 CMceRefer& aRefer,
       
   277                 TBool aActive );
       
   278             
       
   279 	/**
       
   280 	* From MMceReferObserver. An error has occurred concerning a specific SIP refer.
       
   281 	* Note, that each error causes the event state to be ETerminated.
       
   282 	* @param aRefer, The refer raising the error.
       
   283 	* @param aError, Error code
       
   284 	*/
       
   285 	void Failed( CMceRefer& aRefer, TInt aError );
       
   286 
       
   287 
       
   288 // from MConvergedCallProvider 
       
   289 	/**
       
   290 	* Initializes plug-in. All required parameters must be passed
       
   291 	* with this function in order to use services.
       
   292 	* Simplifies pluging construct removing need to pass parameters to ECom interface
       
   293 	* @since Series60 3.2
       
   294 	* @param aMonitor CCP observer
       
   295 	* @param aSsObserver SS observer
       
   296 	*/
       
   297 	void InitializeL( const TUint32 aServiceId,
       
   298 					  const MCCPObserver& aObserver, 
       
   299 					  const MCCPSsObserver& aSsObserver );
       
   300     
       
   301    	/**
       
   302     * Initializes plug-in. All required parameters must be passed
       
   303     * with this function in order to use services.
       
   304     * Simplifies pluging construct removing need to pass parameters to ECom interface
       
   305     * @since Series60 3.2
       
   306     * @param aMonitor CCP observer
       
   307     * @param aSsObserver SS observer
       
   308     */
       
   309     void InitializeL( const MCCPObserver& aMonitor,
       
   310                       const MCCPSsObserver& aSsObserver );
       
   311 
       
   312     /**
       
   313     * Creates a new session and checks secure status from profile. Leaves with
       
   314     * ECCPErrorNetworkBusy if not enough WLAN bandwith.
       
   315     * @since Series60 3.2
       
   316     * @param aParameters Call parameters, SVP uses Service ID parameter
       
   317     * @param aRecipient Recipients address/number
       
   318     * @param aObserver Observer
       
   319     * @return MCCPCall
       
   320     */
       
   321     MCCPCall* NewCallL( const CCCPCallParameters& aParameters,
       
   322 					    const TDesC& aRecipient,
       
   323 					    const MCCPCallObserver& aObserver );
       
   324                                 
       
   325     /**
       
   326     * Returns Uid of plug-in which is on use.
       
   327     * @since Series60 3.2
       
   328     * @return Uid of plug-in
       
   329     */                        
       
   330     const TUid& Uid() const;
       
   331                            
       
   332     /**
       
   333     * Creates a new Emergency call and add user-agent header.
       
   334     * @since Series60 3.2
       
   335     * @param aServiceId Service ID, obsolete!
       
   336     * @param aAddress Emergency number
       
   337     * @param aObserver Observer
       
   338     * @return MCCPEmergencyCall
       
   339     */
       
   340     MCCPEmergencyCall* NewEmergencyCallL( const TUint32 aServiceId,
       
   341                                           const TDesC&  aAddress,
       
   342                                           const MCCPCallObserver& aObserver );
       
   343                                           
       
   344     /**
       
   345     * Creates a new conference session.
       
   346     * @since Series60 3.2
       
   347     * @param aObserver Observer
       
   348     * @return MCCPConferenceCall
       
   349     */
       
   350     MCCPConferenceCall* NewConferenceL( const TUint32 aServiceId,
       
   351                               const MCCPConferenceCallObserver& aObserver );
       
   352                              
       
   353     /**
       
   354     * Releases call
       
   355     * @since Series60 3.2
       
   356     * @param aCall Call to be removed
       
   357     * @return Symbian error code
       
   358     */
       
   359     TInt ReleaseCall( MCCPCall& aCall );
       
   360 
       
   361     /**
       
   362     * Releases emergency call
       
   363     * @since Series60 3.2
       
   364     * @param aCall Call to be removed
       
   365     * @return Symbian error code
       
   366     */
       
   367     TInt ReleaseEmergencyCall( MCCPEmergencyCall& aCall );
       
   368 
       
   369     /**
       
   370     * Releases conference call
       
   371     * @since Series60 3.2
       
   372     * @param aCall Call to be removed
       
   373     * @return Symbian error code
       
   374     */
       
   375     TInt ReleaseConferenceCall( MCCPConferenceCall& aCall );
       
   376 
       
   377     /**
       
   378     * Notifies Plug-In about transfer status.
       
   379     * @since Series 60 3.2
       
   380     * @param aAccept Boolean value is transfer accepted or not.
       
   381     * @return None
       
   382     */                      
       
   383     void AcceptTransfer( TBool aAccept );
       
   384 
       
   385 
       
   386     /**
       
   387     * Notification from UI to Multiple choices query
       
   388     * multiple choices response
       
   389     * @since Series 60 3.2
       
   390     * @param aIndex index of address where the call is to be forwarded
       
   391     * @return KErrNone if succesfull
       
   392     */  
       
   393     TInt ForwardCallToAddressL( const TInt aIndex );
       
   394     
       
   395     /**
       
   396     * Get Plug-In capabilities
       
   397     * @since Series 60 3.2
       
   398     * @return TUint32 On return contains the capability flags of plug-In
       
   399     */
       
   400     TUint32 Caps() const;
       
   401     
       
   402 	/**
       
   403 	* Get DTMF provider
       
   404 	* @since Series 60 3.2
       
   405 	* @param aObserver CCP Dtmf observer for informing events
       
   406 	* @return Pointer to MCCPDTMFProvider if succesfull, NULL if not available
       
   407 	*/
       
   408 	MCCPDTMFProvider* DTMFProviderL( const MCCPDTMFObserver& aObserver );
       
   409 
       
   410 	/**
       
   411 	* Get extension provider
       
   412 	* @since Series 60 3.2
       
   413     * @param aObserver observer for extension(custom) events
       
   414 	* @return Pointer to MCCPExtensionProvider if succesfull, NULL if not available
       
   415 	*/
       
   416 	MCCPExtensionProvider* ExtensionProviderL( const MCCPExtensionObserver& aObserver );
       
   417     
       
   418     /**
       
   419     * Add an observer for DTMF related events.
       
   420     * Plug-in dependent feature if duplicates or more than one observers 
       
   421     * are allowed or not. Currently CCE will set only one observer.
       
   422     * @since S60 v3.2
       
   423     * @param aObserver Observer
       
   424     * @leave system error if observer adding fails
       
   425     */
       
   426     void AddObserverL( const MCCPDTMFObserver& aObserver );
       
   427 
       
   428     /**
       
   429     * Remove an observer.
       
   430     * @since S60 v3.2
       
   431     * @param aObserver Observer
       
   432     * @return KErrNone if removed succesfully. KErrNotFound if observer was not found.
       
   433     * Any other system error depending on the error.
       
   434     */
       
   435     TInt RemoveObserver( const MCCPDTMFObserver& aObserver );
       
   436 
       
   437     
       
   438 // from MCCPDTMFProvider
       
   439 
       
   440     /**
       
   441 	* Cancels asynchronous DTMF string sending.
       
   442 	* @return KErrNone if successful, otherwise system wide error code
       
   443 	* @since Series 60 3.2
       
   444 	*/
       
   445 	TInt CancelDtmfStringSending();
       
   446 
       
   447 	/**
       
   448 	* Starts the transmission of a single DTMF tone across a
       
   449 	* connected and active call.
       
   450 	* @since S60 3.2
       
   451 	* @param aTone Tone to be played.
       
   452 	* @return KErrNone if successful, otherwise another system wide error code
       
   453 	*/
       
   454 	TInt StartDtmfTone( const TChar aTone );
       
   455 
       
   456 	/**
       
   457 	* Stops playing current DTMF tone.
       
   458 	* @since S60 3.2
       
   459     * @param none
       
   460 	* @return KErrNone if successfull, otherwise another system wide error code
       
   461 	*/
       
   462 	TInt StopDtmfTone();
       
   463 
       
   464 	/**
       
   465 	* Plays DTMF string.
       
   466 	* @since S60 3.2
       
   467 	* @param aString String to be played.
       
   468 	* @return KErrNone if successful, otherwise another system wide error code
       
   469 	* KErrArgument if the specified string contains illegal DTMF characters
       
   470 	*/
       
   471 	TInt SendDtmfToneString( const TDesC& aString );
       
   472 
       
   473 	/**
       
   474 	* Continue or cancel sending DTMF string which was stopped with 'w'-character
       
   475 	* in string.
       
   476 	* @since S60 3.2
       
   477 	* @param aContinue ETrue if sending of the DTMF string should continue,
       
   478 	* EFalse if the rest of the DTMF string is to be discarded.
       
   479 	* @return KErrNone if succesfull, otherwise another system wide error code
       
   480 	*/
       
   481 	TInt ContinueDtmfStringSending( const TBool aContinue );   
       
   482 	
       
   483 	
       
   484 // from Mce DTMF observer
       
   485 public: 
       
   486 
       
   487     /**
       
   488     * Incoming DTMF tone received.
       
   489     * @param aSession Session that tone was received.
       
   490     * @param aStream Stream that tone was received.
       
   491     * @param aTone Received tone.
       
   492     */
       
   493     void DtmfToneReceived( CMceSession& aSession,
       
   494                            CMceAudioStream& aStream,
       
   495                            const TChar& aTone );
       
   496                                                                
       
   497     /**
       
   498     * DTMF event received.
       
   499     * @param aSession Session that event was received.
       
   500     * @param aStream Stream that event was received.
       
   501     * @param aSource Source that event was received.
       
   502     * @param aEvent Received event.
       
   503     */
       
   504     void DtmfEventReceived( CMceSession& aSession,
       
   505                             CMceAudioStream& aStream,
       
   506                             CMceMediaSource& aSource,
       
   507                             TMceDtmfEvent aEvent );
       
   508                                   		
       
   509     /**
       
   510     * DTMF error occured. If error occurs, DTMFs becomes
       
   511     * unavailable for that source.
       
   512     * @param aSession Session that event was received.
       
   513     * @param aStream Stream that event was received.
       
   514     * @param aStream Stream that event was received.
       
   515     * @param aError Error code.
       
   516     */
       
   517     void DtmfErrorOccured( CMceSession& aSession,
       
   518                            CMceAudioStream& aStream,
       
   519                            CMceMediaSource& aSource,
       
   520                            TInt aError );
       
   521 
       
   522 
       
   523 public: // methods from MSIPObserver
       
   524 
       
   525     /**
       
   526     * From MSIPObserver A SIP request has been received from the network. 
       
   527     * @since  Series 60 3.0
       
   528     * @param  aIapId The IapId from which the SIP request was received.  
       
   529     * @param  aTransaction Contains local address, remote address of a sip
       
   530     *         message, as well as optional SIP message method, headers and 
       
   531     *         body. The ownership is transferred.  
       
   532     */
       
   533      void IncomingRequest( TUint32 aIapId, 
       
   534                            CSIPServerTransaction* aTransaction );
       
   535 
       
   536     /**
       
   537     * From MSIPObserver The received SIP request time-outed and it has been
       
   538     * destroyed.  
       
   539     * @since  Series 60 3.0
       
   540     * @param  aSIPServerTransaction The time-outed transaction. Ownership is
       
   541     *         not transferred. 
       
   542     */
       
   543      void TimedOut( CSIPServerTransaction& aSIPServerTransaction );
       
   544 
       
   545      
       
   546 public: // methods from MSIPProfileRegistryObserver
       
   547 
       
   548     /**
       
   549     * From MSIPProfileRegistryObserver An asynchronous error has occurred
       
   550     * related to SIP profile Event is send to those observers, who have the
       
   551     * corresponding profile instantiated. 
       
   552     * @since  Series 60 3.0
       
   553     * @param  aSIPProfileId SIP Profile ID. 
       
   554     * @param  aError Error code. 
       
   555     */ 
       
   556      void ProfileRegistryErrorOccurred( TUint32 aSIPProfileId,
       
   557                                         TInt aError );
       
   558     
       
   559     /**
       
   560     * From MSIPProfileRegistryObserver An event related to SIP Profile has
       
   561     * occurred.
       
   562     * @since  Series 60 3.0
       
   563     * @param  aProfileId SIP Profile ID. 
       
   564     * @param  aEvent An occurred event.
       
   565     */ 
       
   566     void ProfileRegistryEventOccurred( TUint32 aProfileId,
       
   567                                         TEvent aEvent );
       
   568 
       
   569 
       
   570 private: // new methods
       
   571     
       
   572     /**
       
   573      * Checks min session expires offered
       
   574      * Responds with 422 if smaller than provisioned
       
   575      * @Since Series 60 3.2
       
   576      * @param aSession Incoming session
       
   577      * @param aHeaders Incoming session SIP headers
       
   578      * @param aMinSE Minimum session expires provisioned to phone
       
   579      */
       
   580     void CheckMinSessionExpiresL( CMceInSession& aSession, 
       
   581                                   CDesC8Array& aHeaders,
       
   582                                   TInt aMinSE );
       
   583 
       
   584     /**
       
   585      * Handles cases where re-INVITE is received without SDP
       
   586      * @Since Series 60 3.2
       
   587      * @param aSessionIndex Session that is under update
       
   588      * @param aUpdatedSession Updated session received from Mce
       
   589      */
       
   590     void IncomingUpdateNoSdpHandlerL( TInt aSessionIndex, 
       
   591                                       CMceInSession* aUpdatedSession );
       
   592 
       
   593 
       
   594     /**
       
   595      * Handles cases where re-INVITE is received with SDP
       
   596      * @Since Series 60 3.2
       
   597      * @param aSessionIndex Session that is under update
       
   598      * @param aOrigSession Session to be updated
       
   599      * @param aUpdatedSession Updated session received from Mce
       
   600      */
       
   601     void IncomingNormalUpdate( TInt aSessionIndex,
       
   602                                CMceSession& aOrigSession,
       
   603                                CMceInSession* aUpdatedSession );
       
   604 
       
   605     /**
       
   606     * Fetches expires time from incoming INVITE
       
   607     * @Since Series 60 3.2
       
   608     * @param aExpiresTime time in expires header
       
   609     */   
       
   610     void FetchExpiresTime( TUint32& aExpiresTime, CDesC8Array& aHeaders ) const;
       
   611     
       
   612     /**
       
   613     * Checks if state change call back reported error in session creation
       
   614     * Used only for secure session 
       
   615     * @since S60 3.2
       
   616     * @param aStatusCode Status code contains the response or system wide error code
       
   617     * @return TBool ETrue if faield, EFalse otherwise
       
   618     */
       
   619     TBool CheckIfSecureFailed( TInt aStatusCode ) const;
       
   620 
       
   621     /**
       
   622     * Method is called when normal Mo session needs to created
       
   623     * after secure session creation has failed 
       
   624     * @since S60 3.2
       
   625     * @param aSessionIndex Session which is to be created again non-securely
       
   626     */
       
   627     void CreateNonSecureSessionL( TInt aSessionIndex ); 
       
   628 
       
   629     /**
       
   630     * Creates new SVP out session
       
   631     * @since Series 60 3.2
       
   632     * @param aRecipient, Recipient address
       
   633     * @param aVoIPProfile, VoIP profile entry
       
   634     * @param aParameters, Call parameters
       
   635     * @param aObserver, Observer
       
   636     * @return MCCPCall 
       
   637     */
       
   638     MCCPCall* CreateNewSessionL( 
       
   639         TDesC8& aRecipient, 
       
   640         CRCSEProfileEntry& aVoipProfile, 
       
   641         const CCCPCallParameters& aParameters,
       
   642         const MCCPCallObserver& aObserver );
       
   643     
       
   644     /**
       
   645     * Method for matching sessions.
       
   646     * @since Series 60 3.2
       
   647     * @param aSession Session object
       
   648     * @return Index of session. Function calls panic if session is not found.
       
   649     */
       
   650     TInt FindSVPSession( const CMceSession& aSession ) const;
       
   651     
       
   652     /**
       
   653     * Handles incoming sessions 
       
   654     * @since Series 60 3.2
       
   655     * @param aSession Session object
       
   656     * @param aContainer In this case contains data concerning incoming session 
       
   657     * @return 
       
   658     */
       
   659     void IncomingSessionHandlerL( CMceInSession* aSession,
       
   660 			                      TMceTransactionDataContainer* aContainer);
       
   661 			                   
       
   662     /**
       
   663     * Handles incoming session updates in case when it is not hold case,
       
   664     * e.g. in codec renegotiation case
       
   665     * @param aOrigSession, the original session to be updated. 
       
   666     *        This instance cannot be used anymore, 
       
   667     *        all actions done using aUpdatedSession instance.
       
   668     * @param aUpdatedSession, the new updated session.
       
   669 	* @return
       
   670     */
       
   671     void UpdateSessionL( CMceSession& aOrigSession,
       
   672                          CMceInSession& aUpdatedSession );
       
   673 
       
   674    	/**
       
   675     * Audio codecs are set in existing stream.
       
   676     * If there isn't existing stream, new stream will be created.
       
   677     * @since Series 60 3.2
       
   678     * @param aVoIPProfile VoIP profile entry
       
   679     * @param aMtSession MtSession object.
       
   680     * @return 
       
   681     */
       
   682     void CheckStreamsL( CRCSEProfileEntry& aVoipProfile, 
       
   683                         CMceSession& aMtSession,
       
   684                         TInt aKeepAliveValue,
       
   685                         TBool aSessionUpdateOngoing = EFalse );
       
   686 
       
   687     /**
       
   688     * Extract call id from user headers.
       
   689     * @since S60 3.2
       
   690     * @param aUserHeaders   User headers.
       
   691     * @param aCallId        On completion, contains call id.
       
   692     * @return ETrue if text Replaces: found, else EFalse
       
   693     * @leave KErrArgument if header doesn't include colonmarks.
       
   694     */
       
   695     TBool GetCallIdFromUserHeadersL( const CDesC8Array& aUserHeaders,
       
   696                                    TDes8& aCallId );
       
   697 
       
   698     /**
       
   699     * Check is incoming session transfer target case or normal incoming call.
       
   700     * @since S60 3.2
       
   701     * @param aHeaders Headers of incoming session. 
       
   702     */
       
   703     void IsTransferTargetCaseL( CDesC8Array* aHeaders );
       
   704     
       
   705     /**
       
   706      * Check Supported and Require headers if Provisional Response
       
   707      * ACKnowledgement (PRACK) method is supported for Preconditions.
       
   708      * @since S60 3.2
       
   709      * @param aHeaders Headers of incoming session
       
   710      * @return ETrue if Precondition is required and PRACK is supported, else EFalse
       
   711      */
       
   712     TBool IsPreconditionRequired( CDesC8Array& aHeaders );
       
   713 
       
   714     /**
       
   715     * Check and store data (FromHeader, ToHeader, CallId) from the headers
       
   716     * to the SessionBase, if CallId not already existing.
       
   717     * @since Series 60 3.2
       
   718     * @param aSVPSession
       
   719     * @param aContainer Contains data concerning changed session  
       
   720     */
       
   721     void CheckHeadersData( CSVPSessionBase* aSVPSession,
       
   722                            TMceTransactionDataContainer* aContainer );
       
   723 
       
   724     /**
       
   725     * Check and store contact data from the headers to the MoSession
       
   726     * @since Series 60 3.2
       
   727     * @param aSVPSession
       
   728     * @param aContainer Contains data concerning changed session  
       
   729     */
       
   730     TInt CheckContactData( CSVPSessionBase* aSVPSession, 
       
   731                                 TMceTransactionDataContainer* aContainer );
       
   732 
       
   733     /**
       
   734     * Handles incoming refers 
       
   735     * @since Series 60 3.2
       
   736     * @param aRefer coming refer
       
   737     * @param aReferTo Refer-to header.
       
   738     * @param aContainer In this case contains data concerning incoming session 
       
   739     * @return void
       
   740     */
       
   741     void IncomingReferHandlerL( CMceInRefer* aRefer,
       
   742                                     const TDesC8& aReferTo,
       
   743                                     TMceTransactionDataContainer* aContainer);
       
   744 
       
   745     /**
       
   746     * Creates new SVP out session in transfer case
       
   747     * @since Series 60 3.2
       
   748     * @param aSessionIndex, SVP session index, receiver of refer.
       
   749     * @param aAttended, ETrue if attended EFalse if unattended
       
   750     */
       
   751     void CreateNewTransferSessionL( 
       
   752         TInt aSessionIndex,
       
   753         TBool aAttended );
       
   754 
       
   755     /**
       
   756     * Handles 3xx call forward events
       
   757     * @since Series 60 3.2
       
   758     * @param aStatusCode Call forward response code
       
   759     * @param aSessionIndex SVP session index
       
   760     * @param aContainer Contains data concerning changed session  
       
   761     */
       
   762     void HandleCallForward( TInt aStatusCode,
       
   763                             TInt aSessionIndex, 
       
   764                             TMceTransactionDataContainer* aContainer );
       
   765     
       
   766     /**
       
   767      * Finalizes the session creation. Adds DTMF observer to created session
       
   768      * and adds the session into the session array.
       
   769      * @since S60 v3.2
       
   770      * @param aSession Session whose construction to finalize.
       
   771      * @return void
       
   772      */
       
   773     void FinalizeSessionCreationL( CSVPSessionBase* aSession );
       
   774     
       
   775     /**
       
   776      * Executes 'ErrorOccurred' callback(Cb) to CCP Monitor if not NULL.
       
   777      * @since S60 v3.2
       
   778      * @param aError the error code
       
   779      * @return System wide error code.
       
   780      */
       
   781     TInt ExecCbErrorOccurred( MCCPObserver::TCCPError aError );
       
   782     
       
   783     /**
       
   784      * Executes 'IncomingCall' callback(Cb) to CCP Monitor if not NULL.
       
   785      * @since S60 v3.2
       
   786      * @param aCall Pointer to the newly created incoming call.
       
   787      * @return System wide error code.
       
   788      */
       
   789     TInt ExecCbIncomingCall( MCCPCall* aCall );
       
   790     
       
   791     /**
       
   792      * Executes 'IncomingCall' callback(Cb) to CCP Monitor if not NULL.
       
   793      * @since S60 v3.2
       
   794      * @param aCall Pointer to the newly created incoming call.
       
   795      * @param aTempCall Reference to the held call.
       
   796      * @return System wide error code.
       
   797      */
       
   798     TInt ExecCbIncomingCall( MCCPCall* aCall, MCCPCall& aTempCall );
       
   799     
       
   800     /**
       
   801      * Executes 'CallCreated' callback(Cb) to CCP Monitor if not NULL.
       
   802      * @since S60 v3.2
       
   803      * @param aNewTransferCall The call that has been created with the new transfer target.
       
   804      * @param aOriginator Pointer to originator of the transfer request.
       
   805      * @param aAttended Transfer requested was attented (ETrue) or un-attented(EFalse)
       
   806      * @return System wide error code.
       
   807      */
       
   808     TInt ExecCbCallCreated( MCCPCall* aNewTransferCall, MCCPCall* aOriginator, TBool aAttended );
       
   809 
       
   810     /**
       
   811     * Evaluates and removes the Dual-tone multi-frequency (DTMF) part from recipient's number.
       
   812     * Leaves with KErrArgument if invalid argument given.
       
   813     * @since S60 3.2
       
   814     * @param aRecipient The address/number to be evaluated, a non-modifiable descriptor.
       
   815     * @return Pointer to the modified recipient address/number heap descriptor. 
       
   816     */
       
   817     HBufC* ParseRecipientDtmfSuffixL( const TDesC& aRecipient ) const;
       
   818 
       
   819     /**
       
   820     * Checks that the given recipient address/number contains only valid DTMF characters.
       
   821     * Called from ParseRecipientDtmfSuffixL method.
       
   822     * Leaves with KErrArgument if invalid argument given.
       
   823     * @since S60 3.2
       
   824     * @param aRecipient The address/number to be checked, a non-modifiable descriptor.
       
   825     * @return ETrue when aRecipient contains only valid dtmf chars, EFalse if not.
       
   826     */
       
   827     TBool IsValidDtmfRecipientL( const TDesC& aRecipient ) const;
       
   828 
       
   829     /**
       
   830     * Checks what call event will be sent after attended transfer cases.
       
   831     * @since S60 3.2
       
   832     * @param aNewSVPSession The new established session.
       
   833     * @param aOldSVPSession The old transfered session.
       
   834     */
       
   835     void CSVPController::CheckCallEventToBeSent( CSVPSessionBase* aNewSVPSession, 
       
   836                                                  CSVPSessionBase* aOldSVPSession ) const;
       
   837 
       
   838 private:
       
   839 
       
   840     /**
       
   841     * C++ default constructor.
       
   842     */
       
   843     CSVPController();
       
   844     
       
   845     /**
       
   846     * second-phase constructor
       
   847     */
       
   848     void ConstructL();
       
   849     
       
   850 private: // data
       
   851     
       
   852     /**
       
   853      * pointer to Mce manager
       
   854      */
       
   855     CMceManager* iMceManager;
       
   856     
       
   857     /*
       
   858      * instance of SVP utility class.
       
   859      * own.
       
   860      */
       
   861     CSVPUtility* iSVPUtility;
       
   862     
       
   863     /**
       
   864      * transaction container, holds detailed data about transaction
       
   865      * TMceTransactionDataContainer* iTransactionDataContainer;
       
   866      */
       
   867     TMceTransactionDataContainer iContainer;
       
   868     
       
   869     /**
       
   870      * array of created SVP sessions
       
   871      */
       
   872     RPointerArray< CSVPSessionBase > iSessionArray;
       
   873     
       
   874     /**
       
   875      * pointer to created SVP emergency session
       
   876      */
       
   877     CSVPEmergencySession* iEmergencySession;
       
   878     
       
   879     /**
       
   880      * CCP observer
       
   881      */
       
   882     MCCPObserver* iCCPMonitor;
       
   883     
       
   884     /**
       
   885      * CCP Supplementary Services observer
       
   886      */
       
   887     MCCPSsObserver* iCCPSsObserver;
       
   888     
       
   889     /**
       
   890      * CCP session observer
       
   891      */ 
       
   892     MCCPCallObserver* iCCPSessionObserver;
       
   893     
       
   894     /**
       
   895      * CCP DTMF observer
       
   896      */
       
   897     const MCCPDTMFObserver* iCCPDtmfObserver;
       
   898     
       
   899     /**
       
   900      * Terminal type
       
   901      */
       
   902     TBuf< KSVPMaxTerminalTypeLength > iTerminalType;
       
   903 
       
   904     /**
       
   905      * WLAN MAC address
       
   906      */
       
   907     TBuf< KSVPWlanMacAddressLength > iWlanMacAddress;
       
   908     
       
   909     /**
       
   910      * Hold call index in attended transfer target case.
       
   911      */
       
   912     TInt32 iHoldCallIndex;
       
   913     
       
   914     /**
       
   915      * Original call index in transfer case.
       
   916      */
       
   917     TInt32 iIncomingReferCallIndex;
       
   918     
       
   919     /**
       
   920      * Untried profile IDs for emergency call
       
   921      */
       
   922     RArray<TUint32> iEmergencyProfileIds;
       
   923     
       
   924     /**
       
   925      * Untried IAP IDs for emergency call
       
   926      */
       
   927     RArray<TUint> iEmergencyIapIds;
       
   928 
       
   929     /**
       
   930      * Flag to indicate that Dtmf string sending is started
       
   931      * This is needed, because Mce provides only two Dtmf events
       
   932      */
       
   933     TBool iDtmfStringSending;
       
   934     
       
   935     /**
       
   936      * Flag to indicate first character of the Dtmf string is send
       
   937      * This is needed, because Mce provides only two Dtmf events
       
   938      */
       
   939     TBool iFirstDtmfSent;
       
   940     
       
   941     /**
       
   942      * Supplementary services.
       
   943      * Own.
       
   944      */
       
   945     CSVPSupplementaryServices* iSuppServices;
       
   946     
       
   947     /**
       
   948      * Flag for prevent wrong handling after SessionStateChanged -callback
       
   949      * in MT Re-Invite case that is not hold/resume. ETrue when e.g. codec
       
   950      * renegotiation ongoing, EFalse otherways
       
   951      */
       
   952     TBool iSessionUpdateOngoing;
       
   953 
       
   954     /**
       
   955      * Flag that indicates that handling of hold re-INVITE 
       
   956      * without is SDP is ongoing
       
   957      */
       
   958     TBool iEmptyReInvite;
       
   959     
       
   960     /**
       
   961      * This flag is set after Failed() callback is received to
       
   962      * prevent handling of subsequent state change callbacks
       
   963      * because session termination started when Failed() was received 
       
   964      */
       
   965     TBool iFailed;
       
   966     
       
   967     /**
       
   968      * RTP observer
       
   969      * Own
       
   970      */
       
   971     CSVPRtpObserver* iRtpObserver;
       
   972     
       
   973     /**
       
   974      * Contains single DTMF tone sent. Used with outband 
       
   975      */ 
       
   976     TChar iDtmfTone;
       
   977     
       
   978     /**
       
   979      * Contains DTMF string sent. Used with outband DTMF 
       
   980      */
       
   981     HBufC* iDtmfString;
       
   982     
       
   983     /** 
       
   984      * Keeps count of the current tone sent. Used with outband DTMF 
       
   985      */
       
   986     TLex iDtmfStringLex;
       
   987     
       
   988     /**
       
   989      * This flag is set ETrue if preconditions are required in SIP headers 
       
   990      */
       
   991     TBool iPreconditions;
       
   992 
       
   993     /**
       
   994      * WLAN management client used for creating virtual WLAN traffic streams. 
       
   995      * Own.
       
   996      */
       
   997     CWlanMgmtClient* iWlanMgmt;
       
   998 
       
   999     /**
       
  1000      * ID of the created WLAN virtual traffic stream during an MO call.
       
  1001      */
       
  1002     TUint iTrafficStreamId;
       
  1003 
       
  1004     /**
       
  1005      * This flag is used for stream creation/deletion logic during an MO call.
       
  1006      */
       
  1007     TBool iTrafficStreamCreated;
       
  1008    
       
  1009 private:
       
  1010     
       
  1011     // For testing
       
  1012     SVP_UT_DEFS
       
  1013     
       
  1014     };
       
  1015 
       
  1016 #endif // CSVPTRANSFERCONTROLLER_H