diff --git a/src/ui/windows.c b/src/ui/windows.c index 9fb2be17..9a10557c 100644 --- a/src/ui/windows.c +++ b/src/ui/windows.c @@ -1418,14 +1418,31 @@ 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(""); - _win_show_time(console->win, '-'); - wprintw(console->win, "%s has invited you to join %s", invitor, room); + cons_show("Chat room invite received:"); + cons_show(" From : %s", invitor); + cons_show(" Room : %s", room); + if (reason != NULL) { - wprintw(console->win, ", \"%s\"", reason); + cons_show(" Message: %s", reason); } - wprintw(console->win, "\n"); - cons_show("Type \"/join %s\" to join the room", room); + + 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); + + jid_destroy(room_jid); + g_string_free(default_service, TRUE); } void diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c index cf721a85..10aedf26 100644 --- a/src/xmpp/connection.c +++ b/src/xmpp/connection.c @@ -50,6 +50,7 @@ static struct _jabber_conn_t { char *presence_message; int priority; int tls_disabled; + char *domain; } jabber_conn; static GHashTable *available_resources; @@ -98,6 +99,7 @@ jabber_init(const int disable_tls) jabber_conn.conn = NULL; jabber_conn.ctx = NULL; jabber_conn.tls_disabled = disable_tls; + jabber_conn.domain = NULL; presence_init(); caps_init(); available_resources = g_hash_table_new_full(g_str_hash, g_str_equal, free, @@ -185,6 +187,7 @@ jabber_disconnect(void) jabber_conn.conn_status = JABBER_STARTED; FREE_SET_NULL(jabber_conn.presence_message); + FREE_SET_NULL(jabber_conn.domain); } void @@ -258,6 +261,12 @@ jabber_get_jid(void) return xmpp_conn_get_jid(jabber_conn.conn); } +const char * +jabber_get_domain(void) +{ + return jabber_conn.domain; +} + char * jabber_get_presence_message(void) { @@ -464,6 +473,10 @@ _connection_handler(xmpp_conn_t * const conn, _connection_free_saved_details(); } + Jid *myJid = jid_create(jabber_get_jid()); + jabber_conn.domain = strdup(myJid->domainpart); + jid_destroy(myJid); + chat_sessions_init(); message_add_handlers(); diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index f7a4f0b3..9b4000ad 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -83,6 +83,7 @@ void jabber_disconnect(void); void jabber_shutdown(void); void jabber_process_events(void); const char * jabber_get_jid(void); +const char * jabber_get_domain(void); jabber_conn_status_t jabber_get_connection_status(void); char * jabber_get_presence_message(void); void jabber_set_autoping(int seconds);