Mercurial > pidgin
changeset 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 | 525cf7ecd919 |
children | 2af814f836e6 |
files | doc/blist-signals.dox plugins/ChangeLog.API plugins/signals-test.c plugins/statenotify.c plugins/ticker/ticker.c src/blist.c src/pounce.c src/signals.c src/signals.h src/status.c |
diffstat | 10 files changed, 138 insertions(+), 150 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/blist-signals.dox Mon Oct 31 20:35:59 2005 +0000 +++ b/doc/blist-signals.dox Mon Oct 31 22:02:30 2005 +0000 @@ -1,10 +1,8 @@ /** @page blist-signals Buddy List Signals @signals - @signal buddy-away - @signal buddy-back - @signal buddy-idle - @signal buddy-unidle + @signal buddy-status-changed + @signal buddy-idle-changed @signal buddy-signed-on @signal buddy-signed-off @signal update-idle @@ -16,55 +14,31 @@ <hr> - @signaldef buddy-away + @signaldef buddy-status-changed @signalproto -void (*buddy_away)(struct buddy *buddy); +void (*buddy_away)(GaimBuddy *buddy, GaimStatus *old_status, GaimStatus *status); @endsignalproto @signaldesc Emitted when a buddy on your buddy list goes away. - @param buddy The buddy that went away. + @param buddy The buddy that went away. + @param old_status The status that the buddy just changed from. + @param status The status that the buddy just changed to. @endsignaldef - @signaldef buddy-back + @signaldef buddy-idle-changed @signalproto -void (*buddy_back)(struct buddy *buddy); - @endsignalproto - @signaldesc - Emitted when a buddy on your buddy list comes back from being away. - @param buddy The buddy that came back from being away. - @endsignaldef - - @signaldef buddy-idle - @signalproto -void (*buddy_idle)(struct buddy *buddy); +void (*buddy_idle)(GaimBuddy *buddy, gboolean old_idle, gboolean idle); @endsignalproto @signaldesc Emitted when a buddy on your buddy list becomes idle. - @param buddy The buddy that became idle. - @endsignaldef - - @signaldef buddy-unidle - @signalproto -void (*buddy_unidle)(struct buddy *buddy); - @endsignalproto - @signaldesc - Emitted when a buddy on your buddy list returns from being idle. - @param buddy The buddy that returned from being idle. - @endsignaldef - - @signaldef buddy-idle-updated - @signalproto -void (*buddy_idle_updated)(struct buddy *buddy); - @endsignalproto - @signaldesc - Emitted when a buddy's idle time changes. The exceptions are when the - buddy goes from being idle to being unidle, or from unidle to idle. - @param buddy The buddy whose idle time changed. + @param buddy The buddy that became idle. + @param old_idle Whether the buddy was idle. + @param idle Whether the buddy is currently idle. @endsignaldef @signaldef buddy-signed-on @signalproto -void (*buddy_signed_on)(struct buddy *buddy); +void (*buddy_signed_on)(GaimBuddy *buddy); @endsignalproto @signaldesc Emitted when a buddy on your buddy list signs on. @@ -73,7 +47,7 @@ @signaldef buddy-signed-off @signalproto -void (*buddy_signed_off)(struct buddy *buddy); +void (*buddy_signed_off)(GaimBuddy *buddy); @endsignalproto @signaldesc Emitted when a buddy on your buddy list signs off.
--- a/plugins/ChangeLog.API Mon Oct 31 20:35:59 2005 +0000 +++ b/plugins/ChangeLog.API Mon Oct 31 22:02:30 2005 +0000 @@ -168,9 +168,17 @@ * "file-send-complete": See Doxygen docs for details. * "buddy-added": Self explanatory; see Doxygen docs for full details. * "buddy-removed": Self explanatory; see Doxygen docs for full details. - * "blist-node-aliased": an alias was set for a buddy, chat or contact. + * "blist-node-aliased": An alias was set for a buddy, chat or contact. + * "buddy-status-changed": A buddy changed status; see Doxygen docs for full details. + * "buddy-idle-changed": A buddy's idle status changed; see Doxygen docs for full details. See Doxygen docs for details. + Signals - Removed: + * "buddy-away": replaced by buddy-status-changed + * "buddy-back": replaced by buddy-status-changed + * "buddy-idle": replaced by buddy-idle-changed + * "buddy-unidle": replaced by buddy-idle-changed + version 1.5.0 (8/11/2005): * Added: gaim_xfer_conversation_write Writes a messages to a conversation window with the use
--- a/plugins/signals-test.c Mon Oct 31 20:35:59 2005 +0000 +++ b/plugins/signals-test.c Mon Oct 31 22:02:30 2005 +0000 @@ -82,27 +82,20 @@ * Buddy List subsystem signal callbacks **************************************************************************/ static void -buddy_away_cb(GaimBuddy *buddy, void *data) +buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, + GaimStatus *status, void *data) { - gaim_debug_misc("signals test", "buddy-away (%s)\n", buddy->name); + gaim_debug_misc("signals test", "buddy-status-changed (%s %s to %s)\n", + buddy->name, gaim_status_get_id(old_status), + gaim_status_get_id(status)); } static void -buddy_back_cb(GaimBuddy *buddy, void *data) -{ - gaim_debug_misc("signals test", "buddy-back (%s)\n", buddy->name); -} - -static void -buddy_idle_cb(GaimBuddy *buddy, void *data) +buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle, + void *data) { - gaim_debug_misc("signals test", "buddy-idle (%s)\n", buddy->name); -} - -static void -buddy_unidle_cb(GaimBuddy *buddy, void *data) -{ - gaim_debug_misc("signals test", "buddy-unidle (%s)\n", buddy->name); + gaim_debug_misc("signals test", "buddy-idle-changed (%s %s)\n", + buddy->name, old_idle ? "unidled" : "idled"); } static void @@ -585,14 +578,10 @@ plugin, GAIM_CALLBACK(buddy_icon_cached_cb), NULL); /* Buddy List subsystem signals */ - gaim_signal_connect(blist_handle, "buddy-away", - plugin, GAIM_CALLBACK(buddy_away_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-back", - plugin, GAIM_CALLBACK(buddy_back_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-idle", - plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-unidle", - plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-status-changed", + plugin, GAIM_CALLBACK(buddy_status_changed_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-idle-changed", + plugin, GAIM_CALLBACK(buddy_idle_changed_cb), NULL); gaim_signal_connect(blist_handle, "buddy-signed-on", plugin, GAIM_CALLBACK(buddy_signed_on_cb), NULL); gaim_signal_connect(blist_handle, "buddy-signed-off",
--- a/plugins/statenotify.c Mon Oct 31 20:35:59 2005 +0000 +++ b/plugins/statenotify.c Mon Oct 31 22:02:30 2005 +0000 @@ -36,31 +36,33 @@ } static void -buddy_away_cb(GaimBuddy *buddy, void *data) +buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, + GaimStatus *status, void *data) { - if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) - write_status(buddy, _("%s has gone away.")); + gboolean available, old_available; + + available = gaim_status_is_available(status); + old_available = gaim_status_is_available(old_status); + + if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) { + if (available && !old_available) + write_status(buddy, _("%s is no longer away.")); + else if (!available && old_available) + write_status(buddy, _("%s has gone away.")); + } } static void -buddy_unaway_cb(GaimBuddy *buddy, void *data) -{ - if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_away")) - write_status(buddy, _("%s is no longer away.")); -} - -static void -buddy_idle_cb(GaimBuddy *buddy, void *data) +buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle, + void *data) { - if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) - write_status(buddy, _("%s has become idle.")); -} - -static void -buddy_unidle_cb(GaimBuddy *buddy, void *data) -{ - if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) - write_status(buddy, _("%s is no longer idle.")); + if (gaim_prefs_get_bool("/plugins/core/statenotify/notify_idle")) { + if (idle) { + write_status(buddy, _("%s has become idle.")); + } else { + write_status(buddy, _("%s is no longer idle.")); + } + } } static void @@ -105,18 +107,14 @@ { void *blist_handle = gaim_blist_get_handle(); - gaim_signal_connect(blist_handle, "buddy-away", - plugin, GAIM_CALLBACK(buddy_away_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-back", - plugin, GAIM_CALLBACK(buddy_unaway_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-idle", - plugin, GAIM_CALLBACK(buddy_idle_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-unidle", - plugin, GAIM_CALLBACK(buddy_unidle_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-signed-on", - plugin, GAIM_CALLBACK(buddy_signon_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-signed-off", - plugin, GAIM_CALLBACK(buddy_signoff_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-status-changed", plugin, + GAIM_CALLBACK(buddy_status_changed_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-idle-changed", plugin, + GAIM_CALLBACK(buddy_idle_changed_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-signed-on", plugin, + GAIM_CALLBACK(buddy_signon_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-signed-off", plugin, + GAIM_CALLBACK(buddy_signoff_cb), NULL); return TRUE; }
--- a/plugins/ticker/ticker.c Mon Oct 31 20:35:59 2005 +0000 +++ b/plugins/ticker/ticker.c Mon Oct 31 22:02:30 2005 +0000 @@ -228,7 +228,7 @@ } static void -away_cb(GaimBuddy *b) +status_changed_cb(GaimBuddy *b, GaimStatus *os, GaimStatus *s) { if(buddy_ticker_find_buddy(b)) buddy_ticker_set_pixmap(b); @@ -279,10 +279,8 @@ plugin, GAIM_CALLBACK(buddy_signon_cb), NULL); gaim_signal_connect(blist_handle, "buddy-signed-off", plugin, GAIM_CALLBACK(buddy_signoff_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-away", - plugin, GAIM_CALLBACK(away_cb), NULL); - gaim_signal_connect(blist_handle, "buddy-back", - plugin, GAIM_CALLBACK(away_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-status-changed", + plugin, GAIM_CALLBACK(status_changed_cb), NULL); if (gaim_connections_get_all()) buddy_ticker_show();
--- a/src/blist.c Mon Oct 31 20:35:59 2005 +0000 +++ b/src/blist.c Mon Oct 31 22:02:30 2005 +0000 @@ -741,14 +741,10 @@ ((GaimContact*)((GaimBlistNode*)buddy)->parent)->online--; if (((GaimContact*)((GaimBlistNode*)buddy)->parent)->online == 0) ((GaimGroup *)((GaimBlistNode *)buddy)->parent->parent)->online--; - } else if (gaim_status_is_available(status) && - !gaim_status_is_available(old_status)) { - gaim_signal_emit(gaim_blist_get_handle(), "buddy-back", buddy); - - } else if (!gaim_status_is_available(status) && - gaim_status_is_available(old_status)) { - gaim_signal_emit(gaim_blist_get_handle(), "buddy-away", buddy); - + } else { + gaim_signal_emit(gaim_blist_get_handle(), + "buddy-status-changed", buddy, old_status, + status); } /* @@ -2122,10 +2118,9 @@ GaimPresence *gaim_buddy_get_presence(const GaimBuddy *buddy) { g_return_val_if_fail(buddy != NULL, NULL); - return buddy->presence; + return buddy->presence; } - GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy) { g_return_val_if_fail(buddy != NULL, NULL); @@ -2548,28 +2543,22 @@ { void *handle = gaim_blist_get_handle(); - gaim_signal_register(handle, "buddy-away", - gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_BLIST_BUDDY)); - - gaim_signal_register(handle, "buddy-back", - gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_BLIST_BUDDY)); - - gaim_signal_register(handle, "buddy-idle", - gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_BLIST_BUDDY)); - gaim_signal_register(handle, "buddy-unidle", - gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_BLIST_BUDDY)); - gaim_signal_register(handle, "buddy-idle-updated", - gaim_marshal_VOID__POINTER, NULL, 1, - gaim_value_new(GAIM_TYPE_SUBTYPE, - GAIM_SUBTYPE_BLIST_BUDDY)); + gaim_signal_register(handle, "buddy-status-changed", + gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, + 3, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_BLIST_BUDDY), + gaim_value_new(GAIM_TYPE_POINTER), + gaim_value_new(GAIM_TYPE_POINTER)); + + gaim_signal_register(handle, "buddy-idle-changed", + gaim_marshal_VOID__POINTER_INT_INT, NULL, + 3, + gaim_value_new(GAIM_TYPE_SUBTYPE, + GAIM_SUBTYPE_BLIST_BUDDY), + gaim_value_new(GAIM_TYPE_INT), + gaim_value_new(GAIM_TYPE_INT)); + gaim_signal_register(handle, "buddy-signed-on", gaim_marshal_VOID__POINTER, NULL, 1,
--- a/src/pounce.c Mon Oct 31 20:35:59 2005 +0000 +++ b/src/pounce.c Mon Oct 31 22:02:30 2005 +0000 @@ -949,6 +949,34 @@ } static void +buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status, + GaimStatus *status) +{ + gboolean old_available, available; + + available = gaim_status_is_available(status); + old_available = gaim_status_is_available(old_status); + + if (available && !old_available) + gaim_pounce_execute(buddy->account, buddy->name, + GAIM_POUNCE_AWAY_RETURN); + else if (!available && old_available) + gaim_pounce_execute(buddy->account, buddy->name, + GAIM_POUNCE_AWAY); +} + +static void +buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle) +{ + if (idle && !old_idle) + gaim_pounce_execute(buddy->account, buddy->name, + GAIM_POUNCE_IDLE); + else if (!idle && old_idle) + gaim_pounce_execute(buddy->account, buddy->name, + GAIM_POUNCE_IDLE_RETURN); +} + +static void buddy_typing_cb(GaimAccount *account, const char *name, void *data) { GaimConversation *conv; @@ -983,18 +1011,10 @@ pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, free_pounce_handler); - gaim_signal_connect(blist_handle, "buddy-idle", - handle, GAIM_CALLBACK(buddy_state_cb), - GINT_TO_POINTER(GAIM_POUNCE_IDLE)); - gaim_signal_connect(blist_handle, "buddy-unidle", - handle, GAIM_CALLBACK(buddy_state_cb), - GINT_TO_POINTER(GAIM_POUNCE_IDLE_RETURN)); - gaim_signal_connect(blist_handle, "buddy-away", - handle, GAIM_CALLBACK(buddy_state_cb), - GINT_TO_POINTER(GAIM_POUNCE_AWAY)); - gaim_signal_connect(blist_handle, "buddy-back", - handle, GAIM_CALLBACK(buddy_state_cb), - GINT_TO_POINTER(GAIM_POUNCE_AWAY_RETURN)); + gaim_signal_connect(blist_handle, "buddy-idle-changed", + handle, GAIM_CALLBACK(buddy_idle_changed_cb), NULL); + gaim_signal_connect(blist_handle, "buddy-status-changed", + handle, GAIM_CALLBACK(buddy_status_changed_cb), NULL); gaim_signal_connect(blist_handle, "buddy-signed-on", handle, GAIM_CALLBACK(buddy_state_cb), GINT_TO_POINTER(GAIM_POUNCE_SIGNON));
--- a/src/signals.c Mon Oct 31 20:35:59 2005 +0000 +++ b/src/signals.c Mon Oct 31 22:02:30 2005 +0000 @@ -639,6 +639,16 @@ ((void (*)(void *, guint, void *))cb)(arg1, arg2, data); } +void gaim_marshal_VOID__POINTER_INT_INT(GaimCallback cb, va_list args, + void *data, void **return_val) +{ + void *arg1 = va_arg(args, void *); + gint arg2 = va_arg(args, gint); + gint arg3 = va_arg(args, gint); + + ((void (*)(void *, gint, gint, void *))cb)(arg1, arg2, arg3, data); +} + void gaim_marshal_VOID__POINTER_POINTER(GaimCallback cb, va_list args, void *data, void **return_val)
--- a/src/signals.h Mon Oct 31 20:35:59 2005 +0000 +++ b/src/signals.h Mon Oct 31 22:02:30 2005 +0000 @@ -281,6 +281,8 @@ GaimCallback cb, va_list args, void *data, void **return_val); void gaim_marshal_VOID__POINTER_UINT( GaimCallback cb, va_list args, void *data, void **return_val); +void gaim_marshal_VOID__POINTER_INT_INT( + GaimCallback cb, va_list args, void *data, void **return_val); void gaim_marshal_VOID__POINTER_POINTER( GaimCallback cb, va_list args, void *data, void **return_val); void gaim_marshal_VOID__POINTER_POINTER_UINT(
--- a/src/status.c Mon Oct 31 20:35:59 2005 +0000 +++ b/src/status.c Mon Oct 31 22:02:30 2005 +0000 @@ -1263,8 +1263,6 @@ if (!old_idle && idle) { - gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle", buddy); - if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(buddy->account); @@ -1278,8 +1276,6 @@ } else if (old_idle && !idle) { - gaim_signal_emit(gaim_blist_get_handle(), "buddy-unidle", buddy); - if (gaim_prefs_get_bool("/core/logging/log_system")) { GaimLog *log = gaim_account_get_log(buddy->account); @@ -1292,6 +1288,10 @@ } } + if (old_idle != idle) + gaim_signal_emit(gaim_blist_get_handle(), "buddy-idle-changed", buddy, + old_idle, idle); + gaim_contact_invalidate_priority_buddy(gaim_buddy_get_contact(buddy)); if (ops != NULL && ops->update != NULL)