9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: This module contains the implementation of IAUpdateSettingDialog |
14 * Description: |
15 * class member functions. |
|
16 * |
15 * |
17 */ |
16 */ |
18 |
17 |
19 #include <hbdataform.h> |
18 |
20 #include <hbdataformmodel.h> |
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include "iaupdatesettingdialog.h" |
|
24 #include "iaupdateaccesspointhandler.h" |
|
25 #include "iaupdatestatuspanehandler.h" |
|
26 #include "iaupdateapplication.h" |
|
27 #include "iaupdate.hrh" |
|
28 #include "iaupdateprivatecrkeys.h" |
|
29 #include "iaupdatedebug.h" |
|
30 #include <iaupdate.rsg> |
|
31 |
21 #include <centralrepository.h> |
32 #include <centralrepository.h> |
22 #include <cmconnectionmethoddef.h> |
33 #include <featmgr.h> |
23 #include <cmdestination.h> |
34 #include <hlplch.h> |
24 #include <xqconversions.h> |
35 |
25 #include <hbaction.h> |
36 |
26 |
37 _LIT( KSWUPDATE_HLP_SETTINGS, "SWUPDATE_HLP_SETTINGS" ); |
27 #include "iaupdatesettingdialog.h" |
38 |
28 #include "iaupdateprivatecrkeys.h" |
39 |
29 #include "iaupdate.hrh" |
40 |
30 |
41 |
31 |
42 // cenrep in emulator: |
32 const TInt KAutoUpdateOn( 0 ); |
43 // copy 2000F85A.txt to '\epoc32\release\winscw\udeb\Z\private\10202be9\' |
33 const TInt KAutoUpdateOff( 1 ); |
44 // delete 2000F85A.txt from 'epoc32\winscw\c\private\10202be9\persists' |
34 const TInt KAutoUpdateOnInHomeNetwork( 2 ); |
45 // |
35 |
46 // cenrep in hardware: |
36 /* |
47 // copy 2000F85A.txt to '\epoc32\data\Z\private\10202be9' |
37 Constructor. It creates a formwidget on the view. |
48 // |
38 */ |
49 |
39 CIAUpdateSettingDialog::CIAUpdateSettingDialog(QGraphicsItem* parent):HbView(parent) |
50 |
40 { |
51 |
41 |
52 /****************************************************************************** |
42 //setTitle("Software update"); |
53 * class CIAUpdateSettingDialog |
43 |
54 ******************************************************************************/ |
44 mSettingsForm = new HbDataForm(this); |
55 |
45 |
56 |
46 |
57 // ----------------------------------------------------------------------------- |
47 // open connection manager |
58 // CIAUpdateSettingDialog::ShowDialogL |
48 TRAPD(err, mCmManager.OpenL()); |
59 // |
49 qt_symbian_throwIfError(err); |
60 // ----------------------------------------------------------------------------- |
50 |
61 TBool CIAUpdateSettingDialog::ShowDialogL() |
51 // destination field flag inititializations |
62 { |
52 mSetByNwQuery = false; // dest set by user/by destination query |
63 //__UHEAP_MARK; |
53 mConnected = false; // already connected to query |
64 |
54 mInitialized = false; // field initialized ? |
65 CIAUpdateSettingDialog* dialog = CIAUpdateSettingDialog::NewL(); |
55 |
66 |
56 // Initialize view |
67 TBool ret = dialog->ExecuteLD( R_IAUPDATE_SETTING_DIALOG ); |
57 initializeView(); |
68 |
58 |
69 //__UHEAP_MARKEND; |
59 //setWidget(mSettingsForm); |
70 |
60 setWidget(mSettingsForm); |
71 return ret; |
61 |
72 } |
62 // Create application settings ui |
73 |
63 mApplSett = new CmApplSettingsUi(this); |
74 |
64 |
75 // ----------------------------------------------------------------------------- |
65 // Create a back key action and set it as the default navigation |
76 // CIAUpdateSettingDialog::NewL |
66 // action once the back key is pressed |
77 // |
67 mBackKey = new HbAction(Hb::BackNaviAction, this); |
78 // ----------------------------------------------------------------------------- |
68 this->setNavigationAction(mBackKey); |
79 CIAUpdateSettingDialog* CIAUpdateSettingDialog::NewL() |
69 |
80 { |
70 connect(mBackKey, SIGNAL(triggered()), this, SLOT(showPreviousView())); |
81 CIAUpdateSettingDialog* self = new ( ELeave ) CIAUpdateSettingDialog(); |
71 |
82 CleanupStack::PushL( self ); |
72 } |
83 self->ConstructL(); |
73 |
84 CleanupStack::Pop( self ); |
74 /* |
85 |
75 Destructor |
86 return self; |
76 */ |
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CIAUpdateSettingDialog::CIAUpdateSettingDialog |
|
92 // |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 CIAUpdateSettingDialog::CIAUpdateSettingDialog() |
|
96 { |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CIAUpdateSettingDialog::ConstructL |
|
102 // |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CIAUpdateSettingDialog::ConstructL() |
|
106 { |
|
107 CAknDialog::ConstructL( R_IAUPDATE_SETTING_DIALOG_MENU ); |
|
108 |
|
109 // get previous title so it can be restored |
|
110 iStatusPaneHandler = CIAUpdateStatusPaneHandler::NewL( iAvkonAppUi ); |
|
111 iStatusPaneHandler->StoreOriginalTitleL(); |
|
112 } |
|
113 |
|
114 |
|
115 // ---------------------------------------------------------------------------- |
|
116 // Destructor |
|
117 // |
|
118 // ---------------------------------------------------------------------------- |
|
119 // |
77 CIAUpdateSettingDialog::~CIAUpdateSettingDialog() |
120 CIAUpdateSettingDialog::~CIAUpdateSettingDialog() |
78 { |
121 { |
79 // close connection manager |
122 delete iStatusPaneHandler; |
80 mCmManager.Close(); |
123 |
81 } |
124 if (iAvkonAppUi) |
82 |
125 { |
83 // ---------------------------------------------------------------------------- |
126 iAvkonAppUi->RemoveFromStack( this ); |
84 // CIAUpdateSettingDialog::toggleChange |
127 } |
85 // |
128 } |
86 // ---------------------------------------------------------------------------- |
129 |
87 // |
130 |
88 void CIAUpdateSettingDialog::toggleChange(QModelIndex startIn, QModelIndex /*endIn*/) |
131 // --------------------------------------------------------- |
89 { |
132 // CIAUpdateSettingDialog::CreateCustomControlL |
90 // HLa: this should work |
133 // --------------------------------------------------------- |
91 HbDataFormModelItem *itm = mModel->itemFromIndex(startIn); |
134 // |
92 |
135 SEikControlInfo CIAUpdateSettingDialog::CreateCustomControlL( TInt aControlType ) |
93 // Destination ? |
136 { |
94 if ( startIn.row() == 0 ) |
137 SEikControlInfo controlInfo; |
95 { |
138 controlInfo.iControl = NULL; |
96 // no query when initializing fields |
139 controlInfo.iTrailerTextId = 0; |
97 if ( mInitialized ) |
140 controlInfo.iFlags = 0; |
98 { |
141 |
99 // no query if field value set by destination query |
142 switch ( aControlType ) |
100 if (!mSetByNwQuery ) |
143 { |
101 { |
144 case EAknCtLastControlId: |
102 queryDestination(); |
145 { |
103 mSetByNwQuery = true; |
146 controlInfo.iControl = new (ELeave) CIAUpdateSettingItemList(); |
104 } |
147 break; |
105 else |
148 } |
106 { |
149 |
107 mSetByNwQuery = false; |
150 default: |
108 } |
151 { |
109 } |
152 break; |
110 else |
153 } |
111 { |
154 } |
112 mInitialized = true; |
155 return controlInfo; |
113 } |
156 } |
114 |
157 |
115 } |
158 |
116 // Auto update ? |
159 //------------------------------------------------------------------------------ |
117 if ( startIn.row() == 1 ) |
160 // CIAUpdateSettingDialog::ActivateL |
118 { |
161 // |
119 int currentIndex = mAutoUpdateItem->contentWidgetData(QString("currentIndex")).toInt(); |
162 // Called by system when dialog is activated. |
120 } |
163 //------------------------------------------------------------------------------ |
121 } |
164 // |
122 // ---------------------------------------------------------------------------- |
165 void CIAUpdateSettingDialog::ActivateL() |
123 // CIAUpdateSettingDialog::queryDestination |
166 { |
124 // |
167 CAknDialog::ActivateL(); |
125 // ---------------------------------------------------------------------------- |
168 |
126 // |
169 // this cannot be in ConstructL which is executed before dialog is launched |
127 void CIAUpdateSettingDialog::queryDestination() |
170 iAvkonAppUi->AddToStackL(this); |
128 { |
171 } |
129 QFlags<CmApplSettingsUi::SelectionDialogItems> listItems; |
172 |
130 QSet<CmApplSettingsUi::BearerTypeFilter> filter; |
173 |
131 |
174 //------------------------------------------------------------------------------ |
132 // Show only destinations |
175 // CIAUpdateSettingDialog::GetHelpContext |
133 listItems |= CmApplSettingsUi::ShowDestinations; |
176 // |
134 // listItems |= CmApplSettingsUi::ShowConnectionMethods; |
177 //------------------------------------------------------------------------------ |
135 |
178 // |
136 mApplSett->setOptions(listItems, filter); |
179 void CIAUpdateSettingDialog::GetHelpContext( TCoeHelpContext& aContext ) const |
137 mApplSett->setSelection(mSelection); |
180 { |
138 |
181 aContext.iMajor = KUidIAUpdateApp; |
139 // Connect finished(uint) signal and handle result via it |
182 aContext.iContext = KSWUPDATE_HLP_SETTINGS; |
140 if (!mConnected) |
183 } |
141 { |
184 |
142 connect(mApplSett, SIGNAL(finished(uint)), this, SLOT(showResults(uint))); |
185 |
143 mConnected = true; |
186 // ----------------------------------------------------------------------------- |
144 } |
187 // CIAUpdateSettingDialog::HandleListBoxEventL |
145 |
188 // |
146 // Start CmApplSettingsUi |
189 // ----------------------------------------------------------------------------- |
147 mApplSett->open(); |
190 void CIAUpdateSettingDialog::HandleListBoxEventL( CEikListBox* /*aListBox*/, |
148 |
191 TListBoxEvent /*aEventType*/ ) |
149 } |
192 { |
150 // ---------------------------------------------------------------------------- |
193 } |
151 // CIAUpdateSettingDialog::showResults |
194 |
152 // |
195 |
153 // ---------------------------------------------------------------------------- |
196 // ----------------------------------------------------------------------------- |
154 // |
197 // CIAUpdateSettingDialog::PreLayoutDynInitL |
155 void CIAUpdateSettingDialog::showResults(uint retval) |
198 // |
156 { |
199 // ----------------------------------------------------------------------------- |
157 if (retval == CmApplSettingsUi::ApplSettingsErrorNone) { |
200 // |
158 mSelection = mApplSett->selection(); |
201 void CIAUpdateSettingDialog::PreLayoutDynInitL() |
159 |
202 { |
160 uint destinationId = mSelection.id; |
203 iList = (CIAUpdateSettingItemList*) ControlOrNull ( EIAUpdateSettingDialogList ); |
161 |
204 |
162 QString idString; |
205 iList->LoadSettingsL(); // from CAknSettingItemList |
163 |
206 |
164 TRAPD( err, getDestinationNameL( destinationId, idString ) ); |
207 iStatusPaneHandler->SetTitleL( R_IAUPDATE_SETTING_DIALOG_TITLE ); |
165 qt_symbian_throwIfError(err); |
208 iStatusPaneHandler->SetNaviPaneTitleL(KNullDesC); |
166 |
209 } |
167 // Destination changed ? |
210 |
168 if ( idString != mCurrentDest ) |
211 |
169 { |
212 //------------------------------------------------------------------------------ |
170 mCurrentDest = idString; |
213 // CIAUpdateSettingDialog::DynInitMenuPaneL |
171 } |
214 // |
172 } |
215 // Called by system before menu is shown. |
173 // inform toggleChange that change is not made by user |
216 //------------------------------------------------------------------------------ |
174 mSetByNwQuery = true; |
217 // |
175 mDestinationItem->setContentWidgetData(QString("text"), mCurrentDest); |
218 void CIAUpdateSettingDialog::DynInitMenuPaneL(TInt aResourceID, CEikMenuPane* aMenuPane ) |
176 } |
219 { |
|
220 if( aResourceID == R_IAUPDATE_SETTING_DIALOG_MENU_PANE ) |
|
221 { |
|
222 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
223 { |
|
224 aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue ); |
|
225 } |
|
226 } |
|
227 } |
|
228 |
|
229 |
|
230 //------------------------------------------------------------------------------ |
|
231 // CIAUpdateSettingDialog::ProcessCommandL |
|
232 // |
|
233 // Handle commands from menu. |
|
234 //------------------------------------------------------------------------------ |
|
235 // |
|
236 void CIAUpdateSettingDialog::ProcessCommandL(TInt aCommandId) |
|
237 { |
|
238 if ( MenuShowing() ) |
|
239 { |
|
240 HideMenu(); |
|
241 } |
|
242 |
|
243 |
|
244 switch ( aCommandId ) |
|
245 { |
|
246 case EAknCmdHelp: |
|
247 { |
|
248 HlpLauncher::LaunchHelpApplicationL( |
|
249 iEikonEnv->WsSession(), |
|
250 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
251 break; |
|
252 } |
|
253 |
|
254 case EAknCmdOpen: |
|
255 { |
|
256 EditItemL(); |
|
257 break; |
|
258 } |
|
259 |
|
260 case EAknCmdExit: |
|
261 case EEikCmdExit: |
|
262 { |
|
263 // close dialog and exit calling application |
|
264 iAvkonAppUi->ProcessCommandL( EAknCmdExit ); |
|
265 break; |
|
266 } |
|
267 |
|
268 default: |
|
269 break; |
|
270 } |
|
271 } |
|
272 |
|
273 |
|
274 //------------------------------------------------------------------------------ |
|
275 // CIAUpdateSettingDialog::OkToExitL |
|
276 // |
|
277 //------------------------------------------------------------------------------ |
|
278 // |
|
279 TBool CIAUpdateSettingDialog::OkToExitL(TInt aButtonId) |
|
280 { |
|
281 if ( aButtonId == EEikBidCancel ) |
|
282 { |
|
283 TRAP_IGNORE( SaveSettingsL() ); //potential leave trapped |
|
284 //because IAD is not closed if SaveSettingsL() leaves |
|
285 return ETrue; // close dialog |
|
286 } |
|
287 |
|
288 if ( aButtonId == EAknSoftkeyOpen ) |
|
289 { |
|
290 EditItemL(); |
|
291 |
|
292 return EFalse; // leave dialog open |
|
293 } |
|
294 |
|
295 if ( aButtonId == EAknSoftkeyBack ) |
|
296 { |
|
297 SaveSettingsL(); |
|
298 |
|
299 return ETrue; // close dialog |
|
300 } |
|
301 |
|
302 return CAknDialog::OkToExitL(aButtonId); |
|
303 } |
|
304 |
|
305 |
|
306 |
|
307 // ---------------------------------------------------------------------------- |
|
308 // CIAUpdateSettingDialog::OfferKeyEventL |
|
309 // |
|
310 // ---------------------------------------------------------------------------- |
|
311 // |
|
312 TKeyResponse CIAUpdateSettingDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
313 { |
|
314 if (aType == EEventKey) |
|
315 { |
|
316 switch (aKeyEvent.iCode) |
|
317 { |
|
318 case EKeyEscape: // framework calls this when dialog must shut down |
|
319 { |
|
320 return CAknDialog::OfferKeyEventL(aKeyEvent, aType); |
|
321 } |
|
322 case EKeyUpArrow: |
|
323 case EKeyDownArrow: |
|
324 { |
|
325 break; |
|
326 } |
|
327 default: |
|
328 { |
|
329 break; |
|
330 } |
|
331 } |
|
332 } |
|
333 |
|
334 return CAknDialog::OfferKeyEventL( aKeyEvent, aType); |
|
335 } |
|
336 |
|
337 |
|
338 // ---------------------------------------------------------------------------- |
|
339 // CIAUpdateSettingDialog::HandleResourceChange |
|
340 // |
|
341 // ---------------------------------------------------------------------------- |
|
342 // |
|
343 void CIAUpdateSettingDialog::HandleResourceChange(TInt aType) |
|
344 { |
|
345 if (aType == KEikDynamicLayoutVariantSwitch) //Handle change in layout orientation |
|
346 { |
|
347 TRect mainPaneRect; |
|
348 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
349 SetRect( mainPaneRect ); |
|
350 |
|
351 iList->HandleResourceChange( aType ); |
|
352 |
|
353 CCoeControl::HandleResourceChange( aType ); |
|
354 DrawDeferred(); |
|
355 return; |
|
356 } |
|
357 |
|
358 if ( aType == KAknsMessageSkinChange ) |
|
359 { |
|
360 } |
|
361 |
|
362 CCoeControl::HandleResourceChange( aType ); |
|
363 } |
|
364 |
|
365 |
|
366 // ---------------------------------------------------------------------------- |
|
367 // CIAUpdateSettingDialog::EditItemL |
|
368 // |
|
369 // ---------------------------------------------------------------------------- |
|
370 // |
|
371 void CIAUpdateSettingDialog::EditItemL() |
|
372 { |
|
373 TInt currentIndex = iList->ListBox()->CurrentItemIndex(); |
|
374 TBool calledFromMenu = ETrue; |
|
375 |
|
376 iList->EditItemL( currentIndex, calledFromMenu ); |
|
377 } |
|
378 |
|
379 |
|
380 // ----------------------------------------------------------------------------- |
|
381 // CIAUpdateSettingDialog::SetVisibility |
|
382 // |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void CIAUpdateSettingDialog::SetVisibility() |
|
386 { |
|
387 } |
|
388 |
|
389 |
|
390 // ----------------------------------------------------------------------------- |
|
391 // CAspContentDialog::SetAllReadOnly |
|
392 // |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 void CIAUpdateSettingDialog::SetAllReadOnly() |
|
396 { |
|
397 } |
|
398 |
177 |
399 |
178 // ---------------------------------------------------------------------------- |
400 // ---------------------------------------------------------------------------- |
179 // CIAUpdateSettingDialog::SaveSettingsL |
401 // CIAUpdateSettingDialog::SaveSettingsL |
180 // |
402 // |
181 // ---------------------------------------------------------------------------- |
403 // ---------------------------------------------------------------------------- |
182 // |
404 // |
183 void CIAUpdateSettingDialog::saveSettingsL() |
405 void CIAUpdateSettingDialog::SaveSettingsL() |
184 { |
406 { |
|
407 iList->StoreSettingsL(); // from CAknSettingItemList |
|
408 |
185 CRepository* cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
409 CRepository* cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
186 TInt err = cenrep->StartTransaction( CRepository::EReadWriteTransaction ); |
410 TInt err = cenrep->StartTransaction( CRepository::EReadWriteTransaction ); |
187 User::LeaveIfError( err ); |
411 User::LeaveIfError( err ); |
188 |
|
189 cenrep->CleanupCancelTransactionPushL(); |
412 cenrep->CleanupCancelTransactionPushL(); |
190 |
413 |
191 // Set destination |
414 |
192 TInt value = mSelection.id; |
415 TInt num = iList->Attribute( EAccessPoint ); |
193 err = cenrep->Set( KIAUpdateAccessPoint, value ) ; |
416 if ( num == 0 ) |
|
417 { |
|
418 // O means default destination. Let's save it as -1 so that we know later on |
|
419 // whether cenrep really contained the default or just nothing. |
|
420 num = -1; |
|
421 } |
|
422 err = cenrep->Set( KIAUpdateAccessPoint, num ); |
194 User::LeaveIfError( err ); |
423 User::LeaveIfError( err ); |
195 |
424 |
196 // Set auto update check |
425 num = iList->Attribute( EAutoUpdateCheck ); |
197 value = mAutoUpdateItem->contentWidgetData(QString("currentIndex")).toInt(); |
426 err = cenrep->Set( KIAUpdateAutoUpdateCheck, num ); |
198 |
|
199 // Convert ist index index to setting value |
|
200 switch ( value ) |
|
201 { |
|
202 case KAutoUpdateOn: |
|
203 value = EIAUpdateSettingValueDisableWhenRoaming; |
|
204 break; |
|
205 case KAutoUpdateOff: |
|
206 value = EIAUpdateSettingValueDisable; |
|
207 break; |
|
208 case KAutoUpdateOnInHomeNetwork: |
|
209 value = EIAUpdateSettingValueEnable; |
|
210 break; |
|
211 default: |
|
212 break; |
|
213 } |
|
214 err = cenrep->Set( KIAUpdateAutoUpdateCheck, value ); |
|
215 |
|
216 User::LeaveIfError( err ); |
427 User::LeaveIfError( err ); |
217 |
428 |
218 TUint32 ignore = KErrNone; |
429 TUint32 ignore = KErrNone; |
219 User::LeaveIfError( cenrep->CommitTransaction( ignore ) ); |
430 User::LeaveIfError( cenrep->CommitTransaction( ignore ) ); |
220 CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL() |
431 CleanupStack::PopAndDestroy(); // CleanupCancelTransactionPushL() |
221 CleanupStack::PopAndDestroy( cenrep ); |
432 CleanupStack::PopAndDestroy( cenrep ); |
222 } |
433 } |
223 |
434 |
224 |
435 |
225 // ----------------------------------------------------------------------------- |
436 |
226 // CIAUpdateSettingDialog::initializeFieldsL |
437 |
227 // ----------------------------------------------------------------------------- |
438 |
228 // |
439 /****************************************************************************** |
229 void CIAUpdateSettingDialog::initializeFieldsL() |
440 * class CIAUpdateSettingItemList |
230 { |
441 ******************************************************************************/ |
|
442 |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CIAUpdateSettingItemList::CreateSettingItemL |
|
446 // |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 CAknSettingItem* CIAUpdateSettingItemList::CreateSettingItemL( TInt aSettingId ) |
|
450 { |
|
451 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSettingItemList::CreateSettingItemL begin"); |
231 CRepository* cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
452 CRepository* cenrep = CRepository::NewLC( KCRUidIAUpdateSettings ); |
232 int destId = 0; |
453 CAknSettingItem* item = NULL; |
233 |
454 |
234 // get access point id |
455 switch ( aSettingId ) |
235 User::LeaveIfError( cenrep->Get( KIAUpdateAccessPoint, destId ) ); |
456 { |
236 |
457 case EIAUpdateSettingAccessPoint: |
237 // save id |
458 { |
238 mSelection.id = destId; |
459 User::LeaveIfError( cenrep->Get( KIAUpdateAccessPoint, iAccessPoint ) ); |
239 |
460 IAUPDATE_TRACE_1("[IAUPDATE] CIAUpdateSettingItemList::CreateSettingItemL iAccessPoint: %d", iAccessPoint); |
240 // On first time: show internet access point |
461 if ( iAccessPoint == -1 ) |
241 if ( mSelection.id == 0 ) |
462 { |
242 { |
463 // -1 was just our private representation in cenrep of the default destination |
243 User::LeaveIfError(mSelection.id = getInternetSnapIdL()); |
464 // Let's handle it as it was 0 |
244 } |
465 iAccessPoint = 0; |
245 |
466 } |
246 // set destination name |
467 item = CIAUpdateAccessPointSettingItem::NewL( aSettingId, iAccessPoint ); |
247 TRAPD( err, getDestinationNameL( mSelection.id, mCurrentDest ) ); |
468 break; |
248 |
469 } |
249 if ( err == KErrNotFound ) |
470 |
250 { |
471 case EIAUpdateSettingAutoUpdateCheck: |
251 mSelection.id = 0; |
472 { |
|
473 User::LeaveIfError( cenrep->Get( KIAUpdateAutoUpdateCheck, iAutoUpdateCheck ) ); |
|
474 item = new (ELeave) CAknEnumeratedTextPopupSettingItem |
|
475 ( aSettingId, iAutoUpdateCheck ); |
|
476 break; |
|
477 } |
|
478 |
|
479 default: |
|
480 { |
|
481 item = new (ELeave) CAknSettingItem( aSettingId ); |
|
482 break; |
|
483 } |
|
484 } |
|
485 CleanupStack::PopAndDestroy( cenrep ); |
|
486 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateSettingItemList::CreateSettingItemL end"); |
|
487 return item; |
|
488 } |
|
489 |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CIAUpdateSettingItemList::LoadSettingsL |
|
493 // |
|
494 // ----------------------------------------------------------------------------- |
|
495 // |
|
496 void CIAUpdateSettingItemList::LoadSettingsL() |
|
497 { |
|
498 CAknSettingItemList::LoadSettingsL(); |
|
499 } |
|
500 |
|
501 |
|
502 // ----------------------------------------------------------------------------- |
|
503 // CIAUpdateSettingItemList::EditItemL |
|
504 // |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 void CIAUpdateSettingItemList::EditItemL( TInt aIndex, TBool aCalledFromMenu ) |
|
508 { |
|
509 CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu ); |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CIAUpdateSettingItemList::SetAttribute |
|
514 // |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CIAUpdateSettingItemList::Attribute |
|
520 // |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 TInt CIAUpdateSettingItemList::Attribute( TInt aKey ) |
|
524 { |
|
525 TInt ret = KErrNotFound; |
|
526 |
|
527 switch ( aKey ) |
|
528 { |
|
529 case CIAUpdateSettingDialog::EAccessPoint: |
|
530 { |
|
531 ret = iAccessPoint; |
|
532 break; |
|
533 } |
|
534 case CIAUpdateSettingDialog::EAutoUpdateCheck: |
|
535 { |
|
536 ret = iAutoUpdateCheck; |
|
537 break; |
|
538 } |
|
539 default: |
|
540 { |
|
541 IAUpdateDialogUtil::Panic( KErrNotSupported ); |
|
542 break; |
|
543 } |
|
544 } |
|
545 |
|
546 return ret; |
|
547 } |
|
548 |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // CIAUpdateSettingItemList::CheckSettings |
|
552 // |
|
553 // ----------------------------------------------------------------------------- |
|
554 // |
|
555 void CIAUpdateSettingItemList::CheckSettings() |
|
556 { |
|
557 if ( iAutoUpdateCheck != EIAUpdateSettingValueDisable && |
|
558 iAutoUpdateCheck != EIAUpdateSettingValueDisableWhenRoaming && |
|
559 iAutoUpdateCheck != EIAUpdateSettingValueEnable ) |
|
560 { |
|
561 iAutoUpdateCheck = EIAUpdateSettingValueEnable; |
|
562 } |
|
563 } |
|
564 |
|
565 |
|
566 |
|
567 /****************************************************************************** |
|
568 * class CIAUpdateAccessPointSettingItem |
|
569 ******************************************************************************/ |
|
570 |
|
571 // ----------------------------------------------------------------------------- |
|
572 // CIAUpdateAccessPointSettingItem::NewL |
|
573 // |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 CIAUpdateAccessPointSettingItem* CIAUpdateAccessPointSettingItem::NewL( |
|
577 TInt aSettingId, TInt& aAccessPointId ) |
|
578 { |
|
579 CIAUpdateAccessPointSettingItem* item = |
|
580 new (ELeave) CIAUpdateAccessPointSettingItem( aSettingId, aAccessPointId ); |
|
581 CleanupStack::PushL(item); |
|
582 item->ConstructL(); |
|
583 CleanupStack::Pop(item); |
|
584 return item; |
|
585 } |
|
586 |
|
587 // ----------------------------------------------------------------------------- |
|
588 // CIAUpdateAccessPointSettingItem::CIAUpdateAccessPointSettingItem |
|
589 // |
|
590 // ----------------------------------------------------------------------------- |
|
591 // |
|
592 CIAUpdateAccessPointSettingItem::CIAUpdateAccessPointSettingItem( |
|
593 TInt aSettingId, TInt& aAccessPointId ) |
|
594 : CAknSettingItem( aSettingId ), |
|
595 iAccessPointId ( aAccessPointId ) |
|
596 { |
|
597 } |
|
598 |
|
599 |
|
600 // ----------------------------------------------------------------------------- |
|
601 // CIAUpdateAccessPointSettingItem::~CIAUpdateAccessPointSettingItem |
|
602 // |
|
603 // ----------------------------------------------------------------------------- |
|
604 // |
|
605 CIAUpdateAccessPointSettingItem::~CIAUpdateAccessPointSettingItem() |
|
606 { |
|
607 delete iSettingText; |
|
608 delete iApHandler; |
|
609 } |
|
610 |
|
611 |
|
612 // ----------------------------------------------------------------------------- |
|
613 // CIAUpdateAccessPointSettingItem::ConstructL |
|
614 // |
|
615 // ----------------------------------------------------------------------------- |
|
616 // |
|
617 void CIAUpdateAccessPointSettingItem::ConstructL() |
|
618 { |
|
619 iApHandler = CIAUpdateAccessPointHandler::NewL(); |
|
620 |
|
621 if ( iAccessPointId == 0 ) |
|
622 { |
|
623 iApHandler->GetDefaultConnectionLabelL( iSettingText ); |
252 } |
624 } |
253 else |
625 else |
254 { |
626 { |
255 // nothing to do ? |
627 TRAPD( err, iApHandler->GetApNameL( iAccessPointId, iSettingText ) ); |
256 User::LeaveIfError( err ); |
628 if ( err == KErrNotFound ) |
257 } |
629 { // destination stored by IAD may be removed |
258 mDestinationItem->setContentWidgetData(QString("text"), mCurrentDest); |
630 iAccessPointId = 0; |
259 |
631 iApHandler->GetDefaultConnectionLabelL( iSettingText ); |
260 // set auto update value |
632 } |
261 int value = 0; |
633 else |
262 User::LeaveIfError( cenrep->Get( KIAUpdateAutoUpdateCheck, value ) ); |
634 { |
263 |
635 User::LeaveIfError( err ); |
264 // map cenrep value to index |
636 } |
265 switch ( value ) |
637 } |
266 { |
|
267 case EIAUpdateSettingValueEnable: |
|
268 value = KAutoUpdateOn; // On |
|
269 break; |
|
270 case EIAUpdateSettingValueDisable: |
|
271 value = KAutoUpdateOff; // Off |
|
272 break; |
|
273 case EIAUpdateSettingValueDisableWhenRoaming: |
|
274 value = KAutoUpdateOnInHomeNetwork; // On in home network |
|
275 break; |
|
276 default: |
|
277 break; |
|
278 } |
|
279 |
|
280 mAutoUpdateItem->setContentWidgetData("currentIndex", value); |
|
281 |
|
282 |
|
283 CleanupStack::PopAndDestroy( cenrep ); |
|
284 |
|
285 } |
638 } |
286 |
639 |
287 |
640 |
288 // ----------------------------------------------------------------------------- |
641 // ----------------------------------------------------------------------------- |
289 // CIAUpdateSettingDialog::getDestinationNameL |
642 // CIAUpdateAccessPointSettingItem::EditItemL |
290 // |
643 // |
291 // ----------------------------------------------------------------------------- |
644 // ----------------------------------------------------------------------------- |
292 // |
645 // |
293 void CIAUpdateSettingDialog::getDestinationNameL( uint aItemUid, QString& aItemName ) |
646 void CIAUpdateAccessPointSettingItem::EditItemL( TBool /*aCalledFromMenu*/ ) |
294 { |
647 { |
295 |
648 EditAccessPointItemL(); |
296 if ( aItemUid == 0 ) |
649 } |
297 { |
650 |
298 aItemUid = getInternetSnapIdL(); |
651 |
299 } |
652 // ----------------------------------------------------------------------------- |
300 |
653 // CIAUpdateAccessPointSettingItem::SettingTextL |
301 RCmDestination dest = mCmManager.DestinationL( aItemUid ); |
654 // |
302 CleanupClosePushL( dest ); |
655 // ----------------------------------------------------------------------------- |
303 HBufC* temp = dest.NameLC(); |
656 // |
304 CleanupStack::Pop( temp ); |
657 const TDesC& CIAUpdateAccessPointSettingItem::SettingTextL() |
305 CleanupStack::PopAndDestroy( &dest ); |
658 { |
306 |
659 if ( !iSettingText ) |
307 aItemName = XQConversions::s60DescToQString( temp->Des() ); |
660 { |
308 |
661 return CAknSettingItem::SettingTextL(); |
309 if ( aItemName.size() == 0 ) |
662 } |
310 { |
663 else if ( iSettingText->Length() == 0 ) |
311 User::Leave(KErrNotFound); |
664 { |
312 } |
665 return CAknSettingItem::SettingTextL(); |
313 } |
666 } |
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // ActionView::initializeView |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void CIAUpdateSettingDialog::initializeView() |
|
320 { |
|
321 |
|
322 setTitle("Software update"); // txt_software_title_software_update |
|
323 mSettingsForm->setHeading("Settings"); // txt_software_subhead_settings |
|
324 |
|
325 //create a model class |
|
326 HbDataFormModel *mModel = new HbDataFormModel(); |
|
327 |
|
328 // add Destination item |
|
329 mDestinationItem = mModel->appendDataFormItem( |
|
330 HbDataFormModelItem::ToggleValueItem, QString("Network connection")); // txt_software_formlabel_access_point |
|
331 |
|
332 // add auto update item |
|
333 mAutoUpdateItem = mModel->appendDataFormItem( |
|
334 HbDataFormModelItem::ComboBoxItem, QString("Auto-check for updates")); // txt_software_setlabel_autocheck_for_updates |
|
335 |
|
336 // auto update selection values |
|
337 QStringList list; |
|
338 list.insert(0, QString("On")); // txt_software_setlabel_val_on |
|
339 list.append(QString("Off")); // txt_software_setlabel_val_off |
|
340 list.append(QString("On in home network")); // txt_software_setlabel_val_on_in_home_network |
|
341 mAutoUpdateItem->setContentWidgetData("items", list); |
|
342 |
|
343 // connect data changes for launching the access point selection dialog |
|
344 connect(mModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), |
|
345 this, SLOT(toggleChange(QModelIndex, QModelIndex))); |
|
346 |
|
347 // connect to function called when data items are displayed |
|
348 connect(mSettingsForm, SIGNAL(activated(QModelIndex)), |
|
349 this, SLOT(activated(QModelIndex))); |
|
350 |
|
351 mSettingsForm->setModel(mModel); |
|
352 |
|
353 // set values for items |
|
354 TRAPD(err, initializeFieldsL()); |
|
355 qt_symbian_throwIfError(err); |
|
356 } |
|
357 |
|
358 // ----------------------------------------------------------------------------- |
|
359 // ActionView::getInternetSnapIdL |
|
360 // ----------------------------------------------------------------------------- |
|
361 // |
|
362 uint CIAUpdateSettingDialog::getInternetSnapIdL() |
|
363 { |
|
364 TUint internetSnapId( 0 ); |
|
365 |
|
366 RArray<TUint32> destinationIdArray; |
|
367 mCmManager.AllDestinationsL( destinationIdArray ); |
|
368 |
|
369 for ( TInt i = 0; i < destinationIdArray.Count(); i++ ) |
|
370 { |
|
371 RCmDestination destination = mCmManager.DestinationL( destinationIdArray[i] ); |
|
372 CleanupClosePushL( destination ); |
|
373 |
667 |
374 TUint32 metadata = destination.MetadataL( CMManager::ESnapMetadataPurpose ); |
668 return *iSettingText; |
375 if ( metadata == CMManager::ESnapPurposeInternet ) |
669 } |
376 { |
670 |
377 internetSnapId = destinationIdArray[i]; |
671 |
378 // Get the destination name with destination.NameLC() if need. |
672 //------------------------------------------------------------------------------ |
379 CleanupStack::PopAndDestroy( &destination ); |
673 // CIAUpdateAccessPointSettingItem::EditAccessPointItemL |
380 break; |
674 // |
381 } |
675 //------------------------------------------------------------------------------ |
382 CleanupStack::PopAndDestroy( &destination ); |
676 // |
383 } |
677 TBool CIAUpdateAccessPointSettingItem::EditAccessPointItemL() |
384 destinationIdArray.Close(); |
678 { |
385 |
679 TInt itemUid = iAccessPointId; |
386 return internetSnapId; |
680 |
387 |
681 TInt ret = KErrNone; |
388 } |
682 |
389 |
683 delete iSettingText; |
390 void CIAUpdateSettingDialog::showPreviousView() |
684 iSettingText = NULL; |
391 { |
685 TRAPD( err, ret = iApHandler->ShowApSelectDialogL( itemUid, iSettingText ) ); |
392 // Save settings |
686 |
393 TRAPD(err, saveSettingsL()); |
687 if ( err != KErrNone ) |
394 qt_symbian_throwIfError(err); |
688 { |
395 |
689 iAccessPointId = KErrNotFound; |
396 // Switch view |
690 UpdateListBoxTextL(); // from CAknSettingItem |
397 emit toMainView(); |
691 return EFalse; |
398 } |
692 } |
399 |
693 |
400 void CIAUpdateSettingDialog::activated(const QModelIndex& index) |
694 if ( ret == CIAUpdateAccessPointHandler::EDialogSelect ) |
401 { |
695 { |
402 if ( this->isActiveWindow() && index.row() == 0 ) |
696 iAccessPointId = itemUid; |
403 { |
697 UpdateListBoxTextL(); // from CAknSettingItem |
404 } |
698 return ETrue; |
405 |
699 } |
406 } |
700 |
|
701 return EFalse; |
|
702 } |
|
703 |
|
704 |
|
705 // End of File |