|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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: Application UI class required by AVKON application architecture.* |
|
15 */ |
|
16 |
|
17 |
|
18 // Version : %version: 7 % |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <MediaSettings.rsg> |
|
24 #include <avkon.hrh> |
|
25 #include <barsread.h> |
|
26 #include <akntabgrp.h> |
|
27 #include <featmgr.h> |
|
28 #include <hlplch.h> |
|
29 #include <StringLoader.h> |
|
30 #include <AknsUtils.h> |
|
31 #include <mediasettings.mbg> |
|
32 |
|
33 #include "mediasettings.hrh" |
|
34 #include "MPSettingsAppUi.h" |
|
35 #include "MPSettingsMainView.h" |
|
36 #include "MPSettingsVideoView.h" |
|
37 #include "MPSettingsStreamingView.h" |
|
38 #include "MPSettingsProxyView.h" |
|
39 #include "MPSettingsNetworkView.h" |
|
40 #include "MPSettingsConstants.h" |
|
41 #include "MPSettingsPluginView.h" |
|
42 #include "MPSettingsAdvancedBwView.h" |
|
43 #include "MPSettingsDocument.h" |
|
44 #include "mpsettingsmodel.h" |
|
45 #include "MPSettingsModelForROP.h" |
|
46 #include "mpxlog.h" |
|
47 #include "feedsettingsview.h" |
|
48 |
|
49 // CONSTANTS |
|
50 const TInt KMPSettViewIdArrayGranularity = 3; |
|
51 |
|
52 // ================= MEMBER FUNCTIONS ======================= |
|
53 // |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CMPSettingsAppUi::CMPSettingsAppUi |
|
57 // C++ default constructor can NOT contain any code, that |
|
58 // might leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CMPSettingsAppUi::CMPSettingsAppUi() : iConstructAsGsPlugin(EFalse) |
|
62 { |
|
63 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::CMPSettingsAppUi()")); |
|
64 } |
|
65 |
|
66 // ---------------------------------------------------------- |
|
67 // CMPSettingsAppUi::ConstructL() |
|
68 // Symbian OS default constructor. |
|
69 // ---------------------------------------------------------- |
|
70 // |
|
71 void CMPSettingsAppUi::ConstructL() |
|
72 { |
|
73 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::ConstructL()")); |
|
74 // Enable skin support in base construction |
|
75 BaseConstructL( EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible ); |
|
76 |
|
77 // Sets up TLS, must be done before FeatureManager is used. |
|
78 FeatureManager::InitializeLibL(); |
|
79 |
|
80 CMPSettingsDocument* doc = static_cast<CMPSettingsDocument*>(static_cast<CEikAppUi*> |
|
81 (CEikonEnv::Static()->AppUi())->Document()); |
|
82 iModel = doc->SettingsModel(); |
|
83 iRopModel = static_cast<CMPSettingsModelForROP*>(iModel); |
|
84 |
|
85 // Fetch pointer to the default navi pane control |
|
86 CEikStatusPane* sp = StatusPane(); |
|
87 iNaviPane = static_cast<CAknNavigationControlContainer*> |
|
88 (sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); |
|
89 |
|
90 // Construct navipane tabs |
|
91 iDecoratedTabGroup = iNaviPane->CreateTabGroupL(this); |
|
92 |
|
93 // Construct tabs |
|
94 AddTabSettingsGroupL(); |
|
95 |
|
96 // Create vector which contains view id's for all setting folders. |
|
97 iViewIds = new(ELeave) CArrayFixFlat<TUid>(KMPSettViewIdArrayGranularity); |
|
98 iViewIds->AppendL(KMPSettVideoViewId); |
|
99 iViewIds->AppendL(KMPSettStreamingViewId); |
|
100 iViewIds->AppendL(KMPSettFeedsViewId); |
|
101 |
|
102 // * Create application views * |
|
103 |
|
104 CAknView* view; |
|
105 |
|
106 view = CMPSettingsMainView::NewLC(iViewIds,iRopModel,iConstructAsGsPlugin); |
|
107 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
108 CleanupStack::Pop(); // view |
|
109 |
|
110 // iMainView is not owned, i.e. it is not deleted in the destructor -> |
|
111 // main view cannot be directly creted to iMainView, as it's against the coding |
|
112 // conventions to place class' pointers to cleanup stack => static_cast. |
|
113 iMainView = static_cast<CMPSettingsMainView*>(view); |
|
114 |
|
115 view = CMPSettingsVideoView::NewLC(iRopModel); |
|
116 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
117 CleanupStack::Pop(); // view |
|
118 |
|
119 view = CMPSettingsStreamingView::NewLC(iRopModel); |
|
120 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
121 CleanupStack::Pop(); // view |
|
122 |
|
123 view = CVcxNsSettingsView::NewLC(); |
|
124 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
125 CleanupStack::Pop(); // view |
|
126 |
|
127 view = CMPSettingsProxyView::NewLC(iRopModel,iConstructAsGsPlugin); |
|
128 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
129 CleanupStack::Pop(); // view |
|
130 |
|
131 view = CMPSettingsNetworkView::NewLC(iRopModel,iConstructAsGsPlugin); |
|
132 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
133 CleanupStack::Pop(); // view |
|
134 |
|
135 view = CMPSettingsAdvancedBwView::NewLC(iRopModel,iConstructAsGsPlugin); |
|
136 AddViewL(view); // transfer ownership to CAknViewAppUi |
|
137 CleanupStack::Pop(); // view |
|
138 |
|
139 |
|
140 // Construct plug-in views (if any exists) |
|
141 CMPSettingsPluginView::ListImplementationsL(iImplInfoArray); |
|
142 TInt count = iImplInfoArray.Count(); |
|
143 |
|
144 if (count > 0) |
|
145 { |
|
146 CMPSettingsPluginView* pluginView = NULL; |
|
147 |
|
148 for (TInt ii(0); ii < count; ++ii) |
|
149 { |
|
150 TUid uid = iImplInfoArray[ii]->ImplementationUid(); |
|
151 pluginView = CMPSettingsPluginView::NewL(uid); |
|
152 CleanupStack::PushL(pluginView); |
|
153 AddViewL(pluginView); |
|
154 CleanupStack::Pop(); // pluginView |
|
155 |
|
156 if (pluginView->OpenedFromMainView()) |
|
157 { |
|
158 iViewIds->AppendL(pluginView->Id()); |
|
159 } |
|
160 } |
|
161 |
|
162 // Sort UID array to rising order |
|
163 TKeyArrayFix sortKey(0, ECmpTUint); |
|
164 User::LeaveIfError(iViewIds->Sort(sortKey)); |
|
165 } |
|
166 |
|
167 SetDefaultViewL(*iMainView); |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------- |
|
171 // CMPSettingsAppUi::~CMPSettingsAppUi |
|
172 // Destructor |
|
173 // Frees reserved resources |
|
174 // ---------------------------------------------------- |
|
175 // |
|
176 CMPSettingsAppUi::~CMPSettingsAppUi() |
|
177 { |
|
178 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::~CMPSettingsAppUi()")); |
|
179 if (iDecoratedTabGroup) |
|
180 { |
|
181 delete iDecoratedTabGroup; |
|
182 } |
|
183 |
|
184 if (iDoorObserver) |
|
185 { |
|
186 iDoorObserver->NotifyExit(MApaEmbeddedDocObserver::EEmpty); |
|
187 } |
|
188 |
|
189 if (iViewIds) |
|
190 { |
|
191 delete iViewIds; |
|
192 } |
|
193 |
|
194 iImplInfoArray.ResetAndDestroy(); |
|
195 FeatureManager::UnInitializeLib(); |
|
196 } |
|
197 |
|
198 // ---------------------------------------------------- |
|
199 // CMPSettingsAppUi::HandleCommandL |
|
200 // ---------------------------------------------------- |
|
201 // |
|
202 void CMPSettingsAppUi::HandleCommandL(TInt aCommand) |
|
203 { |
|
204 MPX_DEBUG2(_L("#MS# CMPSettingsAppUi::HandleCommandL(%d)"),aCommand); |
|
205 switch (aCommand) |
|
206 { |
|
207 case EEikCmdExit: |
|
208 Exit(); |
|
209 break; |
|
210 case EMPSettCmdHelp: |
|
211 case EAknCmdHelp: |
|
212 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
213 AppHelpContextL() ); |
|
214 break; |
|
215 default: |
|
216 CAknViewAppUi::HandleCommandL(aCommand); |
|
217 break; |
|
218 } |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------- |
|
222 // CMPSettingsAppUi::HandleResourceChangeL |
|
223 // ---------------------------------------------------- |
|
224 // |
|
225 void CMPSettingsAppUi::HandleResourceChangeL( TInt aType ) |
|
226 { |
|
227 MPX_DEBUG2(_L("#MS# CMPSettingsAppUi::HandleResourceChangeL(0x%X)"),aType); |
|
228 CAknViewAppUi::HandleResourceChangeL( aType ); |
|
229 |
|
230 if( aType == KAknsMessageSkinChange ) |
|
231 { |
|
232 AddTabSettingsGroupL(); |
|
233 } |
|
234 } |
|
235 |
|
236 |
|
237 // ---------------------------------------------------- |
|
238 // CMPSettingsAppUi::TabChangedL |
|
239 // MAknTabObserver callback for handling tab changed event. |
|
240 // ---------------------------------------------------- |
|
241 // |
|
242 void CMPSettingsAppUi::TabChangedL(TInt aIndex) |
|
243 { |
|
244 MPX_DEBUG2(_L("#MS# CMPSettingsAppUi::TabChangedL(%d)"),aIndex); |
|
245 iMainView->SetActiveFolder(aIndex); |
|
246 ActivateLocalViewL(iViewIds->At(aIndex)); |
|
247 } |
|
248 |
|
249 // ---------------------------------------------------- |
|
250 // CMPSettingsAppUi::NaviContainer |
|
251 // ---------------------------------------------------- |
|
252 // |
|
253 CAknNavigationControlContainer* CMPSettingsAppUi::NaviContainer() const |
|
254 { |
|
255 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::NaviContainer()")); |
|
256 return iNaviPane; |
|
257 } |
|
258 |
|
259 // ---------------------------------------------------- |
|
260 // CMPSettingsAppUi::MPTabGroup |
|
261 // ---------------------------------------------------- |
|
262 // |
|
263 CAknNavigationDecorator* CMPSettingsAppUi::MPTabGroup() const |
|
264 { |
|
265 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::MPTabGroup()")); |
|
266 return iDecoratedTabGroup; |
|
267 } |
|
268 |
|
269 // ---------------------------------------------------- |
|
270 // CMPSettingsAppUi::UpdateTabIndex |
|
271 // Updates tabgroup. |
|
272 // ---------------------------------------------------- |
|
273 // |
|
274 void CMPSettingsAppUi::UpdateTabIndex() |
|
275 { |
|
276 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::UpdateTabIndex()")); |
|
277 iTabGroup->SetActiveTabByIndex(iMainView->ActiveFolder()); |
|
278 } |
|
279 |
|
280 // ------------------------------------------------------------------------------ |
|
281 // CMPSettingsAppUi::DynInitMenuPaneL |
|
282 // This function is called by the AVKON framework just before it displays |
|
283 // a menu pane. Its default implementation is empty, and by overriding it, |
|
284 // the application can set the state of menu items dynamically according |
|
285 // to the state of application data. |
|
286 // ------------------------------------------------------------------------------ |
|
287 // |
|
288 void CMPSettingsAppUi::DynInitMenuPaneL( |
|
289 TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) |
|
290 { |
|
291 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::DynInitMenuPaneL()")); |
|
292 } |
|
293 |
|
294 // ---------------------------------------------------- |
|
295 // CMPSettingsAppUi::HandleKeyEventL |
|
296 // Forwards key events to tabgroup when appropriate. |
|
297 // ---------------------------------------------------- |
|
298 // |
|
299 TKeyResponse CMPSettingsAppUi::HandleKeyEventL( |
|
300 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
301 { |
|
302 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::HandleKeyEventL()")); |
|
303 // Check if the event should be handled by iTabGroup |
|
304 if (aType != EEventKey || iNaviPane->Top() != iDecoratedTabGroup) |
|
305 { |
|
306 return EKeyWasNotConsumed; |
|
307 } |
|
308 |
|
309 return iTabGroup->OfferKeyEventL(aKeyEvent, aType); |
|
310 } |
|
311 |
|
312 |
|
313 // ---------------------------------------------------- |
|
314 // CMPSettingsAppUi::AddTabSettingsGroupL() |
|
315 // (Re)create tab group with skin support |
|
316 // ---------------------------------------------------- |
|
317 // |
|
318 void CMPSettingsAppUi::AddTabSettingsGroupL() |
|
319 { |
|
320 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::AddTabSettingsGroupL()")); |
|
321 TBool iPushed = EFalse; |
|
322 TFileName fileName; |
|
323 |
|
324 // switch view if in tab |
|
325 if(iNaviPane->Top() == iDecoratedTabGroup) |
|
326 { |
|
327 iNaviPane->PushDefaultL(); |
|
328 iPushed = ETrue; |
|
329 } |
|
330 |
|
331 iTabGroup = static_cast<CAknTabGroup*> |
|
332 (iDecoratedTabGroup->DecoratedControl()); |
|
333 |
|
334 iTabGroup->SetTabFixedWidthL(KTabWidthWithThreeTabs); |
|
335 |
|
336 HBufC* mbmpath = StringLoader::LoadLC(R_MPSETT_ICON_MBM_FILE); |
|
337 |
|
338 // This is done to ensure upgraded file is used first. |
|
339 // If no upgraded file is found, default file in Z: drive will be used. |
|
340 TFindFile find( CCoeEnv::Static()->FsSession() ); |
|
341 TInt err = find.FindByDir( *mbmpath, KNullDesC ); |
|
342 |
|
343 if ( err ) |
|
344 { |
|
345 fileName.Append( *mbmpath ); |
|
346 } |
|
347 else |
|
348 { |
|
349 fileName.Append( find.File() ); |
|
350 } |
|
351 |
|
352 // Create skinnable tabs |
|
353 AddTabSettingsL(KAknsIIDQgnPropSetMpVideoTab3, |
|
354 fileName, |
|
355 EMbmMediasettingsQgn_prop_set_mp_video_tab2, |
|
356 EMbmMediasettingsQgn_prop_set_mp_video_tab2_mask, |
|
357 EMPViewVideoTab); |
|
358 |
|
359 AddTabSettingsL(KAknsIIDQgnPropSetMpStreamTab3, |
|
360 fileName, |
|
361 EMbmMediasettingsQgn_prop_set_mp_stream_tab2, |
|
362 EMbmMediasettingsQgn_prop_set_mp_stream_tab2_mask, |
|
363 EMPViewStreamTab); |
|
364 |
|
365 AddTabSettingsL(KAknsIIDQgnPropSetMpStreamTab3, |
|
366 fileName, |
|
367 EMbmMediasettingsQgn_prop_set_mp_video_tab3, |
|
368 EMbmMediasettingsQgn_prop_set_mp_video_tab3_mask, |
|
369 EMPViewFeedsTab); |
|
370 |
|
371 CleanupStack::PopAndDestroy(); // mbmpath |
|
372 |
|
373 // return to previous view & update correct tab index |
|
374 if (iPushed) |
|
375 { |
|
376 iNaviPane->PushL(*iDecoratedTabGroup); |
|
377 UpdateTabIndex(); |
|
378 } |
|
379 } |
|
380 |
|
381 // ---------------------------------------------------- |
|
382 // CMPSettingsAppUi::AddTabSettingsL |
|
383 // Adds individual tabs. |
|
384 // ---------------------------------------------------- |
|
385 // |
|
386 void CMPSettingsAppUi::AddTabSettingsL( |
|
387 const TAknsItemID& aID, |
|
388 const TDesC& aMbmFile, |
|
389 TInt aBitmapId, |
|
390 TInt aMaskId, |
|
391 TInt aTabId) |
|
392 { |
|
393 |
|
394 MPX_DEBUG1(_L("#MS# CMPSettingsAppUi::AddTabSettingsL()")); |
|
395 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
396 |
|
397 CFbsBitmap* bitmap = NULL; |
|
398 CFbsBitmap* mask = NULL; |
|
399 |
|
400 AknsUtils::CreateIconLC(skin, aID, |
|
401 bitmap, mask, aMbmFile, aBitmapId, aMaskId); |
|
402 |
|
403 // delete if exists |
|
404 if(iTabGroup->TabIndexFromId(aTabId) >= 0) |
|
405 { |
|
406 iTabGroup->DeleteTabL(aTabId); |
|
407 } |
|
408 |
|
409 iTabGroup->AddTabL(aTabId, bitmap, mask); |
|
410 |
|
411 CleanupStack::Pop(2); // bitmap, mask |
|
412 } |
|
413 |
|
414 // End of File |