org.guifications.plugins: 25a1ec4f75749ddfb1790ae3efb5daabd1108731
rekkanoryo at guifications.org
rekkanoryo at guifications.org
Tue Oct 9 11:45:04 CDT 2007
-----------------------------------------------------------------
Revision: 25a1ec4f75749ddfb1790ae3efb5daabd1108731
Ancestor: d4ce3d9c1fa71c06bf19621817b6391e1fc2d37d
Author: rekkanoryo at guifications.org
Date: 2007-10-09T16:41:11
Branch: org.guifications.plugins
Modified files:
autoreply/autoreply.c
ChangeLog:
Patch from toblerone3742 (rageboy04) to fix some issues in autoreply. Fixes #393.
----------------------------------------------------------------------
This revision's diffstat output:
autoreply.c | 37 +++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)
-------------- next part --------------
============================================================
--- autoreply/autoreply.c a15d8abfa411a3775444796e7039f832ee5fa262
+++ autoreply/autoreply.c 5e71619a6b449a6f77160c4f3d19cf7526b73f56
@@ -56,6 +56,7 @@ struct _AutoReplyProtocolOptions {
struct _AutoReplyProtocolOptions {
PurpleAccountOption *message;
+ PurpleAccountOption *off;
};
typedef enum
@@ -87,31 +88,31 @@ get_autoreply_message(PurpleBuddy *buddy
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 @@ written_msg(PurpleAccount *account, cons
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 @@ written_msg(PurpleAccount *account, cons
trigger = TRUE;
if (!trigger)
- return;
+ return;
buddy = purple_find_buddy(account, who);
reply = get_autoreply_message(buddy, account);
@@ -226,7 +231,7 @@ set_auto_reply(PurpleBlistNode *node, gp
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 @@ add_options_for_protocol(PurplePlugin *p
{
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 @@ remove_options_for_protocol(PurplePlugin
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 @@ remove_options_for_protocol(PurplePlugin
{
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 @@ plugin_load(PurplePlugin *plugin)
add_options_for_protocol(list->data);
list = list->next;
}
-
+
return TRUE;
}
@@ -382,7 +395,7 @@ get_plugin_pref_frame(PurplePlugin *plug
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));
More information about the Plugins-commits
mailing list