Browse Source

Merge pull request #82 from MyHush/denio

update SDL lib
pull/83/head
Denio 4 years ago
committed by GitHub
parent
commit
346bde0244
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1780
      lib/Cargo.lock
  2. 2
      lib/Cargo.toml
  3. 62
      src/controller.cpp

1780
lib/Cargo.lock

File diff suppressed because it is too large

2
lib/Cargo.toml

@ -11,4 +11,4 @@ crate-type = ["staticlib"]
[dependencies]
libc = "0.2.58"
lazy_static = "1.4.0"
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "015e1617ab836481b0fd7c357ac2977191964730" }
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "cdf2c834a4eaea633274030dce98c61b9e2cc927" }

62
src/controller.cpp

@ -83,11 +83,9 @@ void Controller::setConnection(Connection* c) {
// Create Sietch zdust addr at startup.
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch.txt");
QFile file(path);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -98,7 +96,6 @@ if(!file.open(QIODevice::WriteOnly)){
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt");
QFile file(path);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
@ -110,11 +107,11 @@ if(!file.open(QIODevice::WriteOnly)){
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -125,7 +122,6 @@ if(!file.open(QIODevice::WriteOnly)){
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch3.txt");
QFile file(path);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
@ -137,11 +133,11 @@ if(!file.open(QIODevice::WriteOnly)){
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -152,7 +148,6 @@ if(!file.open(QIODevice::WriteOnly)){
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch5.txt");
QFile file(path);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
@ -164,11 +159,11 @@ if(!file.open(QIODevice::WriteOnly)){
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -179,7 +174,6 @@ if(!file.open(QIODevice::WriteOnly)){
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch7.txt");
QFile file(path);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
@ -191,11 +185,11 @@ if(!file.open(QIODevice::WriteOnly)){
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -204,11 +198,11 @@ if(!file.open(QIODevice::WriteOnly)){
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -235,20 +229,19 @@ void Controller::fillTxJsonParams(json& allRecepients, Tx tx) {
json dust7 = json::object();
json dust8 = json::object();
json dust9 = json::object();
// Create Sietch zdust addr again to not use it twice.
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch.txt");
QFile file(path);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
@ -262,13 +255,12 @@ if(!file.open(QIODevice::WriteOnly)){
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch2.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
@ -289,20 +281,18 @@ if(!file.open(QIODevice::WriteOnly)){
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
@ -322,14 +312,13 @@ if(!file.open(QIODevice::WriteOnly)){
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
@ -343,41 +332,36 @@ if(!file.open(QIODevice::WriteOnly)){
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
zrpc->createNewSietchZaddr( [=] (json reply) {
QString path= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt");
QFile file(path);
auto zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
QString zdust = QString::fromStdString(reply.get<json::array_t>()[0]);
if(!file.open(QIODevice::WriteOnly)){
file.close();
} else {
QTextStream out(&file); out << zdust.toUtf8();
file.close();
}
} );
// Set sietch zdust addr to json.
QString path= (QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)) + QString("/Sietch.txt");
QFile inputFile(path);
if (inputFile.open(QIODevice::ReadOnly))
{
QTextStream in(&inputFile);
@ -392,7 +376,6 @@ if (inputFile.open(QIODevice::ReadOnly))
QString path1= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch1.txt");
QFile inputFile1(path1);
if (inputFile1.open(QIODevice::ReadOnly))
{
QTextStream in(&inputFile1);
@ -431,6 +414,7 @@ if (inputFile3.open(QIODevice::ReadOnly))
}
inputFile3.close();
}
QString path4= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch4.txt");
QFile inputFile4(path4);
if (inputFile4.open(QIODevice::ReadOnly))
@ -456,6 +440,7 @@ if (inputFile5.open(QIODevice::ReadOnly))
}
inputFile5.close();
}
QString path6= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch6.txt");
QFile inputFile6(path6);
if (inputFile6.open(QIODevice::ReadOnly))
@ -481,6 +466,7 @@ if (inputFile7.open(QIODevice::ReadOnly))
}
inputFile7.close();
}
QString path8= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch8.txt");
QFile inputFile8(path8);
if (inputFile8.open(QIODevice::ReadOnly))
@ -493,6 +479,7 @@ if (inputFile8.open(QIODevice::ReadOnly))
}
inputFile.close();
}
QString path9= QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QString("/Sietch9.txt");
QFile inputFile9(path9);
if (inputFile9.open(QIODevice::ReadOnly))
@ -506,6 +493,7 @@ if (inputFile9.open(QIODevice::ReadOnly))
inputFile9.close();
}
// Dust amt/memo, construct the JSON
dust["amount"] = 0;
dust["memo"] = "";
dust1["amount"] = 0;
@ -526,7 +514,9 @@ if (inputFile9.open(QIODevice::ReadOnly))
dust8["memo"] = "";
dust9["amount"] = 0;
dust9["memo"] = "";
// For each addr/amt/memo, construct the JSON and also build the confirm dialog box
for (int i=0; i < tx.toAddrs.size(); i++) {
auto toAddr = tx.toAddrs[i];
@ -544,19 +534,17 @@ if (inputFile9.open(QIODevice::ReadOnly))
if(decider % 4 == 3) {
allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6,dust7,dust8}) ;
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
// std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
}else {
allRecepients.insert(std::begin(allRecepients),{dust,dust1,dust2,dust3,dust4,dust5,dust6,dust7,dust8,dust9}) ;
std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
// std::shuffle(allRecepients.begin(),allRecepients.end(),std::random_device());
}
allRecepients.push_back(rec) ;
}
void Controller::noConnection() {
QIcon i = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
main->statusIcon->setPixmap(i.pixmap(16, 16));

Loading…
Cancel
Save