12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: hsoperatorhandler_p.cpp |
14 * Description: hsoperatorhandler_p.cpp |
15 * |
15 * |
16 */ |
16 */ |
17 #ifndef NO_QT_EXTENSIONS |
17 #ifdef QT_EXTENSIONS |
18 |
18 |
19 #include <QDebug> |
19 #include <QDebug> |
20 #include <XQSettingsManager> |
|
21 #include <XQSettingsKey> |
20 #include <XQSettingsKey> |
22 #include "hsoperatorhandler_p.h" |
21 #include "hsoperatorhandler_p.h" |
23 #include "hsmenuservice.h" |
22 #include "hsmenuservice.h" |
24 #include "caentry.h" |
23 #include "caentry.h" |
25 #include "caservice.h" |
24 #include "caservice.h" |
26 |
25 |
27 const int AppLibUid = 0x20022F97; |
26 const int AppLibUid = 0x20022F97; |
28 const int IconId = 0x00000001; |
27 const int IncludeOperatorStore = 0x00000001; |
29 const int OperatorAppUid = 0x00000002; |
28 const int OperatorStoreType = 0x00000002; |
30 const int OperatorUrl = 0x00000003; |
29 const int OperatorStoreTitle = 0x00000003; |
31 const int OperatorText = 0x00000004; |
30 const int OperatorStoreURL = 0x00000004; |
|
31 const int OperatorStoreIconSkinID = 0x00000005; |
|
32 const int OperatorStoreApplication = 0x00000006; |
|
33 const int OperatorStore1stPopUp = 0x00000007; |
|
34 const int RemoveOviStore = 0x00000008; |
|
35 const char *operatorStoreIconPath |
|
36 = "z:/private/20022F35/customsvg/operatorstore.svg"; |
|
37 |
32 |
38 |
33 // ======== MEMBER FUNCTIONS ======== |
39 // ======== MEMBER FUNCTIONS ======== |
34 |
40 |
35 /*! |
41 /*! |
36 Constructor |
42 Constructor |
37 \param parent parent object |
43 \param parent parent object |
38 */ |
44 */ |
39 HsOperatorHandlerPrivate::HsOperatorHandlerPrivate(QObject *parent): |
45 HsOperatorHandlerPrivate::HsOperatorHandlerPrivate(QObject *parent): |
40 QObject(parent), |
46 QObject(parent), |
|
47 mOviStorePresent(false), |
|
48 mOperatorStorePresent(false), |
|
49 mStoreType(NoneType), |
41 mOperatorEntry(0), |
50 mOperatorEntry(0), |
42 mIcon(), |
51 mIcon(), |
43 mText() |
52 mOperatorStoreTitle(), |
|
53 mOperatorStoreFirst(false) |
44 { |
54 { |
45 readCentralRepository(); |
55 readCentralRepository(); |
46 } |
56 } |
47 |
57 |
48 /*! |
58 /*! |
70 { |
80 { |
71 return mIcon; |
81 return mIcon; |
72 } |
82 } |
73 |
83 |
74 /*! |
84 /*! |
75 Returns Operator icon predefined in Central Repositoryicon |
85 Returns Operator title text predefined in Central Repositoryicon |
|
86 \retval text |
|
87 */ |
|
88 QString HsOperatorHandlerPrivate::text() |
|
89 { |
|
90 return mOperatorStoreTitle; |
|
91 } |
|
92 |
|
93 /*! |
|
94 Returns Ovi Store presence value predefined in Central Repositoryicon |
|
95 \retval true if Ovi Store should be present in toolbar |
|
96 */ |
|
97 bool HsOperatorHandlerPrivate::oviStorePresent() |
|
98 { |
|
99 return mOviStorePresent; |
|
100 } |
|
101 |
|
102 /*! |
|
103 Returns Operator Store presence value predefined in Central Repositoryicon |
|
104 \retval true if Operator Store should be present in toolbar |
|
105 */ |
|
106 bool HsOperatorHandlerPrivate::operatorStorePresent() |
|
107 { |
|
108 return mOperatorStorePresent; |
|
109 } |
|
110 |
|
111 /*! |
|
112 Returns if Operator Store should first in toolbar |
|
113 \retval true if Operator Store should first in toolbar |
|
114 */ |
|
115 bool HsOperatorHandlerPrivate::operatorStoreFirst() |
|
116 { |
|
117 return mOperatorStoreFirst; |
|
118 } |
|
119 |
|
120 /*! |
|
121 Creates icon based on Central Repository |
|
122 \param crManager settings manager |
76 \retval icon |
123 \retval icon |
77 */ |
124 */ |
78 QString HsOperatorHandlerPrivate::text() |
|
79 { |
|
80 return mText; |
|
81 } |
|
82 |
|
83 /*! |
|
84 Creates icon based on Central Repository |
|
85 \param crManager settings manager |
|
86 \retval icon |
|
87 */ |
|
88 HbIcon HsOperatorHandlerPrivate::createIcon(XQSettingsManager *crManager) |
125 HbIcon HsOperatorHandlerPrivate::createIcon(XQSettingsManager *crManager) |
89 { |
126 { |
90 qDebug("HsOperatorHandlerPrivate::createIcon"); |
127 QVariant variant = getVariantFromKey( |
91 HbIcon icon; |
128 crManager, |
92 |
129 OperatorStoreIconSkinID, |
93 XQCentralRepositorySettingsKey iconKey(AppLibUid, IconId); |
130 XQSettingsManager::TypeString); |
94 QVariant iconVarian = crManager->readItemValue( |
131 if (!variant.isNull() && !variant.toString().isEmpty()) { |
95 iconKey, XQSettingsManager::TypeString); |
132 return HbIcon(variant.toString()); |
96 |
133 } else { |
97 if (!iconVarian.isNull() && !iconVarian.toString().isEmpty()) { |
134 return HbIcon(operatorStoreIconPath); |
98 qDebug() << "HsOperatorHandlerPrivate::createIcon" |
135 } |
99 << iconVarian.toString(); |
|
100 icon = HbIcon(iconVarian.toString()); |
|
101 } |
|
102 return icon; |
|
103 } |
|
104 |
|
105 /*! |
|
106 Creates text based on Central Repository |
|
107 \param crManager settings manager |
|
108 \retval icon |
|
109 */ |
|
110 QString HsOperatorHandlerPrivate::readText(XQSettingsManager *crManager) |
|
111 { |
|
112 qDebug("HsOperatorHandlerPrivate::readText"); |
|
113 QString text; |
|
114 |
|
115 XQCentralRepositorySettingsKey textKey(AppLibUid, OperatorText); |
|
116 QVariant textVariant = crManager->readItemValue( |
|
117 textKey, XQSettingsManager::TypeString); |
|
118 |
|
119 if (!textVariant.isNull() && textVariant.isValid()) { |
|
120 qDebug() << "HsOperatorHandlerPrivate::createIcon" |
|
121 << textVariant.toString(); |
|
122 text = textVariant.toString(); |
|
123 } |
|
124 return text; |
|
125 } |
136 } |
126 |
137 |
127 /*! |
138 /*! |
128 Creates application entry based on Central Repository |
139 Creates application entry based on Central Repository |
129 \param crManager settings manager |
140 \param crManager settings manager |
130 \retval entry |
141 \retval entry |
131 */ |
142 */ |
132 CaEntry *HsOperatorHandlerPrivate::createAppEntry( |
143 CaEntry *HsOperatorHandlerPrivate::createAppEntry( |
133 XQSettingsManager *crManager) |
144 XQSettingsManager *crManager) |
134 { |
145 { |
135 qDebug("HsOperatorHandlerPrivate::createAppEntry"); |
146 QVariant variant = getVariantFromKey( |
136 XQCentralRepositorySettingsKey appUidKey(AppLibUid, OperatorAppUid); |
147 crManager, OperatorStoreApplication, XQSettingsManager::TypeString); |
137 QVariant appUidVariant = crManager->readItemValue( |
148 if (!variant.isNull()) { |
138 appUidKey, XQSettingsManager::TypeString); |
|
139 |
|
140 if (!appUidVariant.isNull() && !appUidVariant.toString().isEmpty()) { |
|
141 qDebug() << "HsOperatorHandlerPrivate::createAppEntry" |
|
142 << appUidVariant.toString(); |
|
143 |
|
144 CaEntry *operatorEntry = new CaEntry; |
149 CaEntry *operatorEntry = new CaEntry; |
145 operatorEntry->setEntryTypeName(applicationTypeName()); |
150 operatorEntry->setEntryTypeName(applicationTypeName()); |
146 operatorEntry->setAttribute( |
151 operatorEntry->setAttribute( |
147 applicationUidEntryKey(), appUidVariant.toString()); |
152 applicationUidEntryKey(), variant.toString()); |
|
153 |
148 return operatorEntry; |
154 return operatorEntry; |
149 } |
155 } |
150 return NULL; |
156 return NULL; |
151 } |
157 } |
152 |
158 |
156 \retval entry |
162 \retval entry |
157 */ |
163 */ |
158 CaEntry *HsOperatorHandlerPrivate::createUrlEntry( |
164 CaEntry *HsOperatorHandlerPrivate::createUrlEntry( |
159 XQSettingsManager *crManager) |
165 XQSettingsManager *crManager) |
160 { |
166 { |
161 qDebug("HsOperatorHandlerPrivate::createUrlEntry"); |
167 QVariant variant = getVariantFromKey( |
162 CaEntry *operatorEntry = new CaEntry; |
168 crManager, OperatorStoreURL, XQSettingsManager::TypeString); |
163 |
169 if (!variant.isNull()) { |
164 XQCentralRepositorySettingsKey urlKey(AppLibUid, OperatorUrl); |
170 CaEntry *operatorEntry = new CaEntry; |
165 QVariant urlVariant = crManager->readItemValue( |
|
166 urlKey, XQSettingsManager::TypeString); |
|
167 |
|
168 if (!urlVariant.isNull() && !urlVariant.toString().isEmpty()) { |
|
169 operatorEntry->setEntryTypeName(urlTypeName()); |
171 operatorEntry->setEntryTypeName(urlTypeName()); |
170 operatorEntry->setAttribute(urlEntryKey(), urlVariant.toString()); |
172 operatorEntry->setAttribute(urlEntryKey(), variant.toString()); |
171 qDebug() << "HsOperatorHandlerPrivate::createUrlEntry" |
173 |
172 << urlVariant.toString(); |
174 return operatorEntry; |
173 } |
175 } |
174 return operatorEntry; |
176 return NULL; |
|
177 } |
|
178 |
|
179 |
|
180 /*! |
|
181 Generic function to get stores presence values |
|
182 \param crManager settings manager |
|
183 \param storePresenceKey store key(Ovi or Operator) |
|
184 \retval entry |
|
185 */ |
|
186 bool HsOperatorHandlerPrivate::storeValue( |
|
187 XQSettingsManager *crManager, int storePresenceKey) |
|
188 { |
|
189 QVariant variant = getVariantFromKey( |
|
190 crManager, storePresenceKey, XQSettingsManager::TypeInt); |
|
191 if (!variant.isNull()) { |
|
192 return bool(variant.toInt()); |
|
193 } |
|
194 return false; |
|
195 } |
|
196 |
|
197 /*! |
|
198 Generic function to get QVariant for CR key |
|
199 \param crManager settings manager |
|
200 \param crKey CR key |
|
201 \param type type of QVariant to be returned |
|
202 \retval QVariant |
|
203 */ |
|
204 QVariant HsOperatorHandlerPrivate::getVariantFromKey( |
|
205 XQSettingsManager *crManager, int crKey, XQSettingsManager::Type type) |
|
206 { |
|
207 XQCentralRepositorySettingsKey presenceKey(AppLibUid, crKey); |
|
208 QVariant presenceVariant = crManager->readItemValue( |
|
209 presenceKey, type); |
|
210 |
|
211 if (presenceVariant.isValid()) { |
|
212 qDebug() << "HsOperatorHandlerPrivate::storePresent" |
|
213 << presenceVariant.toInt(); |
|
214 return presenceVariant; |
|
215 } |
|
216 return QVariant(); |
|
217 } |
|
218 |
|
219 /*! |
|
220 Generic function to get store type(Url/App) |
|
221 \param crManager settings manager |
|
222 \retval HsStoreType store type |
|
223 */ |
|
224 HsOperatorHandlerPrivate::HsStoreType |
|
225 HsOperatorHandlerPrivate::operatorStoreType( |
|
226 XQSettingsManager *crManager) |
|
227 { |
|
228 QVariant variant = getVariantFromKey( |
|
229 crManager, OperatorStoreType, XQSettingsManager::TypeInt); |
|
230 if (!variant.isNull()) { |
|
231 return HsOperatorHandlerPrivate::HsStoreType(variant.toInt()); |
|
232 } |
|
233 return NoneType; |
|
234 } |
|
235 |
|
236 /*! |
|
237 Creates text based on Central Repository |
|
238 \param crManager settings manager |
|
239 \retval icon |
|
240 */ |
|
241 QString HsOperatorHandlerPrivate::operatorStoreTitle(XQSettingsManager *crManager) |
|
242 { |
|
243 QVariant variant = getVariantFromKey( |
|
244 crManager, OperatorStoreTitle, XQSettingsManager::TypeString); |
|
245 if (!variant.isNull()) { |
|
246 return variant.toString(); |
|
247 } |
|
248 return QString(); |
|
249 } |
|
250 |
|
251 /*! |
|
252 Retrives information if Operator Store should first in toolbarbased |
|
253 (from Central Repository) |
|
254 \param crManager settings manager |
|
255 \retval true if Operator Store should be first |
|
256 */ |
|
257 bool HsOperatorHandlerPrivate::operatorStoreFirst(XQSettingsManager *crManager) |
|
258 { |
|
259 QVariant variant = getVariantFromKey( |
|
260 crManager, OperatorStore1stPopUp, XQSettingsManager::TypeInt); |
|
261 if (!variant.isNull()) { |
|
262 return bool(variant.toInt()); |
|
263 } |
|
264 return false; |
175 } |
265 } |
176 |
266 |
177 /*! |
267 /*! |
178 Reads Central Repository |
268 Reads Central Repository |
179 */ |
269 */ |
180 void HsOperatorHandlerPrivate::readCentralRepository() |
270 void HsOperatorHandlerPrivate::readCentralRepository() |
181 { |
271 { |
182 XQSettingsManager *crManager = new XQSettingsManager; |
272 XQSettingsManager *crManager = new XQSettingsManager; |
183 |
273 //this key indicates that ovi store should be removed |
184 mIcon = createIcon(crManager); |
274 mOviStorePresent = !storeValue(crManager, RemoveOviStore); |
185 mText = readText(crManager); |
275 //this key indicates that operator store should be added |
186 mOperatorEntry = createAppEntry(crManager); |
276 mOperatorStorePresent = storeValue(crManager, IncludeOperatorStore); |
187 if (!mOperatorEntry) { |
277 |
188 mOperatorEntry = createUrlEntry(crManager); |
278 if (mOperatorStorePresent) { |
|
279 mStoreType = operatorStoreType(crManager); |
|
280 if (mStoreType == ApplicationType) { |
|
281 mOperatorEntry = createAppEntry(crManager); |
|
282 } else { |
|
283 mOperatorEntry = createUrlEntry(crManager); |
|
284 } |
|
285 mOperatorStoreTitle = operatorStoreTitle(crManager); |
|
286 mOperatorStoreFirst = operatorStoreFirst(crManager); |
|
287 mIcon = createIcon(crManager); |
189 } |
288 } |
190 delete crManager; |
289 delete crManager; |
191 } |
290 } |
192 #endif |
291 #endif |