Touchgui/plugins/org.apache.cordova.device/src/ubuntu/device.cpp

changeset 0
e8ccd40d0ef6
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Touchgui/plugins/org.apache.cordova.device/src/ubuntu/device.cpp	Thu Jun 04 14:50:33 2015 +0200
     1.3 @@ -0,0 +1,64 @@
     1.4 +/*
     1.5 + *  Copyright 2011 Wolfgang Koller - http://www.gofg.at/
     1.6 + *
     1.7 + *  Licensed under the Apache License, Version 2.0 (the "License");
     1.8 + *  you may not use this file except in compliance with the License.
     1.9 + *  You may obtain a copy of the License at
    1.10 + *
    1.11 + *      http://www.apache.org/licenses/LICENSE-2.0
    1.12 + *
    1.13 + *  Unless required by applicable law or agreed to in writing, software
    1.14 + *  distributed under the License is distributed on an "AS IS" BASIS,
    1.15 + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    1.16 + *  See the License for the specific language governing permissions and
    1.17 + *  limitations under the License.
    1.18 + */
    1.19 +
    1.20 +#include <QDeviceInfo>
    1.21 +#include <QtSystemInfo>
    1.22 +
    1.23 +#include"device.h"
    1.24 +
    1.25 +#define CORDOVA "3.0.0"
    1.26 +
    1.27 +Device::Device(Cordova *cordova) : CPlugin(cordova) {
    1.28 +}
    1.29 +
    1.30 +static QString getOSName() {
    1.31 +#ifdef Q_OS_SYMBIAN
    1.32 +    QString platform = "Symbian";
    1.33 +#endif
    1.34 +#ifdef Q_OS_WIN
    1.35 +    QString platform = "Windows";
    1.36 +#endif
    1.37 +#ifdef Q_OS_WINCE
    1.38 +    QString platform = "Windows CE";
    1.39 +#endif
    1.40 +#ifdef Q_OS_LINUX
    1.41 +    QString platform = "Linux";
    1.42 +#endif
    1.43 +    return platform;
    1.44 +}
    1.45 +
    1.46 +void Device::getInfo(int scId, int ecId) {
    1.47 +    Q_UNUSED(ecId)
    1.48 +
    1.49 +    QDeviceInfo systemDeviceInfo;
    1.50 +    QDeviceInfo systemInfo;
    1.51 +
    1.52 +    QString platform = getOSName();
    1.53 +
    1.54 +    QString uuid = systemDeviceInfo.uniqueDeviceID();
    1.55 +    if (uuid.isEmpty()) {
    1.56 +        QString deviceDescription = systemInfo.imei(0) + ";" + systemInfo.manufacturer() + ";" + systemInfo.model() + ";" + systemInfo.productName() + ";" + platform;
    1.57 +        QString user = qgetenv("USER");
    1.58 +        if (user.isEmpty()) {
    1.59 +            user = qgetenv("USERNAME");
    1.60 +            if (user.isEmpty())
    1.61 +                user = QDir::homePath();
    1.62 +        }
    1.63 +        uuid = QString(QCryptographicHash::hash((deviceDescription + ";" + user).toUtf8(), QCryptographicHash::Md5).toHex());
    1.64 +    }
    1.65 +
    1.66 +    this->cb(scId, systemDeviceInfo.model(), CORDOVA, platform, uuid, systemInfo.version(QDeviceInfo::Os));
    1.67 +}

mercurial