|
1 /* |
|
2 * Copyright (c) 2004 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: See class definition below. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CTCSIPCONNECTIONCONTAINER_H__ |
|
19 #define __CTCSIPCONNECTIONCONTAINER_H__ |
|
20 |
|
21 // INCLUDES |
|
22 #include <sipconnection.h> |
|
23 #include <sipconnectionobserver.h> |
|
24 #include <cdblen.h> |
|
25 #include "TTcSIPReceived.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CTcSIPContext; |
|
29 class CSIPHeaderBase; |
|
30 |
|
31 // CLASS DEFINITION |
|
32 /** |
|
33 * CTcSIPConnectionContainer implements a container for a single CSIPConnection |
|
34 * object. Its task is also to observe and queue SIP notifications for |
|
35 * future use. |
|
36 */ |
|
37 class CTcSIPConnectionContainer |
|
38 : public CBase, |
|
39 public MSIPConnectionObserver |
|
40 { |
|
41 public: // Constructors and destructor |
|
42 |
|
43 /** |
|
44 * Static constructor. |
|
45 * |
|
46 * @param aContext Reference to test context object. |
|
47 * @param aIAPName Internet Access Point name to be used. |
|
48 * @return An initialized instance of this class. |
|
49 */ |
|
50 static CTcSIPConnectionContainer* NewL( CTcSIPContext& aContext, |
|
51 const TDesC8& aIAPName ); |
|
52 |
|
53 /// Destructor |
|
54 ~CTcSIPConnectionContainer(); |
|
55 |
|
56 private: |
|
57 |
|
58 /** |
|
59 * Constructor. |
|
60 * |
|
61 * @param aContext Reference to test context object. |
|
62 * @param aIAPName Internet Access Point name to be used. |
|
63 */ |
|
64 CTcSIPConnectionContainer( CTcSIPContext& aContext, |
|
65 const TDesC8& aIAPName ); |
|
66 |
|
67 /// Default constructor. Not implementer. |
|
68 CTcSIPConnectionContainer(); |
|
69 |
|
70 /// 2nd phase constructor |
|
71 void ConstructL(); |
|
72 |
|
73 public: // From MSIPConnectionObserver |
|
74 |
|
75 void IncomingRequest( CSIPServerTransaction* aTransaction ); |
|
76 void IncomingRequest( CSIPServerTransaction* aTransaction, |
|
77 CSIPDialog& aDialog ); |
|
78 |
|
79 void IncomingResponse( CSIPClientTransaction& aTransaction ); |
|
80 void IncomingResponse( CSIPClientTransaction& aTransaction, |
|
81 CSIPDialogAssocBase& aDialogAssoc ); |
|
82 void IncomingResponse( CSIPClientTransaction& aTransaction, |
|
83 CSIPInviteDialogAssoc* aDialogAssoc ); |
|
84 void IncomingResponse( CSIPClientTransaction& aTransaction, |
|
85 CSIPRegistrationBinding& aRegistration ); |
|
86 |
|
87 void ErrorOccured( TInt aError, CSIPTransactionBase& aTransaction ); |
|
88 void ErrorOccured( TInt aError, CSIPClientTransaction& aTransaction, |
|
89 CSIPRegistrationBinding& aRegistration ); |
|
90 void ErrorOccured( TInt aError, CSIPTransactionBase& aTransaction, |
|
91 CSIPDialogAssocBase& aDialogAssoc ); |
|
92 void ErrorOccured( TInt aError, CSIPRefresh& aSIPRefresh ); |
|
93 void ErrorOccured( TInt aError, CSIPRegistrationBinding& aRegistration ); |
|
94 void ErrorOccured( TInt aError, CSIPDialogAssocBase& aDialogAssoc ); |
|
95 |
|
96 void InviteCompleted( CSIPClientTransaction& aTransaction ); |
|
97 |
|
98 void InviteCanceled( CSIPServerTransaction& aTransaction ); |
|
99 |
|
100 void ConnectionStateChanged( CSIPConnection::TState aState ); |
|
101 |
|
102 public: // New methods |
|
103 |
|
104 /** |
|
105 * Returns the first item off the receive queue (FIFO). If no |
|
106 * items are present, the function will wait for aTimeout seconds |
|
107 * and then try fetching again. |
|
108 * |
|
109 * @param aTimeOut Time in seconds waited for items to arrive. |
|
110 */ |
|
111 TTcSIPReceived ReceivedItemL( TInt aTimeout ); |
|
112 |
|
113 /// @return Reference to the contained SIP connection object. |
|
114 inline CSIPConnection& Connection() { return *iSipConnection; }; |
|
115 |
|
116 /// @return Reference to the Internet Access Point name |
|
117 inline const TDesC8& IAPName() const { return iIAPName; }; |
|
118 |
|
119 /** |
|
120 * Add the specified item to the received items queue. |
|
121 * The item is copied to the internal array. |
|
122 * |
|
123 * @param aItem Referece to a Received object. |
|
124 */ |
|
125 void QueueReceivedL( TTcSIPReceived& aItem ); |
|
126 |
|
127 private: // New methods |
|
128 |
|
129 /** |
|
130 * CDeltaTimer callback. Called when the timer entry expires. |
|
131 * |
|
132 * @param aSelf Pointer to self |
|
133 * @return KErrNone |
|
134 */ |
|
135 static TInt ReceiveTimeout( TAny* aSelf ); |
|
136 |
|
137 private: // data |
|
138 |
|
139 /// Active scheduler wrapper for async waiting. Owned. |
|
140 CActiveSchedulerWait iActiveWait; |
|
141 |
|
142 /// Reference to the test contextg. Not owned. |
|
143 CTcSIPContext& iContext; |
|
144 |
|
145 /// Array of received items. Owned. |
|
146 CArrayFixSeg< TTcSIPReceived > iReceiveQueue; |
|
147 |
|
148 /// Timeout timer. Owned. |
|
149 CDeltaTimer* iTimer; |
|
150 |
|
151 /// Timeout entry. Owned. |
|
152 TDeltaTimerEntry iReceiveTimeout; |
|
153 |
|
154 /// SIP connection. Owned. |
|
155 CSIPConnection* iSipConnection; |
|
156 |
|
157 /// SIP Connection state |
|
158 CSIPConnection::TState iConnectionState; |
|
159 |
|
160 /// Internet Access Point name for the connection. |
|
161 TBuf8< KCommsDbSvrMaxFieldLength > iIAPName; |
|
162 |
|
163 }; |
|
164 |
|
165 #endif // __CTCSIPCONNECTIONCONTAINER_H__ |