cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [1/3] git commit: add ubuntu platform
Date Mon, 02 Dec 2013 23:47:31 GMT
Updated Branches:
  refs/heads/dev 7256fdd59 -> 2a104e3e3


add ubuntu platform


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/458816bb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/458816bb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/458816bb

Branch: refs/heads/dev
Commit: 458816bbda1ec7d1e69c166b602f134941c5f51c
Parents: a9190fa
Author: Maxim Ermilov <ermilov.maxim@gmail.com>
Authored: Sat Sep 21 17:49:18 2013 +0400
Committer: Maxim Ermilov <ermilov.maxim@gmail.com>
Committed: Sat Sep 21 17:49:18 2013 +0400

----------------------------------------------------------------------
 plugin.xml            |  9 +++++++
 src/ubuntu/device.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 src/ubuntu/device.h   | 47 ++++++++++++++++++++++++++++++++++
 src/ubuntu/device.js  | 34 ++++++++++++++++++++++++
 4 files changed, 154 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/458816bb/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index 54e5137..52786d8 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -25,6 +25,15 @@
         <source-file src="src/android/Device.java" target-dir="src/org/apache/cordova/device"
/>
     </platform>
 
+    <!-- ubuntu -->
+    <platform name="ubuntu">
+        <header-file src="src/ubuntu/device.h" />
+        <source-file src="src/ubuntu/device.cpp" />
+        <js-module src="src/ubuntu/device.js" name="DeviceProxy">
+            <merges target="device" />
+        </js-module>
+    </platform>
+
     <!-- ios -->
     <platform name="ios">
         <config-file target="config.xml" parent="/*">

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

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/458816bb/src/ubuntu/device.h
----------------------------------------------------------------------
diff --git a/src/ubuntu/device.h b/src/ubuntu/device.h
new file mode 100644
index 0000000..91cb937
--- /dev/null
+++ b/src/ubuntu/device.h
@@ -0,0 +1,47 @@
+/*
+ *  Copyright 2011 Wolfgang Koller - http://www.gofg.at/
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#ifndef DEVICE_H_FDSAFAS
+#define DEVICE_H_FDSAFAS
+
+#include <QtCore>
+
+#include <cplugin.h>
+
+class Device: public CPlugin {
+    Q_OBJECT
+public:
+    explicit Device(Cordova *cordova);
+
+    virtual const QString fullName() override {
+        return Device::fullID();
+    }
+
+    virtual const QString shortName() override {
+        return "Device";
+    }
+
+    static const QString fullID() {
+        return "com.cordova.Device";
+    }
+
+signals:
+
+public slots:
+    void getInfo(int scId, int ecId);
+};
+
+#endif

http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/458816bb/src/ubuntu/device.js
----------------------------------------------------------------------
diff --git a/src/ubuntu/device.js b/src/ubuntu/device.js
new file mode 100644
index 0000000..5f9a5c8
--- /dev/null
+++ b/src/ubuntu/device.js
@@ -0,0 +1,34 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var cordova = require('cordova');
+var exec = require('cordova/exec');
+
+module.exports = {
+    getInfo:function(win,fail,args) {
+        Cordova.exec(function (model, cordova, platform, uuid, version) {
+            win({name: name, model: model, cordova: cordova,
+                 platform: platform, uuid: uuid, version: version});
+        }, null, "com.cordova.Device", "getInfo", []);
+    }
+};
+
+require("cordova/commandProxy").add("Device", module.exports);


Mime
View raw message