[evolution-mapi/gnome-3-4] Bug #677684 - Addressbook doesn't return matched contacts
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-mapi/gnome-3-4] Bug #677684 - Addressbook doesn't return matched contacts
- Date: Wed, 13 Jun 2012 14:19:08 +0000 (UTC)
commit 7c30182d3fab9546e9f3d106e8f2986e0d20e4f9
Author: Milan Crha <mcrha redhat com>
Date: Wed Jun 13 16:18:46 2012 +0200
Bug #677684 - Addressbook doesn't return matched contacts
src/libexchangemapi/e-mapi-book-utils.c | 46 +++++++++++++++++++++++----
src/libexchangemapi/e-mapi-connection.c | 51 +++++++++++++++++++++++++++++--
2 files changed, 87 insertions(+), 10 deletions(-)
---
diff --git a/src/libexchangemapi/e-mapi-book-utils.c b/src/libexchangemapi/e-mapi-book-utils.c
index a013bcb..476d8d4 100644
--- a/src/libexchangemapi/e-mapi-book-utils.c
+++ b/src/libexchangemapi/e-mapi-book-utils.c
@@ -688,8 +688,14 @@ term_eval_and (struct _ESExp *f,
if (argv[ii]->type == ESEXP_RES_INT &&
argv[ii]->value.number >= 0 &&
argv[ii]->value.number < esp->res_parts->len) {
+ struct mapi_SRestriction *subres = g_ptr_array_index (esp->res_parts, argv[ii]->value.number);
+
jj = argv[ii]->value.number;
valid++;
+
+ /* join two consecutive AND-s into one */
+ if (subres->rt == RES_AND)
+ valid += subres->res.resAnd.cRes - 1;
}
}
@@ -711,10 +717,20 @@ term_eval_and (struct _ESExp *f,
argv[ii]->value.number < esp->res_parts->len) {
struct mapi_SRestriction *subres = g_ptr_array_index (esp->res_parts, argv[ii]->value.number);
- res->res.resAnd.res[jj].rt = subres->rt;
- res->res.resAnd.res[jj].res = subres->res;
+ /* join two consecutive AND-s into one */
+ if (subres->rt == RES_AND) {
+ gint xx;
+
+ for (xx = 0; xx < subres->res.resAnd.cRes; xx++, jj++) {
+ res->res.resAnd.res[jj].rt = subres->res.resAnd.res[xx].rt;
+ res->res.resAnd.res[jj].res = subres->res.resAnd.res[xx].res;
+ }
+ } else {
+ res->res.resAnd.res[jj].rt = subres->rt;
+ res->res.resAnd.res[jj].res = subres->res;
- jj++;
+ jj++;
+ }
}
}
@@ -742,8 +758,14 @@ term_eval_or (struct _ESExp *f,
if (argv[ii]->type == ESEXP_RES_INT &&
argv[ii]->value.number >= 0 &&
argv[ii]->value.number < esp->res_parts->len) {
+ struct mapi_SRestriction *subres = g_ptr_array_index (esp->res_parts, argv[ii]->value.number);
+
jj = argv[ii]->value.number;
valid++;
+
+ /* join two consecutive OR-s into one */
+ if (subres->rt == RES_OR)
+ valid += subres->res.resOr.cRes - 1;
}
}
@@ -765,10 +787,20 @@ term_eval_or (struct _ESExp *f,
argv[ii]->value.number < esp->res_parts->len) {
struct mapi_SRestriction *subres = g_ptr_array_index (esp->res_parts, argv[ii]->value.number);
- res->res.resOr.res[jj].rt = subres->rt;
- res->res.resOr.res[jj].res = subres->res;
+ /* join two consecutive OR-s into one */
+ if (subres->rt == RES_OR) {
+ gint xx;
+
+ for (xx = 0; xx < subres->res.resOr.cRes; xx++, jj++) {
+ res->res.resOr.res[jj].rt = subres->res.resOr.res[xx].rt;
+ res->res.resOr.res[jj].res = subres->res.resOr.res[xx].res;
+ }
+ } else {
+ res->res.resOr.res[jj].rt = subres->rt;
+ res->res.resOr.res[jj].res = subres->res;
- jj++;
+ jj++;
+ }
}
}
@@ -984,7 +1016,7 @@ func_eval_field_exists (struct _ESExp *f,
res->res.resOr.res[0].res.resExist.ulPropTag = PidTagPrimarySmtpAddress;
for (ii = 1, jj = 0; emails[jj]; jj++) {
- proptag = get_proptag_from_field_name ("email_1", TRUE);
+ proptag = get_proptag_from_field_name (emails[jj], TRUE);
if (proptag == MAPI_E_RESERVED)
continue;
diff --git a/src/libexchangemapi/e-mapi-connection.c b/src/libexchangemapi/e-mapi-connection.c
index ef27648..b18d8a1 100644
--- a/src/libexchangemapi/e-mapi-connection.c
+++ b/src/libexchangemapi/e-mapi-connection.c
@@ -4394,7 +4394,55 @@ e_mapi_connection_list_gal_objects (EMapiConnection *conn,
}
}
+ loi_data.cb = cb;
+ loi_data.user_data = user_data;
+
ms = nspi_GetMatches (priv->session->nspi->ctx, mem_ctx, propTagArray, use_restriction, (uint32_t) -1, &rows, &pMIds);
+ if (ms == MAPI_E_TOO_COMPLEX && use_restriction && use_restriction->rt == RES_OR) {
+ /* case lazy MS servers which do not want to search sertain properties in OR-s */
+ gint ii;
+ gboolean any_good = FALSE;
+
+ for (ii = 0; ii < use_restriction->res.resOr.cRes; ii++) {
+ talloc_free (pMIds);
+ talloc_free (rows);
+ pMIds = NULL;
+ rows = NULL;
+
+ ms = nspi_GetMatches (priv->session->nspi->ctx, mem_ctx, propTagArray,
+ &use_restriction->res.resOr.lpRes[ii],
+ (uint32_t) -1, &rows, &pMIds);
+
+ if (g_cancellable_set_error_if_cancelled (cancellable, perror)) {
+ ms = MAPI_E_USER_CANCEL;
+ goto cleanup;
+ }
+
+ if (ms == MAPI_E_SUCCESS) {
+ if (!rows)
+ continue;
+
+ ms = foreach_gal_tablerow (conn, mem_ctx, rows, pMIds, propTagArray, list_objects_internal_cb, &loi_data, cancellable, perror);
+ if (ms != MAPI_E_SUCCESS) {
+ make_mapi_error (perror, "foreach_gal_tablerow", ms);
+ goto cleanup;
+ }
+
+ any_good = TRUE;
+ } else if (ms != MAPI_E_NOT_FOUND && ms != MAPI_E_TOO_COMPLEX && ms != MAPI_E_TABLE_TOO_BIG) {
+ break;
+ }
+ }
+
+ /* in case the last check fails, update based on the overall result */
+ if (any_good) {
+ ms = MAPI_E_SUCCESS;
+ goto cleanup;
+ } else {
+ ms = MAPI_E_TOO_COMPLEX;
+ }
+ }
+
if (ms != MAPI_E_SUCCESS || !rows) {
if (ms == MAPI_E_NOT_FOUND || (!rows && ms == MAPI_E_SUCCESS))
ms = MAPI_E_SUCCESS;
@@ -4410,9 +4458,6 @@ e_mapi_connection_list_gal_objects (EMapiConnection *conn,
goto cleanup;
}
- loi_data.cb = cb;
- loi_data.user_data = user_data;
-
ms = foreach_gal_tablerow (conn, mem_ctx, rows, pMIds, propTagArray, list_objects_internal_cb, &loi_data, cancellable, perror);
if (ms != MAPI_E_SUCCESS) {
make_mapi_error (perror, "foreach_gal_tablerow", ms);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]