changeset 12340:11d14efe7be2

[gaim-migrate @ 14644] sf patch #1373208, from Will Thompson "In Perl, we have Gaim::Conversation objects. However, all the functions that take Gaim::Conversations as the first argument are in the Gaim::Conv package. This makes the following not work: my $conv = Gaim::Conv::new(); $conv->get_features(); Instead, one has to do the following: my $conv = Gaim::Conv::new(); Gaim::Conv::get_features($conv);" committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 05 Dec 2005 03:53:00 +0000
parents fdac1c5e6c68
children eea31c8cc9f7
files doc/PERL-HOWTO.dox plugins/perl/common/Conversation.xs plugins/perl/common/Gaim.xs plugins/perl/scripts/conversation.pl
diffstat 4 files changed, 115 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/doc/PERL-HOWTO.dox	Mon Dec 05 03:42:48 2005 +0000
+++ b/doc/PERL-HOWTO.dox	Mon Dec 05 03:53:00 2005 +0000
@@ -172,66 +172,83 @@
 
 @section conv-api Conversation API
 
-The Gaim perl API for @c gaim_conversation_ and @c gaim_conv_window_ allow plugins to interact with open conversations, create new conversations, and modify conversations at will.  The following example again replaces the @c plugin_load subroutine.  In the example script, a new window is created, displayed and a new conversation instant message is created.  The @c Gaim::Conv::Chat package handles the @c gaim_conv_chat_ portion of the API very similarly to the examples that follow.   
+The Gaim perl API for @c gaim_conversation_ and @c gaim_conv_window_ allow
+plugins to interact with open conversations, create new conversations, and
+modify conversations at will.  The following example again replaces the @c
+plugin_load subroutine.  In the example script, a new window is created,
+displayed and a new conversation instant message is created.  The @c
+Gaim::Conversation::Chat package handles the @c gaim_conv_chat_ portion of the
+API very similarly to the examples that follow.   
 
 @code
 sub plugin_load {
-        my $plugin = shift;
-        my $protocol = "prpl-oscar";
+	my $plugin = shift;
+	my $protocol = "prpl-oscar";
 
-        $account = Gaim::Accounts::find("USERNAME", $protocol);
+	$account = Gaim::Accounts::find("USERNAME", $protocol);
 
 	# First we create two new conversations.
-        print "Testing Gaim::Conv::new()...";
-        $conv1 = Gaim::Conv::new(1, $account, "Test Conv. 1");
-        if ($conv1) { print "ok.\n"; } else { print "fail.\n"; }
+	print "Testing Gaim::Conversation::new()...";
+	$conv1 = Gaim::Conversation::new(1, $account, "Test Conversation 1");
+	if ($conv1) { print "ok.\n"; } else { print "fail.\n"; }
 
-        print "Testing Gaim::Conv::new()...";
-        $conv2 = Gaim::Conv::new(1, $account, "Test Conv. 2");
-        if ($conv2) { print "ok.\n"; } else { print "fail.\n"; }
+	print "Testing Gaim::Conversation::new()...";
+	$conv2 = Gaim::Conversation::new(1, $account, "Test Conversation 2");
+	if ($conv2) { print "ok.\n"; } else { print "fail.\n"; }
 	
 	# Second we create a window to display the conversations in.
-	#  Note that the package here is Gaim::Conv::Window
-        print "Testing Gaim::Conv::Window::new()...\n";
-        $win = Gaim::Conv::Window::new();
+	#  Note that the package here is Gaim::Conversation::Window
+	print "Testing Gaim::Conversation::Window::new()...\n";
+	$win = Gaim::Conversation::Window::new();
 
 	# The third thing to do is to add the two conversations to the windows.
-	#  The subroutine add_conversation() returns the number of conversations present in the window.
-        print "Testing Gaim::Conv::Window::add_conversation()...";
-        $conv_count = Gaim::Conv::Window::add_conversation($win, $conv1);
-        if ($conv_count) { print "ok..." . $conv_count . " conversations...\n"; } else { print "fail.\n"; }
+	# The subroutine add_conversation() returns the number of conversations
+	# present in the window.
+	print "Testing Gaim::Conversation::Window::add_conversation()...";
+	$conv_count = $conv1->add_conversation();
+	if ($conv_count) { 
+		print "ok..." . $conv_count . " conversations...\n";
+	} else {
+		print "fail.\n";
+	}
 
-        print "Testing Gaim::Conv::Window::add_conversation()...";
-        $conv_count = Gaim::Conv::Window::add_conversation($win, $conv2);
-        if ($conv_count) { print "ok..." . $conv_count . " conversations...\n"; } else { print "fail.\n"; }
+	print "Testing Gaim::Conversation::Window::add_conversation()...";
+	$conv_count = $win->add_conversation($conv2);
+	if ($conv_count) {
+		print "ok..." . $conv_count . " conversations...\n";
+	} else {
+		print "fail.\n";
+	}
 
 	# Now the window is displayed to the user.
-        print "Testing Gaim::Conv::Window::show()...\n";
-        Gaim::Conv::Window::show($win);
+	print "Testing Gaim::Conversation::Window::show()...\n";
+	$win->show();
 
-	# Use Gaim::Conv::get_im_data to get a handle for the conversation	
-        print "Testing Gaim::Conv::get_im_data()...\n";
-        $im = Gaim::Conv::get_im_data($conv1);
-        if ($im) { print "ok.\n"; } else { print "fail.\n"; }
+	# Use get_im_data() to get a handle for the conversation	
+	print "Testing Gaim::Conversation::get_im_data()...\n";
+	$im = $conv1->get_im_data();
+	if ($im) { print "ok.\n"; } else { print "fail.\n"; }
 
 	# Here we send messages to the conversation
-        print "Testing Gaim::Conv::IM::send()...\n";
-        Gaim::Conv::IM::send($im, "Message Test.");
+	print "Testing Gaim::Conversation::IM::send()...\n";
+	$im->send("Message Test.");
 
-        print "Testing Gaim::Conv::IM::write()...\n";
-        Gaim::Conv::IM::write($im, "SENDER", "<b>Message</b> Test.", 0, 0);
+	print "Testing Gaim::Conversation::IM::write()...\n";
+	$im->write("SENDER", "<b>Message</b> Test.", 0, 0);
 }
 @endcode
 
-The next block of code shows how a script can close a known conversation window @c $win.
+The next block of code shows how a script can close a known conversation window
+@c $win.
 
 @code
-        print "Testing Gaim::Conv::Window::get_conversation_count()...\n";
-        $conv_count = Gaim::Conv::Window::get_conversation_count($win);
-        if ($conv_count > 0) {
-                print "Testing Gaim::Conv::Window::destroy()...\n";
-                Gaim::Conv::Window::destroy($win);
-        }
+	print "Testing Gaim::Conversation::Window::get_conversation_count()...\n";
+	$conv_count = $win->get_conversation_count();
+	print "...and it returned $conv_count.\n";
+	if ($conv_count > 0) {
+	        print "Testing Gaim::Conversation::Window::destroy()...\n";
+	        $win->destroy();
+	}
 @endcode
 
 @section plugin-pref-api Plugin Preference and Gtk Preference API
--- a/plugins/perl/common/Conversation.xs	Mon Dec 05 03:42:48 2005 +0000
+++ b/plugins/perl/common/Conversation.xs	Mon Dec 05 03:53:00 2005 +0000
@@ -1,6 +1,6 @@
 #include "module.h"
 
-MODULE = Gaim::Conv  PACKAGE = Gaim::Conv  PREFIX = gaim_conversation_
+MODULE = Gaim::Conversation  PACKAGE = Gaim::Conversation  PREFIX = gaim_conversation_
 PROTOTYPES: ENABLE
 
 void *
@@ -136,7 +136,7 @@
 
 
 
-MODULE = Gaim::Conv  PACKAGE = Gaim::Conv::IM  PREFIX = gaim_conv_im_
+MODULE = Gaim::Conversation  PACKAGE = Gaim::Conversation::IM  PREFIX = gaim_conv_im_
 PROTOTYPES: ENABLE
 
 Gaim::Conversation
@@ -215,7 +215,7 @@
 	time_t mtime
 
 
-MODULE = Gaim::Conv  PACKAGE = Gaim::Conv  PREFIX = gaim_conv_
+MODULE = Gaim::Conversation  PACKAGE = Gaim::Conversation  PREFIX = gaim_conv_
 PROTOTYPES: ENABLE
 
 gboolean
@@ -234,7 +234,7 @@
 
 
 
-MODULE = Gaim::Conv  PACKAGE = Gaim::Conv::Chat  PREFIX = gaim_conv_chat_
+MODULE = Gaim::Conversation  PACKAGE = Gaim::Conversation::Chat  PREFIX = gaim_conv_chat_
 PROTOTYPES: ENABLE
 
 Gaim::Conversation
--- a/plugins/perl/common/Gaim.xs	Mon Dec 05 03:42:48 2005 +0000
+++ b/plugins/perl/common/Gaim.xs	Mon Dec 05 03:53:00 2005 +0000
@@ -89,7 +89,7 @@
 	GAIM_PERL_BOOT(Cipher);
 	GAIM_PERL_BOOT(Cmds);
 	GAIM_PERL_BOOT(Connection);
-	GAIM_PERL_BOOT(Conv);
+	GAIM_PERL_BOOT(Conversation);
 	GAIM_PERL_BOOT(Xfer);
 	GAIM_PERL_BOOT(ImgStore);
 	GAIM_PERL_BOOT(Log);
--- a/plugins/perl/scripts/conversation.pl	Mon Dec 05 03:42:48 2005 +0000
+++ b/plugins/perl/scripts/conversation.pl	Mon Dec 05 03:53:00 2005 +0000
@@ -5,10 +5,15 @@
 # All the information Gaim gets about our nifty plugin
 %PLUGIN_INFO = ( 
 	perl_api_version => 2, 
-	name => " Perl: $MODULE_NAME", 
+	name => "Perl: $MODULE_NAME", 
 	version => "0.1", 
 	summary => "Test plugin for the Perl interpreter.", 
-	description => "Implements a set of test proccedures to ensure all functions that work in the C API still work in the Perl plugin interface.  As XSUBs are added, this *should* be updated to test the changes.  Furthermore, this will function as the tutorial perl plugin.", 
+	description => "Implements a set of test proccedures to ensure all " .
+	               "functions that work in the C API still work in the " .
+		       "Perl plugin interface.  As XSUBs are added, this " .
+		       "*should* be updated to test the changes.  " .
+		       "Furthermore, this will function as the tutorial perl " .
+		       "plugin.", 
 	author => "John H. Kelm <johnhkelm\@gmail.com>", 
 	url => "http://sourceforge.net/users/johnhkelm/", 
 	
@@ -43,37 +48,54 @@
 	$account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID);
 	
 	#########  TEST CODE HERE  ##########
-	print "Testing Gaim::Conv::new()...";
-	$conv1 = Gaim::Conv::new(1, $account, "Test Conv. 1");
-	if ($conv) { print "ok.\n"; } else { print "fail.\n"; }
+	# First we create two new conversations.
+	print "Testing Gaim::Conversation::new()...";
+	$conv1 = Gaim::Conversation::new(1, $account, "Test Conversation 1");
+	if ($conv1) { print "ok.\n"; } else { print "fail.\n"; }
 
-	print "Testing Gaim::Conv::new()...";
-	$conv2 = Gaim::Conv::new(1, $account, "Test Conv. 2");
-	if ($conv) { print "ok.\n"; } else { print "fail.\n"; }
+	print "Testing Gaim::Conversation::new()...";
+	$conv2 = Gaim::Conversation::new(1, $account, "Test Conversation 2");
+	if ($conv2) { print "ok.\n"; } else { print "fail.\n"; }
 	
-	print "Testing Gaim::Conv::Window::new()...\n";
-	$win = Gaim::Conv::Window::new();	
-	
-	print "Testing Gaim::Conv::Window::add_conversation()...";
-	$conv_count = Gaim::Conv::Window::add_conversation($win, $conv1);
-	if ($conv_count) { print "ok..." . $conv_count . " conversations...\n"; } else { print "fail.\n"; }
+	# Second we create a window to display the conversations in.
+	#  Note that the package here is Gaim::Conversation::Window
+	print "Testing Gaim::Conversation::Window::new()...\n";
+	$win = Gaim::Conversation::Window::new();
 
-	print "Testing Gaim::Conv::Window::add_conversation()...";
-	$conv_count = Gaim::Conv::Window::add_conversation($win, $conv2);
-	if ($conv_count) { print "ok..." . $conv_count . " conversations...\n"; } else { print "fail.\n"; }
-	
-	print "Testing Gaim::Conv::Window::show()...\n";
-	Gaim::Conv::Window::show($win);
-	
-	print "Testing Gaim::Conv::get_im_data()...\n";
-	$im = Gaim::Conv::get_im_data($conv1);	
+	# The third thing to do is to add the two conversations to the windows.
+	# The subroutine add_conversation() returns the number of conversations
+	# present in the window.
+	print "Testing Gaim::Conversation::Window::add_conversation()...";
+	$conv_count = $conv1->add_conversation();
+	if ($conv_count) { 
+		print "ok..." . $conv_count . " conversations...\n";
+	} else {
+		print "fail.\n";
+	}
+
+	print "Testing Gaim::Conversation::Window::add_conversation()...";
+	$conv_count = $win->add_conversation($conv2);
+	if ($conv_count) {
+		print "ok..." . $conv_count . " conversations...\n";
+	} else {
+		print "fail.\n";
+	}
+
+	# Now the window is displayed to the user.
+	print "Testing Gaim::Conversation::Window::show()...\n";
+	$win->show();
+
+	# Use get_im_data() to get a handle for the conversation	
+	print "Testing Gaim::Conversation::get_im_data()...\n";
+	$im = $conv1->get_im_data();
 	if ($im) { print "ok.\n"; } else { print "fail.\n"; }
-	
-	print "Testing Gaim::Conv::IM::send()...\n";
-	Gaim::Conv::IM::send($im, "Message Test.");
-	
-	print "Testing Gaim::Conv::IM::write()...\n";
-	Gaim::Conv::IM::write($im, "sendingUser", "<b>Message</b> Test.", 0, 0);
+
+	# Here we send messages to the conversation
+	print "Testing Gaim::Conversation::IM::send()...\n";
+	$im->send("Message Test.");
+
+	print "Testing Gaim::Conversation::IM::write()...\n";
+	$im->write("SENDER", "<b>Message</b> Test.", 0, 0);
 	
 	print "#" x 80 . "\n\n";
 } 
@@ -84,14 +106,12 @@
 	print "#" x 80 . "\n\n";
 	#########  TEST CODE HERE  ##########
 
-
-	
-	print "Testing Gaim::Conv::Window::get_conversation_count()...\n";
-	$conv_count = Gaim::Conv::Window::get_conversation_count($win);
-	print $conv_count;
+	print "Testing Gaim::Conversation::Window::get_conversation_count()...\n";
+	$conv_count = $win->get_conversation_count();
+	print "...and it returned $conv_count.\n";
 	if ($conv_count > 0) {
-		print "Testing Gaim::Conv::Window::destroy()...\n";
-		Gaim::Conv::Window::destroy($win);
+	        print "Testing Gaim::Conversation::Window::destroy()...\n";
+	        $win->destroy();
 	}
 	
 	print "\n\n" . "#" x 80 . "\n\n";