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:
parent
d7bcda0e1c
commit
681c3b6be2
@ -404,15 +404,7 @@ prof_handle_version_result(const char * const jid, const char * const presence,
|
|||||||
void
|
void
|
||||||
prof_handle_room_list(GSList *rooms, const char *conference_node)
|
prof_handle_room_list(GSList *rooms, const char *conference_node)
|
||||||
{
|
{
|
||||||
if ((rooms != NULL) && (g_slist_length(rooms) > 0)) {
|
cons_show_room_list(rooms, conference_node);
|
||||||
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);
|
|
||||||
}
|
|
||||||
win_current_page_off();
|
win_current_page_off();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +173,7 @@ void cons_show_software_version(const char * const jid,
|
|||||||
const char * const presence, const char * const name,
|
const char * const presence, const char * const name,
|
||||||
const char * const version, const char * const os);
|
const char * const version, const char * const os);
|
||||||
void cons_show_account_list(gchar **accounts);
|
void cons_show_account_list(gchar **accounts);
|
||||||
|
void cons_show_room_list(GSList *room, const char * const conference_node);
|
||||||
|
|
||||||
// status bar actions
|
// status bar actions
|
||||||
void status_bar_refresh(void);
|
void status_bar_refresh(void);
|
||||||
|
@ -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
|
void
|
||||||
cons_show_status(const char * const contact)
|
cons_show_status(const char * const contact)
|
||||||
{
|
{
|
||||||
|
@ -492,20 +492,31 @@ _iq_handle_discoitems_result(xmpp_conn_t * const conn, xmpp_stanza_t * const sta
|
|||||||
log_debug("Recieved diso#items response");
|
log_debug("Recieved diso#items response");
|
||||||
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
const char *id = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_ID);
|
||||||
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
|
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) {
|
if (g_strcmp0(id, "confreq") == 0) {
|
||||||
log_debug("Response to query: %s", id);
|
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);
|
xmpp_stanza_t *query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||||
|
|
||||||
if (query != NULL) {
|
if (query != NULL) {
|
||||||
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
xmpp_stanza_t *child = xmpp_stanza_get_children(query);
|
||||||
while (child != NULL) {
|
while (child != NULL) {
|
||||||
const char *name = xmpp_stanza_get_name(child);
|
stanza_name = xmpp_stanza_get_name(child);
|
||||||
if ((name != NULL) && (g_strcmp0(name, STANZA_NAME_ITEM) == 0)) {
|
if ((stanza_name != NULL) && (g_strcmp0(stanza_name, STANZA_NAME_ITEM) == 0)) {
|
||||||
const char *jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
item_jid = xmpp_stanza_get_attribute(child, STANZA_ATTR_JID);
|
||||||
if (jid != NULL) {
|
if (item_jid != NULL) {
|
||||||
rooms = g_slist_append(rooms, strdup(jid));
|
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);
|
prof_handle_room_list(items, from);
|
||||||
g_slist_free_full(rooms, free);
|
g_slist_free_full(items, free);
|
||||||
} else if ((id != NULL) && (g_strcmp0(id, "discoitemsreq") == 0)) {
|
} else if ((id != NULL) && (g_strcmp0(id, "discoitemsreq") == 0)) {
|
||||||
cons_show("GOT DISO ITEMS RESULT");
|
cons_show("GOT DISO ITEMS RESULT");
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,11 @@ typedef struct capabilities_t {
|
|||||||
GSList *features;
|
GSList *features;
|
||||||
} Capabilities;
|
} Capabilities;
|
||||||
|
|
||||||
|
typedef struct disco_item_t {
|
||||||
|
char *jid;
|
||||||
|
char *name;
|
||||||
|
} DiscoItem;
|
||||||
|
|
||||||
// connection functions
|
// connection functions
|
||||||
void jabber_init(const int disable_tls);
|
void jabber_init(const int disable_tls);
|
||||||
jabber_conn_status_t jabber_connect_with_details(const char * const jid,
|
jabber_conn_status_t jabber_connect_with_details(const char * const jid,
|
||||||
|
Loading…
Reference in New Issue
Block a user