pidgin/purple-plugin-pack

Parents 52396fee625b
Children 3566e338f974
Some minor tweaks and attempt to do a channel auto-join list. The auto-join
currently does not work (purple_cmd_do_command() constantly returns
PURPLE_CMD_STATUS_FAILED, but gives no error message. Need to figure that out.
--- a/ChangeLog Tue Mar 09 23:26:42 2010 -0500
+++ b/ChangeLog Sun Mar 28 01:26:38 2010 -0400
@@ -4,6 +4,9 @@
frigg.
* IRC-More now builds when you pass --with-plugins=irc-more to configure.
(Ivan Ponomarev)
+ * IRC-More no longer tries to set umodes on connect if none are specified.
+ * IRC-More now provides a channel autojoin list. Autojoins happen with a
+ 6-second delay to allow IRC Helper to do its job first.
Version 2.6.2: 01/01/10
* Fix IRC More plugin not properly rejoining channels.
--- a/irc-more/irc-more.c Tue Mar 09 23:26:42 2010 -0500
+++ b/irc-more/irc-more.c Sun Mar 28 01:26:38 2010 -0400
@@ -25,15 +25,17 @@
#include <accountopt.h>
#include <cmds.h>
#include <conversation.h>
+#include <debug.h>
#include <plugin.h>
#include <prpl.h>
#include <string.h>
+#define AUTOJOIN purple_account_get_string(account, "autojoin", NULL)
#define CTCP_REPLY purple_account_get_string(account, "ctcp-message", "Purple IRC")
#define PART_MESSAGE purple_account_get_string(account, "part-message", "Leaving.")
#define QUIT_MESSAGE purple_account_get_string(account, "quit-message", "Leaving.")
-#define SET_UMODES purple_account_get_string(account, "setumodes", "i")
+#define SET_UMODES purple_account_get_string(account, "setumodes", NULL)
#define UNSET_UMODES purple_account_get_string(account, "unsetumodes", NULL)
#define PLUGIN_ID "core-plugin_pack-irc-more"
@@ -102,12 +104,38 @@
g_strfreev(splits);
}
+static gboolean
+autojoin_cb(gpointer data)
+{
+ PurpleAccount *account = data;
+ gchar *cmd = g_strdup_printf("join %s", AUTOJOIN), *error = NULL,
+ *esc = g_markup_escape_text(cmd, -1);
+ int result = 0;
+
+ /* this hack courtesy irchelper -- don't use purple_conversation_set_account
+ * because it will fire a signal that other plugins can use. Instead do
+ * this hack. This will break when struct hiding is complete and ABI breaks. */
+ PurpleConversation *conv = g_new0(PurpleConversation, 1);
+ conv->account = account;
+
+ purple_debug_info("irc-more", "Executng command: %s\n", cmd);
+ result = purple_cmd_do_command(conv, cmd, esc, &error);
+ purple_debug_info("irc-more", "Executed command. Result: %d. Error: %s\n",
+ result, error ? error : "(null)");
+
+ g_free(cmd);
+ g_free(conv);
+ g_free(esc);
+
+ return FALSE;
+}
+
static void
signed_on_cb(PurpleConnection *gc)
{
/* should this be done on a timeout? */
PurpleAccount *account = NULL;
- const gchar *nick = NULL, *setmodes = NULL, *unsetmodes = NULL;
+ const gchar *nick = NULL, *setmodes = NULL, *unsetmodes = NULL, *autojoin = NULL;
gchar *msg = NULL, *msg2 = NULL;
account = purple_connection_get_account(gc);
@@ -119,17 +147,25 @@
nick = purple_connection_get_display_name(gc);
setmodes = SET_UMODES;
unsetmodes = UNSET_UMODES;
+ autojoin = AUTOJOIN;
- msg = g_strdup_printf("MODE %s +%s\r\n", nick, setmodes);
- irc_info->send_raw(gc, msg, strlen(msg));
- g_free(msg);
+ if(setmodes && *setmodes) {
+ msg = g_strdup_printf("MODE %s +%s\r\n", nick, setmodes);
+ purple_debug_info("irc-more", "Sending command: %s\n", msg);
+ irc_info->send_raw(gc, msg, strlen(msg));
+ g_free(msg);
+ }
if(unsetmodes && *unsetmodes) {
msg2 = g_strdup_printf("MODE %s -%s\r\n", nick, unsetmodes);
+ purple_debug_info("irc-more", "Sending command: %s\n", msg);
irc_info->send_raw(gc, msg2, strlen(msg2));
g_free(msg2);
}
+ if(autojoin && *autojoin)
+ purple_timeout_add_seconds(6, autojoin_cb, account);
+
return;
}
@@ -219,8 +255,10 @@
{
PurplePlugin *prpl = NULL;
PurpleAccountOption *option;
+ void *gc_handle = NULL;
+#if !PURPLE_VERSION_CHECK(2,4,0)
gchar *notice_help = NULL;
- void *gc_handle = NULL;
+#endif
prpl = purple_find_prpl("prpl-irc");
@@ -228,10 +266,10 @@
if (!prpl)
return FALSE;
+#if !PURPLE_VERSION_CHECK(2,4,0)
/* specify our help string and register our command */
notice_help = _("notice target message: Send a notice to the specified target.");
-#if !PURPLE_VERSION_CHECK(2,4,0)
notice_cmd_id = purple_cmd_register("notice", "ws", PURPLE_CMD_P_PLUGIN,
PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
"prpl-irc", notice_cmd_cb, notice_help, NULL);
@@ -251,6 +289,9 @@
irc_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
/* Alphabetize the option label strings */
+ option = purple_account_option_string_new(_("Auto-Join Channels"), "autojoin", "");
+ irc_info->protocol_options = g_list_append(irc_info->protocol_options, option);
+
option = purple_account_option_string_new(_("CTCP Version reply"), "ctcp-message", "Purple IRC");
irc_info->protocol_options = g_list_append(irc_info->protocol_options, option);
@@ -292,7 +333,8 @@
PP_VERSION,
NULL,
NULL,
- "Sadrul H Chowdhury <sadrul@users.sourceforge.net>",
+ "Sadrul H Chowdhury <sadrul@users.sourceforge.net>\n"
+ "John Bailey <rekkanoryo@rekkanoryo.org>",
PP_WEBSITE,
plugin_load,
@@ -320,9 +362,16 @@
info.name = _("IRC More");
info.summary = _("Adds additional IRC features.");
+#if !PURPLE_VERSION_CHECK(2,4,0)
info.description = _("Adds additional IRC features, including a "
"customizable quit message, a customizable CTCP VERSION reply, "
- "and the /notice command for notices.");
+ "a rudimentary channel autojoin list, and the /notice command for "
+ "notices.");
+#else
+ info.description = _("Adds additional IRC features, including a "
+ "customizable quit message, a customizable CTCP VERSION reply, "
+ "and a rudimentary channel autojoin list.");
+#endif
}
PURPLE_INIT_PLUGIN(irc_more, init_plugin, info)
--- a/irc-more/plugins.cfg Tue Mar 09 23:26:42 2010 -0500
+++ b/irc-more/plugins.cfg Sun Mar 28 01:26:38 2010 -0400
@@ -3,7 +3,7 @@
depends=purple
provides=irc-more
summary=Adds additional IRC features
-description=Adds additional IRC features, including a customizable quit message, a customizable CTCP VERSION reply, and the /notice command for notices where libpurple does not support it.
+description=Adds additional IRC features, including a customizable quit message, a customizable CTCP VERSION reply, a rudimentary channel autojoin list and the /notice command for notices where libpurple does not support it.
authors=Sadrul Habib Chowdhury,John Bailey
introduced=2.2.0
notes=Support for /notice only when built with libpurple older than 2.4.0.