diff options
author | Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> | 2009-09-19 19:39:28 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimo.cecchi@collabora.co.uk> | 2009-09-19 19:39:28 +0800 |
commit | a21225db9d8d723b7360d8946fa0a395ef994a1e (patch) | |
tree | bb320a98e8fc9210dfd2e9c678792586123ba1ed | |
parent | 1fae96ab7f912462fb7dea9960d3344e2eb9f5f3 (diff) | |
parent | 6d777eefedb4d7f4666840da0df312f2cce449e5 (diff) | |
download | gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.tar gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.tar.gz gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.tar.bz2 gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.tar.lz gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.tar.xz gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.tar.zst gsoc2013-empathy-a21225db9d8d723b7360d8946fa0a395ef994a1e.zip |
Merge branch 'gnome-2-28-candidate' into gnome-2-28
-rw-r--r-- | libempathy-gtk/empathy-chat.c | 7 | ||||
-rw-r--r-- | libempathy/empathy-contact.c | 6 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.c | 93 |
3 files changed, 88 insertions, 18 deletions
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index c08b49c3f..d62537110 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -1957,9 +1957,16 @@ empathy_chat_paste (EmpathyChat *chat) { GtkTextBuffer *buffer; GtkClipboard *clipboard; + EmpathyChatPriv *priv; g_return_if_fail (EMPATHY_IS_CHAT (chat)); + priv = GET_PRIV (chat); + + if (priv->tp_chat == NULL || + !GTK_WIDGET_IS_SENSITIVE (chat->input_text_view)) + return; + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (chat->input_text_view)); clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); diff --git a/libempathy/empathy-contact.c b/libempathy/empathy-contact.c index 0a097bb4d..4537d4043 100644 --- a/libempathy/empathy-contact.c +++ b/libempathy/empathy-contact.c @@ -952,8 +952,10 @@ empathy_contact_load_avatar_cache (EmpathyContact *contact, empathy_contact_set_avatar (contact, avatar); empathy_avatar_unref (avatar); } - - g_free (filename); + else + { + g_free (filename); + } return data != NULL; } diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index ef9d180b6..26d032fab 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -126,6 +126,7 @@ typedef struct EmpathyDispatcher *dispatcher; EmpathyDispatchOperation *operation; TpConnection *connection; + gboolean should_ensure; gchar *channel_type; guint handle_type; guint handle; @@ -180,7 +181,8 @@ typedef struct } FindChannelRequest; static void -empathy_dispatcher_call_create_channel (EmpathyDispatcher *dispatcher, +empathy_dispatcher_call_create_or_ensure_channel ( + EmpathyDispatcher *dispatcher, DispatcherRequestData *request_data); static DispatchData * @@ -221,6 +223,8 @@ new_dispatcher_request_data (EmpathyDispatcher *dispatcher, result->dispatcher = g_object_ref (dispatcher); result->connection = connection; + result->should_ensure = FALSE; + result->channel_type = g_strdup (channel_type); result->handle_type = handle_type; result->handle = handle; @@ -744,6 +748,7 @@ dispatcher_connection_got_all (TpProxy *proxy, EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (object); EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher); GPtrArray *requestable_channels; + GPtrArray *existing_channels; if (error) { DEBUG ("Error: %s", error->message); @@ -788,6 +793,32 @@ dispatcher_connection_got_all (TpProxy *proxy, g_hash_table_remove (priv->outstanding_classes_requests, proxy); } + + existing_channels = tp_asv_get_boxed (properties, + "Channels", TP_ARRAY_TYPE_CHANNEL_DETAILS_LIST); + + if (existing_channels != NULL) + { + int idx; + + for (idx = 0; idx < existing_channels->len; idx++) + { + GValueArray *values = g_ptr_array_index (existing_channels, idx); + const gchar *object_path; + GHashTable *properties; + + object_path = g_value_get_boxed (g_value_array_get_nth (values, 0)); + properties = g_value_get_boxed (g_value_array_get_nth (values, 1)); + + if (tp_strdiff (tp_asv_get_string (properties, + TP_IFACE_CHANNEL ".ChannelType"), + TP_IFACE_CHANNEL_TYPE_TEXT)) + continue; + + dispatcher_connection_new_channel_with_properties (dispatcher, + TP_CONNECTION (proxy), object_path, properties); + } + } } static void @@ -1091,10 +1122,12 @@ empathy_dispatcher_init (EmpathyDispatcher *dispatcher) priv->channels = NULL; - connections = empathy_account_manager_dup_connections (priv->account_manager); + connections = empathy_account_manager_dup_connections ( + priv->account_manager); for (l = connections; l; l = l->next) { - dispatcher_new_connection_cb (priv->account_manager, l->data, dispatcher); + dispatcher_new_connection_cb (priv->account_manager, l->data, + dispatcher); g_object_unref (l->data); } g_list_free (connections); @@ -1154,10 +1187,10 @@ dispatcher_request_failed (EmpathyDispatcher *dispatcher, static void dispatcher_connection_new_requested_channel (EmpathyDispatcher *dispatcher, - DispatcherRequestData *request_data, - const gchar *object_path, - GHashTable *properties, - const GError *error) + DispatcherRequestData *request_data, + const gchar *object_path, + GHashTable *properties, + const GError *error) { EmpathyDispatcherPriv *priv = GET_PRIV (dispatcher); EmpathyDispatchOperation *operation = NULL; @@ -1282,8 +1315,8 @@ dispatcher_request_channel (DispatcherRequestData *request_data) tp_asv_set_uint32 (request_data->request, TP_IFACE_CHANNEL ".TargetHandle", request_data->handle); - empathy_dispatcher_call_create_channel (request_data->dispatcher, - request_data); + empathy_dispatcher_call_create_or_ensure_channel ( + request_data->dispatcher, request_data); } else { @@ -1316,9 +1349,10 @@ empathy_dispatcher_chat_with_contact (EmpathyContact *contact, connection_data = g_hash_table_lookup (priv->connections, connection); /* The contact handle might not be known yet */ - request_data = new_dispatcher_request_data (dispatcher, connection, + request_data = new_dispatcher_request_data (dispatcher, connection, TP_IFACE_CHANNEL_TYPE_TEXT, TP_HANDLE_TYPE_CONTACT, empathy_contact_get_handle (contact), NULL, contact, callback, user_data); + request_data->should_ensure = TRUE; connection_data->outstanding_requests = g_list_prepend (connection_data->outstanding_requests, request_data); @@ -1469,13 +1503,40 @@ dispatcher_create_channel_cb (TpConnection *connect, } static void -empathy_dispatcher_call_create_channel (EmpathyDispatcher *dispatcher, +dispatcher_ensure_channel_cb (TpConnection *connect, + gboolean is_ours, + const gchar *object_path, + GHashTable *properties, + const GError *error, + gpointer user_data, + GObject *weak_object) +{ + EmpathyDispatcher *dispatcher = EMPATHY_DISPATCHER (weak_object); + DispatcherRequestData *request_data = (DispatcherRequestData *) user_data; + + dispatcher_connection_new_requested_channel (dispatcher, + request_data, object_path, properties, error); +} + +static void +empathy_dispatcher_call_create_or_ensure_channel ( + EmpathyDispatcher *dispatcher, DispatcherRequestData *request_data) { - tp_cli_connection_interface_requests_call_create_channel ( - request_data->connection, -1, - request_data->request, dispatcher_create_channel_cb, request_data, NULL, - G_OBJECT (request_data->dispatcher)); + if (request_data->should_ensure) + { + tp_cli_connection_interface_requests_call_ensure_channel ( + request_data->connection, -1, + request_data->request, dispatcher_ensure_channel_cb, + request_data, NULL, G_OBJECT (request_data->dispatcher)); + } + else + { + tp_cli_connection_interface_requests_call_create_channel ( + request_data->connection, -1, + request_data->request, dispatcher_create_channel_cb, + request_data, NULL, G_OBJECT (request_data->dispatcher)); + } } void @@ -1516,7 +1577,7 @@ empathy_dispatcher_create_channel (EmpathyDispatcher *dispatcher, connection_data->outstanding_requests = g_list_prepend (connection_data->outstanding_requests, request_data); - empathy_dispatcher_call_create_channel (dispatcher, request_data); + empathy_dispatcher_call_create_or_ensure_channel (dispatcher, request_data); } static gboolean |