]> git.0d.be Git - empathy.git/commitdiff
Rename empathy_contact_factory_set_name() to _set_alias(). Implements
authorXavier Claessens <xclaesse@gmail.com>
Sat, 3 Nov 2007 23:23:22 +0000 (23:23 +0000)
committerXavier Claessens <xclaesse@src.gnome.org>
Sat, 3 Nov 2007 23:23:22 +0000 (23:23 +0000)
2007-11-03  Xavier Claessens  <xclaesse@gmail.com>

* libempathy-gtk/empathy-contact-widget.c:
* libempathy-gtk/empathy-avatar-chooser.c:
* libempathy-gtk/empathy-avatar-chooser.h:
* python/pyempathy/pyempathy.defs:
* libempathy/empathy-contact-factory.c:
* libempathy/empathy-contact-factory.h: Rename
empathy_contact_factory_set_name() to _set_alias(). Implements
empathy_contact_factory_set_avatar(). Return the mime_type in
empathy_avatar_chooser_get_image_data().

svn path=/trunk/; revision=417

ChangeLog
libempathy-gtk/empathy-avatar-chooser.c
libempathy-gtk/empathy-avatar-chooser.h
libempathy-gtk/empathy-contact-widget.c
libempathy/empathy-contact-factory.c
libempathy/empathy-contact-factory.h
python/pyempathy/pyempathy.defs

index 76ef13d6d7f77b531ffed40fc09688965908aed4..6266c349ad58b485061919ecae2432abff528667 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-11-03  Xavier Claessens  <xclaesse@gmail.com>
+
+       * libempathy-gtk/empathy-contact-widget.c:
+       * libempathy-gtk/empathy-avatar-chooser.c:
+       * libempathy-gtk/empathy-avatar-chooser.h:
+       * python/pyempathy/pyempathy.defs:
+       * libempathy/empathy-contact-factory.c:
+       * libempathy/empathy-contact-factory.h: Rename
+       empathy_contact_factory_set_name() to _set_alias(). Implements
+       empathy_contact_factory_set_avatar(). Return the mime_type in
+       empathy_avatar_chooser_get_image_data().
+
 2007-11-03  Xavier Claessens  <xclaesse@gmail.com>
 
        * libempathy-gtk/empathy-main-window.c: Unref contact returned by
index bc5f07e9b7e66525b51f1d65ca154c14bbb7ec5c..0b3487af79471cc3721e93862af0cf8796ed8446 100644 (file)
@@ -545,8 +545,9 @@ empathy_avatar_chooser_set (EmpathyAvatarChooser *chooser,
 
 void
 empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser  *chooser,
-                                      gchar                **data,
-                                      gsize                 *data_size)
+                                      const gchar          **data,
+                                      gsize                 *data_size,
+                                      const gchar          **mime_type)
 {
        EmpathyAvatarChooserPriv *priv;
 
@@ -560,5 +561,8 @@ empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser  *chooser,
        if (*data_size) {
                *data_size = priv->image_data_size;
        }
+       if (mime_type) {
+               *mime_type = "png";
+       }
 }
 
index b0c08df110202b911a6a953e72852ebd63f252a3..55b804f071c4e047b9e4adf1bb002c727f30be21 100644 (file)
@@ -53,7 +53,8 @@ GtkWidget *empathy_avatar_chooser_new            (void);
 void       empathy_avatar_chooser_set            (EmpathyAvatarChooser *chooser,
                                                  EmpathyAvatar        *avatar);
 void       empathy_avatar_chooser_get_image_data (EmpathyAvatarChooser *chooser,
-                                                 gchar               **data,
-                                                 gsize                *data_size);
+                                                 const gchar         **data,
+                                                 gsize                *data_size,
+                                                 const gchar         **mime_type);
 
 #endif /* __EMPATHY_AVATAR_CHOOSER_H__ */
index 2fa1b3d9f1911a1ac313cbf0b97c694909de4c69..51d17bfb71da589205bd33ae4b90a9f29611414c 100644 (file)
@@ -495,14 +495,20 @@ static void
 contact_widget_avatar_changed_cb (EmpathyAvatarChooser *chooser,
                                  EmpathyContactWidget *information)
 {
-       McAccount *account;
-       gchar     *data;
-       gsize      size;
+       if (information->contact &&
+           empathy_contact_is_user (information->contact)) {
+               McAccount   *account;
+               const gchar *data;
+               gsize        size;
+               const gchar *mime_type;
 
-       account = empathy_contact_get_account (information->contact);
-       empathy_avatar_chooser_get_image_data (EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
-                                              &data, &size);
-       mc_account_set_avatar_from_data (account, data, size, "png");
+               account = empathy_contact_get_account (information->contact);
+               empathy_avatar_chooser_get_image_data (EMPATHY_AVATAR_CHOOSER (information->widget_avatar),
+                                                      &data, &size, &mime_type);
+               empathy_contact_factory_set_avatar (information->factory,
+                                                   account,
+                                                   data, size, mime_type);
+       }
 }
 
 static void
@@ -527,12 +533,12 @@ contact_widget_entry_alias_focus_event_cb (GtkEditable          *editable,
                                           EmpathyContactWidget *information)
 {
        if (information->contact) {
-               const gchar *name;
+               const gchar *alias;
 
-               name = gtk_entry_get_text (GTK_ENTRY (editable));
-               empathy_contact_factory_set_name (information->factory,
+               alias = gtk_entry_get_text (GTK_ENTRY (editable));
+               empathy_contact_factory_set_alias (information->factory,
                                                  information->contact,
-                                                 name);
+                                                 alias);
        }
 
        return FALSE;
index cbbe9b5fb4c0e667bed733965a00461ed3e6d692..2aaa8fad3b60b1136e35e16fccd6c5ae787c7738 100644 (file)
@@ -381,6 +381,23 @@ contact_factory_aliases_changed_cb (DBusGProxy *proxy,
        }
 }
 
+static void
+contact_factory_set_avatar_cb (DBusGProxy *proxy,
+                              gchar      *token,
+                              GError     *error,
+                              gpointer    user_data)
+{
+       ContactFactoryAccountData *account_data = user_data;
+
+       if (error) {
+               empathy_debug (DEBUG_DOMAIN, "Error setting avatar: %s",
+                              error->message);
+       }
+
+       contact_factory_account_data_unref (account_data);
+       g_free (token);
+}
+
 static void
 contact_factory_avatar_retrieved_cb (DBusGProxy *proxy,
                                     guint       handle,
@@ -1189,9 +1206,9 @@ empathy_contact_factory_get_from_handles (EmpathyContactFactory *factory,
 }
 
 void
-empathy_contact_factory_set_name (EmpathyContactFactory *factory,
-                                 EmpathyContact        *contact,
-                                 const gchar           *name)
+empathy_contact_factory_set_alias (EmpathyContactFactory *factory,
+                                  EmpathyContact        *contact,
+                                  const gchar           *alias)
 {
        ContactFactoryAccountData *account_data;
        McAccount                 *account;
@@ -1212,7 +1229,7 @@ empathy_contact_factory_set_name (EmpathyContactFactory *factory,
 
        empathy_debug (DEBUG_DOMAIN, "Setting alias for contact %s (%d) to %s",
                       empathy_contact_get_id (contact),
-                      handle, name);
+                      handle, alias);
 
        new_alias = g_hash_table_new_full (g_direct_hash,
                                           g_direct_equal,
@@ -1221,7 +1238,7 @@ empathy_contact_factory_set_name (EmpathyContactFactory *factory,
 
        g_hash_table_insert (new_alias,
                             GUINT_TO_POINTER (handle),
-                            g_strdup (name));
+                            g_strdup (alias));
 
        tp_conn_iface_aliasing_set_aliases_async (account_data->aliasing_iface,
                                                  new_alias,
@@ -1231,6 +1248,37 @@ empathy_contact_factory_set_name (EmpathyContactFactory *factory,
        g_hash_table_destroy (new_alias);
 }
 
+void
+empathy_contact_factory_set_avatar (EmpathyContactFactory *factory,
+                                   McAccount             *account,
+                                   const gchar           *data,
+                                   gsize                  size,
+                                   const gchar           *mime_type)
+{
+       ContactFactoryAccountData *account_data;
+       GArray                     avatar;
+
+       g_return_if_fail (EMPATHY_IS_CONTACT_FACTORY (factory));
+       g_return_if_fail (MC_IS_ACCOUNT (account));
+
+       account_data = contact_factory_account_data_get (factory, account);
+
+       if (!account_data->avatars_iface) {
+               return;
+       }
+
+       empathy_debug (DEBUG_DOMAIN, "Setting avatar on account %s",
+                      mc_account_get_unique_name (account));
+
+       avatar.data = (gchar*) data;
+       avatar.len = size;
+       tp_conn_iface_avatars_set_avatar_async (account_data->avatars_iface,
+                                               &avatar,
+                                               mime_type,
+                                               contact_factory_set_avatar_cb,
+                                               contact_factory_account_data_ref (account_data));
+}
+
 static void
 contact_factory_finalize (GObject *object)
 {
index bed5587813d8856a1f07bd7a3f5c5b34e09e2fab..24aabc7720da857c4980cb1f4dca44003456bec0 100644 (file)
@@ -62,9 +62,14 @@ EmpathyContact *       empathy_contact_factory_get_from_handle  (EmpathyContactF
 GList *                empathy_contact_factory_get_from_handles (EmpathyContactFactory *factory,
                                                                 McAccount             *account,
                                                                 GArray                *handles);
-void                   empathy_contact_factory_set_name         (EmpathyContactFactory *factory,
+void                   empathy_contact_factory_set_alias        (EmpathyContactFactory *factory,
                                                                 EmpathyContact        *contact,
-                                                                const gchar           *name);
+                                                                const gchar           *alias);
+void                   empathy_contact_factory_set_avatar       (EmpathyContactFactory *factory,
+                                                                McAccount             *account,
+                                                                const gchar           *data,
+                                                                gsize                  size,
+                                                                const gchar           *mime_type);
 
 G_END_DECLS
 
index 97f7b6ac9bd39b337ae2bb253bfc1a892758d62e..697fe23df27b865d59b5b0a1fbbcb0aff53b2fb1 100644 (file)
   )
 )
 
-(define-method set_name
+(define-method set_alias
   (of-object "EmpathyContactFactory")
-  (c-name "empathy_contact_factory_set_name")
+  (c-name "empathy_contact_factory_set_alias")
   (return-type "none")
   (parameters
     '("EmpathyContact*" "contact")