|
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 <ProfileEngineSDKCRKeys.h> |
|
20 |
|
21 // User includes |
|
22 #include "fmradiohswidgetprofilereader.h" |
|
23 #include "xqsettingsmanager.h" |
|
24 #include "xqsettingskey.h" |
|
25 #include "xqpublishandsubscribeutils.h" |
|
26 |
|
27 /*! |
|
28 Constructor |
|
29 */ |
|
30 FmRadioHsWidgetProfileReader::FmRadioHsWidgetProfileReader(QObject *parent) : |
|
31 QObject(parent), |
|
32 mSettingsManager(new XQSettingsManager(this)) |
|
33 { |
|
34 // Monitors devices profile. |
|
35 XQSettingsKey profileKey(XQSettingsKey::TargetCentralRepository, |
|
36 KCRUidProfileEngine.iUid, KProEngActiveProfile); |
|
37 mSettingsManager->startMonitoring(profileKey); |
|
38 currentProfileStatus(mSettingsManager->readItemValue(profileKey)); |
|
39 |
|
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 } |
|
52 |
|
53 |
|
54 /*! |
|
55 Handling of deletion of listened P&S key. |
|
56 |
|
57 \param key Deleted key. |
|
58 */ |
|
59 void FmRadioHsWidgetProfileReader::itemDeleted(const XQSettingsKey& key) |
|
60 { |
|
61 if (key.uid() == KCRUidProfileEngine.iUid && key.key() |
|
62 == KProEngActiveProfile) { |
|
63 } |
|
64 } |
|
65 |
|
66 /*! |
|
67 Notifications from settings manager are handled and routed to appropriate |
|
68 private slots. |
|
69 |
|
70 \param key Changed key. |
|
71 \param value Value of changed key. |
|
72 */ |
|
73 void FmRadioHsWidgetProfileReader::handleChanges(const XQSettingsKey& key, |
|
74 const QVariant& value) |
|
75 { |
|
76 if (key.uid() == KCRUidProfileEngine.iUid && key.key() |
|
77 == KProEngActiveProfile) { |
|
78 currentProfileStatus(value); |
|
79 } |
|
80 } |
|
81 |
|
82 /*! |
|
83 Handling changes in profile information. |
|
84 |
|
85 \param value Originally information is of int type. Valid values after |
|
86 conversion are described by KProEngActiveProfile in ProfileEngineSDKCRKeys.h. |
|
87 */ |
|
88 void FmRadioHsWidgetProfileReader::currentProfileStatus(QVariant value) |
|
89 { |
|
90 if (value.canConvert(QVariant::Int)) { |
|
91 emit profileChanged(value.toInt()); |
|
92 } |
|
93 } |
|
94 |