Commit 1470d32e authored by ck's avatar ck

Maemo: Add ssh deployment thread.

Also introduced MaemoSshThread class to factor out common parts
of the runner and the deployer code.
The maemosshrunner files do not contain code anymore and will
be removed soon.
parent f463f3ab
......@@ -42,7 +42,7 @@
#include <qt4projectmanager/qt4projectmanagerconstants.h>
#include "maemodeviceconfigurations.h"
#include "maemosshrunner.h"
#include "maemosshthread.h"
#include "ui_maemosettingswidget.h"
#include "maemosettingspage.h"
......
......@@ -42,7 +42,6 @@
#ifndef MAEMOSSHCONNECTION_H
#define MAEMOSSHCONNECTION_H
// #define USE_SSH_LIB
#ifdef USE_SSH_LIB
#include <QtCore/QObject>
......@@ -75,6 +74,8 @@ class MaemoSshConnection : public QObject
{
Q_DISABLE_COPY(MaemoSshConnection)
public:
typedef QSharedPointer<MaemoSshConnection> Ptr;
void stop();
virtual ~MaemoSshConnection();
......
......@@ -46,30 +46,6 @@
namespace Qt4ProjectManager {
namespace Internal {
MaemoSshRunner::MaemoSshRunner(const MaemoDeviceConfig &devConf, const QString &command)
: m_devConf(devConf), m_command(command)
{
}
void MaemoSshRunner::run()
{
try {
m_connection = MaemoInteractiveSshConnection::create(m_devConf);
emit connectionEstablished();
connect(m_connection.data(), SIGNAL(remoteOutput(QString)),
this, SIGNAL(remoteOutput(QString)));
m_connection->runCommand(m_command);
} catch (const MaemoSshException &e) {
m_error = e.error();
}
}
void MaemoSshRunner::stop()
{
if (!m_connection.isNull())
m_connection->stop();
wait();
}
} // namespace Internal
} // namespace Qt4ProjectManager
......
......@@ -45,34 +45,14 @@
#include "maemodeviceconfigurations.h"
#include "maemosshconnection.h"
#ifdef USE_SSH_LIB
#include <QtCore/QString>
#include <QtCore/QThread>
#ifdef USE_SSH_LIB
namespace Qt4ProjectManager {
namespace Internal {
class MaemoSshRunner : public QThread
{
Q_OBJECT
public:
MaemoSshRunner(const MaemoDeviceConfig &devConf, const QString &command);
QString error() const { return m_error; }
bool hasError() const { return !m_error.isEmpty(); }
void stop();
virtual void run();
signals:
void connectionEstablished();
void remoteOutput(const QString &output);
private:
const MaemoDeviceConfig m_devConf;
const QString m_command;
QString m_error;
MaemoInteractiveSshConnection::Ptr m_connection;
};
} // namespace Internal
} // namespace Qt4ProjectManager
......
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** 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 "maemosshthread.h"
#ifdef USE_SSH_LIB
namespace Qt4ProjectManager {
namespace Internal {
MaemoSshThread::MaemoSshThread(const MaemoDeviceConfig &devConf)
: m_devConf(devConf)
{
}
void MaemoSshThread::run()
{
try {
runInternal();
} catch (const MaemoSshException &e) {
m_error = e.error();
}
}
void MaemoSshThread::stop()
{
connection()->stop();
}
MaemoSshRunner::MaemoSshRunner(const MaemoDeviceConfig &devConf,
const QString &command)
: MaemoSshThread(devConf), m_command(command)
{
}
void MaemoSshRunner::runInternal()
{
m_connection = MaemoInteractiveSshConnection::create(m_devConf);
emit connectionEstablished();
connect(m_connection.data(), SIGNAL(remoteOutput(QString)),
this, SIGNAL(remoteOutput(QString)));
m_connection->runCommand(m_command);
}
MaemoSshConnection::Ptr MaemoSshRunner::connection()
{
return m_connection;
}
MaemoSshDeployer::MaemoSshDeployer(const MaemoDeviceConfig &devConf,
const QStringList &filePaths, const QStringList &targetDirs)
: MaemoSshThread(devConf), m_filePaths(filePaths), m_targetDirs(targetDirs)
{
}
void MaemoSshDeployer::runInternal()
{
m_connection = MaemoSftpConnection::create(m_devConf);
emit connectionEstablished();
connect(m_connection.data(), SIGNAL(fileCopied(QString)),
this, SIGNAL(fileCopied(QString)));
m_connection->transferFiles(m_filePaths, m_targetDirs);
}
MaemoSshConnection::Ptr MaemoSshDeployer::connection()
{
return m_connection;
}
} // namespace Internal
} // namespace Qt4ProjectManager
#endif
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** 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$
**
****************************************************************************/
#ifndef MAEMOSSHTHREAD_H
#define MAEMOSSHTHREAD_H
#include "maemodeviceconfigurations.h"
#include "maemosshconnection.h"
#include <QtCore/QStringList>
#include <QtCore/QThread>
#ifdef USE_SSH_LIB
namespace Qt4ProjectManager {
namespace Internal {
class MaemoSshThread : public QThread
{
Q_OBJECT
Q_DISABLE_COPY(MaemoSshThread)
public:
QString error() const { return m_error; }
bool hasError() const { return !m_error.isEmpty(); }
void stop();
virtual void run();
signals:
void connectionEstablished();
protected:
MaemoSshThread(const MaemoDeviceConfig &devConf);
virtual void runInternal()=0;
const MaemoDeviceConfig m_devConf;
private:
virtual MaemoSshConnection::Ptr connection()=0;
QString m_error;
};
class MaemoSshRunner : public MaemoSshThread
{
Q_OBJECT
Q_DISABLE_COPY(MaemoSshRunner)
public:
MaemoSshRunner(const MaemoDeviceConfig &devConf, const QString &command);
signals:
void remoteOutput(const QString &output);
private:
virtual MaemoSshConnection::Ptr connection();
virtual void runInternal();
const QString m_command;
MaemoInteractiveSshConnection::Ptr m_connection;
};
class MaemoSshDeployer : public MaemoSshThread
{
Q_OBJECT
Q_DISABLE_COPY(MaemoSshDeployer)
public:
MaemoSshDeployer(const MaemoDeviceConfig &devConf,
const QStringList &filePaths, const QStringList &targetDirs);
signals:
void fileCopied(const QString &filePath);
private:
virtual MaemoSshConnection::Ptr connection();
virtual void runInternal();
const QStringList m_filePaths;
const QStringList m_targetDirs;
MaemoSftpConnection::Ptr m_connection;
};
} // namespace Internal
} // namespace Qt4ProjectManager
#endif
#endif // MAEMOSSHTHREAD_H
......@@ -10,14 +10,14 @@ SUPPORT_QT_MAEMO = $$(QTCREATOR_WITH_MAEMO)
$$PWD/maemodeviceconfigurations.h \
$$PWD/maemosettingspage.h \
$$PWD/maemosshconnection.h \
$$PWD/maemosshrunner.h
$$PWD/maemosshthread.h
SOURCES += $$PWD/maemorunconfiguration.cpp \
$$PWD/maemomanager.cpp \
$$PWD/maemotoolchain.cpp \
$$PWD/maemodeviceconfigurations.cpp \
$$PWD/maemosettingspage.cpp \
$$PWD/maemosshconnection.cpp \
$$PWD/maemosshrunner.cpp
$$PWD/maemosshthread.cpp
FORMS += $$PWD/maemosettingswidget.ui
RESOURCES += $$PWD/qt-maemo.qrc
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment