You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2016/05/19 09:54:45 UTC

[2/8] cordova-ubuntu git commit: Add app launch tweaks

Add app launch tweaks

(cherry picked from commit 2b00f308215a00ad7c3305190e8f5a74fdd4dd0f)


Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/8dec0b10
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/8dec0b10
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/8dec0b10

Branch: refs/heads/4.3.x
Commit: 8dec0b108ba9f0ffafcbaa915e69889c67d48837
Parents: 330f1e7
Author: Alexandre Abreu <al...@canonical.com>
Authored: Mon May 9 20:25:32 2016 -0400
Committer: David Barth <da...@canonical.com>
Committed: Thu May 19 11:15:52 2016 +0200

----------------------------------------------------------------------
 CordovaUbuntu/CordovaViewInternal.qml    |  4 ++--
 bin/templates/project/cordova/lib/run.js | 31 ++++++++++++++++++++++++---
 main.cpp                                 |  9 ++++----
 3 files changed, 35 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8dec0b10/CordovaUbuntu/CordovaViewInternal.qml
----------------------------------------------------------------------
diff --git a/CordovaUbuntu/CordovaViewInternal.qml b/CordovaUbuntu/CordovaViewInternal.qml
index 47ea2ab..2f91f73 100644
--- a/CordovaUbuntu/CordovaViewInternal.qml
+++ b/CordovaUbuntu/CordovaViewInternal.qml
@@ -129,8 +129,8 @@ OrientationHelper {
                     msgId: "from-cordova"
                     contexts: [usContext]
                     callback: function(msg, frame) {
-                        CordovaWrapper.messageHandler(msg.args)
-                        console.log(JSON.stringify(msg.args))
+                        CordovaWrapper.messageHandler(msg.payload)
+                        console.log('Message payload', JSON.stringify(msg.payload))
                     }
                 }
             ]

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8dec0b10/bin/templates/project/cordova/lib/run.js
----------------------------------------------------------------------
diff --git a/bin/templates/project/cordova/lib/run.js b/bin/templates/project/cordova/lib/run.js
index 9f905d8..580498e 100644
--- a/bin/templates/project/cordova/lib/run.js
+++ b/bin/templates/project/cordova/lib/run.js
@@ -81,6 +81,27 @@ module.exports.run = function(rootDir, desktop, debug, target, nobuild, emulator
     });
 };
 
+function getDeviceInetAddress(target) {
+    function parseInetLines(lines) {
+        var ip = '';
+        for (var i = 0; i < lines.length; ++i) {
+            var match = /\s+inet\s+(\d+.\d+.\d+.\d+)?.*/.exec(lines[i])
+            if (match && match.length > 0 && match[1] != '127.0.0.1') {
+                ip = match[1];
+                break;
+            }
+        }
+        return ip
+    }
+    var lines = [];
+    if (target) {
+        lines = Devices.adbExec(target, 'shell ip -f inet addr').output.split('\n');
+    } else {
+        lines = Utils.execSync('ip -f inet addr').output.split('\n');
+    }
+    return parseInetLines(lines)
+}
+
 function runNative(rootDir, debug) {
     logger.info('Running Cordova');
     var ubuntuDir = path.join(rootDir, 'platforms', 'ubuntu');
@@ -91,7 +112,9 @@ function runNative(rootDir, debug) {
     var cmd = './cordova-ubuntu www/';
     if (debug) {
         cmd = "DEBUG=1 " + cmd;
-        logger.warn('Debug enabled. Try pointing a Chrome/Chromium browser to http://127.0.0.1:9222');
+        logger.warn('Debug enabled. \
+Try pointing a Chrome/Chromium browser \
+to http://' + getDeviceInetAddress() + ':9222');
     }
 
     logger.info('Launching the application.');
@@ -134,13 +157,15 @@ function runOnDevice(rootDir, debug, target, architecture, framework) {
     Devices.adbExec(target, 'shell "cd /home/phablet/; pkcon install-local ' + names[0] + ' -p --allow-untrusted -y"', {silent: false});
 
     if (debug) {
-        logger.warn('Debug enabled. Try pointing a Chrome/Chromium browser to http://127.0.0.1:9222');
+        logger.warn('Debug enabled. \
+Try pointing a Chrome/Chromium browser \
+to http://' + getDeviceInetAddress(target) + ':9222');
         Devices.adbExec(target, 'forward tcp:9222 tcp:9222');
     }
 
     logger.info('Launching the application on your device.');
 
-    return Devices.adbExecAsync(target, 'shell bash -c "ubuntu-app-launch  \\`ubuntu-app-triplet ' + appId + '\\`"').then(function () {
+    return Devices.adbExecAsync(target, 'shell "DEBUG=1 ubuntu-app-launch  \\`ubuntu-app-triplet ' + appId + '\\`"').then(function () {
         logger.rainbow('have fun!');
         Utils.popd();
     });

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/8dec0b10/main.cpp
----------------------------------------------------------------------
diff --git a/main.cpp b/main.cpp
index 2ab8337..0bf55e6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -29,7 +29,7 @@ void customMessageOutput(
 
     switch (type) {
     case QtDebugMsg:
-      if (QString::fromUtf8(qgetenv("DEBUG")) == "1") {
+        if (QString::fromUtf8(qgetenv("DEBUG")) == "1") {
             fprintf(stderr, "Debug: %s\n", msg.toStdString().c_str());
         }
         break;
@@ -43,9 +43,6 @@ void customMessageOutput(
         fprintf(stderr, "Fatal: %s\n", msg.toStdString().c_str());
         abort();
         break;
-    case QtInfoMsg:
-        fprintf(stderr, "Info: %s\n", msg.toStdString().c_str());
-        break;
     }
 }
 
@@ -100,6 +97,10 @@ int main(int argc, char *argv[]) {
     if (debuggingEnabled) {
       debuggingDevtoolsIp = getDebuggingDevtoolsIp();
       debuggingDevtoolsPort = kDebuggingDevtoolsDefaultPort;
+
+      qDebug() << QString("Devtools started at http://%1:%2")
+        .arg(debuggingDevtoolsIp)
+        .arg(debuggingDevtoolsPort);
     }
 
     view.rootContext()->setContextProperty(


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org