Skip to content

Commit

Permalink
Clean indentation in client.c
Browse files Browse the repository at this point in the history
  • Loading branch information
GDR! authored and GDR! committed Nov 23, 2020
1 parent a64e90e commit 972abf9
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,13 @@ int handle_server_tcp_fin_frame(protocol_frame *rcvd_frame)
/* Close and delete all tunnels (when server went offline) */
void client_close_all_connections()
{
tunnel *tmp = NULL;
tunnel *tun = NULL;
tunnel *tmp = NULL;
tunnel *tun = NULL;

HASH_ITER(hh, by_id, tun, tmp)
{
client_close_tunnel(tun);
}
HASH_ITER(hh, by_id, tun, tmp)
{
client_close_tunnel(tun);
}
}

/* Main loop for the client */
Expand All @@ -284,7 +284,7 @@ int do_client_loop(uint8_t *tox_id_str)
uint32_t friendnumber = 0;
TOX_CONNECTION last_friend_connection_status = TOX_CONNECTION_NONE;
time_t last_friend_connection_status_received = 0;
time_t connection_lost_timestamp = 0;
time_t connection_lost_timestamp = 0;
struct timeval tv;
fd_set fds;
static time_t invitation_sent_time = 0;
Expand Down Expand Up @@ -314,8 +314,8 @@ int do_client_loop(uint8_t *tox_id_str)

while(1)
{
/* Let tox do its stuff */
tox_iterate(tox, NULL);
/* Let tox do its stuff */
tox_iterate(tox, NULL);

switch(state)
{
Expand All @@ -332,7 +332,7 @@ int do_client_loop(uint8_t *tox_id_str)
{
uint8_t* data = (uint8_t *)"Hi, fellow tuntox instance!";
uint16_t length = sizeof(data);
/* https://github.com/TokTok/c-toxcore/blob/acb6b2d8543c8f2ea0c2e60dc046767cf5cc0de8/toxcore/tox.h#L1168 */
/* https://github.com/TokTok/c-toxcore/blob/acb6b2d8543c8f2ea0c2e60dc046767cf5cc0de8/toxcore/tox.h#L1168 */
TOX_ERR_FRIEND_ADD add_error;

if(use_shared_secret)
Expand Down Expand Up @@ -629,11 +629,11 @@ int do_client_loop(uint8_t *tox_id_str)
const char* status = readable_connection_status(friend_connection_status);
log_printf(L_INFO, "Friend connection status changed to: %s (%d)\n", status, friend_connection_status);

if(friend_connection_status == TOX_CONNECTION_NONE)
{
state = CLIENT_STATE_CONNECTION_LOST;
connection_lost_timestamp = time(NULL);
}
if(friend_connection_status == TOX_CONNECTION_NONE)
{
state = CLIENT_STATE_CONNECTION_LOST;
connection_lost_timestamp = time(NULL);
}
}

last_friend_connection_status_received = time(NULL);
Expand All @@ -642,39 +642,39 @@ int do_client_loop(uint8_t *tox_id_str)
}
}
break;
case CLIENT_STATE_CONNECTION_LOST:
{
TOX_CONNECTION friend_connection_status;
friend_connection_status = tox_friend_get_connection_status(tox, friendnumber, &friend_query_error);
if(friend_query_error != TOX_ERR_FRIEND_QUERY_OK)
{
log_printf(L_DEBUG, "tox_friend_get_connection_status: error %u\n", friend_query_error);
}
else
{
if(friend_connection_status == TOX_CONNECTION_NONE)
{
/* https://github.com/TokTok/c-toxcore/blob/acb6b2d8543c8f2ea0c2e60dc046767cf5cc0de8/toxcore/tox.h#L1267 */
TOX_ERR_FRIEND_DELETE tox_delete_error;

log_printf(L_WARNING, "Lost connection to server, closing all tunnels and re-adding friend\n");
client_close_all_connections();
tox_friend_delete(tox, friendnumber, &tox_delete_error);
if(tox_delete_error)
{
log_printf(L_ERROR, "Error when deleting server from friend list: %d\n", tox_delete_error);
}
state = CLIENT_STATE_INITIAL;
}
else
{
state = CLIENT_STATE_FORWARDING;
}
}
}
break;
case 0xffffffff:
log_printf(L_ERROR, "You forgot a break statement\n");
case CLIENT_STATE_CONNECTION_LOST:
{
TOX_CONNECTION friend_connection_status;
friend_connection_status = tox_friend_get_connection_status(tox, friendnumber, &friend_query_error);
if(friend_query_error != TOX_ERR_FRIEND_QUERY_OK)
{
log_printf(L_DEBUG, "tox_friend_get_connection_status: error %u\n", friend_query_error);
}
else
{
if(friend_connection_status == TOX_CONNECTION_NONE)
{
/* https://github.com/TokTok/c-toxcore/blob/acb6b2d8543c8f2ea0c2e60dc046767cf5cc0de8/toxcore/tox.h#L1267 */
TOX_ERR_FRIEND_DELETE tox_delete_error;

log_printf(L_WARNING, "Lost connection to server, closing all tunnels and re-adding friend\n");
client_close_all_connections();
tox_friend_delete(tox, friendnumber, &tox_delete_error);
if(tox_delete_error)
{
log_printf(L_ERROR, "Error when deleting server from friend list: %d\n", tox_delete_error);
}
state = CLIENT_STATE_INITIAL;
}
else
{
state = CLIENT_STATE_FORWARDING;
}
}
}
break;
case 0xffffffff:
log_printf(L_ERROR, "You forgot a break statement\n");
case CLIENT_STATE_SHUTDOWN:
exit(0);
break;
Expand Down

0 comments on commit 972abf9

Please sign in to comment.