44 |
44 |
45 void RefreshConnectionListL() |
45 void RefreshConnectionListL() |
46 { |
46 { |
47 CArrayPtr< CAknEnumeratedText > * enumeratedArr = EnumeratedTextArray(); |
47 CArrayPtr< CAknEnumeratedText > * enumeratedArr = EnumeratedTextArray(); |
48 CArrayPtr< HBufC > * poppedUpTextArray = PoppedUpTextArray(); |
48 CArrayPtr< HBufC > * poppedUpTextArray = PoppedUpTextArray(); |
49 enumeratedArr->ResetAndDestroy(); |
|
50 poppedUpTextArray->ResetAndDestroy(); |
|
51 |
49 |
52 CDesCArrayFlat *iapArray = iPodcastModel.IAPNames(); |
50 CDesCArrayFlat *iapArray = iPodcastModel.IAPNames(); |
53 |
51 |
54 TBool valueExists = EFalse; |
52 TBool valueExists = EFalse; |
55 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
53 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
56 for (int i=0;i<iapArray->Count();i++) { |
54 for (int i=0;i<iapArray->Count();i++) { |
57 HBufC *buf = (*iapArray)[i].AllocL(); |
55 HBufC *buf = (*iapArray)[i].AllocL(); |
58 poppedUpTextArray->AppendL(buf); |
56 poppedUpTextArray->AppendL(buf); |
59 |
57 |
60 TInt iapId = iPodcastModel.IAPIds()[i].iIapId; |
58 TInt iapId = iPodcastModel.IAPIds()[i].iIapId; |
61 DP2("IAP name='%S', id=%d", buf, iapId); |
59 DP2("IAP name='%S', id=%d", buf, iapId); |
62 |
60 |
63 if (iapId == ExternalValue()) { |
61 if (iapId == ExternalValue() || ExternalValue() == 0 || ExternalValue() == -1) |
64 valueExists = ETrue; |
62 { |
65 } |
63 valueExists = ETrue; |
66 // both arrays destroy themselves, so we need two copies to prevent USER 44 |
64 } |
67 HBufC *buf2 = (*iapArray)[i].AllocL(); |
65 |
68 |
66 // both arrays destroy themselves, so we need two copies to prevent USER 44 |
69 CAknEnumeratedText *enumerated = new CAknEnumeratedText(iapId, buf2); |
67 HBufC *buf2 = (*iapArray)[i].AllocL(); |
70 enumeratedArr->AppendL(enumerated); |
68 |
|
69 CAknEnumeratedText *enumerated = new CAknEnumeratedText(iapId, buf2); |
|
70 enumeratedArr->AppendL(enumerated); |
71 } |
71 } |
72 |
72 |
73 DP1("valueExists=%d", valueExists); |
73 DP1("valueExists=%d", valueExists); |
74 if (!valueExists && iPodcastModel.IAPIds().Count() > 0 ) { |
74 if (!valueExists && iPodcastModel.IAPIds().Count() > 0 ) { |
75 DP1("Setting iIap=%d", iPodcastModel.IAPIds()[0].iIapId); |
75 DP1("Setting iIap=%d", iPodcastModel.IAPIds()[0].iIapId); |
76 iIap = iPodcastModel.IAPIds()[0].iIapId; |
76 iIap = iPodcastModel.IAPIds()[0].iIapId; |
77 LoadL(); |
77 LoadL(); |
78 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
78 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
79 } |
79 } |
80 |
80 |
81 TRAPD(err, HandleTextArrayUpdateL()); |
81 TRAPD(err, HandleTextArrayUpdateL()); |
82 |
82 |
83 if (err != KErrNone) { |
83 if (err != KErrNone) { |
119 CPodcastModel& iPodcastModel; |
119 CPodcastModel& iPodcastModel; |
120 TInt& iIap; |
120 TInt& iIap; |
121 }; |
121 }; |
122 |
122 |
123 |
123 |
124 class CConnectionSetting: public CAknEnumeratedTextPopupSettingItem |
124 //class CConnectionSetting: public CAknEnumeratedTextPopupSettingItem |
125 { |
125 //{ |
126 public: |
126 //public: |
127 CConnectionSetting(TInt aResourceId, TInt& aValue, CPodcastModel &aPodcastModel) : |
127 // CConnectionSetting(TInt aResourceId, TInt& aValue, CPodcastModel &aPodcastModel) : |
128 CAknEnumeratedTextPopupSettingItem(aResourceId, aValue), iPodcastModel(aPodcastModel) |
128 // CAknEnumeratedTextPopupSettingItem(aResourceId, aValue), iPodcastModel(aPodcastModel) |
129 { |
129 // { |
130 } |
130 // } |
131 |
131 // |
132 ~CConnectionSetting() |
132 // ~CConnectionSetting() |
133 { |
133 // { |
134 } |
134 // } |
135 |
135 // |
136 void RefreshConnectionListL() |
136 // void RefreshConnectionListL() |
137 { |
137 // { |
138 CArrayPtr< CAknEnumeratedText > * enumeratedArr = EnumeratedTextArray(); |
138 // CArrayPtr< CAknEnumeratedText > * enumeratedArr = EnumeratedTextArray(); |
139 CArrayPtr< HBufC > * poppedUpTextArray = PoppedUpTextArray(); |
139 // CArrayPtr< HBufC > * poppedUpTextArray = PoppedUpTextArray(); |
140 |
140 // |
141 CDesCArrayFlat *snapArray = iPodcastModel.SNAPNames(); |
141 // CDesCArrayFlat *snapArray = iPodcastModel.SNAPNames(); |
142 |
142 // |
143 TBool valueExists = EFalse; |
143 // TBool valueExists = EFalse; |
144 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
144 // DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
145 for (int i=0;i<snapArray->Count();i++) { |
145 // for (int i=0;i<snapArray->Count();i++) { |
146 HBufC *buf = (*snapArray)[i].AllocL(); |
146 // HBufC *buf = (*snapArray)[i].AllocL(); |
147 poppedUpTextArray->InsertL(EConnectionUseNetwork+i,buf); |
147 // poppedUpTextArray->InsertL(EConnectionUseNetwork+i,buf); |
148 |
148 // |
149 TInt snapId = iPodcastModel.SNAPIds()[i].iIapId; |
149 // TInt snapId = iPodcastModel.SNAPIds()[i].iIapId; |
150 DP2("SNAP name='%S', id=%d", buf, snapId); |
150 // DP2("SNAP name='%S', id=%d", buf, snapId); |
151 |
151 // |
152 if (snapId == ExternalValue()) { |
152 // if (snapId == ExternalValue()) { |
153 valueExists = ETrue; |
153 // valueExists = ETrue; |
154 } |
154 // } |
155 // both arrays destroy themselves, so we need two copies to prevent USER 44 |
155 // // both arrays destroy themselves, so we need two copies to prevent USER 44 |
156 HBufC *buf2 = (*snapArray)[i].AllocL(); |
156 // HBufC *buf2 = (*snapArray)[i].AllocL(); |
157 |
157 // |
158 CAknEnumeratedText *enumerated = new CAknEnumeratedText(EConnectionUseNetwork+i, buf2); |
158 // CAknEnumeratedText *enumerated = new CAknEnumeratedText(EConnectionUseNetwork+i, buf2); |
159 enumeratedArr->InsertL(EConnectionUseNetwork+i, enumerated); |
159 // enumeratedArr->InsertL(EConnectionUseNetwork+i, enumerated); |
160 } |
160 // } |
161 |
161 // |
162 DP1("valueExists=%d", valueExists); |
162 // DP1("valueExists=%d", valueExists); |
163 if (!valueExists && iPodcastModel.SNAPIds().Count() > 0 ) { |
163 // if (!valueExists && iPodcastModel.SNAPIds().Count() > 0 ) { |
164 DP1("Setting i=%d", iPodcastModel.SNAPIds()[0].iIapId); |
164 // DP1("Setting i=%d", iPodcastModel.SNAPIds()[0].iIapId); |
165 LoadL(); |
165 // LoadL(); |
166 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
166 // DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
167 } |
167 // } |
168 |
168 // |
169 TRAPD(err, HandleTextArrayUpdateL()); |
169 // TRAPD(err, HandleTextArrayUpdateL()); |
170 |
170 // |
171 if (err != KErrNone) { |
171 // if (err != KErrNone) { |
172 DP1("Leave in HandleTextArrayUpdateL, err=%d", err); |
172 // DP1("Leave in HandleTextArrayUpdateL, err=%d", err); |
173 } |
173 // } |
174 } |
174 // } |
175 |
175 // |
176 void CompleteConstructionL() |
176 // void CompleteConstructionL() |
177 { |
177 // { |
178 DP("CIapSetting::CompleteConstructionL BEGIN"); |
178 // DP("CIapSetting::CompleteConstructionL BEGIN"); |
179 CAknEnumeratedTextPopupSettingItem::CompleteConstructionL(); |
179 // CAknEnumeratedTextPopupSettingItem::CompleteConstructionL(); |
180 RefreshConnectionListL(); |
180 // RefreshConnectionListL(); |
181 DP("CIapSetting::CompleteConstructionL END"); |
181 // DP("CIapSetting::CompleteConstructionL END"); |
182 } |
182 // } |
183 |
183 // |
184 void EditItemL(TBool aCalledFromMenu) |
184 // void EditItemL(TBool aCalledFromMenu) |
185 { |
185 // { |
186 DP("CIapSetting::EditItemL BEGIN"); |
186 // DP("CIapSetting::EditItemL BEGIN"); |
187 LoadL(); |
187 // LoadL(); |
188 CAknEnumeratedTextPopupSettingItem::EditItemL(aCalledFromMenu); |
188 // CAknEnumeratedTextPopupSettingItem::EditItemL(aCalledFromMenu); |
189 StoreL(); |
189 // StoreL(); |
190 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
190 // DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
191 DP("CIapSetting::EditItemL END"); |
191 // DP("CIapSetting::EditItemL END"); |
192 } |
192 // } |
193 |
193 // |
194 void HandleSettingPageEventL(CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType) |
194 // void HandleSettingPageEventL(CAknSettingPage* aSettingPage, TAknSettingPageEvent aEventType) |
195 { |
195 // { |
196 DP("CIapSetting::HandleSettingPageEventL BEGIN"); |
196 // DP("CIapSetting::HandleSettingPageEventL BEGIN"); |
197 CAknSettingItem::HandleSettingPageEventL(aSettingPage, aEventType); |
197 // CAknSettingItem::HandleSettingPageEventL(aSettingPage, aEventType); |
198 /*if (aEventType == EEventSettingOked) |
198 // /*if (aEventType == EEventSettingOked) |
199 { |
199 // { |
200 DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
200 // DP2("InternalValue=%d, ExternalValue=%d", InternalValue(), ExternalValue()); |
201 StoreL(); |
201 // StoreL(); |
202 }*/ |
202 // }*/ |
203 DP("CIapSetting::HandleSettingPageEventL END"); |
203 // DP("CIapSetting::HandleSettingPageEventL END"); |
204 } |
204 // } |
205 |
205 // |
206 protected: |
206 //protected: |
207 CPodcastModel& iPodcastModel; |
207 // CPodcastModel& iPodcastModel; |
208 }; |
208 //}; |
209 |
209 |
210 class CPodcastSettingItemList:public CAknSettingItemList |
210 class CPodcastSettingItemList:public CAknSettingItemList |
211 { |
211 { |
212 public: |
212 public: |
213 CPodcastSettingItemList(CPodcastModel& aPodcastModel) : iPodcastModel(aPodcastModel) |
213 CPodcastSettingItemList(CPodcastModel& aPodcastModel) : iPodcastModel(aPodcastModel) |
224 StoreSettingsL(); |
224 StoreSettingsL(); |
225 CSettingsEngine &se = iPodcastModel.SettingsEngine(); |
225 CSettingsEngine &se = iPodcastModel.SettingsEngine(); |
226 se.SetBaseDir(iShowDir); |
226 se.SetBaseDir(iShowDir); |
227 DP1("Base Dir: %S", &iShowDir); |
227 DP1("Base Dir: %S", &iShowDir); |
228 se.SetUpdateAutomatically((TAutoUpdateSetting)iAutoUpdate); |
228 se.SetUpdateAutomatically((TAutoUpdateSetting)iAutoUpdate); |
229 DP1("Update automatically: %d", iAutoUpdate); |
229 DP1("Update automatically: %d", iAutoUpdate); |
230 switch(iConnection) |
230 se.SetSpecificIAP(iIap); |
231 { |
|
232 case EConnectionDefault: |
|
233 { |
|
234 DP("Specific IAP: 0 Ask user"); |
|
235 se.SetSpecificIAP(0); |
|
236 }break; |
|
237 case EConnectionAlwaysAsk: |
|
238 { |
|
239 DP("Specific IAP: -1 Ask user"); |
|
240 se.SetSpecificIAP(-1); |
|
241 }break; |
|
242 |
|
243 case EConnectionUseIap: |
|
244 { |
|
245 DP1("Specific NETWORK: %d", iIap); |
|
246 se.SetSpecificIAP((iIap|KUseIAPFlag)); |
|
247 }break; |
|
248 default: |
|
249 case EConnectionUseNetwork: |
|
250 { |
|
251 DP1("Specific IAP: %d", iIap); |
|
252 TInt snapIndex = iConnection-EConnectionUseNetwork; |
|
253 se.SetSpecificIAP(iPodcastModel.SNAPIds()[snapIndex].iIapId); |
|
254 }break; |
|
255 } |
|
256 |
231 |
257 DP1("Download automatically: %d", iAutoDownload); |
232 DP1("Download automatically: %d", iAutoDownload); |
258 se.SetDownloadAutomatically(iAutoDownload); |
233 se.SetDownloadAutomatically(iAutoDownload); |
259 se.SaveSettingsL(); |
234 se.SaveSettingsL(); |
260 DP("StoreSettings END"); |
235 DP("StoreSettings END"); |
268 |
243 |
269 void UpdateSettingVisibility() |
244 void UpdateSettingVisibility() |
270 { |
245 { |
271 DP("UpdateSettingVisibility BEGIN"); |
246 DP("UpdateSettingVisibility BEGIN"); |
272 LoadSettingsL(); |
247 LoadSettingsL(); |
273 TBool dimAutoUpdate = iConnection == EConnectionAlwaysAsk; |
248 TBool dimAutoUpdate = iIap == EConnectionAlwaysAsk; |
274 TBool dimIAP = iConnection < EConnectionUseIap; |
249 // TBool dimIAP = EFalse; //iConnection < EConnectionUseIap; |
275 |
250 |
276 iSettingAutoUpdate->SetHidden(dimAutoUpdate); |
251 iSettingAutoUpdate->SetHidden(dimAutoUpdate); |
277 iSettingIAP->SetHidden(dimIAP); |
252 // iSettingIAP->SetHidden(dimIAP); |
278 if(!dimIAP) |
253 // if(!dimIAP) |
279 { |
254 // { |
280 iSettingIAP->RefreshConnectionListL(); |
255 // iSettingIAP->RefreshConnectionListL(); |
281 } |
256 // } |
282 ListBox()->ScrollToMakeItemVisible(0); |
257 ListBox()->ScrollToMakeItemVisible(0); |
283 |
258 |
284 TRAP_IGNORE(HandleChangeInItemArrayOrVisibilityL()); |
259 TRAP_IGNORE(HandleChangeInItemArrayOrVisibilityL()); |
285 DP("UpdateSettingVisibility END"); |
260 DP("UpdateSettingVisibility END"); |
286 } |
261 } |
287 |
262 |
288 void EditItemL (TInt aIndex, TBool aCalledFromMenu) |
263 void EditItemL (TInt aIndex, TBool aCalledFromMenu) |
289 { |
264 { |
290 DP("EditItemL BEGIN"); |
265 if (aIndex == 0) { |
291 // if (aIndex == 0) { |
266 CAknMemorySelectionDialog* memDlg = |
292 // TFileName selectedFolder; |
267 CAknMemorySelectionDialog::NewL(ECFDDialogTypeNormal, ETrue); |
293 // selectedFolder.Copy(iShowDir); |
268 CleanupStack::PushL(memDlg); |
294 // TFileName startFolder; |
269 CAknMemorySelectionDialog::TMemory memory = |
295 // startFolder.Zero(); |
270 CAknMemorySelectionDialog::EPhoneMemory; |
296 // TInt types = AknCommonDialogsDynMem::EMemoryTypePhone | AknCommonDialogsDynMem::EMemoryTypeMMC |AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage| AknCommonDialogsDynMem::EMemoryTypeRemote; |
271 |
297 // |
272 if (memDlg->ExecuteL(memory)) |
298 // HBufC *title = iCoeEnv->AllocReadResourceLC(R_PODCAST_SELECT_FOLDER); |
273 { |
299 // if (AknCommonDialogsDynMem::RunFolderSelectDlgLD (types, selectedFolder, |
274 TFileName importName; |
300 // startFolder, NULL, NULL, *title)) |
275 |
301 // { |
276 if (memory==CAknMemorySelectionDialog::EMemoryCard) |
302 // _LIT(KPodcastsDir, "Podcasts"); |
277 { |
303 // TInt pos = selectedFolder.Find(KPodcastsDir); |
278 importName = PathInfo:: MemoryCardRootPath(); |
304 // if (pos == KErrNotFound || pos != selectedFolder.Length()-9) |
279 } |
305 // { |
280 else |
306 // // append "Podcasts" if the folder isn't already called this |
281 { |
307 // selectedFolder.Append(KPodcastsDir); |
282 importName = PathInfo:: PhoneMemoryRootPath(); |
308 // } |
283 } |
309 // |
284 |
310 // if (selectedFolder[selectedFolder.Length()-1] != '\\') |
285 CAknFileSelectionDialog* dlg = CAknFileSelectionDialog::NewL(ECFDDialogTypeSave, R_PODCAST_SHOWDIR_SELECTOR); |
311 // { |
286 HBufC* select = iEikonEnv->AllocReadResourceLC(R_PODCAST_SOFTKEY_SELECT); |
312 // selectedFolder.Append(_L("\\")); |
287 dlg->SetLeftSoftkeyFileL(*select); |
313 // } |
288 CleanupStack::PopAndDestroy(select); |
314 // |
289 CleanupStack::PushL(dlg); |
315 // iShowDir.Copy(selectedFolder); |
290 |
316 // LoadSettingsL(); |
291 dlg->SetDefaultFolderL(importName); |
317 // } |
292 |
318 // CleanupStack::PopAndDestroy(title); |
293 if(dlg->ExecuteL(importName)) |
319 // } |
294 { |
320 // else { |
295 importName.Append(_L("Podcasts")); |
321 // CAknSettingItemList::EditItemL(aIndex,aCalledFromMenu); |
296 iShowDir.Copy(importName); |
322 // } |
297 LoadSettingsL(); |
323 // StoreSettingsL(); |
298 } |
324 // UpdateSettingVisibility(); |
299 CleanupStack::PopAndDestroy(dlg); |
|
300 } |
|
301 CleanupStack::PopAndDestroy(memDlg); |
|
302 } |
|
303 else { |
|
304 CAknSettingItemList::EditItemL(aIndex,aCalledFromMenu); |
|
305 } |
|
306 StoreSettingsL(); |
|
307 UpdateSettingVisibility(); |
325 DP("EditItemL END"); |
308 DP("EditItemL END"); |
326 } |
309 } |
327 |
310 |
328 /** |
311 /** |
329 * Framework method to create a setting item based upon the user id aSettingId. The |
312 * Framework method to create a setting item based upon the user id aSettingId. The |
340 CSettingsEngine &se = iPodcastModel.SettingsEngine(); |
323 CSettingsEngine &se = iPodcastModel.SettingsEngine(); |
341 iShowDir.Copy(se.BaseDir()); |
324 iShowDir.Copy(se.BaseDir()); |
342 iAutoUpdate = se.UpdateAutomatically(); |
325 iAutoUpdate = se.UpdateAutomatically(); |
343 iIap = se.SpecificIAP(); |
326 iIap = se.SpecificIAP(); |
344 |
327 |
345 if( iIap == 0) |
328 // if( iIap == 0) |
346 { |
329 // { |
347 iConnection = EConnectionDefault; |
330 // iConnection = EConnectionDefault; |
348 } |
331 // } |
349 else if ( iIap == -1) |
332 // else if ( iIap == -1) |
350 { |
333 // { |
351 iConnection = EConnectionAlwaysAsk; |
334 // iConnection = EConnectionAlwaysAsk; |
352 } |
335 // } |
353 else if ( (iIap & KUseIAPFlag)) |
336 // else if ( (iIap & KUseIAPFlag)) |
354 { |
337 // { |
355 iConnection = EConnectionUseIap; |
338 // iConnection = EConnectionUseIap; |
356 iIap = iIap& KUseIAPMask; |
339 // iIap = iIap& KUseIAPMask; |
357 } |
340 // } |
358 else |
341 // else |
359 { |
342 // { |
360 TInt snapIndex = 0; |
343 // TInt snapIndex = 0; |
361 TInt cnt = iPodcastModel.SNAPIds().Count(); |
344 // TInt cnt = iPodcastModel.SNAPIds().Count(); |
362 while(snapIndex < cnt && ((TInt)iPodcastModel.SNAPIds()[snapIndex].iIapId) != iIap) |
345 // while(snapIndex < cnt && ((TInt)iPodcastModel.SNAPIds()[snapIndex].iIapId) != iIap) |
363 { |
346 // { |
364 snapIndex++; |
347 // snapIndex++; |
365 } |
348 // } |
366 |
349 // |
367 if(snapIndex != cnt) |
350 // if(snapIndex != cnt) |
368 { |
351 // { |
369 iConnection = EConnectionUseNetwork+snapIndex; |
352 // iConnection = EConnectionUseI+snapIndex; |
370 } |
353 // } |
371 else |
354 // else |
372 { |
355 // { |
373 iConnection = EConnectionAlwaysAsk; |
356 // iConnection = EConnectionAlwaysAsk; |
374 } |
357 // } |
375 } |
358 // } |
376 |
359 |
377 iAutoDownload = se.DownloadAutomatically(); |
360 iAutoDownload = se.DownloadAutomatically(); |
378 |
361 |
379 switch(aSettingId) |
362 switch(aSettingId) |
380 { |
363 { |
385 case EPodcastSettingAutoUpdate: |
368 case EPodcastSettingAutoUpdate: |
386 DP("EPodcastSettingAutoUpdate"); |
369 DP("EPodcastSettingAutoUpdate"); |
387 iSettingAutoUpdate = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, iAutoUpdate); |
370 iSettingAutoUpdate = new (ELeave) CAknEnumeratedTextPopupSettingItem(aSettingId, iAutoUpdate); |
388 return iSettingAutoUpdate; |
371 return iSettingAutoUpdate; |
389 break; |
372 break; |
390 case EPodcastSettingConnection: |
373 // case EPodcastSettingConnection: |
391 DP("EPodcastSettingConnection"); |
374 // DP("EPodcastSettingConnection"); |
392 return new (ELeave) CConnectionSetting (aSettingId, iConnection, iPodcastModel); |
375 // return new (ELeave) CConnectionSetting (aSettingId, iConnection, iPodcastModel); |
393 break; |
376 // break; |
394 case EPodcastSettingIAPList: |
377 case EPodcastSettingIAPList: |
395 DP("EPodcastSettingIAPList"); |
378 DP("EPodcastSettingIAPList"); |
396 iSettingIAP = new (ELeave) CIapSetting (aSettingId, iIap, iPodcastModel); |
379 iSettingIAP = new (ELeave) CIapSetting (aSettingId, iIap, iPodcastModel); |
397 return iSettingIAP; |
380 return iSettingIAP; |
398 break; |
381 break; |