mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-22 20:53:01 +01:00
better way to check connection status
This commit is contained in:
parent
261310b091
commit
9bf9dbe875
@ -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");
|
||||
}
|
||||
|
||||
|
@ -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";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user