1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Check for groupchat

This commit is contained in:
James Booth 2012-11-05 20:29:57 +00:00
parent a141a997f8
commit 0deba9e13e
3 changed files with 116 additions and 85 deletions

View File

@ -34,6 +34,9 @@
#include "profanity.h"
#include "room_chat.h"
// TODO REMOVE
#include "ui.h"
#define PING_INTERVAL 120000 // 2 minutes
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_stanza_release(presence);
room_join(room_join, nick);
room_join(room_jid, nick);
}
void
@ -397,6 +400,10 @@ _message_handler(xmpp_conn_t * const conn,
type = xmpp_stanza_get_attribute(stanza, "type");
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 (strcmp(type, "error") == 0) {
char *err_msg = NULL;
@ -419,7 +426,6 @@ _message_handler(xmpp_conn_t * const conn,
}
}
char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
@ -475,6 +481,7 @@ _message_handler(xmpp_conn_t * const conn,
char *message = xmpp_stanza_get_text(body);
prof_handle_incoming_message(short_from, message);
}
}
return 1;
}
@ -596,6 +603,10 @@ _presence_handler(xmpp_conn_t * const conn,
char *short_jid = strtok(jid_cpy, "/");
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 *type = xmpp_stanza_get_attribute(stanza, "type");
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);
}
}
}
return 1;
}

View File

@ -42,3 +42,19 @@ room_join(const char * const jid, const char * const nick)
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;
}

View File

@ -20,4 +20,7 @@
*
*/
#include <glib.h>
void room_join(const char * const jid, const char * const nick);
gboolean room_jid_is_room_chat(const char * const jid);