From a437f824c487aff5cc90c3e767cdf840a5614690 Mon Sep 17 00:00:00 2001
From: Christian Kandeler <christian.kandeler@nokia.com>
Date: Thu, 26 Aug 2010 11:17:40 +0200
Subject: [PATCH] Maemo: Display UTFS server stderr output.

This will help us diagnose errors.
---
 .../qt4projectmanager/qt-maemo/maemodeploystep.cpp    |  8 ++++++++
 .../qt4projectmanager/qt-maemo/maemodeploystep.h      |  1 +
 .../qt4projectmanager/qt-maemo/maemoremotemounter.cpp | 11 +++++++++++
 .../qt4projectmanager/qt-maemo/maemoremotemounter.h   |  2 ++
 .../qt4projectmanager/qt-maemo/maemoruncontrol.cpp    |  7 +++++++
 .../qt4projectmanager/qt-maemo/maemoruncontrol.h      |  1 +
 .../qt4projectmanager/qt-maemo/maemosshrunner.cpp     |  2 ++
 .../qt4projectmanager/qt-maemo/maemosshrunner.h       |  1 +
 8 files changed, 33 insertions(+)

diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp
index c3685e56bc6..fb438ac57f8 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.cpp
@@ -110,6 +110,8 @@ void MaemoDeployStep::ctor()
         SLOT(handleMountError(QString)));
     connect(m_mounter, SIGNAL(reportProgress(QString)), this,
         SLOT(handleProgressReport(QString)));
+    connect(m_mounter, SIGNAL(debugOutput(QString)), this,
+        SLOT(handleMountDebugOutput(QString)));
 }
 
 bool MaemoDeployStep::init()
@@ -429,6 +431,12 @@ void MaemoDeployStep::handleMountError(const QString &errorMsg)
         raiseError(errorMsg);
 }
 
+void MaemoDeployStep::handleMountDebugOutput(const QString &output)
+{
+    if (!m_stopped)
+        writeOutput(output, ErrorOutput);
+}
+
 void MaemoDeployStep::setupMount()
 {
     Q_ASSERT(m_needsInstall || !m_filesToCopy.isEmpty());
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h
index 45fdefc216c..d5b52fa94f6 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeploystep.h
@@ -94,6 +94,7 @@ private slots:
     void handleMounted();
     void handleUnmounted();
     void handleMountError(const QString &errorMsg);
+    void handleMountDebugOutput(const QString &output);
     void handleProgressReport(const QString &progressMsg);
     void handleCopyProcessFinished(int exitStatus);
     void handleCleanupTimeout();
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp
index ddced58f137..ae27488e9f5 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.cpp
@@ -300,11 +300,22 @@ void MaemoRemoteMounter::startUtfsServers()
             SLOT(handleUtfsServerFinished(int,QProcess::ExitStatus)));
         connect(utfsServerProc.data(), SIGNAL(error(QProcess::ProcessError)),
             this, SLOT(handleUtfsServerError(QProcess::ProcessError)));
+        connect(utfsServerProc.data(), SIGNAL(readyReadStandardError()), this,
+            SLOT(handleUtfsServerStderr()));
         m_utfsServers << utfsServerProc;
         utfsServerProc->start(utfsServer(), utfsServerArgs);
     }
 }
 
+void MaemoRemoteMounter::handleUtfsServerStderr()
+{
+    if (!m_stop) {
+        QProcess * const proc = static_cast<QProcess *>(sender());
+        const QByteArray &output = proc->readAllStandardError();
+        emit debugOutput(QString::fromLocal8Bit(output));
+    }
+}
+
 void MaemoRemoteMounter::handleUtfsServerError(QProcess::ProcessError)
 {
     if (m_stop || m_utfsServers.isEmpty())
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h
index 4e57892365c..2991632542a 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemoremotemounter.h
@@ -76,6 +76,7 @@ signals:
     void unmounted();
     void error(const QString &reason);
     void reportProgress(const QString &progressOutput);
+    void debugOutput(const QString &output);
 
 private slots:
     void handleUploaderInitialized();
@@ -90,6 +91,7 @@ private slots:
     void handleUtfsServerFinished(int exitCode,
         QProcess::ExitStatus exitStatus);
     void handleUtfsServerTimeout();
+    void handleUtfsServerStderr();
 
 private:
     void deployUtfsClient();
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp
index 270e4cce723..597fb387a19 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.cpp
@@ -89,6 +89,8 @@ void MaemoRunControl::start()
             SLOT(handleRemoteProcessFinished(int)));
         connect(m_runner, SIGNAL(reportProgress(QString)), this,
             SLOT(handleProgressReport(QString)));
+        connect(m_runner, SIGNAL(mountDebugOutput(QString)), this,
+            SLOT(handleMountDebugOutput(QString)));
         m_runner->start();
     }
 }
@@ -139,6 +141,11 @@ void MaemoRunControl::handleProgressReport(const QString &progressString)
     emit appendMessage(this, progressString, false);
 }
 
+void MaemoRunControl::handleMountDebugOutput(const QString &output)
+{
+    emit addToOutputWindowInline(this, output, true);
+}
+
 bool MaemoRunControl::isRunning() const
 {
     return m_running;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h
index 204fb1e3429..ffde0f70189 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemoruncontrol.h
@@ -65,6 +65,7 @@ private slots:
     void handleRemoteOutput(const QByteArray &output);
     void handleRemoteErrorOutput(const QByteArray &output);
     void handleProgressReport(const QString &progressString);
+    void handleMountDebugOutput(const QString &output);
 
 private:
     void setFinished();
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp
index a53c41f3c14..9cfb8c2eb73 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp
@@ -69,6 +69,8 @@ MaemoSshRunner::MaemoSshRunner(QObject *parent,
         SLOT(handleMounterError(QString)));
     connect(m_mounter, SIGNAL(reportProgress(QString)), this,
         SIGNAL(reportProgress(QString)));
+    connect(m_mounter, SIGNAL(debugOutput(QString)), this,
+        SIGNAL(mountDebugOutput(QString)));
 }
 
 MaemoSshRunner::~MaemoSshRunner() {}
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h
index de079d8c273..6d7ea730ec6 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h
@@ -71,6 +71,7 @@ public:
 
 signals:
     void error(const QString &error);
+    void mountDebugOutput(const QString &output);
     void readyForExecution();
     void remoteOutput(const QByteArray &output);
     void remoteErrorOutput(const QByteArray &output);
-- 
GitLab