mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
jabber: added _room_presence_handler
This commit is contained in:
parent
a676c50b68
commit
6cb9c853cb
32
src/jabber.c
32
src/jabber.c
@ -645,22 +645,12 @@ _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata)
|
||||
}
|
||||
|
||||
static int
|
||||
_presence_handler(xmpp_conn_t * const conn,
|
||||
xmpp_stanza_t * const stanza, void * const userdata)
|
||||
_room_presence_handler(const char * const jid)
|
||||
{
|
||||
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
|
||||
char jid_cpy[strlen(jid) + 1];
|
||||
strcpy(jid_cpy, jid);
|
||||
char *short_jid = strtok(jid_cpy, "/");
|
||||
|
||||
char *from = xmpp_stanza_get_attribute(stanza, "from");
|
||||
|
||||
// handle chat room presence
|
||||
if (room_is_active(from)) {
|
||||
char *room = NULL;
|
||||
char *nick = NULL;
|
||||
|
||||
if (!room_parse_room_jid(from, &room, &nick)) {
|
||||
if (!room_parse_room_jid(jid, &room, &nick)) {
|
||||
log_error("Could not parse room jid: %s", room);
|
||||
g_free(room);
|
||||
g_free(nick);
|
||||
@ -675,6 +665,24 @@ _presence_handler(xmpp_conn_t * const conn,
|
||||
room_add_to_roster(room, nick);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_presence_handler(xmpp_conn_t * const conn,
|
||||
xmpp_stanza_t * const stanza, void * const userdata)
|
||||
{
|
||||
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
|
||||
char jid_cpy[strlen(jid) + 1];
|
||||
strcpy(jid_cpy, jid);
|
||||
char *short_jid = strtok(jid_cpy, "/");
|
||||
|
||||
char *from = xmpp_stanza_get_attribute(stanza, "from");
|
||||
|
||||
// handle chat room presence
|
||||
if (room_is_active(from)) {
|
||||
return _room_presence_handler(from);
|
||||
|
||||
// handle regular presence
|
||||
} else {
|
||||
char *short_from = strtok(from, "/");
|
||||
|
Loading…
Reference in New Issue
Block a user