grim/purple-plugin-pack
--leaks
org.guifications.plugins
2009-04-15, darkrain42
Purple-Plonkers - Manage the plonkers out in cyberland Copyright (C) 2005-2008 Peter Lawler Very loosely based on gxr, Copyright (C) 2004 Gary Kramlich 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., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. /* If you can't figure out what this line is for, DON'T TOUCH IT. */ #include "../common/pp_internal.h" #include <conversation.h> /* #define PLONKERS_DEBUG */ /******************************************************************************* ******************************************************************************/ /******************************************************************************* ******************************************************************************/ static PurpleCmdId plonkers_cmd; static PurpleCmdId plonk_cmd; /******************************************************************************* ******************************************************************************/ /******************************************************************************* ******************************************************************************/ plonkers_format_info(PurpleConversation *conv) { gchar *ret, *plonkers_char; plonkers_list = purple_conv_chat_get_ignored(PURPLE_CONV_CHAT(conv)); plonkers_size = g_list_length (plonkers_list); for ( ; plonkers_list; plonkers_list = plonkers_list->next) { plonkers_char = g_strdup_printf("%s", (char *)plonkers_list->data); plonkers_char = g_strdup_printf("%s, %s", plonkers_char, (char *)plonkers_list->data); plonkers_str = g_string_new(""); if (plonkers_size == 1) { format = g_strdup(purple_prefs_get_string("/plugins/core/plugin_pack/plonkers/plonkers/format_singular")); format = g_strdup(purple_prefs_get_string("/plugins/core/plugin_pack/plonkers/plonkers/format_plural")); purple_debug_info("plonkers", "Str: %s\n", plonkers_str->str); plonkers_str = g_string_append_c(plonkers_str, format[0]); plonkers_str = g_string_append_c(plonkers_str, '%'); g_string_append_printf(plonkers_str, "%d", plonkers_size); plonkers_str = g_string_append(plonkers_str, plonkers_char); g_string_free(plonkers_str, FALSE); purple_debug_info("plonkers", "Formatted plonkers: %s\n", ret); plonkers_display(PurpleConversation *conv) { text = plonkers_format_info(conv); purple_conv_chat_send(PURPLE_CONV_CHAT(conv), text); /******************************************************************************* ******************************************************************************/ plonkers_cmd_cb(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) { /* I plan a switch that dumps the current 'block' list, once purple privacy lower = g_ascii_strdown(args[0], strlen(args[0])); return PURPLE_CMD_RET_OK; plonk_cmd_cb(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) { /* this is the funky 'mass block/ignore' routine. * given a/n list of ID/'s it'll add that|those to all block|ignore lists * of each account of the same prpl type. * gchar* g_strdelimit (gchar *string, const gchar *delimiters, gchar new_delimiter); * gchar** g_strsplit (const gchar *string, const gchar *delimiter, gint max_tokens); PurpleConversationUiOps *ops; purple_debug_info("Plonkers", "Bad arg: %s\n", args[0]); return PURPLE_CMD_RET_FAILED; if(!g_utf8_validate(*args, -1, NULL)) { purple_debug_info("Plonkers", "Invalid UTF8: %s\n", args[0]); return PURPLE_CMD_RET_FAILED; purple_debug_info("plonkers", "Plonk arg: %s\n", args[0]); g_strdelimit (*args, "_-|> <.,:;", ' '); purple_debug_info("plonkers", "Plonk delimited arg: %s\n", args[0]); tmp = g_strsplit(args[0], " ", 0); purple_debug_info("plonkers", "Plonk strsplit length: %i\n", g_strv_length(tmp)); /* next step, remove duplicates in the array */ ops = purple_conversation_get_ui_ops(c); PurpleAccount *account = purple_conversation_get_account(c); members = purple_conv_chat_get_users(PURPLE_CONV_CHAT(c)); for (l = account->deny; l != NULL; l = l->next) { for (plonks = members; plonks; plonks = plonks->next) { if (!purple_utf8_strcasecmp((char *)l->data, plonks->data)) { purple_debug_info("plonkers", "Ignoring room member %s in room %s\n" ,(gchar *)plonks->data, room); /* purple_conv_chat_ignore(PURPLE_CONV_CHAT(c),plonks->data); * ops->chat_update_user((c), plonks->data); */ return PURPLE_CMD_RET_OK; /******************************************************************************* ******************************************************************************/ plonkers_make_label(const gchar *text, GtkSizeGroup *sg) { label = gtk_label_new_with_mnemonic(text); gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5); gtk_size_group_add_widget(sg, label); plonkers_get_config_frame(PurplePlugin *plugin) { GtkWidget *vbox, *hbox, *frame, *label; vbox = gtk_vbox_new(FALSE, 6); gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); frame = pidgin_make_frame(vbox, _("Ignored Plonkers")); pidgin_prefs_labeled_entry(frame, _("Plonkers singular format:"), "/plugins/core/plugin_pack/plonkers/plonkers/format_singular", pidgin_prefs_labeled_entry(frame, _("Plonkers plural format:"), "/plugins/core/plugin_pack/plonkers/plonkers/format_plural", frame = pidgin_make_frame(vbox, _("Plonking")); pidgin_prefs_labeled_entry(frame, _("Plonked singular plural:"), "/plugins/core/plugin_pack/plonkers/plonked/format_singular", pidgin_prefs_labeled_entry(frame, _("Plonked plural format:"), "/plugins/core/plugin_pack/plonkers/plonked/format_plural", sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); frame = pidgin_make_frame(vbox, _("Format information")); hbox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); label = plonkers_make_label(_("%P: List of plonkers"), sg); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); label = plonkers_make_label(_("%N: Number of plonkers"), NULL); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); gtk_widget_show_all(vbox); /******************************************************************************* ******************************************************************************/ /******************************************************************************* ******************************************************************************/ plonkers_load(PurplePlugin *plugin) { const gchar *help = _("<pre>plonkers;\nTell people in a chat what you " "really think of them\n</pre>"); /* register our command */ plonkers_cmd = purple_cmd_register("plonkers", "", PURPLE_CMD_P_PLUGIN, PURPLE_CMD_FLAG_CHAT, NULL, plonkers_cmd_cb, help, NULL); plonk_cmd = purple_cmd_register("plonk", "s", PURPLE_CMD_P_PLUGIN, PURPLE_CMD_FLAG_CHAT|PURPLE_CMD_FLAG_IM, NULL, plonk_cmd_cb, help, NULL); plonkers_unload(PurplePlugin *plugin) { purple_cmd_unregister(plonkers_cmd); purple_cmd_unregister(plonk_cmd); static PidginPluginUiInfo ui_info = { plonkers_get_config_frame, static PurplePluginInfo plonkers_info = { PURPLE_PLUGIN_MAGIC, /* Fear */ PURPLE_MAJOR_VERSION, /* the */ PURPLE_MINOR_VERSION, /* reaper */ PURPLE_PLUGIN_STANDARD, /* type */ PIDGIN_PLUGIN_TYPE, /* ui requirement */ PURPLE_PRIORITY_DEFAULT, /* priority */ "core-plugin_pack-Plonkers", /* id */ PP_VERSION, /* version */ "Peter Lawler <bleeter from users.sf.net>", /* author */ PP_WEBSITE, /* homepage */ plonkers_load, /* load */ plonkers_unload, /* unload */ init_plugin(PurplePlugin *plugin) { purple_prefs_add_none("/plugins/core/plugin_pack"); purple_prefs_add_none("/plugins/core/plugin_pack/plonkers"); purple_prefs_add_none("/plugins/core/plugin_pack/plonkers/plonkers"); purple_prefs_add_string("/plugins/core/plugin_pack/plonkers/plonkers/format_singular", _("/me has identified %N plonker: %P.")); purple_prefs_add_string("/plugins/core/plugin_pack/plonkers/plonkers/format_plural", _("/me has identified %N plonkers: %P.")); purple_prefs_add_none("/plugins/core/plugin_pack/plonkers/plonked"); purple_prefs_add_string("/plugins/core/plugin_pack/plonkers/plonked/format_singular", purple_prefs_add_string("/plugins/core/plugin_pack/plonkers/plonked/format_plural", plonkers_info.name = _("Plonkers"); plonkers_info.summary = _("Tell plonkers what you really think."); plonkers_info.description = _("Plonkers is a small plugin that lets you " "announce to a chat room your current list of ignores, as well as " "providing other pointless ignore and privacy tools for dealing " "with idiots. The name is inspired by the British/Irish word for " PURPLE_INIT_PLUGIN(plonkers, init_plugin, plonkers_info)