[evolution-ews] Contact photos from offline GAL not shown
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews] Contact photos from offline GAL not shown
- Date: Mon, 25 Jan 2016 14:07:03 +0000 (UTC)
commit a36e18ae1b98f23c66290b315b26e3673d15570c
Author: Milan Crha <mcrha redhat com>
Date: Mon Jan 25 15:06:09 2016 +0100
Contact photos from offline GAL not shown
src/addressbook/ews-oab-decoder.c | 18 +++++++++++-------
1 files changed, 11 insertions(+), 7 deletions(-)
---
diff --git a/src/addressbook/ews-oab-decoder.c b/src/addressbook/ews-oab-decoder.c
index 9d61505..ff11eb2 100644
--- a/src/addressbook/ews-oab-decoder.c
+++ b/src/addressbook/ews-oab-decoder.c
@@ -179,11 +179,16 @@ ews_populate_photo (EContact *contact,
{
EwsOabDecoder *eod = EWS_OAB_DECODER (user_data);
EwsOabDecoderPrivate *priv = GET_PRIVATE (eod);
- const gchar *val = (gchar *) value, *at;
+ const gchar *at;
+ GBytes *bytes = value;
EContactPhoto *photo = g_new0 (EContactPhoto, 1);
gchar *email = e_contact_get (contact, E_CONTACT_EMAIL_1);
gchar *filename = NULL, *pic_name = NULL, *name;
gboolean success = TRUE;
+ GError *local_error = NULL;
+
+ if (!bytes)
+ return;
/* Rename the binary file to name.jpg */
at = strchr (email, '@');
@@ -192,20 +197,19 @@ ews_populate_photo (EContact *contact,
pic_name = g_strconcat (name, ".jpg", NULL);
filename = g_build_filename (priv->cache_dir, pic_name, NULL);
- if (g_file_test (filename, G_FILE_TEST_EXISTS))
- g_unlink (val);
- else {
- if (g_rename (val, filename))
- success = FALSE;
- }
+ success = g_file_set_contents (filename, g_bytes_get_data (bytes, NULL), g_bytes_get_size (bytes),
&local_error);
if (success) {
photo->type = E_CONTACT_PHOTO_TYPE_URI;
photo->data.uri = filename;
e_contact_set (contact, field, (gpointer) photo);
+ } else {
+ g_warning ("%s: Failed to store '%s': %s", G_STRFUNC, filename, local_error ?
local_error->message : "Unknown error");
}
+ g_clear_error (&local_error);
+
g_free (photo);
g_free (email);
g_free (name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]