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