2010-10-21 12:26:39

by Radoslaw Jablonski

[permalink] [raw]
Subject: [PATCH] Fix history listing queries in phonebook-tracker

Now we are able to display contact's name in vcard-listing when
contact has entry in phonebook available.
---
plugins/phonebook-tracker.c | 140 ++++++++++++++++++++++++++++++++++++-------
1 files changed, 118 insertions(+), 22 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index f0e00b8..1c579d1 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -172,13 +172,34 @@
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"WHERE { " \
+ "{" \
+ "?c a nco:Contact . " \
+ "?c nco:hasPhoneNumber ?h . " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
"nmo:isSent false ; " \
"nmo:isAnswered false ." \
- "?c a nco:Contact . " \
- "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
- "} ORDER BY DESC(nmo:receivedDate(?call))"
+ "}UNION{" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:from ?x ; " \
+ "nmo:isSent false ; " \
+ "nmo:isAnswered false ." \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasPhoneNumber ?h . " \
+ "} UNION { " \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:from ?x ; " \
+ "nmo:isSent false ; " \
+ "nmo:isAnswered false ." \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasAffiliation ?a . " \
+ "?a nco:hasPhoneNumber ?h . " \
+ "} " \
+ "} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"

#define INCOMING_CALLS_QUERY \
"SELECT nco:phoneNumber(?h) nco:fullname(?c) " \
@@ -244,13 +265,34 @@
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"WHERE { " \
+ "{" \
+ "?c a nco:Contact . " \
+ "?c nco:hasPhoneNumber ?h . " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
"nmo:isSent false ; " \
"nmo:isAnswered true ." \
- "?c a nco:Contact . " \
- "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
- "} ORDER BY DESC(nmo:receivedDate(?call))"
+ "} UNION { " \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h ." \
+ "?call a nmo:Call ; " \
+ "nmo:from ?x ; " \
+ "nmo:isSent false ; " \
+ "nmo:isAnswered true ." \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasPhoneNumber ?h ." \
+ "}UNION { " \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h ." \
+ "?call a nmo:Call ; " \
+ "nmo:from ?x ; " \
+ "nmo:isSent false ; " \
+ "nmo:isAnswered true ." \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasAffiliation ?a . " \
+ "?a nco:hasPhoneNumber ?h . " \
+ "}" \
+ "} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"

#define OUTGOING_CALLS_QUERY \
"SELECT nco:phoneNumber(?h) nco:fullname(?c) " \
@@ -313,12 +355,31 @@
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"WHERE { " \
+ "{" \
+ "?c a nco:Contact . " \
+ "?c nco:hasPhoneNumber ?h . " \
"?call a nmo:Call ; " \
"nmo:to ?c ; " \
"nmo:isSent true . " \
- "?c a nco:Contact . " \
- "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
- "} ORDER BY DESC(nmo:sentDate(?call))"
+ "} UNION {" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:to ?x ; " \
+ "nmo:isSent true . " \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasPhoneNumber ?h . " \
+ "} UNION {" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:to ?x ; " \
+ "nmo:isSent true . " \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasAffiliation ?a . " \
+ "?a nco:hasPhoneNumber ?h . " \
+ "}" \
+ "} GROUP BY ?call ORDER BY DESC(nmo:sentDate(?call))"

#define COMBINED_CALLS_QUERY \
"SELECT nco:phoneNumber(?h) nco:fullname(?c) " \
@@ -420,19 +481,54 @@
"nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
"nco:nameHonorificSuffix(?c) nco:phoneNumber(?h) " \
"WHERE { " \
- "{ " \
- "?call a nmo:Call ; " \
- "nmo:to ?c ; " \
- "nmo:isSent true . " \
- "?c a nco:Contact . " \
- "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
- "} UNION { " \
- "?call a nmo:Call ; " \
- "nmo:from ?c ; " \
- "nmo:isSent false . " \
- "?c a nco:Contact . " \
- "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
- "} } ORDER BY DESC(nmo:receivedDate(?call))"
+ " { " \
+ "?c a nco:Contact . " \
+ "?c nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:to ?c ; " \
+ "nmo:isSent true . " \
+ "} UNION {" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:to ?x ; " \
+ "nmo:isSent true . " \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasPhoneNumber ?h . " \
+ "} UNION {" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:to ?x ; " \
+ "nmo:isSent true . " \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasAffiliation ?a . " \
+ "?a nco:hasPhoneNumber ?h . " \
+ "}UNION {" \
+ "?c a nco:Contact . " \
+ "?c nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:from ?c ; " \
+ "nmo:isSent false . " \
+ "} UNION {" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:from ?x ; " \
+ "nmo:isSent false . " \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasPhoneNumber ?h . " \
+ "} UNION {" \
+ "?x a nco:Contact . " \
+ "?x nco:hasPhoneNumber ?h . " \
+ "?call a nmo:Call ; " \
+ "nmo:from ?x ; " \
+ "nmo:isSent false . " \
+ "?c a nco:PersonContact . " \
+ "?c nco:hasAffiliation ?a . " \
+ "?a nco:hasPhoneNumber ?h . " \
+ "}" \
+ "} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"


#define CONTACTS_QUERY_FROM_URI \
--
1.7.0.4



2010-10-22 13:06:25

by Johan Hedberg

[permalink] [raw]
Subject: Re: [PATCH] Fix history listing queries in phonebook-tracker

Hi Radek,

On Thu, Oct 21, 2010, Radoslaw Jablonski wrote:
> Now we are able to display contact's name in vcard-listing when
> contact has entry in phonebook available.
> ---
> plugins/phonebook-tracker.c | 140 ++++++++++++++++++++++++++++++++++++-------
> 1 files changed, 118 insertions(+), 22 deletions(-)

Pushed upstream. Thanks.

Johan