summaryrefslogtreecommitdiff
path: root/testing/toxic/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r--testing/toxic/main.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 9abe8de4..6f6c9db4 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -90,11 +90,11 @@ static Messenger *init_tox()
90#define MAXSERVERS 50 90#define MAXSERVERS 50
91 91
92/* Connects to a random DHT server listed in the DHTservers file */ 92/* Connects to a random DHT server listed in the DHTservers file */
93int init_connection(void) 93int init_connection(Messenger *m)
94{ 94{
95 FILE *fp = NULL; 95 FILE *fp = NULL;
96 96
97 if (DHT_isconnected()) 97 if (DHT_isconnected(m->dht))
98 return 0; 98 return 0;
99 99
100 fp = fopen(SRVLIST_FILE, "r"); 100 fp = fopen(SRVLIST_FILE, "r");
@@ -135,7 +135,7 @@ int init_connection(void)
135 135
136 dht.ip.i = resolved_address; 136 dht.ip.i = resolved_address;
137 unsigned char *binary_string = hex_string_to_bin(key); 137 unsigned char *binary_string = hex_string_to_bin(key);
138 DHT_bootstrap(dht, binary_string); 138 DHT_bootstrap(m->dht, dht, binary_string);
139 free(binary_string); 139 free(binary_string);
140 return 0; 140 return 0;
141} 141}
@@ -146,18 +146,18 @@ static void do_tox(Messenger *m, ToxWindow *prompt)
146 static int conn_err = 0; 146 static int conn_err = 0;
147 static bool dht_on = false; 147 static bool dht_on = false;
148 148
149 if (!dht_on && !DHT_isconnected() && !(conn_try++ % 100)) { 149 if (!dht_on && !DHT_isconnected(m->dht) && !(conn_try++ % 100)) {
150 if (!conn_err) { 150 if (!conn_err) {
151 conn_err = init_connection(); 151 conn_err = init_connection(m);
152 wprintw(prompt->window, "\nEstablishing connection...\n"); 152 wprintw(prompt->window, "\nEstablishing connection...\n");
153 153
154 if (conn_err) 154 if (conn_err)
155 wprintw(prompt->window, "\nAuto-connect failed with error code %d\n", conn_err); 155 wprintw(prompt->window, "\nAuto-connect failed with error code %d\n", conn_err);
156 } 156 }
157 } else if (!dht_on && DHT_isconnected()) { 157 } else if (!dht_on && DHT_isconnected(m->dht)) {
158 dht_on = true; 158 dht_on = true;
159 wprintw(prompt->window, "\nDHT connected.\n"); 159 wprintw(prompt->window, "\nDHT connected.\n");
160 } else if (dht_on && !DHT_isconnected()) { 160 } else if (dht_on && !DHT_isconnected(m->dht)) {
161 dht_on = false; 161 dht_on = false;
162 wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n"); 162 wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
163 } 163 }