2010-01-06 18:20:43 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2010-01-06 18:20:43 +01:00
|
|
|
** All rights reserved.
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** This file is part of the Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
|
** No Commercial Usage
|
|
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "maemoruncontrol.h"
|
2010-04-15 12:47:02 +02:00
|
|
|
|
2010-07-13 15:24:21 +02:00
|
|
|
#include "maemodeploystep.h"
|
2010-07-13 17:00:12 +02:00
|
|
|
#include "maemoglobal.h"
|
2010-01-06 18:20:43 +01:00
|
|
|
#include "maemorunconfiguration.h"
|
2010-07-14 17:26:51 +02:00
|
|
|
#include "maemosshrunner.h"
|
2010-01-06 18:20:43 +01:00
|
|
|
|
2010-07-13 15:24:21 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2010-01-06 18:20:43 +01:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2010-04-12 10:55:17 +02:00
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
|
2010-07-12 09:33:22 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
|
2010-01-06 18:20:43 +01:00
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-01-07 11:21:11 +01:00
|
|
|
using ProjectExplorer::RunConfiguration;
|
2010-06-24 15:20:22 +02:00
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
MaemoRunControl::MaemoRunControl(RunConfiguration *rc)
|
|
|
|
|
: RunControl(rc, ProjectExplorer::Constants::RUNMODE)
|
2010-11-11 12:08:13 +01:00
|
|
|
, m_runner(new MaemoSshRunner(this, qobject_cast<MaemoRunConfiguration *>(rc), false))
|
2010-07-14 17:26:51 +02:00
|
|
|
, m_running(false)
|
2010-01-06 18:20:43 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
MaemoRunControl::~MaemoRunControl()
|
2010-03-18 10:59:06 +01:00
|
|
|
{
|
2010-07-15 16:43:56 +02:00
|
|
|
stop();
|
2010-03-18 10:59:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::start()
|
2010-04-13 12:03:32 +02:00
|
|
|
{
|
2010-11-11 12:08:13 +01:00
|
|
|
m_running = true;
|
|
|
|
|
emit started();
|
|
|
|
|
disconnect(m_runner, 0, this, 0);
|
|
|
|
|
connect(m_runner, SIGNAL(error(QString)), SLOT(handleSshError(QString)));
|
|
|
|
|
connect(m_runner, SIGNAL(readyForExecution()), SLOT(startExecution()));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
|
|
|
|
|
SLOT(handleRemoteErrorOutput(QByteArray)));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
|
|
|
|
|
SLOT(handleRemoteOutput(QByteArray)));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteProcessStarted()),
|
|
|
|
|
SLOT(handleRemoteProcessStarted()));
|
|
|
|
|
connect(m_runner, SIGNAL(remoteProcessFinished(qint64)),
|
|
|
|
|
SLOT(handleRemoteProcessFinished(qint64)));
|
|
|
|
|
connect(m_runner, SIGNAL(reportProgress(QString)),
|
|
|
|
|
SLOT(handleProgressReport(QString)));
|
|
|
|
|
connect(m_runner, SIGNAL(mountDebugOutput(QString)),
|
|
|
|
|
SLOT(handleMountDebugOutput(QString)));
|
|
|
|
|
m_runner->start();
|
2010-04-13 16:30:52 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-20 14:19:25 +02:00
|
|
|
ProjectExplorer::RunControl::StopResult MaemoRunControl::stop()
|
2010-04-13 16:30:52 +02:00
|
|
|
{
|
2010-08-10 15:05:21 +02:00
|
|
|
m_runner->stop();
|
2010-08-20 14:19:25 +02:00
|
|
|
return StoppedSynchronously;
|
2010-04-15 12:47:02 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::handleSshError(const QString &error)
|
2010-07-08 12:17:07 +02:00
|
|
|
{
|
2010-07-14 17:26:51 +02:00
|
|
|
handleError(error);
|
|
|
|
|
setFinished();
|
2010-07-08 12:17:07 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::startExecution()
|
2010-04-12 17:43:46 +02:00
|
|
|
{
|
2010-07-14 17:26:51 +02:00
|
|
|
emit appendMessage(this, tr("Starting remote process ..."), false);
|
2010-07-29 14:42:04 +02:00
|
|
|
m_runner->startExecution(QString::fromLocal8Bit("%1 %2 %3 %4")
|
2010-11-11 12:08:13 +01:00
|
|
|
.arg(MaemoGlobal::remoteCommandPrefix(m_runner->remoteExecutable()))
|
|
|
|
|
.arg(MaemoGlobal::remoteEnvironment(m_runner->userEnvChanges()))
|
|
|
|
|
.arg(m_runner->remoteExecutable())
|
|
|
|
|
.arg(m_runner->arguments().join(QLatin1String(" "))).toUtf8());
|
2010-07-12 09:33:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 15:52:13 +02:00
|
|
|
void MaemoRunControl::handleRemoteProcessFinished(qint64 exitCode)
|
2010-07-12 09:33:22 +02:00
|
|
|
{
|
2010-10-04 15:52:13 +02:00
|
|
|
if (exitCode != MaemoSshRunner::InvalidExitCode) {
|
|
|
|
|
emit appendMessage(this,
|
|
|
|
|
tr("Finished running remote process. Exit code was %1.")
|
|
|
|
|
.arg(exitCode), false);
|
|
|
|
|
}
|
2010-07-14 17:26:51 +02:00
|
|
|
setFinished();
|
2010-07-12 09:33:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::handleRemoteOutput(const QByteArray &output)
|
2010-07-12 09:33:22 +02:00
|
|
|
{
|
|
|
|
|
emit addToOutputWindowInline(this, QString::fromUtf8(output), false);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::handleRemoteErrorOutput(const QByteArray &output)
|
2010-07-12 09:33:22 +02:00
|
|
|
{
|
|
|
|
|
emit addToOutputWindowInline(this, QString::fromUtf8(output), true);
|
2010-04-12 17:43:46 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 15:59:37 +02:00
|
|
|
void MaemoRunControl::handleProgressReport(const QString &progressString)
|
|
|
|
|
{
|
|
|
|
|
emit appendMessage(this, progressString, false);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-26 11:17:40 +02:00
|
|
|
void MaemoRunControl::handleMountDebugOutput(const QString &output)
|
|
|
|
|
{
|
|
|
|
|
emit addToOutputWindowInline(this, output, true);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
bool MaemoRunControl::isRunning() const
|
2010-04-12 17:43:46 +02:00
|
|
|
{
|
2010-07-14 17:26:51 +02:00
|
|
|
return m_running;
|
2010-01-06 18:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::handleError(const QString &errString)
|
2010-04-12 10:55:17 +02:00
|
|
|
{
|
2010-07-12 09:33:22 +02:00
|
|
|
stop();
|
2010-08-17 10:47:36 +02:00
|
|
|
emit appendMessage(this, errString, true);
|
|
|
|
|
QMessageBox::critical(0, tr("Remote Execution Failure"), errString);
|
2010-07-12 09:33:22 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-15 16:43:56 +02:00
|
|
|
void MaemoRunControl::setFinished()
|
2010-07-12 09:33:22 +02:00
|
|
|
{
|
2010-08-10 15:05:21 +02:00
|
|
|
disconnect(m_runner, 0, this, 0);
|
2010-07-14 17:26:51 +02:00
|
|
|
m_running = false;
|
|
|
|
|
emit finished();
|
2010-04-12 10:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
} // namespace Internal
|
2010-01-06 18:20:43 +01:00
|
|
|
} // namespace Qt4ProjectManager
|