Support for XEP-0249 Direct MUC Invitations

Commands /invite, /invites, /decline and /join
This commit is contained in:
James Booth
2013-04-24 23:50:47 +01:00
parent da84aec513
commit 17757c86e6
10 changed files with 174 additions and 25 deletions

View File

@@ -313,6 +313,24 @@ cons_show_wins(void)
_cons_alert();
}
void
cons_show_room_invites(GSList *invites)
{
cons_show("");
if (invites == NULL) {
cons_show("No outstanding chat room invites.");
} else {
cons_show("Chat room invites, use /join or /decline commands:");
while (invites != NULL) {
cons_show(" %s", invites->data);
invites = g_slist_next(invites);
}
}
ui_console_dirty();
_cons_alert();
}
void
cons_show_info(PContact pcontact)
{
@@ -653,12 +671,6 @@ void
cons_show_room_invite(const char * const invitor, const char * const room,
const char * const reason)
{
char *display_room = NULL;
char *domain = strdup(jabber_get_domain());
Jid *room_jid = jid_create(room);
GString *default_service = g_string_new("conference.");
g_string_append(default_service, domain);
cons_show("");
cons_show("Chat room invite received:");
cons_show(" From : %s", invitor);
@@ -668,21 +680,12 @@ cons_show_room_invite(const char * const invitor, const char * const room,
cons_show(" Message: %s", reason);
}
if (strcmp(room_jid->domainpart, default_service->str) == 0) {
display_room = room_jid->localpart;
} else {
display_room = room_jid->barejid;
}
cons_show("Type \"/join %s\" to accept the invitation", display_room);
cons_show("Use /join or /decline");
if (prefs_get_boolean(PREF_NOTIFY_INVITE)) {
notify_invite(invitor, room);
notify_invite(invitor, room, reason);
}
jid_destroy(room_jid);
g_string_free(default_service, TRUE);
ui_console_dirty();
_cons_alert();
}

View File

@@ -33,6 +33,7 @@
#endif
#include "log.h"
#include "muc.h"
#include "ui/ui.h"
static void _notify(const char * const message, int timeout,
@@ -66,12 +67,16 @@ notify_typing(const char * const from)
}
void
notify_invite(const char * const from, const char * const room)
notify_invite(const char * const from, const char * const room,
const char * const reason)
{
GString *message = g_string_new("Room invite\nfrom: ");
g_string_append(message, from);
g_string_append(message, "\nto: ");
g_string_append(message, room);
if (reason != NULL) {
g_string_append_printf(message, "\n\"%s\"", reason);
}
_notify(message->str, 10000, "Incoming message");
@@ -91,8 +96,7 @@ void
notify_remind(void)
{
gint unread = ui_unread();
//gint open = jabber_open_invites();
gint open = 0;
gint open = muc_invite_count();
GString *text = g_string_new("");
@@ -109,9 +113,9 @@ notify_remind(void)
g_string_append(text, "\n");
}
if (open == 1) {
g_string_append(text, "1 open invite");
g_string_append(text, "1 room invite");
} else {
g_string_append_printf(text, "%d open invites", open);
g_string_append_printf(text, "%d room invites", open);
}
}

View File

@@ -26,4 +26,5 @@ void notifier_uninit(void);
void notify_typing(const char * const from);
void notify_message(const char * const short_from);
void notify_remind(void);
void notify_invite(const char * const from, const char * const room);
void notify_invite(const char * const from, const char * const room,
const char * const reason);

View File

@@ -166,6 +166,7 @@ void cons_show_room_invite(const char * const invitor, const char * const room,
void cons_check_version(gboolean not_available_msg);
void cons_show_typing(const char * const short_from);
void cons_show_incoming_message(const char * const short_from, const int win_index);
void cons_show_room_invites(GSList *invites);
// status bar actions
void status_bar_refresh(void);