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

Moved message functions to xmpp_message.c

This commit is contained in:
James Booth 2013-01-29 00:37:50 +00:00
parent b269ac9702
commit 0f01f30b9c
6 changed files with 298 additions and 283 deletions

View File

@ -900,7 +900,7 @@ cmd_execute_default(const char * const inp)
win_current_show("You are not currently connected."); win_current_show("You are not currently connected.");
} else { } else {
char *recipient = win_current_get_recipient(); char *recipient = win_current_get_recipient();
jabber_send_groupchat(inp, recipient); message_send_groupchat(inp, recipient);
free(recipient); free(recipient);
} }
} else if (win_current_is_chat() || win_current_is_private()) { } else if (win_current_is_chat() || win_current_is_private()) {
@ -1898,7 +1898,7 @@ _cmd_tiny(gchar **args, struct cmd_help_t help)
free(recipient); free(recipient);
} else { // groupchat } else { // groupchat
char *recipient = win_current_get_recipient(); char *recipient = win_current_get_recipient();
jabber_send_groupchat(tiny, recipient); message_send_groupchat(tiny, recipient);
free(recipient); free(recipient);
} }
free(tiny); free(tiny);
@ -1936,7 +1936,7 @@ _cmd_close(gchar **args, struct cmd_help_t help)
// send <gone/> chat state before closing // send <gone/> chat state before closing
if (chat_session_get_recipient_supports(recipient)) { if (chat_session_get_recipient_supports(recipient)) {
chat_session_set_gone(recipient); chat_session_set_gone(recipient);
jabber_send_gone(recipient); message_send_gone(recipient);
chat_session_end(recipient); chat_session_end(recipient);
} }
} }

View File

@ -398,7 +398,7 @@ prof_handle_activity(void)
chat_session_set_composing(recipient); chat_session_set_composing(recipient);
if (!chat_session_get_sent(recipient) || if (!chat_session_get_sent(recipient) ||
chat_session_is_paused(recipient)) { chat_session_is_paused(recipient)) {
jabber_send_composing(recipient); message_send_composing(recipient);
} }
} }
} }

View File

@ -314,14 +314,14 @@ ui_idle(void)
if (chat_session_is_gone(recipient) && if (chat_session_is_gone(recipient) &&
!chat_session_get_sent(recipient)) { !chat_session_get_sent(recipient)) {
jabber_send_gone(recipient); message_send_gone(recipient);
} else if (chat_session_is_inactive(recipient) && } else if (chat_session_is_inactive(recipient) &&
!chat_session_get_sent(recipient)) { !chat_session_get_sent(recipient)) {
jabber_send_inactive(recipient); message_send_inactive(recipient);
} else if (prefs_get_outtype() && } else if (prefs_get_outtype() &&
chat_session_is_paused(recipient) && chat_session_is_paused(recipient) &&
!chat_session_get_sent(recipient)) { !chat_session_get_sent(recipient)) {
jabber_send_paused(recipient); message_send_paused(recipient);
} }
} }
} }

View File

@ -146,11 +146,6 @@ jabber_conn_status_t jabber_connect_with_account(ProfAccount *account,
const char * const passwd); const char * const passwd);
void jabber_disconnect(void); void jabber_disconnect(void);
void jabber_process_events(void); void jabber_process_events(void);
void jabber_send_groupchat(const char * const msg, const char * const recipient);
void jabber_send_inactive(const char * const recipient);
void jabber_send_composing(const char * const recipient);
void jabber_send_paused(const char * const recipient);
void jabber_send_gone(const char * const recipient);
const char * jabber_get_jid(void); const char * jabber_get_jid(void);
jabber_conn_status_t jabber_get_connection_status(void); jabber_conn_status_t jabber_get_connection_status(void);
int jabber_get_priority(void); int jabber_get_priority(void);
@ -168,7 +163,15 @@ void jabber_conn_set_status(const char * const message);
char* jabber_get_account_name(void); char* jabber_get_account_name(void);
// message functions // message functions
int message_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
void * const userdata);
void message_send(const char * const msg, const char * const recipient); void message_send(const char * const msg, const char * const recipient);
void message_send_groupchat(const char * const msg, const char * const recipient);
void message_send_inactive(const char * const recipient);
void message_send_composing(const char * const recipient);
void message_send_paused(const char * const recipient);
void message_send_gone(const char * const recipient);
// iq functions // iq functions
void iq_add_handlers(void); void iq_add_handlers(void);

View File

@ -75,16 +75,9 @@ static void _jabber_reconnect(void);
static void _jabber_roster_request(void); static void _jabber_roster_request(void);
// XMPP event handlers
static void _connection_handler(xmpp_conn_t * const conn, static void _connection_handler(xmpp_conn_t * const conn,
const xmpp_conn_event_t status, const int error, const xmpp_conn_event_t status, const int error,
xmpp_stream_error_t * const stream_error, void * const userdata); xmpp_stream_error_t * const stream_error, void * const userdata);
static int _message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata);
static int _groupchat_message_handler(xmpp_stanza_t * const stanza);
static int _chat_message_handler(xmpp_stanza_t * const stanza);
static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata); static int _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata);
void void
@ -106,46 +99,6 @@ jabber_restart(void)
FREE_SET_NULL(jabber_conn.status); FREE_SET_NULL(jabber_conn.status);
} }
static jabber_conn_status_t
_jabber_connect(const char * const fulljid, const char * const passwd,
const char * const altdomain)
{
Jid *jid = jid_create(fulljid);
if (jid == NULL) {
log_error("Malformed JID not able to connect: %s", fulljid);
jabber_conn.conn_status = JABBER_DISCONNECTED;
return jabber_conn.conn_status;
} else if (jid->fulljid == NULL) {
log_error("Full JID required to connect, received: %s", fulljid);
jabber_conn.conn_status = JABBER_DISCONNECTED;
return jabber_conn.conn_status;
}
jid_destroy(jid);
log_info("Connecting as %s", fulljid);
xmpp_initialize();
jabber_conn.log = _xmpp_get_file_logger();
jabber_conn.ctx = xmpp_ctx_new(NULL, jabber_conn.log);
jabber_conn.conn = xmpp_conn_new(jabber_conn.ctx);
xmpp_conn_set_jid(jabber_conn.conn, fulljid);
xmpp_conn_set_pass(jabber_conn.conn, passwd);
if (jabber_conn.tls_disabled)
xmpp_conn_disable_tls(jabber_conn.conn);
int connect_status = xmpp_connect_client(jabber_conn.conn, altdomain, 0,
_connection_handler, jabber_conn.ctx);
if (connect_status == 0)
jabber_conn.conn_status = JABBER_CONNECTING;
else
jabber_conn.conn_status = JABBER_DISCONNECTED;
return jabber_conn.conn_status;
}
jabber_conn_status_t jabber_conn_status_t
jabber_connect_with_account(ProfAccount *account, const char * const passwd) jabber_connect_with_account(ProfAccount *account, const char * const passwd)
{ {
@ -241,60 +194,6 @@ jabber_process_events(void)
} }
void
jabber_send_groupchat(const char * const msg, const char * const recipient)
{
xmpp_stanza_t *message = stanza_create_message(jabber_conn.ctx, recipient,
STANZA_TYPE_GROUPCHAT, msg, NULL);
xmpp_send(jabber_conn.conn, message);
xmpp_stanza_release(message);
}
void
jabber_send_composing(const char * const recipient)
{
xmpp_stanza_t *stanza = stanza_create_chat_state(jabber_conn.ctx, recipient,
STANZA_NAME_COMPOSING);
xmpp_send(jabber_conn.conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void
jabber_send_paused(const char * const recipient)
{
xmpp_stanza_t *stanza = stanza_create_chat_state(jabber_conn.ctx, recipient,
STANZA_NAME_PAUSED);
xmpp_send(jabber_conn.conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void
jabber_send_inactive(const char * const recipient)
{
xmpp_stanza_t *stanza = stanza_create_chat_state(jabber_conn.ctx, recipient,
STANZA_NAME_INACTIVE);
xmpp_send(jabber_conn.conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void
jabber_send_gone(const char * const recipient)
{
xmpp_stanza_t *stanza = stanza_create_chat_state(jabber_conn.ctx, recipient,
STANZA_NAME_GONE);
xmpp_send(jabber_conn.conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void void
jabber_set_autoping(int seconds) jabber_set_autoping(int seconds)
{ {
@ -345,7 +244,6 @@ jabber_get_presence(void)
return jabber_conn.presence; return jabber_conn.presence;
} }
// returns pointer to status, owned by connection
char * char *
jabber_get_status(void) jabber_get_status(void)
{ {
@ -395,101 +293,6 @@ jabber_free_resources(void)
xmpp_shutdown(); xmpp_shutdown();
} }
static void
_jabber_roster_request(void)
{
xmpp_stanza_t *iq = stanza_create_roster_iq(jabber_conn.ctx);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
}
static int
_message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata)
{
gchar *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
if (type == NULL) {
log_error("Message stanza received with no type attribute");
return 1;
} else if (strcmp(type, STANZA_TYPE_ERROR) == 0) {
return error_handler(stanza);
} else if (strcmp(type, STANZA_TYPE_GROUPCHAT) == 0) {
return _groupchat_message_handler(stanza);
} else if (strcmp(type, STANZA_TYPE_CHAT) == 0) {
return _chat_message_handler(stanza);
} else {
log_error("Message stanza received with unknown type: %s", type);
return 1;
}
}
static int
_groupchat_message_handler(xmpp_stanza_t * const stanza)
{
char *message = NULL;
char *room_jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
Jid *jid = jid_create(room_jid);
// handle room broadcasts
if (jid->resourcepart == NULL) {
xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT);
// handle subject
if (subject != NULL) {
message = xmpp_stanza_get_text(subject);
if (message != NULL) {
prof_handle_room_subject(jid->barejid, message);
}
return 1;
// handle other room broadcasts
} else {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (body != NULL) {
message = xmpp_stanza_get_text(body);
if (message != NULL) {
prof_handle_room_broadcast(room_jid, message);
}
}
return 1;
}
}
if (!jid_is_valid_room_form(jid)) {
log_error("Invalid room JID: %s", jid->str);
return 1;
}
// room not active in profanity
if (!muc_room_is_active(jid)) {
log_error("Message recieved for inactive chat room: %s", jid->str);
return 1;
}
// determine if the notifications happened whilst offline
GTimeVal tv_stamp;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
// check for and deal with message
if (body != NULL) {
char *message = xmpp_stanza_get_text(body);
if (delayed) {
prof_handle_room_history(jid->barejid, jid->resourcepart, tv_stamp, message);
} else {
prof_handle_room_message(jid->barejid, jid->resourcepart, message);
}
}
jid_destroy(jid);
return 1;
}
int int
error_handler(xmpp_stanza_t * const stanza) error_handler(xmpp_stanza_t * const stanza)
{ {
@ -529,83 +332,44 @@ error_handler(xmpp_stanza_t * const stanza)
return 1; return 1;
} }
static int static jabber_conn_status_t
_chat_message_handler(xmpp_stanza_t * const stanza) _jabber_connect(const char * const fulljid, const char * const passwd,
const char * const altdomain)
{ {
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM); Jid *jid = jid_create(fulljid);
Jid *jid = jid_create(from);
// private message from chat room use full jid (room/nick) if (jid == NULL) {
if (muc_room_is_active(jid)) { log_error("Malformed JID not able to connect: %s", fulljid);
// determine if the notifications happened whilst offline jabber_conn.conn_status = JABBER_DISCONNECTED;
GTimeVal tv_stamp; return jabber_conn.conn_status;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp); } else if (jid->fulljid == NULL) {
log_error("Full JID required to connect, received: %s", fulljid);
// check for and deal with message jabber_conn.conn_status = JABBER_DISCONNECTED;
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY); return jabber_conn.conn_status;
if (body != NULL) {
char *message = xmpp_stanza_get_text(body);
if (delayed) {
prof_handle_delayed_message(jid->str, message, tv_stamp, TRUE);
} else {
prof_handle_incoming_message(jid->str, message, TRUE);
}
} }
free(jid); jid_destroy(jid);
return 1;
// standard chat message, use jid without resource log_info("Connecting as %s", fulljid);
} else { xmpp_initialize();
// determine chatstate support of recipient jabber_conn.log = _xmpp_get_file_logger();
gboolean recipient_supports = FALSE; jabber_conn.ctx = xmpp_ctx_new(NULL, jabber_conn.log);
if (stanza_contains_chat_state(stanza)) { jabber_conn.conn = xmpp_conn_new(jabber_conn.ctx);
recipient_supports = TRUE; xmpp_conn_set_jid(jabber_conn.conn, fulljid);
} xmpp_conn_set_pass(jabber_conn.conn, passwd);
// create or update chat session if (jabber_conn.tls_disabled)
if (!chat_session_exists(jid->barejid)) { xmpp_conn_disable_tls(jabber_conn.conn);
chat_session_start(jid->barejid, recipient_supports);
} else {
chat_session_set_recipient_supports(jid->barejid, recipient_supports);
}
// determine if the notifications happened whilst offline int connect_status = xmpp_connect_client(jabber_conn.conn, altdomain, 0,
GTimeVal tv_stamp; _connection_handler, jabber_conn.ctx);
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
// deal with chat states if recipient supports them if (connect_status == 0)
if (recipient_supports && (!delayed)) { jabber_conn.conn_status = JABBER_CONNECTING;
if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) { else
if (prefs_get_notify_typing() || prefs_get_intype()) { jabber_conn.conn_status = JABBER_DISCONNECTED;
prof_handle_typing(jid->barejid);
}
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) {
prof_handle_gone(jid->barejid);
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) {
// do something
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL) {
// do something
} else { // handle <active/>
// do something
}
}
// check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (body != NULL) {
char *message = xmpp_stanza_get_text(body);
if (delayed) {
prof_handle_delayed_message(jid->barejid, message, tv_stamp, FALSE);
} else {
prof_handle_incoming_message(jid->barejid, message, FALSE);
}
}
free(jid);
return 1;
}
return jabber_conn.conn_status;
} }
static void static void
@ -639,7 +403,7 @@ _connection_handler(xmpp_conn_t * const conn,
chat_sessions_init(); chat_sessions_init();
xmpp_handler_add(conn, _message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx); xmpp_handler_add(conn, message_handler, NULL, STANZA_NAME_MESSAGE, NULL, ctx);
presence_add_handlers(); presence_add_handlers();
iq_add_handlers(); iq_add_handlers();
@ -692,6 +456,14 @@ _connection_handler(xmpp_conn_t * const conn,
} }
} }
static void
_jabber_roster_request(void)
{
xmpp_stanza_t *iq = stanza_create_roster_iq(jabber_conn.ctx);
xmpp_send(jabber_conn.conn, iq);
xmpp_stanza_release(iq);
}
static int static int
_ping_timed_handler(xmpp_conn_t * const conn, void * const userdata) _ping_timed_handler(xmpp_conn_t * const conn, void * const userdata)
{ {

View File

@ -20,12 +20,21 @@
* *
*/ */
#include <stdlib.h>
#include <string.h>
#include <strophe.h> #include <strophe.h>
#include "chat_session.h" #include "chat_session.h"
#include "log.h"
#include "muc.h"
#include "preferences.h" #include "preferences.h"
#include "profanity.h"
#include "xmpp.h" #include "xmpp.h"
static int _groupchat_message_handler(xmpp_stanza_t * const stanza);
static int _chat_message_handler(xmpp_stanza_t * const stanza);
void void
message_send(const char * const msg, const char * const recipient) message_send(const char * const msg, const char * const recipient)
{ {
@ -50,3 +59,234 @@ message_send(const char * const msg, const char * const recipient)
xmpp_send(conn, message); xmpp_send(conn, message);
xmpp_stanza_release(message); xmpp_stanza_release(message);
} }
void
message_send_groupchat(const char * const msg, const char * const recipient)
{
xmpp_conn_t * const conn = jabber_get_conn();
xmpp_ctx_t * const ctx = jabber_get_ctx();
xmpp_stanza_t *message = stanza_create_message(ctx, recipient,
STANZA_TYPE_GROUPCHAT, msg, NULL);
xmpp_send(conn, message);
xmpp_stanza_release(message);
}
void
message_send_composing(const char * const recipient)
{
xmpp_conn_t * const conn = jabber_get_conn();
xmpp_ctx_t * const ctx = jabber_get_ctx();
xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, recipient,
STANZA_NAME_COMPOSING);
xmpp_send(conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void
message_send_paused(const char * const recipient)
{
xmpp_conn_t * const conn = jabber_get_conn();
xmpp_ctx_t * const ctx = jabber_get_ctx();
xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, recipient,
STANZA_NAME_PAUSED);
xmpp_send(conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void
message_send_inactive(const char * const recipient)
{
xmpp_conn_t * const conn = jabber_get_conn();
xmpp_ctx_t * const ctx = jabber_get_ctx();
xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, recipient,
STANZA_NAME_INACTIVE);
xmpp_send(conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
void
message_send_gone(const char * const recipient)
{
xmpp_conn_t * const conn = jabber_get_conn();
xmpp_ctx_t * const ctx = jabber_get_ctx();
xmpp_stanza_t *stanza = stanza_create_chat_state(ctx, recipient,
STANZA_NAME_GONE);
xmpp_send(conn, stanza);
xmpp_stanza_release(stanza);
chat_session_set_sent(recipient);
}
int
message_handler(xmpp_conn_t * const conn,
xmpp_stanza_t * const stanza, void * const userdata)
{
gchar *type = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_TYPE);
if (type == NULL) {
log_error("Message stanza received with no type attribute");
return 1;
} else if (strcmp(type, STANZA_TYPE_ERROR) == 0) {
return error_handler(stanza);
} else if (strcmp(type, STANZA_TYPE_GROUPCHAT) == 0) {
return _groupchat_message_handler(stanza);
} else if (strcmp(type, STANZA_TYPE_CHAT) == 0) {
return _chat_message_handler(stanza);
} else {
log_error("Message stanza received with unknown type: %s", type);
return 1;
}
}
static int
_groupchat_message_handler(xmpp_stanza_t * const stanza)
{
char *message = NULL;
char *room_jid = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
Jid *jid = jid_create(room_jid);
// handle room broadcasts
if (jid->resourcepart == NULL) {
xmpp_stanza_t *subject = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_SUBJECT);
// handle subject
if (subject != NULL) {
message = xmpp_stanza_get_text(subject);
if (message != NULL) {
prof_handle_room_subject(jid->barejid, message);
}
return 1;
// handle other room broadcasts
} else {
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (body != NULL) {
message = xmpp_stanza_get_text(body);
if (message != NULL) {
prof_handle_room_broadcast(room_jid, message);
}
}
return 1;
}
}
if (!jid_is_valid_room_form(jid)) {
log_error("Invalid room JID: %s", jid->str);
return 1;
}
// room not active in profanity
if (!muc_room_is_active(jid)) {
log_error("Message recieved for inactive chat room: %s", jid->str);
return 1;
}
// determine if the notifications happened whilst offline
GTimeVal tv_stamp;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
// check for and deal with message
if (body != NULL) {
char *message = xmpp_stanza_get_text(body);
if (delayed) {
prof_handle_room_history(jid->barejid, jid->resourcepart, tv_stamp, message);
} else {
prof_handle_room_message(jid->barejid, jid->resourcepart, message);
}
}
jid_destroy(jid);
return 1;
}
static int
_chat_message_handler(xmpp_stanza_t * const stanza)
{
gchar *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
Jid *jid = jid_create(from);
// private message from chat room use full jid (room/nick)
if (muc_room_is_active(jid)) {
// determine if the notifications happened whilst offline
GTimeVal tv_stamp;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
// check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (body != NULL) {
char *message = xmpp_stanza_get_text(body);
if (delayed) {
prof_handle_delayed_message(jid->str, message, tv_stamp, TRUE);
} else {
prof_handle_incoming_message(jid->str, message, TRUE);
}
}
free(jid);
return 1;
// standard chat message, use jid without resource
} else {
// determine chatstate support of recipient
gboolean recipient_supports = FALSE;
if (stanza_contains_chat_state(stanza)) {
recipient_supports = TRUE;
}
// create or update chat session
if (!chat_session_exists(jid->barejid)) {
chat_session_start(jid->barejid, recipient_supports);
} else {
chat_session_set_recipient_supports(jid->barejid, recipient_supports);
}
// determine if the notifications happened whilst offline
GTimeVal tv_stamp;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
// deal with chat states if recipient supports them
if (recipient_supports && (!delayed)) {
if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_COMPOSING) != NULL) {
if (prefs_get_notify_typing() || prefs_get_intype()) {
prof_handle_typing(jid->barejid);
}
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_GONE) != NULL) {
prof_handle_gone(jid->barejid);
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_PAUSED) != NULL) {
// do something
} else if (xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_INACTIVE) != NULL) {
// do something
} else { // handle <active/>
// do something
}
}
// check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (body != NULL) {
char *message = xmpp_stanza_get_text(body);
if (delayed) {
prof_handle_delayed_message(jid->barejid, message, tv_stamp, FALSE);
} else {
prof_handle_incoming_message(jid->barejid, message, FALSE);
}
}
free(jid);
return 1;
}
}