tsrc/sipclientstub/inc/sipservertransaction.h
changeset 0 f0cf47e981f9
equal deleted inserted replaced
-1:000000000000 0:f0cf47e981f9
       
     1 /*
       
     2 * Copyright (c) 2003 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 #ifndef CSIPSERVERTRANSACTION_H
       
    20 #define CSIPSERVERTRANSACTION_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "siptransactionbase.h"
       
    24 #include "musunittesting.h"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class CSIPRequestElements;
       
    28 class CSIPRefresh;
       
    29 class MSIPResponseSender;
       
    30 class CSIPConnection;
       
    31 
       
    32 /**
       
    33 *  Class for managing SIP server transactions.
       
    34 *  It provides services for creating, ending
       
    35 *  and getting SIP transaction parameters.
       
    36 *  Client cannot instantiate this class.
       
    37 *  
       
    38 *  @lib sipclient
       
    39 */
       
    40 class CSIPServerTransaction: public CSIPTransactionBase
       
    41 	{
       
    42 	public:
       
    43 
       
    44         /**
       
    45         * Destructor
       
    46 		*/
       
    47 
       
    48 		IMPORT_C ~CSIPServerTransaction();
       
    49 
       
    50     public: // Not in real SIP API
       
    51     
       
    52  		IMPORT_C static CSIPServerTransaction* NewL( RStringF aType );
       
    53 
       
    54         IMPORT_C void SetRequestElements(CSIPRequestElements* aElements);
       
    55 
       
    56 
       
    57 	public:
       
    58 		
       
    59         /**
       
    60 		* Sends response and ends the transaction;
       
    61 		* The user must not send 100 Trying response. Leaves on failure.
       
    62         * @pre aElements!=0
       
    63         * @pre State()==ETrying || State()==EProceeding
       
    64 		* @pre CSIPConnection::State()==EActive
       
    65 		* @pre ResponseAllowed()==ETrue		
       
    66 		* @param aElements contains Status Code, optional Reason Phrase and
       
    67         *   optional SIP message headers and body. Ownership is transferred.
       
    68 		* @leave KErrArgument if aElements == NULL
       
    69 		* @leave KErrGeneral if ResponseAllowed() == EFalse
       
    70 		*/
       
    71 
       
    72 		IMPORT_C void SendResponseL(CSIPResponseElements *aElements);
       
    73 
       
    74 
       
    75 	    /**
       
    76 		* Gets the request elements
       
    77 		* @return Request elements. Ownership is not transferred.
       
    78 		*/
       
    79 
       
    80 		IMPORT_C const CSIPRequestElements* RequestElements() const;
       
    81 
       
    82 
       
    83         /**
       
    84 		* Checks if the response sending is allowed for this server
       
    85         * transaction. For instance response is not allowed in ACK transaction.
       
    86 		* @return ETrue if response sending is allowed, EFalse otherwise
       
    87 		*/
       
    88 
       
    89 		IMPORT_C TBool ResponseAllowed() const;
       
    90 
       
    91         /**
       
    92 		* Sets a new respose sender, replacing the current sender.
       
    93 		*
       
    94         * @param aSender Response sender to be used from now on. Ownership is
       
    95         *   	 transferred.		
       
    96 		*/
       
    97 
       
    98         void SetResponseSender(MSIPResponseSender* aSender);
       
    99 
       
   100 
       
   101         /**
       
   102 	    * Obtains the associated CSIPConnection instance. If connection can't
       
   103         * be accessed anymore, this function leaves.
       
   104         *	
       
   105 	    * @return CSIPConnection
       
   106 	    */
       
   107 
       
   108         CSIPConnection& SIPConnectionL();
       
   109 
       
   110 
       
   111         /**
       
   112 		* Update the MTransactionAssociation to point to aAssociation.
       
   113 		*
       
   114         * @param aAssociation Associated object		
       
   115 		*/
       
   116 
       
   117         void ReAssociateL(MTransactionAssociation& aAssociation);
       
   118 
       
   119 
       
   120         /**
       
   121 		* Removes, but does not delete, request elements from
       
   122         * aServerTransaction.
       
   123         *
       
   124 		* @param aServerTransaction Server transaction from which response
       
   125         *   elements are removed. Ownership is not transferred.
       
   126 		*/
       
   127 
       
   128         static void DetachRequestElements(TAny* aServerTransaction);
       
   129 
       
   130 	public:
       
   131 
       
   132         /**
       
   133 		* Creates a server transaction.
       
   134 		*
       
   135         * @param aRequestId RequestId for the transaction to use
       
   136         * @param aAssociation Object with which the transaction is associated
       
   137         * @param aElements Request elements. Ownership is transferred.
       
   138         * @return New object. Ownership is transferred.
       
   139 		*/
       
   140 
       
   141 		static CSIPServerTransaction*
       
   142             NewL(TUint32 aRequestId,
       
   143                  MTransactionAssociation& aAssociation,
       
   144                  CSIPRequestElements* aElements);
       
   145 
       
   146 
       
   147         /**
       
   148 		* Creates a server transaction and pushes it to cleanup stack.
       
   149 		*
       
   150         * @param aRequestId RequestId for the transaction to use
       
   151         * @param aAssociation Object with which the transaction is associated
       
   152         * @param aElements Request elements. Ownership is transferred.
       
   153         * @return New object. Ownership is transferred.
       
   154 		*/
       
   155 
       
   156 		static CSIPServerTransaction*
       
   157             NewLC(TUint32 aRequestId,
       
   158                   MTransactionAssociation& aAssociation,
       
   159                   CSIPRequestElements* aElements);
       
   160 
       
   161 
       
   162         
       
   163 	private:
       
   164 		CSIPServerTransaction( RStringF aType );
       
   165 
       
   166 
       
   167         /**
       
   168 		* Second phase constructor.
       
   169 		*        
       
   170         * @param aElements Request elements. Ownership is transferred.        
       
   171 		*/
       
   172         void ConstructL(CSIPRequestElements* aElements);
       
   173 
       
   174 
       
   175         CSIPRequestElements* iRequestElements;
       
   176 
       
   177         //This interface is used for sending the response.
       
   178         //CSIPServerTransaction owns iResponseSender.
       
   179         MSIPResponseSender* iResponseSender;
       
   180     
       
   181     };
       
   182 
       
   183 #endif