pidgin/gtkconv.c

branch
soc.2013.gobjectification
changeset 34661
d9079090f7fe
parent 34660
68c776e3436e
child 34670
9bd5bd903dc7
equal deleted inserted replaced
34660:68c776e3436e 34661:d9079090f7fe
169 GtkWidget *window; 169 GtkWidget *window;
170 170
171 GtkWidget *entry; 171 GtkWidget *entry;
172 GtkWidget *message; 172 GtkWidget *message;
173 173
174 PurpleConversation *conv; 174 PurpleChatConversation *chat;
175 175
176 } InviteBuddyInfo; 176 } InviteBuddyInfo;
177 177
178 static GtkWidget *invite_dialog = NULL; 178 static GtkWidget *invite_dialog = NULL;
179 static GtkWidget *warn_close_dialog = NULL; 179 static GtkWidget *warn_close_dialog = NULL;
199 static gboolean infopane_entry_activate(PidginConversation *gtkconv); 199 static gboolean infopane_entry_activate(PidginConversation *gtkconv);
200 #if 0 200 #if 0
201 static void got_typing_keypress(PidginConversation *gtkconv, gboolean first); 201 static void got_typing_keypress(PidginConversation *gtkconv, gboolean first);
202 #endif 202 #endif
203 static void gray_stuff_out(PidginConversation *gtkconv); 203 static void gray_stuff_out(PidginConversation *gtkconv);
204 static void add_chat_buddy_common(PurpleConversation *conv, PurpleChatConversationBuddy *cb, const char *old_name); 204 static void add_chat_buddy_common(PurpleChatConversation *chat, PurpleChatConversationBuddy *cb, const char *old_name);
205 static gboolean tab_complete(PurpleConversation *conv); 205 static gboolean tab_complete(PurpleConversation *conv);
206 static void pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type); 206 static void pidgin_conv_updated(PurpleConversation *conv, PurpleConversationUpdateType type);
207 static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state); 207 static void conv_set_unseen(PurpleConversation *gtkconv, PidginUnseenState state);
208 static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state); 208 static void gtkconv_set_unseen(PidginConversation *gtkconv, PidginUnseenState state);
209 static void update_typing_icon(PidginConversation *gtkconv); 209 static void update_typing_icon(PidginConversation *gtkconv);
210 static void update_typing_message(PidginConversation *gtkconv, const char *message); 210 static void update_typing_message(PidginConversation *gtkconv, const char *message);
211 gboolean pidgin_conv_has_focus(PurpleConversation *conv); 211 gboolean pidgin_conv_has_focus(PurpleConversation *conv);
212 static GArray* generate_nick_colors(guint numcolors, GdkColor background); 212 static GArray* generate_nick_colors(guint numcolors, GdkColor background);
213 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); 213 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast);
214 static GtkTextTag *get_buddy_tag(PurpleConversation *conv, const char *who, PurpleMessageFlags flag, gboolean create); 214 static GtkTextTag *get_buddy_tag(PurpleChatConversation *chat, const char *who, PurpleMessageFlags flag, gboolean create);
215 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields); 215 static void pidgin_conv_update_fields(PurpleConversation *conv, PidginConvFields fields);
216 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win); 216 static void focus_out_from_menubar(GtkWidget *wid, PidginWindow *win);
217 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv); 217 static void pidgin_conv_tab_pack(PidginWindow *win, PidginConversation *gtkconv);
218 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv); 218 static gboolean infopane_press_cb(GtkWidget *widget, GdkEventButton *e, PidginConversation *conv);
219 static void hide_conv(PidginConversation *gtkconv, gboolean closetimer); 219 static void hide_conv(PidginConversation *gtkconv, gboolean closetimer);
246 get_conversation_blist_node(PurpleConversation *conv) 246 get_conversation_blist_node(PurpleConversation *conv)
247 { 247 {
248 PurpleAccount *account = purple_conversation_get_account(conv); 248 PurpleAccount *account = purple_conversation_get_account(conv);
249 PurpleBlistNode *node = NULL; 249 PurpleBlistNode *node = NULL;
250 250
251 switch (purple_conversation_get_type(conv)) { 251 if (PURPLE_IS_IM_CONVERSATION(conv)) {
252 case PURPLE_CONV_TYPE_IM: 252 node = PURPLE_BLIST_NODE(purple_find_buddy(account, purple_conversation_get_name(conv)));
253 node = PURPLE_BLIST_NODE(purple_find_buddy(account, purple_conversation_get_name(conv))); 253 node = node ? node->parent : NULL;
254 node = node ? node->parent : NULL; 254 } else {
255 break; 255 node = PURPLE_BLIST_NODE(purple_blist_find_chat(account, purple_conversation_get_name(conv)));
256 case PURPLE_CONV_TYPE_CHAT: 256 }
257 node = PURPLE_BLIST_NODE(purple_blist_find_chat(account, purple_conversation_get_name(conv))); 257
258 break;
259 default:
260 break;
261 }
262 return node; 258 return node;
263 } 259 }
264 260
265 /************************************************************************** 261 /**************************************************************************
266 * Callbacks 262 * Callbacks
269 static gboolean 265 static gboolean
270 close_this_sucker(gpointer data) 266 close_this_sucker(gpointer data)
271 { 267 {
272 PidginConversation *gtkconv = data; 268 PidginConversation *gtkconv = data;
273 GList *list = g_list_copy(gtkconv->convs); 269 GList *list = g_list_copy(gtkconv->convs);
274 g_list_foreach(list, (GFunc)purple_conversation_destroy, NULL); 270 g_list_foreach(list, (GFunc)g_object_unref, NULL);
275 g_list_free(list); 271 g_list_free(list);
276 return FALSE; 272 return FALSE;
277 } 273 }
278 274
279 static gboolean 275 static gboolean
286 * not marked 'Persistent' */ 282 * not marked 'Persistent' */
287 PurpleConversation *conv = gtkconv->active_conv; 283 PurpleConversation *conv = gtkconv->active_conv;
288 PurpleAccount *account = purple_conversation_get_account(conv); 284 PurpleAccount *account = purple_conversation_get_account(conv);
289 const char *name = purple_conversation_get_name(conv); 285 const char *name = purple_conversation_get_name(conv);
290 286
291 switch (purple_conversation_get_type(conv)) { 287 if (PURPLE_IS_IM_CONVERSATION(conv)) {
292 case PURPLE_CONV_TYPE_IM: 288 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately"))
293 { 289 close_this_sucker(gtkconv);
294 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately")) 290 else
295 close_this_sucker(gtkconv); 291 hide_conv(gtkconv, TRUE);
296 else 292 } else {
297 hide_conv(gtkconv, TRUE); 293 PurpleChat *chat = purple_blist_find_chat(account, name);
298 break; 294 if (!chat ||
299 } 295 !purple_blist_node_get_bool(&chat->node, "gtk-persistent"))
300 case PURPLE_CONV_TYPE_CHAT: 296 close_this_sucker(gtkconv);
301 { 297 else
302 PurpleChat *chat = purple_blist_find_chat(account, name); 298 hide_conv(gtkconv, FALSE);
303 if (!chat ||
304 !purple_blist_node_get_bool(&chat->node, "gtk-persistent"))
305 close_this_sucker(gtkconv);
306 else
307 hide_conv(gtkconv, FALSE);
308 break;
309 }
310 default:
311 ;
312 } 299 }
313 300
314 return TRUE; 301 return TRUE;
315 } 302 }
316 303
360 347
361 static PurpleCmdRet 348 static PurpleCmdRet
362 say_command_cb(PurpleConversation *conv, 349 say_command_cb(PurpleConversation *conv,
363 const char *cmd, char **args, char **error, void *data) 350 const char *cmd, char **args, char **error, void *data)
364 { 351 {
365 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 352 purple_conversation_send(conv, args[0]);
366 purple_im_conversation_send(PURPLE_CONV_IM(conv), args[0]);
367 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
368 purple_chat_conversation_send(PURPLE_CONV_CHAT(conv), args[0]);
369 353
370 return PURPLE_CMD_RET_OK; 354 return PURPLE_CMD_RET_OK;
371 } 355 }
372 356
373 static PurpleCmdRet 357 static PurpleCmdRet
375 const char *cmd, char **args, char **error, void *data) 359 const char *cmd, char **args, char **error, void *data)
376 { 360 {
377 char *tmp; 361 char *tmp;
378 362
379 tmp = g_strdup_printf("/me %s", args[0]); 363 tmp = g_strdup_printf("/me %s", args[0]);
380 364 purple_conversation_send(conv, tmp);
381 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
382 purple_im_conversation_send(PURPLE_CONV_IM(conv), tmp);
383 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
384 purple_chat_conversation_send(PURPLE_CONV_CHAT(conv), tmp);
385 365
386 g_free(tmp); 366 g_free(tmp);
387 return PURPLE_CMD_RET_OK; 367 return PURPLE_CMD_RET_OK;
388 } 368 }
389 369
443 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL)); 423 PURPLE_MESSAGE_NO_LOG|PURPLE_MESSAGE_ERROR, time(NULL));
444 return PURPLE_CMD_RET_OK; 424 return PURPLE_CMD_RET_OK;
445 } 425 }
446 426
447 markup = g_markup_escape_text(tmp, -1); 427 markup = g_markup_escape_text(tmp, -1);
448 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 428 purple_conversation_send(conv, markup);
449 purple_im_conversation_send(PURPLE_CONV_IM(conv), markup);
450 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
451 purple_chat_conversation_send(PURPLE_CONV_CHAT(conv), markup);
452 429
453 g_free(tmp); 430 g_free(tmp);
454 g_free(markup); 431 g_free(markup);
455 return PURPLE_CMD_RET_OK; 432 return PURPLE_CMD_RET_OK;
456 } 433 }
476 453
477 static PurpleCmdRet 454 static PurpleCmdRet
478 clearall_command_cb(PurpleConversation *conv, 455 clearall_command_cb(PurpleConversation *conv,
479 const char *cmd, char **args, char **error, void *data) 456 const char *cmd, char **args, char **error, void *data)
480 { 457 {
481 purple_conversation_foreach(purple_conversation_clear_message_history); 458 GList *l;
459 for (l = purple_conversations_get_all(); l != NULL; l = l->next)
460 purple_conversation_clear_message_history(PURPLE_CONVERSATION(l->data));
461
482 return PURPLE_CMD_RET_OK; 462 return PURPLE_CMD_RET_OK;
483 } 463 }
484 464
485 static PurpleCmdRet 465 static PurpleCmdRet
486 help_command_cb(PurpleConversation *conv, 466 help_command_cb(PurpleConversation *conv,
606 PURPLE_MESSAGE_NO_LOG, time(NULL)); 586 PURPLE_MESSAGE_NO_LOG, time(NULL));
607 g_free(error); 587 g_free(error);
608 retval = TRUE; 588 retval = TRUE;
609 break; 589 break;
610 case PURPLE_CMD_STATUS_WRONG_TYPE: 590 case PURPLE_CMD_STATUS_WRONG_TYPE:
611 if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 591 if(PURPLE_IS_IM_CONVERSATION(conv))
612 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."), 592 purple_conversation_write(conv, "", _("That command only works in chats, not IMs."),
613 PURPLE_MESSAGE_NO_LOG, time(NULL)); 593 PURPLE_MESSAGE_NO_LOG, time(NULL));
614 else 594 else
615 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."), 595 purple_conversation_write(conv, "", _("That command only works in IMs, not chats."),
616 PURPLE_MESSAGE_NO_LOG, time(NULL)); 596 PURPLE_MESSAGE_NO_LOG, time(NULL));
643 if (check_for_and_do_command(conv)) { 623 if (check_for_and_do_command(conv)) {
644 conversation_entry_clear(gtkconv); 624 conversation_entry_clear(gtkconv);
645 return; 625 return;
646 } 626 }
647 627
648 if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) && 628 if (PURPLE_IS_CHAT_CONVERSATION(conv) &&
649 purple_chat_conversation_has_left(PURPLE_CONV_CHAT(conv))) 629 purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)))
650 return; 630 return;
651 631
652 if (!purple_account_is_connected(account)) 632 if (!purple_account_is_connected(account))
653 return; 633 return;
654 634
680 int i; 660 int i;
681 661
682 bufs = gtk_webview_get_markup_lines(GTK_WEBVIEW(gtkconv->entry)); 662 bufs = gtk_webview_get_markup_lines(GTK_WEBVIEW(gtkconv->entry));
683 for (i = 0; bufs[i]; i++) { 663 for (i = 0; bufs[i]; i++) {
684 send_history_add(gtkconv, bufs[i]); 664 send_history_add(gtkconv, bufs[i]);
685 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 665 purple_conversation_send_with_flags(conv, bufs[i], flags);
686 purple_im_conversation_send_message(PURPLE_CONV_IM(conv), bufs[i], flags);
687 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
688 purple_chat_conversation_send_message(PURPLE_CONV_CHAT(conv), bufs[i], flags);
689 } 666 }
690 667
691 g_strfreev(bufs); 668 g_strfreev(bufs);
692 #endif 669 #endif
693 670
694 } else { 671 } else {
695 send_history_add(gtkconv, buf); 672 send_history_add(gtkconv, buf);
696 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 673 purple_conversation_send_with_flags(conv, buf, flags);
697 purple_im_conversation_send_message(PURPLE_CONV_IM(conv), buf, flags);
698 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
699 purple_chat_conversation_send_message(PURPLE_CONV_CHAT(conv), buf, flags);
700 } 674 }
701 675
702 g_free(clean); 676 g_free(clean);
703 g_free(buf); 677 g_free(buf);
704 678
715 PurpleConversation *conv = gtkconv->active_conv; 689 PurpleConversation *conv = gtkconv->active_conv;
716 690
717 account = purple_conversation_get_account(conv); 691 account = purple_conversation_get_account(conv);
718 name = purple_conversation_get_name(conv); 692 name = purple_conversation_get_name(conv);
719 693
720 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 694 if (PURPLE_IS_IM_CONVERSATION(conv)) {
721 PurpleBuddy *b; 695 PurpleBuddy *b;
722 696
723 b = purple_find_buddy(account, name); 697 b = purple_find_buddy(account, name);
724 if (b != NULL) 698 if (b != NULL)
725 pidgin_dialogs_remove_buddy(b); 699 pidgin_dialogs_remove_buddy(b);
726 else if (account != NULL && purple_account_is_connected(account)) 700 else if (account != NULL && purple_account_is_connected(account))
727 purple_blist_request_add_buddy(account, (char *)name, NULL, NULL); 701 purple_blist_request_add_buddy(account, (char *)name, NULL, NULL);
728 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 702 } else {
729 PurpleChat *c; 703 PurpleChat *c;
730 704
731 c = purple_blist_find_chat(account, name); 705 c = purple_blist_find_chat(account, name);
732 if (c != NULL) 706 if (c != NULL)
733 pidgin_dialogs_remove_chat(c); 707 pidgin_dialogs_remove_chat(c);
738 gtk_widget_grab_focus(PIDGIN_CONVERSATION(conv)->entry); 712 gtk_widget_grab_focus(PIDGIN_CONVERSATION(conv)->entry);
739 } 713 }
740 714
741 static void chat_do_info(PidginConversation *gtkconv, const char *who) 715 static void chat_do_info(PidginConversation *gtkconv, const char *who)
742 { 716 {
717 PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(gtkconv->active_conv);
718 PurpleConnection *gc;
719
720 if ((gc = purple_conversation_get_connection(gtkconv->active_conv))) {
721 pidgin_retrieve_user_info_in_chat(gc, who, purple_chat_conversation_get_id(chat));
722 }
723 }
724
725
726 static void
727 info_cb(GtkWidget *widget, PidginConversation *gtkconv)
728 {
743 PurpleConversation *conv = gtkconv->active_conv; 729 PurpleConversation *conv = gtkconv->active_conv;
744 PurpleConnection *gc; 730
745 731 if (PURPLE_IS_IM_CONVERSATION(conv)) {
746 if ((gc = purple_conversation_get_connection(conv))) {
747 pidgin_retrieve_user_info_in_chat(gc, who, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)));
748 }
749 }
750
751
752 static void
753 info_cb(GtkWidget *widget, PidginConversation *gtkconv)
754 {
755 PurpleConversation *conv = gtkconv->active_conv;
756
757 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
758 pidgin_retrieve_user_info(purple_conversation_get_connection(conv), 732 pidgin_retrieve_user_info(purple_conversation_get_connection(conv),
759 purple_conversation_get_name(conv)); 733 purple_conversation_get_name(conv));
760 gtk_widget_grab_focus(gtkconv->entry); 734 gtk_widget_grab_focus(gtkconv->entry);
761 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 735 } else {
762 /* Get info of the person currently selected in the GtkTreeView */ 736 /* Get info of the person currently selected in the GtkTreeView */
763 PidginChatPane *gtkchat; 737 PidginChatPane *gtkchat;
764 GtkTreeIter iter; 738 GtkTreeIter iter;
765 GtkTreeModel *model; 739 GtkTreeModel *model;
766 GtkTreeSelection *sel; 740 GtkTreeSelection *sel;
830 804
831 static void 805 static void
832 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) 806 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info)
833 { 807 {
834 const char *buddy, *message; 808 const char *buddy, *message;
835 PurpleConversation *conv; 809 PurpleChatConversation *chat;
836 810
837 conv = info->conv; 811 chat = info->chat;
838 812
839 if (resp == GTK_RESPONSE_OK) { 813 if (resp == GTK_RESPONSE_OK) {
840 buddy = gtk_entry_get_text(GTK_ENTRY(info->entry)); 814 buddy = gtk_entry_get_text(GTK_ENTRY(info->entry));
841 message = gtk_entry_get_text(GTK_ENTRY(info->message)); 815 message = gtk_entry_get_text(GTK_ENTRY(info->message));
842 816
843 if (!g_ascii_strcasecmp(buddy, "")) 817 if (!g_ascii_strcasecmp(buddy, ""))
844 return; 818 return;
845 819
846 serv_chat_invite(purple_conversation_get_connection(conv), 820 serv_chat_invite(purple_conversation_get_connection(PURPLE_CONVERSATION(chat)),
847 purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)), 821 purple_chat_conversation_get_id(chat),
848 message, buddy); 822 message, buddy);
849 } 823 }
850 824
851 gtk_widget_destroy(invite_dialog); 825 gtk_widget_destroy(invite_dialog);
852 invite_dialog = NULL; 826 invite_dialog = NULL;
860 { 834 {
861 InviteBuddyInfo *info = (InviteBuddyInfo *)data; 835 InviteBuddyInfo *info = (InviteBuddyInfo *)data;
862 const char *convprotocol; 836 const char *convprotocol;
863 gboolean success = TRUE; 837 gboolean success = TRUE;
864 838
865 convprotocol = purple_account_get_protocol_id(purple_conversation_get_account(info->conv)); 839 convprotocol = purple_account_get_protocol_id(
840 purple_conversation_get_account(PURPLE_CONVERSATION(info->chat)));
866 841
867 if (dnd_info == PIDGIN_DRAG_BLIST_NODE) 842 if (dnd_info == PIDGIN_DRAG_BLIST_NODE)
868 { 843 {
869 PurpleBlistNode *node = NULL; 844 PurpleBlistNode *node = NULL;
870 PurpleBuddy *buddy; 845 PurpleBuddy *buddy;
879 else 854 else
880 return; 855 return;
881 856
882 if (strcmp(convprotocol, purple_account_get_protocol_id(purple_buddy_get_account(buddy)))) 857 if (strcmp(convprotocol, purple_account_get_protocol_id(purple_buddy_get_account(buddy))))
883 { 858 {
884 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, 859 purple_notify_error(PIDGIN_CONVERSATION(PURPLE_CONVERSATION(info->chat)), NULL,
885 _("That buddy is not on the same protocol as this " 860 _("That buddy is not on the same protocol as this "
886 "chat."), NULL); 861 "chat."), NULL);
887 success = FALSE; 862 success = FALSE;
888 } 863 }
889 else 864 else
901 if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account, 876 if (pidgin_parse_x_im_contact((const char *) data, FALSE, &account,
902 &protocol, &username, NULL)) 877 &protocol, &username, NULL))
903 { 878 {
904 if (account == NULL) 879 if (account == NULL)
905 { 880 {
906 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, 881 purple_notify_error(PIDGIN_CONVERSATION(PURPLE_CONVERSATION(info->chat)), NULL,
907 _("You are not currently signed on with an account that " 882 _("You are not currently signed on with an account that "
908 "can invite that buddy."), NULL); 883 "can invite that buddy."), NULL);
909 } 884 }
910 else if (strcmp(convprotocol, purple_account_get_protocol_id(account))) 885 else if (strcmp(convprotocol, purple_account_get_protocol_id(account)))
911 { 886 {
912 purple_notify_error(PIDGIN_CONVERSATION(info->conv), NULL, 887 purple_notify_error(PIDGIN_CONVERSATION(PURPLE_CONVERSATION(info->chat)), NULL,
913 _("That buddy is not on the same protocol as this " 888 _("That buddy is not on the same protocol as this "
914 "chat."), NULL); 889 "chat."), NULL);
915 success = FALSE; 890 success = FALSE;
916 } 891 }
917 else 892 else
929 } 904 }
930 905
931 static void 906 static void
932 invite_cb(GtkWidget *widget, PidginConversation *gtkconv) 907 invite_cb(GtkWidget *widget, PidginConversation *gtkconv)
933 { 908 {
934 PurpleConversation *conv = gtkconv->active_conv; 909 PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(gtkconv->active_conv);
935 InviteBuddyInfo *info = NULL; 910 InviteBuddyInfo *info = NULL;
936 911
937 if (invite_dialog == NULL) { 912 if (invite_dialog == NULL) {
938 PidginWindow *gtkwin; 913 PidginWindow *gtkwin;
939 GtkWidget *label; 914 GtkWidget *label;
943 918
944 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION, 919 img = gtk_image_new_from_stock(PIDGIN_STOCK_DIALOG_QUESTION,
945 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE)); 920 gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_HUGE));
946 921
947 info = g_new0(InviteBuddyInfo, 1); 922 info = g_new0(InviteBuddyInfo, 1);
948 info->conv = conv; 923 info->chat = chat;
949 924
950 gtkwin = pidgin_conv_get_window(gtkconv); 925 gtkwin = pidgin_conv_get_window(gtkconv);
951 926
952 /* Create the new dialog. */ 927 /* Create the new dialog. */
953 invite_dialog = gtk_dialog_new_with_buttons( 928 invite_dialog = gtk_dialog_new_with_buttons(
1006 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); 981 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
1007 982
1008 /* Now the Buddy drop-down entry field. */ 983 /* Now the Buddy drop-down entry field. */
1009 info->entry = gtk_entry_new(); 984 info->entry = gtk_entry_new();
1010 pidgin_setup_screenname_autocomplete(info->entry, NULL, chat_invite_filter, 985 pidgin_setup_screenname_autocomplete(info->entry, NULL, chat_invite_filter,
1011 purple_conversation_get_account(conv)); 986 purple_conversation_get_account(PURPLE_CONVERSATION(chat)));
1012 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); 987 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1);
1013 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); 988 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry);
1014 989
1015 /* Now the label for "Message" */ 990 /* Now the label for "Message" */
1016 label = gtk_label_new(NULL); 991 label = gtk_label_new(NULL);
1150 PurpleAccount *account; 1125 PurpleAccount *account;
1151 GSList *buddies; 1126 GSList *buddies;
1152 GSList *cur; 1127 GSList *cur;
1153 1128
1154 conv = pidgin_conv_window_get_active_conversation(win); 1129 conv = pidgin_conv_window_get_active_conversation(win);
1155 1130 type = PURPLE_IS_IM_CONVERSATION(conv) ? PURPLE_LOG_IM : PURPLE_LOG_CHAT;
1156 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
1157 type = PURPLE_LOG_IM;
1158 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT)
1159 type = PURPLE_LOG_CHAT;
1160 else
1161 return;
1162 1131
1163 gtkblist = pidgin_blist_get_default_gtk_blist(); 1132 gtkblist = pidgin_blist_get_default_gtk_blist();
1164 1133
1165 pidgin_set_cursor(gtkblist->window, GDK_WATCH); 1134 pidgin_set_cursor(gtkblist->window, GDK_WATCH);
1166 pidgin_set_cursor(win->window, GDK_WATCH); 1135 pidgin_set_cursor(win->window, GDK_WATCH);
1229 menu_send_file_cb(GtkAction *action, gpointer data) 1198 menu_send_file_cb(GtkAction *action, gpointer data)
1230 { 1199 {
1231 PidginWindow *win = data; 1200 PidginWindow *win = data;
1232 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); 1201 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
1233 1202
1234 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 1203 if (PURPLE_IS_IM_CONVERSATION(conv)) {
1235 serv_send_file(purple_conversation_get_connection(conv), purple_conversation_get_name(conv), NULL); 1204 serv_send_file(purple_conversation_get_connection(conv), purple_conversation_get_name(conv), NULL);
1236 } 1205 }
1237 1206
1238 } 1207 }
1239 1208
1241 menu_get_attention_cb(GObject *obj, gpointer data) 1210 menu_get_attention_cb(GObject *obj, gpointer data)
1242 { 1211 {
1243 PidginWindow *win = data; 1212 PidginWindow *win = data;
1244 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); 1213 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
1245 1214
1246 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 1215 if (PURPLE_IS_IM_CONVERSATION(conv)) {
1247 int index; 1216 int index;
1248 if ((GtkAction *)obj == win->menu.get_attention) 1217 if ((GtkAction *)obj == win->menu.get_attention)
1249 index = 0; 1218 index = 0;
1250 else 1219 else
1251 index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(obj), "index")); 1220 index = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(obj), "index"));
1302 1271
1303 conv = pidgin_conv_window_get_active_conversation(win); 1272 conv = pidgin_conv_window_get_active_conversation(win);
1304 account = purple_conversation_get_account(conv); 1273 account = purple_conversation_get_account(conv);
1305 name = purple_conversation_get_name(conv); 1274 name = purple_conversation_get_name(conv);
1306 1275
1307 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 1276 if (PURPLE_IS_IM_CONVERSATION(conv)) {
1308 PurpleBuddy *b; 1277 PurpleBuddy *b;
1309 1278
1310 b = purple_find_buddy(account, name); 1279 b = purple_find_buddy(account, name);
1311 if (b != NULL) 1280 if (b != NULL)
1312 pidgin_dialogs_alias_buddy(b); 1281 pidgin_dialogs_alias_buddy(b);
1313 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 1282 } else {
1314 PurpleChat *c; 1283 PurpleChat *c;
1315 1284
1316 c = purple_blist_find_chat(account, name); 1285 c = purple_blist_find_chat(account, name);
1317 if (c != NULL) 1286 if (c != NULL)
1318 pidgin_dialogs_alias_chat(c); 1287 pidgin_dialogs_alias_chat(c);
1375 } 1344 }
1376 1345
1377 static gboolean 1346 static gboolean
1378 close_already(gpointer data) 1347 close_already(gpointer data)
1379 { 1348 {
1380 purple_conversation_destroy(data); 1349 g_object_unref(data);
1381 return FALSE; 1350 return FALSE;
1382 } 1351 }
1383 1352
1384 static void 1353 static void
1385 hide_conv(PidginConversation *gtkconv, gboolean closetimer) 1354 hide_conv(PidginConversation *gtkconv, gboolean closetimer)
1456 /* Disable the logging second, so that the above message can be logged. */ 1425 /* Disable the logging second, so that the above message can be logged. */
1457 purple_conversation_set_logging(conv, FALSE); 1426 purple_conversation_set_logging(conv, FALSE);
1458 } 1427 }
1459 1428
1460 /* Save the setting IFF it's different than the pref. */ 1429 /* Save the setting IFF it's different than the pref. */
1461 switch (purple_conversation_get_type(conv)) 1430 if (PURPLE_IS_IM_CONVERSATION(conv)) {
1462 { 1431 if (logging == purple_prefs_get_bool("/purple/logging/log_ims"))
1463 case PURPLE_CONV_TYPE_IM: 1432 purple_blist_node_remove_setting(node, "enable-logging");
1464 if (logging == purple_prefs_get_bool("/purple/logging/log_ims")) 1433 else
1465 purple_blist_node_remove_setting(node, "enable-logging"); 1434 purple_blist_node_set_bool(node, "enable-logging", logging);
1466 else 1435 } else {
1467 purple_blist_node_set_bool(node, "enable-logging", logging); 1436 if (logging == purple_prefs_get_bool("/purple/logging/log_chats"))
1468 break; 1437 purple_blist_node_remove_setting(node, "enable-logging");
1469 1438 else
1470 case PURPLE_CONV_TYPE_CHAT: 1439 purple_blist_node_set_bool(node, "enable-logging", logging);
1471 if (logging == purple_prefs_get_bool("/purple/logging/log_chats"))
1472 purple_blist_node_remove_setting(node, "enable-logging");
1473 else
1474 purple_blist_node_set_bool(node, "enable-logging", logging);
1475 break;
1476
1477 default:
1478 break;
1479 } 1440 }
1480 } 1441 }
1481 1442
1482 static void 1443 static void
1483 menu_toolbar_cb(GtkAction *action, gpointer data) 1444 menu_toolbar_cb(GtkAction *action, gpointer data)
1525 1486
1526 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); 1487 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
1527 1488
1528 if (prpl_info && prpl_info->get_cb_real_name) 1489 if (prpl_info && prpl_info->get_cb_real_name)
1529 real_who = prpl_info->get_cb_real_name(gc, 1490 real_who = prpl_info->get_cb_real_name(gc,
1530 purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)), who); 1491 purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)), who);
1531 1492
1532 if(!who && !real_who) 1493 if(!who && !real_who)
1533 return; 1494 return;
1534 1495
1535 pidgin_dialogs_im_with_user(account, real_who ? real_who : who); 1496 pidgin_dialogs_im_with_user(account, real_who ? real_who : who);
1536 1497
1537 g_free(real_who); 1498 g_free(real_who);
1538 } 1499 }
1539 1500
1540 static void pidgin_conv_chat_update_user(PurpleConversation *conv, const char *user); 1501 static void pidgin_conv_chat_update_user(PurpleChatConversationBuddy *cbuddy);
1541 1502
1542 static void 1503 static void
1543 ignore_cb(GtkWidget *w, PidginConversation *gtkconv) 1504 ignore_cb(GtkWidget *w, PidginConversation *gtkconv)
1544 { 1505 {
1545 PurpleConversation *conv = gtkconv->active_conv; 1506 PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(gtkconv->active_conv);
1546 PurpleChatConversation *chat;
1547 const char *name; 1507 const char *name;
1548 1508
1549 chat = PURPLE_CONV_CHAT(conv);
1550 name = g_object_get_data(G_OBJECT(w), "user_data"); 1509 name = g_object_get_data(G_OBJECT(w), "user_data");
1551 1510
1552 if (name == NULL) 1511 if (name == NULL)
1553 return; 1512 return;
1554 1513
1555 if (purple_chat_conversation_is_user_ignored(chat, name)) 1514 if (purple_chat_conversation_is_ignored_user(chat, name))
1556 purple_chat_conversation_unignore(chat, name); 1515 purple_chat_conversation_unignore(chat, name);
1557 else 1516 else
1558 purple_chat_conversation_ignore(chat, name); 1517 purple_chat_conversation_ignore(chat, name);
1559 1518
1560 pidgin_conv_chat_update_user(conv, name); 1519 pidgin_conv_chat_update_user(purple_chat_conversation_find_buddy(chat, name));
1561 } 1520 }
1562 1521
1563 static void 1522 static void
1564 menu_chat_im_cb(GtkWidget *w, PidginConversation *gtkconv) 1523 menu_chat_im_cb(GtkWidget *w, PidginConversation *gtkconv)
1565 { 1524 {
1581 1540
1582 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); 1541 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
1583 1542
1584 if (prpl_info && prpl_info->get_cb_real_name) 1543 if (prpl_info && prpl_info->get_cb_real_name)
1585 real_who = prpl_info->get_cb_real_name(gc, 1544 real_who = prpl_info->get_cb_real_name(gc,
1586 purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)), who); 1545 purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)), who);
1587 1546
1588 serv_send_file(gc, real_who ? real_who : who, NULL); 1547 serv_send_file(gc, real_who ? real_who : who, NULL);
1589 g_free(real_who); 1548 g_free(real_who);
1590 } 1549 }
1591 1550
1665 else 1624 else
1666 g_return_if_reached(); 1625 g_return_if_reached();
1667 } 1626 }
1668 1627
1669 static GtkWidget * 1628 static GtkWidget *
1670 create_chat_menu(PurpleConversation *conv, const char *who, PurpleConnection *gc) 1629 create_chat_menu(PurpleChatConversation *chat, const char *who, PurpleConnection *gc)
1671 { 1630 {
1672 static GtkWidget *menu = NULL; 1631 static GtkWidget *menu = NULL;
1673 PurplePluginProtocolInfo *prpl_info = NULL; 1632 PurplePluginProtocolInfo *prpl_info = NULL;
1674 PurpleChatConversation *chat = PURPLE_CONV_CHAT(conv); 1633 PurpleConversation *conv = PURPLE_CONVERSATION(chat);
1675 PurpleAccount *account = purple_conversation_get_account(conv); 1634 PurpleAccount *account = purple_conversation_get_account(conv);
1676 gboolean is_me = FALSE; 1635 gboolean is_me = FALSE;
1677 GtkWidget *button; 1636 GtkWidget *button;
1678 PurpleBuddy *buddy = NULL; 1637 PurpleBuddy *buddy = NULL;
1679 1638
1714 can_receive_file = FALSE; 1673 can_receive_file = FALSE;
1715 else { 1674 else {
1716 gchar *real_who = NULL; 1675 gchar *real_who = NULL;
1717 if (prpl_info->get_cb_real_name) 1676 if (prpl_info->get_cb_real_name)
1718 real_who = prpl_info->get_cb_real_name(gc, 1677 real_who = prpl_info->get_cb_real_name(gc,
1719 purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)), who); 1678 purple_chat_conversation_get_id(chat), who);
1720 if (!(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, real_who ? real_who : who))) 1679 if (!(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, real_who ? real_who : who)))
1721 can_receive_file = FALSE; 1680 can_receive_file = FALSE;
1722 g_free(real_who); 1681 g_free(real_who);
1723 } 1682 }
1724 1683
1727 else 1686 else
1728 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); 1687 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
1729 } 1688 }
1730 1689
1731 1690
1732 if (purple_chat_conversation_is_user_ignored(PURPLE_CONV_CHAT(conv), who)) 1691 if (purple_chat_conversation_is_ignored_user(chat, who))
1733 button = pidgin_new_item_from_stock(menu, _("Un-Ignore"), PIDGIN_STOCK_IGNORE, 1692 button = pidgin_new_item_from_stock(menu, _("Un-Ignore"), PIDGIN_STOCK_IGNORE,
1734 G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); 1693 G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
1735 else 1694 else
1736 button = pidgin_new_item_from_stock(menu, _("Ignore"), PIDGIN_STOCK_IGNORE, 1695 button = pidgin_new_item_from_stock(menu, _("Ignore"), PIDGIN_STOCK_IGNORE,
1737 G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); 1696 G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL);
1808 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); 1767 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list));
1809 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) 1768 if(!gtk_tree_selection_get_selected(sel, NULL, &iter))
1810 return FALSE; 1769 return FALSE;
1811 1770
1812 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); 1771 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1);
1813 menu = create_chat_menu (conv, who, gc); 1772 menu = create_chat_menu (PURPLE_CHAT_CONVERSATION(conv), who, gc);
1814 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, 1773 gtk_menu_popup(GTK_MENU(menu), NULL, NULL,
1815 pidgin_treeview_popup_menu_position_func, widget, 1774 pidgin_treeview_popup_menu_position_func, widget,
1816 0, GDK_CURRENT_TIME); 1775 0, GDK_CURRENT_TIME);
1817 g_free(who); 1776 g_free(who);
1818 1777
1873 1832
1874 if (node != NULL) 1833 if (node != NULL)
1875 webkit_dom_element_scroll_into_view(WEBKIT_DOM_ELEMENT(node), TRUE); 1834 webkit_dom_element_scroll_into_view(WEBKIT_DOM_ELEMENT(node), TRUE);
1876 1835
1877 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { 1836 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
1878 GtkWidget *menu = create_chat_menu (conv, who, gc); 1837 GtkWidget *menu = create_chat_menu (PURPLE_CHAT_CONVERSATION(conv), who, gc);
1879 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 1838 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
1880 event->button, event->time); 1839 event->button, event->time);
1881 } 1840 }
1882 1841
1883 handled: 1842 handled:
1942 1901
1943 static gboolean 1902 static gboolean
1944 gtkconv_cycle_focus(PidginConversation *gtkconv, GtkDirectionType dir) 1903 gtkconv_cycle_focus(PidginConversation *gtkconv, GtkDirectionType dir)
1945 { 1904 {
1946 PurpleConversation *conv = gtkconv->active_conv; 1905 PurpleConversation *conv = gtkconv->active_conv;
1947 gboolean chat = purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT; 1906 gboolean chat = PURPLE_IS_CHAT_CONVERSATION(conv);
1948 GtkWidget *next = NULL; 1907 GtkWidget *next = NULL;
1949 struct { 1908 struct {
1950 GtkWidget *from; 1909 GtkWidget *from;
1951 GtkWidget *to; 1910 GtkWidget *to;
1952 } transitions[] = { 1911 } transitions[] = {
2430 static void 2389 static void
2431 menu_conv_sel_send_cb(GObject *m, gpointer data) 2390 menu_conv_sel_send_cb(GObject *m, gpointer data)
2432 { 2391 {
2433 PurpleAccount *account = g_object_get_data(m, "purple_account"); 2392 PurpleAccount *account = g_object_get_data(m, "purple_account");
2434 gchar *name = g_object_get_data(m, "purple_buddy_name"); 2393 gchar *name = g_object_get_data(m, "purple_buddy_name");
2435 PurpleConversation *conv; 2394 PurpleIMConversation *im;
2436 2395
2437 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) 2396 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE)
2438 return; 2397 return;
2439 2398
2440 conv = purple_im_conversation_new(account, name); 2399 im = purple_im_conversation_new(account, name);
2441 pidgin_conv_switch_active_conversation(conv); 2400 pidgin_conv_switch_active_conversation(PURPLE_CONVERSATION(im));
2442 } 2401 }
2443 2402
2444 #if 0 2403 #if 0
2445 static void 2404 static void
2446 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, 2405 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position,
2525 2484
2526 g_return_val_if_fail(account != NULL, NULL); 2485 g_return_val_if_fail(account != NULL, NULL);
2527 g_return_val_if_fail(name != NULL, NULL); 2486 g_return_val_if_fail(name != NULL, NULL);
2528 2487
2529 /* Use the buddy icon, if possible */ 2488 /* Use the buddy icon, if possible */
2530 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 2489 if (PURPLE_IS_IM_CONVERSATION(conv)) {
2531 PurpleBuddy *b = purple_find_buddy(account, name); 2490 PurpleBuddy *b = purple_find_buddy(account, name);
2532 if (b != NULL) { 2491 if (b != NULL) {
2533 PurplePresence *p; 2492 PurplePresence *p;
2534 p = purple_buddy_get_presence(b); 2493 p = purple_buddy_get_presence(b);
2535 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) 2494 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY))
2558 2517
2559 account = purple_conversation_get_account(conv); 2518 account = purple_conversation_get_account(conv);
2560 g_return_val_if_fail(account != NULL, NULL); 2519 g_return_val_if_fail(account != NULL, NULL);
2561 2520
2562 /* Use the buddy icon, if possible */ 2521 /* Use the buddy icon, if possible */
2563 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 2522 if (PURPLE_IS_IM_CONVERSATION(conv)) {
2564 const char *name = NULL; 2523 const char *name = NULL;
2565 PurpleBuddy *b; 2524 PurpleBuddy *b;
2566 name = purple_conversation_get_name(conv); 2525 name = purple_conversation_get_name(conv);
2567 b = purple_find_buddy(account, name); 2526 b = purple_find_buddy(account, name);
2568 if (b != NULL) { 2527 if (b != NULL) {
2598 2557
2599 g_return_val_if_fail(account != NULL, NULL); 2558 g_return_val_if_fail(account != NULL, NULL);
2600 g_return_val_if_fail(name != NULL, NULL); 2559 g_return_val_if_fail(name != NULL, NULL);
2601 2560
2602 /* Use the buddy icon, if possible */ 2561 /* Use the buddy icon, if possible */
2603 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 2562 if (PURPLE_IS_IM_CONVERSATION(conv)) {
2604 PurpleBuddy *b = purple_find_buddy(account, name); 2563 PurpleBuddy *b = purple_find_buddy(account, name);
2605 if (b != NULL) { 2564 if (b != NULL) {
2606 /* I hate this hack. It fixes a bug where the pending message icon 2565 /* I hate this hack. It fixes a bug where the pending message icon
2607 * displays in the conv tab even though it shouldn't. 2566 * displays in the conv tab even though it shouldn't.
2608 * A better solution would be great. */ 2567 * A better solution would be great. */
2642 if (conv != gtkconv->active_conv) 2601 if (conv != gtkconv->active_conv)
2643 return; 2602 return;
2644 2603
2645 status = infopane_status = pidgin_conv_get_icon_stock(conv); 2604 status = infopane_status = pidgin_conv_get_icon_stock(conv);
2646 2605
2647 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 2606 if (PURPLE_IS_IM_CONVERSATION(conv)) {
2648 PurpleBuddy *b = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); 2607 PurpleBuddy *b = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv));
2649 if (b) 2608 if (b)
2650 emblem = pidgin_blist_get_emblem((PurpleBlistNode*)b); 2609 emblem = pidgin_blist_get_emblem((PurpleBlistNode*)b);
2651 } 2610 }
2652 2611
2680 /* XXX seanegan Why do I have to do this? */ 2639 /* XXX seanegan Why do I have to do this? */
2681 gtk_widget_queue_resize(gtkconv->infopane); 2640 gtk_widget_queue_resize(gtkconv->infopane);
2682 gtk_widget_queue_draw(gtkconv->infopane); 2641 gtk_widget_queue_draw(gtkconv->infopane);
2683 2642
2684 if (pidgin_conv_window_is_active_conversation(conv) && 2643 if (pidgin_conv_window_is_active_conversation(conv) &&
2685 (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM || 2644 (PURPLE_IS_CHAT_CONVERSATION(conv) || gtkconv->u.im->anim == NULL))
2686 gtkconv->u.im->anim == NULL))
2687 { 2645 {
2688 l = pidgin_conv_get_tab_icons(conv); 2646 l = pidgin_conv_get_tab_icons(conv);
2689 2647
2690 gtk_window_set_icon_list(GTK_WINDOW(win->window), l); 2648 gtk_window_set_icon_list(GTK_WINDOW(win->window), l);
2691 } 2649 }
2825 2783
2826 static void 2784 static void
2827 saveicon_writefile_cb(void *user_data, const char *filename) 2785 saveicon_writefile_cb(void *user_data, const char *filename)
2828 { 2786 {
2829 PidginConversation *gtkconv = (PidginConversation *)user_data; 2787 PidginConversation *gtkconv = (PidginConversation *)user_data;
2830 PurpleConversation *conv = gtkconv->active_conv; 2788 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(gtkconv->active_conv);
2831 PurpleBuddyIcon *icon; 2789 PurpleBuddyIcon *icon;
2832 const void *data; 2790 const void *data;
2833 size_t len; 2791 size_t len;
2834 2792
2835 icon = purple_im_conversation_get_icon(PURPLE_CONV_IM(conv)); 2793 icon = purple_im_conversation_get_icon(im);
2836 data = purple_buddy_icon_get_data(icon, &len); 2794 data = purple_buddy_icon_get_data(icon, &len);
2837 2795
2838 if ((len <= 0) || (data == NULL) || !purple_util_write_data_to_file_absolute(filename, data, len)) { 2796 if ((len <= 0) || (data == NULL) || !purple_util_write_data_to_file_absolute(filename, data, len)) {
2839 purple_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL); 2797 purple_notify_error(gtkconv, NULL, _("Unable to save icon file to disk."), NULL);
2840 } 2798 }
2885 } else { 2843 } else {
2886 size = BUDDYICON_SIZE_MAX; 2844 size = BUDDYICON_SIZE_MAX;
2887 } 2845 }
2888 2846
2889 gtk_widget_set_size_request(gtkconv->u.im->icon_container, -1, size); 2847 gtk_widget_set_size_request(gtkconv->u.im->icon_container, -1, size);
2890 pidgin_conv_update_buddy_icon(conv); 2848 pidgin_conv_update_buddy_icon(PURPLE_IM_CONVERSATION(conv));
2891 2849
2892 buddies = purple_find_buddies(purple_conversation_get_account(conv), 2850 buddies = purple_find_buddies(purple_conversation_get_account(conv),
2893 purple_conversation_get_name(conv)); 2851 purple_conversation_get_name(conv));
2894 for (; buddies; buddies = g_slist_delete_link(buddies, buddies)) { 2852 for (; buddies; buddies = g_slist_delete_link(buddies, buddies)) {
2895 PurpleBuddy *buddy = buddies->data; 2853 PurpleBuddy *buddy = buddies->data;
2925 const gchar *ext; 2883 const gchar *ext;
2926 gchar *buf; 2884 gchar *buf;
2927 2885
2928 g_return_if_fail(conv != NULL); 2886 g_return_if_fail(conv != NULL);
2929 2887
2930 ext = purple_buddy_icon_get_extension(purple_im_conversation_get_icon(PURPLE_CONV_IM(conv))); 2888 ext = purple_buddy_icon_get_extension(purple_im_conversation_get_icon(PURPLE_IM_CONVERSATION(conv)));
2931 2889
2932 buf = g_strdup_printf("%s.%s", purple_normalize(purple_conversation_get_account(conv), purple_conversation_get_name(conv)), ext); 2890 buf = g_strdup_printf("%s.%s", purple_normalize(purple_conversation_get_account(conv), purple_conversation_get_name(conv)), ext);
2933 2891
2934 purple_request_file(gtkconv, _("Save Icon"), buf, TRUE, 2892 purple_request_file(gtkconv, _("Save Icon"), buf, TRUE,
2935 G_CALLBACK(saveicon_writefile_cb), NULL, 2893 G_CALLBACK(saveicon_writefile_cb), NULL,
3302 gboolean ret; 3260 gboolean ret;
3303 3261
3304 conv = gtkconv->active_conv; 3262 conv = gtkconv->active_conv;
3305 account = purple_conversation_get_account(conv); 3263 account = purple_conversation_get_account(conv);
3306 3264
3307 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 3265 if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
3308 chat = purple_blist_find_chat(account, purple_conversation_get_name(conv)); 3266 chat = purple_blist_find_chat(account, purple_conversation_get_name(conv));
3309 3267
3310 if ((chat == NULL) && (gtkconv->webview != NULL)) { 3268 if ((chat == NULL) && (gtkconv->webview != NULL)) {
3311 chat = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat"); 3269 chat = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat");
3312 } 3270 }
3402 3360
3403 /* 3361 /*
3404 * Check if account support voice and/or calls, and 3362 * Check if account support voice and/or calls, and
3405 * if the current buddy supports it. 3363 * if the current buddy supports it.
3406 */ 3364 */
3407 if (account != NULL && purple_conversation_get_type(conv) 3365 if (account != NULL && PURPLE_IS_IM_CONVERSATION(conv)) {
3408 == PURPLE_CONV_TYPE_IM) {
3409 PurpleMediaCaps caps = 3366 PurpleMediaCaps caps =
3410 purple_prpl_get_media_caps(account, 3367 purple_prpl_get_media_caps(account,
3411 purple_conversation_get_name(conv)); 3368 purple_conversation_get_name(conv));
3412 3369
3413 gtk_action_set_sensitive(win->menu.audio_call, 3370 gtk_action_set_sensitive(win->menu.audio_call,
3417 caps & PURPLE_MEDIA_CAPS_VIDEO 3374 caps & PURPLE_MEDIA_CAPS_VIDEO
3418 ? TRUE : FALSE); 3375 ? TRUE : FALSE);
3419 gtk_action_set_sensitive(win->menu.audio_video_call, 3376 gtk_action_set_sensitive(win->menu.audio_video_call,
3420 caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO 3377 caps & PURPLE_MEDIA_CAPS_AUDIO_VIDEO
3421 ? TRUE : FALSE); 3378 ? TRUE : FALSE);
3422 } else if (purple_conversation_get_type(conv) 3379 } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
3423 == PURPLE_CONV_TYPE_CHAT) {
3424 /* for now, don't care about chats... */ 3380 /* for now, don't care about chats... */
3425 gtk_action_set_sensitive(win->menu.audio_call, FALSE); 3381 gtk_action_set_sensitive(win->menu.audio_call, FALSE);
3426 gtk_action_set_sensitive(win->menu.video_call, FALSE); 3382 gtk_action_set_sensitive(win->menu.video_call, FALSE);
3427 gtk_action_set_sensitive(win->menu.audio_video_call, FALSE); 3383 gtk_action_set_sensitive(win->menu.audio_video_call, FALSE);
3428 } else { 3384 } else {
3870 } 3826 }
3871 3827
3872 static void 3828 static void
3873 update_typing_icon(PidginConversation *gtkconv) 3829 update_typing_icon(PidginConversation *gtkconv)
3874 { 3830 {
3875 PurpleIMConversation *im = NULL; 3831 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(gtkconv->active_conv);
3876 PurpleConversation *conv = gtkconv->active_conv;
3877 char *message = NULL; 3832 char *message = NULL;
3878
3879 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM)
3880 im = PURPLE_CONV_IM(conv);
3881 3833
3882 if (im == NULL) 3834 if (im == NULL)
3883 return; 3835 return;
3884 3836
3885 if (purple_im_conversation_get_typing_state(im) == PURPLE_IM_CONVERSATION_NOT_TYPING) { 3837 if (purple_im_conversation_get_typing_state(im) == PURPLE_IM_CONVERSATION_NOT_TYPING) {
3890 #endif 3842 #endif
3891 return; 3843 return;
3892 } 3844 }
3893 3845
3894 if (purple_im_conversation_get_typing_state(im) == PURPLE_IM_CONVERSATION_TYPING) { 3846 if (purple_im_conversation_get_typing_state(im) == PURPLE_IM_CONVERSATION_TYPING) {
3895 message = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(conv)); 3847 message = g_strdup_printf(_("\n%s is typing..."), purple_conversation_get_title(PURPLE_CONVERSATION(im)));
3896 } else { 3848 } else {
3897 message = g_strdup_printf(_("\n%s has stopped typing"), purple_conversation_get_title(conv)); 3849 message = g_strdup_printf(_("\n%s has stopped typing"), purple_conversation_get_title(PURPLE_CONVERSATION(im)));
3898 } 3850 }
3899 3851
3900 update_typing_message(gtkconv, message); 3852 update_typing_message(gtkconv, message);
3901 g_free(message); 3853 g_free(message);
3902 } 3854 }
4080 win->menu.send_to, 2); 4032 win->menu.send_to, 2);
4081 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); 4033 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu);
4082 4034
4083 gtk_widget_show(menu); 4035 gtk_widget_show(menu);
4084 4036
4085 if (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_IM) { 4037 if (PURPLE_IS_IM_CONVERSATION(gtkconv->active_conv)) {
4086 buds = purple_find_buddies(purple_conversation_get_account(gtkconv->active_conv), purple_conversation_get_name(gtkconv->active_conv)); 4038 buds = purple_find_buddies(purple_conversation_get_account(gtkconv->active_conv), purple_conversation_get_name(gtkconv->active_conv));
4087 4039
4088 if (buds == NULL) 4040 if (buds == NULL)
4089 { 4041 {
4090 /* The user isn't on the buddy list. So we don't create any sendto menu. */ 4042 /* The user isn't on the buddy list. So we don't create any sendto menu. */
4154 image = PIDGIN_STOCK_STATUS_OPERATOR; 4106 image = PIDGIN_STOCK_STATUS_OPERATOR;
4155 } else if (flags & PURPLE_CHAT_CONVERSATION_BUDDY_HALFOP) { 4107 } else if (flags & PURPLE_CHAT_CONVERSATION_BUDDY_HALFOP) {
4156 image = PIDGIN_STOCK_STATUS_HALFOP; 4108 image = PIDGIN_STOCK_STATUS_HALFOP;
4157 } else if (flags & PURPLE_CHAT_CONVERSATION_BUDDY_VOICE) { 4109 } else if (flags & PURPLE_CHAT_CONVERSATION_BUDDY_VOICE) {
4158 image = PIDGIN_STOCK_STATUS_VOICE; 4110 image = PIDGIN_STOCK_STATUS_VOICE;
4159 } else if ((!flags) && purple_chat_conversation_is_user_ignored(chat, name)) { 4111 } else if ((!flags) && purple_chat_conversation_is_ignored_user(chat, name)) {
4160 image = PIDGIN_STOCK_STATUS_IGNORED; 4112 image = PIDGIN_STOCK_STATUS_IGNORED;
4161 } else { 4113 } else {
4162 return NULL; 4114 return NULL;
4163 } 4115 }
4164 return image; 4116 return image;
4174 purple_chat_conversation_buddy_set_ui_data(cb, NULL); 4126 purple_chat_conversation_buddy_set_ui_data(cb, NULL);
4175 } 4127 }
4176 } 4128 }
4177 4129
4178 static void 4130 static void
4179 add_chat_buddy_common(PurpleConversation *conv, PurpleChatConversationBuddy *cb, const char *old_name) 4131 add_chat_buddy_common(PurpleChatConversation *chat, PurpleChatConversationBuddy *cb, const char *old_name)
4180 { 4132 {
4181 PidginConversation *gtkconv; 4133 PidginConversation *gtkconv;
4134 PurpleConversation *conv;
4182 PidginChatPane *gtkchat; 4135 PidginChatPane *gtkchat;
4183 PurpleChatConversation *chat;
4184 PurpleConnection *gc; 4136 PurpleConnection *gc;
4185 PurplePluginProtocolInfo *prpl_info; 4137 PurplePluginProtocolInfo *prpl_info;
4186 GtkTreeModel *tm; 4138 GtkTreeModel *tm;
4187 GtkListStore *ls; 4139 GtkListStore *ls;
4188 GtkTreePath *newpath; 4140 GtkTreePath *newpath;
4197 4149
4198 alias = purple_chat_conversation_buddy_get_alias(cb); 4150 alias = purple_chat_conversation_buddy_get_alias(cb);
4199 name = purple_chat_conversation_buddy_get_name(cb); 4151 name = purple_chat_conversation_buddy_get_name(cb);
4200 flags = purple_chat_conversation_buddy_get_flags(cb); 4152 flags = purple_chat_conversation_buddy_get_flags(cb);
4201 4153
4202 chat = PURPLE_CONV_CHAT(conv); 4154 conv = PURPLE_CONVERSATION(chat);
4203 gtkconv = PIDGIN_CONVERSATION(conv); 4155 gtkconv = PIDGIN_CONVERSATION(conv);
4204 gtkchat = gtkconv->u.chat; 4156 gtkchat = gtkconv->u.chat;
4205 gc = purple_conversation_get_connection(conv); 4157 gc = purple_conversation_get_connection(conv);
4206 4158
4207 if (!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)))) 4159 if (!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))))
4229 "send-name"); 4181 "send-name");
4230 g_object_get(tag, "foreground-gdk", &color, NULL); 4182 g_object_get(tag, "foreground-gdk", &color, NULL);
4231 #endif /* if 0 */ 4183 #endif /* if 0 */
4232 } else { 4184 } else {
4233 GtkTextTag *tag; 4185 GtkTextTag *tag;
4234 if ((tag = get_buddy_tag(conv, name, 0, FALSE))) 4186 if ((tag = get_buddy_tag(chat, name, 0, FALSE)))
4235 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL); 4187 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL);
4236 if ((tag = get_buddy_tag(conv, name, PURPLE_MESSAGE_NICK, FALSE))) 4188 if ((tag = get_buddy_tag(chat, name, PURPLE_MESSAGE_NICK, FALSE)))
4237 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL); 4189 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_NORMAL, NULL);
4238 color = (GdkColor*)get_nick_color(gtkconv, name); 4190 color = (GdkColor*)get_nick_color(gtkconv, name);
4239 } 4191 }
4240 4192
4241 gtk_list_store_insert_with_values(ls, &iter, 4193 gtk_list_store_insert_with_values(ls, &iter,
4353 4305
4354 word_start = cursor; 4306 word_start = cursor;
4355 4307
4356 /* if there's nothing there just return */ 4308 /* if there's nothing there just return */
4357 if (!gtk_text_iter_compare(&cursor, &start_buffer)) 4309 if (!gtk_text_iter_compare(&cursor, &start_buffer))
4358 return (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) ? TRUE : FALSE; 4310 return PURPLE_IS_CHAT_CONVERSATION(conv);
4359 4311
4360 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, 4312 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer,
4361 &cursor, FALSE); 4313 &cursor, FALSE);
4362 4314
4363 /* if we're at the end of ": " we need to move back 2 spaces */ 4315 /* if we're at the end of ": " we need to move back 2 spaces */
4391 &cursor, FALSE); 4343 &cursor, FALSE);
4392 entered_bytes = strlen(entered); 4344 entered_bytes = strlen(entered);
4393 4345
4394 if (!g_utf8_strlen(entered, -1)) { 4346 if (!g_utf8_strlen(entered, -1)) {
4395 g_free(entered); 4347 g_free(entered);
4396 return (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) ? TRUE : FALSE; 4348 return PURPLE_IS_CHAT_CONVERSATION(conv);
4397 } 4349 }
4398 4350
4399 nick_partial = g_malloc0(entered_bytes + 1); 4351 nick_partial = g_malloc0(entered_bytes + 1);
4400 4352
4401 if (command) { 4353 if (command) {
4406 for (l = list; l != NULL; l = l->next) { 4358 for (l = list; l != NULL; l = l->next) {
4407 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial, 4359 tab_complete_process_item(&most_matched, entered, entered_bytes, &partial, nick_partial,
4408 &matches, l->data); 4360 &matches, l->data);
4409 } 4361 }
4410 g_list_free(list); 4362 g_list_free(list);
4411 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 4363 } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
4412 PurpleChatConversation *chat = PURPLE_CONV_CHAT(conv); 4364 PurpleChatConversation *chat = PURPLE_CONV_CHAT(conv);
4413 GList *l = purple_chat_conversation_get_users(chat); 4365 GList *l = purple_chat_conversation_get_users(chat);
4414 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(PIDGIN_CONVERSATION(conv)->u.chat->list)); 4366 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(PIDGIN_CONVERSATION(conv)->u.chat->list));
4415 GtkTreeIter iter; 4367 GtkTreeIter iter;
4416 int f; 4368 int f;
4455 4407
4456 /* if there weren't any matches, return */ 4408 /* if there weren't any matches, return */
4457 if (!matches) { 4409 if (!matches) {
4458 /* if matches isn't set partials won't be either */ 4410 /* if matches isn't set partials won't be either */
4459 g_free(entered); 4411 g_free(entered);
4460 return (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) ? TRUE : FALSE; 4412 return PURPLE_IS_CHAT_CONVERSATION(conv);
4461 } 4413 }
4462 4414
4463 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); 4415 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor);
4464 4416
4465 if (!matches->next) { 4417 if (!matches->next) {
4525 return; 4477 return;
4526 4478
4527 gtkconv = PIDGIN_CONVERSATION(conv); 4479 gtkconv = PIDGIN_CONVERSATION(conv);
4528 gtkchat = gtkconv->u.chat; 4480 gtkchat = gtkconv->u.chat;
4529 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); 4481 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text)));
4530 current_topic = purple_chat_conversation_get_topic(PURPLE_CONV_CHAT(conv)); 4482 current_topic = purple_chat_conversation_get_topic(PURPLE_CHAT_CONVERSATION(conv));
4531 4483
4532 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ 4484 if(current_topic && !g_utf8_collate(new_topic, current_topic)){
4533 g_free(new_topic); 4485 g_free(new_topic);
4534 return; 4486 return;
4535 } 4487 }
4537 if (current_topic) 4489 if (current_topic)
4538 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); 4490 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic);
4539 else 4491 else
4540 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), ""); 4492 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), "");
4541 4493
4542 prpl_info->set_chat_topic(gc, purple_chat_conversation_get_id(PURPLE_CONV_CHAT(conv)), 4494 prpl_info->set_chat_topic(gc, purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)),
4543 new_topic); 4495 new_topic);
4544 4496
4545 g_free(new_topic); 4497 g_free(new_topic);
4546 } 4498 }
4547 4499
4587 4539
4588 return ret; 4540 return ret;
4589 } 4541 }
4590 4542
4591 static void 4543 static void
4592 update_chat_alias(PurpleBuddy *buddy, PurpleConversation *conv, PurpleConnection *gc, PurplePluginProtocolInfo *prpl_info) 4544 update_chat_alias(PurpleBuddy *buddy, PurpleChatConversation *chat, PurpleConnection *gc, PurplePluginProtocolInfo *prpl_info)
4593 { 4545 {
4594 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); 4546 PidginConversation *gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(chat));
4595 PurpleChatConversation *chat = PURPLE_CONV_CHAT(conv); 4547 PurpleAccount *account = purple_conversation_get_account(PURPLE_CONVERSATION(chat));
4596 PurpleAccount *account = purple_conversation_get_account(conv);
4597 GtkTreeModel *model; 4548 GtkTreeModel *model;
4598 char *normalized_name; 4549 char *normalized_name;
4599 GtkTreeIter iter; 4550 GtkTreeIter iter;
4600 int f; 4551 int f;
4601 4552
4602 g_return_if_fail(buddy != NULL); 4553 g_return_if_fail(buddy != NULL);
4603 g_return_if_fail(conv != NULL); 4554 g_return_if_fail(chat != NULL);
4604 4555
4605 /* This is safe because this callback is only used in chats, not IMs. */ 4556 /* This is safe because this callback is only used in chats, not IMs. */
4606 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list)); 4557 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list));
4607 4558
4608 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) 4559 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
4649 4600
4650 g_free(normalized_name); 4601 g_free(normalized_name);
4651 } 4602 }
4652 4603
4653 static void 4604 static void
4654 blist_node_aliased_cb(PurpleBlistNode *node, const char *old_alias, PurpleConversation *conv) 4605 blist_node_aliased_cb(PurpleBlistNode *node, const char *old_alias, PurpleChatConversation *chat)
4655 { 4606 {
4656 PurpleConnection *gc; 4607 PurpleConnection *gc;
4657 PurplePluginProtocolInfo *prpl_info; 4608 PurplePluginProtocolInfo *prpl_info;
4609 PurpleConversation *conv = PURPLE_CONVERSATION(chat);
4658 4610
4659 g_return_if_fail(node != NULL); 4611 g_return_if_fail(node != NULL);
4660 g_return_if_fail(conv != NULL); 4612 g_return_if_fail(conv != NULL);
4661 4613
4662 gc = purple_conversation_get_connection(conv); 4614 gc = purple_conversation_get_connection(conv);
4674 for(bnode = node->child; bnode; bnode = bnode->next) { 4626 for(bnode = node->child; bnode; bnode = bnode->next) {
4675 4627
4676 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) 4628 if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
4677 continue; 4629 continue;
4678 4630
4679 update_chat_alias((PurpleBuddy *)bnode, conv, gc, prpl_info); 4631 update_chat_alias((PurpleBuddy *)bnode, chat, gc, prpl_info);
4680 } 4632 }
4681 } 4633 }
4682 else if (PURPLE_BLIST_NODE_IS_BUDDY(node)) 4634 else if (PURPLE_BLIST_NODE_IS_BUDDY(node))
4683 update_chat_alias((PurpleBuddy *)node, conv, gc, prpl_info); 4635 update_chat_alias((PurpleBuddy *)node, chat, gc, prpl_info);
4684 else if (PURPLE_BLIST_NODE_IS_CHAT(node) && 4636 else if (PURPLE_BLIST_NODE_IS_CHAT(node) &&
4685 purple_conversation_get_account(conv) == purple_chat_get_account((PurpleChat*)node)) 4637 purple_conversation_get_account(conv) == purple_chat_get_account((PurpleChat*)node))
4686 { 4638 {
4687 if (old_alias == NULL || g_utf8_collate(old_alias, purple_conversation_get_title(conv)) == 0) 4639 if (old_alias == NULL || g_utf8_collate(old_alias, purple_conversation_get_title(conv)) == 0)
4688 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE); 4640 pidgin_conv_update_fields(conv, PIDGIN_CONV_SET_TITLE);
4689 } 4641 }
4690 } 4642 }
4691 4643
4692 static void 4644 static void
4693 buddy_cb_common(PurpleBuddy *buddy, PurpleConversation *conv, gboolean is_buddy) 4645 buddy_cb_common(PurpleBuddy *buddy, PurpleChatConversation *chat, gboolean is_buddy)
4694 { 4646 {
4695 GtkTreeModel *model; 4647 GtkTreeModel *model;
4696 char *normalized_name; 4648 char *normalized_name;
4697 GtkTreeIter iter; 4649 GtkTreeIter iter;
4698 GtkTextTag *texttag; 4650 GtkTextTag *texttag;
4651 PurpleConversation *conv = PURPLE_CONVERSATION(chat);
4699 int f; 4652 int f;
4700 4653
4701 g_return_if_fail(buddy != NULL); 4654 g_return_if_fail(buddy != NULL);
4702 g_return_if_fail(conv != NULL); 4655 g_return_if_fail(conv != NULL);
4703 4656
4730 g_free(name); 4683 g_free(name);
4731 } while (f != 0); 4684 } while (f != 0);
4732 4685
4733 g_free(normalized_name); 4686 g_free(normalized_name);
4734 4687
4735 blist_node_aliased_cb((PurpleBlistNode *)buddy, NULL, conv); 4688 blist_node_aliased_cb((PurpleBlistNode *)buddy, NULL, chat);
4736 4689
4737 texttag = get_buddy_tag(conv, purple_buddy_get_name(buddy), 0, FALSE); /* XXX: do we want the normalized name? */ 4690 texttag = get_buddy_tag(chat, purple_buddy_get_name(buddy), 0, FALSE); /* XXX: do we want the normalized name? */
4738 if (texttag) { 4691 if (texttag) {
4739 g_object_set(texttag, "weight", is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL); 4692 g_object_set(texttag, "weight", is_buddy ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL, NULL);
4740 } 4693 }
4741 } 4694 }
4742 4695
4743 static void 4696 static void
4744 buddy_added_cb(PurpleBlistNode *node, PurpleConversation *conv) 4697 buddy_added_cb(PurpleBlistNode *node, PurpleChatConversation *chat)
4745 { 4698 {
4746 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) 4699 if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
4747 return; 4700 return;
4748 4701
4749 buddy_cb_common(PURPLE_BUDDY(node), conv, TRUE); 4702 buddy_cb_common(PURPLE_BUDDY(node), chat, TRUE);
4750 } 4703 }
4751 4704
4752 static void 4705 static void
4753 buddy_removed_cb(PurpleBlistNode *node, PurpleConversation *conv) 4706 buddy_removed_cb(PurpleBlistNode *node, PurpleChatConversation *chat)
4754 { 4707 {
4755 if (!PURPLE_BLIST_NODE_IS_BUDDY(node)) 4708 if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
4756 return; 4709 return;
4757 4710
4758 /* If there's another buddy for the same "dude" on the list, do nothing. */ 4711 /* If there's another buddy for the same "dude" on the list, do nothing. */
4759 if (purple_find_buddy(purple_buddy_get_account(PURPLE_BUDDY(node)), 4712 if (purple_find_buddy(purple_buddy_get_account(PURPLE_BUDDY(node)),
4760 purple_buddy_get_name(PURPLE_BUDDY(node))) != NULL) 4713 purple_buddy_get_name(PURPLE_BUDDY(node))) != NULL)
4761 return; 4714 return;
4762 4715
4763 buddy_cb_common(PURPLE_BUDDY(node), conv, FALSE); 4716 buddy_cb_common(PURPLE_BUDDY(node), chat, FALSE);
4764 } 4717 }
4765 4718
4766 static void 4719 static void
4767 entry_popup_menu_cb(GtkWebView *webview, GtkMenu *menu, gpointer data) 4720 entry_popup_menu_cb(GtkWebView *webview, GtkMenu *menu, gpointer data)
4768 { 4721 {
5047 PurpleBlistNode *node = NULL; 5000 PurpleBlistNode *node = NULL;
5048 PurpleConversation *conv; 5001 PurpleConversation *conv;
5049 PidginConversation *gtkconv = userdata; 5002 PidginConversation *gtkconv = userdata;
5050 5003
5051 conv = gtkconv->active_conv; 5004 conv = gtkconv->active_conv;
5052 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 5005 if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
5053 node = (PurpleBlistNode*)(purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv))); 5006 node = (PurpleBlistNode*)(purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv)));
5054 if (!node) 5007 if (!node)
5055 node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat"); 5008 node = g_object_get_data(G_OBJECT(gtkconv->webview), "transient_chat");
5056 } else { 5009 } else {
5057 node = (PurpleBlistNode*)(purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv))); 5010 node = (PurpleBlistNode*)(purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)));
5169 } else { 5122 } else {
5170 replace = purple_conversation_get_name(conv); 5123 replace = purple_conversation_get_name(conv);
5171 } 5124 }
5172 5125
5173 } else if (g_str_has_prefix(cur, "%incomingIconPath%")) { 5126 } else if (g_str_has_prefix(cur, "%incomingIconPath%")) {
5174 PurpleBuddyIcon *icon = purple_im_conversation_get_icon(PURPLE_CONV_IM(conv)); 5127 PurpleBuddyIcon *icon = purple_im_conversation_get_icon(PURPLE_IM_CONVERSATION(conv));
5175 if (icon) 5128 if (icon)
5176 replace = purple_buddy_icon_get_full_path(icon); 5129 replace = purple_buddy_icon_get_full_path(icon);
5177 5130
5178 } else if (g_str_has_prefix(cur, "%outgoingIconPath%")) { 5131 } else if (g_str_has_prefix(cur, "%outgoingIconPath%")) {
5179 replace = purple_account_get_buddy_icon_path(account); 5132 replace = purple_account_get_buddy_icon_path(account);
5355 basedir = pidgin_conversation_theme_get_template_path(gtkconv->theme); 5308 basedir = pidgin_conversation_theme_get_template_path(gtkconv->theme);
5356 baseuri = g_strdup_printf("file://%s", basedir); 5309 baseuri = g_strdup_printf("file://%s", basedir);
5357 webkit_web_view_load_string(WEBKIT_WEB_VIEW(gtkconv->webview), template, 5310 webkit_web_view_load_string(WEBKIT_WEB_VIEW(gtkconv->webview), template,
5358 "text/html", "UTF-8", baseuri); 5311 "text/html", "UTF-8", baseuri);
5359 5312
5360 if (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_CHAT) 5313 if (PURPLE_IS_CHAT_CONVERSATION(gtkconv->active_conv))
5361 gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview), 5314 gtk_webview_safe_execute_script(GTK_WEBVIEW(gtkconv->webview),
5362 "document.getElementById('Chat').className = 'groupchat'"); 5315 "document.getElementById('Chat').className = 'groupchat'");
5363 5316
5364 g_signal_connect(G_OBJECT(gtkconv->theme), "notify::variant", 5317 g_signal_connect(G_OBJECT(gtkconv->theme), "notify::variant",
5365 G_CALLBACK(conv_variant_changed_cb), gtkconv); 5318 G_CALLBACK(conv_variant_changed_cb), gtkconv);
5375 GtkWidget *vbox, *frame, *webview_sw, *event_box; 5328 GtkWidget *vbox, *frame, *webview_sw, *event_box;
5376 GtkCellRenderer *rend; 5329 GtkCellRenderer *rend;
5377 GtkTreePath *path; 5330 GtkTreePath *path;
5378 PurpleConversation *conv = gtkconv->active_conv; 5331 PurpleConversation *conv = gtkconv->active_conv;
5379 PurpleBuddy *buddy; 5332 PurpleBuddy *buddy;
5380 gboolean chat = (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT); 5333 gboolean chat = PURPLE_IS_CHAT_CONVERSATION(conv);
5381 int buddyicon_size = 0; 5334 int buddyicon_size = 0;
5382 5335
5383 /* Setup the top part of the pane */ 5336 /* Setup the top part of the pane */
5384 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE); 5337 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
5385 gtk_widget_show(vbox); 5338 gtk_widget_show(vbox);
5561 GtkSelectionData *sd, guint info, guint t, 5514 GtkSelectionData *sd, guint info, guint t,
5562 PidginConversation *gtkconv) 5515 PidginConversation *gtkconv)
5563 { 5516 {
5564 PurpleConversation *conv = gtkconv->active_conv; 5517 PurpleConversation *conv = gtkconv->active_conv;
5565 PidginWindow *win = gtkconv->win; 5518 PidginWindow *win = gtkconv->win;
5566 PurpleConversation *c; 5519 PurpleIMConversation *im;
5567 PurpleAccount *convaccount = purple_conversation_get_account(conv); 5520 PurpleAccount *convaccount = purple_conversation_get_account(conv);
5568 PurpleConnection *gc = purple_account_get_connection(convaccount); 5521 PurpleConnection *gc = purple_account_get_connection(convaccount);
5569 PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL; 5522 PurplePluginProtocolInfo *prpl_info = gc ? PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)) : NULL;
5570 const guchar *data = gtk_selection_data_get_data(sd); 5523 const guchar *data = gtk_selection_data_get_data(sd);
5571 5524
5590 buddyname = purple_buddy_get_name(b); 5543 buddyname = purple_buddy_get_name(b);
5591 /* 5544 /*
5592 * If a buddy is dragged to a chat window of the same protocol, 5545 * If a buddy is dragged to a chat window of the same protocol,
5593 * invite him to the chat. 5546 * invite him to the chat.
5594 */ 5547 */
5595 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && 5548 if (PURPLE_IS_CHAT_CONVERSATION(conv) &&
5596 prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, chat_invite) && 5549 prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, chat_invite) &&
5597 strcmp(purple_account_get_protocol_id(convaccount), 5550 strcmp(purple_account_get_protocol_id(convaccount),
5598 purple_account_get_protocol_id(buddyaccount)) == 0) { 5551 purple_account_get_protocol_id(buddyaccount)) == 0) {
5599 purple_chat_conversation_invite_user(PURPLE_CONV_CHAT(conv), buddyname, NULL, TRUE); 5552 purple_chat_conversation_invite_user(PURPLE_CHAT_CONVERSATION(conv), buddyname, NULL, TRUE);
5600 } else { 5553 } else {
5601 /* 5554 /*
5602 * If we already have an open conversation with this buddy, then 5555 * If we already have an open conversation with this buddy, then
5603 * just move the conv to this window. Otherwise, create a new 5556 * just move the conv to this window. Otherwise, create a new
5604 * conv and add it to this window. 5557 * conv and add it to this window.
5605 */ 5558 */
5606 c = purple_conversations_find_im_with_account(buddyname, buddyaccount); 5559 im = purple_conversations_find_im_with_account(buddyname, buddyaccount);
5607 if (c != NULL) { 5560 if (im != NULL) {
5608 PidginWindow *oldwin; 5561 PidginWindow *oldwin;
5609 gtkconv = PIDGIN_CONVERSATION(c); 5562 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(im));
5610 oldwin = gtkconv->win; 5563 oldwin = gtkconv->win;
5611 if (oldwin != win) { 5564 if (oldwin != win) {
5612 pidgin_conv_window_remove_gtkconv(oldwin, gtkconv); 5565 pidgin_conv_window_remove_gtkconv(oldwin, gtkconv);
5613 pidgin_conv_window_add_gtkconv(win, gtkconv); 5566 pidgin_conv_window_add_gtkconv(win, gtkconv);
5614 } 5567 }
5615 } else { 5568 } else {
5616 c = purple_im_conversation_new(buddyaccount, buddyname); 5569 im = purple_im_conversation_new(buddyaccount, buddyname);
5617 gtkconv = PIDGIN_CONVERSATION(c); 5570 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(im));
5618 if (gtkconv->win != win) { 5571 if (gtkconv->win != win) {
5619 pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv); 5572 pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv);
5620 pidgin_conv_window_add_gtkconv(win, gtkconv); 5573 pidgin_conv_window_add_gtkconv(win, gtkconv);
5621 } 5574 }
5622 } 5575 }
5646 } else { 5599 } else {
5647 /* 5600 /*
5648 * If a buddy is dragged to a chat window of the same protocol, 5601 * If a buddy is dragged to a chat window of the same protocol,
5649 * invite him to the chat. 5602 * invite him to the chat.
5650 */ 5603 */
5651 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && 5604 if (PURPLE_IS_CHAT_CONVERSATION(conv) &&
5652 prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, chat_invite) && 5605 prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, chat_invite) &&
5653 strcmp(purple_account_get_protocol_id(convaccount), protocol) == 0) { 5606 strcmp(purple_account_get_protocol_id(convaccount), protocol) == 0) {
5654 purple_chat_conversation_invite_user(PURPLE_CONV_CHAT(conv), username, NULL, TRUE); 5607 purple_chat_conversation_invite_user(PURPLE_CHAT_CONVERSATION(conv), username, NULL, TRUE);
5655 } else { 5608 } else {
5656 c = purple_im_conversation_new(account, username); 5609 im = purple_im_conversation_new(account, username);
5657 gtkconv = PIDGIN_CONVERSATION(c); 5610 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(im));
5658 if (gtkconv->win != win) { 5611 if (gtkconv->win != win) {
5659 pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv); 5612 pidgin_conv_window_remove_gtkconv(gtkconv->win, gtkconv);
5660 pidgin_conv_window_add_gtkconv(win, gtkconv); 5613 pidgin_conv_window_add_gtkconv(win, gtkconv);
5661 } 5614 }
5662 } 5615 }
5668 5621
5669 gtk_drag_finish(dc, TRUE, 5622 gtk_drag_finish(dc, TRUE,
5670 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); 5623 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
5671 } 5624 }
5672 else if (info == WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST) { 5625 else if (info == WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST) {
5673 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 5626 if (PURPLE_IS_IM_CONVERSATION(conv))
5674 pidgin_dnd_file_manage(sd, convaccount, purple_conversation_get_name(conv)); 5627 pidgin_dnd_file_manage(sd, convaccount, purple_conversation_get_name(conv));
5675 gtk_drag_finish(dc, TRUE, 5628 gtk_drag_finish(dc, TRUE,
5676 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); 5629 gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t);
5677 } 5630 }
5678 else 5631 else
5694 return NULL; 5647 return NULL;
5695 5648
5696 cn = PURPLE_BLIST_NODE(c); 5649 cn = PURPLE_BLIST_NODE(c);
5697 for (bn = purple_blist_node_get_first_child(cn); bn; bn = purple_blist_node_get_sibling_next(bn)) { 5650 for (bn = purple_blist_node_get_first_child(cn); bn; bn = purple_blist_node_get_sibling_next(bn)) {
5698 PurpleBuddy *b = PURPLE_BUDDY(bn); 5651 PurpleBuddy *b = PURPLE_BUDDY(bn);
5699 PurpleConversation *conv; 5652 PurpleIMConversation *im;
5700 if ((conv = purple_conversations_find_im_with_account(purple_buddy_get_name(b), purple_buddy_get_account(b)))) { 5653 if ((im = purple_conversations_find_im_with_account(purple_buddy_get_name(b), purple_buddy_get_account(b)))) {
5701 if (PIDGIN_CONVERSATION(conv)) 5654 if (PIDGIN_CONVERSATION(PURPLE_CONVERSATION(im)))
5702 return PIDGIN_CONVERSATION(conv); 5655 return PIDGIN_CONVERSATION(PURPLE_CONVERSATION(im));
5703 } 5656 }
5704 } 5657 }
5705 5658
5706 return NULL; 5659 return NULL;
5707 } 5660 }
5718 for (list = pidgin_conv_windows_get_list(); list; list = list->next) 5671 for (list = pidgin_conv_windows_get_list(); list; list = list->next)
5719 { 5672 {
5720 PidginWindow *win = list->data; 5673 PidginWindow *win = list->data;
5721 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win); 5674 PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
5722 5675
5723 if (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM) 5676 if (PURPLE_IS_CHAT_CONVERSATION(conv))
5724 continue; 5677 continue;
5725 5678
5726 pidgin_conv_update_fields(conv, PIDGIN_CONV_MENU); 5679 pidgin_conv_update_fields(conv, PIDGIN_CONV_MENU);
5727 } 5680 }
5728 } 5681 }
5783 private_gtkconv_new(PurpleConversation *conv, gboolean hidden) 5736 private_gtkconv_new(PurpleConversation *conv, gboolean hidden)
5784 { 5737 {
5785 PidginConversation *gtkconv; 5738 PidginConversation *gtkconv;
5786 const char *theme_name; 5739 const char *theme_name;
5787 PurpleTheme *theme = NULL; 5740 PurpleTheme *theme = NULL;
5788 PurpleConversationType conv_type = purple_conversation_get_type(conv); 5741 gboolean is_chat = PURPLE_IS_CHAT_CONVERSATION(conv);
5789 GtkWidget *pane = NULL; 5742 GtkWidget *pane = NULL;
5790 GtkWidget *tab_cont; 5743 GtkWidget *tab_cont;
5791 PurpleBlistNode *convnode; 5744 PurpleBlistNode *convnode;
5792 GtkTargetList *targets; 5745 GtkTargetList *targets;
5793 5746
5794 if (conv_type == PURPLE_CONV_TYPE_IM && (gtkconv = pidgin_conv_find_gtkconv(conv))) { 5747 if (!is_chat && (gtkconv = pidgin_conv_find_gtkconv(conv))) {
5795 purple_conversation_set_ui_data(conv, gtkconv); 5748 purple_conversation_set_ui_data(conv, gtkconv);
5796 if (!g_list_find(gtkconv->convs, conv)) 5749 if (!g_list_find(gtkconv->convs, conv))
5797 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); 5750 gtkconv->convs = g_list_prepend(gtkconv->convs, conv);
5798 pidgin_conv_switch_active_conversation(conv); 5751 pidgin_conv_switch_active_conversation(conv);
5799 return; 5752 return;
5815 theme = default_conv_theme; 5768 theme = default_conv_theme;
5816 gtkconv->theme = PIDGIN_CONV_THEME(g_object_ref(theme)); 5769 gtkconv->theme = PIDGIN_CONV_THEME(g_object_ref(theme));
5817 gtkconv->last_flags = 0; 5770 gtkconv->last_flags = 0;
5818 5771
5819 5772
5820 if (conv_type == PURPLE_CONV_TYPE_IM) { 5773 if (!is_chat) {
5821 gtkconv->u.im = g_malloc0(sizeof(PidginImPane)); 5774 gtkconv->u.im = g_malloc0(sizeof(PidginImPane));
5822 } else if (conv_type == PURPLE_CONV_TYPE_CHAT) { 5775 } else {
5823 gtkconv->u.chat = g_malloc0(sizeof(PidginChatPane)); 5776 gtkconv->u.chat = g_malloc0(sizeof(PidginChatPane));
5824 } 5777 }
5825 pane = setup_common_pane(gtkconv); 5778 pane = setup_common_pane(gtkconv);
5826 5779
5827 if (pane == NULL) { 5780 if (pane == NULL) {
5828 if (conv_type == PURPLE_CONV_TYPE_CHAT) 5781 if (is_chat)
5829 g_free(gtkconv->u.chat); 5782 g_free(gtkconv->u.chat);
5830 else if (conv_type == PURPLE_CONV_TYPE_IM) 5783 else
5831 g_free(gtkconv->u.im); 5784 g_free(gtkconv->u.im);
5832 5785
5833 g_free(gtkconv); 5786 g_free(gtkconv);
5834 purple_conversation_set_ui_data(conv, NULL); 5787 purple_conversation_set_ui_data(conv, NULL);
5835 return; 5788 return;
6006 purple_notify_close_with_handle(gtkconv); 5959 purple_notify_close_with_handle(gtkconv);
6007 5960
6008 gtk_widget_destroy(gtkconv->tab_cont); 5961 gtk_widget_destroy(gtkconv->tab_cont);
6009 g_object_unref(gtkconv->tab_cont); 5962 g_object_unref(gtkconv->tab_cont);
6010 5963
6011 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 5964 if (PURPLE_IS_IM_CONVERSATION(conv)) {
6012 if (gtkconv->u.im->icon_timer != 0) 5965 if (gtkconv->u.im->icon_timer != 0)
6013 g_source_remove(gtkconv->u.im->icon_timer); 5966 g_source_remove(gtkconv->u.im->icon_timer);
6014 5967
6015 if (gtkconv->u.im->anim != NULL) 5968 if (gtkconv->u.im->anim != NULL)
6016 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); 5969 g_object_unref(G_OBJECT(gtkconv->u.im->anim));
6017 5970
6018 if (gtkconv->u.im->typing_timer != 0) 5971 if (gtkconv->u.im->typing_timer != 0)
6019 g_source_remove(gtkconv->u.im->typing_timer); 5972 g_source_remove(gtkconv->u.im->typing_timer);
6020 5973
6021 g_free(gtkconv->u.im); 5974 g_free(gtkconv->u.im);
6022 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 5975 } else {
6023 purple_signals_disconnect_by_handle(gtkconv->u.chat); 5976 purple_signals_disconnect_by_handle(gtkconv->u.chat);
6024 g_free(gtkconv->u.chat); 5977 g_free(gtkconv->u.chat);
6025 } 5978 }
6026 5979
6027 gtkconv->send_history = g_list_first(gtkconv->send_history); 5980 gtkconv->send_history = g_list_first(gtkconv->send_history);
6041 g_free(gtkconv); 5994 g_free(gtkconv);
6042 } 5995 }
6043 5996
6044 5997
6045 static void 5998 static void
6046 pidgin_conv_write_im(PurpleConversation *conv, const char *who, 5999 pidgin_conv_write_im(PurpleIMConversation *im, const char *who,
6047 const char *message, PurpleMessageFlags flags, 6000 const char *message, PurpleMessageFlags flags,
6048 time_t mtime) 6001 time_t mtime)
6049 { 6002 {
6050 PidginConversation *gtkconv; 6003 PidginConversation *gtkconv;
6004 PurpleConversation *conv = PURPLE_CONVERSATION(im);
6051 6005
6052 gtkconv = PIDGIN_CONVERSATION(conv); 6006 gtkconv = PIDGIN_CONVERSATION(conv);
6053 6007
6054 if (conv != gtkconv->active_conv && 6008 if (conv != gtkconv->active_conv &&
6055 flags & PURPLE_MESSAGE_ACTIVE_ONLY) 6009 flags & PURPLE_MESSAGE_ACTIVE_ONLY)
6154 6108
6155 return FALSE; 6109 return FALSE;
6156 } 6110 }
6157 #endif 6111 #endif
6158 6112
6159 static GtkTextTag *get_buddy_tag(PurpleConversation *conv, const char *who, PurpleMessageFlags flag, 6113 static GtkTextTag *get_buddy_tag(PurpleChatConversation *chat, const char *who, PurpleMessageFlags flag,
6160 gboolean create) 6114 gboolean create)
6161 { 6115 {
6162 /* TODO WEBKIT */ 6116 /* TODO WEBKIT */
6163 #if 0 6117 #if 0
6164 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv); 6118 PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
6328 } 6282 }
6329 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) { 6283 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) {
6330 replace = freeval = g_build_filename("Outgoing", "buddy_icon.png", NULL); 6284 replace = freeval = g_build_filename("Outgoing", "buddy_icon.png", NULL);
6331 } 6285 }
6332 } else if (flags & PURPLE_MESSAGE_RECV) { 6286 } else if (flags & PURPLE_MESSAGE_RECV) {
6333 PurpleBuddyIcon *icon = purple_im_conversation_get_icon(PURPLE_CONV_IM(conv)); 6287 PurpleBuddyIcon *icon = purple_im_conversation_get_icon(PURPLE_IM_CONVERSATION(conv));
6334 if (icon) 6288 if (icon)
6335 replace = purple_buddy_icon_get_full_path(icon); 6289 replace = purple_buddy_icon_get_full_path(icon);
6336 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) { 6290 if (replace == NULL || !g_file_test(replace, G_FILE_TEST_EXISTS)) {
6337 replace = freeval = g_build_filename("Incoming", "buddy_icon.png", NULL); 6291 replace = freeval = g_build_filename("Incoming", "buddy_icon.png", NULL);
6338 } 6292 }
6411 char *str; 6365 char *str;
6412 char *with_font_tag; 6366 char *with_font_tag;
6413 char *sml_attrib = NULL; 6367 char *sml_attrib = NULL;
6414 size_t length; 6368 size_t length;
6415 #endif 6369 #endif
6416 PurpleConversationType type;
6417 char *displaying; 6370 char *displaying;
6418 gboolean plugin_return; 6371 gboolean plugin_return;
6419 #if 0 6372 #if 0
6420 gboolean is_rtl_message = FALSE; 6373 gboolean is_rtl_message = FALSE;
6421 #endif 6374 #endif
6458 /* TODO: consider not doing this if the account is offline or something */ 6411 /* TODO: consider not doing this if the account is offline or something */
6459 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)) 6412 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV))
6460 pidgin_conv_switch_active_conversation(conv); 6413 pidgin_conv_switch_active_conversation(conv);
6461 } 6414 }
6462 6415
6463 type = purple_conversation_get_type(conv);
6464 account = purple_conversation_get_account(conv); 6416 account = purple_conversation_get_account(conv);
6465 g_return_if_fail(account != NULL); 6417 g_return_if_fail(account != NULL);
6466 gc = purple_account_get_connection(account); 6418 gc = purple_account_get_connection(account);
6467 g_return_if_fail(gc != NULL || !(flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV))); 6419 g_return_if_fail(gc != NULL || !(flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV)));
6468 6420
6471 displaying = g_strdup(message); 6423 displaying = g_strdup(message);
6472 else 6424 else
6473 displaying = purple_markup_linkify(message); 6425 displaying = purple_markup_linkify(message);
6474 6426
6475 plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1( 6427 plugin_return = GPOINTER_TO_INT(purple_signal_emit_return_1(
6476 pidgin_conversations_get_handle(), (type == PURPLE_CONV_TYPE_IM ? 6428 pidgin_conversations_get_handle(), (PURPLE_IS_IM_CONVERSATION(conv) ?
6477 "displaying-im-msg" : "displaying-chat-msg"), 6429 "displaying-im-msg" : "displaying-chat-msg"),
6478 account, name, &displaying, conv, flags)); 6430 account, name, &displaying, conv, flags));
6479 if (plugin_return) 6431 if (plugin_return)
6480 { 6432 {
6481 g_free(displaying); 6433 g_free(displaying);
6756 #endif 6708 #endif
6757 6709
6758 6710
6759 /* on rejoin only request message history from after this message */ 6711 /* on rejoin only request message history from after this message */
6760 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV) && 6712 if (flags & (PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_RECV) &&
6761 purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 6713 PURPLE_IS_CHAT_CONVERSATION(conv)) {
6762 PurpleChat *chat = purple_blist_find_chat( 6714 PurpleChat *chat = purple_blist_find_chat(
6763 purple_conversation_get_account(conv), 6715 purple_conversation_get_account(conv),
6764 purple_conversation_get_name(conv)); 6716 purple_conversation_get_name(conv));
6765 if (chat) { 6717 if (chat) {
6766 GHashTable *comps = purple_chat_get_components(chat); 6718 GHashTable *comps = purple_chat_get_components(chat);
6795 g_strdup(history_since_s)); 6747 g_strdup(history_since_s));
6796 } 6748 }
6797 } 6749 }
6798 6750
6799 purple_signal_emit(pidgin_conversations_get_handle(), 6751 purple_signal_emit(pidgin_conversations_get_handle(),
6800 (type == PURPLE_CONV_TYPE_IM ? "displayed-im-msg" : "displayed-chat-msg"), 6752 (PURPLE_IS_IM_CONVERSATION(conv) ? "displayed-im-msg" : "displayed-chat-msg"),
6801 account, name, displaying, conv, flags); 6753 account, name, displaying, conv, flags);
6802 g_free(displaying); 6754 g_free(displaying);
6803 update_typing_message(gtkconv, NULL); 6755 update_typing_message(gtkconv, NULL);
6804 } 6756 }
6805 6757
6827 gtk_tree_path_free(path); 6779 gtk_tree_path_free(path);
6828 return TRUE; 6780 return TRUE;
6829 } 6781 }
6830 6782
6831 static void 6783 static void
6832 pidgin_conv_chat_add_users(PurpleConversation *conv, GList *cbuddies, gboolean new_arrivals) 6784 pidgin_conv_chat_add_users(PurpleChatConversation *chat, GList *cbuddies, gboolean new_arrivals)
6833 { 6785 {
6834 PurpleChatConversation *chat;
6835 PidginConversation *gtkconv; 6786 PidginConversation *gtkconv;
6836 PidginChatPane *gtkchat; 6787 PidginChatPane *gtkchat;
6837 GtkListStore *ls; 6788 GtkListStore *ls;
6838 GList *l; 6789 GList *l;
6839 6790
6840 char tmp[BUF_LONG]; 6791 char tmp[BUF_LONG];
6841 int num_users; 6792 int num_users;
6842 6793
6843 chat = PURPLE_CONV_CHAT(conv); 6794 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(chat));
6844 gtkconv = PIDGIN_CONVERSATION(conv);
6845 gtkchat = gtkconv->u.chat; 6795 gtkchat = gtkconv->u.chat;
6846 6796
6847 num_users = g_list_length(purple_chat_conversation_get_users(chat)); 6797 num_users = g_list_length(purple_chat_conversation_get_users(chat));
6848 6798
6849 g_snprintf(tmp, sizeof(tmp), 6799 g_snprintf(tmp, sizeof(tmp),
6858 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, 6808 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
6859 GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID); 6809 GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID);
6860 6810
6861 l = cbuddies; 6811 l = cbuddies;
6862 while (l != NULL) { 6812 while (l != NULL) {
6863 add_chat_buddy_common(conv, (PurpleChatConversationBuddy *)l->data, NULL); 6813 add_chat_buddy_common(chat, (PurpleChatConversationBuddy *)l->data, NULL);
6864 l = l->next; 6814 l = l->next;
6865 } 6815 }
6866 6816
6867 /* Currently GTK+ maintains our sorted list after it's in the tree. 6817 /* Currently GTK+ maintains our sorted list after it's in the tree.
6868 * This may change if it turns out we can manage it faster ourselves. 6818 * This may change if it turns out we can manage it faster ourselves.
6870 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN, 6820 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_KEY_COLUMN,
6871 GTK_SORT_ASCENDING); 6821 GTK_SORT_ASCENDING);
6872 } 6822 }
6873 6823
6874 static void 6824 static void
6875 pidgin_conv_chat_rename_user(PurpleConversation *conv, const char *old_name, 6825 pidgin_conv_chat_rename_user(PurpleChatConversation *chat, const char *old_name,
6876 const char *new_name, const char *new_alias) 6826 const char *new_name, const char *new_alias)
6877 { 6827 {
6878 PurpleChatConversation *chat;
6879 PidginConversation *gtkconv; 6828 PidginConversation *gtkconv;
6880 PidginChatPane *gtkchat; 6829 PidginChatPane *gtkchat;
6881 PurpleChatConversationBuddy *old_cbuddy, *new_cbuddy; 6830 PurpleChatConversationBuddy *old_cbuddy, *new_cbuddy;
6882 GtkTreeIter iter; 6831 GtkTreeIter iter;
6883 GtkTreeModel *model; 6832 GtkTreeModel *model;
6884 GtkTextTag *tag; 6833 GtkTextTag *tag;
6885 6834
6886 chat = PURPLE_CONV_CHAT(conv); 6835 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(chat));
6887 gtkconv = PIDGIN_CONVERSATION(conv);
6888 gtkchat = gtkconv->u.chat; 6836 gtkchat = gtkconv->u.chat;
6889 6837
6890 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); 6838 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list));
6891 6839
6892 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) 6840 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
6893 return; 6841 return;
6894 6842
6895 if ((tag = get_buddy_tag(conv, old_name, 0, FALSE))) 6843 if ((tag = get_buddy_tag(chat, old_name, 0, FALSE)))
6896 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); 6844 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
6897 if ((tag = get_buddy_tag(conv, old_name, PURPLE_MESSAGE_NICK, FALSE))) 6845 if ((tag = get_buddy_tag(chat, old_name, PURPLE_MESSAGE_NICK, FALSE)))
6898 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); 6846 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
6899 6847
6900 old_cbuddy = purple_chat_conversation_find_buddy(chat, old_name); 6848 old_cbuddy = purple_chat_conversation_find_buddy(chat, old_name);
6901 if (!old_cbuddy) 6849 if (!old_cbuddy)
6902 return; 6850 return;
6911 6859
6912 g_return_if_fail(new_alias != NULL); 6860 g_return_if_fail(new_alias != NULL);
6913 6861
6914 new_cbuddy = purple_chat_conversation_find_buddy(chat, new_name); 6862 new_cbuddy = purple_chat_conversation_find_buddy(chat, new_name);
6915 6863
6916 add_chat_buddy_common(conv, new_cbuddy, old_name); 6864 add_chat_buddy_common(chat, new_cbuddy, old_name);
6917 } 6865 }
6918 6866
6919 static void 6867 static void
6920 pidgin_conv_chat_remove_users(PurpleConversation *conv, GList *users) 6868 pidgin_conv_chat_remove_users(PurpleChatConversation *chat, GList *users)
6921 { 6869 {
6922 PurpleChatConversation *chat;
6923 PidginConversation *gtkconv; 6870 PidginConversation *gtkconv;
6924 PidginChatPane *gtkchat; 6871 PidginChatPane *gtkchat;
6925 GtkTreeIter iter; 6872 GtkTreeIter iter;
6926 GtkTreeModel *model; 6873 GtkTreeModel *model;
6927 GList *l; 6874 GList *l;
6928 char tmp[BUF_LONG]; 6875 char tmp[BUF_LONG];
6929 int num_users; 6876 int num_users;
6930 gboolean f; 6877 gboolean f;
6931 GtkTextTag *tag; 6878 GtkTextTag *tag;
6932 6879
6933 chat = PURPLE_CONV_CHAT(conv); 6880 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(chat));
6934 gtkconv = PIDGIN_CONVERSATION(conv);
6935 gtkchat = gtkconv->u.chat; 6881 gtkchat = gtkconv->u.chat;
6936 6882
6937 num_users = g_list_length(purple_chat_conversation_get_users(chat)); 6883 num_users = g_list_length(purple_chat_conversation_get_users(chat));
6938 6884
6939 for (l = users; l != NULL; l = l->next) { 6885 for (l = users; l != NULL; l = l->next) {
6956 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); 6902 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
6957 6903
6958 g_free(val); 6904 g_free(val);
6959 } while (f); 6905 } while (f);
6960 6906
6961 if ((tag = get_buddy_tag(conv, l->data, 0, FALSE))) 6907 if ((tag = get_buddy_tag(chat, l->data, 0, FALSE)))
6962 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); 6908 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
6963 if ((tag = get_buddy_tag(conv, l->data, PURPLE_MESSAGE_NICK, FALSE))) 6909 if ((tag = get_buddy_tag(chat, l->data, PURPLE_MESSAGE_NICK, FALSE)))
6964 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL); 6910 g_object_set(G_OBJECT(tag), "style", PANGO_STYLE_ITALIC, NULL);
6965 } 6911 }
6966 6912
6967 g_snprintf(tmp, sizeof(tmp), 6913 g_snprintf(tmp, sizeof(tmp),
6968 ngettext("%d person in room", "%d people in room", 6914 ngettext("%d person in room", "%d people in room",
6970 6916
6971 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); 6917 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp);
6972 } 6918 }
6973 6919
6974 static void 6920 static void
6975 pidgin_conv_chat_update_user(PurpleConversation *conv, const char *user) 6921 pidgin_conv_chat_update_user(PurpleChatConversationBuddy *cbuddy)
6976 { 6922 {
6977 PurpleChatConversation *chat; 6923 PurpleChatConversation *chat;
6978 PurpleChatConversationBuddy *cbuddy;
6979 PidginConversation *gtkconv; 6924 PidginConversation *gtkconv;
6980 PidginChatPane *gtkchat; 6925 PidginChatPane *gtkchat;
6981 GtkTreeIter iter; 6926 GtkTreeIter iter;
6982 GtkTreeModel *model; 6927 GtkTreeModel *model;
6983 6928
6984 chat = PURPLE_CONV_CHAT(conv); 6929 if (!cbuddy)
6985 gtkconv = PIDGIN_CONVERSATION(conv); 6930 return;
6931
6932 chat = purple_chat_conversation_buddy_get_chat(cbuddy);
6933 gtkconv = PIDGIN_CONVERSATION(PURPLE_CONVERSATION(chat));
6986 gtkchat = gtkconv->u.chat; 6934 gtkchat = gtkconv->u.chat;
6987 6935
6988 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); 6936 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list));
6989 6937
6990 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) 6938 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter))
6991 return;
6992
6993 cbuddy = purple_chat_conversation_find_buddy(chat, user);
6994 if (!cbuddy)
6995 return; 6939 return;
6996 6940
6997 if (get_iter_from_chatbuddy(cbuddy, &iter)) { 6941 if (get_iter_from_chatbuddy(cbuddy, &iter)) {
6998 GtkTreeRowReference *ref = purple_chat_conversation_buddy_get_ui_data(cbuddy); 6942 GtkTreeRowReference *ref = purple_chat_conversation_buddy_get_ui_data(cbuddy);
6999 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); 6943 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
7000 gtk_tree_row_reference_free(ref); 6944 gtk_tree_row_reference_free(ref);
7001 purple_chat_conversation_buddy_set_ui_data(cbuddy, NULL); 6945 purple_chat_conversation_buddy_set_ui_data(cbuddy, NULL);
7002 } 6946 }
7003 6947
7004 if (cbuddy) 6948 if (cbuddy)
7005 add_chat_buddy_common(conv, cbuddy, NULL); 6949 add_chat_buddy_common(chat, cbuddy, NULL);
7006 } 6950 }
7007 6951
7008 gboolean 6952 gboolean
7009 pidgin_conv_has_focus(PurpleConversation *conv) 6953 pidgin_conv_has_focus(PurpleConversation *conv)
7010 { 6954 {
7210 * conversations. Stuff that Purple chats support in general should be 7154 * conversations. Stuff that Purple chats support in general should be
7211 * shown for chat conversations. It doesn't matter whether the PRPL 7155 * shown for chat conversations. It doesn't matter whether the PRPL
7212 * supports it or not--that only affects if the button or menu item 7156 * supports it or not--that only affects if the button or menu item
7213 * is sensitive or not. 7157 * is sensitive or not.
7214 */ 7158 */
7215 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 7159 if (PURPLE_IS_IM_CONVERSATION(conv)) {
7216 /* Show stuff that applies to IMs, hide stuff that applies to chats */ 7160 /* Show stuff that applies to IMs, hide stuff that applies to chats */
7217 7161
7218 /* Deal with menu items */ 7162 /* Deal with menu items */
7219 gtk_action_set_visible(win->menu.view_log, TRUE); 7163 gtk_action_set_visible(win->menu.view_log, TRUE);
7220 gtk_action_set_visible(win->menu.send_file, TRUE); 7164 gtk_action_set_visible(win->menu.send_file, TRUE);
7239 gtk_action_set_visible(win->menu.add, FALSE); 7183 gtk_action_set_visible(win->menu.add, FALSE);
7240 } 7184 }
7241 7185
7242 gtk_action_set_visible(win->menu.insert_link, TRUE); 7186 gtk_action_set_visible(win->menu.insert_link, TRUE);
7243 gtk_action_set_visible(win->menu.insert_image, TRUE); 7187 gtk_action_set_visible(win->menu.insert_image, TRUE);
7244 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 7188 } else {
7245 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ 7189 /* Show stuff that applies to Chats, hide stuff that applies to IMs */
7246 7190
7247 /* Deal with menu items */ 7191 /* Deal with menu items */
7248 gtk_action_set_visible(win->menu.view_log, TRUE); 7192 gtk_action_set_visible(win->menu.view_log, TRUE);
7249 gtk_action_set_visible(win->menu.send_file, FALSE); 7193 gtk_action_set_visible(win->menu.send_file, FALSE);
7272 /* 7216 /*
7273 * Handle graying stuff out based on whether an account is connected 7217 * Handle graying stuff out based on whether an account is connected
7274 * and what features that account supports. 7218 * and what features that account supports.
7275 */ 7219 */
7276 if ((gc != NULL) && 7220 if ((gc != NULL) &&
7277 ((purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_CHAT) || 7221 (PURPLE_IS_IM_CONVERSATION(conv) ||
7278 !purple_chat_conversation_has_left(PURPLE_CONV_CHAT(conv)) )) 7222 !purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) ))
7279 { 7223 {
7280 PurpleConnectionFlags features = purple_conversation_get_features(conv); 7224 PurpleConnectionFlags features = purple_conversation_get_features(conv);
7281 /* Account is online */ 7225 /* Account is online */
7282 /* Deal with the toolbar */ 7226 /* Deal with the toolbar */
7283 if (features & PURPLE_CONNECTION_HTML) 7227 if (features & PURPLE_CONNECTION_HTML)
7320 gtk_action_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); 7264 gtk_action_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL));
7321 gtk_action_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); 7265 gtk_action_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL));
7322 gtk_action_set_sensitive(win->menu.insert_link, (features & PURPLE_CONNECTION_HTML)); 7266 gtk_action_set_sensitive(win->menu.insert_link, (features & PURPLE_CONNECTION_HTML));
7323 gtk_action_set_sensitive(win->menu.insert_image, !(features & PURPLE_CONNECTION_NO_IMAGES)); 7267 gtk_action_set_sensitive(win->menu.insert_image, !(features & PURPLE_CONNECTION_NO_IMAGES));
7324 7268
7325 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 7269 if (PURPLE_IS_IM_CONVERSATION(conv))
7326 { 7270 {
7327 gtk_action_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); 7271 gtk_action_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL));
7328 gtk_action_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); 7272 gtk_action_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL));
7329 gtk_action_set_sensitive(win->menu.send_file, 7273 gtk_action_set_sensitive(win->menu.send_file,
7330 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || 7274 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file ||
7332 gtk_action_set_sensitive(win->menu.get_attention, (prpl_info->send_attention != NULL)); 7276 gtk_action_set_sensitive(win->menu.get_attention, (prpl_info->send_attention != NULL));
7333 gtk_action_set_sensitive(win->menu.alias, 7277 gtk_action_set_sensitive(win->menu.alias,
7334 (account != NULL) && 7278 (account != NULL) &&
7335 (purple_find_buddy(account, purple_conversation_get_name(conv)) != NULL)); 7279 (purple_find_buddy(account, purple_conversation_get_name(conv)) != NULL));
7336 } 7280 }
7337 else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) 7281 else
7338 { 7282 {
7339 gtk_action_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); 7283 gtk_action_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL));
7340 gtk_action_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); 7284 gtk_action_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL));
7341 gtk_action_set_sensitive(win->menu.alias, 7285 gtk_action_set_sensitive(win->menu.alias,
7342 (account != NULL) && 7286 (account != NULL) &&
7365 * Update the window's icon 7309 * Update the window's icon
7366 */ 7310 */
7367 if (pidgin_conv_window_is_active_conversation(conv)) 7311 if (pidgin_conv_window_is_active_conversation(conv))
7368 { 7312 {
7369 GList *l = NULL; 7313 GList *l = NULL;
7370 if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) && 7314 if (PURPLE_IS_IM_CONVERSATION(conv) &&
7371 (gtkconv->u.im->anim)) 7315 (gtkconv->u.im->anim))
7372 { 7316 {
7373 PurpleBuddy *buddy = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); 7317 PurpleBuddy *buddy = purple_find_buddy(purple_conversation_get_account(conv), purple_conversation_get_name(conv));
7374 window_icon = 7318 window_icon =
7375 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); 7319 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim);
7408 purple_conversation_autoset_title(conv); 7352 purple_conversation_autoset_title(conv);
7409 } 7353 }
7410 7354
7411 if (fields & PIDGIN_CONV_BUDDY_ICON) 7355 if (fields & PIDGIN_CONV_BUDDY_ICON)
7412 { 7356 {
7413 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 7357 if (PURPLE_IS_IM_CONVERSATION(conv))
7414 pidgin_conv_update_buddy_icon(conv); 7358 pidgin_conv_update_buddy_icon(PURPLE_IM_CONVERSATION(conv));
7415 } 7359 }
7416 7360
7417 if (fields & PIDGIN_CONV_MENU) 7361 if (fields & PIDGIN_CONV_MENU)
7418 { 7362 {
7419 gray_stuff_out(PIDGIN_CONVERSATION(conv)); 7363 gray_stuff_out(PIDGIN_CONVERSATION(conv));
7426 update_tab_icon(conv); 7370 update_tab_icon(conv);
7427 generate_send_to_items(win); /* To update the icons in SendTo menu */ 7371 generate_send_to_items(win); /* To update the icons in SendTo menu */
7428 } 7372 }
7429 7373
7430 if ((fields & PIDGIN_CONV_TOPIC) && 7374 if ((fields & PIDGIN_CONV_TOPIC) &&
7431 purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) 7375 PURPLE_IS_CHAT_CONVERSATION(conv))
7432 { 7376 {
7433 const char *topic; 7377 const char *topic;
7434 PurpleChatConversation *chat = PURPLE_CONV_CHAT(conv);
7435 PidginChatPane *gtkchat = gtkconv->u.chat; 7378 PidginChatPane *gtkchat = gtkconv->u.chat;
7436 7379
7437 if (gtkchat->topic_text != NULL) 7380 if (gtkchat->topic_text != NULL)
7438 { 7381 {
7439 topic = purple_chat_conversation_get_topic(chat); 7382 topic = purple_chat_conversation_get_topic(PURPLE_CHAT_CONVERSATION(conv));
7440 7383
7441 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); 7384 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : "");
7442 gtk_widget_set_tooltip_text(gtkchat->topic_text, 7385 gtk_widget_set_tooltip_text(gtkchat->topic_text,
7443 topic ? topic : ""); 7386 topic ? topic : "");
7444 } 7387 }
7460 char *markup = NULL; 7403 char *markup = NULL;
7461 AtkObject *accessibility_obj; 7404 AtkObject *accessibility_obj;
7462 /* I think this is a little longer than it needs to be but I'm lazy. */ 7405 /* I think this is a little longer than it needs to be but I'm lazy. */
7463 char *style; 7406 char *style;
7464 7407
7465 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) 7408 if (PURPLE_IS_IM_CONVERSATION(conv))
7466 im = PURPLE_CONV_IM(conv); 7409 im = PURPLE_IM_CONVERSATION(conv);
7467 7410
7468 if ((account == NULL) || 7411 if ((account == NULL) ||
7469 !purple_account_is_connected(account) || 7412 !purple_account_is_connected(account) ||
7470 ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) 7413 (PURPLE_IS_CHAT_CONVERSATION(conv)
7471 && purple_chat_conversation_has_left(PURPLE_CONV_CHAT(conv)))) 7414 && purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv))))
7472 title = g_strdup_printf("(%s)", purple_conversation_get_title(conv)); 7415 title = g_strdup_printf("(%s)", purple_conversation_get_title(conv));
7473 else 7416 else
7474 title = g_strdup(purple_conversation_get_title(conv)); 7417 title = g_strdup(purple_conversation_get_title(conv));
7475 7418
7476 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 7419 if (PURPLE_IS_IM_CONVERSATION(conv)) {
7477 buddy = purple_find_buddy(account, purple_conversation_get_name(conv)); 7420 buddy = purple_find_buddy(account, purple_conversation_get_name(conv));
7478 if (buddy) { 7421 if (buddy) {
7479 markup = pidgin_blist_get_name_markup(buddy, FALSE, FALSE); 7422 markup = pidgin_blist_get_name_markup(buddy, FALSE, FALSE);
7480 } else { 7423 } else {
7481 markup = title; 7424 markup = title;
7482 } 7425 }
7483 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 7426 } else if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
7484 const char *topic = gtkconv->u.chat->topic_text 7427 const char *topic = gtkconv->u.chat->topic_text
7485 ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text)) 7428 ? gtk_entry_get_text(GTK_ENTRY(gtkconv->u.chat->topic_text))
7486 : NULL; 7429 : NULL;
7487 const char *title = purple_conversation_get_title(conv); 7430 const char *title = purple_conversation_get_title(conv);
7488 const char *name = purple_conversation_get_name(conv); 7431 const char *name = purple_conversation_get_name(conv);
7530 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_NICK) { 7473 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_NICK) {
7531 atk_object_set_description(accessibility_obj, _("Nick Said")); 7474 atk_object_set_description(accessibility_obj, _("Nick Said"));
7532 style = "tab-label-attention"; 7475 style = "tab-label-attention";
7533 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT) { 7476 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT) {
7534 atk_object_set_description(accessibility_obj, _("Unread Messages")); 7477 atk_object_set_description(accessibility_obj, _("Unread Messages"));
7535 if (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_CHAT) 7478 if (PURPLE_IS_CHAT_CONVERSATION(gtkconv->active_conv))
7536 style = "tab-label-unreadchat"; 7479 style = "tab-label-unreadchat";
7537 else 7480 else
7538 style = "tab-label-attention"; 7481 style = "tab-label-attention";
7539 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { 7482 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) {
7540 atk_object_set_description(accessibility_obj, _("New Event")); 7483 atk_object_set_description(accessibility_obj, _("New Event"));
7593 } 7536 }
7594 else if (type == PURPLE_CONVERSATION_UPDATE_TOPIC) 7537 else if (type == PURPLE_CONVERSATION_UPDATE_TOPIC)
7595 { 7538 {
7596 flags = PIDGIN_CONV_TOPIC; 7539 flags = PIDGIN_CONV_TOPIC;
7597 } 7540 }
7598 else if (type == PURPLE_CONV_ACCOUNT_ONLINE || 7541 else if (type == PURPLE_CONVERSATION_ACCOUNT_ONLINE ||
7599 type == PURPLE_CONV_ACCOUNT_OFFLINE) 7542 type == PURPLE_CONVERSATION_ACCOUNT_OFFLINE)
7600 { 7543 {
7601 flags = PIDGIN_CONV_MENU | PIDGIN_CONV_TAB_ICON | PIDGIN_CONV_SET_TITLE; 7544 flags = PIDGIN_CONV_MENU | PIDGIN_CONV_TAB_ICON | PIDGIN_CONV_SET_TITLE;
7602 } 7545 }
7603 else if (type == PURPLE_CONVERSATION_UPDATE_AWAY) 7546 else if (type == PURPLE_CONVERSATION_UPDATE_AWAY)
7604 { 7547 {
7677 7620
7678 /************************************************************************** 7621 /**************************************************************************
7679 * Public conversation utility functions 7622 * Public conversation utility functions
7680 **************************************************************************/ 7623 **************************************************************************/
7681 void 7624 void
7682 pidgin_conv_update_buddy_icon(PurpleConversation *conv) 7625 pidgin_conv_update_buddy_icon(PurpleIMConversation *im)
7683 { 7626 {
7684 PidginConversation *gtkconv; 7627 PidginConversation *gtkconv;
7628 PurpleConversation *conv;
7685 PidginWindow *win; 7629 PidginWindow *win;
7686 7630
7687 PurpleBuddy *buddy; 7631 PurpleBuddy *buddy;
7688 7632
7689 PurpleStoredImage *custom_img = NULL; 7633 PurpleStoredImage *custom_img = NULL;
7700 7644
7701 PurpleAccount *account; 7645 PurpleAccount *account;
7702 7646
7703 PurpleBuddyIcon *icon; 7647 PurpleBuddyIcon *icon;
7704 7648
7649 conv = PURPLE_CONVERSATION(im);
7650
7705 g_return_if_fail(conv != NULL); 7651 g_return_if_fail(conv != NULL);
7706 g_return_if_fail(PIDGIN_IS_PIDGIN_CONVERSATION(conv)); 7652 g_return_if_fail(PIDGIN_IS_PIDGIN_CONVERSATION(conv));
7707 g_return_if_fail(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM);
7708 7653
7709 gtkconv = PIDGIN_CONVERSATION(conv); 7654 gtkconv = PIDGIN_CONVERSATION(conv);
7710 win = gtkconv->win; 7655 win = gtkconv->win;
7711 if (conv != gtkconv->active_conv) 7656 if (conv != gtkconv->active_conv)
7712 return; 7657 return;
7760 } 7705 }
7761 } 7706 }
7762 } 7707 }
7763 7708
7764 if (data == NULL) { 7709 if (data == NULL) {
7765 icon = purple_im_conversation_get_icon(PURPLE_CONV_IM(conv)); 7710 icon = purple_im_conversation_get_icon(im);
7766 if (icon == NULL) 7711 if (icon == NULL)
7767 { 7712 {
7768 gtk_widget_set_size_request(gtkconv->u.im->icon_container, 7713 gtk_widget_set_size_request(gtkconv->u.im->icon_container,
7769 -1, BUDDYICON_SIZE_MIN); 7714 -1, BUDDYICON_SIZE_MIN);
7770 return; 7715 return;
8066 8011
8067 /* Now either stop or start animation for the active conversation in each window */ 8012 /* Now either stop or start animation for the active conversation in each window */
8068 for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) { 8013 for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) {
8069 win = l->data; 8014 win = l->data;
8070 conv = pidgin_conv_window_get_active_conversation(win); 8015 conv = pidgin_conv_window_get_active_conversation(win);
8071 pidgin_conv_update_buddy_icon(conv); 8016 pidgin_conv_update_buddy_icon(PURPLE_IM_CONVERSATION(conv));
8072 } 8017 }
8073 } 8018 }
8074 8019
8075 static void 8020 static void
8076 show_buddy_icons_pref_cb(const char *name, PurplePrefType type, 8021 show_buddy_icons_pref_cb(const char *name, PurplePrefType type,
8085 if (GPOINTER_TO_INT(value)) 8030 if (GPOINTER_TO_INT(value))
8086 gtk_widget_show(PIDGIN_CONVERSATION(conv)->infopane_hbox); 8031 gtk_widget_show(PIDGIN_CONVERSATION(conv)->infopane_hbox);
8087 else 8032 else
8088 gtk_widget_hide(PIDGIN_CONVERSATION(conv)->infopane_hbox); 8033 gtk_widget_hide(PIDGIN_CONVERSATION(conv)->infopane_hbox);
8089 8034
8090 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 8035 if (PURPLE_IS_IM_CONVERSATION(conv)) {
8091 pidgin_conv_update_buddy_icon(conv); 8036 pidgin_conv_update_buddy_icon(PURPLE_IM_CONVERSATION(conv));
8092 } 8037 }
8093 } 8038 }
8094 8039
8095 /* Make the tabs show/hide correctly */ 8040 /* Make the tabs show/hide correctly */
8096 for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) { 8041 for (l = pidgin_conv_windows_get_list(); l != NULL; l = l->next) {
8137 for (l = hidden_convwin->gtkconvs; l; ) { 8082 for (l = hidden_convwin->gtkconvs; l; ) {
8138 gtkconv = l->data; 8083 gtkconv = l->data;
8139 l = l->next; 8084 l = l->next;
8140 8085
8141 conv = gtkconv->active_conv; 8086 conv = gtkconv->active_conv;
8142 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT || 8087 if (PURPLE_IS_CHAT_CONVERSATION(conv) ||
8143 account != purple_conversation_get_account(conv)) 8088 account != purple_conversation_get_account(conv))
8144 continue; 8089 continue;
8145 8090
8146 pidgin_conv_attach_to_conversation(conv); 8091 pidgin_conv_attach_to_conversation(conv);
8147 8092
8174 gtkconv = l->data; 8119 gtkconv = l->data;
8175 l = l->next; 8120 l = l->next;
8176 8121
8177 conv = gtkconv->active_conv; 8122 conv = gtkconv->active_conv;
8178 8123
8179 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT || 8124 if (PURPLE_IS_CHAT_CONVERSATION(conv) ||
8180 gtkconv->unseen_count == 0 || 8125 gtkconv->unseen_count == 0 ||
8181 (when_away && !purple_status_is_available( 8126 (when_away && !purple_status_is_available(
8182 purple_account_get_active_status( 8127 purple_account_get_active_status(
8183 purple_conversation_get_account(conv))))) 8128 purple_conversation_get_account(conv)))))
8184 continue; 8129 continue;
8213 node = ((PurpleBlistNode*)contact)->child; 8158 node = ((PurpleBlistNode*)contact)->child;
8214 8159
8215 for (; node; node = node->next) 8160 for (; node; node = node->next)
8216 { 8161 {
8217 PurpleBuddy *buddy = (PurpleBuddy*)node; 8162 PurpleBuddy *buddy = (PurpleBuddy*)node;
8218 PurpleConversation *conv; 8163 PurpleIMConversation *im;
8219 conv = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); 8164 im = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy));
8220 if (conv) 8165 if (im)
8221 return PIDGIN_CONVERSATION(conv); 8166 return PIDGIN_CONVERSATION(PURPLE_CONVERSATION(im));
8222 } 8167 }
8223 return NULL; 8168 return NULL;
8224 } 8169 }
8225 8170
8226 static void 8171 static void
8239 /* if (purple_conversation_get_account(conv) == account) */ 8184 /* if (purple_conversation_get_account(conv) == account) */
8240 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON | 8185 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON |
8241 PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE); 8186 PIDGIN_CONV_MENU | PIDGIN_CONV_COLORIZE_TITLE);
8242 8187
8243 if (PURPLE_CONNECTION_IS_CONNECTED(gc) && 8188 if (PURPLE_CONNECTION_IS_CONNECTED(gc) &&
8244 purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT && 8189 PURPLE_IS_CHAT_CONVERSATION(conv) &&
8245 purple_conversation_get_account(conv) == purple_connection_get_account(gc) && 8190 purple_conversation_get_account(conv) == purple_connection_get_account(gc) &&
8246 purple_conversation_get_data(conv, "want-to-rejoin")) { 8191 purple_conversation_get_data(conv, "want-to-rejoin")) {
8247 GHashTable *comps = NULL; 8192 GHashTable *comps = NULL;
8248 PurpleChat *chat = purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv)); 8193 PurpleChat *chat = purple_blist_find_chat(purple_conversation_get_account(conv), purple_conversation_get_name(conv));
8249 if (chat == NULL) { 8194 if (chat == NULL) {
8269 8214
8270 /* We are about to sign off. See which chats we are currently in, and mark 8215 /* We are about to sign off. See which chats we are currently in, and mark
8271 * them for rejoin on reconnect. */ 8216 * them for rejoin on reconnect. */
8272 while (list) { 8217 while (list) {
8273 PurpleConversation *conv = list->data; 8218 PurpleConversation *conv = list->data;
8274 if (!purple_chat_conversation_has_left(PURPLE_CONV_CHAT(conv)) && 8219 if (!purple_chat_conversation_has_left(PURPLE_CHAT_CONVERSATION(conv)) &&
8275 purple_conversation_get_account(conv) == account) { 8220 purple_conversation_get_account(conv) == account) {
8276 purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE)); 8221 purple_conversation_set_data(conv, "want-to-rejoin", GINT_TO_POINTER(TRUE));
8277 purple_conversation_write(conv, NULL, _("The account has disconnected and you are no " 8222 purple_conversation_write(conv, NULL, _("The account has disconnected and you are no "
8278 "longer in this chat. You will automatically rejoin the chat when " 8223 "longer in this chat. You will automatically rejoin the chat when "
8279 "the account reconnects."), 8224 "the account reconnects."),
8315 } 8260 }
8316 8261
8317 static void 8262 static void
8318 update_buddy_idle_changed(PurpleBuddy *buddy, gboolean old, gboolean newidle) 8263 update_buddy_idle_changed(PurpleBuddy *buddy, gboolean old, gboolean newidle)
8319 { 8264 {
8320 PurpleConversation *conv; 8265 PurpleIMConversation *im;
8321 8266
8322 conv = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); 8267 im = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy));
8323 if (conv) 8268 if (im)
8324 pidgin_conv_update_fields(conv, PIDGIN_CONV_TAB_ICON); 8269 pidgin_conv_update_fields(PURPLE_CONVERSATION(im), PIDGIN_CONV_TAB_ICON);
8325 } 8270 }
8326 8271
8327 static void 8272 static void
8328 update_buddy_icon(PurpleBuddy *buddy) 8273 update_buddy_icon(PurpleBuddy *buddy)
8329 { 8274 {
8330 PurpleConversation *conv; 8275 PurpleIMConversation *im;
8331 8276
8332 conv = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy)); 8277 im = purple_conversations_find_im_with_account(purple_buddy_get_name(buddy), purple_buddy_get_account(buddy));
8333 if (conv) 8278 if (im)
8334 pidgin_conv_update_fields(conv, PIDGIN_CONV_BUDDY_ICON); 8279 pidgin_conv_update_fields(PURPLE_CONVERSATION(im), PIDGIN_CONV_BUDDY_ICON);
8335 } 8280 }
8336 8281
8337 static void 8282 static void
8338 update_buddy_sign(PurpleBuddy *buddy, const char *which) 8283 update_buddy_sign(PurpleBuddy *buddy, const char *which)
8339 { 8284 {
8363 update_buddy_typing(PurpleAccount *account, const char *who) 8308 update_buddy_typing(PurpleAccount *account, const char *who)
8364 { 8309 {
8365 PurpleConversation *conv; 8310 PurpleConversation *conv;
8366 PidginConversation *gtkconv; 8311 PidginConversation *gtkconv;
8367 8312
8368 conv = purple_conversations_find_im_with_account(who, account); 8313 conv = PURPLE_CONVERSATION(purple_conversations_find_im_with_account(who, account));
8369 if (!conv) 8314 if (!conv)
8370 return; 8315 return;
8371 8316
8372 gtkconv = PIDGIN_CONVERSATION(conv); 8317 gtkconv = PIDGIN_CONVERSATION(conv);
8373 if (gtkconv && gtkconv->active_conv == conv) 8318 if (gtkconv && gtkconv->active_conv == conv)
8374 pidgin_conv_update_fields(conv, PIDGIN_CONV_COLORIZE_TITLE); 8319 pidgin_conv_update_fields(conv, PIDGIN_CONV_COLORIZE_TITLE);
8375 } 8320 }
8376 8321
8377 static void 8322 static void
8378 update_chat(PurpleConversation *conv) 8323 update_chat(PurpleChatConversation *chat)
8379 { 8324 {
8380 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC | 8325 pidgin_conv_update_fields(PURPLE_CONVERSATION(chat), PIDGIN_CONV_TOPIC |
8381 PIDGIN_CONV_MENU | PIDGIN_CONV_SET_TITLE); 8326 PIDGIN_CONV_MENU | PIDGIN_CONV_SET_TITLE);
8382 } 8327 }
8383 8328
8384 static void 8329 static void
8385 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) 8330 update_chat_topic(PurpleChatConversation *chat, const char *old, const char *new)
8386 { 8331 {
8387 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); 8332 pidgin_conv_update_fields(PURPLE_CONVERSATION(chat), PIDGIN_CONV_TOPIC);
8388 } 8333 }
8389 8334
8390 /* Message history stuff */ 8335 /* Message history stuff */
8391 8336
8392 /* Compare two PurpleConversationMessage's, according to time in ascending order. */ 8337 /* Compare two PurpleConversationMessage's, according to time in ascending order. */
8404 PidginConversation *gtkconv = data; 8349 PidginConversation *gtkconv = data;
8405 GtkWebView *webview = GTK_WEBVIEW(gtkconv->webview); 8350 GtkWebView *webview = GTK_WEBVIEW(gtkconv->webview);
8406 int count = 0; 8351 int count = 0;
8407 int timer = gtkconv->attach.timer; 8352 int timer = gtkconv->attach.timer;
8408 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); 8353 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time"));
8409 gboolean im = (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_IM); 8354 gboolean im = (PURPLE_IS_IM_CONVERSATION(gtkconv->active_conv));
8410 8355
8411 gtkconv->attach.timer = 0; 8356 gtkconv->attach.timer = 0;
8412 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ 8357 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */
8413 PurpleConversationMessage *msg = gtkconv->attach.current->data; 8358 PurpleConversationMessage *msg = gtkconv->attach.current->data;
8414 if (!im && when && when < purple_conversation_message_get_timestamp(msg)) { 8359 if (!im && when && when < purple_conversation_message_get_timestamp(msg)) {
8512 pidgin_conv_attach(conv); 8457 pidgin_conv_attach(conv);
8513 gtkconv = PIDGIN_CONVERSATION(conv); 8458 gtkconv = PIDGIN_CONVERSATION(conv);
8514 8459
8515 list = purple_conversation_get_message_history(conv); 8460 list = purple_conversation_get_message_history(conv);
8516 if (list) { 8461 if (list) {
8517 switch (purple_conversation_get_type(conv)) { 8462 if (PURPLE_IS_IM_CONVERSATION(conv)) {
8518 case PURPLE_CONV_TYPE_IM: 8463 GList *convs;
8519 { 8464 list = g_list_copy(list);
8520 GList *convs; 8465 for (convs = purple_conversations_get_ims(); convs; convs = convs->next)
8521 list = g_list_copy(list); 8466 if (convs->data != conv &&
8522 for (convs = purple_conversations_get_ims(); convs; convs = convs->next) 8467 pidgin_conv_find_gtkconv(convs->data) == gtkconv) {
8523 if (convs->data != conv && 8468 pidgin_conv_attach(convs->data);
8524 pidgin_conv_find_gtkconv(convs->data) == gtkconv) { 8469 list = g_list_concat(list, g_list_copy(purple_conversation_get_message_history(convs->data)));
8525 pidgin_conv_attach(convs->data); 8470 }
8526 list = g_list_concat(list, g_list_copy(purple_conversation_get_message_history(convs->data))); 8471 list = g_list_sort(list, message_compare);
8527 } 8472 gtkconv->attach.current = list;
8528 list = g_list_sort(list, message_compare); 8473 list = g_list_last(list);
8529 gtkconv->attach.current = list; 8474 } else {
8530 list = g_list_last(list); 8475 gtkconv->attach.current = g_list_last(list);
8531 break; 8476 }
8532 } 8477
8533 case PURPLE_CONV_TYPE_CHAT:
8534 gtkconv->attach.current = g_list_last(list);
8535 break;
8536 default:
8537 g_return_val_if_reached(TRUE);
8538 }
8539 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", 8478 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time",
8540 GINT_TO_POINTER(purple_conversation_message_get_timestamp((PurpleConversationMessage*)(list->data)))); 8479 GINT_TO_POINTER(purple_conversation_message_get_timestamp((PurpleConversationMessage*)(list->data))));
8541 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); 8480 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv);
8542 } else { 8481 } else {
8543 purple_signal_emit(pidgin_conversations_get_handle(), 8482 purple_signal_emit(pidgin_conversations_get_handle(),
8544 "conversation-displayed", gtkconv); 8483 "conversation-displayed", gtkconv);
8545 } 8484 }
8546 8485
8547 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 8486 if (PURPLE_IS_CHAT_CONVERSATION(conv)) {
8487 PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(conv);
8548 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); 8488 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC);
8549 pidgin_conv_chat_add_users(conv, purple_chat_conversation_get_users(PURPLE_CONV_CHAT(conv)), TRUE); 8489 pidgin_conv_chat_add_users(chat, purple_chat_conversation_get_users(chat), TRUE);
8550 } 8490 }
8551 8491
8552 return TRUE; 8492 return TRUE;
8553 } 8493 }
8554 8494
8795 * UI operations 8735 * UI operations
8796 **********************************************************************/ 8736 **********************************************************************/
8797 8737
8798 purple_signal_connect(purple_connections_get_handle(), "signed-on", handle, 8738 purple_signal_connect(purple_connections_get_handle(), "signed-on", handle,
8799 G_CALLBACK(account_signed_off_cb), 8739 G_CALLBACK(account_signed_off_cb),
8800 GINT_TO_POINTER(PURPLE_CONV_ACCOUNT_ONLINE)); 8740 GINT_TO_POINTER(PURPLE_CONVERSATION_ACCOUNT_ONLINE));
8801 purple_signal_connect(purple_connections_get_handle(), "signed-off", handle, 8741 purple_signal_connect(purple_connections_get_handle(), "signed-off", handle,
8802 G_CALLBACK(account_signed_off_cb), 8742 G_CALLBACK(account_signed_off_cb),
8803 GINT_TO_POINTER(PURPLE_CONV_ACCOUNT_OFFLINE)); 8743 GINT_TO_POINTER(PURPLE_CONVERSATION_ACCOUNT_OFFLINE));
8804 purple_signal_connect(purple_connections_get_handle(), "signing-off", handle, 8744 purple_signal_connect(purple_connections_get_handle(), "signing-off", handle,
8805 G_CALLBACK(account_signing_off), NULL); 8745 G_CALLBACK(account_signing_off), NULL);
8806 8746
8807 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", 8747 purple_signal_connect(purple_conversations_get_handle(), "received-im-msg",
8808 handle, G_CALLBACK(received_im_msg_cb), NULL); 8748 handle, G_CALLBACK(received_im_msg_cb), NULL);
9055 /* If there are unread messages then show a warning dialog */ 8995 /* If there are unread messages then show a warning dialog */
9056 for (l = pidgin_conv_window_get_gtkconvs(win); 8996 for (l = pidgin_conv_window_get_gtkconvs(win);
9057 l != NULL; l = l->next) 8997 l != NULL; l = l->next)
9058 { 8998 {
9059 PidginConversation *gtkconv = l->data; 8999 PidginConversation *gtkconv = l->data;
9060 if (purple_conversation_get_type(gtkconv->active_conv) == PURPLE_CONV_TYPE_IM && 9000 if (PURPLE_IS_IM_CONVERSATION(gtkconv->active_conv) &&
9061 gtkconv->unseen_state >= PIDGIN_UNSEEN_TEXT) 9001 gtkconv->unseen_state >= PIDGIN_UNSEEN_TEXT)
9062 { 9002 {
9063 build_warn_close_dialog(win); 9003 build_warn_close_dialog(win);
9064 gtk_widget_show_all(warn_close_dialog); 9004 gtk_widget_show_all(warn_close_dialog);
9065 9005
9580 win = user_data; 9520 win = user_data;
9581 conv = pidgin_conv_window_get_active_conversation(win); 9521 conv = pidgin_conv_window_get_active_conversation(win);
9582 9522
9583 g_return_if_fail(conv != NULL); 9523 g_return_if_fail(conv != NULL);
9584 9524
9585 if (purple_conversation_get_type(conv) != PURPLE_CONV_TYPE_IM) 9525 if (PURPLE_IS_CHAT_CONVERSATION(conv))
9586 return; 9526 return;
9587 9527
9588 gtkconv = PIDGIN_CONVERSATION(conv); 9528 gtkconv = PIDGIN_CONVERSATION(conv);
9589 9529
9590 if (gtkconv->u.im->typing_timer != 0) { 9530 if (gtkconv->u.im->typing_timer != 0) {
9798 } 9738 }
9799 conv = gtkconv->active_conv; 9739 conv = gtkconv->active_conv;
9800 account = purple_conversation_get_account(conv); 9740 account = purple_conversation_get_account(conv);
9801 name = purple_conversation_get_name(conv); 9741 name = purple_conversation_get_name(conv);
9802 9742
9803 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 9743 if (PURPLE_IS_IM_CONVERSATION(conv)) {
9804 PurpleBuddy *buddy; 9744 PurpleBuddy *buddy;
9805 buddy = purple_find_buddy(account, name); 9745 buddy = purple_find_buddy(account, name);
9806 if (buddy != NULL) { 9746 if (buddy != NULL) {
9807 purple_blist_alias_buddy(buddy, gtk_entry_get_text(entry)); 9747 purple_blist_alias_buddy(buddy, gtk_entry_get_text(entry));
9808 } 9748 }
9809 serv_alias_buddy(buddy); 9749 serv_alias_buddy(buddy);
9810 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 9750 } else {
9811 gtk_entry_set_text(GTK_ENTRY(gtkconv->u.chat->topic_text), gtk_entry_get_text(entry)); 9751 gtk_entry_set_text(GTK_ENTRY(gtkconv->u.chat->topic_text), gtk_entry_get_text(entry));
9812 topic_callback(NULL, gtkconv); 9752 topic_callback(NULL, gtkconv);
9813 } 9753 }
9814 remove_edit_entry(user_data, GTK_WIDGET(entry)); 9754 remove_edit_entry(user_data, GTK_WIDGET(entry));
9815 } 9755 }
9829 if (!purple_account_is_connected(purple_conversation_get_account(gtkconv->active_conv))) { 9769 if (!purple_account_is_connected(purple_conversation_get_account(gtkconv->active_conv))) {
9830 /* Do not allow aliasing someone on a disconnected account. */ 9770 /* Do not allow aliasing someone on a disconnected account. */
9831 return FALSE; 9771 return FALSE;
9832 } 9772 }
9833 9773
9834 if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) { 9774 if (PURPLE_IS_IM_CONVERSATION(conv)) {
9835 PurpleBuddy *buddy = purple_find_buddy(purple_conversation_get_account(gtkconv->active_conv), purple_conversation_get_name(gtkconv->active_conv)); 9775 PurpleBuddy *buddy = purple_find_buddy(purple_conversation_get_account(gtkconv->active_conv), purple_conversation_get_name(gtkconv->active_conv));
9836 if (!buddy) 9776 if (!buddy)
9837 /* This buddy isn't in your buddy list, so we can't alias him */ 9777 /* This buddy isn't in your buddy list, so we can't alias him */
9838 return FALSE; 9778 return FALSE;
9839 9779
9840 text = purple_buddy_get_contact_alias(buddy); 9780 text = purple_buddy_get_contact_alias(buddy);
9841 } else if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { 9781 } else {
9842 PurpleConnection *gc; 9782 PurpleConnection *gc;
9843 PurplePluginProtocolInfo *prpl_info = NULL; 9783 PurplePluginProtocolInfo *prpl_info = NULL;
9844 9784
9845 gc = purple_conversation_get_connection(conv); 9785 gc = purple_conversation_get_connection(conv);
9846 if (gc != NULL) 9786 if (gc != NULL)
9847 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); 9787 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
9848 if (prpl_info && prpl_info->set_chat_topic == NULL) 9788 if (prpl_info && prpl_info->set_chat_topic == NULL)
9849 /* This protocol doesn't support setting the chat room topic */ 9789 /* This protocol doesn't support setting the chat room topic */
9850 return FALSE; 9790 return FALSE;
9851 9791
9852 text = purple_chat_conversation_get_topic(PURPLE_CONV_CHAT(conv)); 9792 text = purple_chat_conversation_get_topic(PURPLE_CHAT_CONVERSATION(conv));
9853 } 9793 }
9854 9794
9855 /* alias label */ 9795 /* alias label */
9856 entry = gtk_entry_new(); 9796 entry = gtk_entry_new();
9857 gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE); 9797 gtk_entry_set_has_frame(GTK_ENTRY(entry), FALSE);
9924 9864
9925 /* 9865 /*
9926 * We pause icons when they are not visible. If this icon should 9866 * We pause icons when they are not visible. If this icon should
9927 * be animated then start it back up again. 9867 * be animated then start it back up again.
9928 */ 9868 */
9929 if ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) && 9869 if (PURPLE_IS_IM_CONVERSATION(conv) &&
9930 (gtkconv->u.im->animate)) 9870 (gtkconv->u.im->animate))
9931 start_anim(NULL, gtkconv); 9871 start_anim(NULL, gtkconv);
9932 9872
9933 purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv); 9873 purple_signal_emit(pidgin_conversations_get_handle(), "conversation-switched", conv);
9934 } 9874 }
10313 pidgin_conv_window_add_gtkconv(PidginWindow *win, PidginConversation *gtkconv) 10253 pidgin_conv_window_add_gtkconv(PidginWindow *win, PidginConversation *gtkconv)
10314 { 10254 {
10315 PurpleConversation *conv = gtkconv->active_conv; 10255 PurpleConversation *conv = gtkconv->active_conv;
10316 PidginConversation *focus_gtkconv; 10256 PidginConversation *focus_gtkconv;
10317 GtkWidget *tab_cont = gtkconv->tab_cont; 10257 GtkWidget *tab_cont = gtkconv->tab_cont;
10318 PurpleConversationType conv_type;
10319 const gchar *tmp_lab; 10258 const gchar *tmp_lab;
10320
10321 conv_type = purple_conversation_get_type(conv);
10322 10259
10323 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); 10260 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv);
10324 gtkconv->win = win; 10261 gtkconv->win = win;
10325 10262
10326 if (win->gtkconvs && win->gtkconvs->next && win->gtkconvs->next->next == NULL) 10263 if (win->gtkconvs && win->gtkconvs->next && win->gtkconvs->next->next == NULL)
10362 gtk_widget_show(gtkconv->menu_label); 10299 gtk_widget_show(gtkconv->menu_label);
10363 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); 10300 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0);
10364 10301
10365 gtk_widget_show(gtkconv->menu_tabby); 10302 gtk_widget_show(gtkconv->menu_tabby);
10366 10303
10367 if (conv_type == PURPLE_CONV_TYPE_IM) 10304 if (PURPLE_IS_IM_CONVERSATION(conv))
10368 pidgin_conv_update_buddy_icon(conv); 10305 pidgin_conv_update_buddy_icon(PURPLE_IM_CONVERSATION(conv));
10369 10306
10370 /* Build and set conversations tab */ 10307 /* Build and set conversations tab */
10371 pidgin_conv_tab_pack(win, gtkconv); 10308 pidgin_conv_tab_pack(win, gtkconv);
10372 10309
10373 gtk_notebook_set_menu_label(GTK_NOTEBOOK(win->notebook), tab_cont, gtkconv->menu_tabby); 10310 gtk_notebook_set_menu_label(GTK_NOTEBOOK(win->notebook), tab_cont, gtkconv->menu_tabby);
10745 static gboolean 10682 static gboolean
10746 conv_placement_last_created_win_type_configured_cb(GtkWidget *w, 10683 conv_placement_last_created_win_type_configured_cb(GtkWidget *w,
10747 GdkEventConfigure *event, PidginConversation *conv) 10684 GdkEventConfigure *event, PidginConversation *conv)
10748 { 10685 {
10749 int x, y; 10686 int x, y;
10750 PurpleConversationType type = purple_conversation_get_type(conv->active_conv);
10751 GList *all; 10687 GList *all;
10752 10688
10753 if (gtk_widget_get_visible(w)) 10689 if (gtk_widget_get_visible(w))
10754 gtk_window_get_position(GTK_WINDOW(w), &x, &y); 10690 gtk_window_get_position(GTK_WINDOW(w), &x, &y);
10755 else 10691 else
10766 x > gdk_screen_width() || 10702 x > gdk_screen_width() ||
10767 y > gdk_screen_height()) 10703 y > gdk_screen_height())
10768 return FALSE; /* carry on normally */ 10704 return FALSE; /* carry on normally */
10769 10705
10770 for (all = conv->convs; all != NULL; all = all->next) { 10706 for (all = conv->convs; all != NULL; all = all->next) {
10771 if (type != purple_conversation_get_type(all->data)) { 10707 if (PURPLE_IS_IM_CONVERSATION(conv->active_conv) != PURPLE_IS_IM_CONVERSATION(all->data)) {
10772 /* this window has different types of conversation, don't save */ 10708 /* this window has different types of conversation, don't save */
10773 return FALSE; 10709 return FALSE;
10774 } 10710 }
10775 } 10711 }
10776 10712
10777 if (type == PURPLE_CONV_TYPE_IM) { 10713 if (PURPLE_IS_IM_CONVERSATION(conv->active_conv)) {
10778 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/x", x); 10714 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/x", x);
10779 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/y", y); 10715 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/y", y);
10780 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width", event->width); 10716 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/width", event->width);
10781 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height); 10717 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/im/height", event->height);
10782 } else if (type == PURPLE_CONV_TYPE_CHAT) { 10718 } else {
10783 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/x", x); 10719 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/x", x);
10784 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/y", y); 10720 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/y", y);
10785 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/width", event->width); 10721 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/width", event->width);
10786 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/height", event->height); 10722 purple_prefs_set_int(PIDGIN_PREFS_ROOT "/conversations/chat/height", event->height);
10787 } 10723 }
10792 static void 10728 static void
10793 conv_placement_last_created_win_type(PidginConversation *conv) 10729 conv_placement_last_created_win_type(PidginConversation *conv)
10794 { 10730 {
10795 PidginWindow *win; 10731 PidginWindow *win;
10796 10732
10797 win = pidgin_conv_window_last_with_type(purple_conversation_get_type(conv->active_conv)); 10733 if (PURPLE_IS_IM_CONVERSATION(conv->active_conv))
10734 win = pidgin_conv_window_last_im();
10735 else
10736 win = pidgin_conv_window_last_chat();
10798 10737
10799 if (win == NULL) { 10738 if (win == NULL) {
10800 win = pidgin_conv_window_new(); 10739 win = pidgin_conv_window_new();
10801 10740
10802 if (PURPLE_CONV_TYPE_IM == purple_conversation_get_type(conv->active_conv) || 10741 if (PURPLE_IS_IM_CONVERSATION(conv->active_conv) ||
10803 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/width") == 0) { 10742 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/width") == 0) {
10804 pidgin_conv_set_position_size(win, 10743 pidgin_conv_set_position_size(win,
10805 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/x"), 10744 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/x"),
10806 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/y"), 10745 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/y"),
10807 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width"), 10746 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/width"),
10808 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height")); 10747 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/im/height"));
10809 } else if (PURPLE_CONV_TYPE_CHAT == purple_conversation_get_type(conv->active_conv)) { 10748 } else if (PURPLE_IS_CHAT_CONVERSATION(conv->active_conv)) {
10810 pidgin_conv_set_position_size(win, 10749 pidgin_conv_set_position_size(win,
10811 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/x"), 10750 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/x"),
10812 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/y"), 10751 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/y"),
10813 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/width"), 10752 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/width"),
10814 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/height")); 10753 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/chat/height"));
10842 static PurpleGroup * 10781 static PurpleGroup *
10843 conv_get_group(PidginConversation *conv) 10782 conv_get_group(PidginConversation *conv)
10844 { 10783 {
10845 PurpleGroup *group = NULL; 10784 PurpleGroup *group = NULL;
10846 10785
10847 if (purple_conversation_get_type(conv->active_conv) == PURPLE_CONV_TYPE_IM) { 10786 if (PURPLE_IS_IM_CONVERSATION(conv->active_conv)) {
10848 PurpleBuddy *buddy; 10787 PurpleBuddy *buddy;
10849 10788
10850 buddy = purple_find_buddy(purple_conversation_get_account(conv->active_conv), 10789 buddy = purple_find_buddy(purple_conversation_get_account(conv->active_conv),
10851 purple_conversation_get_name(conv->active_conv)); 10790 purple_conversation_get_name(conv->active_conv));
10852 10791
10853 if (buddy != NULL) 10792 if (buddy != NULL)
10854 group = purple_buddy_get_group(buddy); 10793 group = purple_buddy_get_group(buddy);
10855 10794
10856 } else if (purple_conversation_get_type(conv->active_conv) == PURPLE_CONV_TYPE_CHAT) { 10795 } else {
10857 PurpleChat *chat; 10796 PurpleChat *chat;
10858 10797
10859 chat = purple_blist_find_chat(purple_conversation_get_account(conv->active_conv), 10798 chat = purple_blist_find_chat(purple_conversation_get_account(conv->active_conv),
10860 purple_conversation_get_name(conv->active_conv)); 10799 purple_conversation_get_name(conv->active_conv));
10861 10800

mercurial