[Pkg-privacy-commits] [irssi-plugin-otr] 171/267: Add otr_error_message/free libotr callbacks

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:41:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.

commit 300bd8437818f79943de6b6fc8de1a14b13c5dce
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Sun Dec 2 00:43:32 2012 -0500

    Add otr_error_message/free libotr callbacks
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/otr-ops.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/otr-ops.c b/src/otr-ops.c
index dd988f5..9364c14 100644
--- a/src/otr-ops.c
+++ b/src/otr-ops.c
@@ -332,6 +332,46 @@ static void ops_timer_control(void *opdata, unsigned int interval)
 }
 
 /*
+ * Handle otr error message.
+ */
+static const char *ops_otr_error_message(void *opdata, ConnContext *context,
+		OtrlErrorCode code)
+{
+	char *msg = NULL;
+
+	switch (code) {
+	case OTRL_ERRCODE_NONE:
+		break;
+	case OTRL_ERRCODE_ENCRYPTION_ERROR:
+		msg = strdup("Error occurred encrypting message.");
+		break;
+	case OTRL_ERRCODE_MSG_NOT_IN_PRIVATE:
+		if (context) {
+			msg = strdup("You sent encrypted data which was unexpected");
+		}
+		break;
+	case OTRL_ERRCODE_MSG_UNREADABLE:
+		msg = strdup("You transmitted an unreadable encrypted message");
+		break;
+	case OTRL_ERRCODE_MSG_MALFORMED:
+		msg = strdup("You transmitted a malformed data message.");
+		break;
+	}
+
+	return msg;
+}
+
+/*
+ * Free otr error message callback.
+ */
+static void ops_otr_error_message_free(void *opdata, const char *err_msg)
+{
+	if (err_msg) {
+		free((char *)err_msg);
+	}
+}
+
+/*
  * Assign OTR message operations.
  */
 OtrlMessageAppOps otr_ops = {
@@ -349,8 +389,8 @@ OtrlMessageAppOps otr_ops = {
 	NULL, /* account_name */
 	NULL, /* account_name_free */
 	NULL, /* received_symkey */
-	NULL, /* otr_error_message */
-	NULL, /* otr_error_message_free */
+	ops_otr_error_message,
+	ops_otr_error_message_free,
 	NULL, /* resent_msg_prefix */
 	NULL, /* resent_msg_prefix_free */
 	ops_smp_event,
@@ -358,5 +398,5 @@ OtrlMessageAppOps otr_ops = {
 	ops_create_instag,
 	NULL, /* convert_msg */
 	NULL, /* convert_free */
-	ops_timer_control, /* timer_control */
+	ops_timer_control,
 };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git



More information about the Pkg-privacy-commits mailing list