michael@0: /* michael@0: * Copyright 2011 Wolfgang Koller - http://www.gofg.at/ michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #include"device.h" michael@0: michael@0: #define CORDOVA "3.0.0" michael@0: michael@0: Device::Device(Cordova *cordova) : CPlugin(cordova) { michael@0: } michael@0: michael@0: static QString getOSName() { michael@0: #ifdef Q_OS_SYMBIAN michael@0: QString platform = "Symbian"; michael@0: #endif michael@0: #ifdef Q_OS_WIN michael@0: QString platform = "Windows"; michael@0: #endif michael@0: #ifdef Q_OS_WINCE michael@0: QString platform = "Windows CE"; michael@0: #endif michael@0: #ifdef Q_OS_LINUX michael@0: QString platform = "Linux"; michael@0: #endif michael@0: return platform; michael@0: } michael@0: michael@0: void Device::getInfo(int scId, int ecId) { michael@0: Q_UNUSED(ecId) michael@0: michael@0: QDeviceInfo systemDeviceInfo; michael@0: QDeviceInfo systemInfo; michael@0: michael@0: QString platform = getOSName(); michael@0: michael@0: QString uuid = systemDeviceInfo.uniqueDeviceID(); michael@0: if (uuid.isEmpty()) { michael@0: QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform; michael@0: QString user = qgetenv("USER"); michael@0: if (user.isEmpty()) { michael@0: user = qgetenv("USERNAME"); michael@0: if (user.isEmpty()) michael@0: user = QDir::homePath(); michael@0: } michael@0: uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex()); michael@0: } michael@0: michael@0: this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os)); michael@0: }