From: Sean E. <sea...@us...> - 2002-09-26 07:37:54
|
Update of /cvsroot/gaim/gaim/plugins In directory usw-pr-cvs1:/tmp/cvs-serv29880/plugins Modified Files: PERL-HOWTO chatlist.c error.c events.c filectl.c gaim.pl gaiminc.c gtik.c iconaway.c mailchk.c notify.c raw.c simple.c spellchk.c Log Message: In the interest of continued progress, I pulled what's usable out of my development tree and am committing it. Here, we have gotten rid of the plugins dialog and perl menu under Tools and put them both in preferences. Perl scripts now work like plugins--you have to load them explicitly (it will probe $prefix/lib/gaim and $HOME/.gaim for them) and you can unload them (although right now, this is entirely unreliable) Oh, and I broke all your perl scripts. Sorry about that. Don't try fixing them yet, though--I'm gonna make unloading single scripts more reliable tommorow. I should also finish Phase Two tommorow as well. Index: PERL-HOWTO =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/PERL-HOWTO,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- PERL-HOWTO 28 Aug 2002 02:38:18 -0000 1.15 +++ PERL-HOWTO 26 Sep 2002 07:37:51 -0000 1.16 @@ -1,33 +1,42 @@ -This is really the wrong place for a HOWTO on writing perl scripts for gaim, -but there didn't seem to be a much better place. +So, you wanna write a perl script. -If you've ever written a perl script for X-Chat then you've basically written -one for gaim as well. perl.c in gaim's source is basically an exact copy of -X-Chat's perl.c file, with small modifications to suit Gaim rather than IRC. +Perl scripts in Gaim can be very useful. Although they can't directly manipulate +Gaim data like a plugin, or provide any sort of UI, they're portable, easy to develop +rapidly and extremely powerful when manipulating incoming and outgoing messages. -Basically the reason for including perl is based on the experience with the -plugins. X-Chat's docs on Perl Scripting sums it up nicely: - it's not quite as simple to stick a module together in C and make it - stable compared to the development time of perl code +This document assumes you know perl--Gaim perl scripts work exactly like normal perl +scripts, with a few extra commands you can use. -Plugins are more powerful as they can directly access gaim's functions and -variables; as such they should be used for things like modifying the UI or -when something takes quite a bit of trickery not offered by perl. But for -the most part things should be written in Perl. It's more stable than -plugins. +The first thing Gaim will do with your plugin (provided it's in $prefix/lib/gaim or +$HOME/.gaim/) is look for and call a function called "description". description() +gives Gaim the information it will use in the plugins dialog--script name, version, +your name--all sorts of good things. Let's look at an example: -There's a really quick simple perl script in this directory, gaim.pl, that -should show most of the functions. Most things should be self-explanatory. + 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"); + } -There's one thing you need to be aware of in perl scripts for gaim. Gaim -supports multiple connections, and perl deals with them by using a unique -identifier for each of them (that's a fancy way of saying that perl scripts -use the memory address of the connection). +This pushes what's needed to the perl stack. What is all that stuff? + $a - Name + $b - Version + $c - Description + $d - Authors + $e - Webpage + $f - Icon (this is the path to an icon Gaim will use for your script) -Everything available in normal perl scripts should be available in gaim's -perl interface, so I'm not going to bother describing that. The important -things are the functions provided by gaim's internal GAIM module, which is -what most of this document is about. So, onto the functions. +It should be noted that this information will be formatted according to Pango's +markup language--a language akin to HTML. This is neat in that it lets you bold +and italicize your description and stuff, but it's important you take care to +properly escape stuff (notice the < in $d). + +Now, for the Gaim-specific perl functions (if you know x-chat scripts, you'll +feel right at home): GAIM::register(name, version, shutdownroutine, unused) Just like X-Chat. This is the first function your script should call. Index: chatlist.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/chatlist.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- chatlist.c 30 Aug 2002 03:17:21 -0000 1.13 +++ chatlist.c 26 Sep 2002 07:37:51 -0000 1.14 @@ -459,6 +459,17 @@ cp = NULL; } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Chat List"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Allows you to add chat rooms to your buddy list."); + desc.authors = g_strdup("Eric Warmenhoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Chat List"; Index: error.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/error.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- error.c 1 Nov 2000 22:30:35 -0000 1.6 +++ error.c 26 Sep 2002 07:37:51 -0000 1.7 @@ -37,6 +37,17 @@ } } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Error Tester"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("A plugin that causes error messages."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Error Tester " VERSION ; } Index: events.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/events.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- events.c 6 Aug 2001 21:47:17 -0000 1.6 +++ events.c 26 Sep 2002 07:37:51 -0000 1.7 @@ -142,6 +142,17 @@ return NULL; } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Event Tester"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Test to see that all plugin events are working properly."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Event Test"; Index: filectl.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/filectl.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- filectl.c 29 Aug 2002 21:40:06 -0000 1.11 +++ filectl.c 26 Sep 2002 07:37:51 -0000 1.12 @@ -118,6 +118,17 @@ gtk_timeout_remove(check); } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Gaim File Control"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Allows you to control Gaim by entering commands in aa file."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Gaim File Control"; } Index: gaim.pl =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/gaim.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gaim.pl 15 Oct 2001 19:52:44 -0000 1.4 +++ gaim.pl 26 Sep 2002 07:37:51 -0000 1.5 @@ -1,4 +1,4 @@ -GAIM::register("gaim test", "0.0.1", "goodbye", ""); +GAIM::register("Example", "1.0", "goodbye", ""); $ver = GAIM::get_info(0); @ids = GAIM::get_info(1); @@ -30,3 +30,9 @@ sub goodbye { 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"); + } + Index: gaiminc.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/gaiminc.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- gaiminc.c 1 Nov 2000 22:30:35 -0000 1.6 +++ gaiminc.c 26 Sep 2002 07:37:51 -0000 1.7 @@ -53,6 +53,23 @@ return NULL; } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Demonstration"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup( + "This is a really cool plugin that does a lot of stuff:\n" + "- It tells you who wrote the program when you log in\n" + "- It reverses all incoming text\n" + "- It sends a message to people on your list immediately" + " when they sign on";); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + + char *name() { return "Gaim Demonstration Plugin"; } Index: gtik.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/gtik.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- gtik.c 18 Oct 2001 12:12:36 -0000 1.5 +++ gtik.c 26 Sep 2002 07:37:51 -0000 1.6 @@ -593,7 +593,27 @@ /*-----------------------------------------------------------------*/ - char *description() { + + struct gaim_plugin_description desc; + struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Stock Ticker"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup( + " This program uses ghttp to connect to " + "a popular stock quote site, then downloads " + "and parses the html returned from the " + "site to scroll delayed quotes" + "\n\n The Gnome Stock Ticker is a free, Internet based application. These quotes are not " + "guaranteed to be timely or accurate. " + "Do not use the Gnome Stock Ticker for making investment decisions; it is for " + "informational purposes only."); + desc.authors = g_strdup("Jayson Lorenzen, Jim Garrison, Rached Blili"); + desc.url = g_strdup(WEBSITE); + return &desc; + } + + char *description() { return " This program uses ghttp to connect to " "a popular stock quote site, then downloads " Index: iconaway.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/iconaway.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- iconaway.c 29 Aug 2002 21:40:06 -0000 1.15 +++ iconaway.c 26 Sep 2002 07:37:51 -0000 1.16 @@ -33,6 +33,17 @@ return NULL; } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Iconify on away"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Iconifies the away box and thee buddy list when you go away."); + desc.authors = g_strdup("Eric Warmenhoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Iconify On Away"; } Index: mailchk.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/mailchk.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mailchk.c 16 Mar 2002 00:32:53 -0000 1.5 +++ mailchk.c 26 Sep 2002 07:37:51 -0000 1.6 @@ -116,6 +116,17 @@ mail = NULL; } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Mail Checker"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Checks for new local mail."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Mail Check"; Index: notify.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/notify.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- notify.c 15 Sep 2002 03:40:47 -0000 1.14 +++ notify.c 26 Sep 2002 07:37:51 -0000 1.15 @@ -261,7 +261,7 @@ snprintf(buf, 1000, "%s/.gaim/.notify", getenv("HOME")); if (!(fp = fopen(buf, "w"))) { - do_error_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); + do_eror_dialog(_("Unable to write to config file"), _("Notify plugin"), GAIM_ERROR); return; } @@ -403,6 +403,17 @@ /* } */ c = c->next; } +} + +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Message Notification"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Provides a variety of ways of notifying you of unread messages."); + desc.authors = g_strdup("Etan Reisner <de...@ed...>"); + desc.url = g_strdup(WEBSITE); + return &desc; } char *name() { Index: raw.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/raw.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- raw.c 1 Dec 2001 02:14:47 -0000 1.2 +++ raw.c 26 Sep 2002 07:37:51 -0000 1.3 @@ -17,6 +17,18 @@ * gc->proto_data for MSN, TOC, and IRC connections can be cast to an int *. */ +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Raw Input"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Lets you send raw input to text-vased protocols (Jabber, MSN, IRC, TOC). Hit 'Enter' in the entry box to send. Watch the debug window."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + + char *name() { return "Raw"; Index: simple.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/simple.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- simple.c 15 Feb 2001 17:14:15 -0000 1.6 +++ simple.c 26 Sep 2002 07:37:51 -0000 1.7 @@ -20,6 +20,17 @@ printf("configuring plugin.\n"); } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Simple Plugin"); + desc.version = g_strdup("1.0"); + desc.description = g_strdup("Tests to see that most things are working."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "Simple Plugin Version 1.0"; } Index: spellchk.c =================================================================== RCS file: /cvsroot/gaim/gaim/plugins/spellchk.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- spellchk.c 21 Dec 2001 10:23:03 -0000 1.22 +++ spellchk.c 26 Sep 2002 07:37:51 -0000 1.23 @@ -147,6 +147,17 @@ void gaim_plugin_remove() { } +struct gaim_plugin_description desc; +struct gaim_plugin_description *gaim_plugin_desc() { + desc.api_version = PLUGIN_API_VERSION; + desc.name = g_strdup("Text replacement"); + desc.version = g_strdup(VERSION); + desc.description = g_strdup("Replaces text in outgoing messages according to user-defined rules."); + desc.authors = g_strdup("Eric Warmehoven <er...@wa...>"); + desc.url = g_strdup(WEBSITE); + return &desc; +} + char *name() { return "IM Spell Check"; } |