changeset 3551:cd938f18f3f8

[gaim-migrate @ 3626] 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. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 26 Sep 2002 07:37:52 +0000
parents e9b2003ee562
children 8c14a6745c59
files ChangeLog configure.ac configure.in plugins/PERL-HOWTO plugins/chatlist.c plugins/docklet/docklet.c plugins/error.c plugins/events.c plugins/filectl.c plugins/gaim.pl plugins/gaiminc.c plugins/gtik.c plugins/iconaway.c plugins/mailchk.c plugins/notify.c plugins/raw.c plugins/simple.c plugins/spellchk.c plugins/ticker/ticker.c src/aim.c src/buddy.c src/core.h src/module.c src/perl.c src/plugins.c src/prefs.c
diffstat 26 files changed, 825 insertions(+), 733 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 25 14:27:18 2002 +0000
+++ b/ChangeLog	Thu Sep 26 07:37:52 2002 +0000
@@ -26,7 +26,6 @@
 	* Updated desktop and window icons (Thanks Robert McQueen)
 	* GTK2 Goodness:
 		- Preferences dialog
-		- Plugins dialog (Ari Pollak)
 		- GtkIMHtml, sorta (Ari Pollak, Christian Hammond)
 		- Buddy Icons
 		- IM Images
@@ -74,6 +73,7 @@
 	* Docklet plugin--replaces the old GNOME applet.  You'll need the
 	  Panel Notification Area applet for GNOME 2, or the patch from
 	  RedHat for KDE 3. (Thanks Robert McQueen)
+	* Plugins dialog and perl script menu merged into preferences.
 
 version 0.59 (06/24/2002):
 	* Hungarian translation added (Thanks, Sutto Zoltan)
--- a/configure.ac	Wed Sep 25 14:27:18 2002 +0000
+++ b/configure.ac	Thu Sep 26 07:37:52 2002 +0000
@@ -120,11 +120,11 @@
 	AC_DEFINE(DEBUG)
 fi
 
-AM_PATH_GLIB_2_0(1.3.0,,AC_MSG_ERROR([
+AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR([
 *** GLib 2.0 is required to build Gaim; please make sure you have the GLib
 *** development headers installed. The latest version of GLib is
 *** always available at http://www.gtk.org/.]))
-AM_PATH_GTK_2_0(1.3.0,,AC_MSG_ERROR([
+AM_PATH_GTK_2_0(2.0.0,,AC_MSG_ERROR([
 *** GTK+ 2.0 is required to build Gaim; please make sure you have the GTK+
 *** development headers installed. The latest version of GTK+ is
 *** always available at http://www.gtk.org/.]))
--- a/configure.in	Wed Sep 25 14:27:18 2002 +0000
+++ b/configure.in	Thu Sep 26 07:37:52 2002 +0000
@@ -120,11 +120,11 @@
 fi
 
 
-AM_PATH_GLIB_2_0(1.3.0,,AC_MSG_ERROR([
+AM_PATH_GLIB_2_0(2.0.0,,AC_MSG_ERROR([
 *** GLib 2.0 is required to build Gaim; please make sure you have the GLib
 *** development headers installed. The latest version of GLib is
 *** always available at http://www.gtk.org/.]))
-AM_PATH_GTK_2_0(1.3.0,,AC_MSG_ERROR([
+AM_PATH_GTK_2_0(2.0.0,,AC_MSG_ERROR([
 *** GTK+ 2.0 is required to build Gaim; please make sure you have the GTK+
 *** development headers installed. The latest version of GTK+ is
 *** always available at http://www.gtk.org/.]))
--- a/plugins/PERL-HOWTO	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/PERL-HOWTO	Thu Sep 26 07:37:52 2002 +0000
@@ -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.
+
+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.
 
-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.
+This document assumes you know perl--Gaim perl scripts work exactly like normal perl
+scripts, with a few extra commands you can use.
 
-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
+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:
 
-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.
-
-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 &lt;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 &lt; 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.
--- a/plugins/chatlist.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/chatlist.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
 char *name()
 {
 	return "Chat List";
--- a/plugins/docklet/docklet.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/docklet/docklet.c	Thu Sep 26 07:37:52 2002 +0000
@@ -147,10 +147,6 @@
 	g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_prefs), NULL);
 	gtk_menu_append(GTK_MENU(menu), entry);
 
-	entry = gtk_menu_item_new_with_label(_("Plugins"));
-	g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_plugins), NULL);
-	gtk_menu_append(GTK_MENU(menu), entry);
-
 	entry = gtk_separator_menu_item_new();
 	gtk_menu_append(GTK_MENU(menu), entry);
 
@@ -331,6 +327,7 @@
 	gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL);
 	gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL);
 	gaim_signal_connect(handle, event_away, gaim_away, NULL);
+	gaim_signal_connect(handle, event_im_displayed_rcvd, gaim_im_recv, NULL);
 	gaim_signal_connect(handle, event_im_recv, gaim_im_recv, NULL);
 	gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL);
 	gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL);
@@ -378,6 +375,18 @@
 
 	debug_printf("Docklet: removed\n");
 }
+      
+struct gaim_plugin_description desc; 
+struct gaim_plugin_description *gaim_plugin_desc() {
+	desc.api_version = PLUGIN_API_VERSION;
+	desc.name = g_strdup("System Tray Docklet");
+	desc.version = g_strdup(VERSION);
+	desc.description = g_strdup("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window.");
+	desc.authors = g_strdup("Robert McQueen &lt;robot101@debian.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+ 
 
 const char *name() {
 	return _("System Tray Docklet");
--- a/plugins/error.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/error.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
 char *name() {
 	return "Error Tester " VERSION ;
 }
--- a/plugins/events.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/events.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
 char *name()
 {
 	return "Event Test";
--- a/plugins/filectl.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/filectl.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+ 
 char *name() {
 	return "Gaim File Control";
 }
--- a/plugins/gaim.pl	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/gaim.pl	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric\@warmenhoven.org>", "http://gaim.sf.net", "/dev/null");
+		}
+		
--- a/plugins/gaiminc.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/gaiminc.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
+
 char *name() {
 	return "Gaim Demonstration Plugin";
 }
--- a/plugins/gtik.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/gtik.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 "
--- a/plugins/iconaway.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/iconaway.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+ 
 char *name() {
 	return "Iconify On Away";
 }
--- a/plugins/mailchk.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/mailchk.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
 char *name()
 {
 	return "Mail Check";
--- a/plugins/notify.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/notify.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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;
 	}
 
@@ -405,6 +405,17 @@
 	}
 }
 
+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 &lt;deryni@eden.rutgers.edu>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
 char *name() {
 	return "Visual Notification";
 }
--- a/plugins/raw.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/raw.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
+
 char *name()
 {
 	return "Raw";
--- a/plugins/simple.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/simple.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+
 char *name() {
 	return "Simple Plugin Version 1.0";
 }
--- a/plugins/spellchk.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/spellchk.c	Thu Sep 26 07:37:52 2002 +0000
@@ -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 &lt;eric@warmenhoven.org>");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
+ 
 char *name() {
 	return "IM Spell Check";
 }
--- a/plugins/ticker/ticker.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/plugins/ticker/ticker.c	Thu Sep 26 07:37:52 2002 +0000
@@ -408,7 +408,6 @@
 	gaim_signal_connect(h, event_signoff, signoff_cb, NULL);
 	gaim_signal_connect(h, event_buddy_signoff, buddy_signoff_cb, NULL);
 	gaim_signal_connect(h, event_buddy_away, away_cb, NULL);
-	gaim_signal_connect(h, event_buddy_back, away_cb, NULL);
 
 	if (connections)
 		BuddyTickerShow();
@@ -418,3 +417,13 @@
 void gaim_plugin_remove() {
 	gtk_widget_destroy(tickerwindow);
 }
+struct gaim_plugin_description desc; 
+struct gaim_plugin_description *gaim_plugin_desc() {
+	desc.api_version = PLUGIN_API_VERSION;
+	desc.name = g_strdup("Ticker");
+	desc.version = g_strdup(VERSION);
+	desc.description = g_strdup("A horizontal scrolling version of the buddy list.");
+	desc.authors = g_strdup("Syd Logan");
+	desc.url = g_strdup(WEBSITE);
+	return &desc;
+}
--- a/src/aim.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/aim.c	Thu Sep 26 07:37:52 2002 +0000
@@ -217,9 +217,7 @@
 {
 	GtkWidget *signon_all;
 	GtkWidget *options;
-#ifdef GAIM_PLUGINS
 	GtkWidget *plugs;
-#endif
 #ifndef NO_MULTI
 	GtkWidget *accts;
 #endif
@@ -340,32 +338,24 @@
 
 	reg = gtk_button_new_with_label(_("Auto-login"));
 	options = gtk_button_new_with_label(_("Options"));
-#ifdef GAIM_PLUGINS
-	plugs = gtk_button_new_with_label(_("Plugins"));
-#endif
+	plugs = gtk_button_new_with_label(_("About"));
 	if (misc_options & OPT_MISC_COOL_LOOK) {
 		gtk_button_set_relief(GTK_BUTTON(reg), GTK_RELIEF_NONE);
 		gtk_button_set_relief(GTK_BUTTON(options), GTK_RELIEF_NONE);
-#ifdef GAIM_PLUGINS
 		gtk_button_set_relief(GTK_BUTTON(plugs), GTK_RELIEF_NONE);
-#endif
 	}
 
 	gtk_signal_connect(GTK_OBJECT(reg), "clicked", GTK_SIGNAL_FUNC(dologin_all), NULL);
 	gtk_signal_connect(GTK_OBJECT(options), "clicked", GTK_SIGNAL_FUNC(show_prefs), NULL);
-#ifdef GAIM_PLUGINS
-	gtk_signal_connect(GTK_OBJECT(plugs), "clicked", GTK_SIGNAL_FUNC(show_plugins), NULL);
+	gtk_signal_connect(GTK_OBJECT(plugs), "clicked", GTK_SIGNAL_FUNC(show_about), NULL);
 	gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0);
-#endif
 
 	gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(hbox), reg, TRUE, TRUE, 0);
 
 	gtk_widget_show(reg);
 	gtk_widget_show(options);
-#ifdef GAIM_PLUGINS
 	gtk_widget_show(plugs);
-#endif
 
 	if (aim_users) {
 		struct aim_user *c = (struct aim_user *)aim_users->data;
@@ -724,9 +714,11 @@
 		printf("Gaim %s\n",VERSION);
 		return 0;
 	}
-
+	
+#if GAIM_PLUGINS || USE_PERL
+	gaim_probe_plugins();
+#endif
 	load_prefs();
-
 	core_main();
 	ui_main();
 
@@ -752,9 +744,7 @@
 			debug_printf("gtkspell started with ispell\n");
 		}
 	}
-#ifdef USE_PERL
-	perl_autoload();
-#endif
+
 	static_proto_init();
 
 	/* deal with --login */
--- a/src/buddy.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/buddy.c	Thu Sep 26 07:37:52 2002 +0000
@@ -2729,32 +2729,6 @@
 	gaim_new_item_with_pixmap(menu, _("View System Log"), prefs_small_xpm,
 				  GTK_SIGNAL_FUNC(show_syslog), NULL, 0, 0, 0);
 
-	gaim_separator(menu);
-
-#ifdef GAIM_PLUGINS
-	gaim_new_item_with_pixmap(menu, _("Plugins"), plugins_small_xpm, GTK_SIGNAL_FUNC(show_plugins), NULL,
-				  0, 0, 0);
-#endif
-#ifdef USE_PERL
-	perlmenu = gtk_menu_new();
-	gtk_widget_show(perlmenu);
-	menuitem = gaim_new_item_with_pixmap(menu, _("Perl"), plugins_small_xpm, NULL, NULL, 0, 0, 0);
-	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), perlmenu);
-	gtk_widget_show(menuitem);
-	menuitem = gtk_menu_item_new_with_label(_("Load Script"));
-	gtk_menu_append(GTK_MENU(perlmenu), menuitem);
-	gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(load_perl_script), NULL);
-	gtk_widget_show(menuitem);
-	menuitem = gtk_menu_item_new_with_label(_("Unload All Scripts"));
-	gtk_menu_append(GTK_MENU(perlmenu), menuitem);
-	gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(unload_perl_scripts), NULL);
-	gtk_widget_show(menuitem);
-	menuitem = gtk_menu_item_new_with_label(_("List Scripts"));
-	gtk_menu_append(GTK_MENU(perlmenu), menuitem);
-	gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(list_perl_scripts), NULL);
-	gtk_widget_show(menuitem);
-#endif
-
 	menu = gtk_menu_new();
 
 	menuitem = gaim_new_item(NULL, _("Help"));
--- a/src/core.h	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/core.h	Thu Sep 26 07:37:52 2002 +0000
@@ -109,21 +109,37 @@
 	guint inpa;
 };
 
-#ifdef GAIM_PLUGINS
+#define USE_PLUGINS GAIM_PLUGINS || USE_PERL
+#define PLUGIN_API_VERSION 1
+enum gaim_plugin_type {
+	perl_script,
+	plugin
+};
+
+struct gaim_plugin_description {	
+	int api_version;
+	gchar *name;
+	gchar *version;
+	gchar *description;
+	gchar *authors;
+	gchar *url;
+	gchar *iconfile;
+};
 
 struct gaim_plugin {
-	GModule *handle;
-	char *name;
-	char *description;
+	enum gaim_plugin_type type;
+	void *handle;
+	gchar path[128];
+	struct gaim_plugin_description desc;
 };
 
+#ifdef GAIM_PLUGINS
 struct gaim_callback {
 	GModule *handle;
 	enum gaim_event event;
 	void *function;
 	void *data;
 };
-
 #endif
 
 #define BUDDY_ALIAS_MAXLEN 388	/* because MSN names can be 387 characters */
@@ -155,6 +171,7 @@
 
 /* Globals in plugins.c */
 extern GList *plugins;
+extern GList *probed_plugins;
 extern GList *callbacks;
 
 /* Functions in buddy.c */
@@ -188,12 +205,13 @@
 
 /* Functions in perl.c */
 #ifdef USE_PERL
-extern void perl_autoload();
 extern void perl_end();
 extern int perl_event(enum gaim_event, void *, void *, void *, void *, void *);
 extern int perl_load_file(char *);
+extern void perl_unload_file(struct gaim_plugin *);
 extern void unload_perl_scripts();
 extern void list_perl_scripts();
+extern struct gaim_plugin *probe_perl(const char *);
 #endif
 
 /* Functions in plugins.c */
@@ -206,6 +224,7 @@
 extern void gaim_plugin_unload(GModule *);
 extern void remove_all_plugins();
 #endif
+extern void gaim_probe_plugins();
 extern int plugin_event(enum gaim_event, ...);
 extern char *event_name(enum gaim_event);
 
--- a/src/module.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/module.c	Thu Sep 26 07:37:52 2002 +0000
@@ -36,8 +36,6 @@
 
 #include "gaim.h"
 
-#ifdef GAIM_PLUGINS
-
 #include <string.h>
 #include <sys/time.h>
 
@@ -51,6 +49,7 @@
 /* ------------------ Global Variables ----------------------- */
 
 GList *plugins = NULL;
+GList *probed_plugins = NULL;
 GList *callbacks = NULL;
 
 char *last_dir = NULL;
@@ -58,9 +57,9 @@
 /* --------------- Function Declarations --------------------- */
 
 struct gaim_plugin *  load_plugin(const char *);
+#ifdef GAIM_PLUGINS
               void  unload_plugin(struct gaim_plugin *p);
 struct gaim_plugin *reload_plugin(struct gaim_plugin *p);
-
 void gaim_signal_connect(GModule *, enum gaim_event, void *, void *);
 void gaim_signal_disconnect(GModule *, enum gaim_event, void *);
 void gaim_plugin_unload(GModule *);
@@ -68,50 +67,141 @@
 /* --------------- Static Function Declarations ------------- */
 
 static void plugin_remove_callbacks(GModule *);
-
+#endif
 /* ------------------ Code Below ---------------------------- */
 
+static int is_so_file(char *filename, char *ext)
+{
+	int len;
+	if (!filename) return 0;
+	if (!filename[0]) return 0;
+	len = strlen(filename);
+	len -= strlen(ext);
+	if (len < 0) return 0;
+	return (!strncmp(filename + len, ext, strlen(ext)));
+}
+
+void gaim_probe_plugins() {
+	GDir *dir;
+	const gchar *file;
+	gchar *path;
+	struct gaim_plugin_description *plugdes;
+	struct gaim_plugin *plug;
+	char userspace[128];
+	char *probedirs[] = {LIBDIR, &userspace, 0};
+#if GAIM_PLUGINS     
+	char *(*gaim_plugin_init)(GModule *);
+	char *(*cfunc)();
+	int l;
+	struct gaim_plugin_description *(*desc)();
+	GModule *handle;
+#endif
+
+	g_snprintf(userspace, sizeof(userspace), "%s" G_DIR_SEPARATOR_S ".gaim", g_get_home_dir());
+
+	for (l=0; probedirs[l]; l++) {
+		dir = g_dir_open(probedirs[l], 0, NULL);
+		if (dir) {
+			while ((file = g_dir_read_name(dir))) {
+#ifdef GAIM_PLUGINS
+				if (is_so_file(file, ".so") && g_module_supported()) {
+					path = g_build_filename(probedirs[l], file, NULL);
+					handle = g_module_open(path, 0);
+					if (!handle) {
+						debug_printf("%s is unloadable: %s\n", file, g_module_error());
+						continue;
+					}
+					if (!g_module_symbol(handle, "gaim_plugin_init", (gpointer *)&gaim_plugin_init)) {
+						debug_printf("%s is unloadable %s\n", file, g_module_error());
+						g_module_close(handle);
+						continue;
+					}
+					plug = g_new0(struct gaim_plugin, 1);
+					g_snprintf(plug->path, sizeof(plug->path), path);
+					plug->type = plugin;
+					g_free(path);
+					if (g_module_symbol(handle, "gaim_plugin_desc", (gpointer *)&desc)) {
+						memcpy(&(plug->desc), desc(), sizeof(plug->desc));
+					} else {
+						if (g_module_symbol(handle, "name", (gpointer *)&cfunc)) {
+							plug->desc.name = g_strdup(cfunc());
+						}
+						if (g_module_symbol(handle, "description", (gpointer *)&cfunc)) {
+							plug->desc.description = g_strdup(cfunc());
+						}
+					}
+					probed_plugins = g_list_append(probed_plugins, plug);
+					g_module_close(handle);
+				}
+#endif
+#ifdef USE_PERL
+				if (is_so_file(file, ".pl")) {
+					path = g_build_filename(LIBDIR, file, NULL);
+					plug = probe_perl(path);
+					if (plug) 
+						probed_plugins = g_list_append(probed_plugins, plug);
+					g_free(path);
+				}
+#endif
+			}
+			g_dir_close(dir);
+		}
+	}
+}
+
+#ifdef GAIM_PLUGINS
 struct gaim_plugin *load_plugin(const char *filename)
 {
 	struct gaim_plugin *plug;
-	GList *c = plugins;
-	char *(*gaim_plugin_init)(GModule *);
+	struct gaim_plugin_description *desc;
+	struct gaim_plugin_description *(*gaim_plugin_desc)();
 	char *(*cfunc)();
-	char *error;
-	char *retval;
+	GList *c = plugins;
+	GList *p = probed_plugins;
+	char *(*gaim_plugin_init)(GModule *);
+	char *error, *retval, *tmp;
+	gboolean newplug = FALSE;
 
 	if (!g_module_supported())
 		return NULL;
-	if (filename && !strlen(filename))
+	if (!filename || !strlen(filename))
 		return NULL;
 
-	while (filename && c) {
-		plug = (struct gaim_plugin *)c->data;
-		if (!strcmp(filename, g_module_name(plug->handle))) {
-			/* just need to reload plugin */
-			return reload_plugin(plug);
-		} else
-			c = g_list_next(c);
+	while (filename && p) {
+		plug = (struct gaim_plugin *)p->data;
+		if (!strcmp(filename, plug->path)) 
+			break;
+		p = p->next;
 	}
-	plug = g_malloc(sizeof *plug);
-
-	if (last_dir)
-		g_free(last_dir);
-	last_dir = g_dirname(filename);
-
+	
+	if (plug && plug->handle) {
+		reload_plugin(plug);
+		return NULL;
+	}
+	    
+	if (!plug) {
+		plug = g_new0(struct gaim_plugin, 1);
+		g_snprintf(plug->path, sizeof(plug->path), filename);
+		newplug = TRUE;
+	}
+			
 	debug_printf("Loading %s\n", filename);
 	plug->handle = g_module_open(filename, 0);
 	if (!plug->handle) {
 		error = (char *)g_module_error();
-		do_error_dialog(_("Gaim was unable to load your plugin."), error, GAIM_ERROR);
-		g_free(plug);
+		plug->handle = NULL;
+		tmp = plug->desc.description;
+		plug->desc.description = g_strdup_printf("<span weight=\"bold\" foreground=\"red\">%s</span>\n\n%s", error, tmp);
+		g_free(tmp);
 		return NULL;
 	}
-
+	
 	if (!g_module_symbol(plug->handle, "gaim_plugin_init", (gpointer *)&gaim_plugin_init)) {
-		do_error_dialog(_("Gaim was unable to load your plugin."), g_module_error(), GAIM_ERROR);
 		g_module_close(plug->handle);
-		g_free(plug);
+		plug->handle = NULL;
+		tmp = plug->desc.description;
+		plug->desc.description = g_strdup_printf("<span foreground=\"red\">%s</span>\n\n%s", g_module_error(), tmp);
+		g_free(tmp);
 		return NULL;
 	}
 
@@ -121,25 +211,31 @@
 		plugin_remove_callbacks(plug->handle);
 		do_error_dialog("Gaim was unable to load your plugin.", retval, GAIM_ERROR);
 		g_module_close(plug->handle);
-		g_free(plug);
+		plug->handle = NULL;
 		return NULL;
 	}
 
 	plugins = g_list_append(plugins, plug);
 
-	if (g_module_symbol(plug->handle, "name", (gpointer *)&cfunc)) {
-		plug->name = cfunc();
-	} else {
-		plug->name = NULL;
+	if (newplug) {
+		g_snprintf(plug->path, sizeof(plug->path), filename);
+		if (g_module_symbol(plug->handle, "gaim_plugin_desc", (gpointer *)&gaim_plugin_desc)) {
+			desc = gaim_plugin_desc();
+			plug->desc.name = desc->name;
+		} else {
+			if (g_module_symbol(plug->handle, "name", (gpointer *)&cfunc)) {
+				plug->desc.name = g_strdup(cfunc());
+			}
+			if (g_module_symbol(plug->handle, "description", (gpointer *)&cfunc)) {
+				plug->desc.description = g_strdup(cfunc());
+			}
+		}
+		probed_plugins = g_list_append(probed_plugins, plug);
 	}
-
-	if (g_module_symbol(plug->handle, "description", (gpointer *)&cfunc))
-		plug->description = cfunc();
-	else
-		plug->description = NULL;
-
+	
 	save_prefs();
 	return plug;
+
 }
 
 static void unload_gaim_plugin(struct gaim_plugin *p)
@@ -155,7 +251,7 @@
 	plugin_remove_callbacks(p->handle);
 
 	plugins = g_list_remove(plugins, p);
-	g_free(p);
+	p->handle = NULL;
 	save_prefs();
 }
 
@@ -194,8 +290,8 @@
 	plugin_remove_callbacks(p->handle);
 	plugins = g_list_remove(plugins, p);
 	g_free(p);
-	/* XXX CUI need to tell UI what happened, but not like this */
-	update_show_plugins();
+	/* XXX CUI need to tell UI what happened, but not like this 
+	   update_show_plugins(); */
 
 	g_timeout_add(5000, unload_timeout, handle);
 }
@@ -381,13 +477,14 @@
 #ifdef GAIM_PLUGINS
 	GList *c = callbacks;
 	struct gaim_callback *g;
+#endif
 	va_list arrg;
 	void    *arg1 = NULL, 
 		*arg2 = NULL,
 		*arg3 = NULL, 
 		*arg4 = NULL,
 		*arg5 = NULL;
-#endif
+
 
 	debug_printf("%s\n", event_name(event));
 
--- a/src/perl.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/perl.c	Thu Sep 26 07:37:52 2002 +0000
@@ -73,12 +73,14 @@
 struct _perl_event_handlers {
 	char *event_type;
 	char *handler_name;
+	char *handle;
 };
 
 struct _perl_timeout_handlers {
 	char *handler_name;
 	char *handler_args;
 	gint iotag;
+	char *handle;
 };
 
 static GList *perl_list = NULL; /* should probably extern this at some point */
@@ -115,7 +117,31 @@
 void xs_init()
 {
 	char *file = __FILE__;
+
+	/* This one allows dynamic loading of perl modules in perl
+           scripts by the 'use perlmod;' construction*/
 	newXS ("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
+	
+	/* load up all the custom Gaim perl functions */
+		newXS ("GAIM::register", XS_GAIM_register, "GAIM");
+	newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM");
+	newXS ("GAIM::print", XS_GAIM_print, "GAIM");
+	newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM");
+
+	newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM");
+	newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM");
+
+	newXS ("GAIM::command", XS_GAIM_command, "GAIM");
+	newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM");
+	newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM");
+	newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM");
+	newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM");
+
+	newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM");
+	newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM");
+	newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM");
+
+	newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM");
 }
 
 static char *escape_quotes(char *buf)
@@ -136,119 +162,243 @@
 	return (tmp_buf);
 }
 
-static SV *execute_perl(char *function, char *args)
+/*
+  2001/06/14: execute_perl replaced by Martin Persson <mep@passagen.se>
+              previous use of perl_eval leaked memory, replaced with
+              a version that uses perl_call instead
+*/
+
+static int 
+execute_perl(char *function, char *args)
 {
-	static char *perl_cmd = NULL;
-	SV *i;
+	char *perl_args[2] = { args, NULL }, buf[512];
+	int count, ret_value = 1;
+	SV *sv;
+
+	dSP;
+        ENTER;
+        SAVETMPS;
+        PUSHMARK(sp);
+        count = perl_call_argv(function, G_EVAL | G_SCALAR, perl_args);
+        SPAGAIN;
+
+        sv = GvSV(gv_fetchpv("@", TRUE, SVt_PV));
+        if (SvTRUE(sv)) {
+                snprintf(buf, 512, "Perl error: %s\n", SvPV(sv, count));
+                debug_printf(buf);
+                POPs;
+        } else if (count != 1) {
+                snprintf(buf, 512, "Perl error: expected 1 value from %s, "
+                        "got: %d\n", function, count);
+                debug_printf(buf);
+        } else {
+                ret_value = POPi;
+        }
+
+        PUTBACK;
+        FREETMPS;
+        LEAVE;
+
+        return ret_value;
+
+}
+
+/* This function is so incredibly broken and should never, ever, ever
+   be trusted to work */
+void perl_unload_file(struct gaim_plugin *plug) {
+	struct perlscript *scp = NULL;
+	struct _perl_timeout_handlers *thn;
+	struct _perl_event_handlers *ehn;
 
-	if (perl_cmd)
-		g_free(perl_cmd);
-	perl_cmd = g_malloc(strlen(function) + strlen(args) + 4);
-	sprintf(perl_cmd, "&%s(%s)", function, args);
-#ifndef HAVE_PERL_EVAL_PV
-	i = (perl_eval_pv(perl_cmd, TRUE));
-#else
-	i = (Perl_eval_pv(perl_cmd, TRUE));
-#endif
-	return i;
+	GList *pl = perl_list;
+
+	debug_printf("Unloading %s\n", plug->handle);
+	while (pl) {
+		scp = pl->data;
+		/* This is so broken */
+		if (!strcmp(scp->name, plug->desc.name) &&
+		    !strcmp(scp->version, plug->desc.version))
+			break;
+		pl = pl->next;
+		scp = NULL;
+	}
+	if (scp) {
+		perl_list = g_list_remove(perl_list, scp);
+		if (scp->shutdowncallback[0])
+			execute_perl(scp->shutdowncallback, "");
+		perl_list = g_list_remove(perl_list, scp);
+		g_free(scp->name);
+		g_free(scp->version);
+		g_free(scp->shutdowncallback);
+		g_free(scp);
+	}
+
+	pl = perl_timeout_handlers;
+	while (pl) {
+		thn = pl->data;
+		if (thn && thn->handle == plug->handle) {
+			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);
+		}
+		pl = pl->next;
+	}
+
+	pl = perl_event_handlers;
+	while (pl) {
+		ehn = pl->data;
+		if (ehn && ehn->handle == plug->handle) {
+			perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
+			g_free(ehn->event_type);
+			g_free(ehn->handler_name);
+			g_free(ehn);
+		}
+		pl = pl->next;
+	}
+
+	plug->handle=NULL;
 }
 
 int perl_load_file(char *script_name)
 {
-	char *name = g_strdup_printf("'%s'", escape_quotes(script_name));
-	SV *return_val;
+	struct gaim_plugin *plug;
+	GList *p = probed_plugins;
+	GList *e = perl_event_handlers;
+	GList *t = perl_timeout_handlers;
+	int num_e, num_t, ret;
+
 	if (my_perl == NULL)
 		perl_init();
-	return_val = execute_perl("load_file", name);
-	g_free(name);
-	return SvNV (return_val);
-}
+	
+	while (p) {
+		plug = (struct gaim_plugin *)p->data;
+		if (!strcmp(script_name, plug->path)) 
+			break;
+		p = p->next;
+	}
+	
+	if (!plug) {
+		probe_perl(script_name);
+	}
+	
+	plug->handle = plug->path;
+	
+	/* This is such a terrible hack-- if I weren't tired and annoyed
+	 * with perl, I'm sure I wouldn't even be considering this. */
+	num_e=g_list_length(e);
+	num_t=g_list_length(t);
 
-static int is_pl_file(char *filename)
-{
-	int len;
-	if (!filename) return 0;
-	if (!filename[0]) return 0;
-	len = strlen(filename);
-	len -= 3;
-	if (len < 0) return 0;
-	return (!strncmp(filename + len, ".pl", 3));
+	ret = execute_perl("load_n_eval", script_name);
+
+	t = g_list_nth(perl_timeout_handlers, num_t++);
+	while (t) {
+		struct _perl_timeout_handlers *h = t->data;
+		h->handle = plug->handle;
+		t = t->next;
+	}
+
+	e = g_list_nth(perl_event_handlers, num_e++);
+	while (e) {
+		struct _perl_event_handlers *h = e->data;
+		h->handle = plug->handle;
+		e = e->next;
+	}
+	return ret;
 }
 
-void perl_autoload()
-{
-	DIR *dir;
-	struct dirent *ent;
-	struct dirent dirent_buf;
-	char *buf;
-	char *path;
+struct gaim_plugin *probe_perl(const char *filename) {
+
+	/* XXX This woulld be much faster if I didn't create a new
+	 *     PerlInterpreter every time I did probed a plugin */
 
-	path = gaim_user_dir();
-	dir = opendir(path);
-	if (dir) {
-		while ((readdir_r(dir,&dirent_buf,&ent),ent)) {
-			if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) {
-				if (is_pl_file(ent->d_name)) {
-					buf = g_malloc(strlen(path) + strlen(ent->d_name) + 2);
-					sprintf(buf, "%s/%s", path, ent->d_name);
-					perl_load_file(buf);
-					g_free(buf);
-				}
-			}
+	PerlInterpreter *prober = perl_alloc();
+	struct gaim_plugin * plug = NULL;
+	char *argv[] = {"", filename};
+	int count;
+	perl_construct(prober);
+	perl_parse(prober, NULL, 2, argv, NULL);
+	
+	{
+		dSP;
+		ENTER;
+		SAVETMPS;
+		PUSHMARK(SP);
+		count =perl_call_pv("description", G_NOARGS | G_ARRAY);
+		SPAGAIN;
+		
+		if (count = sizeof(struct gaim_plugin_description) / sizeof(char*)) {
+			plug = g_new0(struct gaim_plugin, 1);
+			plug->type = perl_script;
+			g_snprintf(plug->path, sizeof(plug->path), filename);
+			plug->desc.iconfile = g_strdup(POPp);
+			plug->desc.url = g_strdup(POPp);
+			plug->desc.authors = g_strdup(POPp);
+			plug->desc.description = g_strdup(POPp);
+			plug->desc.version = g_strdup(POPp);
+			plug->desc.name = g_strdup(POPp);
 		}
-		closedir(dir);
+			
+		PUTBACK;
+		FREETMPS;
+		LEAVE;
 	}
-	g_free(path);
+	perl_destruct(prober);
+	perl_free(prober);
+	return plug;
 }
 
 static void perl_init()
-{
-	char *perl_args[] = {"", "-e", "0", "-w"};
-	char load_file[] =
-"sub load_file()\n"
-"{\n"
-"	(my $file_name) = @_;\n"
-"	open FH, $file_name or return 2;\n"
-"	my $is = $/;\n"
-"	local($/) = undef;\n"
-"	$file = <FH>;\n"
-"	close FH;\n"
-"	$/ = $is;\n"
-"	$file = \"\\@ISA = qw(Exporter DynaLoader);\\n\" . $file;\n"
-"	eval $file;\n"
-"	eval $file if $@;\n"
-"	return 1 if $@;\n"
-"	return 0;\n"
-"}";
+{        /*changed the name of the variable from load_file to
+	   perl_definitions since now it does much more than defining
+	   the load_file sub. Moreover, deplaced the initialisation to
+	   the xs_init function. (TheHobbit)*/
+        char *perl_args[] = { "", "-e", "0", "-w" };
+        char perl_definitions[] =
+        {
+		/* We use to function one to load a file the other to
+		   execute the string obtained from the first and holding
+		   the file conents. This allows to have a realy local $/
+		   without introducing temp variables to hold the old
+		   value. Just a question of style:) */ 
+		"sub load_file{"
+		  "my $f_name=shift;"
+		  "local $/=undef;"
+		  "open FH,$f_name or return \"__FAILED__\";"
+		  "$_=<FH>;"
+		  "close FH;"
+		  "return $_;"
+		"}"
+		"sub load_n_eval{"
+		  "my $f_name=shift;"
+		  "my $strin=load_file($f_name);"
+		  "return 2 if($strin eq \"__FAILED__\");"
+		  "eval $strin;"
+		  "if($@){"
+		    /*"  #something went wrong\n"*/
+		    "GAIM::print\"Errors loading file $f_name:\\n\";"
+		    "GAIM::print\"$@\\n\";"
+		    "return 1;"
+		  "}"
+		  "return 0;"
+		"}"
+	};
 
 	my_perl = perl_alloc();
 	perl_construct(my_perl);
+#ifdef DEBUG
 	perl_parse(my_perl, xs_init, 4, perl_args, NULL);
+#else
+	perl_parse(my_perl, xs_init, 3, perl_args, NULL);
+#endif
 #ifndef HAVE_PERL_EVAL_PV
-	perl_eval_pv(load_file, TRUE);
+	eval_pv(perl_definitions, TRUE);
 #else
-	Perl_eval_pv(load_file, TRUE);
+	perl_eval_pv(perl_definitions, TRUE); /* deprecated */
 #endif
 
-	newXS ("GAIM::register", XS_GAIM_register, "GAIM");
-	newXS ("GAIM::get_info", XS_GAIM_get_info, "GAIM");
-	newXS ("GAIM::print", XS_GAIM_print, "GAIM");
-	newXS ("GAIM::write_to_conv", XS_GAIM_write_to_conv, "GAIM");
 
-	newXS ("GAIM::buddy_list", XS_GAIM_buddy_list, "GAIM");
-	newXS ("GAIM::online_list", XS_GAIM_online_list, "GAIM");
-
-	newXS ("GAIM::command", XS_GAIM_command, "GAIM");
-	newXS ("GAIM::user_info", XS_GAIM_user_info, "GAIM");
-	newXS ("GAIM::print_to_conv", XS_GAIM_print_to_conv, "GAIM");
-	newXS ("GAIM::print_to_chat", XS_GAIM_print_to_chat, "GAIM");
-	newXS ("GAIM::serv_send_im", XS_GAIM_serv_send_im, "GAIM");
-
-	newXS ("GAIM::add_event_handler", XS_GAIM_add_event_handler, "GAIM");
-	newXS ("GAIM::remove_event_handler", XS_GAIM_remove_event_handler, "GAIM");
-	newXS ("GAIM::add_timeout_handler", XS_GAIM_add_timeout_handler, "GAIM");
-
-	newXS ("GAIM::play_sound", XS_GAIM_play_sound, "GAIM");
 }
 
 void perl_end()
@@ -281,6 +431,7 @@
 		ehn = perl_event_handlers->data;
 		perl_event_handlers = g_list_remove(perl_event_handlers, ehn);
 		g_free(ehn->event_type);
+		debug_printf("handler_name: %s\n", ehn->handler_name);
 		g_free(ehn->handler_name);
 		g_free(ehn);
 	}
@@ -412,7 +563,7 @@
 
 	title = SvPV(ST(0), junk);
 	message = SvPV(ST(1), junk);
-	do_error_dialog(message, NULL, GAIM_INFO);
+	do_error_dialog(title, message, GAIM_INFO);
 	XSRETURN(0);
 }
 
--- a/src/plugins.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/plugins.c	Thu Sep 26 07:37:52 2002 +0000
@@ -1,515 +0,0 @@
-/*
- * gaim
- *
- * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * ----------------
- * The Plug-in plug
- *
- * Plugin support is currently being maintained by Mike Saraf
- * msaraf@dwc.edu
- *
- * Well, I didn't see any work done on it for a while, so I'm going to try
- * my hand at it. - Eric warmenhoven@yahoo.com
- *
- * Mike is my roomate.  I can assure you that he's lazy :-P  -- Rob rob@marko.net
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef GAIM_PLUGINS
-
-#include <string.h>
-#include <sys/time.h>
-
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <gtk/gtk.h>
-#include "gaim.h"
-
-#include "pixmaps/gnome_add.xpm"
-#include "pixmaps/gnome_remove.xpm"
-#include "pixmaps/gnome_preferences.xpm"
-#include "pixmaps/refresh.xpm"
-#include "pixmaps/cancel.xpm"
-
-#define PATHSIZE 1024	/* XXX: stolen from dialogs.c */
-
-
-/* ------------------ Local Variables ------------------------ */
-
-static GtkWidget *plugin_dialog = NULL;
-
-static GtkWidget *pluglist = NULL;
-static GtkWidget *plugtext = NULL;
-static GtkWidget *plugwindow = NULL;
-static GtkWidget *plugentry = NULL;
-
-static GtkTooltips *tooltips = NULL;
-
-static GtkWidget *config = NULL;
-static guint confighandle = 0;
-static GtkWidget *reload = NULL;
-static GtkWidget *unload = NULL;
-extern char *last_dir;
-
-/* --------------- Function Declarations --------------------- */
-
-void show_plugins(GtkWidget *, gpointer);
-
-/* UI button callbacks */
-static void unload_plugin_cb(GtkWidget *, gpointer);
-static void plugin_reload_cb(GtkWidget *, gpointer);
-
-static const gchar *plugin_makelistname(GModule *);
-
-static void destroy_plugins(GtkWidget *, gpointer);
-static void load_file(GtkWidget *, gpointer);
-static void load_which_plugin(GtkWidget *, gpointer);
-void update_show_plugins();
-static void hide_plugins(GtkWidget *, gpointer);
-static void clear_plugin_display();
-static struct gaim_plugin *get_selected_plugin(GtkWidget *);
-static void select_plugin(GtkWidget *w, struct gaim_plugin *p);
-static void list_clicked(GtkWidget *, gpointer);
-
-/* ------------------ Code Below ---------------------------- */
-
-static void destroy_plugins(GtkWidget *w, gpointer data)
-{
-	if (plugin_dialog)
-		gtk_widget_destroy(plugin_dialog);
-	plugin_dialog = NULL;
-}
-
-static void load_file(GtkWidget *w, gpointer data)
-{
-	gchar *buf;
-
-	if (plugin_dialog) {
-		gtk_widget_show(plugin_dialog);
-		gdk_window_raise(plugin_dialog->window);
-		return;
-	}
-
-	plugin_dialog = gtk_file_selection_new(_("Gaim - Plugin List"));
-
-	gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(plugin_dialog));
-
-	if (!last_dir)
-		buf = g_strdup(LIBDIR);
-	else
-		buf = g_strconcat(last_dir, G_DIR_SEPARATOR_S, NULL);
-
-	gtk_file_selection_set_filename(GTK_FILE_SELECTION(plugin_dialog), buf);
-	gtk_file_selection_complete(GTK_FILE_SELECTION(plugin_dialog), "*.so");
-	gtk_signal_connect(GTK_OBJECT(plugin_dialog), "destroy",
-			   GTK_SIGNAL_FUNC(destroy_plugins), plugin_dialog);
-
-	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->ok_button),
-			   "clicked", GTK_SIGNAL_FUNC(load_which_plugin), NULL);
-
-	gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(plugin_dialog)->cancel_button),
-			   "clicked", GTK_SIGNAL_FUNC(destroy_plugins), NULL);
-
-	g_free(buf);
-	gtk_widget_show(plugin_dialog);
-	gdk_window_raise(plugin_dialog->window);
-}
-
-static void load_which_plugin(GtkWidget *w, gpointer data)
-{
-	const char *file;
-	struct gaim_plugin *p;
-	
-	file = (char *)gtk_file_selection_get_filename(GTK_FILE_SELECTION(plugin_dialog));
-	if (file_is_dir(file, plugin_dialog)) {
-		return;
-	}
-
-	if (file)
-		p = load_plugin(file);
-	else
-		p = NULL;
-
-	if (plugin_dialog)
-		gtk_widget_destroy(plugin_dialog);
-	plugin_dialog = NULL;
-
-	update_show_plugins();
-	/* Select newly loaded plugin */
-	if(p == NULL)
-		return;
-	select_plugin(pluglist, p);
-}
-
-void show_plugins(GtkWidget *w, gpointer data)
-{
-	/* most of this code was shamelessly stolen from Glade */
-	GtkWidget *mainvbox;
-	GtkWidget *tophbox;
-	GtkWidget *bothbox;
-	GtkWidget *hbox;
-	GtkWidget *vbox;
-	GtkWidget *frame;
-	GtkWidget *scrolledwindow;
-	GtkWidget *label;
-	GtkWidget *add;
-	GtkWidget *close;
-	/* stuff needed for GtkTreeView *pluglist */
-	GtkListStore *store;
-	GtkCellRenderer *renderer;
-	GtkTreeViewColumn *column;
-	GtkTreeSelection *selection;
-	/* needed for GtkTextView *plugtext */
-	GtkTextBuffer *buffer;
-	
-	if (plugwindow) {
-		gtk_window_present(GTK_WINDOW(plugwindow));
-		return;
-	}
-
-	GAIM_DIALOG(plugwindow);
-	gtk_window_set_wmclass(GTK_WINDOW(plugwindow), "plugins", "Gaim");
-	gtk_widget_realize(plugwindow);
-	gtk_window_set_title(GTK_WINDOW(plugwindow), _("Gaim - Plugins"));
-	gtk_signal_connect(GTK_OBJECT(plugwindow), "destroy", GTK_SIGNAL_FUNC(hide_plugins), NULL);
-
-	mainvbox = gtk_vbox_new(FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(plugwindow), mainvbox);
-	gtk_widget_show(mainvbox);
-
-	/* Build the top */
-	tophbox = gtk_hbox_new(FALSE, 0);
-	gtk_box_pack_start(GTK_BOX(mainvbox), tophbox, TRUE, TRUE, 0);
-	gtk_widget_show(tophbox);
-
-	/* Left side: frame with list of plugin file names */
-	frame = gtk_frame_new(_("Loaded Plugins"));
-	gtk_box_pack_start(GTK_BOX(tophbox), frame, FALSE, FALSE, 0);
-	gtk_container_set_border_width(GTK_CONTAINER(frame), 6);
-	gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5);
-	gtk_widget_show(frame);
-
-	scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
-	gtk_container_add(GTK_CONTAINER(frame), scrolledwindow);
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
-					GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-	gtk_widget_show(scrolledwindow);
-	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
-					GTK_SHADOW_IN);
-
-	/* Create & show plugin list */
-	store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
-	pluglist = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
-	gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(pluglist), FALSE);
-	renderer = gtk_cell_renderer_text_new();
-	column = gtk_tree_view_column_new_with_attributes("text", 
-				renderer, "text", 0, NULL);
-	gtk_tree_view_append_column(GTK_TREE_VIEW(pluglist), column);
-	gtk_container_add(GTK_CONTAINER(scrolledwindow), pluglist);
-
-	g_object_unref(G_OBJECT(store));
-
-	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluglist));
-	g_signal_connect(G_OBJECT(selection), "changed", 
-			G_CALLBACK(list_clicked),
-			NULL);
-
-	gtk_widget_show(pluglist);
-
-	/* Right side: frame with description and the filepath of plugin */
-	frame = gtk_frame_new(_("Selected Plugin"));
-	gtk_box_pack_start(GTK_BOX(tophbox), frame, TRUE, TRUE, 0);
-	gtk_container_set_border_width(GTK_CONTAINER(frame), 6);
-	gtk_frame_set_label_align(GTK_FRAME(frame), 0.05, 0.5);
-	gtk_widget_show(frame);
-
-	vbox = gtk_vbox_new(FALSE, 0);
-	gtk_container_add(GTK_CONTAINER(frame), vbox);
-	gtk_widget_show(vbox);
-
-	scrolledwindow = gtk_scrolled_window_new(NULL, NULL);
-	gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0);
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow),
-					GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-	gtk_widget_show(scrolledwindow);
-	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow),
-					GTK_SHADOW_IN);		
-	
-	/* Create & show the plugin description widget */
-	plugtext = gtk_text_view_new();
-	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(plugtext), GTK_WRAP_WORD);
-	gtk_text_view_set_editable(GTK_TEXT_VIEW(plugtext), FALSE);
-	gtk_container_add(GTK_CONTAINER(scrolledwindow), plugtext);
-	gtk_widget_set_size_request(GTK_WIDGET(plugtext), -1, 200);
-	
-	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext));
-	gtk_text_buffer_create_tag(buffer, "bold", "weight", 
-			PANGO_WEIGHT_BOLD, NULL);
-	gtk_widget_show(plugtext);
-
-	hbox = gtk_hbox_new(FALSE, 5);
-	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-	gtk_container_set_border_width(GTK_CONTAINER(hbox), 6);
-	gtk_widget_show(hbox);
-
-	label = gtk_label_new(_("Filepath:"));
-	gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-	gtk_widget_show(label);
-
-	plugentry = gtk_entry_new();
-	gtk_box_pack_start(GTK_BOX(hbox), plugentry, TRUE, TRUE, 0);
-	gtk_entry_set_editable(GTK_ENTRY(plugentry), FALSE);
-	gtk_widget_show(plugentry);
-
-	/* Build the bottom button bar */
-	bothbox = gtk_hbox_new(TRUE, 3);
-	gtk_box_pack_start(GTK_BOX(mainvbox), bothbox, FALSE, FALSE, 0);
-	gtk_container_set_border_width(GTK_CONTAINER(hbox), 5);
-	gtk_widget_show(bothbox);
-
-	if (!tooltips)
-		tooltips = gtk_tooltips_new();
-
-	add = picture_button(plugwindow, _("Load"), gnome_add_xpm);
-	gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(load_file), NULL);
-	gtk_box_pack_start_defaults(GTK_BOX(bothbox), add);
-	gtk_tooltips_set_tip(tooltips, add, _("Load a plugin from a file"), "");
-
-	config = picture_button(plugwindow, _("Configure"), gnome_preferences_xpm);
-	gtk_widget_set_sensitive(config, FALSE);
-	gtk_box_pack_start_defaults(GTK_BOX(bothbox), config);
-	gtk_tooltips_set_tip(tooltips, config, _("Configure settings of the selected plugin"), "");
-
-	reload = picture_button(plugwindow, _("Reload"), refresh_xpm);
-	gtk_widget_set_sensitive(reload, FALSE);
-	gtk_signal_connect(GTK_OBJECT(reload), "clicked", GTK_SIGNAL_FUNC(plugin_reload_cb), NULL);
-	gtk_box_pack_start_defaults(GTK_BOX(bothbox), reload);
-	gtk_tooltips_set_tip(tooltips, reload, _("Reload the selected plugin"), "");
-
-	unload = picture_button(plugwindow, _("Unload"), gnome_remove_xpm);
-	gtk_signal_connect(GTK_OBJECT(unload), "clicked", GTK_SIGNAL_FUNC(unload_plugin_cb), pluglist);
-	gtk_box_pack_start_defaults(GTK_BOX(bothbox), unload);
-	gtk_tooltips_set_tip(tooltips, unload, _("Unload the selected plugin"), "");
-
-	close = picture_button(plugwindow, _("Close"), cancel_xpm);
-	gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(hide_plugins), NULL);
-	gtk_box_pack_start_defaults(GTK_BOX(bothbox), close);
-	gtk_tooltips_set_tip(tooltips, close, _("Close this window"), "");
-
-	update_show_plugins();
-	gtk_widget_show(plugwindow);
-}
-
-void update_show_plugins()
-{
-	GList *plugs = plugins;
-	struct gaim_plugin *p;
-	int pnum = 0;
-	GtkListStore *store;
-	GtkTreeIter iter;
-	
-	if (plugwindow == NULL)
-		return;
-
-	store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(pluglist)));
-	gtk_list_store_clear(store);
-	while (plugs) {
-		p = (struct gaim_plugin *)plugs->data;
-		gtk_list_store_append(store, &iter);
-		gtk_list_store_set(store, &iter, 0, plugin_makelistname(p->handle), -1);
-		gtk_list_store_set(store, &iter, 1, pnum++, -1);
-		plugs = g_list_next(plugs);
-	}
-
-	clear_plugin_display();
-}
-
-static void unload_plugin_cb(GtkWidget *w, gpointer data)
-{
-	struct gaim_plugin *p;
-	p = get_selected_plugin(pluglist);
-	if(p == NULL)
-		return;
-	unload_plugin(p);
-	update_show_plugins();
-}
-
-static void plugin_reload_cb(GtkWidget *w, gpointer data)
-{
-	struct gaim_plugin *p;
-	p = get_selected_plugin(pluglist);
-	if(p == NULL)
-		return;
-	p = reload_plugin(p);
-	update_show_plugins();
-
-	/* Try and reselect the plugin in list */
-	if (!pluglist)
-		return;
-	select_plugin(pluglist, p);
-}
-
-
-static void list_clicked(GtkWidget *w, gpointer data)
-{
-	void (*gaim_plugin_config)();
-	struct gaim_plugin *p;
-	GtkTextBuffer *buffer;
-	GtkTextIter iter;
-
-	if (confighandle != 0) {
-		gtk_signal_disconnect(GTK_OBJECT(config), confighandle);
-		confighandle = 0;
-	}
-
-	p = get_selected_plugin(pluglist);
-	if(p == NULL) { /* No selected plugin */
-		clear_plugin_display();
-		return;
-	}
-
-	/* Set text and filepath widgets */
-	buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext));
-	gtk_text_buffer_set_text(buffer, "", -1);
-	gtk_text_buffer_get_start_iter(buffer, &iter);
-
-	gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "Name:", -1, 
-					"bold", NULL);
-	gtk_text_buffer_insert(buffer, &iter, "   ", -1); 
-	gtk_text_buffer_insert(buffer, &iter, (p->name != NULL) ? p->name : "", -1);
-	gtk_text_buffer_insert(buffer, &iter, "\n\n", -1);
-	gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, "Description:", -1,
-					"bold", NULL);
-	gtk_text_buffer_insert(buffer, &iter, "\n", -1);
-	gtk_text_buffer_insert(buffer, &iter, 
-					(p->description != NULL) ? p->description : "", -1);
-
-	gtk_entry_set_text(GTK_ENTRY(plugentry), g_module_name(p->handle));
-	/* Find out if this plug-in has a configuration function */
-	if (g_module_symbol(p->handle, "gaim_plugin_config", (gpointer *)&gaim_plugin_config)) {
-		confighandle = gtk_signal_connect(GTK_OBJECT(config), "clicked",
-						  GTK_SIGNAL_FUNC(gaim_plugin_config), NULL);
-		gtk_widget_set_sensitive(config, TRUE);
-	} else {
-		confighandle = 0;
-		gtk_widget_set_sensitive(config, FALSE);
-	}
-
-	gtk_widget_set_sensitive(reload, TRUE);
-	gtk_widget_set_sensitive(unload, TRUE);
-}
-
-static void hide_plugins(GtkWidget *w, gpointer data)
-{
-	if (plugwindow)
-		gtk_widget_destroy(plugwindow);
-	plugwindow = NULL;
-	config = NULL;
-	confighandle = 0;
-}
-
-static const gchar *plugin_makelistname(GModule *module)
-{
-	static gchar filename[PATHSIZE];
-	const gchar *filepath = (char *)g_module_name(module);
-	const char *cp;
-
-	if (filepath == NULL || strlen(filepath) == 0)
-		return NULL;
-	
-	if ((cp = strrchr(filepath, '/')) == NULL || *++cp == '\0')
-		cp = filepath;
-
-	strncpy(filename, cp, sizeof(filename));
-	filename[sizeof(filename) - 1] = '\0';
-
-	/* Try to pretty name by removing any trailing ".so" */
-	if (strlen(filename) > 3 &&
-	    strncmp(filename + strlen(filename) - 3, ".so", 3) == 0)
-		filename[strlen(filename) - 3] = '\0';
-
-	return filename;
-}		
-
-static struct gaim_plugin *get_selected_plugin(GtkWidget *w) {
-	/* Given the pluglist widget, this will return a pointer to the plugin
-	 * currently selected in the list, and NULL if none is selected. */
-	gint index;
-	GList *plugs = plugins;
-	GtkTreeSelection *sel;
-	GtkTreeIter iter;
-	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(w));
-
-	/* Get list index of selected plugin */
-	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(w));
-	if(!gtk_tree_selection_get_selected(sel, &model, &iter))
-		return NULL;
-	gtk_tree_model_get(model, &iter, 1, &index, -1);
-				
-	/* Get plugin entry from index */
-	plugs = g_list_nth(plugins, index);
-	if(plugs == NULL)
-		return NULL;
-	else
-		return (struct gaim_plugin *)plugs->data;
-}
-
-static void select_plugin(GtkWidget *w, struct gaim_plugin *p) {
-	/* Given the pluglist widget and a plugin, this will try to select
-	 * entry in the list which corresponds with the plugin. */
-	GtkTreeSelection *sel;
-	GtkTreeIter iter;
-	GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(w));
-	gchar temp[10];
-	
-	if(g_list_index(plugins, p) == -1)
-		return;
-
-	snprintf(temp, 10, "%d", g_list_index(plugins, p));
-	gtk_tree_model_get_iter_from_string(model, 
-			&iter, temp);
-	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(w));
-	gtk_tree_selection_select_iter(sel, &iter);
-}
-
-static void clear_plugin_display() {
-	GtkTreeSelection *selection;
-	GtkTextBuffer *buffer;
-	
-	/* Clear the plugin display if nothing's selected */
-	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(pluglist));
-	if(gtk_tree_selection_get_selected(selection, NULL, NULL) == FALSE) {
-		buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(plugtext));
-		gtk_text_buffer_set_text(buffer, "", -1);
-		gtk_entry_set_text(GTK_ENTRY(plugentry), "");
-
-		gtk_widget_set_sensitive(config, FALSE);
-		gtk_widget_set_sensitive(reload, FALSE);
-		gtk_widget_set_sensitive(unload, FALSE);
-	}
-}
-
-#endif
--- a/src/prefs.c	Wed Sep 25 14:27:18 2002 +0000
+++ b/src/prefs.c	Thu Sep 26 07:37:52 2002 +0000
@@ -100,7 +100,7 @@
 	for (v = 0; v < NUM_SOUNDS; v++) {
 		if (sound_file_new[v]) {
 			g_free(sound_file_new[v]);
-			sound_file_new[v] = NULL;
+		sound_file_new[v] = NULL;
 		}
 	}
 	sound_entry = NULL;
@@ -847,6 +847,198 @@
 	return ret;
 }
 
+#if USE_PLUGINS
+GtkWidget *plugin_description=NULL, *plugin_details=NULL;
+static void prefs_plugin_sel (GtkTreeSelection *sel, GtkTreeModel *model) 
+{
+	gchar buf[1024];
+	GtkTreeIter  iter;
+	GValue val = { 0, };
+	struct gaim_plugin *plug;
+
+	if (! gtk_tree_selection_get_selected (sel, &model, &iter))
+		return;
+	gtk_tree_model_get_value (model, &iter, 2, &val);
+	plug = g_value_get_pointer(&val);
+	
+	g_snprintf(buf, sizeof(buf), _("<span size=\"larger\">%s %s</span>\n\n%s"), 
+		   plug->desc.name, plug->desc.version, plug->desc.description);
+	gtk_label_set_markup(GTK_LABEL(plugin_description), buf);
+	g_snprintf(buf, sizeof(buf), _("<span size=\"larger\">%s %s</span>\n\n"
+				       "<span weight=\"bold\">Written by:</span>\t%s\n"
+				       "<span weight=\"bold\">URL:</span>\t%s\n"
+				       "<span weight=\"bold\">File name:</span>\t %s"),
+		   plug->desc.name, plug->desc.version, plug->desc.authors, plug->desc.url, plug->path);
+	gtk_label_set_markup(GTK_LABEL(plugin_details), buf);
+	g_value_unset (&val);
+}
+
+static void plugin_load (GtkCellRendererToggle *cell, gchar *pth, gpointer data)
+{
+	GtkTreeModel *model = (GtkTreeModel *)data;
+	GtkTreeIter iter;
+	GtkTreePath *path = gtk_tree_path_new_from_string(pth);
+	struct gaim_plugin *plug;
+	gchar buf[1024];
+	GdkCursor *wait = gdk_cursor_new (GDK_WATCH);
+	gdk_window_set_cursor(prefs->window, wait);
+	gdk_cursor_unref(wait);
+  
+	gtk_tree_model_get_iter (model, &iter, path);
+	gtk_tree_model_get (model, &iter, 2, &plug, -1);
+	
+	if (!plug->handle)
+
+		if (plug->type == plugin)
+#ifdef GAIM_PLUGINS
+			load_plugin(plug->path);
+#else
+	        {}	
+#endif
+		else
+#ifdef USE_PERL
+			perl_load_file(plug->path);
+#else
+	        {}
+#endif 
+	else
+		if (plug->type == plugin)
+#ifdef GAIM_PLUGINS
+			unload_plugin(plug);
+#else
+	                {} 
+#endif
+		else
+#ifdef USE_PERL
+			perl_unload_file(plug);
+#else
+	                {}
+#endif
+	gdk_window_set_cursor(prefs->window, NULL);
+	
+	gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, plug->handle, -1);
+	g_snprintf(buf, sizeof(buf), _("<span size=\"larger\">%s %s</span>\n\n%s"), 
+		   plug->desc.name, plug->desc.version, plug->desc.description);
+	gtk_label_set_markup(GTK_LABEL(plugin_description), buf);
+	gtk_tree_path_free(path);
+}
+
+static GtkWidget *plugin_page ()
+{
+	GtkWidget *ret;
+
+	GtkWidget *sw, *vp;
+	GtkTreeIter iter;
+	GtkWidget *event_view;
+	GtkListStore *ls;
+	GtkCellRenderer *rend, *rendt;
+	GtkTreeViewColumn *col;
+	GtkTreeSelection *sel;
+	GtkTreePath *path;
+	
+	GtkWidget *nb;
+
+	GList *probes = probed_plugins;
+	struct gaim_plugin *plug;
+	
+	ret = gtk_vbox_new(FALSE, 18);
+	gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
+
+	sw = gtk_scrolled_window_new(NULL,NULL);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
+
+	gtk_box_pack_start(GTK_BOX(ret), sw, TRUE, TRUE, 0);
+
+	ls = gtk_list_store_new (3, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_POINTER);
+	while (probes) {
+		plug = probes->data;
+		gtk_list_store_append (ls, &iter);
+		gtk_list_store_set(ls, &iter,
+				   0, plug->handle,
+				   1, plug->desc.name ? plug->desc.name : plug->path, 
+				   2, plug, -1);
+		probes = probes->next;
+	}
+	
+	event_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(ls));
+
+	rend = gtk_cell_renderer_toggle_new();
+	sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (event_view));
+
+	
+	col = gtk_tree_view_column_new_with_attributes ("Load",
+							rend,
+							"active", 0,
+							NULL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col);
+
+	rendt = gtk_cell_renderer_text_new();
+	col = gtk_tree_view_column_new_with_attributes ("Name",
+							rendt,
+							"text", 1,
+							NULL);
+	gtk_tree_view_append_column (GTK_TREE_VIEW(event_view), col);
+	g_object_unref(G_OBJECT(ls));
+	gtk_container_add(GTK_CONTAINER(sw), event_view);
+	
+
+	nb = gtk_notebook_new();
+	gtk_notebook_set_tab_pos (GTK_NOTEBOOK(nb), GTK_POS_BOTTOM);
+	gtk_notebook_popup_disable(GTK_NOTEBOOK(nb));
+	
+	/* Description */
+	sw = gtk_scrolled_window_new(NULL, NULL);
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+	plugin_description = gtk_label_new(NULL);
+	
+	vp = gtk_viewport_new(NULL, NULL);
+	gtk_viewport_set_shadow_type(vp, GTK_SHADOW_NONE);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_NONE);
+
+	gtk_container_add(vp, plugin_description);
+	gtk_container_add(sw, vp);
+
+	gtk_label_set_selectable(plugin_description, TRUE);  
+	gtk_label_set_line_wrap(plugin_description, TRUE);
+	gtk_misc_set_alignment(GTK_MISC(plugin_description), 0, 0);
+	gtk_misc_set_padding(GTK_MISC(plugin_description), 6, 6);
+	gtk_notebook_append_page(GTK_NOTEBOOK(nb), sw, gtk_label_new(_("Description")));
+
+	/* Details */
+	sw = gtk_scrolled_window_new(NULL, NULL);
+	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+	plugin_details = gtk_label_new(NULL);
+	
+	vp = gtk_viewport_new(NULL, NULL);
+	gtk_viewport_set_shadow_type(vp, GTK_SHADOW_NONE);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_NONE);
+
+	gtk_container_add(vp, plugin_details);
+	gtk_container_add(sw, vp);
+
+	gtk_label_set_selectable(plugin_details, TRUE);  
+	gtk_label_set_line_wrap(plugin_details, TRUE);
+	gtk_misc_set_alignment(GTK_MISC(plugin_details), 0, 0);
+	gtk_misc_set_padding(GTK_MISC(plugin_details), 6, 6);	
+	gtk_notebook_append_page(GTK_NOTEBOOK(nb), sw, gtk_label_new(_("Details")));
+	gtk_box_pack_start(GTK_BOX(ret), nb, TRUE, TRUE, 0);
+
+	g_signal_connect (G_OBJECT (sel), "changed",
+			  G_CALLBACK (prefs_plugin_sel),
+			  NULL); 
+	g_signal_connect (G_OBJECT(rend), "toggled",
+			  G_CALLBACK(plugin_load), ls);
+
+	path = gtk_tree_path_new_first();
+	gtk_tree_selection_select_path(sel, path);
+	gtk_tree_path_free(path);
+
+	gtk_widget_show_all(ret);
+	return ret;
+}
+#endif
+
 static void event_toggled (GtkCellRendererToggle *cell, gchar *pth, gpointer data)
 {
 	GtkTreeModel *model = (GtkTreeModel *)data;
@@ -1233,6 +1425,9 @@
 	prefs_notebook_add_page(_("Sound Events"), NULL, sound_events_page(), &c, &p, a++);
 	prefs_notebook_add_page(_("Away / Idle"), NULL, away_page(), &p, NULL, a++);
 	prefs_notebook_add_page(_("Away Messages"), NULL, away_message_page(), &c, &p, a++);
+#if USE_PLUGINS
+	prefs_notebook_add_page(_("Plugins"), NULL, plugin_page(), &p, NULL, a++);
+#endif
 }
 
 void show_prefs()