|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <etelmm.h> |
|
20 #include <xqsysinfo.h> |
|
21 #include <xqsettingsmanager.h> |
|
22 #include <xqsettingskey.h> |
|
23 #include <e32base.h> |
|
24 #include <etelmm.h> |
|
25 #include <exterror.h> |
|
26 #include <gsmerror.h> |
|
27 #include <settingsinternalcrkeys.h> |
|
28 #include <LogsDomainCRKeys.h> |
|
29 #include <BTSapDomainPSKeys.h> |
|
30 #include <NumberGroupingCRKeys.h> |
|
31 #include <hbglobal.h> |
|
32 #include <CoreApplicationUIsSDKCRKeys.h> |
|
33 #include <telephonyvariant.hrh> |
|
34 #include <telinternalcrkeys.h> |
|
35 #include <ctsydomainpskeys.h> |
|
36 #include "cptelephonyutilsdefs.h" |
|
37 #include "cpplugincommon.h" |
|
38 #include "cppluginlogging.h" |
|
39 |
|
40 const int CenrepKeyValueOff = 0; |
|
41 const int CenrepKeyValueOn = 1; |
|
42 |
|
43 const int SoftRejectTextDefault = 0; |
|
44 const int SoftRejectTextUserDefined = 1; |
|
45 |
|
46 /*! |
|
47 Tools::voipSupported |
|
48 */ |
|
49 bool Tools::voipSupported() |
|
50 { |
|
51 return XQSysInfo::isSupported(KFeatureIdCommonVoip); |
|
52 } |
|
53 |
|
54 /*! |
|
55 Tools::videoSupported |
|
56 */ |
|
57 bool Tools::videoSupported() |
|
58 { |
|
59 return XQSysInfo::isSupported(KFeatureIdCsVideoTelephony); |
|
60 } |
|
61 |
|
62 /*! |
|
63 Tools::errorCodeTextMapping. |
|
64 */ |
|
65 bool Tools::errorCodeTextMapping(const int errorcode, QString &errorText) |
|
66 { |
|
67 DPRINT; |
|
68 errorText.clear(); |
|
69 bool errorTextFound(true); |
|
70 |
|
71 switch(errorcode){ |
|
72 case KErrGsmSSSubscriptionViolation: |
|
73 errorText = hbTrId("txt_phone_info_barring_operation_not_successful"); |
|
74 break; |
|
75 case KErrGsmSSUnknownSubscriber: |
|
76 case KErrGsmSSAbsentSubscriber: |
|
77 case KErrGsmSSIllegalOperation: |
|
78 case KErrGsmSSIllegalSubscriber: |
|
79 case KErrGsmSSIllegalEquipment: |
|
80 case KErrGsmSSCallBarred: |
|
81 case KErrGsmSSDataMissing: |
|
82 errorText = hbTrId("txt_phone_info_not_allowed"); |
|
83 break; |
|
84 case KErrGsmSSIncompatibility: |
|
85 errorText = hbTrId("txt_phone_info_conflict_error"); |
|
86 break; |
|
87 case KErrGsmSSSystemFailure: |
|
88 errorText = hbTrId("txt_phone_info_result_unknown"); |
|
89 break; |
|
90 case KErrGsmSSUnexpectedDataValue: |
|
91 case KErrGsmSSResourcesUnavailable: |
|
92 errorText = hbTrId("txt_phone_info_request_rejected"); |
|
93 break; |
|
94 case KErrGsmSSNegativePasswordCheck: |
|
95 case KErrGsmSSPasswordRegistrationFailure: |
|
96 errorText = hbTrId("Password error"); |
|
97 break; |
|
98 case KErrGsmSSPasswordAttemptsViolation: |
|
99 errorText = hbTrId("txt_phone_info_barring_password_blocked"); |
|
100 break; |
|
101 case KErrGsmSMSNoNetworkService: |
|
102 case KErrGsmNoService: |
|
103 errorText = hbTrId("No network coverage"); |
|
104 break; |
|
105 case KErrSsActivationDataLost: |
|
106 errorText = hbTrId("Check network services"); |
|
107 break; |
|
108 case KErrGsmOfflineOpNotAllowed: |
|
109 if(XQSysInfo::isSupported(KFeatureIdOfflineMode)){ |
|
110 XQSettingsManager *xqsettingsManager = new XQSettingsManager(); |
|
111 XQSettingsKey key(XQSettingsKey::TargetPublishAndSubscribe, |
|
112 KPSUidBluetoothSapConnectionState.iUid, |
|
113 KBTSapConnectionState); |
|
114 QVariant startupValue = xqsettingsManager->readItemValue(key); |
|
115 int value = startupValue.toInt(); |
|
116 delete xqsettingsManager; |
|
117 xqsettingsManager = NULL; |
|
118 if (value == EBTSapConnected){ |
|
119 errorText = hbTrId("Operation not possible in SIM access profile mode"); |
|
120 } else { |
|
121 errorText = hbTrId("Operation not possible in Off-line mode"); |
|
122 } |
|
123 } else { |
|
124 errorText = hbTrId("txt_phone_info_request_not_completed"); |
|
125 } |
|
126 break; |
|
127 case KErrGsmSSUnknownAlphabet: |
|
128 errorText = hbTrId("txt_phone_info_invalid_phone_number"); |
|
129 break; |
|
130 default: |
|
131 errorText = hbTrId("txt_phone_info_request_not_completed"); |
|
132 break; |
|
133 } |
|
134 |
|
135 return errorTextFound; |
|
136 } |
|
137 |
|
138 CpSettingsWrapper::CpSettingsWrapper(QObject *parent): |
|
139 QObject(parent), |
|
140 m_settings(NULL), |
|
141 m_deviceInfo(NULL) |
|
142 { |
|
143 m_settings = new XQSettingsManager(this); |
|
144 m_deviceInfo = new QSystemDeviceInfo(this); |
|
145 } |
|
146 |
|
147 CpSettingsWrapper::~CpSettingsWrapper() |
|
148 { |
|
149 |
|
150 } |
|
151 |
|
152 bool CpSettingsWrapper::showCallDuration() |
|
153 { |
|
154 bool showDuration; |
|
155 if (CenrepKeyValueOn == readCenrepValue(KCRUidLogs.iUid, KLogsShowCallDuration).toInt()) { |
|
156 showDuration = true; |
|
157 } else { |
|
158 showDuration = false; |
|
159 } |
|
160 |
|
161 DPRINT << "show call duration:" << showDuration; |
|
162 return showDuration; |
|
163 } |
|
164 |
|
165 int CpSettingsWrapper::setShowCallDuration(bool value) |
|
166 { |
|
167 int cenrepValue; |
|
168 DPRINT << "show call duration:" << value; |
|
169 |
|
170 if (value) { |
|
171 cenrepValue = CenrepKeyValueOn; |
|
172 } else { |
|
173 cenrepValue = CenrepKeyValueOff; |
|
174 } |
|
175 return writeCenrepValue(KCRUidLogs.iUid, KLogsShowCallDuration, cenrepValue ); |
|
176 } |
|
177 |
|
178 int CpSettingsWrapper::readVtVideoSending() |
|
179 { |
|
180 DPRINT << ": IN"; |
|
181 return readCenrepValue(KCRUidTelephonySettings.iUid, KSettingsVTVideoSending).toInt(); |
|
182 } |
|
183 |
|
184 int CpSettingsWrapper::writeVtVideoSending(int value) |
|
185 { |
|
186 DPRINT << ": IN"; |
|
187 return writeCenrepValue(KCRUidTelephonySettings.iUid, KSettingsVTVideoSending, value); |
|
188 } |
|
189 |
|
190 void CpSettingsWrapper::readSoftRejectText(QString &text, bool &userDefined ) |
|
191 { |
|
192 if (SoftRejectTextDefault == |
|
193 readCenrepValue(KCRUidTelephonySettings.iUid, KSettingsSoftRejectDefaultInUse ).toInt()) { |
|
194 userDefined = false; |
|
195 } else { |
|
196 userDefined = true; |
|
197 } |
|
198 |
|
199 text = readCenrepString(KCRUidTelephonySettings.iUid, KSettingsSoftRejectText); |
|
200 DPRINT << "text:" << text << " ,userDefined:" << userDefined; |
|
201 } |
|
202 |
|
203 int CpSettingsWrapper::writeSoftRejectText(const QString &text, bool userDefined ) |
|
204 { |
|
205 int err = writeCenrepValue(KCRUidTelephonySettings.iUid, KSettingsSoftRejectText, text); |
|
206 int cenrepValue; |
|
207 if (userDefined) { |
|
208 cenrepValue = SoftRejectTextUserDefined; |
|
209 } else { |
|
210 cenrepValue = SoftRejectTextDefault; |
|
211 } |
|
212 err |= writeCenrepValue(KCRUidTelephonySettings.iUid, KSettingsSoftRejectDefaultInUse, cenrepValue); |
|
213 DPRINT << "text:" << text << " ,userDefined:" << userDefined << " , err:" << err; |
|
214 return err; |
|
215 } |
|
216 |
|
217 bool CpSettingsWrapper::numberGroupingSupported() const |
|
218 { |
|
219 return readCenrepValue(KCRUidNumberGrouping.iUid, KNumberGrouping).toBool(); |
|
220 } |
|
221 |
|
222 bool CpSettingsWrapper::forbiddenIconSupported() const |
|
223 { |
|
224 int keyValue = readCenrepValue(KCRUidTelVariation.iUid, KTelVariationFlags).toInt(); |
|
225 return (KTelephonyLVFlagForbiddenIcon & keyValue); |
|
226 } |
|
227 |
|
228 QVariant CpSettingsWrapper::readCenrepValue( |
|
229 const long int uid, const unsigned long int key) const |
|
230 { |
|
231 XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, uid, key); |
|
232 QVariant ret = m_settings->readItemValue(settingsKey); |
|
233 DPRINT << "ret: " << ret; |
|
234 return ret; |
|
235 } |
|
236 |
|
237 QVariant CpSettingsWrapper::readPubSubValue( |
|
238 const long int uid, const unsigned long int key) const |
|
239 { |
|
240 XQSettingsKey settingsKey(XQSettingsKey::TargetPublishAndSubscribe, uid, key); |
|
241 QVariant ret = m_settings->readItemValue(settingsKey); |
|
242 DPRINT << "PubSub ret: " << ret; |
|
243 return ret; |
|
244 } |
|
245 |
|
246 QString CpSettingsWrapper::readCenrepString( |
|
247 const long int uid, const unsigned long int key) const |
|
248 { |
|
249 XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, uid, key); |
|
250 QString text = m_settings->readItemValue(settingsKey, XQSettingsManager::TypeString).toString(); |
|
251 DPRINT << "text: " << text; |
|
252 return text; |
|
253 } |
|
254 |
|
255 int CpSettingsWrapper::writeCenrepValue( |
|
256 const long int uid, const unsigned long int key, const QVariant &settingsKeyValue ) const |
|
257 { |
|
258 DPRINT << "uid:" << uid << ", key:" << key << ", settingsKeyValue:" << settingsKeyValue; |
|
259 XQSettingsKey settingsKey(XQSettingsKey::TargetCentralRepository, uid, key); |
|
260 int err = m_settings->writeItemValue(settingsKey, settingsKeyValue ); |
|
261 DPRINT << "err: " << err; |
|
262 return err; |
|
263 } |
|
264 |
|
265 bool CpSettingsWrapper::isFeatureCallWaitingDistiquishNotProvisionedEnabled() |
|
266 { |
|
267 bool enabled = readCenrepValue(KCRUidPhoneSettings.iUid, KPSetCallWaiting).toBool(); |
|
268 DPRINT << "enabled: " << enabled; |
|
269 return enabled; |
|
270 } |
|
271 |
|
272 bool CpSettingsWrapper::isPhoneOffline() const |
|
273 { |
|
274 bool networkConnectionAllowed = readCenrepValue(KCRUidCoreApplicationUIs.iUid, |
|
275 KCoreAppUIsNetworkConnectionAllowed).toBool(); |
|
276 // 0 = Offline Mode, 1 = Online Mode |
|
277 DPRINT << "networkConnectionAllowed: " << networkConnectionAllowed; |
|
278 return !networkConnectionAllowed; |
|
279 } |
|
280 |
|
281 bool CpSettingsWrapper::isOngoingCall() const |
|
282 { |
|
283 bool callOngoing(false); |
|
284 if (EPSCTsyCallStateNone < |
|
285 readPubSubValue(KPSUidCtsyCallInformation.iUid, KCTsyCallState).toInt()) { |
|
286 callOngoing = true; |
|
287 } |
|
288 return callOngoing; |
|
289 } |