1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Handle occupant kicked/banned in private chat wins

This commit is contained in:
James Booth 2016-02-02 22:25:55 +00:00
parent 150015fa3d
commit 3ddef99dfe
4 changed files with 71 additions and 1 deletions

View File

@ -686,6 +686,14 @@ sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const
if (mucwin) {
mucwin_occupant_kicked(mucwin, nick, actor, reason);
}
Jid *jidp = jid_create_from_bare_and_resource(room, nick);
ProfPrivateWin *privwin = wins_get_private(jidp->fulljid);
jid_destroy(jidp);
if (privwin != NULL) {
privwin_occupant_kicked(privwin, actor, reason);
}
occupantswin_occupants(room);
rosterwin_roster();
}
@ -699,6 +707,14 @@ sv_ev_room_occupent_banned(const char *const room, const char *const nick, const
if (mucwin) {
mucwin_occupant_banned(mucwin, nick, actor, reason);
}
Jid *jidp = jid_create_from_bare_and_resource(room, nick);
ProfPrivateWin *privwin = wins_get_private(jidp->fulljid);
jid_destroy(jidp);
if (privwin != NULL) {
privwin_occupant_banned(privwin, actor, reason);
}
occupantswin_occupants(room);
rosterwin_roster();
}

View File

@ -126,10 +126,56 @@ privwin_occupant_offline(ProfPrivateWin *privwin)
privwin->occupant_offline = TRUE;
Jid *jidp = jid_create(privwin->fulljid);
win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "-- %s has left the room.", jidp->resourcepart);
win_vprint((ProfWin*)privwin, '-', 0, NULL, 0, THEME_OFFLINE, NULL, "<- %s has left the room.", jidp->resourcepart);
jid_destroy(jidp);
}
void
privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason)
{
assert(privwin != NULL);
privwin->occupant_offline = TRUE;
Jid *jidp = jid_create(privwin->fulljid);
GString *message = g_string_new(jidp->resourcepart);
jid_destroy(jidp);
g_string_append(message, " has been kicked from the room");
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, NULL, "<- %s", message->str);
g_string_free(message, TRUE);
}
void
privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason)
{
assert(privwin != NULL);
privwin->occupant_offline = TRUE;
Jid *jidp = jid_create(privwin->fulljid);
GString *message = g_string_new(jidp->resourcepart);
jid_destroy(jidp);
g_string_append(message, " has been banned from the room");
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, NULL, "<- %s", message->str);
g_string_free(message, TRUE);
}
void
privwin_occupant_online(ProfPrivateWin *privwin)
{

View File

@ -198,6 +198,8 @@ void privwin_message_occupant_offline(ProfPrivateWin *privwin);
char* privwin_get_string(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_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason);
void privwin_occupant_online(ProfPrivateWin *privwin);
// MUC room config window

View File

@ -168,6 +168,12 @@ void chatwin_outgoing_msg(ProfChatWin *chatwin, const char * const message, char
void chatwin_outgoing_carbon(ProfChatWin *chatwin, const char * const message) {}
void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {}
void privwin_occupant_offline(ProfPrivateWin *privwin) {}
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_online(ProfPrivateWin *privwin) {}
void privwin_message_occupant_offline(ProfPrivateWin *privwin) {}
void ui_room_join(const char * const roomjid, gboolean focus) {}
void ui_switch_to_room(const char * const roomjid) {}