1 /* |
|
2 * Copyright (c) 2009-2010 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 #ifndef CXESETTINGSCENREPSTORE_H_ |
|
18 #define CXESETTINGSCENREPSTORE_H_ |
|
19 |
|
20 // Include Files |
|
21 #include <QHash> |
|
22 #include <QVariant> |
|
23 #include <QMetaType> |
|
24 |
|
25 #include "cxeerror.h" |
|
26 #include "cxenamespace.h" |
|
27 #include "xqsettingsmanager.h" |
|
28 #include "cxesettingsstore.h" |
|
29 |
|
30 // forward declarations |
|
31 class XQSettingsManager; |
|
32 class XQSettingsKey; |
|
33 |
|
34 /*! |
|
35 * CxeSettingsCenRepStore class implements CxeSettingsStore. |
|
36 |
|
37 * This class uses CenRep key mechanism for storing and retrieving settings information. |
|
38 */ |
|
39 class CxeSettingsCenRepStore : public QObject, |
|
40 public CxeSettingsStore |
|
41 { |
|
42 |
|
43 Q_OBJECT |
|
44 |
|
45 public: |
|
46 |
|
47 CxeSettingsCenRepStore(); |
|
48 ~CxeSettingsCenRepStore(); |
|
49 |
|
50 public: // from base class |
|
51 |
|
52 void reset(); |
|
53 CxeError::Id get(const QString &key, QVariant &value); |
|
54 void startMonitoring(long int uid, unsigned long int key, Cxe::SettingKeyType type, QVariant &value); |
|
55 CxeError::Id set(const QString &key, const QVariant newValue); |
|
56 QHash<QString, QVariantList> loadVariationSettings(QList<QString> &settingKeys); |
|
57 |
|
58 |
|
59 signals: |
|
60 void settingValueChanged(long int uid, unsigned long int key, QVariant value); |
|
61 |
|
62 private slots: |
|
63 void handleValueChanged(XQSettingsKey key, QVariant value); |
|
64 |
|
65 private: |
|
66 |
|
67 class CxeCenRepDefinition |
|
68 { |
|
69 public: |
|
70 long int mRepositoryUid; //! UID of the all the setting keys |
|
71 unsigned long int mKeyId; //! key cenrep id |
|
72 bool mReadOnly; //! if the key holds data that is read-only |
|
73 XQSettingsManager::Type mDataType; //! type of data that cenrep key holds |
|
74 |
|
75 }; |
|
76 |
|
77 private: |
|
78 |
|
79 void addKeyMapping(QString key, |
|
80 unsigned long int keyid, |
|
81 XQSettingsManager::Type type, |
|
82 bool readOnly = false); |
|
83 |
|
84 XQSettingsKey generateXQSettingsKey(const QString& key,CxeError::Id& error); |
|
85 void mapKeys(); |
|
86 |
|
87 protected: |
|
88 const QHash<QString, CxeCenRepDefinition>& keyMapping() const; |
|
89 |
|
90 private: // data |
|
91 |
|
92 XQSettingsManager* mSettingsManager; |
|
93 QHash<QString, CxeCenRepDefinition> mKeyMapping; |
|
94 }; |
|
95 |
|
96 |
|
97 /*! |
|
98 * \class CxeSettingsLocalStore |
|
99 * \brief Settings store that reads key values from cenrep and keeps |
|
100 * cached copies of them in memory. Doesn't write anything back |
|
101 * to cenrep. |
|
102 */ |
|
103 class CxeSettingsLocalStore : public CxeSettingsCenRepStore |
|
104 { |
|
105 Q_OBJECT |
|
106 |
|
107 public: |
|
108 CxeSettingsLocalStore(); |
|
109 ~CxeSettingsLocalStore(); |
|
110 |
|
111 CxeError::Id get(const QString& key, QVariant &value); |
|
112 CxeError::Id set(const QString& key, const QVariant newValue); |
|
113 |
|
114 private: |
|
115 |
|
116 bool useValueFromCenrep(const QString &key) const; |
|
117 |
|
118 QHash<QString, QVariant> mSettings; |
|
119 }; |
|
120 |
|
121 #endif // CXESETTINGSCENREPSTORE_H_ |
|
122 |
|