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:38 UTC
[2/9] cordova-ubuntu git commit: Add app launch tweaks
Add app launch tweaks
Project: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/commit/2b00f308
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/tree/2b00f308
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/diff/2b00f308
Branch: refs/heads/master
Commit: 2b00f308215a00ad7c3305190e8f5a74fdd4dd0f
Parents: e64d558
Author: Alexandre Abreu <al...@canonical.com>
Authored: Mon May 9 20:25:32 2016 -0400
Committer: Alexandre Abreu <al...@canonical.com>
Committed: Mon May 9 20:25:32 2016 -0400
----------------------------------------------------------------------
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/2b00f308/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/2b00f308/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/2b00f308/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