|
1 /* |
|
2 * Copyright (c) 2005 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mceinevent.h" |
|
22 #include "mceinrefer.h" |
|
23 #include "mceitcsender.h" |
|
24 #include "mceserial.h" |
|
25 #include "mceclilogs.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CMceInRefer::~CMceInRefer |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CMceInRefer::~CMceInRefer() |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CMceInRefer::AcceptL |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CMceInEvent* CMceInRefer::AcceptL() |
|
44 { |
|
45 MCECLI_DEBUG("CMceInRefer::AcceptL, Entry"); |
|
46 TState state = State(); |
|
47 MCECLI_DEBUG_EVENTSTATE( "state", state ); |
|
48 |
|
49 User::LeaveIfError( State() == EIdle ? KErrNone : KErrNotReady ); |
|
50 if ( ReferEvent() ) |
|
51 { |
|
52 static_cast< CMceInEvent* >( ReferEvent() )->AcceptL(); |
|
53 |
|
54 // resolve new state |
|
55 iState = ResolveStateL(); |
|
56 } |
|
57 else |
|
58 { |
|
59 TMceIds ids; |
|
60 PrepareForITC( ids ); |
|
61 ids.iState = State(); |
|
62 iSender->SendL( ids, EMceItcAcceptEvent ); |
|
63 //update the state |
|
64 iState = static_cast< TState >( ids.iState ); |
|
65 } |
|
66 state = State(); |
|
67 MCECLI_DEBUG_EVENTSTATE( "CMceInRefer::AcceptL, after ITC, state", state ); |
|
68 MCECLI_DEBUG("CMceInRefer::AcceptL, Exit"); |
|
69 |
|
70 return static_cast< CMceInEvent* >( TransferEventOwnership() ); |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMceInRefer::RejectL |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 EXPORT_C void CMceInRefer::RejectL() |
|
78 { |
|
79 MCECLI_DEBUG("CMceInRefer::RejectL, Entry"); |
|
80 TState state = State(); |
|
81 MCECLI_DEBUG_EVENTSTATE( "state", state ); |
|
82 |
|
83 User::LeaveIfError( State() == EIdle ? KErrNone : KErrNotReady ); |
|
84 if ( ReferEvent() ) |
|
85 { |
|
86 static_cast< CMceInEvent* >( ReferEvent() )->RejectL(); |
|
87 // resolve new state |
|
88 iState = ResolveStateL(); |
|
89 } |
|
90 else |
|
91 { |
|
92 TMceIds ids; |
|
93 PrepareForITC( ids ); |
|
94 ids.iState = State(); |
|
95 iSender->SendL( ids, EMceItcRejectEvent ); |
|
96 //update the state |
|
97 iState = static_cast<TState>( ids.iState ); |
|
98 } |
|
99 state = State(); |
|
100 MCECLI_DEBUG_EVENTSTATE( "CMceInRefer::RejectL, after ITC, state", state ); |
|
101 MCECLI_DEBUG("CMceInRefer::RejectL, Exit"); |
|
102 |
|
103 } |
|
104 |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CMceInRefer::RespondL |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 EXPORT_C CMceInEvent* CMceInRefer::RespondL( |
|
111 const TDesC8& aReason, |
|
112 TUint32 aCode, |
|
113 CDesC8Array* aHeaders, |
|
114 HBufC8* aContentType, |
|
115 HBufC8* aContent ) |
|
116 { |
|
117 MCECLI_DEBUG("CMceInRefer::RespondL, Entry"); |
|
118 TState state = State(); |
|
119 MCECLI_DEBUG_EVENTSTATE( "state", state ); |
|
120 MCECLI_DEBUG_SVALUE( "reason", aReason ); |
|
121 MCECLI_DEBUG_DVALUE( "code", aCode ); |
|
122 |
|
123 |
|
124 User::LeaveIfError( State() == EIdle ? KErrNone : KErrNotReady ); |
|
125 User::LeaveIfError( |
|
126 ( aContentType && aContent ) || !( aContentType || aContent ) ? |
|
127 KErrNone : KErrArgument ); |
|
128 |
|
129 if ( ReferEvent() ) |
|
130 { |
|
131 static_cast< CMceInEvent* >( ReferEvent() )-> RespondL( aReason, |
|
132 aCode, |
|
133 aHeaders, |
|
134 aContentType, |
|
135 aContent ); |
|
136 // resolve new state |
|
137 iState = ResolveStateL(); |
|
138 } |
|
139 else |
|
140 { |
|
141 //copy reason |
|
142 HBufC8* reason = aReason.AllocLC(); |
|
143 //create reply |
|
144 CMceMsgSIPReply* reply = new (ELeave) CMceMsgSIPReply( *reason, |
|
145 aCode, |
|
146 *aHeaders, |
|
147 *aContentType ); |
|
148 CleanupStack::PushL( reply ); |
|
149 |
|
150 TMceIds ids; |
|
151 PrepareForITC( ids ); |
|
152 ids.iState = State(); |
|
153 |
|
154 iSender->SendL( ids, EMceItcRespondEvent , *reply, aContent ); |
|
155 |
|
156 //update the state |
|
157 iState = static_cast<TState>( ids.iState ); |
|
158 |
|
159 //cleanup |
|
160 CleanupStack::PopAndDestroy( reply ); |
|
161 CleanupStack::PopAndDestroy( reason ); |
|
162 delete aHeaders; |
|
163 delete aContentType; |
|
164 } |
|
165 state = State(); |
|
166 MCECLI_DEBUG_EVENTSTATE( "CMceInRefer::RespondL, after ITC, state", state ); |
|
167 MCECLI_DEBUG("CMceInRefer::RespondL, Exit"); |
|
168 |
|
169 return ( iState == EPending ? |
|
170 static_cast< CMceInEvent* >( TransferEventOwnership() ) : NULL ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CMceInRefer::NewL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 CMceInRefer* CMceInRefer::NewL( CMceManager& aManager, |
|
178 TUint32 aProfileId, |
|
179 CMceMsgSIPEvent& aEventMsg, |
|
180 CMceInEvent* aInEvent ) |
|
181 { |
|
182 MCECLI_DEBUG("CMceInRefer::NewL, Entry"); |
|
183 MCECLI_DEBUG_DVALUE("profile", aProfileId ); |
|
184 |
|
185 CMceInRefer* self = new (ELeave) CMceInRefer( |
|
186 aManager, |
|
187 aProfileId, |
|
188 aEventMsg.Id(), |
|
189 aEventMsg.DialogId(), |
|
190 static_cast< TType > ( aEventMsg.ReferType() ) ); |
|
191 |
|
192 CleanupStack::PushL( self ); |
|
193 |
|
194 HBufC8* referTo = aEventMsg.ReferTo(); |
|
195 CleanupStack::PushL( referTo ); |
|
196 HBufC8* recipient = aEventMsg.Recipient(); |
|
197 CleanupStack::PushL( recipient ); |
|
198 HBufC8* originator = aEventMsg.Originator(); |
|
199 CleanupStack::PushL( originator ); |
|
200 |
|
201 self->ConstructL( referTo, |
|
202 recipient, |
|
203 originator, |
|
204 aInEvent ); |
|
205 |
|
206 CleanupStack::Pop( originator ); |
|
207 CleanupStack::Pop( recipient ); |
|
208 CleanupStack::Pop( referTo ); |
|
209 |
|
210 CleanupStack::Pop( self ); |
|
211 MCECLI_DEBUG("CMceInRefer::NewL, Exit"); |
|
212 return self; |
|
213 } |
|
214 |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CMceInRefer::CMceInRefer |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 CMceInRefer::CMceInRefer( CMceManager& aManager, |
|
221 TUint32 aProfileId, |
|
222 TUint32 aId, |
|
223 TUint32 aDialogId, |
|
224 TType aType ) |
|
225 : CMceRefer( aManager, aProfileId, aDialogId, aType ) |
|
226 { |
|
227 iId = aId; |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CMceInRefer::ConstructL |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CMceInRefer::ConstructL( HBufC8* aReferTo, |
|
235 HBufC8* aRecipient, |
|
236 HBufC8* aOrginator, |
|
237 CMceInEvent* aInEvent ) |
|
238 { |
|
239 iEvent = aInEvent; |
|
240 CMceRefer::ConstructL( aRecipient, aReferTo, aOrginator, NULL ); |
|
241 iEvent = NULL; |
|
242 iOwnedEvent = aInEvent; |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CMceInRefer::IsInRefer |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TBool CMceInRefer::IsInRefer() const |
|
250 { |
|
251 return ETrue; |
|
252 } |
|
253 |