1 /* |
|
2 * Copyright (c) 2002 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 // INCLUDE FILES |
|
20 #include "obexutilsdialog.h" |
|
21 #include "obexutilsdialogtimer.h" |
|
22 #include "obexutilsuilayer.h" |
|
23 #include <secondarydisplay/obexutilssecondarydisplayapi.h> |
|
24 #include <aknnotewrappers.h> |
|
25 #include <eikprogi.h> |
|
26 #include <Obexutils.rsg> |
|
27 #include <e32def.h> |
|
28 #include <bautils.h> |
|
29 #include <StringLoader.h> |
|
30 #include <featmgr.h> |
|
31 #include "obexutilsdebug.h" |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 CObexUtilsDialog::CObexUtilsDialog( MObexUtilsDialogObserver* aObserverPtr ) : |
|
40 iDialogObserverPtr( aObserverPtr ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CObexUtilsDialog::NewL |
|
46 // ----------------------------------------------------------------------------- |
|
47 EXPORT_C CObexUtilsDialog* CObexUtilsDialog::NewL( MObexUtilsDialogObserver* aObserverPtr ) |
|
48 { |
|
49 CObexUtilsDialog* self = new ( ELeave ) CObexUtilsDialog( aObserverPtr ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 return( self ); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CObexUtilsDialog::NewLC |
|
58 // ----------------------------------------------------------------------------- |
|
59 EXPORT_C CObexUtilsDialog* CObexUtilsDialog::NewLC( MObexUtilsDialogObserver* aObserverPtr ) |
|
60 { |
|
61 CObexUtilsDialog* self = new ( ELeave ) CObexUtilsDialog( aObserverPtr ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 return( self ); |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CObexUtilsDialog::ConstructL |
|
69 // Symbian OS default constructor can leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 void CObexUtilsDialog::ConstructL() |
|
72 { |
|
73 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ConstructL()")); |
|
74 |
|
75 if (!iDialogObserverPtr) |
|
76 { |
|
77 // The observer pointer was not given as an argument. |
|
78 // |
|
79 User::Leave(KErrArgument); |
|
80 } |
|
81 |
|
82 TFileName fileName; |
|
83 fileName += KObexUtilsFileDrive; |
|
84 fileName += KDC_RESOURCE_FILES_DIR; |
|
85 fileName += KObexUtilsResourceFileName; |
|
86 BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(), fileName ); |
|
87 iResourceFileId = CCoeEnv::Static()->AddResourceFileL( fileName ); |
|
88 |
|
89 iCoverDisplayEnabled = IsCoverDisplayL(); |
|
90 |
|
91 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ConstructL() completed")); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // Destructor |
|
96 // ----------------------------------------------------------------------------- |
|
97 CObexUtilsDialog::~CObexUtilsDialog() |
|
98 { |
|
99 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog()")); |
|
100 |
|
101 CCoeEnv::Static()->DeleteResourceFile( iResourceFileId ); |
|
102 delete iObexDialogTimer; |
|
103 |
|
104 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog() completed")); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CObexUtilsDialog::LaunchProgressDialogL |
|
109 // ----------------------------------------------------------------------------- |
|
110 EXPORT_C void CObexUtilsDialog::LaunchProgressDialogL( |
|
111 MObexUtilsProgressObserver* aObserverPtr, TInt aFinalValue, |
|
112 TInt aResId, TInt aTimeoutValue ) |
|
113 { |
|
114 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL()")); |
|
115 |
|
116 if ( aObserverPtr ) |
|
117 { |
|
118 // The observerPtr was given, so store it and start a timer |
|
119 // |
|
120 iProgressObserverPtr = aObserverPtr; |
|
121 |
|
122 if ( iObexDialogTimer ) |
|
123 { |
|
124 iObexDialogTimer->Cancel(); |
|
125 delete iObexDialogTimer; |
|
126 iObexDialogTimer = NULL; |
|
127 } |
|
128 |
|
129 iObexDialogTimer = CObexUtilsDialogTimer::NewL( this ); |
|
130 iObexDialogTimer->SetTimeout( aTimeoutValue ); |
|
131 } |
|
132 |
|
133 iProgressDialogResId = aResId; |
|
134 |
|
135 iProgressDialog = new( ELeave ) CAknProgressDialog( |
|
136 ( reinterpret_cast<CEikDialog**>( &iProgressDialog ) ), ETrue ); |
|
137 PrepareDialogExecuteL( aResId, iProgressDialog ); |
|
138 iProgressDialog->ExecuteLD( R_SENDING_PROGRESS_NOTE ); |
|
139 |
|
140 HBufC* buf = StringLoader::LoadLC( aResId ); |
|
141 iProgressDialog->SetTextL( buf->Des() ); |
|
142 CleanupStack::PopAndDestroy( buf ); |
|
143 |
|
144 iProgressDialog->GetProgressInfoL()->SetFinalValue( aFinalValue ); |
|
145 iProgressDialog->SetCallback( this ); |
|
146 if ( iProgressObserverPtr ) |
|
147 { |
|
148 iObexDialogTimer->Tickle(); |
|
149 } |
|
150 |
|
151 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL() completed")); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CObexUtilsDialog::LaunchWaitDialogL |
|
156 // ----------------------------------------------------------------------------- |
|
157 EXPORT_C void CObexUtilsDialog::LaunchWaitDialogL( TInt aResId ) |
|
158 { |
|
159 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL()")); |
|
160 |
|
161 if ( iWaitDialog || iProgressDialog ) |
|
162 { |
|
163 // Allow only one dialog at a time |
|
164 // |
|
165 User::Leave( KErrInUse ); |
|
166 } |
|
167 |
|
168 iWaitDialog = new( ELeave ) CAknWaitDialog( |
|
169 ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ), EFalse ); |
|
170 |
|
171 iWaitDialog->SetCallback( this ); |
|
172 PrepareDialogExecuteL( aResId, iWaitDialog ); |
|
173 iWaitDialog->ExecuteLD( aResId ); |
|
174 |
|
175 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL() completed")); |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // CObexUtilsDialog::CancelWaitDialogL |
|
180 // ----------------------------------------------------------------------------- |
|
181 EXPORT_C void CObexUtilsDialog::CancelWaitDialogL() |
|
182 { |
|
183 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL()")); |
|
184 |
|
185 if( iWaitDialog ) |
|
186 { |
|
187 iWaitDialog->SetCallback(NULL); |
|
188 iWaitDialog->ProcessFinishedL(); |
|
189 iWaitDialog = NULL; |
|
190 } |
|
191 |
|
192 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL() completed")); |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CObexUtilsDialog::CancelProgressDialogL |
|
197 // ----------------------------------------------------------------------------- |
|
198 EXPORT_C void CObexUtilsDialog::CancelProgressDialogL() |
|
199 { |
|
200 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL()")); |
|
201 |
|
202 if( iProgressDialog ) |
|
203 { |
|
204 iProgressDialog->SetCallback(NULL); |
|
205 iProgressDialog->ProcessFinishedL(); |
|
206 iProgressDialog = NULL; |
|
207 |
|
208 if ( iObexDialogTimer ) |
|
209 { |
|
210 iObexDialogTimer->Cancel(); |
|
211 delete iObexDialogTimer; |
|
212 iObexDialogTimer = NULL; |
|
213 } |
|
214 } |
|
215 |
|
216 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL() completed")); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CObexUtilsDialog::UpdateProgressDialogL |
|
221 // ----------------------------------------------------------------------------- |
|
222 EXPORT_C void CObexUtilsDialog::UpdateProgressDialogL( TInt aValue, TInt aResId ) |
|
223 { |
|
224 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL()")); |
|
225 |
|
226 if ( iProgressDialog ) |
|
227 { |
|
228 iProgressDialog->GetProgressInfoL()->SetAndDraw( aValue ); |
|
229 |
|
230 HBufC* buf = StringLoader::LoadLC( aResId ); |
|
231 iProgressDialog->SetTextL( buf->Des() ); |
|
232 iProgressDialog->LayoutAndDraw(); |
|
233 CleanupStack::PopAndDestroy( buf ); |
|
234 } |
|
235 |
|
236 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL() completed")); |
|
237 } |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CObexUtilsDialog::DialogDismissedL |
|
241 // ----------------------------------------------------------------------------- |
|
242 void CObexUtilsDialog::DialogDismissedL( TInt aButtonId ) |
|
243 { |
|
244 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::DialogDismissedL()")); |
|
245 |
|
246 // The dialog has already been deleted by UI framework. |
|
247 // |
|
248 if( aButtonId == EAknSoftkeyCancel ) |
|
249 { |
|
250 if ( iDialogObserverPtr ) |
|
251 { |
|
252 iDialogObserverPtr->DialogDismissed( aButtonId ); |
|
253 } |
|
254 |
|
255 if ( iObexDialogTimer ) |
|
256 { |
|
257 iObexDialogTimer->Cancel(); |
|
258 delete iObexDialogTimer; |
|
259 iObexDialogTimer = NULL; |
|
260 } |
|
261 } |
|
262 |
|
263 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::DialogDismissedL() completed")); |
|
264 } |
|
265 |
|
266 // ----------------------------------------------------------------------------- |
|
267 // CObexUtilsDialog::UpdateProgressDialog |
|
268 // ----------------------------------------------------------------------------- |
|
269 void CObexUtilsDialog::UpdateProgressDialog() |
|
270 { |
|
271 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialog()")); |
|
272 |
|
273 TRAPD( ignoredError, UpdateProgressDialogL( |
|
274 iProgressObserverPtr->GetProgressStatus(), iProgressDialogResId ) ); |
|
275 |
|
276 if (ignoredError != KErrNone) |
|
277 { |
|
278 FLOG(_L("Ignore this error")); |
|
279 } |
|
280 |
|
281 if ( iObexDialogTimer ) |
|
282 { |
|
283 iObexDialogTimer->Tickle(); |
|
284 } |
|
285 |
|
286 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialog() completed")); |
|
287 } |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // CObexUtilsDialog::LaunchQueryDialogL |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 EXPORT_C TInt CObexUtilsDialog::LaunchQueryDialogL( const TInt& aResourceID ) |
|
294 { |
|
295 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchQueryDialogL()")); |
|
296 |
|
297 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
298 CleanupStack::PushL( dlg ); |
|
299 PrepareDialogExecuteL( aResourceID, dlg ); |
|
300 CleanupStack::Pop( dlg ); |
|
301 TInt keypress = dlg->ExecuteLD( aResourceID ); |
|
302 |
|
303 return keypress; |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // CObexUtilsDialog::ShowNumberOfSendFileL |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 |
|
311 EXPORT_C void CObexUtilsDialog::ShowNumberOfSendFileL( TInt aSentNum, TInt aTotalNum ) |
|
312 { |
|
313 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ShowNumberOfSendFile()")); |
|
314 |
|
315 CAknInformationNote* myNote = new (ELeave) CAknInformationNote(); |
|
316 |
|
317 CArrayFix<TInt>* nums = new( ELeave ) CArrayFixFlat<TInt>(3); |
|
318 CleanupStack::PushL(nums); |
|
319 nums->AppendL(aSentNum); |
|
320 nums->AppendL(aTotalNum); |
|
321 CleanupStack::Pop(nums); |
|
322 |
|
323 HBufC* stringholder = StringLoader::LoadLC( R_BT_SENT_IMAGE_NUMBER, *nums); |
|
324 PrepareDialogExecuteL( R_BT_SENT_IMAGE_NUMBER, myNote ); |
|
325 myNote->ExecuteLD( *stringholder ); |
|
326 CleanupStack::PopAndDestroy( stringholder ); |
|
327 } |
|
328 |
|
329 // ----------------------------------------------------------------------------- |
|
330 // CObexUtilsDialog::PrepareDialogExecuteL |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 void CObexUtilsDialog::PrepareDialogExecuteL( const TInt& aResourceID, CEikDialog* aDialog ) |
|
334 { |
|
335 if (iCoverDisplayEnabled) |
|
336 { |
|
337 TInt dialogIndex = |
|
338 ((aResourceID & KResourceNumberMask) - KFirstResourceOffset) + KEnumStart; |
|
339 aDialog->PublishDialogL( dialogIndex, KObexUtilsCategory ); |
|
340 } |
|
341 } |
|
342 |
|
343 // ----------------------------------------------------------------------------- |
|
344 // CObexUtilsDialog::IsCoverDisplayL() |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 TBool CObexUtilsDialog::IsCoverDisplayL() |
|
348 { |
|
349 TBool coverDisplay = EFalse; |
|
350 FeatureManager::InitializeLibL(); |
|
351 if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
352 { |
|
353 coverDisplay = ETrue; |
|
354 } |
|
355 FeatureManager::UnInitializeLib(); |
|
356 return coverDisplay; |
|
357 } |
|
358 |
|
359 // End of File |
|