GAIM Plugins aren't too hard to write; for the basic skeleton, look at the simple.c file in the plugins directory of the GAIM source distribution. This write-up aims to provide enough basic information to make gaim plugin writing just a little easier to get into for someone with moderate programming skills. One of the easier things you can do with a GAIM plugin is modify the text of a message. To do so, you'll need to modify the plugin_load function, kinda like this:

static gboolean
plugin_load(GaimPlugin *plugin)
{
	gaim_debug(GAIM_DEBUG_INFO, "E2New-Plug", "E2New-Plugin loaded.\n");

	void *conv_handle = gaim_conversations_get_handle();

	gaim_signal_connect(conv_handle, "displaying-im-msg",
						plugin, GAIM_CALLBACK(parse_e2), NULL);
	gaim_signal_connect(conv_handle, "displaying-chat-msg",
						plugin, GAIM_CALLBACK(parse_e2), NULL);


	return TRUE;
}

Now, when a message is sent, the text of the message will first get passed to the function "parse_e2". This function should look about like this:


static gboolean parse_e2(GaimAccount *account, GaimConversation *conv, char **message, void *data){

  char *msg=*message;
  int start_link=-1,end_link=-2,i=0,len=0;
  gboolean in_link=FALSE;
  

  gaim_debug(GAIM_DEBUG_INFO, "E2New-Plug", "Starting to parse the message\n");

...

  gaim_debug(GAIM_DEBUG_INFO, "E2New-Plug", "Done...\n");  

  *message=msg; 

  return FALSE;
}

This is part of the GAIM Everything2 plugin. In this particular example, modify the *msg pointer, and you'll be modifying the text of the message. Generally, you'll want to parse the text, find something you're looking for, ie, square brackets, then allocate a new message buffer, and write out the changes. In the case of this plugin, it looked for square brackets, pulled out what was in between, and then built a new message with that portion replaced by a link to the appropriate Everything2 node.

That's pretty much it! There's obviously a lot more you can do with them; check the various gaim headers. gtkutils.h, and utils.h have some useful function prototypes in them. Unfortunately, the GAIM website doesn't have the API thoroughly documented yet. Also be sure to check out the info struct in simple.c to set some other useful things.