From 1e59b30280a9bc837bc0b486340ff3009d8766ba Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 16 May 2020 20:29:35 +0200 Subject: [PATCH] undo addressbook fix --- lib/Cargo.lock | 6 +++--- lib/Cargo.toml | 2 +- src/addressbook.cpp | 37 ++++++++++++++----------------------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/lib/Cargo.lock b/lib/Cargo.lock index e198570..01613d0 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -1177,7 +1177,7 @@ version = "0.1.0" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)", - "silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=1da0f0e3210db704edec74de1bc318b4e22cb6c8)", + "silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=32ca60735b3529ff8589ab08fc16678f508a9359)", ] [[package]] @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "silentdragonlitelib" version = "0.1.0" -source = "git+https://github.com/DenioD/silentdragonlite-cli?rev=1da0f0e3210db704edec74de1bc318b4e22cb6c8#1da0f0e3210db704edec74de1bc318b4e22cb6c8" +source = "git+https://github.com/DenioD/silentdragonlite-cli?rev=32ca60735b3529ff8589ab08fc16678f508a9359#32ca60735b3529ff8589ab08fc16678f508a9359" dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)", @@ -2631,7 +2631,7 @@ dependencies = [ "checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35" "checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0" "checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" -"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=1da0f0e3210db704edec74de1bc318b4e22cb6c8)" = "" +"checksum silentdragonlitelib 0.1.0 (git+https://github.com/DenioD/silentdragonlite-cli?rev=32ca60735b3529ff8589ab08fc16678f508a9359)" = "" "checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" "checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85" diff --git a/lib/Cargo.toml b/lib/Cargo.toml index bdf5a9b..fba5265 100644 --- a/lib/Cargo.toml +++ b/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/DenioD/silentdragonlite-cli", rev = "1da0f0e3210db704edec74de1bc318b4e22cb6c8" } +silentdragonlitelib = { git = "https://github.com/DenioD/silentdragonlite-cli", rev = "32ca60735b3529ff8589ab08fc16678f508a9359" } diff --git a/src/addressbook.cpp b/src/addressbook.cpp index 2c7c107..8c4d132 100644 --- a/src/addressbook.cpp +++ b/src/addressbook.cpp @@ -373,39 +373,30 @@ void AddressBook::readFromStorage() in >> version; qDebug() << "Detected old addressbook format"; // Convert old addressbook format v1 to v2 - if(in.status() == QDataStream::ReadCorruptData) + QList> stuff; + in >> stuff; + //qDebug() << "Stuff: " << stuff; + for (int i=0; i < stuff.size(); i++) { - qDebug() << "Error reading contacts! ---> Your hush contacts from disk maybe corrupted"; - QString filepath = QFileInfo(AddressBook::writeableFile()).absolutePath() + QString("/"); - QFile::rename(filepath + QString("addresslabels.dat"), filepath + QString("addresslabels.dat-corrupted")); - QMessageBox::critical( - nullptr, - QObject::tr("Error reading contacts!"), - QObject::tr("Your hush contacts from disk maybe corrupted"), - QMessageBox::Ok - ); + //qDebug() << "0:" << stuff[i][0]; + //qDebug() << "1:" << stuff[i][1]; + //qDebug() << "2:" << stuff[i][2]; + ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]); + //qDebug() << "contact=" << contact.toQTString(); + allLabels.push_back(contact); } - else + { - qDebug() << "Read " << version << " Hush contacts from disk..."; - QList> stuff; - in >> stuff; - for (int i=0; i < stuff.size(); i++) - { - ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]); - allLabels.push_back(contact); - } - - qDebug() << "Hush contacts readed from disk..."; - } + qDebug() << "Read " << version << " Hush contacts from disk..."; file.close(); } - else + }else{ { qDebug() << "No Hush contacts found on disk!"; } } +} void AddressBook::writeToStorage() {