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, 10 insertions, 4 deletions
diff --git a/testing/toxic/main.c b/testing/toxic/main.c
index 397f9391..8ef44012 100644
--- a/testing/toxic/main.c
+++ b/testing/toxic/main.c
@@ -124,6 +124,7 @@ static void init_term()
124 init_pair(2, COLOR_CYAN, COLOR_BLACK); 124 init_pair(2, COLOR_CYAN, COLOR_BLACK);
125 init_pair(3, COLOR_RED, COLOR_BLACK); 125 init_pair(3, COLOR_RED, COLOR_BLACK);
126 init_pair(4, COLOR_BLUE, COLOR_BLACK); 126 init_pair(4, COLOR_BLUE, COLOR_BLACK);
127 init_pair(5, COLOR_YELLOW, COLOR_BLACK);
127 } 128 }
128 refresh(); 129 refresh();
129} 130}
@@ -139,6 +140,7 @@ static void init_tox()
139 m_callback_namechange(m, on_nickchange, NULL); 140 m_callback_namechange(m, on_nickchange, NULL);
140 m_callback_statusmessage(m, on_statuschange, NULL); 141 m_callback_statusmessage(m, on_statuschange, NULL);
141 m_callback_action(m, on_action, NULL); 142 m_callback_action(m, on_action, NULL);
143 setname(m, (uint8_t*) "n00b", strlen("n00b")+1);
142} 144}
143 145
144#define MAXLINE 90 /* Approx max number of chars in a sever line (IP + port + key) */ 146#define MAXLINE 90 /* Approx max number of chars in a sever line (IP + port + key) */
@@ -179,7 +181,7 @@ int init_connection(void)
179 dht.port = htons(atoi(port)); 181 dht.port = htons(atoi(port));
180 uint32_t resolved_address = resolve_addr(ip); 182 uint32_t resolved_address = resolve_addr(ip);
181 if (resolved_address == 0) 183 if (resolved_address == 0)
182 return 4; 184 return 0;
183 dht.ip.i = resolved_address; 185 dht.ip.i = resolved_address;
184 unsigned char *binary_string = hex_string_to_bin(key); 186 unsigned char *binary_string = hex_string_to_bin(key);
185 DHT_bootstrap(dht, binary_string); 187 DHT_bootstrap(dht, binary_string);
@@ -250,10 +252,15 @@ static void init_windows()
250static void do_tox() 252static void do_tox()
251{ 253{
252 static int conn_try = 0; 254 static int conn_try = 0;
255 static int conn_err = 0;
253 static bool dht_on = false; 256 static bool dht_on = false;
254 if (!dht_on && !DHT_isconnected() && !(conn_try++ % 100)) { 257 if (!dht_on && !DHT_isconnected() && !(conn_try++ % 100)) {
255 init_connection(); 258 if (!conn_err) {
256 wprintw(prompt->window, "\nEstablishing connection...\n"); 259 conn_err = init_connection();
260 wprintw(prompt->window, "\nEstablishing connection...\n");
261 if (conn_err)
262 wprintw(prompt->window, "\nAuto-connect failed with error code %d\n", conn_err);
263 }
257 } 264 }
258 else if (!dht_on && DHT_isconnected()) { 265 else if (!dht_on && DHT_isconnected()) {
259 dht_on = true; 266 dht_on = true;
@@ -262,7 +269,6 @@ static void do_tox()
262 else if (dht_on && !DHT_isconnected()) { 269 else if (dht_on && !DHT_isconnected()) {
263 dht_on = false; 270 dht_on = false;
264 wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n"); 271 wprintw(prompt->window, "\nDHT disconnected. Attempting to reconnect.\n");
265 init_connection();
266 } 272 }
267 doMessenger(m); 273 doMessenger(m);
268} 274}