|
1 /* |
|
2 * Copyright (c) 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: Container class for settings view |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CCASettingsViewContainer.h" |
|
20 #include "CCAAppUi.h" |
|
21 #include "CCAStatusPaneHandler.h" |
|
22 #include "CCAAppSettingsDialog.h" |
|
23 #include "MCAViewSwitcher.h" |
|
24 #include "CAExternalInterface.h" |
|
25 #include "ChatDefinitions.h" |
|
26 #include "CCAApp.h" |
|
27 #include "CCAVariantFactory.h" |
|
28 #include "MCAOpBrandVariant.h" |
|
29 #include "ChatDebugPrint.h" |
|
30 #include "CCAUISessionManager.h" |
|
31 #include "chatngclient.hrh" |
|
32 #include "CCAUISessionManager.h" |
|
33 #include "CCAAppSettingsSAPExt.h" |
|
34 #include "impsbuilddefinitions.h" |
|
35 |
|
36 #include <barsread.h> |
|
37 #include <chatNG.rsg> |
|
38 #include <bldvariant.hrh> |
|
39 #include <csxhelp/imng.hlp.hrh> |
|
40 #include <CWVSettingsUINGDialog.h> |
|
41 #include <CIMPSSAPSettingsStore.h> |
|
42 #include <CIMPSSAPSettings.h> |
|
43 #include <bautils.h> |
|
44 |
|
45 // The Settings have been moved to Cenrep (also retained in the Resource file), |
|
46 // so the enums for keys and central repository header is added here |
|
47 #include "VariantKeys.h" |
|
48 // CONSTANTS |
|
49 _LIT( KWVSettingsResFileName, "CWVSETTINGSUING.RSC" ); |
|
50 // The variation resource file (the settings) is added now. |
|
51 _LIT( KIMPSCUVariationResFileName, "IMConnectionUIVariationNG.RSC" ); |
|
52 |
|
53 |
|
54 // ================= MEMBER FUNCTIONS ======================= |
|
55 //Default constructor |
|
56 CCASettingsViewContainer::CCASettingsViewContainer( MCAViewSwitcher& aViewSwitcher, |
|
57 MCASettingsPC& aSettings ) |
|
58 : iViewSwitcher( aViewSwitcher ), |
|
59 iSettingsPC( aSettings ) |
|
60 { |
|
61 } |
|
62 // Symbian OS default constructor can leave. |
|
63 void CCASettingsViewContainer::ConstructL( const TRect& aRect ) |
|
64 { |
|
65 iSAPSettingsStore = CIMPSSAPSettingsStore::NewL(); |
|
66 |
|
67 CCAApp* application = |
|
68 static_cast<CCAApp*>( iEikonEnv->EikAppUi()->Application() ); |
|
69 CCAVariantFactory* var = application->VariantFactory(); |
|
70 iOpBrand = var->OpBrandVariantL(); |
|
71 CreateWindowL(); |
|
72 |
|
73 iAppUi = static_cast<CCAAppUi*>( iEikonEnv->AppUi() ); |
|
74 iAppUi->AddLayoutChangeObserver( this ); |
|
75 |
|
76 iListBox = new ( ELeave ) CAknSettingStyleListBox; |
|
77 iListBox->SetContainerWindowL( *this ); |
|
78 TResourceReader rr; |
|
79 iEikonEnv->CreateResourceReaderLC( rr, R_SETTINGS_LISTBOX ); |
|
80 iListBox->ConstructFromResourceL( rr ); |
|
81 CleanupStack::PopAndDestroy(); //RR |
|
82 |
|
83 iListBox->SetListBoxObserver( this ); |
|
84 iListBox->CreateScrollBarFrameL( ETrue ); |
|
85 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
86 CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto ); |
|
87 |
|
88 //List items from resource |
|
89 CDesCArray* itemList = |
|
90 static_cast<CDesCArrayFlat*>( iListBox->Model()->ItemTextArray() ); |
|
91 //There is always items, because loading from resource |
|
92 TInt itemCount( itemList->MdcaCount() ); |
|
93 //We need new array that contains formatted items |
|
94 CDesCArray* newItemList = new ( ELeave ) CDesCArrayFlat( itemCount ); |
|
95 CleanupStack::PushL( newItemList ); |
|
96 |
|
97 HBufC* itemTxt = NULL; |
|
98 TPtr itemTxtPtr( 0, NULL ); |
|
99 |
|
100 for ( TInt i( 0 ); i < itemCount; i++ ) |
|
101 { |
|
102 itemTxt = HBufC::NewLC( itemList->MdcaPoint( i ).Length() + |
|
103 KTab().Length() ); |
|
104 itemTxtPtr.Set( itemTxt->Des() ); |
|
105 |
|
106 itemTxtPtr.Copy( KTab ); |
|
107 itemTxtPtr.Append( itemList->MdcaPoint( i ) ); |
|
108 newItemList->AppendL( itemTxtPtr ); |
|
109 |
|
110 CleanupStack::PopAndDestroy( itemTxt ); |
|
111 } |
|
112 |
|
113 //Lets set new array for the list box |
|
114 CleanupStack::Pop( newItemList ); |
|
115 iListBox->Model()->SetItemTextArray( newItemList ); |
|
116 iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray ); |
|
117 |
|
118 SetRect( aRect ); |
|
119 ActivateL(); |
|
120 } |
|
121 |
|
122 // Destructor |
|
123 CCASettingsViewContainer::~CCASettingsViewContainer() |
|
124 { |
|
125 if ( iAppUi && !iAppUi->IsUnderDestruction() ) |
|
126 { |
|
127 iAppUi->RemoveLayoutChangeObserver( this ); |
|
128 } |
|
129 |
|
130 delete iListBox; |
|
131 delete iSAPSettingsStore; |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CCASettingsViewContainer::Listbox |
|
136 // (other items were commented in a header). |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CAknSettingStyleListBox* CCASettingsViewContainer::Listbox() const |
|
140 { |
|
141 return iListBox; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CCASettingsViewContainer::LaunchAppSettingsDialogL |
|
146 // (other items were commented in a header). |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 void CCASettingsViewContainer::LaunchAppSettingsDialogL() |
|
150 { |
|
151 |
|
152 CCAAppSettingsDialog* dlg = new ( ELeave ) CCAAppSettingsDialog( |
|
153 *( static_cast<CCAAppUi*>( iEikonEnv->AppUi() )->CAStatusPane() ), |
|
154 iSettingsPC, |
|
155 static_cast<CCAAppUi*>( iEikonEnv->AppUi() )->UISessionManager(), NULL ); |
|
156 |
|
157 CleanupStack::PushL( dlg ); |
|
158 dlg->ConstructL( R_CHATCLIENT_APPSETTINGS_MENUBAR ); |
|
159 CleanupStack::Pop( dlg ); |
|
160 |
|
161 dlg->ExecuteLD( R_CHATCLIENT_APPSETTINGS_DLG ); |
|
162 |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CCASettingsViewContainer::LaunchServSettingsDialogL |
|
167 // (other items were commented in a header). |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CCASettingsViewContainer::LaunchServSettingsDialogL( |
|
171 TBool aForcedLaunch /*= EFalse */ ) |
|
172 { |
|
173 TFileName resPath; |
|
174 // The IM Variation Resource file which contains the settings should also be loaded during the launch of dialog |
|
175 TFileName resIMCUVariationPath; |
|
176 |
|
177 // if there are no SAPs then don't try the get default |
|
178 if ( iSAPSettingsStore->SAPCountL( EIMPSIMAccessGroup ) > 0 ) |
|
179 { |
|
180 CIMPSSAPSettings* sap = static_cast<CCAAppUi*>( iEikonEnv->AppUi() ) |
|
181 ->UISessionManager().CurrentSAPLC(); |
|
182 TPtrC sapName( sap->SAPName() ); |
|
183 TPtrC wvSettRes( KWVSettingsResFileName ); |
|
184 // The IM UI Variation Resource file is loaded |
|
185 TPtrC wvIMUIVariationRes( KIMPSCUVariationResFileName ); |
|
186 |
|
187 |
|
188 iOpBrand->CurrentResourceFileL( sapName, wvSettRes, resPath ); |
|
189 // The IM UI Variation Resource file is used to read the settings (if settings are not present in Cenrep) |
|
190 iOpBrand->CurrentResourceFileL( sapName, wvIMUIVariationRes, resIMCUVariationPath ); |
|
191 |
|
192 if ( resPath.Length() != 0 ) |
|
193 { |
|
194 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resPath ); |
|
195 } |
|
196 |
|
197 if ( resIMCUVariationPath.Length() != 0 ) |
|
198 { |
|
199 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resIMCUVariationPath ); |
|
200 } |
|
201 |
|
202 CleanupStack::PopAndDestroy( sap ); |
|
203 } |
|
204 |
|
205 TInt exitReason( 0 ); |
|
206 iServSettingsDialog = CWVSettingsUIDialog::NewL(); |
|
207 |
|
208 #ifdef RD_SERVICE_ENHANCEMENTS |
|
209 iServSettingsDialogActive = ETrue; |
|
210 #endif // RD_SERVICE_ENHANCEMENTS |
|
211 |
|
212 // CodeScanner warning ignored because iServSettingsDialog |
|
213 // is not owned by us |
|
214 TInt retVal( iServSettingsDialog->RunDialogLD( *iSAPSettingsStore, // CSI: 50 # See comment above |
|
215 this, |
|
216 resPath, |
|
217 resIMCUVariationPath, |
|
218 exitReason, |
|
219 NULL, |
|
220 &iServSettingsDialog, |
|
221 aForcedLaunch ) ); |
|
222 #ifdef RD_SERVICE_ENHANCEMENTS |
|
223 if ( exitReason != EForcedExit ) |
|
224 { |
|
225 // Set dialog not active |
|
226 iServSettingsDialogActive = EFalse; |
|
227 } |
|
228 #endif // RD_SERVICE_ENHANCEMENTS |
|
229 |
|
230 iServSettingsDialog = NULL; |
|
231 |
|
232 // clear the navipane from unvanted tabs |
|
233 static_cast<CCAAppUi*>( iEikonEnv->AppUi() )->CAStatusPane()->ClearNaviPaneL(); |
|
234 |
|
235 // this is for updating settings view |
|
236 if ( iNeedRefresh ) |
|
237 { |
|
238 iViewSwitcher.SwitchViewL( KUidRefreshView ); |
|
239 } |
|
240 |
|
241 if ( retVal == EWVSettingsViewExitCalled ) |
|
242 { |
|
243 static_cast<CCAAppUi*>( iEikonEnv->AppUi() )->HandleCommandL( EChatClientCmdExit ); |
|
244 } |
|
245 |
|
246 // update the title |
|
247 static_cast<CCAAppUi*>( iEikonEnv->AppUi() )->CAStatusPane() |
|
248 ->SetTitleL( iEikonEnv, R_CHATCLIEN_SETTINGS_VIEW_TITLE ); |
|
249 } |
|
250 |
|
251 #ifdef RD_SERVICE_ENHANCEMENTS |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CCASettingsViewContainer::IsServSettingsDialogActive |
|
254 // (other items were commented in a header). |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 TBool CCASettingsViewContainer::IsServSettingsDialogActive() const |
|
258 { |
|
259 return iServSettingsDialogActive; |
|
260 } |
|
261 #endif // RD_SERVICE_ENHANCEMENTS |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CCASettingsViewContainer::HandleListBoxEventL |
|
265 // (other items were commented in a header). |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CCASettingsViewContainer::HandleListBoxEventL( CEikListBox* aListBox, |
|
269 TListBoxEvent aEventType ) |
|
270 { |
|
271 if ( aEventType == EEventEnterKeyPressed || |
|
272 aEventType == EEventItemDoubleClicked ) |
|
273 { |
|
274 switch ( aListBox->CurrentItemIndex() ) |
|
275 { |
|
276 case EApplicationSettings: |
|
277 { |
|
278 LaunchAppSettingsDialogL(); |
|
279 break; |
|
280 } |
|
281 case EServiceSettings: |
|
282 { |
|
283 LaunchServSettingsDialogL(); |
|
284 // this is for updating settings view |
|
285 if ( iNeedRefresh ) |
|
286 { |
|
287 iViewSwitcher.SwitchViewL( KUidRefreshView ); |
|
288 } |
|
289 break; |
|
290 } |
|
291 default: |
|
292 { |
|
293 |
|
294 break; |
|
295 } |
|
296 } |
|
297 } |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CCASettingsViewContainer::CountComponentControls |
|
302 // (other items were commented in a header). |
|
303 // ----------------------------------------------------------------------------- |
|
304 // |
|
305 TInt CCASettingsViewContainer::CountComponentControls() const |
|
306 { |
|
307 if ( iListBox ) |
|
308 { |
|
309 return 1; |
|
310 } |
|
311 |
|
312 return 0; |
|
313 } |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // CCASettingsViewContainer::ComponentControl |
|
317 // (other items were commented in a header). |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 CCoeControl* CCASettingsViewContainer::ComponentControl( TInt aIndex ) const |
|
321 { |
|
322 switch ( aIndex ) |
|
323 { |
|
324 case 0: |
|
325 { |
|
326 return iListBox; |
|
327 } |
|
328 default: |
|
329 { |
|
330 return NULL; |
|
331 } |
|
332 } |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CCASettingsViewContainer::SizeChanged |
|
337 // (other items were commented in a header). |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CCASettingsViewContainer::SizeChanged() |
|
341 { |
|
342 iListBox->SetRect( Rect() ); |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CCASettingsViewContainer::OfferKeyEventL |
|
347 // (other items were commented in a header). |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 TKeyResponse CCASettingsViewContainer::OfferKeyEventL( const TKeyEvent& aEvent, |
|
351 TEventCode aType ) |
|
352 { |
|
353 return iListBox->OfferKeyEventL( aEvent, aType ); |
|
354 } |
|
355 |
|
356 // --------------------------------------------------------- |
|
357 // CCASettingsViewContainer::GetHelpContext |
|
358 // (other items were commented in a header). |
|
359 // --------------------------------------------------------- |
|
360 // |
|
361 void CCASettingsViewContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
362 { |
|
363 aContext.iMajor = KUidChatClient; |
|
364 aContext.iContext = KIMNG_HLP_SETTINGS; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------- |
|
368 // CCASettingsViewContainer::FocusChanged |
|
369 // (other items were commented in a header). |
|
370 // --------------------------------------------------------- |
|
371 // |
|
372 void CCASettingsViewContainer::FocusChanged( TDrawNow /* aDrawNow */ ) |
|
373 { |
|
374 if ( iListBox ) |
|
375 { |
|
376 // give focus to list box so that highlight animations |
|
377 // are done properly |
|
378 iListBox->SetFocus( IsFocused() ); |
|
379 } |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CCASettingsViewContainer::ServerChangedL |
|
384 // (other items were commented in a header). |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 void CCASettingsViewContainer::ServerChangedL ( const TDesC& aNewServerName, TBool /* aDefaultServerchanged = EFalse */ ) |
|
388 { |
|
389 CHAT_DP( D_CHAT_LIT( "CCASettingsViewContainer::ServerChangedL(%S)" ), &aNewServerName ); |
|
390 if ( aNewServerName.Length() == 0 || |
|
391 iSAPSettingsStore->SAPCountL( EIMPSIMAccessGroup ) == 0 ) |
|
392 { |
|
393 // no servers |
|
394 return; |
|
395 } |
|
396 |
|
397 CCAAppUi* appUi = static_cast<CCAAppUi*>( iEikonEnv->EikAppUi() ); |
|
398 iNeedRefresh = appUi->UISessionManager().BrandUIL( EFalse, aNewServerName ); |
|
399 |
|
400 // Stop here if brand did not actually change |
|
401 |
|
402 if ( ! iNeedRefresh && ! iServSettingsDialog ) |
|
403 { |
|
404 return; |
|
405 } |
|
406 |
|
407 // Update status-pane |
|
408 appUi->UISessionManager().SetStatusPaneIconsL(); |
|
409 |
|
410 // Get resource file for settings dialog |
|
411 TFileName resPath; |
|
412 TFileName resIMCUVariationPath; |
|
413 |
|
414 TPtrC resId( KWVSettingsResFileName() ); |
|
415 TPtrC resIMCUVariationId ( KIMPSCUVariationResFileName() ); |
|
416 |
|
417 iOpBrand->CurrentResourceFileL( aNewServerName, resId, resPath ); |
|
418 iOpBrand->CurrentResourceFileL( aNewServerName, resIMCUVariationId, resIMCUVariationPath ); |
|
419 |
|
420 if ( resPath.Length() != 0 ) |
|
421 { |
|
422 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resPath ); |
|
423 } |
|
424 |
|
425 if ( resIMCUVariationPath.Length() != 0 ) |
|
426 { |
|
427 BaflUtils::NearestLanguageFile( iEikonEnv->FsSession(), resIMCUVariationPath ); |
|
428 } |
|
429 |
|
430 CHAT_DP( D_CHAT_LIT( "CCASettingsViewContainer::ServerChangedL, signalling service settings about resPath: %S" ), &resPath ); |
|
431 iServSettingsDialog->ChangeResourceFileL( resPath, resIMCUVariationPath ); |
|
432 } |
|
433 |
|
434 // --------------------------------------------------------- |
|
435 // CCASettingsViewContainer::LayoutChangedL |
|
436 // (other items were commented in a header). |
|
437 // --------------------------------------------------------- |
|
438 // |
|
439 void CCASettingsViewContainer::LayoutChangedL( TInt aType ) |
|
440 { |
|
441 // updates tabgroup |
|
442 iViewSwitcher.CAStatusPane()->ShowTabGroupL( KUidSettingsView ); |
|
443 |
|
444 TRect mainPaneRect; |
|
445 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
446 SetRect( mainPaneRect ); |
|
447 CCoeControl::HandleResourceChange( aType ); |
|
448 } |
|
449 |
|
450 // --------------------------------------------------------- |
|
451 // CCASettingsViewContainer::CurrentServerNameLC |
|
452 // (other items were commented in a header). |
|
453 // --------------------------------------------------------- |
|
454 // |
|
455 HBufC* CCASettingsViewContainer::CurrentServerNameLC() |
|
456 { |
|
457 HBufC* sapName = NULL; |
|
458 TRAPD( err, |
|
459 CIMPSSAPSettings* sap = static_cast<CCAAppUi*>( iEikonEnv->AppUi() )->UISessionManager().CurrentSAPLC(); |
|
460 // CodeScanner warning ignored because sapName is pushed to |
|
461 // cleanupstack later and there is no leaving code before it |
|
462 sapName = sap->SAPName().AllocL(); // CSI: 35 # See comment above |
|
463 CleanupStack::PopAndDestroy( sap ); |
|
464 ); |
|
465 |
|
466 if ( err != KErrNone || !sapName ) |
|
467 { |
|
468 sapName = KNullDesC().AllocL(); |
|
469 } |
|
470 |
|
471 CleanupStack::PushL( sapName ); |
|
472 return sapName; |
|
473 } |
|
474 |
|
475 // End of File |