public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP
@ 2011-01-04 12:23 Radoslaw Jablonski
  2011-01-04 12:23 ` [PATCH 2/2 v2] Remove unnecessary "?_key" variable in call history queries Radoslaw Jablonski
  2011-01-04 12:54 ` [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP Johan Hedberg
  0 siblings, 2 replies; 3+ messages in thread
From: Radoslaw Jablonski @ 2011-01-04 12:23 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Radoslaw Jablonski

Application which stores contacts data in database has been
optimized - fax and cell phones are now stored in "affilation"
structures for better performance. So queries used in
phonebook-tracker need to be changed to handle this properly.
Without that cell and fax phone numbers are not listed in pull
phonebook results.
---
 plugins/phonebook-tracker.c |   61 ++++++++++++++++++++----------------------
 1 files changed, 29 insertions(+), 32 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index d211660..eda5d38 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -86,10 +86,10 @@
 
 #define CONTACTS_QUERY_ALL						\
 "SELECT "								\
-"(SELECT GROUP_CONCAT("							\
-"nco:phoneNumber(?number), \"\30\")"					\
+"(SELECT GROUP_CONCAT(fn:concat(rdf:type(?aff_number),"			\
+"\"\31\", nco:phoneNumber(?aff_number)), \"\30\")"			\
 "WHERE {"								\
-"	?_role nco:hasPhoneNumber ?number"				\
+"	?_role nco:hasPhoneNumber ?aff_number"				\
 "}) "									\
 "nco:fullname(?_contact) "						\
 "nco:nameFamily(?_contact) "						\
@@ -168,7 +168,8 @@
 
 #define MISSED_CALLS_QUERY						\
 "SELECT "								\
-"(SELECT nco:phoneNumber(?role_number) "				\
+"(SELECT fn:concat(rdf:type(?role_number),"				\
+	"\"\31\", nco:phoneNumber(?role_number))"			\
 	"WHERE {"							\
 	"?_role nco:hasPhoneNumber ?role_number "			\
 	"FILTER (?role_number = ?_number)"				\
@@ -314,10 +315,11 @@
 
 #define INCOMING_CALLS_QUERY						\
 "SELECT "								\
-"(SELECT nco:phoneNumber(?role_number) "				\
+"(SELECT fn:concat(rdf:type(?role_number),"				\
+	"\"\31\", nco:phoneNumber(?role_number))"			\
 	"WHERE {"							\
-"	?_role nco:hasPhoneNumber ?role_number"				\
-"	FILTER (?role_number = ?_number)"				\
+	"?_role nco:hasPhoneNumber ?role_number "			\
+	"FILTER (?role_number = ?_number)"				\
 "} GROUP BY nco:phoneNumber(?role_number) ) "				\
 	"nco:fullname(?_contact) "					\
 	"nco:nameFamily(?_contact) "					\
@@ -459,10 +461,11 @@
 
 #define OUTGOING_CALLS_QUERY						\
 "SELECT "								\
-"(SELECT nco:phoneNumber(?role_number) "				\
+"(SELECT fn:concat(rdf:type(?role_number),"				\
+	"\"\31\", nco:phoneNumber(?role_number))"			\
 	"WHERE {"							\
-"	?_role nco:hasPhoneNumber ?role_number"				\
-"	FILTER (?role_number = ?_number)"				\
+	"?_role nco:hasPhoneNumber ?role_number "			\
+	"FILTER (?role_number = ?_number)"				\
 "} GROUP BY nco:phoneNumber(?role_number) ) "				\
 	"nco:fullname(?_contact) "					\
 	"nco:nameFamily(?_contact) "					\
@@ -598,10 +601,11 @@
 
 #define COMBINED_CALLS_QUERY						\
 "SELECT "								\
-"(SELECT nco:phoneNumber(?role_number) "				\
+"(SELECT fn:concat(rdf:type(?role_number),"				\
+	"\"\31\", nco:phoneNumber(?role_number))"			\
 	"WHERE {"							\
-"	?_role nco:hasPhoneNumber ?role_number"				\
-"	FILTER (?role_number = ?_number)"				\
+	"?_role nco:hasPhoneNumber ?role_number "			\
+	"FILTER (?role_number = ?_number)"				\
 "} GROUP BY nco:phoneNumber(?role_number) ) "				\
 	"nco:fullname(?_contact) "					\
 	"nco:nameFamily(?_contact) "					\
@@ -791,10 +795,10 @@
 
 #define CONTACTS_QUERY_FROM_URI						\
 "SELECT "								\
-"(SELECT GROUP_CONCAT("							\
-"nco:phoneNumber(?number), \"\30\")"					\
+"(SELECT GROUP_CONCAT(fn:concat(rdf:type(?aff_number),"			\
+"\"\31\", nco:phoneNumber(?aff_number)), \"\30\")"			\
 "WHERE {"								\
-"	?_role nco:hasPhoneNumber ?number"				\
+"	?_role nco:hasPhoneNumber ?aff_number"				\
 "}) "									\
 "nco:fullname(<%s>) "							\
 "nco:nameFamily(<%s>) "							\
@@ -1469,7 +1473,8 @@ static enum phonebook_number_type get_phone_type(const char *affilation)
 	return TEL_TYPE_OTHER;
 }
 
-static void add_main_number(struct phonebook_contact *contact, char *pnumber)
+static void add_aff_number(struct phonebook_contact *contact, char *pnumber,
+								char *aff_type)
 {
 	char **num_parts;
 	char *type, *number;
@@ -1497,7 +1502,9 @@ static void add_main_number(struct phonebook_contact *contact, char *pnumber)
 	else if (g_strrstr(type, MOBILE_NUM_TYPE))
 		add_phone_number(contact, number, TEL_TYPE_MOBILE);
 	else
-		add_phone_number(contact, number, TEL_TYPE_OTHER);
+		/* if this is no fax/mobile phone, then adding phone number
+		 * type based on type of the affilation field */
+		add_phone_number(contact, number, get_phone_type(aff_type));
 
 failed:
 	g_strfreev(num_parts);
@@ -1506,28 +1513,18 @@ failed:
 static void contact_add_numbers(struct phonebook_contact *contact,
 								char **reply)
 {
-	char **aff_numbers, **con_numbers;
+	char **aff_numbers;
 	int i;
 
-	/* Filling phonegit  numbers from contact's affilation */
+	/* Filling phone numbers from contact's affilation */
 	aff_numbers = g_strsplit(reply[COL_PHONE_AFF], MAIN_DELIM, MAX_FIELDS);
 
 	if (aff_numbers)
 		for(i = 0;aff_numbers[i]; ++i)
-			add_phone_number(contact, aff_numbers[i],
-					get_phone_type(reply[COL_AFF_TYPE]));
+			add_aff_number(contact, aff_numbers[i],
+							reply[COL_AFF_TYPE]);
 
 	g_strfreev(aff_numbers);
-
-	/* Filling phone numbers directly from contact's struct */
-	con_numbers = g_strsplit(reply[COL_PHONE_CONTACT], MAIN_DELIM,
-								MAX_FIELDS);
-
-	if (con_numbers)
-		for(i = 0; con_numbers[i] != NULL; ++i)
-			add_main_number(contact, con_numbers[i]);
-
-	g_strfreev(con_numbers);
 }
 
 static enum phonebook_email_type get_email_type(const char *affilation)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2 v2] Remove unnecessary "?_key" variable in call history queries
  2011-01-04 12:23 [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP Radoslaw Jablonski
@ 2011-01-04 12:23 ` Radoslaw Jablonski
  2011-01-04 12:54 ` [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Radoslaw Jablonski @ 2011-01-04 12:23 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Radoslaw Jablonski

This "?_key" variable need to be filled only in pull phonebook
queries(for sorting results). In call history queries it is
unnecessary.
---
 plugins/phonebook-tracker.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index eda5d38..c052b43 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -248,7 +248,6 @@
 	"?_contact a nco:PersonContact ; "				\
 	"nco:hasPhoneNumber ?_number . "				\
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-	"?_contact nco:nameFamily ?_key ."				\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
 	"?_ncontact nco:hasPhoneNumber ?_number . "			\
@@ -257,7 +256,6 @@
 	"nmo:isAnswered false ;"					\
 	"nmo:isSent false . "						\
 	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:nameFamily ?_key . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
 "} UNION { "								\
@@ -395,7 +393,6 @@
 	"?_contact a nco:PersonContact ; "				\
 	"nco:hasPhoneNumber ?_number . "				\
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-	"?_contact nco:nameFamily ?_key ."				\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
 	"?_ncontact nco:hasPhoneNumber ?_number . "			\
@@ -404,7 +401,6 @@
 	"nmo:isAnswered true ;"						\
 	"nmo:isSent false . "						\
 	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:nameFamily ?_key . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
 "} UNION { "								\
@@ -540,7 +536,6 @@
 	"?_contact a nco:PersonContact ; "				\
 	"nco:hasPhoneNumber ?_number . "				\
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-	"?_contact nco:nameFamily ?_key ."				\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
 	"?_ncontact nco:hasPhoneNumber ?_number . "			\
@@ -548,7 +543,6 @@
 	"nmo:to ?_ncontact ; "						\
 	"nmo:isSent true . "						\
 	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:nameFamily ?_key . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
 "} UNION { "								\
@@ -680,7 +674,6 @@
 	"?_contact a nco:PersonContact ; "				\
 	"nco:hasPhoneNumber ?_number . "				\
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-	"?_contact nco:nameFamily ?_key ."				\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
 	"?_ncontact nco:hasPhoneNumber ?_number . "			\
@@ -688,7 +681,6 @@
 	"nmo:to ?_ncontact ; "						\
 	"nmo:isSent true . "						\
 	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:nameFamily ?_key . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
 "} UNION { "								\
@@ -712,7 +704,6 @@
 	"?_contact a nco:PersonContact ; "				\
 	"nco:hasPhoneNumber ?_number . "				\
 	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-	"?_contact nco:nameFamily ?_key ."				\
 "} UNION { "								\
 	"?_ncontact a nco:Contact . "					\
 	"?_ncontact nco:hasPhoneNumber ?_number . "			\
@@ -720,7 +711,6 @@
 	"nmo:from ?_ncontact ; "					\
 	"nmo:isSent false . "						\
 	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:nameFamily ?_key . "				\
 	"?_contact nco:hasAffiliation ?_role . "			\
 	"?_role nco:hasPhoneNumber ?_number . "				\
 "} UNION { "								\
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP
  2011-01-04 12:23 [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP Radoslaw Jablonski
  2011-01-04 12:23 ` [PATCH 2/2 v2] Remove unnecessary "?_key" variable in call history queries Radoslaw Jablonski
@ 2011-01-04 12:54 ` Johan Hedberg
  1 sibling, 0 replies; 3+ messages in thread
From: Johan Hedberg @ 2011-01-04 12:54 UTC (permalink / raw)
  To: Radoslaw Jablonski; +Cc: linux-bluetooth

Hi Radek,

On Tue, Jan 04, 2011, Radoslaw Jablonski wrote:
> Application which stores contacts data in database has been
> optimized - fax and cell phones are now stored in "affilation"
> structures for better performance. So queries used in
> phonebook-tracker need to be changed to handle this properly.
> Without that cell and fax phone numbers are not listed in pull
> phonebook results.
> ---
>  plugins/phonebook-tracker.c |   61 ++++++++++++++++++++----------------------
>  1 files changed, 29 insertions(+), 32 deletions(-)

Both patches have been pushed upstream. Thanks.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-04 12:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-04 12:23 [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP Radoslaw Jablonski
2011-01-04 12:23 ` [PATCH 2/2 v2] Remove unnecessary "?_key" variable in call history queries Radoslaw Jablonski
2011-01-04 12:54 ` [PATCH 1/2 v2] Fix for handling fax and cell phone numbers in PBAP Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox