Mercurial > pidgin
diff plugins/perl/perl-handlers.c @ 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 | 1aa771990188 |
line wrap: on
line diff
--- 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); }