pidgin: 95a44af4: Add the recent perl callback changes to ...

deryni at pidgin.im deryni at pidgin.im
Tue Apr 22 23:10:44 EDT 2008


-----------------------------------------------------------------
Revision: 95a44af48cc13a9cd6373ef1b011acd7d2b95e98
Ancestor: a2f6c4dc4bdd42033a20ea1fc4f559bc3f7aa7b7
Author: deryni at pidgin.im
Date: 2008-04-23T03:06:49
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/95a44af48cc13a9cd6373ef1b011acd7d2b95e98

Modified files:
        ChangeLog.API libpurple/plugins/perl/common/Purple.xs
        libpurple/plugins/perl/perl-handlers.c
        libpurple/plugins/perl/perl-handlers.h

ChangeLog: 

Add the recent perl callback changes to ChangeLog.API.
Add a Purple::timeout_remove function.
Change Purple::timeout_add to return a value usable in Purple::timeout_remove.

-------------- next part --------------
============================================================
--- ChangeLog.API	3a2d444e8639cab713304907c1c964ac36210b29
+++ ChangeLog.API	59e457c99f6c9e707a625a2ca616494d3aedc2ef
@@ -1,5 +1,17 @@ Pidgin and Finch: The Pimpin' Penguin IM
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
+version 2.x.x:
+	perl:
+		Added:
+		* Purple::Prefs::get_children_names.
+		* Purple::timeout_remove.
+		Changed:
+		* Purple::timeout_add now returns a handle which can be used
+		  to remove the timeout.
+		* Callbacks to Purple::Util::fetch_url and the
+		  Purple::Request::* functions can now be specified as both
+		  strings (the name of the callback function) and as coderefs.
+
 version 2.4.0 (02/29/2008):
 	libpurple:
 		Added:
============================================================
--- libpurple/plugins/perl/common/Purple.xs	6817fea4544d8d8fcfd38de44e1724b35b37729c
+++ libpurple/plugins/perl/common/Purple.xs	6a4886992c3878d84bde921ba4df22c8f21846ca
@@ -74,15 +74,25 @@ BOOT:
 	PURPLE_PERL_BOOT(Util);
 	PURPLE_PERL_BOOT(XMLNode);
 
-void
+guint
 timeout_add(plugin, seconds, callback, data = 0)
 	Purple::Plugin plugin
 	int seconds
 	SV *callback
 	SV *data
 CODE:
-	purple_perl_timeout_add(plugin, seconds, callback, data);
+	RETVAL = purple_perl_timeout_add(plugin, seconds, callback, data);
+OUTPUT:
+	RETVAL
 
+gboolean
+timeout_remove(handle)
+	guint handle
+CODE:
+	RETVAL = purple_perl_timeout_remove(handle);
+OUTPUT:
+	RETVAL
+
 void
 deinit()
 CODE:
============================================================
--- libpurple/plugins/perl/perl-handlers.c	621a99c1cab90948eebdca69063a2797b8f7d712
+++ libpurple/plugins/perl/perl-handlers.c	f67ee5b1917358b93bad48e2f88e15e06d72e9ba
@@ -207,13 +207,15 @@ purple_perl_get_plugin_frame(PurplePlugi
 	return ret_frame;
 }
 
-static void
+static gboolean
 destroy_timeout_handler(PurplePerlTimeoutHandler *handler)
 {
+	gboolean ret = FALSE;
+
 	timeout_handlers = g_list_remove(timeout_handlers, handler);
 
 	if (handler->iotag > 0)
-		purple_timeout_remove(handler->iotag);
+		ret = purple_timeout_remove(handler->iotag);
 
 	if (handler->callback != NULL)
 		SvREFCNT_dec(handler->callback);
@@ -222,6 +224,8 @@ destroy_timeout_handler(PurplePerlTimeou
 		SvREFCNT_dec(handler->data);
 
 	g_free(handler);
+
+	return ret;
 }
 
 static void
@@ -301,8 +305,8 @@ perl_signal_cb(va_list args, void *data)
 
 	for (i = 0; i < value_count; i++) {
 		sv_args[i] = purple_perl_sv_from_vargs(values[i],
-		                                     (va_list*)&args,
-		                                     &copy_args[i]);
+		                                       (va_list*)&args,
+		                                       &copy_args[i]);
 
 		XPUSHs(sv_args[i]);
 	}
@@ -422,14 +426,14 @@ find_signal_handler(PurplePlugin *plugin
 	return NULL;
 }
 
-void
+guint
 purple_perl_timeout_add(PurplePlugin *plugin, int seconds, SV *callback, SV *data)
 {
 	PurplePerlTimeoutHandler *handler;
 
 	if (plugin == NULL) {
 		croak("Invalid handle in adding perl timeout handler.\n");
-		return;
+		return 0;
 	}
 
 	handler = g_new0(PurplePerlTimeoutHandler, 1);
@@ -443,15 +447,39 @@ purple_perl_timeout_add(PurplePlugin *pl
 	timeout_handlers = g_list_append(timeout_handlers, handler);
 
 	handler->iotag = purple_timeout_add(seconds * 1000, perl_timeout_cb, handler);
+
+	return handler->iotag;
 }
 
+gboolean
+purple_perl_timeout_remove(guint handle)
+{
+	GList *l, *l_next;
+
+	for (l = timeout_handlers; l != NULL; l = l_next) {
+		PurplePerlTimeoutHandler *handler;
+
+		l_next = l->next;
+
+		handler = (PurplePerlTimeoutHandler *)l->data;
+
+		if (handler->iotag == handle)
+			return destroy_timeout_handler(handler);
+	}
+
+	purple_debug_info("perl", "No timeout handler found with handle %u.\n",
+	                  handle);
+	return FALSE;
+}
+
 void
 purple_perl_timeout_clear_for_plugin(PurplePlugin *plugin)
 {
-	PurplePerlTimeoutHandler *handler;
 	GList *l, *l_next;
 
 	for (l = timeout_handlers; l != NULL; l = l_next) {
+		PurplePerlTimeoutHandler *handler;
+
 		l_next = l->next;
 
 		handler = (PurplePerlTimeoutHandler *)l->data;
============================================================
--- libpurple/plugins/perl/perl-handlers.h	7d33500283be03462bec1f3ffea4828d982d549f
+++ libpurple/plugins/perl/perl-handlers.h	6b5188feb79bf5e40aad40526aa386985674ae9d
@@ -48,8 +48,9 @@ GtkWidget *purple_perl_gtk_get_plugin_fr
 GtkWidget *purple_perl_gtk_get_plugin_frame(PurplePlugin *plugin);
 #endif
 
-void purple_perl_timeout_add(PurplePlugin *plugin, int seconds, SV *callback,
-                           SV *data);
+guint purple_perl_timeout_add(PurplePlugin *plugin, int seconds, SV *callback,
+                              SV *data);
+gboolean purple_perl_timeout_remove(guint handle);
 void purple_perl_timeout_clear_for_plugin(PurplePlugin *plugin);
 void purple_perl_timeout_clear(void);
 


More information about the Commits mailing list