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: FM Radio widget process handler |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <QDateTime> |
|
20 #include <ProfileEngineSDKCRKeys.h> |
|
21 #include "xqsettingsmanager.h" |
|
22 #include "xqsettingskey.h" |
|
23 #include "xqpublishandsubscribeutils.h" |
|
24 |
|
25 // User includes |
|
26 #include "fmradiohswidgetprofilereader.h" |
|
27 #include "fmradiohswidget.h" |
|
28 #include "radioservicedef.h" |
|
29 #include "radiologger.h" |
|
30 |
|
31 /*! |
|
32 Constructor |
|
33 */ |
|
34 FmRadioHsWidgetProfileReader::FmRadioHsWidgetProfileReader(QObject *parent) : |
|
35 QObject(parent), |
|
36 mSettingsManager(new XQSettingsManager(this)), |
|
37 mRadioStatus(-1) |
|
38 { |
|
39 LOG_METHOD; |
|
40 connect(mSettingsManager, SIGNAL(itemDeleted(XQSettingsKey)), this, |
|
41 SLOT(itemDeleted(XQSettingsKey))); |
|
42 connect(mSettingsManager, SIGNAL(valueChanged(XQSettingsKey, QVariant)), |
|
43 this, SLOT(handleChanges(XQSettingsKey, QVariant))); |
|
44 } |
|
45 |
|
46 /*! |
|
47 Destructor |
|
48 */ |
|
49 FmRadioHsWidgetProfileReader::~FmRadioHsWidgetProfileReader() |
|
50 { |
|
51 LOG_METHOD; |
|
52 } |
|
53 |
|
54 |
|
55 /*! |
|
56 Handling of deletion of listened keys. |
|
57 |
|
58 \param key Deleted key. |
|
59 */ |
|
60 void FmRadioHsWidgetProfileReader::itemDeleted(const XQSettingsKey &key) |
|
61 { |
|
62 LOG_METHOD; |
|
63 // Profile information will be used for offline query. |
|
64 /* |
|
65 if (key.uid() == KCRUidProfileEngine.iUid && key.key() |
|
66 == KProEngActiveProfile) { |
|
67 } |
|
68 */ |
|
69 if (key.uid() == KRadioPSUid && key.key() == KRadioStartupKey) { |
|
70 LOG("KRadioStartupKey deleted"); |
|
71 startMonitoringRadioRunningStatus(); |
|
72 } |
|
73 } |
|
74 |
|
75 /*! |
|
76 Notifications from settings manager are handled and routed to appropriate |
|
77 private slots. |
|
78 |
|
79 \param key Changed key. |
|
80 \param value Value of changed key. |
|
81 */ |
|
82 void FmRadioHsWidgetProfileReader::handleChanges(const XQSettingsKey &key, |
|
83 const QVariant& value) |
|
84 { |
|
85 LOG_SLOT_CALLER; |
|
86 |
|
87 // Profile information will be used for offline query. |
|
88 /* |
|
89 if (key.uid() == KCRUidProfileEngine.iUid && key.key() |
|
90 == KProEngActiveProfile) { |
|
91 currentProfileStatus(value); |
|
92 } |
|
93 */ |
|
94 |
|
95 if (key.uid() == KRadioPSUid && key.key() |
|
96 == KRadioStartupKey) { |
|
97 LOG("KRadioStartupKey changed"); |
|
98 currentRadioRunningStatus(value); |
|
99 } |
|
100 } |
|
101 |
|
102 |
|
103 /*! |
|
104 Handling changes in profile information. |
|
105 |
|
106 \param value |
|
107 */ |
|
108 /* |
|
109 void FmRadioHsWidgetProfileReader::currentProfileStatus(QVariant value) |
|
110 { |
|
111 if (value.canConvert(QVariant::Int)) { |
|
112 emit profileChanged(value.toInt()); |
|
113 } |
|
114 } |
|
115 */ |
|
116 |
|
117 /*! |
|
118 Handling changes in radio running P&S key. |
|
119 |
|
120 \param value is int representation of time in seconds when radio was started. |
|
121 */ |
|
122 void FmRadioHsWidgetProfileReader::currentRadioRunningStatus(const QVariant &value) |
|
123 { |
|
124 LOG_METHOD; |
|
125 if (value.isValid()) { |
|
126 if (value.canConvert(QVariant::Int)) { |
|
127 mRadioStatus = value.toInt(); |
|
128 // Emit that radio is running. |
|
129 QVariant state(FmRadioHsWidget::Running); |
|
130 emit radioRunning(state); |
|
131 } |
|
132 } else { |
|
133 mRadioStatus = -1; |
|
134 // Emit that radio is not running. |
|
135 QVariant state(FmRadioHsWidget::NotRunning); |
|
136 emit radioRunning(state); |
|
137 } |
|
138 } |
|
139 |
|
140 /*! |
|
141 Start monitoring radio P&S key. |
|
142 |
|
143 */ |
|
144 void FmRadioHsWidgetProfileReader::startMonitoringRadioRunningStatus() |
|
145 { |
|
146 LOG_METHOD; |
|
147 XQSettingsKey radioRunningKey(XQSettingsKey::TargetPublishAndSubscribe, KRadioPSUid, |
|
148 KRadioStartupKey); |
|
149 // Start monitoring. |
|
150 mSettingsManager->startMonitoring(radioRunningKey); |
|
151 // Read current value. |
|
152 currentRadioRunningStatus(mSettingsManager->readItemValue(radioRunningKey)); |
|
153 } |
|