1 /* |
|
2 * Copyright (c) 2008-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 "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 * Nokia Corporation |
|
14 * |
|
15 * Description: Setting item for the connection settings. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include "serversettingconnectionsettingitem.h" |
|
20 |
|
21 #include <cmmanagerext.h> |
|
22 #include <cmpluginvpndef.h> |
|
23 #include <cmsettingsui.h> |
|
24 #include <cmapplicationsettingsui.h> |
|
25 #include <cmdestinationext.h> |
|
26 |
|
27 using namespace CMManager; |
|
28 |
|
29 CServerSettingConnectionSettingItem::CServerSettingConnectionSettingItem(TInt aIdentifier, |
|
30 TCmSettingSelection& aSelection) |
|
31 :CAknSettingItem(aIdentifier), iExternalValue(aSelection) |
|
32 { |
|
33 } |
|
34 |
|
35 |
|
36 CServerSettingConnectionSettingItem::~CServerSettingConnectionSettingItem() |
|
37 { |
|
38 delete iSettingText; |
|
39 } |
|
40 |
|
41 |
|
42 void CServerSettingConnectionSettingItem::StoreL() |
|
43 { |
|
44 iExternalValue = iInternalValue; |
|
45 } |
|
46 |
|
47 |
|
48 void CServerSettingConnectionSettingItem::LoadL() |
|
49 { |
|
50 iInternalValue = iExternalValue; |
|
51 UpdateSettingTextL(); |
|
52 } |
|
53 |
|
54 |
|
55 void CServerSettingConnectionSettingItem::EditItemL( TBool /*aCalledFromMenu*/ ) |
|
56 { |
|
57 RCmManagerExt cmManager; |
|
58 cmManager.OpenLC(); |
|
59 // Get supported bearer filter types |
|
60 const TInt KArrayGranularity = 10; |
|
61 RArray<TUint32> bearers = RArray<TUint32>( KArrayGranularity ); |
|
62 CleanupClosePushL( bearers ); |
|
63 cmManager.SupportedBearersL( bearers ); |
|
64 // Do not include VPN bearer |
|
65 TInt index = bearers.Find( KPluginVPNBearerTypeUid ); |
|
66 if ( index != KErrNotFound ) |
|
67 { |
|
68 bearers.Remove( index ); |
|
69 } |
|
70 // Show settings page |
|
71 |
|
72 CCmApplicationSettingsUi* settings = CCmApplicationSettingsUi::NewL(); |
|
73 CleanupStack::PushL( settings ); |
|
74 TBool selected = settings->RunApplicationSettingsL( iInternalValue, |
|
75 EShowDestinations | |
|
76 EShowConnectionMethods, |
|
77 bearers ); |
|
78 CleanupStack::PopAndDestroy( 2 ); // settings, bearers |
|
79 |
|
80 if ( selected ) |
|
81 { |
|
82 UpdateSettingTextL(); |
|
83 UpdateListBoxTextL(); |
|
84 } |
|
85 |
|
86 CleanupStack::PopAndDestroy(); // cmManager |
|
87 |
|
88 } |
|
89 |
|
90 |
|
91 const TDesC& CServerSettingConnectionSettingItem::SettingTextL() |
|
92 { |
|
93 if (iSettingText == NULL) |
|
94 { |
|
95 return CAknSettingItem::SettingTextL(); |
|
96 } |
|
97 else |
|
98 { |
|
99 return *iSettingText; |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 void CServerSettingConnectionSettingItem::UpdateSettingTextL() |
|
105 { |
|
106 delete iSettingText; |
|
107 iSettingText = NULL; |
|
108 |
|
109 if ((iInternalValue.iResult == EDestination || |
|
110 iInternalValue.iResult == EConnectionMethod) && |
|
111 iInternalValue.iId != 0) |
|
112 { |
|
113 |
|
114 RCmManagerExt cmManager; |
|
115 cmManager.OpenLC(); |
|
116 |
|
117 if ( iInternalValue.iResult == EDestination ) |
|
118 { |
|
119 // Destination selected |
|
120 RCmDestinationExt dest; |
|
121 TRAPD( err, dest = cmManager.DestinationL( iInternalValue.iId ) ); |
|
122 |
|
123 if( KErrNone == err ) |
|
124 { |
|
125 CleanupClosePushL( dest ); |
|
126 iSettingText = dest.NameLC(); |
|
127 CleanupStack::Pop(iSettingText); |
|
128 CleanupStack::PopAndDestroy(); // dest |
|
129 } |
|
130 } |
|
131 else if ( iInternalValue.iResult == EConnectionMethod ) |
|
132 { |
|
133 // Connection method selected |
|
134 RCmConnectionMethodExt conn; |
|
135 TRAPD( err, conn = cmManager.ConnectionMethodL( iInternalValue.iId ) ); |
|
136 |
|
137 if( KErrNone == err ) |
|
138 { |
|
139 CleanupClosePushL( conn ); |
|
140 iSettingText = conn.GetStringAttributeL( ECmName ); |
|
141 CleanupStack::PopAndDestroy(); // conn |
|
142 } |
|
143 } |
|
144 |
|
145 CleanupStack::PopAndDestroy(); // cmManager |
|
146 } |
|
147 } |
|
148 |
|
149 /***/ |
|