From 92866a515039af1f986764457743531849435565 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 23 Feb 2015 09:54:10 +0100 Subject: [PATCH] small changes --- mix/FileIo.cpp | 39 +++++++++++++++--------------------- mix/FileIo.h | 2 +- mix/qml/DeploymentDialog.qml | 15 ++++---------- mix/qml/ProjectModel.qml | 2 +- mix/qml/js/ProjectModel.js | 4 ++-- 5 files changed, 24 insertions(+), 38 deletions(-) diff --git a/mix/FileIo.cpp b/mix/FileIo.cpp index b368e6a1f..d43c92ceb 100644 --- a/mix/FileIo.cpp +++ b/mix/FileIo.cpp @@ -20,8 +20,6 @@ * Ethereum IDE client. */ -#include -#include #include #include #include @@ -112,7 +110,7 @@ bool FileIo::fileExists(QString const& _url) return file.exists(); } -QStringList FileIo::compress(QString const& _deploymentFolder) +QStringList FileIo::makePackage(QString const& _deploymentFolder) { Json::Value manifest; @@ -124,42 +122,37 @@ QStringList FileIo::compress(QString const& _deploymentFolder) dev::RLPStream str; int k = 1; + QMap files; for (auto item: deployDir.entryInfoList(QDir::Files)) { QFile qFile(item.filePath()); - if (qFile.open(QIODevice::ReadOnly | QIODevice::Text)) - k++; - } - str.appendList(k); - - for (auto item: deployDir.entryInfoList(QDir::Files)) - { - QFile qFile(item.filePath()); - if (qFile.open(QIODevice::ReadOnly | QIODevice::Text)) + if (qFile.open(QIODevice::ReadOnly)) { + k++; QFileInfo i = QFileInfo(qFile.fileName()); - - QByteArray _a = qFile.readAll(); - bytes b = bytes(_a.begin(), _a.end()); - str.append(b); - Json::Value f; - f["path"] = "/"; //TODO: Manage relative sub folder + std::string path = i.fileName() == "index.html" ? "/" : i.fileName().toStdString(); + f["path"] = path; //TODO: Manage relative sub folder f["file"] = "/" + i.fileName().toStdString(); - f["contentType"] = "application/html"; //TODO: manage multiple content type - f["hash"] = toHex(dev::sha3(b).ref()); + f["contentType"] = "text/html"; //TODO: manage multiple content type + QByteArray _a = qFile.readAll(); + files.insert(path, bytesConstRef((const unsigned char*)_a.data(), _a.size())); + f["hash"] = toHex(dev::sha3(files.value(path)).ref()); entries.append(f); } qFile.close(); } - - manifest["entries"] = entries; + str.appendList(k); std::stringstream jsonStr; jsonStr << manifest; QByteArray b = QString::fromStdString(jsonStr.str()).toUtf8(); - str.append(bytes(b.begin(), b.end())); + str.append(bytesConstRef((const unsigned char*)b.data(), b.size())); + + for (auto item: files.keys()) + str.append(files.value(item)); + manifest["entries"] = entries; bytes dapp = str.out(); dev::h256 h = dev::sha3(dapp); //encrypt diff --git a/mix/FileIo.h b/mix/FileIo.h index 2048a37c6..3646627b8 100644 --- a/mix/FileIo.h +++ b/mix/FileIo.h @@ -54,7 +54,7 @@ public: /// Check if file exists Q_INVOKABLE bool fileExists(QString const& _url); /// Compress a folder, @returns sha3 of the compressed file. - Q_INVOKABLE QStringList compress(QString const& _deploymentFolder); + Q_INVOKABLE QStringList makePackage(QString const& _deploymentFolder); private: QString getHomePath() const; diff --git a/mix/qml/DeploymentDialog.qml b/mix/qml/DeploymentDialog.qml index e72866512..d84a4e8a7 100644 --- a/mix/qml/DeploymentDialog.qml +++ b/mix/qml/DeploymentDialog.qml @@ -110,17 +110,10 @@ Window { anchors.right: parent.right; anchors.bottomMargin: 10 Button { - text: qsTr("Deploy on Ethereum"); - tooltip: qsTr("Deploy the contract and Package ressources files.") + text: qsTr("Deploy to Ethereum"); + tooltip: qsTr("Deploy contract and package resources files.") onClicked: { - if (applicationUrlEth.text === "") - { - deployDialog.title = text; - deployDialog.text = qsTr("Please provide the Ethereum link you want to use for this application.") - deployDialog.open(); - } - else - deployWarningDialog.open(); + deployWarningDialog.open(); } } @@ -131,7 +124,7 @@ Window { if (applicationUrlHttp.text === "" || deploymentDialog.packageHash === "") { deployDialog.title = text; - deployDialog.text = qsTr("Please provide the link where the ressources are stored and ensure the package is aleary built using the deployment step. ") + deployDialog.text = qsTr("Please provide the link where the resources are stored and ensure the package is aleary built using the deployment step. ") deployDialog.open(); } else diff --git a/mix/qml/ProjectModel.qml b/mix/qml/ProjectModel.qml index 02929d39e..19008be5e 100644 --- a/mix/qml/ProjectModel.qml +++ b/mix/qml/ProjectModel.qml @@ -101,7 +101,7 @@ Item { { redeploy = true standardButtons = StandardButton.Ok | StandardButton.Reset | StandardButton.Abort; - return qsTr("This project has been already deployed to the network. Do you want to repackage the ressources only, or also reset the deployed contract to his initial state?") + return qsTr("This project has been already deployed to the network. Do you want to repackage the resources only, or also reset the deployed contract to its initial state?") } else { diff --git a/mix/qml/js/ProjectModel.js b/mix/qml/js/ProjectModel.js index c2f1a1d4b..f4a3817a7 100644 --- a/mix/qml/js/ProjectModel.js +++ b/mix/qml/js/ProjectModel.js @@ -390,7 +390,7 @@ function finalizeDeployment(deploymentId, addresses) { deploymentAddresses = addresses; saveProject(); - var packageRet = fileIo.compress(deploymentDir); + var packageRet = fileIo.makePackage(deploymentDir); deploymentDialog.packageHash = packageRet[0]; deploymentDialog.packageBase64 = packageRet[1]; @@ -531,7 +531,7 @@ function checkRegistration(dappUrl, addr, callBack) function registerToUrlHint() { - deploymentStepChanged(qsTr("Registering application Ressources (" + deploymentDialog.applicationUrlHttp) + ") ..."); + deploymentStepChanged(qsTr("Registering application Resources (" + deploymentDialog.applicationUrlHttp) + ") ..."); var requests = []; var paramUrlHttp = createString(deploymentDialog.applicationUrlHttp); requests.push({