Browse Source

small changes

cl-refactor
yann300 10 years ago
parent
commit
92866a5150
  1. 39
      mix/FileIo.cpp
  2. 2
      mix/FileIo.h
  3. 15
      mix/qml/DeploymentDialog.qml
  4. 2
      mix/qml/ProjectModel.qml
  5. 4
      mix/qml/js/ProjectModel.js

39
mix/FileIo.cpp

@ -20,8 +20,6 @@
* Ethereum IDE client.
*/
#include <QJsonObject>
#include <QDebug>
#include <QDirIterator>
#include <QDir>
#include <QFile>
@ -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<std::string, bytesConstRef> 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

2
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;

15
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

2
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
{

4
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({

Loading…
Cancel
Save