summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-05-20 19:13:28 -0300
committerVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-05-21 13:52:00 -0300
commitbc4044e8ebf4daeadafc1484c7200d189337214d (patch)
treea1a32ac93a5c967eff556703cd1686ee359073b4
parent7c97a48854402a32906ca2aaf2b66438f8ed432a (diff)
downloadobexd-bc4044e8ebf4daeadafc1484c7200d189337214d.tar.gz
Add support for the ADR filter
This includes retrieving information from Tracker about the contact's address.
-rw-r--r--plugins/phonebook-tracker.c56
-rw-r--r--plugins/vcard.c18
-rw-r--r--plugins/vcard.h7
3 files changed, 66 insertions, 15 deletions
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index f28b234..ee8c42d 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -47,14 +47,17 @@
"nco:nameFamily(?c) nco:nameGiven(?c) " \
"nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
"nco:nameHonorificSuffix(?c) nco:emailAddress(?e) " \
- "nco:phoneNumber(?w) " \
+ "nco:phoneNumber(?w) nco:pobox(?p) nco:extendedAddress(?p) " \
+ "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
+ "nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
"?c a nco:PersonContact ; " \
"nco:hasPhoneNumber ?h . " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"}"
@@ -73,7 +76,9 @@
"nco:nameFamily(?c) nco:nameGiven(?c) " \
"nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
"nco:nameHonorificSuffix(?c) nco:emailAddress(?e) " \
- "nco:phoneNumber(?w) " \
+ "nco:phoneNumber(?w) nco:pobox(?p) nco:extendedAddress(?p) " \
+ "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
+ "nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
@@ -84,7 +89,8 @@
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -107,7 +113,9 @@
"nco:nameFamily(?c) nco:nameGiven(?c) " \
"nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
"nco:nameHonorificSuffix(?c) nco:emailAddress(?e) " \
- "nco:phoneNumber(?w) " \
+ "nco:phoneNumber(?w) nco:pobox(?p) nco:extendedAddress(?p) " \
+ "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
+ "nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
@@ -117,7 +125,8 @@
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -139,7 +148,9 @@
"nco:nameFamily(?c) nco:nameGiven(?c) " \
"nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
"nco:nameHonorificSuffix(?c) nco:emailAddress(?e) " \
- "nco:phoneNumber(?w) " \
+ "nco:phoneNumber(?w) nco:pobox(?p) nco:extendedAddress(?p) " \
+ "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
+ "nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
"?call a nmo:Call ; " \
"nmo:to ?c ; " \
@@ -149,7 +160,8 @@
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"} ORDER BY DESC(nmo:sentDate(?call))"
@@ -171,7 +183,9 @@
"nco:nameFamily(?c) nco:nameGiven(?c) " \
"nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
"nco:nameHonorificSuffix(?c) nco:emailAddress(?e) " \
- "nco:phoneNumber(?w) " \
+ "nco:phoneNumber(?w) nco:pobox(?p) nco:extendedAddress(?p) " \
+ "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
+ "nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
"{ " \
"?call a nmo:Call ; " \
@@ -182,7 +196,8 @@
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"} UNION { " \
"?call a nmo:Call ; " \
@@ -193,7 +208,8 @@
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"} } "
@@ -223,7 +239,9 @@
"nco:nameFamily(?c) nco:nameGiven(?c) nco:nameAdditional(?c) " \
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:emailAddress(?e) " \
- "nco:phoneNumber(?w) " \
+ "nco:phoneNumber(?w) nco:pobox(?p) nco:extendedAddress(?p) " \
+ "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
+ "nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
"?c a nco:PersonContact ; " \
"nco:contactUID <%s> ; " \
@@ -231,7 +249,8 @@
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e" \
+ "?c nco:hasEmailAddress ?e . " \
+ "?c nco:hasPostalAddress ?p . " \
"} " \
"}"
@@ -486,6 +505,13 @@ add_entry:
contact->prefix = g_strdup(reply[5]);
contact->suffix = g_strdup(reply[6]);
contact->email = g_strdup(reply[7]);
+ contact->pobox = g_strdup(reply[9]);
+ contact->extended = g_strdup(reply[10]);
+ contact->street = g_strdup(reply[11]);
+ contact->locality = g_strdup(reply[12]);
+ contact->region = g_strdup(reply[13]);
+ contact->postal = g_strdup(reply[14]);
+ contact->country = g_strdup(reply[15]);
number = g_new0(struct phonebook_number, 1);
number->tel = g_strdup(reply[0]);
@@ -650,7 +676,7 @@ int phonebook_pull(const char *name, const struct apparam_field *params,
data->user_data = user_data;
data->cb = cb;
- return query_tracker(query, 9, pull_contacts, data);
+ return query_tracker(query, 16, pull_contacts, data);
}
int phonebook_get_entry(const char *folder, const char *id,
@@ -672,7 +698,7 @@ int phonebook_get_entry(const char *folder, const char *id,
query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id);
- ret = query_tracker(query, 9, pull_contacts, data);
+ ret = query_tracker(query, 16, pull_contacts, data);
g_free(query);
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 0bd2052..6c2445c 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -198,6 +198,14 @@ static void vcard_printf_email(GString *vcards, const char *email)
}
}
+static void vcard_printf_adr(GString *vcards, struct phonebook_contact *contact)
+{
+ vcard_printf(vcards, "ADR:%s;%s;%s;%s;%s;%s;%s", contact->pobox,
+ contact->extended, contact->street,
+ contact->locality, contact->region,
+ contact->postal, contact->country);
+}
+
static void vcard_printf_end(GString *vcards)
{
vcard_printf(vcards, "END:VCARD");
@@ -249,6 +257,9 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
if (filter & FILTER_EMAIL)
vcard_printf_email(vcards, contact->email);
+ if (filter & FILTER_ADR)
+ vcard_printf_adr(vcards, contact);
+
vcard_printf_end(vcards);
}
@@ -275,5 +286,12 @@ void phonebook_contact_free(struct phonebook_contact *contact)
g_free(contact->email);
g_free(contact->prefix);
g_free(contact->suffix);
+ g_free(contact->pobox);
+ g_free(contact->extended);
+ g_free(contact->street);
+ g_free(contact->locality);
+ g_free(contact->region);
+ g_free(contact->postal);
+ g_free(contact->country);
g_free(contact);
}
diff --git a/plugins/vcard.h b/plugins/vcard.h
index 45b82d7..f2b5c09 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -41,6 +41,13 @@ struct phonebook_contact {
char *email;
char *prefix;
char *suffix;
+ char *pobox;
+ char *extended;
+ char *street;
+ char *locality;
+ char *region;
+ char *postal;
+ char *country;
};
void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,