Mercurial > pidgin
changeset 6568:33486b749aa9
[gaim-migrate @ 7090]
Add the same spiffiness to timeouts.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 22 Aug 2003 04:17:10 +0000 |
parents | 6e25e1e08ffb |
children | 4dbd1efc6a47 |
files | plugins/perl/common/Gaim.xs plugins/perl/perl-handlers.c plugins/perl/perl-handlers.h |
diffstat | 3 files changed, 22 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/perl/common/Gaim.xs Fri Aug 22 04:09:06 2003 +0000 +++ b/plugins/perl/common/Gaim.xs Fri Aug 22 04:17:10 2003 +0000 @@ -5,13 +5,13 @@ PROTOTYPES: ENABLE void -timeout_add(plugin, seconds, func, data) +timeout_add(plugin, seconds, callback, data) Gaim::Plugin plugin int seconds - const char *func + SV *callback SV *data CODE: - gaim_perl_timeout_add(plugin, seconds, func, data); + gaim_perl_timeout_add(plugin, seconds, callback, data); void signal_connect(instance, signal, plugin, callback, data)
--- a/plugins/perl/perl-handlers.c Fri Aug 22 04:09:06 2003 +0000 +++ b/plugins/perl/perl-handlers.c Fri Aug 22 04:17:10 2003 +0000 @@ -14,7 +14,12 @@ { timeout_handlers = g_list_remove(timeout_handlers, handler); - g_free(handler->name); + if (handler->callback != NULL) + SvREFCNT_dec(handler->callback); + + if (handler->data != NULL) + SvREFCNT_dec(handler->data); + g_free(handler); } @@ -23,9 +28,6 @@ { signal_handlers = g_list_remove(signal_handlers, handler); - if (handler->instance != NULL) - SvREFCNT_dec(handler->instance); - if (handler->callback != NULL) SvREFCNT_dec(handler->callback); @@ -45,9 +47,9 @@ ENTER; SAVETMPS; PUSHMARK(sp); - XPUSHs((SV *)handler->args); + XPUSHs((SV *)handler->data); PUTBACK; - call_pv(handler->name, G_EVAL | G_SCALAR); + call_sv(handler->callback, G_EVAL | G_SCALAR); SPAGAIN; PUTBACK; @@ -133,8 +135,7 @@ } void -gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, const char *func, - void *args) +gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback, SV *data) { GaimPerlTimeoutHandler *handler; @@ -146,11 +147,14 @@ handler = g_new0(GaimPerlTimeoutHandler, 1); - handler->plugin = plugin; - handler->name = g_strdup(func); - handler->args = args; + handler->plugin = plugin; + handler->callback = (callback != NULL && callback != &PL_sv_undef + ? newSVsv(callback) : NULL); + handler->data = (data != NULL && data != &PL_sv_undef + ? newSVsv(data) : NULL); timeout_handlers = g_list_append(timeout_handlers, handler); + handler->iotag = g_timeout_add(seconds * 1000, perl_timeout_cb, handler); }
--- a/plugins/perl/perl-handlers.h Fri Aug 22 04:09:06 2003 +0000 +++ b/plugins/perl/perl-handlers.h Fri Aug 22 04:17:10 2003 +0000 @@ -5,8 +5,8 @@ typedef struct { - char *name; - void *args; + SV *callback; + SV *data; GaimPlugin *plugin; int iotag; @@ -23,8 +23,8 @@ } GaimPerlSignalHandler; -void gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, const char *func, - void *args); +void gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback, + SV *data); void gaim_perl_timeout_clear_for_plugin(GaimPlugin *plugin); void gaim_perl_timeout_clear(void);