|
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 : TransactionTimer.cpp |
|
15 // Part of : Transaction |
|
16 // Version : SIP/5.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "SipAssert.h" |
|
22 #include "sipstrings.h" |
|
23 #include "sipresponse.h" |
|
24 #include "TransactionTimer.h" |
|
25 #include "ServerTransaction.h" |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CTransactionTimer::CTransactionTimer |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CTransactionTimer::CTransactionTimer(MTimerManager& aTimerMgr, |
|
32 MExpirationHandler* aObserver, |
|
33 TUint32 aDuration) : |
|
34 CTimerBase(aTimerMgr, aObserver, aDuration) |
|
35 { |
|
36 __ASSERT_DEBUG(aObserver, |
|
37 User::Panic(_L("CTransactionTimer::CTransactionTimer() aObserver = 0"), |
|
38 KErrArgument)); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CTimerRetransmit::NewL |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CTimerRetransmit* CTimerRetransmit::NewL(MTimerManager& aTimerMgr, |
|
46 MExpirationHandler* aObserver, |
|
47 TUint32 aDuration) |
|
48 { |
|
49 CTimerRetransmit* self = new (ELeave) CTimerRetransmit(aTimerMgr, |
|
50 aObserver, |
|
51 aDuration); |
|
52 CleanupStack::PushL(self); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CTimerRetransmit::CTimerRetransmit |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CTimerRetransmit::CTimerRetransmit(MTimerManager& aTimerMgr, |
|
63 MExpirationHandler* aObserver, |
|
64 TUint32 aDuration) : |
|
65 CTransactionTimer(aTimerMgr, aObserver, aDuration) |
|
66 { |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CTimerRetransmit::ExpiredL |
|
71 // Retransmit a SIP message, unless CTransmitter is sending. That happen only if |
|
72 // InviteServerTransaction receives INVITE, sends response and timer G expires |
|
73 // before CTransmitter has finished sending. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CTimerRetransmit::ExpiredL(CTransaction& aTransaction, TTimerId aTimerId) |
|
77 { |
|
78 __SIP_ASSERT_LEAVE(aTimerId == iId, KErrArgument); |
|
79 |
|
80 if (!aTransaction.IsTransmitterSending()) |
|
81 { |
|
82 aTransaction.SendToTransmitterL(); |
|
83 } |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CTimerTerminateTa::NewL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CTimerTerminateTa* CTimerTerminateTa::NewL(MTimerManager& aTimerMgr, |
|
91 MExpirationHandler* aObserver, |
|
92 TUint32 aDuration, |
|
93 TInt aReason) |
|
94 { |
|
95 CTimerTerminateTa* self = new (ELeave) CTimerTerminateTa(aTimerMgr, |
|
96 aObserver, |
|
97 aDuration, |
|
98 aReason); |
|
99 CleanupStack::PushL(self); |
|
100 self->ConstructL(); |
|
101 CleanupStack::Pop(self); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CTimerTerminateTa::CTimerTerminateTa |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CTimerTerminateTa::CTimerTerminateTa(MTimerManager& aTimerMgr, |
|
110 MExpirationHandler* aObserver, |
|
111 TUint32 aDuration, |
|
112 TInt aReason) : |
|
113 CTransactionTimer(aTimerMgr, aObserver, aDuration), |
|
114 iReason(aReason) |
|
115 { |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CTimerTerminateTa::ExpiredL |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CTimerTerminateTa::ExpiredL(CTransaction& aTransaction, TTimerId aTimerId) |
|
123 { |
|
124 __SIP_ASSERT_LEAVE(aTimerId == iId, KErrArgument); |
|
125 |
|
126 aTransaction.TerminatedL(iReason); |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CTimerSend100::NewL |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CTimerSend100* CTimerSend100::NewL(MTimerManager& aTimerMgr, |
|
134 MExpirationHandler* aObserver, |
|
135 TUint32 aDuration, |
|
136 CSIPResponse* aResponse, |
|
137 RStringF aTransportProtocol, |
|
138 TSIPTransportParams& aTransportParams) |
|
139 { |
|
140 CTimerSend100* self = new (ELeave) CTimerSend100(aTimerMgr, |
|
141 aObserver, |
|
142 aDuration, |
|
143 aTransportProtocol, |
|
144 aTransportParams); |
|
145 CleanupStack::PushL(self); |
|
146 self->ConstructL(); |
|
147 self->iResponse = aResponse; |
|
148 CleanupStack::Pop(self); |
|
149 return self; |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CTimerSend100::CTimerSend100 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 CTimerSend100::CTimerSend100(MTimerManager& aTimerMgr, |
|
157 MExpirationHandler* aObserver, |
|
158 TUint32 aDuration, |
|
159 RStringF aTransportProtocol, |
|
160 TSIPTransportParams& aTransportParams) : |
|
161 CTransactionTimer(aTimerMgr, aObserver, aDuration), |
|
162 iTransportParams(aTransportParams) |
|
163 { |
|
164 iTransportProtocol = aTransportProtocol.Copy(); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CTimerSend100::~CTimerSend100 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 CTimerSend100::~CTimerSend100() |
|
172 { |
|
173 delete iResponse; |
|
174 iTransportProtocol.Close(); |
|
175 } |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CTimerSend100::ExpiredL |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 void CTimerSend100::ExpiredL(CTransaction& aTransaction, TTimerId aTimerId) |
|
182 { |
|
183 __SIP_ASSERT_LEAVE(aTimerId == iId, KErrArgument); |
|
184 |
|
185 CSIPResponse* resp = iResponse; |
|
186 iResponse = NULL; |
|
187 CleanupStack::PushL(resp); |
|
188 |
|
189 //Causes transaction to delete this timer, so don't refer it afterwards. |
|
190 aTransaction.SendResponseL(resp, iTransportProtocol, iTransportParams); |
|
191 CleanupStack::Pop(resp); |
|
192 } |