Commit dd6966b2 authored by ck's avatar ck
Browse files

Maemo: Do the bind() for remote mounts on the device.

This makes us more independent of the developer PC's firewall setting.

Reviewed-by: kh1
parent 34c1c10c
......@@ -72,7 +72,6 @@ static const QLatin1String MountPortsKey(PREFIX ".MountPorts");
static const QLatin1String BaseEnvironmentBaseKey(PREFIX ".BaseEnvironmentBase");
static const QLatin1String UserEnvironmentChangesKey(PREFIX ".UserEnvironmentChanges");
static const QLatin1String UseRemoteGdbKey(PREFIX ".UseRemoteGdb");
static const QLatin1String GdbMountPortKey(PREFIX ".GdbMountPort");
} // namespace Internal
} // namespace Qt4ProjectManager
......
......@@ -292,7 +292,7 @@ QString MaemoDebugSupport::gdbServerPort(const MaemoRunConfiguration *rc,
// something in the config dialog, but we will make sure we use
// the right port from the information file.
return devConf.type == MaemoDeviceConfig::Physical
? QString::number(devConf.gdbServerPort)
? QString::number(devConf.debuggingPort)
: rc->runtimeGdbServerPort();
}
......
......@@ -56,7 +56,7 @@ namespace {
const QLatin1String TypeKey("Type");
const QLatin1String HostKey("Host");
const QLatin1String SshPortKey("SshPort");
const QLatin1String GdbServerPortKey("GdbServerPort");
const QLatin1String DebuggingPortKey("GdbServerPort");
const QLatin1String UserNameKey("Uname");
const QLatin1String AuthKey("Authentication");
const QLatin1String KeyFileKey("KeyFile");
......@@ -94,7 +94,7 @@ private:
MaemoDeviceConfig::MaemoDeviceConfig(const QString &name, MaemoDeviceConfig::DeviceType devType)
: name(name),
type(devType),
gdbServerPort(defaultGdbServerPort(type)),
debuggingPort(defaultDebuggingPort(type)),
internalId(MaemoDeviceConfigurations::instance().m_nextId++)
{
server.host = defaultHost(type);
......@@ -109,7 +109,7 @@ MaemoDeviceConfig::MaemoDeviceConfig(const QSettings &settings,
quint64 &nextId)
: name(settings.value(NameKey).toString()),
type(static_cast<DeviceType>(settings.value(TypeKey, DefaultDeviceType).toInt())),
gdbServerPort(settings.value(GdbServerPortKey, defaultGdbServerPort(type)).toInt()),
debuggingPort(settings.value(DebuggingPortKey, defaultDebuggingPort(type)).toInt()),
internalId(settings.value(InternalIdKey, nextId).toULongLong())
{
if (internalId == nextId)
......@@ -136,7 +136,7 @@ int MaemoDeviceConfig::defaultSshPort(DeviceType type) const
return type == Physical ? DefaultSshPortHW : DefaultSshPortSim;
}
int MaemoDeviceConfig::defaultGdbServerPort(DeviceType type) const
int MaemoDeviceConfig::defaultDebuggingPort(DeviceType type) const
{
return type == Physical ? DefaultGdbServerPortHW : DefaultGdbServerPortSim;
}
......@@ -157,7 +157,7 @@ void MaemoDeviceConfig::save(QSettings &settings) const
settings.setValue(TypeKey, type);
settings.setValue(HostKey, server.host);
settings.setValue(SshPortKey, server.port);
settings.setValue(GdbServerPortKey, gdbServerPort);
settings.setValue(DebuggingPortKey, debuggingPort);
settings.setValue(UserNameKey, server.uname);
settings.setValue(AuthKey, server.authType);
settings.setValue(PasswordKey, server.pwd);
......
......@@ -63,12 +63,12 @@ public:
Core::SshConnectionParameters server;
QString name;
DeviceType type;
int gdbServerPort;
int debuggingPort;
quint64 internalId;
private:
int defaultSshPort(DeviceType type) const;
int defaultGdbServerPort(DeviceType type) const;
int defaultDebuggingPort(DeviceType type) const;
QString defaultHost(DeviceType type) const;
};
......
......@@ -39,7 +39,7 @@ const QLatin1String InvalidMountPoint("/");
} // anonymous namespace
MaemoRemoteMountsModel::MountSpecification::MountSpecification(const QString &l,
const QString &r, int p) : localDir(l), remoteMountPoint(r), port(p) {}
const QString &r, int p) : localDir(l), remoteMountPoint(r), remotePort(p) {}
bool MaemoRemoteMountsModel::MountSpecification::isValid() const
{
......@@ -54,10 +54,10 @@ MaemoRemoteMountsModel::MaemoRemoteMountsModel(QObject *parent) :
void MaemoRemoteMountsModel::addMountSpecification(const QString &localDir)
{
int port = 10000;
int port = 10100;
int i = 0;
while (i < rowCount()) {
if (mountSpecificationAt(i).port == port) {
if (mountSpecificationAt(i).remotePort == port) {
++port;
i = 0;
} else {
......@@ -114,7 +114,7 @@ QVariantMap MaemoRemoteMountsModel::toMap() const
foreach (const MountSpecification &mountSpec, m_mountSpecs) {
localDirsList << mountSpec.localDir;
remoteMountPointsList << mountSpec.remoteMountPoint;
mountPortsList << mountSpec.port;
mountPortsList << mountSpec.remotePort;
}
map.insert(ExportedLocalDirsKey, localDirsList);
map.insert(RemoteMountPointsKey, remoteMountPointsList);
......@@ -157,7 +157,7 @@ QVariant MaemoRemoteMountsModel::headerData(int section,
switch (section) {
case LocalDirRow: return tr("Local directory");
case RemoteMountPointRow: return tr("Remote mount point");
case PortRow: return tr("Local port");
case PortRow: return tr("Remote port");
default: return QVariant();
}
}
......@@ -179,7 +179,7 @@ QVariant MaemoRemoteMountsModel::data(const QModelIndex &index, int role) const
break;
case PortRow:
if (role == Qt::DisplayRole || role == Qt::EditRole)
return mountSpec.port;
return mountSpec.remotePort;
break;
}
return QVariant();
......@@ -208,10 +208,10 @@ bool MaemoRemoteMountsModel::setData(const QModelIndex &index,
case PortRow: {
const int newPort = value.toInt();
for (int i = 0; i < m_mountSpecs.count(); ++i) {
if (i != index.row() && m_mountSpecs.at(i).port == newPort)
if (i != index.row() && m_mountSpecs.at(i).remotePort == newPort)
return false;
}
m_mountSpecs[index.row()].port = newPort;
m_mountSpecs[index.row()].remotePort = newPort;
set = true;
break;
}
......
......@@ -48,7 +48,7 @@ public:
QString localDir;
QString remoteMountPoint;
int port;
int remotePort;
};
explicit MaemoRemoteMountsModel(QObject *parent = 0);
......
......@@ -56,8 +56,7 @@ namespace Qt4ProjectManager {
namespace Internal {
namespace {
const bool DefaultUseRemoteGdbValue = false; // TODO: Make true once utfs-server works on Windows.
const int DefaultGdbMountPort = 10100;
const bool DefaultUseRemoteGdbValue = false; // TODO: Make true once it works reliably on Windows
} // anonymous namespace
using namespace ProjectExplorer;
......@@ -67,7 +66,6 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
: RunConfiguration(parent, QLatin1String(MAEMO_RC_ID))
, m_proFilePath(proFilePath)
, m_useRemoteGdb(DefaultUseRemoteGdbValue)
, m_gdbMountPort(DefaultGdbMountPort)
, m_baseEnvironmentBase(SystemEnvironmentBase)
{
init();
......@@ -80,7 +78,6 @@ MaemoRunConfiguration::MaemoRunConfiguration(Qt4Target *parent,
, m_gdbPath(source->m_gdbPath)
, m_arguments(source->m_arguments)
, m_useRemoteGdb(source->useRemoteGdb())
, m_gdbMountPort(source->gdbMountPort())
, m_baseEnvironmentBase(source->m_baseEnvironmentBase)
, m_systemEnvironment(source->m_systemEnvironment)
, m_userEnvironmentChanges(source->m_userEnvironmentChanges)
......@@ -150,7 +147,6 @@ QVariantMap MaemoRunConfiguration::toMap() const
const QDir dir = QDir(target()->project()->projectDirectory());
map.insert(ProFileKey, dir.relativeFilePath(m_proFilePath));
map.insert(UseRemoteGdbKey, useRemoteGdb());
map.insert(GdbMountPortKey, gdbMountPort());
map.insert(BaseEnvironmentBaseKey, m_baseEnvironmentBase);
map.insert(UserEnvironmentChangesKey,
ProjectExplorer::EnvironmentItem::toStringList(m_userEnvironmentChanges));
......@@ -168,7 +164,6 @@ bool MaemoRunConfiguration::fromMap(const QVariantMap &map)
const QDir dir = QDir(target()->project()->projectDirectory());
m_proFilePath = dir.filePath(map.value(ProFileKey).toString());
m_useRemoteGdb = map.value(UseRemoteGdbKey, DefaultUseRemoteGdbValue).toBool();
m_gdbMountPort = map.value(GdbMountPortKey, DefaultGdbMountPort).toInt();
m_userEnvironmentChanges =
ProjectExplorer::EnvironmentItem::fromStringList(map.value(UserEnvironmentChangesKey)
.toStringList());
......
......@@ -96,8 +96,6 @@ public:
QString runtimeGdbServerPort() const;
bool useRemoteGdb() const { return m_useRemoteGdb; }
void setUseRemoteGdb(bool useRemoteGdb) { m_useRemoteGdb = useRemoteGdb; }
int gdbMountPort() const { return m_gdbMountPort; }
void setGdbMountPort(int port) { m_gdbMountPort = port; }
const QString gdbCmd() const;
const QString dumperLib() const;
......@@ -144,7 +142,6 @@ private:
MaemoRemoteMountsModel *m_remoteMounts;
QStringList m_arguments;
bool m_useRemoteGdb;
int m_gdbMountPort;
BaseEnvironmentBase m_baseEnvironmentBase;
ProjectExplorer::Environment m_systemEnvironment;
......
......@@ -56,7 +56,6 @@
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QRadioButton>
#include <QtGui/QSpinBox>
#include <QtGui/QTableView>
#include <QtGui/QToolButton>
......@@ -132,9 +131,7 @@ void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
m_debugDetailsContainer = new Utils::DetailsWidget(this);
QWidget *debugWidget = new QWidget;
m_debugDetailsContainer->setWidget(debugWidget);
#ifndef Q_OS_WIN
mainLayout->addWidget(m_debugDetailsContainer);
#endif
QFormLayout *debugLayout = new QFormLayout(debugWidget);
QHBoxLayout *debugRadioButtonsLayout = new QHBoxLayout;
debugLayout->addRow(debugRadioButtonsLayout);
......@@ -147,17 +144,6 @@ void MaemoRunConfigurationWidget::addDebuggingWidgets(QVBoxLayout *mainLayout)
gdbServerButton->setChecked(!gdbButton->isChecked());
connect(gdbButton, SIGNAL(toggled(bool)), this,
SLOT(handleDebuggingTypeChanged(bool)));
QHBoxLayout *spinBoxLayout = new QHBoxLayout;
m_gdbMountPortSpinBox = new QSpinBox;
m_gdbMountPortSpinBox->setMinimum(1024);
m_gdbMountPortSpinBox->setMaximum((1 << 16) - 1);
spinBoxLayout->addWidget(m_gdbMountPortSpinBox);
spinBoxLayout->addStretch(1);
debugLayout->addRow(tr("Local port for mounting the project directory:"),
spinBoxLayout);
m_gdbMountPortSpinBox->setValue(m_runConfiguration->gdbMountPort());
connect(m_gdbMountPortSpinBox, SIGNAL(valueChanged(int)), this,
SLOT(handleGdbMountPortChanged(int)));
handleDebuggingTypeChanged(gdbButton->isChecked());
}
......@@ -167,9 +153,7 @@ void MaemoRunConfigurationWidget::addMountWidgets(QVBoxLayout *mainLayout)
m_mountDetailsContainer = new Utils::DetailsWidget(this);
QWidget *mountViewWidget = new QWidget;
m_mountDetailsContainer->setWidget(mountViewWidget);
#ifndef Q_OS_WIN
mainLayout->addWidget(m_mountDetailsContainer);
#endif
QVBoxLayout *mountViewLayout = new QVBoxLayout(mountViewWidget);
QHBoxLayout *tableLayout = new QHBoxLayout;
mountViewLayout->addLayout(tableLayout);
......@@ -339,12 +323,6 @@ void MaemoRunConfigurationWidget::handleDebuggingTypeChanged(bool useGdb)
const QString detailsText = useGdb ? tr("Use gdb") : tr("Use gdbserver");
m_debugDetailsContainer->setSummaryText(tr("<b>Debugging details:</b> ")
+ detailsText);
m_gdbMountPortSpinBox->setEnabled(useGdb);
}
void MaemoRunConfigurationWidget::handleGdbMountPortChanged(int port)
{
m_runConfiguration->setGdbMountPort(port);
}
void MaemoRunConfigurationWidget::fetchEnvironment()
......
......@@ -43,7 +43,6 @@ class QLabel;
class QLineEdit;
class QModelIndex;
class QPushButton;
class QSpinBox;
class QTableView;
class QToolButton;
class QVBoxLayout;
......@@ -81,7 +80,6 @@ private slots:
void changeLocalMountDir(const QModelIndex &index);
void enableOrDisableRemoveMountSpecButton();
void handleDebuggingTypeChanged(bool useGdb);
void handleGdbMountPortChanged(int port);
void fetchEnvironment();
void fetchEnvironmentFinished();
void userChangesEdited();
......@@ -101,7 +99,6 @@ private:
QLineEdit *m_argsLineEdit;
QLabel *m_executableLabel;
QComboBox *m_devConfBox;
QSpinBox *m_gdbMountPortSpinBox;
QTableView *m_mountView;
QToolButton *m_removeMountButton;
Utils::DetailsWidget *m_mountDetailsContainer;
......
......@@ -114,7 +114,7 @@ QString MaemoSettingsWidget::searchKeywords() const
{
QString rc;
QTextStream(&rc) << m_ui->configurationLabel->text()
<< ' ' << m_ui->gdbServerLabel->text()
<< ' ' << m_ui->debuggingPortLabel->text()
<< ' ' << m_ui->sshPortLabel->text()
<< ' ' << m_ui->keyButton->text()
<< ' ' << m_ui->passwordButton->text()
......@@ -213,7 +213,7 @@ void MaemoSettingsWidget::fillInValues()
m_ui->nameLineEdit->setText(currentConfig().name);
m_ui->hostLineEdit->setText(currentConfig().server.host);
m_ui->sshPortSpinBox->setValue(currentConfig().server.port);
m_ui->gdbServerPortSpinBox->setValue(currentConfig().gdbServerPort);
m_ui->gdbServerPortSpinBox->setValue(currentConfig().debuggingPort);
m_ui->timeoutSpinBox->setValue(currentConfig().server.timeout);
m_ui->userLineEdit->setText(currentConfig().server.uname);
m_ui->pwdLineEdit->setText(currentConfig().server.pwd);
......@@ -295,7 +295,7 @@ void MaemoSettingsWidget::sshPortEditingFinished()
void MaemoSettingsWidget::gdbServerPortEditingFinished()
{
currentConfig().gdbServerPort = m_ui->gdbServerPortSpinBox->value();
currentConfig().debuggingPort = m_ui->gdbServerPortSpinBox->value();
}
void MaemoSettingsWidget::timeoutEditingFinished()
......
......@@ -184,7 +184,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="gdbServerLabel">
<widget class="QLabel" name="debuggingPortLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -192,7 +192,7 @@
</sizepolicy>
</property>
<property name="text">
<string>Gdb server:</string>
<string>Debugging:</string>
</property>
</widget>
</item>
......
......@@ -87,7 +87,7 @@ void MaemoSshRunner::start()
m_mountSpecs << MaemoRemoteMountsModel::MountSpecification(
m_runConfig->localDirToMountForRemoteGdb(),
MaemoGlobal::remoteProjectSourcesMountPoint(),
m_runConfig->gdbMountPort());
m_devConfig.debuggingPort);
}
m_stop = false;
......@@ -252,10 +252,10 @@ void MaemoSshRunner::handleUploadFinished(Core::SftpJobId jobId,
return;
}
mount();
startUtfsClients();
}
void MaemoSshRunner::mount()
void MaemoSshRunner::startUtfsClients()
{
const QString chmodFuse
= MaemoGlobal::remoteSudo() + QLatin1String(" chmod a+r+w /dev/fuse");
......@@ -266,43 +266,34 @@ void MaemoSshRunner::mount()
for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec
= m_mountSpecs.at(i);
QProcess * const utfsServerProc = new QProcess(this);
connect(utfsServerProc, SIGNAL(readyReadStandardError()), this,
SLOT(handleUtfsServerErrorOutput()));
const QString port = QString::number(mountSpec.port);
const QString localSecretOpt = QLatin1String("-l");
const QString remoteSecretOpt = QLatin1String("-r");
const QStringList utfsServerArgs = QStringList() << localSecretOpt
<< port << remoteSecretOpt << port << QLatin1String("-b") << port
<< mountSpec.localDir;
utfsServerProc->start(utfsServer(), utfsServerArgs);
if (!utfsServerProc->waitForStarted()) {
delete utfsServerProc;
emit error(tr("Could not start UTFS server: %1")
.arg(utfsServerProc->errorString()));
return;
}
m_utfsServers << utfsServerProc;
const QString port = QString::number(mountSpec.remotePort);
const QString mkdir = QString::fromLocal8Bit("%1 mkdir -p %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
const QString chmod = QString::fromLocal8Bit("%1 chmod a+r+w+x %2")
.arg(MaemoGlobal::remoteSudo(), mountSpec.remoteMountPoint);
const QString utfsClient
= QString::fromLocal8Bit("%1 -l %2 -r %2 -c `echo $SSH_CLIENT|cut -d ' ' -f 1`:%2 %4")
= QString::fromLocal8Bit("%1 -l %2 -r %2 -b %2 %4")
.arg(utfsClientOnDevice()).arg(port)
.arg(mountSpec.remoteMountPoint);
remoteCall += andOp + mkdir + andOp + chmod + andOp + utfsClient;
}
m_mountProcess = m_connection->createRemoteProcess(remoteCall.toUtf8());
connect(m_mountProcess.data(), SIGNAL(started()), this,
SLOT(handleUtfsClientsStarted()));
connect(m_mountProcess.data(), SIGNAL(closed(int)), this,
SLOT(handleMountProcessFinished(int)));
SLOT(handleUtfsClientsFinished(int)));
connect(m_mountProcess.data(), SIGNAL(errorOutputAvailable(QByteArray)),
this, SIGNAL(remoteErrorOutput(QByteArray)));
m_mountProcess->start();
}
void MaemoSshRunner::handleMountProcessFinished(int exitStatus)
void MaemoSshRunner::handleUtfsClientsStarted()
{
startUtfsServers();
}
void MaemoSshRunner::handleUtfsClientsFinished(int exitStatus)
{
if (m_stop)
return;
......@@ -316,11 +307,8 @@ void MaemoSshRunner::handleMountProcessFinished(int exitStatus)
.arg(m_mountProcess->errorString()));
break;
case SshRemoteProcess::ExitedNormally:
if (m_mountProcess->exitCode() == 0) {
emit readyForExecution();
} else {
if (m_mountProcess->exitCode() != 0)
emit error(tr("Could not execute mount request."));
}
break;
default:
Q_ASSERT_X(false, Q_FUNC_INFO,
......@@ -328,6 +316,34 @@ void MaemoSshRunner::handleMountProcessFinished(int exitStatus)
}
}
void MaemoSshRunner::startUtfsServers()
{
for (int i = 0; i < m_mountSpecs.count(); ++i) {
const MaemoRemoteMountsModel::MountSpecification &mountSpec
= m_mountSpecs.at(i);
QProcess * const utfsServerProc = new QProcess(this);
connect(utfsServerProc, SIGNAL(readyReadStandardError()), this,
SLOT(handleUtfsServerErrorOutput()));
const QString port = QString::number(mountSpec.remotePort);
const QString localSecretOpt = QLatin1String("-l");
const QString remoteSecretOpt = QLatin1String("-r");
const QStringList utfsServerArgs = QStringList() << localSecretOpt
<< port << remoteSecretOpt << port << QLatin1String("-c")
<< (m_devConfig.server.host + QLatin1Char(':') + port)
<< mountSpec.localDir;
utfsServerProc->start(utfsServer(), utfsServerArgs);
if (!utfsServerProc->waitForStarted()) {
delete utfsServerProc;
emit error(tr("Could not start UTFS server: %1")
.arg(utfsServerProc->errorString()));
return;
}
m_utfsServers << utfsServerProc;
}
emit readyForExecution();
}
void MaemoSshRunner::startExecution(const QByteArray &remoteCall)
{
if (m_runConfig->remoteExecutableFilePath().isEmpty()) {
......
......@@ -90,13 +90,15 @@ private slots:
void handleUploaderInitialized();
void handleUploaderInitializationFailed(const QString &reason);
void handleUploadFinished(Core::SftpJobId jobId, const QString &error);
void handleMountProcessFinished(int exitStatus);
void handleUtfsClientsStarted();
void handleUtfsClientsFinished(int exitStatus);
void handleUtfsServerErrorOutput();
private:
void cleanup(bool initialCleanup);
void deployUtfsClient();
void mount();
void startUtfsClients();
void startUtfsServers();
QString utfsClientOnDevice() const;
QString utfsServer() const;
......
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