mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Handle self leaving room in private wins
This commit is contained in:
parent
292c9cf454
commit
77e819e81a
@ -185,6 +185,8 @@ cl_ev_send_priv_msg(ProfPrivateWin *privwin, const char *const msg)
|
|||||||
{
|
{
|
||||||
if (privwin->occupant_offline) {
|
if (privwin->occupant_offline) {
|
||||||
privwin_message_occupant_offline(privwin);
|
privwin_message_occupant_offline(privwin);
|
||||||
|
} else if (privwin->room_left) {
|
||||||
|
privwin_message_left_room(privwin);
|
||||||
} else {
|
} else {
|
||||||
message_send_private(privwin->fulljid, msg);
|
message_send_private(privwin->fulljid, msg);
|
||||||
privwin_outgoing_msg(privwin, msg);
|
privwin_outgoing_msg(privwin, msg);
|
||||||
|
@ -821,6 +821,15 @@ ui_room_join(const char *const roomjid, gboolean focus)
|
|||||||
char *nick = muc_nick(roomjid);
|
char *nick = muc_nick(roomjid);
|
||||||
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num);
|
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "-> Autojoined %s as %s (%d).", roomjid, nick, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *privwins = wins_get_private_chats(roomjid);
|
||||||
|
GList *curr = privwins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPrivateWin *privwin = curr->data;
|
||||||
|
privwin_room_joined(privwin);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(privwins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -841,6 +850,15 @@ ui_room_destroy(const char *const roomjid)
|
|||||||
ui_close_win(num);
|
ui_close_win(num);
|
||||||
cons_show("Room destroyed: %s", roomjid);
|
cons_show("Room destroyed: %s", roomjid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *privwins = wins_get_private_chats(roomjid);
|
||||||
|
GList *curr = privwins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPrivateWin *privwin = curr->data;
|
||||||
|
privwin_room_destroyed(privwin);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(privwins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -851,6 +869,16 @@ ui_leave_room(const char *const roomjid)
|
|||||||
int num = wins_get_num(window);
|
int num = wins_get_num(window);
|
||||||
ui_close_win(num);
|
ui_close_win(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *privwins = wins_get_private_chats(roomjid);
|
||||||
|
GList *curr = privwins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPrivateWin *privwin = curr->data;
|
||||||
|
privwin_room_left(privwin);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(privwins);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -879,6 +907,15 @@ ui_room_destroyed(const char *const roomjid, const char *const reason, const cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *privwins = wins_get_private_chats(roomjid);
|
||||||
|
GList *curr = privwins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPrivateWin *privwin = curr->data;
|
||||||
|
privwin_room_destroyed(privwin);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(privwins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -906,6 +943,15 @@ ui_room_kicked(const char *const roomjid, const char *const actor, const char *c
|
|||||||
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str);
|
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str);
|
||||||
g_string_free(message, TRUE);
|
g_string_free(message, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *privwins = wins_get_private_chats(roomjid);
|
||||||
|
GList *curr = privwins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPrivateWin *privwin = curr->data;
|
||||||
|
privwin_room_kicked(privwin, actor, reason);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(privwins);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -933,6 +979,15 @@ ui_room_banned(const char *const roomjid, const char *const actor, const char *c
|
|||||||
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str);
|
win_vprint(console, '!', 0, NULL, 0, THEME_TYPING, "", "<- %s", message->str);
|
||||||
g_string_free(message, TRUE);
|
g_string_free(message, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GList *privwins = wins_get_private_chats(roomjid);
|
||||||
|
GList *curr = privwins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPrivateWin *privwin = curr->data;
|
||||||
|
privwin_room_banned(privwin, actor, reason);
|
||||||
|
curr = g_list_next(curr);
|
||||||
|
}
|
||||||
|
g_list_free(privwins);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -119,6 +119,14 @@ privwin_message_occupant_offline(ProfPrivateWin *privwin)
|
|||||||
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room.");
|
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, occupant no longer present in room.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_message_left_room(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
win_print((ProfWin*)privwin, '-', 0, NULL, 0, THEME_ERROR, NULL, "Unable to send message, you are no longer present in room.");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
privwin_occupant_offline(ProfPrivateWin *privwin)
|
privwin_occupant_offline(ProfPrivateWin *privwin)
|
||||||
{
|
{
|
||||||
@ -187,6 +195,85 @@ privwin_occupant_online(ProfPrivateWin *privwin)
|
|||||||
jid_destroy(jidp);
|
jid_destroy(jidp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_room_destroyed(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->room_left = TRUE;
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %s has been destroyed.", jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_room_joined(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->room_left = FALSE;
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have joined %s.", jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_room_left(ProfPrivateWin *privwin)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->room_left = TRUE;
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, NULL, "-- You have left %s.", jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->room_left = TRUE;
|
||||||
|
GString *message = g_string_new("Kicked from ");
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
g_string_append(message, jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
if (actor) {
|
||||||
|
g_string_append(message, " by ");
|
||||||
|
g_string_append(message, actor);
|
||||||
|
}
|
||||||
|
if (reason) {
|
||||||
|
g_string_append(message, ", reason: ");
|
||||||
|
g_string_append(message, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str);
|
||||||
|
g_string_free(message, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason)
|
||||||
|
{
|
||||||
|
assert(privwin != NULL);
|
||||||
|
|
||||||
|
privwin->room_left = TRUE;
|
||||||
|
GString *message = g_string_new("Banned from ");
|
||||||
|
Jid *jidp = jid_create(privwin->fulljid);
|
||||||
|
g_string_append(message, jidp->barejid);
|
||||||
|
jid_destroy(jidp);
|
||||||
|
if (actor) {
|
||||||
|
g_string_append(message, " by ");
|
||||||
|
g_string_append(message, actor);
|
||||||
|
}
|
||||||
|
if (reason) {
|
||||||
|
g_string_append(message, ", reason: ");
|
||||||
|
g_string_append(message, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
win_vprint((ProfWin*)privwin, '!', 0, NULL, 0, THEME_OFFLINE, "", "<- %s", message->str);
|
||||||
|
g_string_free(message, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
privwin_get_string(ProfPrivateWin *privwin)
|
privwin_get_string(ProfPrivateWin *privwin)
|
||||||
{
|
{
|
||||||
|
@ -196,12 +196,20 @@ void privwin_incoming_msg(ProfPrivateWin *privatewin, const char *const message,
|
|||||||
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message);
|
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char *const message);
|
||||||
void privwin_message_occupant_offline(ProfPrivateWin *privwin);
|
void privwin_message_occupant_offline(ProfPrivateWin *privwin);
|
||||||
|
|
||||||
|
void privwin_message_left_room(ProfPrivateWin *privwin);
|
||||||
|
|
||||||
char* privwin_get_string(ProfPrivateWin *privwin);
|
char* privwin_get_string(ProfPrivateWin *privwin);
|
||||||
void privwin_occupant_offline(ProfPrivateWin *privwin);
|
void privwin_occupant_offline(ProfPrivateWin *privwin);
|
||||||
void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||||
void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||||
void privwin_occupant_online(ProfPrivateWin *privwin);
|
void privwin_occupant_online(ProfPrivateWin *privwin);
|
||||||
|
|
||||||
|
void privwin_room_destroyed(ProfPrivateWin *privwin);
|
||||||
|
void privwin_room_left(ProfPrivateWin *privwin);
|
||||||
|
void privwin_room_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||||
|
void privwin_room_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
|
||||||
|
void privwin_room_joined(ProfPrivateWin *privwin);
|
||||||
|
|
||||||
// MUC room config window
|
// MUC room config window
|
||||||
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
void mucconfwin_handle_configuration(ProfMucConfWin *confwin, DataForm *form);
|
||||||
void mucconfwin_show_form(ProfMucConfWin *confwin);
|
void mucconfwin_show_form(ProfMucConfWin *confwin);
|
||||||
|
@ -138,6 +138,7 @@ typedef struct prof_private_win_t {
|
|||||||
gboolean notify;
|
gboolean notify;
|
||||||
unsigned long memcheck;
|
unsigned long memcheck;
|
||||||
gboolean occupant_offline;
|
gboolean occupant_offline;
|
||||||
|
gboolean room_left;
|
||||||
} ProfPrivateWin;
|
} ProfPrivateWin;
|
||||||
|
|
||||||
typedef struct prof_xml_win_t {
|
typedef struct prof_xml_win_t {
|
||||||
|
@ -221,6 +221,7 @@ win_create_private(const char *const fulljid)
|
|||||||
new_win->unread = 0;
|
new_win->unread = 0;
|
||||||
new_win->notify = FALSE;
|
new_win->notify = FALSE;
|
||||||
new_win->occupant_offline = FALSE;
|
new_win->occupant_offline = FALSE;
|
||||||
|
new_win->room_left = FALSE;
|
||||||
|
|
||||||
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
new_win->memcheck = PROFPRIVATEWIN_MEMCHECK;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user