diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c
index 4c41c95..13e557d 100644
--- a/obexd/plugins/phonebook-tracker.c
+++ b/obexd/plugins/phonebook-tracker.c
"nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
"nco:postalcode(?p) nco:country(?p) " \
"WHERE { " \
- "?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { ?c nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { ?c nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"}"
#define CONTACTS_QUERY_ALL_LIST \
- "SELECT ?c nco:contactUID(?c) nco:nameFamily(?c) " \
+ "SELECT ?c nco:nameFamily(?c) " \
"nco:nameGiven(?c) nco:nameAdditional(?c) " \
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"WHERE { " \
- "?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
"}"
#define MISSED_CALLS_QUERY \
"nmo:from ?c ; " \
"nmo:isSent false ; " \
"nmo:isAnswered false ." \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { ?c nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { ?c nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
#define MISSED_CALLS_LIST \
- "SELECT ?c nco:contactUID(?c) nco:nameFamily(?c) " \
+ "SELECT ?c nco:nameFamily(?c) " \
"nco:nameGiven(?c) nco:nameAdditional(?c) " \
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"nmo:from ?c ; " \
"nmo:isSent false ; " \
"nmo:isAnswered false ." \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
#define INCOMING_CALLS_QUERY \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
"nmo:isSent false . " \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { ?c nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { ?c nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
#define INCOMING_CALLS_LIST \
- "SELECT ?c nco:contactUID(?c) nco:nameFamily(?c) " \
+ "SELECT ?c nco:nameFamily(?c) " \
"nco:nameGiven(?c) nco:nameAdditional(?c) " \
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
"nmo:isSent false . " \
- "?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact ; " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
"} ORDER BY DESC(nmo:receivedDate(?call))"
#define OUTGOING_CALLS_QUERY \
"?call a nmo:Call ; " \
"nmo:to ?c ; " \
"nmo:isSent true . " \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { ?c nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { ?c nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"} ORDER BY DESC(nmo:sentDate(?call))"
#define OUTGOING_CALLS_LIST \
- "SELECT ?c nco:contactUID(?c) nco:nameFamily(?c) " \
+ "SELECT ?c nco:nameFamily(?c) " \
"nco:nameGiven(?c) nco:nameAdditional(?c) " \
"nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
"nco:phoneNumber(?h) " \
"?call a nmo:Call ; " \
"nmo:to ?c ; " \
"nmo:isSent true . " \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { nco:hasPhoneNumber ?h . } " \
"} ORDER BY DESC(nmo:sentDate(?call))"
#define COMBINED_CALLS_QUERY \
"?call a nmo:Call ; " \
"nmo:to ?c ; " \
"nmo:isSent true . " \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { ?c nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { ?c nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"} UNION { " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
"nmo:isSent false . " \
- "?c a nco:Contact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { ?c nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { ?c nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
"?c nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"} } "
#define COMBINED_CALLS_LIST \
- "SELECT ?c nco:contactUID(?c) nco:nameFamily(?c) " \
- "nco:nameGiven(?c) nco:nameAdditional(?c) " \
- "nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
- "nco:phoneNumber(?h) " \
+ "SELECT ?c nco:nameFamily(?c) nco:nameGiven(?c) " \
+ "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 ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
"} UNION { " \
"?call a nmo:Call ; " \
"nmo:from ?c ; " \
"nmo:isSent false . " \
- "?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?h . " \
+ "?c a nco:Contact . " \
+ "OPTIONAL { ?c nco:hasPhoneNumber ?h . } " \
"} } "
#define CONTACTS_QUERY_FROM_URI \
- "SELECT nco:phoneNumber(?h) nco:fullname(?c) " \
- "nco:nameFamily(?c) nco:nameGiven(?c) nco:nameAdditional(?c) " \
- "nco:nameHonorificPrefix(?c) nco:nameHonorificSuffix(?c) " \
- "nco:emailAddress(?e) " \
+ "SELECT nco:phoneNumber(?h) nco:fullname(<%s>) " \
+ "nco:nameFamily(<%s>) nco:nameGiven(<%s>) " \
+ "nco:nameAdditional(<%s>) nco:nameHonorificPrefix(<%s>) " \
+ "nco:nameHonorificSuffix(<%s>) nco:emailAddress(?e) " \
"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:Contact ; " \
- "nco:contactUID <%s> ; " \
- "nco:hasPhoneNumber ?h . " \
+ "<%s> a nco:Contact . " \
+ "OPTIONAL { <%s> nco:hasPhoneNumber ?h . } " \
+ "OPTIONAL { <%s> nco:hasEmailAddress ?e . } " \
+ "OPTIONAL { <%s> nco:hasPostalAddress ?p . } " \
"OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
+ "<%s> nco:hasAffiliation ?a . " \
"?a nco:hasPhoneNumber ?w . " \
- "?c nco:hasEmailAddress ?e . " \
- "?c nco:hasPostalAddress ?p . " \
"} " \
"}"
while (dbus_message_iter_get_arg_type(&element) != DBUS_TYPE_INVALID) {
char **node;
+ int i;
if (dbus_message_iter_get_arg_type(&element) !=
DBUS_TYPE_ARRAY) {
}
node = string_array_from_iter(element, pending->num_fields);
- pending->callback(node, pending->num_fields,
+
+ /* Ignoring empty responses */
+ for (i = 0; i < pending->num_fields; i++) {
+ if (node[i][0] != '\0') {
+ pending->callback(node, pending->num_fields,
pending->user_data);
+ break;
+ }
+ }
+
g_free(node);
dbus_message_iter_next(&element);
if (reply == NULL)
goto done;
- formatted = g_strdup_printf("%s;%s;%s;%s;%s", reply[2], reply[3],
- reply[4], reply[5], reply[6]);
+ formatted = g_strdup_printf("%s;%s;%s;%s;%s", reply[1], reply[2],
+ reply[3], reply[4], reply[5]);
/* The owner vCard must have the 0 handle */
if (strcmp(reply[0], TRACKER_DEFAULT_CONTACT_ME) == 0)
- cache->entry_cb(reply[1], 0, formatted, "",
- reply[7], cache->user_data);
+ cache->entry_cb(reply[0], 0, formatted, "",
+ reply[6], cache->user_data);
else
- cache->entry_cb(reply[1], PHONEBOOK_INVALID_HANDLE, formatted,
- "", reply[7], cache->user_data);
+ cache->entry_cb(reply[0], PHONEBOOK_INVALID_HANDLE, formatted,
+ "", reply[6], cache->user_data);
g_free(formatted);
data->cb = cb;
data->vcardentry = TRUE;
- query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id);
+ query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id, id,
+ id, id, id, id, id, id);
ret = query_tracker(query, 16, pull_contacts, data);
cache->ready_cb = ready_cb;
cache->user_data = user_data;
- return query_tracker(query, 8, add_to_cache, cache);
+ return query_tracker(query, 7, add_to_cache, cache);
}