Mercurial > pidgin
comparison src/conversation.c @ 6407:ba0b99a72be2
[gaim-migrate @ 6913]
Added API commands for adding or removing a batch of users at once to/from
a chat. IRC no longer has half a billion "Diablo-D3 has entered the room."
messages anymore.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 07 Aug 2003 20:47:29 +0000 |
parents | 96de6d9eb422 |
children | 874a5c9f4eb8 |
comparison
equal
deleted
inserted
replaced
6406:efaff39618a5 | 6407:ba0b99a72be2 |
---|---|
1930 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); | 1930 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
1931 } | 1931 } |
1932 } | 1932 } |
1933 | 1933 |
1934 void | 1934 void |
1935 gaim_chat_add_users(GaimChat *chat, GList *users) | |
1936 { | |
1937 GaimConversation *conv; | |
1938 GaimConversationUiOps *ops; | |
1939 GList *l; | |
1940 | |
1941 g_return_if_fail(chat != NULL); | |
1942 g_return_if_fail(users != NULL); | |
1943 | |
1944 conv = gaim_chat_get_conversation(chat); | |
1945 ops = gaim_conversation_get_ui_ops(conv); | |
1946 | |
1947 for (l = users; l != NULL; l = l->next) { | |
1948 gaim_chat_set_users(chat, | |
1949 g_list_insert_sorted(gaim_chat_get_users(chat), | |
1950 g_strdup((char *)l->data), | |
1951 insertname_compare)); | |
1952 | |
1953 gaim_event_broadcast(event_chat_buddy_join, | |
1954 gaim_conversation_get_gc(conv), gaim_chat_get_id(chat), | |
1955 (char *)l->data); | |
1956 } | |
1957 | |
1958 if (ops != NULL && ops->chat_add_users != NULL) | |
1959 ops->chat_add_users(conv, users); | |
1960 } | |
1961 | |
1962 void | |
1935 gaim_chat_rename_user(GaimChat *chat, const char *old_user, | 1963 gaim_chat_rename_user(GaimChat *chat, const char *old_user, |
1936 const char *new_user) | 1964 const char *new_user) |
1937 { | 1965 { |
1938 GaimConversation *conv; | 1966 GaimConversation *conv; |
1939 GaimConversationUiOps *ops; | 1967 GaimConversationUiOps *ops; |
2019 _("%s left the room (%s)."), user, reason); | 2047 _("%s left the room (%s)."), user, reason); |
2020 else | 2048 else |
2021 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user); | 2049 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user); |
2022 | 2050 |
2023 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); | 2051 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); |
2052 } | |
2053 } | |
2054 | |
2055 void | |
2056 gaim_chat_remove_users(GaimChat *chat, GList *users, const char *reason) | |
2057 { | |
2058 GaimConversation *conv; | |
2059 GaimConversationUiOps *ops; | |
2060 char tmp[BUF_LONG]; | |
2061 GList *names, *l; | |
2062 | |
2063 g_return_if_fail(chat != NULL); | |
2064 g_return_if_fail(users != NULL); | |
2065 | |
2066 conv = gaim_chat_get_conversation(chat); | |
2067 ops = gaim_conversation_get_ui_ops(conv); | |
2068 | |
2069 for (l = users; l != NULL; l = l->next) { | |
2070 gaim_event_broadcast(event_chat_buddy_leave, | |
2071 gaim_conversation_get_gc(conv), | |
2072 gaim_chat_get_id(chat), l->data); | |
2073 } | |
2074 | |
2075 if (ops != NULL && ops->chat_remove_users != NULL) | |
2076 ops->chat_remove_users(conv, users); | |
2077 | |
2078 for (l = users; l != NULL; l = l->next) { | |
2079 for (names = gaim_chat_get_users(chat); | |
2080 names != NULL; | |
2081 names = names->next) { | |
2082 | |
2083 if (!gaim_utf8_strcasecmp((char *)names->data, (char *)l->data)) { | |
2084 gaim_chat_set_users(chat, | |
2085 g_list_remove(gaim_chat_get_users(chat), names->data)); | |
2086 | |
2087 break; | |
2088 } | |
2089 } | |
2090 } | |
2091 | |
2092 /* NOTE: Don't remove them from ignored in case they re-enter. */ | |
2093 | |
2094 if (gaim_prefs_get_bool("/core/conversations/chat/show_leave")) { | |
2095 if (reason != NULL && *reason != '\0') { | |
2096 int i; | |
2097 int size = g_list_length(users); | |
2098 int max = MIN(10, size); | |
2099 GList *l; | |
2100 | |
2101 *tmp = '\0'; | |
2102 | |
2103 for (l = users, i = 0; i < max; i++, l = l->next) { | |
2104 g_strlcat(tmp, (char *)l->data, sizeof(tmp)); | |
2105 | |
2106 if (i < max - 1) | |
2107 g_strlcat(tmp, ", ", sizeof(tmp)); | |
2108 } | |
2109 | |
2110 if (size > 10) | |
2111 g_snprintf(tmp, sizeof(tmp), | |
2112 _("(+%d more)"), size - 10); | |
2113 | |
2114 g_snprintf(tmp, sizeof(tmp), _(" left the room (%s)."), reason); | |
2115 | |
2116 gaim_conversation_write(conv, NULL, tmp, -1, | |
2117 WFLAG_SYSTEM, time(NULL)); | |
2118 } | |
2024 } | 2119 } |
2025 } | 2120 } |
2026 | 2121 |
2027 GaimConversation * | 2122 GaimConversation * |
2028 gaim_find_chat(const GaimConnection *gc, int id) | 2123 gaim_find_chat(const GaimConnection *gc, int id) |