Skip to contentSkip to conversation

Remove unnecessary ordering from single vCard query

PATCH In review Rafal Michalski 2 participants 4 messages Jan 26, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Remove unnecessary ordering from single vCard query

Previously ordering for query called CONTACTS_QUERY_FROM_URI was applied. It is not needed since always only one vCard (with id specified) is fetched.

---
 plugins/phonebook-tracker.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
plugins/phonebook-tracker.c +3 -6
index e60cf74..4e37f1c 100644
@@ -788,11 +788,9 @@
 "\"NOTACALL\" \"false\" \"false\" "					\
 "<%s> "									\
 "WHERE {"								\
-"	<%s> a nco:PersonContact ;"					\
-"	nco:nameFamily ?_key ."						\
+"	<%s> a nco:PersonContact ."					\
 "	OPTIONAL {<%s> nco:hasAffiliation ?_role .}"			\
-"}"									\
-"ORDER BY ?_key tracker:id(<%s>)"
+"}"
 
 #define CONTACTS_OTHER_QUERY_FROM_URI					\
 	"SELECT fn:concat(\"TYPE_OTHER\", \"\31\", nco:phoneNumber(?t))"\
@@ -1926,8 +1924,7 @@ void *phonebook_get_entry(const char *folder, const char *id,
 
 	if (strncmp(id, CONTACT_ID_PREFIX, strlen(CONTACT_ID_PREFIX)) == 0)
 		query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id,
-						id, id, id, id, id, id, id, id,
-						id, id);
+					id, id, id, id, id, id, id, id, id);
 	else
 		query = g_strdup_printf(CONTACTS_OTHER_QUERY_FROM_URI,
 								id, id, id);
Signature · 1 line
1.6.3.3
#1 lore raw

PATCH v2 2/2 Fix fetching non-empty single owner vCard

Previously only empty owner vCard fetching was handled. This patch makes that fetching empty (by default) and non-empty (filled somehow by the user) single owner vCard is handled.

---
 plugins/phonebook-tracker.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
plugins/phonebook-tracker.c +2 -1
index 4e37f1c..353b5cb 100644
@@ -1922,7 +1922,8 @@ void *phonebook_get_entry(const char *folder, const char *id,
 	data->cb = cb;
 	data->vcardentry = TRUE;
 
-	if (strncmp(id, CONTACT_ID_PREFIX, strlen(CONTACT_ID_PREFIX)) == 0)
+	if (g_str_has_prefix(id, CONTACT_ID_PREFIX) == TRUE ||
+		g_strcmp0(id, TRACKER_DEFAULT_CONTACT_ME) == 0)
 		query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id,
 					id, id, id, id, id, id, id, id, id);
 	else
Signature · 1 line
1.6.3.3
#3 lore raw
In reply to Rafal Michalski

Hi Rafal,

Quoted 6 lines · Rafal Michalski

Previously ordering for query called CONTACTS_QUERY_FROM_URI was applied. It is not needed since always only one vCard (with id specified) is fetched.

---
 plugins/phonebook-tracker.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

Pushed upstream. Thanks.

Johan

#2 lore raw

Re: [PATCH 2/2 v2] Fix fetching non-empty single owner vCard

In reply to Rafal Michalski

Hi Rafal,

Quoted 6 lines · Rafal Michalski

Previously only empty owner vCard fetching was handled. This patch makes that fetching empty (by default) and non-empty (filled somehow by the user) single owner vCard is handled.

---
 plugins/phonebook-tracker.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Still one coding style issue here:

plugins/phonebook-tracker.c void *phonebook_get_entry(const char *folder, const char *id, · line 1928

Quoted 13 lines
plugins/phonebook-tracker.c +2 -1
index 4e37f1c..353b5cb 100644
@@ -1922,7 +1922,8 @@ void *phonebook_get_entry(const char *folder, const char *id,
 	data->cb = cb;
 	data->vcardentry = TRUE;
 
-	if (strncmp(id, CONTACT_ID_PREFIX, strlen(CONTACT_ID_PREFIX)) == 0)
+	if (g_str_has_prefix(id, CONTACT_ID_PREFIX) == TRUE ||
+		g_strcmp0(id, TRACKER_DEFAULT_CONTACT_ME) == 0)
 		query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id,
 					id, id, id, id, id, id, id, id, id);

The split second line of the if-statment should be indented by at least two tabs so that it's distinguishable from the rest of the code. Please send a v3.

Johan