|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : TransactionMgr.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipAssert.h" |
|
22 |
|
23 #include "TransactionMgr.h" |
|
24 #include "NormalClientTa.h" |
|
25 #include "InviteClientTa.h" |
|
26 #include "NormalServerTa.h" |
|
27 #include "InviteServerTa.h" |
|
28 #include "NormalClientTaStates.h" |
|
29 #include "InviteClientTaStates.h" |
|
30 #include "NormalServerTaStates.h" |
|
31 #include "InviteServerTaStates.h" |
|
32 |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CTransactionMgr::NewL |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CTransactionMgr* CTransactionMgr::NewL(MTimerManager& aTimers, |
|
39 MTransactionStore& aTransactionStore) |
|
40 { |
|
41 CTransactionMgr* self = new (ELeave) CTransactionMgr(aTimers, |
|
42 aTransactionStore); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CTransactionMgr::CTransactionMgr |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CTransactionMgr::CTransactionMgr(MTimerManager& aTimers, |
|
54 MTransactionStore& aTransactionStore) : |
|
55 iTimers(aTimers), |
|
56 iTransactionStore(aTransactionStore) |
|
57 { |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CTransactionMgr::ConstructL |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CTransactionMgr::ConstructL() |
|
65 { |
|
66 //Invite client transaction states |
|
67 iInviteClientTa_Calling = new (ELeave) CInviteClientTa_Calling; |
|
68 iInviteClientTa_Proceeding = new (ELeave) CInviteClientTa_Proceeding; |
|
69 iInviteClientTa_Completed = new (ELeave) CInviteClientTa_Completed; |
|
70 |
|
71 iInviteClientTa_Calling->SetNeighbourStates(*iInviteClientTa_Proceeding, |
|
72 *iInviteClientTa_Completed); |
|
73 iInviteClientTa_Proceeding->SetNeighbourStates(*iInviteClientTa_Completed); |
|
74 |
|
75 |
|
76 //Non-Invite client transaction states |
|
77 iNormalClientTa_Trying = new (ELeave) CNormalClientTa_Trying; |
|
78 iNormalClientTa_Proceeding = new (ELeave) CNormalClientTa_Proceeding; |
|
79 iNormalClientTa_Completed = new (ELeave) CNormalClientTa_Completed; |
|
80 |
|
81 iNormalClientTa_Trying->SetNeighbourStates(*iNormalClientTa_Proceeding, |
|
82 *iNormalClientTa_Completed); |
|
83 iNormalClientTa_Proceeding->SetNeighbourStates(*iNormalClientTa_Completed); |
|
84 |
|
85 |
|
86 //Invite server transaction states |
|
87 iInviteServerTa_Proceeding = new (ELeave) CInviteServerTa_Proceeding; |
|
88 iInviteServerTa_Completed = new (ELeave) CInviteServerTa_Completed; |
|
89 iInviteServerTa_Confirmed = new (ELeave) CInviteServerTa_Confirmed; |
|
90 iInviteServerTa_Sending2xx = new (ELeave) CInviteServerTa_Sending2xx; |
|
91 |
|
92 iInviteServerTa_Proceeding->SetNeighbourStates(*iInviteServerTa_Completed, |
|
93 *iInviteServerTa_Sending2xx); |
|
94 iInviteServerTa_Completed->SetNeighbourStates(*iInviteServerTa_Confirmed); |
|
95 |
|
96 |
|
97 //Non-Invite server transaction states |
|
98 iNormalServerTa_Trying = new (ELeave) CNormalServerTa_Trying; |
|
99 iNormalServerTa_Proceeding = new (ELeave) CNormalServerTa_Proceeding; |
|
100 iNormalServerTa_Completed = new (ELeave) CNormalServerTa_Completed; |
|
101 |
|
102 iNormalServerTa_Trying->SetNeighbourStates(*iNormalServerTa_Proceeding, |
|
103 *iNormalServerTa_Completed); |
|
104 iNormalServerTa_Proceeding->SetNeighbourStates(*iNormalServerTa_Completed); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CTransactionMgr::~CTransactionMgr |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CTransactionMgr::~CTransactionMgr() |
|
112 { |
|
113 delete iInviteClientTa_Calling; |
|
114 delete iInviteClientTa_Proceeding; |
|
115 delete iInviteClientTa_Completed; |
|
116 |
|
117 delete iNormalClientTa_Trying; |
|
118 delete iNormalClientTa_Proceeding; |
|
119 delete iNormalClientTa_Completed; |
|
120 |
|
121 delete iInviteServerTa_Proceeding; |
|
122 delete iInviteServerTa_Completed; |
|
123 delete iInviteServerTa_Confirmed; |
|
124 delete iInviteServerTa_Sending2xx; |
|
125 |
|
126 delete iNormalServerTa_Trying; |
|
127 delete iNormalServerTa_Proceeding; |
|
128 delete iNormalServerTa_Completed; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CTransactionMgr::CreateTransactionL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 CTransactionBase* |
|
136 CTransactionMgr::CreateTransactionL(CTransactionBase::TTransactionType aType, |
|
137 CUserAgentBase& aUserAgent, |
|
138 CTransmitter& aTransmitter, |
|
139 TTimerValues& aTimerValues, |
|
140 TBool aRetransmitInvite) |
|
141 { |
|
142 CTransactionBase* ta = NULL; |
|
143 |
|
144 switch (aType) |
|
145 { |
|
146 case CTransactionBase::KServerTransaction: |
|
147 { |
|
148 ta = CNormalServerTransaction::NewL(aUserAgent, |
|
149 aTransmitter, |
|
150 iTimers, |
|
151 *iNormalServerTa_Trying, |
|
152 aTimerValues); |
|
153 break; |
|
154 } |
|
155 |
|
156 case CTransactionBase::KServerInviteTransaction: |
|
157 { |
|
158 ta = CInviteServerTransaction::NewL(aUserAgent, |
|
159 aTransmitter, |
|
160 iTimers, |
|
161 *iInviteServerTa_Proceeding, |
|
162 aTimerValues); |
|
163 break; |
|
164 } |
|
165 |
|
166 case CTransactionBase::KClientTransaction: |
|
167 { |
|
168 ta = CNormalClientTransaction::NewL(aUserAgent, |
|
169 aTransmitter, |
|
170 iTimers, |
|
171 *iNormalClientTa_Trying, |
|
172 aTimerValues, |
|
173 iTransactionStore); |
|
174 break; |
|
175 } |
|
176 |
|
177 case CTransactionBase::KClientInviteTransaction: |
|
178 { |
|
179 ta = CInviteClientTransaction::NewL(aUserAgent, |
|
180 aTransmitter, |
|
181 iTimers, |
|
182 *iInviteClientTa_Calling, |
|
183 aTimerValues, |
|
184 iTransactionStore, |
|
185 aRetransmitInvite); |
|
186 break; |
|
187 } |
|
188 |
|
189 default: |
|
190 User::Leave(KErrArgument); |
|
191 } |
|
192 return ta; |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CTransactionMgr::IsPossibleToSendCancel |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 TBool CTransactionMgr::IsPossibleToSendCancel( |
|
200 const CTransactionBase& aTransaction) const |
|
201 { |
|
202 return (!aTransaction.HasTerminated() && |
|
203 (static_cast<const CTransaction&>(aTransaction).State() == |
|
204 iInviteClientTa_Proceeding)); |
|
205 } |