| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | /**************************************************************************
 | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** This file is part of Qt Creator | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-01-26 18:33:46 +01:00
										 |  |  | ** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2011-11-02 15:59:12 +01:00
										 |  |  | ** Contact: Nokia Corporation (qt-info@nokia.com) | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** 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. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Other Usage | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** Alternatively, this file may be used in accordance with the terms and | 
					
						
							|  |  |  | ** conditions contained in a signed written agreement between you and Nokia. | 
					
						
							|  |  |  | ** | 
					
						
							|  |  |  | ** If you have questions regarding the use of this file, please contact | 
					
						
							| 
									
										
										
										
											2011-11-02 15:59:12 +01:00
										 |  |  | ** Nokia at qt-info@nokia.com. | 
					
						
							| 
									
										
										
										
											2011-05-06 15:05:37 +02:00
										 |  |  | ** | 
					
						
							|  |  |  | **************************************************************************/ | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "startremotedialog.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ui_startremotedialog.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  | #include <ssh/sshconnection.h>
 | 
					
						
							| 
									
										
										
										
											2011-08-17 13:37:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QPushButton>
 | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Analyzer { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-04 10:50:44 +02:00
										 |  |  | StartRemoteDialog::StartRemoteDialog(QWidget *parent) | 
					
						
							|  |  |  |     : QDialog(parent) | 
					
						
							| 
									
										
										
										
											2011-11-23 15:15:01 +00:00
										 |  |  |     , m_ui(new Internal::Ui::StartRemoteDialog) | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     m_ui->setupUi(this); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_ui->keyFile->setExpectedKind(Utils::PathChooser::File); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     QSettings *settings = Core::ICore::settings(); | 
					
						
							| 
									
										
										
										
											2012-01-25 17:39:50 +01:00
										 |  |  |     settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); | 
					
						
							|  |  |  |     m_ui->host->setText(settings->value(QLatin1String("host")).toString()); | 
					
						
							|  |  |  |     m_ui->port->setValue(settings->value(QLatin1String("port"), 22).toInt()); | 
					
						
							|  |  |  |     m_ui->user->setText(settings->value(QLatin1String("user"), qgetenv("USER")).toString()); | 
					
						
							|  |  |  |     m_ui->keyFile->setPath(settings->value(QLatin1String("keyFile")).toString()); | 
					
						
							|  |  |  |     m_ui->executable->setText(settings->value(QLatin1String("executable")).toString()); | 
					
						
							|  |  |  |     m_ui->workingDirectory->setText(settings->value(QLatin1String("workingDirectory")).toString()); | 
					
						
							|  |  |  |     m_ui->arguments->setText(settings->value(QLatin1String("arguments")).toString()); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |     settings->endGroup(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_ui->host, SIGNAL(textChanged(QString)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  |     connect(m_ui->port, SIGNAL(valueChanged(int)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  |     connect(m_ui->password, SIGNAL(textChanged(QString)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  |     connect(m_ui->keyFile, SIGNAL(changed(QString)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_ui->executable, SIGNAL(textChanged(QString)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  |     connect(m_ui->workingDirectory, SIGNAL(textChanged(QString)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  |     connect(m_ui->arguments, SIGNAL(textChanged(QString)), | 
					
						
							|  |  |  |             this, SLOT(validate())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(m_ui->buttonBox, SIGNAL(accepted()), | 
					
						
							|  |  |  |             this, SLOT(accept())); | 
					
						
							|  |  |  |     connect(m_ui->buttonBox, SIGNAL(rejected()), | 
					
						
							|  |  |  |             this, SLOT(reject())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     validate(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | StartRemoteDialog::~StartRemoteDialog() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     delete m_ui; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void StartRemoteDialog::accept() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-01-24 15:36:40 +01:00
										 |  |  |     QSettings *settings = Core::ICore::settings(); | 
					
						
							| 
									
										
										
										
											2012-01-25 17:39:50 +01:00
										 |  |  |     settings->beginGroup(QLatin1String("AnalyzerStartRemoteDialog")); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("host"), m_ui->host->text()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("port"), m_ui->port->value()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("user"), m_ui->user->text()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("keyFile"), m_ui->keyFile->path()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("executable"), m_ui->executable->text()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("workingDirectory"), m_ui->workingDirectory->text()); | 
					
						
							|  |  |  |     settings->setValue(QLatin1String("arguments"), m_ui->arguments->text()); | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |     settings->endGroup(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QDialog::accept(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void StartRemoteDialog::validate() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool valid = !m_ui->host->text().isEmpty() && !m_ui->user->text().isEmpty() | 
					
						
							|  |  |  |                     && !m_ui->executable->text().isEmpty(); | 
					
						
							|  |  |  |     valid = valid && (!m_ui->password->text().isEmpty() || m_ui->keyFile->isValid()); | 
					
						
							|  |  |  |     m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  | QSsh::SshConnectionParameters StartRemoteDialog::sshParams() const | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  |     QSsh::SshConnectionParameters params; | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |     params.host = m_ui->host->text(); | 
					
						
							|  |  |  |     params.userName = m_ui->user->text(); | 
					
						
							|  |  |  |     if (m_ui->keyFile->isValid()) { | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  |         params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByKey; | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |         params.privateKeyFile = m_ui->keyFile->path(); | 
					
						
							|  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2012-05-18 10:49:35 +02:00
										 |  |  |         params.authenticationType = QSsh::SshConnectionParameters::AuthenticationByPassword; | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |         params.password = m_ui->password->text(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     params.port = m_ui->port->value(); | 
					
						
							| 
									
										
										
										
											2012-02-24 15:09:08 +01:00
										 |  |  |     params.timeout = 10; | 
					
						
							| 
									
										
										
										
											2011-04-04 14:39:28 +02:00
										 |  |  |     return params; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString StartRemoteDialog::executable() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_ui->executable->text(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString StartRemoteDialog::arguments() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_ui->arguments->text(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString StartRemoteDialog::workingDirectory() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_ui->workingDirectory->text(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-05-18 15:56:01 +02:00
										 |  |  | } // namespace Analyzer
 |