Mercurial > pidgin
changeset 22702:870a580e8fde
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.
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Wed, 23 Apr 2008 03:06:49 +0000 |
parents | 0ad88bfdde60 |
children | 32624648b797 |
files | ChangeLog.API libpurple/plugins/perl/common/Purple.xs libpurple/plugins/perl/perl-handlers.c libpurple/plugins/perl/perl-handlers.h |
diffstat | 4 files changed, 62 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog.API Wed Apr 23 02:59:37 2008 +0000 +++ b/ChangeLog.API Wed Apr 23 03:06:49 2008 +0000 @@ -1,5 +1,17 @@ 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:
--- a/libpurple/plugins/perl/common/Purple.xs Wed Apr 23 02:59:37 2008 +0000 +++ b/libpurple/plugins/perl/common/Purple.xs Wed Apr 23 03:06:49 2008 +0000 @@ -74,14 +74,24 @@ 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()
--- a/libpurple/plugins/perl/perl-handlers.c Wed Apr 23 02:59:37 2008 +0000 +++ b/libpurple/plugins/perl/perl-handlers.c Wed Apr 23 03:06:49 2008 +0000 @@ -207,13 +207,15 @@ 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 @@ SvREFCNT_dec(handler->data); g_free(handler); + + return ret; } static void @@ -301,8 +305,8 @@ for (i = 0; i < value_count; i++) { sv_args[i] = purple_perl_sv_from_vargs(values[i], - (va_list*)&args, - ©_args[i]); + (va_list*)&args, + ©_args[i]); XPUSHs(sv_args[i]); } @@ -422,14 +426,14 @@ 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 @@ 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;
--- a/libpurple/plugins/perl/perl-handlers.h Wed Apr 23 02:59:37 2008 +0000 +++ b/libpurple/plugins/perl/perl-handlers.h Wed Apr 23 03:06:49 2008 +0000 @@ -48,8 +48,9 @@ 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);