about summary refs log tree commit diff stats
path: root/src/xmpp
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-12-27 00:52:34 +0000
committerJames Booth <boothj5@gmail.com>2014-12-27 00:52:34 +0000
commite602c2909e250e8f1dd9e6420585232113fb9ded (patch)
tree47b705ae3c1c17f7d51a2b6ce9a0a92180d6bd1e /src/xmpp
parent676ed1cbae17f7fff6435db58f20b7dfd8a28552 (diff)
downloadprofani-tty-e602c2909e250e8f1dd9e6420585232113fb9ded.tar.gz
Moved chat states out of xmpp module for message send chat
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/message.c33
-rw-r--r--src/xmpp/xmpp.h3
2 files changed, 14 insertions, 22 deletions
diff --git a/src/xmpp/message.c b/src/xmpp/message.c
index 17119bb8..d2748a13 100644
--- a/src/xmpp/message.c
+++ b/src/xmpp/message.c
@@ -80,36 +80,27 @@ message_add_handlers(void)
 }
 
 void
-message_send_chat(const char * const barejid, const char * const msg)
+message_send_chat(const char * const barejid, const char * const resource, const char * const msg, gboolean send_state)
 {
-    const char * jid = NULL;
-
-    if (roster_barejid_from_name(barejid) != NULL) {
-        jid = roster_barejid_from_name(barejid);
-    } else {
-        jid = barejid;
-    }
-
-    if (prefs_get_boolean(PREF_STATES)) {
-        if (!chat_session_exists(jid)) {
-            chat_session_start(jid, TRUE);
-        }
-    }
-
     xmpp_stanza_t *message;
     xmpp_conn_t * const conn = connection_get_conn();
     xmpp_ctx_t * const ctx = connection_get_ctx();
-    if (prefs_get_boolean(PREF_STATES) && chat_session_get_recipient_supports(jid)) {
-        chat_session_set_active(jid);
-        message = stanza_create_message(ctx, jid, STANZA_TYPE_CHAT,
-            msg, STANZA_NAME_ACTIVE);
+
+    GString *jid = g_string_new(barejid);
+    if (resource) {
+        g_string_append(jid, "/");
+        g_string_append(jid, resource);
+    }
+
+    if (send_state) {
+        message = stanza_create_message(ctx, jid->str, STANZA_TYPE_CHAT, msg, STANZA_NAME_ACTIVE);
     } else {
-        message = stanza_create_message(ctx, jid, STANZA_TYPE_CHAT,
-            msg, NULL);
+        message = stanza_create_message(ctx, jid->str, STANZA_TYPE_CHAT, msg, NULL);
     }
 
     xmpp_send(conn, message);
     xmpp_stanza_release(message);
+    g_string_free(jid, TRUE);
 }
 
 void
diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h
index f96a9100..2499d008 100644
--- a/src/xmpp/xmpp.h
+++ b/src/xmpp/xmpp.h
@@ -145,7 +145,8 @@ char* jabber_get_account_name(void);
 GList * jabber_get_available_resources(void);
 
 // message functions
-void message_send_chat(const char * const barejid, const char * const msg);
+void message_send_chat(const char * const barejid, const char * const resource, const char * const msg,
+    gboolean send_state);
 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);