changeset 11123:4315bb5f427b

[gaim-migrate @ 13179] Time to make perl start working again committer: Tailor Script <tailor@pidgin.im>
author John H. Kelm <johnkelm@gmail.com>
date Mon, 18 Jul 2005 16:27:53 +0000
parents 59a4bc5c24e5
children 00a2a480fc0c
files plugins/perl/Makefile.am plugins/perl/common/Conversation.xs plugins/perl/perl-handlers.c plugins/perl/perl-handlers.h plugins/perl/perl.c
diffstat 5 files changed, 540 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/perl/Makefile.am	Mon Jul 18 15:49:12 2005 +0000
+++ b/plugins/perl/Makefile.am	Mon Jul 18 16:27:53 2005 +0000
@@ -2,10 +2,10 @@
 
 perl_dirs = common
 
-plugin_LTLIBRARIES = perl.la
+plugin_LTLIBRARIES = perl.la 
 
 perl_la_LDFLAGS = -module -avoid-version $(GLIB_LIBS) $(PERL_LIBS)
-perl_la_LIBADD = $(PERL_LIBS)
+perl_la_LIBADD = $(PERL_LIBS) -L. -lgaimperl
 perl_la_SOURCES = \
 	perl.c \
 	perl-common.c \
@@ -15,7 +15,11 @@
 
 perl_la_DEPENDENCIES = \
 	.libs/libperl_orig.a \
-	.libs/DynaLoader.a
+	.libs/DynaLoader.a \
+	libgaimperl.so
+
+libgaimperl.so:
+	$(CC) -shared -fPIC -olibgaimperl.so libgaimperl.c	
 
 .libs/libperl_orig.a:
 	@mkdir -p .libs
@@ -35,24 +39,45 @@
 		$(LN_S) $(DYNALOADER_A) .libs/DynaLoader.a; \
 	fi
 
+
 common_sources = \
-	common/fallback/const-c.inc \
-	common/fallback/const-xs.inc \
-	common/Account.xs \
-	common/BuddyList.xs \
-	common/BuddyList_Buddy.xs \
-	common/BuddyList_Chat.xs \
-	common/BuddyList_Group.xs \
-	common/Connection.xs \
-	common/ConvWindow.xs \
-	common/Conversation.xs \
-	common/Conversation_Chat.xs \
-	common/Conversation_IM.xs \
-	common/Gaim.xs \
-	common/Gaim.pm \
-	common/Makefile.PL.in \
-	common/typemap \
-	common/module.h
+        common/Account.xs \
+        common/AccountOpts.xs \
+        common/BuddyIcon.xs \
+        common/BuddyList.xs \
+        common/Cipher.xs \
+        common/Cmds.xs \
+        common/Connection.xs \
+        common/Conversation.xs \
+        common/FT.xs \
+        common/Gaim.pm \
+        common/Gaim.xs \
+        common/ImgStore.xs \
+        common/Log.xs \
+        common/Makefile.PL.in \
+        common/Network.xs \
+        common/Notify.xs \
+        common/Plugin.xs \
+        common/PluginPref.xs \
+        common/Pounce.xs \
+        common/Prefs.xs \
+        common/Privacy.xs \
+        common/Proxy.xs \
+        common/Prpl.xs \
+        common/Request.xs \
+        common/Roomlist.xs \
+        common/SSLConn.xs \
+        common/SavedStatuses.xs \
+        common/Server.xs \
+        common/Sound.xs \
+        common/Status.xs \
+        common/Stringref.xs \
+        common/Util.xs \
+        common/XMLNode.xs \
+        common/fallback/const-c.inc \
+        common/fallback/const-xs.inc \
+        common/module.h \
+        common/typemap
 
 
 EXTRA_DIST = \
@@ -88,6 +113,7 @@
 		$(MAKE) install; \
 		cd ..; \
 	done
+	cp libgaimperl.so $(libdir)
 
 # Evil Hack (TM)
 uninstall-local:
@@ -103,6 +129,7 @@
 		$(MAKE) clean; \
 		cd ..; \
 	done
+	rm *.so
 
 distclean-generic:
 	@for dir in $(perl_dirs); do \
--- a/plugins/perl/common/Conversation.xs	Mon Jul 18 15:49:12 2005 +0000
+++ b/plugins/perl/common/Conversation.xs	Mon Jul 18 16:27:53 2005 +0000
@@ -1,12 +1,151 @@
 #include "module.h"
 
-MODULE = Gaim::Conversation  PACKAGE = Gaim::Conversation  PREFIX = gaim_conversation_
+/**********************XS Code for Conversation.xs*********************************/
+MODULE = Gaim::Conv  PACKAGE = Gaim::Conv::Window  PREFIX = gaim_conv_window_
 PROTOTYPES: ENABLE
 
+void 
+gaim_conversations_set_win_ui_ops(ops)
+	Gaim::ConvWindow::UiOps ops
+
+Gaim::ConvWindow::UiOps
+gaim_conversations_get_win_ui_ops()
+
 void
-gaim_conversation_set_account(conv, account)
+gaim_conv_window_get_conversations(win)
+	Gaim::ConvWindow win
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_conv_window_get_conversations(win); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+Gaim::ConvWindow
+gaim_conv_window_new()
+
+void 
+gaim_conv_window_destroy(win)
+	Gaim::ConvWindow win
+
+void 
+gaim_conv_window_show(win)
+	Gaim::ConvWindow win
+
+void 
+gaim_conv_window_hide(win)
+	Gaim::ConvWindow win
+
+void 
+gaim_conv_window_raise(win)
+	Gaim::ConvWindow win
+
+size_t 
+gaim_conv_window_get_conversation_count(win)
+	Gaim::ConvWindow win
+
+gboolean 
+gaim_conv_window_has_focus(win)
+	Gaim::ConvWindow win
+
+Gaim::ConvWindow::UiOps
+gaim_conv_window_get_ui_ops(win)
+	Gaim::ConvWindow win
+
+Gaim::ConvWindow
+get_first_window_with_type(type)
+	Gaim::ConversationType type
+CODE:
+	RETVAL = gaim_get_first_window_with_type(type);
+OUTPUT:
+	RETVAL
+
+Gaim::ConvWindow
+get_last_window_with_type(type)
+	Gaim::ConversationType type
+CODE:
+	RETVAL = gaim_get_last_window_with_type(type);
+OUTPUT:
+	RETVAL
+
+
+
+
+MODULE = Gaim::Conv  PACKAGE = Gaim::Conv  PREFIX = gaim_conversation_
+PROTOTYPES: ENABLE
+
+void *
+gaim_conversations_get_handle()
+
+void 
+gaim_conversations_init()
+
+void 
+gaim_conversations_uninit()
+
+void
+gaim_conv_placement_get_options()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_conv_placement_get_options(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+
+void
+get_ims()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_get_ims(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void
+get_conversations()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_get_conversations(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void
+get_windows()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_get_windows(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void
+get_chats()
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_get_chats(); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void
+gaim_conversation_get_send_history(conv)
 	Gaim::Conversation conv
-	Gaim::Account account
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_conversation_get_send_history(conv); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void 
+gaim_conversation_destroy(conv)
+	Gaim::Conversation conv
+
+Gaim::ConversationType 
+gaim_conversation_get_type(conv)
+	Gaim::Conversation conv
 
 Gaim::Account
 gaim_conversation_get_account(conv)
@@ -16,68 +155,46 @@
 gaim_conversation_get_gc(conv)
 	Gaim::Conversation conv
 
-void
-gaim_conversation_set_title(conv, title)
+void 
+gaim_conversation_set_title(conv, title);
 	Gaim::Conversation conv
-	const char *title
+	const char * title
 
-void
+const char *
+gaim_conversation_get_title(conv)
+	Gaim::Conversation conv
+
+void 
 gaim_conversation_autoset_title(conv)
 	Gaim::Conversation conv
 
+Gaim::UnseenState 
+gaim_conversation_get_unseen(conv)
+	Gaim::Conversation conv
+
+void 
+gaim_conversation_set_name(conv, name)
+	Gaim::Conversation conv
+	const char *name
+
 const char *
 gaim_conversation_get_name(conv)
 	Gaim::Conversation conv
-
-void
+	
+void 
 gaim_conversation_set_logging(conv, log)
 	Gaim::Conversation conv
 	gboolean log
 
-gboolean
+gboolean 
 gaim_conversation_is_logging(conv)
 	Gaim::Conversation conv
 
+
 Gaim::ConvWindow
 gaim_conversation_get_window(conv)
 	Gaim::Conversation conv
 
-gboolean
-is_chat(conv)
-	Gaim::Conversation conv
-CODE:
-	RETVAL = (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT);
-OUTPUT:
-	RETVAL
-
-gboolean
-is_im(conv)
-	Gaim::Conversation conv
-CODE:
-	RETVAL = (gaim_conversation_get_type(conv) == GAIM_CONV_IM);
-OUTPUT:
-	RETVAL
-
-void
-gaim_conversation_set_data(conv, key, data)
-	Gaim::Conversation conv
-	const char *key
-	void *data
-
-void *
-gaim_conversation_get_data(conv, key)
-	Gaim::Conversation conv
-	const char *key
-
-void
-gaim_conversation_write(conv, who, message, flags)
-	Gaim::Conversation conv
-	const char *who
-	const char *message
-	int flags
-CODE:
-	gaim_conversation_write(conv, who, message, flags, time(NULL));
-
 Gaim::Conversation::IM
 gaim_conversation_get_im_data(conv)
 	Gaim::Conversation conv
@@ -86,37 +203,288 @@
 gaim_conversation_get_chat_data(conv)
 	Gaim::Conversation conv
 
+gpointer 
+gaim_conversation_get_data(conv, key)
+	Gaim::Conversation conv
+	const char * key
 
-MODULE = Gaim::Conversation  PACKAGE = Gaim::Conversations  PREFIX = gaim_conversations_
+Gaim::ConnectionFlags 
+gaim_conversation_get_features(conv)
+	Gaim::Conversation conv
+
+void 
+gaim_conversation_update_progress(conv, percent)
+	Gaim::Conversation conv
+	float percent
+	
+gboolean 
+gaim_conversation_has_focus(conv)
+	Gaim::Conversation conv
+
+void 
+gaim_conversation_update(conv, type)
+	Gaim::Conversation conv
+	Gaim::ConvUpdateType type
+
+
+
+
+
+MODULE = Gaim::Conv  PACKAGE = Gaim::Conv::IM  PREFIX = gaim_conv_im_
+PROTOTYPES: ENABLE
+
+Gaim::Conversation
+gaim_conv_im_get_conversation(im)
+	Gaim::Conversation::IM im
+
+void 
+gaim_conv_im_set_icon(im, icon)
+	Gaim::Conversation::IM im
+	Gaim::Buddy::Icon icon
+
+Gaim::Buddy::Icon
+gaim_conv_im_get_icon(im)
+	Gaim::Conversation::IM im
+
+void 
+gaim_conv_im_set_typing_state(im, state)
+	Gaim::Conversation::IM im
+	Gaim::TypingState state
+
+Gaim::TypingState 
+gaim_conv_im_get_typing_state(im)
+	Gaim::Conversation::IM im
+
+void 
+gaim_conv_im_start_typing_timeout(im, timeout)
+	Gaim::Conversation::IM im
+	int timeout
+
+void 
+gaim_conv_im_stop_typing_timeout(im)
+	Gaim::Conversation::IM im
+
+guint 
+gaim_conv_im_get_typing_timeout(im)
+	Gaim::Conversation::IM im
+
+void 
+gaim_conv_im_set_type_again(im, val)
+	Gaim::Conversation::IM im
+	time_t val
+
+time_t
+gaim_conv_im_get_type_again(im)
+	Gaim::Conversation::IM im
+
+void 
+gaim_conv_im_start_type_again_timeout(im)
+	Gaim::Conversation::IM im
+
+void 
+gaim_conv_im_stop_type_again_timeout(im)
+	Gaim::Conversation::IM im
+
+guint 
+gaim_conv_im_get_type_again_timeout(im)
+	Gaim::Conversation::IM im
+
+
+void 
+gaim_conv_im_update_typing(im)
+	Gaim::Conversation::IM im
+
+
+void 
+gaim_conv_im_send(im, message)
+	Gaim::Conversation::IM im
+	const char *message
+
+
+
+
+
+
+MODULE = Gaim::Conv  PACKAGE = Gaim::Conv  PREFIX = gaim_conv_
+PROTOTYPES: ENABLE
+
+gboolean 
+gaim_conv_present_error(who, account, what)
+	const char *who
+	Gaim::Account account
+ 	const char *what
+
+void 
+gaim_conv_custom_smiley_close(conv, smile)
+	Gaim::Conversation conv
+	const char *smile
+
+
+
+
+
+
+MODULE = Gaim::Conv  PACKAGE = Gaim::Conv::Chat  PREFIX = gaim_conv_chat_
 PROTOTYPES: ENABLE
 
 Gaim::Conversation
-find_with_account(name, account)
-	const char *name
-	Gaim::Account account
-CODE:
-	RETVAL = gaim_find_conversation_with_account(GAIM_CONV_ANY, name, account);
-OUTPUT:
-	RETVAL
+gaim_conv_chat_get_conversation(chat)
+	Gaim::Conversation::Chat chat
 
-void *
-handle()
-CODE:
-	RETVAL = gaim_conversations_get_handle();
-OUTPUT:
-	RETVAL
+void
+gaim_conv_chat_set_users(chat, users)
+	Gaim::Conversation::Chat chat
+	SV * users
+PREINIT:
+	GList *l, *t_GL;
+	int i, t_len;
+PPCODE:
+	t_GL = NULL;
+	t_len = av_len((AV *)SvRV(users));
 
+	for (i = 0; i < t_len; i++) {
+		STRLEN t_sl;
+		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(users), i, 0), t_sl));
+	}
 
-MODULE = Gaim::Conversation  PACKAGE = Gaim  PREFIX = gaim_
-PROTOTYPES: ENABLE
+	for (l = gaim_conv_chat_set_users(chat, t_GL); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
 
 void
-conversations()
+gaim_conv_chat_get_users(chat)
+	Gaim::Conversation::Chat chat
+PREINIT:
+	GList *l;
+PPCODE:
+	for (l = gaim_conv_chat_get_users(chat); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void 
+gaim_conv_chat_ignore(chat, name)
+	Gaim::Conversation::Chat chat
+	const char *name
+
+void 
+gaim_conv_chat_unignore(chat, name)
+	Gaim::Conversation::Chat chat
+	const char *name
+
+void 
+gaim_conv_chat_set_ignored(chat, ignored)
+	Gaim::Conversation::Chat chat
+	SV * ignored
+PREINIT:
+	GList *l, *t_GL;
+	int i, t_len;
+PPCODE:
+	t_GL = NULL;
+	t_len = av_len((AV *)SvRV(ignored));
+
+	for (i = 0; i < t_len; i++) {
+		STRLEN t_sl;
+		t_GL = g_list_append(t_GL, SvPV(*av_fetch((AV *)SvRV(ignored), i, 0), t_sl));
+	}
+
+	for (l = gaim_conv_chat_set_ignored(chat, t_GL); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+void
+gaim_conv_chat_get_ignored(chat)
+	Gaim::Conversation::Chat chat
 PREINIT:
 	GList *l;
 PPCODE:
-	for (l = gaim_get_conversations(); l != NULL; l = l->next)
-	{
-		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data,
-			"Gaim::Conversation")));
+	for (l = gaim_conv_chat_get_ignored(chat); l != NULL; l = l->next) {
+		XPUSHs(sv_2mortal(gaim_perl_bless_object(l->data, "Gaim::ListEntry")));
+	}
+
+const char *
+gaim_conv_chat_get_topic(chat)
+	Gaim::Conversation::Chat chat
+
+
+
+void 
+gaim_conv_chat_set_id(chat, id)
+	Gaim::Conversation::Chat chat
+	int id
+
+int 
+gaim_conv_chat_get_id(chat)
+	Gaim::Conversation::Chat chat
+
+void 
+gaim_conv_chat_send(chat, message)
+	Gaim::Conversation::Chat chat
+	const char * message
+
+void 
+gaim_conv_chat_add_users(chat, users, flags)
+	Gaim::Conversation::Chat chat
+	SV * users
+	SV * flags
+PREINIT:
+	GList *t_GL_users, *t_GL_flags;
+	int i, t_len;
+PPCODE:
+	t_GL_users = NULL;
+	t_len = av_len((AV *)SvRV(users));
+
+	for (i = 0; i < t_len; i++) {
+		STRLEN t_sl;
+		t_GL_users = g_list_append(t_GL_users, SvPV(*av_fetch((AV *)SvRV(users), i, 0), t_sl));
 	}
+
+	t_GL_flags = NULL;
+	t_len = av_len((AV *)SvRV(flags));
+
+	for (i = 0; i < t_len; i++) {
+		STRLEN t_sl;
+		t_GL_flags = g_list_append(t_GL_flags, SvPV(*av_fetch((AV *)SvRV(flags), i, 0), t_sl));
+	}
+
+	gaim_conv_chat_add_users(chat, t_GL_users, t_GL_flags);
+	
+
+gboolean 
+gaim_conv_chat_find_user(chat, user)
+	Gaim::Conversation::Chat chat
+	const char * user
+
+void gaim_conv_chat_clear_users(chat)
+	Gaim::Conversation::Chat chat
+
+void gaim_conv_chat_set_nick(chat, nick)
+	Gaim::Conversation::Chat chat
+	const char * nick
+
+const char *
+gaim_conv_chat_get_nick(chat)
+	Gaim::Conversation::Chat chat
+
+Gaim::Conversation
+gaim_find_chat(gc, id)
+	Gaim::Connection gc
+	int id
+
+void gaim_conv_chat_left(chat)
+	Gaim::Conversation::Chat chat
+
+gboolean gaim_conv_chat_has_left(chat)
+	Gaim::Conversation::Chat chat
+
+Gaim::Conversation::ChatBuddy
+gaim_conv_chat_cb_find(chat, name)
+	Gaim::Conversation::Chat chat
+	const char *name
+
+const char *
+gaim_conv_chat_cb_get_name(cb)
+	Gaim::Conversation::ChatBuddy cb
+
+void 
+gaim_conv_chat_cb_destroy(cb);
+	Gaim::Conversation::ChatBuddy cb
--- a/plugins/perl/perl-handlers.c	Mon Jul 18 15:49:12 2005 +0000
+++ b/plugins/perl/perl-handlers.c	Mon Jul 18 16:27:53 2005 +0000
@@ -6,8 +6,56 @@
 
 static GList *timeout_handlers = NULL;
 static GList *signal_handlers = NULL;
+static char *perl_plugin_pref_cb;
+extern PerlInterpreter *my_perl;
 
-extern PerlInterpreter *my_perl;
+
+/* Called to create a pointer to GaimPluginUiInfo for the GaimPluginInfo 	*/
+/*	It will then inturn create ui_info with the C function pointer 		*/
+/*	that will eventually do a call_pv to call a perl functions so users	*/
+/*	can create their own frames in the prefs				*/
+GaimPluginUiInfo *gaim_perl_plugin_pref(char * frame_cb) {
+	GaimPluginUiInfo *ui_info;
+	
+	ui_info = g_new0(GaimPluginUiInfo, 1);
+	
+	perl_plugin_pref_cb = frame_cb;
+	
+	ui_info->get_plugin_pref_frame = gaim_perl_get_plugin_frame;
+
+	return ui_info;
+}
+
+GaimPluginPrefFrame *gaim_perl_get_plugin_frame(GaimPlugin *plugin) {
+	/* Sets up the Perl Stack for our call back into the script to run the 	*/
+	/*	plugin_pref... sub						*/
+	GaimPluginPrefFrame *ret_frame;
+	dSP;
+	int count;
+
+	ENTER;
+	SAVETMPS;
+	/* Some perl magic to run perl_plugin_pref_frame_SV perl sub and return	*/
+	/* 	the frame							*/
+	PUSHMARK(SP);
+	PUTBACK;
+
+	count = call_pv(perl_plugin_pref_cb, G_SCALAR | G_NOARGS);
+
+	SPAGAIN;
+
+	if (count != 1)
+		croak("call_pv: Did not return the correct number of values.\n");
+	/* the frame was created in a perl sub and is returned */
+	ret_frame = (GaimPluginPrefFrame *)gaim_perl_ref_object(POPs);
+
+	/* Tidy up the Perl stack */
+	PUTBACK;
+	FREETMPS;
+	LEAVE;
+		
+	return ret_frame;
+}
 
 static void
 destroy_timeout_handler(GaimPerlTimeoutHandler *handler)
--- a/plugins/perl/perl-handlers.h	Mon Jul 18 15:49:12 2005 +0000
+++ b/plugins/perl/perl-handlers.h	Mon Jul 18 16:27:53 2005 +0000
@@ -2,6 +2,8 @@
 #define _GAIM_PERL_HANDLERS_H_
 
 #include "plugin.h"
+#include "prefs.h"
+#include "pluginpref.h"
 
 typedef struct
 {
@@ -22,6 +24,8 @@
 
 } GaimPerlSignalHandler;
 
+GaimPluginUiInfo *gaim_perl_plugin_pref(char * frame_cb);
+GaimPluginPrefFrame *gaim_perl_get_plugin_frame(GaimPlugin *plugin);
 
 void gaim_perl_timeout_add(GaimPlugin *plugin, int seconds, SV *callback,
 						   SV *data);
--- a/plugins/perl/perl.c	Mon Jul 18 15:49:12 2005 +0000
+++ b/plugins/perl/perl.c	Mon Jul 18 16:27:53 2005 +0000
@@ -334,6 +334,11 @@
 				gps->unload_sub = g_strdup_printf("%s::%s", gps->package,
 												  SvPV(*key, len));
 
+			if ((key = hv_fetch(plugin_info, "prefs_info", strlen("prefs_info"), 0))) {
+				/* key now is the name of the Perl sub that will create a frame for us */
+				info->prefs_info = gaim_perl_plugin_pref(g_strdup_printf("%s::%s", gps->package, SvPV(*key, len)));
+			}
+
 			plugin->info = info;
 			info->extra_info = gps;