mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 06:13:03 +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)) {
|
} else if (!dht_on && tox_isconnected(m)) {
|
||||||
dht_on = true;
|
dht_on = true;
|
||||||
|
prompt_update_connectionstatus(prompt, dht_on);
|
||||||
wprintw(prompt->window, "\nDHT connected.\n");
|
wprintw(prompt->window, "\nDHT connected.\n");
|
||||||
} else if (dht_on && !tox_isconnected(m)) {
|
} else if (dht_on && !tox_isconnected(m)) {
|
||||||
dht_on = false;
|
dht_on = false;
|
||||||
|
prompt_update_connectionstatus(prompt, dht_on);
|
||||||
wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
|
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;
|
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)
|
void prompt_onFriendRequest(ToxWindow *prompt, uint8_t *key, uint8_t *data, uint16_t length)
|
||||||
{
|
{
|
||||||
int n = add_req(key);
|
int n = add_req(key);
|
||||||
@ -584,7 +591,7 @@ static void prompt_onDraw(ToxWindow *self, Tox *m)
|
|||||||
|
|
||||||
werase(statusbar->topline);
|
werase(statusbar->topline);
|
||||||
|
|
||||||
if (tox_isconnected(m)) {
|
if (statusbar->is_online) {
|
||||||
int colour = WHITE;
|
int colour = WHITE;
|
||||||
char *status_text = "Unknown";
|
char *status_text = "Unknown";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user