changeset 11290:b284c703d398

[gaim-migrate @ 13490] Did some house cleaning on the code finished up some of the "TODO" stuff that was left over from when I originally did the XSUBs. Furthermore, the dynamically loaded Perl package problems should be corrected now that the context is set before one of the concurrent perl interpreters is run. committer: Tailor Script <tailor@pidgin.im>
author John H. Kelm <johnkelm@gmail.com>
date Thu, 18 Aug 2005 01:35:14 +0000
parents b633879e23f9
children 57fccea36e36
files plugins/perl/common/Account.xs plugins/perl/common/AccountOpts.xs plugins/perl/common/BuddyIcon.xs plugins/perl/common/BuddyList.xs plugins/perl/common/Cipher.xs plugins/perl/common/Cmds.xs plugins/perl/common/Connection.xs plugins/perl/common/Conversation.xs plugins/perl/common/FT.xs plugins/perl/common/Gaim.xs plugins/perl/common/ImgStore.xs plugins/perl/common/Log.xs plugins/perl/common/Network.xs plugins/perl/common/Notify.xs plugins/perl/common/Plugin.xs plugins/perl/common/PluginPref.xs plugins/perl/common/Pounce.xs plugins/perl/common/Prefs.xs plugins/perl/common/Privacy.xs plugins/perl/common/Proxy.xs plugins/perl/common/Prpl.xs plugins/perl/common/Request.xs plugins/perl/common/Roomlist.xs plugins/perl/common/SSLConn.xs plugins/perl/common/SavedStatuses.xs plugins/perl/common/Server.xs plugins/perl/common/Sound.xs plugins/perl/common/Status.xs plugins/perl/common/Stringref.xs plugins/perl/common/Util.xs plugins/perl/common/XMLNode.xs plugins/perl/perl-common.c plugins/perl/perl.c
diffstat 33 files changed, 133 insertions(+), 237 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/perl/common/Account.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Account.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,7 +1,7 @@
-
 #include "module.h"
 
-/* TODO
+MODULE = Gaim::Account  PACKAGE = Gaim::Account  PREFIX = gaim_account_
+PROTOTYPES: ENABLE
 
 Gaim::Presence
 gaim_account_get_presence(account)
@@ -12,12 +12,6 @@
 	Gaim::Account account
 	Gaim::Presence presence
 
-*/
-
-/**********************XS Code for Account.xs*********************************/
-MODULE = Gaim::Account  PACKAGE = Gaim::Account  PREFIX = gaim_account_
-PROTOTYPES: ENABLE
-
 Gaim::Account
 gaim_account_new(username, protocol_id)
 	const char * username
--- a/plugins/perl/common/AccountOpts.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/AccountOpts.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,10 +1,5 @@
 #include "module.h"
 
-/* TODO
-
-*/
-
-/**********************XS Code for Account.xs*********************************/
 MODULE = Gaim::Account::Option  PACKAGE = Gaim::Account::Option  PREFIX = gaim_account_option_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/BuddyIcon.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/BuddyIcon.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,16 +1,8 @@
-
 #include "module.h"
 
-/*
-TODO
-
-*/
-
-
 MODULE = Gaim::Buddy::Icon PACKAGE = Gaim::Buddy::Icon   PREFIX = gaim_buddy_icon_
 PROTOTYPES: ENABLE
 
-
 void
 gaim_buddy_icon_destroy(icon)
 	Gaim::Buddy::Icon icon
--- a/plugins/perl/common/BuddyList.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/BuddyList.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,23 +1,6 @@
 #include "module.h"
 #include "../perl-handlers.h"
 
-/*
-TODO
-
-void *
-gaim_blist_node_action_new(label, cb, data, children)
-	char * label
-	SV * cb
-	SV * data
-	SV * children
-CODE:
-	RETVAL = gaim_perl_blist_node_action(label, cb, data, children);
-OUTPUT:
-	RETVAL
-
-*/
-
-
 MODULE = Gaim::BuddyList  PACKAGE = Gaim::BuddyList  PREFIX = gaim_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Cipher.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Cipher.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,12 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
-/**********************XS Code for Account.xs*********************************/
 MODULE = Gaim::Cipher  PACKAGE = Gaim::Cipher  PREFIX = gaim_cipher_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Cmds.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Cmds.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -3,7 +3,6 @@
 MODULE = Gaim::Cmds  PACKAGE = Gaim::Cmds  PREFIX = gaim_cmd_
 PROTOTYPES: ENABLE
 
-
 void
 gaim_cmd_help(conv, cmd)
 	Gaim::Conversation conv
--- a/plugins/perl/common/Connection.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Connection.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,19 +1,5 @@
 #include "module.h"
 
-/* TODO
-;
-
-;
-;
-;
-;;;;;
-;;;
-
-
-
-*/
-
-/**********************XS Code for Conversation.xs*********************************/
 MODULE = Gaim::Connection  PACKAGE = Gaim::GTK::Connection  PREFIX = gaim_gtk_connections_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Conversation.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Conversation.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,6 +1,5 @@
 #include "module.h"
 
-/**********************XS Code for Conversation.xs*********************************/
 MODULE = Gaim::Conv  PACKAGE = Gaim::Conv::Window  PREFIX = gaim_conv_window_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/FT.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/FT.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -3,7 +3,6 @@
 MODULE = Gaim::Xfer  PACKAGE = Gaim::Xfer  PREFIX = gaim_xfer_
 PROTOTYPES: ENABLE
 
-
 void 
 gaim_xfer_add(xfer)
 	Gaim::Xfer xfer
--- a/plugins/perl/common/Gaim.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Gaim.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -83,30 +83,30 @@
 
 BOOT:
 	GAIM_PERL_BOOT(Account);
-	GAIM_PERL_BOOT(BuddyList);
 	GAIM_PERL_BOOT(Account__Option); 
 	GAIM_PERL_BOOT(Buddy__Icon);
+	GAIM_PERL_BOOT(BuddyList);
 	GAIM_PERL_BOOT(Cipher);
-	GAIM_PERL_BOOT(Conv);
+	GAIM_PERL_BOOT(Cmds);
 	GAIM_PERL_BOOT(Connection);
-	GAIM_PERL_BOOT(Plugin);
-	GAIM_PERL_BOOT(Prefs);
-	GAIM_PERL_BOOT(Cmds);
+	GAIM_PERL_BOOT(Conv);
 	GAIM_PERL_BOOT(Xfer);
 	GAIM_PERL_BOOT(ImgStore);
 	GAIM_PERL_BOOT(Log);
 	GAIM_PERL_BOOT(Network);
 	GAIM_PERL_BOOT(Notify);
+	GAIM_PERL_BOOT(Plugin);
+	GAIM_PERL_BOOT(Pref); 
 	GAIM_PERL_BOOT(Pounce);
-	GAIM_PERL_BOOT(Pref); 
+	GAIM_PERL_BOOT(Prefs);
 	GAIM_PERL_BOOT(Privacy);
 	GAIM_PERL_BOOT(Proxy);
 	GAIM_PERL_BOOT(Prpl);
 	GAIM_PERL_BOOT(Request);
 	GAIM_PERL_BOOT(Roomlist);
+	GAIM_PERL_BOOT(SSL);
 	GAIM_PERL_BOOT(SavedStatus);
 	GAIM_PERL_BOOT(Sound);
-	GAIM_PERL_BOOT(SSL);
 	GAIM_PERL_BOOT(Status);
 	GAIM_PERL_BOOT(Stringref);
 	GAIM_PERL_BOOT(Util);
--- a/plugins/perl/common/ImgStore.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/ImgStore.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,12 +1,8 @@
-
 #include "module.h"
 
-
 MODULE = Gaim::ImgStore  PACKAGE = Gaim::ImgStore  PREFIX = gaim_imgstore_
 PROTOTYPES: ENABLE
 
-
-
 int 
 gaim_imgstore_add(data, size, filename)
 	void *data
--- a/plugins/perl/common/Log.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Log.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,8 @@
 #include "module.h"
 
-
 MODULE = Gaim::Log  PACKAGE = Gaim::Log  PREFIX = gaim_log_
 PROTOTYPES: ENABLE
 
-
-
 int 
 gaim_log_common_sizer(log)
 	Gaim::Log log
@@ -35,11 +32,10 @@
 void
 gaim_log_get_log_sets()
 PREINIT:
-        GList *l;
+        GHashTable *l;
 PPCODE:
-        for (l = gaim_log_get_log_sets(); l != NULL; l = l->next) {
-                XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
-        }
+        l = gaim_log_get_log_sets(); 
+        XPUSHs(sv_2mortal(gaim_perl_bless_object(l, "GHashTable")));
 
 void
 gaim_log_get_logs(type, name, account)
--- a/plugins/perl/common/Network.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Network.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -3,7 +3,6 @@
 MODULE = Gaim::Network  PACKAGE = Gaim::Network  PREFIX = gaim_network_
 PROTOTYPES: ENABLE
 
-
 const char *
 gaim_network_get_local_system_ip(fd)
 	int fd
--- a/plugins/perl/common/Notify.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Notify.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,16 +1,8 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::Notify  PACKAGE = Gaim::Notify  PREFIX = gaim_notify_
 PROTOTYPES: ENABLE
 
-
-
 void 
 gaim_notify_close(type, ui_handle)
 	Gaim::NotifyType type
--- a/plugins/perl/common/Plugin.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Plugin.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -3,8 +3,6 @@
 MODULE = Gaim::Plugin  PACKAGE = Gaim::Plugin  PREFIX = gaim_plugin_
 PROTOTYPES: ENABLE
 
-
-
 void 
 gaim_plugin_destroy(plugin)
 	Gaim::Plugin plugin
--- a/plugins/perl/common/PluginPref.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/PluginPref.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,12 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
-
 MODULE = Gaim::Pref  PACKAGE = Gaim::Pref  PREFIX = gaim_plugin_pref_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Pounce.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Pounce.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::Pounce  PACKAGE = Gaim::Pounce  PREFIX = gaim_pounce_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Prefs.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Prefs.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -3,7 +3,6 @@
 MODULE = Gaim::Prefs  PACKAGE = Gaim::Prefs  PREFIX = gaim_prefs_
 PROTOTYPES: ENABLE
 
-
 void 
 gaim_prefs_add_bool(name, value)
 	const char *name
--- a/plugins/perl/common/Privacy.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Privacy.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::Privacy  PACKAGE = Gaim::Privacy  PREFIX = gaim_privacy_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Proxy.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Proxy.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,15 +1,8 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::Proxy  PACKAGE = Gaim::Proxy  PREFIX = gaim_proxy_
 PROTOTYPES: ENABLE
 
-
 Gaim::ProxyInfo
 gaim_global_proxy_get_info()
  
--- a/plugins/perl/common/Prpl.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Prpl.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-gaim_prpl_got_account_statu(s) ... variable arguments lists suck.
-
-*/
-
 MODULE = Gaim::Prpl  PACKAGE = Gaim::Find  PREFIX = gaim_find_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Request.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Request.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -52,38 +52,63 @@
 	LEAVE;
 }
 
-
-/* TODO
-
-
-void *
-gaim_request_input(handle, title, primary, secondary, default_value, multiline, masked, hint, ok_text, ok_cb, cancel_text, cancel_cb, user_data)
- 
-
-void *
-gaim_request_file(handle, title, filename, savedialog, ok_cb, cancel_cb, user_data)
-
-void 
-gaim_request_field_account_set_filter(field, filter_func)
-
+MODULE = Gaim::Request  PACKAGE = Gaim::Request  PREFIX = gaim_request_
+PROTOTYPES: ENABLE
 
 void *
-gaim_request_action(handle, title, primary, secondary, default_action, user_data, action_count, gaim_request_action)
-
-
-void *
-gaim_request_choice(handle, title, primary, secondary, default_value, ok_text, ok_cb, cancel_text, cancel_cb, user_data, gaim_request_choice)
-
+gaim_request_input(handle, title, primary, secondary, default_value, multiline, masked, hint, ok_text, ok_cb, cancel_text, cancel_cb)
+	Gaim::Plugin handle
+	const char * title
+	const char * primary
+	const char * secondary
+	const char * default_value
+	gboolean multiline
+	gboolean masked
+	gchar * hint
+	const char * ok_text
+	SV * ok_cb
+	const char * cancel_text
+	SV * cancel_cb
+CODE:
+	GaimPerlRequestData *gpr;
+	STRLEN len;
+	char *basename, *package;
+	
+	basename = g_path_get_basename(handle->path);
+	gaim_perl_normalize_script_name(basename);
+	package = g_strdup_printf("Gaim::Script::%s", basename);
+	gpr = g_new(GaimPerlRequestData, 1);
+	gpr->ok_cb = g_strdup_printf("%s::%s", package, SvPV(ok_cb, len));
+	gpr->cancel_cb = g_strdup_printf("%s::%s", package, SvPV(cancel_cb, len));
+	
+	RETVAL = gaim_request_input(handle, title, primary, secondary, default_value, multiline, masked, hint, ok_text, G_CALLBACK(gaim_perl_request_ok_cb), cancel_text, G_CALLBACK(gaim_perl_request_cancel_cb), gpr);
+OUTPUT:
+	RETVAL
+	
 void *
-gaim_request_choice_varg(handle, title, primary, secondary, default_value, ok_text, ok_cb, cancel_text, cancel_cb, user_data, choices)
-
-
+gaim_request_file(handle, title, filename, savedialog, ok_cb, cancel_cb)
+	Gaim::Plugin handle
+	const char * title
+	const char * filename
+	gboolean savedialog
+	SV * ok_cb
+	SV * cancel_cb
+CODE:
+	GaimPerlRequestData *gpr;
+	STRLEN len;
+	char *basename, *package;
 
-*/
-
+	basename = g_path_get_basename(handle->path);
+	gaim_perl_normalize_script_name(basename);
+	package = g_strdup_printf("Gaim::Script::%s", basename);
+	gpr = g_new(GaimPerlRequestData, 1);
+	gpr->ok_cb = g_strdup_printf("%s::%s", package, SvPV(ok_cb, len));
+	gpr->cancel_cb = g_strdup_printf("%s::%s", package, SvPV(cancel_cb, len));
 
-MODULE = Gaim::Request  PACKAGE = Gaim::Request  PREFIX = gaim_request_
-PROTOTYPES: ENABLE
+	RETVAL = gaim_request_file(handle, title, filename, savedialog, G_CALLBACK(gaim_perl_request_ok_cb), G_CALLBACK(gaim_perl_request_cancel_cb), gpr);
+OUTPUT:
+	RETVAL
+			
 
 void *
 gaim_request_fields(handle, title, primary, secondary, fields, ok_text, ok_cb, cancel_text, cancel_cb)
@@ -112,16 +137,6 @@
 OUTPUT:
 	RETVAL
 
-
-
-
-
-
-
-
-
-
-
 void *
 gaim_request_action_varg(handle, title, primary, secondary, default_action, user_data, action_count, actions)
  	void * handle
@@ -133,8 +148,6 @@
 	size_t action_count
 	va_list actions
 
-
-
 void 
 gaim_request_close(type, uihandle)
 	Gaim::RequestType type
--- a/plugins/perl/common/Roomlist.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Roomlist.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,12 +1,5 @@
-
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::Roomlist  PACKAGE = Gaim::Roomlist  PREFIX = gaim_roomlist_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/SSLConn.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/SSLConn.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,5 +1,3 @@
-
-
 #include "module.h"
 
 /* TODO
--- a/plugins/perl/common/SavedStatuses.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/SavedStatuses.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,17 +1,11 @@
-
 #include "module.h"
 
-/* TODO
-
+MODULE = Gaim::SavedStatus  PACKAGE = Gaim::SavedStatus  PREFIX = gaim_savedstatus_
+PROTOTYPES: ENABLE
 
 void *
 gaim_savedstatuses_get_handle()
 
-*/
-
-MODULE = Gaim::SavedStatus  PACKAGE = Gaim::SavedStatus  PREFIX = gaim_savedstatus_
-PROTOTYPES: ENABLE
-
 
 gboolean 
 gaim_savedstatus_delete(title)
--- a/plugins/perl/common/Server.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Server.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,5 @@
 #include "module.h"
 
-/*
-TODO
-
-*/
-
-
 MODULE = Gaim::Serv  PACKAGE = Gaim::Serv  PREFIX = serv_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Sound.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Sound.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::Sound  PACKAGE = Gaim::Sound  PREFIX = gaim_sound_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Status.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Status.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,4 +1,3 @@
-
 #include "module.h"
 
 /* TODO
@@ -26,6 +25,11 @@
 	Gaim::Value attr_value
 	...
 
+*/
+
+MODULE = Gaim::Status  PACKAGE = Gaim::Presence  PREFIX = gaim_presence_
+PROTOTYPES: ENABLE
+
 void 
 gaim_presence_add_list(presence, source_list)
 	Gaim::Presence presence
@@ -43,12 +47,6 @@
 	}
 	gaim_presence_add_list(presence, t_GL);
 	
-*/
-
-/***************************XS Code Status.xs**************************/
-MODULE = Gaim::Status  PACKAGE = Gaim::Presence  PREFIX = gaim_presence_
-PROTOTYPES: ENABLE
-
 void 
 gaim_presence_add_status(presence, status)
 	Gaim::Presence presence
--- a/plugins/perl/common/Stringref.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Stringref.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,15 +1,5 @@
 #include "module.h"
 
-/* TODO
-
-Gaim::Stringref
-gaim_stringref_printf(format, gaim_stringref_printf)
-	const char *format
-	...
-
-
-*/
-
 MODULE = Gaim::Stringref  PACKAGE = Gaim::Stringref  PREFIX = gaim_stringref_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/common/Util.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/Util.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,25 +1,51 @@
-
-
 #include "module.h"
 
-/* TODO
+typedef struct {
+	char *cb;
+} GaimPerlUrlData;
+
+void gaim_perl_util_url_cb(void *data, const char *url_data, size_t size) {
+        GaimPerlUrlData *gpr = (GaimPerlUrlData *)data;
+        dSP;
+        ENTER;
+        SAVETMPS;
+        PUSHMARK(sp);
 
-void 
-gaim_url_fetch(url, full, user_agent, http11, void *, char *, size_t), data)
-	const char *url
-	gboolean full
-	const char *user_agent
-	gboolean http11
- 
-	const char *
-	size_t)
+        XPUSHs(sv_2mortal(newSVpv(url_data, 0)));
+        PUTBACK;
+
+        call_pv(gpr->cb, G_EVAL | G_SCALAR);
+        SPAGAIN;
 
-*/
+        PUTBACK;
+        FREETMPS;
+        LEAVE;
+}
 
-/**********************XS Code for Account.xs*********************************/
+
 MODULE = Gaim::Util  PACKAGE = Gaim::Util  PREFIX = gaim_
 PROTOTYPES: ENABLE	
-	
+
+void
+gaim_url_fetch(handle, url, full, user_agent, http11, cb)
+        Gaim::Plugin handle
+        const char *url
+        gboolean full
+        const char *user_agent
+        gboolean http11
+        SV * cb
+CODE:
+        GaimPerlUrlData *gpr;
+        STRLEN len;
+        char *basename, *package;
+
+        basename = g_path_get_basename(handle->path);
+        gaim_perl_normalize_script_name(basename);
+        package = g_strdup_printf("Gaim::Script::%s", basename);
+        gpr = g_new(GaimPerlUrlData, 1);
+
+	gpr->cb = g_strdup_printf("%s::%s", package, SvPV(cb, len));
+        gaim_url_fetch(url, full, user_agent, http11, gaim_perl_util_url_cb, gpr);
 
 int 
 gaim_build_dir(path, mode)
--- a/plugins/perl/common/XMLNode.xs	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/common/XMLNode.xs	Thu Aug 18 01:35:14 2005 +0000
@@ -1,11 +1,5 @@
-
 #include "module.h"
 
-/* TODO
-
-
-*/
-
 MODULE = Gaim::XMLNode  PACKAGE = Gaim::XMLNode  PREFIX = xmlnode_
 PROTOTYPES: ENABLE
 
--- a/plugins/perl/perl-common.c	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/perl-common.c	Thu Aug 18 01:35:14 2005 +0000
@@ -178,7 +178,7 @@
 	int count = 0, i, ret_value = 1;
 	SV *sv_args[argc];
 	STRLEN na;
-
+        PERL_SET_CONTEXT(my_perl);
 	/*
 	 * Set up the perl environment, push arguments onto the
 	 * perl stack, then call the given function
@@ -196,6 +196,7 @@
 	}
 
 	PUTBACK;
+        PERL_SET_CONTEXT(my_perl);
 	count = call_pv(function, G_EVAL | G_SCALAR);
 	SPAGAIN;
 
--- a/plugins/perl/perl.c	Wed Aug 17 21:42:28 2005 +0000
+++ b/plugins/perl/perl.c	Thu Aug 18 01:35:14 2005 +0000
@@ -33,7 +33,6 @@
 
 #undef PACKAGE
 
-
 #define group perl_group
 
 #ifdef _WIN32
@@ -175,6 +174,8 @@
 	};
 
 	my_perl = perl_alloc();
+        PERL_SET_CONTEXT(my_perl);
+	PL_perl_destruct_level = 1;
 	perl_construct(my_perl);
 #ifdef DEBUG
 	perl_parse(my_perl, xs_init, 4, perl_args, NULL);
@@ -186,7 +187,6 @@
 #else
 	perl_eval_pv(perl_definitions, TRUE); /* deprecated */
 #endif
-
 	perl_run(my_perl);
 }
 
@@ -195,7 +195,9 @@
 {
 	if (my_perl == NULL)
 		return;
-
+	
+	PL_perl_destruct_level = 1;
+        PERL_SET_CONTEXT(my_perl);
 	perl_eval_pv(
 		"foreach my $lib (@DynaLoader::dl_modules) {"
 		  "if ($lib =~ /^Gaim\\b/) {"
@@ -205,6 +207,8 @@
 		"}",
 		TRUE);
 
+	PL_perl_destruct_level = 1;
+        PERL_SET_CONTEXT(my_perl);
 	perl_destruct(my_perl);
 	perl_free(my_perl);
 	my_perl = NULL;
@@ -226,13 +230,17 @@
 {
 	/* XXX This would be much faster if I didn't create a new
 	 *     PerlInterpreter every time I probed a plugin */
+	
 	PerlInterpreter *prober = perl_alloc();
 	char *argv[] = {"", plugin->path };
 	gboolean status = TRUE;
 	HV *plugin_info;
-
+        PERL_SET_CONTEXT(prober);
+	PL_perl_destruct_level = 1;
 	perl_construct(prober);
+
 	perl_parse(prober, xs_init, 2, argv, NULL);
+
 	perl_run(prober);
 
 	plugin_info = perl_get_hv("PLUGIN_INFO", FALSE);
@@ -367,9 +375,10 @@
 		}
 	}
 	
+	PL_perl_destruct_level = 1;
+        PERL_SET_CONTEXT(prober);
 	perl_destruct(prober);
 	perl_free(prober);
-
 	return status;
 }
 
@@ -390,10 +399,12 @@
 	plugin->handle = gps;
 
 	atmp[1] = gps->package;
-
+	
+        PERL_SET_CONTEXT(my_perl);
 	execute_perl("Gaim::PerlLoader::load_n_eval", 2, atmp);
 
 	{
+		PERL_SET_CONTEXT(my_perl);
 		dSP;
 		ENTER;
 		SAVETMPS;
@@ -423,6 +434,7 @@
 static void
 destroy_package(const char *package)
 {
+        PERL_SET_CONTEXT(my_perl);
 	dSP;
 
 	ENTER;
@@ -454,6 +466,7 @@
 
 	if (gps->unload_sub != NULL)
 	{
+        	PERL_SET_CONTEXT(my_perl);
 		dSP;
 		ENTER;
 		SAVETMPS;