1 /* |
|
2 * Copyright (c) 2008 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: Implementation for RProperty where conversation view login event handled. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "cimcvapplogineventlistener.h" |
|
22 #include "cimcvengine.h" |
|
23 #include "cimcvappui.h" |
|
24 #include "imconnectionproviderconsts.h" |
|
25 #include <imcvuiapp.rsg> |
|
26 #include "cimcvappwaitnote.h" |
|
27 #include "mimcvenginemessagehandler.h" |
|
28 |
|
29 //system includes |
|
30 #include <avkon.hrh> |
|
31 #include <aknnotewrappers.h> |
|
32 |
|
33 #include <StringLoader.h> |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // -------------------------------------------------------------------------- |
|
38 // CIMCVAppLoginEventListener::CIMCVAppLoginEventListener |
|
39 // -------------------------------------------------------------------------- |
|
40 // |
|
41 CIMCVAppLoginEventListener::CIMCVAppLoginEventListener( CIMCVEngine& aEngine, |
|
42 CIMCVAppUi& aAppUi ) |
|
43 : CActive( CActive::EPriorityStandard ), |
|
44 iEngine( aEngine ), |
|
45 iAppUi( aAppUi ) |
|
46 { |
|
47 CActiveScheduler::Add( this ); |
|
48 } |
|
49 |
|
50 // -------------------------------------------------------------------------- |
|
51 // CIMCVAppLoginEventListener::ConstructL |
|
52 // -------------------------------------------------------------------------- |
|
53 // |
|
54 void CIMCVAppLoginEventListener::ConstructL( const TDesC& aUserId ) |
|
55 { |
|
56 iUserId = aUserId.AllocL(); |
|
57 |
|
58 RProperty::Set(KIMPropertyUid, KIMCCHLauncher, EMecoCV ); //0 reset property |
|
59 RProperty::Set(KIMPropertyUid, KIMCCHLauncherId, *iUserId ); //0 reset property |
|
60 RProperty::Set(KIMPropertyUid, KIMCCHLauncherErr, 0 ); //0 reset property |
|
61 User::LeaveIfError( iProperty.Attach(KIMPropertyUid, KIMCCHLauncherErr) ); |
|
62 } |
|
63 |
|
64 |
|
65 // -------------------------------------------------------------------------- |
|
66 // CIMCVAppLoginEventListener::NewL |
|
67 // -------------------------------------------------------------------------- |
|
68 // |
|
69 CIMCVAppLoginEventListener* CIMCVAppLoginEventListener::NewL(CIMCVEngine& aEngine, |
|
70 CIMCVAppUi& aAppUi, |
|
71 const TDesC& aUserId ) |
|
72 { |
|
73 CIMCVAppLoginEventListener* self = new(ELeave) CIMCVAppLoginEventListener( aEngine, aAppUi ); |
|
74 CleanupStack::PushL(self); |
|
75 self->ConstructL(aUserId); |
|
76 CleanupStack::Pop(self); |
|
77 return self; |
|
78 } |
|
79 // --------------------------------------------------------- |
|
80 // CIMCVAppLoginEventListener::~CIMCVAppLoginEventListener() |
|
81 // C++ Destructor |
|
82 // --------------------------------------------------------- |
|
83 // |
|
84 CIMCVAppLoginEventListener::~CIMCVAppLoginEventListener() |
|
85 { |
|
86 |
|
87 //reset all properties |
|
88 RProperty::Set(KIMPropertyUid, KIMCCHLauncher, EMecoCV ); //0 reset property |
|
89 RProperty::Set(KIMPropertyUid, KIMCCHLauncherErr, 0 ); //0 reset property |
|
90 |
|
91 if (iWaitDialog) |
|
92 { |
|
93 delete iWaitDialog; |
|
94 iWaitDialog = NULL; |
|
95 } |
|
96 |
|
97 |
|
98 if (iUserId) |
|
99 { |
|
100 RProperty::Set(KIMPropertyUid, KIMCCHLauncherId, *iUserId ); //0 reset property |
|
101 delete iUserId; |
|
102 iUserId = NULL; |
|
103 } |
|
104 |
|
105 Cancel(); // Cancel any request, if outstanding |
|
106 iProperty.Close(); // Destroy the property object |
|
107 } |
|
108 // --------------------------------------------------------- |
|
109 // CIMCVAppLoginEventListener::RunL() |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 void CIMCVAppLoginEventListener::RunL() |
|
113 { |
|
114 |
|
115 TInt eventValue = 0; |
|
116 |
|
117 TInt error = RProperty::Get(KIMPropertyUid,KIMCCHLauncherErr, eventValue ); |
|
118 |
|
119 if (error) |
|
120 { |
|
121 iErr = KErrGeneral; |
|
122 User::Leave( error ); |
|
123 } |
|
124 |
|
125 switch (eventValue) |
|
126 { |
|
127 case ESuccess: |
|
128 //login is successfull; |
|
129 // hide wait note |
|
130 if ( iWaitVisible ) |
|
131 { |
|
132 TRAPD(err,LoginCompletedL() ); |
|
133 if ( err != KErrNone ) |
|
134 { |
|
135 User::Leave( err ); |
|
136 } |
|
137 iWaitVisible = EFalse; |
|
138 |
|
139 //iEngine.DeleteContextL(); |
|
140 //iEngine.CreateContextL(); |
|
141 iEngine.MessageHandler().SubscribePresenceL( *iUserId ); |
|
142 iErr = KErrNone; |
|
143 } |
|
144 break; |
|
145 |
|
146 case EInvalid: |
|
147 //this user is not in the fetched contact list |
|
148 //hence show the note and close the coversation view |
|
149 // hide wait note |
|
150 if ( iWaitVisible ) |
|
151 { |
|
152 TRAPD(err,LoginCompletedL() ); |
|
153 if ( err != KErrNone ) |
|
154 { |
|
155 User::Leave( err ); |
|
156 } |
|
157 iWaitVisible = EFalse; |
|
158 } |
|
159 //iEngine.DeleteContextL(); |
|
160 //iEngine.CreateContextL(); |
|
161 iErr = KErrBadHandle; |
|
162 break; |
|
163 |
|
164 case EGeneral: |
|
165 //some error in logging |
|
166 // hide wait note |
|
167 if ( iWaitVisible ) |
|
168 { |
|
169 TRAPD(err,LoginCompletedL() ); |
|
170 if ( err != KErrNone ) |
|
171 { |
|
172 User::Leave( err ); |
|
173 } |
|
174 iWaitVisible = EFalse; |
|
175 } |
|
176 iErr = KErrGeneral; |
|
177 |
|
178 break; |
|
179 |
|
180 default: |
|
181 iErr = KErrGeneral; |
|
182 break; |
|
183 |
|
184 } |
|
185 |
|
186 error = RProperty::Set(KIMPropertyUid,KIMCCHLauncherErr, 0 ); |
|
187 |
|
188 } |
|
189 // --------------------------------------------------------- |
|
190 // CIMCVAppLoginEventListener::RunL() |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 void CIMCVAppLoginEventListener::DoCancel() |
|
194 { |
|
195 iProperty.Cancel(); |
|
196 } |
|
197 // --------------------------------------------------------- |
|
198 // CIMCVAppLoginEventListener::StartListening() |
|
199 // --------------------------------------------------------- |
|
200 // |
|
201 void CIMCVAppLoginEventListener::StartListening() |
|
202 { |
|
203 if(!IsActive() ) |
|
204 { |
|
205 iProperty.Subscribe(iStatus); |
|
206 SetActive(); // Tell scheduler a request is active |
|
207 } |
|
208 } |
|
209 |
|
210 |
|
211 // --------------------------------------------------------- |
|
212 // CIMCVAppLoginEventListener::StopListening() |
|
213 // --------------------------------------------------------- |
|
214 // |
|
215 void CIMCVAppLoginEventListener::StopListening() |
|
216 { |
|
217 if(IsActive() ) |
|
218 { |
|
219 Cancel(); // Cancel any request, if outstanding |
|
220 } |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------- |
|
225 // CIMCVAppLoginEventListener::LoginL |
|
226 // (other items were commented in a header). |
|
227 // --------------------------------------------------------- |
|
228 |
|
229 TInt CIMCVAppLoginEventListener::LoginL() |
|
230 { |
|
231 |
|
232 if( !iWaitVisible ) |
|
233 { |
|
234 // launch the wait note |
|
235 iWaitVisible = ETrue; |
|
236 |
|
237 //reset the error |
|
238 iErr = KErrNone; |
|
239 |
|
240 MIMCVEngineCchHandler& cchHandler = iEngine.CCHHandler(); |
|
241 |
|
242 StartListening(); |
|
243 |
|
244 cchHandler.EnableService(); |
|
245 |
|
246 // load the promp from lOC file + server name |
|
247 HBufC* prompt = StringLoader::LoadLC( R_SERVTAB_LOGIN_ONGOING, |
|
248 iEngine.ServiceName() ); |
|
249 |
|
250 iWaitDialog = CIMCVAppWaitNote::ShowWaitNoteL( |
|
251 *prompt, |
|
252 ETrue ); |
|
253 |
|
254 CleanupStack::PopAndDestroy( prompt ); |
|
255 |
|
256 // start capturing the events |
|
257 iAppUi.CaptureEventsL(); |
|
258 |
|
259 if ( !iWait.IsStarted() ) |
|
260 { |
|
261 iWait.Start(); // CSI: 10 # iWait is not an active object |
|
262 } |
|
263 |
|
264 delete iWaitDialog; |
|
265 |
|
266 iWaitDialog = NULL; |
|
267 |
|
268 StopListening(); |
|
269 |
|
270 } |
|
271 |
|
272 RProperty::Set(KIMPropertyUid, KIMCCHLauncher, 0 ); //0 reset property |
|
273 RProperty::Set(KIMPropertyUid, KIMCCHLauncherId, KNullDesC ); //0 reset property |
|
274 RProperty::Set(KIMPropertyUid, KIMCCHLauncherErr, 0 ); //0 reset property |
|
275 |
|
276 return iErr; |
|
277 |
|
278 } |
|
279 |
|
280 |
|
281 // --------------------------------------------------------- |
|
282 // CIMCVAppLoginEventListener::LoginCompletedL |
|
283 // (other items were commented in a header). |
|
284 // --------------------------------------------------------- |
|
285 // |
|
286 void CIMCVAppLoginEventListener::LoginCompletedL() |
|
287 { |
|
288 if( iWait.IsStarted() ) |
|
289 { |
|
290 iWait.AsyncStop(); |
|
291 } |
|
292 // stop capturing the events |
|
293 iAppUi.ReleaseCapturingL(); |
|
294 |
|
295 } |
|
296 |
|
297 |
|
298 |
|
299 // --------------------------------------------------------- |
|
300 // CIMCVAppLoginEventListener::SetUserIdL |
|
301 // (other items were commented in a header). |
|
302 // --------------------------------------------------------- |
|
303 // |
|
304 void CIMCVAppLoginEventListener::SetUserIdL( const TDesC& aUserId ) |
|
305 { |
|
306 delete iUserId; |
|
307 iUserId = NULL; |
|
308 iUserId = aUserId.AllocL(); |
|
309 |
|
310 RProperty::Set(KIMPropertyUid, KIMCCHLauncher, EMecoCV ); //0 reset property |
|
311 RProperty::Set(KIMPropertyUid, KIMCCHLauncherId, *iUserId ); //0 reset property |
|
312 RProperty::Set(KIMPropertyUid, KIMCCHLauncherErr, 0 ); //0 reset property |
|
313 } |
|
314 |
|
315 // End of File |
|
316 |
|