evolution-data-server r8432 - in trunk/addressbook: . libedata-book tests/ebook



Author: msuman
Date: Mon Jan 28 05:09:59 2008
New Revision: 8432
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8432&view=rev

Log:
Patch from Milan Crha  <mcrha redhat com>  ** Fix for bug #496081 (Compare/check exact field, if requested - while searching addressbook entries)

Modified:
   trunk/addressbook/ChangeLog
   trunk/addressbook/libedata-book/e-book-backend-sexp.c
   trunk/addressbook/tests/ebook/test-changes.c

Modified: trunk/addressbook/libedata-book/e-book-backend-sexp.c
==============================================================================
--- trunk/addressbook/libedata-book/e-book-backend-sexp.c	(original)
+++ trunk/addressbook/libedata-book/e-book-backend-sexp.c	Mon Jan 28 05:09:59 2008
@@ -292,6 +292,7 @@
 		struct prop_info *info = NULL;
 		int i;
 		gboolean any_field;
+		gboolean saw_any = FALSE;
 
 		propname = argv[0]->value.string;
 
@@ -299,6 +300,7 @@
 		for (i = 0; i < G_N_ELEMENTS (prop_info_table); i ++) {
 			if (any_field
 			    || !strcmp (prop_info_table[i].query_prop, propname)) {
+				saw_any = TRUE;
 				info = &prop_info_table[i];
 
 				if (any_field && info->field_id == E_CONTACT_UID) {
@@ -335,6 +337,24 @@
 			}
 		}
 
+		if (!saw_any) {
+			/* propname didn't match to any of our known "special" properties,
+			   so try to find if it isn't a real field and if so, then compare
+			   against value in this field only */
+			EContactField fid = e_contact_field_id (propname);
+
+			if (fid >= E_CONTACT_FIELD_FIRST && fid < E_CONTACT_FIELD_LAST) {
+				const char *prop = e_contact_get_const (ctx->contact, fid);
+
+				if (prop && compare (prop, argv[1]->value.string)) {
+					truth = TRUE;
+				}
+
+				if ((!prop) && compare ("", argv[1]->value.string)) {
+					truth = TRUE;
+				}
+			}
+		}
 	}
 	r = e_sexp_result_new(f, ESEXP_RES_BOOL);
 	r->value.bool = truth;
@@ -417,11 +437,13 @@
 		char *propname;
 		struct prop_info *info = NULL;
 		int i;
+		gboolean saw_any = FALSE;
 
 		propname = argv[0]->value.string;
 
 		for (i = 0; i < G_N_ELEMENTS (prop_info_table); i ++) {
 			if (!strcmp (prop_info_table[i].query_prop, propname)) {
+				saw_any = TRUE;
 				info = &prop_info_table[i];
 
 				if (info->prop_type == PROP_TYPE_NORMAL) {
@@ -443,6 +465,19 @@
 			}
 		}
 
+		if (!saw_any) {
+			/* propname didn't match to any of our known "special" properties,
+			   so try to find if it isn't a real field and if so, then check
+			   against value in this field only */
+			EContactField fid = e_contact_field_id (propname);
+
+			if (fid >= E_CONTACT_FIELD_FIRST && fid < E_CONTACT_FIELD_LAST) {
+				const char *prop = e_contact_get_const (ctx->contact, fid);
+
+				if (prop && *prop)
+					truth = TRUE;
+			}
+		}
 	}
 	r = e_sexp_result_new(f, ESEXP_RES_BOOL);
 	r->value.bool = truth;

Modified: trunk/addressbook/tests/ebook/test-changes.c
==============================================================================
--- trunk/addressbook/tests/ebook/test-changes.c	(original)
+++ trunk/addressbook/tests/ebook/test-changes.c	Mon Jan 28 05:09:59 2008
@@ -26,7 +26,7 @@
 	file_template = g_build_filename (g_get_tmp_dir (),
 					  "change-test-XXXXXX",
 					  NULL);
-	mktemp (file_template);
+	mkstemp (file_template);
 
 	uri = g_filename_to_uri (file_template, NULL, &error);
 	if (!uri) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]