summaryrefslogtreecommitdiff
path: root/client.c
diff options
context:
space:
mode:
authorGDR! <gdr@gdr.name>2016-06-07 21:52:48 +0200
committerGDR! <gdr@gdr.name>2016-06-07 21:52:48 +0200
commit1013b2aaeafa9112849df4e08bcced23cbd91fdf (patch)
tree101e51c47c70ac1a9a70c4db3633983939de95aa /client.c
parent816245f429145052b8908d500c64d372fc8c2972 (diff)
"Whitelist clients by pubkeys" mode, re-request friends
See #14
Diffstat (limited to 'client.c')
-rw-r--r--client.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/client.c b/client.c
index 9dc1b03..0634702 100644
--- a/client.c
+++ b/client.c
@@ -266,6 +266,7 @@ int do_client_loop(char *tox_id_str)
266 struct timeval tv; 266 struct timeval tv;
267 fd_set fds; 267 fd_set fds;
268 static time_t invitation_sent_time = 0; 268 static time_t invitation_sent_time = 0;
269 uint32_t invitations_sent = 0;
269 TOX_ERR_FRIEND_QUERY friend_query_error; 270 TOX_ERR_FRIEND_QUERY friend_query_error;
270 TOX_ERR_FRIEND_CUSTOM_PACKET custom_packet_error; 271 TOX_ERR_FRIEND_CUSTOM_PACKET custom_packet_error;
271 272
@@ -318,7 +319,14 @@ int do_client_loop(char *tox_id_str)
318 log_printf(L_DEBUG, "Sent shared secret of length %u\n", length); 319 log_printf(L_DEBUG, "Sent shared secret of length %u\n", length);
319 } 320 }
320 321
321 log_printf(L_INFO, "Connected. Sending friend request.\n"); 322 if(invitations_sent == 0)
323 {
324 log_printf(L_INFO, "Connected. Sending friend request.\n");
325 }
326 else
327 {
328 log_printf(L_INFO, "Sending another friend request.\n");
329 }
322 330
323 friendnumber = tox_friend_add( 331 friendnumber = tox_friend_add(
324 tox, 332 tox,
@@ -337,6 +345,7 @@ int do_client_loop(char *tox_id_str)
337 } 345 }
338 346
339 invitation_sent_time = time(NULL); 347 invitation_sent_time = time(NULL);
348 invitations_sent++;
340 state = CLIENT_STATE_SENTREQUEST; 349 state = CLIENT_STATE_SENTREQUEST;
341 log_printf(L_INFO, "Waiting for friend to accept us...\n"); 350 log_printf(L_INFO, "Waiting for friend to accept us...\n");
342 } 351 }
@@ -359,9 +368,21 @@ int do_client_loop(char *tox_id_str)
359 } 368 }
360 else 369 else
361 { 370 {
362 if(0 && (time(NULL) - invitation_sent_time > 60)) 371 if(1 && (time(NULL) - invitation_sent_time > 45))
363 { 372 {
373 TOX_ERR_FRIEND_DELETE error = 0;
374
364 log_printf(L_INFO, "Sending another friend request..."); 375 log_printf(L_INFO, "Sending another friend request...");
376 tox_friend_delete(
377 tox,
378 friendnumber,
379 &error);
380 if(error != TOX_ERR_FRIEND_DELETE_OK)
381 {
382 log_printf(L_ERROR, "Error %u deleting friend before reconnection\n", error);
383 exit(-1);
384 }
385
365 state = CLIENT_STATE_CONNECTED; 386 state = CLIENT_STATE_CONNECTED;
366 } 387 }
367 } 388 }