aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.c8
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.h5
-rw-r--r--libempathy-gtk/empathy-contact-widget.c28
-rw-r--r--libempathy/empathy-contact-factory.c58
-rw-r--r--libempathy/empathy-contact-factory.h9
-rw-r--r--python/pyempathy/pyempathy.defs4
7 files changed, 100 insertions, 24 deletions
diff --git a/ChangeLog b/ChangeLog
index 76ef13d6d..6266c349a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
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
empathy_contact_factory_get_user().
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c
index bc5f07e9b..0b3487af7 100644
--- a/libempathy-gtk/empathy-avatar-chooser.c
+++ b/libempathy-gtk/empathy-avatar-chooser.c
@@ -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";
+ }
}
diff --git a/libempathy-gtk/empathy-avatar-chooser.h b/libempathy-gtk/empathy-avatar-chooser.h
index b0c08df11..55b804f07 100644
--- a/libempathy-gtk/empathy-avatar-chooser.h
+++ b/libempathy-gtk/empathy-avatar-chooser.h
@@ -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__ */
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 2fa1b3d9f..51d17bfb7 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -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;
diff --git a/libempathy/empathy-contact-factory.c b/libempathy/empathy-contact-factory.c
index cbbe9b5fb..2aaa8fad3 100644
--- a/libempathy/empathy-contact-factory.c
+++ b/libempathy/empathy-contact-factory.c
@@ -382,6 +382,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,
gchar *token,
@@ -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)
{
diff --git a/libempathy/empathy-contact-factory.h b/libempathy/empathy-contact-factory.h
index bed558781..24aabc772 100644
--- a/libempathy/empathy-contact-factory.h
+++ b/libempathy/empathy-contact-factory.h
@@ -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
diff --git a/python/pyempathy/pyempathy.defs b/python/pyempathy/pyempathy.defs
index 97f7b6ac9..697fe23df 100644
--- a/python/pyempathy/pyempathy.defs
+++ b/python/pyempathy/pyempathy.defs
@@ -547,9 +547,9 @@
)
)
-(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")