aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/backend/pas
diff options
context:
space:
mode:
authorChris Toshok <toshok@src.gnome.org>2000-04-12 00:04:48 +0800
committerChris Toshok <toshok@src.gnome.org>2000-04-12 00:04:48 +0800
commitb4cea26ae4136cd260aa232dfc2ac79ef54fb0ba (patch)
tree31d8869c82c54f495b40d234ad1cd34187145e1d /addressbook/backend/pas
parent562afc46d5e83393978d94c80025aa49557d8f26 (diff)
downloadgsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar
gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar.gz
gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar.bz2
gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar.lz
gsoc2013-evolution-b4cea26ae4136cd260aa232dfc2ac79ef54fb0ba.tar.xz
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
Diffstat (limited to 'addressbook/backend/pas')
-rw-r--r--addressbook/backend/pas/pas-backend-file.c88
1 files changed, 83 insertions, 5 deletions
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;