mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 17:26:20 +00:00
Check for groupchat
This commit is contained in:
16
src/jabber.c
16
src/jabber.c
@@ -34,6 +34,9 @@
|
|||||||
#include "profanity.h"
|
#include "profanity.h"
|
||||||
#include "room_chat.h"
|
#include "room_chat.h"
|
||||||
|
|
||||||
|
// TODO REMOVE
|
||||||
|
#include "ui.h"
|
||||||
|
|
||||||
#define PING_INTERVAL 120000 // 2 minutes
|
#define PING_INTERVAL 120000 // 2 minutes
|
||||||
|
|
||||||
static struct _jabber_conn_t {
|
static struct _jabber_conn_t {
|
||||||
@@ -294,7 +297,7 @@ jabber_join(const char * const room_jid, const char * const nick)
|
|||||||
xmpp_send(jabber_conn.conn, presence);
|
xmpp_send(jabber_conn.conn, presence);
|
||||||
xmpp_stanza_release(presence);
|
xmpp_stanza_release(presence);
|
||||||
|
|
||||||
room_join(room_join, nick);
|
room_join(room_jid, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -397,6 +400,10 @@ _message_handler(xmpp_conn_t * const conn,
|
|||||||
type = xmpp_stanza_get_attribute(stanza, "type");
|
type = xmpp_stanza_get_attribute(stanza, "type");
|
||||||
from = xmpp_stanza_get_attribute(stanza, "from");
|
from = xmpp_stanza_get_attribute(stanza, "from");
|
||||||
|
|
||||||
|
if (room_jid_is_room_chat(from)) {
|
||||||
|
cons_show("CHAT ROOM MESSAGE RECIEVED");
|
||||||
|
} else {
|
||||||
|
|
||||||
if (type != NULL) {
|
if (type != NULL) {
|
||||||
if (strcmp(type, "error") == 0) {
|
if (strcmp(type, "error") == 0) {
|
||||||
char *err_msg = NULL;
|
char *err_msg = NULL;
|
||||||
@@ -419,7 +426,6 @@ _message_handler(xmpp_conn_t * const conn,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char from_cpy[strlen(from) + 1];
|
char from_cpy[strlen(from) + 1];
|
||||||
strcpy(from_cpy, from);
|
strcpy(from_cpy, from);
|
||||||
char *short_from = strtok(from_cpy, "/");
|
char *short_from = strtok(from_cpy, "/");
|
||||||
@@ -475,6 +481,7 @@ _message_handler(xmpp_conn_t * const conn,
|
|||||||
char *message = xmpp_stanza_get_text(body);
|
char *message = xmpp_stanza_get_text(body);
|
||||||
prof_handle_incoming_message(short_from, message);
|
prof_handle_incoming_message(short_from, message);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -596,6 +603,10 @@ _presence_handler(xmpp_conn_t * const conn,
|
|||||||
char *short_jid = strtok(jid_cpy, "/");
|
char *short_jid = strtok(jid_cpy, "/");
|
||||||
|
|
||||||
char *from = xmpp_stanza_get_attribute(stanza, "from");
|
char *from = xmpp_stanza_get_attribute(stanza, "from");
|
||||||
|
|
||||||
|
if (room_jid_is_room_chat(from)) {
|
||||||
|
cons_show("CHAT ROOM PRESENCE RECIEVED");
|
||||||
|
} else {
|
||||||
char *short_from = strtok(from, "/");
|
char *short_from = strtok(from, "/");
|
||||||
char *type = xmpp_stanza_get_attribute(stanza, "type");
|
char *type = xmpp_stanza_get_attribute(stanza, "type");
|
||||||
char *show_str, *status_str;
|
char *show_str, *status_str;
|
||||||
@@ -622,6 +633,7 @@ _presence_handler(xmpp_conn_t * const conn,
|
|||||||
prof_handle_contact_online(short_from, show_str, status_str);
|
prof_handle_contact_online(short_from, show_str, status_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,3 +42,19 @@ room_join(const char * const jid, const char * const nick)
|
|||||||
rooms = g_slist_append(rooms, new_room);
|
rooms = g_slist_append(rooms, new_room);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
room_jid_is_room_chat(const char * const jid)
|
||||||
|
{
|
||||||
|
GSList *current = rooms;
|
||||||
|
while (current != NULL) {
|
||||||
|
muc_room *room = current->data;
|
||||||
|
if (g_str_has_prefix(jid, room->jid)) {
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
current = g_slist_next(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,4 +20,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
void room_join(const char * const jid, const char * const nick);
|
void room_join(const char * const jid, const char * const nick);
|
||||||
|
gboolean room_jid_is_room_chat(const char * const jid);
|
||||||
|
|||||||
Reference in New Issue
Block a user