~ubuntu-sdk-team/qtcreator-plugin-remotelinux/trunk

« back to all changes in this revision

Viewing changes to src/qnx/blackberrydeviceconfigurationwidget.cpp

  • Committer: CI bot
  • Author(s): Benjamin Zeller
  • Date: 2014-06-16 10:28:43 UTC
  • mfrom: (4.2.4 remotelinux)
  • Revision ID: ps-jenkins@lists.canonical.com-20140616102843-8juvmjvzwlzsboyw
Migrating to Qt5.3 and QtC 3.1 

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "blackberrydebugtokenuploader.h"
34
34
#include "blackberrydebugtokenrequestdialog.h"
35
35
#include "ui_blackberrydeviceconfigurationwidget.h"
36
 
#include "blackberryconfiguration.h"
37
36
#include "blackberrydeviceconnectionmanager.h"
 
37
#include "blackberrysigningutils.h"
 
38
#include "blackberrydebugtokenreader.h"
38
39
#include "qnxconstants.h"
39
40
#include "qnxutils.h"
40
41
 
47
48
#include <QProgressDialog>
48
49
#include <QMessageBox>
49
50
#include <QFileInfo>
 
51
#include <QFileDialog>
50
52
#include <QDir>
51
53
#include <QAbstractButton>
52
54
 
57
59
    IDeviceWidget(device, parent),
58
60
    ui(new Ui::BlackBerryDeviceConfigurationWidget),
59
61
    progressDialog(new QProgressDialog(this)),
60
 
    uploader(new BlackBerryDebugTokenUploader(this))
 
62
    uploader(new BlackBerryDebugTokenUploader(this)),
 
63
    m_utils(BlackBerrySigningUtils::instance())
61
64
{
62
65
    ui->setupUi(this);
63
66
 
64
67
    ui->connectionLog->setFont(TextEditor::TextEditorSettings::fontSettings().font());
65
68
 
 
69
    populateDebugTokenCombo(deviceConfiguration()->debugToken());
 
70
 
66
71
    connect(ui->hostLineEdit, SIGNAL(editingFinished()), this, SLOT(hostNameEditingFinished()));
67
72
    connect(ui->pwdLineEdit, SIGNAL(editingFinished()), this, SLOT(passwordEditingFinished()));
68
73
    connect(ui->keyFileLineEdit, SIGNAL(editingFinished()), this, SLOT(keyFileEditingFinished()));
69
74
    connect(ui->keyFileLineEdit, SIGNAL(browsingFinished()), this, SLOT(keyFileEditingFinished()));
70
75
    connect(ui->showPasswordCheckBox, SIGNAL(toggled(bool)), this, SLOT(showPassword(bool)));
71
 
    connect(ui->debugToken, SIGNAL(changed(QString)), this, SLOT(updateUploadButton()));
72
 
    connect(ui->debugToken, SIGNAL(editingFinished()), this, SLOT(debugTokenEditingFinished()));
73
 
    connect(ui->debugToken, SIGNAL(browsingFinished()), this, SLOT(debugTokenEditingFinished()));
 
76
    connect(ui->debugToken, SIGNAL(currentTextChanged(QString)), this, SLOT(updateUploadButton()));
 
77
    connect(ui->debugToken, SIGNAL(currentTextChanged(QString)), this, SLOT(debugTokenEditingFinished()));
74
78
    connect(uploader, SIGNAL(finished(int)), this, SLOT(uploadFinished(int)));
75
79
 
76
80
    connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)),
78
82
    connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceAboutToConnect(Core::Id)),
79
83
            this, SLOT(clearConnectionLog(Core::Id)));
80
84
 
 
85
    connect(ui->importButton, SIGNAL(clicked()), this, SLOT(importDebugToken()));
81
86
    connect(ui->requestButton, SIGNAL(clicked()), this, SLOT(requestDebugToken()));
82
87
    connect(ui->uploadButton, SIGNAL(clicked()), this, SLOT(uploadDebugToken()));
83
88
 
84
 
    QString debugTokenBrowsePath = QnxUtils::dataDirPath();
85
 
    if (!QFileInfo(debugTokenBrowsePath).exists())
86
 
        debugTokenBrowsePath = QDir::homePath();
87
 
    ui->debugToken->setInitialBrowsePathBackup(debugTokenBrowsePath);
 
89
    connect(&m_utils, SIGNAL(debugTokenListChanged()), this, SLOT(updateDebugTokenCombo()));
88
90
 
89
91
    initGui();
90
92
}
91
93
 
92
94
BlackBerryDeviceConfigurationWidget::~BlackBerryDeviceConfigurationWidget()
93
95
{
 
96
    m_utils.saveDebugTokens();
94
97
    delete ui;
95
98
}
96
99
 
123
126
 
124
127
void BlackBerryDeviceConfigurationWidget::debugTokenEditingFinished()
125
128
{
126
 
    deviceConfiguration()->setDebugToken(ui->debugToken->path());
 
129
    deviceConfiguration()->setDebugToken(ui->debugToken->currentText());
 
130
}
 
131
 
 
132
void BlackBerryDeviceConfigurationWidget::importDebugToken()
 
133
{
 
134
    const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"),
 
135
                                                            QString(), tr("BAR file (*.bar)"));
 
136
 
 
137
    if (debugToken.isEmpty())
 
138
        return;
 
139
 
 
140
    BlackBerryDebugTokenReader debugTokenReader(debugToken);
 
141
    if (!debugTokenReader.isValid()) {
 
142
        QMessageBox::warning(this, tr("Invalid Debug Token"),
 
143
                             tr("Debug token file %1 cannot be read.").arg(debugToken));
 
144
        return;
 
145
    }
 
146
 
 
147
    m_utils.addDebugToken(debugToken);
 
148
    populateDebugTokenCombo(debugToken);
 
149
    debugTokenEditingFinished();
127
150
}
128
151
 
129
152
void BlackBerryDeviceConfigurationWidget::requestDebugToken()
138
161
    if (result != QDialog::Accepted)
139
162
        return;
140
163
 
141
 
    ui->debugToken->setPath(dialog.debugToken());
 
164
    m_utils.addDebugToken(dialog.debugToken());
 
165
    populateDebugTokenCombo(dialog.debugToken());
142
166
    debugTokenEditingFinished();
143
167
}
144
168
 
145
169
void BlackBerryDeviceConfigurationWidget::uploadDebugToken()
146
170
{
147
171
    // check the debug token path before even laucnhing the uploader process
148
 
    if (!QFileInfo(ui->debugToken->fileName().toString()).exists()) {
 
172
    if (!QFileInfo(ui->debugToken->currentText()).exists()) {
149
173
        QMessageBox::critical(this, tr("Error"), tr("Invalid debug token path."));
150
174
        return;
151
175
    }
152
176
 
153
177
    progressDialog->show();
154
178
 
155
 
    uploader->uploadDebugToken(ui->debugToken->path(),
 
179
    uploader->uploadDebugToken(ui->debugToken->currentText(),
156
180
            ui->hostLineEdit->text(), ui->pwdLineEdit->text());
157
181
}
158
182
 
159
183
void BlackBerryDeviceConfigurationWidget::updateUploadButton()
160
184
{
161
 
    ui->uploadButton->setEnabled(!ui->debugToken->path().isEmpty());
 
185
    const QString path = ui->debugToken->currentText();
 
186
    ui->uploadButton->setEnabled(QFileInfo(path).exists());
162
187
}
163
188
 
164
189
void BlackBerryDeviceConfigurationWidget::uploadFinished(int status)
213
238
        ui->connectionLog->clear();
214
239
}
215
240
 
 
241
void BlackBerryDeviceConfigurationWidget::populateDebugTokenCombo(const QString& current)
 
242
{
 
243
    ui->debugToken->clear();
 
244
    ui->debugToken->addItems(m_utils.debugTokens());
 
245
    ui->debugToken->setEditText(current);
 
246
}
 
247
 
 
248
void BlackBerryDeviceConfigurationWidget::updateDebugTokenCombo()
 
249
{
 
250
    populateDebugTokenCombo(ui->debugToken->currentText());
 
251
}
 
252
 
216
253
void BlackBerryDeviceConfigurationWidget::updateDeviceFromUi()
217
254
{
218
255
    hostNameEditingFinished();
223
260
 
224
261
void BlackBerryDeviceConfigurationWidget::initGui()
225
262
{
226
 
    ui->debugToken->setExpectedKind(Utils::PathChooser::File);
227
 
    ui->debugToken->setPromptDialogFilter(QLatin1String("*.bar"));
228
 
 
229
263
    ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File);
 
264
    ui->keyFileLineEdit->setHistoryCompleter(QLatin1String("BB.Key.History"));
230
265
    ui->keyFileLineEdit->lineEdit()->setMinimumWidth(0);
231
266
 
232
267
    const QSsh::SshConnectionParameters &sshParams = deviceConfiguration()->sshParameters();
237
272
    ui->pwdLineEdit->setText(sshParams.password);
238
273
    ui->keyFileLineEdit->setPath(sshParams.privateKeyFile);
239
274
    ui->showPasswordCheckBox->setChecked(false);
240
 
    ui->debugToken->setPath(deviceConfiguration()->debugToken());
241
 
 
242
275
    if (deviceConfiguration()->machineType() == IDevice::Emulator) {
243
276
        ui->debugToken->setEnabled(false);
244
277
        ui->requestButton->setEnabled(false);