From: Sean E. <sea...@us...> - 2002-09-28 08:08:17
|
Update of /cvsroot/gaim/gaim/plugins In directory usw-pr-cvs1:/tmp/cvs-serv17668/plugins Modified Files: PERL-HOWTO gaim.pl Log Message: I made my perl script unloading not suck (as much). Now you may port your perl scripts--use gaim.pl and PERL-HOWTO as references. Index: PERL-HOWTO =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/PERL-HOWTO,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- PERL-HOWTO 26 Sep 2002 07:37:51 -0000 1.16 +++ PERL-HOWTO 28 Sep 2002 08:08:14 -0000 1.17 @@ -42,7 +42,15 @@ Just like X-Chat. This is the first function your script should call. shutdownroutine is a function that will be called when the script gets unloaded (like when gaim gets closed). This function returns - gaim's version number. + gaim's version number. This function MUST use the same Name and Version + given in description()--the plugin won't work otherwise. This returns a + handle--you want to hold on to this. + + The handle is what Gaim will use to distinguish your script from any others + running. It's actually a string--the path to the script, but you'll probably + never need to know that. As long as you just hold on to it and don't change it + everything should work fine. You need it for GAIM::add_event_handler and + GAIM::add_timeout_handler. GAIM::get_info(integer, ...) This function returns different information based on the integer passed @@ -125,11 +133,12 @@ GAIM::print_to_chat(index, room, what) Room is actually an int. Read SIGNALS to find out why. -GAIM::add_event_handler(event, function) +GAIM::add_event_handler(handle, event, function) This is the most important of them all. This is basically exactly like - gaim_signal_connect for plugins. You pass which event you want to connect to - (a string with the same name as the events for plugins, see SIGNALS), and a - string with the name of the function you want called. Simple enough? + gaim_signal_connect for plugins. You pass the handle returned by GAIM::register, + which event you want to connect to (a string with the same name as the events for + plugins, see SIGNALS), and a string with the name of the function you want called. + Simple enough? When this is triggered, the arguments will be passed in @_ and are broken into a list. This is different from all previous versions of Gaim, where you @@ -150,11 +159,11 @@ calls "function" as its handler. The event handler must have been previously added with GAIM::add_event_handler. -GAIM::add_timeout_handler(integer, function, args) +GAIM::add_timeout_handler(handle, 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. + optional. Handle is the handle returned by GAIM::register--it is not optional. GAIM::play_sound(int sound) Plays a sound using whatever method the user has selected. The argument is Index: gaim.pl =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/gaim.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gaim.pl 26 Sep 2002 07:37:51 -0000 1.5 +++ gaim.pl 28 Sep 2002 08:08:14 -0000 1.6 @@ -1,5 +1,12 @@ -GAIM::register("Example", "1.0", "goodbye", ""); +sub description { + my($a, $b, $c, $d, $e, $f) = @_; + ("Example", "1.0", "An example Gaim perl script that does nothing particularly useful:\n\t-Show a dialog on load\n\t-Set user idle for 6,000 seconds\n\t-Greets people signing on with \"Hello\"\n\t-Informs you when script has been loaded for one minute.", "Eric Warmenhoven <eric\@warmenhoven.org>", "http://gaim.sf.net", "/dev/null"); +} +$handle = GAIM::register("Example", "1.0", "goodbye", ""); + +GAIM::print("Perl Says", "Handle $handle"); + $ver = GAIM::get_info(0); @ids = GAIM::get_info(1); @@ -10,12 +17,11 @@ $msg .= "\n$nam using $pro"; } -GAIM::print("Perl Says", $msg); GAIM::command("idle", 6000); -GAIM::add_event_handler("event_buddy_signon", "echo_reply"); -GAIM::add_timeout_handler(60, "notify"); +GAIM::add_event_handler($handle, "event_buddy_signon", "echo_reply"); +GAIM::add_timeout_handler($handle, 60, "notify"); sub echo_reply { $index = $_[0]; @@ -31,8 +37,3 @@ GAIM::print("You Bastard!", "You killed Kenny!"); } -sub description { - my($a, $b, $c, $d, $e, $f) = @_; - ("Example", "1.0", "An example Gaim perl script that does nothing particularly useful:\n\t-Show a dialog on load\n\t-Set user idle for 6,000 seconds\n\t-Greets people signing on with \"Hello\"\n\t-Informs you when script has been loaded for one minute.", "Eric Warmenhoven <eric\@warmenhoven.org>", "http://gaim.sf.net", "/dev/null"); - } - |