1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the Qt Creator.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
33 ****************************************************************************/
35 #include "maemoruncontrol.h"
37 #include "maemodeploystep.h"
38 #include "maemoglobal.h"
39 #include "maemorunconfiguration.h"
40 #include "maemosshrunner.h"
42 #include <projectexplorer/projectexplorerconstants.h>
43 #include <utils/qtcassert.h>
45 #include <QtGui/QMessageBox>
48 using namespace ProjectExplorer;
50 namespace Qt4ProjectManager {
53 using ProjectExplorer::RunConfiguration;
55 MaemoRunControl::MaemoRunControl(RunConfiguration *rc)
56 : RunControl(rc, ProjectExplorer::Constants::RUNMODE)
57 , m_runner(new MaemoSshRunner(this, qobject_cast<MaemoRunConfiguration *>(rc), false))
62 MaemoRunControl::~MaemoRunControl()
67 void MaemoRunControl::start()
71 disconnect(m_runner, 0, this, 0);
72 connect(m_runner, SIGNAL(error(QString)), SLOT(handleSshError(QString)));
73 connect(m_runner, SIGNAL(readyForExecution()), SLOT(startExecution()));
74 connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
75 SLOT(handleRemoteErrorOutput(QByteArray)));
76 connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
77 SLOT(handleRemoteOutput(QByteArray)));
78 connect(m_runner, SIGNAL(remoteProcessStarted()),
79 SLOT(handleRemoteProcessStarted()));
80 connect(m_runner, SIGNAL(remoteProcessFinished(qint64)),
81 SLOT(handleRemoteProcessFinished(qint64)));
82 connect(m_runner, SIGNAL(reportProgress(QString)),
83 SLOT(handleProgressReport(QString)));
84 connect(m_runner, SIGNAL(mountDebugOutput(QString)),
85 SLOT(handleMountDebugOutput(QString)));
89 RunControl::StopResult MaemoRunControl::stop()
92 return StoppedSynchronously;
95 void MaemoRunControl::handleSshError(const QString &error)
101 void MaemoRunControl::startExecution()
103 appendMessage(tr("Starting remote process ..."), NormalMessageFormat);
104 m_runner->startExecution(QString::fromLocal8Bit("%1 %2 %3 %4")
105 .arg(MaemoGlobal::remoteCommandPrefix(m_runner->remoteExecutable()))
106 .arg(MaemoGlobal::remoteEnvironment(m_runner->userEnvChanges()))
107 .arg(m_runner->remoteExecutable())
108 .arg(m_runner->arguments()).toUtf8());
111 void MaemoRunControl::handleRemoteProcessFinished(qint64 exitCode)
113 if (exitCode != MaemoSshRunner::InvalidExitCode) {
114 appendMessage(tr("Finished running remote process. Exit code was %1.")
115 .arg(exitCode), NormalMessageFormat);
120 void MaemoRunControl::handleRemoteOutput(const QByteArray &output)
122 appendMessage(QString::fromUtf8(output), StdOutFormatSameLine);
125 void MaemoRunControl::handleRemoteErrorOutput(const QByteArray &output)
127 appendMessage(QString::fromUtf8(output), StdErrFormatSameLine);
130 void MaemoRunControl::handleProgressReport(const QString &progressString)
132 appendMessage(progressString, NormalMessageFormat);
135 void MaemoRunControl::handleMountDebugOutput(const QString &output)
137 appendMessage(output, StdErrFormatSameLine);
140 bool MaemoRunControl::isRunning() const
145 void MaemoRunControl::handleError(const QString &errString)
148 appendMessage(errString, ErrorMessageFormat);
149 QMessageBox::critical(0, tr("Remote Execution Failure"), errString);
152 void MaemoRunControl::setFinished()
154 disconnect(m_runner, 0, this, 0);
159 } // namespace Internal
160 } // namespace Qt4ProjectManager