1 /* |
|
2 * Copyright (c) 2007 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: GSPDataAccessPointPlugin implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // User includes |
|
20 #include "GSPDataAccessPointPlugin.h" |
|
21 #include "GSPDataAccessPointModel.h" |
|
22 #include <gsparentplugin.h> |
|
23 #include <gscommon.hrh> |
|
24 #include <GSPDataAccessPointPluginRsc.rsg> // GUI Resource |
|
25 #include <gsprivatepluginproviderids.h> |
|
26 #include <gsfwviewuids.h> |
|
27 |
|
28 // System includes |
|
29 #include <aknnotewrappers.h> |
|
30 #include <aknradiobuttonsettingpage.h> |
|
31 #include <akntextsettingpage.h> |
|
32 #include <aknViewAppUi.h> |
|
33 #include <bautils.h> |
|
34 #include <featmgr.h> |
|
35 #include <hlplch.h> // HlpLauncher |
|
36 #include <StringLoader.h> |
|
37 #include <telephonydomainpskeys.h> |
|
38 #include <apgtask.h> |
|
39 |
|
40 // Constants |
|
41 const TInt KGSBufSize128 = 128; |
|
42 // ========================= MEMBER FUNCTIONS ================================ |
|
43 |
|
44 // --------------------------------------------------------------------------- |
|
45 // CGSPDataAccessPointPlugin::CGSPDataAccessPointPlugin() |
|
46 // Constructor |
|
47 // |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CGSPDataAccessPointPlugin::CGSPDataAccessPointPlugin() |
|
51 : iResources( *iCoeEnv ) |
|
52 { |
|
53 } |
|
54 |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CGSPDataAccessPointPlugin::~CGSPDataAccessPointPlugin() |
|
58 // Destructor |
|
59 // |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CGSPDataAccessPointPlugin::~CGSPDataAccessPointPlugin() |
|
63 { |
|
64 iResources.Close(); |
|
65 |
|
66 if( iModel ) |
|
67 { |
|
68 delete iModel; |
|
69 } |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CGSPDataAccessPointPlugin::ConstructL(const TRect& aRect) |
|
75 // Symbian OS two-phased constructor |
|
76 // |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CGSPDataAccessPointPlugin::ConstructL() |
|
80 { |
|
81 iModel = CGSPDataAccessPointModel::NewL(); |
|
82 OpenLocalizedResourceFileL( KPDataAccessPointResourceFileName, iResources ); |
|
83 BaseConstructL( R_GS_PDATAACCESSPOINT_VIEW ); |
|
84 } |
|
85 |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CGSPDataAccessPointPlugin::NewL() |
|
89 // Static constructor |
|
90 // |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CGSPDataAccessPointPlugin* CGSPDataAccessPointPlugin::NewL( TAny* /*aInitParams*/ ) |
|
94 { |
|
95 CGSPDataAccessPointPlugin* self = new( ELeave ) CGSPDataAccessPointPlugin(); |
|
96 CleanupStack::PushL( self ); |
|
97 self->ConstructL(); |
|
98 CleanupStack::Pop( self ); |
|
99 return self; |
|
100 } |
|
101 |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CGSPDataAccessPointPlugin::Id |
|
105 // |
|
106 // |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TUid CGSPDataAccessPointPlugin::Id() const |
|
110 { |
|
111 return KGSPDataAccessPointPluginUID; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CGSPDataAccessPointPlugin::DoActivateL |
|
116 // |
|
117 // |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CGSPDataAccessPointPlugin::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
121 TUid /*aCustomMessageId*/, |
|
122 const TDesC8& /*aCustomMessage*/ ) |
|
123 { |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CGSPDataAccessPointPlugin::DoDeactivate |
|
129 // |
|
130 // |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CGSPDataAccessPointPlugin::DoDeactivate() |
|
134 { |
|
135 } |
|
136 |
|
137 |
|
138 // ========================= From CGSPluginInterface ================== |
|
139 |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CGSPDataAccessPointPlugin::GetCaptionL |
|
143 // |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CGSPDataAccessPointPlugin::GetCaptionL( TDes& aCaption ) const |
|
148 { |
|
149 HBufC* result = StringLoader::LoadL( R_GS_PDATAACCESSPOINT_PLUGIN_CAPTION ); |
|
150 aCaption.Copy( *result ); |
|
151 delete result; |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CGSPDataAccessPointPlugin::PluginProviderCategory |
|
157 // |
|
158 // |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 TInt CGSPDataAccessPointPlugin::PluginProviderCategory() const |
|
162 { |
|
163 return KGSPluginProviderInternal; |
|
164 } |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CGSPDataAccessPointPlugin::ItemType() |
|
169 // |
|
170 // |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 TGSListboxItemTypes CGSPDataAccessPointPlugin::ItemType() |
|
174 { |
|
175 return EGSItemTypeSettingDialog; |
|
176 } |
|
177 |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CGSPDataAccessPointPlugin::GetValue() |
|
181 // |
|
182 // |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CGSPDataAccessPointPlugin::GetValue( const TGSPluginValueKeys aKey, |
|
186 TDes& aValue ) |
|
187 { |
|
188 TRAPD( err, GetValueL( aValue ) ); |
|
189 if ( err != KErrNone ) |
|
190 { |
|
191 CGSPluginInterface::GetValue( aKey, aValue ); |
|
192 } |
|
193 } |
|
194 |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // CGSPDataAccessPointPlugin::GetValueL() |
|
198 // |
|
199 // Leaving version of GetValue() |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CGSPDataAccessPointPlugin::GetValueL( TDes& aValue ) |
|
203 { |
|
204 HBufC* name = HBufC::NewLC( KGSBufSize128 ); |
|
205 TPtr ptrBuffer ( name->Des() ); |
|
206 HBufC* dynamicText = name; |
|
207 if ( iModel->GetDialupAPNameL( ptrBuffer ) != KErrNone |
|
208 || ptrBuffer.Length() == 0 ) |
|
209 { |
|
210 dynamicText = iEikonEnv->AllocReadResourceL( R_DIALUP_AP_NAME_NONE ); |
|
211 } |
|
212 TPtr bufPtr( dynamicText->Des() ); |
|
213 aValue.Copy( *dynamicText ); |
|
214 CleanupStack::PopAndDestroy( name ); |
|
215 } |
|
216 |
|
217 |
|
218 // ----------------------------------------------------------------------------- |
|
219 // CGSPDataAccessPointPlugin::HandleSelection() |
|
220 // |
|
221 // |
|
222 // ----------------------------------------------------------------------------- |
|
223 // |
|
224 void CGSPDataAccessPointPlugin::HandleSelection( |
|
225 const TGSSelectionTypes aSelectionType ) |
|
226 { |
|
227 switch( aSelectionType ) |
|
228 { |
|
229 case EGSSelectionBySelectionKey: |
|
230 case EGSSelectionByMenu: |
|
231 TRAP_IGNORE( ShowAccessPointSettingPageL() ); |
|
232 break; |
|
233 } |
|
234 |
|
235 } |
|
236 |
|
237 |
|
238 // ----------------------------------------------------------------------------- |
|
239 // CGSPDataAccessPointPlugin::ShowAccessPointSettingPageL() |
|
240 // |
|
241 // |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 void CGSPDataAccessPointPlugin::ShowAccessPointSettingPageL() |
|
245 { |
|
246 TBuf<KGSMaxDAPName> name; |
|
247 //returns error code, no need to check the value |
|
248 //(it doesn't matter if 'name' is empty) |
|
249 iModel->GetDialupAPNameL( name ); |
|
250 |
|
251 CAknTextSettingPage* dlg = new( ELeave ) CAknTextSettingPage( |
|
252 R_DIALUP_AP_NAME_SETTING_PAGE, |
|
253 name, |
|
254 CAknTextSettingPage::EZeroLengthAllowed ); |
|
255 |
|
256 if ( dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged ) ) |
|
257 { |
|
258 iModel->SetDialupAPNameL( name ); |
|
259 // Update AI item's value to lbx: |
|
260 CGSParentPlugin* parent = static_cast<CGSParentPlugin*>( |
|
261 AppUi()->View( KGSPDataPluginUid ) );// This is the parent plugin |
|
262 parent->UpdateView(); |
|
263 } |
|
264 } |
|
265 |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // CGSPDataAccessPointPlugin::OpenLocalizedResourceFileL() |
|
269 // |
|
270 // |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CGSPDataAccessPointPlugin::OpenLocalizedResourceFileL( |
|
274 const TDesC& aResourceFileName, |
|
275 RConeResourceLoader& aResourceLoader ) |
|
276 { |
|
277 RFs fsSession; |
|
278 User::LeaveIfError( fsSession.Connect() ); |
|
279 |
|
280 // Find the resource file: |
|
281 TParse parse; |
|
282 parse.Set( aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
283 TFileName fileName( parse.FullName() ); |
|
284 |
|
285 // Get language of resource file: |
|
286 BaflUtils::NearestLanguageFile( fsSession, fileName ); |
|
287 |
|
288 // Open resource file: |
|
289 aResourceLoader.OpenL( fileName ); |
|
290 |
|
291 // If leave occurs before this, close is called automatically when the |
|
292 // thread exits. |
|
293 fsSession.Close(); |
|
294 } |
|
295 |
|
296 |
|
297 // ----------------------------------------------------------------------------- |
|
298 // CGSPDataAccessPointPlugin::TGSMenuActivationItems() |
|
299 // |
|
300 // |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 TGSMenuActivationItems CGSPDataAccessPointPlugin::MenuActivationItem() |
|
304 { |
|
305 return EGSMenuActivationItemChange; |
|
306 } |
|
307 |
|
308 // End of file |
|