2009-11-27 16:40:07 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
** All rights reserved.
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** This file is part of the Qt Assistant of the Qt Toolkit.
|
|
|
|
|
**
|
|
|
|
|
** $QT_BEGIN_LICENSE:LGPL$
|
|
|
|
|
** No Commercial Usage
|
|
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <qt4projectmanager/qt4projectmanagerconstants.h>
|
|
|
|
|
|
|
|
|
|
#include "maemodeviceconfigurations.h"
|
2009-12-23 10:53:57 +01:00
|
|
|
#include "maemosshrunner.h"
|
2009-11-27 16:40:07 +01:00
|
|
|
|
|
|
|
|
#include "ui_maemosettingswidget.h"
|
|
|
|
|
#include "maemosettingspage.h"
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
#include <QtCore/QRegExp>
|
2009-11-30 14:09:08 +01:00
|
|
|
#include <QtGui/QIntValidator>
|
|
|
|
|
|
2009-11-27 16:40:07 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2009-11-27 17:30:09 +01:00
|
|
|
#define PAGE_ID "ZZ.Maemo Device Configurations"
|
|
|
|
|
#define PAGE_ID_TR "Maemo Device Configurations"
|
2009-11-27 16:40:07 +01:00
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
bool configNameExists(const QList<MaemoDeviceConfig> &devConfs,
|
2009-11-30 14:09:08 +01:00
|
|
|
const QString &name)
|
|
|
|
|
{
|
|
|
|
|
return std::find_if(devConfs.constBegin(), devConfs.constEnd(),
|
2009-12-23 10:53:57 +01:00
|
|
|
DevConfNameMatcher(name)) != devConfs.constEnd();
|
2009-11-30 14:09:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class PortAndTimeoutValidator : public QIntValidator
|
2009-11-27 16:40:07 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2009-11-30 14:09:08 +01:00
|
|
|
PortAndTimeoutValidator() : QIntValidator(0, SHRT_MAX, 0)
|
2009-11-27 16:40:07 +01:00
|
|
|
{
|
|
|
|
|
}
|
2009-11-30 14:09:08 +01:00
|
|
|
|
|
|
|
|
void setValue(int oldValue) { m_oldValue = oldValue; }
|
|
|
|
|
|
|
|
|
|
virtual void fixup(QString &input) const
|
|
|
|
|
{
|
|
|
|
|
int dummy = 0;
|
|
|
|
|
if (validate(input, dummy) != Acceptable)
|
|
|
|
|
input = QString::number(m_oldValue);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-27 16:40:07 +01:00
|
|
|
private:
|
2009-11-30 14:09:08 +01:00
|
|
|
int m_oldValue;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class NameValidator : public QValidator
|
|
|
|
|
{
|
|
|
|
|
public:
|
2009-12-23 10:53:57 +01:00
|
|
|
NameValidator(const QList<MaemoDeviceConfig> &devConfs)
|
2009-11-30 14:09:08 +01:00
|
|
|
: m_devConfs(devConfs)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setName(const QString &name) { m_oldName = name; }
|
|
|
|
|
|
|
|
|
|
virtual State validate(QString &input, int & /* pos */) const
|
|
|
|
|
{
|
|
|
|
|
if (input.trimmed().isEmpty()
|
|
|
|
|
|| (input != m_oldName && configNameExists(m_devConfs, input)))
|
|
|
|
|
return Intermediate;
|
|
|
|
|
return Acceptable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void fixup(QString &input) const
|
|
|
|
|
{
|
|
|
|
|
int dummy = 0;
|
|
|
|
|
if (validate(input, dummy) != Acceptable)
|
|
|
|
|
input = m_oldName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QString m_oldName;
|
2009-12-23 10:53:57 +01:00
|
|
|
const QList<MaemoDeviceConfig> &m_devConfs;
|
2009-11-27 16:40:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MaemoSettingsWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
MaemoSettingsWidget(QWidget *parent);
|
2009-11-30 14:09:08 +01:00
|
|
|
~MaemoSettingsWidget();
|
2009-11-27 16:40:07 +01:00
|
|
|
void saveSettings();
|
2009-11-30 14:09:08 +01:00
|
|
|
private slots:
|
|
|
|
|
void selectionChanged();
|
|
|
|
|
void addConfig();
|
|
|
|
|
void deleteConfig();
|
|
|
|
|
void configNameEditingFinished();
|
|
|
|
|
void deviceTypeChanged();
|
2009-12-01 16:22:50 +01:00
|
|
|
void authenticationTypeChanged();
|
2009-11-30 14:09:08 +01:00
|
|
|
void hostNameEditingFinished();
|
|
|
|
|
void portEditingFinished();
|
|
|
|
|
void timeoutEditingFinished();
|
|
|
|
|
void userNameEditingFinished();
|
|
|
|
|
void passwordEditingFinished();
|
2009-12-01 16:22:50 +01:00
|
|
|
void keyFileEditingFinished();
|
2009-12-23 10:53:57 +01:00
|
|
|
void testConfig();
|
|
|
|
|
void enableTestStop();
|
|
|
|
|
void processSshOutput(const QString &data);
|
|
|
|
|
void handleSshFinished();
|
|
|
|
|
void stopConfigTest();
|
2009-11-30 14:09:08 +01:00
|
|
|
|
2009-11-27 16:40:07 +01:00
|
|
|
private:
|
|
|
|
|
void initGui();
|
2009-12-23 10:53:57 +01:00
|
|
|
void display(const MaemoDeviceConfig &devConfig);
|
|
|
|
|
MaemoDeviceConfig ¤tConfig();
|
2009-11-30 14:09:08 +01:00
|
|
|
void setPortOrTimeout(const QLineEdit *lineEdit, int &confVal,
|
|
|
|
|
PortAndTimeoutValidator &validator);
|
|
|
|
|
void clearDetails();
|
2009-12-23 10:53:57 +01:00
|
|
|
QString parseTestOutput();
|
2009-11-27 16:40:07 +01:00
|
|
|
|
|
|
|
|
Ui_maemoSettingsWidget *m_ui;
|
2009-12-23 10:53:57 +01:00
|
|
|
QList<MaemoDeviceConfig> m_devConfs;
|
2009-11-30 14:09:08 +01:00
|
|
|
PortAndTimeoutValidator m_portValidator;
|
|
|
|
|
PortAndTimeoutValidator m_timeoutValidator;
|
|
|
|
|
NameValidator m_nameValidator;
|
2009-12-23 11:57:56 +01:00
|
|
|
#ifdef USE_SSH_LIB
|
2009-12-23 10:53:57 +01:00
|
|
|
MaemoSshRunner *m_deviceTester;
|
|
|
|
|
#endif
|
|
|
|
|
QString m_deviceTestOutput;
|
|
|
|
|
QString m_defaultTestOutput;
|
2009-11-27 16:40:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MaemoSettingsPage::MaemoSettingsPage(QObject *parent)
|
2009-11-30 14:09:08 +01:00
|
|
|
: Core::IOptionsPage(parent)
|
2009-11-27 16:40:07 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoSettingsPage::~MaemoSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoSettingsPage::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(PAGE_ID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoSettingsPage::trName() const
|
|
|
|
|
{
|
2009-11-27 17:30:09 +01:00
|
|
|
return tr(PAGE_ID_TR);
|
2009-11-27 16:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoSettingsPage::category() const
|
|
|
|
|
{
|
2009-11-27 17:30:09 +01:00
|
|
|
return QLatin1String(Constants::QT_SETTINGS_CATEGORY);
|
2009-11-27 16:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoSettingsPage::trCategory() const
|
|
|
|
|
{
|
2009-11-27 17:30:09 +01:00
|
|
|
return QCoreApplication::translate("Qt4ProjectManager",
|
|
|
|
|
Constants::QT_SETTINGS_CATEGORY);
|
2009-11-27 16:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *MaemoSettingsPage::createPage(QWidget *parent)
|
|
|
|
|
{
|
|
|
|
|
m_widget = new MaemoSettingsWidget(parent);
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsPage::apply()
|
|
|
|
|
{
|
|
|
|
|
m_widget->saveSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsPage::finish()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MaemoSettingsWidget::MaemoSettingsWidget(QWidget *parent)
|
|
|
|
|
: QWidget(parent),
|
|
|
|
|
m_ui(new Ui_maemoSettingsWidget),
|
2009-11-30 14:09:08 +01:00
|
|
|
m_devConfs(MaemoDeviceConfigurations::instance().devConfigs()),
|
|
|
|
|
m_nameValidator(m_devConfs)
|
2009-12-23 11:57:56 +01:00
|
|
|
#ifdef USE_SSH_LIB
|
2009-12-23 10:53:57 +01:00
|
|
|
, m_deviceTester(0)
|
|
|
|
|
#endif
|
2009-11-27 16:40:07 +01:00
|
|
|
|
|
|
|
|
{
|
|
|
|
|
initGui();
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-30 14:09:08 +01:00
|
|
|
MaemoSettingsWidget::~MaemoSettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-27 16:40:07 +01:00
|
|
|
void MaemoSettingsWidget::initGui()
|
|
|
|
|
{
|
|
|
|
|
m_ui->setupUi(this);
|
2009-11-30 14:09:08 +01:00
|
|
|
m_ui->nameLineEdit->setValidator(&m_nameValidator);
|
|
|
|
|
m_ui->portLineEdit->setValidator(&m_portValidator);
|
2009-12-03 12:37:42 +01:00
|
|
|
m_ui->timeoutLineEdit->setValidator(&m_timeoutValidator);
|
|
|
|
|
m_ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File);
|
2009-12-23 10:53:57 +01:00
|
|
|
foreach(const MaemoDeviceConfig &devConf, m_devConfs)
|
2009-11-27 16:40:07 +01:00
|
|
|
m_ui->configListWidget->addItem(devConf.name);
|
2009-12-23 10:53:57 +01:00
|
|
|
m_defaultTestOutput = m_ui->testResultEdit->toPlainText();
|
2009-12-10 17:34:22 +01:00
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
#ifndef USE_SSH_LIB // Password authentication does not currently work due to ssh/scp issues.
|
|
|
|
|
m_ui->testConfigButton->hide();
|
|
|
|
|
m_ui->testResultEdit->hide();
|
2009-12-10 17:34:22 +01:00
|
|
|
m_ui->authTypeLabel->hide();
|
|
|
|
|
m_ui->authTypeButtonsWidget->hide();
|
|
|
|
|
m_ui->passwordLabel->hide();
|
|
|
|
|
m_ui->pwdLineEdit->hide();
|
|
|
|
|
#endif
|
2009-11-27 16:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::addConfig()
|
|
|
|
|
{
|
|
|
|
|
QLatin1String prefix("New Device Configuration ");
|
|
|
|
|
int suffix = 1;
|
|
|
|
|
QString newName;
|
|
|
|
|
bool isUnique = false;
|
|
|
|
|
do {
|
|
|
|
|
newName = prefix + QString::number(suffix++);
|
2009-11-30 14:09:08 +01:00
|
|
|
isUnique = !configNameExists(m_devConfs, newName);
|
2009-11-27 16:40:07 +01:00
|
|
|
} while (!isUnique);
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
m_devConfs.append(MaemoDeviceConfig(newName));
|
2009-11-27 16:40:07 +01:00
|
|
|
m_ui->configListWidget->addItem(newName);
|
2009-11-30 14:09:08 +01:00
|
|
|
m_ui->configListWidget->setCurrentRow(m_ui->configListWidget->count() - 1);
|
|
|
|
|
m_ui->nameLineEdit->selectAll();
|
|
|
|
|
m_ui->removeConfigButton->setEnabled(true);
|
|
|
|
|
m_ui->nameLineEdit->setFocus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::deleteConfig()
|
|
|
|
|
{
|
|
|
|
|
const QList<QListWidgetItem *> &selectedItems =
|
|
|
|
|
m_ui->configListWidget->selectedItems();
|
|
|
|
|
if (selectedItems.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
QListWidgetItem *item = selectedItems.first();
|
|
|
|
|
const int selectedRow = m_ui->configListWidget->row(item);
|
|
|
|
|
m_devConfs.removeAt(selectedRow);
|
|
|
|
|
disconnect(m_ui->configListWidget, SIGNAL(itemSelectionChanged()), 0, 0);
|
|
|
|
|
delete m_ui->configListWidget->takeItem(selectedRow);
|
|
|
|
|
connect(m_ui->configListWidget, SIGNAL(itemSelectionChanged()),
|
|
|
|
|
this, SLOT(selectionChanged()));
|
|
|
|
|
Q_ASSERT(m_ui->configListWidget->count() == m_devConfs.count());
|
|
|
|
|
selectionChanged();
|
2009-11-27 16:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
void MaemoSettingsWidget::display(const MaemoDeviceConfig &devConfig)
|
2009-11-27 16:40:07 +01:00
|
|
|
{
|
|
|
|
|
m_ui->nameLineEdit->setText(devConfig.name);
|
2009-12-23 10:53:57 +01:00
|
|
|
if (devConfig.type == MaemoDeviceConfig::Physical)
|
2009-12-01 14:04:25 +01:00
|
|
|
m_ui->deviceButton->setChecked(true);
|
2009-11-27 16:40:07 +01:00
|
|
|
else
|
2009-12-01 14:04:25 +01:00
|
|
|
m_ui->simulatorButton->setChecked(true);
|
2009-12-23 10:53:57 +01:00
|
|
|
if (devConfig.authentication == MaemoDeviceConfig::Password)
|
2009-12-01 16:22:50 +01:00
|
|
|
m_ui->passwordButton->setChecked(true);
|
|
|
|
|
else
|
|
|
|
|
m_ui->keyButton->setChecked(true);
|
2009-11-27 16:40:07 +01:00
|
|
|
m_ui->hostLineEdit->setText(devConfig.host);
|
|
|
|
|
m_ui->portLineEdit->setText(QString::number(devConfig.port));
|
|
|
|
|
m_ui->timeoutLineEdit->setText(QString::number(devConfig.timeout));
|
|
|
|
|
m_ui->userLineEdit->setText(devConfig.uname);
|
|
|
|
|
m_ui->pwdLineEdit->setText(devConfig.pwd);
|
2009-12-03 12:37:42 +01:00
|
|
|
m_ui->keyFileLineEdit->setPath(devConfig.keyFile);
|
2009-11-27 16:40:07 +01:00
|
|
|
m_ui->detailsWidget->setEnabled(true);
|
2009-11-30 14:09:08 +01:00
|
|
|
m_nameValidator.setName(devConfig.name);
|
|
|
|
|
m_portValidator.setValue(devConfig.port);
|
|
|
|
|
m_timeoutValidator.setValue(devConfig.timeout);
|
|
|
|
|
m_ui->detailsWidget->setEnabled(true);
|
2009-11-27 16:40:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::saveSettings()
|
|
|
|
|
{
|
|
|
|
|
MaemoDeviceConfigurations::instance().setDevConfigs(m_devConfs);
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
MaemoDeviceConfig &MaemoSettingsWidget::currentConfig()
|
2009-11-30 14:09:08 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(m_ui->configListWidget->count() == m_devConfs.count());
|
|
|
|
|
const QList<QListWidgetItem *> &selectedItems =
|
|
|
|
|
m_ui->configListWidget->selectedItems();
|
|
|
|
|
Q_ASSERT(selectedItems.count() == 1);
|
|
|
|
|
const int selectedRow = m_ui->configListWidget->row(selectedItems.first());
|
|
|
|
|
Q_ASSERT(selectedRow < m_devConfs.count());
|
|
|
|
|
return m_devConfs[selectedRow];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::configNameEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
const QString &newName = m_ui->nameLineEdit->text();
|
|
|
|
|
currentConfig().name = newName;
|
|
|
|
|
m_nameValidator.setName(newName);
|
|
|
|
|
m_ui->configListWidget->currentItem()->setText(newName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::deviceTypeChanged()
|
|
|
|
|
{
|
|
|
|
|
currentConfig().type =
|
|
|
|
|
m_ui->deviceButton->isChecked()
|
2009-12-23 10:53:57 +01:00
|
|
|
? MaemoDeviceConfig::Physical
|
|
|
|
|
: MaemoDeviceConfig::Simulator;
|
2009-11-30 14:09:08 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-01 16:22:50 +01:00
|
|
|
void MaemoSettingsWidget::authenticationTypeChanged()
|
|
|
|
|
{
|
|
|
|
|
const bool usePassword = m_ui->passwordButton->isChecked();
|
|
|
|
|
currentConfig().authentication = usePassword
|
2009-12-23 10:53:57 +01:00
|
|
|
? MaemoDeviceConfig::Password
|
|
|
|
|
: MaemoDeviceConfig::Key;
|
2009-12-01 16:22:50 +01:00
|
|
|
m_ui->pwdLineEdit->setEnabled(usePassword);
|
|
|
|
|
m_ui->passwordLabel->setEnabled(usePassword);
|
|
|
|
|
m_ui->keyFileLineEdit->setEnabled(!usePassword);
|
|
|
|
|
m_ui->keyLabel->setEnabled(!usePassword);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-30 14:09:08 +01:00
|
|
|
void MaemoSettingsWidget::hostNameEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
currentConfig().host = m_ui->hostLineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::portEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
setPortOrTimeout(m_ui->portLineEdit, currentConfig().port, m_portValidator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::timeoutEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
setPortOrTimeout(m_ui->timeoutLineEdit, currentConfig().timeout,
|
|
|
|
|
m_timeoutValidator);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::setPortOrTimeout(const QLineEdit *lineEdit,
|
|
|
|
|
int &confVal, PortAndTimeoutValidator &validator)
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
confVal = lineEdit->text().toInt(&ok);
|
|
|
|
|
Q_ASSERT(ok);
|
|
|
|
|
validator.setValue(confVal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::userNameEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
currentConfig().uname = m_ui->userLineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::passwordEditingFinished()
|
|
|
|
|
{
|
|
|
|
|
currentConfig().pwd = m_ui->pwdLineEdit->text();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-01 16:22:50 +01:00
|
|
|
void MaemoSettingsWidget::keyFileEditingFinished()
|
|
|
|
|
{
|
2009-12-03 12:37:42 +01:00
|
|
|
currentConfig().keyFile = m_ui->keyFileLineEdit->path();
|
2009-12-01 16:22:50 +01:00
|
|
|
}
|
|
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
void MaemoSettingsWidget::testConfig()
|
|
|
|
|
{
|
2009-12-23 11:57:56 +01:00
|
|
|
#ifdef USE_SSH_LIB
|
2009-12-23 10:53:57 +01:00
|
|
|
qDebug("Oh yes, this config will be tested!");
|
|
|
|
|
if (m_deviceTester)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
m_ui->testResultEdit->setPlainText(m_defaultTestOutput);
|
|
|
|
|
QLatin1String sysInfoCmd("uname -rsm");
|
|
|
|
|
QLatin1String qtInfoCmd("dpkg -l |grep libqt "
|
|
|
|
|
"|sed 's/[[:space:]][[:space:]]*/ /g' "
|
|
|
|
|
"|cut -d ' ' -f 2,3 |sed 's/~.*//g'");
|
|
|
|
|
QString command(sysInfoCmd + " && " + qtInfoCmd);
|
|
|
|
|
m_deviceTester = new MaemoSshRunner(currentConfig(), command);
|
|
|
|
|
connect(m_deviceTester, SIGNAL(connectionEstablished()),
|
|
|
|
|
this, SLOT(enableTestStop()));
|
|
|
|
|
connect(m_deviceTester, SIGNAL(remoteOutput(QString)),
|
|
|
|
|
this, SLOT(processSshOutput(QString)));
|
|
|
|
|
connect(m_deviceTester, SIGNAL(finished()),
|
|
|
|
|
this, SLOT(handleSshFinished()));
|
|
|
|
|
m_deviceTester->start();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::enableTestStop()
|
|
|
|
|
{
|
|
|
|
|
m_ui->testConfigButton->disconnect();
|
|
|
|
|
m_ui->testConfigButton->setText(tr("Stop test"));
|
|
|
|
|
connect(m_ui->testConfigButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(stopConfigTest()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::processSshOutput(const QString &data)
|
|
|
|
|
{
|
|
|
|
|
qDebug("%s", qPrintable(data));
|
|
|
|
|
m_deviceTestOutput.append(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::handleSshFinished()
|
|
|
|
|
{
|
2009-12-23 11:57:56 +01:00
|
|
|
#ifdef USE_SSH_LIB
|
2009-12-23 10:53:57 +01:00
|
|
|
qDebug("================> %s", Q_FUNC_INFO);
|
|
|
|
|
if (!m_deviceTester)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QString output;
|
|
|
|
|
if (m_deviceTester->hasError()) {
|
|
|
|
|
output = tr("Device configuration test failed:\n");
|
|
|
|
|
output.append(m_deviceTester->error());
|
|
|
|
|
} else {
|
|
|
|
|
output = parseTestOutput();
|
|
|
|
|
}
|
|
|
|
|
m_ui->testResultEdit->setPlainText(output);
|
|
|
|
|
stopConfigTest();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::stopConfigTest()
|
|
|
|
|
{
|
2009-12-23 11:57:56 +01:00
|
|
|
#ifdef USE_SSH_LIB
|
2009-12-23 10:53:57 +01:00
|
|
|
qDebug("================> %s", Q_FUNC_INFO);
|
|
|
|
|
if (m_deviceTester) {
|
|
|
|
|
qDebug("Actually doing something");
|
|
|
|
|
m_deviceTester->disconnect();
|
|
|
|
|
const bool buttonWasEnabled = m_ui->testConfigButton->isEnabled();
|
|
|
|
|
m_ui->testConfigButton->setEnabled(false);
|
|
|
|
|
m_deviceTester->stop();
|
|
|
|
|
delete m_deviceTester;
|
|
|
|
|
m_deviceTester = 0;
|
|
|
|
|
m_deviceTestOutput.clear();
|
|
|
|
|
m_ui->testConfigButton->setText(tr("Test"));
|
|
|
|
|
m_ui->testConfigButton->disconnect();
|
|
|
|
|
connect(m_ui->testConfigButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(testConfig()));
|
|
|
|
|
m_ui->testConfigButton->setEnabled(buttonWasEnabled);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString MaemoSettingsWidget::parseTestOutput()
|
|
|
|
|
{
|
|
|
|
|
QString output;
|
|
|
|
|
const QRegExp unamePattern(QLatin1String("Linux (\\S+)\\s(\\S+)"));
|
|
|
|
|
int index = unamePattern.indexIn(m_deviceTestOutput);
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
output = tr("Device configuration test failed: Unexpected output:\n");
|
|
|
|
|
output.append(m_deviceTestOutput);
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
output = tr("Hardware architecture: %1\n").arg(unamePattern.cap(2));
|
|
|
|
|
output.append(tr("Kernel version: %1\n").arg(unamePattern.cap(1)));
|
|
|
|
|
output.prepend(tr("Device configuration successful.\n"));
|
|
|
|
|
const QRegExp dkpgPattern(QLatin1String("libqt\\S+ \\d\\.\\d\\.\\d"));
|
|
|
|
|
index = dkpgPattern.indexIn(m_deviceTestOutput);
|
|
|
|
|
if (index == -1) {
|
|
|
|
|
output.append("No Qt packages installed.");
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
output.append("List of installed Qt packages:\n");
|
|
|
|
|
do {
|
|
|
|
|
output.append(QLatin1String("\t") + dkpgPattern.cap(0)
|
|
|
|
|
+ QLatin1String("\n"));
|
|
|
|
|
index = dkpgPattern.indexIn(m_deviceTestOutput, index + 1);
|
|
|
|
|
} while (index != -1);
|
|
|
|
|
return output;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-30 14:09:08 +01:00
|
|
|
void MaemoSettingsWidget::selectionChanged()
|
|
|
|
|
{
|
|
|
|
|
const QList<QListWidgetItem *> &selectedItems =
|
|
|
|
|
m_ui->configListWidget->selectedItems();
|
|
|
|
|
Q_ASSERT(selectedItems.count() <= 1);
|
2009-12-23 10:53:57 +01:00
|
|
|
stopConfigTest();
|
|
|
|
|
m_ui->testResultEdit->setPlainText(m_defaultTestOutput);
|
2009-11-30 14:09:08 +01:00
|
|
|
if (selectedItems.isEmpty()) {
|
|
|
|
|
m_ui->removeConfigButton->setEnabled(false);
|
2009-12-23 10:53:57 +01:00
|
|
|
m_ui->testConfigButton->setEnabled(false);
|
2009-11-30 14:09:08 +01:00
|
|
|
clearDetails();
|
|
|
|
|
m_ui->detailsWidget->setEnabled(false);
|
|
|
|
|
} else {
|
|
|
|
|
m_ui->removeConfigButton->setEnabled(true);
|
2009-12-23 10:53:57 +01:00
|
|
|
m_ui->testConfigButton->setEnabled(true);
|
2009-11-30 14:09:08 +01:00
|
|
|
display(currentConfig());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MaemoSettingsWidget::clearDetails()
|
|
|
|
|
{
|
|
|
|
|
m_ui->nameLineEdit->clear();
|
|
|
|
|
m_ui->hostLineEdit->clear();
|
|
|
|
|
m_ui->portLineEdit->clear();
|
|
|
|
|
m_ui->timeoutLineEdit->clear();
|
|
|
|
|
m_ui->userLineEdit->clear();
|
|
|
|
|
m_ui->pwdLineEdit->clear();
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-27 16:40:07 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qt4ProjectManager
|
|
|
|
|
|
|
|
|
|
#include "maemosettingspage.moc"
|