[pkg-otr-team] [irssi-plugin-otr] 163/167: Add a timer_control callback for the last-minute libotr 4 API change.
Holger Levsen
holger at moszumanska.debian.org
Mon Mar 3 21:55:42 UTC 2014
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to tag 4.0.0
in repository irssi-plugin-otr.
commit 18dd7d983f07a8cd2ad91c5552e44e200ea35f3d
Author: Ian Goldberg <iang at cs.uwaterloo.ca>
Date: Mon Aug 27 11:09:56 2012 -0400
Add a timer_control callback for the last-minute libotr 4 API change.
---
ChangeLog | 5 +++++
otr-plugin.c | 37 ++++++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index ccb8c6a..984b25d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-08-27
+
+ * otr-plugin.c: Add a timer_control callback for the last-minute
+ libotr 4 API change.
+
2012-08-24
* otr-plugin.c: Turn off the beta dialog
diff --git a/otr-plugin.c b/otr-plugin.c
index 1cee2a6..bec8dd0 100644
--- a/otr-plugin.c
+++ b/otr-plugin.c
@@ -627,6 +627,30 @@ static void received_symkey_cb(void *opdata, ConnContext *context,
}
#endif
+static guint otrg_plugin_timerid = 0;
+
+/* Called by the glib main loop, as set up by stop_start_timer */
+static gboolean timer_fired_cb(gpointer data);
+
+/* Stop the timer, if it's currently running. If interval > 0, start it
+ * to periodically fire every interval seconds. */
+static void stop_start_timer(unsigned int interval) {
+ if (otrg_plugin_timerid) {
+ g_source_remove(otrg_plugin_timerid);
+ otrg_plugin_timerid = 0;
+ }
+ if (interval > 0) {
+ otrg_plugin_timerid = g_timeout_add_seconds(interval,
+ timer_fired_cb, NULL);
+ }
+}
+
+/* Called by libotr */
+static void timer_control_cb(void *opdata, unsigned int interval)
+{
+ stop_start_timer(interval);
+}
+
static OtrlMessageAppOps ui_ops = {
policy_cb,
create_privkey_cb,
@@ -654,9 +678,15 @@ static OtrlMessageAppOps ui_ops = {
handle_msg_event_cb,
create_instag_cb,
NULL, /* convert_data */
- NULL /* convert_data_free */
+ NULL, /* convert_data_free */
+ timer_control_cb
};
+/* Called by the glib main loop, as set up by stop_start_timer */
+static gboolean timer_fired_cb(gpointer data) {
+ otrl_message_poll(otrg_plugin_userstate, &ui_ops, NULL);
+ return TRUE;
+}
static void process_sending_im(PurpleAccount *account, char *who,
char **message, void *m)
@@ -1257,6 +1287,8 @@ static gboolean otr_plugin_load(PurplePlugin *handle)
/* Make our OtrlUserState; we'll only use the one. */
otrg_plugin_userstate = otrl_userstate_create();
+ otrg_plugin_timerid = 0;
+
otrl_privkey_read_FILEp(otrg_plugin_userstate, privf);
otrl_privkey_read_fingerprints_FILEp(otrg_plugin_userstate, storef,
NULL, NULL);
@@ -1327,6 +1359,9 @@ static gboolean otr_plugin_unload(PurplePlugin *handle)
purple_signal_disconnect(blist_handle, "blist-node-extended-menu",
otrg_plugin_handle, PURPLE_CALLBACK(supply_extended_menu));
+ /* Stop the timer, if necessary */
+ stop_start_timer(0);
+
otrl_userstate_free(otrg_plugin_userstate);
otrg_plugin_userstate = NULL;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-otr/packages/irssi-plugin-otr.git
More information about the Pkg-otr-team
mailing list