forked from qt-creator/qt-creator
Maemo: Implement sftp file transfer (untested).
This commit is contained in:
@@ -47,8 +47,10 @@
|
|||||||
|
|
||||||
#include "/opt/ne7ssh/include/ne7ssh.h"
|
#include "/opt/ne7ssh/include/ne7ssh.h"
|
||||||
|
|
||||||
#include <QtCore/QMutex>
|
#include <QtCore/QStringBuilder>
|
||||||
#include <QtCore/QMutexLocker>
|
#include <QtCore/QStringList>
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -134,9 +136,12 @@ MaemoInteractiveSshConnection::Ptr MaemoInteractiveSshConnection::create(const M
|
|||||||
}
|
}
|
||||||
|
|
||||||
MaemoSftpConnection::MaemoSftpConnection(const MaemoDeviceConfig &devConf)
|
MaemoSftpConnection::MaemoSftpConnection(const MaemoDeviceConfig &devConf)
|
||||||
: MaemoSshConnection(devConf, false)
|
: MaemoSshConnection(devConf, false),
|
||||||
|
sftp(new Ne7SftpSubsystem)
|
||||||
{
|
{
|
||||||
// TODO: Initialize sftp subsystem
|
if (!ssh.initSftp(*sftp, channel()) || !sftp->setTimeout(devConf.timeout))
|
||||||
|
throw MaemoSshException(tr("Error setting up SFTP subsystem: %1")
|
||||||
|
.arg(lastError()));
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoSftpConnection::~MaemoSftpConnection()
|
MaemoSftpConnection::~MaemoSftpConnection()
|
||||||
@@ -147,7 +152,22 @@ MaemoSftpConnection::~MaemoSftpConnection()
|
|||||||
void MaemoSftpConnection::transferFiles(const QStringList &filePaths,
|
void MaemoSftpConnection::transferFiles(const QStringList &filePaths,
|
||||||
const QStringList &targetDirs)
|
const QStringList &targetDirs)
|
||||||
{
|
{
|
||||||
|
Q_ASSERT(filePaths.count() == targetDirs.count());
|
||||||
|
for (int i = 0; i < filePaths.count(); ++i) {
|
||||||
|
const QString &curFile = filePaths.at(i);
|
||||||
|
QSharedPointer<FILE> filePtr(fopen(curFile.toLatin1().data(), "rb"),
|
||||||
|
&std::fclose);
|
||||||
|
if (filePtr.isNull())
|
||||||
|
throw MaemoSshException(tr("Could not open file '%1'").arg(curFile));
|
||||||
|
const QString &targetFile
|
||||||
|
= targetDirs.at(i) % QLatin1String("/") % curFile;
|
||||||
|
if (!sftp->put(filePtr.data(), targetFile.toLatin1().data())) {
|
||||||
|
const QString &error = tr("Could not copy local file '%1' "
|
||||||
|
"to remote file '%2': %3").arg(curFile, targetFile)
|
||||||
|
.arg(lastError());
|
||||||
|
throw MaemoSshException(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MaemoSftpConnection::Ptr MaemoSftpConnection::create(const MaemoDeviceConfig &devConf)
|
MaemoSftpConnection::Ptr MaemoSftpConnection::create(const MaemoDeviceConfig &devConf)
|
||||||
@@ -155,7 +175,6 @@ MaemoSftpConnection::Ptr MaemoSftpConnection::create(const MaemoDeviceConfig &de
|
|||||||
return Ptr(new MaemoSftpConnection(devConf));
|
return Ptr(new MaemoSftpConnection(devConf));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Qt4ProjectManager
|
} // namespace Qt4ProjectManager
|
||||||
|
|
||||||
|
|||||||
@@ -45,15 +45,17 @@
|
|||||||
// #define USE_SSH_LIB
|
// #define USE_SSH_LIB
|
||||||
#ifdef USE_SSH_LIB
|
#ifdef USE_SSH_LIB
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QScopedPointer>
|
#include <QtCore/QScopedPointer>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
|
#include <QtCore/QString>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QStringList;
|
class QStringList;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class ne7ssh;
|
class ne7ssh;
|
||||||
|
class Ne7SftpSubsystem;
|
||||||
|
|
||||||
namespace Qt4ProjectManager {
|
namespace Qt4ProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -124,6 +126,8 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MaemoSftpConnection(const MaemoDeviceConfig &devConf);
|
MaemoSftpConnection(const MaemoDeviceConfig &devConf);
|
||||||
|
|
||||||
|
QScopedPointer<Ne7SftpSubsystem> sftp;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user