|
1 /* |
|
2 * Copyright (c) 2009 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: Ussd note controller |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <AknGlobalNote.h> //CAknGlobalNote |
|
21 #include <aknnotewrappers.h> |
|
22 #include <ConeResLoader.h> |
|
23 #include <StringLoader.h> |
|
24 |
|
25 #include "PhCltClientServer.h" |
|
26 #include "CPhCltUssdNoteController.h" |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CPhCltUssdNoteController::NewL |
|
33 // Two-phased constructor. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CPhCltUssdNoteController* CPhCltUssdNoteController::NewL( |
|
37 MPhCltUssdNoteControllerCallBack& aCallBack, |
|
38 TInt aPriority ) |
|
39 { |
|
40 CPhCltUssdNoteController* self = new( ELeave ) |
|
41 CPhCltUssdNoteController( aCallBack, aPriority ); |
|
42 |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CPhCltUssdNoteController::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CPhCltUssdNoteController::ConstructL() |
|
56 { |
|
57 LoadResourceFileL(); |
|
58 } |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CPhCltUssdNoteController::CPhCltUssdNoteController |
|
63 // C++ constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 CPhCltUssdNoteController::CPhCltUssdNoteController( |
|
67 MPhCltUssdNoteControllerCallBack& aCallBack, |
|
68 TInt aPriority ) |
|
69 : CActive( aPriority ), |
|
70 iCallBack( aCallBack ), |
|
71 iWaitNoteId( KErrNotFound ) |
|
72 { |
|
73 CActiveScheduler::Add( this ); |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CPhCltUssdNoteController:~CPhCltUssdNoteController |
|
79 // C++ default constructor can NOT contain any code, that |
|
80 // might leave. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CPhCltUssdNoteController::~CPhCltUssdNoteController() |
|
84 { |
|
85 Cancel(); |
|
86 |
|
87 DestroyGlobalWaitNote(); |
|
88 |
|
89 delete iMessageBuffer; |
|
90 iMessageBuffer = NULL; |
|
91 |
|
92 if ( iResourceLoader ) |
|
93 { |
|
94 iResourceLoader->Close(); |
|
95 delete iResourceLoader; |
|
96 iResourceLoader = NULL; |
|
97 } |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CPhCltUssdNoteController::RunL |
|
103 // |
|
104 // Called when dialog is dismissed by pressing a softkey. |
|
105 // ----------------------------------------------------------------------------- |
|
106 void CPhCltUssdNoteController::RunL() |
|
107 { |
|
108 iCallBack.GlobalWaitNoteDismissedL( iStatus.Int() ); |
|
109 } |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CPhCltUssdNoteController::DoCancel |
|
114 // ----------------------------------------------------------------------------- |
|
115 void CPhCltUssdNoteController::DoCancel() |
|
116 { |
|
117 DestroyGlobalWaitNote(); |
|
118 } |
|
119 |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CPhCltUssdNoteController::ShowInformationNoteL |
|
123 // ----------------------------------------------------------------------------- |
|
124 void CPhCltUssdNoteController::ShowInformationNoteL( TInt aResourceId ) |
|
125 { |
|
126 ShowNoteL( EPhCltUssdInformationNote, aResourceId ); |
|
127 } |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CPhCltUssdNoteController::ShowGlobalInformationNoteL |
|
132 // ----------------------------------------------------------------------------- |
|
133 void CPhCltUssdNoteController::ShowGlobalInformationNoteL( TInt aResourceId ) |
|
134 { |
|
135 ShowNoteL( EPhCltUssdGlobalInformationNote, aResourceId ); |
|
136 } |
|
137 |
|
138 |
|
139 // ----------------------------------------------------------------------------- |
|
140 // CPhCltUssdNoteController::ShowGlobalConfirmationNoteL |
|
141 // ----------------------------------------------------------------------------- |
|
142 void CPhCltUssdNoteController::ShowGlobalConfirmationNoteL( TInt aResourceId ) |
|
143 { |
|
144 ShowNoteL( EPhCltUssdGlobalConfirmationNote, aResourceId ); |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CPhCltUssdNoteController::ShowGlobalWaitNoteL |
|
150 // ----------------------------------------------------------------------------- |
|
151 void CPhCltUssdNoteController::ShowGlobalWaitNoteL( |
|
152 TInt aResourceId, |
|
153 TInt aSoftkeyResourceId ) |
|
154 { |
|
155 delete iMessageBuffer; |
|
156 iMessageBuffer = NULL; |
|
157 iMessageBuffer = StringLoader::LoadL( aResourceId ); |
|
158 |
|
159 DestroyGlobalWaitNote(); |
|
160 |
|
161 iGlobalWaitNote = CAknGlobalNote::NewL(); |
|
162 |
|
163 if ( aSoftkeyResourceId ) |
|
164 { |
|
165 iGlobalWaitNote->SetSoftkeys( aSoftkeyResourceId ); |
|
166 } |
|
167 |
|
168 SetActive(); |
|
169 |
|
170 iWaitNoteId = iGlobalWaitNote->ShowNoteL( iStatus, |
|
171 EAknGlobalWaitNote, |
|
172 *iMessageBuffer ); |
|
173 } |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CPhCltUssdNoteController::DestroyGlobalWaitNote |
|
178 // ----------------------------------------------------------------------------- |
|
179 void CPhCltUssdNoteController::DestroyGlobalWaitNote() |
|
180 { |
|
181 if ( iGlobalWaitNote ) |
|
182 { |
|
183 if ( iWaitNoteId != KErrNotFound ) |
|
184 { |
|
185 TRAP_IGNORE( iGlobalWaitNote->CancelNoteL( iWaitNoteId ) ); |
|
186 iWaitNoteId = KErrNotFound; |
|
187 } |
|
188 delete iGlobalWaitNote; |
|
189 iGlobalWaitNote = NULL; |
|
190 } |
|
191 } |
|
192 |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CPhCltUssdNoteController::ShowNoteL |
|
196 // |
|
197 // Launches a corresponding dialog with the given string. |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CPhCltUssdNoteController::ShowNoteL( TPhCltUssdNoteType aType, TInt aResourceId ) |
|
201 { |
|
202 switch ( aType ) |
|
203 { |
|
204 case EPhCltUssdInformationNote: |
|
205 { |
|
206 delete iMessageBuffer; |
|
207 iMessageBuffer = NULL; |
|
208 iMessageBuffer = StringLoader::LoadL( aResourceId ); |
|
209 |
|
210 if ( iMessageBuffer->Length() == 0 ) |
|
211 { |
|
212 break; |
|
213 } |
|
214 CAknInformationNote* dlg = new ( ELeave ) |
|
215 CAknInformationNote( ETrue ); |
|
216 |
|
217 dlg->ExecuteLD( *iMessageBuffer ); |
|
218 break; |
|
219 } |
|
220 case EPhCltUssdGlobalInformationNote: |
|
221 case EPhCltUssdGlobalConfirmationNote: |
|
222 { |
|
223 CAknGlobalNote* dlg = CAknGlobalNote::NewLC(); |
|
224 |
|
225 delete iMessageBuffer; |
|
226 iMessageBuffer = NULL; |
|
227 iMessageBuffer = StringLoader::LoadL( aResourceId ); |
|
228 |
|
229 if ( aType == EPhCltUssdGlobalInformationNote ) |
|
230 { |
|
231 dlg->ShowNoteL( EAknGlobalInformationNote , *iMessageBuffer ); |
|
232 } |
|
233 else if ( aType == EPhCltUssdGlobalConfirmationNote ) |
|
234 { |
|
235 dlg->ShowNoteL( EAknGlobalConfirmationNote , *iMessageBuffer ); |
|
236 } |
|
237 CleanupStack::PopAndDestroy(); // dlg |
|
238 break; |
|
239 } |
|
240 |
|
241 default: |
|
242 break; |
|
243 } |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CPhCltUssdNoteController::LoadResourceFileL |
|
248 // |
|
249 // Loads resource file via RConeResourceLoader. |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 void CPhCltUssdNoteController::LoadResourceFileL() |
|
253 { |
|
254 // load resource file for notes |
|
255 iResourceLoader = new( ELeave ) RConeResourceLoader( *CCoeEnv::Static() ); |
|
256 TFileName fileName ( KPhCltServerZDrive ); |
|
257 fileName.Append( KDC_RESOURCE_FILES_DIR ); |
|
258 fileName.Append( KPhCltResourceFileNameAndPath ); |
|
259 fileName.ZeroTerminate(); |
|
260 iResourceLoader->OpenL( fileName ); |
|
261 } |
|
262 |
|
263 // End of file |
|
264 |