diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp index 4aa2d4fe105cb04db525446016d7b6325ffaaaa8..4112c40a51f86dc6fdf70ca281d5a1968a3dcd44 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp +++ b/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp @@ -36,6 +36,7 @@ #include "blackberryconfiguration.h" #include "blackberrydeviceconnectionmanager.h" #include "blackberrysigningutils.h" +#include "blackberrydebugtokenreader.h" #include "qnxconstants.h" #include "qnxutils.h" @@ -48,6 +49,7 @@ #include <QProgressDialog> #include <QMessageBox> #include <QFileInfo> +#include <QFileDialog> #include <QDir> #include <QAbstractButton> @@ -81,6 +83,7 @@ BlackBerryDeviceConfigurationWidget::BlackBerryDeviceConfigurationWidget(const I connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceAboutToConnect(Core::Id)), this, SLOT(clearConnectionLog(Core::Id))); + connect(ui->importButton, SIGNAL(clicked()), this, SLOT(importDebugToken())); connect(ui->requestButton, SIGNAL(clicked()), this, SLOT(requestDebugToken())); connect(ui->uploadButton, SIGNAL(clicked()), this, SLOT(uploadDebugToken())); @@ -127,6 +130,26 @@ void BlackBerryDeviceConfigurationWidget::debugTokenEditingFinished() deviceConfiguration()->setDebugToken(ui->debugToken->currentText()); } +void BlackBerryDeviceConfigurationWidget::importDebugToken() +{ + const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"), + QString(), tr("Bar file (*.bar)")); + + if (debugToken.isEmpty()) + return; + + BlackBerryDebugTokenReader debugTokenReader(debugToken); + if (!debugTokenReader.isValid()) { + QMessageBox::warning(this, tr("Invalid Debug Token"), + tr("Debug token file %1 cannot be read.").arg(debugToken)); + return; + } + + m_utils.addDebugToken(debugToken); + populateDebugTokenCombo(debugToken); + debugTokenEditingFinished(); +} + void BlackBerryDeviceConfigurationWidget::requestDebugToken() { BlackBerryDebugTokenRequestDialog dialog; diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.h b/src/plugins/qnx/blackberrydeviceconfigurationwidget.h index e0950b6ac3b9943158800e47d02b77970d31176f..8a75153cd630f6474fe205c6813c6117e1e87a2c 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.h +++ b/src/plugins/qnx/blackberrydeviceconfigurationwidget.h @@ -66,6 +66,7 @@ private slots: void keyFileEditingFinished(); void showPassword(bool showClearText); void debugTokenEditingFinished(); + void importDebugToken(); void requestDebugToken(); void uploadDebugToken(); void updateUploadButton(); diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui b/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui index 46ea60a3f7e9cf40bd917a76f15acc07e638d99b..1bcbf8e1b1daacdfda21d36ff14680a3485981cd 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui +++ b/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui @@ -114,6 +114,13 @@ </property> </spacer> </item> + <item> + <widget class="QPushButton" name="importButton"> + <property name="text"> + <string>Import</string> + </property> + </widget> + </item> <item> <widget class="QPushButton" name="requestButton"> <property name="text"> diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui b/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui index 74afa809d3817d9b57d35049ba88ea84746f586f..a021d859f88ce6a915242934dcc27530ea3607df 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui @@ -27,7 +27,7 @@ </property> </widget> </item> - <item row="2" column="2"> + <item row="2" column="3"> <widget class="QPushButton" name="generateButton"> <property name="text"> <string>Generate</string> @@ -47,7 +47,7 @@ </property> </widget> </item> - <item row="4" column="0" colspan="3"> + <item row="4" column="0" colspan="4"> <widget class="QLabel" name="label_3"> <property name="font"> <font> @@ -62,6 +62,13 @@ </property> </widget> </item> + <item row="2" column="2"> + <widget class="QPushButton" name="importButton"> + <property name="text"> + <string>Import</string> + </property> + </widget> + </item> </layout> </widget> </item> diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp index 62b70f1c2a5587568004a977d1ccf3b842ed1d82..82571651fc1f581445a897833dcabe0569123bd8 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp @@ -32,6 +32,7 @@ #include "blackberrydeviceconfigurationwizardpages.h" #include "blackberryconfiguration.h" #include "blackberrydebugtokenrequestdialog.h" +#include "blackberrydebugtokenreader.h" #include "blackberrysshkeysgenerator.h" #include "blackberrydeviceinformation.h" #include "ui_blackberrydeviceconfigurationwizardsetuppage.h" @@ -364,6 +365,7 @@ BlackBerryDeviceConfigurationWizardConfigPage::BlackBerryDeviceConfigurationWiza connect(m_ui->configurationNameField, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); connect(m_ui->debugTokenCombo, SIGNAL(currentTextChanged(QString)), this, SIGNAL(completeChanged())); connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generateDebugToken())); + connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importDebugToken())); registerField(QLatin1String(CONFIGURATIONNAME_FIELD_ID), m_ui->configurationNameField); registerField(QLatin1String(DEBUGTOKENPATH_FIELD_ID), m_ui->debugTokenCombo); @@ -407,6 +409,31 @@ void BlackBerryDeviceConfigurationWizardConfigPage::generateDebugToken() m_utils.addDebugToken(dialog.debugToken()); m_ui->debugTokenCombo->addItem(dialog.debugToken()); + const int index = m_ui->debugTokenCombo->findText(dialog.debugToken()); + if (index != -1) + m_ui->debugTokenCombo->setCurrentIndex(index); +} + +void BlackBerryDeviceConfigurationWizardConfigPage::importDebugToken() +{ + const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"), + QString(), tr("Bar file (*.bar)")); + + if (debugToken.isEmpty()) + return; + + BlackBerryDebugTokenReader debugTokenReader(debugToken); + if (!debugTokenReader.isValid()) { + QMessageBox::warning(this, tr("Invalid Debug Token"), + tr("Debug token file %1 cannot be read.").arg(debugToken)); + return; + } + + m_utils.addDebugToken(debugToken); + m_ui->debugTokenCombo->addItem(debugToken); + const int index = m_ui->debugTokenCombo->findText(debugToken); + if (index != -1) + m_ui->debugTokenCombo->setCurrentIndex(index); } QString BlackBerryDeviceConfigurationWizardConfigPage::configurationName() const diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h index c736374479937516c5dae33f9b2e2f72eedbbe34..50b58eced185254e6f03b92e8c8f3b85704d8ecd 100644 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h +++ b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h @@ -146,6 +146,7 @@ public: QString debugToken() const; private slots: void generateDebugToken(); + void importDebugToken(); private: Ui::BlackBerryDeviceConfigurationWizardConfigPage *m_ui;