[Pkg-privacy-commits] [irssi-plugin-otr] 170/267: Add timer_control libotr callback

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 264545ee4e2f92eb32128c47d60d770c1c8aa3c9
Author: David Goulet <dgoulet at ev0ke.net>
Date:   Sun Dec 2 00:23:56 2012 -0500

    Add timer_control libotr callback
    
    Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
 src/module.c  |  3 +++
 src/otr-ops.c | 12 ++++++++++--
 src/otr.c     | 25 +++++++++++++++++++++++++
 src/otr.h     |  2 ++
 4 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/src/module.c b/src/module.c
index fba7a4b..b61b4af 100644
--- a/src/module.c
+++ b/src/module.c
@@ -351,6 +351,9 @@ void otr_deinit(void)
 
 	otr_finishall(user_state_global);
 
+	/* Remove glib timer if any. */
+	otr_control_timer(0, NULL);
+
 	otr_free_user_state(user_state_global);
 
 	otr_lib_uninit();
diff --git a/src/otr-ops.c b/src/otr-ops.c
index 8bc9329..dd988f5 100644
--- a/src/otr-ops.c
+++ b/src/otr-ops.c
@@ -324,6 +324,14 @@ static void ops_smp_event(void *opdata, OtrlSMPEvent smp_event,
 }
 
 /*
+ * timer_control callback.
+ */
+static void ops_timer_control(void *opdata, unsigned int interval)
+{
+	otr_control_timer(interval, opdata);
+}
+
+/*
  * Assign OTR message operations.
  */
 OtrlMessageAppOps otr_ops = {
@@ -338,7 +346,7 @@ OtrlMessageAppOps otr_ops = {
 	ops_insecure,
 	NULL, /* still_secure */
 	ops_max_msg,
-	NULL, /* accoun_name */
+	NULL, /* account_name */
 	NULL, /* account_name_free */
 	NULL, /* received_symkey */
 	NULL, /* otr_error_message */
@@ -350,5 +358,5 @@ OtrlMessageAppOps otr_ops = {
 	ops_create_instag,
 	NULL, /* convert_msg */
 	NULL, /* convert_free */
-	NULL, /* timer_control */
+	ops_timer_control, /* timer_control */
 };
diff --git a/src/otr.c b/src/otr.c
index 858f07d..0d248ba 100644
--- a/src/otr.c
+++ b/src/otr.c
@@ -45,6 +45,9 @@ static const char *statusbar_txt[] = {
 	"CTX_UPDATE"
 };
 
+/* Glib timer for otr. */
+static guint otr_timerid;
+
 /*
  * Allocate and return a string containing the account name of the Irssi server
  * record.
@@ -221,6 +224,28 @@ end:
 }
 
 /*
+ * Timer called from the glib main loop and set up by the timer_control
+ * callback of libotr.
+ */
+static gboolean timer_fired_cb(gpointer data)
+{
+	otrl_message_poll(user_state_global->otr_state, &otr_ops, NULL);
+	return TRUE;
+}
+
+void otr_control_timer(unsigned int interval, void *opdata)
+{
+	if (otr_timerid) {
+		g_source_remove(otr_timerid);
+		otr_timerid = 0;
+	}
+
+	if (interval > 0) {
+		otr_timerid = g_timeout_add_seconds(interval, timer_fired_cb, opdata);
+	}
+}
+
+/*
  * Find context from nickname and irssi server record.
  */
 ConnContext *otr_find_context(SERVER_REC *irssi, const char *nick, int create)
diff --git a/src/otr.h b/src/otr.h
index afe7cc0..6085665 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -119,6 +119,8 @@ void otr_free_user_state(struct otr_user_state *ustate);
 void otr_lib_init();
 void otr_lib_uninit();
 
+void otr_control_timer(unsigned int interval, void *opdata);
+
 /* Message transport. */
 int otr_send(SERVER_REC *irssi, const char *msg, const char *to,
 		char **otr_msg);

-- 
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