diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-contact.c | 6 | ||||
-rw-r--r-- | libempathy/empathy-dispatcher.c | 31 | ||||
-rw-r--r-- | libempathy/empathy-idle.c | 31 | ||||
-rw-r--r-- | libempathy/empathy-tp-contact-factory.c | 109 |
4 files changed, 111 insertions, 66 deletions
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 18647e4e2..57c79c2e0 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -748,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); @@ -792,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 @@ -844,7 +871,9 @@ dispatcher_init_connection_if_needed (EmpathyDispatcher *dispatcher, 1, TP_CHANNEL_MEDIA_CAPABILITY_AUDIO | TP_CHANNEL_MEDIA_CAPABILITY_VIDEO | TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_STUN | - TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P, G_MAXUINT); + TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_GTALK_P2P | + TP_CHANNEL_MEDIA_CAPABILITY_NAT_TRAVERSAL_ICE_UDP, + G_MAXUINT); g_ptr_array_add (capabilities, g_value_get_boxed (&cap)); tp_cli_connection_interface_capabilities_call_advertise_capabilities ( diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c index b8c7784d7..64ec37001 100644 --- a/libempathy/empathy-idle.c +++ b/libempathy/empathy-idle.c @@ -410,6 +410,27 @@ empathy_idle_class_init (EmpathyIdleClass *klass) } static void +account_manager_ready_cb (EmpathyAccountManager *account_manager, + GParamSpec *pspec, + EmpathyIdle *idle) +{ + EmpathyIdlePriv *priv; + TpConnectionPresenceType state; + gchar *status, *status_message; + + priv = GET_PRIV (idle); + + state = empathy_account_manager_get_global_presence (priv->manager, + &status, &status_message); + + idle_presence_changed_cb (account_manager, state, status, + status_message, idle); + + g_free (status); + g_free (status_message); +} + +static void empathy_idle_init (EmpathyIdle *idle) { EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle, @@ -419,8 +440,14 @@ empathy_idle_init (EmpathyIdle *idle) priv->is_idle = FALSE; priv->manager = empathy_account_manager_dup_singleton (); - priv->state = empathy_account_manager_get_global_presence (priv->manager, - NULL, &priv->status); + + if (empathy_account_manager_is_ready (priv->manager)) { + priv->state = empathy_account_manager_get_global_presence (priv->manager, + NULL, &priv->status); + } else { + g_signal_connect (priv->manager, "notify::ready", + G_CALLBACK (account_manager_ready_cb), idle); + } g_signal_connect (priv->manager, "global-presence-changed", diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c index c990b92f4..dd6b60586 100644 --- a/libempathy/empathy-tp-contact-factory.c +++ b/libempathy/empathy-tp-contact-factory.c @@ -237,60 +237,51 @@ tp_contact_factory_avatar_maybe_update (EmpathyTpContactFactory *tp_factory, return FALSE; } -typedef struct { - EmpathyTpContactFactory *tp_factory; - GArray *handles; -} TokensData; - static void -tp_contact_factory_avatar_tokens_foreach (gpointer key, - gpointer value, - gpointer user_data) -{ - TokensData *data = user_data; - const gchar *token = value; - guint handle = GPOINTER_TO_UINT (key); - - if (!tp_contact_factory_avatar_maybe_update (data->tp_factory, - handle, token)) { - g_array_append_val (data->handles, handle); - } -} - -static void -tp_contact_factory_got_known_avatar_tokens (EmpathyTpContactFactory *tp_factory, - GHashTable *tokens, - const GError *error) +tp_contact_factory_got_known_avatar_tokens (TpConnection *connection, + GHashTable *tokens, + const GError *error, + gpointer user_data, + GObject *weak_object) { + EmpathyTpContactFactory *tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object); EmpathyTpContactFactoryPriv *priv = GET_PRIV (tp_factory); - TokensData data; + GArray *handles; + GHashTableIter iter; + gpointer key, value; if (error) { DEBUG ("Error: %s", error->message); return; } - data.tp_factory = tp_factory; - data.handles = g_array_new (FALSE, FALSE, sizeof (guint)); - g_hash_table_foreach (tokens, - tp_contact_factory_avatar_tokens_foreach, - &data); + handles = g_array_new (FALSE, FALSE, sizeof (guint)); + + g_hash_table_iter_init (&iter, tokens); + while (g_hash_table_iter_next (&iter, &key, &value)) { + guint handle = GPOINTER_TO_UINT (key); + const gchar *token = value; + + if (!tp_contact_factory_avatar_maybe_update (tp_factory, + handle, token)) { + g_array_append_val (handles, handle); + } + } DEBUG ("Got %d tokens, need to request %d avatars", - g_hash_table_size (tokens), data.handles->len); + g_hash_table_size (tokens), handles->len); /* Request needed avatars */ - if (data.handles->len > 0) { + if (handles->len > 0) { tp_cli_connection_interface_avatars_call_request_avatars (priv->connection, -1, - data.handles, + handles, tp_contact_factory_request_avatars_cb, NULL, NULL, G_OBJECT (tp_factory)); } - g_array_free (data.handles, TRUE); - g_hash_table_destroy (tokens); + g_array_free (handles, TRUE); } static void @@ -360,12 +351,17 @@ tp_contact_factory_update_capabilities (EmpathyTpContactFactory *tp_factory, } static void -tp_contact_factory_got_capabilities (EmpathyTpContactFactory *tp_factory, - GPtrArray *capabilities, - const GError *error) +tp_contact_factory_got_capabilities (TpConnection *connection, + const GPtrArray *capabilities, + const GError *error, + gpointer user_data, + GObject *weak_object) { + EmpathyTpContactFactory *tp_factory; guint i; + tp_factory = EMPATHY_TP_CONTACT_FACTORY (weak_object); + if (error) { DEBUG ("Error: %s", error->message); /* FIXME Should set the capabilities of the contacts for which this request @@ -391,11 +387,7 @@ tp_contact_factory_got_capabilities (EmpathyTpContactFactory *tp_factory, channel_type, generic, specific); - - g_value_array_free (values); } - - g_ptr_array_free (capabilities, TRUE); } #if HAVE_GEOCLUE @@ -740,9 +732,6 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory, TpHandle self_handle; TpHandle handle; GArray handles = {(gchar *) &handle, 1}; - GHashTable *tokens; - GPtrArray *capabilities; - GError *error = NULL; EmpathyCapabilities caps; /* Keep a weak ref to that contact */ @@ -778,23 +767,21 @@ tp_contact_factory_add_contact (EmpathyTpContactFactory *tp_factory, empathy_contact_set_is_user (contact, self_handle == handle); /* FIXME: This should be done by TpContact */ - tp_cli_connection_interface_avatars_run_get_known_avatar_tokens (priv->connection, - -1, - &handles, - &tokens, - &error, - NULL); - tp_contact_factory_got_known_avatar_tokens (tp_factory, tokens, error); - g_clear_error (&error); - - tp_cli_connection_interface_capabilities_run_get_capabilities (priv->connection, - -1, - &handles, - &capabilities, - &error, - NULL); - tp_contact_factory_got_capabilities (tp_factory, capabilities, error); - g_clear_error (&error); + if (tp_proxy_has_interface_by_id (priv->connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_AVATARS)) { + tp_cli_connection_interface_avatars_call_get_known_avatar_tokens ( + priv->connection, -1, &handles, + tp_contact_factory_got_known_avatar_tokens, NULL, NULL, + G_OBJECT (tp_factory)); + } + + if (tp_proxy_has_interface_by_id (priv->connection, + TP_IFACE_QUARK_CONNECTION_INTERFACE_CAPABILITIES)) { + tp_cli_connection_interface_capabilities_call_get_capabilities ( + priv->connection, -1, &handles, + tp_contact_factory_got_capabilities, NULL, NULL, + G_OBJECT (tp_factory)); + } if (tp_proxy_has_interface_by_id (TP_PROXY (priv->connection), TP_IFACE_QUARK_CONNECTION_INTERFACE_LOCATION)) { |