1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

incremental

This commit is contained in:
dubslow 2014-11-22 02:46:22 -06:00 committed by Dubslow
parent 8985466ed3
commit dde410bb9c
6 changed files with 11 additions and 267 deletions

View File

@ -32,7 +32,6 @@ FORMS += \
src/widget/form/settings/identitysettings.ui \
src/widget/form/settings/privacysettings.ui \
src/widget/form/loadhistorydialog.ui \
src/widget/form/inputpassworddialog.ui \
src/widget/form/setpassworddialog.ui \
src/widget/form/settings/advancedsettings.ui
@ -153,7 +152,6 @@ HEADERS += src/widget/form/addfriendform.h \
src/misc/db/genericddinterface.h \
src/misc/db/plaindb.h \
src/misc/db/encrypteddb.h \
src/widget/form/inputpassworddialog.h \
src/widget/form/setpassworddialog.h \
src/widget/form/tabcompleter.h \
src/video/videoframe.h \
@ -220,7 +218,6 @@ SOURCES += \
src/misc/db/genericddinterface.cpp \
src/misc/db/plaindb.cpp \
src/misc/db/encrypteddb.cpp \
src/widget/form/inputpassworddialog.cpp \
src/widget/form/setpassworddialog.cpp \
src/video/netvideosource.cpp \
src/widget/form/tabcompleter.cpp \

View File

@ -1,38 +0,0 @@
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
This file is part of qTox, a Qt-based graphical interface for Tox.
This program is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
#include "inputpassworddialog.h"
#include "ui_inputpassworddialog.h"
InputPasswordDialog::InputPasswordDialog(QString title, QWidget *parent) :
QDialog(parent),
ui(new Ui::InputPasswordDialog)
{
ui->setupUi(this);
if (title != QString())
setWindowTitle(title);
}
InputPasswordDialog::~InputPasswordDialog()
{
delete ui;
}
QString InputPasswordDialog::getPassword()
{
return ui->passwordLineEdit->text();
}

View File

@ -1,40 +0,0 @@
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
This file is part of qTox, a Qt-based graphical interface for Tox.
This program is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
#ifndef INPUTPASSWORDDIALOG_H
#define INPUTPASSWORDDIALOG_H
#include <QDialog>
namespace Ui {
class InputPasswordDialog;
}
class InputPasswordDialog : public QDialog
{
Q_OBJECT
public:
explicit InputPasswordDialog(QString title = QString(), QWidget *parent = 0);
~InputPasswordDialog();
QString getPassword();
private:
Ui::InputPasswordDialog *ui;
};
#endif // INPUTPASSWORDDIALOG_H

View File

@ -1,97 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InputPasswordDialog</class>
<widget class="QDialog" name="InputPasswordDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>123</height>
</rect>
</property>
<property name="windowTitle">
<string>Password Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Input password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="passwordLineEdit">
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>InputPasswordDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>InputPasswordDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -60,86 +60,23 @@ void PrivacyForm::onTypingNotificationEnabledUpdated()
void PrivacyForm::onEncryptLogsUpdated()
{
bool encrytionState = bodyUI->cbEncryptHistory->isChecked();
bool keepOldFile = false;
bool encryption = bodyUI->cbEncryptHistory->isChecked();
if (encrytionState)
if (encryption)
{
Settings::getInstance().setEncryptLogs(true);
if (HistoryKeeper::isFileExist())
{
QByteArray salt = Core::getSaltFromFile(HistoryKeeper::getHistoryPath());
if (salt.size() != 0)
{
if (QMessageBox::Ok == QMessageBox::warning(nullptr, tr("Encrypted log"),
tr("You already have history file.\nDo you want to try open it?"),
QMessageBox::Ok | QMessageBox::Cancel))
{
keepOldFile = true;
bool exit = false;
do
{
Widget::getInstance()->getPassword(tr("Encrypted log"), Core::ptHistory, reinterpret_cast<uint8_t*>(salt.data()));
exit = HistoryKeeper::checkPassword();
if (!exit)
{
if (QMessageBox::warning(nullptr, tr("Encrypted log"), tr("Wrong password!\nTry again?"),
QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
{
keepOldFile = false;
encrytionState = false;
exit = true;
QMessageBox::warning(nullptr, tr("Encrypetd log"), tr("Encrypted log will be disabled!"));
}
}
} while (!exit);
} else {
if (QMessageBox::warning(nullptr, tr("Encrypted log"), tr("Do you want to delete encrypted history file?"),
QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok)
{
keepOldFile = true;
encrytionState = false;
}
}
}
}
}
if (encrytionState && !keepOldFile)
else
{
Core::getInstance()->clearPassword(Core::ptHistory);
SetPasswordDialog dialog;
if (dialog.exec())
{
QString pswd = dialog.getPassword();
if (pswd.size() == 0)
encrytionState = false;
Core::getInstance()->setPassword(pswd, Core::ptHistory);
} else {
encrytionState = false;
}
}
Settings::getInstance().setEncryptLogs(encrytionState);
HistoryKeeper::resetInstance();
Settings::getInstance().setEncryptLogs(encrytionState);
bodyUI->cbEncryptHistory->setChecked(encrytionState);
if (!Settings::getInstance().getEncryptLogs())
Core::getInstance()->clearPassword(Core::ptHistory);
}
void PrivacyForm::onEncryptToxUpdated()
{
bool encrytionState = bodyUI->cbEncryptTox->isChecked();
bool encryptionState = bodyUI->cbEncryptTox->isChecked();
if (encrytionState)
if (encryptionState)
{
if (!Core::getInstance()->isPasswordSet(Core::ptMain))
{
@ -148,18 +85,18 @@ void PrivacyForm::onEncryptToxUpdated()
{
QString pswd = dialog.getPassword();
if (pswd.size() == 0)
encrytionState = false;
encryptionState = false;
Core::getInstance()->setPassword(pswd, Core::ptMain);
} else {
encrytionState = false;
encryptionState = false;
Core::getInstance()->clearPassword(Core::ptMain);
}
}
}
bodyUI->cbEncryptTox->setChecked(encrytionState);
Settings::getInstance().setEncryptTox(encrytionState);
bodyUI->cbEncryptTox->setChecked(encryptionState);
Settings::getInstance().setEncryptTox(encryptionState);
if (!Settings::getInstance().getEncryptTox())
Core::getInstance()->clearPassword(Core::ptMain);

View File

@ -32,7 +32,6 @@
#include "form/chatform.h"
#include "maskablepixmapwidget.h"
#include "src/historykeeper.h"
#include "form/inputpassworddialog.h"
#include "src/autoupdate.h"
#include "src/audio.h"
#include "src/platform/timer.h"
@ -1165,20 +1164,6 @@ void Widget::onGroupSendResult(int groupId, const QString& message, int result)
g->getChatForm()->addSystemInfoMessage(tr("Message failed to send"), "red", QDateTime::currentDateTime());
}
void Widget::getPassword(QString info, int passtype, uint8_t* salt)
{
Core::PasswordType pt = static_cast<Core::PasswordType>(passtype);
InputPasswordDialog dialog(info);
if (dialog.exec())
{
QString pswd = dialog.getPassword();
if (pswd.isEmpty())
core->clearPassword(pt);
else
core->setPassword(pswd, pt, salt);
}
}
void Widget::onSetShowSystemTray(bool newValue){
icon->setVisible(newValue);
}