Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 32827:4a34689eeb33 default tip
merged from im.pidgin.pidgin
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Sat, 19 Nov 2011 14:42:54 +0900 |
parents | 0f94ec89f0bc 3bcc868c6c8e |
children |
comparison
equal
deleted
inserted
replaced
32692:0f94ec89f0bc | 32827:4a34689eeb33 |
---|---|
238 } | 238 } |
239 | 239 |
240 static PurpleBlistNode * | 240 static PurpleBlistNode * |
241 get_conversation_blist_node(PurpleConversation *conv) | 241 get_conversation_blist_node(PurpleConversation *conv) |
242 { | 242 { |
243 PurpleAccount *account = purple_conversation_get_account(conv); | |
243 PurpleBlistNode *node = NULL; | 244 PurpleBlistNode *node = NULL; |
244 | 245 |
245 switch (purple_conversation_get_type(conv)) { | 246 switch (purple_conversation_get_type(conv)) { |
246 case PURPLE_CONV_TYPE_IM: | 247 case PURPLE_CONV_TYPE_IM: |
247 node = PURPLE_BLIST_NODE(purple_find_buddy(conv->account, conv->name)); | 248 node = PURPLE_BLIST_NODE(purple_find_buddy(account, purple_conversation_get_name(conv))); |
248 node = node ? node->parent : NULL; | 249 node = node ? node->parent : NULL; |
249 break; | 250 break; |
250 case PURPLE_CONV_TYPE_CHAT: | 251 case PURPLE_CONV_TYPE_CHAT: |
251 node = PURPLE_BLIST_NODE(purple_blist_find_chat(conv->account, conv->name)); | 252 node = PURPLE_BLIST_NODE(purple_blist_find_chat(account, purple_conversation_get_name(conv))); |
252 break; | 253 break; |
253 default: | 254 default: |
254 break; | 255 break; |
255 } | 256 } |
256 return node; | 257 return node; |
355 | 356 |
356 static void | 357 static void |
357 default_formatize(PidginConversation *c) | 358 default_formatize(PidginConversation *c) |
358 { | 359 { |
359 PurpleConversation *conv = c->active_conv; | 360 PurpleConversation *conv = c->active_conv; |
360 gtk_imhtml_setup_entry(GTK_IMHTML(c->entry), conv->features); | 361 gtk_imhtml_setup_entry(GTK_IMHTML(c->entry), purple_conversation_get_features(conv)); |
361 } | 362 } |
362 | 363 |
363 static void | 364 static void |
364 conversation_entry_clear(PidginConversation *gtkconv) | 365 conversation_entry_clear(PidginConversation *gtkconv) |
365 { | 366 { |
616 case PURPLE_CMD_STATUS_NOT_FOUND: | 617 case PURPLE_CMD_STATUS_NOT_FOUND: |
617 { | 618 { |
618 PurplePluginProtocolInfo *prpl_info = NULL; | 619 PurplePluginProtocolInfo *prpl_info = NULL; |
619 PurpleConnection *gc; | 620 PurpleConnection *gc; |
620 | 621 |
621 if ((gc = purple_conversation_get_gc(conv))) | 622 if ((gc = purple_conversation_get_connection(conv))) |
622 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 623 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
623 | 624 |
624 if ((prpl_info != NULL) && (prpl_info->options & OPT_PROTO_SLASH_COMMANDS_NATIVE)) { | 625 if ((prpl_info != NULL) && (prpl_info->options & OPT_PROTO_SLASH_COMMANDS_NATIVE)) { |
625 char *spaceslash; | 626 char *spaceslash; |
626 | 627 |
627 /* If the first word in the entered text has a '/' in it, then the user | 628 /* If the first word in the entered text has a '/' in it, then the user |
709 /* XXX: is there a better way to tell if the message has images? */ | 710 /* XXX: is there a better way to tell if the message has images? */ |
710 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | 711 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) |
711 flags |= PURPLE_MESSAGE_IMAGES; | 712 flags |= PURPLE_MESSAGE_IMAGES; |
712 | 713 |
713 gc = purple_account_get_connection(account); | 714 gc = purple_account_get_connection(account); |
714 if (gc && (conv->features & PURPLE_CONNECTION_NO_NEWLINES)) { | 715 if (gc && (purple_conversation_get_features(conv) & PURPLE_CONNECTION_NO_NEWLINES)) { |
715 char **bufs; | 716 char **bufs; |
716 int i; | 717 int i; |
717 | 718 |
718 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | 719 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); |
719 for (i = 0; bufs[i]; i++) { | 720 for (i = 0; bufs[i]; i++) { |
775 static void chat_do_info(PidginConversation *gtkconv, const char *who) | 776 static void chat_do_info(PidginConversation *gtkconv, const char *who) |
776 { | 777 { |
777 PurpleConversation *conv = gtkconv->active_conv; | 778 PurpleConversation *conv = gtkconv->active_conv; |
778 PurpleConnection *gc; | 779 PurpleConnection *gc; |
779 | 780 |
780 if ((gc = purple_conversation_get_gc(conv))) { | 781 if ((gc = purple_conversation_get_connection(conv))) { |
781 pidgin_retrieve_user_info_in_chat(gc, who, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv))); | 782 pidgin_retrieve_user_info_in_chat(gc, who, purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv))); |
782 } | 783 } |
783 } | 784 } |
784 | 785 |
785 | 786 |
787 info_cb(GtkWidget *widget, PidginConversation *gtkconv) | 788 info_cb(GtkWidget *widget, PidginConversation *gtkconv) |
788 { | 789 { |
789 PurpleConversation *conv = gtkconv->active_conv; | 790 PurpleConversation *conv = gtkconv->active_conv; |
790 | 791 |
791 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { | 792 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
792 pidgin_retrieve_user_info(purple_conversation_get_gc(conv), | 793 pidgin_retrieve_user_info(purple_conversation_get_connection(conv), |
793 purple_conversation_get_name(conv)); | 794 purple_conversation_get_name(conv)); |
794 gtk_widget_grab_focus(gtkconv->entry); | 795 gtk_widget_grab_focus(gtkconv->entry); |
795 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { | 796 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
796 /* Get info of the person currently selected in the GtkTreeView */ | 797 /* Get info of the person currently selected in the GtkTreeView */ |
797 PidginChatPane *gtkchat; | 798 PidginChatPane *gtkchat; |
875 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | 876 message = gtk_entry_get_text(GTK_ENTRY(info->message)); |
876 | 877 |
877 if (!g_ascii_strcasecmp(buddy, "")) | 878 if (!g_ascii_strcasecmp(buddy, "")) |
878 return; | 879 return; |
879 | 880 |
880 serv_chat_invite(purple_conversation_get_gc(conv), | 881 serv_chat_invite(purple_conversation_get_connection(conv), |
881 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), | 882 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), |
882 message, buddy); | 883 message, buddy); |
883 } | 884 } |
884 | 885 |
885 gtk_widget_destroy(invite_dialog); | 886 gtk_widget_destroy(invite_dialog); |
910 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) | 911 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
911 buddy = (PurpleBuddy *)node; | 912 buddy = (PurpleBuddy *)node; |
912 else | 913 else |
913 return; | 914 return; |
914 | 915 |
915 if (strcmp(convprotocol, purple_account_get_protocol_id(buddy->account))) | 916 if (strcmp(convprotocol, purple_account_get_protocol_id(purple_buddy_get_account(buddy)))) |
916 { | 917 { |
917 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, | 918 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, |
918 _("That buddy is not on the same protocol as this " | 919 _("That buddy is not on the same protocol as this " |
919 "chat."), NULL); | 920 "chat."), NULL); |
920 success = FALSE; | 921 success = FALSE; |
1146 static void | 1147 static void |
1147 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) | 1148 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
1148 { | 1149 { |
1149 PidginWindow *win = data; | 1150 PidginWindow *win = data; |
1150 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); | 1151 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); |
1151 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name); | 1152 PurpleAccount *account = purple_conversation_get_account(conv); |
1153 PurpleBuddy *buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); | |
1152 const char *name; | 1154 const char *name; |
1153 gchar *buf; | 1155 gchar *buf; |
1154 gchar *c; | 1156 gchar *c; |
1155 | 1157 |
1156 if (buddy != NULL) | 1158 if (buddy != NULL) |
1157 name = purple_buddy_get_contact_alias(buddy); | 1159 name = purple_buddy_get_contact_alias(buddy); |
1158 else | 1160 else |
1159 name = purple_normalize(conv->account, conv->name); | 1161 name = purple_normalize(account, purple_conversation_get_name(conv)); |
1160 | 1162 |
1161 buf = g_strdup_printf("%s.html", name); | 1163 buf = g_strdup_printf("%s.html", name); |
1162 for (c = buf ; *c ; c++) | 1164 for (c = buf ; *c ; c++) |
1163 { | 1165 { |
1164 if (*c == '/' || *c == '\\') | 1166 if (*c == '/' || *c == '\\') |
1268 { | 1270 { |
1269 PidginWindow *win = data; | 1271 PidginWindow *win = data; |
1270 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); | 1272 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); |
1271 | 1273 |
1272 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { | 1274 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
1273 serv_send_file(purple_conversation_get_gc(conv), purple_conversation_get_name(conv), NULL); | 1275 serv_send_file(purple_conversation_get_connection(conv), purple_conversation_get_name(conv), NULL); |
1274 } | 1276 } |
1275 | 1277 |
1276 } | 1278 } |
1277 | 1279 |
1278 static void | 1280 static void |
1280 { | 1282 { |
1281 PidginWindow *win = data; | 1283 PidginWindow *win = data; |
1282 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); | 1284 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); |
1283 | 1285 |
1284 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { | 1286 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
1285 purple_prpl_send_attention(purple_conversation_get_gc(conv), | 1287 int index; |
1286 purple_conversation_get_name(conv), 0); | 1288 if (widget == win->menu.get_attention) |
1289 index = 0; | |
1290 else | |
1291 index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "index")); | |
1292 purple_prpl_send_attention(purple_conversation_get_connection(conv), | |
1293 purple_conversation_get_name(conv), index); | |
1287 } | 1294 } |
1288 } | 1295 } |
1289 | 1296 |
1290 static void | 1297 static void |
1291 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) | 1298 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
1477 /* Enable logging first so the message below can be logged. */ | 1484 /* Enable logging first so the message below can be logged. */ |
1478 purple_conversation_set_logging(conv, TRUE); | 1485 purple_conversation_set_logging(conv, TRUE); |
1479 | 1486 |
1480 purple_conversation_write(conv, NULL, | 1487 purple_conversation_write(conv, NULL, |
1481 _("Logging started. Future messages in this conversation will be logged."), | 1488 _("Logging started. Future messages in this conversation will be logged."), |
1482 conv->logs ? (PURPLE_MESSAGE_SYSTEM) : | 1489 PURPLE_MESSAGE_SYSTEM, |
1483 (PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG), | |
1484 time(NULL)); | 1490 time(NULL)); |
1485 } | 1491 } |
1486 else | 1492 else |
1487 { | 1493 { |
1488 purple_conversation_write(conv, NULL, | 1494 purple_conversation_write(conv, NULL, |
1489 _("Logging stopped. Future messages in this conversation will not be logged."), | 1495 _("Logging stopped. Future messages in this conversation will not be logged."), |
1490 conv->logs ? (PURPLE_MESSAGE_SYSTEM) : | 1496 PURPLE_MESSAGE_SYSTEM, |
1491 (PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NO_LOG), | |
1492 time(NULL)); | 1497 time(NULL)); |
1493 | 1498 |
1494 /* Disable the logging second, so that the above message can be logged. */ | 1499 /* Disable the logging second, so that the above message can be logged. */ |
1495 purple_conversation_set_logging(conv, FALSE); | 1500 purple_conversation_set_logging(conv, FALSE); |
1496 } | 1501 } |
1497 | 1502 |
1498 /* Save the setting IFF it's different than the pref. */ | 1503 /* Save the setting IFF it's different than the pref. */ |
1499 switch (conv->type) | 1504 switch (purple_conversation_get_type(conv)) |
1500 { | 1505 { |
1501 case PURPLE_CONV_TYPE_IM: | 1506 case PURPLE_CONV_TYPE_IM: |
1502 if (logging == purple_prefs_get_bool("/purple/logging/log_ims")) | 1507 if (logging == purple_prefs_get_bool("/purple/logging/log_ims")) |
1503 purple_blist_node_remove_setting(node, "enable-logging"); | 1508 purple_blist_node_remove_setting(node, "enable-logging"); |
1504 else | 1509 else |
1566 g_return_if_fail(account != NULL); | 1571 g_return_if_fail(account != NULL); |
1567 | 1572 |
1568 gc = purple_account_get_connection(account); | 1573 gc = purple_account_get_connection(account); |
1569 g_return_if_fail(gc != NULL); | 1574 g_return_if_fail(gc != NULL); |
1570 | 1575 |
1571 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 1576 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
1572 | 1577 |
1573 if (prpl_info && prpl_info->get_cb_real_name) | 1578 if (prpl_info && prpl_info->get_cb_real_name) |
1574 real_who = prpl_info->get_cb_real_name(gc, | 1579 real_who = prpl_info->get_cb_real_name(gc, |
1575 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); | 1580 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); |
1576 | 1581 |
1617 menu_chat_send_file_cb(GtkWidget *w, PidginConversation *gtkconv) | 1622 menu_chat_send_file_cb(GtkWidget *w, PidginConversation *gtkconv) |
1618 { | 1623 { |
1619 PurplePluginProtocolInfo *prpl_info; | 1624 PurplePluginProtocolInfo *prpl_info; |
1620 PurpleConversation *conv = gtkconv->active_conv; | 1625 PurpleConversation *conv = gtkconv->active_conv; |
1621 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | 1626 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1622 PurpleConnection *gc = purple_conversation_get_gc(conv); | 1627 PurpleConnection *gc = purple_conversation_get_connection(conv); |
1623 gchar *real_who = NULL; | 1628 gchar *real_who = NULL; |
1624 | 1629 |
1625 g_return_if_fail(gc != NULL); | 1630 g_return_if_fail(gc != NULL); |
1626 | 1631 |
1627 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 1632 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
1628 | 1633 |
1629 if (prpl_info && prpl_info->get_cb_real_name) | 1634 if (prpl_info && prpl_info->get_cb_real_name) |
1630 real_who = prpl_info->get_cb_real_name(gc, | 1635 real_who = prpl_info->get_cb_real_name(gc, |
1631 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); | 1636 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); |
1632 | 1637 |
1697 create_chat_menu(PurpleConversation *conv, const char *who, PurpleConnection *gc) | 1702 create_chat_menu(PurpleConversation *conv, const char *who, PurpleConnection *gc) |
1698 { | 1703 { |
1699 static GtkWidget *menu = NULL; | 1704 static GtkWidget *menu = NULL; |
1700 PurplePluginProtocolInfo *prpl_info = NULL; | 1705 PurplePluginProtocolInfo *prpl_info = NULL; |
1701 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); | 1706 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); |
1707 PurpleAccount *account = purple_conversation_get_account(conv); | |
1702 gboolean is_me = FALSE; | 1708 gboolean is_me = FALSE; |
1703 GtkWidget *button; | 1709 GtkWidget *button; |
1704 PurpleBuddy *buddy = NULL; | 1710 PurpleBuddy *buddy = NULL; |
1705 | 1711 |
1706 if (gc != NULL) | 1712 if (gc != NULL) |
1707 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 1713 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
1708 | 1714 |
1709 /* | 1715 /* |
1710 * If a menu already exists, destroy it before creating a new one, | 1716 * If a menu already exists, destroy it before creating a new one, |
1711 * thus freeing-up the memory it occupied. | 1717 * thus freeing-up the memory it occupied. |
1712 */ | 1718 */ |
1713 if (menu) | 1719 if (menu) |
1714 gtk_widget_destroy(menu); | 1720 gtk_widget_destroy(menu); |
1715 | 1721 |
1716 if (!strcmp(chat->nick, purple_normalize(conv->account, who))) | 1722 if (!strcmp(purple_conv_chat_get_nick(chat), purple_normalize(account, who))) |
1717 is_me = TRUE; | 1723 is_me = TRUE; |
1718 | 1724 |
1719 menu = gtk_menu_new(); | 1725 menu = gtk_menu_new(); |
1720 | 1726 |
1721 if (!is_me) { | 1727 if (!is_me) { |
1777 else | 1783 else |
1778 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1784 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1779 } | 1785 } |
1780 | 1786 |
1781 if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { | 1787 if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
1782 if ((buddy = purple_find_buddy(conv->account, who)) != NULL) | 1788 if ((buddy = purple_find_buddy(account, who)) != NULL) |
1783 button = pidgin_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, | 1789 button = pidgin_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
1784 G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1790 G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1785 else | 1791 else |
1786 button = pidgin_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, | 1792 button = pidgin_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
1787 G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1793 G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1798 if (!get_mark_for_user(PIDGIN_CONVERSATION(conv), who)) | 1804 if (!get_mark_for_user(PIDGIN_CONVERSATION(conv), who)) |
1799 gtk_widget_set_sensitive(button, FALSE); | 1805 gtk_widget_set_sensitive(button, FALSE); |
1800 | 1806 |
1801 if (buddy != NULL) | 1807 if (buddy != NULL) |
1802 { | 1808 { |
1803 if (purple_account_is_connected(conv->account)) | 1809 if (purple_account_is_connected(account)) |
1804 pidgin_append_blist_node_proto_menu(menu, conv->account->gc, | 1810 pidgin_append_blist_node_proto_menu(menu, purple_account_get_connection(account), |
1805 (PurpleBlistNode *)buddy); | 1811 (PurpleBlistNode *)buddy); |
1806 pidgin_append_blist_node_extended_menu(menu, (PurpleBlistNode *)buddy); | 1812 pidgin_append_blist_node_extended_menu(menu, (PurpleBlistNode *)buddy); |
1807 gtk_widget_show_all(menu); | 1813 gtk_widget_show_all(menu); |
1808 } | 1814 } |
1809 | 1815 |
1825 gchar *who; | 1831 gchar *who; |
1826 | 1832 |
1827 gtkconv = PIDGIN_CONVERSATION(conv); | 1833 gtkconv = PIDGIN_CONVERSATION(conv); |
1828 gtkchat = gtkconv->u.chat; | 1834 gtkchat = gtkconv->u.chat; |
1829 account = purple_conversation_get_account(conv); | 1835 account = purple_conversation_get_account(conv); |
1830 gc = account->gc; | 1836 gc = purple_account_get_connection(account); |
1831 | 1837 |
1832 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | 1838 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
1833 | 1839 |
1834 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | 1840 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
1835 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | 1841 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) |
1861 gchar *who; | 1867 gchar *who; |
1862 int x, y; | 1868 int x, y; |
1863 | 1869 |
1864 gtkchat = gtkconv->u.chat; | 1870 gtkchat = gtkconv->u.chat; |
1865 account = purple_conversation_get_account(conv); | 1871 account = purple_conversation_get_account(conv); |
1866 gc = account->gc; | 1872 gc = purple_account_get_connection(account); |
1867 | 1873 |
1868 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | 1874 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
1869 | 1875 |
1870 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), | 1876 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
1871 event->x, event->y, &path, &column, &x, &y); | 1877 event->x, event->y, &path, &column, &x, &y); |
2333 { | 2339 { |
2334 PidginConversation *gtkconv; | 2340 PidginConversation *gtkconv; |
2335 PurpleConversation *old_conv; | 2341 PurpleConversation *old_conv; |
2336 GtkIMHtml *entry; | 2342 GtkIMHtml *entry; |
2337 const char *protocol_name; | 2343 const char *protocol_name; |
2344 PurpleConnectionFlags features; | |
2338 | 2345 |
2339 g_return_if_fail(conv != NULL); | 2346 g_return_if_fail(conv != NULL); |
2340 | 2347 |
2341 gtkconv = PIDGIN_CONVERSATION(conv); | 2348 gtkconv = PIDGIN_CONVERSATION(conv); |
2342 old_conv = gtkconv->active_conv; | 2349 old_conv = gtkconv->active_conv; |
2354 | 2361 |
2355 purple_conversation_set_logging(conv, | 2362 purple_conversation_set_logging(conv, |
2356 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); | 2363 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
2357 | 2364 |
2358 entry = GTK_IMHTML(gtkconv->entry); | 2365 entry = GTK_IMHTML(gtkconv->entry); |
2359 protocol_name = purple_account_get_protocol_name(conv->account); | 2366 protocol_name = purple_account_get_protocol_name(purple_conversation_get_account(conv)); |
2360 gtk_imhtml_set_protocol_name(entry, protocol_name); | 2367 gtk_imhtml_set_protocol_name(entry, protocol_name); |
2361 /* TODO WEBKIT: gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); */ | 2368 /* TODO WEBKIT: gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), protocol_name); */ |
2362 | 2369 |
2363 if (!(conv->features & PURPLE_CONNECTION_HTML)) | 2370 features = purple_conversation_get_features(conv); |
2371 if (!(features & PURPLE_CONNECTION_HTML)) | |
2364 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); | 2372 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
2365 else if (conv->features & PURPLE_CONNECTION_FORMATTING_WBFO && | 2373 else if (features & PURPLE_CONNECTION_FORMATTING_WBFO && |
2366 !(old_conv->features & PURPLE_CONNECTION_FORMATTING_WBFO)) | 2374 !(purple_conversation_get_features(old_conv) & PURPLE_CONNECTION_FORMATTING_WBFO)) |
2367 { | 2375 { |
2368 /* The old conversation allowed formatting on parts of the | 2376 /* The old conversation allowed formatting on parts of the |
2369 * buffer, but the new one only allows it on the whole | 2377 * buffer, but the new one only allows it on the whole |
2370 * buffer. This code saves the formatting from the current | 2378 * buffer. This code saves the formatting from the current |
2371 * position of the cursor, clears the formatting, then | 2379 * position of the cursor, clears the formatting, then |
2401 if (underline != underline2) | 2409 if (underline != underline2) |
2402 gtk_imhtml_toggle_underline(entry); | 2410 gtk_imhtml_toggle_underline(entry); |
2403 | 2411 |
2404 gtk_imhtml_toggle_fontface(entry, fontface); | 2412 gtk_imhtml_toggle_fontface(entry, fontface); |
2405 | 2413 |
2406 if (!(conv->features & PURPLE_CONNECTION_NO_FONTSIZE)) | 2414 if (!(features & PURPLE_CONNECTION_NO_FONTSIZE)) |
2407 gtk_imhtml_font_set_size(entry, fontsize); | 2415 gtk_imhtml_font_set_size(entry, fontsize); |
2408 | 2416 |
2409 gtk_imhtml_toggle_forecolor(entry, forecolor); | 2417 gtk_imhtml_toggle_forecolor(entry, forecolor); |
2410 | 2418 |
2411 if (!(conv->features & PURPLE_CONNECTION_NO_BGCOLOR)) | 2419 if (!(features & PURPLE_CONNECTION_NO_BGCOLOR)) |
2412 { | 2420 { |
2413 gtk_imhtml_toggle_backcolor(entry, backcolor); | 2421 gtk_imhtml_toggle_backcolor(entry, backcolor); |
2414 gtk_imhtml_toggle_background(entry, background); | 2422 gtk_imhtml_toggle_background(entry, background); |
2415 } | 2423 } |
2416 | 2424 |
2424 /* This is done in default_formatize, which is called from clear_formatting_cb, | 2432 /* This is done in default_formatize, which is called from clear_formatting_cb, |
2425 * which is (obviously) a clear_formatting signal handler. However, if we're | 2433 * which is (obviously) a clear_formatting signal handler. However, if we're |
2426 * here, we didn't call gtk_imhtml_clear_formatting() (because we want to | 2434 * here, we didn't call gtk_imhtml_clear_formatting() (because we want to |
2427 * preserve the formatting exactly as it is), so we have to do this now. */ | 2435 * preserve the formatting exactly as it is), so we have to do this now. */ |
2428 gtk_imhtml_set_whole_buffer_formatting_only(entry, | 2436 gtk_imhtml_set_whole_buffer_formatting_only(entry, |
2429 (conv->features & PURPLE_CONNECTION_FORMATTING_WBFO)); | 2437 (features & PURPLE_CONNECTION_FORMATTING_WBFO)); |
2430 } | 2438 } |
2431 | 2439 |
2432 purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv); | 2440 purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv); |
2433 | 2441 |
2434 gray_stuff_out(gtkconv); | 2442 gray_stuff_out(gtkconv); |
2489 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | 2497 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { |
2490 | 2498 |
2491 /* We deleted all the text, so turn off typing. */ | 2499 /* We deleted all the text, so turn off typing. */ |
2492 purple_conv_im_stop_send_typed_timeout(im); | 2500 purple_conv_im_stop_send_typed_timeout(im); |
2493 | 2501 |
2494 serv_send_typing(purple_conversation_get_gc(conv), | 2502 serv_send_typing(purple_conversation_get_connection(conv), |
2495 purple_conversation_get_name(conv), | 2503 purple_conversation_get_name(conv), |
2496 PURPLE_NOT_TYPING); | 2504 PURPLE_NOT_TYPING); |
2497 } | 2505 } |
2498 else { | 2506 else { |
2499 /* We're deleting, but not all of it, so it counts as typing. */ | 2507 /* We're deleting, but not all of it, so it counts as typing. */ |
2654 return; | 2662 return; |
2655 | 2663 |
2656 status = infopane_status = pidgin_conv_get_icon_stock(conv); | 2664 status = infopane_status = pidgin_conv_get_icon_stock(conv); |
2657 | 2665 |
2658 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { | 2666 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
2659 PurpleBuddy *b = purple_find_buddy(conv->account, conv->name); | 2667 PurpleBuddy *b = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); |
2660 if (b) | 2668 if (b) |
2661 emblem = pidgin_blist_get_emblem((PurpleBlistNode*)b); | 2669 emblem = pidgin_blist_get_emblem((PurpleBlistNode*)b); |
2662 } | 2670 } |
2663 | 2671 |
2664 g_return_if_fail(status != NULL); | 2672 g_return_if_fail(status != NULL); |
2675 CONV_EMBLEM_COLUMN, emblem, -1); | 2683 CONV_EMBLEM_COLUMN, emblem, -1); |
2676 if (emblem) | 2684 if (emblem) |
2677 g_object_unref(emblem); | 2685 g_object_unref(emblem); |
2678 | 2686 |
2679 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons")) { | 2687 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_protocol_icons")) { |
2680 emblem = pidgin_create_prpl_icon(gtkconv->active_conv->account, PIDGIN_PRPL_ICON_SMALL); | 2688 emblem = pidgin_create_prpl_icon(purple_conversation_get_account(gtkconv->active_conv), PIDGIN_PRPL_ICON_SMALL); |
2681 } else { | 2689 } else { |
2682 emblem = NULL; | 2690 emblem = NULL; |
2683 } | 2691 } |
2684 | 2692 |
2685 gtk_list_store_set(GTK_LIST_STORE(gtkconv->infopane_model), | 2693 gtk_list_store_set(GTK_LIST_STORE(gtkconv->infopane_model), |
2731 int size; | 2739 int size; |
2732 | 2740 |
2733 gtkconv = PIDGIN_CONVERSATION(conv); | 2741 gtkconv = PIDGIN_CONVERSATION(conv); |
2734 account = purple_conversation_get_account(conv); | 2742 account = purple_conversation_get_account(conv); |
2735 | 2743 |
2736 if (!(account && account->gc)) { | 2744 if (!(account && purple_account_get_connection(account))) { |
2737 gtkconv->u.im->icon_timer = 0; | 2745 gtkconv->u.im->icon_timer = 0; |
2738 return FALSE; | 2746 return FALSE; |
2739 } | 2747 } |
2740 | 2748 |
2741 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | 2749 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); |
2938 | 2946 |
2939 g_return_if_fail(conv != NULL); | 2947 g_return_if_fail(conv != NULL); |
2940 | 2948 |
2941 ext = purple_buddy_icon_get_extension(purple_conv_im_get_icon(PURPLE_CONV_IM(conv))); | 2949 ext = purple_buddy_icon_get_extension(purple_conv_im_get_icon(PURPLE_CONV_IM(conv))); |
2942 | 2950 |
2943 buf = g_strdup_printf("%s.%s", purple_normalize(conv->account, conv->name), ext); | 2951 buf = g_strdup_printf("%s.%s", purple_normalize(purple_conversation_get_account(conv), purple_conversation_get_name(conv)), ext); |
2944 | 2952 |
2945 purple_request_file(gtkconv, _("Save Icon"), buf, TRUE, | 2953 purple_request_file(gtkconv, _("Save Icon"), buf, TRUE, |
2946 G_CALLBACK(saveicon_writefile_cb), NULL, | 2954 G_CALLBACK(saveicon_writefile_cb), NULL, |
2947 conv->account, NULL, conv, | 2955 purple_conversation_get_account(conv), NULL, conv, |
2948 gtkconv); | 2956 gtkconv); |
2949 | 2957 |
2950 g_free(buf); | 2958 g_free(buf); |
2951 } | 2959 } |
2952 | 2960 |
3295 static gboolean | 3303 static gboolean |
3296 populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolean all) | 3304 populate_menu_with_options(GtkWidget *menu, PidginConversation *gtkconv, gboolean all) |
3297 { | 3305 { |
3298 GList *list; | 3306 GList *list; |
3299 PurpleConversation *conv; | 3307 PurpleConversation *conv; |
3308 PurpleAccount *account; | |
3300 PurpleBlistNode *node = NULL; | 3309 PurpleBlistNode *node = NULL; |
3301 PurpleChat *chat = NULL; | 3310 PurpleChat *chat = NULL; |
3302 PurpleBuddy *buddy = NULL; | 3311 PurpleBuddy *buddy = NULL; |
3303 gboolean ret; | 3312 gboolean ret; |
3304 | 3313 |
3305 conv = gtkconv->active_conv; | 3314 conv = gtkconv->active_conv; |
3315 account = purple_conversation_get_account(conv); | |
3306 | 3316 |
3307 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { | 3317 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
3308 chat = purple_blist_find_chat(conv->account, conv->name); | 3318 chat = purple_blist_find_chat(account, purple_conversation_get_name(conv)); |
3309 | 3319 |
3310 if ((chat == NULL) && (gtkconv->webview != NULL)) { | 3320 if ((chat == NULL) && (gtkconv->webview != NULL)) { |
3311 chat = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat"); | 3321 chat = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat"); |
3312 } | 3322 } |
3313 | 3323 |
3324 components = g_hash_table_new_full(g_str_hash, g_str_equal, | 3334 components = g_hash_table_new_full(g_str_hash, g_str_equal, |
3325 g_free, g_free); | 3335 g_free, g_free); |
3326 g_hash_table_replace(components, g_strdup("channel"), | 3336 g_hash_table_replace(components, g_strdup("channel"), |
3327 g_strdup(purple_conversation_get_name(conv))); | 3337 g_strdup(purple_conversation_get_name(conv))); |
3328 } | 3338 } |
3329 chat = purple_chat_new(conv->account, NULL, components); | 3339 chat = purple_chat_new(account, NULL, components); |
3330 purple_blist_node_set_flags((PurpleBlistNode *)chat, | 3340 purple_blist_node_set_flags((PurpleBlistNode *)chat, |
3331 PURPLE_BLIST_NODE_FLAG_NO_SAVE); | 3341 PURPLE_BLIST_NODE_FLAG_NO_SAVE); |
3332 g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_chat", | 3342 g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_chat", |
3333 chat, (GDestroyNotify)purple_blist_remove_chat); | 3343 chat, (GDestroyNotify)purple_blist_remove_chat); |
3334 } | 3344 } |
3335 } else { | 3345 } else { |
3336 if (!purple_account_is_connected(conv->account)) | 3346 if (!purple_account_is_connected(account)) |
3337 return FALSE; | 3347 return FALSE; |
3338 | 3348 |
3339 buddy = purple_find_buddy(conv->account, conv->name); | 3349 buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); |
3340 | 3350 |
3341 /* gotta remain bug-compatible :( libpurple < 2.0.2 didn't handle | 3351 /* gotta remain bug-compatible :( libpurple < 2.0.2 didn't handle |
3342 * removing "isolated" buddy nodes well */ | 3352 * removing "isolated" buddy nodes well */ |
3343 if (purple_version_check(2, 0, 2) == NULL) { | 3353 if (purple_version_check(2, 0, 2) == NULL) { |
3344 if ((buddy == NULL) && (gtkconv->webview != NULL)) { | 3354 if ((buddy == NULL) && (gtkconv->webview != NULL)) { |
3345 buddy = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_buddy"); | 3355 buddy = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_buddy"); |
3346 } | 3356 } |
3347 | 3357 |
3348 if ((buddy == NULL) && (gtkconv->webview != NULL)) { | 3358 if ((buddy == NULL) && (gtkconv->webview != NULL)) { |
3349 buddy = purple_buddy_new(conv->account, conv->name, NULL); | 3359 buddy = purple_buddy_new(account, purple_conversation_get_name(conv), NULL); |
3350 purple_blist_node_set_flags((PurpleBlistNode *)buddy, | 3360 purple_blist_node_set_flags((PurpleBlistNode *)buddy, |
3351 PURPLE_BLIST_NODE_FLAG_NO_SAVE); | 3361 PURPLE_BLIST_NODE_FLAG_NO_SAVE); |
3352 g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_buddy", | 3362 g_object_set_data_full(G_OBJECT(gtkconv->webview), "transient_buddy", |
3353 buddy, (GDestroyNotify)purple_buddy_destroy); | 3363 buddy, (GDestroyNotify)purple_buddy_destroy); |
3354 } | 3364 } |
3366 pidgin_blist_make_buddy_menu(menu, buddy, TRUE); | 3376 pidgin_blist_make_buddy_menu(menu, buddy, TRUE); |
3367 else if (chat) { | 3377 else if (chat) { |
3368 /* XXX: */ | 3378 /* XXX: */ |
3369 } | 3379 } |
3370 } else if (node) { | 3380 } else if (node) { |
3371 if (purple_account_is_connected(conv->account)) | 3381 if (purple_account_is_connected(account)) |
3372 pidgin_append_blist_node_proto_menu(menu, conv->account->gc, node); | 3382 pidgin_append_blist_node_proto_menu(menu, purple_account_get_connection(account), node); |
3373 pidgin_append_blist_node_extended_menu(menu, node); | 3383 pidgin_append_blist_node_extended_menu(menu, node); |
3374 } | 3384 } |
3375 | 3385 |
3376 if ((list = gtk_container_get_children(GTK_CONTAINER(menu))) == NULL) { | 3386 if ((list = gtk_container_get_children(GTK_CONTAINER(menu))) == NULL) { |
3377 ret = FALSE; | 3387 ret = FALSE; |
3437 } | 3447 } |
3438 #endif | 3448 #endif |
3439 } | 3449 } |
3440 | 3450 |
3441 static void | 3451 static void |
3452 regenerate_attention_items(PidginWindow *win) | |
3453 { | |
3454 GtkWidget *menu; | |
3455 PurpleConversation *conv; | |
3456 PurpleConnection *pc; | |
3457 PurplePlugin *prpl = NULL; | |
3458 PurplePluginProtocolInfo *prpl_info = NULL; | |
3459 GList *list; | |
3460 | |
3461 conv = pidgin_conv_window_get_active_conversation(win); | |
3462 if (!conv) | |
3463 return; | |
3464 | |
3465 /* Remove the previous entries */ | |
3466 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.get_attention), NULL); | |
3467 | |
3468 pc = purple_conversation_get_connection(conv); | |
3469 if (pc != NULL) | |
3470 prpl = purple_connection_get_prpl(pc); | |
3471 if (prpl != NULL) | |
3472 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); | |
3473 | |
3474 if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, get_attention_types)) { | |
3475 list = prpl_info->get_attention_types(purple_connection_get_account(pc)); | |
3476 | |
3477 /* Multiple attention types */ | |
3478 if (list && list->next) { | |
3479 int index = 0; | |
3480 | |
3481 menu = gtk_menu_new(); | |
3482 while (list) { | |
3483 PurpleAttentionType *type; | |
3484 GtkWidget *menuitem; | |
3485 | |
3486 type = list->data; | |
3487 | |
3488 menuitem = gtk_menu_item_new_with_label(purple_attention_type_get_name(type)); | |
3489 g_object_set_data(G_OBJECT(menuitem), "index", GINT_TO_POINTER(index)); | |
3490 g_signal_connect(G_OBJECT(menuitem), "activate", | |
3491 G_CALLBACK(menu_get_attention_cb), | |
3492 win); | |
3493 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3494 | |
3495 index++; | |
3496 list = g_list_delete_link(list, list); | |
3497 } | |
3498 | |
3499 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.get_attention), menu); | |
3500 gtk_widget_show_all(menu); | |
3501 } | |
3502 } | |
3503 } | |
3504 | |
3505 static void | |
3442 regenerate_options_items(PidginWindow *win) | 3506 regenerate_options_items(PidginWindow *win) |
3443 { | 3507 { |
3444 GtkWidget *menu; | 3508 GtkWidget *menu; |
3445 PidginConversation *gtkconv; | 3509 PidginConversation *gtkconv; |
3446 GList *list; | 3510 GList *list; |
3524 { | 3588 { |
3525 PidginWindow *win = data; | 3589 PidginWindow *win = data; |
3526 regenerate_media_items(win); | 3590 regenerate_media_items(win); |
3527 regenerate_options_items(win); | 3591 regenerate_options_items(win); |
3528 regenerate_plugins_items(win); | 3592 regenerate_plugins_items(win); |
3593 regenerate_attention_items(win); | |
3529 | 3594 |
3530 /* The following are to make sure the 'More' submenu is not regenerated every time | 3595 /* The following are to make sure the 'More' submenu is not regenerated every time |
3531 * the focus shifts from 'Conversations' to some other menu and back. */ | 3596 * the focus shifts from 'Conversations' to some other menu and back. */ |
3532 g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(menubar_activated), data); | 3597 g_signal_handlers_block_by_func(G_OBJECT(item), G_CALLBACK(menubar_activated), data); |
3533 g_signal_connect(G_OBJECT(win->menu.menubar), "deactivate", G_CALLBACK(focus_out_from_menubar), data); | 3598 g_signal_connect(G_OBJECT(win->menu.menubar), "deactivate", G_CALLBACK(focus_out_from_menubar), data); |
3596 | 3661 |
3597 win->menu.send_file = | 3662 win->menu.send_file = |
3598 gtk_item_factory_get_widget(win->menu.item_factory, | 3663 gtk_item_factory_get_widget(win->menu.item_factory, |
3599 N_("/Conversation/Send File...")); | 3664 N_("/Conversation/Send File...")); |
3600 | 3665 |
3601 g_object_set_data(G_OBJECT(win->window), "get_attention", | 3666 win->menu.get_attention = |
3602 gtk_item_factory_get_widget(win->menu.item_factory, | 3667 gtk_item_factory_get_widget(win->menu.item_factory, |
3603 N_("/Conversation/Get Attention"))); | 3668 N_("/Conversation/Get Attention")); |
3669 | |
3604 win->menu.add_pounce = | 3670 win->menu.add_pounce = |
3605 gtk_item_factory_get_widget(win->menu.item_factory, | 3671 gtk_item_factory_get_widget(win->menu.item_factory, |
3606 N_("/Conversation/Add Buddy Pounce...")); | 3672 N_("/Conversation/Add Buddy Pounce...")); |
3607 | 3673 |
3608 /* --- */ | 3674 /* --- */ |
3707 /* Check if we need to send another PURPLE_TYPING message */ | 3773 /* Check if we need to send another PURPLE_TYPING message */ |
3708 if (first || (purple_conv_im_get_type_again(im) != 0 && | 3774 if (first || (purple_conv_im_get_type_again(im) != 0 && |
3709 time(NULL) > purple_conv_im_get_type_again(im))) | 3775 time(NULL) > purple_conv_im_get_type_again(im))) |
3710 { | 3776 { |
3711 unsigned int timeout; | 3777 unsigned int timeout; |
3712 timeout = serv_send_typing(purple_conversation_get_gc(conv), | 3778 timeout = serv_send_typing(purple_conversation_get_connection(conv), |
3713 purple_conversation_get_name(conv), | 3779 purple_conversation_get_name(conv), |
3714 PURPLE_TYPING); | 3780 PURPLE_TYPING); |
3715 purple_conv_im_set_type_again(im, timeout); | 3781 purple_conv_im_set_type_again(im, timeout); |
3716 } | 3782 } |
3717 } | 3783 } |
3849 return FALSE; | 3915 return FALSE; |
3850 | 3916 |
3851 if (win->menu.send_to == NULL) | 3917 if (win->menu.send_to == NULL) |
3852 return FALSE; | 3918 return FALSE; |
3853 | 3919 |
3854 if (!(b = purple_find_buddy(account, conv->name))) | 3920 if (!(b = purple_find_buddy(account, purple_conversation_get_name(conv)))) |
3855 return FALSE; | 3921 return FALSE; |
3856 | 3922 |
3857 | 3923 |
3858 gtk_widget_show(win->menu.send_to); | 3924 gtk_widget_show(win->menu.send_to); |
3859 | 3925 |
4013 win->menu.send_to, 2); | 4079 win->menu.send_to, 2); |
4014 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | 4080 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); |
4015 | 4081 |
4016 gtk_widget_show(menu); | 4082 gtk_widget_show(menu); |
4017 | 4083 |
4018 if (gtkconv->active_conv->type == PURPLE_CONV_TYPE_IM) { | 4084 if (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_IM) { |
4019 buds = purple_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | 4085 buds = purple_find_buddies(purple_conversation_get_account(gtkconv->active_conv), purple_conversation_get_name(gtkconv->active_conv)); |
4020 | 4086 |
4021 if (buds == NULL) | 4087 if (buds == NULL) |
4022 { | 4088 { |
4023 /* The user isn't on the buddy list. So we don't create any sendto menu. */ | 4089 /* The user isn't on the buddy list. So we don't create any sendto menu. */ |
4024 } | 4090 } |
4039 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) | 4105 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) |
4040 continue; | 4106 continue; |
4041 | 4107 |
4042 account = purple_buddy_get_account(buddy); | 4108 account = purple_buddy_get_account(buddy); |
4043 /* TODO WEBKIT: (I'm not actually sure if this is webkit-related --Mark Doliner) */ | 4109 /* TODO WEBKIT: (I'm not actually sure if this is webkit-related --Mark Doliner) */ |
4044 if (purple_account_is_connected(account) /*|| account == gtkconv->active_conv->account*/) | 4110 if (purple_account_is_connected(account) /*|| account == purple_conversation_get_account(gtkconv->active_conv)*/) |
4045 { | 4111 { |
4046 /* Use the PurplePresence to get unique buddies. */ | 4112 /* Use the PurplePresence to get unique buddies. */ |
4047 PurplePresence *presence = purple_buddy_get_presence(buddy); | 4113 PurplePresence *presence = purple_buddy_get_presence(buddy); |
4048 if (!g_list_find_custom(list, presence, (GCompareFunc)compare_buddy_presence)) | 4114 if (!g_list_find_custom(list, presence, (GCompareFunc)compare_buddy_presence)) |
4049 list = g_list_prepend(list, presence); | 4115 list = g_list_prepend(list, presence); |
4098 } | 4164 } |
4099 | 4165 |
4100 static void | 4166 static void |
4101 deleting_chat_buddy_cb(PurpleConvChatBuddy *cb) | 4167 deleting_chat_buddy_cb(PurpleConvChatBuddy *cb) |
4102 { | 4168 { |
4103 if (cb->ui_data) { | 4169 GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(cb); |
4104 GtkTreeRowReference *ref = cb->ui_data; | 4170 |
4171 if (ref) { | |
4105 gtk_tree_row_reference_free(ref); | 4172 gtk_tree_row_reference_free(ref); |
4106 cb->ui_data = NULL; | 4173 purple_conv_chat_cb_set_ui_data(cb, NULL); |
4107 } | 4174 } |
4108 } | 4175 } |
4109 | 4176 |
4110 static void | 4177 static void |
4111 add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const char *old_name) | 4178 add_chat_buddy_common(PurpleConversation *conv, PurpleConvChatBuddy *cb, const char *old_name) |
4120 GtkTreePath *newpath; | 4187 GtkTreePath *newpath; |
4121 const char *stock; | 4188 const char *stock; |
4122 GtkTreeIter iter; | 4189 GtkTreeIter iter; |
4123 gboolean is_me = FALSE; | 4190 gboolean is_me = FALSE; |
4124 gboolean is_buddy; | 4191 gboolean is_buddy; |
4125 gchar *tmp, *alias_key, *name, *alias; | 4192 const gchar *name, *alias; |
4193 gchar *tmp, *alias_key; | |
4126 PurpleConvChatBuddyFlags flags; | 4194 PurpleConvChatBuddyFlags flags; |
4127 GdkColor *color = NULL; | 4195 GdkColor *color = NULL; |
4128 | 4196 |
4129 alias = cb->alias; | 4197 alias = purple_conv_chat_cb_get_alias(cb); |
4130 name = cb->name; | 4198 name = purple_conv_chat_cb_get_name(cb); |
4131 flags = cb->flags; | 4199 flags = purple_conv_chat_cb_get_flags(cb); |
4132 | 4200 |
4133 chat = PURPLE_CONV_CHAT(conv); | 4201 chat = PURPLE_CONV_CHAT(conv); |
4134 gtkconv = PIDGIN_CONVERSATION(conv); | 4202 gtkconv = PIDGIN_CONVERSATION(conv); |
4135 gtkchat = gtkconv->u.chat; | 4203 gtkchat = gtkconv->u.chat; |
4136 gc = purple_conversation_get_gc(conv); | 4204 gc = purple_conversation_get_connection(conv); |
4137 | 4205 |
4138 if (!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) | 4206 if (!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)))) |
4139 return; | 4207 return; |
4140 | 4208 |
4141 tm = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | 4209 tm = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4142 ls = GTK_LIST_STORE(tm); | 4210 ls = GTK_LIST_STORE(tm); |
4143 | 4211 |
4144 stock = get_chat_buddy_status_icon(chat, name, flags); | 4212 stock = get_chat_buddy_status_icon(chat, name, flags); |
4145 | 4213 |
4146 if (!strcmp(chat->nick, purple_normalize(conv->account, old_name != NULL ? old_name : name))) | 4214 if (!strcmp(purple_conv_chat_get_nick(chat), purple_normalize(purple_conversation_get_account(conv), old_name != NULL ? old_name : name))) |
4147 is_me = TRUE; | 4215 is_me = TRUE; |
4148 | 4216 |
4149 is_buddy = cb->buddy; | 4217 is_buddy = purple_conv_chat_cb_is_buddy(cb); |
4150 | 4218 |
4151 tmp = g_utf8_casefold(alias, -1); | 4219 tmp = g_utf8_casefold(alias, -1); |
4152 alias_key = g_utf8_collate_key(tmp, -1); | 4220 alias_key = g_utf8_collate_key(tmp, -1); |
4153 g_free(tmp); | 4221 g_free(tmp); |
4154 | 4222 |
4185 CHAT_USERS_FLAGS_COLUMN, flags, | 4253 CHAT_USERS_FLAGS_COLUMN, flags, |
4186 CHAT_USERS_COLOR_COLUMN, color, | 4254 CHAT_USERS_COLOR_COLUMN, color, |
4187 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, | 4255 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, |
4188 -1); | 4256 -1); |
4189 | 4257 |
4190 if (cb->ui_data) { | 4258 if (purple_conv_chat_cb_get_ui_data(cb)) { |
4191 GtkTreeRowReference *ref = cb->ui_data; | 4259 GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(cb); |
4192 gtk_tree_row_reference_free(ref); | 4260 gtk_tree_row_reference_free(ref); |
4193 } | 4261 } |
4194 | 4262 |
4195 newpath = gtk_tree_model_get_path(tm, &iter); | 4263 newpath = gtk_tree_model_get_path(tm, &iter); |
4196 cb->ui_data = gtk_tree_row_reference_new(tm, newpath); | 4264 purple_conv_chat_cb_set_ui_data(cb, gtk_tree_row_reference_new(tm, newpath)); |
4197 gtk_tree_path_free(newpath); | 4265 gtk_tree_path_free(newpath); |
4198 | 4266 |
4199 if (is_me && color) | 4267 if (is_me && color) |
4200 gdk_color_free(color); | 4268 gdk_color_free(color); |
4201 g_free(alias_key); | 4269 g_free(alias_key); |
4221 * @param name The buddy name or alias or slash command name that we're | 4289 * @param name The buddy name or alias or slash command name that we're |
4222 * checking for a match. | 4290 * checking for a match. |
4223 */ | 4291 */ |
4224 static void | 4292 static void |
4225 tab_complete_process_item(int *most_matched, const char *entered, gsize entered_bytes, char **partial, char *nick_partial, | 4293 tab_complete_process_item(int *most_matched, const char *entered, gsize entered_bytes, char **partial, char *nick_partial, |
4226 GList **matches, char *name) | 4294 GList **matches, const char *name) |
4227 { | 4295 { |
4228 memcpy(nick_partial, name, entered_bytes); | 4296 memcpy(nick_partial, name, entered_bytes); |
4229 if (purple_utf8_strcasecmp(nick_partial, entered)) | 4297 if (purple_utf8_strcasecmp(nick_partial, entered)) |
4230 return; | 4298 return; |
4231 | 4299 |
4343 int f; | 4411 int f; |
4344 | 4412 |
4345 /* Users */ | 4413 /* Users */ |
4346 for (; l != NULL; l = l->next) { | 4414 for (; l != NULL; l = l->next) { |
4347 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, | 4415 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, |
4348 &matches, ((PurpleConvChatBuddy *)l->data)->name); | 4416 &matches, purple_conv_chat_cb_get_name((PurpleConvChatBuddy *)l->data)); |
4349 } | 4417 } |
4350 | 4418 |
4351 | 4419 |
4352 /* Aliases */ | 4420 /* Aliases */ |
4353 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 4421 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
4441 PurpleConversation *conv = gtkconv->active_conv; | 4509 PurpleConversation *conv = gtkconv->active_conv; |
4442 PidginChatPane *gtkchat; | 4510 PidginChatPane *gtkchat; |
4443 char *new_topic; | 4511 char *new_topic; |
4444 const char *current_topic; | 4512 const char *current_topic; |
4445 | 4513 |
4446 gc = purple_conversation_get_gc(conv); | 4514 gc = purple_conversation_get_connection(conv); |
4447 | 4515 |
4448 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl))) | 4516 if(!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)))) |
4449 return; | 4517 return; |
4450 | 4518 |
4451 if(prpl_info->set_chat_topic == NULL) | 4519 if(prpl_info->set_chat_topic == NULL) |
4452 return; | 4520 return; |
4453 | 4521 |
4518 static void | 4586 static void |
4519 update_chat_alias(PurpleBuddy *buddy, PurpleConversation *conv, PurpleConnection *gc, PurplePluginProtocolInfo *prpl_info) | 4587 update_chat_alias(PurpleBuddy *buddy, PurpleConversation *conv, PurpleConnection *gc, PurplePluginProtocolInfo *prpl_info) |
4520 { | 4588 { |
4521 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); | 4589 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); |
4522 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); | 4590 PurpleConvChat *chat = PURPLE_CONV_CHAT(conv); |
4591 PurpleAccount *account = purple_conversation_get_account(conv); | |
4523 GtkTreeModel *model; | 4592 GtkTreeModel *model; |
4524 char *normalized_name; | 4593 char *normalized_name; |
4525 GtkTreeIter iter; | 4594 GtkTreeIter iter; |
4526 int f; | 4595 int f; |
4527 | 4596 |
4532 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list)); | 4601 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list)); |
4533 | 4602 |
4534 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 4603 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
4535 return; | 4604 return; |
4536 | 4605 |
4537 normalized_name = g_strdup(purple_normalize(conv->account, buddy->name)); | 4606 normalized_name = g_strdup(purple_normalize(account, purple_buddy_get_name(buddy))); |
4538 | 4607 |
4539 do { | 4608 do { |
4540 char *name; | 4609 char *name; |
4541 | 4610 |
4542 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); | 4611 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4543 | 4612 |
4544 if (!strcmp(normalized_name, purple_normalize(conv->account, name))) { | 4613 if (!strcmp(normalized_name, purple_normalize(account, name))) { |
4545 const char *alias = name; | 4614 const char *alias = name; |
4546 char *tmp; | 4615 char *tmp; |
4547 char *alias_key = NULL; | 4616 char *alias_key = NULL; |
4548 PurpleBuddy *buddy2; | 4617 PurpleBuddy *buddy2; |
4549 | 4618 |
4550 if (strcmp(chat->nick, purple_normalize(conv->account, name))) { | 4619 if (strcmp(purple_conv_chat_get_nick(chat), purple_normalize(account, name))) { |
4551 /* This user is not me, so look into updating the alias. */ | 4620 /* This user is not me, so look into updating the alias. */ |
4552 | 4621 |
4553 if ((buddy2 = purple_find_buddy(conv->account, name)) != NULL) { | 4622 if ((buddy2 = purple_find_buddy(account, name)) != NULL) { |
4554 alias = purple_buddy_get_contact_alias(buddy2); | 4623 alias = purple_buddy_get_contact_alias(buddy2); |
4555 } | 4624 } |
4556 | 4625 |
4557 tmp = g_utf8_casefold(alias, -1); | 4626 tmp = g_utf8_casefold(alias, -1); |
4558 alias_key = g_utf8_collate_key(tmp, -1); | 4627 alias_key = g_utf8_collate_key(tmp, -1); |
4583 PurplePluginProtocolInfo *prpl_info; | 4652 PurplePluginProtocolInfo *prpl_info; |
4584 | 4653 |
4585 g_return_if_fail(node != NULL); | 4654 g_return_if_fail(node != NULL); |
4586 g_return_if_fail(conv != NULL); | 4655 g_return_if_fail(conv != NULL); |
4587 | 4656 |
4588 gc = purple_conversation_get_gc(conv); | 4657 gc = purple_conversation_get_connection(conv); |
4589 g_return_if_fail(gc != NULL); | 4658 g_return_if_fail(gc != NULL); |
4590 g_return_if_fail(gc->prpl != NULL); | 4659 g_return_if_fail(purple_connection_get_prpl(gc) != NULL); |
4591 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 4660 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
4592 | 4661 |
4593 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) | 4662 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
4594 return; | 4663 return; |
4595 | 4664 |
4596 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) | 4665 if (PURPLE_BLIST_NODE_IS_CONTACT(node)) |
4606 } | 4675 } |
4607 } | 4676 } |
4608 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) | 4677 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) |
4609 update_chat_alias((PurpleBuddy *)node, conv, gc, prpl_info); | 4678 update_chat_alias((PurpleBuddy *)node, conv, gc, prpl_info); |
4610 else if (PURPLE_BLIST_NODE_IS_CHAT(node) && | 4679 else if (PURPLE_BLIST_NODE_IS_CHAT(node) && |
4611 purple_conversation_get_account(conv) == ((PurpleChat*)node)->account) | 4680 purple_conversation_get_account(conv) == purple_chat_get_account((PurpleChat*)node)) |
4612 { | 4681 { |
4613 if (old_alias == NULL || g_utf8_collate(old_alias, purple_conversation_get_title(conv)) == 0) | 4682 if (old_alias == NULL || g_utf8_collate(old_alias, purple_conversation_get_title(conv)) == 0) |
4614 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE); | 4683 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE); |
4615 } | 4684 } |
4616 } | 4685 } |
4635 model = gtk_tree_view_get_model(GTK_TREE_VIEW(PIDGIN_CONVERSATION(conv)->u.chat->list)); | 4704 model = gtk_tree_view_get_model(GTK_TREE_VIEW(PIDGIN_CONVERSATION(conv)->u.chat->list)); |
4636 | 4705 |
4637 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 4706 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
4638 return; | 4707 return; |
4639 | 4708 |
4640 normalized_name = g_strdup(purple_normalize(conv->account, buddy->name)); | 4709 normalized_name = g_strdup(purple_normalize(purple_conversation_get_account(conv), purple_buddy_get_name(buddy))); |
4641 | 4710 |
4642 do { | 4711 do { |
4643 char *name; | 4712 char *name; |
4644 | 4713 |
4645 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); | 4714 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4646 | 4715 |
4647 if (!strcmp(normalized_name, purple_normalize(conv->account, name))) { | 4716 if (!strcmp(normalized_name, purple_normalize(purple_conversation_get_account(conv), name))) { |
4648 gtk_list_store_set(GTK_LIST_STORE(model), &iter, | 4717 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
4649 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, -1); | 4718 CHAT_USERS_WEIGHT_COLUMN, is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, -1); |
4650 g_free(name); | 4719 g_free(name); |
4651 break; | 4720 break; |
4652 } | 4721 } |
4791 | 4860 |
4792 static void | 4861 static void |
4793 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) | 4862 setup_chat_topic(PidginConversation *gtkconv, GtkWidget *vbox) |
4794 { | 4863 { |
4795 PurpleConversation *conv = gtkconv->active_conv; | 4864 PurpleConversation *conv = gtkconv->active_conv; |
4796 PurpleConnection *gc = purple_conversation_get_gc(conv); | 4865 PurpleConnection *gc = purple_conversation_get_connection(conv); |
4797 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 4866 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
4798 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) | 4867 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4799 { | 4868 { |
4800 GtkWidget *hbox, *label; | 4869 GtkWidget *hbox, *label; |
4801 PidginChatPane *gtkchat = gtkconv->u.chat; | 4870 PidginChatPane *gtkchat = gtkconv->u.chat; |
4802 | 4871 |
4833 PurpleBlistNode *node; | 4902 PurpleBlistNode *node; |
4834 PurplePluginProtocolInfo *prpl_info; | 4903 PurplePluginProtocolInfo *prpl_info; |
4835 PurpleAccount *account = purple_conversation_get_account(conv); | 4904 PurpleAccount *account = purple_conversation_get_account(conv); |
4836 char *who = NULL; | 4905 char *who = NULL; |
4837 | 4906 |
4838 if (account->gc == NULL) | 4907 if (purple_account_get_connection(account) == NULL) |
4839 return FALSE; | 4908 return FALSE; |
4840 | 4909 |
4841 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path)) | 4910 if (!gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path)) |
4842 return FALSE; | 4911 return FALSE; |
4843 | 4912 |
4844 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); | 4913 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
4845 | 4914 |
4846 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | 4915 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(purple_account_get_connection(account))); |
4847 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, who)); | 4916 node = (PurpleBlistNode*)(purple_find_buddy(purple_conversation_get_account(conv), who)); |
4848 if (node && prpl_info && (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) | 4917 if (node && prpl_info && (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) |
4849 pidgin_blist_draw_tooltip(node, gtkconv->infopane); | 4918 pidgin_blist_draw_tooltip(node, gtkconv->infopane); |
4850 | 4919 |
4851 g_free(who); | 4920 g_free(who); |
4852 return FALSE; | 4921 return FALSE; |
4957 PurpleConversation *conv; | 5026 PurpleConversation *conv; |
4958 PidginConversation *gtkconv = userdata; | 5027 PidginConversation *gtkconv = userdata; |
4959 | 5028 |
4960 conv = gtkconv->active_conv; | 5029 conv = gtkconv->active_conv; |
4961 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { | 5030 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
4962 node = (PurpleBlistNode*)(purple_blist_find_chat(conv->account, conv->name)); | 5031 node = (PurpleBlistNode*)(purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv))); |
4963 if (!node) | 5032 if (!node) |
4964 node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat"); | 5033 node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat"); |
4965 } else { | 5034 } else { |
4966 node = (PurpleBlistNode*)(purple_find_buddy(conv->account, conv->name)); | 5035 node = (PurpleBlistNode*)(purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv))); |
4967 #if 0 | 5036 #if 0 |
4968 /* Using the transient blist nodes to show the tooltip doesn't quite work yet. */ | 5037 /* Using the transient blist nodes to show the tooltip doesn't quite work yet. */ |
4969 if (!node) | 5038 if (!node) |
4970 node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_buddy"); | 5039 node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_buddy"); |
4971 #endif | 5040 #endif |
5050 /* }}} */ | 5119 /* }}} */ |
5051 | 5120 |
5052 static char * | 5121 static char * |
5053 replace_header_tokens(PurpleConversation *conv, const char *text) | 5122 replace_header_tokens(PurpleConversation *conv, const char *text) |
5054 { | 5123 { |
5124 PurpleAccount *account = purple_conversation_get_account(conv); | |
5055 GString *str; | 5125 GString *str; |
5056 const char *cur = text; | 5126 const char *cur = text; |
5057 const char *prev = cur; | 5127 const char *prev = cur; |
5058 | 5128 |
5059 if (text == NULL || *text == '\0') | 5129 if (text == NULL || *text == '\0') |
5063 while ((cur = strchr(cur, '%'))) { | 5133 while ((cur = strchr(cur, '%'))) { |
5064 const char *replace = NULL; | 5134 const char *replace = NULL; |
5065 const char *fin = NULL; | 5135 const char *fin = NULL; |
5066 | 5136 |
5067 if (g_str_has_prefix(cur, "%chatName%")) { | 5137 if (g_str_has_prefix(cur, "%chatName%")) { |
5068 replace = conv->name; | 5138 replace = purple_conversation_get_name(conv); |
5069 | 5139 |
5070 } else if (g_str_has_prefix(cur, "%sourceName%")) { | 5140 } else if (g_str_has_prefix(cur, "%sourceName%")) { |
5071 replace = purple_account_get_alias(conv->account); | 5141 replace = purple_account_get_alias(account); |
5072 if (replace == NULL) | 5142 if (replace == NULL) |
5073 replace = purple_account_get_username(conv->account); | 5143 replace = purple_account_get_username(account); |
5074 | 5144 |
5075 } else if (g_str_has_prefix(cur, "%destinationName%")) { | 5145 } else if (g_str_has_prefix(cur, "%destinationName%")) { |
5076 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name); | 5146 PurpleBuddy *buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); |
5077 if (buddy) { | 5147 if (buddy) { |
5078 replace = purple_buddy_get_alias(buddy); | 5148 replace = purple_buddy_get_alias(buddy); |
5079 } else { | 5149 } else { |
5080 replace = conv->name; | 5150 replace = purple_conversation_get_name(conv); |
5081 } | 5151 } |
5082 | 5152 |
5083 } else if (g_str_has_prefix(cur, "%incomingIconPath%")) { | 5153 } else if (g_str_has_prefix(cur, "%incomingIconPath%")) { |
5084 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv)); | 5154 PurpleBuddyIcon *icon = purple_conv_im_get_icon(PURPLE_CONV_IM(conv)); |
5085 if (icon) | 5155 if (icon) |
5086 replace = purple_buddy_icon_get_full_path(icon); | 5156 replace = purple_buddy_icon_get_full_path(icon); |
5087 | 5157 |
5088 } else if (g_str_has_prefix(cur, "%outgoingIconPath%")) { | 5158 } else if (g_str_has_prefix(cur, "%outgoingIconPath%")) { |
5089 replace = purple_account_get_buddy_icon_path(conv->account); | 5159 replace = purple_account_get_buddy_icon_path(account); |
5090 | 5160 |
5091 } else if (g_str_has_prefix(cur, "%timeOpened")) { | 5161 } else if (g_str_has_prefix(cur, "%timeOpened")) { |
5092 const char *tmp = cur + strlen("%timeOpened"); | 5162 const char *tmp = cur + strlen("%timeOpened"); |
5093 char *format = NULL; | 5163 char *format = NULL; |
5094 if (*tmp == '{') { | 5164 if (*tmp == '{') { |
5101 fin = end + 1; | 5171 fin = end + 1; |
5102 } | 5172 } |
5103 replace = purple_utf8_strftime(format ? format : "%X", NULL); | 5173 replace = purple_utf8_strftime(format ? format : "%X", NULL); |
5104 g_free(format); | 5174 g_free(format); |
5105 | 5175 |
5176 } else if (g_str_has_prefix(cur, "%dateOpened%")) { | |
5177 replace = purple_date_format_short(NULL); | |
5178 | |
5106 } else { | 5179 } else { |
5180 cur++; | |
5107 continue; | 5181 continue; |
5108 } | 5182 } |
5109 | 5183 |
5110 /* Here we have a replacement to make */ | 5184 /* Here we have a replacement to make */ |
5111 g_string_append_len(str, prev, cur - prev); | 5185 g_string_append_len(str, prev, cur - prev); |
5196 if (val && G_VALUE_HOLDS_BOOLEAN(val)) | 5270 if (val && G_VALUE_HOLDS_BOOLEAN(val)) |
5197 /* this does not work :( */ | 5271 /* this does not work :( */ |
5198 webkit_web_view_set_transparent(webview, g_value_get_boolean(val)); | 5272 webkit_web_view_set_transparent(webview, g_value_get_boolean(val)); |
5199 } | 5273 } |
5200 | 5274 |
5275 static void | |
5276 conv_variant_changed_cb(GObject *gobject, GParamSpec *pspec, gpointer user_data) | |
5277 { | |
5278 PidginConversation *gtkconv = user_data; | |
5279 const char *path; | |
5280 char *js; | |
5281 | |
5282 path = pidgin_conversation_theme_get_css_path(PIDGIN_CONV_THEME(gobject)); | |
5283 js = g_strdup_printf("setStylesheet(\"mainStyle\", \"file://%s\");", path); | |
5284 gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview), js); | |
5285 g_free(js); | |
5286 } | |
5287 | |
5201 static GtkWidget * | 5288 static GtkWidget * |
5202 setup_common_pane(PidginConversation *gtkconv) | 5289 setup_common_pane(PidginConversation *gtkconv) |
5203 { | 5290 { |
5204 GtkWidget *paned, *vbox, *frame, *imhtml_sw, *webview_sw, *event_box; | 5291 GtkWidget *paned, *vbox, *frame, *imhtml_sw, *webview_sw, *event_box; |
5205 GtkCellRenderer *rend; | 5292 GtkCellRenderer *rend; |
5206 GtkTreePath *path; | 5293 GtkTreePath *path; |
5207 PurpleConversation *conv = gtkconv->active_conv; | 5294 PurpleConversation *conv = gtkconv->active_conv; |
5208 PurpleBuddy *buddy; | 5295 PurpleBuddy *buddy; |
5209 gboolean chat = (conv->type == PURPLE_CONV_TYPE_CHAT); | 5296 gboolean chat = (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT); |
5210 int buddyicon_size = 0; | 5297 int buddyicon_size = 0; |
5211 char *header, *footer; | 5298 char *header, *footer; |
5212 char *template; | 5299 char *template; |
5213 | 5300 |
5214 paned = gtk_vpaned_new(); | 5301 paned = gtk_vpaned_new(); |
5328 webkit_web_view_load_string(WEBKIT_WEB_VIEW(gtkconv->webview), template, "text/html", "UTF-8", baseuri); | 5415 webkit_web_view_load_string(WEBKIT_WEB_VIEW(gtkconv->webview), template, "text/html", "UTF-8", baseuri); |
5329 | 5416 |
5330 if (chat) | 5417 if (chat) |
5331 gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview), "document.getElementById('Chat').className = 'groupchat'"); | 5418 gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview), "document.getElementById('Chat').className = 'groupchat'"); |
5332 | 5419 |
5420 g_signal_connect(G_OBJECT(gtkconv->theme), "notify::variant", | |
5421 G_CALLBACK(conv_variant_changed_cb), gtkconv); | |
5422 | |
5333 g_free(basedir); | 5423 g_free(basedir); |
5334 g_free(baseuri); | 5424 g_free(baseuri); |
5335 g_free(template); | 5425 g_free(template); |
5336 } | 5426 } |
5337 | 5427 |
5384 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | 5474 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
5385 gtk_widget_show(frame); | 5475 gtk_widget_show(frame); |
5386 | 5476 |
5387 gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry"); | 5477 gtk_widget_set_name(gtkconv->entry, "pidgin_conv_entry"); |
5388 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | 5478 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
5389 purple_account_get_protocol_name(conv->account)); | 5479 purple_account_get_protocol_name(purple_conversation_get_account(conv))); |
5480 | |
5390 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, | 5481 gtk_widget_set_size_request(gtkconv->lower_hbox, -1, |
5391 chat ? purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height") : | 5482 chat ? purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/entry_height") : |
5392 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height")); | 5483 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height")); |
5393 | 5484 |
5394 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", | 5485 g_signal_connect(G_OBJECT(gtkconv->entry), "populate-popup", |
5436 PurpleConversation *conv = gtkconv->active_conv; | 5527 PurpleConversation *conv = gtkconv->active_conv; |
5437 PidginWindow *win = gtkconv->win; | 5528 PidginWindow *win = gtkconv->win; |
5438 PurpleConversation *c; | 5529 PurpleConversation *c; |
5439 PurpleAccount *convaccount = purple_conversation_get_account(conv); | 5530 PurpleAccount *convaccount = purple_conversation_get_account(conv); |
5440 PurpleConnection *gc = purple_account_get_connection(convaccount); | 5531 PurpleConnection *gc = purple_account_get_connection(convaccount); |
5441 PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl) : NULL; | 5532 PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL; |
5442 | 5533 |
5443 if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) | 5534 if (sd->target == gdk_atom_intern("PURPLE_BLIST_NODE", FALSE)) |
5444 { | 5535 { |
5445 PurpleBlistNode *n = NULL; | 5536 PurpleBlistNode *n = NULL; |
5446 PurpleBuddy *b; | 5537 PurpleBuddy *b; |
5556 }; | 5647 }; |
5557 | 5648 |
5558 static PidginConversation * | 5649 static PidginConversation * |
5559 pidgin_conv_find_gtkconv(PurpleConversation * conv) | 5650 pidgin_conv_find_gtkconv(PurpleConversation * conv) |
5560 { | 5651 { |
5561 PurpleBuddy *bud = purple_find_buddy(conv->account, conv->name); | 5652 PurpleBuddy *bud = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); |
5562 PurpleContact *c; | 5653 PurpleContact *c; |
5563 PurpleBlistNode *cn, *bn; | 5654 PurpleBlistNode *cn, *bn; |
5564 | 5655 |
5565 if (!bud) | 5656 if (!bud) |
5566 return NULL; | 5657 return NULL; |
5570 | 5661 |
5571 cn = PURPLE_BLIST_NODE(c); | 5662 cn = PURPLE_BLIST_NODE(c); |
5572 for (bn = purple_blist_node_get_first_child(cn); bn; bn = purple_blist_node_get_sibling_next(bn)) { | 5663 for (bn = purple_blist_node_get_first_child(cn); bn; bn = purple_blist_node_get_sibling_next(bn)) { |
5573 PurpleBuddy *b = PURPLE_BUDDY(bn); | 5664 PurpleBuddy *b = PURPLE_BUDDY(bn); |
5574 PurpleConversation *conv; | 5665 PurpleConversation *conv; |
5575 if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, b->name, b->account))) { | 5666 if ((conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(b), purple_buddy_get_account(b)))) { |
5576 if (PIDGIN_CONVERSATION(conv)) | 5667 if (PIDGIN_CONVERSATION(conv)) |
5577 return PIDGIN_CONVERSATION(conv); | 5668 return PIDGIN_CONVERSATION(conv); |
5578 } | 5669 } |
5579 } | 5670 } |
5580 | 5671 |
5661 PurpleTheme *theme; | 5752 PurpleTheme *theme; |
5662 PurpleConversationType conv_type = purple_conversation_get_type(conv); | 5753 PurpleConversationType conv_type = purple_conversation_get_type(conv); |
5663 GtkWidget *pane = NULL; | 5754 GtkWidget *pane = NULL; |
5664 GtkWidget *tab_cont; | 5755 GtkWidget *tab_cont; |
5665 PurpleBlistNode *convnode; | 5756 PurpleBlistNode *convnode; |
5666 PurpleValue *value; | |
5667 | 5757 |
5668 if (conv_type == PURPLE_CONV_TYPE_IM && (gtkconv = pidgin_conv_find_gtkconv(conv))) { | 5758 if (conv_type == PURPLE_CONV_TYPE_IM && (gtkconv = pidgin_conv_find_gtkconv(conv))) { |
5669 purple_conversation_set_ui_data(conv, gtkconv); | 5759 purple_conversation_set_ui_data(conv, gtkconv); |
5670 if (!g_list_find(gtkconv->convs, conv)) | 5760 if (!g_list_find(gtkconv->convs, conv)) |
5671 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | 5761 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); |
5746 | 5836 |
5747 convnode = get_conversation_blist_node(conv); | 5837 convnode = get_conversation_blist_node(conv); |
5748 if (convnode == NULL || !purple_blist_node_get_bool(convnode, "gtk-mute-sound")) | 5838 if (convnode == NULL || !purple_blist_node_get_bool(convnode, "gtk-mute-sound")) |
5749 gtkconv->make_sound = TRUE; | 5839 gtkconv->make_sound = TRUE; |
5750 | 5840 |
5751 if (convnode != NULL && | 5841 if (convnode != NULL) { |
5752 (value = g_hash_table_lookup(convnode->settings, "enable-logging")) && | 5842 gboolean logging = purple_blist_node_get_bool(convnode, "enable-logging"); |
5753 purple_value_get_type(value) == PURPLE_TYPE_BOOLEAN) | 5843 purple_conversation_set_logging(conv, logging); |
5754 { | |
5755 purple_conversation_set_logging(conv, purple_value_get_boolean(value)); | |
5756 } | 5844 } |
5757 | 5845 |
5758 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")) | 5846 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_formatting_toolbar")) |
5759 gtk_widget_show(gtkconv->toolbar); | 5847 gtk_widget_show(gtkconv->toolbar); |
5760 else | 5848 else |
5778 if (nick_colors == NULL) { | 5866 if (nick_colors == NULL) { |
5779 nbr_nick_colors = NUM_NICK_COLORS; | 5867 nbr_nick_colors = NUM_NICK_COLORS; |
5780 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->webview)->base[GTK_STATE_NORMAL]); | 5868 nick_colors = generate_nick_colors(&nbr_nick_colors, gtk_widget_get_style(gtkconv->webview)->base[GTK_STATE_NORMAL]); |
5781 } | 5869 } |
5782 | 5870 |
5783 if (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) | 5871 if (purple_conversation_get_features(conv) & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
5784 pidgin_themes_smiley_themeize_custom(gtkconv->entry); | 5872 pidgin_themes_smiley_themeize_custom(gtkconv->entry); |
5785 } | 5873 } |
5786 | 5874 |
5787 static void | 5875 static void |
5788 pidgin_conv_new_hidden(PurpleConversation *conv) | 5876 pidgin_conv_new_hidden(PurpleConversation *conv) |
5889 | 5977 |
5890 if (gtkconv->attach.timer) { | 5978 if (gtkconv->attach.timer) { |
5891 g_source_remove(gtkconv->attach.timer); | 5979 g_source_remove(gtkconv->attach.timer); |
5892 } | 5980 } |
5893 | 5981 |
5982 g_object_disconnect(G_OBJECT(gtkconv->theme), "any_signal::notify", | |
5983 conv_variant_changed_cb, gtkconv, NULL); | |
5894 g_object_unref(gtkconv->theme); | 5984 g_object_unref(gtkconv->theme); |
5895 | 5985 |
5896 g_free(gtkconv); | 5986 g_free(gtkconv); |
5897 } | 5987 } |
5898 | 5988 |
5982 if (!gtk_text_buffer_get_selection_bounds( | 6072 if (!gtk_text_buffer_get_selection_bounds( |
5983 gtk_text_iter_get_buffer(arg2), | 6073 gtk_text_iter_get_buffer(arg2), |
5984 &start, &end)) { | 6074 &start, &end)) { |
5985 GtkWidget *menu = NULL; | 6075 GtkWidget *menu = NULL; |
5986 PurpleConnection *gc = | 6076 PurpleConnection *gc = |
5987 purple_conversation_get_gc(conv); | 6077 purple_conversation_get_connection(conv); |
5988 | 6078 |
5989 | 6079 |
5990 menu = create_chat_menu(conv, buddyname, gc); | 6080 menu = create_chat_menu(conv, buddyname, gc); |
5991 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, | 6081 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
5992 NULL, GTK_WIDGET(imhtml), | 6082 NULL, GTK_WIDGET(imhtml), |
6135 fin = end + 1; | 6225 fin = end + 1; |
6136 } | 6226 } |
6137 replace = purple_utf8_strftime(format ? format : "%X", NULL); | 6227 replace = purple_utf8_strftime(format ? format : "%X", NULL); |
6138 g_free(format); | 6228 g_free(format); |
6139 | 6229 |
6230 } else if (g_str_has_prefix(cur, "%shortTime%")) { | |
6231 replace = purple_utf8_strftime("%H:%M", NULL); | |
6232 | |
6140 } else if (g_str_has_prefix(cur, "%userIconPath%")) { | 6233 } else if (g_str_has_prefix(cur, "%userIconPath%")) { |
6141 if (flags & PURPLE_MESSAGE_SEND) { | 6234 if (flags & PURPLE_MESSAGE_SEND) { |
6142 if (purple_account_get_bool(conv->account, "use-global-buddyicon", TRUE)) { | 6235 if (purple_account_get_bool(purple_conversation_get_account(conv), "use-global-buddyicon", TRUE)) { |
6143 replace = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); | 6236 replace = purple_prefs_get_path(PIDGIN_PREFS_ROOT "/accounts/buddyicon"); |
6144 } else { | 6237 } else { |
6145 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(conv->account); | 6238 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(purple_conversation_get_account(conv)); |
6146 replace = purple_imgstore_get_filename(img); | 6239 replace = purple_imgstore_get_filename(img); |
6147 } | 6240 } |
6148 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) { | 6241 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) { |
6149 replace = g_build_filename("Outgoing", "buddy_icon.png", NULL); | 6242 replace = g_build_filename("Outgoing", "buddy_icon.png", NULL); |
6150 } | 6243 } |
6162 | 6255 |
6163 } else if (g_str_has_prefix(cur, "%sender%")) { | 6256 } else if (g_str_has_prefix(cur, "%sender%")) { |
6164 replace = alias; | 6257 replace = alias; |
6165 | 6258 |
6166 } else if (g_str_has_prefix(cur, "%service%")) { | 6259 } else if (g_str_has_prefix(cur, "%service%")) { |
6167 replace = purple_account_get_protocol_name(conv->account); | 6260 replace = purple_account_get_protocol_name(purple_conversation_get_account(conv)); |
6261 | |
6262 } else if (g_str_has_prefix(cur, "%messageDirection%")) { | |
6263 replace = purple_markup_is_rtl(message) ? "rtl" : "ltr"; | |
6168 | 6264 |
6169 } else { | 6265 } else { |
6170 cur++; | 6266 cur++; |
6171 continue; | 6267 continue; |
6172 } | 6268 } |
6353 if ((flags & PURPLE_MESSAGE_RECV) && | 6449 if ((flags & PURPLE_MESSAGE_RECV) && |
6354 !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting")) | 6450 !purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/show_incoming_formatting")) |
6355 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; | 6451 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
6356 | 6452 |
6357 /* this is gonna crash one day, I can feel it. */ | 6453 /* this is gonna crash one day, I can feel it. */ |
6358 if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(conv->account)))->options & | 6454 if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_find_prpl(purple_account_get_protocol_id(purple_conversation_get_account(conv))))->options & |
6359 OPT_PROTO_USE_POINTSIZE) { | 6455 OPT_PROTO_USE_POINTSIZE) { |
6360 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; | 6456 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
6361 } | 6457 } |
6362 | 6458 |
6363 if (!(flags & PURPLE_MESSAGE_RECV) && (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)) | 6459 if (!(flags & PURPLE_MESSAGE_RECV) && (purple_conversation_get_features(conv) & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)) |
6364 { | 6460 { |
6365 /* We want to see our own smileys. Need to revert it after send*/ | 6461 /* We want to see our own smileys. Need to revert it after send*/ |
6366 pidgin_themes_smiley_themeize_custom(gtkconv->webview); | 6462 pidgin_themes_smiley_themeize_custom(gtkconv->webview); |
6367 } | 6463 } |
6368 | 6464 |
6520 | 6616 |
6521 gtkconv_set_unseen(gtkconv, unseen); | 6617 gtkconv_set_unseen(gtkconv, unseen); |
6522 } | 6618 } |
6523 | 6619 |
6524 #if 0 | 6620 #if 0 |
6525 if (!(flags & PURPLE_MESSAGE_RECV) && (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)) | 6621 if (!(flags & PURPLE_MESSAGE_RECV) && (purple_conversation_get_features(conv) & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY)) |
6526 { | 6622 { |
6527 /* Restore the smiley-data */ | 6623 /* Restore the smiley-data */ |
6528 pidgin_themes_smiley_themeize(gtkconv->webview); | 6624 pidgin_themes_smiley_themeize(gtkconv->webview); |
6529 } | 6625 } |
6530 #endif | 6626 #endif |
6536 update_typing_message(gtkconv, NULL); | 6632 update_typing_message(gtkconv, NULL); |
6537 } | 6633 } |
6538 | 6634 |
6539 static gboolean get_iter_from_chatbuddy(PurpleConvChatBuddy *cb, GtkTreeIter *iter) | 6635 static gboolean get_iter_from_chatbuddy(PurpleConvChatBuddy *cb, GtkTreeIter *iter) |
6540 { | 6636 { |
6541 GtkTreeRowReference *ref = cb->ui_data; | 6637 GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(cb); |
6542 GtkTreePath *path; | 6638 GtkTreePath *path; |
6543 GtkTreeModel *model; | 6639 GtkTreeModel *model; |
6544 | 6640 |
6545 if (!ref) | 6641 if (!ref) |
6546 return FALSE; | 6642 return FALSE; |
6622 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 6718 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
6623 return; | 6719 return; |
6624 | 6720 |
6625 old_cbuddy = purple_conv_chat_cb_find(chat, old_name); | 6721 old_cbuddy = purple_conv_chat_cb_find(chat, old_name); |
6626 if (get_iter_from_chatbuddy(old_cbuddy, &iter)) { | 6722 if (get_iter_from_chatbuddy(old_cbuddy, &iter)) { |
6627 GtkTreeRowReference *ref = old_cbuddy->ui_data; | 6723 GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(old_cbuddy); |
6628 | 6724 |
6629 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | 6725 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
6630 gtk_tree_row_reference_free(ref); | 6726 gtk_tree_row_reference_free(ref); |
6631 old_cbuddy->ui_data = NULL; | 6727 purple_conv_chat_cb_set_ui_data(old_cbuddy, NULL); |
6632 } | 6728 } |
6633 | 6729 |
6634 if ((tag = get_buddy_tag(conv, old_name, 0, FALSE))) | 6730 if ((tag = get_buddy_tag(conv, old_name, 0, FALSE))) |
6635 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); | 6731 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); |
6636 if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE))) | 6732 if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE))) |
6720 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | 6816 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
6721 return; | 6817 return; |
6722 | 6818 |
6723 cbuddy = purple_conv_chat_cb_find(chat, user); | 6819 cbuddy = purple_conv_chat_cb_find(chat, user); |
6724 if (get_iter_from_chatbuddy(cbuddy, &iter)) { | 6820 if (get_iter_from_chatbuddy(cbuddy, &iter)) { |
6725 GtkTreeRowReference *ref = cbuddy->ui_data; | 6821 GtkTreeRowReference *ref = purple_conv_chat_cb_get_ui_data(cbuddy); |
6726 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | 6822 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
6727 gtk_tree_row_reference_free(ref); | 6823 gtk_tree_row_reference_free(ref); |
6728 cbuddy->ui_data = NULL; | 6824 purple_conv_chat_cb_set_ui_data(cbuddy, NULL); |
6729 } | 6825 } |
6730 | 6826 |
6731 if (cbuddy) | 6827 if (cbuddy) |
6732 add_chat_buddy_common(conv, cbuddy, NULL); | 6828 add_chat_buddy_common(conv, cbuddy, NULL); |
6733 } | 6829 } |
6793 if (pidgin_themes_smileys_disabled()) | 6889 if (pidgin_themes_smileys_disabled()) |
6794 return FALSE; | 6890 return FALSE; |
6795 | 6891 |
6796 /* If possible add this smiley to the current theme. | 6892 /* If possible add this smiley to the current theme. |
6797 * The addition is only temporary: custom smilies aren't saved to disk. */ | 6893 * The addition is only temporary: custom smilies aren't saved to disk. */ |
6798 conv_sml = purple_account_get_protocol_name(conv->account); | 6894 conv_sml = purple_account_get_protocol_name(purple_conversation_get_account(conv)); |
6799 gtkconv = PIDGIN_CONVERSATION(conv); | 6895 gtkconv = PIDGIN_CONVERSATION(conv); |
6800 | 6896 |
6801 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | 6897 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { |
6802 if (!strcmp(list->sml, conv_sml)) { | 6898 if (!strcmp(list->sml, conv_sml)) { |
6803 sml = list->sml; | 6899 sml = list->sml; |
6824 PidginConversation *gtkconv; | 6920 PidginConversation *gtkconv; |
6825 GtkIMHtmlSmiley *smiley; | 6921 GtkIMHtmlSmiley *smiley; |
6826 const char *sml; | 6922 const char *sml; |
6827 GError *error = NULL; | 6923 GError *error = NULL; |
6828 | 6924 |
6829 sml = purple_account_get_protocol_name(conv->account); | 6925 sml = purple_account_get_protocol_name(purple_conversation_get_account(conv)); |
6830 gtkconv = PIDGIN_CONVERSATION(conv); | 6926 gtkconv = PIDGIN_CONVERSATION(conv); |
6831 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | 6927 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
6832 | 6928 |
6833 if (!smiley) | 6929 if (!smiley) |
6834 return; | 6930 return; |
6869 GError *error = NULL; | 6965 GError *error = NULL; |
6870 | 6966 |
6871 g_return_if_fail(conv != NULL); | 6967 g_return_if_fail(conv != NULL); |
6872 g_return_if_fail(smile != NULL); | 6968 g_return_if_fail(smile != NULL); |
6873 | 6969 |
6874 sml = purple_account_get_protocol_name(conv->account); | 6970 sml = purple_account_get_protocol_name(purple_conversation_get_account(conv)); |
6875 gtkconv = PIDGIN_CONVERSATION(conv); | 6971 gtkconv = PIDGIN_CONVERSATION(conv); |
6876 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | 6972 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
6877 | 6973 |
6878 if (!smiley) | 6974 if (!smiley) |
6879 return; | 6975 return; |
6925 GdkPixbuf *window_icon = NULL; | 7021 GdkPixbuf *window_icon = NULL; |
6926 GtkIMHtmlButtons buttons; | 7022 GtkIMHtmlButtons buttons; |
6927 PurpleAccount *account; | 7023 PurpleAccount *account; |
6928 | 7024 |
6929 win = pidgin_conv_get_window(gtkconv); | 7025 win = pidgin_conv_get_window(gtkconv); |
6930 gc = purple_conversation_get_gc(conv); | 7026 gc = purple_conversation_get_connection(conv); |
6931 account = purple_conversation_get_account(conv); | 7027 account = purple_conversation_get_account(conv); |
6932 | 7028 |
6933 if (gc != NULL) | 7029 if (gc != NULL) |
6934 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 7030 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
6935 | 7031 |
6936 if (win->menu.send_to != NULL) | 7032 if (win->menu.send_to != NULL) |
6937 update_send_to_selection(win); | 7033 update_send_to_selection(win); |
6938 | 7034 |
6939 /* | 7035 /* |
6948 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | 7044 /* Show stuff that applies to IMs, hide stuff that applies to chats */ |
6949 | 7045 |
6950 /* Deal with menu items */ | 7046 /* Deal with menu items */ |
6951 gtk_widget_show(win->menu.view_log); | 7047 gtk_widget_show(win->menu.view_log); |
6952 gtk_widget_show(win->menu.send_file); | 7048 gtk_widget_show(win->menu.send_file); |
6953 gtk_widget_show(g_object_get_data(G_OBJECT(win->window), "get_attention")); | 7049 gtk_widget_show(win->menu.get_attention); |
6954 gtk_widget_show(win->menu.add_pounce); | 7050 gtk_widget_show(win->menu.add_pounce); |
6955 gtk_widget_show(win->menu.get_info); | 7051 gtk_widget_show(win->menu.get_info); |
6956 gtk_widget_hide(win->menu.invite); | 7052 gtk_widget_hide(win->menu.invite); |
6957 gtk_widget_show(win->menu.alias); | 7053 gtk_widget_show(win->menu.alias); |
6958 if (purple_privacy_check(account, purple_conversation_get_name(conv))) { | 7054 if (purple_privacy_check(account, purple_conversation_get_name(conv))) { |
6977 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | 7073 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ |
6978 | 7074 |
6979 /* Deal with menu items */ | 7075 /* Deal with menu items */ |
6980 gtk_widget_show(win->menu.view_log); | 7076 gtk_widget_show(win->menu.view_log); |
6981 gtk_widget_hide(win->menu.send_file); | 7077 gtk_widget_hide(win->menu.send_file); |
6982 gtk_widget_hide(g_object_get_data(G_OBJECT(win->window), "get_attention")); | 7078 gtk_widget_hide(win->menu.get_attention); |
6983 gtk_widget_hide(win->menu.add_pounce); | 7079 gtk_widget_hide(win->menu.add_pounce); |
6984 gtk_widget_hide(win->menu.get_info); | 7080 gtk_widget_hide(win->menu.get_info); |
6985 gtk_widget_show(win->menu.invite); | 7081 gtk_widget_show(win->menu.invite); |
6986 gtk_widget_show(win->menu.alias); | 7082 gtk_widget_show(win->menu.alias); |
6987 gtk_widget_hide(win->menu.block); | 7083 gtk_widget_hide(win->menu.block); |
7007 */ | 7103 */ |
7008 if ((gc != NULL) && | 7104 if ((gc != NULL) && |
7009 ((purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_CHAT) || | 7105 ((purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_CHAT) || |
7010 !purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)) )) | 7106 !purple_conv_chat_has_left(PURPLE_CONV_CHAT(conv)) )) |
7011 { | 7107 { |
7108 PurpleConnectionFlags features = purple_conversation_get_features(conv); | |
7012 /* Account is online */ | 7109 /* Account is online */ |
7013 /* Deal with the toolbar */ | 7110 /* Deal with the toolbar */ |
7014 if (conv->features & PURPLE_CONNECTION_HTML) | 7111 if (features & PURPLE_CONNECTION_HTML) |
7015 { | 7112 { |
7016 buttons = GTK_IMHTML_ALL; /* Everything on */ | 7113 buttons = GTK_IMHTML_ALL; /* Everything on */ |
7017 if (conv->features & PURPLE_CONNECTION_NO_BGCOLOR) | 7114 if (features & PURPLE_CONNECTION_NO_BGCOLOR) |
7018 buttons &= ~GTK_IMHTML_BACKCOLOR; | 7115 buttons &= ~GTK_IMHTML_BACKCOLOR; |
7019 if (conv->features & PURPLE_CONNECTION_NO_FONTSIZE) | 7116 if (features & PURPLE_CONNECTION_NO_FONTSIZE) |
7020 { | 7117 { |
7021 buttons &= ~GTK_IMHTML_GROW; | 7118 buttons &= ~GTK_IMHTML_GROW; |
7022 buttons &= ~GTK_IMHTML_SHRINK; | 7119 buttons &= ~GTK_IMHTML_SHRINK; |
7023 } | 7120 } |
7024 if (conv->features & PURPLE_CONNECTION_NO_URLDESC) | 7121 if (features & PURPLE_CONNECTION_NO_URLDESC) |
7025 buttons &= ~GTK_IMHTML_LINKDESC; | 7122 buttons &= ~GTK_IMHTML_LINKDESC; |
7026 } else { | 7123 } else { |
7027 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; | 7124 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
7028 } | 7125 } |
7029 | 7126 |
7030 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE)) | 7127 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) |
7031 conv->features |= PURPLE_CONNECTION_NO_IMAGES; | 7128 && !(features & PURPLE_CONNECTION_NO_IMAGES)) { |
7032 | 7129 features |= PURPLE_CONNECTION_NO_IMAGES; |
7033 if(conv->features & PURPLE_CONNECTION_NO_IMAGES) | 7130 purple_conversation_set_features(conv, features); |
7131 } | |
7132 | |
7133 if (features & PURPLE_CONNECTION_NO_IMAGES) | |
7034 buttons &= ~GTK_IMHTML_IMAGE; | 7134 buttons &= ~GTK_IMHTML_IMAGE; |
7035 | 7135 |
7036 if (conv->features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) | 7136 if (features & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
7037 buttons |= GTK_IMHTML_CUSTOM_SMILEY; | 7137 buttons |= GTK_IMHTML_CUSTOM_SMILEY; |
7038 else | 7138 else |
7039 buttons &= ~GTK_IMHTML_CUSTOM_SMILEY; | 7139 buttons &= ~GTK_IMHTML_CUSTOM_SMILEY; |
7040 | 7140 |
7041 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | 7141 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
7045 /* Deal with menu items */ | 7145 /* Deal with menu items */ |
7046 gtk_widget_set_sensitive(win->menu.view_log, TRUE); | 7146 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
7047 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | 7147 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); |
7048 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | 7148 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); |
7049 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | 7149 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); |
7050 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & PURPLE_CONNECTION_HTML)); | 7150 gtk_widget_set_sensitive(win->menu.insert_link, (features & PURPLE_CONNECTION_HTML)); |
7051 gtk_widget_set_sensitive(win->menu.insert_image, !(conv->features & PURPLE_CONNECTION_NO_IMAGES)); | 7151 gtk_widget_set_sensitive(win->menu.insert_image, !(features & PURPLE_CONNECTION_NO_IMAGES)); |
7052 | 7152 |
7053 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) | 7153 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) |
7054 { | 7154 { |
7055 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | 7155 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); |
7056 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | 7156 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); |
7057 gtk_widget_set_sensitive(win->menu.send_file, | 7157 gtk_widget_set_sensitive(win->menu.send_file, |
7058 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | 7158 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || |
7059 prpl_info->can_receive_file(gc, purple_conversation_get_name(conv))))); | 7159 prpl_info->can_receive_file(gc, purple_conversation_get_name(conv))))); |
7060 gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(win->window), "get_attention"), (prpl_info->send_attention != NULL)); | 7160 gtk_widget_set_sensitive(win->menu.get_attention, (prpl_info->send_attention != NULL)); |
7061 gtk_widget_set_sensitive(win->menu.alias, | 7161 gtk_widget_set_sensitive(win->menu.alias, |
7062 (account != NULL) && | 7162 (account != NULL) && |
7063 (purple_find_buddy(account, purple_conversation_get_name(conv)) != NULL)); | 7163 (purple_find_buddy(account, purple_conversation_get_name(conv)) != NULL)); |
7064 } | 7164 } |
7065 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) | 7165 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) |
7076 /* Or it's a chat that we've left. */ | 7176 /* Or it's a chat that we've left. */ |
7077 | 7177 |
7078 /* Then deal with menu items */ | 7178 /* Then deal with menu items */ |
7079 gtk_widget_set_sensitive(win->menu.view_log, TRUE); | 7179 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
7080 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | 7180 gtk_widget_set_sensitive(win->menu.send_file, FALSE); |
7081 gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(win->window), | 7181 gtk_widget_set_sensitive(win->menu.get_attention, FALSE); |
7082 "get_attention"), FALSE); | |
7083 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | 7182 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); |
7084 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | 7183 gtk_widget_set_sensitive(win->menu.get_info, FALSE); |
7085 gtk_widget_set_sensitive(win->menu.invite, FALSE); | 7184 gtk_widget_set_sensitive(win->menu.invite, FALSE); |
7086 gtk_widget_set_sensitive(win->menu.alias, FALSE); | 7185 gtk_widget_set_sensitive(win->menu.alias, FALSE); |
7087 gtk_widget_set_sensitive(win->menu.add, FALSE); | 7186 gtk_widget_set_sensitive(win->menu.add, FALSE); |
7097 { | 7196 { |
7098 GList *l = NULL; | 7197 GList *l = NULL; |
7099 if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) && | 7198 if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) && |
7100 (gtkconv->u.im->anim)) | 7199 (gtkconv->u.im->anim)) |
7101 { | 7200 { |
7102 PurpleBuddy *buddy = purple_find_buddy(conv->account, conv->name); | 7201 PurpleBuddy *buddy = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); |
7103 window_icon = | 7202 window_icon = |
7104 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | 7203 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
7105 | 7204 |
7106 if (buddy && !PURPLE_BUDDY_IS_ONLINE(buddy)) | 7205 if (buddy && !PURPLE_BUDDY_IS_ONLINE(buddy)) |
7107 gdk_pixbuf_saturate_and_pixelate(window_icon, window_icon, 0.0, FALSE); | 7206 gdk_pixbuf_saturate_and_pixelate(window_icon, window_icon, 0.0, FALSE); |
7203 title = g_strdup_printf("(%s)", purple_conversation_get_title(conv)); | 7302 title = g_strdup_printf("(%s)", purple_conversation_get_title(conv)); |
7204 else | 7303 else |
7205 title = g_strdup(purple_conversation_get_title(conv)); | 7304 title = g_strdup(purple_conversation_get_title(conv)); |
7206 | 7305 |
7207 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { | 7306 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
7208 buddy = purple_find_buddy(account, conv->name); | 7307 buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); |
7209 if (buddy) { | 7308 if (buddy) { |
7210 markup = pidgin_blist_get_name_markup(buddy, FALSE, FALSE); | 7309 markup = pidgin_blist_get_name_markup(buddy, FALSE, FALSE); |
7211 } else { | 7310 } else { |
7212 markup = title; | 7311 markup = title; |
7213 } | 7312 } |
7248 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_NICK) { | 7347 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_NICK) { |
7249 atk_object_set_description(accessibility_obj, _("Nick Said")); | 7348 atk_object_set_description(accessibility_obj, _("Nick Said")); |
7250 style = "tab-label-attention"; | 7349 style = "tab-label-attention"; |
7251 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT) { | 7350 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT) { |
7252 atk_object_set_description(accessibility_obj, _("Unread Messages")); | 7351 atk_object_set_description(accessibility_obj, _("Unread Messages")); |
7253 if (gtkconv->active_conv->type == PURPLE_CONV_TYPE_CHAT) | 7352 if (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_CHAT) |
7254 style = "tab-label-unreadchat"; | 7353 style = "tab-label-unreadchat"; |
7255 else | 7354 else |
7256 style = "tab-label-attention"; | 7355 style = "tab-label-attention"; |
7257 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { | 7356 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { |
7258 atk_object_set_description(accessibility_obj, _("New Event")); | 7357 atk_object_set_description(accessibility_obj, _("New Event")); |
7478 gtkconv->u.im->iter = NULL; | 7577 gtkconv->u.im->iter = NULL; |
7479 | 7578 |
7480 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons")) | 7579 if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons")) |
7481 return; | 7580 return; |
7482 | 7581 |
7483 if (purple_conversation_get_gc(conv) == NULL) | 7582 if (purple_conversation_get_connection(conv) == NULL) |
7484 return; | 7583 return; |
7485 | 7584 |
7486 buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); | 7585 buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); |
7487 if (buddy) | 7586 if (buddy) |
7488 { | 7587 { |
7963 gtkconv = l->data; | 8062 gtkconv = l->data; |
7964 l = l->next; | 8063 l = l->next; |
7965 | 8064 |
7966 conv = gtkconv->active_conv; | 8065 conv = gtkconv->active_conv; |
7967 | 8066 |
7968 if (conv->type == PURPLE_CONV_TYPE_CHAT || | 8067 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT || |
7969 gtkconv->unseen_count == 0 || | 8068 gtkconv->unseen_count == 0 || |
7970 (when_away && !purple_status_is_available( | 8069 (when_away && !purple_status_is_available( |
7971 purple_account_get_active_status( | 8070 purple_account_get_active_status( |
7972 purple_conversation_get_account(conv))))) | 8071 purple_conversation_get_account(conv))))) |
7973 continue; | 8072 continue; |
8003 | 8102 |
8004 for (; node; node = node->next) | 8103 for (; node; node = node->next) |
8005 { | 8104 { |
8006 PurpleBuddy *buddy = (PurpleBuddy*)node; | 8105 PurpleBuddy *buddy = (PurpleBuddy*)node; |
8007 PurpleConversation *conv; | 8106 PurpleConversation *conv; |
8008 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, buddy->name, buddy->account); | 8107 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); |
8009 if (conv) | 8108 if (conv) |
8010 return PIDGIN_CONVERSATION(conv); | 8109 return PIDGIN_CONVERSATION(conv); |
8011 } | 8110 } |
8012 return NULL; | 8111 return NULL; |
8013 } | 8112 } |
8028 /* if (purple_conversation_get_account(conv) == account) */ | 8127 /* if (purple_conversation_get_account(conv) == account) */ |
8029 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON | | 8128 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON | |
8030 PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE); | 8129 PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE); |
8031 | 8130 |
8032 if (PURPLE_CONNECTION_IS_CONNECTED(gc) && | 8131 if (PURPLE_CONNECTION_IS_CONNECTED(gc) && |
8033 conv->type == PURPLE_CONV_TYPE_CHAT && | 8132 purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && |
8034 conv->account == gc->account && | 8133 purple_conversation_get_account(conv) == purple_connection_get_account(gc) && |
8035 purple_conversation_get_data(conv, "want-to-rejoin")) { | 8134 purple_conversation_get_data(conv, "want-to-rejoin")) { |
8036 GHashTable *comps = NULL; | 8135 GHashTable *comps = NULL; |
8037 PurpleChat *chat = purple_blist_find_chat(conv->account, conv->name); | 8136 PurpleChat *chat = purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); |
8038 if (chat == NULL) { | 8137 if (chat == NULL) { |
8039 if (PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL) | 8138 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
8040 comps = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, conv->name); | 8139 |
8140 if (prpl_info->chat_info_defaults != NULL) | |
8141 comps = prpl_info->chat_info_defaults(gc, purple_conversation_get_name(conv)); | |
8041 } else { | 8142 } else { |
8042 comps = chat->components; | 8143 comps = purple_chat_get_components(chat); |
8043 } | 8144 } |
8044 serv_join_chat(gc, comps); | 8145 serv_join_chat(gc, comps); |
8045 if (chat == NULL && comps != NULL) | 8146 if (chat == NULL && comps != NULL) |
8046 g_hash_table_destroy(comps); | 8147 g_hash_table_destroy(comps); |
8047 } | 8148 } |
8104 static void | 8205 static void |
8105 update_buddy_idle_changed(PurpleBuddy *buddy, gboolean old, gboolean newidle) | 8206 update_buddy_idle_changed(PurpleBuddy *buddy, gboolean old, gboolean newidle) |
8106 { | 8207 { |
8107 PurpleConversation *conv; | 8208 PurpleConversation *conv; |
8108 | 8209 |
8109 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, buddy->name, buddy->account); | 8210 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); |
8110 if (conv) | 8211 if (conv) |
8111 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON); | 8212 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON); |
8112 } | 8213 } |
8113 | 8214 |
8114 static void | 8215 static void |
8115 update_buddy_icon(PurpleBuddy *buddy) | 8216 update_buddy_icon(PurpleBuddy *buddy) |
8116 { | 8217 { |
8117 PurpleConversation *conv; | 8218 PurpleConversation *conv; |
8118 | 8219 |
8119 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, buddy->name, buddy->account); | 8220 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); |
8120 if (conv) | 8221 if (conv) |
8121 pidgin_conv_update_fields(conv, PIDGIN_CONV_BUDDY_ICON); | 8222 pidgin_conv_update_fields(conv, PIDGIN_CONV_BUDDY_ICON); |
8122 } | 8223 } |
8123 | 8224 |
8124 static void | 8225 static void |
8179 /* Compare two PurpleConvMessage's, according to time in ascending order. */ | 8280 /* Compare two PurpleConvMessage's, according to time in ascending order. */ |
8180 static int | 8281 static int |
8181 message_compare(gconstpointer p1, gconstpointer p2) | 8282 message_compare(gconstpointer p1, gconstpointer p2) |
8182 { | 8283 { |
8183 const PurpleConvMessage *m1 = p1, *m2 = p2; | 8284 const PurpleConvMessage *m1 = p1, *m2 = p2; |
8184 return (m1->when > m2->when); | 8285 return (purple_conversation_message_get_timestamp(m1) > purple_conversation_message_get_timestamp(m2)); |
8185 } | 8286 } |
8186 | 8287 |
8187 /* Adds some message history to the gtkconv. This happens in a idle-callback. */ | 8288 /* Adds some message history to the gtkconv. This happens in a idle-callback. */ |
8188 static gboolean | 8289 static gboolean |
8189 add_message_history_to_gtkconv(gpointer data) | 8290 add_message_history_to_gtkconv(gpointer data) |
8190 { | 8291 { |
8191 PidginConversation *gtkconv = data; | 8292 PidginConversation *gtkconv = data; |
8192 int count = 0; | 8293 int count = 0; |
8193 int timer = gtkconv->attach.timer; | 8294 int timer = gtkconv->attach.timer; |
8194 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); | 8295 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); |
8195 gboolean im = (gtkconv->active_conv->type == PURPLE_CONV_TYPE_IM); | 8296 gboolean im = (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_IM); |
8196 | 8297 |
8197 gtkconv->attach.timer = 0; | 8298 gtkconv->attach.timer = 0; |
8198 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ | 8299 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ |
8199 PurpleConvMessage *msg = gtkconv->attach.current->data; | 8300 PurpleConvMessage *msg = gtkconv->attach.current->data; |
8200 if (!im && when && when < msg->when) { | 8301 if (!im && when && when < purple_conversation_message_get_timestamp(msg)) { |
8201 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR><HR>"); | 8302 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR><HR>"); |
8202 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | 8303 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); |
8203 } | 8304 } |
8204 pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); | 8305 pidgin_conv_write_conv( |
8306 purple_conversation_message_get_conv(msg), | |
8307 purple_conversation_message_get_sender(msg), | |
8308 purple_conversation_message_get_alias(msg), | |
8309 purple_conversation_message_get_message(msg), | |
8310 purple_conversation_message_get_flags(msg), | |
8311 purple_conversation_message_get_timestamp(msg)); | |
8205 if (im) { | 8312 if (im) { |
8206 gtkconv->attach.current = g_list_delete_link(gtkconv->attach.current, gtkconv->attach.current); | 8313 gtkconv->attach.current = g_list_delete_link(gtkconv->attach.current, gtkconv->attach.current); |
8207 } else { | 8314 } else { |
8208 gtkconv->attach.current = gtkconv->attach.current->prev; | 8315 gtkconv->attach.current = gtkconv->attach.current->prev; |
8209 } | 8316 } |
8222 for (; iter; iter = iter->next) { | 8329 for (; iter; iter = iter->next) { |
8223 PurpleConversation *conv = iter->data; | 8330 PurpleConversation *conv = iter->data; |
8224 GList *history = purple_conversation_get_message_history(conv); | 8331 GList *history = purple_conversation_get_message_history(conv); |
8225 for (; history; history = history->next) { | 8332 for (; history; history = history->next) { |
8226 PurpleConvMessage *msg = history->data; | 8333 PurpleConvMessage *msg = history->data; |
8227 if (msg->when > when) | 8334 if (purple_conversation_message_get_timestamp(msg) > when) |
8228 msgs = g_list_prepend(msgs, msg); | 8335 msgs = g_list_prepend(msgs, msg); |
8229 } | 8336 } |
8230 } | 8337 } |
8231 msgs = g_list_sort(msgs, message_compare); | 8338 msgs = g_list_sort(msgs, message_compare); |
8232 for (; msgs; msgs = g_list_delete_link(msgs, msgs)) { | 8339 for (; msgs; msgs = g_list_delete_link(msgs, msgs)) { |
8233 PurpleConvMessage *msg = msgs->data; | 8340 PurpleConvMessage *msg = msgs->data; |
8234 pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); | 8341 pidgin_conv_write_conv( |
8342 purple_conversation_message_get_conv(msg), | |
8343 purple_conversation_message_get_sender(msg), | |
8344 purple_conversation_message_get_alias(msg), | |
8345 purple_conversation_message_get_message(msg), | |
8346 purple_conversation_message_get_flags(msg), | |
8347 purple_conversation_message_get_timestamp(msg)); | |
8235 } | 8348 } |
8236 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR><HR>"); | 8349 gtk_webview_append_html(GTK_WEBVIEW(gtkconv->webview), "<BR><HR>"); |
8237 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | 8350 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); |
8238 } | 8351 } |
8239 | 8352 |
8307 break; | 8420 break; |
8308 default: | 8421 default: |
8309 g_return_val_if_reached(TRUE); | 8422 g_return_val_if_reached(TRUE); |
8310 } | 8423 } |
8311 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", | 8424 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", |
8312 GINT_TO_POINTER(((PurpleConvMessage*)(list->data))->when)); | 8425 GINT_TO_POINTER(purple_conversation_message_get_timestamp((PurpleConvMessage*)(list->data)))); |
8313 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); | 8426 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); |
8314 } else { | 8427 } else { |
8315 purple_signal_emit(pidgin_conversations_get_handle(), | 8428 purple_signal_emit(pidgin_conversations_get_handle(), |
8316 "conversation-displayed", gtkconv); | 8429 "conversation-displayed", gtkconv); |
8317 } | 8430 } |
8318 | 8431 |
8319 if (conv->type == PURPLE_CONV_TYPE_CHAT) { | 8432 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
8320 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); | 8433 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
8321 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); | 8434 pidgin_conv_chat_add_users(conv, purple_conv_chat_get_users(PURPLE_CONV_CHAT(conv)), TRUE); |
8322 } | 8435 } |
8323 | 8436 |
8324 return TRUE; | 8437 return TRUE; |
8325 } | 8438 } |
8326 | 8439 |
9515 if (!GTK_WIDGET_VISIBLE(gtkconv->infopane)) { | 9628 if (!GTK_WIDGET_VISIBLE(gtkconv->infopane)) { |
9516 /* There's already an entry for alias. Let's not create another one. */ | 9629 /* There's already an entry for alias. Let's not create another one. */ |
9517 return FALSE; | 9630 return FALSE; |
9518 } | 9631 } |
9519 | 9632 |
9520 if (!purple_account_is_connected(gtkconv->active_conv->account)) { | 9633 if (!purple_account_is_connected(purple_conversation_get_account(gtkconv->active_conv))) { |
9521 /* Do not allow aliasing someone on a disconnected account. */ | 9634 /* Do not allow aliasing someone on a disconnected account. */ |
9522 return FALSE; | 9635 return FALSE; |
9523 } | 9636 } |
9524 | 9637 |
9525 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { | 9638 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { |
9526 PurpleBuddy *buddy = purple_find_buddy(gtkconv->active_conv->account, gtkconv->active_conv->name); | 9639 PurpleBuddy *buddy = purple_find_buddy(purple_conversation_get_account(gtkconv->active_conv), purple_conversation_get_name(gtkconv->active_conv)); |
9527 if (!buddy) | 9640 if (!buddy) |
9528 /* This buddy isn't in your buddy list, so we can't alias him */ | 9641 /* This buddy isn't in your buddy list, so we can't alias him */ |
9529 return FALSE; | 9642 return FALSE; |
9530 | 9643 |
9531 text = purple_buddy_get_contact_alias(buddy); | 9644 text = purple_buddy_get_contact_alias(buddy); |
9532 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { | 9645 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { |
9533 PurpleConnection *gc; | 9646 PurpleConnection *gc; |
9534 PurplePluginProtocolInfo *prpl_info = NULL; | 9647 PurplePluginProtocolInfo *prpl_info = NULL; |
9535 | 9648 |
9536 gc = purple_conversation_get_gc(conv); | 9649 gc = purple_conversation_get_connection(conv); |
9537 if (gc != NULL) | 9650 if (gc != NULL) |
9538 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 9651 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); |
9539 if (prpl_info && prpl_info->set_chat_topic == NULL) | 9652 if (prpl_info && prpl_info->set_chat_topic == NULL) |
9540 /* This protocol doesn't support setting the chat room topic */ | 9653 /* This protocol doesn't support setting the chat room topic */ |
9541 return FALSE; | 9654 return FALSE; |
9542 | 9655 |
9543 text = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); | 9656 text = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(conv)); |