comparison libpurple/plugins/joinpart.c @ 23870:13ca254ea7db

In the Join/Part plugin, add the ability to apply the rules to buddies. By default, joins and parts for buddies are still shown.
author Richard Laager <rlaager@wiktel.com>
date Wed, 20 Aug 2008 21:10:01 +0000
parents 22fce0be8ed0
children 7f552614ec8a
comparison
equal deleted inserted replaced
23869:9f1d3db77fc3 23870:13ca254ea7db
39 /* The number of people that must be in a room for this 39 /* The number of people that must be in a room for this
40 * plugin to have any effect */ 40 * plugin to have any effect */
41 #define THRESHOLD_PREF "/plugins/core/joinpart/threshold" 41 #define THRESHOLD_PREF "/plugins/core/joinpart/threshold"
42 #define THRESHOLD_DEFAULT 20 42 #define THRESHOLD_DEFAULT 20
43 43
44 /* Hide buddies */
45 #define HIDE_BUDDIES_PREF "/plugins/core/joinpart/hide_buddies"
46 #define HIDE_BUDDIES_DEFAULT FALSE
47
44 struct joinpart_key 48 struct joinpart_key
45 { 49 {
46 PurpleConversation *conv; 50 PurpleConversation *conv;
47 char *user; 51 char *user;
48 }; 52 };
87 chat = PURPLE_CONV_CHAT(conv); 91 chat = PURPLE_CONV_CHAT(conv);
88 threshold = purple_prefs_get_int(THRESHOLD_PREF); 92 threshold = purple_prefs_get_int(THRESHOLD_PREF);
89 if (g_list_length(purple_conv_chat_get_users(chat)) < threshold) 93 if (g_list_length(purple_conv_chat_get_users(chat)) < threshold)
90 return FALSE; 94 return FALSE;
91 95
92 /* We always care about our buddies! */ 96 if (!purple_prefs_get_bool(HIDE_BUDDIES_PREF) &&
93 if (purple_find_buddy(purple_conversation_get_account(conv), name)) 97 purple_find_buddy(purple_conversation_get_account(conv), name))
94 return FALSE; 98 return FALSE;
95 99
96 /* Only show the notice if the user has spoken recently. */ 100 /* Only show the notice if the user has spoken recently. */
97 key.conv = conv; 101 key.conv = conv;
98 key.user = (gchar *)name; 102 key.user = (gchar *)name;
231 ppref = purple_plugin_pref_new_with_name_and_label(THRESHOLD_PREF, 235 ppref = purple_plugin_pref_new_with_name_and_label(THRESHOLD_PREF,
232 _("Minimum Room Size")); 236 _("Minimum Room Size"));
233 purple_plugin_pref_set_bounds(ppref, 0, 1000); 237 purple_plugin_pref_set_bounds(ppref, 0, 1000);
234 purple_plugin_pref_frame_add(frame, ppref); 238 purple_plugin_pref_frame_add(frame, ppref);
235 239
236
237 ppref = purple_plugin_pref_new_with_name_and_label(DELAY_PREF, 240 ppref = purple_plugin_pref_new_with_name_and_label(DELAY_PREF,
238 _("User Inactivity Timeout (in minutes)")); 241 _("User Inactivity Timeout (in minutes)"));
239 purple_plugin_pref_set_bounds(ppref, 0, 8 * 60); /* 8 Hours */ 242 purple_plugin_pref_set_bounds(ppref, 0, 8 * 60); /* 8 Hours */
243 purple_plugin_pref_frame_add(frame, ppref);
244
245 ppref = purple_plugin_pref_new_with_name_and_label(HIDE_BUDDIES_PREF,
246 _("Apply hiding rules to buddies"));
240 purple_plugin_pref_frame_add(frame, ppref); 247 purple_plugin_pref_frame_add(frame, ppref);
241 248
242 return frame; 249 return frame;
243 } 250 }
244 251
298 { 305 {
299 purple_prefs_add_none("/plugins/core/joinpart"); 306 purple_prefs_add_none("/plugins/core/joinpart");
300 307
301 purple_prefs_add_int(DELAY_PREF, DELAY_DEFAULT); 308 purple_prefs_add_int(DELAY_PREF, DELAY_DEFAULT);
302 purple_prefs_add_int(THRESHOLD_PREF, THRESHOLD_DEFAULT); 309 purple_prefs_add_int(THRESHOLD_PREF, THRESHOLD_DEFAULT);
310 purple_prefs_add_bool(HIDE_BUDDIES_PREF, HIDE_BUDDIES_DEFAULT);
303 } 311 }
304 312
305 PURPLE_INIT_PLUGIN(joinpart, init_plugin, info) 313 PURPLE_INIT_PLUGIN(joinpart, init_plugin, info)