Merge pull request #82 from MyHush/denio

update SDL lib
This commit is contained in:
Denio
2020-02-08 15:23:25 +01:00
committed by GitHub
3 changed files with 1063 additions and 929 deletions

1842
lib/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -11,4 +11,4 @@ crate-type = ["staticlib"]
[dependencies] [dependencies]
libc = "0.2.58" libc = "0.2.58"
lazy_static = "1.4.0" 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" }

View File

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