diff --git a/src/chat_commands.c b/src/chat_commands.c index 54dadf8..7ce55f1 100644 --- a/src/chat_commands.c +++ b/src/chat_commands.c @@ -149,6 +149,9 @@ void cmd_savefile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv ft->state = FILE_TRANSFER_STARTED; return; + + + on_recv_error: switch (err) { diff --git a/src/friendlist.c b/src/friendlist.c index 8f352b2..4a9614d 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -332,7 +332,7 @@ static void friendlist_onConnectionChange(ToxWindow *self, Tox *m, uint32_t num, if (connection_status == TOX_CONNECTION_NONE) --Friends.num_online; - else + else if (Friends.list[num].connection_status == TOX_CONNECTION_NONE) ++Friends.num_online; Friends.list[num].connection_status = connection_status; diff --git a/src/friendlist.h b/src/friendlist.h index b7c612b..cc28e3a 100644 --- a/src/friendlist.h +++ b/src/friendlist.h @@ -56,6 +56,7 @@ typedef struct { struct LastOnline last_online; struct GroupInvite group_invite; + struct FileTransfer file_receiver[MAX_FILES]; struct FileTransfer file_sender[MAX_FILES]; } ToxicFriend; diff --git a/src/group_commands.c b/src/group_commands.c index ad43176..701e074 100644 --- a/src/group_commands.c +++ b/src/group_commands.c @@ -111,7 +111,9 @@ void cmd_set_topic(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*arg char selfnick[TOX_MAX_NAME_LENGTH]; get_time_str(timefrmt, sizeof(timefrmt)); - int sn_len = tox_group_get_self_name(m, self->num, (uint8_t *) selfnick); + + tox_self_get_name(m, (uint8_t *) selfnick); + size_t sn_len = tox_self_get_name_size(m); selfnick[sn_len] = '\0'; line_info_add(self, timefrmt, NULL, NULL, SYS_MSG, 1, MAGENTA, "-!- You set the topic to: %s", topic); diff --git a/src/help.c b/src/help.c index afb43d1..e948380 100644 --- a/src/help.c +++ b/src/help.c @@ -250,14 +250,7 @@ static void help_draw_group(ToxWindow *self) wprintw(win, " /whisper : Send private message to nick\n\n"); #ifdef AUDIO - wattron(win, A_BOLD); - wprintw(win, " Audio commands:\n"); - wattroff(win, A_BOLD); - - wprintw(win, " /mute : Mute active device where type: in | out\n"); - wprintw(win, " /sense : VAD sensitivity threshold\n\n"); #endif /* AUDIO */ - help_draw_bottom_menu(win); box(win, ACS_VLINE, ACS_HLINE); @@ -313,11 +306,7 @@ void help_onKey(ToxWindow *self, wint_t key) break; case 'r': -#ifdef AUDIO - help_init_window(self, 15, 80); -#else - help_init_window(self, 11, 80); -#endif + help_init_window(self, 6, 80); self->help->type = HELP_GROUP; break; diff --git a/src/prompt.c b/src/prompt.c index 26e55b3..24346d3 100644 --- a/src/prompt.c +++ b/src/prompt.c @@ -31,6 +31,7 @@ #include "toxic.h" #include "windows.h" #include "prompt.h" +#include "friendlist.h" #include "execute.h" #include "misc_tools.h" #include "toxic_strings.h" @@ -46,6 +47,7 @@ extern ToxWindow *prompt; extern struct user_settings *user_settings; extern struct Winthread Winthread; +extern FriendsList Friends; FriendRequests FrndRequests; #ifdef AUDIO @@ -347,7 +349,7 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnu get_time_str(timefrmt, sizeof(timefrmt)); const char *msg; - if (connection_status != TOX_CONNECTION_NONE) { + if (connection_status != TOX_CONNECTION_NONE && Friends.list[friendnum].connection_status == TOX_CONNECTION_NONE) { msg = "has come online"; line_info_add(self, timefrmt, nick, NULL, CONNECTION, 0, GREEN, msg); write_to_log(msg, nick, ctx->log, true); @@ -358,7 +360,8 @@ static void prompt_onConnectionChange(ToxWindow *self, Tox *m, uint32_t friendnu else box_notify(self, user_log_in, NT_WNDALERT_2 | NT_NOTIFWND | NT_RESTOL, &self->active_box, "Toxic", "%s has come online", nick ); - } else { + } + else if (connection_status == TOX_CONNECTION_NONE) { msg = "has gone offline"; line_info_add(self, timefrmt, nick, NULL, DISCONNECTION, 0, RED, msg); write_to_log(msg, nick, ctx->log, true); diff --git a/src/toxic.c b/src/toxic.c index a6abfd6..9217c05 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -359,6 +359,17 @@ int init_connection(Tox *m) return 4; } +static void load_groups(Tox *m) +{ + size_t i; + size_t numgroups = tox_group_count_groups(m); + + for (i = 0; i < numgroups; ++i) { + if (init_groupchat_win(m, i, NULL, 0) == -1) + tox_group_delete(m, i, NULL, 0); + } +} + static void load_friendlist(Tox *m) { size_t i; @@ -370,17 +381,6 @@ static void load_friendlist(Tox *m) sort_friendlist_index(); } -static void load_groups(Tox *m) -{ - uint32_t i; - uint32_t numgroups = tox_group_count_groups(m); - - for (i = 0; i < numgroups; ++i) { - if (init_groupchat_win(m, i, NULL, 0) == -1) - tox_group_delete(m, i, NULL, 0); - } -} - /* return length of password on success, 0 on failure */ static int password_prompt(char *buf, int size) { @@ -525,7 +525,6 @@ int store_data(Tox *m, const char *path) static void init_tox_callbacks(Tox *m) { tox_callback_self_connection_status(m, prompt_onSelfConnectionChange, NULL); - tox_callback_friend_connection_status(m, on_connectionchange, NULL); tox_callback_friend_typing(m, on_typing_change, NULL); tox_callback_friend_request(m, on_request, NULL); @@ -534,12 +533,10 @@ static void init_tox_callbacks(Tox *m) tox_callback_friend_status(m, on_statuschange, NULL); tox_callback_friend_status_message(m, on_statusmessagechange, NULL); tox_callback_friend_read_receipt(m, on_read_receipt, NULL); - tox_callback_file_recv(m, on_file_recv, NULL); tox_callback_file_chunk_request(m, on_file_chunk_request, NULL); tox_callback_file_recv_control(m, on_file_control, NULL); tox_callback_file_recv_chunk(m, on_file_recv_chunk, NULL); - tox_callback_group_invite(m, on_group_invite, NULL); tox_callback_group_message(m, on_group_message, NULL); tox_callback_group_action(m, on_group_action, NULL); diff --git a/src/windows.c b/src/windows.c index 899cd3b..1a0f2db 100644 --- a/src/windows.c +++ b/src/windows.c @@ -151,7 +151,7 @@ void on_friendadded(Tox *m, uint32_t friendnumber, bool sort) void on_group_invite(Tox *m, int32_t friendnumber, const uint8_t *invite_data, uint16_t length, void *userdata) { - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupInvite != NULL) @@ -213,7 +213,7 @@ void on_group_namelistchange(Tox *m, int groupnumber, void *userdata) void on_group_peer_join(Tox *m, int groupnumber, uint32_t peernumber, void *userdata) { - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupPeerJoin != NULL) @@ -228,12 +228,12 @@ void on_group_peer_exit(Tox *m, int groupnumber, uint32_t peernumber, const uint if (length == 0 || !partmsg) { strcpy(msg, "Quit"); - length = 5; + length = strlen(msg); } else { length = copy_tox_str(msg, sizeof(msg), (const char *) partmsg, length); } - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupPeerExit != NULL) @@ -262,7 +262,7 @@ void on_group_nick_change(Tox *m, int groupnumber, uint32_t peernumber, const ui length = copy_tox_str(name, sizeof(name), (const char *) newname, length); filter_str(name, length); - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupNickChange != NULL) @@ -273,7 +273,7 @@ void on_group_nick_change(Tox *m, int groupnumber, uint32_t peernumber, const ui void on_group_op_certificate(Tox *m, int groupnumber, uint32_t src_peernum, uint32_t tgt_peernum, uint8_t cert_type, void *userdata) { - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupOpCertificate != NULL) @@ -283,7 +283,7 @@ void on_group_op_certificate(Tox *m, int groupnumber, uint32_t src_peernum, uint void on_group_self_join(Tox *m, int groupnumber, void *userdata) { - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupSelfJoin != NULL) @@ -293,7 +293,7 @@ void on_group_self_join(Tox *m, int groupnumber, void *userdata) void on_group_self_timeout(Tox *m, int groupnumber, void *userdata) { - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupSelfTimeout != NULL) @@ -303,7 +303,7 @@ void on_group_self_timeout(Tox *m, int groupnumber, void *userdata) void on_group_rejected(Tox *m, int groupnumber, uint8_t type, void *userdata) { - int i; + size_t i; for (i = 0; i < MAX_WINDOWS_NUM; ++i) { if (windows[i].onGroupRejected != NULL)