Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 23359:398f84dd4041
Use the chat user's real username (if available) for more things (e.g.) file
transfers
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Fri, 13 Jun 2008 04:34:06 +0000 |
parents | e965a497ddfb |
children | a5bfc59b0c6e 3da0957e7821 a5bb767b8644 |
comparison
equal
deleted
inserted
replaced
23358:1be3301fa2a3 | 23359:398f84dd4041 |
---|---|
1479 { | 1479 { |
1480 PurpleConversation *conv = gtkconv->active_conv; | 1480 PurpleConversation *conv = gtkconv->active_conv; |
1481 PurpleAccount *account; | 1481 PurpleAccount *account; |
1482 PurpleConnection *gc; | 1482 PurpleConnection *gc; |
1483 PurplePluginProtocolInfo *prpl_info = NULL; | 1483 PurplePluginProtocolInfo *prpl_info = NULL; |
1484 char *real_who; | 1484 gchar *real_who = NULL; |
1485 | 1485 |
1486 account = purple_conversation_get_account(conv); | 1486 account = purple_conversation_get_account(conv); |
1487 g_return_if_fail(account != NULL); | 1487 g_return_if_fail(account != NULL); |
1488 | 1488 |
1489 gc = purple_account_get_connection(account); | 1489 gc = purple_account_get_connection(account); |
1492 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | 1492 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
1493 | 1493 |
1494 if (prpl_info && prpl_info->get_cb_real_name) | 1494 if (prpl_info && prpl_info->get_cb_real_name) |
1495 real_who = prpl_info->get_cb_real_name(gc, | 1495 real_who = prpl_info->get_cb_real_name(gc, |
1496 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); | 1496 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); |
1497 else | 1497 |
1498 real_who = g_strdup(who); | 1498 if(!who && !real_who) |
1499 | |
1500 if(!real_who) | |
1501 return; | 1499 return; |
1502 | 1500 |
1503 pidgin_dialogs_im_with_user(account, real_who); | 1501 pidgin_dialogs_im_with_user(account, real_who ? real_who : who); |
1504 | 1502 |
1505 g_free(real_who); | 1503 g_free(real_who); |
1506 } | 1504 } |
1507 | 1505 |
1508 static void pidgin_conv_chat_update_user(PurpleConversation *conv, const char *user); | 1506 static void pidgin_conv_chat_update_user(PurpleConversation *conv, const char *user); |
1537 } | 1535 } |
1538 | 1536 |
1539 static void | 1537 static void |
1540 menu_chat_send_file_cb(GtkWidget *w, PidginConversation *gtkconv) | 1538 menu_chat_send_file_cb(GtkWidget *w, PidginConversation *gtkconv) |
1541 { | 1539 { |
1540 PurplePluginProtocolInfo *prpl_info; | |
1542 PurpleConversation *conv = gtkconv->active_conv; | 1541 PurpleConversation *conv = gtkconv->active_conv; |
1543 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | 1542 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1544 PurpleConnection *gc = purple_conversation_get_gc(conv); | 1543 PurpleConnection *gc = purple_conversation_get_gc(conv); |
1545 | 1544 gchar *real_who = NULL; |
1546 serv_send_file(gc, who, NULL); | 1545 |
1546 g_return_if_fail(gc != NULL); | |
1547 | |
1548 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1549 | |
1550 if (prpl_info && prpl_info->get_cb_real_name) | |
1551 real_who = prpl_info->get_cb_real_name(gc, | |
1552 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); | |
1553 | |
1554 serv_send_file(gc, real_who ? real_who : who, NULL); | |
1555 g_free(real_who); | |
1547 } | 1556 } |
1548 | 1557 |
1549 static void | 1558 static void |
1550 menu_chat_info_cb(GtkWidget *w, PidginConversation *gtkconv) | 1559 menu_chat_info_cb(GtkWidget *w, PidginConversation *gtkconv) |
1551 { | 1560 { |
1657 button = pidgin_new_item_from_stock(menu, _("IM"), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, | 1666 button = pidgin_new_item_from_stock(menu, _("IM"), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, |
1658 G_CALLBACK(menu_chat_im_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1667 G_CALLBACK(menu_chat_im_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1659 | 1668 |
1660 if (gc == NULL) | 1669 if (gc == NULL) |
1661 gtk_widget_set_sensitive(button, FALSE); | 1670 gtk_widget_set_sensitive(button, FALSE); |
1662 | 1671 else |
1663 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1672 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1664 | 1673 |
1665 | 1674 |
1666 if (prpl_info && prpl_info->send_file) | 1675 if (prpl_info && prpl_info->send_file) |
1667 { | 1676 { |
1677 gboolean can_receive_file = TRUE; | |
1678 | |
1668 button = pidgin_new_item_from_stock(menu, _("Send File"), | 1679 button = pidgin_new_item_from_stock(menu, _("Send File"), |
1669 PIDGIN_STOCK_TOOLBAR_SEND_FILE, G_CALLBACK(menu_chat_send_file_cb), | 1680 PIDGIN_STOCK_TOOLBAR_SEND_FILE, G_CALLBACK(menu_chat_send_file_cb), |
1670 PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1681 PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1671 | 1682 |
1672 if (gc == NULL || prpl_info == NULL || | 1683 if (gc == NULL || prpl_info == NULL) |
1673 !(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) | 1684 can_receive_file = FALSE; |
1674 { | 1685 else { |
1686 gchar *real_who = NULL; | |
1687 if (prpl_info->get_cb_real_name) | |
1688 real_who = prpl_info->get_cb_real_name(gc, | |
1689 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who); | |
1690 if (!(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, real_who ? real_who : who))) | |
1691 can_receive_file = FALSE; | |
1692 g_free(real_who); | |
1693 } | |
1694 | |
1695 if (!can_receive_file) | |
1675 gtk_widget_set_sensitive(button, FALSE); | 1696 gtk_widget_set_sensitive(button, FALSE); |
1676 } | 1697 else |
1677 | 1698 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1678 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | |
1679 } | 1699 } |
1680 | 1700 |
1681 | 1701 |
1682 if (purple_conv_chat_is_user_ignored(PURPLE_CONV_CHAT(conv), who)) | 1702 if (purple_conv_chat_is_user_ignored(PURPLE_CONV_CHAT(conv), who)) |
1683 button = pidgin_new_item_from_stock(menu, _("Un-Ignore"), PIDGIN_STOCK_IGNORE, | 1703 button = pidgin_new_item_from_stock(menu, _("Un-Ignore"), PIDGIN_STOCK_IGNORE, |
1686 button = pidgin_new_item_from_stock(menu, _("Ignore"), PIDGIN_STOCK_IGNORE, | 1706 button = pidgin_new_item_from_stock(menu, _("Ignore"), PIDGIN_STOCK_IGNORE, |
1687 G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1707 G_CALLBACK(ignore_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1688 | 1708 |
1689 if (gc == NULL) | 1709 if (gc == NULL) |
1690 gtk_widget_set_sensitive(button, FALSE); | 1710 gtk_widget_set_sensitive(button, FALSE); |
1691 | 1711 else |
1692 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1712 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1693 } | 1713 } |
1694 | 1714 |
1695 if (prpl_info && (prpl_info->get_info || prpl_info->get_cb_info)) { | 1715 if (prpl_info && (prpl_info->get_info || prpl_info->get_cb_info)) { |
1696 button = pidgin_new_item_from_stock(menu, _("Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO, | 1716 button = pidgin_new_item_from_stock(menu, _("Info"), PIDGIN_STOCK_TOOLBAR_USER_INFO, |
1697 G_CALLBACK(menu_chat_info_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1717 G_CALLBACK(menu_chat_info_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1698 | 1718 |
1699 if (gc == NULL) | 1719 if (gc == NULL) |
1700 gtk_widget_set_sensitive(button, FALSE); | 1720 gtk_widget_set_sensitive(button, FALSE); |
1701 | 1721 else |
1702 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1722 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1703 } | 1723 } |
1704 | 1724 |
1705 if (prpl_info && prpl_info->get_cb_away) { | 1725 if (prpl_info && prpl_info->get_cb_away) { |
1706 button = pidgin_new_item_from_stock(menu, _("Get Away Message"), PIDGIN_STOCK_AWAY, | 1726 button = pidgin_new_item_from_stock(menu, _("Get Away Message"), PIDGIN_STOCK_AWAY, |
1707 G_CALLBACK(menu_chat_get_away_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1727 G_CALLBACK(menu_chat_get_away_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1708 | 1728 |
1709 if (gc == NULL) | 1729 if (gc == NULL) |
1710 gtk_widget_set_sensitive(button, FALSE); | 1730 gtk_widget_set_sensitive(button, FALSE); |
1711 | 1731 else |
1712 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1732 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1713 } | 1733 } |
1714 | 1734 |
1715 if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { | 1735 if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
1716 if ((buddy = purple_find_buddy(conv->account, who)) != NULL) | 1736 if ((buddy = purple_find_buddy(conv->account, who)) != NULL) |
1717 button = pidgin_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, | 1737 button = pidgin_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
1720 button = pidgin_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, | 1740 button = pidgin_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
1721 G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1741 G_CALLBACK(menu_chat_add_remove_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1722 | 1742 |
1723 if (gc == NULL) | 1743 if (gc == NULL) |
1724 gtk_widget_set_sensitive(button, FALSE); | 1744 gtk_widget_set_sensitive(button, FALSE); |
1725 | 1745 else |
1726 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1746 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
1727 } | 1747 } |
1728 | 1748 |
1729 button = pidgin_new_item_from_stock(menu, _("Last said"), GTK_STOCK_INDEX, | 1749 button = pidgin_new_item_from_stock(menu, _("Last said"), GTK_STOCK_INDEX, |
1730 G_CALLBACK(menu_last_said_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); | 1750 G_CALLBACK(menu_last_said_cb), PIDGIN_CONVERSATION(conv), 0, 0, NULL); |
1731 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); | 1751 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |