|
1 /* |
|
2 * Copyright (c) 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 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "irqsettings_p.h" |
|
19 #include "irinternalcrkeys.h" |
|
20 #include <XQSettingsKey> |
|
21 #include <XQSettingsManager> |
|
22 #include <QDesktopServices> |
|
23 #include <QTextCodec> |
|
24 |
|
25 const int KDefaultVolume = 6; |
|
26 const int KDefaultHttpTimeOut = 60000000; // unit: us, 6s |
|
27 const int KIRDefaultMinDiskSpace = 3145728; // byte, 3MB |
|
28 const QString KIRDefaultIsdsUrl = "http://idirectory.xgns.net/isds"; |
|
29 #ifdef USE_TEST_ISDS_SERVER |
|
30 const QString KIRTestIsdsUrl = "http://88.114.146.238/isds"; |
|
31 #endif |
|
32 |
|
33 IRQSettingsPrivate::IRQSettingsPrivate() : |
|
34 mSettingsManager(new XQSettingsManager()) |
|
35 { |
|
36 mPrivatePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/"; |
|
37 } |
|
38 |
|
39 IRQSettingsPrivate::~IRQSettingsPrivate() |
|
40 { |
|
41 if (mSettingsManager) |
|
42 { |
|
43 delete mSettingsManager; |
|
44 } |
|
45 } |
|
46 |
|
47 QString IRQSettingsPrivate::privatePath() |
|
48 { |
|
49 return mPrivatePath; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // IRQSettingsPrivate::isFlagTermsAndConditions() |
|
54 // |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 bool IRQSettingsPrivate::isFlagTermsAndConditions(bool& aFlag) |
|
58 { |
|
59 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
60 KCRUidInternetRadio.iUid, KIRTermsAndConditionsFlag); |
|
61 |
|
62 Q_ASSERT(mSettingsManager); |
|
63 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
64 |
|
65 bool br = !value.isNull(); |
|
66 |
|
67 if (br) |
|
68 { |
|
69 int nFlag = value.toInt(); |
|
70 aFlag = ( nFlag == 1 ); |
|
71 } |
|
72 |
|
73 return br; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // IRQSettingsPrivate::setFlagTermsAndConditions() |
|
78 // |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void IRQSettingsPrivate::setFlagTermsAndConditions() |
|
82 { |
|
83 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
84 KCRUidInternetRadio.iUid, KIRTermsAndConditionsFlag); |
|
85 |
|
86 Q_ASSERT(mSettingsManager); |
|
87 mSettingsManager->writeItemValue(profileKey, 1); |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // IRQSettingsPrivate::reSetFlagTermsAndConditions() |
|
92 // |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void IRQSettingsPrivate::reSetFlagTermsAndConditions() |
|
96 { |
|
97 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
98 KCRUidInternetRadio.iUid, KIRTermsAndConditionsFlag); |
|
99 |
|
100 Q_ASSERT(mSettingsManager); |
|
101 mSettingsManager->writeItemValue(profileKey, 0); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // IRQSettingsPrivate::getIRID() |
|
106 // |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 bool IRQSettingsPrivate::getIRID(QString& aIRID) |
|
110 { |
|
111 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
112 KCRUidInternetRadio.iUid, KIRIrId); |
|
113 |
|
114 Q_ASSERT(mSettingsManager); |
|
115 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
116 |
|
117 bool br = !value.isNull(); |
|
118 |
|
119 if (br) |
|
120 { |
|
121 aIRID = QTextCodec::codecForName("UTF-16")->toUnicode(value.toByteArray()); |
|
122 } |
|
123 |
|
124 return br; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // IRQSettingsPrivate::getVolumeSetting() |
|
129 // |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 int IRQSettingsPrivate::getVolumeSetting() |
|
133 { |
|
134 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
135 KCRUidInternetRadio.iUid, KIRPlayerVolume); |
|
136 |
|
137 Q_ASSERT(mSettingsManager); |
|
138 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
139 |
|
140 int ir = KDefaultVolume; |
|
141 |
|
142 if (!value.isNull()) |
|
143 { |
|
144 ir = value.toInt(); |
|
145 } |
|
146 |
|
147 return ir; |
|
148 } |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // IRQSettingsPrivate::setVolumeSetting() |
|
152 // |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void IRQSettingsPrivate::setVolumeSetting(int aPlayVolume) |
|
156 { |
|
157 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
158 KCRUidInternetRadio.iUid, KIRPlayerVolume); |
|
159 |
|
160 Q_ASSERT(mSettingsManager); |
|
161 mSettingsManager->writeItemValue(profileKey, aPlayVolume); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------------------------- |
|
165 // IRQSettingsPrivate::setTimeOut() |
|
166 // |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void IRQSettingsPrivate::setTimeOut(int aTimeOut) |
|
170 { |
|
171 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
172 KCRUidInternetRadio.iUid, KIRHttpTimeout); |
|
173 |
|
174 Q_ASSERT(mSettingsManager); |
|
175 mSettingsManager->writeItemValue(profileKey, aTimeOut); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // IRQSettingsPrivate::getTimeOut() |
|
180 // |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 int IRQSettingsPrivate::getTimeOut() |
|
184 { |
|
185 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
186 KCRUidInternetRadio.iUid, KIRHttpTimeout); |
|
187 |
|
188 Q_ASSERT(mSettingsManager); |
|
189 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
190 |
|
191 int ir = KDefaultHttpTimeOut; |
|
192 |
|
193 if (!value.isNull()) |
|
194 { |
|
195 ir = value.toInt(); |
|
196 } |
|
197 |
|
198 return ir; |
|
199 } |
|
200 |
|
201 void IRQSettingsPrivate::setSongHistoryShow(int aShowFlag) |
|
202 { |
|
203 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
204 KCRUidInternetRadio.iUid, KIRSongHistoryFTU); |
|
205 |
|
206 Q_ASSERT(mSettingsManager); |
|
207 mSettingsManager->writeItemValue(profileKey, aShowFlag); |
|
208 } |
|
209 |
|
210 int IRQSettingsPrivate::getSongHistoryShow() |
|
211 { |
|
212 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
213 KCRUidInternetRadio.iUid, KIRSongHistoryFTU); |
|
214 |
|
215 Q_ASSERT(mSettingsManager); |
|
216 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
217 |
|
218 int ir = 0; |
|
219 |
|
220 if (!value.isNull()) |
|
221 { |
|
222 ir = value.toInt(); |
|
223 } |
|
224 |
|
225 return ir; |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // IRQSettingsPrivate::setStartingViewId() |
|
230 // Sets the starting view Id in cenrep |
|
231 // --------------------------------------------------------------------------- |
|
232 // |
|
233 void IRQSettingsPrivate::setStartingViewId(int aStartingViewId) |
|
234 { |
|
235 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
236 KCRUidInternetRadio.iUid, KIRStartingViewId); |
|
237 |
|
238 Q_ASSERT(mSettingsManager); |
|
239 mSettingsManager->writeItemValue(profileKey, aStartingViewId); |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // IRQSettingsPrivate::getStartingViewId() |
|
244 // Gets the starting view Id from cenrep |
|
245 // --------------------------------------------------------------------------- |
|
246 // |
|
247 bool IRQSettingsPrivate::getStartingViewId(TIRViewId& aStartingViewId) |
|
248 { |
|
249 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
250 KCRUidInternetRadio.iUid, KIRStartingViewId); |
|
251 |
|
252 Q_ASSERT(mSettingsManager); |
|
253 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
254 |
|
255 bool br = !value.isNull(); |
|
256 |
|
257 if (br) |
|
258 { |
|
259 aStartingViewId = (TIRViewId) value.toInt(); |
|
260 } |
|
261 else |
|
262 { |
|
263 aStartingViewId = EIRView_CategoryView; |
|
264 } |
|
265 |
|
266 return br; |
|
267 } |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // IRQSettingsPrivate::setPreferredQuality() |
|
271 // |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 void IRQSettingsPrivate::setPreferredQuality(IRQPreferredQuality aQualityValue) |
|
275 { |
|
276 TInt value = 0; |
|
277 switch (aQualityValue) |
|
278 { |
|
279 case EIRQHighQuality: |
|
280 value = 1; |
|
281 break; |
|
282 default: |
|
283 break; |
|
284 } |
|
285 |
|
286 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
287 KCRUidInternetRadio.iUid, KIRPreferredQuality); |
|
288 |
|
289 Q_ASSERT(mSettingsManager); |
|
290 mSettingsManager->writeItemValue(profileKey, value); |
|
291 } |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // IRQSettingsPrivate::getPreferredQuality() |
|
295 // |
|
296 // --------------------------------------------------------------------------- |
|
297 // |
|
298 IRQPreferredQuality IRQSettingsPrivate::getPreferredQuality() const |
|
299 { |
|
300 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
301 KCRUidInternetRadio.iUid, KIRPreferredQuality); |
|
302 |
|
303 Q_ASSERT(mSettingsManager); |
|
304 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
305 |
|
306 int ir = 0; |
|
307 |
|
308 if (!value.isNull()) |
|
309 { |
|
310 ir = value.toInt(); |
|
311 } |
|
312 |
|
313 switch (ir) |
|
314 { |
|
315 case 1: |
|
316 return EIRQHighQuality; |
|
317 default: |
|
318 return EIRQStandardQuality; |
|
319 } |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // IRQSettingsPrivate::getGlobalAdvFlag() |
|
324 // Gets the global advertisement flag from cenrep |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 bool IRQSettingsPrivate::getGlobalAdvFlag(bool& aFlag) |
|
328 { |
|
329 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
330 KCRUidInternetRadio.iUid, KIRGlobalAdvEnabled); |
|
331 |
|
332 Q_ASSERT(mSettingsManager); |
|
333 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
334 |
|
335 bool br = !value.isNull(); |
|
336 |
|
337 if (br) |
|
338 { |
|
339 aFlag = value.toBool(); |
|
340 } |
|
341 |
|
342 return br; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // IRQSettingsPrivate::getManuallyInputtedStationUrl(QString& aUrl) |
|
347 // |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 bool IRQSettingsPrivate::getManuallyInputtedStationUrl(QString& aUrl) |
|
351 { |
|
352 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
353 KCRUidInternetRadio.iUid, KIRManuallyInputStationUrl); |
|
354 |
|
355 Q_ASSERT(mSettingsManager); |
|
356 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
357 |
|
358 bool br = !value.isNull(); |
|
359 |
|
360 if (br) |
|
361 { |
|
362 aUrl = QTextCodec::codecForName("UTF-16")->toUnicode(value.toByteArray()); |
|
363 } |
|
364 |
|
365 return br; |
|
366 } |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // IRQSettingsPrivate::setManuallyInputtedStationUrl(const QString& aUrl) |
|
370 // |
|
371 // --------------------------------------------------------------------------- |
|
372 // |
|
373 void IRQSettingsPrivate::setManuallyInputtedStationUrl(const QString& aUrl) |
|
374 { |
|
375 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
376 KCRUidInternetRadio.iUid, KIRManuallyInputStationUrl); |
|
377 |
|
378 Q_ASSERT(mSettingsManager); |
|
379 mSettingsManager->writeItemValue(profileKey, QString::fromUtf16(aUrl.utf16())); |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // IRQSettingsPrivate::getManuallyInputtedStationName(QString& aName) |
|
384 // |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 bool IRQSettingsPrivate::getManuallyInputtedStationName(QString& aName) |
|
388 { |
|
389 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
390 KCRUidInternetRadio.iUid, KIRManuallyInputStationName); |
|
391 |
|
392 Q_ASSERT(mSettingsManager); |
|
393 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
394 |
|
395 bool br = !value.isNull(); |
|
396 |
|
397 if (br) |
|
398 { |
|
399 aName = QTextCodec::codecForName("UTF-16")->toUnicode(value.toByteArray()); |
|
400 } |
|
401 |
|
402 return br; |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // IRQSettingsPrivate::setManuallyInputtedStationName(const QString& aName) |
|
407 // |
|
408 // --------------------------------------------------------------------------- |
|
409 // |
|
410 void IRQSettingsPrivate::setManuallyInputtedStationName(const QString& aName) |
|
411 { |
|
412 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
413 KCRUidInternetRadio.iUid, KIRManuallyInputStationName); |
|
414 |
|
415 Q_ASSERT(mSettingsManager); |
|
416 mSettingsManager->writeItemValue(profileKey, QString::fromUtf16(aName.utf16())); |
|
417 } |
|
418 |
|
419 // --------------------------------------------------------------------------- |
|
420 // IRQSettingsPrivate::getSearchText(QString& aSearchText) |
|
421 // |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 bool IRQSettingsPrivate::getSearchText(QString& aSearchText) |
|
425 { |
|
426 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
427 KCRUidInternetRadio.iUid, KIRSearchText); |
|
428 |
|
429 Q_ASSERT(mSettingsManager); |
|
430 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
431 |
|
432 bool br = !value.isNull(); |
|
433 |
|
434 if (br) |
|
435 { |
|
436 aSearchText = value.toString(); |
|
437 } |
|
438 |
|
439 return br; |
|
440 } |
|
441 |
|
442 // --------------------------------------------------------------------------- |
|
443 // IRQSettingsPrivate::setSearchText(const QString& aSearchText) |
|
444 // |
|
445 // --------------------------------------------------------------------------- |
|
446 // |
|
447 void IRQSettingsPrivate::setSearchText(const QString& aSearchText) |
|
448 { |
|
449 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
450 KCRUidInternetRadio.iUid, KIRSearchText); |
|
451 |
|
452 Q_ASSERT(mSettingsManager); |
|
453 mSettingsManager->writeItemValue(profileKey, aSearchText.toUtf8()); |
|
454 } |
|
455 |
|
456 int IRQSettingsPrivate::getMinDiskSpaceRequired() |
|
457 { |
|
458 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
459 KCRUidInternetRadio.iUid, KIRMinDiskSpaceRequired); |
|
460 |
|
461 Q_ASSERT(mSettingsManager); |
|
462 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
463 |
|
464 int retVal = KIRDefaultMinDiskSpace; |
|
465 |
|
466 if (!value.isNull()) |
|
467 { |
|
468 retVal = value.toInt(); |
|
469 } |
|
470 |
|
471 return retVal; |
|
472 } |
|
473 |
|
474 bool IRQSettingsPrivate::getIdentifySongEnabled() |
|
475 { |
|
476 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
477 KCRUidInternetRadio.iUid, KIRIdentifySongEnabled); |
|
478 |
|
479 Q_ASSERT(mSettingsManager); |
|
480 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
481 |
|
482 bool retVal = false; |
|
483 |
|
484 if (!value.isNull()) |
|
485 { |
|
486 retVal = value.toBool(); |
|
487 } |
|
488 |
|
489 return retVal; |
|
490 } |
|
491 |
|
492 int IRQSettingsPrivate::getSongRecognitionAppUid() |
|
493 { |
|
494 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
495 KCRUidInternetRadio.iUid, KIRSongRecognitionAppUid); |
|
496 |
|
497 Q_ASSERT(mSettingsManager); |
|
498 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
499 |
|
500 int retVal = 0; |
|
501 |
|
502 if (!value.isNull()) |
|
503 { |
|
504 retVal = value.toInt(); |
|
505 } |
|
506 |
|
507 return retVal; |
|
508 } |
|
509 |
|
510 QString IRQSettingsPrivate::getIsdsUrl() |
|
511 { |
|
512 #ifdef USE_TEST_ISDS_SERVER |
|
513 return KIRTestIsdsUrl; |
|
514 #else |
|
515 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
516 KCRUidInternetRadio.iUid, KIRIsdsUrl); |
|
517 |
|
518 Q_ASSERT(mSettingsManager); |
|
519 QVariant value = mSettingsManager->readItemValue(profileKey); |
|
520 |
|
521 QString retVal = KIRDefaultIsdsUrl; |
|
522 |
|
523 if (!value.isNull()) |
|
524 { |
|
525 retVal = QTextCodec::codecForName("UTF-16")->toUnicode(value.toByteArray());; |
|
526 } |
|
527 |
|
528 return retVal; |
|
529 #endif |
|
530 } |