about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-06-21 01:48:25 +0100
committerJames Booth <boothj5@gmail.com>2015-06-21 01:48:25 +0100
commite45afd5c09a5a4bea9cbf8f16eb6af3908344dba (patch)
tree5832dce58ec4eea210ba2c2adffcf38715296e24 /src/xmpp
parent6617bb5a2b432d9c4178984386855f30be76ecf3 (diff)
downloadprofani-tty-e45afd5c09a5a4bea9cbf8f16eb6af3908344dba.tar.gz
Added pgp checks for message sending
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/message.c46
-rw-r--r--src/xmpp/xmpp.h3
2 files changed, 47 insertions, 2 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 417c68ab..255bf39b 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -103,6 +103,49 @@ message_send_chat(const char * const barejid, const char * const msg)
 
     char *id = create_unique_id("msg");
     xmpp_stanza_t *message = NULL;
+    message = stanza_create_message(ctx, id, jid, STANZA_TYPE_CHAT, msg);
+
+    free(jid);
+
+    if (state) {
+        stanza_attach_state(ctx, message, state);
+    }
+    if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
+        stanza_attach_receipt_request(ctx, message);
+    }
+
+    xmpp_send(conn, message);
+    xmpp_stanza_release(message);
+
+    return id;
+}
+
+char *
+message_send_chat_pgp(const char * const barejid, const char * const msg)
+{
+    xmpp_conn_t * const conn = connection_get_conn();
+    xmpp_ctx_t * const ctx = connection_get_ctx();
+
+    ChatSession *session = chat_session_get(barejid);
+    char *state = NULL;
+    char *jid = NULL;
+    if (session) {
+        if (prefs_get_boolean(PREF_STATES) && session->send_states) {
+            state = STANZA_NAME_ACTIVE;
+        }
+        Jid *jidp = jid_create_from_bare_and_resource(session->barejid, session->resource);
+        jid = strdup(jidp->fulljid);
+        jid_destroy(jidp);
+
+    } else {
+        if (prefs_get_boolean(PREF_STATES)) {
+            state = STANZA_NAME_ACTIVE;
+        }
+        jid = strdup(barejid);
+    }
+
+    char *id = create_unique_id("msg");
+    xmpp_stanza_t *message = NULL;
 
 #ifdef HAVE_LIBGPGME
     char *account_name = jabber_get_account_name();
@@ -137,6 +180,7 @@ message_send_chat(const char * const barejid, const char * const msg)
     if (state) {
         stanza_attach_state(ctx, message, state);
     }
+    stanza_attach_carbons_private(ctx, message);
     if (prefs_get_boolean(PREF_RECEIPTS_REQUEST)) {
         stanza_attach_receipt_request(ctx, message);
     }
@@ -148,7 +192,7 @@ message_send_chat(const char * const barejid, const char * const msg)
 }
 
 char *
-message_send_chat_encrypted(const char * const barejid, const char * const msg)
+message_send_chat_otr(const char * const barejid, const char * const msg)
 {
     xmpp_conn_t * const conn = connection_get_conn();
     xmpp_ctx_t * const ctx = connection_get_ctx();
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index 26122d51..575f9ae1 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -146,7 +146,8 @@ GList * jabber_get_available_resources(void);
 
 // message functions
 char* message_send_chat(const char * const barejid, const char * const msg);
-char* message_send_chat_encrypted(const char * const barejid, const char * const msg);
+char* message_send_chat_otr(const char * const barejid, const char * const msg);
+char* message_send_chat_pgp(const char * const barejid, const char * const msg);
 void message_send_private(const char * const fulljid, const char * const msg);
 void message_send_groupchat(const char * const roomjid, const char * const msg);
 void message_send_groupchat_subject(const char * const roomjid, const char * const subject);