mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added client to /info command in chat rooms
This commit is contained in:
parent
cae7717e73
commit
b4ea35d40a
@ -42,7 +42,8 @@ struct p_contact_t {
|
||||
PContact
|
||||
p_contact_new(const char * const jid, const char * const name,
|
||||
const char * const presence, const char * const status,
|
||||
const char * const subscription, gboolean pending_out)
|
||||
const char * const subscription, gboolean pending_out,
|
||||
const char * const caps_str)
|
||||
{
|
||||
PContact contact = malloc(sizeof(struct p_contact_t));
|
||||
contact->jid = strdup(jid);
|
||||
@ -66,11 +67,15 @@ p_contact_new(const char * const jid, const char * const name,
|
||||
if (subscription != NULL)
|
||||
contact->subscription = strdup(subscription);
|
||||
else
|
||||
contact->subscription = strdup("none");;
|
||||
contact->subscription = strdup("none");
|
||||
|
||||
if (caps_str != NULL)
|
||||
contact->caps_str = strdup(caps_str);
|
||||
else
|
||||
contact->caps_str = NULL;
|
||||
|
||||
contact->pending_out = pending_out;
|
||||
contact->last_activity = NULL;
|
||||
contact->caps_str = NULL;
|
||||
|
||||
return contact;
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ typedef struct p_contact_t *PContact;
|
||||
|
||||
PContact p_contact_new(const char * const jid, const char * const name,
|
||||
const char * const presence, const char * const status,
|
||||
const char * const subscription, gboolean pending_out);
|
||||
const char * const subscription, gboolean pending_out,
|
||||
const char * const caps_str);
|
||||
void p_contact_free(PContact contact);
|
||||
const char* p_contact_jid(PContact contact);
|
||||
const char* p_contact_name(PContact contact);
|
||||
|
@ -70,7 +70,7 @@ contact_list_add(const char * const jid, const char * const name,
|
||||
|
||||
if (contact == NULL) {
|
||||
contact = p_contact_new(jid, name, presence, status, subscription,
|
||||
pending_out);
|
||||
pending_out, NULL);
|
||||
g_hash_table_insert(contacts, strdup(jid), contact);
|
||||
p_autocomplete_add(ac, strdup(jid));
|
||||
added = TRUE;
|
||||
@ -126,7 +126,7 @@ contact_list_update_subscription(const char * const jid,
|
||||
|
||||
if (contact == NULL) {
|
||||
contact = p_contact_new(jid, NULL, "offline", NULL, subscription,
|
||||
pending_out);
|
||||
pending_out, NULL);
|
||||
g_hash_table_insert(contacts, strdup(jid), contact);
|
||||
} else {
|
||||
p_contact_set_subscription(contact, subscription);
|
||||
|
33
src/jabber.c
33
src/jabber.c
@ -792,7 +792,7 @@ _iq_handler(xmpp_conn_t * const conn,
|
||||
if (g_strcmp0(id, "roster") == 0) {
|
||||
return _roster_handler(conn, stanza, userdata);
|
||||
|
||||
// handle the initial roster request
|
||||
// handle diso requests
|
||||
} else if ((g_strcmp0(id, "disco") == 0) && (g_strcmp0(type, "result") == 0)) {
|
||||
return _disco_handler(conn, stanza, userdata);
|
||||
|
||||
@ -1032,6 +1032,29 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
|
||||
char *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
|
||||
char *show_str, *status_str;
|
||||
|
||||
char *caps_str = NULL;
|
||||
xmpp_stanza_t *caps = stanza_get_caps(stanza);
|
||||
if (caps != NULL) {
|
||||
char *node = xmpp_stanza_get_attribute(caps, STANZA_ATTR_NODE);
|
||||
char *ver = xmpp_stanza_get_attribute(caps, STANZA_ATTR_VER);
|
||||
|
||||
if ((node != NULL) && (ver != NULL)) {
|
||||
GString *caps_gstr = g_string_new(node);
|
||||
g_string_append(caps_gstr, "#");
|
||||
g_string_append(caps_gstr, ver);
|
||||
caps_str = caps_gstr->str;
|
||||
g_string_free(caps_gstr, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
if (caps_str != NULL) {
|
||||
if (!caps_contains(caps_str)) {
|
||||
xmpp_stanza_t *iq = stanza_create_disco_iq(jabber_conn.ctx, jid, caps_str);
|
||||
xmpp_send(jabber_conn.conn, iq);
|
||||
xmpp_stanza_release(iq);
|
||||
}
|
||||
}
|
||||
|
||||
xmpp_stanza_t *status = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_STATUS);
|
||||
if (status != NULL) {
|
||||
status_str = xmpp_stanza_get_text(status);
|
||||
@ -1056,18 +1079,18 @@ _room_presence_handler(const char * const jid, xmpp_stanza_t * const stanza)
|
||||
show_str = "online";
|
||||
}
|
||||
if (!muc_get_roster_received(room)) {
|
||||
muc_add_to_roster(room, nick, show_str, status_str);
|
||||
muc_add_to_roster(room, nick, show_str, status_str, caps_str);
|
||||
} else {
|
||||
char *old_nick = muc_complete_roster_nick_change(room, nick);
|
||||
|
||||
if (old_nick != NULL) {
|
||||
muc_add_to_roster(room, nick, show_str, status_str);
|
||||
muc_add_to_roster(room, nick, show_str, status_str, caps_str);
|
||||
prof_handle_room_member_nick_change(room, old_nick, nick);
|
||||
} else {
|
||||
if (!muc_nick_in_roster(room, nick)) {
|
||||
prof_handle_room_member_online(room, nick, show_str, status_str);
|
||||
prof_handle_room_member_online(room, nick, show_str, status_str, caps_str);
|
||||
} else {
|
||||
prof_handle_room_member_presence(room, nick, show_str, status_str);
|
||||
prof_handle_room_member_presence(room, nick, show_str, status_str, caps_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,8 @@ muc_nick_in_roster(const char * const room, const char * const nick)
|
||||
*/
|
||||
gboolean
|
||||
muc_add_to_roster(const char * const room, const char * const nick,
|
||||
const char * const show, const char * const status)
|
||||
const char * const show, const char * const status,
|
||||
const char * const caps_str)
|
||||
{
|
||||
ChatRoom *chat_room = g_hash_table_lookup(rooms, room);
|
||||
gboolean updated = FALSE;
|
||||
@ -219,8 +220,7 @@ muc_add_to_roster(const char * const room, const char * const nick,
|
||||
(g_strcmp0(p_contact_status(old), status) != 0)) {
|
||||
updated = TRUE;
|
||||
}
|
||||
|
||||
PContact contact = p_contact_new(nick, NULL, show, status, NULL, FALSE);
|
||||
PContact contact = p_contact_new(nick, NULL, show, status, NULL, FALSE, caps_str);
|
||||
g_hash_table_replace(chat_room->roster, strdup(nick), contact);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,8 @@ void muc_complete_room_nick_change(const char * const room,
|
||||
const char * const nick);
|
||||
|
||||
gboolean muc_add_to_roster(const char * const room, const char * const nick,
|
||||
const char * const show, const char * const status);
|
||||
const char * const show, const char * const status,
|
||||
const char * const caps_str);
|
||||
void muc_remove_from_roster(const char * const room, const char * const nick);
|
||||
GList * muc_get_roster(const char * const room);
|
||||
PAutocomplete muc_get_roster_ac(const char * const room);
|
||||
|
@ -312,9 +312,9 @@ prof_handle_room_roster_complete(const char * const room)
|
||||
void
|
||||
prof_handle_room_member_presence(const char * const room,
|
||||
const char * const nick, const char * const show,
|
||||
const char * const status)
|
||||
const char * const status, const char * const caps_str)
|
||||
{
|
||||
gboolean updated = muc_add_to_roster(room, nick, show, status);
|
||||
gboolean updated = muc_add_to_roster(room, nick, show, status, caps_str);
|
||||
|
||||
if (updated) {
|
||||
win_show_room_member_presence(room, nick, show, status);
|
||||
@ -324,9 +324,10 @@ prof_handle_room_member_presence(const char * const room,
|
||||
|
||||
void
|
||||
prof_handle_room_member_online(const char * const room, const char * const nick,
|
||||
const char * const show, const char * const status)
|
||||
const char * const show, const char * const status,
|
||||
const char * const caps_str)
|
||||
{
|
||||
muc_add_to_roster(room, nick, show, status);
|
||||
muc_add_to_roster(room, nick, show, status, caps_str);
|
||||
win_show_room_member_online(room, nick, show, status);
|
||||
win_current_page_off();
|
||||
}
|
||||
|
@ -51,12 +51,13 @@ void prof_handle_room_subject(const char * const room_jid,
|
||||
const char * const subject);
|
||||
void prof_handle_room_roster_complete(const char * const room);
|
||||
void prof_handle_room_member_online(const char * const room,
|
||||
const char * const nick, const char * const show, const char * const status);
|
||||
const char * const nick, const char * const show, const char * const status,
|
||||
const char * const caps_str);
|
||||
void prof_handle_room_member_offline(const char * const room,
|
||||
const char * const nick, const char * const show, const char * const status);
|
||||
void prof_handle_room_member_presence(const char * const room,
|
||||
const char * const nick, const char * const show,
|
||||
const char * const status);
|
||||
const char * const status, const char * const caps_str);
|
||||
void prof_handle_leave_room(const char * const room);
|
||||
void prof_handle_room_member_nick_change(const char * const room,
|
||||
const char * const old_nick, const char * const nick);
|
||||
|
@ -2405,6 +2405,7 @@ _win_show_info(WINDOW *win, PContact pcontact)
|
||||
wprintw(win, "Client : %s\n", caps->client);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user