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

Show name as well as jid for room list

This commit is contained in:
James Booth 2013-03-14 22:03:38 +00:00
parent d7bcda0e1c
commit 681c3b6be2
5 changed files with 46 additions and 17 deletions

View File

@ -404,15 +404,7 @@ prof_handle_version_result(const char * const jid, const char * const presence,
void
prof_handle_room_list(GSList *rooms, const char *conference_node)
{
if ((rooms != NULL) && (g_slist_length(rooms) > 0)) {
cons_show("Chat rooms at %s:", conference_node);
while (rooms != NULL) {
cons_show(" %s", rooms->data);
rooms = g_slist_next(rooms);
}
} else {
cons_show("No chat rooms at %s", conference_node);
}
cons_show_room_list(rooms, conference_node);
win_current_page_off();
}

View File

@ -173,6 +173,7 @@ void cons_show_software_version(const char * const jid,
const char * const presence, const char * const name,
const char * const version, const char * const os);
void cons_show_account_list(gchar **accounts);
void cons_show_room_list(GSList *room, const char * const conference_node);
// status bar actions
void status_bar_refresh(void);

View File

@ -1303,6 +1303,26 @@ cons_show_software_version(const char * const jid, const char * const presence,
}
}
void
cons_show_room_list(GSList *rooms, const char * const conference_node)
{
if ((rooms != NULL) && (g_slist_length(rooms) > 0)) {
cons_show("Chat rooms at %s:", conference_node);
while (rooms != NULL) {
DiscoItem *room = rooms->data;
_win_show_time(console->win, '-');
wprintw(console->win, " %s", room->jid);
if (room->name != NULL) {
wprintw(console->win, ", (%s)", room->name);
}
wprintw(console->win, "\n");
rooms = g_slist_next(rooms);
}
} else {
cons_show("No chat rooms at %s", conference_node);
}
}
void
cons_show_status(const char * const contact)
{

View File

@ -492,20 +492,31 @@ _iq_handle_discoitems_result(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
log_debug("Recieved diso#items response");
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
const char *stanza_name = NULL;
const char *item_jid = NULL;
const char *item_name = NULL;
if (g_strcmp0(id, "confreq") == 0) {
log_debug("Response to query: %s", id);
GSList *rooms = NULL;
GSList *items = NULL;
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
if (query != NULL) {
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
while (child != NULL) {
const char *name = xmpp_stanza_get_name(child);
if ((name != NULL) && (g_strcmp0(name, STANZA_NAME_ITEM) == 0)) {
const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
if (jid != NULL) {
rooms = g_slist_append(rooms, strdup(jid));
stanza_name = xmpp_stanza_get_name(child);
if ((stanza_name != NULL) && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
if (item_jid != NULL) {
DiscoItem *item = malloc(sizeof(struct disco_item_t));
item->jid = strdup(item_jid);
item_name = xmpp_stanza_get_attribute(child, STANZA_ATTR_NAME);
if (item_name != NULL) {
item->name = strdup(item_name);
} else {
item->name = NULL;
}
items = g_slist_append(items, item);
}
}
@ -513,8 +524,8 @@ _iq_handle_discoitems_result(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
}
}
prof_handle_room_list(rooms, from);
g_slist_free_full(rooms, free);
prof_handle_room_list(items, from);
g_slist_free_full(items, free);
} else if ((id != NULL) && (g_strcmp0(id, "discoitemsreq") == 0)) {
cons_show("GOT DISO ITEMS RESULT");
}

View File

@ -57,6 +57,11 @@ typedef struct capabilities_t {
GSList *features;
} Capabilities;
typedef struct disco_item_t {
char *jid;
char *name;
} DiscoItem;
// connection functions
void jabber_init(const int disable_tls);
jabber_conn_status_t jabber_connect_with_details(const char * const jid,