|
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: Implements CAcpDialog methods |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <avkon.rsg> |
|
20 #include <StringLoader.h> |
|
21 #include <AknGlobalNote.h> |
|
22 #include <AknQueryDialog.h> |
|
23 #include <aknnotewrappers.h> |
|
24 #include <AknGlobalMsgQuery.h> |
|
25 #include <accountcreationplugin.rsg> |
|
26 |
|
27 #include "acpdialog.h" |
|
28 #include "accountcreationpluginlogger.h" |
|
29 #include "macpdialogobserver.h" |
|
30 |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CAcpDialog::CAcpDialog |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CAcpDialog::CAcpDialog( MAcpDialogObserver& aObserver ) |
|
37 : CActive ( EPriorityStandard ), |
|
38 iObserver( aObserver ) |
|
39 { |
|
40 CActiveScheduler::Add( this ); |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CAcpDialog::NewL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CAcpDialog* CAcpDialog::NewL( MAcpDialogObserver& aObserver ) |
|
48 { |
|
49 CAcpDialog* self = CAcpDialog::NewLC( aObserver ); |
|
50 CleanupStack::Pop( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CAcpDialog::NewLC |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CAcpDialog* CAcpDialog::NewLC( MAcpDialogObserver& aObserver ) |
|
59 { |
|
60 CAcpDialog* self = new ( ELeave ) CAcpDialog( aObserver ); |
|
61 CleanupStack::PushL( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CAcpDialog::~CAcpDialog |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CAcpDialog::~CAcpDialog() |
|
70 { |
|
71 Cancel(); |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CAcpDialog::LaunchWaitNoteL |
|
76 // Launches a wait note. |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CAcpDialog::LaunchWaitNoteL( TInt aWaitNote ) |
|
80 { |
|
81 ACPLOG( "CAcpDialog::LaunchWaitNoteL begin" ); |
|
82 |
|
83 if ( !IsActive() ) |
|
84 { |
|
85 // Show wait note with appropriate text. |
|
86 HBufC* text = StringLoader::LoadLC( aWaitNote ); |
|
87 iWaitNote = CAknGlobalNote::NewL(); |
|
88 iWaitNote->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL ); |
|
89 iNoteId = iWaitNote->ShowNoteL( |
|
90 iStatus, |
|
91 EAknGlobalWaitNote, |
|
92 *text ); |
|
93 CleanupStack::PopAndDestroy( text ); |
|
94 ACPLOG( " - SetActive();" ); |
|
95 SetActive(); |
|
96 } |
|
97 ACPLOG( "CAcpDialog::LaunchWaitNoteL end" ); |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // CAcpDialog::LaunchWaitNoteL |
|
102 // Launches a wait note with a custom string. |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CAcpDialog::LaunchWaitNoteL( TInt aWaitNote, const TDesC& aString ) |
|
106 { |
|
107 ACPLOG( "CAcpDialog::LaunchWaitNoteL begin" ); |
|
108 |
|
109 if ( !IsActive() ) |
|
110 { |
|
111 // Show wait note with appropriate text. |
|
112 HBufC* text = StringLoader::LoadLC( aWaitNote, aString ); |
|
113 iWaitNote = CAknGlobalNote::NewL(); |
|
114 iWaitNote->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL ); |
|
115 iNoteId = iWaitNote->ShowNoteL( |
|
116 iStatus, |
|
117 EAknGlobalWaitNote, |
|
118 *text ); |
|
119 CleanupStack::PopAndDestroy( text ); |
|
120 ACPLOG( " - SetActive();" ); |
|
121 SetActive(); |
|
122 } |
|
123 ACPLOG( "CAcpDialog::LaunchWaitNoteL end" ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CAcpDialog::DestroyWaitNote |
|
128 // Destroys a wait note. |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CAcpDialog::DestroyWaitNote() |
|
132 { |
|
133 ACPLOG( "CAcpDialog::DestroyWaitNote begin" ); |
|
134 Cancel(); |
|
135 |
|
136 // If dialog handler wasn't active anymore, DoCancel wasn't called and |
|
137 // the wait note needs to be deleted separately. |
|
138 if ( iWaitNote ) |
|
139 { |
|
140 TRAP_IGNORE( iWaitNote->CancelNoteL( iNoteId ) ); |
|
141 delete iWaitNote; |
|
142 iWaitNote = NULL; |
|
143 } |
|
144 |
|
145 ACPLOG( "CAcpDialog::DestroyWaitNoteL end" ); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // CAcpDialog::ShowQueryL |
|
150 // --------------------------------------------------------------------------- |
|
151 // |
|
152 TInt CAcpDialog::ShowQueryL( TInt aQuery ) |
|
153 { |
|
154 ACPLOG( "CAcpDialog::ShowQueryL begin" ); |
|
155 CAknQueryDialog* query = new ( ELeave ) |
|
156 CAknQueryDialog( CAknQueryDialog::ENoTone ); |
|
157 ACPLOG( " - return ( query->ExecuteLD( aQuery ) );" ); |
|
158 ACPLOG( "CAcpDialog::ShowQueryL end" ); |
|
159 return ( query->ExecuteLD( aQuery ) ); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // CAcpDialog::ShowMessageQueryL |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CAcpDialog::ShowMessageQueryL( TInt aMessageQuery, const TDesC& aString ) |
|
167 { |
|
168 ACPLOG( "CAcpDialog::ShowMessageQueryL begin" ); |
|
169 |
|
170 if ( !IsActive() ) |
|
171 { |
|
172 HBufC* text = StringLoader::LoadLC( aMessageQuery, aString ); |
|
173 iGlobalMsgQuery = CAknGlobalMsgQuery::NewL(); |
|
174 |
|
175 ACPLOG( " --> show query" ); |
|
176 |
|
177 iGlobalMsgQuery->ShowMsgQueryL( |
|
178 iStatus, |
|
179 text->Des(), |
|
180 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
181 KNullDesC, |
|
182 KNullDesC ); |
|
183 |
|
184 CleanupStack::PopAndDestroy( text ); |
|
185 SetActive(); |
|
186 } |
|
187 |
|
188 ACPLOG( "CAcpDialog::ShowMessageQueryL end" ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // CAcpDialog::ShowNoteL |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CAcpDialog::ShowNoteL( TInt aNote, const TDesC& aString ) |
|
196 { |
|
197 ACPLOG( "CAcpDialog::ShowNoteL(string) begin" ); |
|
198 HBufC* text = StringLoader::LoadLC( aNote, aString ); |
|
199 CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue ); |
|
200 note->ExecuteLD( *text ); |
|
201 CleanupStack::PopAndDestroy( text ); |
|
202 ACPLOG( "CAcpDialog::ShowNoteL(string) end" ); |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CAcpDialog::ShowGlobalNoteL |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 void CAcpDialog::ShowGlobalNoteL( TInt aNote ) |
|
210 { |
|
211 ACPLOG( "CAcpDialog::ShowGlobalNoteL begin" ); |
|
212 HBufC* text = StringLoader::LoadLC( aNote ); |
|
213 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
214 note->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY ); |
|
215 note->ShowNoteL( EAknGlobalInformationNote, *text ); |
|
216 CleanupStack::PopAndDestroy( 2, text ); |
|
217 ACPLOG( "CAcpDialog::ShowGlobalNoteL end" ); |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------------------------- |
|
221 // CAcpDialog::ShowGlobalNoteL |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CAcpDialog::ShowGlobalNoteL( TInt aNote, const TDesC& aString ) |
|
225 { |
|
226 ACPLOG( "CAcpDialog::ShowGlobalNoteL(string) begin" ); |
|
227 HBufC* text = StringLoader::LoadLC( aNote, aString ); |
|
228 CAknGlobalNote* note = CAknGlobalNote::NewLC(); |
|
229 note->SetSoftkeys( R_AVKON_SOFTKEYS_OK_EMPTY ); |
|
230 note->ShowNoteL( EAknGlobalInformationNote, *text ); |
|
231 CleanupStack::PopAndDestroy( 2, text ); |
|
232 ACPLOG( "CAcpDialog::ShowGlobalNoteL(string) end" ); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // CAcpDialog::ShowSelectionDialogL |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 TInt CAcpDialog::ShowSelectionDialogL( TInt aDialog, MDesC16Array* aArray ) |
|
240 { |
|
241 ACPLOG( "CAcpDialog::ShowSelectionDialogL begin" ); |
|
242 TInt index( KErrNotFound ); |
|
243 CAknListQueryDialog* dialog = new (ELeave) CAknListQueryDialog( &index ); |
|
244 dialog->PrepareLC( aDialog ); |
|
245 dialog->SetItemTextArray( aArray ); |
|
246 dialog->SetOwnershipType( ELbmOwnsItemArray ); |
|
247 dialog->RunLD(); |
|
248 |
|
249 ACPLOG( "CAcpDialog::ShowSelectionDialogL end" ); |
|
250 return index; |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------------------------- |
|
254 // CAcpDialog::RunL |
|
255 // From CActive. |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void CAcpDialog::RunL() |
|
259 { |
|
260 ACPLOG2( "CAcpDialog::RunL: iStatus=%d", iStatus.Int() ); |
|
261 |
|
262 TInt status = iStatus.Int(); |
|
263 |
|
264 if ( iWaitNote ) |
|
265 { |
|
266 ACPLOG( "CAcpDialog::RunL --> wait note" ); |
|
267 |
|
268 iObserver.DialogDismissedL( iStatus.Int() ); |
|
269 } |
|
270 else if ( iGlobalMsgQuery && |
|
271 ( status == EAknSoftkeyYes || status == EAknSoftkeyOk ) ) |
|
272 { |
|
273 ACPLOG( "CAcpDialog::RunL --> message query" ); |
|
274 |
|
275 iGlobalMsgQuery->CancelMsgQuery(); |
|
276 iObserver.DialogDismissedL( iStatus.Int() ); |
|
277 } |
|
278 else if ( iGlobalMsgQuery && |
|
279 ( status != EAknSoftkeyYes || status != EAknSoftkeyOk ) ) |
|
280 { |
|
281 ACPLOG( "CAcpDialog::RunL --> waiting user to check message query" ); |
|
282 |
|
283 // do nothing, wait user to press ok to message query. |
|
284 } |
|
285 else |
|
286 { |
|
287 ACPLOG( "CAcpDialog::RunL --> cancel" ); |
|
288 |
|
289 // in other cases cancel |
|
290 Cancel(); |
|
291 } |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // CAcpDialog::DoCancel |
|
296 // From CActive. |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 void CAcpDialog::DoCancel() |
|
300 { |
|
301 ACPLOG( "CAcpDialog::DoCancel - begin" ); |
|
302 |
|
303 if ( iWaitNote ) |
|
304 { |
|
305 TRAP_IGNORE( iWaitNote->CancelNoteL( iNoteId ) ); |
|
306 delete iWaitNote; |
|
307 iWaitNote = NULL; |
|
308 } |
|
309 |
|
310 if ( iGlobalMsgQuery ) |
|
311 { |
|
312 iGlobalMsgQuery->CancelMsgQuery(); |
|
313 delete iGlobalMsgQuery; |
|
314 iGlobalMsgQuery = NULL; |
|
315 } |
|
316 |
|
317 ACPLOG( "CAcpDialog::DoCancel - end" ); |
|
318 } |
|
319 |
|
320 // End of file. |