RemoteLinux: Rename MaemoPackageUploader.

There is no Maemo dependency in this class.
Also use better assertions.

Change-Id: I28f055e35f17ed41535fd76a45fe1a06b9567953
Reviewed-on: http://codereview.qt.nokia.com/1868
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
Christian Kandeler
2011-07-20 10:57:51 +02:00
parent b778692510
commit a6cc06415e
4 changed files with 34 additions and 33 deletions

View File

@@ -33,7 +33,7 @@
#include "deployablefile.h" #include "deployablefile.h"
#include "linuxdeviceconfiguration.h" #include "linuxdeviceconfiguration.h"
#include "maemopackageuploader.h" #include "packageuploader.h"
#include "remotelinuxpackageinstaller.h" #include "remotelinuxpackageinstaller.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -52,13 +52,13 @@ class AbstractUploadAndInstallPackageServicePrivate
{ {
public: public:
AbstractUploadAndInstallPackageServicePrivate() AbstractUploadAndInstallPackageServicePrivate()
: state(Inactive), uploader(new MaemoPackageUploader) : state(Inactive), uploader(new PackageUploader)
{ {
} }
~AbstractUploadAndInstallPackageServicePrivate() { delete uploader; } ~AbstractUploadAndInstallPackageServicePrivate() { delete uploader; }
State state; State state;
MaemoPackageUploader * const uploader; PackageUploader * const uploader;
QString packageFilePath; QString packageFilePath;
}; };

View File

@@ -30,33 +30,31 @@
** **
**************************************************************************/ **************************************************************************/
#include "maemopackageuploader.h" #include "packageuploader.h"
#include "maemoglobal.h"
#include <utils/qtcassert.h>
#include <utils/ssh/sftpchannel.h> #include <utils/ssh/sftpchannel.h>
#include <utils/ssh/sshconnection.h> #include <utils/ssh/sshconnection.h>
#define ASSERT_STATE(state) ASSERT_STATE_GENERIC(State, state, m_state)
using namespace Utils; using namespace Utils;
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
MaemoPackageUploader::MaemoPackageUploader(QObject *parent) : PackageUploader::PackageUploader(QObject *parent) :
QObject(parent), m_state(Inactive) QObject(parent), m_state(Inactive)
{ {
} }
MaemoPackageUploader::~MaemoPackageUploader() PackageUploader::~PackageUploader()
{ {
} }
void MaemoPackageUploader::uploadPackage(const SshConnection::Ptr &connection, void PackageUploader::uploadPackage(const SshConnection::Ptr &connection,
const QString &localFilePath, const QString &remoteFilePath) const QString &localFilePath, const QString &remoteFilePath)
{ {
ASSERT_STATE(Inactive); QTC_ASSERT(m_state == Inactive, return);
setState(InitializingSftp); setState(InitializingSftp);
emit progress(tr("Preparing SFTP connection...")); emit progress(tr("Preparing SFTP connection..."));
@@ -75,14 +73,14 @@ void MaemoPackageUploader::uploadPackage(const SshConnection::Ptr &connection,
m_uploader->initialize(); m_uploader->initialize();
} }
void MaemoPackageUploader::cancelUpload() void PackageUploader::cancelUpload()
{ {
ASSERT_STATE(QList<State>() << InitializingSftp << Uploading); QTC_ASSERT(m_state == InitializingSftp || m_state == Uploading, return);
cleanup(); cleanup();
} }
void MaemoPackageUploader::handleConnectionFailure() void PackageUploader::handleConnectionFailure()
{ {
if (m_state == Inactive) if (m_state == Inactive)
return; return;
@@ -92,9 +90,10 @@ void MaemoPackageUploader::handleConnectionFailure()
emit uploadFinished(tr("Connection failed: %1").arg(errorMsg)); emit uploadFinished(tr("Connection failed: %1").arg(errorMsg));
} }
void MaemoPackageUploader::handleSftpChannelInitializationFailed(const QString &errorMsg) void PackageUploader::handleSftpChannelInitializationFailed(const QString &errorMsg)
{ {
ASSERT_STATE(QList<State>() << InitializingSftp << Inactive); QTC_ASSERT(m_state == InitializingSftp || m_state == Inactive, return);
if (m_state == Inactive) if (m_state == Inactive)
return; return;
@@ -102,9 +101,10 @@ void MaemoPackageUploader::handleSftpChannelInitializationFailed(const QString &
emit uploadFinished(tr("SFTP error: %1").arg(errorMsg)); emit uploadFinished(tr("SFTP error: %1").arg(errorMsg));
} }
void MaemoPackageUploader::handleSftpChannelInitialized() void PackageUploader::handleSftpChannelInitialized()
{ {
ASSERT_STATE(QList<State>() << InitializingSftp << Inactive); QTC_ASSERT(m_state == InitializingSftp || m_state == Inactive, return);
if (m_state == Inactive) if (m_state == Inactive)
return; return;
@@ -119,9 +119,10 @@ void MaemoPackageUploader::handleSftpChannelInitialized()
} }
} }
void MaemoPackageUploader::handleSftpJobFinished(SftpJobId, const QString &errorMsg) void PackageUploader::handleSftpJobFinished(SftpJobId, const QString &errorMsg)
{ {
ASSERT_STATE(QList<State>() << Uploading << Inactive); QTC_ASSERT(m_state == Uploading || m_state == Inactive, return);
if (m_state == Inactive) if (m_state == Inactive)
return; return;
@@ -132,13 +133,13 @@ void MaemoPackageUploader::handleSftpJobFinished(SftpJobId, const QString &error
cleanup(); cleanup();
} }
void MaemoPackageUploader::cleanup() void PackageUploader::cleanup()
{ {
m_uploader->closeChannel(); m_uploader->closeChannel();
setState(Inactive); setState(Inactive);
} }
void MaemoPackageUploader::setState(State newState) void PackageUploader::setState(State newState)
{ {
if (m_state == newState) if (m_state == newState)
return; return;

View File

@@ -30,8 +30,8 @@
** **
**************************************************************************/ **************************************************************************/
#ifndef MAEMOPACKAGEUPLOADER_H #ifndef PACKAGEUPLOADER_H
#define MAEMOPACKAGEUPLOADER_H #define PACKAGEUPLOADER_H
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QSharedPointer> #include <QtCore/QSharedPointer>
@@ -47,12 +47,12 @@ class SshConnection;
namespace RemoteLinux { namespace RemoteLinux {
namespace Internal { namespace Internal {
class MaemoPackageUploader : public QObject class PackageUploader : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit MaemoPackageUploader(QObject *parent = 0); explicit PackageUploader(QObject *parent = 0);
~MaemoPackageUploader(); ~PackageUploader();
// Connection has to be established already. // Connection has to be established already.
void uploadPackage(const QSharedPointer<Utils::SshConnection> &connection, void uploadPackage(const QSharedPointer<Utils::SshConnection> &connection,
@@ -85,4 +85,4 @@ private:
} // namespace Internal } // namespace Internal
} // namespace RemoteLinux } // namespace RemoteLinux
#endif // MAEMOPACKAGEUPLOADER_H #endif // PACKAGEUPLOADER_H

View File

@@ -54,7 +54,6 @@ HEADERS += \
maemodeployconfigurationwidget.h \ maemodeployconfigurationwidget.h \
maemoinstalltosysrootstep.h \ maemoinstalltosysrootstep.h \
maemodeploymentmounter.h \ maemodeploymentmounter.h \
maemopackageuploader.h \
maemopackageinstaller.h \ maemopackageinstaller.h \
maemoremotecopyfacility.h \ maemoremotecopyfacility.h \
maemoqtversionfactory.h \ maemoqtversionfactory.h \
@@ -92,7 +91,8 @@ HEADERS += \
genericremotelinuxdeploystepfactory.h \ genericremotelinuxdeploystepfactory.h \
abstractpackagingstep.h \ abstractpackagingstep.h \
tarpackagecreationstep.h \ tarpackagecreationstep.h \
remotelinuxpackageinstaller.h remotelinuxpackageinstaller.h \
packageuploader.h
SOURCES += \ SOURCES += \
remotelinuxplugin.cpp \ remotelinuxplugin.cpp \
@@ -141,7 +141,6 @@ SOURCES += \
maemodeployconfigurationwidget.cpp \ maemodeployconfigurationwidget.cpp \
maemoinstalltosysrootstep.cpp \ maemoinstalltosysrootstep.cpp \
maemodeploymentmounter.cpp \ maemodeploymentmounter.cpp \
maemopackageuploader.cpp \
maemopackageinstaller.cpp \ maemopackageinstaller.cpp \
maemoremotecopyfacility.cpp \ maemoremotecopyfacility.cpp \
maemoqtversionfactory.cpp \ maemoqtversionfactory.cpp \
@@ -178,7 +177,8 @@ SOURCES += \
genericremotelinuxdeploystepfactory.cpp \ genericremotelinuxdeploystepfactory.cpp \
abstractpackagingstep.cpp \ abstractpackagingstep.cpp \
tarpackagecreationstep.cpp \ tarpackagecreationstep.cpp \
remotelinuxpackageinstaller.cpp remotelinuxpackageinstaller.cpp \
packageuploader.cpp
FORMS += \ FORMS += \
maemoconfigtestdialog.ui \ maemoconfigtestdialog.ui \