GNOME Bugzilla – Bug 309276
"is" sexp queries not working with E_CONTACT_UID
Last modified: 2005-07-13 13:22:58 UTC
Please describe the problem: Here's a small program that illustrates the problem (at least on my machine); note that the "is uid blah" query returns zero contacts but when I get all contacts, the UID I'm looking for definitely exists: ====================================== [tom at tom evtest]$ cat evtest.c ; echo "OUTPUT" ; ./evtest #include <stdio.h> #include <libebook/e-book.h> #include <libebook/e-contact.h> #include <libecal/e-cal.h> int main(int argc, char* argv[]) { GError* error = 0; GList* results, *l = NULL; EBook* book = e_book_new_default_addressbook(&error); e_book_open(book, TRUE, &error); char* uid = "pas-id-42B70B7100000001"; EBookQuery* query = e_book_query_from_string(g_strdup_printf ("(is \"id\" \"%s\")", uid)); e_book_get_contacts(book, query, &results, &error); printf("Number of contacts with uid %s is %d\n", uid, g_list_length(results)); query = e_book_query_any_field_contains(""); results = NULL; e_book_get_contacts(book, query, &results, &error); for (l = results; l; l = l->next) { EContact* ev_contact = E_CONTACT(l->data); if (!g_strcasecmp(e_contact_get(ev_contact, E_CONTACT_UID), uid)) { printf("Found a contact with uid %s, last name is %s\n", uid, (char*)e_contact_get(ev_contact, E_CONTACT_GIVEN_NAME)); } } e_book_query_unref(query); return 0; } OUTPUT Number of contacts with uid pas-id-42B70B7100000001 is 0 Found a contact with uid pas-id-42B70B7100000001, last name is jadmin at jabber.org ====================================== Steps to reproduce: 1. Please see the program in the description field. 2. 3. Actual results: Please see the program in the description field. Expected results: Please see the program in the description field. Does this happen every time? Yes Other information: Nope.
This is a bug which needs to be fixed. But you can use e_book_get_contact() to read the contact when you are having the contact id, instead of forming the querying.
Fix committed to cvs head, along with fix for #242165
Great, thanks very much Sushma! tom