Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 27735:98604b4bfa3b
propagate from branch 'im.pidgin.pidgin' (head cc8513f94aa94550d600cd8a5d42475dbf7249c0)
to branch 'im.pidgin.pidgin.yaz' (head 3a859b75c16c1c1e2e79d4f4acb4424d13af5e0b)
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 22 Nov 2007 07:44:59 +0000 |
parents | 3f5b0039428b c797c101b358 |
children | 6befd211e707 e81d5493626c |
comparison
equal
deleted
inserted
replaced
27734:3f5b0039428b | 27735:98604b4bfa3b |
---|---|
361 { | 361 { |
362 char *tmp, *markup; | 362 char *tmp, *markup; |
363 PurpleCmdStatus status; | 363 PurpleCmdStatus status; |
364 | 364 |
365 if (!g_ascii_strcasecmp(args[0], "version")) { | 365 if (!g_ascii_strcasecmp(args[0], "version")) { |
366 tmp = g_strdup_printf("me is using %s v%s.", "Pidgin", VERSION); | 366 tmp = g_strdup_printf("me is using %s v%s.", "Pidgin", DISPLAY_VERSION); |
367 markup = g_markup_escape_text(tmp, -1); | 367 markup = g_markup_escape_text(tmp, -1); |
368 | 368 |
369 status = purple_cmd_do_command(conv, tmp, markup, error); | 369 status = purple_cmd_do_command(conv, tmp, markup, error); |
370 | 370 |
371 g_free(tmp); | 371 g_free(tmp); |
3089 PURPLE_BLIST_NODE_FLAG_NO_SAVE); | 3089 PURPLE_BLIST_NODE_FLAG_NO_SAVE); |
3090 g_object_set_data_full(G_OBJECT(gtkconv->imhtml), "transient_chat", | 3090 g_object_set_data_full(G_OBJECT(gtkconv->imhtml), "transient_chat", |
3091 chat, (GDestroyNotify)purple_blist_remove_chat); | 3091 chat, (GDestroyNotify)purple_blist_remove_chat); |
3092 } | 3092 } |
3093 } else { | 3093 } else { |
3094 if (!purple_account_is_connected(conv->account)) | |
3095 return FALSE; | |
3096 | |
3094 buddy = purple_find_buddy(conv->account, conv->name); | 3097 buddy = purple_find_buddy(conv->account, conv->name); |
3095 | 3098 |
3096 /* gotta remain bug-compatible :( libpurple < 2.0.2 didn't handle | 3099 /* gotta remain bug-compatible :( libpurple < 2.0.2 didn't handle |
3097 * removing "isolated" buddy nodes well */ | 3100 * removing "isolated" buddy nodes well */ |
3098 if (purple_version_check(2, 0, 2) == NULL) { | 3101 if (purple_version_check(2, 0, 2) == NULL) { |
5066 gtkconv->active_conv = conv; | 5069 gtkconv->active_conv = conv; |
5067 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | 5070 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); |
5068 gtkconv->send_history = g_list_append(NULL, NULL); | 5071 gtkconv->send_history = g_list_append(NULL, NULL); |
5069 | 5072 |
5070 /* Setup some initial variables. */ | 5073 /* Setup some initial variables. */ |
5071 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
5072 gtkconv->tooltips = gtk_tooltips_new(); | 5074 gtkconv->tooltips = gtk_tooltips_new(); |
5073 gtkconv->unseen_state = PIDGIN_UNSEEN_NONE; | 5075 gtkconv->unseen_state = PIDGIN_UNSEEN_NONE; |
5074 gtkconv->unseen_count = 0; | 5076 gtkconv->unseen_count = 0; |
5075 | 5077 |
5076 if (conv_type == PURPLE_CONV_TYPE_IM) { | 5078 if (conv_type == PURPLE_CONV_TYPE_IM) { |
6604 purple_conv_im_get_typing_state(im) == PURPLE_TYPED) { | 6606 purple_conv_im_get_typing_state(im) == PURPLE_TYPED) { |
6605 atk_object_set_description(accessibility_obj, _("Stopped Typing")); | 6607 atk_object_set_description(accessibility_obj, _("Stopped Typing")); |
6606 style = "color=\"#c4a000\""; | 6608 style = "color=\"#c4a000\""; |
6607 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_NICK) { | 6609 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_NICK) { |
6608 atk_object_set_description(accessibility_obj, _("Nick Said")); | 6610 atk_object_set_description(accessibility_obj, _("Nick Said")); |
6609 style = "color=\"#cc0000\""; | 6611 style = "color=\"#204a87\""; |
6610 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT) { | 6612 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_TEXT) { |
6611 atk_object_set_description(accessibility_obj, _("Unread Messages")); | 6613 atk_object_set_description(accessibility_obj, _("Unread Messages")); |
6612 if (gtkconv->active_conv->type == PURPLE_CONV_TYPE_CHAT) | 6614 if (gtkconv->active_conv->type == PURPLE_CONV_TYPE_CHAT) |
6615 style = "color=\"#cc0000\""; | |
6616 else | |
6613 style = "color=\"#204a87\""; | 6617 style = "color=\"#204a87\""; |
6614 else | |
6615 style = "color=\"#cc0000\""; | |
6616 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { | 6618 } else if (gtkconv->unseen_state == PIDGIN_UNSEEN_EVENT) { |
6617 atk_object_set_description(accessibility_obj, _("New Event")); | 6619 atk_object_set_description(accessibility_obj, _("New Event")); |
6618 style = "color=\"#888a85\""; | 6620 style = "color=\"#888a85\""; |
6619 } else { | 6621 } else { |
6620 style = NULL; | 6622 style = NULL; |
7482 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) | 7484 update_chat_topic(PurpleConversation *conv, const char *old, const char *new) |
7483 { | 7485 { |
7484 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); | 7486 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
7485 } | 7487 } |
7486 | 7488 |
7489 /* Message history stuff */ | |
7490 | |
7491 /* Compare two PurpleConvMessage's, according to time in ascending order. */ | |
7492 static int | |
7493 message_compare(gconstpointer p1, gconstpointer p2) | |
7494 { | |
7495 const PurpleConvMessage *m1 = p1, *m2 = p2; | |
7496 return (m1->when > m2->when); | |
7497 } | |
7498 | |
7499 /* Adds some message history to the gtkconv. This happens in a idle-callback. */ | |
7487 static gboolean | 7500 static gboolean |
7488 add_message_history_to_gtkconv(gpointer data) | 7501 add_message_history_to_gtkconv(gpointer data) |
7489 { | 7502 { |
7490 PidginConversation *gtkconv = data; | 7503 PidginConversation *gtkconv = data; |
7491 int count = 0; | 7504 int count = 0; |
7492 int timer = gtkconv->attach.timer; | 7505 int timer = gtkconv->attach.timer; |
7493 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); | 7506 time_t when = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(gtkconv->entry), "attach-start-time")); |
7507 gboolean im = (gtkconv->active_conv->type == PURPLE_CONV_TYPE_IM); | |
7494 | 7508 |
7495 gtkconv->attach.timer = 0; | 7509 gtkconv->attach.timer = 0; |
7496 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ | 7510 while (gtkconv->attach.current && count < 100) { /* XXX: 100 is a random value here */ |
7497 PurpleConvMessage *msg = gtkconv->attach.current->data; | 7511 PurpleConvMessage *msg = gtkconv->attach.current->data; |
7498 if (when && when < msg->when) { | 7512 if (!im && when && when < msg->when) { |
7499 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR><HR>", 0); | 7513 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR><HR>", 0); |
7500 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | 7514 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); |
7501 } | 7515 } |
7502 pidgin_conv_write_conv(gtkconv->active_conv, msg->who, msg->who, msg->what, msg->flags, msg->when); | 7516 pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); |
7503 gtkconv->attach.current = gtkconv->attach.current->prev; | 7517 if (im) { |
7518 gtkconv->attach.current = g_list_delete_link(gtkconv->attach.current, gtkconv->attach.current); | |
7519 } else { | |
7520 gtkconv->attach.current = gtkconv->attach.current->prev; | |
7521 } | |
7504 count++; | 7522 count++; |
7505 } | 7523 } |
7506 gtkconv->attach.timer = timer; | 7524 gtkconv->attach.timer = timer; |
7507 if (gtkconv->attach.current) | 7525 if (gtkconv->attach.current) |
7508 return TRUE; | 7526 return TRUE; |
7509 | 7527 |
7528 g_source_remove(gtkconv->attach.timer); | |
7529 gtkconv->attach.timer = 0; | |
7530 if (im) { | |
7531 /* Print any message that was sent while the old history was being added back. */ | |
7532 GList *msgs = NULL; | |
7533 GList *iter = gtkconv->convs; | |
7534 for (; iter; iter = iter->next) { | |
7535 PurpleConversation *conv = iter->data; | |
7536 GList *history = purple_conversation_get_message_history(conv); | |
7537 for (; history; history = history->next) { | |
7538 PurpleConvMessage *msg = history->data; | |
7539 if (msg->when > when) | |
7540 msgs = g_list_prepend(msgs, msg); | |
7541 } | |
7542 } | |
7543 msgs = g_list_sort(msgs, message_compare); | |
7544 for (; msgs; msgs = g_list_delete_link(msgs, msgs)) { | |
7545 PurpleConvMessage *msg = msgs->data; | |
7546 pidgin_conv_write_conv(msg->conv, msg->who, msg->alias, msg->what, msg->flags, msg->when); | |
7547 } | |
7548 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR><HR>", 0); | |
7549 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | |
7550 } | |
7551 | |
7510 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); | 7552 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", NULL); |
7511 purple_signal_emit(pidgin_conversations_get_handle(), | 7553 purple_signal_emit(pidgin_conversations_get_handle(), |
7512 "conversation-displayed", gtkconv); | 7554 "conversation-displayed", gtkconv); |
7513 g_source_remove(gtkconv->attach.timer); | |
7514 gtkconv->attach.timer = 0; | |
7515 return FALSE; | 7555 return FALSE; |
7516 } | 7556 } |
7517 | 7557 |
7518 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) | 7558 static void |
7519 { | 7559 pidgin_conv_attach(PurpleConversation *conv) |
7520 GList *list; | 7560 { |
7521 PidginConversation *gtkconv; | |
7522 int timer; | 7561 int timer; |
7523 | |
7524 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
7525 return FALSE; | |
7526 | |
7527 purple_conversation_set_data(conv, "unseen-count", NULL); | 7562 purple_conversation_set_data(conv, "unseen-count", NULL); |
7528 purple_conversation_set_data(conv, "unseen-state", NULL); | 7563 purple_conversation_set_data(conv, "unseen-state", NULL); |
7529 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); | 7564 purple_conversation_set_ui_ops(conv, pidgin_conversations_get_conv_ui_ops()); |
7530 private_gtkconv_new(conv, FALSE); | 7565 private_gtkconv_new(conv, FALSE); |
7566 timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); | |
7567 if (timer) | |
7568 purple_timeout_remove(timer); | |
7569 } | |
7570 | |
7571 gboolean pidgin_conv_attach_to_conversation(PurpleConversation *conv) | |
7572 { | |
7573 GList *list; | |
7574 PidginConversation *gtkconv; | |
7575 | |
7576 if (PIDGIN_IS_PIDGIN_CONVERSATION(conv)) | |
7577 return FALSE; | |
7578 | |
7579 pidgin_conv_attach(conv); | |
7531 gtkconv = PIDGIN_CONVERSATION(conv); | 7580 gtkconv = PIDGIN_CONVERSATION(conv); |
7532 | 7581 |
7533 list = purple_conversation_get_message_history(conv); | 7582 list = purple_conversation_get_message_history(conv); |
7534 if (list) { | 7583 if (list) { |
7584 switch (purple_conversation_get_type(conv)) { | |
7585 case PURPLE_CONV_TYPE_IM: | |
7586 { | |
7587 GList *convs; | |
7588 list = g_list_copy(list); | |
7589 for (convs = purple_get_ims(); convs; convs = convs->next) | |
7590 if (convs->data != conv && | |
7591 pidgin_conv_find_gtkconv(convs->data) == gtkconv) { | |
7592 pidgin_conv_attach(convs->data); | |
7593 list = g_list_concat(list, g_list_copy(purple_conversation_get_message_history(convs->data))); | |
7594 } | |
7595 list = g_list_sort(list, message_compare); | |
7596 gtkconv->attach.current = list; | |
7597 list = g_list_last(list); | |
7598 break; | |
7599 } | |
7600 case PURPLE_CONV_TYPE_CHAT: | |
7601 gtkconv->attach.current = g_list_last(list); | |
7602 break; | |
7603 default: | |
7604 g_return_val_if_reached(TRUE); | |
7605 } | |
7535 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", | 7606 g_object_set_data(G_OBJECT(gtkconv->entry), "attach-start-time", |
7536 GINT_TO_POINTER(((PurpleConvMessage*)(list->data))->when)); | 7607 GINT_TO_POINTER(((PurpleConvMessage*)(list->data))->when)); |
7537 gtkconv->attach.current = g_list_last(list); | |
7538 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); | 7608 gtkconv->attach.timer = g_idle_add(add_message_history_to_gtkconv, gtkconv); |
7539 } else { | 7609 } else { |
7540 purple_signal_emit(pidgin_conversations_get_handle(), | 7610 purple_signal_emit(pidgin_conversations_get_handle(), |
7541 "conversation-displayed", gtkconv); | 7611 "conversation-displayed", gtkconv); |
7542 } | 7612 } |
7544 if (conv->type == PURPLE_CONV_TYPE_CHAT) { | 7614 if (conv->type == PURPLE_CONV_TYPE_CHAT) { |
7545 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); | 7615 pidgin_conv_update_fields(conv, PIDGIN_CONV_TOPIC); |
7546 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); | 7616 pidgin_conv_chat_add_users(conv, PURPLE_CONV_CHAT(conv)->in_room, TRUE); |
7547 } | 7617 } |
7548 | 7618 |
7549 timer = GPOINTER_TO_INT(purple_conversation_get_data(conv, "close-timer")); | |
7550 if (timer) | |
7551 purple_timeout_remove(timer); | |
7552 return TRUE; | 7619 return TRUE; |
7553 } | 7620 } |
7554 | 7621 |
7555 void * | 7622 void * |
7556 pidgin_conversations_get_handle(void) | 7623 pidgin_conversations_get_handle(void) |
7613 | 7680 |
7614 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", 54); | 7681 purple_prefs_add_int(PIDGIN_PREFS_ROOT "/conversations/im/entry_height", 54); |
7615 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", TRUE); | 7682 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/show_buddy_icons", TRUE); |
7616 | 7683 |
7617 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "never"); | 7684 purple_prefs_add_string(PIDGIN_PREFS_ROOT "/conversations/im/hide_new", "never"); |
7618 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately", FALSE); | 7685 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/conversations/im/close_immediately", TRUE); |
7619 | 7686 |
7620 #ifdef _WIN32 | 7687 #ifdef _WIN32 |
7621 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/win32/minimize_new_convs", FALSE); | 7688 purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/win32/minimize_new_convs", FALSE); |
7622 #endif | 7689 #endif |
7623 | 7690 |
9920 } | 9987 } |
9921 | 9988 |
9922 return colors; | 9989 return colors; |
9923 } | 9990 } |
9924 | 9991 |
9992 |