diff options
author | Chris Toshok <toshok@src.gnome.org> | 2000-04-12 00:04:48 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2000-04-12 00:04:48 +0800 |
commit | b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba (patch) | |
tree | 31d8869c82c54f495b40d234ad1cd34187145e1d | |
parent | 562afc46d5e83393978d94c80025aa49557d8f26 (diff) | |
download | gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar.gz gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar.zst gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.zip |
new function for searching all email addresses of a contact.
* addressbook/backend/pas/pas-backend-file.c
(compare_email): new function for searching all email addresses of
a contact.
(compare_phone): new function for searching all phone numbers of a
contact.
(compare_address): new function for searching all addresses of a
contact (unimplemented as yet).
(entry_compare): add support for searching the list items "email",
"phone" and "address".
svn path=/trunk/; revision=2393
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 88 |
2 files changed, 95 insertions, 7 deletions
@@ -10,9 +10,19 @@ function. (func_is): new function, implementing "is" for searches. (endswith_helper): new function. - (func_endswith) new function, implementing "endswith" for searches. + (func_endswith) new function, implementing "endswith" for + searches. (beginswith_helper): new function. - (func_beginswith): new function, implementing "beginswith" for searches. + (func_beginswith): new function, implementing "beginswith" for + searches. + (compare_email): new function for searching all email addresses of + a contact. + (compare_phone): new function for searching all phone numbers of a + contact. + (compare_address): new function for searching all addresses of a + contact (unimplemented as yet). + (entry_compare): add support for searching the list items "email", + "phone" and "address". 2000-04-11 Christopher James Lahey <clahey@helixcode.com> diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index fcd61f6937..dda5faad94 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -154,7 +154,7 @@ pas_backend_file_create_unique_id (char *vcard) } static char * -get_e_card_prop (ECard *ecard, const char *propname) +get_e_card_string_prop (ECard *ecard, const char *propname) { char *prop = NULL; @@ -171,6 +171,72 @@ get_e_card_prop (ECard *ecard, const char *propname) return prop; } +static gboolean +compare_email (ECard *ecard, const char *str, + char *(*compare)(const char*, const char*)) +{ + ECardList *prop_list; + ECardIterator *iter; + gboolean truth = FALSE; + + gtk_object_get(GTK_OBJECT(ecard), + "email", &prop_list, NULL); + + iter = e_card_list_get_iterator(prop_list); + + while (e_card_iterator_is_valid(iter)) { + + if (compare((char*)e_card_iterator_get(iter), str)) { + truth = TRUE; + break; + } + else { + e_card_iterator_next(iter); + } + } + + gtk_object_unref (GTK_OBJECT(iter)); + + return truth; +} + +static gboolean +compare_phone (ECard *ecard, const char *str, + char *(*compare)(const char*, const char*)) +{ + ECardList *prop_list; + ECardIterator *iter; + gboolean truth = FALSE; + + gtk_object_get(GTK_OBJECT(ecard), + "phone", &prop_list, NULL); + + iter = e_card_list_get_iterator(prop_list); + + while (e_card_iterator_is_valid(iter)) { + ECardPhone *phone = (ECardPhone*)e_card_iterator_get(iter); + if (compare(phone->number, str)) { + truth = TRUE; + break; + } + else { + e_card_iterator_next(iter); + } + } + + gtk_object_unref (GTK_OBJECT(iter)); + + return truth; +} + +static gboolean +compare_address (ECard *ecard, const char *str, + char *(*compare)(const char*, const char*)) +{ + g_warning("address searching not implemented\n"); + return FALSE; +} + static ESExpResult * entry_compare(PASBackendFileSearchContext *ctx, struct _ESExp *f, int argc, struct _ESExpResult **argv, @@ -180,19 +246,31 @@ entry_compare(PASBackendFileSearchContext *ctx, struct _ESExp *f, int truth = FALSE; if (argc>1 - && argv[0]->type == ESEXP_RES_STRING) { + && argv[0]->type == ESEXP_RES_STRING + && argv[1]->type == ESEXP_RES_STRING) { char *propname, *prop = NULL; propname = argv[0]->value.string; - prop = get_e_card_prop (ctx->ecard, propname); + prop = get_e_card_string_prop (ctx->ecard, propname); if (prop) { - if (argv[1]->type == ESEXP_RES_STRING - && compare(prop, argv[1]->value.string)) { + if (compare(prop, argv[1]->value.string)) { truth = TRUE; } } + else{ + if (!strcmp(propname, "email")) { + truth = compare_email (ctx->ecard, argv[1]->value.string, compare); + } + else if (!strcasecmp(propname, "phone")) { + truth = compare_phone (ctx->ecard, argv[1]->value.string, compare); + } + else if (!strcasecmp(propname, "address")) { + truth = compare_address (ctx->ecard, argv[1]->value.string, compare); + } + } + } r = e_sexp_result_new(ESEXP_RES_BOOL); r->value.bool = truth; |