pidgin/purple-plugin-pack

merge of '03abf61fc417f02c8a2888aa3783acb220fad2f8'
org.guifications.plugins
2007-10-09, rekkanoryo
764ade3ee2db
merge of '03abf61fc417f02c8a2888aa3783acb220fad2f8'
and '25a1ec4f75749ddfb1790ae3efb5daabd1108731'
--- a/autoreply/autoreply.c Tue Oct 09 06:13:57 2007 -0400
+++ b/autoreply/autoreply.c Tue Oct 09 16:41:23 2007 -0400
@@ -56,6 +56,7 @@
struct _AutoReplyProtocolOptions {
PurpleAccountOption *message;
+ PurpleAccountOption *off;
};
typedef enum
@@ -87,31 +88,31 @@
reply = purple_savedstatus_get_message(purple_savedstatus_get_current());
}
- if (!reply && buddy)
+ if ((!reply || !*reply) && buddy)
{
/* Is there any special auto-reply for this buddy? */
reply = purple_blist_node_get_string((PurpleBlistNode*)buddy, "autoreply");
- if (!reply && PURPLE_BLIST_NODE_IS_BUDDY((PurpleBlistNode*)buddy))
+ if ((!reply || !*reply) && PURPLE_BLIST_NODE_IS_BUDDY((PurpleBlistNode*)buddy))
{
/* Anything for the contact, then? */
reply = purple_blist_node_get_string(((PurpleBlistNode*)buddy)->parent, "autoreply");
}
}
- if (!reply)
+ if (!reply || !*reply)
{
/* Is there any specific auto-reply for this account? */
reply = purple_account_get_string(account, "autoreply", NULL);
}
- if (!reply)
+ if (!reply || !*reply)
{
/* Get the global auto-reply message */
reply = purple_prefs_get_string(PREFS_GLOBAL);
}
- if (*reply == ' ')
+ if (*reply == ' ' || *reply == '\0')
reply = NULL;
if (!reply && use_status == STATUS_FALLBACK)
@@ -139,6 +140,10 @@
if (flags & PURPLE_MESSAGE_AUTO_RESP)
return;
+ if(purple_account_get_bool(account, "ar_off", FALSE))
+ return;
+
+
g_return_if_fail(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM);
presence = purple_account_get_presence(account);
@@ -149,7 +154,7 @@
trigger = TRUE;
if (!trigger)
- return;
+ return;
buddy = purple_find_buddy(account, who);
reply = get_autoreply_message(buddy, account);
@@ -226,7 +231,7 @@
get_autoreply_message(buddy, account), TRUE, FALSE,
(gc->flags & PURPLE_CONNECTION_HTML) ? "html" : NULL,
_("_Save"), G_CALLBACK(set_auto_reply_cb),
- _("_Cancel"), NULL,
+ _("_Cancel"), NULL,
account, purple_buddy_get_name(buddy), NULL, node);
g_free(message);
}
@@ -252,13 +257,16 @@
{
AutoReplyProtocolOptions *arpo;
PurplePluginProtocolInfo *info = PURPLE_PLUGIN_PROTOCOL_INFO(plg);
-
+
arpo = g_new(AutoReplyProtocolOptions, 1);
arpo->message = purple_account_option_string_new(_("Autoreply message"),
"autoreply", NULL);
+ arpo->off = purple_account_option_bool_new(_("Turn off autoreply"),
+ "ar_off", FALSE);
info->protocol_options = g_list_append(info->protocol_options,
arpo->message);
+ info->protocol_options = g_list_append(info->protocol_options, arpo->off);
if (!g_hash_table_lookup(options, plg))
g_hash_table_insert(options, plg, arpo);
@@ -273,7 +281,7 @@
if(!arpo)
return;
-
+
/*
* 22:55 < sadrul> grim: the check when removing is required, iirc, when
* pidgin quits, and a prpl is unloaded before the plugin
@@ -282,9 +290,14 @@
{
info->protocol_options = g_list_remove_link(info->protocol_options, l);
purple_account_option_destroy(arpo->message);
- g_hash_table_remove(options, plg);
+ }
+ if ((l = g_list_find(info->protocol_options, arpo->off)))
+ {
+ info->protocol_options = g_list_remove_link(info->protocol_options, l);
+ purple_account_option_destroy(arpo->off);
}
+ g_hash_table_remove(options, plg);
g_free(arpo);
}
@@ -322,7 +335,7 @@
add_options_for_protocol(list->data);
list = list->next;
}
-
+
return TRUE;
}
@@ -382,7 +395,7 @@
pref = purple_plugin_pref_new_with_name_and_label(PREFS_USESTATUS,
_("Autoreply with status message"));
purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE);
- purple_plugin_pref_add_choice(pref, _("Never"),
+ purple_plugin_pref_add_choice(pref, _("Never"),
GINT_TO_POINTER(STATUS_NEVER));
purple_plugin_pref_add_choice(pref, _("Always when there is a status message"),
GINT_TO_POINTER(STATUS_ALWAYS));