diff options
Diffstat (limited to 'testing/toxic/main.c')
-rw-r--r-- | testing/toxic/main.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c index ad89b23c..397f9391 100644 --- a/testing/toxic/main.c +++ b/testing/toxic/main.c | |||
@@ -159,8 +159,7 @@ int init_connection(void) | |||
159 | char line[MAXLINE]; | 159 | char line[MAXLINE]; |
160 | int linecnt = 0; | 160 | int linecnt = 0; |
161 | while (fgets(line, sizeof(line), fp) && linecnt < MAXSERVERS) { | 161 | while (fgets(line, sizeof(line), fp) && linecnt < MAXSERVERS) { |
162 | int len = strlen(line); | 162 | if (strlen(line) > MINLINE) |
163 | if (len > MINLINE && len < MAXLINE) | ||
164 | strcpy(servers[linecnt++], line); | 163 | strcpy(servers[linecnt++], line); |
165 | } | 164 | } |
166 | if (linecnt < 1) { | 165 | if (linecnt < 1) { |
@@ -250,14 +249,20 @@ static void init_windows() | |||
250 | 249 | ||
251 | static void do_tox() | 250 | static void do_tox() |
252 | { | 251 | { |
252 | static int conn_try = 0; | ||
253 | static bool dht_on = false; | 253 | static bool dht_on = false; |
254 | if (!dht_on && DHT_isconnected()) { | 254 | if (!dht_on && !DHT_isconnected() && !(conn_try++ % 100)) { |
255 | init_connection(); | ||
256 | wprintw(prompt->window, "\nEstablishing connection...\n"); | ||
257 | } | ||
258 | else if (!dht_on && DHT_isconnected()) { | ||
255 | dht_on = true; | 259 | dht_on = true; |
256 | wprintw(prompt->window, "\nDHT connected.\n"); | 260 | wprintw(prompt->window, "\nDHT connected.\n"); |
257 | } | 261 | } |
258 | else if (dht_on && !DHT_isconnected()) { | 262 | else if (dht_on && !DHT_isconnected()) { |
259 | dht_on = false; | 263 | dht_on = false; |
260 | wprintw(prompt->window, "\nDHT disconnected.\n"); | 264 | wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n"); |
265 | init_connection(); | ||
261 | } | 266 | } |
262 | doMessenger(m); | 267 | doMessenger(m); |
263 | } | 268 | } |
@@ -442,10 +447,6 @@ int main(int argc, char *argv[]) | |||
442 | load_data(DATA_FILE); | 447 | load_data(DATA_FILE); |
443 | free(DATA_FILE); | 448 | free(DATA_FILE); |
444 | 449 | ||
445 | int connected = init_connection(); | ||
446 | if (connected != 0) | ||
447 | wprintw(prompt->window, "Auto-connect failed (error code %d)\n", connected); | ||
448 | |||
449 | if (f_flag == -1) { | 450 | if (f_flag == -1) { |
450 | attron(COLOR_PAIR(3) | A_BOLD); | 451 | attron(COLOR_PAIR(3) | A_BOLD); |
451 | wprintw(prompt->window, "You passed '-f' without giving an argument.\n" | 452 | wprintw(prompt->window, "You passed '-f' without giving an argument.\n" |