mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
swapping profiles is now less buggy, but friends still don't come online
This commit is contained in:
parent
b684e56df0
commit
e4c6216ba8
31
core.cpp
31
core.cpp
|
@ -687,6 +687,8 @@ void Core::acceptFileRecvRequest(int friendId, int fileNum, QString path)
|
|||
|
||||
void Core::removeFriend(int friendId)
|
||||
{
|
||||
if (!tox)
|
||||
return;
|
||||
if (tox_del_friend(tox, friendId) == -1) {
|
||||
emit failedToRemoveFriend(friendId);
|
||||
} else {
|
||||
|
@ -789,7 +791,7 @@ void Core::onFileTransferFinished(ToxFile file)
|
|||
emit fileDownloadFinished(file.filePath);
|
||||
}
|
||||
|
||||
void Core::bootstrapDht()
|
||||
void Core::bootstrapDht(bool reset)
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
|
||||
|
@ -797,6 +799,13 @@ void Core::bootstrapDht()
|
|||
int listSize = dhtServerList.size();
|
||||
static int j = qrand() % listSize, n=0;
|
||||
|
||||
if (reset)
|
||||
{
|
||||
n = 0;
|
||||
bootstrapTimer->setInterval(TOX_BOOTSTRAP_INTERVAL);
|
||||
return;
|
||||
}
|
||||
|
||||
// We couldn't connect after trying 6 different nodes, let's try something else
|
||||
if (n>3)
|
||||
{
|
||||
|
@ -811,7 +820,7 @@ void Core::bootstrapDht()
|
|||
{
|
||||
const Settings::DhtServer& dhtServer = dhtServerList[j % listSize];
|
||||
if (tox_bootstrap_from_address(tox, dhtServer.address.toLatin1().data(),
|
||||
qToBigEndian(dhtServer.port), CUserId(dhtServer.userId).data()) == 1)
|
||||
dhtServer.port, CUserId(dhtServer.userId).data()) == 1)
|
||||
qDebug() << QString("Core: Bootstraping from ")+dhtServer.name+QString(", addr ")+dhtServer.address.toLatin1().data()
|
||||
+QString(", port ")+QString().setNum(dhtServer.port);
|
||||
else
|
||||
|
@ -826,14 +835,17 @@ void Core::bootstrapDht()
|
|||
|
||||
void Core::process()
|
||||
{
|
||||
tox_do(tox);
|
||||
if (tox)
|
||||
{
|
||||
tox_do(tox);
|
||||
#ifdef DEBUG
|
||||
//we want to see the debug messages immediately
|
||||
fflush(stdout);
|
||||
//we want to see the debug messages immediately
|
||||
fflush(stdout);
|
||||
#endif
|
||||
checkConnection();
|
||||
//int toxInterval = tox_do_interval(tox);
|
||||
//qDebug() << QString("Tox interval %1").arg(toxInterval);
|
||||
checkConnection();
|
||||
//int toxInterval = tox_do_interval(tox);
|
||||
//qDebug() << QString("Tox interval %1").arg(toxInterval);
|
||||
}
|
||||
toxTimer->start(50);
|
||||
}
|
||||
|
||||
|
@ -957,11 +969,14 @@ void Core::switchConfiguration(QString profile)
|
|||
|
||||
if (tox) {
|
||||
toxav_kill(toxav);
|
||||
toxav = nullptr;
|
||||
tox_kill(tox);
|
||||
tox = nullptr;
|
||||
}
|
||||
emit clearFriends();
|
||||
|
||||
get_tox();
|
||||
bootstrapDht(true); // reset this func
|
||||
|
||||
Settings::getInstance().setCurrentProfile(profile);
|
||||
loadConfiguration(Settings::getSettingsDirPath() + QDir::separator() + profile + TOX_EXT);
|
||||
|
|
2
core.h
2
core.h
|
@ -140,7 +140,7 @@ public:
|
|||
public slots:
|
||||
void start();
|
||||
void process();
|
||||
void bootstrapDht();
|
||||
void bootstrapDht(bool reset = false);
|
||||
|
||||
void acceptFriendRequest(const QString& userId);
|
||||
void requestFriendship(const QString& friendAddress, const QString& message);
|
||||
|
|
|
@ -183,7 +183,7 @@ private:
|
|||
|
||||
signals:
|
||||
//void dataChanged();
|
||||
void dhtServerListChanged();
|
||||
void dhtServerListChanged(bool reset = false);
|
||||
void logStorageOptsChanged();
|
||||
void smileyPackChanged();
|
||||
void emojiFontChanged();
|
||||
|
|
Loading…
Reference in New Issue
Block a user