|
1 /* |
|
2 * Copyright (c) 2007-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: Handles interaction with setup wizard implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include <FreestyleEmailUi.rsg> |
|
22 #include <aknnotewrappers.h> |
|
23 #include <centralrepository.h> |
|
24 #include <StringLoader.h> |
|
25 //<cmail> |
|
26 #include "CFSMailClient.h" |
|
27 //</cmail> |
|
28 |
|
29 // INTERNAL INCLUDE FILES |
|
30 #include "FreestyleEmailUiWizardObserver.h" |
|
31 #include "FreestyleEmailUiLauncherGridVisualiser.h" |
|
32 #include "FreestyleEmailCenRepHandler.h" |
|
33 #include "FreestyleEmailUiUtilities.h" |
|
34 |
|
35 |
|
36 // CONSTANT VALUES |
|
37 |
|
38 |
|
39 // ================= MEMBER FUNCTIONS ========================================== |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CFSEmailUiWizardObserver::CFSEmailUiWizardObserver |
|
42 // ----------------------------------------------------------------------------- |
|
43 CFSEmailUiWizardObserver::CFSEmailUiWizardObserver( |
|
44 CFreestyleEmailUiAppUi* aAppUi, |
|
45 CFSEmailUiLauncherGridVisualiser* aMainUiGridVisualiser ) |
|
46 : iAppUi( aAppUi ), iMainUiGridVisualiser( aMainUiGridVisualiser ), |
|
47 iProcessComplete( ETrue ), iForegroundAfterWizardMessage( EFalse ), |
|
48 iInformAboutParams( EFalse ), iNewMailboxEventHandlingAllowed( EFalse ), |
|
49 iNewMailboxCreated( EFalse ) |
|
50 { |
|
51 FUNC_LOG; |
|
52 |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CFSMailPluginManager::~CFSMailPluginManager |
|
57 // ----------------------------------------------------------------------------- |
|
58 CFSEmailUiWizardObserver::~CFSEmailUiWizardObserver() |
|
59 { |
|
60 FUNC_LOG; |
|
61 // just in case: dismiss possible wait note |
|
62 if ( iMainUiGridVisualiser ) |
|
63 { |
|
64 iMainUiGridVisualiser->SetWizardWaitnoteShown( EFalse ); |
|
65 } |
|
66 |
|
67 delete iWaitNote; |
|
68 iWaitNote = NULL; |
|
69 } |
|
70 |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CFreestyleEmailUiWizardObserver::NewLC |
|
74 // ----------------------------------------------------------------------------- |
|
75 CFSEmailUiWizardObserver* CFSEmailUiWizardObserver::NewLC( |
|
76 CFreestyleEmailUiAppUi* aAppUi, |
|
77 CFSEmailUiLauncherGridVisualiser* aMainUiGridVisualiser ) |
|
78 { |
|
79 FUNC_LOG; |
|
80 CFSEmailUiWizardObserver* self = |
|
81 new (ELeave) CFSEmailUiWizardObserver( aAppUi, aMainUiGridVisualiser ); |
|
82 CleanupStack:: PushL( self ); |
|
83 self->ConstructL(); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CFSEmailUiWizardObserver::NewL |
|
89 // ----------------------------------------------------------------------------- |
|
90 CFSEmailUiWizardObserver* CFSEmailUiWizardObserver::NewL( |
|
91 CFreestyleEmailUiAppUi* aAppUi, |
|
92 CFSEmailUiLauncherGridVisualiser* aMainUiGridVisualiser ) |
|
93 { |
|
94 FUNC_LOG; |
|
95 CFSEmailUiWizardObserver* self = |
|
96 CFSEmailUiWizardObserver::NewLC( aAppUi, aMainUiGridVisualiser ); |
|
97 CleanupStack:: Pop( self ); |
|
98 return self; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CFSEmailUiWizardObserver::ConstructL |
|
103 // ----------------------------------------------------------------------------- |
|
104 void CFSEmailUiWizardObserver::ConstructL() |
|
105 { |
|
106 FUNC_LOG; |
|
107 |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CFSEmailUiWizardObserver::DoWizardStartupActionsL() |
|
112 // |
|
113 // Check if there are some params set by a setup wizard in the centrep |
|
114 // location (meaning that we have been launched by a setup wizard) and |
|
115 // inform FW about in that case |
|
116 // ----------------------------------------------------------------------------- |
|
117 void CFSEmailUiWizardObserver::DoWizardStartupActionsL() |
|
118 { |
|
119 FUNC_LOG; |
|
120 |
|
121 // In this case we are not interested of the actual content of the cenrep, |
|
122 // our only interest is that is there something in the specified keys or |
|
123 // not. So to avoid unneccessary stack usage, we keep the size of |
|
124 // accountType buffer in minimum -> cenrep handler returns KErrOverflow |
|
125 // if there is something (and it doesn't fit to buffer). |
|
126 TBuf<1> accountType = KNullDesC(); |
|
127 TBuf<KMaxUidName> centrepStartKey = KNullDesC(); |
|
128 |
|
129 CFSEmailCRHandler* crHandler = iAppUi->GetCRHandler(); |
|
130 if ( !crHandler ) |
|
131 { |
|
132 return; |
|
133 } |
|
134 |
|
135 TInt accountTypeError = crHandler->SetupWizAccountType( accountType ); |
|
136 TInt startKeyError = crHandler->SetupWizCentrepStartKey( centrepStartKey ); |
|
137 |
|
138 |
|
139 |
|
140 // IF accountType had some content and it didn't fit to buffer OR |
|
141 // accountType had some content and it fit to buffer |
|
142 // ==> there was something in accountType |
|
143 // AND |
|
144 // IF startKey had some content and it didn't fit to buffer OR |
|
145 // startKey had some content and it fit to buffer |
|
146 // ==> there was something in startKey |
|
147 if ( ( accountTypeError == KErrOverflow || |
|
148 ( accountTypeError == KErrNone && accountType.Length() > 0 ) ) && |
|
149 ( startKeyError == KErrOverflow || |
|
150 ( startKeyError == KErrNone && centrepStartKey.Length() > 0 ) ) ) |
|
151 { |
|
152 |
|
153 // Launches the "Creating mailbox" wait note - |
|
154 // execution continues in the method StepL() after that. |
|
155 StartWaitNoteL(); |
|
156 } |
|
157 else |
|
158 { |
|
159 } |
|
160 |
|
161 } |
|
162 |
|
163 void CFSEmailUiWizardObserver::HandleMessage( TUint32 /*aClientHandleOfTargetWindowGroup*/, |
|
164 TUid /*aMessageUid*/, |
|
165 const TDesC8& aMessageParameters ) |
|
166 { |
|
167 FUNC_LOG; |
|
168 |
|
169 if ( aMessageParameters.Compare( KNullDesC8 ) == 0 ) |
|
170 { |
|
171 |
|
172 TApaTaskList taskList( CEikonEnv::Static()->WsSession() ); |
|
173 TApaTask task = taskList.FindApp( KFSEmailUiUid ); |
|
174 if ( task.Exists() ) |
|
175 { |
|
176 if ( !iAppUi->IsForeground() ) |
|
177 { |
|
178 // Bring Email UI to foreground |
|
179 |
|
180 iForegroundAfterWizardMessage = ETrue; |
|
181 task.BringToForeground(); |
|
182 } |
|
183 else |
|
184 { |
|
185 // Launches the "Creating mailbox" wait note - |
|
186 // execution continues in the method StepL() after that. |
|
187 TRAPD( err, StartWaitNoteL() ); |
|
188 if ( err != KErrNone ) |
|
189 { |
|
190 } |
|
191 } |
|
192 } |
|
193 } |
|
194 |
|
195 } |
|
196 |
|
197 void CFSEmailUiWizardObserver::HandleForegroundEventL( TBool aForeground ) |
|
198 { |
|
199 FUNC_LOG; |
|
200 |
|
201 // iForegroundAfterWizardMessage flag is turned into ETrue when we have received |
|
202 // a KNullDesC message from mailbox setup wizard in HandleMessage() and if UI is |
|
203 // brought to foreground after that. |
|
204 if ( iForegroundAfterWizardMessage && aForeground ) |
|
205 { |
|
206 iForegroundAfterWizardMessage = EFalse; |
|
207 |
|
208 // launches the "Creating mailbox" wait note - |
|
209 // execution continues in the method StepL() after that. |
|
210 StartWaitNoteL(); |
|
211 } |
|
212 |
|
213 } |
|
214 |
|
215 void CFSEmailUiWizardObserver::StartWaitNoteL() |
|
216 { |
|
217 FUNC_LOG; |
|
218 |
|
219 // This wait note will be dismissed in callback method EventL() |
|
220 iProcessComplete = EFalse; |
|
221 iInformAboutParams = ETrue; |
|
222 iMainUiGridVisualiser->SetWizardWaitnoteShown( ETrue ); |
|
223 |
|
224 TRAPD( waitNoteError, |
|
225 { |
|
226 if ( !iWaitNote ) |
|
227 { |
|
228 iWaitNote = CAknWaitNoteWrapper::NewL(); |
|
229 } |
|
230 |
|
231 iWaitNote->ExecuteL( R_FSE_CREATING_MAILBOX_DIALOG, *this ); |
|
232 // after ExecuteL the execution continues in StepL() |
|
233 } ); |
|
234 |
|
235 if ( waitNoteError != KErrNone ) |
|
236 { |
|
237 |
|
238 // Only reason for the wait note showing to fail should be if we run |
|
239 // out of memory, so there's not much we can do, except give up. So |
|
240 // first reset our internal variables and clear the cenrep data so |
|
241 // that the user data is not left there. |
|
242 iProcessComplete = ETrue; |
|
243 iInformAboutParams = EFalse; |
|
244 iMainUiGridVisualiser->SetWizardWaitnoteShown( EFalse ); |
|
245 |
|
246 iAppUi->GetCRHandler()->ClearWizardParams(); |
|
247 |
|
248 // Our own error note showing is probably not working either, |
|
249 // but let's try it anyway |
|
250 TRAPD( errorNoteError, |
|
251 { |
|
252 TFsEmailUiUtility::ShowGlobalErrorNoteL( R_FREESTYLE_EMAIL_UI_LOGIN_INFO_NOTE_ERROR_MAILBOX_SETUP_TRY_AGAIN ); |
|
253 } ); |
|
254 |
|
255 // If our own error note showing failed, then we leave and let |
|
256 // the system show it's own error note |
|
257 if ( errorNoteError != KErrNone ) |
|
258 { |
|
259 User::Leave( waitNoteError ); |
|
260 } |
|
261 } |
|
262 |
|
263 } |
|
264 |
|
265 void CFSEmailUiWizardObserver::InformFrameworkAboutParamsL() |
|
266 { |
|
267 FUNC_LOG; |
|
268 |
|
269 TInt mailboxConfigError( KErrNone ); |
|
270 // tell framework - and thus the plugin - to check the parameters from centrep |
|
271 TRAPD( wDataAvailableError, |
|
272 { |
|
273 mailboxConfigError = iAppUi->GetMailClient()->WizardDataAvailableL(); |
|
274 } ); |
|
275 |
|
276 // clears the two centrep keys that were passed as parameters to plugins |
|
277 iAppUi->GetCRHandler()->ClearWizardParams(); |
|
278 |
|
279 // The error filtering logic was moved here from CFSMailClient::WizardDataAvailableL. |
|
280 // if an error is received, some called plugin didn't support the mailbox |
|
281 // creation process, or the parameters couldn't be read from central repository. |
|
282 if ( mailboxConfigError != KErrNone || wDataAvailableError != KErrNone ) |
|
283 { |
|
284 |
|
285 // dismiss the wait note |
|
286 iProcessComplete = ETrue; |
|
287 iMainUiGridVisualiser->SetWizardWaitnoteShown( EFalse ); |
|
288 |
|
289 // show an error note |
|
290 TRAP_IGNORE( |
|
291 { |
|
292 TFsEmailUiUtility::ShowGlobalErrorNoteL( R_FREESTYLE_EMAIL_UI_LOGIN_INFO_NOTE_ERROR_MAILBOX_SETUP_TRY_AGAIN ); |
|
293 }); |
|
294 } |
|
295 else |
|
296 { |
|
297 iNewMailboxEventHandlingAllowed = ETrue; |
|
298 } |
|
299 |
|
300 } |
|
301 |
|
302 void CFSEmailUiWizardObserver::EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, |
|
303 TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ ) |
|
304 { |
|
305 FUNC_LOG; |
|
306 |
|
307 switch ( aEvent ) |
|
308 { |
|
309 case TFSEventNewMailbox: |
|
310 { |
|
311 // update grid view now when we have new mailbox created |
|
312 iMainUiGridVisualiser->RefreshLauncherViewL(); |
|
313 |
|
314 if ( iNewMailboxEventHandlingAllowed ) |
|
315 { |
|
316 iNewMailboxEventHandlingAllowed = EFalse; //reset the boolean |
|
317 |
|
318 // dismiss the wait note |
|
319 iProcessComplete = ETrue; |
|
320 iMainUiGridVisualiser->SetWizardWaitnoteShown( EFalse ); |
|
321 |
|
322 // clears the two centrep keys that were passed as parameters to plugins |
|
323 iAppUi->GetCRHandler()->ClearWizardParams(); |
|
324 |
|
325 // <cmail> |
|
326 // new mailbox created -> open its Inbox folder after the |
|
327 // wait dialog is dismissed -> continued in |
|
328 // DialogDismissedL method. |
|
329 // This code needed to be moved because Wait dialog is |
|
330 // still open and prevents the active view from receiving |
|
331 // events. That's why the grid view was not deactivated. |
|
332 iNewMailboxCreated = ETrue; |
|
333 iNewlyCreatedMailboxId = aMailbox; |
|
334 // </cmail> |
|
335 } |
|
336 else |
|
337 { |
|
338 } |
|
339 } |
|
340 break; |
|
341 |
|
342 case TFSEventMailboxCreationFailure: |
|
343 { |
|
344 |
|
345 // dismiss the wait note |
|
346 iProcessComplete = ETrue; |
|
347 iMainUiGridVisualiser->SetWizardWaitnoteShown( EFalse ); |
|
348 |
|
349 // clears the two centrep keys that were passed as parameters to plugins |
|
350 iAppUi->GetCRHandler()->ClearWizardParams(); |
|
351 |
|
352 TRAP_IGNORE( |
|
353 { |
|
354 TFsEmailUiUtility::ShowGlobalErrorNoteL( R_FREESTYLE_EMAIL_UI_LOGIN_INFO_NOTE_ERROR_MAILBOX_SETUP_TRY_AGAIN ); |
|
355 }); |
|
356 } |
|
357 break; |
|
358 } |
|
359 |
|
360 } |
|
361 |
|
362 // |
|
363 // MAknBackgroundProcess methods |
|
364 // |
|
365 void CFSEmailUiWizardObserver::StepL() |
|
366 { |
|
367 FUNC_LOG; |
|
368 // Tell framework that there are parameters in the centrep |
|
369 // with which it can create a new mail account. |
|
370 if ( iInformAboutParams ) |
|
371 { |
|
372 iInformAboutParams = EFalse; //reset the value |
|
373 InformFrameworkAboutParamsL(); |
|
374 } |
|
375 } |
|
376 |
|
377 TBool CFSEmailUiWizardObserver::IsProcessDone() const |
|
378 { |
|
379 FUNC_LOG; |
|
380 return iProcessComplete; |
|
381 } |
|
382 |
|
383 void CFSEmailUiWizardObserver::ProcessFinished() |
|
384 { |
|
385 FUNC_LOG; |
|
386 // nothing here |
|
387 } |
|
388 |
|
389 void CFSEmailUiWizardObserver::DialogDismissedL( TInt aButtonId ) |
|
390 { |
|
391 FUNC_LOG; |
|
392 // <cmail> |
|
393 if ( iNewMailboxCreated ) |
|
394 { |
|
395 // new mailbox created -> open its Inbox folder if Cancel button |
|
396 // not pressed |
|
397 iNewMailboxCreated = EFalse; |
|
398 if ( aButtonId != EAknSoftkeyCancel ) |
|
399 { |
|
400 CFSMailBox* mailBox = iAppUi->GetMailClient()->GetMailBoxByUidL( |
|
401 iNewlyCreatedMailboxId ); |
|
402 CleanupStack::PushL( mailBox ); |
|
403 if ( mailBox ) |
|
404 { |
|
405 TFSMailMsgId inboxFolderId = mailBox->GetStandardFolderId( |
|
406 EFSInbox ); |
|
407 |
|
408 // launch the inbox of the new mailbox |
|
409 TMailListActivationData tmp; |
|
410 tmp.iFolderId = inboxFolderId; |
|
411 tmp.iMailBoxId = iNewlyCreatedMailboxId; |
|
412 const TPckgBuf<TMailListActivationData> pkgOut( tmp ); |
|
413 iAppUi->EnterFsEmailViewL( MailListId, KStartListWithFolderId, |
|
414 pkgOut ); |
|
415 // the App might have been, say, in Attachments list of some |
|
416 // other mailbox but we should not return there with 'Back' |
|
417 // button |
|
418 iAppUi->EraseViewHistory(); |
|
419 } |
|
420 |
|
421 CleanupStack::PopAndDestroy( mailBox ); |
|
422 } |
|
423 } |
|
424 // </cmail> |
|
425 } |
|
426 |
|
427 TInt CFSEmailUiWizardObserver::CycleError( TInt /*aError*/ ) |
|
428 { |
|
429 FUNC_LOG; |
|
430 return KErrNone; |
|
431 } |
|
432 |
|
433 // End of file |
|
434 |