1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/mw/siptransactionbase.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,230 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* Name : siptransactionbase.h
1.19 +* Part of : SIP Client
1.20 +* Interface : SDK API, SIP Client API
1.21 +* Version : 1.0
1.22 +*
1.23 +*/
1.24 +
1.25 +
1.26 +
1.27 +#ifndef CSIPTRANSACTIONBASE_H
1.28 +#define CSIPTRANSACTIONBASE_H
1.29 +
1.30 +// INCLUDES
1.31 +#include <e32base.h>
1.32 +#include <stringpool.h>
1.33 +#include "_sipcodecdefs.h"
1.34 +
1.35 +// FORWARD DECLARATIONS
1.36 +class CSIPResponseElements;
1.37 +class MTransactionAssociation;
1.38 +
1.39 +// CLASS DECLARATION
1.40 +
1.41 +/**
1.42 +* @publishedAll
1.43 +* @released
1.44 +*
1.45 +* Base class for managing SIP transactions.
1.46 +* It provides services for querying transaction type and its state.
1.47 +*
1.48 +* This class is an abstract class and cannot be instantiated.
1.49 +* @lib sipclient
1.50 +*/
1.51 +class CSIPTransactionBase: public CBase
1.52 + {
1.53 + public:
1.54 + /** SIP transaction state */
1.55 + enum TState
1.56 + {
1.57 + /** Trying state */
1.58 + ETrying,
1.59 + /** Calling state */
1.60 + ECalling,
1.61 + /** Proceeding state */
1.62 + EProceeding,
1.63 + /** Completed state */
1.64 + ECompleted,
1.65 + /** Confirmed state */
1.66 + EConfirmed,
1.67 + /** Terminated state */
1.68 + ETerminated,
1.69 + /** Object is being constructed and is not yet ready for use */
1.70 + EConstructing
1.71 + };
1.72 +
1.73 + public: // Destructor
1.74 + /**
1.75 + * Destructor
1.76 + * @internalComponent
1.77 + */
1.78 + virtual ~CSIPTransactionBase();
1.79 +
1.80 + public: // New functions
1.81 + /**
1.82 + * Gets the SIP transaction type
1.83 + * @return SIP transaction type
1.84 + */
1.85 + IMPORT_C RStringF Type() const;
1.86 +
1.87 + /**
1.88 + * Gets SIP transaction state
1.89 + * @return SIP transaction state
1.90 + * @leave KErrSIPResourceNotAvailable if a required SIP Client API
1.91 + * object has been deleted
1.92 + */
1.93 + IMPORT_C CSIPTransactionBase::TState StateL();
1.94 +
1.95 + /**
1.96 + * Checks the if the actual object
1.97 + * is of type CSIPClientTransaction.
1.98 + * @return ETrue if object is of type CSIPClientTransaction and
1.99 + * EFalse otherwise
1.100 + */
1.101 + IMPORT_C TBool IsSIPClientTransaction() const;
1.102 +
1.103 + /**
1.104 + * Compares this object to another object also having
1.105 + * CSIPTransactionBase base class
1.106 + * The function has to be implemented in each of the sub-classes.
1.107 + * @param aTransaction a CSIPTransactionBase object to compare
1.108 + * @return ETrue if the objects are equal otherwise EFalse
1.109 + */
1.110 + IMPORT_C TBool
1.111 + operator==(const CSIPTransactionBase& aTransaction) const;
1.112 +
1.113 + public: // New functions, for internal use
1.114 + /**
1.115 + * Obtains the RequestId of the transaction.
1.116 + *
1.117 + * @return RequestId
1.118 + */
1.119 + TUint32 RequestId() const;
1.120 +
1.121 + /**
1.122 + * Clears the MTransactionAssociation. After this the object can't be
1.123 + * used anymore and it is expected that user will delete it soon.
1.124 + *
1.125 + * @param aAssociation Object requesting the detach
1.126 + * @internalComponent
1.127 + */
1.128 + virtual void Detach(const MTransactionAssociation& aAssociation);
1.129 +
1.130 + /**
1.131 + * Changes the transaction state.
1.132 + *
1.133 + * @param aNextState State into which transaction moves
1.134 + */
1.135 + void ChangeState(CSIPTransactionBase::TState aNextState);
1.136 +
1.137 + /**
1.138 + * Determines whether this transaction has an effect on the associated
1.139 + * dialog's state.
1.140 + *
1.141 + * @return ETrue if transaction has an effect on the dialog's state,
1.142 + * EFalse otherwise.
1.143 + */
1.144 + TBool AffectsDialogState() const;
1.145 +
1.146 + /**
1.147 + * Sets this transaction to affect the dialog state.
1.148 + */
1.149 + void SetAffectsDialogState();
1.150 +
1.151 + /**
1.152 + * Determines whether the transaction type is a target refresh request.
1.153 + *
1.154 + * @param aType Type of transaction
1.155 + * @return ETrue If the transaction is a target refresh request, EFalse
1.156 + * otherwise.
1.157 + */
1.158 + static TBool IsTargetRefresh(RStringF aType);
1.159 +
1.160 + /**
1.161 + * Stores response elements. Depending on the status code, transaction
1.162 + * may enter another state.
1.163 + *
1.164 + * @param aElements Response elements, ownership is transferred.
1.165 + */
1.166 + void SetResponseElements(CSIPResponseElements* aElements);
1.167 +
1.168 + protected: // Constructors
1.169 + CSIPTransactionBase(TBool aIsClientTransaction,
1.170 + TUint32 aRequestId,
1.171 + MTransactionAssociation& aAssociation);
1.172 +
1.173 + void ConstructL(RStringF aType);
1.174 +
1.175 + protected: // New functions, for internal use
1.176 + /**
1.177 + * Checks that iAssociation is available (not NULL). If iAssociation is
1.178 + * NULL, it means user has deleted a resource needed by
1.179 + * CSIPTransactionBase, and this function leaves.
1.180 + */
1.181 + void CheckAssociationL() const;
1.182 +
1.183 + /**
1.184 + * Gets response elements.
1.185 + *
1.186 + * @return Response elements. Ownership isn't transferred.
1.187 + */
1.188 + const CSIPResponseElements* ResponseElements() const;
1.189 +
1.190 + protected: // Data
1.191 +
1.192 + /**
1.193 + * RequestId received from SIP client
1.194 + * @internalComponent
1.195 + */
1.196 + TUint32 iRequestId;
1.197 +
1.198 + /**
1.199 + * Every transaction is associated to exactly one other object:
1.200 + * CSIP, CSIPConnection, CSIPRegistrationBinding or CSIPDialogAssocBase
1.201 + * @internalComponent
1.202 + */
1.203 + MTransactionAssociation* iAssociation;
1.204 +
1.205 + private: // Data
1.206 + RStringF iType;
1.207 +
1.208 + //ETrue is the transaction is a client transaction, EFalse otherwise
1.209 + TBool iIsClientTransaction;
1.210 +
1.211 + //Current transaction state
1.212 + CSIPTransactionBase::TState iState;
1.213 +
1.214 + //ETrue if the transaction has an effect on the dialog state in case
1.215 + //the transaction is associated with a dialog.
1.216 + //EFalse otherwise.
1.217 + TBool iAffectsDialogState;
1.218 +
1.219 + //SIP response elements
1.220 + CSIPResponseElements* iResponseElements;
1.221 +
1.222 + private: // For testing purposes
1.223 + UNIT_TEST(CSIP_Test)
1.224 + UNIT_TEST(CSIPServerTransaction_Test)
1.225 + UNIT_TEST(CSIPSubscribeDialogAssoc_Test)
1.226 + UNIT_TEST(CSIPInviteDialogAssoc_Test)
1.227 + UNIT_TEST(CSIPNotifyDialogAssoc_Test)
1.228 + UNIT_TEST(CSIPConnection_Test)
1.229 +
1.230 + __DECLARE_TEST;
1.231 + };
1.232 +
1.233 +#endif