about summary refs log tree commit diff stats
path: root/src/otr
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-05-02 23:23:12 +0100
committerJames Booth <boothj5@gmail.com>2015-05-02 23:23:12 +0100
commitbe4ee40ed4566680b15385f6fc736402612e8812 (patch)
treea09b684b58996174209129b27520ad830fb181d2 /src/otr
parent01181780801a46ecc6996be5b75b2245c1c1b953 (diff)
downloadprofani-tty-be4ee40ed4566680b15385f6fc736402612e8812.tar.gz
Pass ProfChatWin to otr_on_message_send
Diffstat (limited to 'src/otr')
-rw-r--r--src/otr/otr.c46
-rw-r--r--src/otr/otr.h11
2 files changed, 20 insertions, 37 deletions
diff --git a/src/otr/otr.c b/src/otr/otr.c
index 46ad491c..ae8ed006 100644
--- a/src/otr/otr.c
+++ b/src/otr/otr.c
@@ -313,43 +313,43 @@ otr_on_message_recv(const char * const barejid, const char * const resource, con
     otr_free_message(decrypted);
 }
 
-prof_otrsendres_t
-otr_on_message_send(const char * const barejid, const char * const message)
+void
+otr_on_message_send(ProfChatWin *chatwin, const char * const message)
 {
     char *id = NULL;
 
-    prof_otrpolicy_t policy = otr_get_policy(barejid);
+    prof_otrpolicy_t policy = otr_get_policy(chatwin->barejid);
 
-    if (otr_is_secure(barejid)) {
-        char *encrypted = otr_encrypt_message(barejid, message);
+    if (otr_is_secure(chatwin->barejid)) {
+        char *encrypted = otr_encrypt_message(chatwin->barejid, message);
         if (encrypted) {
-            id = message_send_chat_encrypted(barejid, encrypted);
-            chat_log_otr_msg_out(barejid, message);
-            ui_outgoing_chat_msg(barejid, message, id);
+            id = message_send_chat_encrypted(chatwin->barejid, encrypted);
+            chat_log_otr_msg_out(chatwin->barejid, message);
+            ui_outgoing_chat_msg(chatwin->barejid, message, id);
             otr_free_message(encrypted);
         } else {
-            return PROF_OTRENCFAIL;
+            ui_win_error_line((ProfWin*)chatwin, "Failed to encrypt and send message.");
+            return;
         }
 
     } else if (policy == PROF_OTRPOLICY_ALWAYS) {
-        return PROF_OTRPOLICYFAIL;
+        ui_win_error_line((ProfWin*)chatwin, "Failed to send message. OTR policy set to: always");
+        return;
 
     } else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
         char *otr_tagged_msg = otr_tag_message(message);
-        id = message_send_chat_encrypted(barejid, otr_tagged_msg);
-        ui_outgoing_chat_msg(barejid, message, id);
-        chat_log_msg_out(barejid, message);
+        id = message_send_chat_encrypted(chatwin->barejid, otr_tagged_msg);
+        ui_outgoing_chat_msg(chatwin->barejid, message, id);
+        chat_log_msg_out(chatwin->barejid, message);
         free(otr_tagged_msg);
 
     } else {
-        id = message_send_chat(barejid, message);
-        ui_outgoing_chat_msg(barejid, message, id);
-        chat_log_msg_out(barejid, message);
+        id = message_send_chat(chatwin->barejid, message);
+        ui_outgoing_chat_msg(chatwin->barejid, message, id);
+        chat_log_msg_out(chatwin->barejid, message);
     }
 
     free(id);
-
-    return PROF_OTRSUCCESS;
 }
 
 void
@@ -743,16 +743,6 @@ otr_decrypt_message(const char * const from, const char * const message, gboolea
     }
 }
 
-char*
-otr_senderror_str(prof_otrsendres_t res)
-{
-    switch (res) {
-    case PROF_OTRENCFAIL:    return "Failed to encrypt and send message.";
-    case PROF_OTRPOLICYFAIL: return "Failed to send message. OTR policy set to: always";
-    default:                 return "Unknown OTR error.";
-    }
-}
-
 void
 otr_free_message(char *message)
 {
diff --git a/src/otr/otr.h b/src/otr/otr.h
index 6f1103df..e020c0c8 100644
--- a/src/otr/otr.h
+++ b/src/otr/otr.h
@@ -39,6 +39,7 @@
 #include <libotr/message.h>
 
 #include "config/accounts.h"
+#include "ui/window.h"
 
 typedef enum {
     PROF_OTRPOLICY_MANUAL,
@@ -46,12 +47,6 @@ typedef enum {
     PROF_OTRPOLICY_ALWAYS
 } prof_otrpolicy_t;
 
-typedef enum {
-    PROF_OTRENCFAIL,
-    PROF_OTRPOLICYFAIL,
-    PROF_OTRSUCCESS
-} prof_otrsendres_t;
-
 OtrlUserState otr_userstate(void);
 OtrlMessageAppOps* otr_messageops(void);
 GHashTable* otr_smpinitators(void);
@@ -64,7 +59,7 @@ void otr_poll(void);
 void otr_on_connect(ProfAccount *account);
 
 void otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message);
-prof_otrsendres_t otr_on_message_send(const char * const barejid, const char * const message);
+void otr_on_message_send(ProfChatWin *chatwin, const char * const message);
 
 void otr_keygen(ProfAccount *account);
 
@@ -94,6 +89,4 @@ void otr_free_message(char *message);
 
 prof_otrpolicy_t otr_get_policy(const char * const recipient);
 
-char* otr_senderror_str(prof_otrsendres_t res);
-
 #endif