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

Show shortened room jid if possible on invite

This commit is contained in:
James Booth 2013-04-18 22:49:46 +01:00
parent 202bc6b427
commit 91d587a19f
3 changed files with 36 additions and 5 deletions

View File

@ -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

View File

@ -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();

View File

@ -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);