Skip to content

Commit

Permalink
decryptDatabaseCrypt7_8_12(): removed code duplications
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-mausch committed Nov 5, 2017
1 parent 583a6ed commit 127ff73
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 46 deletions.
55 changes: 9 additions & 46 deletions source/Platforms/Win32/GUI/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ void MainWindow::decryptDatabaseCrypt5()
}
}

void MainWindow::decryptDatabaseCrypt7()
void MainWindow::decryptDatabaseCrypt7_8_12(void (*decryptWhatsappDatabase)(const std::string &filename, const std::string &filenameDecrypted, const std::string &keyFilename))
{
OpenDatabaseStruct openDatabaseStruct = lastDatabaseOpened;
DecryptDatabaseDialog7 dialog(MainWindow::dialog, openDatabaseStruct);
Expand All @@ -545,7 +545,7 @@ void MainWindow::decryptDatabaseCrypt7()
{
try
{
decryptWhatsappDatabase7(openDatabaseStruct.filename, openDatabaseStruct.decryptedFilename, openDatabaseStruct.keyFilename);
decryptWhatsappDatabase(openDatabaseStruct.filename, openDatabaseStruct.decryptedFilename, openDatabaseStruct.keyFilename);

lastDatabaseOpened = openDatabaseStruct;
settings.write("lastOpenedFile", lastDatabaseOpened.filename);
Expand All @@ -562,56 +562,19 @@ void MainWindow::decryptDatabaseCrypt7()
}
}

void MainWindow::decryptDatabaseCrypt8()
void MainWindow::decryptDatabaseCrypt7()
{
OpenDatabaseStruct openDatabaseStruct = lastDatabaseOpened;
DecryptDatabaseDialog7 dialog(MainWindow::dialog, openDatabaseStruct);

if (dialog.openModal() == IDOK)
{
try
{
decryptWhatsappDatabase8(openDatabaseStruct.filename, openDatabaseStruct.decryptedFilename, openDatabaseStruct.keyFilename);

lastDatabaseOpened = openDatabaseStruct;
settings.write("lastOpenedFile", lastDatabaseOpened.filename);
settings.write("lastOpenedKeyfile", lastDatabaseOpened.keyFilename);
decryptDatabaseCrypt7_8_12(decryptWhatsappDatabase7);
}

std::stringstream message;
message << "Database decrypted to file " << openDatabaseStruct.decryptedFilename;
MessageBox(MainWindow::dialog, strtowstr(message.str()).c_str(), L"Success", MB_OK | MB_ICONINFORMATION);
}
catch (Exception &exception)
{
displayException(MainWindow::dialog, exception);
}
}
void MainWindow::decryptDatabaseCrypt8()
{
decryptDatabaseCrypt7_8_12(decryptWhatsappDatabase8);
}

void MainWindow::decryptDatabaseCrypt12()
{
OpenDatabaseStruct openDatabaseStruct = lastDatabaseOpened;
DecryptDatabaseDialog7 dialog(MainWindow::dialog, openDatabaseStruct);

if (dialog.openModal() == IDOK)
{
try
{
decryptWhatsappDatabase12(openDatabaseStruct.filename, openDatabaseStruct.decryptedFilename, openDatabaseStruct.keyFilename);

lastDatabaseOpened = openDatabaseStruct;
settings.write("lastOpenedFile", lastDatabaseOpened.filename);
settings.write("lastOpenedKeyfile", lastDatabaseOpened.keyFilename);

std::stringstream message;
message << "Database decrypted to file " << openDatabaseStruct.decryptedFilename;
MessageBox(MainWindow::dialog, strtowstr(message.str()).c_str(), L"Success", MB_OK | MB_ICONINFORMATION);
}
catch (Exception &exception)
{
displayException(MainWindow::dialog, exception);
}
}
decryptDatabaseCrypt7_8_12(decryptWhatsappDatabase12);
}

void MainWindow::displayException(HWND mainWindow, Exception &exception)
Expand Down
1 change: 1 addition & 0 deletions source/Platforms/Win32/GUI/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MainWindow
void decryptDatabaseCrypt7();
void decryptDatabaseCrypt8();
void decryptDatabaseCrypt12();
void decryptDatabaseCrypt7_8_12(void (*decryptWhatsappDatabase)(const std::string &filename, const std::string &filenameDecrypted, const std::string &keyFilename));
void clearChats();
void clearChatList();

Expand Down

0 comments on commit 127ff73

Please sign in to comment.