Browse Source

Merge pull request #196 from MyHush/dev

add error check for addresslabels, set version to 1.3.10
pull/203/merge
Denio 4 years ago
committed by GitHub
parent
commit
df17c525b0
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      silentdragon-lite.pro
  2. 60
      src/addressbook.cpp
  3. 2
      src/version.h

1
silentdragon-lite.pro

@ -143,6 +143,7 @@ FORMS += \
src/viewalladdresses.ui \
src/connection.ui \
src/addressbook.ui \
src/memodialog.ui \
src/mobileappconnector.ui \
src/createhushconfdialog.ui \
src/recurringdialog.ui \

60
src/addressbook.cpp

@ -468,9 +468,7 @@ void AddressBook::readFromStorage()
void AddressBook::writeToStorage()
{
//FileSystem::getInstance()->writeContacts(AddressBook::writeableFile(), DataStore::getContactDataStore()->dump());
// FileSystem::getInstance()->writeContactsOldFormat(AddressBook::writeableFile(), allLabels);
QString passphraseHash = DataStore::getChatDataStore()->getPassword();
int length = passphraseHash.length();
@ -497,7 +495,18 @@ void AddressBook::writeToStorage()
FileEncryption::decrypt(target_decaddr_file, target_encaddr_file, pwHash);
QFile file(target_decaddr_file);
try {
file.open(QIODevice::ReadWrite | QIODevice::Truncate);
} catch(...) {
QMessageBox msgWarning;
msgWarning.setText("WARNING!\n Could not open Addressbook.");
msgWarning.setIcon(QMessageBox::Warning);
msgWarning.setWindowTitle("Caution");
msgWarning.exec();
}
QDataStream out(&file); // we will serialize the data into the file
QList<QList<QString>> contacts;
@ -513,19 +522,53 @@ void AddressBook::writeToStorage()
}
out << QString("v2") << contacts;
try {
file.close();
} catch(...) {
QMessageBox msgWarning;
msgWarning.setText("WARNING!\nCould not close Addressbook.");
msgWarning.setIcon(QMessageBox::Warning);
msgWarning.setWindowTitle("Caution");
msgWarning.exec();
}
try {
FileEncryption::encrypt(target_encaddr_file, target_decaddr_file , pwHash);
}
catch(...) {
QMessageBox msgWarning;
msgWarning.setText("WARNING!\nCould not encrypt Addressbook.");
msgWarning.setIcon(QMessageBox::Warning);
msgWarning.setWindowTitle("Caution");
msgWarning.exec();
}
QFile file1(target_decaddr_file);
try {
file1.remove();
} catch(...) {
QMessageBox msgWarning;
msgWarning.setText("WARNING!\nCould not remove Addressbook.");
msgWarning.setIcon(QMessageBox::Warning);
msgWarning.setWindowTitle("Caution");
msgWarning.exec();
}
}
QString AddressBook::writeableFile()
{
auto filename = QStringLiteral("addresslabels.dat");
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
try {
if (!dir.exists())
QDir().mkpath(dir.absolutePath());
@ -534,6 +577,15 @@ QString AddressBook::writeableFile()
else
return dir.filePath(filename);
} catch(...) {
QMessageBox msgWarning;
msgWarning.setText("WARNING!\nCould not write Addressbook.");
msgWarning.setIcon(QMessageBox::Warning);
msgWarning.setWindowTitle("Caution");
msgWarning.exec();
}
}

2
src/version.h

@ -1 +1 @@
#define APP_VERSION "1.4.0"
#define APP_VERSION "1.3.10"

Loading…
Cancel
Save