diff --git a/src/plugins/analyzerbase/startremotedialog.cpp b/src/plugins/analyzerbase/startremotedialog.cpp index 82724a5f001eedaf622c3b5cbf39e7ac34f334ff..7696314413d53ffb4e4557c6a96d3952584f0e75 100644 --- a/src/plugins/analyzerbase/startremotedialog.cpp +++ b/src/plugins/analyzerbase/startremotedialog.cpp @@ -31,39 +31,31 @@ #include "startremotedialog.h" #include <coreplugin/icore.h> +#include <coreplugin/id.h> +#include <projectexplorer/profilechooser.h> +#include <projectexplorer/profileinformation.h> #include <ssh/sshconnection.h> #include <utils/pathchooser.h> #include <QDialogButtonBox> #include <QFormLayout> -#include <QGroupBox> #include <QLabel> #include <QLineEdit> #include <QPushButton> #include <QSpinBox> +using namespace ProjectExplorer; +using namespace Utils; + namespace Analyzer { namespace Internal { class StartRemoteDialogPrivate { public: - QLabel *hostLabel; - QLineEdit *host; - QLabel *userLabel; - QLineEdit *user; - QLabel *portLabel; - QSpinBox *port; - QLabel *passwordLabel; - QLineEdit *password; - QLabel *keyFileLabel; - Utils::PathChooser *keyFile; - QFormLayout *formLayout; - QLabel *executableLabel; + ProfileChooser *profileChooser; QLineEdit *executable; - QLabel *argumentsLabel; QLineEdit *arguments; - QLabel *workingDirectoryLabel; QLineEdit *workingDirectory; QDialogButtonBox *buttonBox; }; @@ -77,97 +69,41 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent) setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Start Remote Analysis")); - QGroupBox *groupBox = new QGroupBox(tr("Remote"), this); - - d->host = new QLineEdit(groupBox); - d->hostLabel = new QLabel(tr("Host:"), groupBox); - - d->user = new QLineEdit(groupBox); - d->userLabel = new QLabel(tr("User:"), groupBox); - - d->port = new QSpinBox(groupBox); - d->port->setMaximum(65535); - d->port->setSingleStep(1); - d->port->setValue(22); - d->portLabel = new QLabel(tr("Port:"), groupBox); - - d->passwordLabel = new QLabel(tr("Password:"), groupBox); - d->passwordLabel->setToolTip(tr("You need to pass either a password or an SSH key.")); - - d->password = new QLineEdit(groupBox); - d->password->setEchoMode(QLineEdit::Password); - - d->keyFileLabel = new QLabel(tr("Private key:"), groupBox); - d->keyFileLabel->setToolTip(tr("You need to pass either a password or an SSH key.")); - - d->keyFile = new Utils::PathChooser(groupBox); - - QGroupBox *groupBox2 = new QGroupBox(tr("Target"), this); - - d->executable = new QLineEdit(groupBox2); - d->executableLabel = new QLabel(tr("Executable:"), groupBox2); - - d->arguments = new QLineEdit(groupBox2); - d->argumentsLabel = new QLabel(tr("Arguments:"), groupBox2); - - d->workingDirectory = new QLineEdit(groupBox2); - d->workingDirectoryLabel = new QLabel(tr("Working directory:"), groupBox2); + d->profileChooser = new ProfileChooser(this, true); + d->executable = new QLineEdit(this); + d->arguments = new QLineEdit(this); + d->workingDirectory = new QLineEdit(this); d->buttonBox = new QDialogButtonBox(this); d->buttonBox->setOrientation(Qt::Horizontal); d->buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); - QFormLayout *formLayout = new QFormLayout(groupBox); + QFormLayout *formLayout = new QFormLayout; formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - formLayout->addRow(d->hostLabel, d->host); - formLayout->addRow(d->userLabel, d->user); - formLayout->addRow(d->portLabel, d->port); - formLayout->addRow(d->passwordLabel, d->password); - formLayout->addRow(d->keyFileLabel, d->keyFile); - - QFormLayout *formLayout2 = new QFormLayout(groupBox2); - formLayout2->addRow(d->executableLabel, d->executable); - formLayout2->addRow(d->argumentsLabel, d->arguments); - formLayout2->addRow(d->workingDirectoryLabel, d->workingDirectory); + formLayout->addRow(tr("Profile:"), d->profileChooser); + formLayout->addRow(tr("Executable:"), d->executable); + formLayout->addRow(tr("Arguments:"), d->arguments); + formLayout->addRow(tr("Working directory:"), d->workingDirectory); QVBoxLayout *verticalLayout = new QVBoxLayout(this); - verticalLayout->addWidget(groupBox); - verticalLayout->addWidget(groupBox2); + verticalLayout->addLayout(formLayout); verticalLayout->addWidget(d->buttonBox); - d->keyFile->setExpectedKind(Utils::PathChooser::File); - QSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); - d->host->setText(settings->value(QLatin1String("host")).toString()); - d->port->setValue(settings->value(QLatin1String("port"), 22).toInt()); - d->user->setText(settings->value(QLatin1String("user"), qgetenv("USER")).toString()); - d->keyFile->setPath(settings->value(QLatin1String("keyFile")).toString()); + QString profile = settings->value(QLatin1String("profile")).toString(); + d->profileChooser->setCurrentProfileId(Core::Id(profile)); d->executable->setText(settings->value(QLatin1String("executable")).toString()); d->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString()); d->arguments->setText(settings->value(QLatin1String("arguments")).toString()); settings->endGroup(); - connect(d->host, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(d->port, SIGNAL(valueChanged(int)), - this, SLOT(validate())); - connect(d->password, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(d->keyFile, SIGNAL(changed(QString)), - this, SLOT(validate())); - - connect(d->executable, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(d->workingDirectory, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(d->arguments, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - - connect(d->buttonBox, SIGNAL(accepted()), - this, SLOT(accept())); - connect(d->buttonBox, SIGNAL(rejected()), - this, SLOT(reject())); + connect(d->profileChooser, SIGNAL(activated(int)), SLOT(validate())); + connect(d->executable, SIGNAL(textChanged(QString)), SLOT(validate())); + connect(d->workingDirectory, SIGNAL(textChanged(QString)), SLOT(validate())); + connect(d->arguments, SIGNAL(textChanged(QString)), SLOT(validate())); + connect(d->buttonBox, SIGNAL(accepted()), SLOT(accept())); + connect(d->buttonBox, SIGNAL(rejected()), SLOT(reject())); validate(); } @@ -181,10 +117,7 @@ void StartRemoteDialog::accept() { QSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); - settings->setValue(QLatin1String("host"), d->host->text()); - settings->setValue(QLatin1String("port"), d->port->value()); - settings->setValue(QLatin1String("user"), d->user->text()); - settings->setValue(QLatin1String("keyFile"), d->keyFile->path()); + settings->setValue(QLatin1String("profile"), d->profileChooser->currentProfileId().toString()); settings->setValue(QLatin1String("executable"), d->executable->text()); settings->setValue(QLatin1String("workingDirectory"), d->workingDirectory->text()); settings->setValue(QLatin1String("arguments"), d->arguments->text()); @@ -195,27 +128,15 @@ void StartRemoteDialog::accept() void StartRemoteDialog::validate() { - bool valid = !d->host->text().isEmpty() && !d->user->text().isEmpty() - && !d->executable->text().isEmpty(); - valid = valid && (!d->password->text().isEmpty() || d->keyFile->isValid()); + bool valid = !d->executable->text().isEmpty(); d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); } QSsh::SshConnectionParameters StartRemoteDialog::sshParams() const { - QSsh::SshConnectionParameters params; - params.host = d->host->text(); - params.userName = d->user->text(); - if (d->keyFile->isValid()) { - params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByKey; - params.privateKeyFile = d->keyFile->path(); - } else { - params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByPassword; - params.password = d->password->text(); - } - params.port = d->port->value(); - params.timeout = 10; - return params; + Profile *profile = d->profileChooser->currentProfile(); + IDevice::ConstPtr device = DeviceProfileInformation::device(profile); + return device->sshParameters(); } QString StartRemoteDialog::executable() const diff --git a/src/plugins/valgrind/memcheck/memcheckrunner.cpp b/src/plugins/valgrind/memcheck/memcheckrunner.cpp index ee5cb0174caa0bdc0dc31d863b78677c8d32eb4c..7867ff7bcefebf04e0b038862b5806770bf6fa2c 100644 --- a/src/plugins/valgrind/memcheck/memcheckrunner.cpp +++ b/src/plugins/valgrind/memcheck/memcheckrunner.cpp @@ -120,70 +120,14 @@ bool MemcheckRunner::start() setValgrindArguments(memcheckArguments); } + if (startMode() == Analyzer::StartRemote) { QTC_ASSERT(d->parser, return false); - QList<QHostAddress> possibleHostAddresses; - //NOTE: ::allAddresses does not seem to work for usb interfaces... - foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) { - foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) { - const QHostAddress addr = entry.ip(); - if (addr.toString() != "127.0.0.1" - && addr.toString() != "0:0:0:0:0:0:0:1") - { - possibleHostAddresses << addr; - break; - } - } - } - - QHostAddress hostAddr; - - if (possibleHostAddresses.isEmpty()) { - emit processErrorReceived(tr("No network interface found for remote analysis."), - QProcess::FailedToStart); - return false; - } else if (possibleHostAddresses.size() > 1) { - QDialog dlg; - dlg.setWindowTitle(tr("Select Network Interface")); - QVBoxLayout *layout = new QVBoxLayout; - QLabel *description = new QLabel; - description->setWordWrap(true); - description->setText(tr("More than one network interface was found on your machine. Please select which one you want to use for remote analysis.")); - layout->addWidget(description); - QListWidget *list = new QListWidget; - foreach (const QHostAddress &address, possibleHostAddresses) - list->addItem(address.toString()); - - list->setSelectionMode(QAbstractItemView::SingleSelection); - list->setCurrentRow(0); - layout->addWidget(list); - - QDialogButtonBox *buttons = new QDialogButtonBox; - buttons->addButton(QDialogButtonBox::Ok); - buttons->addButton(QDialogButtonBox::Cancel); - connect(buttons, SIGNAL(accepted()), - &dlg, SLOT(accept())); - connect(buttons, SIGNAL(rejected()), - &dlg, SLOT(reject())); - layout->addWidget(buttons); - - dlg.setLayout(layout); - if (dlg.exec() != QDialog::Accepted) { - emit processErrorReceived(tr("No Network Interface was chosen for remote analysis"), QProcess::FailedToStart); - return false; - } - - QTC_ASSERT(list->currentRow() >= 0, return false); - QTC_ASSERT(list->currentRow() < possibleHostAddresses.size(), return false); - hostAddr = possibleHostAddresses.at(list->currentRow()); - } else { - hostAddr = possibleHostAddresses.first(); - } - - QString ip = hostAddr.toString(); + QString ip = connectionParameters().host; QTC_ASSERT(!ip.isEmpty(), return false); + QHostAddress hostAddr(ip); bool check = d->xmlServer.listen(hostAddr); QTC_ASSERT(check, return false); d->xmlServer.setMaxPendingConnections(1);