1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Merge branch 'master' into pgp

Conflicts:
	src/xmpp/message.c
This commit is contained in:
James Booth 2015-05-03 01:30:14 +01:00
commit d3f4347513
3 changed files with 100 additions and 95 deletions

View File

@ -154,7 +154,7 @@ sv_ev_room_message(const char * const room_jid, const char * const nick,
}
void
sv_ev_incoming_private_message(char *fulljid, char *message)
sv_ev_incoming_private_message(const char * const fulljid, char *message)
{
ui_incoming_private_msg(fulljid, message, NULL);
}
@ -177,7 +177,7 @@ sv_ev_incoming_message(char *barejid, char *resource, char *message)
}
void
sv_ev_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp)
sv_ev_delayed_private_message(const char * const fulljid, char *message, GTimeVal tv_stamp)
{
ui_incoming_private_msg(fulljid, message, &tv_stamp);
}

View File

@ -51,9 +51,9 @@ void sv_ev_room_history(const char * const room_jid, const char * const nick,
void sv_ev_room_message(const char * const room_jid, const char * const nick,
const char * const message);
void sv_ev_incoming_message(char *barejid, char *resource, char *message);
void sv_ev_incoming_private_message(char *fulljid, char *message);
void sv_ev_incoming_private_message(const char * const fulljid, char *message);
void sv_ev_delayed_message(char *fulljid, char *message, GTimeVal tv_stamp);
void sv_ev_delayed_private_message(char *fulljid, char *message, GTimeVal tv_stamp);
void sv_ev_delayed_private_message(const char * const fulljid, char *message, GTimeVal tv_stamp);
void sv_ev_typing(char *barejid, char *resource);
void sv_ev_paused(char *barejid, char *resource);
void sv_ev_inactive(char *barejid, char *resource);

View File

@ -585,6 +585,30 @@ _receipt_received_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza
return 1;
}
void _private_chat_handler(xmpp_stanza_t * const stanza, const char * const fulljid)
{
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (!body) {
return;
}
char *message = xmpp_stanza_get_text(body);
if (!message) {
return;
}
GTimeVal tv_stamp;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
if (delayed) {
sv_ev_delayed_private_message(fulljid, message, tv_stamp);
} else {
sv_ev_incoming_private_message(fulljid, message);
}
xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_free(ctx, message);
}
static int
_chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata)
{
@ -646,42 +670,19 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con
return 1;
}
xmpp_ctx_t *ctx = connection_get_ctx();
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_active(jid->barejid)) {
// 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) {
char *message = xmpp_stanza_get_text(body);
if (message) {
if (delayed) {
sv_ev_delayed_private_message(jid->str, message, tv_stamp);
} else {
sv_ev_incoming_private_message(jid->str, message);
}
xmpp_free(ctx, message);
}
}
jid_destroy(jid);
_private_chat_handler(stanza, jid->fulljid);
return 1;
}
// standard chat message, use jid without resource
} else {
// determine if the notifications happened whilst offline
GTimeVal tv_stamp;
gboolean delayed = stanza_get_delay(stanza, &tv_stamp);
char *id = xmpp_stanza_get_id(stanza);
// check for and deal with message
xmpp_stanza_t *body = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_BODY);
if (body) {
char *message = xmpp_stanza_get_text(body);
@ -707,6 +708,9 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con
sv_ev_incoming_message(jid->barejid, jid->resourcepart, message);
#endif
}
// send receipt if configured
char *id = xmpp_stanza_get_id(stanza);
if (id && prefs_get_boolean(PREF_RECEIPTS_SEND)) {
xmpp_stanza_t *receipts = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_RECEIPTS);
if (receipts) {
@ -716,6 +720,8 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con
}
}
}
xmpp_ctx_t *ctx = connection_get_ctx();
xmpp_free(ctx, message);
}
}
@ -744,4 +750,3 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con
jid_destroy(jid);
return 1;
}
}