about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-08-20 19:08:13 +0100
committerJames Booth <boothj5@gmail.com>2016-08-20 19:08:13 +0100
commit39ff3996263698c7fb7b0035ff246f7b29af7b92 (patch)
tree642db6db1555d33517a03984e7b04c799cb713f3 /src/xmpp
parent45048e3ac8bb342b63aaac323f76d0fa3c472720 (diff)
downloadprofani-tty-39ff3996263698c7fb7b0035ff246f7b29af7b92.tar.gz
Use libstrophe xmpp_message_new convenience function
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/message.c6
-rw-r--r--src/xmpp/stanza.c28
2 files changed, 12 insertions, 22 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index e9fc8297..ea93c816 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -602,12 +602,10 @@ void
 _message_send_receipt(const char *const fulljid, const char *const message_id)
 {
     xmpp_ctx_t * const ctx = connection_get_ctx();
-    xmpp_stanza_t *message = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
+
     char *id = create_unique_id("receipt");
-    xmpp_stanza_set_id(message, id);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, fulljid, id);
     free(id);
-    xmpp_stanza_set_to(message, fulljid);
 
     xmpp_stanza_t *receipt = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(receipt, "received");
diff --git a/src/xmpp/stanza.c b/src/xmpp/stanza.c
index 7b7396fe..557ad26f 100644
--- a/src/xmpp/stanza.c
+++ b/src/xmpp/stanza.c
@@ -319,12 +319,9 @@ stanza_disable_carbons(xmpp_ctx_t *ctx)
 xmpp_stanza_t*
 stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char *const state)
 {
-    xmpp_stanza_t *msg = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE);
-    xmpp_stanza_set_type(msg, STANZA_TYPE_CHAT);
-    xmpp_stanza_set_to(msg, fulljid);
-    _stanza_add_unique_id(msg, NULL);
-
+    char *id = create_unique_id(NULL);
+    xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_CHAT, fulljid, id);
+    free(id);
 
     xmpp_stanza_t *chat_state = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(chat_state, state);
@@ -338,10 +335,7 @@ stanza_create_chat_state(xmpp_ctx_t *ctx, const char *const fulljid, const char
 xmpp_stanza_t*
 stanza_create_room_subject_message(xmpp_ctx_t *ctx, const char *const room, const char *const subject)
 {
-    xmpp_stanza_t *msg = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(msg, STANZA_NAME_MESSAGE);
-    xmpp_stanza_set_type(msg, STANZA_TYPE_GROUPCHAT);
-    xmpp_stanza_set_to(msg, room);
+    xmpp_stanza_t *msg = xmpp_message_new(ctx, STANZA_TYPE_GROUPCHAT, room, NULL);
 
     xmpp_stanza_t *subject_st = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(subject_st, STANZA_NAME_SUBJECT);
@@ -517,10 +511,9 @@ xmpp_stanza_t*
 stanza_create_invite(xmpp_ctx_t *ctx, const char *const room,
     const char *const contact, const char *const reason, const char *const password)
 {
-    xmpp_stanza_t *message = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
-    xmpp_stanza_set_to(message, contact);
-    _stanza_add_unique_id(message, NULL);
+    char *id = create_unique_id(NULL);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, contact, id);
+    free(id);
 
     xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);
@@ -544,10 +537,9 @@ xmpp_stanza_t*
 stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char *const room,
     const char *const contact, const char *const reason)
 {
-    xmpp_stanza_t *message = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
-    xmpp_stanza_set_to(message, room);
-    _stanza_add_unique_id(message, NULL);
+    char *id = create_unique_id(NULL);
+    xmpp_stanza_t *message = xmpp_message_new(ctx, NULL, room, id);
+    free(id);
 
     xmpp_stanza_t *x = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(x, STANZA_NAME_X);