Mercurial > pidgin
comparison plugins/statenotify.c @ 11935:cb73483c9f63
[gaim-migrate @ 14226]
Here are buddy-status-changed and buddy-idle-changed signals, to replace
buddy-away, buddy-back, buddy-idle, and buddy-unidle. It it now possible to
detect when a buddy goes from one away-state to another away-state without
coming back in between.
I'm not really sure I like how buddy-idle-changed works here, but it felt
better to keep it consistent. It currently only fires on idle and unidle and
not on just-more-idle, though that's easy to change if we decide plugins might
want to know as idle time increases.
I think I got all the doxygen and ChangeLog.API stuff, someone yell if I
missed something.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Mon, 31 Oct 2005 22:02:30 +0000 |
parents | 077f956e41a1 |
children | e856f985a0b9 |
comparison
equal
deleted
inserted
replaced
11934:525cf7ecd919 | 11935:cb73483c9f63 |
---|---|
34 | 34 |
35 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); | 35 gaim_conversation_write(conv, NULL, buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
36 } | 36 } |
37 | 37 |
38 static void | 38 static void |
39 buddy_away_cb(GaimBuddy *buddy, void *data) | 39 buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, |
40 GaimStatus *status, void *data) | |
40 { | 41 { |
41 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) | 42 gboolean available, old_available; |
42 write_status(buddy, _("%s has gone away.")); | 43 |
44 available = gaim_status_is_available(status); | |
45 old_available = gaim_status_is_available(old_status); | |
46 | |
47 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) { | |
48 if (available && !old_available) | |
49 write_status(buddy, _("%s is no longer away.")); | |
50 else if (!available && old_available) | |
51 write_status(buddy, _("%s has gone away.")); | |
52 } | |
43 } | 53 } |
44 | 54 |
45 static void | 55 static void |
46 buddy_unaway_cb(GaimBuddy *buddy, void *data) | 56 buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle, |
57 void *data) | |
47 { | 58 { |
48 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) | 59 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { |
49 write_status(buddy, _("%s is no longer away.")); | 60 if (idle) { |
50 } | 61 write_status(buddy, _("%s has become idle.")); |
51 | 62 } else { |
52 static void | 63 write_status(buddy, _("%s is no longer idle.")); |
53 buddy_idle_cb(GaimBuddy *buddy, void *data) | 64 } |
54 { | 65 } |
55 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) | |
56 write_status(buddy, _("%s has become idle.")); | |
57 } | |
58 | |
59 static void | |
60 buddy_unidle_cb(GaimBuddy *buddy, void *data) | |
61 { | |
62 if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) | |
63 write_status(buddy, _("%s is no longer idle.")); | |
64 } | 66 } |
65 | 67 |
66 static void | 68 static void |
67 buddy_signon_cb(GaimBuddy *buddy, void *data) | 69 buddy_signon_cb(GaimBuddy *buddy, void *data) |
68 { | 70 { |
103 static gboolean | 105 static gboolean |
104 plugin_load(GaimPlugin *plugin) | 106 plugin_load(GaimPlugin *plugin) |
105 { | 107 { |
106 void *blist_handle = gaim_blist_get_handle(); | 108 void *blist_handle = gaim_blist_get_handle(); |
107 | 109 |
108 gaim_signal_connect(blist_handle, "buddy-away", | 110 gaim_signal_connect(blist_handle, "buddy-status-changed", plugin, |
109 plugin, GAIM_CALLBACK(buddy_away_cb), NULL); | 111 GAIM_CALLBACK(buddy_status_changed_cb), NULL); |
110 gaim_signal_connect(blist_handle, "buddy-back", | 112 gaim_signal_connect(blist_handle, "buddy-idle-changed", plugin, |
111 plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); | 113 GAIM_CALLBACK(buddy_idle_changed_cb), NULL); |
112 gaim_signal_connect(blist_handle, "buddy-idle", | 114 gaim_signal_connect(blist_handle, "buddy-signed-on", plugin, |
113 plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); | 115 GAIM_CALLBACK(buddy_signon_cb), NULL); |
114 gaim_signal_connect(blist_handle, "buddy-unidle", | 116 gaim_signal_connect(blist_handle, "buddy-signed-off", plugin, |
115 plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); | 117 GAIM_CALLBACK(buddy_signoff_cb), NULL); |
116 gaim_signal_connect(blist_handle, "buddy-signed-on", | |
117 plugin, GAIM_CALLBACK(buddy_signon_cb), NULL); | |
118 gaim_signal_connect(blist_handle, "buddy-signed-off", | |
119 plugin, GAIM_CALLBACK(buddy_signoff_cb), NULL); | |
120 | 118 |
121 return TRUE; | 119 return TRUE; |
122 } | 120 } |
123 | 121 |
124 static GaimPluginUiInfo prefs_info = | 122 static GaimPluginUiInfo prefs_info = |