Mercurial > pidgin.yaz
changeset 9587:5e1c76f3d232
[gaim-migrate @ 10430]
" These 2 patches (one or the other, they are mutually
exclusive) fix a slight bug in the
gaim_conv_chat_add_user (it was not emitting the user's
flags in the chat joining/joined signals).
The 1st patch (gaim-0.81cvs-chat-join-signal-fix.patch)
just fixes that bug, and nothing else.
The 2nd patch
(gaim-0.81cvs-chat-join-signal-fix-and-change.patch)
also changes the joining/leaving signals to boolean
signals to allow a plugin to optionally prevent the
display of users joining and leaving chats. This would
allow us to respond to "How do I turn off the display
of users joinging and leaving a chat?" with "Write a
plugin", instead of "You can't"." --Stu Tomlinson - nosnilmot
should we be updating the ChangeLog.API?
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 24 Jul 2004 15:26:09 +0000 |
parents | 70fe6ef5d3a3 |
children | bb722a784568 |
files | doc/conversation-signals.dox plugins/signals-test.c src/conversation.c |
diffstat | 3 files changed, 44 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/conversation-signals.dox Sat Jul 24 15:22:19 2004 +0000 +++ b/doc/conversation-signals.dox Sat Jul 24 15:26:09 2004 +0000 @@ -331,12 +331,13 @@ @signaldef chat-buddy-joining @signalproto -void (*chat_buddy_joining)(GaimConversation *conv, const char *name, +gboolean (*chat_buddy_joining)(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags); @endsignalproto @signaldesc Emitted when a buddy is joining a chat, before the list of users in the chat updates to include the new user. + @return @c TRUE if the join should be hidden, or @c FALSE otherwise. @param conv The chat conversation. @param name The name of the user that is joining the conversation. @param flags The flags of the user that is joining the conversation. @@ -370,12 +371,13 @@ @signaldef chat-buddy-leaving @signalproto -void (*chat_buddy_leaving)(GaimConversation *conv, const char *name, +gboolean (*chat_buddy_leaving)(GaimConversation *conv, const char *name, const char *reason); @endsignalproto @signaldesc Emitted when a user is leaving a chat, before the user list is updated. This may include an optional reason why the user is leaving. + @return @c TRUE if the leave should be hidden, or @c FALSE otherwise. @param conv The chat conversation. @param name The name of the user that is leaving the chat. @param reason The optional reason why the user is leaving.
--- a/plugins/signals-test.c Sat Jul 24 15:22:19 2004 +0000 +++ b/plugins/signals-test.c Sat Jul 24 15:26:09 2004 +0000 @@ -344,12 +344,14 @@ gaim_conversation_get_name(conv)); } -static void +static gboolean chat_buddy_joining_cb(GaimConversation *conv, const char *user, GaimConvChatBuddyFlags flags, void *data) { gaim_debug_misc("signals test", "chat-buddy-joining (%s, %s, %d)\n", gaim_conversation_get_name(conv), user, flags); + + return FALSE; } static void @@ -368,12 +370,14 @@ gaim_conversation_get_name(conv), user, oldflags, newflags); } -static void +static gboolean chat_buddy_leaving_cb(GaimConversation *conv, const char *user, const char *reason, void *data) { gaim_debug_misc("signals test", "chat-buddy-leaving (%s, %s, %s)\n", gaim_conversation_get_name(conv), user, reason); + + return FALSE; } static void
--- a/src/conversation.c Sat Jul 24 15:22:19 2004 +0000 +++ b/src/conversation.c Sat Jul 24 15:26:09 2004 +0000 @@ -1902,6 +1902,7 @@ GaimConversationUiOps *ops; GaimConvChatBuddy *cb; char tmp[BUF_LONG]; + gboolean quiet; g_return_if_fail(chat != NULL); g_return_if_fail(user != NULL); @@ -1909,8 +1910,8 @@ conv = gaim_conv_chat_get_conversation(chat); ops = gaim_conversation_get_ui_ops(conv); - gaim_signal_emit(gaim_conversations_get_handle(), - "chat-buddy-joining", conv, user); + quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(), + "chat-buddy-joining", conv, user, flags)); cb = gaim_conv_chat_cb_new(user, flags); @@ -1920,17 +1921,19 @@ if (ops != NULL && ops->chat_add_user != NULL) ops->chat_add_user(conv, user); - if (extra_msg == NULL) - g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user); - else - g_snprintf(tmp, sizeof(tmp), - _("%s [<I>%s</I>] entered the room."), - user, extra_msg); - - gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); + if (!quiet) { + if (extra_msg == NULL) + g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user); + else + g_snprintf(tmp, sizeof(tmp), + _("%s [<I>%s</I>] entered the room."), + user, extra_msg); + + gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); + } gaim_signal_emit(gaim_conversations_get_handle(), - "chat-buddy-joined", conv, user); + "chat-buddy-joined", conv, user, flags); } void @@ -2036,6 +2039,7 @@ GaimConversationUiOps *ops; GaimConvChatBuddy *cb; char tmp[BUF_LONG]; + gboolean quiet; g_return_if_fail(chat != NULL); g_return_if_fail(user != NULL); @@ -2043,8 +2047,8 @@ conv = gaim_conv_chat_get_conversation(chat); ops = gaim_conversation_get_ui_ops(conv); - gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-leaving", - conv, user, reason); + quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(), + "chat-buddy-leaving", conv, user, reason)); if (ops != NULL && ops->chat_remove_user != NULL) ops->chat_remove_user(conv, user); @@ -2059,13 +2063,15 @@ /* NOTE: Don't remove them from ignored in case they re-enter. */ - if (reason != NULL && *reason != '\0') - g_snprintf(tmp, sizeof(tmp), - _("%s left the room (%s)."), user, reason); - else - g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user); - - gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); + if (!quiet) { + if (reason != NULL && *reason != '\0') + g_snprintf(tmp, sizeof(tmp), + _("%s left the room (%s)."), user, reason); + else + g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user); + + gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); + } gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-left", conv, user, reason); @@ -2079,6 +2085,7 @@ GaimConvChatBuddy *cb; char tmp[BUF_LONG]; GList *l; + gboolean quiet; g_return_if_fail(chat != NULL); g_return_if_fail(users != NULL); @@ -2089,8 +2096,8 @@ for (l = users; l != NULL; l = l->next) { const char *user = (const char *)l->data; - gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-leaving", - conv, user, reason); + quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(), + "chat-buddy-leaving", conv, user, reason)); } if (ops != NULL && ops->chat_remove_users != NULL) @@ -2113,7 +2120,7 @@ /* NOTE: Don't remove them from ignored in case they re-enter. */ - if (reason != NULL && *reason != '\0') { + if (!quiet && reason != NULL && *reason != '\0') { int i; int size = g_list_length(users); int max = MIN(10, size); @@ -2881,7 +2888,8 @@ GAIM_SUBTYPE_CONVERSATION)); gaim_signal_register(handle, "chat-buddy-joining", - gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, + gaim_marshal_BOOLEAN__POINTER_POINTER_UINT, + gaim_value_new(GAIM_TYPE_BOOLEAN), 3, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONVERSATION), gaim_value_new(GAIM_TYPE_STRING), @@ -2903,7 +2911,8 @@ gaim_value_new(GAIM_TYPE_UINT)); gaim_signal_register(handle, "chat-buddy-leaving", - gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, + gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER, + gaim_value_new(GAIM_TYPE_BOOLEAN), 3, gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONVERSATION), gaim_value_new(GAIM_TYPE_STRING),