1 /* |
|
2 * Copyright (c) 2008 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: Setting list implementation for upnp GS plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <aknnotewrappers.h> // CAknInformationNote |
|
25 #include <pathinfo.h> |
|
26 #include <upnpstring.h> |
|
27 |
|
28 #include "upnpsettingsengine.h" |
|
29 #include "upnpsettingsengine.hrh" |
|
30 |
|
31 #include "upnpgsplugin.hrh" |
|
32 #include "upnpappsettingslist.h" |
|
33 #include "upnpappsettingitemhomeiap.h" |
|
34 #include "upnpappsettingitemmydevicename.h" |
|
35 #include <upnpgspluginrsc.rsg> |
|
36 |
|
37 #include <AknCommonDialogsDynMem.h> |
|
38 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
39 #include "upnpsettingitemmemoryselection.h" |
|
40 |
|
41 _LIT( KComponentLogfile, "upnpgsplugin.txt"); |
|
42 #include "upnplog.h" |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS ============================ |
|
45 |
|
46 // -------------------------------------------------------------------------- |
|
47 // CUPnPAppSettingsList::CUPnPAppSettingsList |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // -------------------------------------------------------------------------- |
|
51 // |
|
52 CUPnPAppSettingsList::CUPnPAppSettingsList( TBool& aSharingState ) |
|
53 : iSharingState( aSharingState ) |
|
54 { |
|
55 __LOG("[gsplugin]\tCUPnPAppSettingsList::CUPnPAppSettingsList"); |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CUPnPAppSettingsList::ConstructL |
|
60 // Symbian 2nd phase constructor can leave. |
|
61 // -------------------------------------------------------------------------- |
|
62 // |
|
63 void CUPnPAppSettingsList::ConstructL( TInt aResourceId ) |
|
64 { |
|
65 __LOG("[gsplugin]\t CUPnPAppSettingsList::ConstructL"); |
|
66 |
|
67 iName = HBufC8::NewL( KMaxFriendlyNameLength ); |
|
68 |
|
69 iSettingsEngine = CUPnPSettingsEngine::NewL(); |
|
70 |
|
71 if( aResourceId != 0 ) |
|
72 { |
|
73 CAknSettingItemList::ConstructFromResourceL( aResourceId ); |
|
74 } |
|
75 } |
|
76 |
|
77 // -------------------------------------------------------------------------- |
|
78 // CUPnPAppSettingsList::NewL |
|
79 // Two-phased constructor. |
|
80 // -------------------------------------------------------------------------- |
|
81 // |
|
82 CUPnPAppSettingsList* CUPnPAppSettingsList::NewL( TBool& aSharingState, |
|
83 TInt aResourceId ) |
|
84 { |
|
85 __LOG("[gsplugin]\t CUPnPAppSettingsList::NewL"); |
|
86 |
|
87 CUPnPAppSettingsList* self = new (ELeave) CUPnPAppSettingsList( |
|
88 aSharingState ); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL( aResourceId ); |
|
91 CleanupStack::Pop(self); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // -------------------------------------------------------------------------- |
|
96 // CUPnPAppSettingsList::~CUPnPAppSettingsList |
|
97 // Destructor |
|
98 // -------------------------------------------------------------------------- |
|
99 // |
|
100 CUPnPAppSettingsList::~CUPnPAppSettingsList() |
|
101 { |
|
102 __LOG("[gsplugin]\t CUPnPAppSettingsList:: \ |
|
103 ~CUPnPAppSettingsList"); |
|
104 delete iName; |
|
105 delete iSettingsEngine; |
|
106 } |
|
107 |
|
108 // -------------------------------------------------------------------------- |
|
109 // CUPnPAppSettingsList::CreateSettingItemL |
|
110 // Creates list items |
|
111 // -------------------------------------------------------------------------- |
|
112 // |
|
113 CAknSettingItem* CUPnPAppSettingsList::CreateSettingItemL( TInt aIdentifier ) |
|
114 { |
|
115 __LOG("[gsplugin]\t CUPnPAppSettingsList::CreateSettingItemL"); |
|
116 |
|
117 LoadSettingsL(); |
|
118 |
|
119 CAknSettingItem* settingItem = NULL; |
|
120 switch (aIdentifier) |
|
121 { |
|
122 case EUPnPGSPluginItemIAP: |
|
123 { |
|
124 settingItem = UPnPAppSettingItemHomeIAP::NewL( |
|
125 aIdentifier, |
|
126 iIapSetting, iIapId, |
|
127 iWapId, |
|
128 iSharingState ); |
|
129 break; |
|
130 } |
|
131 case EUPnPGSPluginItemMyDeviceName: |
|
132 { |
|
133 settingItem = UPnPAppSettingItemMyDeviceName::NewL( |
|
134 aIdentifier, |
|
135 iFriendlyName, |
|
136 iSharingState ); |
|
137 break; |
|
138 } |
|
139 case EUPnPGSPluginItemCopyLocation: |
|
140 { |
|
141 settingItem = CUPnPSettingItemMemorySelection::NewL( |
|
142 aIdentifier, iCopyLocationDrive); |
|
143 } |
|
144 break; |
|
145 |
|
146 default: |
|
147 { |
|
148 __LOG("[gsplugin]\t CUPnPAppSettingsList:: \ |
|
149 CreateSettingItemL No such item!"); |
|
150 break; |
|
151 } |
|
152 } |
|
153 |
|
154 return settingItem; |
|
155 } |
|
156 |
|
157 // -------------------------------------------------------------------------- |
|
158 // CUPnPAppSettingsList::EditItemL |
|
159 // Called when setting list item is modified |
|
160 // -------------------------------------------------------------------------- |
|
161 // |
|
162 void CUPnPAppSettingsList::EditItemL (TInt aIndex, TBool aCalledFromMenu) |
|
163 { |
|
164 __LOG("[gsplugin]\t CUPnPAppSettingsList::EditItemL"); |
|
165 |
|
166 // Validates the access point. |
|
167 TBool validiap = EFalse; |
|
168 TRAPD(err, validiap = CUPnPSettingsEngine::IsAccessPointValidL( iIapId ) ); |
|
169 if( err || !validiap ) |
|
170 { |
|
171 iIapId = EUPnPSettingsEngineIAPIdNone; |
|
172 iIapSetting = EUPnPSettingsEngineIAPItemNone; |
|
173 iWapId = EUPnPSettingsEngineIAPItemNone; |
|
174 } |
|
175 |
|
176 if ( aIndex != EUPnPGSPluginItemCopyLocation ) |
|
177 { |
|
178 CAknSettingItemList::EditItemL (aIndex, aCalledFromMenu); |
|
179 } |
|
180 |
|
181 StoreSettingsL(); |
|
182 |
|
183 switch (aIndex) |
|
184 { |
|
185 case EUPnPGSPluginItemIAP: |
|
186 { |
|
187 // if sharing is on, nothing is done |
|
188 if ( !iSharingState ) |
|
189 { |
|
190 iSettingsEngine->SetAccessPoint(iIapId); |
|
191 iSettingsEngine->SetAccessPointSetting(iIapSetting); |
|
192 iSettingsEngine->SetWapId(iWapId); |
|
193 } |
|
194 break; |
|
195 } |
|
196 case EUPnPGSPluginItemMyDeviceName: |
|
197 { |
|
198 // if sharing is on, nothing is done |
|
199 if ( !iSharingState ) |
|
200 { |
|
201 HBufC8* tmpStr = NULL; |
|
202 tmpStr = UpnpString::FromUnicodeL( iFriendlyName ); |
|
203 CleanupStack::PushL( tmpStr ); |
|
204 |
|
205 User::LeaveIfError( |
|
206 iSettingsEngine->SetLocalFriendlyName( tmpStr->Des() )); |
|
207 CleanupStack::PopAndDestroy( tmpStr ); |
|
208 } |
|
209 break; |
|
210 } |
|
211 case EUPnPGSPluginItemCopyLocation: |
|
212 { |
|
213 // if sharing is on, nothing is done |
|
214 if ( !iSharingState ) |
|
215 { |
|
216 CAknSettingItemList::EditItemL ( aIndex, aCalledFromMenu ); |
|
217 StoreSettingsL(); |
|
218 iSettingsEngine->SetCopyLocationL( iCopyLocationDrive ); |
|
219 } |
|
220 else |
|
221 { |
|
222 CAknInformationNote* note = new (ELeave) |
|
223 CAknInformationNote; |
|
224 HBufC* noteText = CCoeEnv::Static()->AllocReadResourceLC( |
|
225 R_QTN_IUPNP_IAP_TURN_SHARING_OFF); |
|
226 note->ExecuteLD(*noteText); |
|
227 CleanupStack::PopAndDestroy(noteText); |
|
228 } |
|
229 |
|
230 break; |
|
231 } |
|
232 default: |
|
233 { |
|
234 __LOG("[gsplugin]\t CUPnPAppSettingsList::EditItemL \ |
|
235 No such item!"); |
|
236 break; |
|
237 } |
|
238 } |
|
239 StoreSettingsL(); |
|
240 // load settings to screen |
|
241 CAknSettingItemList::LoadSettingsL (); |
|
242 } |
|
243 |
|
244 // -------------------------------------------------------------------------- |
|
245 // CUPnPAppSettingsList::LoadDataFromEngineL |
|
246 // Loads data from Central Repository to member variables |
|
247 // (other items were commented in a header). |
|
248 // -------------------------------------------------------------------------- |
|
249 // |
|
250 void CUPnPAppSettingsList::LoadDataFromEngineL() |
|
251 { |
|
252 __LOG("[gsplugin]\t CUPnPAppSettingsList::\ |
|
253 LoadDataFromEngineL begin"); |
|
254 |
|
255 // Get friendly name |
|
256 TPtr8 ptr( iName->Des() ); |
|
257 iSettingsEngine->GetLocalFriendlyName( ptr ); |
|
258 |
|
259 HBufC* unicodeFriendlyName = UpnpString::ToUnicodeL( ptr ); |
|
260 CleanupStack::PushL( unicodeFriendlyName ); |
|
261 iFriendlyName.Copy( unicodeFriendlyName->Des() ); |
|
262 CleanupStack::PopAndDestroy( unicodeFriendlyName ); |
|
263 |
|
264 iSettingsEngine->GetAccessPoint( iIapId ); |
|
265 iSettingsEngine->GetAccessPointSetting(iIapSetting); |
|
266 |
|
267 iSettingsEngine->GetWapId(iWapId); |
|
268 |
|
269 TInt error( KErrNone ); |
|
270 |
|
271 TRAP(error, iSettingsEngine->GetCopyLocationDriveL( iCopyLocationDrive ) ) |
|
272 |
|
273 // Something wrong in getting copy location. It defaults to |
|
274 // drive C and hopes that setting copy location succeeds |
|
275 if( error != KErrNone ) |
|
276 { |
|
277 iCopyLocationDrive = EDriveC; |
|
278 } |
|
279 |
|
280 // check if the IAP id is valid |
|
281 if ( !CUPnPSettingsEngine::IsAccessPointValidL( iIapId ) ) |
|
282 { |
|
283 // Resets all variables related to iap. |
|
284 iIapId = EUPnPSettingsEngineIAPIdNone; |
|
285 iIapSetting = EUPnPSettingsEngineIAPItemNone; |
|
286 iWapId = EUPnPSettingsEngineIAPItemNone; |
|
287 |
|
288 // set iap id |
|
289 iSettingsEngine->SetAccessPoint( iIapId ); |
|
290 // set iap UI setting |
|
291 iSettingsEngine->SetAccessPointSetting( iIapSetting ); |
|
292 // set iap wap id (needed for focus in iap selection component) |
|
293 iSettingsEngine->SetWapId( iWapId ); |
|
294 } |
|
295 |
|
296 //load settings to screen |
|
297 CAknSettingItemList::LoadSettingsL(); |
|
298 } |
|
299 |
|
300 // -------------------------------------------------------------------------- |
|
301 // CUPnPAppSettingsList::HandleResourceChange |
|
302 // -------------------------------------------------------------------------- |
|
303 // |
|
304 void CUPnPAppSettingsList::HandleResourceChange( TInt aType ) |
|
305 { |
|
306 __LOG("[gsplugin]\t CUPnPAppSettingsList::\ |
|
307 HandleResourceChange"); |
|
308 |
|
309 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
310 { |
|
311 TRect mainPaneRect; |
|
312 AknLayoutUtils::LayoutMetricsRect( |
|
313 AknLayoutUtils::EMainPane, mainPaneRect ); |
|
314 |
|
315 TAknLayoutRect layoutRect; |
|
316 layoutRect.LayoutRect( |
|
317 TRect( TPoint( 0, 0 ), mainPaneRect.Size() ), |
|
318 AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) ); |
|
319 |
|
320 ListBox()->SetRect( layoutRect.Rect() ); |
|
321 } |
|
322 |
|
323 // Base call |
|
324 CAknSettingItemList::HandleResourceChange( aType ); |
|
325 } |
|
326 |
|
327 // End of File |
|