diff options
author | Samuli Piippo <samuli.piippo@theqtcompany.com> | 2016-01-21 15:58:29 +0200 |
---|---|---|
committer | Samuli Piippo <samuli.piippo@theqtcompany.com> | 2016-01-22 06:41:39 +0000 |
commit | 887c8bffd05a3784d83e8280f8c725eead4c7a5c (patch) | |
tree | e1461a1e2ab1f689b96a99f7d67a33df2dc77dd0 | |
parent | 2b81f8dbc97b446b33fb67e3196a8726ed195008 (diff) |
Remove flashing wizard codes
b2qt flashing wizard was moved to own repository
Change-Id: Id51d460338f8134beb55936e4169f180e64cf007
Reviewed-by: Rainer Keller <rainer.keller@theqtcompany.com>
35 files changed, 0 insertions, 2129 deletions
diff --git a/src/b2qt-flashing-wizard/.gitignore b/src/b2qt-flashing-wizard/.gitignore deleted file mode 100644 index 9f9ec21..0000000 --- a/src/b2qt-flashing-wizard/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.o -Makefile -b2qt-wand -qrc_*.cpp -moc_*.cpp diff --git a/src/b2qt-flashing-wizard/B2Qt_QtC_icon@2x.png b/src/b2qt-flashing-wizard/B2Qt_QtC_icon@2x.png Binary files differdeleted file mode 100644 index d407a1f..0000000 --- a/src/b2qt-flashing-wizard/B2Qt_QtC_icon@2x.png +++ /dev/null diff --git a/src/b2qt-flashing-wizard/README b/src/b2qt-flashing-wizard/README deleted file mode 100644 index a04bc96..0000000 --- a/src/b2qt-flashing-wizard/README +++ /dev/null @@ -1,24 +0,0 @@ -If you want to use this tool outside of the SDK installation directory -you have to set SDKDIR environment variable. - -How to get root permission: - -sudo -A /bin/askpass-tool - -Sudo will ask when starting scripts - -sudo -E ./b2qt-flashing-wizard - --E is needed to keep the X vars - -Variables needed: - -#!/bin/bash -export HOME=/home/rkeller -export XDG_SESSION_COOKIE=0dbc1b47e88f5cfa62c5818b00000237-1381472004.761811-1314725543 -./b2qt-flashing-wizard - -GUI stuff: - -kdesu -gsu diff --git a/src/b2qt-flashing-wizard/actor.cpp b/src/b2qt-flashing-wizard/actor.cpp deleted file mode 100644 index 1cd76bf..0000000 --- a/src/b2qt-flashing-wizard/actor.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "actor.h" - -Actor::Actor(QObject *parent) - : QObject(parent) -{ -} - -Actor::~Actor() -{ -} diff --git a/src/b2qt-flashing-wizard/actor.h b/src/b2qt-flashing-wizard/actor.h deleted file mode 100644 index 9af55fe..0000000 --- a/src/b2qt-flashing-wizard/actor.h +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef ACTOR_H -#define ACTOR_H - -#include <QObject> - -class Actor : public QObject -{ - Q_OBJECT - -public: - Actor(QObject *parent); - virtual ~Actor(); - virtual bool ready(QString &) const = 0; - virtual void start() = 0; - -signals: - void progress(const QString &step); - void finished(); - void failed(const QString &message); - void details(const QByteArray &); - void errorDetails(const QByteArray &); -}; - -#endif // ACTOR_H diff --git a/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro b/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro deleted file mode 100644 index 31c734d..0000000 --- a/src/b2qt-flashing-wizard/b2qt-flashing-wizard.pro +++ /dev/null @@ -1,54 +0,0 @@ -QT += widgets -CONFIG += c++11 - -SOURCES += \ - actor.cpp \ - commit_page.cpp \ - common.cpp \ - device_page.cpp \ - disk_page.cpp \ - elevator.cpp \ - finish_page.cpp \ - introduction_page.cpp \ - main.cpp \ - mainwindow.cpp \ - platform_page.cpp \ - progress_page.cpp \ - scriptwriter.cpp \ - -HEADERS += \ - actor.h \ - commit_page.h \ - common.h \ - device_page.h \ - disk_page.h \ - elevator.h \ - finish_page.h \ - introduction_page.h \ - mainwindow.h \ - platform_page.h \ - progress_page.h \ - scriptwriter.h \ - -RESOURCES += b2qt-flashing-wizard.qrc -INSTALLS += target -target.path = /bin - -# Find out git hash -unix:system(which git):HAS_GIT=TRUE -win32:system(where git.exe):HAS_GIT=TRUE -contains(HAS_GIT, TRUE) { - GIT_HASH=$$system(git log -1 --format=%H) - !system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty" - GIT_VERSION=$$system(git describe --tags --exact-match) - isEmpty(GIT_VERSION) : GIT_VERSION="unknown" -} else { - GIT_HASH="unknown" - GIT_VERSION="unknown" -} - -isEmpty(GIT_VERSION) : error("No suitable tag found") -isEmpty(GIT_HASH) : error("No hash available") - -DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\"" -DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\"" diff --git a/src/b2qt-flashing-wizard/b2qt-flashing-wizard.qrc b/src/b2qt-flashing-wizard/b2qt-flashing-wizard.qrc deleted file mode 100644 index 1522ca4..0000000 --- a/src/b2qt-flashing-wizard/b2qt-flashing-wizard.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource> - <file>logo.png</file> - <file>background.png</file> - <file>watermark.png</file> - </qresource> -</RCC> diff --git a/src/b2qt-flashing-wizard/background.png b/src/b2qt-flashing-wizard/background.png Binary files differdeleted file mode 100644 index f5eeb6a..0000000 --- a/src/b2qt-flashing-wizard/background.png +++ /dev/null diff --git a/src/b2qt-flashing-wizard/commit_page.cpp b/src/b2qt-flashing-wizard/commit_page.cpp deleted file mode 100644 index 62d9965..0000000 --- a/src/b2qt-flashing-wizard/commit_page.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "commit_page.h" -#include "scriptwriter.h" -#include "progress_page.h" -#include "mainwindow.h" -#include "platforminfo.h" -#include <QDebug> -#include <QVBoxLayout> -#include <QLabel> - -extern PlatformInfo G_platforminfo; -extern QString G_device; -extern QString G_mode; -QLabel *createErrorLabel(QWidget *parent); - -CommitPage::CommitPage(QWidget *parent) - : QWizardPage(parent) - , mText(new QLabel(this)) - , mActor(0) - , mError(createErrorLabel(this)) - , mLayout(new QVBoxLayout(this)) - , mComplete(false) -{ - setButtonText(QWizard::CommitButton, tr("Write")); - setCommitPage(true); - setTitle(tr("Confirm Action")); - setSubTitle(tr("Confirm the action to continue.")); - mLayout->addWidget(mText); - mLayout->addSpacerItem(new QSpacerItem(40,40,QSizePolicy::Minimum, QSizePolicy::Expanding)); - mLayout->addWidget(mError); - setLayout(mLayout); -} - -CommitPage::~CommitPage() -{ -} - -bool CommitPage::isComplete() const -{ - if (!mComplete) - return false; - - QString error; - bool result = mActor->ready(error); - if (result) - mError->clear(); - else - mError->setText(error); - - return result; -} - -void CommitPage::initializePage() -{ - qDebug() << "platform:" << G_platforminfo.platform << "version:" << G_platforminfo.version - << "os:" << G_platforminfo.os << "board:" << G_platforminfo.board - << "deploycommand:" << G_platforminfo.deployCommand << "deployarguments:" << G_platforminfo.deployArguments - << "device:" << G_device << "mode:" << G_mode; - - QString text(tr("Write %1-%2 (%3) to device %4.")); - mText->setText(text.arg(G_platforminfo.platform, G_platforminfo.os, G_platforminfo.version, G_device)); - mComplete = true; - - ScriptWriter *i = new ScriptWriter(this); - i->setScriptFile(G_platforminfo.deployCommand); - i->setRootFlag(G_platforminfo.asroot); - - QStringList args; - foreach (QString a, G_platforminfo.deployArguments) { - if (a == "@DEVICE@") - a = G_device; - args << a; - } - - if (G_platforminfo.board.startsWith("nexus7") && G_mode == "fastboot") - args << "-fastboot"; - - i->setAdditionalArgs(args); - i->setEnvironment("VERBOSE","1"); - mActor = i; -} - -bool CommitPage::validatePage() -{ - ProgressPage *p = qobject_cast<ProgressPage*>(wizard()->page(MainWindow::Page_Progress)); - Q_ASSERT(p); - - p->setActor(mActor); - return true; -} diff --git a/src/b2qt-flashing-wizard/commit_page.h b/src/b2qt-flashing-wizard/commit_page.h deleted file mode 100644 index e934152..0000000 --- a/src/b2qt-flashing-wizard/commit_page.h +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef COMMIT_PAGE_H -#define COMMIT_PAGE_H - -#include <QWizardPage> -class QLabel; -class Actor; -class QLabel; -class QVBoxLayout; - -class CommitPage : public QWizardPage -{ - Q_OBJECT -public: - CommitPage(QWidget *parent = 0); - virtual ~CommitPage(); - void initializePage(); - bool validatePage(); - bool isComplete() const; - -private: - QLabel *mText; - Actor *mActor; - QLabel *mError; - QVBoxLayout *mLayout; - bool mComplete; -}; - -#endif // COMMIT_PAGE_H diff --git a/src/b2qt-flashing-wizard/common.cpp b/src/b2qt-flashing-wizard/common.cpp deleted file mode 100644 index bd95a3c..0000000 --- a/src/b2qt-flashing-wizard/common.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include <QByteArray> -#include <QFile> -#include <QPair> -#include <QDebug> - -QByteArray readAll(const QString &fileName) -{ - QByteArray rc; - QFile file(fileName); - if (!file.open(QFile::ReadOnly)) { - qWarning() << "Could not open file:" << fileName; - return rc; - } - - rc = file.readAll(); - file.close(); - return rc; -} - - -static QList<QPair<QString, QString> > getMounts() -{ - QList<QPair<QString, QString> > rc; - - QByteArray ba = readAll("/proc/mounts"); - foreach (const QString &line, ba.split('\n')) { - if (line.isEmpty()) - continue; - - QStringList token = line.split(' '); - if (token.size() < 2) { - qWarning() << "Error parsing mounts:" << line; - continue; - } - rc.append(qMakePair(token[0], token[1])); - } - return rc; -} - -bool checkForDeviceMounted(const QString &device, QString &mountPoint, QString &partition) -{ - QList<QPair<QString, QString> > mounts = getMounts(); - if (mounts.isEmpty()) { - qWarning() << "No mounts found"; - return false; - } - - foreach (const auto &item, mounts) { - if (item.first.startsWith(device)) { - mountPoint = item.second; - partition = item.first; - return true; - } - } - mountPoint.clear(); - partition.clear(); - return false; -} - diff --git a/src/b2qt-flashing-wizard/common.h b/src/b2qt-flashing-wizard/common.h deleted file mode 100644 index 1884532..0000000 --- a/src/b2qt-flashing-wizard/common.h +++ /dev/null @@ -1,21 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -QByteArray readAll(const QString &fileName); -bool checkForDeviceMounted(const QString &device, QString &mountPoint, QString &partition); diff --git a/src/b2qt-flashing-wizard/device_page.cpp b/src/b2qt-flashing-wizard/device_page.cpp deleted file mode 100644 index 97a6def..0000000 --- a/src/b2qt-flashing-wizard/device_page.cpp +++ /dev/null @@ -1,277 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "device_page.h" -#include "common.h" -#include "mainwindow.h" // for Page_ enum -#include "platforminfo.h" -#include <QDebug> -#include <QDir> -#include <QLabel> -#include <QLayout> -#include <QListWidget> -#include <QMessageBox> -#include <QProcess> -#include <QRadioButton> -#include <QTimer> - -extern QString G_SDKDIR; -extern QString G_device; -extern PlatformInfo G_platforminfo; -extern QString G_mode; - -QLabel *createErrorLabel(QWidget *parent); - -DevicePage::DevicePage(QWidget *parent) - : QWizardPage(parent) - , mListWidget(new QListWidget(this)) - , mError(createErrorLabel(this)) - , mLayout(new QVBoxLayout(this)) -{ - setTitle(tr("Device")); - setSubTitle(tr("Select a device to be used")); - mLayout->addWidget(mListWidget); - mLayout->addSpacerItem(new QSpacerItem(40,40,QSizePolicy::Minimum, QSizePolicy::Expanding)); - mLayout->addWidget(mError); - setLayout(mLayout); - connect(mListWidget, &QListWidget::itemClicked, this, &DevicePage::itemSelected); - - QTimer *timer = new QTimer(this); - timer->setInterval(1000); - connect(timer, &QTimer::timeout, this, &DevicePage::updateDeviceList); - timer->start(); -} - -DevicePage::~DevicePage() -{ -} - -QList<DevicePage::DeviceInfo> DevicePage::list() const -{ - QList<DeviceInfo> diList; - - QProcess process; - process.start(G_SDKDIR + "/Tools/b2qt/adb", QStringList() << "devices" << "-l"); - process.waitForFinished(); - - QList<QByteArray> lines = process.readAll().split('\n'); - foreach (const QByteArray &ba, lines) { - if (ba.startsWith("List of")) - continue; - if (ba.isEmpty()) - continue; - if (ba.startsWith("192.168.56.101:")) - continue; - QList<QByteArray> token = ba.simplified().split(' '); - - if (token.size() == 6){ - DeviceInfo d; - - if (token[5].startsWith("device:")) { - QString deviceName = token[5].mid(7); - if (deviceName == "grouper") - d.name = "Nexus7"; - else if (deviceName == "flo") - d.name = "Nexus7v2"; - else - d.name = deviceName; - } - d.serial = token[0]; - d.mode = "adb"; - if (token[1] == "device") - d.state = "ready"; - else - d.state = "not ready"; - diList.append(d); - } else if (token.size() == 3) { - DeviceInfo d; - d.serial = token[0]; - d.mode = "adb"; - d.name = "Unknown device"; - if (token[1] == "offline") - d.state = "not ready"; - else { - qDebug() << "Unknown state:" << token[1]; - continue; - } - diList.append(d); - } else { - qDebug() << "Invalid token count:" << token.size() << token; - continue; - } - - } - - process.start(G_SDKDIR + "/Tools/b2qt/fastboot", QStringList("devices") << "-l"); - process.waitForFinished(); - lines = process.readAll().split('\n'); - foreach (const QByteArray &ba, lines) { - if (ba.isEmpty()) - continue; - - QList<QByteArray> token = ba.simplified().split(' '); - - if (token.size() != 3) { - qDebug() << "Invalid token count:" << token; - continue; - } - - - DeviceInfo d; - d.serial = token[0]; - - QProcess p2; - p2.start(G_SDKDIR + "/Tools/b2qt/fastboot", QStringList() << "-s" << d.serial << "getvar" << "product"); - if (!p2.waitForFinished()) { - qDebug() << "Could not get product type"; - d.name = "Unknown"; - } - - QString productString = p2.readAllStandardError().split('\n')[0].simplified(); - if (productString.startsWith("product: ")) { - QString productName = productString.mid(9); - if (productName == "grouper") - d.name = "Nexus7"; - else if (productName == "flo") - d.name = "Nexus7v2"; - else - d.name = "Unknown"; - } else - d.name = "Unknown"; - - d.mode = "fastboot"; - d.state = "ready"; - diList.append(d); - } - - return diList; -} - -bool DevicePage::isComplete() const -{ - int index = mListWidget->currentRow(); - if (index < 0 || index >= mListItems.size()) { - return false; - } - - return true; -} - -void DevicePage::itemSelected() -{ - emit completeChanged(); -} - -void DevicePage::updateDeviceList() -{ - if (wizard()->currentPage() != this) - return; - - QList<DeviceInfo> diList = list(); - - QStringList currentDevices; - - foreach (const DeviceInfo &di, diList) - currentDevices += di.serial; - - QMutableMapIterator<QString, QListWidgetItem*> iter(mListItems); - while (iter.hasNext()) { - iter.next(); - if (!currentDevices.contains(iter.key())) { - mDeviceInfo.remove(iter.key()); - delete iter.value(); - iter.remove(); - } - } - - foreach (const DeviceInfo &di, diList) { - QString text = "<h3>%1</h3><table style=\"margin-left:10px\"><tr><td>Serial number</td><td style=\"padding-left:10\">%2</td></tr><tr><td>Mode</td><td style=\"padding-left:10\">%3</td></tr><tr><td>State</td><td style=\"padding-left:10\">%4</td></tr></table>"; - text = text.arg(di.name, di.serial, di.mode, di.state); - - mDeviceInfo[di.serial] = di; - if (mListItems.contains(di.serial)) { - // update existing item - QListWidgetItem *item = mListItems.value(di.serial); - QLabel *label = qobject_cast<QLabel*>(mListWidget->itemWidget(item)); - label->setText(text); - } else { - // new item - QListWidgetItem *item = new QListWidgetItem(); - item->setData(Qt::UserRole, di.serial); - QLabel *label = new QLabel; - label->setText(text); - mListWidget->addItem(item); - mListWidget->setItemWidget(item, label); - item->setSizeHint(label->size()); - mListItems.insert(di.serial, item); - } - } - - if (mListWidget->count() == 0) - mError->setText("No suitable device found"); - else - mError->setText(""); - - emit completeChanged(); -} - - -void DevicePage::initializePage() -{ - mError->clear(); - updateDeviceList(); -} - -bool DevicePage::validatePage() -{ - QListWidgetItem *item = mListWidget->currentItem(); - if (!item) { - return false; - } - - QString serial = item->data(Qt::UserRole).toString(); - if (serial.isEmpty()) { - return false; - } - - if (!mDeviceInfo.contains(serial)) { - return false; - } - - DeviceInfo deviceInfo = mDeviceInfo[serial]; - if (deviceInfo.state != "ready") { - QMessageBox::critical(this, tr("Wrong device status"), tr("The selected device is not ready.")); - return false; - } - - if (deviceInfo.name.toLower() != G_platforminfo.board.toLower()) { - QMessageBox::critical(this, tr("Wrong device type"), tr("The selected device is not compatible for this platform.")); - return false; - } - - G_device = deviceInfo.serial; - G_platforminfo.board = deviceInfo.name.toLower(); - G_mode = deviceInfo.mode; - return true; -} - -int DevicePage::nextId() const -{ - return MainWindow::Page_Commit; -} diff --git a/src/b2qt-flashing-wizard/device_page.h b/src/b2qt-flashing-wizard/device_page.h deleted file mode 100644 index d0f26a2..0000000 --- a/src/b2qt-flashing-wizard/device_page.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef DEVICE_PAGE_H -#define DEVICE_PAGE_H - -#include <QWizardPage> -#include <QMap> -class QListWidget; -class QLabel; -class QVBoxLayout; -class QListWidgetItem; - -class DevicePage : public QWizardPage -{ - Q_OBJECT -public: - DevicePage(QWidget *parent = 0); - virtual ~DevicePage(); - bool isComplete() const; - void initializePage(); - bool validatePage(); - int nextId() const; - -private slots: - void itemSelected(); - void updateDeviceList(); - -private: - struct DeviceInfo - { - QString name; - QString serial; - QString mode; - QString state; - }; - QList<DeviceInfo> list() const; - -private: - QListWidget *mListWidget; - QMap<QString, QListWidgetItem*> mListItems; - QMap<QString, DeviceInfo> mDeviceInfo; - QLabel *mError; - QVBoxLayout *mLayout; -}; - -#endif // DEVICE_PAGE_H diff --git a/src/b2qt-flashing-wizard/disk_page.cpp b/src/b2qt-flashing-wizard/disk_page.cpp deleted file mode 100644 index 9c43643..0000000 --- a/src/b2qt-flashing-wizard/disk_page.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "disk_page.h" -#include "common.h" -#include "elevator.h" -#include "mainwindow.h" // for Page_ enum -#include <QRadioButton> -#include <QLayout> -#include <QDebug> -#include <QDir> -#include <QListWidget> -#include <QLabel> -#include <QTimer> -#include <QProcess> -#include <QMessageBox> - -extern QString G_device; -QLabel *createErrorLabel(QWidget *parent); - -DiskPage::DiskPage(QWidget *parent) - : QWizardPage(parent) - , mListWidget(new QListWidget(this)) - , mError(createErrorLabel(this)) - , mLayout(new QVBoxLayout(this)) -{ - setTitle(tr("Disk")); - setSubTitle(tr("Select a disk to be used")); - mLayout->addWidget(mListWidget); - mLayout->addSpacerItem(new QSpacerItem(40,40,QSizePolicy::Minimum, QSizePolicy::Expanding)); - mLayout->addWidget(mError); - setLayout(mLayout); - connect(mListWidget, &QListWidget::itemClicked, this, &DiskPage::itemSelected); - - QTimer *timer = new QTimer(this); - timer->setInterval(1000); - connect(timer, &QTimer::timeout, this, &DiskPage::updateDeviceList); - timer->start(); - - // Remember devices already present at startup - foreach (const DiskInfo &di, list()) { - if (!di.removable) - mHiddenDevices += di.path; - } -} - -DiskPage::~DiskPage() -{ -} - -QList<DiskPage::DiskInfo> DiskPage::list() const -{ - QList<DiskInfo> diList; - - QDir sys("/sys/block"); - - foreach (const QString &i, sys.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { - DiskInfo di; - - if (readAll(sys.absoluteFilePath(i) + "/removable").trimmed() == "1") - di.removable = true; - else - di.removable = false; - - di.logicalBlockSize = readAll(sys.absoluteFilePath(i) + "/queue/logical_block_size").trimmed().toULong(); - di.blocks = readAll(sys.absoluteFilePath(i) + "/size").trimmed().toULong(); - di.name = i; - di.path = "/dev/" + i; - - checkForDeviceMounted(di.path, di.mountPoint, di.mountPartition); - - diList.append(di); - } - - return diList; -} - -bool DiskPage::isComplete() const -{ - QListWidgetItem *item = mListWidget->currentItem(); - if (!item) - return false; - - QString path = item->data(Qt::UserRole).toString(); - if (path.isEmpty()) - return false; - if (!mListItems.contains(path)) - return false; - - return true; -} - -void DiskPage::itemSelected() -{ - emit completeChanged(); -} - -void DiskPage::updateDeviceList() -{ - if (wizard()->currentPage() != this) - return; - - QList<DiskInfo> diList = list(); - - QSet<QString> currentDevices; - - { // filter devices by name, size etc. - QMutableListIterator<DiskInfo> iter(diList); - - while (iter.hasNext()) { - iter.next(); - const DiskInfo &di = iter.value(); - - if (di.logicalBlockSize == 0 || di.blocks == 0 || di.name.startsWith("ram") - || di.name.startsWith("sr") || di.name.startsWith("fd")) { - iter.remove(); - continue; - } - currentDevices += di.path; - } - } - - { // Update hidden devices list if a device was removed - QMutableSetIterator<QString> iter(mHiddenDevices); - - while (iter.hasNext()) { - iter.next(); - if (!currentDevices.contains(iter.value())) - iter.remove(); - } - } - currentDevices.subtract(mHiddenDevices); - - // Remove devices from map and UI - QMutableMapIterator<QString, QListWidgetItem*> iter(mListItems); - while (iter.hasNext()) { - iter.next(); - if (!currentDevices.contains(iter.key())) { - mDiskInfo.remove(iter.key()); - delete iter.value(); - iter.remove(); - } - } - - foreach (const DiskInfo &di, diList) { - if (!currentDevices.contains(di.path)) - continue; - - QString text = tr("<h3>%1</h3><table style=\"margin-left:10px\"><tr><td>Size</td>" - "<td style=\"padding-left:10\">%2</td></tr><tr><td>Removable</td>" - "<td style=\"padding-left:10\">%3</td><tr><td>Mounted</td>" - "<td style=\"padding-left:10\">%4</td></tr></table>"); - double size = di.logicalBlockSize * di.blocks; - QString sizeText; - - if (size < 1000) { - sizeText = QString::number(size) + tr(" B"); - } else if (size < 1000000) { - sizeText = QString::number(size / 1000) + tr(" KB"); - } else if (size < 1000000000) { - sizeText = QString::number(size / 1000000) + tr(" MB"); - } else { - sizeText = QString::number(qRound(size / 1000 / 1000 / 1000)) + tr(" GB"); - } - - text = text.arg(di.name, sizeText, di.removable?tr("yes"):tr("no"), di.mountPoint.isEmpty()?tr("no"):di.mountPoint); - - mDiskInfo[di.path] = di; - if (mListItems.contains(di.path)) { - // update existing item - QListWidgetItem *item = mListItems.value(di.path); - QLabel *label = qobject_cast<QLabel*>(mListWidget->itemWidget(item)); - label->setText(text); - } else { - // new item - QListWidgetItem *item = new QListWidgetItem(); - item->setData(Qt::UserRole, di.path); - QLabel *label = new QLabel; - label->setText(text); - mListWidget->addItem(item); - mListWidget->setItemWidget(item, label); - item->setSizeHint(label->size()); - mListItems.insert(di.path, item); - } - } - - if (mListWidget->count() == 0) - mError->setText(tr("No suitable disk device found. Connect a device.")); - else - mError->setText(""); - - emit completeChanged(); -} - -void DiskPage::initializePage() -{ - mError->clear(); - updateDeviceList(); -} - -bool DiskPage::validatePage() -{ - QListWidgetItem *item = mListWidget->currentItem(); - if (!item) - return false; - QString path = item->data(Qt::UserRole).toString(); - if (path.isEmpty()) - return false; - - DiskInfo di = mDiskInfo[path]; - - if (!di.mountPoint.isEmpty()) { - // Ask the user before unmount - if (QMessageBox::Ok != QMessageBox::warning(this, tr("Unmount action"), tr("The disk you selected is mounted at '%1'. It will be unmounted now.").arg(di.mountPoint), QMessageBox::Ok | QMessageBox::Cancel)) - return false; - - QStringList args = elevate(); - args << "umount" << di.mountPoint; - - int rc = QProcess::execute(args.takeFirst(), args); - if (rc != 0) { - QMessageBox::critical(this, tr("Unmount failed"), tr("Could not umount the disk.")); - return false; - } - } - - G_device = path; - return true; -} - -int DiskPage::nextId() const -{ - return MainWindow::Page_Commit; -} diff --git a/src/b2qt-flashing-wizard/disk_page.h b/src/b2qt-flashing-wizard/disk_page.h deleted file mode 100644 index abc0ba5..0000000 --- a/src/b2qt-flashing-wizard/disk_page.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef DISK_PAGE_H -#define DISK_PAGE_H - -#include <QWizardPage> -#include <QMap> -#include <QSet> -class QListWidget; -class QLabel; -class QVBoxLayout; -class QListWidgetItem; - -class DiskPage : public QWizardPage -{ - Q_OBJECT -public: - DiskPage(QWidget *parent = 0); - virtual ~DiskPage(); - bool isComplete() const; - void initializePage(); - bool validatePage(); - int nextId() const; - -private slots: - void itemSelected(); - void updateDeviceList(); - -private: - struct DiskInfo - { - QString path; - bool removable; - QString name; - quint64 logicalBlockSize; - quint64 blocks; - QString mountPoint; - QString mountPartition; - }; - QList<DiskInfo> list() const; - -private: - QListWidget *mListWidget; - QMap<QString, QListWidgetItem*> mListItems; - QMap<QString, DiskInfo> mDiskInfo; - QLabel *mError; - QVBoxLayout *mLayout; - QSet<QString> mHiddenDevices; -}; - -#endif // DISK_PAGE_H diff --git a/src/b2qt-flashing-wizard/elevator.cpp b/src/b2qt-flashing-wizard/elevator.cpp deleted file mode 100644 index 6264cc8..0000000 --- a/src/b2qt-flashing-wizard/elevator.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "elevator.h" - -#include <QFile> -#include <QDebug> -#include <QProcess> - -QStringList elevate() -{ - QStringList rc; - - int trySudo = QProcess::execute("sudo", QStringList() << "-n" << "echo" << "foo"); - if (trySudo == 0) { - qDebug() << "Sudo seems to work"; - rc << "sudo" << "--"; - return rc; - } - - if (QFile::exists("/usr/bin/pkexec")) - rc << "/usr/bin/pkexec"; // @ARGS - - return rc; -} - diff --git a/src/b2qt-flashing-wizard/elevator.h b/src/b2qt-flashing-wizard/elevator.h deleted file mode 100644 index 903acc6..0000000 --- a/src/b2qt-flashing-wizard/elevator.h +++ /dev/null @@ -1,22 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include <QStringList> - -QStringList elevate(); diff --git a/src/b2qt-flashing-wizard/finish_page.cpp b/src/b2qt-flashing-wizard/finish_page.cpp deleted file mode 100644 index aa5932a..0000000 --- a/src/b2qt-flashing-wizard/finish_page.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "finish_page.h" -#include <QLabel> - -FinishPage::FinishPage(QWidget *parent) - : QWizardPage(parent) -{ - setCommitPage(true); - setTitle(tr("Finish")); - new QLabel(tr("The Qt device setup is complete."), this); -} - -FinishPage::~FinishPage() -{ -} diff --git a/src/b2qt-flashing-wizard/finish_page.h b/src/b2qt-flashing-wizard/finish_page.h deleted file mode 100644 index a333e7c..0000000 --- a/src/b2qt-flashing-wizard/finish_page.h +++ /dev/null @@ -1,34 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef FINISH_PAGE_H -#define FINISH_PAGE_H - -#include <QWizardPage> - -class FinishPage : public QWizardPage -{ - Q_OBJECT - -public: - FinishPage(QWidget *parent = 0); - virtual ~FinishPage(); -}; - -#endif // FINISH_PAGE_H diff --git a/src/b2qt-flashing-wizard/introduction_page.cpp b/src/b2qt-flashing-wizard/introduction_page.cpp deleted file mode 100644 index 56ae6a1..0000000 --- a/src/b2qt-flashing-wizard/introduction_page.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "introduction_page.h" -#include <QLabel> - -IntroductionPage::IntroductionPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Boot to Qt Flashing Wizard")); -// setSubTitle(" "); - new QLabel(tr("The wizard helps you set up your device"), this); -} - -IntroductionPage::~IntroductionPage() -{ -} diff --git a/src/b2qt-flashing-wizard/introduction_page.h b/src/b2qt-flashing-wizard/introduction_page.h deleted file mode 100644 index 43575d6..0000000 --- a/src/b2qt-flashing-wizard/introduction_page.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef INTRODUCTION_PAGE_H -#define INTRODUCTION_PAGE_H - -#include <QWizardPage> - -class IntroductionPage : public QWizardPage -{ - Q_OBJECT - -public: - IntroductionPage(QWidget *parent = 0); - virtual ~IntroductionPage(); -// void initializePage(); -}; - -#endif // INTRODUCTION_PAGE_H diff --git a/src/b2qt-flashing-wizard/logo.png b/src/b2qt-flashing-wizard/logo.png Binary files differdeleted file mode 100644 index ee2ef28..0000000 --- a/src/b2qt-flashing-wizard/logo.png +++ /dev/null diff --git a/src/b2qt-flashing-wizard/main.cpp b/src/b2qt-flashing-wizard/main.cpp deleted file mode 100644 index 25ab9d1..0000000 --- a/src/b2qt-flashing-wizard/main.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "mainwindow.h" -#include <QApplication> -//#include <QCleanlooksStyle> -#include <QStyleFactory> -#include <QDebug> -#include <QIcon> - -int main(int argc, char **argv) -{ - printf("Version %s, SHA1 %s\n", GIT_VERSION, GIT_HASH); - QApplication app(argc, argv); -// qDebug() << QStyleFactory::keys(); - QStyle *style = QStyleFactory::create("Fusion"); - if (style) - app.setStyle(style); - app.setWindowIcon(QIcon(":logo.png")); - MainWindow mw; - mw.show(); - return app.exec(); -} diff --git a/src/b2qt-flashing-wizard/mainwindow.cpp b/src/b2qt-flashing-wizard/mainwindow.cpp deleted file mode 100644 index 8693eab..0000000 --- a/src/b2qt-flashing-wizard/mainwindow.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "mainwindow.h" -#include "introduction_page.h" -#include "platform_page.h" -#include "disk_page.h" -#include "device_page.h" -#include "commit_page.h" -#include "progress_page.h" -#include "finish_page.h" -#include <QDebug> -#include <QDir> -#include <QCoreApplication> - -PlatformInfo G_platforminfo; -QString G_SDKDIR; // install directory -QString G_mode; // adb or fastboot -QString G_device; - -MainWindow::MainWindow() - : QWizard() -{ - setWindowTitle(tr("Boot to Qt Flashing Wizard")); - setPixmap(QWizard::LogoPixmap, QPixmap(":logo.png").scaled(64, 64, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - setPixmap(QWizard::BackgroundPixmap, QPixmap(":background.png")); - setPixmap(QWizard::WatermarkPixmap, QPixmap(":watermark.png")); - G_SDKDIR = qgetenv("SDKDIR"); - if (G_SDKDIR.isEmpty()) - G_SDKDIR = QDir::cleanPath(QCoreApplication::applicationDirPath() + "/../.."); - if (!G_SDKDIR.endsWith('/')) - G_SDKDIR.append('/'); - - setWizardStyle(QWizard::ModernStyle); - setPage(Page_Intro, new IntroductionPage); - setPage(Page_Platform, new PlatformPage); - setPage(Page_Disk, new DiskPage); - setPage(Page_Device, new DevicePage); - setPage(Page_Commit, new CommitPage); - setPage(Page_Progress, new ProgressPage); - setPage(Page_Finish, new FinishPage); -} - -MainWindow::~MainWindow() -{ -} - diff --git a/src/b2qt-flashing-wizard/mainwindow.h b/src/b2qt-flashing-wizard/mainwindow.h deleted file mode 100644 index 517520e..0000000 --- a/src/b2qt-flashing-wizard/mainwindow.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QWizard> - -class MainWindow : public QWizard -{ - Q_OBJECT - -public: - enum {Page_Intro, Page_Platform, Page_Disk, Page_Device, Page_Commit, Page_Progress, Page_Finish}; - MainWindow(); - virtual ~MainWindow(); -}; - -#endif // MAINWINDOW_H diff --git a/src/b2qt-flashing-wizard/platform_page.cpp b/src/b2qt-flashing-wizard/platform_page.cpp deleted file mode 100644 index 98dbf56..0000000 --- a/src/b2qt-flashing-wizard/platform_page.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "platform_page.h" -#include <QRadioButton> -#include <QLayout> -#include <QDebug> -#include <QDir> -#include <QLabel> -#include <QSpacerItem> -#include <QSettings> -#include "mainwindow.h" // Page_ enum - -static QList<PlatformInfo> platforms; -extern QString G_SDKDIR; -extern PlatformInfo G_platforminfo; - -QLabel *createErrorLabel(QWidget *parent) -{ - QLabel *label = new QLabel(parent); - label->setAlignment(Qt::AlignHCenter); - label->setWordWrap(true); - - QFont f = label->font(); - f.setBold(true); - label->setFont(f); - - QPalette p = label->palette(); - p.setColor(QPalette::WindowText, Qt::red); - label->setPalette(p); - - return label; -} - -PlatformPage::PlatformPage(QWidget *parent) - : QWizardPage(parent) - , mError(createErrorLabel(this)) - , mLayout(new QVBoxLayout(this)) -{ - setTitle(tr("Platform")); - setSubTitle(tr("Select a platform to create a disk for")); - mLayout->addSpacerItem(new QSpacerItem(40,40,QSizePolicy::Minimum, QSizePolicy::Expanding)); - mLayout->addWidget(mError); - setLayout(mLayout); -} - -PlatformPage::~PlatformPage() -{ -} - -bool PlatformPage::isComplete() const -{ - if (mButtons.isEmpty() || buttonData().name.isEmpty()) - return false; - return true; -} - -void PlatformPage::itemSelected() -{ - mError->clear(); - emit completeChanged(); -} - -static void loadDeployConfig(const QString &filename, const QString &version) -{ - qDebug() << "Trying to load config" << filename; - if (!QFile::exists(filename)) - return; - - QFileInfo fi(filename); - - QSettings settings(filename, QSettings::IniFormat); - - foreach (const QString &group, settings.childGroups()) { - PlatformInfo pi; - - settings.beginGroup(group); - pi.name = group; - pi.platform = settings.value("platform").toString(); - pi.os = settings.value("os").toString(); - pi.androidversion = settings.value("androidversion").toString(); - pi.board = settings.value("board").toString(); - pi.deployCommand = settings.value("deploycommand").toString(); - pi.deployCommand = QDir::cleanPath(fi.canonicalPath() + "/" + pi.deployCommand); - pi.deployArguments = settings.value("deployarguments").toStringList(); - pi.asroot = settings.value("asroot").toBool(); - pi.version = version; - settings.endGroup(); - - if (pi.platform.isEmpty() || pi.os.isEmpty() || pi.deployCommand.isEmpty()) { - qWarning() << "Invalid data"; - continue; - } - - if (pi.os == "eAndroid" && pi.androidversion.isEmpty()) { - qWarning() << "Invalid data"; - continue; - } - - qDebug() << "Adding platform" << group; - platforms.append(pi); - } -} - -void PlatformPage::initializePage() -{ - mError->clear(); - - platforms.clear(); - qDeleteAll(mButtons); - mButtons.clear(); - - QDir dir(G_SDKDIR); - foreach (const QString i, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { - QDir dir2(dir.absoluteFilePath(i)); - - if (i.startsWith("Boot2Qt-")) { - // nothing - } else if (dir2.exists("Boot2Qt")) { - dir2 = dir2.absoluteFilePath("Boot2Qt"); - } else { - continue; - } - - foreach (const QString j, dir2.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { - if (j.startsWith("emulator-")) - continue; - - loadDeployConfig(dir2.absoluteFilePath(j) + "/images/deploy.conf", i); - } - } - if (platforms.isEmpty()) { - mError->setText(tr("No suitable platform found in '%1'.\nMake sure you have " - "installed at least one hardware platform.").arg(G_SDKDIR)); - } - - for (int i = 0; i < platforms.count(); ++i) { - const PlatformInfo &pi = platforms[i]; - QRadioButton *button = new QRadioButton; - if (pi.os == "eAndroid") - button->setText(pi.name + " | " + pi.os + " " + pi.androidversion + " (" + pi.version + ")"); - else - button->setText(pi.name + " | " + pi.os + " (" + pi.version + ")"); - mLayout->insertWidget(0, button); - connect(button, &QRadioButton::toggled, this, &PlatformPage::itemSelected); - button->setProperty("b2qt-platform-name", i); - mButtons.append(button); - } -} - -PlatformInfo PlatformPage::buttonData() const -{ - foreach (QRadioButton *button, mButtons) { - if (button->isChecked()) { - int id = button->property("b2qt-platform-name").toInt(); - return platforms[id]; - } - } - - return PlatformInfo(); -} - -bool PlatformPage::validatePage() -{ - G_platforminfo = buttonData(); - qDebug() << "Selected:" << G_platforminfo.name; - return true; -} - -int PlatformPage::nextId() const -{ - if (G_platforminfo.board.startsWith("nexus7")) - return MainWindow::Page_Device; - else - return MainWindow::Page_Disk; -} - diff --git a/src/b2qt-flashing-wizard/platform_page.h b/src/b2qt-flashing-wizard/platform_page.h deleted file mode 100644 index f14f207..0000000 --- a/src/b2qt-flashing-wizard/platform_page.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef PLATFORM_PAGE_H -#define PLATFORM_PAGE_H - -#include "platforminfo.h" -#include <QWizardPage> -class QRadioButton; -class QLabel; -class QVBoxLayout; - -class PlatformPage : public QWizardPage -{ - Q_OBJECT -public: - PlatformPage(QWidget *parent = 0); - virtual ~PlatformPage(); - bool isComplete() const; - void initializePage(); - bool validatePage(); - int nextId() const; - -private slots: - void itemSelected(); - -private: - PlatformInfo buttonData() const; - - QList<QRadioButton*> mButtons; - QLabel *mError; - QVBoxLayout *mLayout; -}; - -#endif // PLATFORM_PAGE_H diff --git a/src/b2qt-flashing-wizard/platforminfo.h b/src/b2qt-flashing-wizard/platforminfo.h deleted file mode 100644 index 5108aec..0000000 --- a/src/b2qt-flashing-wizard/platforminfo.h +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef PLATFORMINFO_H -#define PLATFORMINFO_H - -#include <QStringList> - -class PlatformInfo { -public: - PlatformInfo() : asroot(false) { } - QString name; // Display name - QString platform; // generic-4.4 / iMX6 - QString os; // eAndroid / eLinux - QString board; // nexus7v2,nexus7, etc... - QString deployCommand; // script - QStringList deployArguments; - QString androidversion; - QString version; // Boot2Qt version - bool asroot; // script needs root privileges -}; - -#endif // PLATFORMINFO_H diff --git a/src/b2qt-flashing-wizard/progress_page.cpp b/src/b2qt-flashing-wizard/progress_page.cpp deleted file mode 100644 index e9203b3..0000000 --- a/src/b2qt-flashing-wizard/progress_page.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "progress_page.h" -#include "actor.h" -#include <QApplication> -#include <QClipboard> -#include <QDebug> -#include <QLabel> -#include <QLayout> -#include <QProgressBar> -#include <QPushButton> -#include <QScrollBar> -#include <QTextEdit> -#include <QTimer> - -ProgressPage::ProgressPage(QWidget *parent) - : QWizardPage(parent) - , mProgress(new QLabel(this)) - , mActor(0) - , mFinished(false) - , mTextEdit(new QTextEdit(this)) - , mToggleDetailsButton(new QPushButton(this)) - , mCopyToClipboardButton(new QPushButton(this)) - , mProgressBar(0) -{ - setTitle(tr("Disk Creation")); - setSubTitle(tr("Writing the hardware platform image to the disk")); - setLayout(new QVBoxLayout(this)); - mProgressBar = new QProgressBar(this); - mProgressBar->setRange(0, 0); - layout()->addWidget(mProgressBar); - mProgress->setWordWrap(true); - mProgress->setText(tr("Preparing the disk device...")); - layout()->addWidget(mProgress); - mToggleDetailsButton->setText(tr("Show details")); - layout()->addWidget(mToggleDetailsButton); - layout()->addWidget(mTextEdit); - mCopyToClipboardButton->setText(tr("Copy to clipboard")); - layout()->addWidget(mCopyToClipboardButton); - - mTextEdit->hide(); - mCopyToClipboardButton->hide(); - - connect(mToggleDetailsButton, &QPushButton::clicked, this, &ProgressPage::toggleDetails); - connect(mCopyToClipboardButton, &QPushButton::clicked, this, &ProgressPage::copyDetailsToClipboard); -} - -ProgressPage::~ProgressPage() -{ -} - -bool ProgressPage::isComplete() const -{ - return mFinished; -} - -void ProgressPage::initializePage() -{ - Q_ASSERT(mActor); - mActor->start(); -} - -void ProgressPage::progress(const QString &step) -{ - mProgress->setText(step); -} - -void ProgressPage::finished() -{ - mFinished = true; - emit completeChanged(); - wizard()->next(); // progress to next page automatically -} - -void ProgressPage::failed(const QString &message) -{ - mFinished = false; - emit completeChanged(); - showDetails(); - mProgressBar->setEnabled(false); - mProgressBar->setRange(0, 100); - mProgressBar->setValue(100); - mProgressBar->setFormat(""); - - // Scroll to bottom - mTextEdit->verticalScrollBar()->setValue(mTextEdit->verticalScrollBar()->maximum()); - mProgress->setText(message); -} - -void ProgressPage::setActor(Actor *actor) -{ - Q_ASSERT(actor); - mActor = actor; - connect(actor, &Actor::finished, this, &ProgressPage::finished); - connect(actor, &Actor::failed, this, &ProgressPage::failed); - connect(actor, &Actor::details, this, &ProgressPage::addDetails); - connect(actor, &Actor::errorDetails, this, &ProgressPage::addErrorDetails); - connect(actor, &Actor::progress, this, &ProgressPage::progress); -} - -static void commonDetailReplacements(QByteArray &data) -{ - data.replace(0x08 /* backspace */, ' '); -} - -void ProgressPage::addDetails(QByteArray newData) -{ - commonDetailReplacements(newData); - mTextEdit->insertPlainText(QString::fromLocal8Bit(newData)); -} - -void ProgressPage::addErrorDetails(QByteArray newData) -{ - if (newData.startsWith('+')) { - addDetails(newData); - return; - } - commonDetailReplacements(newData); - QColor c = mTextEdit->textColor(); - mTextEdit->setTextColor(Qt::red); - mTextEdit->insertPlainText(QString::fromLocal8Bit(newData)); - mTextEdit->setTextColor(c); -} - -void ProgressPage::showDetails() -{ - mTextEdit->show(); - mCopyToClipboardButton->show(); - mToggleDetailsButton->setText(tr("Hide details")); -} - -void ProgressPage::hideDetails() -{ - mTextEdit->hide(); - mCopyToClipboardButton->hide(); - mToggleDetailsButton->setText(tr("Show details")); -} - -void ProgressPage::toggleDetails() -{ - if (mTextEdit->isHidden()) - showDetails(); - else - hideDetails(); -} - -void ProgressPage::copyDetailsToClipboard() -{ - QApplication::clipboard()->setText(mTextEdit->toPlainText()); -} diff --git a/src/b2qt-flashing-wizard/progress_page.h b/src/b2qt-flashing-wizard/progress_page.h deleted file mode 100644 index 393619d..0000000 --- a/src/b2qt-flashing-wizard/progress_page.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef PROGRESS_PAGE_H -#define PROGRESS_PAGE_H - -#include <QWizardPage> -class QLabel; -class Actor; -class QTextEdit; -class QPushButton; -class QProgressBar; - -class ProgressPage : public QWizardPage -{ - Q_OBJECT -public: - ProgressPage(QWidget *parent = 0); - virtual ~ProgressPage(); - bool isComplete() const; - void initializePage(); - void setActor(Actor *actor); - -public slots: - void progress(const QString &step); - void finished(); - void failed(const QString &step); - void addDetails(QByteArray newData); - void addErrorDetails(QByteArray newData); - void showDetails(); - void hideDetails(); - void toggleDetails(); - void copyDetailsToClipboard(); - -private: - QLabel *mProgress; - Actor *mActor; - bool mFinished; - QTextEdit *mTextEdit; - QPushButton *mToggleDetailsButton; - QPushButton *mCopyToClipboardButton; - QProgressBar *mProgressBar; -}; - -#endif // PROGRESS_PAGE_H diff --git a/src/b2qt-flashing-wizard/scriptwriter.cpp b/src/b2qt-flashing-wizard/scriptwriter.cpp deleted file mode 100644 index 4e38bdd..0000000 --- a/src/b2qt-flashing-wizard/scriptwriter.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#include "scriptwriter.h" -#include <QPair> -#include <QStringList> -#include <QFileInfo> -#include <QDebug> -#include <QTimer> -#include <QProcessEnvironment> -#include <QElapsedTimer> -#include <sys/stat.h> -#include "elevator.h" -#include "common.h" - -ScriptWriter::ScriptWriter(QObject *parent) - : Actor(parent) - , mDebug(false) - , mRoot(false) -{ - mDebug = qEnvironmentVariableIsSet("DEBUG"); -} - -ScriptWriter::~ScriptWriter() -{ -} - -void ScriptWriter::setScriptFile(const QString &fileName) -{ - mScriptName = fileName; -} - -bool ScriptWriter::ready(QString &error) const -{ - if (mScriptName.isEmpty()) { - error = tr("File name is empty"); - return false; - } - - QFileInfo file(mScriptName); - if (!file.exists()) { - error = tr("File does not exist: %1").arg(mScriptName); - return false; - } - if (!file.isFile()) { - error = tr("File %1 is not a file").arg(mScriptName); - return false; - } - if (!file.isReadable()) { - error = tr("File is not readable"); - return false; - } - if (!file.isExecutable()) { - error = tr("File is not executable"); - return false; - } - if (file.size() == 0) { - error = tr("File is empty"); - return false; - } - - return true; -} - -void ScriptWriter::start() -{ - connect(&mProcess, &QProcess::readyReadStandardOutput, this, &ScriptWriter::readStandardOutput); - connect(&mProcess, &QProcess::readyReadStandardError, this, &ScriptWriter::readStandardError); - connect(&mProcess, (void (QProcess::*)(QProcess::ProcessError))&QProcess::error, this, &ScriptWriter::processError); - connect(&mProcess, (void (QProcess::*)(int, QProcess::ExitStatus))&QProcess::finished, this, &ScriptWriter::processFinished); - - QStringList args; - - if (mRoot) - args << elevate(); - args << "/bin/sh" << "-x" << mScriptName << mAdditionalArgs; - qDebug() << "Executing" << args; - - mProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment()); - - mProcess.start(args.takeFirst(), args); - if (!mProcess.waitForStarted()) - qFatal("Failed to start script"); -} - -void ScriptWriter::readStandardOutput() -{ - QByteArray ba = mProcess.readAllStandardOutput(); - QList<QByteArray> baList = ba.split('\n'); - - foreach (const QByteArray &line, baList) { - if (line.startsWith("-- STEP -- ")) - emit progress(QString::fromLocal8Bit(line.mid(11).trimmed())); - } - - emit details(ba); -} - -void ScriptWriter::readStandardError() -{ - QByteArray ba = mProcess.readAllStandardError(); - emit errorDetails(ba); -} - -void ScriptWriter::processFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - if (exitStatus != QProcess::NormalExit || exitCode != 0) { - emit failed(tr("Image creation failed")); - return; - } - emit finished(); -} - -void ScriptWriter::processError(QProcess::ProcessError error) -{ - qWarning() << "processError" << error; -} - -void ScriptWriter::setEnvironment(const QString &key, const QString &value) -{ - QProcessEnvironment env = mProcess.processEnvironment(); - env.insert(key, value); - mProcess.setProcessEnvironment(env); -} - -void ScriptWriter::setAdditionalArgs(const QStringList &args) -{ - mAdditionalArgs = args; -} - -void ScriptWriter::setRootFlag(bool value) -{ - mRoot = value; -} diff --git a/src/b2qt-flashing-wizard/scriptwriter.h b/src/b2qt-flashing-wizard/scriptwriter.h deleted file mode 100644 index a984577..0000000 --- a/src/b2qt-flashing-wizard/scriptwriter.h +++ /dev/null @@ -1,55 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Digia Plc -** All rights reserved. -** For any questions to Digia, please use the contact form at -** http://qt.digia.com/ -** -** This file is part of Qt Enterprise Embedded. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** the contact form at http://qt.digia.com/ -** -****************************************************************************/ - -#ifndef SCRIPTWRITER_H -#define SCRIPTWRITER_H - -#include "actor.h" -#include <QProcess> -class QElapsedTimer; - -class ScriptWriter : public Actor -{ - Q_OBJECT - -public: - ScriptWriter(QObject *parent); - virtual ~ScriptWriter(); - void setScriptFile(const QString &fileName); - bool ready(QString &) const; - void start(); - void setEnvironment(const QString &key, const QString &value); - void setAdditionalArgs(const QStringList &); - void setRootFlag(bool); - -private slots: - void readStandardOutput(); - void readStandardError(); - void processFinished(int, QProcess::ExitStatus); - void processError(QProcess::ProcessError); - -private: - QString mScriptName; - QProcess mProcess; - QStringList mAdditionalArgs; - bool mDebug; - bool mRoot; -}; - -#endif // SCRIPTWRITER_H diff --git a/src/b2qt-flashing-wizard/sync.profile b/src/b2qt-flashing-wizard/sync.profile deleted file mode 100644 index 8d7f77e..0000000 --- a/src/b2qt-flashing-wizard/sync.profile +++ /dev/null @@ -1,3 +0,0 @@ -%dependencies = ( - "qtbase" => "", -); diff --git a/src/b2qt-flashing-wizard/watermark.png b/src/b2qt-flashing-wizard/watermark.png Binary files differdeleted file mode 100644 index c154c54..0000000 --- a/src/b2qt-flashing-wizard/watermark.png +++ /dev/null |