|
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 iProgressDialog; |
|
103 delete iObexDialogTimer; |
|
104 delete iWaitDialog; |
|
105 |
|
106 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::~CObexUtilsDialog() completed")); |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CObexUtilsDialog::LaunchProgressDialogL |
|
111 // ----------------------------------------------------------------------------- |
|
112 EXPORT_C void CObexUtilsDialog::LaunchProgressDialogL( |
|
113 MObexUtilsProgressObserver* aObserverPtr, TInt aFinalValue, |
|
114 TInt aResId, TInt aTimeoutValue ) |
|
115 { |
|
116 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL()")); |
|
117 |
|
118 if ( aObserverPtr ) |
|
119 { |
|
120 // The observerPtr was given, so store it and start a timer |
|
121 // |
|
122 iProgressObserverPtr = aObserverPtr; |
|
123 |
|
124 if ( iObexDialogTimer ) |
|
125 { |
|
126 iObexDialogTimer->Cancel(); |
|
127 delete iObexDialogTimer; |
|
128 iObexDialogTimer = NULL; |
|
129 } |
|
130 |
|
131 iObexDialogTimer = CObexUtilsDialogTimer::NewL( this ); |
|
132 iObexDialogTimer->SetTimeout( aTimeoutValue ); |
|
133 } |
|
134 |
|
135 iProgressDialogResId = aResId; |
|
136 |
|
137 iProgressDialog = new( ELeave ) CAknProgressDialog( |
|
138 ( reinterpret_cast<CEikDialog**>( &iProgressDialog ) ), ETrue ); |
|
139 PrepareDialogExecuteL( aResId, iProgressDialog ); |
|
140 iProgressDialog->ExecuteLD( R_SENDING_PROGRESS_NOTE ); |
|
141 |
|
142 HBufC* buf = StringLoader::LoadLC( aResId ); |
|
143 iProgressDialog->SetTextL( buf->Des() ); |
|
144 CleanupStack::PopAndDestroy( buf ); |
|
145 |
|
146 iProgressDialog->GetProgressInfoL()->SetFinalValue( aFinalValue ); |
|
147 iProgressDialog->SetCallback( this ); |
|
148 if ( iProgressObserverPtr ) |
|
149 { |
|
150 iObexDialogTimer->Tickle(); |
|
151 } |
|
152 |
|
153 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchProgressDialogL() completed")); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CObexUtilsDialog::LaunchWaitDialogL |
|
158 // ----------------------------------------------------------------------------- |
|
159 EXPORT_C void CObexUtilsDialog::LaunchWaitDialogL( TInt aResId ) |
|
160 { |
|
161 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL()")); |
|
162 |
|
163 if ( iWaitDialog || iProgressDialog ) |
|
164 { |
|
165 // Allow only one dialog at a time |
|
166 // |
|
167 User::Leave( KErrInUse ); |
|
168 } |
|
169 |
|
170 iWaitDialog = new( ELeave ) CAknWaitDialog( |
|
171 ( reinterpret_cast<CEikDialog**>( &iWaitDialog ) ), ETrue ); |
|
172 iWaitDialog->SetCallback( this ); |
|
173 PrepareDialogExecuteL( aResId, iWaitDialog ); |
|
174 iWaitDialog->ExecuteLD( aResId ); |
|
175 |
|
176 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchWaitDialogL() completed")); |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CObexUtilsDialog::CancelWaitDialogL |
|
181 // ----------------------------------------------------------------------------- |
|
182 EXPORT_C void CObexUtilsDialog::CancelWaitDialogL() |
|
183 { |
|
184 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL()")); |
|
185 |
|
186 if( iWaitDialog ) |
|
187 { |
|
188 iWaitDialog->ProcessFinishedL(); |
|
189 } |
|
190 |
|
191 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelWaitDialogL() completed")); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CObexUtilsDialog::CancelProgressDialogL |
|
196 // ----------------------------------------------------------------------------- |
|
197 EXPORT_C void CObexUtilsDialog::CancelProgressDialogL() |
|
198 { |
|
199 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL()")); |
|
200 |
|
201 if( iProgressDialog ) |
|
202 { |
|
203 iProgressDialog->ProcessFinishedL(); |
|
204 |
|
205 if ( iObexDialogTimer ) |
|
206 { |
|
207 iObexDialogTimer->Cancel(); |
|
208 delete iObexDialogTimer; |
|
209 iObexDialogTimer = NULL; |
|
210 } |
|
211 } |
|
212 |
|
213 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::CancelProgressDialogL() completed")); |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CObexUtilsDialog::UpdateProgressDialogL |
|
218 // ----------------------------------------------------------------------------- |
|
219 EXPORT_C void CObexUtilsDialog::UpdateProgressDialogL( TInt aValue, TInt aResId ) |
|
220 { |
|
221 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL()")); |
|
222 |
|
223 if ( iProgressDialog ) |
|
224 { |
|
225 iProgressDialog->GetProgressInfoL()->SetAndDraw( aValue ); |
|
226 |
|
227 HBufC* buf = StringLoader::LoadLC( aResId ); |
|
228 iProgressDialog->SetTextL( buf->Des() ); |
|
229 iProgressDialog->LayoutAndDraw(); |
|
230 CleanupStack::PopAndDestroy( buf ); |
|
231 } |
|
232 |
|
233 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialogL() completed")); |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CObexUtilsDialog::DialogDismissedL |
|
238 // ----------------------------------------------------------------------------- |
|
239 void CObexUtilsDialog::DialogDismissedL( TInt aButtonId ) |
|
240 { |
|
241 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::DialogDismissedL()")); |
|
242 |
|
243 // The dialog has already been deleted by UI framework. |
|
244 // |
|
245 if( aButtonId == EAknSoftkeyCancel ) |
|
246 { |
|
247 if ( iDialogObserverPtr ) |
|
248 { |
|
249 iDialogObserverPtr->DialogDismissed( aButtonId ); |
|
250 } |
|
251 |
|
252 if ( iObexDialogTimer ) |
|
253 { |
|
254 iObexDialogTimer->Cancel(); |
|
255 delete iObexDialogTimer; |
|
256 iObexDialogTimer = NULL; |
|
257 } |
|
258 } |
|
259 |
|
260 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::DialogDismissedL() completed")); |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CObexUtilsDialog::UpdateProgressDialog |
|
265 // ----------------------------------------------------------------------------- |
|
266 void CObexUtilsDialog::UpdateProgressDialog() |
|
267 { |
|
268 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialog()")); |
|
269 |
|
270 TRAPD( ignoredError, UpdateProgressDialogL( |
|
271 iProgressObserverPtr->GetProgressStatus(), iProgressDialogResId ) ); |
|
272 |
|
273 if (ignoredError != KErrNone) |
|
274 { |
|
275 FLOG(_L("Ignore this error")); |
|
276 } |
|
277 |
|
278 if ( iObexDialogTimer ) |
|
279 { |
|
280 iObexDialogTimer->Tickle(); |
|
281 } |
|
282 |
|
283 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::UpdateProgressDialog() completed")); |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CObexUtilsDialog::LaunchQueryDialogL |
|
288 // ----------------------------------------------------------------------------- |
|
289 // |
|
290 EXPORT_C TInt CObexUtilsDialog::LaunchQueryDialogL( const TInt& aResourceID ) |
|
291 { |
|
292 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::LaunchQueryDialogL()")); |
|
293 |
|
294 CAknQueryDialog* dlg = CAknQueryDialog::NewL(); |
|
295 CleanupStack::PushL( dlg ); |
|
296 PrepareDialogExecuteL( aResourceID, dlg ); |
|
297 CleanupStack::Pop( dlg ); |
|
298 TInt keypress = dlg->ExecuteLD( aResourceID ); |
|
299 |
|
300 return keypress; |
|
301 } |
|
302 |
|
303 // ----------------------------------------------------------------------------- |
|
304 // CObexUtilsDialog::ShowNumberOfSendFileL |
|
305 // ----------------------------------------------------------------------------- |
|
306 // |
|
307 |
|
308 EXPORT_C void CObexUtilsDialog::ShowNumberOfSendFileL( TInt aSentNum, TInt aTotalNum ) |
|
309 { |
|
310 FLOG(_L("[OBEXUTILS]\t CObexUtilsDialog::ShowNumberOfSendFile()")); |
|
311 |
|
312 CAknInformationNote* myNote = new (ELeave) CAknInformationNote(); |
|
313 |
|
314 CArrayFix<TInt>* nums = new( ELeave ) CArrayFixFlat<TInt>(3); |
|
315 CleanupStack::PushL(nums); |
|
316 nums->AppendL(aSentNum); |
|
317 nums->AppendL(aTotalNum); |
|
318 CleanupStack::Pop(nums); |
|
319 |
|
320 HBufC* stringholder = StringLoader::LoadLC( R_BT_SENT_IMAGE_NUMBER, *nums); |
|
321 PrepareDialogExecuteL( R_BT_SENT_IMAGE_NUMBER, myNote ); |
|
322 myNote->ExecuteLD( *stringholder ); |
|
323 CleanupStack::PopAndDestroy( stringholder ); |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CObexUtilsDialog::PrepareDialogExecuteL |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CObexUtilsDialog::PrepareDialogExecuteL( const TInt& aResourceID, CEikDialog* aDialog ) |
|
331 { |
|
332 if (iCoverDisplayEnabled) |
|
333 { |
|
334 TInt dialogIndex = |
|
335 ((aResourceID & KResourceNumberMask) - KFirstResourceOffset) + KEnumStart; |
|
336 aDialog->PublishDialogL( dialogIndex, KObexUtilsCategory ); |
|
337 } |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CObexUtilsDialog::IsCoverDisplayL() |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 TBool CObexUtilsDialog::IsCoverDisplayL() |
|
345 { |
|
346 TBool coverDisplay = EFalse; |
|
347 FeatureManager::InitializeLibL(); |
|
348 if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ) |
|
349 { |
|
350 coverDisplay = ETrue; |
|
351 } |
|
352 FeatureManager::UnInitializeLib(); |
|
353 return coverDisplay; |
|
354 } |
|
355 |
|
356 // End of File |