view plugins/perl/scripts/conversation.pl @ 12600:e856f985a0b9

[gaim-migrate @ 14934] Enable the extra warnings regardless of --enable-debug. Enable FORTIFY_SOURCE regardless of --enable-debug, adding a --disable-fortify flag to configure. Enable (well, stop disabling) the missing initializer warnings. This leads to warnings with: GValue v = {0,}; that must be worked around. Basically, instead of: GValue v = {0,}; ... g_value_init(&v, G_TYPE_FOO); /* or other use of the GValue */ We'd need to do: GValue v; ... v.g_type = 0; g_value_init(&v, G_TYPE_FOO); /* or other use of the GValue */ Fix several cases of missing initializers. I don't think any of these are bugs, but having this warning seems like a good idea. It might prevent us from making a mistake in the future. While I was fixing missing initializers, I optimized substitute_simple_word in plugins/spellchk.c, in the same way as I did substitute_word before. Yes, I'm bad for committing these together. Added a --enable-fatal-asserts flag to configure. As the name implies, this makes g_return_... guards fatal. This is a useful flag to run on a debug copy of Gaim. It will make it very clear if your changes have triggered one of these guards. It's also useful in detecting g_return_... abuse, which helps prevent crashes if Gaim is compiled with G_DISABLE_ASSERT defined. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 21 Dec 2005 18:36:19 +0000
parents 6fd82071a7b8
children
line wrap: on
line source

$MODULE_NAME = "Conversation Test";

use Gaim;

# All the information Gaim gets about our nifty plugin
%PLUGIN_INFO = ( 
	perl_api_version => 2, 
	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.", 
	author => "John H. Kelm <johnhkelm\@gmail.com>", 
	url => "http://sourceforge.net/users/johnhkelm/", 
	
	load => "plugin_load", 
	unload => "plugin_unload" 
); 


	# These names must already exist
	my $GROUP		= "UIUC Buddies";
	my $USERNAME 		= "johnhkelm2";
	
	# We will create these on load then destroy them on unload
	my $TEST_GROUP		= "UConn Buddies";
	my $TEST_NAME	 	= "johnhkelm";
	my $TEST_ALIAS	 	= "John Kelm";
	my $PROTOCOL_ID 	= "prpl-oscar";


sub plugin_init { 
	return %PLUGIN_INFO; 
} 


# This is the sub defined in %PLUGIN_INFO to be called when the plugin is loaded
#	Note: The plugin has a reference to itself on top of the argument stack.
sub plugin_load { 
	my $plugin = shift; 
	print "#" x 80 . "\n\n";

	print "PERL: Finding account.\n";
	$account = Gaim::Accounts::find($USERNAME, $PROTOCOL_ID);
	
	#########  TEST CODE HERE  ##########
	# 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::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::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::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"; }

	# 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";
} 

sub plugin_unload { 
	my $plugin = shift; 

	print "#" x 80 . "\n\n";
	#########  TEST CODE HERE  ##########

	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();
	}
	
	print "\n\n" . "#" x 80 . "\n\n";
}