mirror of
https://github.com/lubosz/overte.git
synced 2025-04-27 00:55:42 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into black
This commit is contained in:
commit
4035478b9a
14 changed files with 108 additions and 57 deletions
interface
resources/qml/hifi
commerce/wallet
tablet
src
scripts
unpublishedScripts/marketplace/blocks
|
@ -40,10 +40,8 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
onKeyFilePathResult: {
|
||||
if (path !== "") {
|
||||
keyFilePath.text = path;
|
||||
}
|
||||
onKeyFilePathIfExistsResult: {
|
||||
keyFilePath.text = path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +262,7 @@ Item {
|
|||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
commerce.getKeyFilePath();
|
||||
commerce.getKeyFilePathIfExists();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,9 @@ Rectangle {
|
|||
|
||||
id: root;
|
||||
|
||||
property string activeView: "walletHome";
|
||||
property string activeView: "initialize";
|
||||
property bool securityImageResultReceived: false;
|
||||
property bool keyFilePathIfExistsResultReceived: false;
|
||||
|
||||
// Style
|
||||
color: hifi.colors.baseGray;
|
||||
|
@ -33,16 +35,20 @@ Rectangle {
|
|||
id: commerce;
|
||||
|
||||
onSecurityImageResult: {
|
||||
if (!exists) { // "If security image is not set up"
|
||||
if (root.activeView !== "notSetUp") {
|
||||
root.activeView = "notSetUp";
|
||||
}
|
||||
securityImageResultReceived = true;
|
||||
if (!exists && root.activeView !== "notSetUp") { // "If security image is not set up"
|
||||
root.activeView = "notSetUp";
|
||||
} else if (root.securityImageResultReceived && exists && root.keyFilePathIfExistsResultReceived && root.activeView === "initialize") {
|
||||
root.activeView = "walletHome";
|
||||
}
|
||||
}
|
||||
|
||||
onKeyFilePathResult: {
|
||||
onKeyFilePathIfExistsResult: {
|
||||
keyFilePathIfExistsResultReceived = true;
|
||||
if (path === "" && root.activeView !== "notSetUp") {
|
||||
root.activeView = "notSetUp";
|
||||
} else if (root.securityImageResultReceived && root.keyFilePathIfExistsResultReceived && path !== "" && root.activeView === "initialize") {
|
||||
root.activeView = "walletHome";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +157,22 @@ Rectangle {
|
|||
//
|
||||
// TAB CONTENTS START
|
||||
//
|
||||
|
||||
Rectangle {
|
||||
id: initialize;
|
||||
visible: root.activeView === "initialize";
|
||||
anchors.top: titleBarContainer.bottom;
|
||||
anchors.bottom: parent.top;
|
||||
anchors.left: parent.left;
|
||||
anchors.right: parent.right;
|
||||
color: hifi.colors.baseGray;
|
||||
|
||||
Component.onCompleted: {
|
||||
commerce.getSecurityImage();
|
||||
commerce.getKeyFilePathIfExists();
|
||||
}
|
||||
}
|
||||
|
||||
NotSetUp {
|
||||
id: notSetUp;
|
||||
visible: root.activeView === "notSetUp";
|
||||
|
@ -283,13 +305,6 @@ Rectangle {
|
|||
onEntered: parent.color = hifi.colors.blueHighlight;
|
||||
onExited: parent.color = root.activeView === "walletHome" ? hifi.colors.blueAccent : hifi.colors.black;
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
commerce.getSecurityImage();
|
||||
commerce.balance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "SEND MONEY" tab button
|
||||
|
@ -382,13 +397,6 @@ Rectangle {
|
|||
onEntered: parent.color = hifi.colors.blueHighlight;
|
||||
onExited: parent.color = root.activeView === "security" ? hifi.colors.blueAccent : hifi.colors.black;
|
||||
}
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
commerce.getSecurityImage();
|
||||
commerce.getKeyFilePath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// "HELP" tab button
|
||||
|
|
|
@ -56,10 +56,8 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
|
||||
onKeyFilePathResult: {
|
||||
if (path !== "") {
|
||||
keyFilePath.text = path;
|
||||
}
|
||||
onKeyFilePathIfExistsResult: {
|
||||
keyFilePath.text = path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,10 +453,10 @@ Rectangle {
|
|||
text: "Next";
|
||||
onClicked: {
|
||||
if (passphraseSelection.validateAndSubmitPassphrase()) {
|
||||
root.lastPage = "passphrase";
|
||||
root.lastPage = "choosePassphrase";
|
||||
commerce.balance(); // Do this here so that keys are generated. Order might change as backend changes?
|
||||
choosePassphraseContainer.visible = false;
|
||||
privateKeysReadyContainer.visible = true;
|
||||
commerce.balance(); // Do this here so that keys are generated. Order might change as backend changes?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -562,7 +560,7 @@ Rectangle {
|
|||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
commerce.getKeyFilePath();
|
||||
commerce.getKeyFilePathIfExists();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
10
interface/resources/qml/hifi/tablet/BlocksWebView.qml
Normal file
10
interface/resources/qml/hifi/tablet/BlocksWebView.qml
Normal file
|
@ -0,0 +1,10 @@
|
|||
import QtQuick 2.0
|
||||
import QtWebEngine 1.2
|
||||
|
||||
import "../../controls" as Controls
|
||||
|
||||
Controls.TabletWebView {
|
||||
profile: WebEngineProfile { httpUserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36"}
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ Item {
|
|||
|
||||
function loadTabletWebBase() {
|
||||
loader.source = "";
|
||||
loader.source = "../../controls/TabletWebView.qml";
|
||||
loader.source = "./BlocksWebView.qml";
|
||||
}
|
||||
|
||||
function returnToPreviousApp() {
|
||||
|
|
|
@ -44,7 +44,7 @@ Windows.ScrollingWindow {
|
|||
|
||||
function loadTabletWebBase() {
|
||||
loader.source = "";
|
||||
loader.source = "../../controls/TabletWebView.qml";
|
||||
loader.source = "./BlocksWebView.qml";
|
||||
}
|
||||
|
||||
function loadWebUrl(url, injectedJavaScriptUrl) {
|
||||
|
|
|
@ -6457,7 +6457,7 @@ void Application::addAssetToWorldFromURL(QString url) {
|
|||
}
|
||||
if (url.contains("vr.google.com/downloads")) {
|
||||
filename = url.section('/', -1);
|
||||
filename.remove(".zip?noDownload=false");
|
||||
filename.remove(".zip");
|
||||
}
|
||||
|
||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||
|
@ -6487,7 +6487,7 @@ void Application::addAssetToWorldFromURLRequestFinished() {
|
|||
}
|
||||
if (url.contains("vr.google.com/downloads")) {
|
||||
filename = url.section('/', -1);
|
||||
filename.remove(".zip?noDownload=false");
|
||||
filename.remove(".zip");
|
||||
isBlocks = true;
|
||||
}
|
||||
|
||||
|
@ -6504,6 +6504,7 @@ void Application::addAssetToWorldFromURLRequestFinished() {
|
|||
if (tempFile.open(QIODevice::WriteOnly)) {
|
||||
tempFile.write(request->getData());
|
||||
addAssetToWorldInfoClear(filename); // Remove message from list; next one added will have a different key.
|
||||
tempFile.close();
|
||||
qApp->getFileDownloadInterface()->runUnzip(downloadPath, url, true, false, isBlocks);
|
||||
} else {
|
||||
QString errorInfo = "Couldn't open temporary file for download";
|
||||
|
|
|
@ -25,7 +25,7 @@ QmlCommerce::QmlCommerce(QQuickItem* parent) : OffscreenQmlDialog(parent) {
|
|||
connect(ledger.data(), &Ledger::balanceResult, this, &QmlCommerce::balanceResult);
|
||||
connect(ledger.data(), &Ledger::inventoryResult, this, &QmlCommerce::inventoryResult);
|
||||
connect(wallet.data(), &Wallet::securityImageResult, this, &QmlCommerce::securityImageResult);
|
||||
connect(wallet.data(), &Wallet::keyFilePathResult, this, &QmlCommerce::keyFilePathResult);
|
||||
connect(wallet.data(), &Wallet::keyFilePathIfExistsResult, this, &QmlCommerce::keyFilePathIfExistsResult);
|
||||
}
|
||||
|
||||
void QmlCommerce::buy(const QString& assetId, int cost, const QString& buyerUsername) {
|
||||
|
@ -69,7 +69,7 @@ void QmlCommerce::setPassphrase(const QString& passphrase) {
|
|||
void QmlCommerce::getPassphraseSetupStatus() {
|
||||
emit passphraseSetupStatusResult(false);
|
||||
}
|
||||
void QmlCommerce::getKeyFilePath() {
|
||||
void QmlCommerce::getKeyFilePathIfExists() {
|
||||
auto wallet = DependencyManager::get<Wallet>();
|
||||
wallet->getKeyFilePath();
|
||||
wallet->sendKeyFilePathIfExists();
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ signals:
|
|||
void securityImageResult(bool exists);
|
||||
void loginStatusResult(bool isLoggedIn);
|
||||
void passphraseSetupStatusResult(bool passphraseIsSetup);
|
||||
void keyFilePathResult(const QString& path);
|
||||
void keyFilePathIfExistsResult(const QString& path);
|
||||
|
||||
protected:
|
||||
Q_INVOKABLE void buy(const QString& assetId, int cost, const QString& buyerUsername = "");
|
||||
|
@ -47,7 +47,7 @@ protected:
|
|||
Q_INVOKABLE void getLoginStatus();
|
||||
Q_INVOKABLE void setPassphrase(const QString& passphrase);
|
||||
Q_INVOKABLE void getPassphraseSetupStatus();
|
||||
Q_INVOKABLE void getKeyFilePath();
|
||||
Q_INVOKABLE void getKeyFilePathIfExists();
|
||||
};
|
||||
|
||||
#endif // hifi_QmlCommerce_h
|
||||
|
|
|
@ -220,8 +220,8 @@ static const unsigned char IVEC[16] = "IAmAnIVecYay123";
|
|||
void initializeAESKeys(unsigned char* ivec, unsigned char* ckey, const QByteArray& salt) {
|
||||
// first ivec
|
||||
memcpy(ivec, IVEC, 16);
|
||||
auto hash = QCryptographicHash::hash(salt, QCryptographicHash::Md5);
|
||||
memcpy(ckey, hash.data(), 16);
|
||||
auto hash = QCryptographicHash::hash(salt, QCryptographicHash::Sha256);
|
||||
memcpy(ckey, hash.data(), 32);
|
||||
}
|
||||
|
||||
void Wallet::setPassphrase(const QString& passphrase) {
|
||||
|
@ -238,7 +238,7 @@ bool Wallet::encryptFile(const QString& inputFilePath, const QString& outputFile
|
|||
// a constant. We can review this later - there are ways to generate keys
|
||||
// from a password that may be better.
|
||||
unsigned char ivec[16];
|
||||
unsigned char ckey[16];
|
||||
unsigned char ckey[32];
|
||||
|
||||
initializeAESKeys(ivec, ckey, _salt);
|
||||
|
||||
|
@ -292,7 +292,7 @@ bool Wallet::encryptFile(const QString& inputFilePath, const QString& outputFile
|
|||
|
||||
bool Wallet::decryptFile(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferSize) {
|
||||
unsigned char ivec[16];
|
||||
unsigned char ckey[16];
|
||||
unsigned char ckey[32];
|
||||
initializeAESKeys(ivec, ckey, _salt);
|
||||
|
||||
// read encrypted file
|
||||
|
@ -331,7 +331,6 @@ bool Wallet::decryptFile(const QString& inputFilePath, unsigned char** outputBuf
|
|||
*outputBufferSize += tempSize;
|
||||
*outputBufferPtr = outputBuffer;
|
||||
qCDebug(commerce) << "decrypted buffer size" << *outputBufferSize;
|
||||
delete[] outputBuffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -359,6 +358,7 @@ bool Wallet::createIfNeeded() {
|
|||
bool Wallet::generateKeyPair() {
|
||||
qCInfo(commerce) << "Generating keypair.";
|
||||
auto keyPair = generateRSAKeypair();
|
||||
sendKeyFilePathIfExists();
|
||||
QString oldKey = _publicKeys.count() == 0 ? "" : _publicKeys.last();
|
||||
QString key = keyPair.first->toBase64();
|
||||
_publicKeys.push_back(key);
|
||||
|
@ -465,12 +465,19 @@ void Wallet::getSecurityImage() {
|
|||
auto imageProvider = reinterpret_cast<ImageProvider*>(engine->imageProvider(ImageProvider::PROVIDER_NAME));
|
||||
imageProvider->setSecurityImage(_securityImage);
|
||||
|
||||
delete[] data;
|
||||
emit securityImageResult(true);
|
||||
} else {
|
||||
qCDebug(commerce) << "failed to decrypt security image (maybe none saved yet?)";
|
||||
emit securityImageResult(false);
|
||||
}
|
||||
}
|
||||
void Wallet::getKeyFilePath() {
|
||||
emit keyFilePathResult(keyFilePath());
|
||||
void Wallet::sendKeyFilePathIfExists() {
|
||||
QString filePath(keyFilePath());
|
||||
QFileInfo fileInfo(filePath);
|
||||
if (fileInfo.exists()) {
|
||||
emit keyFilePathIfExistsResult(filePath);
|
||||
} else {
|
||||
emit keyFilePathIfExistsResult("");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
QString signWithKey(const QByteArray& text, const QString& key);
|
||||
void chooseSecurityImage(const QString& imageFile);
|
||||
void getSecurityImage();
|
||||
void getKeyFilePath();
|
||||
void sendKeyFilePathIfExists();
|
||||
|
||||
void setSalt(const QByteArray& salt) { _salt = salt; }
|
||||
QByteArray getSalt() { return _salt; }
|
||||
|
@ -40,7 +40,7 @@ public:
|
|||
|
||||
signals:
|
||||
void securityImageResult(bool exists) ;
|
||||
void keyFilePathResult(const QString& path);
|
||||
void keyFilePathIfExistsResult(const QString& path);
|
||||
|
||||
protected:
|
||||
enum SecurityImage {
|
||||
|
|
|
@ -24,12 +24,12 @@ var DEFAULT_SCRIPTS_COMBINED = [
|
|||
"system/makeUserConnection.js",
|
||||
"system/tablet-goto.js",
|
||||
"system/marketplaces/marketplaces.js",
|
||||
"system/commerce/wallet.js",
|
||||
"system/edit.js",
|
||||
"system/notifications.js",
|
||||
"system/dialTone.js",
|
||||
"system/firstPersonHMD.js",
|
||||
"system/tablet-ui/tabletUI.js",
|
||||
"system/commerce/wallet.js"
|
||||
"system/tablet-ui/tabletUI.js"
|
||||
];
|
||||
var DEFAULT_SCRIPTS_SEPARATE = [
|
||||
"system/controllers/controllerScripts.js",
|
||||
|
|
|
@ -126,7 +126,8 @@
|
|||
button = tablet.addButton({
|
||||
text: buttonName,
|
||||
icon: "icons/tablet-icons/wallet-i.svg",
|
||||
activeIcon: "icons/tablet-icons/wallet-a.svg"
|
||||
activeIcon: "icons/tablet-icons/wallet-a.svg",
|
||||
sortOrder: 10
|
||||
});
|
||||
button.clicked.connect(onButtonClicked);
|
||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
||||
|
|
|
@ -15,28 +15,56 @@
|
|||
(function () {
|
||||
var APP_NAME = "BLOCKS";
|
||||
var APP_URL = "https://vr.google.com/objects/";
|
||||
var APP_OUTDATED_URL = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/updateToBlocks.html";
|
||||
var APP_ICON = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-i.svg";
|
||||
var APP_ICON_ACTIVE = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/blocks-a.svg";
|
||||
|
||||
try {
|
||||
print("Current Interface version: " + Window.checkVersion());
|
||||
} catch(err) {
|
||||
print("Outdated Interface version does not support Blocks");
|
||||
APP_URL = "https://hifi-content.s3.amazonaws.com/elisalj/blocks/updateToBlocks.html";
|
||||
APP_URL = APP_OUTDATED_URL;
|
||||
}
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
icon: APP_ICON,
|
||||
icon: APP_ICON,
|
||||
activeIcon: APP_ICON_ACTIVE,
|
||||
text: APP_NAME
|
||||
});
|
||||
|
||||
function onClicked() {
|
||||
tablet.gotoWebScreen(APP_URL, "", true);
|
||||
if (!shown) {
|
||||
tablet.gotoWebScreen(APP_URL, "", true);
|
||||
} else {
|
||||
tablet.gotoHomeScreen();
|
||||
}
|
||||
}
|
||||
button.clicked.connect(onClicked);
|
||||
|
||||
var shown = false;
|
||||
|
||||
function checkIfBlocks(url) {
|
||||
if (url.indexOf("google") !== -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
if ((type === 'Web' && checkIfBlocks(url)) || url === APP_OUTDATED_URL) {
|
||||
button.editProperties({ isActive: true });
|
||||
shown = true;
|
||||
} else {
|
||||
button.editProperties({ isActive: false });
|
||||
shown = false;
|
||||
}
|
||||
}
|
||||
|
||||
tablet.screenChanged.connect(onScreenChanged);
|
||||
|
||||
function cleanup() {
|
||||
tablet.removeButton(button);
|
||||
tablet.removeButton(button);
|
||||
}
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
|
|
Loading…
Reference in a new issue