Browse Source

swapping profiles is now less buggy, but friends still don't come online

pull/288/head
Dubslow 11 years ago
parent
commit
e4c6216ba8
  1. 19
      core.cpp
  2. 2
      core.h
  3. 2
      settings.h

19
core.cpp

@ -687,6 +687,8 @@ void Core::acceptFileRecvRequest(int friendId, int fileNum, QString path) @@ -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) @@ -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() @@ -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() @@ -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,6 +835,8 @@ void Core::bootstrapDht() @@ -826,6 +835,8 @@ void Core::bootstrapDht()
void Core::process()
{
if (tox)
{
tox_do(tox);
#ifdef DEBUG
//we want to see the debug messages immediately
@ -834,6 +845,7 @@ void Core::process() @@ -834,6 +845,7 @@ void Core::process()
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) @@ -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

@ -140,7 +140,7 @@ public: @@ -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);

2
settings.h

@ -183,7 +183,7 @@ private: @@ -183,7 +183,7 @@ private:
signals:
//void dataChanged();
void dhtServerListChanged();
void dhtServerListChanged(bool reset = false);
void logStorageOptsChanged();
void smileyPackChanged();
void emojiFontChanged();

Loading…
Cancel
Save