mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-03 06:41:14 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into commerce_zachsPunchlist2
This commit is contained in:
commit
e0878e7a3f
6 changed files with 44 additions and 20 deletions
|
@ -183,7 +183,6 @@
|
||||||
#include "ui/UpdateDialog.h"
|
#include "ui/UpdateDialog.h"
|
||||||
#include "ui/overlays/Overlays.h"
|
#include "ui/overlays/Overlays.h"
|
||||||
#include "ui/DomainConnectionModel.h"
|
#include "ui/DomainConnectionModel.h"
|
||||||
#include "ui/ImageProvider.h"
|
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include "InterfaceParentFinder.h"
|
#include "InterfaceParentFinder.h"
|
||||||
#include "ui/OctreeStatsProvider.h"
|
#include "ui/OctreeStatsProvider.h"
|
||||||
|
@ -2246,8 +2245,6 @@ void Application::initializeUi() {
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
});
|
});
|
||||||
|
|
||||||
// register the pixmap image provider (used only for security image, for now)
|
|
||||||
engine->addImageProvider(ImageProvider::PROVIDER_NAME, new ImageProvider());
|
|
||||||
|
|
||||||
setupPreferences();
|
setupPreferences();
|
||||||
|
|
||||||
|
|
|
@ -224,6 +224,12 @@ void initializeAESKeys(unsigned char* ivec, unsigned char* ckey, const QByteArra
|
||||||
memcpy(ckey, hash.data(), 32);
|
memcpy(ckey, hash.data(), 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Wallet::~Wallet() {
|
||||||
|
if (_securityImage) {
|
||||||
|
delete _securityImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Wallet::setPassphrase(const QString& passphrase) {
|
void Wallet::setPassphrase(const QString& passphrase) {
|
||||||
if (_passphrase) {
|
if (_passphrase) {
|
||||||
delete _passphrase;
|
delete _passphrase;
|
||||||
|
@ -411,6 +417,13 @@ QString Wallet::signWithKey(const QByteArray& text, const QString& key) {
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wallet::updateImageProvider() {
|
||||||
|
// inform the image provider. Note it doesn't matter which one you inform, as the
|
||||||
|
// images are statics
|
||||||
|
auto engine = DependencyManager::get<OffscreenUi>()->getSurfaceContext()->engine();
|
||||||
|
auto imageProvider = reinterpret_cast<ImageProvider*>(engine->imageProvider(ImageProvider::PROVIDER_NAME));
|
||||||
|
imageProvider->setSecurityImage(_securityImage);
|
||||||
|
}
|
||||||
|
|
||||||
void Wallet::chooseSecurityImage(const QString& filename) {
|
void Wallet::chooseSecurityImage(const QString& filename) {
|
||||||
|
|
||||||
|
@ -431,10 +444,7 @@ void Wallet::chooseSecurityImage(const QString& filename) {
|
||||||
if (encryptFile(path, imageFilePath())) {
|
if (encryptFile(path, imageFilePath())) {
|
||||||
qCDebug(commerce) << "emitting pixmap";
|
qCDebug(commerce) << "emitting pixmap";
|
||||||
|
|
||||||
// inform the image provider
|
updateImageProvider();
|
||||||
auto engine = DependencyManager::get<OffscreenUi>()->getSurfaceContext()->engine();
|
|
||||||
auto imageProvider = reinterpret_cast<ImageProvider*>(engine->imageProvider(ImageProvider::PROVIDER_NAME));
|
|
||||||
imageProvider->setSecurityImage(_securityImage);
|
|
||||||
|
|
||||||
emit securityImageResult(true);
|
emit securityImageResult(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -460,10 +470,7 @@ void Wallet::getSecurityImage() {
|
||||||
_securityImage->loadFromData(data, dataLen, "jpg");
|
_securityImage->loadFromData(data, dataLen, "jpg");
|
||||||
qCDebug(commerce) << "created pixmap from encrypted file";
|
qCDebug(commerce) << "created pixmap from encrypted file";
|
||||||
|
|
||||||
// inform the image provider
|
updateImageProvider();
|
||||||
auto engine = DependencyManager::get<OffscreenUi>()->getSurfaceContext()->engine();
|
|
||||||
auto imageProvider = reinterpret_cast<ImageProvider*>(engine->imageProvider(ImageProvider::PROVIDER_NAME));
|
|
||||||
imageProvider->setSecurityImage(_securityImage);
|
|
||||||
|
|
||||||
delete[] data;
|
delete[] data;
|
||||||
emit securityImageResult(true);
|
emit securityImageResult(true);
|
||||||
|
|
|
@ -23,6 +23,8 @@ class Wallet : public QObject, public Dependency {
|
||||||
SINGLETON_DEPENDENCY
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
~Wallet();
|
||||||
// These are currently blocking calls, although they might take a moment.
|
// These are currently blocking calls, although they might take a moment.
|
||||||
bool createIfNeeded();
|
bool createIfNeeded();
|
||||||
bool generateKeyPair();
|
bool generateKeyPair();
|
||||||
|
@ -48,6 +50,7 @@ private:
|
||||||
QByteArray _salt {"iamsalt!"};
|
QByteArray _salt {"iamsalt!"};
|
||||||
QString* _passphrase { new QString("pwd") };
|
QString* _passphrase { new QString("pwd") };
|
||||||
|
|
||||||
|
void updateImageProvider();
|
||||||
bool encryptFile(const QString& inputFilePath, const QString& outputFilePath);
|
bool encryptFile(const QString& inputFilePath, const QString& outputFilePath);
|
||||||
bool decryptFile(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
bool decryptFile(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferLen);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,13 +10,24 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ImageProvider.h"
|
#include "ImageProvider.h"
|
||||||
#include <QDebug>
|
|
||||||
|
#include <QReadLocker>
|
||||||
|
#include <QWriteLocker>
|
||||||
|
|
||||||
const QString ImageProvider::PROVIDER_NAME = "security";
|
const QString ImageProvider::PROVIDER_NAME = "security";
|
||||||
|
QReadWriteLock ImageProvider::_rwLock;
|
||||||
|
QPixmap* ImageProvider::_securityImage = nullptr;
|
||||||
|
|
||||||
|
void ImageProvider::setSecurityImage(QPixmap* pixmap) {
|
||||||
|
// no need to delete old one, that is managed by the wallet
|
||||||
|
QWriteLocker lock(&_rwLock);
|
||||||
|
_securityImage = pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) {
|
QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) {
|
||||||
|
|
||||||
// adjust the internal pixmap to have the requested size
|
// adjust the internal pixmap to have the requested size
|
||||||
|
QReadLocker lock(&_rwLock);
|
||||||
if (id == "securityImage" && _securityImage) {
|
if (id == "securityImage" && _securityImage) {
|
||||||
*size = _securityImage->size();
|
*size = _securityImage->size();
|
||||||
if (requestedSize.width() > 0 && requestedSize.height() > 0) {
|
if (requestedSize.width() > 0 && requestedSize.height() > 0) {
|
|
@ -13,6 +13,7 @@
|
||||||
#define hifi_ImageProvider_h
|
#define hifi_ImageProvider_h
|
||||||
|
|
||||||
#include <QQuickImageProvider>
|
#include <QQuickImageProvider>
|
||||||
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
class ImageProvider: public QQuickImageProvider {
|
class ImageProvider: public QQuickImageProvider {
|
||||||
public:
|
public:
|
||||||
|
@ -22,10 +23,10 @@ public:
|
||||||
|
|
||||||
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;
|
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;
|
||||||
|
|
||||||
void setSecurityImage(QPixmap* pixmap) { _securityImage = pixmap; }
|
void setSecurityImage(QPixmap* pixmap);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QPixmap* _securityImage { nullptr };
|
static QReadWriteLock _rwLock;
|
||||||
|
static QPixmap* _securityImage;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
#include "OffscreenQmlSurface.h"
|
#include "OffscreenQmlSurface.h"
|
||||||
|
#include "ImageProvider.h"
|
||||||
|
|
||||||
// Has to come before Qt GL includes
|
// Has to come before Qt GL includes
|
||||||
#include <gl/Config.h>
|
#include <gl/Config.h>
|
||||||
|
@ -305,6 +306,9 @@ static size_t globalEngineRefCount{ 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initializeQmlEngine(QQmlEngine* engine, QQuickWindow* window) {
|
void initializeQmlEngine(QQmlEngine* engine, QQuickWindow* window) {
|
||||||
|
// register the pixmap image provider (used only for security image, for now)
|
||||||
|
engine->addImageProvider(ImageProvider::PROVIDER_NAME, new ImageProvider());
|
||||||
|
|
||||||
engine->setNetworkAccessManagerFactory(new QmlNetworkAccessManagerFactory);
|
engine->setNetworkAccessManagerFactory(new QmlNetworkAccessManagerFactory);
|
||||||
auto importList = engine->importPathList();
|
auto importList = engine->importPathList();
|
||||||
importList.insert(importList.begin(), PathUtils::resourcesPath());
|
importList.insert(importList.begin(), PathUtils::resourcesPath());
|
||||||
|
@ -526,6 +530,7 @@ void OffscreenQmlSurface::create() {
|
||||||
|
|
||||||
// Create a QML engine.
|
// Create a QML engine.
|
||||||
auto qmlEngine = acquireEngine(_quickWindow);
|
auto qmlEngine = acquireEngine(_quickWindow);
|
||||||
|
|
||||||
_qmlContext = new QQmlContext(qmlEngine->rootContext());
|
_qmlContext = new QQmlContext(qmlEngine->rootContext());
|
||||||
|
|
||||||
_qmlContext->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow()));
|
_qmlContext->setContextProperty("offscreenWindow", QVariant::fromValue(getWindow()));
|
||||||
|
|
Loading…
Reference in a new issue