org.guifications.plugins: aadb5b36b2c509098948f1c1ba52a67838026d45

grim at guifications.org grim at guifications.org
Wed Mar 26 23:05:06 CDT 2008


-----------------------------------------------------------------
Revision: aadb5b36b2c509098948f1c1ba52a67838026d45
Ancestor: be2023dd8045f0d7222c330f90a2fe38168830ed
Author: grim at guifications.org
Date: 2008-03-27T04:00:12
Branch: org.guifications.plugins

Added files:
        splitter/.incomplete splitter/.purple-plugin
        splitter/ChangeLog splitter/Makefile.am
        splitter/Makefile.mingw splitter/README splitter/splitter.c
Added directories:
        splitter
Modified files:
        configure.ac

ChangeLog: 

Added Ike Gingerich's splitter plugin.

It still needs to be assimilated to fit our build system, but fixes #371


-----------------------------------------------------------------
This revision's diffstat output:
 configure.ac            |    1 
 splitter/ChangeLog      |   71 ++++++
 splitter/Makefile.am    |   26 ++
 splitter/Makefile.mingw |   12 +
 splitter/README         |   91 ++++++++
 splitter/splitter.c     |  533 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 734 insertions(+)
-------------- next part --------------
============================================================
--- splitter/.incomplete	da39a3ee5e6b4b0d3255bfef95601890afd80709
+++ splitter/.incomplete	da39a3ee5e6b4b0d3255bfef95601890afd80709
============================================================
--- splitter/.purple-plugin	da39a3ee5e6b4b0d3255bfef95601890afd80709
+++ splitter/.purple-plugin	da39a3ee5e6b4b0d3255bfef95601890afd80709
============================================================
--- splitter/ChangeLog	a6170fb6860cb00997e7c909fc47394c22b94e1a
+++ splitter/ChangeLog	a6170fb6860cb00997e7c909fc47394c22b94e1a
@@ -0,0 +1,71 @@
+splitter v0.95
+Ike Gingerich <ike_ at users.sourceforge.net>
+
+2007-05-04 21:21:15 [v0.95 for 2.0.0]
+
+	* trimmed a good amount of unnecessary code and made with the 
+	  gaim -> pidgin conversion.
+
+2006-04-15 15:55:10 [v0.95]
+
+	* now using Pango to split the message appropriately in different languages
+
+2006-04-13 20:33:07 [v0.93]
+
+	* fixed a bug where border characters were sometimes eaten as whitespace
+	* no longer processes empty slices
+
+2006-04-13 16:47:22 [v0.92]
+
+	* replaced html slicing algorithm with a modified version of Gaim's
+	* corrected a non-static function to be static
+	* internal refactoring
+
+2006-04-11 09:52:29 [v0.91]
+
+	* fixed a bug with escaped HTML characters counting for more than one
+	  character (thanks xx3nvyxx)
+
+2006-04-11 01:25:06 [v0.9]
+
+	* added continuing of HTML formatting between splits
+	* removed "split around whole words" option and made default behavior
+
+2005-10-04 23:39:59 [v0.8]
+
+	* fixed a tiny but lethal and frustrating crash related to word wrapping
+	  (big thanks to itchysoft_ant and mgilb81)
+	* added additional NULL pointer checking
+
+2005-09-23 18:37:24 [v0.7]
+
+	* chat support added
+
+2005-09-23 09:37:24 [v0.6]
+
+	* you can now specify delay between message sends
+
+2005-09-12 04:40:16 [v0.5]
+
+	* splits on whitespace where possible
+	* preferences option added to mediate splitting on whitespace
+
+2005-07-27 00:19:21 [v0.4]
+
+	* sends messages in the same manner as gaim:
+		- emits "sent-im-msg" signal
+		- takes into consideration HTML preferences
+	* much more robust error checking
+
+2005-07-22 07:44:06 [v0.3]
+
+	* big memory allocation bug fixed that could cause a crash in certain situations
+
+2005-07-21 20:29:44 [v0.2]
+
+	* alias is displayed in conversation window instead of username
+	  (thanks rageboy04)
+
+2005-07-21 03:50:14 [v0.1]
+
+	* initial release of plugin
============================================================
--- splitter/Makefile.am	27bebac3ca8cbbbf125e40704dd51fced34a7e55
+++ splitter/Makefile.am	27bebac3ca8cbbbf125e40704dd51fced34a7e55
@@ -0,0 +1,26 @@
+EXTRA_DIST = .purple-plugin .incomplete Makefile.mingw
+
+splitterdir = $(PURPLE_LIBDIR)
+
+splitter_la_LDFLAGS = -module -avoid-version
+
+if HAVE_PURPLE
+
+splitter_LTLIBRARIES = splitter.la
+
+splitter_la_SOURCES = \
+	splitter.c
+
+splitter_la_LIBADD = \
+	$(GLIB_LIBS) \
+	$(PURPLE_LIBS)
+
+endif
+
+AM_CPPFLAGS = \
+	-DLIBDIR=\"$(PURPLE_LIBDIR)\" \
+	-DDATADIR=\"$(PURPLE_DATADIR)\" \
+	-DPIXMAPSDIR=\"$(PURPLE_PIXMAPSDIR)\" \
+	$(DEBUG_CFLAGS) \
+	$(PURPLE_CFLAGS)
+
============================================================
--- splitter/Makefile.mingw	7e889c9e1f7a5f4faa9740b13d5d8d9ba92f487b
+++ splitter/Makefile.mingw	7e889c9e1f7a5f4faa9740b13d5d8d9ba92f487b
@@ -0,0 +1,12 @@
+#
+# Makefile.mingw
+#
+# Description: Makefile for dice plugin.
+#
+
+PP_TOP :=		..
+
+PP = splitter
+
+include $(PP_TOP)/win_pp.mak
+
============================================================
--- splitter/README	13392ba4e1e0e7d32164a0fbdb30660df46bbd4e
+++ splitter/README	13392ba4e1e0e7d32164a0fbdb30660df46bbd4e
@@ -0,0 +1,91 @@
+Message Splitter Plugin v0.95
+Ike Gingerich <ike_ at users.sourceforge.net>
+
+
+------------
+INTRODUCTION
+------------
+
+This is a simple plugin to split up outgoing messages that are larger
+than a specified threshold in characters.
+
+
+--------
+FEATURES
+--------
+
+ - The split size and delay between messages are configurable from the
+   plugin preferences menu.
+ - Splits yield valid and balanced HTML taking into account tags that may
+   have been opened or closed outside the split itself.
+ - Splitting is done using Pango to split the message as appropriate 
+   according to the current locale.
+
+
+----
+TODO
+----
+
+ - fix conflicts with plugins like Slashexec that don't expect to be 
+   supplied an empty message during the 'sending-im' signal.
+ - fix bug with characters disappearing when splitting heavily marked-up 
+   lines.
+ - find any remaining bugs and memory leaks.
+
+------------
+INSTALLATION
+------------
+
+ - *NIX users:
+	$ make install
+
+	If you have build problems make sure you have the 
+	appropriate pidgin-dev and build-essential files
+	installed.
+
+	Alternately you can copy spliter.c to
+	(unzipped-source)/pidgin/plugins and
+	after building Pidgin:
+
+	$ make splitter.so
+
+	then copy splitter.so to ~/.purple/plugins/ and launch Pidgin.
+
+
+ - Windows users:
+	I try to keep a pre-built current version of the plugin here:
+	<http://ikebo.hypermart.net/splitter/splitter-current.dll> and
+	on the Sourceforge message splitter plugin tracker.
+
+	Otherwise you must compile it manually with Cygwin:
+
+	        copy splitter.c to the plugin directory where the Pidgin
+		source code is extracted to and type:
+
+		$ make -f Makefile.mingw splitter.dll
+
+	and copy splitter.dll to your plugin directory
+	(e.x. C:\Program Files\Pidgin\plugins)
+
+
+------------
+CONTRIBUTORS
+------------
+
+xx3nvyxx - caught disappearing text bug in v0.9
+
+itchysoft_ant - isolated crash in v0.7 and submitted backtrace logs
+		suggested delay/chat features for v0.6/v0.7
+
+mgilb81 - notified of crash in v0.7 and filed report
+
+rageboy04 - a number of other issues/feedback throughout
+	  - notified/fixed alias issues for v0.2
+
+
+-------
+CONTACT
+-------
+
+Feel free to contact me at <ike_ at users.sourceforge.net> about problems,
+suggestions, or contributions.
============================================================
--- splitter/splitter.c	d152b0f1056dd7c274f3869c19c1878b170869b5
+++ splitter/splitter.c	d152b0f1056dd7c274f3869c19c1878b170869b5
@@ -0,0 +1,533 @@
+/* Message Splitter Plugin v0.95
+ *
+ * Splits a large message into smaller messages and sends them away
+ * in its place.
+ *
+ * Copyright (C) 2005-2007, Ike Gingerich <ike_ at users.sourceforge.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#define GETTEXT_PACKAGE "gtk20"
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#include <string.h>
+#include <errno.h>
+
+#ifndef PURPLE_PLUGINS
+#define PURPLE_PLUGINS
+#endif
+
+#include <debug.h>
+#include <notify.h>
+#include <version.h>
+#include <util.h>
+
+#define WEBSITE   "http://ikebo.hypermart.net/"
+#define PLUGIN_ID "core-ike-splitter"
+
+/* grr */
+#ifndef ENOTCONN
+#define ENOTCONN 107
+#endif
+
+/* plugin constants and structures */
+static const gint MIN_SPLIT_SIZE     =      32;
+static const gint DEFAULT_SPLIT_SIZE =     786;
+static const gint MAX_SPLIT_SIZE     =    8192;
+
+static const gint MIN_DELAY_MS       =       0;
+static const gint DEFAULT_DELAY_MS   =     500;
+static const gint MAX_DELAY_MS       = 3600000; 
+
+typedef struct
+{
+	char *sender_username;
+	char *sender_protocol_id;
+	GQueue *messages;
+
+	PurpleConversationType type;
+	union {
+		char *receiver; /* IM username */
+		int  id;        /* chat ID */
+	};
+} message_to_conv;
+
+typedef struct {
+	int start, end;
+} message_slice;
+
+/* plugin preference variables */
+static gint current_split_size;
+
+
+/* initialize preferences dialog */
+static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin *plugin)
+{
+	PurplePluginPrefFrame *frame;
+	PurplePluginPref      *ppref;
+
+	frame = purple_plugin_pref_frame_new();
+	g_return_val_if_fail(frame != NULL, NULL);
+
+	ppref = purple_plugin_pref_new_with_label("Message split size");
+	g_return_val_if_fail(ppref != NULL, NULL);
+	purple_plugin_pref_frame_add(frame, ppref);
+	ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/splitter/split_size", 
+							 "Letter count: ");
+	g_return_val_if_fail(ppref != NULL, NULL);
+	purple_plugin_pref_set_bounds(ppref, MIN_SPLIT_SIZE, MAX_SPLIT_SIZE);
+	purple_plugin_pref_frame_add(frame, ppref);
+
+	ppref = purple_plugin_pref_new_with_label("Delay between messages");
+	g_return_val_if_fail(ppref != NULL, NULL);
+	purple_plugin_pref_frame_add(frame, ppref);
+	ppref = purple_plugin_pref_new_with_name_and_label("/plugins/core/splitter/delay_ms", 
+							 "ms: ");
+	g_return_val_if_fail(ppref != NULL, NULL);
+	purple_plugin_pref_set_bounds(ppref, MIN_DELAY_MS, MAX_DELAY_MS);
+	purple_plugin_pref_frame_add(frame, ppref);
+
+	return frame;
+}
+
+/**
+ * A function to send a chat or im message to the specific conversation
+ * without emitting "sending-im" or "sending-chat" signal, which would
+ * cause an infinite loop for this plugin.
+ *
+ * taken from conversation.c with signal emission removed.
+ */
+static void splitter_common_send(PurpleConversation *conv, const char *message, PurpleMessageFlags msgflags)
+{
+	PurpleConversationType type;
+	PurpleAccount *account;
+	PurpleConnection *gc;
+	char *displayed = NULL, *sent = NULL;
+	int err = 0;
+
+	if (strlen(message) == 0)
+		return;
+
+	account = purple_conversation_get_account(conv);
+	gc = purple_conversation_get_gc(conv);
+
+	g_return_if_fail(account != NULL);
+	g_return_if_fail(gc != NULL);
+
+	type = purple_conversation_get_type(conv);
+
+	/* Always linkfy the text for display */
+	displayed = purple_markup_linkify(message);
+
+	if ((conv->features & PURPLE_CONNECTION_HTML) &&
+		!(msgflags & PURPLE_MESSAGE_RAW))
+	{
+		sent = g_strdup(displayed);
+	}
+	else
+		sent = g_strdup(message);
+
+	msgflags |= PURPLE_MESSAGE_SEND;
+
+	if (type == PURPLE_CONV_TYPE_IM) {
+		PurpleConvIm *im = PURPLE_CONV_IM(conv);
+
+		if (sent != NULL && sent[0] != '\0') {
+
+			err = serv_send_im(gc, purple_conversation_get_name(conv),
+			                   sent, msgflags);
+
+			if ((err > 0) && (displayed != NULL))
+				purple_conv_im_write(im, NULL, displayed, msgflags, time(NULL));
+
+			purple_signal_emit(purple_conversations_get_handle(), "sent-im-msg",
+							 account,
+							 purple_conversation_get_name(conv), sent);
+		}
+	}
+	else {
+		if (sent != NULL && sent[0] != '\0') {
+			err = serv_chat_send(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), sent, msgflags);
+
+			purple_signal_emit(purple_conversations_get_handle(), "sent-chat-msg",
+							 account, sent,
+							 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)));
+		}
+	}
+
+	if (err < 0) {
+		const char *who;
+		const char *msg;
+
+		who = purple_conversation_get_name(conv);
+
+		if (err == -E2BIG) {
+			msg = _("Unable to send message: The message is too large.");
+
+			if (!purple_conv_present_error(who, account, msg)) {
+				char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who);
+				purple_notify_error(gc, NULL, msg2, _("The message is too large."));
+				g_free(msg2);
+			}
+		}
+		else if (err == -ENOTCONN) {
+			purple_debug(PURPLE_DEBUG_ERROR, "conversation",
+					   "Not yet connected.\n");
+		}
+		else {
+			msg = _("Unable to send message.");
+
+			if (!purple_conv_present_error(who, account, msg)) {
+				char *msg2 = g_strdup_printf(_("Unable to send message to %s."), who);
+				purple_notify_error(gc, NULL, msg2, NULL);
+				g_free(msg2);
+			}
+		}
+	}
+
+	g_free(displayed);
+	g_free(sent);
+}
+
+/* a timer based callback function that sends the next message in the queue */
+static gboolean send_message_timer_cb( message_to_conv *msg_to_conv )
+{
+	PurpleAccount *account;
+	PurpleConversation *conv;
+	gchar *msg;
+
+	g_return_val_if_fail(msg_to_conv                     != NULL, FALSE);
+	g_return_val_if_fail(msg_to_conv->messages           != NULL, FALSE);
+	g_return_val_if_fail(msg_to_conv->sender_username    != NULL, FALSE);
+	g_return_val_if_fail(msg_to_conv->sender_protocol_id != NULL, FALSE);
+
+	msg = g_queue_pop_head(msg_to_conv->messages);
+
+	if( msg == NULL )
+	{
+		/* clean up and terminate timer callback */
+		g_queue_free(msg_to_conv->messages);
+		g_free(msg_to_conv->sender_username);
+		g_free(msg_to_conv->sender_protocol_id);
+		if( msg_to_conv->type == PURPLE_CONV_TYPE_IM &&
+			msg_to_conv->receiver != NULL )
+		g_free(msg_to_conv->receiver);
+
+		g_free(msg_to_conv);
+
+		return FALSE;
+	}
+	else
+	{
+		/* find account info (it may have changed) and try and create a new
+		   conversation window (it may have been closed) or find the existing
+		   chat, and finally send the message */
+		account = purple_accounts_find(msg_to_conv->sender_username,
+					     msg_to_conv->sender_protocol_id);
+		g_return_val_if_fail(account != NULL, FALSE);
+
+		if( msg_to_conv->type == PURPLE_CONV_TYPE_IM && msg_to_conv->receiver != NULL )
+			conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, msg_to_conv->receiver);
+		else if( msg_to_conv->type == PURPLE_CONV_TYPE_CHAT )
+			conv = purple_find_chat(account->gc, msg_to_conv->id);
+		else
+			conv = NULL;
+
+		g_return_val_if_fail(conv != NULL, FALSE);
+
+		splitter_common_send(conv, msg, PURPLE_MESSAGE_SEND);
+		g_free(msg);
+
+		return TRUE;
+	}
+}
+
+/* finds the first line-breakable character backwards starting from a[last]  */
+static int find_last_break(PangoLogAttr *a, int last)
+{
+	for(; last > 0; last-- )
+		if( a[last].is_line_break == 1)
+			break;
+
+	return ( a[last].is_line_break == 1) ? last-1 : -1;
+}
+
+/* uses Pango to find all possible line break locations in a message and returns
+   a PangoLogAttr array which maps to each byte of the message of length
+   one larger than the message.  This must be g_free()'d */
+static PangoLogAttr* find_all_breaks(const char *message)
+{
+	PangoContext *context;
+	PangoLogAttr *a;
+	GList *list;
+	int len, n_attr;
+
+	g_return_val_if_fail(message != NULL, NULL);
+
+	len  = strlen(message);
+	n_attr = len+1;
+	a = g_new0(PangoLogAttr, n_attr);
+
+	/* init Pango */
+	context = gdk_pango_context_get();
+	g_return_val_if_fail(context != NULL, NULL);
+
+	list = pango_itemize(context, message, 0, len, NULL, NULL);
+
+	if (list != NULL && list->data != NULL)
+		pango_break(message, -1, &((PangoItem*)(list->data))->analysis, a, n_attr);
+
+	return a;
+}
+
+/* return a queue of message slices from a plain text message based on current_split_size using
+   Pango to determine possible line break locations */
+static GQueue* get_message_slices(const char *message)
+{
+	int current_break_start, last_break_start, break_pos, len;
+	message_slice *slice;
+	PangoLogAttr *a;
+	GQueue *q;
+
+	q = g_queue_new();
+	len = strlen(message);
+	a = find_all_breaks(message);
+	g_return_val_if_fail(a != NULL, NULL);
+
+	last_break_start = current_break_start = 0;
+
+	while(current_break_start + current_split_size < len)
+	{
+		break_pos = find_last_break(a + last_break_start, current_split_size);
+
+		if( break_pos > -1 )   current_break_start += break_pos;
+		else                   current_break_start += current_split_size;
+
+		slice = g_new0( message_slice, 1 );
+		slice->start = MAX( last_break_start, 0 );
+		slice->end   = MIN( current_break_start, len );
+
+		if( slice->end > slice->start )
+			g_queue_push_tail(q, slice);
+		else	g_free(slice);
+
+		if( break_pos > -1 )
+			current_break_start++;
+
+		last_break_start = current_break_start;
+	}
+
+	slice = g_new0( message_slice, 1 );
+	slice->start = last_break_start;
+	slice->end   = len;
+	g_queue_push_tail(q, slice);
+
+	/* cleanup */
+	g_free(a);
+
+	return q;
+	
+}
+
+/* takes a message, splits it up based on whitespace (ignoring HTML formatting),
+   requests HTMLized slices of the splits, and returns a queue of them.  The
+   messages and the queue must be freed */
+static GQueue* create_message_queue(const char *message)
+{
+	GQueue *slices, *messages;
+	message_slice *slice;
+	char *stripped_message, *msg;
+	int stripped_len;
+
+	stripped_message = purple_markup_strip_html(message);
+	stripped_len = strlen(stripped_message);
+
+	messages = g_queue_new();
+	slices   = get_message_slices(stripped_message);
+	g_return_val_if_fail(slices != NULL, NULL);
+
+	while( (slice = g_queue_pop_head(slices)) != NULL )
+	{
+		msg = purple_markup_slice(message, slice->start, slice->end);
+
+		if( msg != NULL )
+			g_queue_push_tail(messages, msg);
+
+		g_free(slice);
+	}
+
+	g_queue_free(slices);
+
+	/* cleanup */
+	g_free(stripped_message);
+
+	return messages;
+}
+
+/* create message queue and prepare timer callbacks */
+static void split_and_send(message_to_conv *msg_to_conv, const char **message)
+{
+	gint message_delay_ms;
+
+	g_return_if_fail( msg_to_conv != NULL );
+	g_return_if_fail( message     != NULL );
+	g_return_if_fail( *message    != NULL );
+
+	/* read and validate preferences */
+	current_split_size = purple_prefs_get_int("/plugins/core/splitter/split_size");
+	if( current_split_size > MAX_SPLIT_SIZE ) current_split_size = MAX_SPLIT_SIZE;
+	if( current_split_size < MIN_SPLIT_SIZE ) current_split_size = MIN_SPLIT_SIZE;
+
+	message_delay_ms = purple_prefs_get_int("/plugins/core/splitter/delay_ms");
+	if( message_delay_ms > MAX_DELAY_MS ) message_delay_ms = MAX_DELAY_MS;
+	if( message_delay_ms < MIN_DELAY_MS ) message_delay_ms = MIN_DELAY_MS;
+
+	/* prepare message queue */
+	msg_to_conv->messages = create_message_queue(*message);
+	g_return_if_fail( msg_to_conv->messages != NULL );
+
+	/* initialize message send timer */
+	purple_timeout_add( (g_queue_get_length(msg_to_conv->messages) > 1) ? message_delay_ms : 0,
+			  (GSourceFunc)send_message_timer_cb,
+			  msg_to_conv);
+
+	/* free the original message and ensure it does not get sent */
+	g_free((char*)*message);
+	*message = NULL;
+}
+
+/* initialize a chat message to potentially be split */
+static void sending_chat_msg_cb(PurpleAccount *account, const char **message, int id)
+{
+	message_to_conv *msg_to_conv;
+
+	purple_debug(PURPLE_DEBUG_MISC, "purple-splitter", "splitter plugin invoked\n");
+
+	g_return_if_fail(account  != NULL);
+	g_return_if_fail(message  != NULL);
+	g_return_if_fail(*message != NULL);
+
+	msg_to_conv = g_new0(message_to_conv, 1);
+	g_return_if_fail( msg_to_conv != NULL );
+
+	msg_to_conv->sender_username     = g_strdup(account->username);
+	msg_to_conv->sender_protocol_id  = g_strdup(account->protocol_id);
+	msg_to_conv->id                  = id;
+	msg_to_conv->type                = PURPLE_CONV_TYPE_CHAT;
+
+	split_and_send(msg_to_conv, message);
+}
+
+/* initialize an IM message to potentially be split */
+static void sending_im_msg_cb(PurpleAccount *account, const char *receiver,
+						    const char **message)
+{
+	message_to_conv *msg_to_conv;
+
+	purple_debug(PURPLE_DEBUG_MISC, "purple-splitter", "splitter plugin invoked\n");
+
+	g_return_if_fail(account  != NULL);
+	g_return_if_fail(receiver != NULL);
+	g_return_if_fail(message  != NULL);
+	g_return_if_fail(*message != NULL);
+
+	msg_to_conv = g_new0(message_to_conv, 1);
+	g_return_if_fail( msg_to_conv != NULL );
+
+	msg_to_conv->sender_username     = g_strdup(account->username);
+	msg_to_conv->sender_protocol_id  = g_strdup(account->protocol_id);
+	msg_to_conv->receiver            = g_strdup(receiver);
+	msg_to_conv->type                = PURPLE_CONV_TYPE_IM;
+
+	split_and_send(msg_to_conv, message);
+}
+
+/* register "sending" message signal callback */
+static gboolean plugin_load(PurplePlugin *plugin)
+{
+	purple_signal_connect(purple_conversations_get_handle(),
+			    "sending-im-msg",
+			    plugin,
+			    PURPLE_CALLBACK(sending_im_msg_cb),
+			    NULL);
+	purple_signal_connect(purple_conversations_get_handle(),
+			    "sending-chat-msg",
+			    plugin,
+			    PURPLE_CALLBACK(sending_chat_msg_cb),
+			    NULL);
+
+	return TRUE;
+}
+
+
+static gboolean plugin_unload(PurplePlugin *plugin)
+{
+	return TRUE;
+}
+
+static PurplePluginUiInfo prefs_info = {
+	get_plugin_pref_frame, 0, NULL, NULL, NULL, NULL, NULL
+};
+
+static PurplePluginInfo info =
+{
+	PURPLE_PLUGIN_MAGIC,
+	PURPLE_MAJOR_VERSION,
+	PURPLE_MINOR_VERSION,
+	PURPLE_PLUGIN_STANDARD,                             /**< type           */
+	NULL,                                             /**< ui_requirement */
+	0,                                                /**< flags          */
+	NULL,                                             /**< dependencies   */
+	PURPLE_PRIORITY_DEFAULT,                            /**< priority       */
+
+	PLUGIN_ID,                                        /**< id             */
+	N_("Message Splitter"),                           /**< name           */
+	VERSION,                                          /**< version        */
+							  /**  summary        */
+	N_("Splits a large outgoing message into smaller "
+	   "messages of a specified size."),
+							  /**  description    */
+	N_("Splits a large outgoing message into smaller "
+	   "messages of a specified size."),
+	"Ike Gingerich <ike_ at users.sourceforge.net>",     /**< author         */
+	WEBSITE,                                          /**< homepage       */
+
+	plugin_load,                                      /**< load           */
+	plugin_unload,                                    /**< unload         */
+	NULL,                                             /**< destroy        */
+
+	NULL,                                             /**< ui_info        */
+	NULL,                                             /**< extra_info     */
+	&prefs_info,                                      /**< prefs_info     */
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
+/* store initial preference values */
+static void init_plugin(PurplePlugin *plugin)
+{
+	purple_prefs_add_none("/plugins/core/splitter");
+	purple_prefs_add_int ("/plugins/core/splitter/split_size", DEFAULT_SPLIT_SIZE);
+	purple_prefs_add_int ("/plugins/core/splitter/delay_ms",   DEFAULT_DELAY_MS);
+}
+
+PURPLE_INIT_PLUGIN(splitter, init_plugin, info)
============================================================
--- configure.ac	1fc1dd6bed183671b1d5c3bbb16f27dbaa43b79b
+++ configure.ac	43512f67ef3780d8808916f5817135f2eaed55f7
@@ -350,6 +350,7 @@ AC_OUTPUT([
 	simfix/Makefile
 	slashexec/Makefile
 	snpp/Makefile
+	splitter/Makefile
 	sslinfo/Makefile
 	stocker/Makefile
 	switchspell/Makefile


More information about the Plugins-commits mailing list