From da369f150772e188e2e41f3838911a59c1a26b24 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Tue, 20 Aug 2013 12:08:55 -0400 Subject: [PATCH] More refactoring done. --- dhtstatus.c | 2 +- main.c | 14 +++++++------- prompt.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dhtstatus.c b/dhtstatus.c index a11dc61..c7a57c7 100644 --- a/dhtstatus.c +++ b/dhtstatus.c @@ -36,7 +36,7 @@ static void dhtstatus_onKey(ToxWindow *self, Messenger *m, int key) static void dhtstatus_onDraw(ToxWindow *self) { - Client_data *close_clientlist = DHT_get_close_list(); + Client_data *close_clientlist = DHT_get_close_list(temp_DHT); curs_set(0); werase(self->window); diff --git a/main.c b/main.c index 9abe8de..6f6c9db 100644 --- a/main.c +++ b/main.c @@ -90,11 +90,11 @@ static Messenger *init_tox() #define MAXSERVERS 50 /* Connects to a random DHT server listed in the DHTservers file */ -int init_connection(void) +int init_connection(Messenger *m) { FILE *fp = NULL; - if (DHT_isconnected()) + if (DHT_isconnected(m->dht)) return 0; fp = fopen(SRVLIST_FILE, "r"); @@ -135,7 +135,7 @@ int init_connection(void) dht.ip.i = resolved_address; unsigned char *binary_string = hex_string_to_bin(key); - DHT_bootstrap(dht, binary_string); + DHT_bootstrap(m->dht, dht, binary_string); free(binary_string); return 0; } @@ -146,18 +146,18 @@ static void do_tox(Messenger *m, ToxWindow *prompt) static int conn_err = 0; static bool dht_on = false; - if (!dht_on && !DHT_isconnected() && !(conn_try++ % 100)) { + if (!dht_on && !DHT_isconnected(m->dht) && !(conn_try++ % 100)) { if (!conn_err) { - conn_err = init_connection(); + conn_err = init_connection(m); wprintw(prompt->window, "\nEstablishing connection...\n"); if (conn_err) wprintw(prompt->window, "\nAuto-connect failed with error code %d\n", conn_err); } - } else if (!dht_on && DHT_isconnected()) { + } else if (!dht_on && DHT_isconnected(m->dht)) { dht_on = true; wprintw(prompt->window, "\nDHT connected.\n"); - } else if (dht_on && !DHT_isconnected()) { + } else if (dht_on && !DHT_isconnected(m->dht)) { dht_on = false; wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n"); } diff --git a/prompt.c b/prompt.c index 81f00bc..204cd7e 100644 --- a/prompt.c +++ b/prompt.c @@ -204,7 +204,7 @@ void cmd_connect(ToxWindow *self, Messenger *m, char **args) dht.ip.i = resolved_address; unsigned char *binary_string = hex_string_to_bin(key); - DHT_bootstrap(dht, binary_string); + DHT_bootstrap(m->dht, dht, binary_string); free(binary_string); }