30
30
****************************************************************************/
32
32
#include "blackberrydeviceconfigurationwizardpages.h"
33
#include "blackberryconfiguration.h"
34
33
#include "blackberrydebugtokenrequestdialog.h"
34
#include "blackberrydebugtokenreader.h"
35
35
#include "blackberrysshkeysgenerator.h"
36
36
#include "blackberrydeviceinformation.h"
37
37
#include "ui_blackberrydeviceconfigurationwizardsetuppage.h"
38
38
#include "ui_blackberrydeviceconfigurationwizardquerypage.h"
39
39
#include "ui_blackberrydeviceconfigurationwizardconfigpage.h"
40
#include "blackberryconfiguration.h"
41
40
#include "blackberrydeviceconnectionmanager.h"
41
#include "blackberrysigningutils.h"
42
42
#include "qnxutils.h"
44
44
#include <coreplugin/icore.h>
265
265
checkAndGenerateSSHKeys();
267
267
setState(Done, tr("Cannot connect to the device. "
268
"Check if the device is in development mode and has matching host name and password."));
268
"Check that the device is in development mode and has matching host name and password."));
271
271
void BlackBerryDeviceConfigurationWizardQueryPage::checkAndGenerateSSHKeys()
353
353
: QWizardPage(parent)
354
354
, m_ui(new Ui::BlackBerryDeviceConfigurationWizardConfigPage)
355
355
, m_holder(holder)
356
, m_utils(BlackBerrySigningUtils::instance())
357
358
m_ui->setupUi(this);
358
359
setTitle(tr("Configuration"));
360
m_ui->debugTokenField->setExpectedKind(Utils::PathChooser::File);
361
m_ui->debugTokenField->setPromptDialogFilter(QLatin1String("*.bar"));
363
QString debugTokenBrowsePath = QnxUtils::dataDirPath();
364
if (!QFileInfo(debugTokenBrowsePath).exists())
365
debugTokenBrowsePath = QDir::homePath();
366
m_ui->debugTokenField->setInitialBrowsePathBackup(debugTokenBrowsePath);
361
m_ui->debugTokenCombo->addItems(m_utils.debugTokens());
368
363
connect(m_ui->configurationNameField, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged()));
369
connect(m_ui->debugTokenField, SIGNAL(changed(QString)), this, SIGNAL(completeChanged()));
364
connect(m_ui->debugTokenCombo, SIGNAL(currentTextChanged(QString)), this, SIGNAL(completeChanged()));
370
365
connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generateDebugToken()));
366
connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importDebugToken()));
372
368
registerField(QLatin1String(CONFIGURATIONNAME_FIELD_ID), m_ui->configurationNameField);
373
registerField(QLatin1String(DEBUGTOKENPATH_FIELD_ID), m_ui->debugTokenField);
369
registerField(QLatin1String(DEBUGTOKENPATH_FIELD_ID), m_ui->debugTokenCombo);
376
372
BlackBerryDeviceConfigurationWizardConfigPage::~BlackBerryDeviceConfigurationWizardConfigPage()
385
381
m_ui->configurationNameField->setText(m_holder.deviceName);
386
382
m_ui->deviceHostNameField->setText(deviceHostName);
387
383
m_ui->deviceTypeField->setText(QLatin1String (m_holder.isSimulator ? "Simulator" : "Device"));
388
m_ui->debugTokenField->setEnabled(!m_holder.isSimulator);
384
m_ui->debugTokenCombo->setEnabled(!m_holder.isSimulator);
389
385
m_ui->generateButton->setEnabled(!m_holder.isSimulator);
392
388
bool BlackBerryDeviceConfigurationWizardConfigPage::isComplete() const
394
390
bool configurationNameComplete = !m_ui->configurationNameField->text().isEmpty();
395
Utils::FileName fileName = m_ui->debugTokenField->fileName();
391
Utils::FileName fileName = Utils::FileName::fromString(m_ui->debugTokenCombo->currentText());
396
392
bool debugTokenComplete = m_holder.isSimulator || !m_holder.isProductionDevice
397
|| (!fileName.isEmpty() && QFileInfo(fileName.toString()).exists());
393
|| (!fileName.isEmpty() && fileName.toFileInfo().exists());
399
395
return configurationNameComplete && debugTokenComplete;
409
405
if (result != QDialog::Accepted)
412
m_ui->debugTokenField->setPath(dialog.debugToken());
408
m_utils.addDebugToken(dialog.debugToken());
409
m_ui->debugTokenCombo->addItem(dialog.debugToken());
410
const int index = m_ui->debugTokenCombo->findText(dialog.debugToken());
412
m_ui->debugTokenCombo->setCurrentIndex(index);
415
void BlackBerryDeviceConfigurationWizardConfigPage::importDebugToken()
417
const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"),
418
QString(), tr("BAR file (*.bar)"));
420
if (debugToken.isEmpty())
423
BlackBerryDebugTokenReader debugTokenReader(debugToken);
424
if (!debugTokenReader.isValid()) {
425
QMessageBox::warning(this, tr("Invalid Debug Token"),
426
tr("Debug token file %1 cannot be read.").arg(debugToken));
430
m_utils.addDebugToken(debugToken);
431
m_ui->debugTokenCombo->addItem(debugToken);
432
const int index = m_ui->debugTokenCombo->findText(debugToken);
434
m_ui->debugTokenCombo->setCurrentIndex(index);
415
437
QString BlackBerryDeviceConfigurationWizardConfigPage::configurationName() const
420
442
QString BlackBerryDeviceConfigurationWizardConfigPage::debugToken() const
422
return m_ui->debugTokenField->fileName().toString();
444
return m_ui->debugTokenCombo->currentText();
425
447
// ----------------------------------------------------------------------------