]> git.0d.be Git - empathy.git/blobdiff - libempathy/empathy-client-factory.c
EmpathySmileyManager: use the proper Unicode characters
[empathy.git] / libempathy / empathy-client-factory.c
index 2a85594410daeae3c557fceda61484c3e4410193..b57ea06524b00b1e2061a5dd68803464fcd1dfbd 100644 (file)
  * Authors: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
  */
 
-#include <config.h>
-
+#include "config.h"
 #include "empathy-client-factory.h"
 
+#include <tp-account-widgets/tpaw-utils.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
+
 #include "empathy-tp-chat.h"
 #include "empathy-utils.h"
 
@@ -45,12 +47,8 @@ empathy_client_factory_create_channel (TpSimpleClientFactory *factory,
 
   if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
     {
-      TpAccount *account;
-
-      account = tp_connection_get_account (conn);
-
       return TP_CHANNEL (empathy_tp_chat_new (
-            TP_SIMPLE_CLIENT_FACTORY (factory), account, conn, path,
+            TP_SIMPLE_CLIENT_FACTORY (factory), conn, path,
             properties));
     }
 
@@ -66,9 +64,12 @@ empathy_client_factory_dup_channel_features (TpSimpleClientFactory *factory,
 
   features = chainup->dup_channel_features (factory, channel);
 
+  feature = TP_CHANNEL_FEATURE_CONTACTS;
+  g_array_append_val (features, feature);
+
   if (EMPATHY_IS_TP_CHAT (channel))
     {
-      feature = TP_CHANNEL_FEATURE_CHAT_STATES;
+      feature = TP_TEXT_CHANNEL_FEATURE_CHAT_STATES;
       g_array_append_val (features, feature);
 
       feature = EMPATHY_TP_CHAT_FEATURE_READY;
@@ -93,6 +94,9 @@ empathy_client_factory_dup_account_features (TpSimpleClientFactory *factory,
   feature = TP_ACCOUNT_FEATURE_ADDRESSING;
   g_array_append_val (features, feature);
 
+  feature = TP_ACCOUNT_FEATURE_STORAGE;
+  g_array_append_val (features, feature);
+
   return features;
 }
 
@@ -144,6 +148,8 @@ empathy_client_factory_dup_contact_features (TpSimpleClientFactory *factory,
        * is already in the contact list. This feature is pretty cheap to
        * prepare as it doesn't prepare the full roster. */
       TP_CONTACT_FEATURE_SUBSCRIPTION_STATES,
+      TP_CONTACT_FEATURE_CONTACT_GROUPS,
+      TP_CONTACT_FEATURE_CLIENT_TYPES,
   };
 
   features = chainup->dup_contact_features (factory, connection);
@@ -210,3 +216,67 @@ empathy_client_factory_dup (void)
 
   return singleton;
 }
+
+static void
+dup_contact_cb (GObject *source,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  GSimpleAsyncResult *my_result = user_data;
+  GError *error = NULL;
+  TpContact *contact;
+
+  contact = tp_connection_dup_contact_by_id_finish (TP_CONNECTION (source),
+      result, &error);
+
+  if (contact == NULL)
+    {
+      g_simple_async_result_take_error (my_result, error);
+    }
+  else
+    {
+      g_simple_async_result_set_op_res_gpointer (my_result,
+          empathy_contact_dup_from_tp_contact (contact), g_object_unref);
+
+      g_object_unref (contact);
+    }
+
+  g_simple_async_result_complete (my_result);
+  g_object_unref (my_result);
+}
+
+void
+empathy_client_factory_dup_contact_by_id_async (
+    EmpathyClientFactory *self,
+    TpConnection *connection,
+    const gchar *id,
+    GAsyncReadyCallback callback,
+    gpointer user_data)
+{
+  GSimpleAsyncResult *result;
+  GArray *features;
+
+  g_return_if_fail (EMPATHY_IS_CLIENT_FACTORY (self));
+  g_return_if_fail (id != NULL);
+
+  result = g_simple_async_result_new ((GObject *) self, callback, user_data,
+      empathy_client_factory_dup_contact_by_id_async);
+
+  features = empathy_client_factory_dup_contact_features (
+      TP_SIMPLE_CLIENT_FACTORY (self), connection);
+
+  tp_connection_dup_contact_by_id_async (connection, id, features->len,
+      (TpContactFeature * ) features->data, dup_contact_cb, result);
+
+  g_array_unref (features);
+}
+
+EmpathyContact *
+empathy_client_factory_dup_contact_by_id_finish (
+    EmpathyClientFactory *self,
+    GAsyncResult *result,
+    GError **error)
+{
+  tpaw_implement_finish_return_copy_pointer (self,
+      empathy_client_factory_dup_contact_by_id_async, g_object_ref);
+}