mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
more details
This commit is contained in:
parent
34bb83aca7
commit
c1572abedf
29
src/core.cpp
29
src/core.cpp
|
@ -115,11 +115,7 @@ Core::~Core()
|
|||
if (alInDev)
|
||||
alcCaptureCloseDevice(alInDev);
|
||||
|
||||
if (pwhash)
|
||||
{
|
||||
delete[] pwhash;
|
||||
pwhash = nullptr;
|
||||
}
|
||||
clearPassword();
|
||||
}
|
||||
|
||||
Core* Core::getInstance()
|
||||
|
@ -1124,7 +1120,9 @@ bool Core::loadConfiguration(QString path)
|
|||
while (error != 0)
|
||||
{
|
||||
error = tox_encrypted_load(tox, reinterpret_cast<uint8_t *>(data.data()), data.size(), pwhash, TOX_HASH_LENGTH);
|
||||
// something something QInputDialog new password
|
||||
emit blockingGetPassword();
|
||||
if (!pwhash)
|
||||
// we need a way to start core without any profile
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
@ -1155,22 +1153,18 @@ void Core::saveConfiguration()
|
|||
}
|
||||
|
||||
QString profile = Settings::getInstance().getCurrentProfile();
|
||||
//qDebug() << "saveConf read profile: " << profile;
|
||||
|
||||
if (profile == "")
|
||||
{ // no profile active; this should only happen on startup, if at all
|
||||
profile = sanitize(getUsername());
|
||||
|
||||
if (profile == "") // happens on creation of a new Tox ID
|
||||
profile = getIDString();
|
||||
//qDebug() << "saveConf: read sanitized user as " << profile;
|
||||
|
||||
Settings::getInstance().setCurrentProfile(profile);
|
||||
}
|
||||
|
||||
QString path = dir + QDir::separator() + profile + TOX_EXT;
|
||||
QFileInfo info(path);
|
||||
// if (!info.exists()) // fall back to old school 'data'
|
||||
// { //path = dir + QDir::separator() + CONFIG_FILE_NAME;
|
||||
// qDebug() << "Core:" << path << " does not exist";
|
||||
// }
|
||||
QString path = directory.filePath(profile + TOX_EXT);
|
||||
|
||||
saveConfiguration(path);
|
||||
}
|
||||
|
@ -1204,6 +1198,10 @@ void Core::saveConfiguration(const QString& path)
|
|||
|
||||
if (Settings::getInstance().getEncryptTox())
|
||||
{
|
||||
if (!pwhash)
|
||||
emit blockingGetPassword();
|
||||
//if (!pwhash)
|
||||
// revert to unsaved...? or maybe we shouldn't even try to get a pw from here ^
|
||||
int ret = tox_encrypted_save(tox, data, pwhash, TOX_HASH_LENGTH);
|
||||
if (ret == -1)
|
||||
{
|
||||
|
@ -1229,8 +1227,9 @@ void Core::switchConfiguration(const QString& profile)
|
|||
}
|
||||
else
|
||||
qDebug() << "Core: switching from" << Settings::getInstance().getCurrentProfile() << "to" << profile;
|
||||
saveConfiguration();
|
||||
|
||||
saveConfiguration();
|
||||
clearPassword();
|
||||
toxTimer->stop();
|
||||
|
||||
if (tox) {
|
||||
|
|
|
@ -115,6 +115,7 @@ signals:
|
|||
void connected();
|
||||
void disconnected();
|
||||
void blockingClearContacts();
|
||||
void blockingGetPassword();
|
||||
|
||||
void friendRequestReceived(const QString& userId, const QString& message);
|
||||
void friendMessageReceived(int friendId, const QString& message, bool isAction);
|
||||
|
|
|
@ -147,6 +147,7 @@ Widget::Widget(QWidget *parent)
|
|||
connect(core, &Core::emptyGroupCreated, this, &Widget::onEmptyGroupCreated);
|
||||
connect(core, &Core::avInvite, this, &Widget::playRingtone);
|
||||
connect(core, &Core::blockingClearContacts, this, &Widget::clearContactsList, Qt::BlockingQueuedConnection);
|
||||
connect(core, &Core::blockingGetPassword, this, &Widget::getPassword, Qt::BlockingQueuedConnection);
|
||||
|
||||
connect(core, SIGNAL(messageSentResult(int,QString,int)), this, SLOT(onMessageSendResult(int,QString,int)));
|
||||
connect(core, SIGNAL(groupSentResult(int,QString,int)), this, SLOT(onGroupSendResult(int,QString,int)));
|
||||
|
@ -830,3 +831,12 @@ void Widget::onGroupSendResult(int groupId, const QString& message, int result)
|
|||
if (result == -1)
|
||||
g->chatForm->addSystemInfoMessage("Message failed to send", "red");
|
||||
}
|
||||
|
||||
void Widget::getPassword()
|
||||
{
|
||||
//QString password = QInputDialog();
|
||||
//if (password.isEmpty())
|
||||
// core->clearPassword();
|
||||
//else
|
||||
// core->setPassword(password);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ public:
|
|||
bool isFriendWidgetCurActiveWidget(Friend* f);
|
||||
bool getIsWindowMinimized();
|
||||
static QList<QString> searchProfiles();
|
||||
void clearContactsList();
|
||||
~Widget();
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
|
@ -109,6 +108,8 @@ private slots:
|
|||
void onGroupSendResult(int groupId, const QString& message, int result);
|
||||
void playRingtone();
|
||||
void onIconClick();
|
||||
void clearContactsList();
|
||||
void getPassword();
|
||||
|
||||
private:
|
||||
void hideMainForms();
|
||||
|
|
Loading…
Reference in New Issue
Block a user