pidgin: 5351a16a: Use the chat user's real username (if av...
datallah at pidgin.im
datallah at pidgin.im
Fri Jun 13 01:01:00 EDT 2008
-----------------------------------------------------------------
Revision: 5351a16ab57aaf40fa894c47258d4ffedbca6363
Ancestor: 0c514d6585e59f90f56e666cfb85495342ca9ff4
Author: datallah at pidgin.im
Date: 2008-06-13T04:34:06
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5351a16ab57aaf40fa894c47258d4ffedbca6363
Modified files:
pidgin/gtkconv.c
ChangeLog:
Use the chat user's real username (if available) for more things (e.g.) file
transfers
-------------- next part --------------
============================================================
--- pidgin/gtkconv.c f656bee349ca2844b43247a872078617dd2e7de6
+++ pidgin/gtkconv.c 2bc2c412f49993c3919aa616ae250a8e6a0cf70c
@@ -1481,7 +1481,7 @@ chat_do_im(PidginConversation *gtkconv,
PurpleAccount *account;
PurpleConnection *gc;
PurplePluginProtocolInfo *prpl_info = NULL;
- char *real_who;
+ gchar *real_who = NULL;
account = purple_conversation_get_account(conv);
g_return_if_fail(account != NULL);
@@ -1494,13 +1494,11 @@ chat_do_im(PidginConversation *gtkconv,
if (prpl_info && prpl_info->get_cb_real_name)
real_who = prpl_info->get_cb_real_name(gc,
purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who);
- else
- real_who = g_strdup(who);
- if(!real_who)
+ if(!who && !real_who)
return;
- pidgin_dialogs_im_with_user(account, real_who);
+ pidgin_dialogs_im_with_user(account, real_who ? real_who : who);
g_free(real_who);
}
@@ -1539,11 +1537,22 @@ menu_chat_send_file_cb(GtkWidget *w, Pid
static void
menu_chat_send_file_cb(GtkWidget *w, PidginConversation *gtkconv)
{
+ PurplePluginProtocolInfo *prpl_info;
PurpleConversation *conv = gtkconv->active_conv;
const char *who = g_object_get_data(G_OBJECT(w), "user_data");
PurpleConnection *gc = purple_conversation_get_gc(conv);
+ gchar *real_who = NULL;
- serv_send_file(gc, who, NULL);
+ g_return_if_fail(gc != NULL);
+
+ prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
+ if (prpl_info && prpl_info->get_cb_real_name)
+ real_who = prpl_info->get_cb_real_name(gc,
+ purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who);
+
+ serv_send_file(gc, real_who ? real_who : who, NULL);
+ g_free(real_who);
}
static void
@@ -1659,23 +1668,34 @@ create_chat_menu(PurpleConversation *con
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
+ else
+ g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
- g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
-
if (prpl_info && prpl_info->send_file)
{
+ gboolean can_receive_file = TRUE;
+
button = pidgin_new_item_from_stock(menu, _("Send File"),
PIDGIN_STOCK_TOOLBAR_SEND_FILE, G_CALLBACK(menu_chat_send_file_cb),
PIDGIN_CONVERSATION(conv), 0, 0, NULL);
- if (gc == NULL || prpl_info == NULL ||
- !(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who)))
- {
- gtk_widget_set_sensitive(button, FALSE);
+ if (gc == NULL || prpl_info == NULL)
+ can_receive_file = FALSE;
+ else {
+ gchar *real_who = NULL;
+ if (prpl_info->get_cb_real_name)
+ real_who = prpl_info->get_cb_real_name(gc,
+ purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), who);
+ if (!(!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, real_who ? real_who : who)))
+ can_receive_file = FALSE;
+ g_free(real_who);
}
- g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
+ if (!can_receive_file)
+ gtk_widget_set_sensitive(button, FALSE);
+ else
+ g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
}
@@ -1688,8 +1708,8 @@ create_chat_menu(PurpleConversation *con
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
-
- g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
+ else
+ g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
}
if (prpl_info && (prpl_info->get_info || prpl_info->get_cb_info)) {
@@ -1698,8 +1718,8 @@ create_chat_menu(PurpleConversation *con
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
-
- g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
+ else
+ g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
}
if (prpl_info && prpl_info->get_cb_away) {
@@ -1708,8 +1728,8 @@ create_chat_menu(PurpleConversation *con
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
-
- g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
+ else
+ g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
}
if (!is_me && prpl_info && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) {
@@ -1722,8 +1742,8 @@ create_chat_menu(PurpleConversation *con
if (gc == NULL)
gtk_widget_set_sensitive(button, FALSE);
-
- g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
+ else
+ g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free);
}
button = pidgin_new_item_from_stock(menu, _("Last said"), GTK_STOCK_INDEX,
More information about the Commits
mailing list