aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorunknown <pesco@khjk.org>2014-02-02 00:59:00 +0100
committerunknown <pesco@khjk.org>2014-02-02 00:59:00 +0100
commit367ea3c4533d9e72b783636ab16f0479788f6276 (patch)
tree22e38befdf25ab6cdaf359714835e37cf2469fc4
parentcc17b764196c160e665574ce5bd1bc6e6daf95ee (diff)
work around libotr 4 not sending outgoing plaintext messages
-rw-r--r--otr.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/otr.c b/otr.c
index 3cea1d87..cd542e64 100644
--- a/otr.c
+++ b/otr.c
@@ -440,7 +440,6 @@ char *otr_filter_msg_out(irc_user_t *iu, char *msg, int flags)
{
int st;
char *otrmsg = NULL;
- char *emsg = msg; /* the message as we hand it to libotr */
ConnContext *ctx = NULL;
irc_t *irc = iu->irc;
struct im_connection *ic = iu->bu->ic;
@@ -453,26 +452,21 @@ char *otr_filter_msg_out(irc_user_t *iu, char *msg, int flags)
st = otrl_message_sending(irc->otr->us, &otr_ops, ic,
ic->acc->user, ic->acc->prpl->name, iu->bu->handle, instag,
- emsg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_SKIP, &ctx, NULL, NULL);
- /* in libotr 4.0.0 with OTRL_FRAGMENT_SEND_ALL, otrmsg must be passed
- * but the value it gets carries no meaning. it can be set even though
- * the message has been injected.
- * With OTRL_FRAGMENT_SEND_SKIP, libotr doesn't handle the sending, it's
- * up to us.
- */
-
- if(emsg != msg) {
- g_free(emsg); /* we're done with this one */
- emsg = NULL;
- }
- if(st) {
- irc_rootmsg(irc, "Error encrypting text for OTR: %d", st);
+ msg, NULL, &otrmsg, OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &ctx, NULL, NULL);
+
+ if(otrmsg && otrmsg != msg) {
+ /* libotr wants us to replace our message */
+ /* NB: caller will free old msg */
+ msg = g_strdup(otrmsg);
+ otrl_message_free(otrmsg);
}
- if (otrmsg != NULL) {
- return otrmsg;
+ if(st) {
+ irc_usernotice(iu, "otr: error handling outgoing message: %d", st);
+ msg = NULL; /* do not send plaintext! */
}
- return emsg;
+
+ return msg;
}
static const struct irc_plugin otr_plugin =