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

Use stanza module to create groupchat messages

This commit is contained in:
James Booth 2012-11-08 23:44:09 +00:00
parent f90d13bd5e
commit f167fdd55d
2 changed files with 5 additions and 22 deletions

View File

@ -167,28 +167,11 @@ jabber_send(const char * const msg, const char * const recipient)
void
jabber_send_groupchat(const char * const msg, const char * const recipient)
{
char *encoded_xml = encode_xml(msg);
xmpp_stanza_t *message = stanza_create_message(jabber_conn.ctx, recipient,
"groupchat", msg, NULL);
xmpp_stanza_t *reply, *body, *text;
reply = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(reply, "message");
xmpp_stanza_set_type(reply, "groupchat");
xmpp_stanza_set_attribute(reply, "to", recipient);
body = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_name(body, "body");
text = xmpp_stanza_new(jabber_conn.ctx);
xmpp_stanza_set_text(text, encoded_xml);
xmpp_stanza_add_child(body, text);
xmpp_stanza_add_child(reply, body);
xmpp_send(jabber_conn.conn, reply);
xmpp_stanza_release(reply);
free(encoded_xml);
xmpp_send(jabber_conn.conn, message);
xmpp_stanza_release(message);
}
void

View File

@ -54,7 +54,7 @@ stanza_create_message(xmpp_ctx_t *ctx, const char * const recipient,
msg = xmpp_stanza_new(ctx);
xmpp_stanza_set_name(msg, "message");
xmpp_stanza_set_type(msg, "chat");
xmpp_stanza_set_type(msg, type);
xmpp_stanza_set_attribute(msg, "to", recipient);
body = xmpp_stanza_new(ctx);