changeset 2512:bf7ec3874810

[gaim-migrate @ 2525] Artem Litvinovich's patch committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Mon, 15 Oct 2001 20:08:15 +0000
parents a83b4a5ffcd6
children 6e52448f352a
files ChangeLog plugins/PERL-HOWTO src/perl.c
diffstat 3 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Oct 15 19:52:44 2001 +0000
+++ b/ChangeLog	Mon Oct 15 20:08:15 2001 +0000
@@ -13,6 +13,8 @@
 	* Event handlers in perl passed arguments as elements of
 	  an array rather than all concatenated as a string, making
 	  perl much easier to use (thanks Dennis Lambe Jr.)
+	* Can pass an argument to timeout_handlers in perl
+	  (thanks Artem Litvinovich)
 
 version 0.45 (10/04/2001):
 	* New plugin event: event_chat_send_invite
--- a/plugins/PERL-HOWTO	Mon Oct 15 19:52:44 2001 +0000
+++ b/plugins/PERL-HOWTO	Mon Oct 15 20:08:15 2001 +0000
@@ -136,6 +136,8 @@
 	and the event itself to never happen (i.e. the user won't see it happen,
 	and _send events won't actually send).
 
-GAIM::add_timeout_handler(integer, function)
+GAIM::add_timeout_handler(integer, function, args)
 	This calls function after integer number of seconds. It only calls function
 	once, so if you want to keep calling function, keep readding the handler.
+	Args is a string that you'd like to have passed to your timeout handler; it's
+	optional.
--- a/src/perl.c	Mon Oct 15 19:52:44 2001 +0000
+++ b/src/perl.c	Mon Oct 15 20:08:15 2001 +0000
@@ -74,6 +74,7 @@
 
 struct _perl_timeout_handlers {
 	char *handler_name;
+	char *handler_args;
 	gint iotag;
 };
 
@@ -260,6 +261,7 @@
 		thn = perl_timeout_handlers->data;
 		perl_timeout_handlers = g_list_remove(perl_timeout_handlers, thn);
 		g_source_remove(thn->iotag);
+		g_free(thn->handler_args);
 		g_free(thn->handler_name);
 		g_free(thn);
 	}
@@ -804,8 +806,9 @@
 static int perl_timeout(gpointer data)
 {
 	struct _perl_timeout_handlers *handler = data;
-	execute_perl(handler->handler_name, "");
+	execute_perl(handler->handler_name, escape_quotes(handler->handler_args));
 	perl_timeout_handlers = g_list_remove(perl_timeout_handlers, handler);
+	g_free(handler->handler_args);
 	g_free(handler->handler_name);
 	g_free(handler);
 
@@ -824,6 +827,7 @@
 	timeout = 1000 * SvIV(ST(0));
 	debug_printf("Adding timeout for %d seconds.\n", timeout/1000);
 	handler->handler_name = g_strdup(SvPV(ST(1), junk));
+	handler->handler_args = g_strdup(SvPV(ST(2), junk));
 	perl_timeout_handlers = g_list_append(perl_timeout_handlers, handler);
 	handler->iotag = g_timeout_add(timeout, perl_timeout, handler);
 	XSRETURN_EMPTY;