|
1 /* |
|
2 * Copyright (c) 2006-2006 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: Base class for the Settings View |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <bldvariant.hrh> |
|
20 #include <featmgr.h> |
|
21 #include <hlplch.h> |
|
22 #include <pathinfo.h> |
|
23 #include <stringloader.h> |
|
24 #include <bautils.h> |
|
25 #include "ir.hrh" |
|
26 #include "ircommonsettingscontainer.h" |
|
27 #include "irsettingsviewbase.h" |
|
28 #include "irdebug.h" |
|
29 #include <internetradio.rsg> |
|
30 #include <aknappui.h> |
|
31 #include <akntitle.h> |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 // Settings view resource file. |
|
37 _LIT( KIRSettingsViewResourceFile, "apps\\internetradio.rsc" ); |
|
38 |
|
39 // ======== LOCAL FUNCTIONS ======== |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // Default constructor |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C CIRSettingsViewBase::CIRSettingsViewBase() |
|
49 : iSettingsBaseResourceLoader( *iCoeEnv ) |
|
50 { |
|
51 IRLOG_DEBUG( "CIRSettingsViewBase::CIRSettingsViewBase " ); |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Second phase constructor |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C void CIRSettingsViewBase::BaseConstructL() |
|
59 { |
|
60 IRLOG_DEBUG( "CIRSettingsViewBase::BaseConstructL - Entering " ); |
|
61 FeatureManager::InitializeLibL(); |
|
62 LoadResourcesL( iSettingsBaseResourceLoader, KIRSettingsViewResourceFile ); |
|
63 CAknView::BaseConstructL( R_IR_SETTINGSVIEW ); |
|
64 IRLOG_DEBUG( "CIRSettingsViewBase::BaseConstructL - Exiting " ); |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 EXPORT_C CIRSettingsViewBase::~CIRSettingsViewBase() |
|
72 { |
|
73 IRLOG_DEBUG( "CIRSettingsViewBase::~CIRSettingsViewBase - Entering " ); |
|
74 DeleteContainer(); |
|
75 FeatureManager::UnInitializeLib(); |
|
76 iSettingsBaseResourceLoader.Close(); |
|
77 IRLOG_DEBUG( "CIRSettingsViewBase::~CIRSettingsViewBase - Exiting " ); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // LoadResourcesL() |
|
82 // Loads the required resources. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 EXPORT_C void CIRSettingsViewBase::LoadResourcesL( RConeResourceLoader& aResourceLoader, |
|
86 const TDesC& aFileName ) |
|
87 { |
|
88 IRLOG_DEBUG( "CIRSettingsViewBase::LoadResourcesL - Entering " ); |
|
89 TFileName resourceFileName( KDC_RESOURCE_FILES_DIR ); |
|
90 resourceFileName.Append(aFileName); |
|
91 |
|
92 ResolveDriveL( iCoeEnv->FsSession(), resourceFileName ); |
|
93 |
|
94 aResourceLoader.OpenL( resourceFileName ); |
|
95 IRLOG_DEBUG( "CIRSettingsViewBase::LoadResourcesL - Exiting " ); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // DoActivateL() |
|
100 // View activation |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C void CIRSettingsViewBase::DoActivateL( const TVwsViewId& aPrevViewId, |
|
104 TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) |
|
105 { |
|
106 IRLOG_DEBUG( "CIRSettingsViewBase::DoActivateL - Entering." ); |
|
107 |
|
108 CreateContainerL(); |
|
109 |
|
110 StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
111 |
|
112 iContainer->SetMopParent( this ); |
|
113 AppUi()->AddToViewStackL( *this, iContainer ); |
|
114 iContainer->ActivateL(); |
|
115 iContainer->MakeVisible( ETrue ); |
|
116 |
|
117 iPrevViewUid = aPrevViewId.iViewUid; |
|
118 IRLOG_DEBUG( "CIRSettingsViewBase::DoActivateL - Exiting " ); |
|
119 |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // DoDeactivate() |
|
124 // View deactivation |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CIRSettingsViewBase::DoDeactivate() |
|
128 { |
|
129 IRLOG_DEBUG( "CIRSettingsViewBase::DoDeactivate - Entering " ); |
|
130 DeleteContainer(); |
|
131 IRLOG_DEBUG( "CIRSettingsViewBase::DoDeactivate - Exiting " ); |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // HandleCommandL() |
|
136 // Command handler. |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C void CIRSettingsViewBase::HandleCommandL( TInt aCommand ) |
|
140 { |
|
141 IRRDEBUG2( " *** Internet Radio -- CIRSettingsViewBase::HandleCommandL(%d)", aCommand ); |
|
142 switch ( aCommand ) |
|
143 { |
|
144 case EIRCmdChangeSetting: //Falls through |
|
145 case EAknSoftkeyChange: |
|
146 { |
|
147 TBool calledFromMenu = ( aCommand == EIRCmdChangeSetting); |
|
148 iContainer->EditCurrentItemL( calledFromMenu ); |
|
149 break; |
|
150 } |
|
151 |
|
152 case EHelpCmd: |
|
153 { |
|
154 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
155 AppUi()->AppHelpContextL() ); |
|
156 } |
|
157 break; |
|
158 |
|
159 //Only if invoked from settings plugin |
|
160 case EAknSoftkeyBack: |
|
161 case EIRBack: |
|
162 { |
|
163 AppUi()->ActivateLocalViewL( iPrevViewUid ); |
|
164 } |
|
165 break; |
|
166 |
|
167 case EEikCmdExit: |
|
168 case EExitCmd: //lint -fallthrough |
|
169 case EIRExit: |
|
170 case EAknSoftkeyExit: |
|
171 { |
|
172 AppUi()->HandleCommandL(aCommand); |
|
173 } |
|
174 |
|
175 break; |
|
176 |
|
177 default: |
|
178 AppUi()->HandleCommandL(aCommand); |
|
179 break; |
|
180 } |
|
181 IRLOG_DEBUG( "CIRSettingsViewBase::HandleCommandL - Exiting " ); |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // HandleForegroundEventL() |
|
186 // Handles changes in keyboard focus when an application switches to foreground |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 |
|
190 EXPORT_C void CIRSettingsViewBase::HandleForegroundEventL( TBool aForeground ) |
|
191 { |
|
192 IRLOG_DEBUG( "CIRSettingsViewBase::HandleForegroundEventL - Entering " ); |
|
193 if(aForeground) |
|
194 { |
|
195 iContainer->UpdateStatusL(); |
|
196 } |
|
197 IRLOG_DEBUG( "CIRSettingsViewBase::HandleForegroundEventL - Exiting " ); |
|
198 } |
|
199 |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // SetTitleL() |
|
203 // Sets the Title of the View |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 |
|
207 EXPORT_C void CIRSettingsViewBase::SetTitleL( TInt aResourceId ) |
|
208 { |
|
209 IRLOG_DEBUG( "CIRSettingsViewBase::SetTitleL - Entering " ); |
|
210 HBufC* title = StringLoader::LoadLC(aResourceId); |
|
211 static_cast<CAknTitlePane*>( StatusPane()->ControlL( |
|
212 TUid::Uid( EEikStatusPaneUidTitle ) ) )->SetTextL( *title ); |
|
213 CleanupStack::PopAndDestroy( title ); |
|
214 IRLOG_DEBUG( "CIRSettingsViewBase::SetTitleL - Exiting " ); |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // DeleteContainer() |
|
219 // Deletes container |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CIRSettingsViewBase::DeleteContainer() |
|
223 { |
|
224 IRLOG_DEBUG( "CIRSettingsViewBase::DeleteContainer - Entering " ); |
|
225 if ( iContainer ) |
|
226 { |
|
227 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
228 delete iContainer; |
|
229 iContainer = NULL; |
|
230 } |
|
231 IRLOG_DEBUG( "CIRSettingsViewBase::DeleteContainer - Exiting " ); |
|
232 } |
|
233 |
|
234 // --------------------------------------------------------------------------- |
|
235 // Static version of ResolveDriveL. |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 EXPORT_C void CIRSettingsViewBase::ResolveDriveL( const RFs& aFs, TFileName& aFileName ) |
|
239 { |
|
240 IRRDEBUG2( "CIRSettingsViewBase::ResolveDriveL( aFileName = %S )", &aFileName ); |
|
241 |
|
242 _LIT( resourceFileExt, ".rsc" ); |
|
243 |
|
244 TParsePtrC romDrive( PathInfo::RomRootPath() ); |
|
245 TParsePtrC phoneDrive( PathInfo::PhoneMemoryRootPath() ); |
|
246 TParsePtrC mmcDrive( PathInfo::MemoryCardRootPath() ); |
|
247 |
|
248 TParse parse; |
|
249 User::LeaveIfError( parse.Set( mmcDrive.Drive(), NULL, &aFileName ) ); |
|
250 |
|
251 TBool isResourceFile = (parse.Ext() == resourceFileExt()); |
|
252 |
|
253 aFileName = parse.FullName(); |
|
254 |
|
255 if ( isResourceFile ) |
|
256 { |
|
257 BaflUtils::NearestLanguageFile( aFs, aFileName ); |
|
258 } |
|
259 |
|
260 if ( !BaflUtils::FileExists( aFs, aFileName ) ) |
|
261 { |
|
262 User::LeaveIfError( parse.Set( phoneDrive.Drive(), NULL, &aFileName ) ); |
|
263 aFileName = parse.FullName(); |
|
264 |
|
265 if ( isResourceFile ) |
|
266 { |
|
267 BaflUtils::NearestLanguageFile( aFs, aFileName ); |
|
268 } |
|
269 |
|
270 if ( !BaflUtils::FileExists( aFs, aFileName ) ) |
|
271 { |
|
272 User::LeaveIfError( parse.Set( romDrive.Drive(), NULL, &aFileName ) ); |
|
273 aFileName = parse.FullName(); |
|
274 |
|
275 if ( isResourceFile ) |
|
276 { |
|
277 BaflUtils::NearestLanguageFile( aFs, aFileName ); |
|
278 } |
|
279 |
|
280 if ( !BaflUtils::FileExists( aFs, aFileName ) ) |
|
281 { |
|
282 IRRDEBUG2( "CVRSettings::ResolveDriveL - File %S not found!", &aFileName ); |
|
283 User::Leave( KErrNotFound ); |
|
284 } |
|
285 } |
|
286 } |
|
287 |
|
288 IRRDEBUG2( "CIRSettingsViewBase::ResolveDriveL( aFileName = %S )", &aFileName ); |
|
289 } |
|
290 |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // GetCaptionL() |
|
294 // Gets the caption |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 |
|
298 EXPORT_C void CIRSettingsViewBase::GetCaptionL( TDes& aCaption ) const |
|
299 { |
|
300 IRLOG_DEBUG( "CIRSettingsViewBase::GetCaptionL - Entering " ); |
|
301 aCaption.Zero(); |
|
302 IRLOG_DEBUG( "CIRSettingsViewBase::GetCaptionL - Exiting " ); |
|
303 return; |
|
304 } |
|
305 // ======== GLOBAL FUNCTIONS ======== |