[evolution-mapi] Bug #636854 - Ensure GAL contacts has filled UID
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi] Bug #636854 - Ensure GAL contacts has filled UID
- Date: Thu, 9 Dec 2010 19:04:09 +0000 (UTC)
commit 70b0068bf74fa2f8ee1576913ad538139e074fd8
Author: Milan Crha <mcrha redhat com>
Date: Thu Dec 9 20:03:27 2010 +0100
Bug #636854 - Ensure GAL contacts has filled UID
src/addressbook/e-book-backend-mapi-gal.c | 39 ++++++++++++++++++++++++++--
src/addressbook/e-book-backend-mapi.c | 32 ++++++++++++++++++++---
2 files changed, 63 insertions(+), 8 deletions(-)
---
diff --git a/src/addressbook/e-book-backend-mapi-gal.c b/src/addressbook/e-book-backend-mapi-gal.c
index 87dbf4d..1c930a2 100644
--- a/src/addressbook/e-book-backend-mapi-gal.c
+++ b/src/addressbook/e-book-backend-mapi-gal.c
@@ -33,6 +33,29 @@ struct _EBookBackendMAPIGALPrivate
gint32 unused;
};
+static gchar *
+get_uid_from_row (struct SRow *aRow, uint32_t row_index, mapi_id_t fid)
+{
+ gchar *suid = NULL;
+ const gchar *str;
+
+ g_return_val_if_fail (aRow != NULL, NULL);
+
+ str = exchange_mapi_util_find_row_propval (aRow, PR_EMAIL_ADDRESS_UNICODE);
+ if (str && *str)
+ suid = g_strdup (str);
+
+ if (!suid) {
+ const mapi_id_t *midptr;
+
+ midptr = exchange_mapi_util_find_row_propval (aRow, PR_MID);
+
+ suid = exchange_mapi_util_mapi_ids_to_uid (fid, midptr ? *midptr : row_index);
+ }
+
+ return suid;
+}
+
struct FetchGalData
{
EBookBackendMAPI *ebma;
@@ -59,6 +82,14 @@ fetch_gal_cb (ExchangeMapiConnection *conn, uint32_t row_index, uint32_t n_rows,
return TRUE;
}
+ if (!e_contact_get_const (contact, E_CONTACT_UID)) {
+ gchar *suid;
+
+ suid = get_uid_from_row (aRow, row_index, fgd->fid);
+ e_contact_set (contact, E_CONTACT_UID, suid);
+ g_free (suid);
+ }
+
spropval = get_SPropValue_SRow (aRow, PR_LAST_MODIFICATION_TIME);
if (spropval && get_mapi_SPropValue_date_timeval (&tv, *spropval) == MAPI_E_SUCCESS)
last_modification = &tv;
@@ -77,21 +108,22 @@ struct FetchGalUidsData
{
GCancellable *cancelled;
GHashTable *uids;
+ mapi_id_t fid; /* folder ID of contacts */
};
static gboolean
fetch_gal_uids_cb (ExchangeMapiConnection *conn, uint32_t row_index, uint32_t n_rows, struct SRow *aRow, gpointer data)
{
- const gchar *uid;
+ gchar *uid;
struct FetchGalUidsData *fgud = data;
g_return_val_if_fail (conn != NULL, FALSE);
g_return_val_if_fail (aRow != NULL, FALSE);
g_return_val_if_fail (data != NULL, FALSE);
- uid = exchange_mapi_util_find_row_propval (aRow, PR_EMAIL_ADDRESS_UNICODE);
+ uid = get_uid_from_row (aRow, row_index, fgud->fid);
if (uid)
- g_hash_table_insert (fgud->uids, g_strdup (uid), GINT_TO_POINTER (1));
+ g_hash_table_insert (fgud->uids, uid, GINT_TO_POINTER (1));
return !g_cancellable_is_cancelled (fgud->cancelled);
}
@@ -219,6 +251,7 @@ ebbm_gal_fetch_known_uids (EBookBackendMAPI *ebma, GCancellable *cancelled, GHas
fgud.cancelled = cancelled;
fgud.uids = uids;
+ fgud.fid = exchange_mapi_connection_get_default_folder_id (conn, olFolderContacts, NULL);
exchange_mapi_connection_fetch_gal (conn, NULL,
mapi_book_utils_get_prop_list, GET_UIDS_ONLY,
diff --git a/src/addressbook/e-book-backend-mapi.c b/src/addressbook/e-book-backend-mapi.c
index 758e745..5393a43 100644
--- a/src/addressbook/e-book-backend-mapi.c
+++ b/src/addressbook/e-book-backend-mapi.c
@@ -192,8 +192,9 @@ ebbm_pick_book_view (EBookBackendMAPI *ebma)
return NULL;
}
+ e_iterator_last (iter);
if (e_iterator_is_valid (iter)) {
- /* just always use the first book view */
+ /* just always use the last book view */
EDataBookView *v = (EDataBookView *) e_iterator_get (iter);
if (v)
rv = v;
@@ -205,6 +206,30 @@ ebbm_pick_book_view (EBookBackendMAPI *ebma)
return rv;
}
+static void
+complete_views (EBookBackendMAPI *ebma)
+{
+ EList *views;
+ EIterator *iter;
+
+ g_return_if_fail (ebma != NULL);
+
+ views = e_book_backend_get_book_views (E_BOOK_BACKEND (ebma));
+ if (!views)
+ return;
+
+ for (iter = e_list_get_iterator (views); iter && e_iterator_is_valid (iter); e_iterator_next (iter)) {
+ EDataBookView *book_view = (EDataBookView *) e_iterator_get (iter);
+
+ if (book_view)
+ e_data_book_view_notify_complete (book_view, NULL);
+ }
+
+ if (iter)
+ g_object_unref (iter);
+ g_object_unref (views);
+}
+
struct FetchContactsData
{
glong last_notification;
@@ -298,7 +323,6 @@ ebbm_update_cache_cb (gpointer data)
EBookBackendMAPIPrivate *priv;
EBookBackendMAPIClass *ebmac;
glong last_modification_secs = 0;
- EDataBookView *book_view;
GError *error = NULL;
g_return_val_if_fail (ebma != NULL, NULL);
@@ -376,9 +400,7 @@ ebbm_update_cache_cb (gpointer data)
if (error)
g_error_free (error);
- book_view = ebbm_pick_book_view (ebma);
- if (book_view)
- e_data_book_view_notify_complete (book_view, NULL);
+ complete_views (ebma);
/* indicate the thread is not running */
g_cancellable_cancel (priv->update_cache);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]