diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp index 109469e5c60..7098157e89d 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp @@ -42,7 +42,7 @@ #include #include "maemodeviceconfigurations.h" -#include "maemosshrunner.h" +#include "maemosshthread.h" #include "ui_maemosettingswidget.h" #include "maemosettingspage.h" diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.h index 1c395c30d65..17e218910ea 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconnection.h @@ -42,7 +42,6 @@ #ifndef MAEMOSSHCONNECTION_H #define MAEMOSSHCONNECTION_H -// #define USE_SSH_LIB #ifdef USE_SSH_LIB #include @@ -75,6 +74,8 @@ class MaemoSshConnection : public QObject { Q_DISABLE_COPY(MaemoSshConnection) public: + typedef QSharedPointer Ptr; + void stop(); virtual ~MaemoSshConnection(); diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp index 551be4654eb..63dd33cdd60 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp @@ -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 diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h index ebffe6250a3..9e2a4d5eb90 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.h @@ -45,34 +45,14 @@ #include "maemodeviceconfigurations.h" #include "maemosshconnection.h" -#ifdef USE_SSH_LIB - #include #include +#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 diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp new file mode 100644 index 00000000000..ba54dc0f6c5 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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 diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h new file mode 100644 index 00000000000..aad0b5d29dd --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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 +#include + +#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 diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 4af4d47e53f..49eda97133b 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -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 }