|
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: Setting page used to selection target memory. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <commondialogs.rsg> |
|
21 #include <pathinfo.h> |
|
22 #include <driveinfo.h> //DriveInfo |
|
23 |
|
24 #include "CAknMemorySelectionSettingPage.h" |
|
25 #include "CAknMemorySelectionModel.h" // KMemorySelectionGranularity |
|
26 #include "CAknCommonDialogsRadioButtonSettingPage.h" |
|
27 #include "CAknMemorySelectionEventHandler.h" |
|
28 #include "MAknCommonDialogsEventObserver.h" |
|
29 #include "AknCFDUtility.h" |
|
30 |
|
31 |
|
32 // ======== MEMBER FUNCTIONS ======== |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CAknMemorySelectionSettingPage::CAknMemorySelectionSettingPage |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CAknMemorySelectionSettingPage::CAknMemorySelectionSettingPage() |
|
39 : CAknMemorySelectionDialog( ECFDDialogTypeDefaultSetting ) |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CAknMemorySelectionSettingPage::NewL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CAknMemorySelectionSettingPage* CAknMemorySelectionSettingPage::NewL() |
|
48 { |
|
49 return NewL( 0 ); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CAknMemorySelectionSettingPage::NewL |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CAknMemorySelectionSettingPage* CAknMemorySelectionSettingPage::NewL( |
|
57 TInt aResourceId ) |
|
58 { |
|
59 CAknMemorySelectionSettingPage* self = new( ELeave ) CAknMemorySelectionSettingPage(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructFromResourceL( aResourceId, ETrue ); |
|
62 CleanupStack::Pop(); // self |
|
63 return self; |
|
64 } |
|
65 |
|
66 // Destructor |
|
67 EXPORT_C CAknMemorySelectionSettingPage::~CAknMemorySelectionSettingPage() |
|
68 { |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CAknMemorySelectionSettingPage::ExecuteL |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C CAknCommonDialogsBase::TReturnKey CAknMemorySelectionSettingPage::ExecuteL( |
|
76 TMemory& aSelectedMemory ) |
|
77 { |
|
78 return ExecuteL( aSelectedMemory, NULL, NULL ); |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CAknMemorySelectionSettingPage::ExecuteL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C CAknCommonDialogsBase::TReturnKey |
|
86 CAknMemorySelectionSettingPage::ExecuteL( |
|
87 TMemory& aSelectedMemory, TDes* aRootPath, TDes* aDefaultFolder ) |
|
88 { |
|
89 __ASSERT_DEBUG( iTitle && iLeftSoftkey && iRightSoftkey, |
|
90 User::Panic( KCFDPanicText, ECFDPanicTitleOrSoftkeyNotSet ) ); |
|
91 |
|
92 TInt selectedItem( aSelectedMemory ); |
|
93 |
|
94 CAknCommonDialogsRadioButtonSettingPage* dlg = |
|
95 new( ELeave ) CAknCommonDialogsRadioButtonSettingPage( |
|
96 R_CFD_RADIOBUTTON_SETTING_PAGE, selectedItem, iModel, *iEventHandler, iModel ); |
|
97 CleanupStack::PushL( dlg ); |
|
98 dlg->ConstructL(); |
|
99 dlg->SetSettingTextL( *iTitle ); |
|
100 CEikButtonGroupContainer* cba = dlg->Cba(); |
|
101 MEikButtonGroup* buttonGroup = cba->ButtonGroup(); |
|
102 cba->SetCommandL( buttonGroup->CommandId( 0 ), *iLeftSoftkey ); |
|
103 cba->SetCommandL( buttonGroup->CommandId( 2 ), *iRightSoftkey ); |
|
104 |
|
105 TDriveNumber memoryCardDrive; |
|
106 User::LeaveIfError( |
|
107 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, |
|
108 ( TInt& )memoryCardDrive ) ); |
|
109 TCFDDriveStatus driveStatus = AknCFDUtility::DriveStatusL( memoryCardDrive ); |
|
110 |
|
111 // If the selected memory is MMC but it is not ready, make LSK invisible: |
|
112 if( ( aSelectedMemory == EMemoryCard ) && |
|
113 ( driveStatus == EDriveNotReady ) ) |
|
114 { |
|
115 cba->MakeCommandVisible( buttonGroup->CommandId( 0 ), |
|
116 TBool( EFalse ) ); |
|
117 } |
|
118 |
|
119 // Start listen to NotifyDisk only if MMC is unavailable |
|
120 TBool ifNotifyDisk = EFalse; |
|
121 if ( driveStatus == EDriveNotReady ) |
|
122 { |
|
123 iEventHandler->StartNotifyDisk(dlg); |
|
124 ifNotifyDisk = ETrue; |
|
125 } |
|
126 |
|
127 // CAknSettingPage::ExecuteLD pushes itself to cleanup stack. |
|
128 CleanupStack::Pop(); // dlg |
|
129 TBool returnValue( dlg->ExecuteLD() ); |
|
130 |
|
131 // Stop notifyDisk if started |
|
132 if (ifNotifyDisk) |
|
133 { |
|
134 iEventHandler->StopNotifyDisk(); |
|
135 } |
|
136 |
|
137 if( returnValue ) // If user accepted selection |
|
138 { |
|
139 // Change value to user selected EEikListBoxMultipleSelection |
|
140 aSelectedMemory = TMemory( selectedItem ); |
|
141 GetMemories( aSelectedMemory, aRootPath, aDefaultFolder ); |
|
142 } |
|
143 // There is no need to know if the selection is done with left or right |
|
144 // softkey and there is no support for it in the |
|
145 // CAknCommonDialogsRadioButtonSettingPage |
|
146 return TReturnKey( returnValue ); |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CAknMemorySelectionSettingPage::RunDlgLD |
|
151 // A wrapper for RunL. |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 EXPORT_C TBool CAknMemorySelectionSettingPage::RunDlgLD( |
|
155 TMemory& aSelectedMemory, |
|
156 MAknMemorySelectionObserver* aObserver ) |
|
157 { |
|
158 return RunL( 0, aSelectedMemory, KNullDesC, NULL, NULL, aObserver ); |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // CAknMemorySelectionSettingPage::RunDlgLD |
|
163 // A wrapper for RunL. |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 EXPORT_C TBool CAknMemorySelectionSettingPage::RunDlgLD( |
|
167 TMemory& aSelectedMemory, |
|
168 const TDesC& aTitle, |
|
169 MAknMemorySelectionObserver* aObserver ) |
|
170 { |
|
171 return RunL( 0, aSelectedMemory, aTitle, NULL, NULL, aObserver ); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CAknMemorySelectionSettingPage::RunDlgLD |
|
176 // A wrapper for RunL. |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 EXPORT_C TBool CAknMemorySelectionSettingPage::RunDlgLD( |
|
180 TMemory& aSelectedMemory, |
|
181 TInt aResourceId, |
|
182 TDes* aRootPath, TDes* aDefaultFolder, |
|
183 MAknMemorySelectionObserver* aObserver ) |
|
184 { |
|
185 return RunL( aResourceId, aSelectedMemory, KNullDesC, aRootPath, aDefaultFolder, aObserver ); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CAknMemorySelectionSettingPage::RunL |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 TBool CAknMemorySelectionSettingPage::RunL( |
|
193 TInt aResourceId, |
|
194 TMemory& aSelectedMemory, |
|
195 const TDesC& aTitle, |
|
196 TDes* aRootPath, |
|
197 TDes* aDefaultFolder, |
|
198 MAknMemorySelectionObserver* aObserver ) |
|
199 { |
|
200 CAknMemorySelectionSettingPage* self = |
|
201 CAknMemorySelectionSettingPage::NewL( aResourceId ); |
|
202 CleanupStack::PushL( self ); |
|
203 self->iObserver = aObserver; |
|
204 self->SetTitleL( aTitle ); |
|
205 |
|
206 TBool returnValue( |
|
207 self->ExecuteL( aSelectedMemory, aRootPath, aDefaultFolder ) |
|
208 ); |
|
209 |
|
210 CleanupStack::PopAndDestroy(); |
|
211 return returnValue; |
|
212 } |