comparison src/conversation.c @ 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 8b2451878e26
children 03be9d653123
comparison
equal deleted inserted replaced
9586:70fe6ef5d3a3 9587:5e1c76f3d232
1900 { 1900 {
1901 GaimConversation *conv; 1901 GaimConversation *conv;
1902 GaimConversationUiOps *ops; 1902 GaimConversationUiOps *ops;
1903 GaimConvChatBuddy *cb; 1903 GaimConvChatBuddy *cb;
1904 char tmp[BUF_LONG]; 1904 char tmp[BUF_LONG];
1905 gboolean quiet;
1905 1906
1906 g_return_if_fail(chat != NULL); 1907 g_return_if_fail(chat != NULL);
1907 g_return_if_fail(user != NULL); 1908 g_return_if_fail(user != NULL);
1908 1909
1909 conv = gaim_conv_chat_get_conversation(chat); 1910 conv = gaim_conv_chat_get_conversation(chat);
1910 ops = gaim_conversation_get_ui_ops(conv); 1911 ops = gaim_conversation_get_ui_ops(conv);
1911 1912
1912 gaim_signal_emit(gaim_conversations_get_handle(), 1913 quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(),
1913 "chat-buddy-joining", conv, user); 1914 "chat-buddy-joining", conv, user, flags));
1914 1915
1915 cb = gaim_conv_chat_cb_new(user, flags); 1916 cb = gaim_conv_chat_cb_new(user, flags);
1916 1917
1917 gaim_conv_chat_set_users(chat, 1918 gaim_conv_chat_set_users(chat,
1918 g_list_append(gaim_conv_chat_get_users(chat), cb)); 1919 g_list_append(gaim_conv_chat_get_users(chat), cb));
1919 1920
1920 if (ops != NULL && ops->chat_add_user != NULL) 1921 if (ops != NULL && ops->chat_add_user != NULL)
1921 ops->chat_add_user(conv, user); 1922 ops->chat_add_user(conv, user);
1922 1923
1923 if (extra_msg == NULL) 1924 if (!quiet) {
1924 g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user); 1925 if (extra_msg == NULL)
1925 else 1926 g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user);
1926 g_snprintf(tmp, sizeof(tmp), 1927 else
1927 _("%s [<I>%s</I>] entered the room."), 1928 g_snprintf(tmp, sizeof(tmp),
1928 user, extra_msg); 1929 _("%s [<I>%s</I>] entered the room."),
1929 1930 user, extra_msg);
1930 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); 1931
1932 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
1933 }
1931 1934
1932 gaim_signal_emit(gaim_conversations_get_handle(), 1935 gaim_signal_emit(gaim_conversations_get_handle(),
1933 "chat-buddy-joined", conv, user); 1936 "chat-buddy-joined", conv, user, flags);
1934 } 1937 }
1935 1938
1936 void 1939 void
1937 gaim_conv_chat_add_users(GaimConvChat *chat, GList *users, GList *flags) 1940 gaim_conv_chat_add_users(GaimConvChat *chat, GList *users, GList *flags)
1938 { 1941 {
2034 { 2037 {
2035 GaimConversation *conv; 2038 GaimConversation *conv;
2036 GaimConversationUiOps *ops; 2039 GaimConversationUiOps *ops;
2037 GaimConvChatBuddy *cb; 2040 GaimConvChatBuddy *cb;
2038 char tmp[BUF_LONG]; 2041 char tmp[BUF_LONG];
2042 gboolean quiet;
2039 2043
2040 g_return_if_fail(chat != NULL); 2044 g_return_if_fail(chat != NULL);
2041 g_return_if_fail(user != NULL); 2045 g_return_if_fail(user != NULL);
2042 2046
2043 conv = gaim_conv_chat_get_conversation(chat); 2047 conv = gaim_conv_chat_get_conversation(chat);
2044 ops = gaim_conversation_get_ui_ops(conv); 2048 ops = gaim_conversation_get_ui_ops(conv);
2045 2049
2046 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-leaving", 2050 quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(),
2047 conv, user, reason); 2051 "chat-buddy-leaving", conv, user, reason));
2048 2052
2049 if (ops != NULL && ops->chat_remove_user != NULL) 2053 if (ops != NULL && ops->chat_remove_user != NULL)
2050 ops->chat_remove_user(conv, user); 2054 ops->chat_remove_user(conv, user);
2051 2055
2052 cb = gaim_conv_chat_cb_find(chat, user); 2056 cb = gaim_conv_chat_cb_find(chat, user);
2057 gaim_conv_chat_cb_destroy(cb); 2061 gaim_conv_chat_cb_destroy(cb);
2058 } 2062 }
2059 2063
2060 /* NOTE: Don't remove them from ignored in case they re-enter. */ 2064 /* NOTE: Don't remove them from ignored in case they re-enter. */
2061 2065
2062 if (reason != NULL && *reason != '\0') 2066 if (!quiet) {
2063 g_snprintf(tmp, sizeof(tmp), 2067 if (reason != NULL && *reason != '\0')
2064 _("%s left the room (%s)."), user, reason); 2068 g_snprintf(tmp, sizeof(tmp),
2065 else 2069 _("%s left the room (%s)."), user, reason);
2066 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user); 2070 else
2067 2071 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user);
2068 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL)); 2072
2073 gaim_conversation_write(conv, NULL, tmp, GAIM_MESSAGE_SYSTEM, time(NULL));
2074 }
2069 2075
2070 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-left", 2076 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-left",
2071 conv, user, reason); 2077 conv, user, reason);
2072 } 2078 }
2073 2079
2077 GaimConversation *conv; 2083 GaimConversation *conv;
2078 GaimConversationUiOps *ops; 2084 GaimConversationUiOps *ops;
2079 GaimConvChatBuddy *cb; 2085 GaimConvChatBuddy *cb;
2080 char tmp[BUF_LONG]; 2086 char tmp[BUF_LONG];
2081 GList *l; 2087 GList *l;
2088 gboolean quiet;
2082 2089
2083 g_return_if_fail(chat != NULL); 2090 g_return_if_fail(chat != NULL);
2084 g_return_if_fail(users != NULL); 2091 g_return_if_fail(users != NULL);
2085 2092
2086 conv = gaim_conv_chat_get_conversation(chat); 2093 conv = gaim_conv_chat_get_conversation(chat);
2087 ops = gaim_conversation_get_ui_ops(conv); 2094 ops = gaim_conversation_get_ui_ops(conv);
2088 2095
2089 for (l = users; l != NULL; l = l->next) { 2096 for (l = users; l != NULL; l = l->next) {
2090 const char *user = (const char *)l->data; 2097 const char *user = (const char *)l->data;
2091 2098
2092 gaim_signal_emit(gaim_conversations_get_handle(), "chat-buddy-leaving", 2099 quiet = GPOINTER_TO_INT(gaim_signal_emit_return_1(gaim_conversations_get_handle(),
2093 conv, user, reason); 2100 "chat-buddy-leaving", conv, user, reason));
2094 } 2101 }
2095 2102
2096 if (ops != NULL && ops->chat_remove_users != NULL) 2103 if (ops != NULL && ops->chat_remove_users != NULL)
2097 ops->chat_remove_users(conv, users); 2104 ops->chat_remove_users(conv, users);
2098 2105
2111 conv, user, reason); 2118 conv, user, reason);
2112 } 2119 }
2113 2120
2114 /* NOTE: Don't remove them from ignored in case they re-enter. */ 2121 /* NOTE: Don't remove them from ignored in case they re-enter. */
2115 2122
2116 if (reason != NULL && *reason != '\0') { 2123 if (!quiet && reason != NULL && *reason != '\0') {
2117 int i; 2124 int i;
2118 int size = g_list_length(users); 2125 int size = g_list_length(users);
2119 int max = MIN(10, size); 2126 int max = MIN(10, size);
2120 GList *l; 2127 GList *l;
2121 2128
2879 gaim_marshal_VOID__POINTER, NULL, 1, 2886 gaim_marshal_VOID__POINTER, NULL, 1,
2880 gaim_value_new(GAIM_TYPE_SUBTYPE, 2887 gaim_value_new(GAIM_TYPE_SUBTYPE,
2881 GAIM_SUBTYPE_CONVERSATION)); 2888 GAIM_SUBTYPE_CONVERSATION));
2882 2889
2883 gaim_signal_register(handle, "chat-buddy-joining", 2890 gaim_signal_register(handle, "chat-buddy-joining",
2884 gaim_marshal_VOID__POINTER_POINTER_UINT, NULL, 3, 2891 gaim_marshal_BOOLEAN__POINTER_POINTER_UINT,
2892 gaim_value_new(GAIM_TYPE_BOOLEAN), 3,
2885 gaim_value_new(GAIM_TYPE_SUBTYPE, 2893 gaim_value_new(GAIM_TYPE_SUBTYPE,
2886 GAIM_SUBTYPE_CONVERSATION), 2894 GAIM_SUBTYPE_CONVERSATION),
2887 gaim_value_new(GAIM_TYPE_STRING), 2895 gaim_value_new(GAIM_TYPE_STRING),
2888 gaim_value_new(GAIM_TYPE_UINT)); 2896 gaim_value_new(GAIM_TYPE_UINT));
2889 2897
2901 gaim_value_new(GAIM_TYPE_STRING), 2909 gaim_value_new(GAIM_TYPE_STRING),
2902 gaim_value_new(GAIM_TYPE_UINT), 2910 gaim_value_new(GAIM_TYPE_UINT),
2903 gaim_value_new(GAIM_TYPE_UINT)); 2911 gaim_value_new(GAIM_TYPE_UINT));
2904 2912
2905 gaim_signal_register(handle, "chat-buddy-leaving", 2913 gaim_signal_register(handle, "chat-buddy-leaving",
2906 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, 2914 gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER,
2915 gaim_value_new(GAIM_TYPE_BOOLEAN), 3,
2907 gaim_value_new(GAIM_TYPE_SUBTYPE, 2916 gaim_value_new(GAIM_TYPE_SUBTYPE,
2908 GAIM_SUBTYPE_CONVERSATION), 2917 GAIM_SUBTYPE_CONVERSATION),
2909 gaim_value_new(GAIM_TYPE_STRING), 2918 gaim_value_new(GAIM_TYPE_STRING),
2910 gaim_value_new(GAIM_TYPE_STRING)); 2919 gaim_value_new(GAIM_TYPE_STRING));
2911 2920