|
1 /* |
|
2 * Copyright (c) 2003-2009 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 * Name : SipDialogAssocImplementation.h |
|
16 * Part of : SIP Client |
|
17 * Interface : SDK API, SIP Client API |
|
18 * Version : 1.0 |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 /** |
|
26 @internalComponent |
|
27 */ |
|
28 |
|
29 #ifndef CSIPDIALOGASSOCIMPLEMENTATION_H |
|
30 #define CSIPDIALOGASSOCIMPLEMENTATION_H |
|
31 |
|
32 // INCLUDES |
|
33 #include <stringpool.h> |
|
34 #include "_sipcodecdefs.h" |
|
35 #include "transactionassociation.h" |
|
36 #include "siprefreshassociation.h" |
|
37 |
|
38 // FORWARD DECLARATIONS |
|
39 class CSIPDialogAssocBase; |
|
40 class CSIPClientTransaction; |
|
41 class CSIPRefresh; |
|
42 class CSIPDialog; |
|
43 class CSIPMessageElements; |
|
44 class CSIPServerTransaction; |
|
45 class CSIPHeaderBase; |
|
46 class TMessageHeaderCleanup; |
|
47 class CSIPDialogImplementation; |
|
48 class CSIPConnectionImplementation; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 /** |
|
53 * Implementation class of CSIPDialogAssocBase. |
|
54 */ |
|
55 class CSIPDialogAssocImplementation : |
|
56 public CBase, |
|
57 public MTransactionAssociation, |
|
58 public MSIPRefreshAssociation |
|
59 { |
|
60 public: // Constructors and destructor |
|
61 |
|
62 static CSIPDialogAssocImplementation* |
|
63 NewL(RStringF aType, |
|
64 CSIPDialogAssocBase& aAssoc, |
|
65 CSIPDialog& aDialog); |
|
66 |
|
67 static CSIPDialogAssocImplementation* |
|
68 NewL(RStringF aType, |
|
69 CSIPDialogAssocBase& aAssoc, |
|
70 CSIPDialog& aDialog, |
|
71 CSIPServerTransaction& aTransaction); |
|
72 |
|
73 /** |
|
74 * Destructor |
|
75 */ |
|
76 virtual ~CSIPDialogAssocImplementation(); |
|
77 |
|
78 public: //From MTransactionAssociation |
|
79 |
|
80 CSIPClientConnection& ClientConnectionL(); |
|
81 |
|
82 CSIPClientConnection* ClientConnection(); |
|
83 |
|
84 CSIPConnection& SIPConnectionL(); |
|
85 |
|
86 void AddTransactionL(CSIPTransactionBase& aTransaction); |
|
87 |
|
88 void RemoveTransaction(const CSIPTransactionBase& aTransaction); |
|
89 |
|
90 public: //From MSIPRefreshAssociation |
|
91 |
|
92 CSIPClientTransaction* |
|
93 UpdateRefreshL(CSIPRefresh& aRefresh, |
|
94 CSIPMessageElements* aElements, |
|
95 TBool aTerminate); |
|
96 |
|
97 void DeletingRefresh(CSIPRefresh& aRefresh, TUint32 aRefreshId); |
|
98 |
|
99 MTransactionAssociation& TransactionAssociation(); |
|
100 |
|
101 TInt CheckIfStandAlone(); |
|
102 |
|
103 public: // New functions |
|
104 |
|
105 /** |
|
106 * Gets the dialog this dialog association belongs to |
|
107 * @return associated dialog |
|
108 */ |
|
109 const CSIPDialog& Dialog() const; |
|
110 |
|
111 /** |
|
112 * Gets dialog this dialog association belongs to |
|
113 * @return associated dialog |
|
114 */ |
|
115 CSIPDialog& Dialog(); |
|
116 |
|
117 /** |
|
118 * Creates SIP request and sends it to the remote target. |
|
119 * This function should be used for sending SIP extension |
|
120 * requests within dialog assocation that do not cause |
|
121 * sip dialog associations to be created. In SIP terms |
|
122 * this request is non target refresh request. |
|
123 * @pre SIPDialog().State() != CSIPDialog::EInit && |
|
124 * SIPDialog().State() != CSIPDialog::ETerminated |
|
125 * @pre Dialog().Connection().State() == EActive |
|
126 * @pre aMethod != "REGISTER" |"INVITE" | "BYE" | "CANCEL" | "ACK" | |
|
127 * "SUBSCRIBE" | "NOTIFY" | "UPDATE" | "PRACK" |
|
128 * @param aElements contains optional SIP message headers and body. |
|
129 * Ownership is transferred. |
|
130 * @return SIP extension client transaction. Ownership is transferred. |
|
131 * @leave KErrSIPInvalidDialogState If dialog's state is not correct |
|
132 * @leave KErrArgument if invalid value has been set to aMethod |
|
133 * @leave KErrSIPResourceNotAvailable if a required SIP Client API |
|
134 * object has been deleted |
|
135 */ |
|
136 virtual CSIPClientTransaction* |
|
137 SendNonTargetRefreshRequestL(RStringF aMethod, |
|
138 CSIPMessageElements* aElements); |
|
139 |
|
140 /** |
|
141 * Gets dialog association type. |
|
142 * |
|
143 * @return dialog association type e.g. "INVITE", "SUBSCRIBE" etc... |
|
144 */ |
|
145 RStringF Type() const; |
|
146 |
|
147 /** |
|
148 * Searches for a transaction with the given aRequestId. |
|
149 * |
|
150 * @param aRequestId RequestId of a transaction |
|
151 * @return Found transaction, or NULL if not found. Ownership is not |
|
152 * transferred |
|
153 */ |
|
154 CSIPTransactionBase* FindTransaction(TUint32 aRequestId); |
|
155 |
|
156 /** |
|
157 * Checks if this dialog association has a transaction of the given |
|
158 * type. |
|
159 * |
|
160 * @param aType Transaction type |
|
161 * @param aIsClientTransaction ETrue if searching for a client |
|
162 * transaction, EFalse if searching for a server transaction |
|
163 * @return ETrue if such a transaction exists, EFalse otherwise |
|
164 */ |
|
165 TBool HasTransaction(RStringF aType, TBool aIsClientTransaction); |
|
166 |
|
167 /** |
|
168 * The connection used by dialog association has been lost. |
|
169 * Those classes derived from CSIPDialogAssocImplementation, which can contain |
|
170 * refreshes must implement this function for terminating the refresh. |
|
171 */ |
|
172 virtual void ConnectionLost(); |
|
173 |
|
174 /** |
|
175 * Makes a copy of aHeader and adds it into aElements and also into |
|
176 * headerCleanup. |
|
177 * @param aHeader SIP header |
|
178 * @param aElements Message elements |
|
179 * @param aHeaderCleanup Information to detach and delete the copy of |
|
180 * aHeader from aElements in case leave occurs. |
|
181 */ |
|
182 static void CopyHeaderL(const CSIPHeaderBase& aHeader, |
|
183 CSIPMessageElements& aElements, |
|
184 TMessageHeaderCleanup& aHeaderCleanup); |
|
185 |
|
186 protected: |
|
187 |
|
188 /* |
|
189 * Constructor |
|
190 */ |
|
191 CSIPDialogAssocImplementation(CSIPDialogAssocBase& aAssoc, |
|
192 CSIPDialog& aDialog); |
|
193 void ConstructL(RStringF aType); |
|
194 void ConstructL(RStringF aType, CSIPServerTransaction& aTransaction); |
|
195 |
|
196 private: // Data |
|
197 |
|
198 //Dialog association type |
|
199 RStringF iType; |
|
200 |
|
201 CSIPDialogAssocBase& iAssoc; |
|
202 |
|
203 CSIPDialog& iDialog; |
|
204 |
|
205 //Existing transactions that are related to this dialog association. |
|
206 //CSIPDialogAssocImplementation doesn't own them. |
|
207 RPointerArray<CSIPTransactionBase> iTransactions; |
|
208 |
|
209 TBool iStringPoolOpened; |
|
210 |
|
211 private: // For testing purposes |
|
212 |
|
213 UNIT_TEST(CSIPInviteDialogAssoc_Test) |
|
214 }; |
|
215 |
|
216 #endif |