1 /* |
|
2 * Copyright (c) 2006-2010 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: Implementation of CCmSettingsUiImpl. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <cmmanager.rsg> |
|
19 |
|
20 #include "cmsettingsuiimpl.h" |
|
21 #include "cmmanagerimpl.h" |
|
22 #include "destdlg.h" |
|
23 #include <cmcommonui.h> |
|
24 #include <cmpluginbase.h> |
|
25 #include <cmmanagerdef.h> |
|
26 #include <cmcommonconstants.h> |
|
27 #include <cmpluginwlandef.h> |
|
28 #include "selectdestinationdlg.h" |
|
29 #include <data_caging_path_literals.hrh> |
|
30 |
|
31 //----------------------------------------------------------------------------- |
|
32 // CCmSettingsUiImpl::NewL() |
|
33 //----------------------------------------------------------------------------- |
|
34 // |
|
35 CCmSettingsUiImpl* CCmSettingsUiImpl::NewL() |
|
36 { |
|
37 CCmSettingsUiImpl* self = new (ELeave) CCmSettingsUiImpl(); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop( self ); |
|
41 return self; |
|
42 } |
|
43 |
|
44 //----------------------------------------------------------------------------- |
|
45 // CCmSettingsUiImpl::CCmSettingsUiImpl |
|
46 //----------------------------------------------------------------------------- |
|
47 // |
|
48 CCmSettingsUiImpl::CCmSettingsUiImpl(): |
|
49 iResourceReader( *CCoeEnv::Static() ) |
|
50 { |
|
51 } |
|
52 |
|
53 //----------------------------------------------------------------------------- |
|
54 // CCmSettingsUiImpl::LoadResourceL |
|
55 // Load the resource for the dll module |
|
56 // ---------------------------------------------------------------------------- |
|
57 // |
|
58 TInt CCmSettingsUiImpl::LoadResourceL () |
|
59 { |
|
60 // Add resource file. |
|
61 TParse* fp = new(ELeave) TParse(); |
|
62 TInt err = fp->Set( KACMManagerResDirAndFileName, |
|
63 &KDC_RESOURCE_FILES_DIR, |
|
64 NULL ); |
|
65 if ( err != KErrNone) |
|
66 { |
|
67 User::Leave( err ); |
|
68 } |
|
69 |
|
70 TFileName resourceFileNameBuf = fp->FullName(); |
|
71 delete fp; |
|
72 |
|
73 iResourceReader.OpenL (resourceFileNameBuf); |
|
74 return err; |
|
75 } |
|
76 |
|
77 //----------------------------------------------------------------------------- |
|
78 // CCmSettingsUiImpl::~CCmSettingsUiImpl |
|
79 //----------------------------------------------------------------------------- |
|
80 // |
|
81 CCmSettingsUiImpl::~CCmSettingsUiImpl() |
|
82 { |
|
83 delete iCmManagerImpl; |
|
84 iResourceReader.Close(); |
|
85 } |
|
86 |
|
87 //----------------------------------------------------------------------------- |
|
88 // CCmSettingsUiImpl::ConstructL |
|
89 //----------------------------------------------------------------------------- |
|
90 // |
|
91 void CCmSettingsUiImpl::ConstructL() |
|
92 { |
|
93 iCmManagerImpl = CCmManagerImpl::NewL(); |
|
94 LoadResourceL(); |
|
95 AknsUtils::SetAvkonSkinEnabledL( ETrue ); |
|
96 } |
|
97 |
|
98 //----------------------------------------------------------------------------- |
|
99 // CCmSettingsUiImpl::RunSettingsL |
|
100 //----------------------------------------------------------------------------- |
|
101 // |
|
102 TInt CCmSettingsUiImpl::RunSettingsL() |
|
103 { |
|
104 CDestDlg* destDlg = new (ELeave) CDestDlg; |
|
105 |
|
106 TUint32 selected = 0; |
|
107 // No need to push it on to the cleanup stack as CEikDialog::PrepareLC |
|
108 // does this favour for us. |
|
109 |
|
110 TBool exiting = EFalse; |
|
111 |
|
112 TInt result = destDlg->ConstructAndRunLD( |
|
113 iCmManagerImpl, 0, selected, exiting ); |
|
114 |
|
115 return ( exiting ) ? KDialogUserExit: KDialogUserBack; |
|
116 } |
|
117 |
|
118 //----------------------------------------------------------------------------- |
|
119 // CCmSettingsUiImpl::SelectDestinationDlgL |
|
120 //----------------------------------------------------------------------------- |
|
121 // |
|
122 TBool CCmSettingsUiImpl::SelectDestinationDlgL( TUint32& aDestinationId ) |
|
123 { |
|
124 CSelectDestinationDlg* dlg = CSelectDestinationDlg::NewL( aDestinationId, |
|
125 *iCmManagerImpl ); |
|
126 |
|
127 return dlg->ExecuteLD( R_CMMANAGER_LIST_QUERY_WITH_MSGBOX ); |
|
128 } |
|
129 //----------------------------------------------------------------------------- |
|
130 // CCmSettingsUiImpl::AddCmL |
|
131 //----------------------------------------------------------------------------- |
|
132 // |
|
133 TUint32 CCmSettingsUiImpl::AddCmL( TUint32& aDestUid, TUint32 aBearerType ) |
|
134 { |
|
135 // Add new connection method |
|
136 TUint32 addedIapId(0); |
|
137 |
|
138 CCmDestinationImpl* destImpl = iCmManagerImpl->DestinationL( aDestUid ); |
|
139 CleanupStack::PushL(destImpl); |
|
140 |
|
141 // Check first if parent destination is protected |
|
142 if ( destImpl->ProtectionLevel() == CMManager::EProtLevel1 ) |
|
143 { |
|
144 TCmCommonUi::ShowNoteL( R_CMWIZARD_CANNOT_PERFORM_FOR_PROTECTED, |
|
145 TCmCommonUi::ECmErrorNote ); |
|
146 } |
|
147 else |
|
148 { |
|
149 // Automatically check for available conn methods? |
|
150 |
|
151 TBool manualConfigure = ETrue; |
|
152 if (aBearerType == KUidWlanBearerType) |
|
153 { |
|
154 TInt retval = |
|
155 TCmCommonUi::ShowConfirmationQueryL( R_CMWIZARD_AUTOMATIC_CHECK ); |
|
156 |
|
157 manualConfigure = ( retval == EAknSoftkeyYes || retval == EAknSoftkeyOk ) |
|
158 ? EFalse : ETrue; |
|
159 } |
|
160 |
|
161 CCmPluginBase* plugin = destImpl->CreateConnectionMethodL( aBearerType ); |
|
162 CleanupStack::PushL( plugin ); |
|
163 |
|
164 // Bearer-specific UI-supported initialization is done by plug-ins |
|
165 if ( plugin->InitializeWithUiL( manualConfigure ) ) |
|
166 { |
|
167 destImpl->UpdateL(); // commit changes |
|
168 |
|
169 RArray<TUint32> additionalCms; |
|
170 CleanupClosePushL (additionalCms); |
|
171 plugin->GetAdditionalUids( additionalCms ); |
|
172 //if there are additional cms created, move them to the target destination as well |
|
173 for ( TInt i = 0; i<additionalCms.Count(); i++) |
|
174 { |
|
175 CCmPluginBase* cm = iCmManagerImpl->GetConnectionMethodL( additionalCms[i] ); |
|
176 CleanupStack::PushL(cm); |
|
177 iCmManagerImpl->CopyConnectionMethodL( *destImpl, *cm ); |
|
178 CleanupStack::PopAndDestroy( cm ); |
|
179 } |
|
180 CleanupStack::PopAndDestroy( &additionalCms ); |
|
181 addedIapId = plugin->GetIntAttributeL( CMManager::ECmIapId ); |
|
182 } |
|
183 CleanupStack::PopAndDestroy(plugin); |
|
184 } |
|
185 CleanupStack::PopAndDestroy(destImpl); |
|
186 |
|
187 return addedIapId; |
|
188 } |
|
189 |
|
190 //----------------------------------------------------------------------------- |
|
191 // CCmSettingsUiImpl::EditCmL |
|
192 //----------------------------------------------------------------------------- |
|
193 // |
|
194 TInt CCmSettingsUiImpl::EditCmL( TUint32 aCmId ) |
|
195 { |
|
196 // Edit connection method |
|
197 TInt ret( KDialogUserBack ); |
|
198 |
|
199 CCmPluginBase* cm = iCmManagerImpl->GetConnectionMethodL( aCmId ); |
|
200 CleanupStack::PushL( cm ); |
|
201 |
|
202 cm->ReLoadL(); |
|
203 if ( cm->GetBoolAttributeL( CMManager::ECmProtected ) || |
|
204 cm->GetBoolAttributeL( CMManager::ECmDestination ) ) |
|
205 { |
|
206 TCmCommonUi::ShowNoteL( R_CMMANAGERUI_INFO_PROTECTED_CANNOT_EDIT, |
|
207 TCmCommonUi::ECmErrorNote ); |
|
208 } |
|
209 else if ( cm->GetBoolAttributeL( CMManager::ECmBearerHasUi ) ) |
|
210 { |
|
211 // check if the cm is in use |
|
212 if ( cm->GetBoolAttributeL( CMManager::ECmConnected ) ) |
|
213 { |
|
214 TCmCommonUi::ShowNoteL( R_QTN_SET_NOTE_AP_IN_USE_EDIT, |
|
215 TCmCommonUi::ECmErrorNote ); |
|
216 } |
|
217 else |
|
218 { |
|
219 //Makes sure that the commsdat notifier is initialized. |
|
220 cm->CmMgr().StartCommsDatNotifierL(); |
|
221 ret = cm->RunSettingsL(); |
|
222 } |
|
223 } |
|
224 CleanupStack::PopAndDestroy(cm); |
|
225 return ret; |
|
226 } |
|
227 |
|