|
1 /* |
|
2 * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ |
|
3 * |
|
4 * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 * you may not use this file except in compliance with the License. |
|
6 * You may obtain a copy of the License at |
|
7 * |
|
8 * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 * |
|
10 * Unless required by applicable law or agreed to in writing, software |
|
11 * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 * See the License for the specific language governing permissions and |
|
14 * limitations under the License. |
|
15 */ |
|
16 |
|
17 #include <QDeviceInfo> |
|
18 #include <QtSystemInfo> |
|
19 |
|
20 #include"device.h" |
|
21 |
|
22 #define CORDOVA "3.0.0" |
|
23 |
|
24 Device::Device(Cordova *cordova) : CPlugin(cordova) { |
|
25 } |
|
26 |
|
27 static QString getOSName() { |
|
28 #ifdef Q_OS_SYMBIAN |
|
29 QString platform = "Symbian"; |
|
30 #endif |
|
31 #ifdef Q_OS_WIN |
|
32 QString platform = "Windows"; |
|
33 #endif |
|
34 #ifdef Q_OS_WINCE |
|
35 QString platform = "Windows CE"; |
|
36 #endif |
|
37 #ifdef Q_OS_LINUX |
|
38 QString platform = "Linux"; |
|
39 #endif |
|
40 return platform; |
|
41 } |
|
42 |
|
43 void Device::getInfo(int scId, int ecId) { |
|
44 Q_UNUSED(ecId) |
|
45 |
|
46 QDeviceInfo systemDeviceInfo; |
|
47 QDeviceInfo systemInfo; |
|
48 |
|
49 QString platform = getOSName(); |
|
50 |
|
51 QString uuid = systemDeviceInfo.uniqueDeviceID(); |
|
52 if (uuid.isEmpty()) { |
|
53 QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform; |
|
54 QString user = qgetenv("USER"); |
|
55 if (user.isEmpty()) { |
|
56 user = qgetenv("USERNAME"); |
|
57 if (user.isEmpty()) |
|
58 user = QDir::homePath(); |
|
59 } |
|
60 uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex()); |
|
61 } |
|
62 |
|
63 this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os)); |
|
64 } |