mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-08-02 15:36:21 +00:00
jabber: added _room_presence_handler
This commit is contained in:
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
|
static int
|
||||||
_presence_handler(xmpp_conn_t * const conn,
|
_room_presence_handler(const char * const jid)
|
||||||
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)) {
|
|
||||||
char *room = NULL;
|
char *room = NULL;
|
||||||
char *nick = 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);
|
log_error("Could not parse room jid: %s", room);
|
||||||
g_free(room);
|
g_free(room);
|
||||||
g_free(nick);
|
g_free(nick);
|
||||||
@@ -675,6 +665,24 @@ _presence_handler(xmpp_conn_t * const conn,
|
|||||||
room_add_to_roster(room, nick);
|
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
|
// handle regular presence
|
||||||
} else {
|
} else {
|
||||||
char *short_from = strtok(from, "/");
|
char *short_from = strtok(from, "/");
|
||||||
|
|||||||
Reference in New Issue
Block a user