1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-15 02:23:04 +01:00

don't delete groups on client exit

This commit is contained in:
Jfreegman 2015-03-19 17:39:11 -04:00
parent 02a0cac85a
commit 6cc8fdf215
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
3 changed files with 10 additions and 6 deletions

View File

@ -167,10 +167,8 @@ static void kill_groupchat_window(ToxWindow *self)
} }
/* Closes groupchat window and cleans up. */ /* Closes groupchat window and cleans up. */
void close_groupchat(ToxWindow *self, Tox *m, int groupnum, const char *partmessage, int length) void close_groupchat(ToxWindow *self, Tox *m, int groupnum)
{ {
tox_group_delete(m, groupnum, (uint8_t *) partmessage, (uint16_t) length);
free(groupchats[groupnum].peer_names); free(groupchats[groupnum].peer_names);
free(groupchats[groupnum].peer_name_lengths); free(groupchats[groupnum].peer_name_lengths);
memset(&groupchats[groupnum], 0, sizeof(GroupChat)); memset(&groupchats[groupnum], 0, sizeof(GroupChat));
@ -186,6 +184,12 @@ void close_groupchat(ToxWindow *self, Tox *m, int groupnum, const char *partmess
kill_groupchat_window(self); kill_groupchat_window(self);
} }
static void exit_groupchat(ToxWindow *self, Tox *m, int groupnum, const char *partmessage, int length)
{
tox_group_delete(m, groupnum, (uint8_t *) partmessage, (uint16_t) length);
close_groupchat(self, m, groupnum);
}
/* Note: the arguments to these functions are validated in the caller functions */ /* Note: the arguments to these functions are validated in the caller functions */
void set_nick_all_groups(Tox *m, const char *nick, uint16_t length) void set_nick_all_groups(Tox *m, const char *nick, uint16_t length)
{ {
@ -744,7 +748,7 @@ static void groupchat_onKey(ToxWindow *self, Tox *m, wint_t key, bool ltr)
if (line[offset] != '\0') if (line[offset] != '\0')
++offset; ++offset;
close_groupchat(self, m, self->num, line + offset, ctx->len - offset); exit_groupchat(self, m, self->num, line + offset, ctx->len - offset);
return; return;
} else if (strncmp(line, "/me ", 4) == 0) { } else if (strncmp(line, "/me ", 4) == 0) {
send_group_action(self, m, self->num, line + 4); send_group_action(self, m, self->num, line + 4);

View File

@ -72,7 +72,7 @@ typedef struct {
#endif #endif
} GroupChat; } GroupChat;
void close_groupchat(ToxWindow *self, Tox *m, int groupnum, const char *partmessage, int length); void close_groupchat(ToxWindow *self, Tox *m, int groupnum);
int init_groupchat_win(Tox *m, int groupnum, const char *groupname, int length); int init_groupchat_win(Tox *m, int groupnum, const char *groupname, int length);
void set_nick_all_groups(Tox *m, const char *nick, uint16_t length); void set_nick_all_groups(Tox *m, const char *nick, uint16_t length);
void set_status_all_groups(Tox *m, uint8_t status); void set_status_all_groups(Tox *m, uint8_t status);

View File

@ -661,7 +661,7 @@ void kill_all_windows(Tox *m)
if (windows[i].is_chat) if (windows[i].is_chat)
kill_chat_window(&windows[i], m); kill_chat_window(&windows[i], m);
else if (windows[i].is_groupchat) else if (windows[i].is_groupchat)
close_groupchat(&windows[i], m, windows[i].num, "Quit", 4); close_groupchat(&windows[i], m, windows[i].num);
} }
kill_prompt_window(prompt); kill_prompt_window(prompt);