cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dba...@apache.org
Subject [1/8] cordova-ubuntu git commit: Improve debugging behavior; Add ip option
Date Thu, 19 May 2016 09:54:44 GMT
Repository: cordova-ubuntu
Updated Branches:
  refs/heads/4.3.x 81381a5f1 -> a12a3d13d


Improve debugging behavior; Add ip option

(cherry picked from commit e64d55827b35f462b381a8a9eedd9b146534b138)


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

Branch: refs/heads/4.3.x
Commit: 330f1e715d02f4d3a824b53a0ca21ea0d747a27a
Parents: 81381a5
Author: Alexandre Abreu <alexandre.abreu@canonical.com>
Authored: Mon May 9 16:45:46 2016 -0400
Committer: David Barth <david.barth@canonical.com>
Committed: Thu May 19 11:15:38 2016 +0200

----------------------------------------------------------------------
 CordovaUbuntu/CordovaViewInternal.qml | 18 ++++++++++++++-
 main.cpp                              | 36 ++++++++++++++++++++++++++++--
 2 files changed, 51 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/330f1e71/CordovaUbuntu/CordovaViewInternal.qml
----------------------------------------------------------------------
diff --git a/CordovaUbuntu/CordovaViewInternal.qml b/CordovaUbuntu/CordovaViewInternal.qml
index 02dea8c..47ea2ab 100644
--- a/CordovaUbuntu/CordovaViewInternal.qml
+++ b/CordovaUbuntu/CordovaViewInternal.qml
@@ -82,11 +82,27 @@ OrientationHelper {
                 request.accept();
             }
 
+            onJavaScriptConsoleMessage: {
+                var msg = "[JS] (%1:%2) %3".arg(sourceId).arg(lineNumber).arg(message)
+                if (level === WebView.LogSeverityVerbose) {
+                    console.log(msg)
+                } else if (level === WebView.LogSeverityInfo) {
+                    console.info(msg)
+                } else if (level === WebView.LogSeverityWarning) {
+                    console.warn(msg)
+                } else if ((level === WebView.LogSeverityError) ||
+                           (level === WebView.LogSeverityErrorReport) ||
+                           (level === WebView.LogSeverityFatal)) {
+                    console.error(msg)
+                }
+            }
+
             context: WebContext {
                 id: webcontext
 
                 devtoolsEnabled: debuggingEnabled
-                devtoolsPort: debuggingEnabled ? 9222 : -1
+                devtoolsIp: debuggingDevtoolsIp
+                devtoolsPort: debuggingEnabled ? debuggingDevtoolsPort : -1
 
                 userScripts: [
                     UserScript {

http://git-wip-us.apache.org/repos/asf/cordova-ubuntu/blob/330f1e71/main.cpp
----------------------------------------------------------------------
diff --git a/main.cpp b/main.cpp
index ffef445..2ab8337 100644
--- a/main.cpp
+++ b/main.cpp
@@ -18,15 +18,18 @@
 #include <QtCore>
 #include <QApplication>
 #include <QtQuick>
+#include <QtNetwork/QNetworkInterface>
 
-static void customMessageOutput(
+const int kDebuggingDevtoolsDefaultPort = 9222;
+
+void customMessageOutput(
         QtMsgType type,
         const QMessageLogContext &,
         const QString &msg) {
 
     switch (type) {
     case QtDebugMsg:
-        if (qgetenv("DEBUG").size()) {
+      if (QString::fromUtf8(qgetenv("DEBUG")) == "1") {
             fprintf(stderr, "Debug: %s\n", msg.toStdString().c_str());
         }
         break;
@@ -39,7 +42,23 @@ static void customMessageOutput(
     case QtFatalMsg:
         fprintf(stderr, "Fatal: %s\n", msg.toStdString().c_str());
         abort();
+        break;
+    case QtInfoMsg:
+        fprintf(stderr, "Info: %s\n", msg.toStdString().c_str());
+        break;
+    }
+}
+
+QString getDebuggingDevtoolsIp()
+{
+    QString host;
+    Q_FOREACH(QHostAddress address, QNetworkInterface::allAddresses()) {
+        if (!address.isLoopback() && (address.protocol() == QAbstractSocket::IPv4Protocol))
{
+            host = address.toString();
+            break;
+        }
     }
+    return host;
 }
 
 int main(int argc, char *argv[]) {
@@ -75,6 +94,19 @@ int main(int argc, char *argv[]) {
     view.rootContext()->setContextProperty(
                 "debuggingEnabled", debuggingEnabled);
 
+    QString debuggingDevtoolsIp;
+    int debuggingDevtoolsPort = -1;
+
+    if (debuggingEnabled) {
+      debuggingDevtoolsIp = getDebuggingDevtoolsIp();
+      debuggingDevtoolsPort = kDebuggingDevtoolsDefaultPort;
+    }
+
+    view.rootContext()->setContextProperty(
+                "debuggingDevtoolsIp", debuggingDevtoolsIp);
+    view.rootContext()->setContextProperty(
+                "debuggingDevtoolsPort", debuggingDevtoolsPort);
+
     view.rootContext()->setContextProperty(
                 "www", wwwDir.absolutePath());
 


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


Mime
View raw message