mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Added room_parse_room_jid to room_chat
This commit is contained in:
parent
8beca3cbf7
commit
3436a2245d
38
src/jabber.c
38
src/jabber.c
@ -392,13 +392,20 @@ _message_handler(xmpp_conn_t * const conn,
|
|||||||
|
|
||||||
if(g_time_val_from_iso8601(utc_stamp, &tv_stamp)) {
|
if(g_time_val_from_iso8601(utc_stamp, &tv_stamp)) {
|
||||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
|
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
|
||||||
|
|
||||||
if (body != NULL) {
|
if (body != NULL) {
|
||||||
char *message = xmpp_stanza_get_text(body);
|
char *room = NULL;
|
||||||
char **tokens = g_strsplit(from, "/", 0);
|
char *nick = NULL;
|
||||||
char *room_jid = tokens[0];
|
gboolean parse_success = room_parse_room_jid(from, &room, &nick);
|
||||||
char *nick = tokens[1];
|
|
||||||
prof_handle_room_history(room_jid, nick, tv_stamp, message);
|
if (parse_success) {
|
||||||
g_strfreev(tokens);
|
char *message = xmpp_stanza_get_text(body);
|
||||||
|
prof_handle_room_history(room, nick, tv_stamp, message);
|
||||||
|
g_free(room);
|
||||||
|
g_free(nick);
|
||||||
|
} else {
|
||||||
|
log_error("Could not parse room jid: %s", from);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_error("Couldn't parse datetime string receiving room history: %s", utc_stamp);
|
log_error("Couldn't parse datetime string receiving room history: %s", utc_stamp);
|
||||||
@ -408,12 +415,18 @@ _message_handler(xmpp_conn_t * const conn,
|
|||||||
} else {
|
} else {
|
||||||
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
|
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, "body");
|
||||||
if (body != NULL) {
|
if (body != NULL) {
|
||||||
char *message = xmpp_stanza_get_text(body);
|
char *room = NULL;
|
||||||
char **tokens = g_strsplit(from, "/", 0);
|
char *nick = NULL;
|
||||||
char *room_jid = tokens[0];
|
gboolean parse_success = room_parse_room_jid(from, &room, &nick);
|
||||||
char *nick = tokens[1];
|
|
||||||
prof_handle_room_message(room_jid, nick, message);
|
if (parse_success) {
|
||||||
g_strfreev(tokens);
|
char *message = xmpp_stanza_get_text(body);
|
||||||
|
prof_handle_room_message(room, nick, message);
|
||||||
|
g_free(room);
|
||||||
|
g_free(nick);
|
||||||
|
} else {
|
||||||
|
log_error("Could not parse room jid: %s", from);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -729,3 +742,4 @@ _jabber_send_state(const char * const recipient, const char * const state)
|
|||||||
|
|
||||||
chat_session_set_sent(recipient);
|
chat_session_set_sent(recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,23 @@ room_get_nick_for_room(const char * const jid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
room_parse_room_jid(const char * const room_jid, char **room, char **nick)
|
||||||
|
{
|
||||||
|
char **tokens = g_strsplit(room_jid, "/", 0);
|
||||||
|
|
||||||
|
if (tokens == NULL || tokens[0] == NULL || tokens[1] == NULL) {
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
*room = strdup(tokens[0]);
|
||||||
|
*nick = strdup(tokens[1]);
|
||||||
|
|
||||||
|
g_strfreev(tokens);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_room_free(muc_room *room)
|
_room_free(muc_room *room)
|
||||||
{
|
{
|
||||||
|
@ -26,3 +26,5 @@ void room_join(const char * const jid, const char * const nick);
|
|||||||
void room_leave(const char * const jid);
|
void room_leave(const char * const jid);
|
||||||
gboolean room_jid_is_room_chat(const char * const jid);
|
gboolean room_jid_is_room_chat(const char * const jid);
|
||||||
char * room_get_nick_for_room(const char * const jid);
|
char * room_get_nick_for_room(const char * const jid);
|
||||||
|
gboolean room_parse_room_jid(const char * const room_jid, char **room,
|
||||||
|
char **nick);
|
||||||
|
Loading…
Reference in New Issue
Block a user