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.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 9abe8de4..e5525e94 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 }
@@ -297,7 +297,7 @@ int main(int argc, char *argv[])
297 strcpy(DATA_FILE, user_config_dir); 297 strcpy(DATA_FILE, user_config_dir);
298 strcat(DATA_FILE, CONFIGDIR); 298 strcat(DATA_FILE, CONFIGDIR);
299 strcat(DATA_FILE, "data"); 299 strcat(DATA_FILE, "data");
300 300
301 SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1); 301 SRVLIST_FILE = malloc(strlen(user_config_dir) + strlen(CONFIGDIR) + strlen("DHTservers") + 1);
302 strcpy(SRVLIST_FILE, user_config_dir); 302 strcpy(SRVLIST_FILE, user_config_dir);
303 strcat(SRVLIST_FILE, CONFIGDIR); 303 strcat(SRVLIST_FILE, CONFIGDIR);