src/conversation.c

changeset 5545
a8b1a1262402
parent 5539
a13dd0ba205a
child 5563
d5a7852aa0cb
equal deleted inserted replaced
5544:5b623486acb2 5545:a8b1a1262402
370 gaim_im_write(im, NULL, bigbuf, length, 370 gaim_im_write(im, NULL, bigbuf, length,
371 WFLAG_SEND, time(NULL)); 371 WFLAG_SEND, time(NULL));
372 else 372 else
373 gaim_im_write(im, NULL, buffy, -1, WFLAG_SEND, 373 gaim_im_write(im, NULL, buffy, -1, WFLAG_SEND,
374 time(NULL)); 374 time(NULL));
375
376 if (im_options & OPT_IM_POPDOWN)
377 gaim_window_hide(gaim_conversation_get_window(conv));
378 } 375 }
379 376
380 if (binary) 377 if (binary)
381 g_free(bigbuf); 378 g_free(bigbuf);
382 } 379 }
383 else { 380 else {
384 err = serv_send_im(gc, (char *)gaim_conversation_get_name(conv), 381 err = serv_send_im(gc, (char *)gaim_conversation_get_name(conv),
385 buffy, -1, imflags); 382 buffy, -1, imflags);
386 383
387 if (err > 0) { 384 if (err > 0)
388 gaim_im_write(im, NULL, buf, -1, WFLAG_SEND, time(NULL)); 385 gaim_im_write(im, NULL, buf, -1, WFLAG_SEND, time(NULL));
389
390 if (im_options & OPT_IM_POPDOWN)
391 gaim_window_hide(gaim_conversation_get_window(conv));
392 }
393 } 386 }
394 387
395 g_free(buffy); 388 g_free(buffy);
396 } 389 }
397 } 390 }
415 else { 408 else {
416 gaim_notify_error(NULL, NULL, _("Unable to send message."), NULL); 409 gaim_notify_error(NULL, NULL, _("Unable to send message."), NULL);
417 } 410 }
418 } 411 }
419 else { 412 else {
420 if (err > 0 && (away_options & OPT_AWAY_BACK_ON_IM)) { 413 if (err > 0 &&
414 gaim_prefs_get_bool("/core/conversations/away_back_on_send")) {
415
421 if (awaymessage != NULL) { 416 if (awaymessage != NULL) {
422 do_im_back(); 417 do_im_back();
423 } 418 }
424 else if (gc->away) { 419 else if (gc->away) {
425 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL); 420 serv_set_away(gc, GAIM_AWAY_CUSTOM, NULL);
891 conv->u.im->conv = conv; 886 conv->u.im->conv = conv;
892 887
893 ims = g_list_append(ims, conv); 888 ims = g_list_append(ims, conv);
894 889
895 gaim_conversation_set_logging(conv, 890 gaim_conversation_set_logging(conv,
896 (logging_options & OPT_LOG_CONVOS)); 891 gaim_prefs_get_bool("/gaim/gtk/logging/log_conversations"));
897 } 892 }
898 else if (type == GAIM_CONV_CHAT) 893 else if (type == GAIM_CONV_CHAT)
899 { 894 {
900 conv->u.chat = g_malloc0(sizeof(struct gaim_chat)); 895 conv->u.chat = g_malloc0(sizeof(struct gaim_chat));
901 conv->u.chat->conv = conv; 896 conv->u.chat->conv = conv;
902 897
903 chats = g_list_append(chats, conv); 898 chats = g_list_append(chats, conv);
904 899
905 gaim_conversation_set_logging(conv, (logging_options & OPT_LOG_CHATS)); 900 gaim_conversation_set_logging(conv,
901 gaim_prefs_get_bool("/gaim/gtk/logging/log_chats"));
906 } 902 }
907 903
908 conversations = g_list_append(conversations, conv); 904 conversations = g_list_append(conversations, conv);
909 905
910 /* Auto-set the title. */ 906 /* Auto-set the title. */
913 /* 909 /*
914 * Create a window if one does not exist. If it does, use the last 910 * Create a window if one does not exist. If it does, use the last
915 * created window. 911 * created window.
916 */ 912 */
917 if (windows == NULL || 913 if (windows == NULL ||
918 (type == GAIM_CONV_IM && !(im_options & OPT_IM_ONE_WINDOW)) || 914 !gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) {
919 (type == GAIM_CONV_CHAT && !(chat_options & OPT_CHAT_ONE_WINDOW))) { 915
920 struct gaim_window *win; 916 struct gaim_window *win;
921 917
922 win = gaim_window_new(); 918 win = gaim_window_new();
923 gaim_window_add_conversation(win, conv); 919 gaim_window_add_conversation(win, conv);
924 920
958 if (gc) { 954 if (gc) {
959 /* Still connected */ 955 /* Still connected */
960 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 956 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
961 957
962 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { 958 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
963 if (!(misc_options & OPT_MISC_STEALTH_TYPING)) 959 if (gaim_prefs_get_bool("/core/conversations/im/send_typing"))
964 serv_send_typing(gc, (char *)name, NOT_TYPING); 960 serv_send_typing(gc, (char *)name, NOT_TYPING);
965 961
966 if (gc && prpl_info->convo_closed != NULL) 962 if (gc && prpl_info->convo_closed != NULL)
967 prpl_info->convo_closed(gc, (char *)name); 963 prpl_info->convo_closed(gc, (char *)name);
968 } 964 }
1177 return; 1173 return;
1178 1174
1179 account = gaim_conversation_get_account(conv); 1175 account = gaim_conversation_get_account(conv);
1180 name = gaim_conversation_get_name(conv); 1176 name = gaim_conversation_get_name(conv);
1181 1177
1182 if (((im_options & OPT_IM_ALIAS_TAB) == OPT_IM_ALIAS_TAB) && 1178 if (gaim_prefs_get_bool("/core/conversations/use_alias_for_title") &&
1183 account != NULL && ((b = gaim_find_buddy(account, name)) != NULL)) { 1179 account != NULL && ((b = gaim_find_buddy(account, name)) != NULL)) {
1184 1180
1185 text = gaim_get_buddy_alias(b); 1181 text = gaim_get_buddy_alias(b);
1186 } 1182 }
1187 else 1183 else
1488 1484
1489 ops->write_conv(conv, who, message, length, flags, mtime); 1485 ops->write_conv(conv, who, message, length, flags, mtime);
1490 1486
1491 win = gaim_conversation_get_window(conv); 1487 win = gaim_conversation_get_window(conv);
1492 1488
1493 if (!(flags & WFLAG_NOLOG) &&
1494 ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT &&
1495 (chat_options & OPT_CHAT_POPUP)) ||
1496 (gaim_conversation_get_type(conv) == GAIM_CONV_IM &&
1497 ((im_options & OPT_IM_POPUP) || (im_options & OPT_IM_POPDOWN))))) {
1498
1499 gaim_window_show(win);
1500 }
1501
1502 /* Tab highlighting */ 1489 /* Tab highlighting */
1503 if (!(flags & WFLAG_RECV) && !(flags & WFLAG_SYSTEM)) 1490 if (!(flags & WFLAG_RECV) && !(flags & WFLAG_SYSTEM))
1504 return; 1491 return;
1505 1492
1506 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { 1493 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) {
1699 return; 1686 return;
1700 1687
1701 c = gaim_im_get_conversation(im); 1688 c = gaim_im_get_conversation(im);
1702 1689
1703 /* Raise the window, if specified in prefs. */ 1690 /* Raise the window, if specified in prefs. */
1704 if (!(flags & WFLAG_NOLOG) & (im_options & OPT_IM_POPUP))
1705 gaim_window_raise(gaim_conversation_get_window(c));
1706
1707 if (c->ui_ops != NULL && c->ui_ops->write_im != NULL) 1691 if (c->ui_ops != NULL && c->ui_ops->write_im != NULL)
1708 c->ui_ops->write_im(c, who, message, len, flags, mtime); 1692 c->ui_ops->write_im(c, who, message, len, flags, mtime);
1709 else 1693 else
1710 gaim_conversation_write(c, who, message, -1, flags, mtime); 1694 gaim_conversation_write(c, who, message, -1, flags, mtime);
1711 } 1695 }
1904 gc = gaim_conversation_get_gc(conv); 1888 gc = gaim_conversation_get_gc(conv);
1905 1889
1906 /* Don't display this if the person who wrote it is ignored. */ 1890 /* Don't display this if the person who wrote it is ignored. */
1907 if (gaim_chat_is_user_ignored(chat, who)) 1891 if (gaim_chat_is_user_ignored(chat, who))
1908 return; 1892 return;
1909
1910 /* Raise the window, if specified in prefs. */
1911 if (!(flags & WFLAG_NOLOG) & (chat_options & OPT_CHAT_POPUP))
1912 gaim_window_raise(gaim_conversation_get_window(conv));
1913 1893
1914 if (!(flags & WFLAG_WHISPER)) { 1894 if (!(flags & WFLAG_WHISPER)) {
1915 char *str; 1895 char *str;
1916 1896
1917 str = g_strdup(normalize(who)); 1897 str = g_strdup(normalize(who));
1970 user); 1950 user);
1971 1951
1972 if (ops != NULL && ops->chat_add_user != NULL) 1952 if (ops != NULL && ops->chat_add_user != NULL)
1973 ops->chat_add_user(conv, user); 1953 ops->chat_add_user(conv, user);
1974 1954
1975 if (chat_options & OPT_CHAT_LOGON) { 1955 if (gaim_prefs_get_bool("/core/conversations/chat/show_join")) {
1976 if (extra_msg == NULL) 1956 if (extra_msg == NULL)
1977 g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user); 1957 g_snprintf(tmp, sizeof(tmp), _("%s entered the room."), user);
1978 else 1958 else
1979 g_snprintf(tmp, sizeof(tmp), 1959 g_snprintf(tmp, sizeof(tmp),
1980 _("%s [<I>%s</I>] entered the room."), 1960 _("%s [<I>%s</I>] entered the room."),
2022 gaim_chat_ignore(chat, new_user); 2002 gaim_chat_ignore(chat, new_user);
2023 } 2003 }
2024 else if (gaim_chat_is_user_ignored(chat, new_user)) 2004 else if (gaim_chat_is_user_ignored(chat, new_user))
2025 gaim_chat_unignore(chat, new_user); 2005 gaim_chat_unignore(chat, new_user);
2026 2006
2027 if (chat_options & OPT_CHAT_LOGON) { 2007 if (gaim_prefs_get_bool("/core/conversations/chat/show_nick_change")) {
2028 g_snprintf(tmp, sizeof(tmp), 2008 g_snprintf(tmp, sizeof(tmp),
2029 _("%s is now known as %s"), old_user, new_user); 2009 _("%s is now known as %s"), old_user, new_user);
2030 2010
2031 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL)); 2011 gaim_conversation_write(conv, NULL, tmp, -1, WFLAG_SYSTEM, time(NULL));
2032 } 2012 }
2064 } 2044 }
2065 } 2045 }
2066 2046
2067 /* NOTE: Don't remove them from ignored in case they re-enter. */ 2047 /* NOTE: Don't remove them from ignored in case they re-enter. */
2068 2048
2069 if (chat_options & OPT_CHAT_LOGON) { 2049 if (gaim_prefs_get_bool("/core/conversations/chat/show_leave")) {
2070 if (reason != NULL && *reason != '\0') 2050 if (reason != NULL && *reason != '\0')
2071 g_snprintf(tmp, sizeof(tmp), 2051 g_snprintf(tmp, sizeof(tmp),
2072 _("%s left the room (%s)."), user, reason); 2052 _("%s left the room (%s)."), user, reason);
2073 else 2053 else
2074 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user); 2054 g_snprintf(tmp, sizeof(tmp), _("%s left the room."), user);
2101 static void 2081 static void
2102 conv_placement_last_created_win(struct gaim_conversation *conv) 2082 conv_placement_last_created_win(struct gaim_conversation *conv)
2103 { 2083 {
2104 struct gaim_window *win; 2084 struct gaim_window *win;
2105 2085
2106 if (convo_options & OPT_CONVO_COMBINE) 2086 if (gaim_prefs_get_bool("/core/conversations/combine_chat_im"))
2107 win = g_list_last(gaim_get_windows())->data; 2087 win = g_list_last(gaim_get_windows())->data;
2108 else 2088 else
2109 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv)); 2089 win = gaim_get_last_window_with_type(gaim_conversation_get_type(conv));
2110 2090
2111 if (win == NULL) { 2091 if (win == NULL) {
2221 convs != NULL; 2201 convs != NULL;
2222 convs = convs->next) { 2202 convs = convs->next) {
2223 2203
2224 conv2 = (struct gaim_conversation *)convs->data; 2204 conv2 = (struct gaim_conversation *)convs->data;
2225 2205
2226 if (((convo_options & OPT_CONVO_COMBINE) || 2206 if ((gaim_prefs_get_bool("/core/conversations/combine_chat_im") ||
2227 type == gaim_conversation_get_type(conv2)) && 2207 type == gaim_conversation_get_type(conv2)) &&
2228 account == gaim_conversation_get_account(conv2)) { 2208 account == gaim_conversation_get_account(conv2)) {
2209
2229 gaim_window_add_conversation(win2, conv); 2210 gaim_window_add_conversation(win2, conv);
2230 return; 2211 return;
2231 } 2212 }
2232 2213
2233 } 2214 }
2234 } 2215 }
2216
2235 /* Make a new window. */ 2217 /* Make a new window. */
2236 conv_placement_new_window(conv); 2218 conv_placement_new_window(conv);
2237 } 2219 }
2238 2220
2239 static int 2221 static int

mercurial