1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-07-01 18:37:46 +02:00

better way to check connection status

This commit is contained in:
Jfreegman 2013-09-06 21:37:16 -04:00
parent 261310b091
commit 9bf9dbe875
2 changed files with 10 additions and 1 deletions

View File

@ -238,9 +238,11 @@ static void do_tox(Tox *m, ToxWindow *prompt)
}
} else if (!dht_on && tox_isconnected(m)) {
dht_on = true;
prompt_update_connectionstatus(prompt, dht_on);
wprintw(prompt->window, "\nDHT connected.\n");
} else if (dht_on && !tox_isconnected(m)) {
dht_on = false;
prompt_update_connectionstatus(prompt, dht_on);
wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
}

View File

@ -77,6 +77,13 @@ void prompt_update_status(ToxWindow *prompt, TOX_USERSTATUS status)
statusbar->status = status;
}
/* Updates own connection status */
void prompt_update_connectionstatus(ToxWindow *prompt, bool is_connected)
{
StatusBar *statusbar = (StatusBar *) prompt->s;
statusbar->is_online = is_connected;
}
void prompt_onFriendRequest(ToxWindow *prompt, uint8_t *key, uint8_t *data, uint16_t length)
{
int n = add_req(key);
@ -584,7 +591,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
werase(statusbar->topline);
if (tox_isconnected(m)) {
if (statusbar->is_online) {
int colour = WHITE;
char *status_text = "Unknown";