Handle self leaving room in private wins

This commit is contained in:
James Booth
2016-02-03 00:11:38 +00:00
parent 292c9cf454
commit 77e819e81a
6 changed files with 154 additions and 0 deletions

View File

@@ -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.");
}
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
privwin_occupant_offline(ProfPrivateWin *privwin)
{
@@ -187,6 +195,85 @@ privwin_occupant_online(ProfPrivateWin *privwin)
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*
privwin_get_string(ProfPrivateWin *privwin)
{