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. 31
      core.cpp
  2. 2
      core.h
  3. 2
      settings.h

31
core.cpp

@ -687,6 +687,8 @@ void Core::acceptFileRecvRequest(int friendId, int fileNum, QString path)
void Core::removeFriend(int friendId) void Core::removeFriend(int friendId)
{ {
if (!tox)
return;
if (tox_del_friend(tox, friendId) == -1) { if (tox_del_friend(tox, friendId) == -1) {
emit failedToRemoveFriend(friendId); emit failedToRemoveFriend(friendId);
} else { } else {
@ -789,7 +791,7 @@ void Core::onFileTransferFinished(ToxFile file)
emit fileDownloadFinished(file.filePath); emit fileDownloadFinished(file.filePath);
} }
void Core::bootstrapDht() void Core::bootstrapDht(bool reset)
{ {
const Settings& s = Settings::getInstance(); const Settings& s = Settings::getInstance();
QList<Settings::DhtServer> dhtServerList = s.getDhtServerList(); QList<Settings::DhtServer> dhtServerList = s.getDhtServerList();
@ -797,6 +799,13 @@ void Core::bootstrapDht()
int listSize = dhtServerList.size(); int listSize = dhtServerList.size();
static int j = qrand() % listSize, n=0; 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 // We couldn't connect after trying 6 different nodes, let's try something else
if (n>3) if (n>3)
{ {
@ -811,7 +820,7 @@ void Core::bootstrapDht()
{ {
const Settings::DhtServer& dhtServer = dhtServerList[j % listSize]; const Settings::DhtServer& dhtServer = dhtServerList[j % listSize];
if (tox_bootstrap_from_address(tox, dhtServer.address.toLatin1().data(), 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() qDebug() << QString("Core: Bootstraping from ")+dhtServer.name+QString(", addr ")+dhtServer.address.toLatin1().data()
+QString(", port ")+QString().setNum(dhtServer.port); +QString(", port ")+QString().setNum(dhtServer.port);
else else
@ -826,14 +835,17 @@ void Core::bootstrapDht()
void Core::process() void Core::process()
{ {
tox_do(tox); if (tox)
{
tox_do(tox);
#ifdef DEBUG #ifdef DEBUG
//we want to see the debug messages immediately //we want to see the debug messages immediately
fflush(stdout); fflush(stdout);
#endif #endif
checkConnection(); checkConnection();
//int toxInterval = tox_do_interval(tox); //int toxInterval = tox_do_interval(tox);
//qDebug() << QString("Tox interval %1").arg(toxInterval); //qDebug() << QString("Tox interval %1").arg(toxInterval);
}
toxTimer->start(50); toxTimer->start(50);
} }
@ -957,11 +969,14 @@ void Core::switchConfiguration(QString profile)
if (tox) { if (tox) {
toxav_kill(toxav); toxav_kill(toxav);
toxav = nullptr;
tox_kill(tox); tox_kill(tox);
tox = nullptr;
} }
emit clearFriends(); emit clearFriends();
get_tox(); get_tox();
bootstrapDht(true); // reset this func
Settings::getInstance().setCurrentProfile(profile); Settings::getInstance().setCurrentProfile(profile);
loadConfiguration(Settings::getSettingsDirPath() + QDir::separator() + profile + TOX_EXT); loadConfiguration(Settings::getSettingsDirPath() + QDir::separator() + profile + TOX_EXT);

2
core.h

@ -140,7 +140,7 @@ public:
public slots: public slots:
void start(); void start();
void process(); void process();
void bootstrapDht(); void bootstrapDht(bool reset = false);
void acceptFriendRequest(const QString& userId); void acceptFriendRequest(const QString& userId);
void requestFriendship(const QString& friendAddress, const QString& message); void requestFriendship(const QString& friendAddress, const QString& message);

2
settings.h

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

Loading…
Cancel
Save