forked from qt-creator/qt-creator
QNX: Set Author and Author ID from debug token in bar descriptor editor
This adds dependencies on private Qt headers for the QNX plugin, as we need the QZipReader to read the .bar file. Change-Id: Id70def551776a9d5ac43203cf807d2a0ca65e22f Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Tobias Hunger
parent
6821e50620
commit
d4a09cce3c
@@ -35,13 +35,18 @@
|
||||
#include "qnxconstants.h"
|
||||
#include "bardescriptoreditor.h"
|
||||
#include "bardescriptorpermissionsmodel.h"
|
||||
#include "blackberrydeviceconfiguration.h"
|
||||
#include "blackberrydebugtokenreader.h"
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <qtsupport/qtversionmanager.h>
|
||||
#include <texteditor/plaintexteditor.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QItemSelection>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardItemModel>
|
||||
#include <QStringListModel>
|
||||
|
||||
@@ -103,6 +108,8 @@ BarDescriptorEditorWidget::~BarDescriptorEditorWidget()
|
||||
|
||||
void BarDescriptorEditorWidget::initGeneralPage()
|
||||
{
|
||||
m_ui->setFromDebugToken->setVisible(BlackBerryDebugTokenReader::isSupported());
|
||||
|
||||
QRegExp versionNumberRegExp(QLatin1String("(\\d{1,3}\\.)?(\\d{1,3}\\.)?(\\d{1,3})"));
|
||||
QRegExpValidator *versionNumberValidator = new QRegExpValidator(versionNumberRegExp, this);
|
||||
m_ui->packageVersion->setValidator(versionNumberValidator);
|
||||
@@ -113,6 +120,7 @@ void BarDescriptorEditorWidget::initGeneralPage()
|
||||
|
||||
connect(m_ui->author, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
|
||||
connect(m_ui->authorId, SIGNAL(textChanged(QString)), this, SLOT(setDirty()));
|
||||
connect(m_ui->setFromDebugToken, SIGNAL(clicked()), this, SLOT(setAuthorFromDebugToken()));
|
||||
}
|
||||
|
||||
void BarDescriptorEditorWidget::clearGeneralPage()
|
||||
@@ -691,3 +699,35 @@ void BarDescriptorEditorWidget::addImageAsAsset(const QString &path)
|
||||
asset.entry = false;
|
||||
addAssetInternal(asset);
|
||||
}
|
||||
|
||||
void BarDescriptorEditorWidget::setAuthorFromDebugToken()
|
||||
{
|
||||
// To select debug token, make it fancier once the debug token management is done in
|
||||
// Qt Creator
|
||||
QStringList debugTokens;
|
||||
ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
|
||||
for (int i = 0; i < deviceManager->deviceCount(); ++i) {
|
||||
ProjectExplorer::IDevice::ConstPtr device = deviceManager->deviceAt(i);
|
||||
if (device->type() == Core::Id(Constants::QNX_BB_OS_TYPE)) {
|
||||
BlackBerryDeviceConfiguration::ConstPtr bbDevice = device.dynamicCast<const BlackBerryDeviceConfiguration>();
|
||||
QTC_ASSERT(bbDevice, continue);
|
||||
|
||||
debugTokens << bbDevice->debugToken();
|
||||
}
|
||||
}
|
||||
debugTokens.removeDuplicates();
|
||||
|
||||
bool ok;
|
||||
QString debugToken = QInputDialog::getItem(this, tr("Select Debug Token"), tr("Debug token:"), debugTokens, 0, false, &ok);
|
||||
if (!ok || debugToken.isEmpty())
|
||||
return;
|
||||
|
||||
BlackBerryDebugTokenReader debugTokenReader(debugToken);
|
||||
if (!debugTokenReader.isValid()) {
|
||||
QMessageBox::warning(this, tr("Error Reading Debug Token"), tr("There was a problem reading debug token"));
|
||||
return;
|
||||
}
|
||||
|
||||
m_ui->author->setText(debugTokenReader.author());
|
||||
m_ui->authorId->setText(debugTokenReader.authorId());
|
||||
}
|
||||
|
||||
@@ -137,6 +137,8 @@ signals:
|
||||
void changed();
|
||||
|
||||
private slots:
|
||||
void setAuthorFromDebugToken();
|
||||
|
||||
void addNewAsset();
|
||||
void removeSelectedAsset();
|
||||
void updateEntryCheckState(QStandardItem *item);
|
||||
|
||||
@@ -107,16 +107,23 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="author"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Author ID:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="authorId"/>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="setFromDebugToken">
|
||||
<property name="text">
|
||||
<string>Set from debug token...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
110
src/plugins/qnx/blackberrydebugtokenreader.cpp
Normal file
110
src/plugins/qnx/blackberrydebugtokenreader.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 - 2013 Research In Motion
|
||||
**
|
||||
** Contact: Research In Motion (blackberry-qt@qnx.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "blackberrydebugtokenreader.h"
|
||||
|
||||
#ifdef QNX_ZIP_FILE_SUPPORT
|
||||
#include <private/qzipreader_p.h>
|
||||
#endif
|
||||
|
||||
using namespace Qnx;
|
||||
using namespace Qnx::Internal;
|
||||
|
||||
namespace {
|
||||
const char MANIFEST_FILENAME[] = "META-INF/MANIFEST.MF";
|
||||
|
||||
const char MANIFEST_AUTHOR_KEY[] = "Package-Author: ";
|
||||
const char MANIFEST_AUTHOR_ID_KEY[] = "Package-Author-Id: ";
|
||||
}
|
||||
|
||||
BlackBerryDebugTokenReader::BlackBerryDebugTokenReader(const QString &filePath)
|
||||
{
|
||||
#ifdef QNX_ZIP_FILE_SUPPORT
|
||||
m_zipReader = new QZipReader(filePath);
|
||||
#endif
|
||||
}
|
||||
|
||||
BlackBerryDebugTokenReader::~BlackBerryDebugTokenReader()
|
||||
{
|
||||
#ifdef QNX_ZIP_FILE_SUPPORT
|
||||
m_zipReader->close();
|
||||
delete m_zipReader;
|
||||
m_zipReader = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool BlackBerryDebugTokenReader::isValid() const
|
||||
{
|
||||
#ifdef QNX_ZIP_FILE_SUPPORT
|
||||
return m_zipReader->status() == QZipReader::NoError;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString BlackBerryDebugTokenReader::author() const
|
||||
{
|
||||
return manifestValue(MANIFEST_AUTHOR_KEY);
|
||||
}
|
||||
|
||||
QString BlackBerryDebugTokenReader::authorId() const
|
||||
{
|
||||
return manifestValue(MANIFEST_AUTHOR_ID_KEY);
|
||||
}
|
||||
|
||||
bool BlackBerryDebugTokenReader::isSupported()
|
||||
{
|
||||
#ifdef QNX_ZIP_FILE_SUPPORT
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
QString BlackBerryDebugTokenReader::manifestValue(const QByteArray &key) const
|
||||
{
|
||||
if (!isValid())
|
||||
return QString();
|
||||
|
||||
#ifdef QNX_ZIP_FILE_SUPPORT
|
||||
QByteArray manifestContent = m_zipReader->fileData(QLatin1String(MANIFEST_FILENAME));
|
||||
return value(key, manifestContent);
|
||||
#else
|
||||
return QString();
|
||||
#endif
|
||||
}
|
||||
|
||||
QString BlackBerryDebugTokenReader::value(const QByteArray &key, const QByteArray &data) const
|
||||
{
|
||||
int valueStart = data.indexOf(key) + key.size();
|
||||
int valueEnd = data.indexOf(QByteArray("\r\n"), valueStart);
|
||||
return QString::fromAscii(data.mid(valueStart, valueEnd - valueStart));
|
||||
}
|
||||
67
src/plugins/qnx/blackberrydebugtokenreader.h
Normal file
67
src/plugins/qnx/blackberrydebugtokenreader.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/**************************************************************************
|
||||
**
|
||||
** Copyright (C) 2011 - 2013 Research In Motion
|
||||
**
|
||||
** Contact: Research In Motion (blackberry-qt@qnx.com)
|
||||
** Contact: KDAB (info@kdab.com)
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** GNU Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** In addition, as a special exception, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNX_INTERNAL_BLACKBERRYDEBUGTOKENREADER_H
|
||||
#define QNX_INTERNAL_BLACKBERRYDEBUGTOKENREADER_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QZipReader;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Qnx {
|
||||
namespace Internal {
|
||||
|
||||
class BlackBerryDebugTokenReader
|
||||
{
|
||||
public:
|
||||
BlackBerryDebugTokenReader(const QString &filePath);
|
||||
~BlackBerryDebugTokenReader();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
QString author() const;
|
||||
QString authorId() const;
|
||||
|
||||
static bool isSupported();
|
||||
|
||||
private:
|
||||
QString manifestValue(const QByteArray &key) const;
|
||||
QString value(const QByteArray &key, const QByteArray &data) const;
|
||||
|
||||
QZipReader *m_zipReader;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Qnx
|
||||
|
||||
#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENREADER_H
|
||||
@@ -72,6 +72,7 @@ SOURCES += qnxplugin.cpp \
|
||||
blackberrydebugtokenrequester.cpp \
|
||||
blackberrydebugtokenrequestdialog.cpp \
|
||||
blackberrydebugtokenuploader.cpp \
|
||||
blackberrydebugtokenreader.cpp \
|
||||
blackberryndkprocess.cpp
|
||||
|
||||
HEADERS += qnxplugin.h\
|
||||
@@ -141,6 +142,7 @@ HEADERS += qnxplugin.h\
|
||||
blackberrydebugtokenrequester.h \
|
||||
blackberrydebugtokenrequestdialog.h \
|
||||
blackberrydebugtokenuploader.h \
|
||||
blackberrydebugtokenreader.h \
|
||||
blackberryndkprocess.h
|
||||
|
||||
FORMS += \
|
||||
@@ -158,6 +160,14 @@ FORMS += \
|
||||
blackberrycreatecertificatedialog.ui \
|
||||
blackberrydebugtokenrequestdialog.ui
|
||||
|
||||
include(../../private_headers.pri)
|
||||
exists($${QT_PRIVATE_HEADERS}/QtGui/private/qzipreader_p.h) {
|
||||
DEFINES += QNX_ZIP_FILE_SUPPORT
|
||||
} else {
|
||||
warning("The QNX plugin depends on private headers from QtGui module, to be fully functional.")
|
||||
warning("To fix it, pass 'QT_PRIVATE_HEADERS=$QTDIR/include' to qmake, where $QTDIR is the source directory of qt.")
|
||||
}
|
||||
|
||||
DEFINES += QT_NO_CAST_TO_ASCII QT_NO_CAST_FROM_ASCII
|
||||
|
||||
RESOURCES += \
|
||||
|
||||
@@ -62,6 +62,8 @@ QtcPlugin {
|
||||
"blackberrydeploystepconfigwidget.h",
|
||||
"blackberrydeploystepfactory.cpp",
|
||||
"blackberrydeploystepfactory.h",
|
||||
"blackberrydebugtokenreader.cpp",
|
||||
"blackberrydebugtokenreader.h",
|
||||
"blackberrydeviceconfiguration.cpp",
|
||||
"blackberrydeviceconfiguration.h",
|
||||
"blackberrydeviceconfigurationfactory.cpp",
|
||||
|
||||
Reference in New Issue
Block a user