--- a/splitter/splitter.c Mon Dec 28 23:09:22 2009 -0800
+++ b/splitter/splitter.c Wed Dec 30 19:48:39 2009 -0800
@@ -75,6 +75,9 @@
+/* Global variable to block infinite loops. Single-threaded is nice */ +static gboolean splitter_injected_message = FALSE; /* plugin preference variables */
static gint current_split_size;
@@ -123,7 +126,6 @@
char *displayed = NULL, *sent = NULL;
if (strlen(message) == 0)
@@ -149,60 +151,18 @@
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),
+ splitter_injected_message = TRUE; - 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",
- purple_conversation_get_name(conv), sent);
+ if (type == PURPLE_CONV_TYPE_IM) { + if (sent != NULL && sent[0] != '\0') + purple_conv_im_send_with_flags(PURPLE_CONV_IM(conv), sent, msgflags); - 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",
- purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)));
+ if (sent != NULL && sent[0] != '\0') + purple_conv_chat_send_with_flags(PURPLE_CONV_CHAT(conv), sent, msgflags);
- who = purple_conversation_get_name(conv);
- 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."));
- else if (err == -ENOTCONN) {
- purple_debug_error("conversation", "Not yet connected.\n");
- 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);
+ splitter_injected_message = FALSE; @@ -443,6 +403,9 @@
sending_chat_msg_cb(PurpleAccount *account, const char **message, int id) {
message_to_conv *msg_to_conv;
+ if (splitter_injected_message) purple_debug_misc("purple-splitter", "splitter plugin invoked\n");
g_return_if_fail(account != NULL);
@@ -466,6 +429,9 @@
message_to_conv *msg_to_conv;
+ if (splitter_injected_message) purple_debug_misc("purple-splitter", "splitter plugin invoked\n");
g_return_if_fail(account != NULL);
@@ -473,6 +439,10 @@
g_return_if_fail(message != NULL);
g_return_if_fail(*message != NULL);
+ /* OTR compatibility hack */ + if (0 == strncmp(*message, "?OTR", strlen("?OTR"))) msg_to_conv = g_new0(message_to_conv, 1);
msg_to_conv->sender_username = g_strdup(account->username);
@@ -491,13 +461,13 @@
PURPLE_CALLBACK(sending_im_msg_cb),
- PURPLE_SIGNAL_PRIORITY_LOWEST);
+ PURPLE_SIGNAL_PRIORITY_HIGHEST); purple_signal_connect_priority(purple_conversations_get_handle(),
PURPLE_CALLBACK(sending_chat_msg_cb),
- PURPLE_SIGNAL_PRIORITY_LOWEST);
+ PURPLE_SIGNAL_PRIORITY_HIGHEST);