|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, version 2.1 of the License. |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program. If not, |
|
16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/". |
|
17 * |
|
18 * Description: |
|
19 * |
|
20 */ |
|
21 |
|
22 #include "xqsysinfo_p.h" |
|
23 #include "xqsysinfo.h" |
|
24 #include "cdeviceinfo.h" |
|
25 #include <e32const.h> |
|
26 #include <sysutil.h> |
|
27 #include <etel3rdparty.h> |
|
28 #include <f32file.h> |
|
29 #include <featdiscovery.h> |
|
30 |
|
31 XQSysInfoPrivate::XQSysInfoPrivate(XQSysInfo *sysInfo) : q(sysInfo) |
|
32 { |
|
33 TRAP(iError, iDeviceInfo = CDeviceInfo::NewL();) |
|
34 } |
|
35 |
|
36 XQSysInfoPrivate::~XQSysInfoPrivate() |
|
37 { |
|
38 delete iDeviceInfo; |
|
39 } |
|
40 |
|
41 XQSysInfo::Language XQSysInfoPrivate::currentLanguage() const |
|
42 { |
|
43 return static_cast<XQSysInfo::Language>(User::Language()); |
|
44 } |
|
45 |
|
46 QString XQSysInfoPrivate::imei() const |
|
47 { |
|
48 TBuf<CTelephony::KPhoneSerialNumberSize> imei(iDeviceInfo->imei()); |
|
49 return QString::fromUtf16(imei.Ptr(), imei.Length()); |
|
50 } |
|
51 |
|
52 QString XQSysInfoPrivate::model() const |
|
53 { |
|
54 TBuf<CTelephony::KPhoneModelIdSize> model(iDeviceInfo->model()); |
|
55 return QString::fromUtf16(model.Ptr(), model.Length()); |
|
56 } |
|
57 |
|
58 QString XQSysInfoPrivate::manufacturer() const |
|
59 { |
|
60 TBuf<CTelephony::KPhoneModelIdSize> manufacturer( |
|
61 iDeviceInfo->manufacturer()); |
|
62 return QString::fromUtf16(manufacturer.Ptr(), manufacturer.Length()); |
|
63 } |
|
64 |
|
65 QString XQSysInfoPrivate::imsi() const |
|
66 { |
|
67 TBuf<CTelephony::KIMSISize> imsi(iDeviceInfo->imsi()); |
|
68 return QString::fromUtf16(imsi.Ptr(), imsi.Length()); |
|
69 } |
|
70 |
|
71 QString XQSysInfoPrivate::softwareVersion() const |
|
72 { |
|
73 QString version; |
|
74 TBuf<KSysUtilVersionTextLength> versionBuf; |
|
75 if (SysUtil::GetSWVersion(versionBuf) == KErrNone) { |
|
76 version = QString::fromUtf16(versionBuf.Ptr(), versionBuf.Length()); |
|
77 } |
|
78 return version; |
|
79 } |
|
80 |
|
81 uint XQSysInfoPrivate::batteryLevel() const |
|
82 { |
|
83 return iDeviceInfo->batteryLevel(); |
|
84 } |
|
85 |
|
86 int XQSysInfoPrivate::signalStrength() const |
|
87 { |
|
88 return iDeviceInfo->signalStrength(); |
|
89 } |
|
90 |
|
91 int XQSysInfoPrivate::memory() const |
|
92 { |
|
93 TMemoryInfoV1Buf info; |
|
94 UserHal::MemoryInfo(info); |
|
95 return info().iFreeRamInBytes; |
|
96 } |
|
97 |
|
98 QString XQSysInfoPrivate::browserVersion() const |
|
99 { |
|
100 return QString(); |
|
101 } |
|
102 |
|
103 qlonglong XQSysInfoPrivate::diskSpace(XQSysInfo::Drive drive) |
|
104 { |
|
105 RFs fsSession; |
|
106 TInt64 driveFreeSize = 0; |
|
107 TRAP(iError, |
|
108 CleanupClosePushL(fsSession); |
|
109 User::LeaveIfError(fsSession.Connect()); |
|
110 int driveIndex = static_cast<TDriveNumber>(drive); |
|
111 |
|
112 if (fsSession.IsValidDrive(driveIndex)) { |
|
113 TDriveInfo driveInfo; |
|
114 User::LeaveIfError(fsSession.Drive(driveInfo, driveIndex)); |
|
115 TVolumeInfo volumeInfo; |
|
116 User::LeaveIfError(fsSession.Volume(volumeInfo, driveIndex)); |
|
117 driveFreeSize = volumeInfo.iFree; |
|
118 } |
|
119 CleanupStack::PopAndDestroy(&fsSession); |
|
120 ) |
|
121 return driveFreeSize; |
|
122 } |
|
123 |
|
124 bool XQSysInfoPrivate::isDiskSpaceCritical(XQSysInfo::Drive drive) const |
|
125 { |
|
126 bool isCritical = false; |
|
127 |
|
128 TRAP(iError, |
|
129 int driveIndex = static_cast<TDriveNumber>(drive); |
|
130 |
|
131 RFs fsSession; |
|
132 CleanupClosePushL(fsSession); |
|
133 if (fsSession.IsValidDrive(driveIndex)) { |
|
134 User::LeaveIfError(fsSession.Connect()); |
|
135 |
|
136 if (SysUtil::DiskSpaceBelowCriticalLevelL( |
|
137 &fsSession, 0, driveIndex)) { |
|
138 isCritical = true; |
|
139 } else { |
|
140 isCritical = false; |
|
141 } |
|
142 } else { |
|
143 User::Leave(KErrNotFound); |
|
144 } |
|
145 CleanupStack::PopAndDestroy(&fsSession); |
|
146 ) |
|
147 return isCritical; |
|
148 } |
|
149 |
|
150 bool XQSysInfoPrivate::isSupported(int featureId) |
|
151 { |
|
152 bool isFeatureSupported = false; |
|
153 TRAPD(iError, isFeatureSupported = CFeatureDiscovery::IsFeatureSupportedL(featureId);) //insp: major, error checking is not reliable |
|
154 return isFeatureSupported; |
|
155 } |
|
156 |
|
157 void XQSysInfoPrivate::SignalStatusL(TInt32 aStrength, TInt8 /*aBars*/) |
|
158 { |
|
159 emit q->networkSignalChanged(aStrength); |
|
160 } |
|
161 |
|
162 void XQSysInfoPrivate::BatteryLevelL(TUint aChargeLevel, CTelephony::TBatteryStatus /*aBatteryStatus*/) |
|
163 { |
|
164 emit q->batteryLevelChanged(aChargeLevel); |
|
165 } |
|
166 |
|
167 bool XQSysInfoPrivate::isNetwork() const |
|
168 { |
|
169 return (signalStrength() != 0); |
|
170 } |
|
171 |
|
172 XQSysInfo::Error XQSysInfoPrivate::error() const |
|
173 { |
|
174 switch (iError) { |
|
175 case KErrNone: |
|
176 return XQSysInfo::NoError; |
|
177 case KErrNoMemory: |
|
178 return XQSysInfo::OutOfMemoryError; |
|
179 case KErrNotFound: |
|
180 return XQSysInfo::DriveNotFoundError; |
|
181 default: |
|
182 return XQSysInfo::UnknownError; |
|
183 } |
|
184 } |