diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp new file mode 100644 index 00000000000..f0f09675d8c --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.cpp @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $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 "maemosshconfigdialog.h" +#include "maemosshthread.h" + +#include +#include + +#include + +using namespace Qt4ProjectManager::Internal; + +MaemoSshConfigDialog::MaemoSshConfigDialog(QWidget *parent) + : QDialog(parent) + , m_keyDeployer(0) +{ + m_ui.setupUi(this); + + const QLatin1String root("MaemoSsh/"); + QSettings *settings = Core::ICore::instance()->settings(); + m_ui.useKeyFromPath->setChecked(settings->value(root + QLatin1String("userKey"), + false).toBool()); + m_ui.keyFileLineEdit->setExpectedKind(Utils::PathChooser::File); + m_ui.keyFileLineEdit->setPath(settings->value(root + QLatin1String("keyPath"), + QDir::toNativeSeparators(QDir::homePath() + QLatin1String("/.ssh/id_rsa.pub"))) + .toString()); + + connect(m_ui.deployButton, SIGNAL(clicked()), this, SLOT(deployKey())); + connect(m_ui.generateButton, SIGNAL(clicked()), this, SLOT(generateSshKey())); +} + +MaemoSshConfigDialog::~MaemoSshConfigDialog() +{ +} + +void MaemoSshConfigDialog::generateSshKey() +{ + if (!m_ui.keyFileLineEdit->isValid()) { + ne7ssh ssh; + ssh.generateKeyPair("rsa", "test", "id_rsa", "id_rsa.pub"); + } else { + m_ui.infoLabel->setText("An public key has been created already."); + } +} + +void MaemoSshConfigDialog::deployKey() +{ + if (m_keyDeployer) + return; + + if (m_ui.keyFileLineEdit->validatePath(m_ui.keyFileLineEdit->path())) { + m_ui.deployButton->disconnect(); + //SshDeploySpec deploySpec(keyFile, homeDirOnDevice(currentConfig().uname) + // + QLatin1String("/.ssh/authorized_keys"), true); + //m_keyDeployer = new MaemoSshDeployer(currentConfig(), QList() + // << deploySpec); + //connect(m_keyDeployer, SIGNAL(finished()), this, + // SLOT(handleDeployThreadFinished())); + if (m_keyDeployer) { + m_keyDeployer->start(); + m_ui.deployButton->setText(tr("Stop deploying")); + connect(m_ui.deployButton, SIGNAL(clicked()), this, SLOT(stopDeploying())); + } + } else { + m_ui.infoLabel->setText("The public key path is invalid."); + } +} + +void MaemoSshConfigDialog::handleDeployThreadFinished() +{ + if (!m_keyDeployer) + return; + + if (m_keyDeployer->hasError()) { + m_ui.infoLabel->setText(tr("Key deployment failed: %1") + .arg(m_keyDeployer->error())); + } else { + m_ui.infoLabel->setText(tr("Key was successfully deployed.")); + } + stopDeploying(); +} + +void MaemoSshConfigDialog::stopDeploying() +{ + if (m_keyDeployer) { + m_ui.deployButton->disconnect(); + const bool buttonWasEnabled = m_ui.deployButton->isEnabled(); + m_keyDeployer->disconnect(); + m_keyDeployer->stop(); + delete m_keyDeployer; + m_keyDeployer = 0; + m_ui.deployButton->setText(tr("Deploy Public Key")); + connect(m_ui.deployButton, SIGNAL(clicked()), this, SLOT(deployKey())); + m_ui.deployButton->setEnabled(buttonWasEnabled); + } +} diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.h b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.h new file mode 100644 index 00000000000..aa8284a7a5b --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.h @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $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$ +** +****************************************************************************/ + +#ifndef MAEMOSSHCONFIGDIALOG_H +#define MAEMOSSHCONFIGDIALOG_H + +#include "ui_maemosshconfigdialog.h" + +#include + +namespace Qt4ProjectManager { + namespace Internal { + +class MaemoSshDeployer; + +class MaemoSshConfigDialog : public QDialog +{ + Q_OBJECT +public: + MaemoSshConfigDialog(QWidget *parent = 0); + ~MaemoSshConfigDialog(); + +private slots: + void generateSshKey(); + void deployKey(); + void handleDeployThreadFinished(); + void stopDeploying(); + +private: + Ui::MaemoSshConfigDialog m_ui; + MaemoSshDeployer *m_keyDeployer; +}; + + } // Qt4ProjectManager +} // Internal + +#endif // MAEMOSSHCONFIGDIALOG_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.ui b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.ui new file mode 100644 index 00000000000..8f80c258c6b --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshconfigdialog.ui @@ -0,0 +1,221 @@ + + + MaemoSshConfigDialog + + + true + + + + 0 + 0 + 387 + 128 + + + + + 0 + 0 + + + + SSH Key Configuration + + + + + + + 0 + 0 + + + + Use key from location: + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + false + + + + 0 + 0 + + + + Private key file: + + + + + + + false + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 0 + + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + + + Generate SSH Key + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Deploy Public Key + + + + + + + Close + + + + + + + + + + Utils::PathChooser + QWidget +
utils/pathchooser.h
+ 1 + + editingFinished() + browsingFinished() + +
+
+ + closeButton + deployButton + generateButton + useKeyFromPath + + + + + closeButton + clicked() + MaemoSshConfigDialog + close() + + + 351 + 96 + + + 381 + 107 + + + + + useKeyFromPath + toggled(bool) + keyLabel + setEnabled(bool) + + + 83 + 17 + + + 73 + 42 + + + + + useKeyFromPath + toggled(bool) + keyFileLineEdit + setEnabled(bool) + + + 193 + 17 + + + 246 + 42 + + + + +