Commit af647447 authored by ck's avatar ck

Maemo: Add option to create directory on device in deployment API.

parent 6b1a98cd
......@@ -43,8 +43,9 @@
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <debugger/debuggermanager.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/toolchain.h>
#include <utils/qtcassert.h>
#include <QtCore/QDir>
......@@ -55,7 +56,9 @@
namespace Qt4ProjectManager {
namespace Internal {
#ifndef USE_SSH_LIB
using ProjectExplorer::Environment;
#endif // USE_SSH_LIB
using ProjectExplorer::RunConfiguration;
using ProjectExplorer::ToolChain;
......@@ -115,14 +118,16 @@ void AbstractMaemoRunControl::deploy()
{
#ifdef USE_SSH_LIB
if (!deployables.isEmpty()) {
QList<SshDeploySpec> deploySpecs;
QStringList files;
QStringList targetDirs;
foreach (const Deployable &deployable, deployables) {
files << deployable.dir + QDir::separator() + deployable.fileName;
targetDirs << remoteDir();
const QString srcFilePath
= deployable.dir % QDir::separator() % deployable.fileName;
files << srcFilePath;
deploySpecs << SshDeploySpec(srcFilePath, remoteDir());
}
emit addToOutputWindow(this, tr("Files to deploy: %1.").arg(files.join(" ")));
sshDeployer.reset(new MaemoSshDeployer(devConfig, files, targetDirs));
sshDeployer.reset(new MaemoSshDeployer(devConfig, deploySpecs));
connect(sshDeployer.data(), SIGNAL(finished()),
this, SLOT(deployProcessFinished()));
connect(sshDeployer.data(), SIGNAL(fileCopied(QString)),
......
......@@ -49,7 +49,6 @@
#include <QtCore/QFileInfo>
#include <QtCore/QStringBuilder>
#include <QtCore/QStringList>
#include <cstdio>
#include <cstring>
......@@ -60,6 +59,8 @@ namespace {
ne7ssh ssh;
}
// TODO: Which encoding to use for file names? Unicode? Latin1? ASCII?
MaemoSshConnection::MaemoSshConnection(const MaemoDeviceConfig &devConf,
bool shell)
: m_channel(-1), m_stopRequested(false)
......@@ -155,17 +156,22 @@ MaemoSftpConnection::~MaemoSftpConnection()
}
void MaemoSftpConnection::transferFiles(const QStringList &filePaths,
const QStringList &targetDirs)
void MaemoSftpConnection::transferFiles(const QList<SshDeploySpec> &deploySpecs)
{
Q_ASSERT(filePaths.count() == targetDirs.count());
for (int i = 0; i < filePaths.count(); ++i) {
const QString &curFile = filePaths.at(i);
for (int i = 0; i < deploySpecs.count(); ++i) {
const SshDeploySpec &deploySpec = deploySpecs.at(i);
const QString &curFile = deploySpec.srcFilePath();
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("/")
// TODO: Is the mkdir() method recursive? If not, we have to
// introduce a recursive version ourselves.
if (deploySpec.mkdir())
sftp->mkdir(deploySpec.targetDir().toLatin1().data());
const QString &targetFile = deploySpec.targetDir() % QLatin1String("/")
% QFileInfo(curFile).fileName();
if (!sftp->put(filePtr.data(), targetFile.toLatin1().data())) {
const QString &error = tr("Could not copy local file '%1' "
......
......@@ -49,11 +49,6 @@
#include <QtCore/QSharedPointer>
#include <QtCore/QString>
QT_BEGIN_NAMESPACE
class QStringList;
QT_END_NAMESPACE
class ne7ssh;
class Ne7SftpSubsystem;
namespace Qt4ProjectManager {
......@@ -110,6 +105,26 @@ private:
const char *m_prompt;
};
class SshDeploySpec
{
public:
SshDeploySpec(const QString &srcFilePath, const QString &targetDir,
bool mkdir = false)
: m_srcFilePath(srcFilePath), m_targetDir(targetDir), m_mkdir(mkdir)
{
}
QString srcFilePath() const { return m_srcFilePath; }
QString targetDir() const { return m_targetDir; }
bool mkdir() const { return m_mkdir; }
private:
QString m_srcFilePath;
QString m_targetDir;
bool m_mkdir;
};
class MaemoSftpConnection : public MaemoSshConnection
{
Q_OBJECT
......@@ -118,8 +133,7 @@ public:
typedef QSharedPointer<MaemoSftpConnection> Ptr;
static Ptr create(const MaemoDeviceConfig &devConf);
void transferFiles(const QStringList &filePaths,
const QStringList &targetDirs);
void transferFiles(const QList<SshDeploySpec> &deploySpecs);
virtual ~MaemoSftpConnection();
signals:
......
......@@ -104,8 +104,8 @@ void MaemoSshRunner::runInternal()
}
MaemoSshDeployer::MaemoSshDeployer(const MaemoDeviceConfig &devConf,
const QStringList &filePaths, const QStringList &targetDirs)
: MaemoSshThread(devConf), m_filePaths(filePaths), m_targetDirs(targetDirs)
const QList<SshDeploySpec> &deploySpecs)
: MaemoSshThread(devConf), m_deploySpecs(deploySpecs)
{
}
......@@ -117,7 +117,7 @@ void MaemoSshDeployer::runInternal()
return;
connect(connection.data(), SIGNAL(fileCopied(QString)),
this, SIGNAL(fileCopied(QString)));
connection->transferFiles(m_filePaths, m_targetDirs);
connection->transferFiles(m_deploySpecs);
}
} // namespace Internal
......
......@@ -45,8 +45,8 @@
#include "maemodeviceconfigurations.h"
#include "maemosshconnection.h"
#include <QtCore/QList>
#include <QtCore/QMutex>
#include <QtCore/QStringList>
#include <QtCore/QThread>
#ifdef USE_SSH_LIB
......@@ -104,7 +104,7 @@ class MaemoSshDeployer : public MaemoSshThread
Q_DISABLE_COPY(MaemoSshDeployer)
public:
MaemoSshDeployer(const MaemoDeviceConfig &devConf,
const QStringList &filePaths, const QStringList &targetDirs);
const QList<SshDeploySpec> &deploySpecs);
signals:
void fileCopied(const QString &filePath);
......@@ -112,8 +112,7 @@ signals:
private:
virtual void runInternal();
const QStringList m_filePaths;
const QStringList m_targetDirs;
const QList<SshDeploySpec> m_deploySpecs;
};
} // namespace Internal
......
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