|
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: hsoperatorhandler_p.cpp |
|
15 * |
|
16 */ |
|
17 #ifdef QT_EXTENSIONS |
|
18 |
|
19 #include <QDebug> |
|
20 #include <XQSettingsKey> |
|
21 #include "hsoperatorhandler_p.h" |
|
22 #include "hsmenuservice.h" |
|
23 #include "caentry.h" |
|
24 #include "caservice.h" |
|
25 |
|
26 const int AppLibUid = 0x20022F97; |
|
27 const int IncludeOperatorStore = 0x00000001; |
|
28 const int OperatorStoreType = 0x00000002; |
|
29 const int OperatorStoreTitle = 0x00000003; |
|
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 |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 /*! |
|
42 Constructor |
|
43 \param parent parent object |
|
44 */ |
|
45 HsOperatorHandlerPrivate::HsOperatorHandlerPrivate(QObject *parent): |
|
46 QObject(parent), |
|
47 mOviStorePresent(false), |
|
48 mOperatorStorePresent(false), |
|
49 mStoreType(NoneType), |
|
50 mOperatorEntry(0), |
|
51 mIcon(), |
|
52 mOperatorStoreTitle(), |
|
53 mOperatorStoreFirst(false) |
|
54 { |
|
55 readCentralRepository(); |
|
56 } |
|
57 |
|
58 /*! |
|
59 Destructor |
|
60 */ |
|
61 HsOperatorHandlerPrivate::~HsOperatorHandlerPrivate() |
|
62 { |
|
63 delete mOperatorEntry; |
|
64 } |
|
65 |
|
66 /*! |
|
67 Executes action |
|
68 */ |
|
69 void HsOperatorHandlerPrivate::action() |
|
70 { |
|
71 qDebug("HsOperatorHandlerPrivate::action"); |
|
72 CaService::instance()->executeCommand(*mOperatorEntry); |
|
73 } |
|
74 |
|
75 /*! |
|
76 Returns Operator icon predefined in Central Repositoryicon |
|
77 \retval icon |
|
78 */ |
|
79 HbIcon HsOperatorHandlerPrivate::icon() |
|
80 { |
|
81 return mIcon; |
|
82 } |
|
83 |
|
84 /*! |
|
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 |
|
123 \retval icon |
|
124 */ |
|
125 HbIcon HsOperatorHandlerPrivate::createIcon(XQSettingsManager *crManager) |
|
126 { |
|
127 QVariant variant = getVariantFromKey( |
|
128 crManager, |
|
129 OperatorStoreIconSkinID, |
|
130 XQSettingsManager::TypeString); |
|
131 if (!variant.isNull() && !variant.toString().isEmpty()) { |
|
132 return HbIcon(variant.toString()); |
|
133 } else { |
|
134 return HbIcon(operatorStoreIconPath); |
|
135 } |
|
136 } |
|
137 |
|
138 /*! |
|
139 Creates application entry based on Central Repository |
|
140 \param crManager settings manager |
|
141 \retval entry |
|
142 */ |
|
143 CaEntry *HsOperatorHandlerPrivate::createAppEntry( |
|
144 XQSettingsManager *crManager) |
|
145 { |
|
146 QVariant variant = getVariantFromKey( |
|
147 crManager, OperatorStoreApplication, XQSettingsManager::TypeString); |
|
148 if (!variant.isNull()) { |
|
149 CaEntry *operatorEntry = new CaEntry; |
|
150 operatorEntry->setEntryTypeName(Hs::applicationTypeName); |
|
151 operatorEntry->setAttribute( |
|
152 Hs::applicationUidEntryKey, variant.toString()); |
|
153 |
|
154 return operatorEntry; |
|
155 } |
|
156 return NULL; |
|
157 } |
|
158 |
|
159 /*! |
|
160 Creates url entry based on Central Repository |
|
161 \param crManager settings manager |
|
162 \retval entry |
|
163 */ |
|
164 CaEntry *HsOperatorHandlerPrivate::createUrlEntry( |
|
165 XQSettingsManager *crManager) |
|
166 { |
|
167 QVariant variant = getVariantFromKey( |
|
168 crManager, OperatorStoreURL, XQSettingsManager::TypeString); |
|
169 if (!variant.isNull()) { |
|
170 CaEntry *operatorEntry = new CaEntry; |
|
171 operatorEntry->setEntryTypeName(Hs::urlTypeName); |
|
172 operatorEntry->setAttribute(Hs::urlEntryKey, variant.toString()); |
|
173 |
|
174 return operatorEntry; |
|
175 } |
|
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; |
|
265 } |
|
266 |
|
267 /*! |
|
268 Reads Central Repository |
|
269 */ |
|
270 void HsOperatorHandlerPrivate::readCentralRepository() |
|
271 { |
|
272 XQSettingsManager *crManager = new XQSettingsManager; |
|
273 //this key indicates that ovi store should be removed |
|
274 mOviStorePresent = !storeValue(crManager, RemoveOviStore); |
|
275 //this key indicates that operator store should be added |
|
276 mOperatorStorePresent = storeValue(crManager, IncludeOperatorStore); |
|
277 |
|
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); |
|
288 } |
|
289 delete crManager; |
|
290 } |
|
291 #endif |