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

« back to all changes in this revision

Viewing changes to src/qnx/blackberrydeviceconfigurationwizardpages.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:
30
30
****************************************************************************/
31
31
 
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"
43
43
 
44
44
#include <coreplugin/icore.h>
265
265
        checkAndGenerateSSHKeys();
266
266
    else
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."));
269
269
}
270
270
 
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())
356
357
{
357
358
    m_ui->setupUi(this);
358
359
    setTitle(tr("Configuration"));
359
360
 
360
 
    m_ui->debugTokenField->setExpectedKind(Utils::PathChooser::File);
361
 
    m_ui->debugTokenField->setPromptDialogFilter(QLatin1String("*.bar"));
362
 
 
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());
367
362
 
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()));
371
367
 
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);
374
370
}
375
371
 
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);
390
386
}
391
387
 
392
388
bool BlackBerryDeviceConfigurationWizardConfigPage::isComplete() const
393
389
{
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());
398
394
 
399
395
    return configurationNameComplete  &&  debugTokenComplete;
400
396
}
409
405
    if (result != QDialog::Accepted)
410
406
        return;
411
407
 
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());
 
411
    if (index != -1)
 
412
        m_ui->debugTokenCombo->setCurrentIndex(index);
 
413
}
 
414
 
 
415
void BlackBerryDeviceConfigurationWizardConfigPage::importDebugToken()
 
416
{
 
417
    const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"),
 
418
                                                            QString(), tr("BAR file (*.bar)"));
 
419
 
 
420
    if (debugToken.isEmpty())
 
421
        return;
 
422
 
 
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));
 
427
        return;
 
428
    }
 
429
 
 
430
    m_utils.addDebugToken(debugToken);
 
431
    m_ui->debugTokenCombo->addItem(debugToken);
 
432
    const int index = m_ui->debugTokenCombo->findText(debugToken);
 
433
    if (index != -1)
 
434
        m_ui->debugTokenCombo->setCurrentIndex(index);
413
435
}
414
436
 
415
437
QString BlackBerryDeviceConfigurationWizardConfigPage::configurationName() const
419
441
 
420
442
QString BlackBerryDeviceConfigurationWizardConfigPage::debugToken() const
421
443
{
422
 
    return m_ui->debugTokenField->fileName().toString();
 
444
    return m_ui->debugTokenCombo->currentText();
423
445
}
424
446
 
425
447
// ----------------------------------------------------------------------------