|
1 /* |
|
2 * Copyright (c) 2002 - 2007 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 * Message centre's general settings dialog. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <aknViewAppUi.h> |
|
24 #include <AknDlgShut.h> |
|
25 #include <muiusettingsarray.h> // CMuiuSettingsArray |
|
26 |
|
27 #include <centralrepository.h> |
|
28 #include <messaginginternalcrkeys.h> |
|
29 #include <e32property.h> |
|
30 #include <messaginginternalpskeys.h> |
|
31 #include <e32capability.h> |
|
32 |
|
33 #include "MceSettingsGeneralSettingsDialog.h" |
|
34 #include "MceSettingsMoveProgress.h" // CMceMoveProgress |
|
35 #include "MceSettingsIds.hrh" |
|
36 #include "MceSettingsAccountManager.h" |
|
37 #include <MceSettings.rsg> |
|
38 |
|
39 #include <CAknMemorySelectionSettingItem.h> // CAknMemorySelectionSettingPage |
|
40 #include <msvuids.h> // KUidMsvServiceEntry |
|
41 #include <akninputblock.h> // CAknInputBlock |
|
42 #include <aknnotewrappers.h> // CAknErrorNote |
|
43 #include <bautils.h> // BaflUtils |
|
44 |
|
45 #include <MuiuOperationWait.h> // CMuiuOperationWait |
|
46 #include <sysutil.h> // Sysutil |
|
47 |
|
48 #include <csxhelp/mce.hlp.hrh> |
|
49 #include <featmgr.h> |
|
50 #include <hlplch.h> // For HlpLauncher |
|
51 #include "MceSettingsUtils.h" |
|
52 |
|
53 #ifdef RD_MULTIPLE_DRIVE |
|
54 #include <AknCommonDialogsDynMem.h> // Media type |
|
55 #include <CAknMemorySelectionDialogMultiDrive.h> // CAknMemorySelectionDialogMultiDrive |
|
56 #include <driveinfo.h> // DriveInfo |
|
57 #endif //RD_MULTIPLE_DRIVE |
|
58 #include <e32cmn.h> // RBuf |
|
59 |
|
60 #include <bldvariant.hrh> |
|
61 #include <data_caging_path_literals.hrh> |
|
62 |
|
63 // CONSTANTS |
|
64 |
|
65 #define KMceApplicationUidValue 0x100058C5 |
|
66 const TUid KMceApplicationUid = {KMceApplicationUidValue}; |
|
67 |
|
68 const TInt KMceDefaultSentItemsCount = 15; |
|
69 const TInt KMceDefaultSentItemsOn = 0; // first item in list array is 'On' |
|
70 const TInt KMceDefaultSentItemsOff = 1; // second item in list array is 'Off' |
|
71 const TInt KMceDefaultSentItems = 1; // == On |
|
72 |
|
73 const TInt KMceEmptyMessageStore = 40000; // size of empty message store |
|
74 const TInt KMceEditorsWaitInterval = 4000000; // wait one second,that message editors close |
|
75 |
|
76 const TInt KMSKPosition = 3; |
|
77 |
|
78 const TInt KMceListTypeTwoRow = 0; |
|
79 const TInt KMceListTypeOneRow = 1; |
|
80 |
|
81 #ifdef _DEBUG |
|
82 _LIT( KPanicText, "MceSettings" ); |
|
83 const TInt KCRepositorySettingFailure = 1; |
|
84 #endif |
|
85 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
86 _LIT( KMceDirAndFile,"MceSettings.rsc" ); |
|
87 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
88 |
|
89 // MODULE DATA STRUCTURES |
|
90 enum TMceGeneralSettings |
|
91 { |
|
92 EMceGeneralSettingsSentItemsInUse, |
|
93 EMceGeneralSettingsSentItemsCount, |
|
94 EMceGeneralSettingsMemoryInUse, |
|
95 EMceGeneralSettingsInboxListType, |
|
96 EMceGeneralSettingsMailListType |
|
97 }; |
|
98 #ifdef RD_MULTIPLE_DRIVE |
|
99 const TInt KSpaceDelimiter=' '; |
|
100 #endif //RD_MULTIPLE_DRIVE |
|
101 |
|
102 // ================= MEMBER FUNCTIONS ======================= |
|
103 |
|
104 EXPORT_C TInt CMceGeneralSettingsDialog::CreateAndExecuteL( |
|
105 CMsvSession* aSession, MMsvSessionObserver& aObserver ) |
|
106 { |
|
107 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
108 // general settings are list item in the list |
|
109 CMceGeneralSettingsDialog* generalSettingsDlg = |
|
110 new (ELeave) CMceGeneralSettingsDialog( aSession, aObserver, NULL ); |
|
111 CleanupStack::PushL( generalSettingsDlg ); |
|
112 generalSettingsDlg->ConstructL( R_MCE_GENERAL_SETTINGS_CHOICE_MENUBAR ); |
|
113 CleanupStack::Pop( generalSettingsDlg ); |
|
114 return generalSettingsDlg->ExecuteLD( R_MCE_GENERAL_SETTINGS ); |
|
115 #else |
|
116 User::Leave( KErrNotSupported ); |
|
117 return KErrNotSupported; |
|
118 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
119 } |
|
120 |
|
121 // C++ default constructor can NOT contain any code that |
|
122 // might leave. |
|
123 // ---------------------------------------------------- |
|
124 // CMceGeneralSettingsDialog::Constructor |
|
125 // ---------------------------------------------------- |
|
126 CMceGeneralSettingsDialog::CMceGeneralSettingsDialog( |
|
127 CMsvSession* aSession, |
|
128 MMsvSessionObserver& aObserver, |
|
129 MMceSettingsAccountManager* aManager ) |
|
130 : |
|
131 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
132 CMceSettingsTitlePaneHandlerDialog(), |
|
133 iSession( aSession ), iObserver( aObserver ), |
|
134 iResources( *CCoeEnv::Static() ), iAccountManager( aManager ) |
|
135 #else |
|
136 CMceSettingsTitlePaneHandlerDialog(), |
|
137 iSession( aSession ), iObserver(aObserver ), iAccountManager( aManager ) |
|
138 #endif |
|
139 { |
|
140 } |
|
141 |
|
142 |
|
143 void CMceGeneralSettingsDialog::ConstructL( TInt aResource ) |
|
144 { |
|
145 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
146 TParse fp; |
|
147 fp.Set( KMceDirAndFile, &KDC_RESOURCE_FILES_DIR , NULL ); |
|
148 TFileName fileName = fp.FullName(); |
|
149 |
|
150 iResources.OpenL( fileName ); |
|
151 #endif |
|
152 CMceSettingsTitlePaneHandlerDialog::ConstructL( aResource ); |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------- |
|
156 // CMceGeneralSettingsDialog::Destructor |
|
157 // ---------------------------------------------------- |
|
158 CMceGeneralSettingsDialog::~CMceGeneralSettingsDialog() |
|
159 { |
|
160 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
161 iResources.Close(); |
|
162 #endif // RD_MESSAGING_GENERAL_SETTINGS_RENOVATION |
|
163 // don't delete iAccountManager |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------- |
|
167 // CMceGeneralSettingsDialog::OkToExitL |
|
168 // ---------------------------------------------------- |
|
169 TInt CMceGeneralSettingsDialog::OkToExitL( TInt aButtonId ) |
|
170 { |
|
171 TBool okToExit = CAknDialog::OkToExitL( aButtonId ); |
|
172 if ( aButtonId == EAknSoftkeyBack || okToExit ) |
|
173 { |
|
174 CRepository* repository = NULL; |
|
175 TRAPD( ret, repository = CRepository::NewL( KCRUidMuiuSettings ) ); |
|
176 CleanupStack::PushL( repository ); |
|
177 |
|
178 if ( ret == KErrNone ) |
|
179 { |
|
180 ret = repository->Set( KMuiuSentItemsInUse, |
|
181 ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsInUse].iCurrentNumber == KMceDefaultSentItemsOn ); |
|
182 __ASSERT_DEBUG( !ret, User::Panic( KPanicText,KCRepositorySettingFailure ) ); |
|
183 #ifdef _DEBUG |
|
184 TInt setValue = ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsInUse].iCurrentNumber; |
|
185 setValue = ( setValue == KMceDefaultSentItemsOn ); |
|
186 #endif |
|
187 |
|
188 ret = repository->Set( KMuiuSentItemsCount, |
|
189 ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber ); |
|
190 __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) ); |
|
191 #ifdef _DEBUG |
|
192 setValue = ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber; |
|
193 #endif |
|
194 |
|
195 ret = repository->Set( KMuiuInboxMessageListType, |
|
196 ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber ); |
|
197 __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) ); |
|
198 |
|
199 ret = repository->Set( KMuiuMailMessageListType, |
|
200 ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber ); |
|
201 __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) ); |
|
202 } |
|
203 CleanupStack::Pop( repository ); |
|
204 delete repository; |
|
205 } |
|
206 |
|
207 if ( aButtonId == EMceSettingsCmdSettingsDialogOpen || |
|
208 aButtonId == EMceSettingsCmdSettingsDialogChange ) |
|
209 { |
|
210 ProcessCommandL( aButtonId ); |
|
211 okToExit = EFalse; // Cannot exit, since MSK was pressed |
|
212 } |
|
213 else if ( aButtonId != EEikBidCancel && okToExit ) |
|
214 { |
|
215 RestoreTitleTextL(); |
|
216 } |
|
217 return okToExit; |
|
218 } |
|
219 |
|
220 // ---------------------------------------------------- |
|
221 // CMceGeneralSettingsDialog::HandleListBoxEventL |
|
222 // ---------------------------------------------------- |
|
223 void CMceGeneralSettingsDialog::HandleListBoxEventL( |
|
224 CEikListBox* /*aListBox*/, |
|
225 TListBoxEvent aEventType ) |
|
226 { |
|
227 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
228 Control( EMceSettingsIdOtherItems ) ); |
|
229 switch(aEventType) |
|
230 { |
|
231 case EEventEnterKeyPressed: |
|
232 case EEventItemSingleClicked: |
|
233 { |
|
234 TInt item = list->CurrentItemIndex(); |
|
235 if ( iMemoryInUse && item == EMceGeneralSettingsMemoryInUse ) |
|
236 { |
|
237 HandleMemoryInUseDialogL(); |
|
238 } |
|
239 else |
|
240 { |
|
241 iMceSettingsArray->EditItemL( item, ETrue ); |
|
242 list->DrawNow(); |
|
243 } |
|
244 } |
|
245 break; |
|
246 |
|
247 default: |
|
248 break; |
|
249 } |
|
250 } |
|
251 |
|
252 // ---------------------------------------------------- |
|
253 // CMceGeneralSettingsDialog::ProcessCommandL |
|
254 // ---------------------------------------------------- |
|
255 void CMceGeneralSettingsDialog::ProcessCommandL( TInt aCommandId ) |
|
256 { |
|
257 CAknDialog::ProcessCommandL( aCommandId ); // hides menu |
|
258 if ( aCommandId == EMceSettingsCmdSettingsDialogExit ) |
|
259 { |
|
260 if (iAvkonViewAppUi->ExitHidesInBackground()) |
|
261 { |
|
262 iAvkonViewAppUi->ProcessCommandL( EAknCmdHideInBackground ); |
|
263 } |
|
264 else |
|
265 { |
|
266 iAvkonViewAppUi->ProcessCommandL( EAknCmdExit ); |
|
267 } |
|
268 return; |
|
269 } |
|
270 |
|
271 |
|
272 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
273 Control( EMceSettingsIdOtherItems ) ); |
|
274 |
|
275 switch ( aCommandId ) |
|
276 { |
|
277 case EMceSettingsCmdSettingsDialogOpen: |
|
278 { |
|
279 TInt item = list->CurrentItemIndex(); |
|
280 if ( iMemoryInUse && item == EMceGeneralSettingsMemoryInUse ) |
|
281 { |
|
282 HandleMemoryInUseDialogL(); |
|
283 } |
|
284 else |
|
285 { |
|
286 iMceSettingsArray->EditItemL( item, EFalse ); |
|
287 list->DrawNow(); |
|
288 } |
|
289 } |
|
290 break; |
|
291 |
|
292 case EMceSettingsCmdSettingsDialogHelp: |
|
293 { |
|
294 LaunchHelpL(); |
|
295 } |
|
296 break; |
|
297 |
|
298 case EMceSettingsCmdSettingsDialogChange: |
|
299 { |
|
300 TInt item = list->CurrentItemIndex(); |
|
301 if ( iMemoryInUse && item == EMceGeneralSettingsMemoryInUse ) |
|
302 { |
|
303 HandleMemoryInUseDialogL(); |
|
304 } |
|
305 else |
|
306 { |
|
307 iMceSettingsArray->EditItemL( item, ETrue ); |
|
308 list->DrawNow(); |
|
309 } |
|
310 } |
|
311 break; |
|
312 default : |
|
313 break; |
|
314 } |
|
315 } |
|
316 |
|
317 |
|
318 // ---------------------------------------------------- |
|
319 // CMceGeneralSettingsDialog::PreLayoutDynInitL |
|
320 // ---------------------------------------------------- |
|
321 void CMceGeneralSettingsDialog::PreLayoutDynInitL( ) |
|
322 { |
|
323 //check if 'Memory in use' -option is enabled in mce settings |
|
324 iMemoryInUse = ETrue; |
|
325 iMemoryInUse = MceSettingsUtils::MemoryInUseOptionL(); |
|
326 |
|
327 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
328 Control( EMceSettingsIdOtherItems ) ); |
|
329 |
|
330 // Setting scrollbar-indicators on |
|
331 list->CreateScrollBarFrameL( ETrue ); |
|
332 list->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
333 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
334 |
|
335 if ( iMemoryInUse ) |
|
336 { |
|
337 iMceSettingsArray = CMuiuSettingsArray::NewL( R_MCE_GENERAL_MMC ); |
|
338 } |
|
339 else |
|
340 { |
|
341 iMceSettingsArray = CMuiuSettingsArray::NewL( R_MCE_GENERAL_SETTINGS_ITEMS ); |
|
342 } |
|
343 |
|
344 list->SetListBoxObserver( this ); |
|
345 |
|
346 CRepository* repository = NULL; |
|
347 TRAPD( ret, repository = CRepository::NewL( KCRUidMuiuSettings ) ); |
|
348 CleanupStack::PushL( repository ); |
|
349 |
|
350 if ( ret == KErrNone ) |
|
351 { |
|
352 TInt i; |
|
353 if ( repository->Get( KMuiuSentItemsInUse, i ) != KErrNone ) |
|
354 { |
|
355 i = KMceDefaultSentItems; |
|
356 } |
|
357 ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsInUse].iCurrentNumber = |
|
358 i ? KMceDefaultSentItemsOn : KMceDefaultSentItemsOff; |
|
359 |
|
360 if ( repository->Get(KMuiuSentItemsCount, i ) != KErrNone ) |
|
361 { |
|
362 i = KMceDefaultSentItemsCount; |
|
363 } |
|
364 ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber = i; |
|
365 ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iUserText.Num( i ); |
|
366 |
|
367 // Get one/two row list type selection |
|
368 if ( repository->Get( KMuiuInboxMessageListType, i ) != KErrNone ) |
|
369 { |
|
370 i = KMceListTypeTwoRow; |
|
371 } |
|
372 ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber = |
|
373 i ? KMceListTypeOneRow : KMceListTypeTwoRow; |
|
374 |
|
375 // Get one/two row list type selection |
|
376 if ( repository->Get( KMuiuMailMessageListType, i ) != KErrNone ) |
|
377 { |
|
378 i = KMceListTypeOneRow; |
|
379 } |
|
380 ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber = |
|
381 i ? KMceListTypeOneRow : KMceListTypeTwoRow; |
|
382 } |
|
383 |
|
384 if ( iMemoryInUse ) |
|
385 { |
|
386 UpdateMemorySelectionL(); |
|
387 } |
|
388 |
|
389 CleanupStack::Pop( repository ); |
|
390 delete repository; |
|
391 |
|
392 CTextListBoxModel* model=list->Model(); |
|
393 model->SetItemTextArray( iMceSettingsArray ); |
|
394 |
|
395 StoreTitleTextAndSetNewL( R_MCE_SETTINGS_TITLE_GENERAL ); |
|
396 SetMSKButtonL(); |
|
397 } |
|
398 |
|
399 // ---------------------------------------------------- |
|
400 // CMceGeneralSettingsDialog::SetTransferError |
|
401 // Catches the error when failed moving message store |
|
402 // ---------------------------------------------------- |
|
403 void CMceGeneralSettingsDialog::SetTransferError( TInt aError ) |
|
404 { |
|
405 iTransferError = aError; |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------- |
|
409 // CMceGeneralSettingsDialog::MoveMessageStoreL |
|
410 // starts copying/moving message store |
|
411 // if move, aDeleteCopiedStore is ETrue, if copy EFalse |
|
412 // ---------------------------------------------------- |
|
413 void CMceGeneralSettingsDialog::MoveMessageStoreL( TInt currentDrive, |
|
414 TInt driveNumber, TBool aDeleteCopiedStore ) |
|
415 { |
|
416 if( !CheckIsServerBusyL() ) |
|
417 { |
|
418 CAknInputBlock* comAbs=CAknInputBlock::NewLC(); |
|
419 iTransferError = KErrNone; |
|
420 CMceMoveProgress* moveProgress=CMceMoveProgress::NewL( |
|
421 iSession, iObserver, currentDrive, driveNumber, aDeleteCopiedStore,*this, EFalse ); |
|
422 |
|
423 CleanupStack::PushL( moveProgress ); |
|
424 if ( iAccountManager ) |
|
425 { |
|
426 iAccountManager->SetChangeMessageStore( EFalse ); |
|
427 } |
|
428 |
|
429 moveProgress->InitializingL(); |
|
430 |
|
431 // KErrAccessDenied: when MC is read-only |
|
432 // preventing messaging close. Todo: anyother erro cases? |
|
433 if ( iTransferError != KErrAccessDenied && iAccountManager ) |
|
434 { |
|
435 iAccountManager->SetChangeMessageStore( ETrue ); |
|
436 } |
|
437 |
|
438 // cannot delete CMceMoveProgress, |
|
439 // because CMceMessageTransHandler is cancelled-> has to be deleted in CMceMoveProgress |
|
440 CleanupStack::Pop( moveProgress ); |
|
441 CleanupStack::PopAndDestroy( comAbs ); |
|
442 } |
|
443 } |
|
444 |
|
445 |
|
446 // ---------------------------------------------------- |
|
447 // CMceGeneralSettingsDialog::CheckIsServerBusyL |
|
448 // checks, if connection is on |
|
449 // return ETrue, if connection is on |
|
450 // ---------------------------------------------------- |
|
451 TBool CMceGeneralSettingsDialog::CheckIsServerBusyL() |
|
452 { |
|
453 TInt outstanding=iSession->OutstandingOperationsL(); |
|
454 |
|
455 if (outstanding==0) |
|
456 { |
|
457 // check to see if any mailboxes are open - otherwise we could miss client side operations |
|
458 CMsvEntry* root=CMsvEntry::NewL( *iSession, |
|
459 KMsvRootIndexEntryIdValue, |
|
460 TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue ) ); |
|
461 CleanupStack::PushL( root ); |
|
462 CMsvEntrySelection* sel=root->ChildrenWithTypeL( KUidMsvServiceEntry ); |
|
463 CleanupStack::PushL( sel ); |
|
464 const TMsvEntry* tentry=NULL; |
|
465 for ( TInt cc=sel->Count(); --cc>=0 && !outstanding ;) |
|
466 { |
|
467 tentry=&( root->ChildDataL( ( *sel )[cc] ) ); |
|
468 if ( tentry->Connected() ) |
|
469 { |
|
470 outstanding++; |
|
471 } |
|
472 } |
|
473 |
|
474 CleanupStack::PopAndDestroy( sel ); |
|
475 CleanupStack::PopAndDestroy( root ); |
|
476 } |
|
477 |
|
478 if (outstanding>0) |
|
479 { |
|
480 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SERVER_BUSY, CCoeEnv::Static() ); |
|
481 CAknErrorNote* note = new ( ELeave ) CAknErrorNote(); |
|
482 note->ExecuteLD( *text ); |
|
483 CleanupStack::PopAndDestroy( text ); |
|
484 return ETrue; |
|
485 } |
|
486 |
|
487 return EFalse; |
|
488 } |
|
489 |
|
490 // ---------------------------------------------------- |
|
491 // CMceGeneralSettingsDialog::FindSourcePathL |
|
492 // gives message store path in aPath, when drive number is got |
|
493 // |
|
494 // ---------------------------------------------------- |
|
495 void CMceGeneralSettingsDialog::FindSourcePathL( TInt aDrive, TFileName& aPath ) const |
|
496 { |
|
497 GetMessageDriveL( aDrive, aPath ); |
|
498 TParsePtrC pptr( KMsvDefaultFolder ); |
|
499 aPath.Append( pptr.Path() ); |
|
500 } |
|
501 |
|
502 // ---------------------------------------------------- |
|
503 // CMceGeneralSettingsDialog::GetMessageDriveL |
|
504 // gives drive letter and drive delimiter in aPath, |
|
505 // when drive number is got |
|
506 // ---------------------------------------------------- |
|
507 void CMceGeneralSettingsDialog::GetMessageDriveL( TInt aDrive, TDes& aPath ) const |
|
508 { |
|
509 TChar driveLetter; |
|
510 User::LeaveIfError( iEikonEnv->FsSession().DriveToChar( aDrive, driveLetter ) ); |
|
511 aPath.Zero(); |
|
512 aPath.Append( driveLetter ); |
|
513 aPath.Append( TChar( KDriveDelimiter ) ); |
|
514 } |
|
515 |
|
516 // ---------------------------------------------------- |
|
517 // CMceGeneralSettingsDialog::UpdateMemorySelectionL |
|
518 // sets correct string in General settings memory in use -option |
|
519 // |
|
520 // ---------------------------------------------------- |
|
521 void CMceGeneralSettingsDialog::UpdateMemorySelectionL() |
|
522 { |
|
523 RFs& fs=iEikonEnv->FsSession(); |
|
524 |
|
525 #ifndef RD_MULTIPLE_DRIVE |
|
526 if ( TInt( iSession->CurrentDriveL() ) == EDriveC ) |
|
527 { |
|
528 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_PHONE_MEMORY, iEikonEnv ); |
|
529 |
|
530 ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( *text ); |
|
531 CleanupStack::PopAndDestroy( text ); |
|
532 } |
|
533 else |
|
534 { |
|
535 TVolumeInfo volumeinfo; |
|
536 fs.Volume( volumeinfo, TInt(iSession->CurrentDriveL() ) ); |
|
537 if( volumeinfo.iName.Length() > 0 ) // Volume has a label |
|
538 { // Use volume label as memory card name |
|
539 ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( volumeinfo.iName ); |
|
540 } |
|
541 else |
|
542 { |
|
543 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_MEMORY_CARD, iEikonEnv ); |
|
544 ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( *text ); |
|
545 CleanupStack::PopAndDestroy( text ); |
|
546 } |
|
547 } |
|
548 |
|
549 #else |
|
550 TInt currentDrive = TInt( iSession->CurrentDriveL() ); |
|
551 |
|
552 TVolumeInfo volumeinfo; |
|
553 fs.Volume( volumeinfo, TInt( currentDrive ) ); |
|
554 if( volumeinfo.iName.Length() > 0 ) // Volume has a label |
|
555 { // Use volume label as memory card name |
|
556 TDriveName driveName(TDriveUnit( currentDrive ).Name() ); |
|
557 RBuf newtxt; |
|
558 newtxt.CreateL( driveName.Length() + volumeinfo.iName.Length() + 1 ); // 1 for space |
|
559 CleanupClosePushL( newtxt ); |
|
560 |
|
561 newtxt.Append( driveName ); |
|
562 newtxt.Append( KSpaceDelimiter ); |
|
563 newtxt.Append( volumeinfo.iName ); |
|
564 |
|
565 ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( newtxt ); |
|
566 CleanupStack::PopAndDestroy( &newtxt ); |
|
567 } |
|
568 else |
|
569 { |
|
570 HBufC *driveNameText = MakeDriveNameStringLC( currentDrive ); |
|
571 ( *iMceSettingsArray )[EMceGeneralSettingsMemoryInUse].iUserText.Copy( *driveNameText ); |
|
572 CleanupStack::PopAndDestroy( driveNameText ); |
|
573 } |
|
574 |
|
575 #endif //RD_MULTIPLE_DRIVE |
|
576 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
577 Control( EMceSettingsIdOtherItems ) ); |
|
578 list->DrawNow(); |
|
579 |
|
580 CRepository* repository = NULL; |
|
581 TRAPD( ret, repository = CRepository::NewL( KCRUidMuiuSettings ) ); |
|
582 CleanupStack::PushL( repository ); |
|
583 |
|
584 if ( ret == KErrNone ) |
|
585 { |
|
586 ret = repository->Set( KMuiuMemoryInUse, TInt( iSession->CurrentDriveL() ) ); |
|
587 __ASSERT_DEBUG( !ret, User::Panic( KPanicText,KCRepositorySettingFailure ) ); |
|
588 } |
|
589 |
|
590 CleanupStack::Pop( repository ); |
|
591 delete repository; |
|
592 } |
|
593 |
|
594 // ---------------------------------------------------- |
|
595 // CMceGeneralSettingsDialog::ShutdownAppsL |
|
596 // closes sms, mms and mail applications, |
|
597 // before changing message store |
|
598 // ---------------------------------------------------- |
|
599 TBool CMceGeneralSettingsDialog::ShutdownAppsL() const |
|
600 { |
|
601 RProperty property; |
|
602 |
|
603 User::LeaveIfError( property.Attach( KPSUidMuiu,KMuiuSysOpenMsgEditors ) ); |
|
604 CleanupClosePushL( property ); |
|
605 |
|
606 TInt i = 0; |
|
607 if ( property.Get(i) != KErrNone ) |
|
608 { |
|
609 i = 0; |
|
610 } |
|
611 if ( i != 0 ) |
|
612 { |
|
613 // clients are open |
|
614 CAknQueryDialog* closeDialog = CAknQueryDialog::NewL(); |
|
615 |
|
616 HBufC* text = NULL; |
|
617 text = StringLoader::LoadLC( R_MCE_CLOSE_MESSAGES_CONFIRM, CCoeEnv::Static() ); |
|
618 closeDialog->SetPromptL( *text ); |
|
619 CleanupStack::PopAndDestroy( text ); |
|
620 |
|
621 // Do you want to close all the open messages? |
|
622 if ( !closeDialog->ExecuteLD( R_MCE_MOVE_CONFIRM ) ) |
|
623 { |
|
624 CleanupStack::PopAndDestroy( &property ); |
|
625 return EFalse; |
|
626 } |
|
627 else |
|
628 { |
|
629 i = 0; |
|
630 property.Set( KPSUidMuiu, KMuiuSysOpenMsgEditors, i ); |
|
631 |
|
632 // wait a second |
|
633 User::After( KMceEditorsWaitInterval ); |
|
634 } |
|
635 } |
|
636 CleanupStack::PopAndDestroy( &property ); |
|
637 return ETrue; |
|
638 } |
|
639 |
|
640 |
|
641 // ---------------------------------------------------- |
|
642 // CMceGeneralSettingsDialog::HandleMemoryInUseDialogL |
|
643 // handles Memory in Use option |
|
644 // |
|
645 // ---------------------------------------------------- |
|
646 void CMceGeneralSettingsDialog::HandleMemoryInUseDialogL() |
|
647 { |
|
648 if ( !ShutdownAppsL() ) |
|
649 { |
|
650 // User does not want to close open messages |
|
651 return; |
|
652 } |
|
653 |
|
654 RFs& fs=iEikonEnv->FsSession(); |
|
655 |
|
656 #ifdef RD_MULTIPLE_DRIVE |
|
657 // Memory selection dialog from Avkon |
|
658 CAknMemorySelectionDialogMultiDrive* dlg = CAknMemorySelectionDialogMultiDrive::NewL( |
|
659 ECFDDialogTypeNormal, |
|
660 0, // Default resource Id |
|
661 EFalse, |
|
662 AknCommonDialogsDynMem::EMemoryTypePhone | |
|
663 AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage | |
|
664 AknCommonDialogsDynMem::EMemoryTypeMMCExternal ); |
|
665 |
|
666 CleanupStack::PushL( dlg ); |
|
667 TInt currentDrive = TInt( iSession->CurrentDriveL() ); |
|
668 TDriveNumber driveNumber = static_cast<TDriveNumber>( currentDrive ); |
|
669 CAknMemorySelectionDialogMultiDrive::TReturnKey value = dlg->ExecuteL( driveNumber ); |
|
670 CleanupStack::PopAndDestroy( dlg ); |
|
671 |
|
672 TInt selectedDrive; |
|
673 //if the user didn't press cancel key |
|
674 if (value != CAknMemorySelectionDialogMultiDrive::ERightSoftkey ) |
|
675 { |
|
676 selectedDrive = static_cast<TInt>( driveNumber ); |
|
677 } |
|
678 // if the user press cancel |
|
679 else |
|
680 { |
|
681 return; |
|
682 } |
|
683 |
|
684 #else |
|
685 TInt currentDrive = TInt( iSession->CurrentDriveL() ); |
|
686 CAknMemorySelectionSettingPage::TMemory memory( CAknMemorySelectionSettingPage::EPhoneMemory ); |
|
687 |
|
688 CAknMemorySelectionSettingPage* dlg = CAknMemorySelectionSettingPage::NewL(); |
|
689 CleanupStack::PushL( dlg ); |
|
690 |
|
691 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_GEN_HEADING, iEikonEnv ); |
|
692 dlg->SetTitleL( *text ); |
|
693 CleanupStack::PopAndDestroy( text ); |
|
694 |
|
695 if ( currentDrive == EDriveC ) |
|
696 { |
|
697 memory = CAknMemorySelectionSettingPage::EPhoneMemory; |
|
698 } |
|
699 else |
|
700 { |
|
701 memory = CAknMemorySelectionSettingPage::EMemoryCard; |
|
702 } |
|
703 |
|
704 CAknMemorySelectionSettingPage::TReturnKey value = dlg->ExecuteL( memory ); |
|
705 CleanupStack::PopAndDestroy( dlg ); |
|
706 |
|
707 if ( value == CAknMemorySelectionSettingPage::ERightSoftkey ) |
|
708 //Cancel was pressed; |
|
709 { |
|
710 return; |
|
711 } |
|
712 |
|
713 TInt selectedDrive; |
|
714 if ( memory == CAknMemorySelectionSettingPage::EPhoneMemory ) |
|
715 { |
|
716 selectedDrive = EDriveC; |
|
717 } |
|
718 else |
|
719 { |
|
720 selectedDrive = EDriveE; |
|
721 } |
|
722 #endif // RD_MULTIPLE_DRIVE |
|
723 |
|
724 if (selectedDrive == currentDrive ) |
|
725 { |
|
726 // no change, memory has not been changed |
|
727 UpdateMemorySelectionL(); |
|
728 return; |
|
729 } |
|
730 else |
|
731 { |
|
732 TBool storeExist = EFalse; |
|
733 TRAPD( error, storeExist = iSession->DriveContainsStoreL( selectedDrive ) ); |
|
734 |
|
735 if ( !error && storeExist ) |
|
736 { |
|
737 //if server is busy, do not change store |
|
738 if( CheckIsServerBusyL() ) |
|
739 { |
|
740 return; |
|
741 } |
|
742 |
|
743 // change message store |
|
744 CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC(); |
|
745 |
|
746 CMsvProgressReporterOperation* reportOp = |
|
747 CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus ); |
|
748 CleanupStack::PushL( reportOp ); |
|
749 |
|
750 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, |
|
751 iEikonEnv ); |
|
752 reportOp->SetTitleL( *text ); |
|
753 |
|
754 reportOp->SetCanCancelL( EFalse); |
|
755 |
|
756 CleanupStack::PopAndDestroy( text ); |
|
757 |
|
758 CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, reportOp->RequestStatus() ); |
|
759 reportOp->SetOperationL( changeOp ); |
|
760 |
|
761 waiter->Start(); |
|
762 |
|
763 CleanupStack::PopAndDestroy( reportOp ); |
|
764 CleanupStack::PopAndDestroy( waiter ); |
|
765 |
|
766 //memory has been changed |
|
767 UpdateMemorySelectionL(); |
|
768 } |
|
769 else |
|
770 { |
|
771 //#ifdef RD_MULTIPLE_DRIVE |
|
772 // //Todo: Check the memory statue here, if it's read-only then show error note |
|
773 // // Wait for UIcr approved |
|
774 // TUint driveStatus( 0 ); |
|
775 // User::LeaveIfError( DriveInfo::GetDriveStatus( fs, driveNumber, driveStatus ) ); |
|
776 // if ( driveStatus & DriveInfo::EDriveReadOnly ) |
|
777 // { |
|
778 // HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_CANNOT_MOVE_STORE, |
|
779 // CCoeEnv::Static() ); |
|
780 // CAknErrorNote* note = new (ELeave) CAknErrorNote(); |
|
781 // note->ExecuteLD(*text); |
|
782 // CleanupStack::PopAndDestroy( text ); |
|
783 // |
|
784 // return; |
|
785 // } |
|
786 //#endif |
|
787 |
|
788 // copy/move message store |
|
789 CAknQueryDialog* moveDialog = CAknQueryDialog::NewL(); |
|
790 |
|
791 // Do you want to copy all messages to the messaging store? |
|
792 if ( moveDialog->ExecuteLD( R_MCE_MOVE_CONFIRM ) ) |
|
793 { |
|
794 // Yes: |
|
795 // other question: Do you want to save the original messages? |
|
796 CAknQueryDialog* movesaveDialog = CAknQueryDialog::NewL(); |
|
797 |
|
798 HBufC* text = NULL; |
|
799 text = StringLoader::LoadLC( R_MCE_MOVE_SAVE_CONFIRM, CCoeEnv::Static() ); |
|
800 movesaveDialog->SetPromptL( *text ); |
|
801 CleanupStack::PopAndDestroy( text ); |
|
802 |
|
803 if ( movesaveDialog->ExecuteLD( R_MCE_MOVE_CONFIRM ) ) |
|
804 { |
|
805 //Yes: Copy messages |
|
806 MoveMessageStoreL( currentDrive, selectedDrive, EFalse ); |
|
807 } |
|
808 else |
|
809 { |
|
810 //No: Move messages |
|
811 MoveMessageStoreL( currentDrive, selectedDrive, ETrue ); |
|
812 } |
|
813 } |
|
814 else |
|
815 { |
|
816 // No: show empty message storage |
|
817 |
|
818 //if server is busy, do not change store |
|
819 if( CheckIsServerBusyL() ) |
|
820 { |
|
821 return; |
|
822 } |
|
823 |
|
824 // when empty store is created, it takes memory about 40kb |
|
825 // check first free memory |
|
826 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iEikonEnv->FsSession(), |
|
827 KMceEmptyMessageStore, selectedDrive ) ) |
|
828 { |
|
829 User::Leave( KErrDiskFull ); |
|
830 } |
|
831 |
|
832 CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC(); |
|
833 |
|
834 CMsvProgressReporterOperation* reportOp = |
|
835 CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus ); |
|
836 CleanupStack::PushL( reportOp ); |
|
837 |
|
838 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, |
|
839 iEikonEnv ); |
|
840 reportOp->SetTitleL( *text ); |
|
841 |
|
842 reportOp->SetCanCancelL( EFalse); |
|
843 |
|
844 CleanupStack::PopAndDestroy( text ); |
|
845 |
|
846 CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, |
|
847 reportOp->RequestStatus() ); |
|
848 reportOp->SetOperationL( changeOp ); |
|
849 |
|
850 waiter->Start(); |
|
851 |
|
852 CleanupStack::PopAndDestroy( reportOp ); |
|
853 CleanupStack::PopAndDestroy( waiter ); |
|
854 UpdateMemorySelectionL(); |
|
855 } |
|
856 } |
|
857 |
|
858 CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, |
|
859 Control( EMceSettingsIdOtherItems ) ); |
|
860 list->DrawNow(); |
|
861 } |
|
862 } |
|
863 |
|
864 |
|
865 // ---------------------------------------------------- |
|
866 // CMceGeneralSettingsDialog::GetHelpContext |
|
867 // returns helpcontext as aContext |
|
868 // |
|
869 // ---------------------------------------------------- |
|
870 void CMceGeneralSettingsDialog::GetHelpContext |
|
871 ( TCoeHelpContext& aContext ) const |
|
872 { |
|
873 aContext.iMajor = KMceApplicationUid; |
|
874 aContext.iContext = KMCE_HLP_SETTINGS_GEN; |
|
875 } |
|
876 |
|
877 // ---------------------------------------------------- |
|
878 // CMceGeneralSettingsDialog::DynInitMenuPaneL |
|
879 // ---------------------------------------------------- |
|
880 void CMceGeneralSettingsDialog::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
881 { |
|
882 if ( aResourceId == R_MCE_GENERAL_SETTINGS_CHOICE_MENUPANE ) |
|
883 { |
|
884 aMenuPane->SetItemDimmed( EMceSettingsCmdSettingsDialogHelp, |
|
885 !FeatureManager::FeatureSupported( KFeatureIdHelp ) ); |
|
886 } |
|
887 } |
|
888 |
|
889 // ---------------------------------------------------- |
|
890 // CMceGeneralSettingsDialog::LaunchHelpL |
|
891 // Launch help using context |
|
892 // |
|
893 // ---------------------------------------------------- |
|
894 void CMceGeneralSettingsDialog::LaunchHelpL() const |
|
895 { |
|
896 CCoeAppUi* appUi = STATIC_CAST( CCoeAppUi*, ControlEnv()->AppUi() ); |
|
897 CArrayFix<TCoeHelpContext>* helpContext = appUi->AppHelpContextL(); |
|
898 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext ); |
|
899 } |
|
900 |
|
901 // ---------------------------------------------------- |
|
902 // CMceGeneralSettingsDialog::ChangeMessageStoreL |
|
903 // Changes the drive of the message store |
|
904 // |
|
905 // ---------------------------------------------------- |
|
906 #ifdef RD_MULTIPLE_DRIVE |
|
907 void CMceGeneralSettingsDialog::ChangeMessageStoreL( TInt aTargetDrive ) |
|
908 #else |
|
909 void CMceGeneralSettingsDialog::ChangeMessageStoreL() |
|
910 #endif //RD_MULTIPLE_DRIVE |
|
911 { |
|
912 //if server is busy, do not change store |
|
913 if( CheckIsServerBusyL() ) |
|
914 { |
|
915 return; |
|
916 } |
|
917 |
|
918 RFs& fs=iEikonEnv->FsSession(); |
|
919 |
|
920 TInt driveNumber; |
|
921 |
|
922 #ifdef RD_MULTIPLE_DRIVE |
|
923 driveNumber = aTargetDrive; |
|
924 #else |
|
925 // Get the current drive |
|
926 TInt currentDrive=TInt( iSession->CurrentDriveL() ); |
|
927 |
|
928 if ( currentDrive == EDriveC ) |
|
929 { |
|
930 driveNumber = EDriveE; |
|
931 } |
|
932 else |
|
933 { |
|
934 driveNumber = EDriveC; |
|
935 } |
|
936 #endif //RD_MULTIPLE_DRIVE |
|
937 |
|
938 // change message store |
|
939 CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC(); |
|
940 |
|
941 CMsvProgressReporterOperation* reportOp = |
|
942 CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus ); |
|
943 CleanupStack::PushL( reportOp ); |
|
944 |
|
945 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, |
|
946 iEikonEnv ); |
|
947 reportOp->SetTitleL( *text ); |
|
948 |
|
949 reportOp->SetCanCancelL( EFalse ); |
|
950 |
|
951 CleanupStack::PopAndDestroy( text ); |
|
952 |
|
953 CMsvOperation* changeOp=iSession->ChangeDriveL( driveNumber, reportOp->RequestStatus() ); |
|
954 reportOp->SetOperationL( changeOp ); |
|
955 |
|
956 waiter->Start(); |
|
957 |
|
958 CleanupStack::PopAndDestroy( reportOp ); |
|
959 CleanupStack::PopAndDestroy( waiter ); |
|
960 } |
|
961 |
|
962 |
|
963 // ---------------------------------------------------- |
|
964 // void CMceGeneralSettingsDialog::SetMSKButtonL() |
|
965 // ---------------------------------------------------- |
|
966 void CMceGeneralSettingsDialog::SetMSKButtonL() |
|
967 { |
|
968 CEikTextListBox* list=STATIC_CAST( |
|
969 CEikTextListBox*, |
|
970 Control( EMceSettingsIdOtherItems) ); |
|
971 const TInt index = list->CurrentItemIndex(); |
|
972 const TInt numberOfItem = list->Model()->NumberOfItems(); |
|
973 const TInt resourceId = index==0 ? |
|
974 R_MCE_MSK_BUTTON_CHANGE : R_MCE_MSK_BUTTON_OPEN; |
|
975 CEikButtonGroupContainer& cba = ButtonGroupContainer(); |
|
976 cba.SetCommandL( KMSKPosition, resourceId ); |
|
977 cba.DrawNow(); |
|
978 } |
|
979 |
|
980 #ifdef RD_MULTIPLE_DRIVE |
|
981 // ---------------------------------------------------- |
|
982 // CMceGeneralSettingsDialog::MakeDriveNameStringLC |
|
983 // ---------------------------------------------------- |
|
984 HBufC* CMceGeneralSettingsDialog::MakeDriveNameStringLC( TInt aDriveNumber ) |
|
985 { |
|
986 // get drive later and delimiter, e.g. "C:" |
|
987 TDriveName driveName(TDriveUnit( aDriveNumber ).Name() ); |
|
988 |
|
989 TUint driveStatus( 0 ); |
|
990 RFs& fs=iEikonEnv->FsSession(); |
|
991 User::LeaveIfError( DriveInfo::GetDriveStatus( fs, aDriveNumber, driveStatus ) ); |
|
992 |
|
993 //Following flitters are referred to filemanager application |
|
994 if ( driveStatus & DriveInfo::EDriveInternal ) |
|
995 { |
|
996 //Device Memory and Mass storage drives |
|
997 if ( driveStatus & DriveInfo::EDriveExternallyMountable ) |
|
998 { |
|
999 return StringLoader::LoadLC( R_MCE_SETT_MEM_MASS_STORAGE, driveName, iEikonEnv ); |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 return StringLoader::LoadLC( R_MCE_SETT_MEM_DEVICE, driveName, iEikonEnv ); |
|
1004 } |
|
1005 } |
|
1006 //memory card |
|
1007 else |
|
1008 { |
|
1009 return StringLoader::LoadLC( R_MCE_SETT_MEM_MEMORY_CARD, driveName, iEikonEnv ); |
|
1010 } |
|
1011 } |
|
1012 #endif //RD_MULTIPLE_DRIVE |
|
1013 // End of File |