Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Change OPUSH sdp record when use sdptool for GOEP v2.0.
From: nami @ 2011-05-18  9:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: nami

---
 lib/sdp.h       |    5 +++++
 tools/sdptool.c |   11 ++++++++++-
 2 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/lib/sdp.h b/lib/sdp.h
index 5f7d271..bb217a5 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -312,6 +312,11 @@ extern "C" {
 #define SDP_ATTR_HID_BOOT_DEVICE		0x020e
 
 /*
+ * GoepL2capPsm attribute is added on GOEP v2.0 and later
+ */
+ #define SDP_ATTR_GOEP_L2CAP_PSM		0x0200
+
+/*
  * These identifiers are based on the SDP spec stating that
  * "base attribute id of the primary (universal) language must be 0x0100"
  *
diff --git a/tools/sdptool.c b/tools/sdptool.c
index 140a46a..1b2117a 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1752,6 +1752,8 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
 	uint8_t dtd = SDP_UINT8;
 	sdp_data_t *sflist;
 	int ret = 0;
+	uint16_t psm = si->psm ? si->psm : 0x1015;
+	sdp_data_t *l2cappsm;
 
 	memset(&record, 0, sizeof(sdp_record_t));
 	record.handle = si->handle;
@@ -1765,7 +1767,9 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
 	sdp_set_service_classes(&record, svclass_id);
 
 	sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID);
-	profile[0].version = 0x0100;
+	/* The profile version number in the BluetoothProfileDescriptorList attribute
+	shall be incremented for GOEPv2.0 and later. */
+	profile[0].version = 0x0102;
 	pfseq = sdp_list_append(0, profile);
 	sdp_set_profile_descs(&record, pfseq);
 
@@ -1795,6 +1799,10 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
 
 	sdp_set_info_attr(&record, "OBEX Object Push", 0, 0);
 
+	/* The SDP records shall include the GoepL2capPsm attribute for GOEPv2.0 and later. */
+	l2cappsm = sdp_data_alloc (SDP_UINT16, &psm);
+	sdp_attr_add (&record, SDP_ATTR_GOEP_L2CAP_PSM, l2cappsm);
+
 	if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
 		printf("Service Record registration failed\n");
 		ret = -1;
@@ -1805,6 +1813,7 @@ static int add_opush(sdp_session_t *session, svc_info_t *si)
 
 end:
 	sdp_data_free(channel);
+	sdp_data_free(l2cappsm);
 	sdp_list_free(proto[0], 0);
 	sdp_list_free(proto[1], 0);
 	sdp_list_free(proto[2], 0);
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH] Change OPUSH sdp record when use sdptool for GOEP v2.0.
From: hui li @ 2011-05-18  9:31 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1305710832-11037-1-git-send-email-nami.li1984@gmail.com>

Please kindly let me know this patch`s errors. If this patch can be
accepted, I will commit FTP, PBAP, BIP new sdp record patches later.

Thank you very much.


2011/5/18, nami <nami.li1984@gmail.com>:
> ---
>  lib/sdp.h       |    5 +++++
>  tools/sdptool.c |   11 ++++++++++-
>  2 files changed, 15 insertions(+), 1 deletions(-)
>
> diff --git a/lib/sdp.h b/lib/sdp.h
> index 5f7d271..bb217a5 100644
> --- a/lib/sdp.h
> +++ b/lib/sdp.h
> @@ -312,6 +312,11 @@ extern "C" {
>  #define SDP_ATTR_HID_BOOT_DEVICE		0x020e
>
>  /*
> + * GoepL2capPsm attribute is added on GOEP v2.0 and later
> + */
> + #define SDP_ATTR_GOEP_L2CAP_PSM		0x0200
> +
> +/*
>   * These identifiers are based on the SDP spec stating that
>   * "base attribute id of the primary (universal) language must be 0x0100"
>   *
> diff --git a/tools/sdptool.c b/tools/sdptool.c
> index 140a46a..1b2117a 100644
> --- a/tools/sdptool.c
> +++ b/tools/sdptool.c
> @@ -1752,6 +1752,8 @@ static int add_opush(sdp_session_t *session,
> svc_info_t *si)
>  	uint8_t dtd = SDP_UINT8;
>  	sdp_data_t *sflist;
>  	int ret = 0;
> +	uint16_t psm = si->psm ? si->psm : 0x1015;
> +	sdp_data_t *l2cappsm;
>
>  	memset(&record, 0, sizeof(sdp_record_t));
>  	record.handle = si->handle;
> @@ -1765,7 +1767,9 @@ static int add_opush(sdp_session_t *session,
> svc_info_t *si)
>  	sdp_set_service_classes(&record, svclass_id);
>
>  	sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID);
> -	profile[0].version = 0x0100;
> +	/* The profile version number in the BluetoothProfileDescriptorList
> attribute
> +	shall be incremented for GOEPv2.0 and later. */
> +	profile[0].version = 0x0102;
>  	pfseq = sdp_list_append(0, profile);
>  	sdp_set_profile_descs(&record, pfseq);
>
> @@ -1795,6 +1799,10 @@ static int add_opush(sdp_session_t *session,
> svc_info_t *si)
>
>  	sdp_set_info_attr(&record, "OBEX Object Push", 0, 0);
>
> +	/* The SDP records shall include the GoepL2capPsm attribute for GOEPv2.0
> and later. */
> +	l2cappsm = sdp_data_alloc (SDP_UINT16, &psm);
> +	sdp_attr_add (&record, SDP_ATTR_GOEP_L2CAP_PSM, l2cappsm);
> +
>  	if (sdp_device_record_register(session, &interface, &record,
> SDP_RECORD_PERSIST) < 0) {
>  		printf("Service Record registration failed\n");
>  		ret = -1;
> @@ -1805,6 +1813,7 @@ static int add_opush(sdp_session_t *session,
> svc_info_t *si)
>
>  end:
>  	sdp_data_free(channel);
> +	sdp_data_free(l2cappsm);
>  	sdp_list_free(proto[0], 0);
>  	sdp_list_free(proto[1], 0);
>  	sdp_list_free(proto[2], 0);
> --
> 1.7.1
>
>

^ permalink raw reply

* [PATCH] Fix newmissedcalls handling for large responses
From: Radoslaw Jablonski @ 2011-05-18 10:55 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Radoslaw Jablonski

Previously pull_newmissedcalls was called for every part when
processing large response (more that one part of results) and
number of 'newmissedcalls' was wrong in that scenario.
Now newmissedcalls will be counted only once (during generating
first part of mch results).
---
 plugins/phonebook-tracker.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 9431d8a..7328bb3 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -2027,7 +2027,11 @@ int phonebook_pull_read(void *request)
 	if(!data)
 		return -ENOENT;
 
-	if (g_strcmp0(data->req_name, "/telecom/mch.vcf") == 0) {
+	if (g_strcmp0(data->req_name,"/telecom/mch.vcf") == 0 &&
+			data->tracker_index == 0) {
+		/* newmissedcalls amount should be counted only once - it
+		 * will be done during generating first part of results of
+		 * missed calls history */
 		query = NEW_MISSED_CALLS_LIST;
 		col_amount = PULL_QUERY_COL_AMOUNT;
 		pull_cb = pull_newmissedcalls;
-- 
1.7.0.4


^ permalink raw reply related

* [PATCH] Rewrite of PBAP call history queries
From: Slawomir Bochenski @ 2011-05-18 13:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Slawomir Bochenski

Graph patterns used in queries for PullPhonebook and PullvCardListing in
case of call history are now rewritten to share the same code and be
simpler - previously they were doing almost the same, but exact code
differed. So in this patch repeating parts of queries were reduced to one
place for easy management.

Also new queries fix the behaviour in situation when there is more than
one contact matching a phone number from call history entry - in this
case no contact data is returned instead of returning random contact as
it was the case before.
---
 plugins/phonebook-tracker.c |  600 ++++--------------------------------------
 1 files changed, 58 insertions(+), 542 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 8da8b80..eec1e5d 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -156,428 +156,40 @@
 	"} "								\
 	"} GROUP BY ?c"
 
-#define MISSED_CALLS_QUERY						\
-"SELECT "								\
-"(SELECT fn:concat(rdf:type(?role_number),"				\
-	"\"\31\", nco:phoneNumber(?role_number))"			\
-	"WHERE {"							\
-	"{"								\
-	"	?_role nco:hasPhoneNumber ?role_number "		\
-	"	FILTER (?role_number = ?_number)"			\
-	"} UNION { "							\
-		"?_unb_contact nco:hasPhoneNumber ?role_number . "	\
-	"}"								\
-"} GROUP BY nco:phoneNumber(?role_number) ) "				\
-	"nco:fullname(?_contact) "					\
-	"nco:nameFamily(?_contact) "					\
-	"nco:nameGiven(?_contact) "					\
-	"nco:nameAdditional(?_contact) "				\
-	"nco:nameHonorificPrefix(?_contact) "				\
-	"nco:nameHonorificSuffix(?_contact) "				\
-"(SELECT GROUP_CONCAT(fn:concat("					\
-	"tracker:coalesce(nco:pobox(?aff_addr), \"\"), \";\","		\
-	"tracker:coalesce(nco:extendedAddress(?aff_addr), \"\"), \";\","\
-	"tracker:coalesce(nco:streetAddress(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\","		\
-	"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:country(?aff_addr), \"\"), "		\
-	"\"\31\", rdfs:label(?c_role) ), "				\
-	"\"\30\") "							\
-	"WHERE {"							\
-	"?_contact nco:hasAffiliation ?c_role . "			\
-	"?c_role nco:hasPostalAddress ?aff_addr"			\
-	"}) "								\
-	"nco:birthDate(?_contact) "					\
-	"nco:nickname(?_contact) "					\
-"(SELECT GROUP_CONCAT(fn:concat( "					\
-	"?url_value, \"\31\", ?aff_type "				\
-	"), \"\30\") "							\
-	"WHERE {"							\
-		"?_contact nco:hasAffiliation ?c_role . "		\
-		"?c_role nco:url ?url_value . "				\
-		"?c_role rdfs:label ?aff_type . "			\
-"})"									\
-	"nie:url(nco:photo(?_contact)) "				\
-	"nco:role(?_role) "						\
-	"nco:contactUID(?_contact) "					\
-	"nco:title(?_role) "						\
-	"rdfs:label(?_role) "						\
-	"nco:fullname(nco:org(?_role)) "				\
-	"nco:department(?_role) "					\
-"(SELECT GROUP_CONCAT(fn:concat(?emailaddress,\"\31\","			\
-	"rdfs:label(?c_role)),"						\
-	"\"\30\") "							\
-	"WHERE { "							\
-	"?_contact nco:hasAffiliation ?c_role . "			\
-	"?c_role nco:hasEmailAddress "					\
-	"		[ nco:emailAddress ?emailaddress ] "		\
-	"}) "								\
-	"nmo:receivedDate(?_call) "					\
-	"nmo:isSent(?_call) "						\
-	"nmo:isAnswered(?_call) "					\
-	"fn:concat(tracker:coalesce(?_ncontact, \"\"),"			\
-	"tracker:coalesce(?_unb_contact, \"\"))"			\
-	" "								\
-"WHERE { "								\
-"{ "									\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_ncontact ; "					\
-	"nmo:isAnswered false ;"					\
-	"nmo:isSent false . "						\
-	"?_contact a nco:PersonContact ; "				\
-	"nco:hasPhoneNumber ?_number . "				\
-	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-"} UNION { "								\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_ncontact ; "					\
-	"nmo:isAnswered false ;"					\
-	"nmo:isSent false . "						\
-	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:hasAffiliation ?_role . "			\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum . "			\
-	"?_number maemo:localPhoneNumber ?_realnum . "			\
-"} UNION { "								\
+#define CALLS_CONSTRAINTS(CONSTRAINT)					\
+" WHERE { "								\
+	"?_call a nmo:Call . "						\
 	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_unb_contact ; "					\
-	"nmo:isAnswered false ;"					\
-	"nmo:isSent false . "						\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasPhoneNumber ?_number . } "				\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum . "			\
-	"?_number maemo:localPhoneNumber ?_realnum . }"			\
-	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
-"} "									\
-"} "									\
-"ORDER BY DESC(nmo:sentDate(?_call)) "
-
-
-#define MISSED_CALLS_LIST						\
-	"SELECT ?c nco:nameFamily(?c) "					\
-	"nco:nameGiven(?c) nco:nameAdditional(?c) "			\
-	"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 ."				\
-	"}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 ?no . "				\
-		"?h maemo:localPhoneNumber ?num . "			\
-		"?no maemo:localPhoneNumber ?num . "			\
+	"?_unb_contact nco:hasPhoneNumber ?_cpn . "			\
+	"OPTIONAL { "							\
+		"{ SELECT ?_contact ?_cpn ?_role ?_number "		\
+			"count(?_contact) as ?cnt "			\
+		"WHERE { "						\
+			"?_contact a nco:PersonContact . "		\
+			"{ "						\
+				"?_contact nco:hasAffiliation ?_role . "\
+				"?_role nco:hasPhoneNumber ?_number . " \
+			"} UNION { "					\
+				"?_contact nco:hasPhoneNumber ?_number" \
+			"} "						\
+			"?_number maemo:localPhoneNumber ?_no . "	\
+			"?_cpn maemo:localPhoneNumber ?_no . "		\
+		"} GROUP BY ?_cpn } "					\
+		"FILTER(?cnt = 1) "					\
 	"} "								\
-	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
-
-#define INCOMING_CALLS_QUERY						\
-"SELECT "								\
-"(SELECT fn:concat(rdf:type(?role_number),"				\
-	"\"\31\", nco:phoneNumber(?role_number))"			\
-	"WHERE {"							\
-	"{"								\
-	"	?_role nco:hasPhoneNumber ?role_number "		\
-	"	FILTER (?role_number = ?_number)"			\
-	"} UNION { "							\
-		"?_unb_contact nco:hasPhoneNumber ?role_number . "	\
-	"}"								\
-"} GROUP BY nco:phoneNumber(?role_number) ) "				\
-	"nco:fullname(?_contact) "					\
-	"nco:nameFamily(?_contact) "					\
-	"nco:nameGiven(?_contact) "					\
-	"nco:nameAdditional(?_contact) "				\
-	"nco:nameHonorificPrefix(?_contact) "				\
-	"nco:nameHonorificSuffix(?_contact) "				\
-"(SELECT GROUP_CONCAT(fn:concat("					\
-	"tracker:coalesce(nco:pobox(?aff_addr), \"\"), \";\","		\
-	"tracker:coalesce(nco:extendedAddress(?aff_addr), \"\"), \";\","\
-	"tracker:coalesce(nco:streetAddress(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\","		\
-	"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:country(?aff_addr), \"\"), "		\
-	"\"\31\", rdfs:label(?c_role) ), "				\
-	"\"\30\") "							\
-	"WHERE {"							\
-	"?_contact nco:hasAffiliation ?c_role . "			\
-	"?c_role nco:hasPostalAddress ?aff_addr"			\
-	"}) "								\
-	"nco:birthDate(?_contact) "					\
-	"nco:nickname(?_contact) "					\
-"(SELECT GROUP_CONCAT(fn:concat( "					\
-	"?url_value, \"\31\", ?aff_type "				\
-	"), \"\30\") "							\
-	"WHERE {"							\
-		"?_contact nco:hasAffiliation ?c_role . "		\
-		"?c_role nco:url ?url_value . "				\
-		"?c_role rdfs:label ?aff_type . "			\
-"})"									\
-	"nie:url(nco:photo(?_contact)) "				\
-	"nco:role(?_role) "						\
-	"nco:contactUID(?_contact) "					\
-	"nco:title(?_role) "						\
-	"rdfs:label(?_role) "						\
-	"nco:fullname(nco:org(?_role)) "				\
-	"nco:department(?_role) "					\
-"(SELECT GROUP_CONCAT(fn:concat(?emailaddress,\"\31\","			\
-	"rdfs:label(?c_role)),"						\
-	"\"\30\") "							\
-	"WHERE { "							\
-	"?_contact nco:hasAffiliation ?c_role . "			\
-	"?c_role nco:hasEmailAddress "					\
-	"		[ nco:emailAddress ?emailaddress ] "		\
-	"}) "								\
-	"nmo:receivedDate(?_call) "					\
-	"nmo:isSent(?_call) "						\
-	"nmo:isAnswered(?_call) "					\
-	"fn:concat(tracker:coalesce(?_ncontact, \"\"),"			\
-	"tracker:coalesce(?_unb_contact, \"\"))"			\
-	" "								\
-"WHERE { "								\
-"{ "									\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_ncontact ; "					\
-	"nmo:isAnswered true ;"						\
-	"nmo:isSent false . "						\
-	"?_contact a nco:PersonContact ; "				\
-	"nco:hasPhoneNumber ?_number . "				\
-	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-"} UNION { "								\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_ncontact ; "					\
-	"nmo:isAnswered true ;"						\
-	"nmo:isSent false . "						\
-	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:hasAffiliation ?_role . "			\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_number maemo:localPhoneNumber ?_realnum . "			\
-	"?_other maemo:localPhoneNumber ?_realnum . "			\
-"} UNION { "								\
-	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_unb_contact ; "					\
-	"nmo:isAnswered true ;"						\
-	"nmo:isSent false . "						\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasPhoneNumber ?_number . } "				\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_number maemo:localPhoneNumber ?_realnum ."			\
-	"?_other maemo:localPhoneNumber ?_realnum . }"			\
-	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
-"} "									\
-"} "\
-"ORDER BY DESC(nmo:sentDate(?_call)) "
-
-#define INCOMING_CALLS_LIST						\
-	"SELECT ?c nco:nameFamily(?c) "					\
-	"nco:nameGiven(?c) nco:nameAdditional(?c) "			\
-	"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 ."					\
-	"} 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 ?no . "				\
-		"?h maemo:localPhoneNumber ?num . "			\
-		"?no maemo:localPhoneNumber ?num . "			\
-	"}"								\
-	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
+CONSTRAINT								\
+"} "
 
-#define OUTGOING_CALLS_QUERY						\
-"SELECT "								\
-"(SELECT fn:concat(rdf:type(?role_number),"				\
-	"\"\31\", nco:phoneNumber(?role_number))"			\
-	"WHERE {"							\
-	"{"								\
-	"	?_role nco:hasPhoneNumber ?role_number "		\
-	"	FILTER (?role_number = ?_number)"			\
-	"} UNION { "							\
-		"?_unb_contact nco:hasPhoneNumber ?role_number . "	\
-	"}"								\
-"} GROUP BY nco:phoneNumber(?role_number) ) "				\
-	"nco:fullname(?_contact) "					\
-	"nco:nameFamily(?_contact) "					\
-	"nco:nameGiven(?_contact) "					\
-	"nco:nameAdditional(?_contact) "				\
+#define CALLS_LIST(CONSTRAINT)						\
+"SELECT ?_contact nco:nameFamily(?_contact) "				\
+	"nco:nameGiven(?_contact) nco:nameAdditional(?_contact) "	\
 	"nco:nameHonorificPrefix(?_contact) "				\
 	"nco:nameHonorificSuffix(?_contact) "				\
-"(SELECT GROUP_CONCAT(fn:concat("					\
-	"tracker:coalesce(nco:pobox(?aff_addr), \"\"), \";\","		\
-	"tracker:coalesce(nco:extendedAddress(?aff_addr), \"\"), \";\","\
-	"tracker:coalesce(nco:streetAddress(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:locality(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:region(?aff_addr), \"\"), \";\","		\
-	"tracker:coalesce(nco:postalcode(?aff_addr), \"\"), \";\","	\
-	"tracker:coalesce(nco:country(?aff_addr), \"\"), "		\
-	"\"\31\", rdfs:label(?c_role) ), "				\
-	"\"\30\") "							\
-	"WHERE {"							\
-	"?_contact nco:hasAffiliation ?c_role . "			\
-	"?c_role nco:hasPostalAddress ?aff_addr"			\
-	"}) "								\
-	"nco:birthDate(?_contact) "					\
-	"nco:nickname(?_contact) "					\
-"(SELECT GROUP_CONCAT(fn:concat( "					\
-	"?url_value, \"\31\", ?aff_type "				\
-	"), \"\30\") "							\
-	"WHERE {"							\
-		"?_contact nco:hasAffiliation ?c_role . "		\
-		"?c_role nco:url ?url_value . "				\
-		"?c_role rdfs:label ?aff_type . "			\
-"})"									\
-	"nie:url(nco:photo(?_contact)) "				\
-	"nco:role(?_role) "						\
-	"nco:contactUID(?_contact) "					\
-	"nco:title(?_role) "						\
-	"rdfs:label(?_role) "						\
-	"nco:fullname(nco:org(?_role)) "				\
-	"nco:department(?_role) "					\
-"(SELECT GROUP_CONCAT(fn:concat(?emailaddress,\"\31\","			\
-	"rdfs:label(?c_role)),"						\
-	"\"\30\") "							\
-	"WHERE { "							\
-	"?_contact nco:hasAffiliation ?c_role . "			\
-	"?c_role nco:hasEmailAddress "					\
-	"		[ nco:emailAddress ?emailaddress ] "		\
-	"}) "								\
-	"nmo:receivedDate(?_call) "					\
-	"nmo:isSent(?_call) "						\
-	"nmo:isAnswered(?_call) "					\
-	"fn:concat(tracker:coalesce(?_ncontact, \"\"),"			\
-	"tracker:coalesce(?_unb_contact, \"\"))"			\
-	" "								\
-"WHERE { "								\
-"{ "									\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:to ?_ncontact ; "						\
-	"nmo:isSent true . "						\
-	"?_contact a nco:PersonContact ; "				\
-	"nco:hasPhoneNumber ?_number . "				\
-	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-"} UNION { "								\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:to ?_ncontact ; "						\
-	"nmo:isSent true . "						\
-	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:hasAffiliation ?_role . "			\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum . "			\
-	"?_number maemo:localPhoneNumber ?_realnum . "			\
-"} UNION { "								\
-	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:to ?_unb_contact ; "					\
-	"nmo:isSent true . "						\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasPhoneNumber ?_number . } "				\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum ."			\
-	"?_number maemo:localPhoneNumber ?_realnum . }"			\
-	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
-"} "									\
-"} "									\
+	"nco:phoneNumber(?_cpn) "					\
+CALLS_CONSTRAINTS(CONSTRAINT)						\
 "ORDER BY DESC(nmo:sentDate(?_call)) "
 
-#define OUTGOING_CALLS_LIST						\
-	"SELECT ?c nco:nameFamily(?c) "					\
-	"nco:nameGiven(?c) nco:nameAdditional(?c) "			\
-	"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 . "					\
-	"} 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 ?no . "				\
-		"?h maemo:localPhoneNumber ?num . "			\
-		"?no maemo:localPhoneNumber ?num . "			\
-	"}"								\
-	"} GROUP BY ?call ORDER BY DESC(nmo:sentDate(?call))"
-
-#define COMBINED_CALLS_QUERY						\
+#define CALLS_QUERY(CONSTRAINT)						\
 "SELECT "								\
 "(SELECT fn:concat(rdf:type(?role_number),"				\
 	"\"\31\", nco:phoneNumber(?role_number))"			\
@@ -587,6 +199,7 @@
 	"	FILTER (?role_number = ?_number)"			\
 	"} UNION { "							\
 		"?_unb_contact nco:hasPhoneNumber ?role_number . "	\
+	"	FILTER (!bound(?_role)) "				\
 	"}"								\
 "} GROUP BY nco:phoneNumber(?role_number) ) "				\
 	"nco:fullname(?_contact) "					\
@@ -639,137 +252,40 @@
 	"nmo:isAnswered(?_call) "					\
 	"fn:concat(tracker:coalesce(?_ncontact, \"\"),"			\
 	"tracker:coalesce(?_unb_contact, \"\"))"			\
-	" "								\
-"WHERE { "								\
-"{ "									\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:to ?_ncontact ; "						\
-	"nmo:isSent true . "						\
-	"?_contact a nco:PersonContact ; "				\
-	"nco:hasPhoneNumber ?_number . "				\
-	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-"} UNION { "								\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:to ?_ncontact ; "						\
-	"nmo:isSent true . "						\
-	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:hasAffiliation ?_role . "			\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum . "			\
-	"?_number maemo:localPhoneNumber ?_realnum . "			\
-"} UNION { "								\
-	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:to ?_unb_contact ; "					\
-	"nmo:isSent true . "						\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasPhoneNumber ?_number . } "				\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum ."			\
-	"?_number maemo:localPhoneNumber ?_realnum . }"			\
-	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
-"} UNION { "								\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_number . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_ncontact ; "					\
-	"nmo:isSent false . "						\
-	"?_contact a nco:PersonContact ; "				\
-	"nco:hasPhoneNumber ?_number . "				\
-	"OPTIONAL { ?_contact nco:hasAffiliation ?_role .} "		\
-"} UNION { "								\
-	"?_ncontact a nco:Contact . "					\
-	"?_ncontact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_ncontact ; "					\
-	"nmo:isSent false . "						\
-	"?_contact a nco:PersonContact . "				\
-	"?_contact nco:hasAffiliation ?_role . "			\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum . "			\
-	"?_number maemo:localPhoneNumber ?_realnum . "			\
-"} UNION { "								\
-	"?_unb_contact a nco:Contact . "				\
-	"?_unb_contact nco:hasPhoneNumber ?_other . "			\
-	"?_call a nmo:Call ; "						\
-	"nmo:from ?_unb_contact ; "					\
-	"nmo:isSent false . "						\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasPhoneNumber ?_number . } "				\
-	"OPTIONAL {?_contact a nco:PersonContact ; "			\
-	"nco:hasAffiliation ?_role . "					\
-	"?_role nco:hasPhoneNumber ?_number . "				\
-	"?_other maemo:localPhoneNumber ?_realnum ."			\
-	"?_number maemo:localPhoneNumber ?_realnum . }"			\
-	"FILTER ( !bound(?_contact) && !bound(?_role) ) "		\
-"} "									\
-"} "									\
+CALLS_CONSTRAINTS(CONSTRAINT)						\
 "ORDER BY DESC(nmo:sentDate(?_call)) "
 
-#define COMBINED_CALLS_LIST						\
-	"SELECT ?c nco:nameFamily(?c) nco:nameGiven(?c) "		\
-	"nco:nameAdditional(?c) 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 . "				\
-		"} 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 ?no . "			\
-			"?h maemo:localPhoneNumber ?num . "		\
-			"?no maemo:localPhoneNumber ?num . "		\
-		"}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 ?no . "			\
-			"?h maemo:localPhoneNumber ?num . "		\
-			"?no maemo:localPhoneNumber ?num . "		\
-		"}"							\
-	"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
+#define MISSED_CONSTRAINT		\
+"?_call nmo:from ?_unb_contact . "	\
+"?_call nmo:isSent false . "		\
+"?_call nmo:isAnswered false . "
+
+#define INCOMING_CONSTRAINT		\
+"?_call nmo:from ?_unb_contact . "	\
+"?_call nmo:isSent false . "		\
+"?_call nmo:isAnswered true . "
+
+#define OUTGOING_CONSTRAINT		\
+"?_call nmo:to ?_unb_contact . "	\
+"?_call nmo:isSent true . "
+
+#define COMBINED_CONSTRAINT			\
+"{ "						\
+"	?_call nmo:from ?_unb_contact .  "	\
+"	?_call nmo:isSent false "		\
+"} UNION { "					\
+"	?_call nmo:to ?_unb_contact . "		\
+"	?_call nmo:isSent true "		\
+"} "
+
+#define MISSED_CALLS_QUERY CALLS_QUERY(MISSED_CONSTRAINT)
+#define MISSED_CALLS_LIST CALLS_LIST(MISSED_CONSTRAINT)
+#define INCOMING_CALLS_QUERY CALLS_QUERY(INCOMING_CONSTRAINT)
+#define INCOMING_CALLS_LIST CALLS_LIST(INCOMING_CONSTRAINT)
+#define OUTGOING_CALLS_QUERY CALLS_QUERY(OUTGOING_CONSTRAINT)
+#define OUTGOING_CALLS_LIST CALLS_LIST(OUTGOING_CONSTRAINT)
+#define COMBINED_CALLS_QUERY CALLS_QUERY(COMBINED_CONSTRAINT)
+#define COMBINED_CALLS_LIST CALLS_LIST(COMBINED_CONSTRAINT)
 
 #define CONTACTS_QUERY_FROM_URI						\
 "SELECT "								\
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 1/3] Move phonebook_req_finalize
From: Dmitriy Paliy @ 2011-05-18 15:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy

It is used in successive patch.
---
 plugins/phonebook-tracker.c |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 9431d8a..9c60ec3 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -1905,26 +1905,6 @@ done:
 	return path;
 }
 
-void phonebook_req_finalize(void *request)
-{
-	struct phonebook_data *data = request;
-
-	DBG("");
-
-	if (!data)
-		return;
-
-	/* canceling asynchronous operation on tracker if any is active */
-	if (data->query_canc) {
-		g_cancellable_cancel(data->query_canc);
-		g_object_unref(data->query_canc);
-	}
-
-	free_data_contacts(data);
-	g_free(data->req_name);
-	g_free(data);
-}
-
 static gboolean find_checked_number(GSList *numbers, const char *number)
 {
 	GSList *l;
@@ -1996,6 +1976,26 @@ done:
 	return 0;
 }
 
+void phonebook_req_finalize(void *request)
+{
+	struct phonebook_data *data = request;
+
+	DBG("");
+
+	if (!data)
+		return;
+
+	/* canceling asynchronous operation on tracker if any is active */
+	if (data->query_canc) {
+		g_cancellable_cancel(data->query_canc);
+		g_object_unref(data->query_canc);
+	}
+
+	free_data_contacts(data);
+	g_free(data->req_name);
+	g_free(data);
+}
+
 void *phonebook_pull(const char *name, const struct apparam_field *params,
 				phonebook_cb cb, void *user_data, int *err)
 {
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 2/3] Fix numbers GSlist to be used in new missed calls
From: Dmitriy Paliy @ 2011-05-18 15:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1305734288-4317-1-git-send-email-dmitriy.paliy@nokia.com>

It is possible that phonebook_pull_read is invoked several times
submitting multiple pull requests without closing PBAP object. E.g. when
maxlistcount value is small and size of call history is large enough.

The result is possibility of different data structures (gstring and
contact_data) to be mixed in a single GSlist that may lead to undefined
behaviour.
---
 plugins/phonebook-tracker.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 9c60ec3..52ed31b 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -948,6 +948,7 @@ struct phonebook_data {
 	gboolean vcardentry;
 	const struct apparam_field *params;
 	GSList *contacts;
+	GSList *numbers;
 	phonebook_cache_ready_cb ready_cb;
 	phonebook_entry_cb entry_cb;
 	int newmissedcalls;
@@ -1923,6 +1924,13 @@ static void gstring_free_helper(gpointer data, gpointer user_data)
 	g_string_free(data, TRUE);
 }
 
+static void free_data_numbers(struct phonebook_data *data)
+{
+	g_slist_foreach(data->numbers, gstring_free_helper, NULL);
+	g_slist_free(data->numbers);
+	data->numbers = NULL;
+}
+
 static int pull_newmissedcalls(const char **reply, int num_fields,
 							void *user_data)
 {
@@ -1934,12 +1942,12 @@ static int pull_newmissedcalls(const char **reply, int num_fields,
 	if (num_fields < 0 || reply == NULL)
 		goto done;
 
-	if (!find_checked_number(data->contacts, reply[1])) {
+	if (!find_checked_number(data->numbers, reply[1])) {
 		if (g_strcmp0(reply[2], "false") == 0)
 			data->newmissedcalls++;
 		else {
 			GString *number = g_string_new(reply[1]);
-			data->contacts = g_slist_append(data->contacts,
+			data->numbers = g_slist_append(data->numbers,
 								number);
 		}
 	}
@@ -1947,9 +1955,7 @@ static int pull_newmissedcalls(const char **reply, int num_fields,
 
 done:
 	DBG("newmissedcalls %d", data->newmissedcalls);
-	g_slist_foreach(data->contacts, gstring_free_helper, NULL);
-	g_slist_free(data->contacts);
-	data->contacts = NULL;
+	free_data_numbers(data);
 
 	if (num_fields < 0) {
 		data->cb(NULL, 0, num_fields, 0, TRUE, data->user_data);
@@ -1991,6 +1997,7 @@ void phonebook_req_finalize(void *request)
 		g_object_unref(data->query_canc);
 	}
 
+	free_data_numbers(data);
 	free_data_contacts(data);
 	g_free(data->req_name);
 	g_free(data);
-- 
1.7.4.1


^ permalink raw reply related

* [PATCH 3/3] Change append to prepend in pull_newmissedcalls
From: Dmitriy Paliy @ 2011-05-18 15:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Dmitriy Paliy
In-Reply-To: <1305734288-4317-1-git-send-email-dmitriy.paliy@nokia.com>

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

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 52ed31b..d5cdc15 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -1947,7 +1947,7 @@ static int pull_newmissedcalls(const char **reply, int num_fields,
 			data->newmissedcalls++;
 		else {
 			GString *number = g_string_new(reply[1]);
-			data->numbers = g_slist_append(data->numbers,
+			data->numbers = g_slist_prepend(data->numbers,
 								number);
 		}
 	}
-- 
1.7.4.1


^ permalink raw reply related

* Re: [PATCH v2 1/2] Fix empty parameter list in functions declarations
From: Johan Hedberg @ 2011-05-18 16:09 UTC (permalink / raw)
  To: Szymon Janc; +Cc: linux-bluetooth, par-gunnar.p.hjalmdahl
In-Reply-To: <1305700967-13217-1-git-send-email-szymon.janc@tieto.com>

Hi Szymon,

On Wed, May 18, 2011, Szymon Janc wrote:
> ---
>  lib/sdp.c           |    2 +-
>  src/log.c           |    2 +-
>  src/log.h           |    2 +-
>  src/sdpd-database.c |    2 +-
>  test/avtest.c       |    2 +-
>  tools/avinfo.c      |    2 +-
>  6 files changed, 6 insertions(+), 6 deletions(-)

Both patches have been pushed upstream. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH v4 03/12] Move legacy verification to a new function
From: Claudio Takahasi @ 2011-05-18 19:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656720-9622-1-git-send-email-claudio.takahasi@openbossa.org>

Hi,

On Tue, May 17, 2011 at 3:25 PM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> ---
>  src/adapter.c |   35 ++++++++++++++++++++++-------------
>  1 files changed, 22 insertions(+), 13 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 3188974..d4e1121 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -3002,6 +3002,26 @@ void adapter_update_device_from_info(struct btd_adapter *adapter,
>        adapter_emit_device_found(adapter, dev);
>  }
>
> +static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
> +                                       gboolean eir, gboolean name)

Based on the discussion in the IRC, a new patch series will be sent
replacing the booleans("name" and "data") by pointers.

Claudio.

> +{
> +       unsigned char features[8];
> +
> +       if (eir)
> +               return FALSE;
> +
> +       if (name == FALSE)
> +               return TRUE;
> +
> +       if (read_remote_features(local, peer, NULL, features) < 0)
> +               return TRUE;
> +
> +       if (features[0] & 0x01)
> +               return FALSE;
> +       else
> +               return TRUE;
> +}
> +
>  void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
>                                uint32_t class, int8_t rssi, uint8_t *data)
>  {
> @@ -3011,7 +3031,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
>        char *alias, *name;
>        gboolean new_dev, legacy;
>        name_status_t name_status;
> -       unsigned char features[8];
>        const char *dev_name;
>        int err;
>
> @@ -3037,18 +3056,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
>        create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "names");
>        name = textfile_get(filename, peer_addr);
>
> -       if (data)
> -               legacy = FALSE;
> -       else if (name == NULL)
> -               legacy = TRUE;
> -       else if (read_remote_features(&adapter->bdaddr, bdaddr, NULL,
> -                                                       features) == 0) {
> -               if (features[0] & 0x01)
> -                       legacy = FALSE;
> -               else
> -                       legacy = TRUE;
> -       } else
> -               legacy = TRUE;
> +       legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr,
> +                               data ? TRUE : FALSE, name ? TRUE : FALSE);
>
>        /* Complete EIR names are always used. Shortened EIR names are only
>         * used if there is no name already in storage. */
> --
> 1.7.5.rc3
>
>

^ permalink raw reply

* Re: [PATCH] Fix newmissedcalls handling for large responses
From: Johan Hedberg @ 2011-05-18 19:19 UTC (permalink / raw)
  To: Radoslaw Jablonski; +Cc: linux-bluetooth
In-Reply-To: <1305716103-14564-1-git-send-email-ext-jablonski.radoslaw@nokia.com>

Hi Radek,

On Wed, May 18, 2011, Radoslaw Jablonski wrote:
> Previously pull_newmissedcalls was called for every part when
> processing large response (more that one part of results) and
> number of 'newmissedcalls' was wrong in that scenario.
> Now newmissedcalls will be counted only once (during generating
> first part of mch results).
> ---
>  plugins/phonebook-tracker.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)

This conflicts with Slawek's patch. Are both still valid?

Johan

^ permalink raw reply

* [PATCH v5 03/12] Move legacy verification to a new function
From: Claudio Takahasi @ 2011-05-18 19:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <BANLkTi=VZH-H4m8Aynn47nPYSs-fKFYRBA@mail.gmail.com>

---
 src/adapter.c |   34 +++++++++++++++++++++-------------
 1 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 3188974..5660097 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3002,6 +3002,26 @@ void adapter_update_device_from_info(struct btd_adapter *adapter,
 	adapter_emit_device_found(adapter, dev);
 }
 
+static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
+					const uint8_t *eir, const char *name)
+{
+	unsigned char features[8];
+
+	if (eir)
+		return FALSE;
+
+	if (name == NULL)
+		return TRUE;
+
+	if (read_remote_features(local, peer, NULL, features) < 0)
+		return TRUE;
+
+	if (features[0] & 0x01)
+		return FALSE;
+	else
+		return TRUE;
+}
+
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 				uint32_t class, int8_t rssi, uint8_t *data)
 {
@@ -3011,7 +3031,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	char *alias, *name;
 	gboolean new_dev, legacy;
 	name_status_t name_status;
-	unsigned char features[8];
 	const char *dev_name;
 	int err;
 
@@ -3037,18 +3056,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "names");
 	name = textfile_get(filename, peer_addr);
 
-	if (data)
-		legacy = FALSE;
-	else if (name == NULL)
-		legacy = TRUE;
-	else if (read_remote_features(&adapter->bdaddr, bdaddr, NULL,
-							features) == 0) {
-		if (features[0] & 0x01)
-			legacy = FALSE;
-		else
-			legacy = TRUE;
-	} else
-		legacy = TRUE;
+	legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data, name);
 
 	/* Complete EIR names are always used. Shortened EIR names are only
 	 * used if there is no name already in storage. */
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 04/12] Cleanup read name and alias from storage
From: Claudio Takahasi @ 2011-05-18 19:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656736-9658-1-git-send-email-claudio.takahasi@openbossa.org>

---
 src/adapter.c |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 5660097..dacb1dd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3022,13 +3022,24 @@ static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
 		return TRUE;
 }
 
+static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
+{
+	char local_addr[18], peer_addr[18], filename[PATH_MAX + 1];
+
+	ba2str(local, local_addr);
+	ba2str(peer, peer_addr);
+
+	create_name(filename, PATH_MAX, STORAGEDIR, local_addr, file);
+
+	return textfile_get(filename, peer_addr);
+}
+
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 				uint32_t class, int8_t rssi, uint8_t *data)
 {
-	char local_addr[18], peer_addr[18], filename[PATH_MAX + 1];
 	struct remote_dev_info *dev;
 	struct eir_data eir_data;
-	char *alias, *name;
+	char *name;
 	gboolean new_dev, legacy;
 	name_status_t name_status;
 	const char *dev_name;
@@ -3047,14 +3058,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	else
 		name_status = NAME_NOT_REQUIRED;
 
-	ba2str(&adapter->bdaddr, local_addr);
-	ba2str(bdaddr, peer_addr);
-
-	create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "aliases");
-	alias = textfile_get(filename, peer_addr);
-
-	create_name(filename, PATH_MAX, STORAGEDIR, local_addr, "names");
-	name = textfile_get(filename, peer_addr);
+	name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
 
 	legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data, name);
 
@@ -3074,18 +3078,22 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	dev = get_found_dev(adapter, bdaddr, &new_dev);
 
 	if (new_dev) {
+		char *alias;
 		if (dev_name)
 			dev->name = g_strdup(dev_name);
 
-		if (alias)
+		alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
+		if (alias) {
 			dev->alias = g_strdup(alias);
+			free(alias);
+		}
 
 		dev->le = FALSE;
 		dev->class = class;
 		dev->legacy = legacy;
 		dev->name_status = name_status;
 	} else if (dev->rssi == rssi)
-		return;
+		goto done;
 
 	dev->rssi = rssi;
 
@@ -3096,6 +3104,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	g_slist_foreach(eir_data.services, dev_prepend_uuid, dev);
 
 	adapter_emit_device_found(adapter, dev);
+
+done:
+	free(name);
 }
 
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 05/12] Don't resolve name if the name is in the storage
From: Claudio Takahasi @ 2011-05-18 19:38 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656749-9695-1-git-send-email-claudio.takahasi@openbossa.org>

---
 src/adapter.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index dacb1dd..f1d9148 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3052,16 +3052,16 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 		return;
 	}
 
-	/* the inquiry result can be triggered by NON D-Bus client */
-	if (main_opts.name_resolv && adapter_has_discov_sessions(adapter))
-		name_status = NAME_REQUIRED;
-	else
-		name_status = NAME_NOT_REQUIRED;
-
 	name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
 
 	legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data, name);
 
+	if (!name && main_opts.name_resolv &&
+			adapter_has_discov_sessions(adapter))
+		name_status = NAME_REQUIRED;
+	else
+		name_status = NAME_NOT_REQUIRED;
+
 	/* Complete EIR names are always used. Shortened EIR names are only
 	 * used if there is no name already in storage. */
 	dev_name = name;
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 06/12] Unify inquiry results and advertises
From: Claudio Takahasi @ 2011-05-18 19:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656757-9731-1-git-send-email-claudio.takahasi@openbossa.org>

Adapter needs to have only one method to allow discovery results
integration for both interfaces: hciops and mgmtops. This patch
moves the code related to advertises parsing to the same function
that handles inquiry results.
---
 src/adapter.c |   67 ++++++++++++++++++--------------------------------------
 src/adapter.h |    7 +----
 src/event.c   |   25 +++-----------------
 3 files changed, 28 insertions(+), 71 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index f1d9148..e77d3e9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2966,42 +2966,6 @@ static void dev_prepend_uuid(gpointer data, gpointer user_data)
 	dev->services = g_slist_prepend(dev->services, g_strdup(new_uuid));
 }
 
-void adapter_update_device_from_info(struct btd_adapter *adapter,
-					bdaddr_t bdaddr, int8_t rssi,
-					const char *name, GSList *services,
-					int flags)
-{
-	struct remote_dev_info *dev;
-	gboolean new_dev;
-
-	dev = get_found_dev(adapter, &bdaddr, &new_dev);
-
-	if (new_dev)
-		dev->le = TRUE;
-	else if (dev->rssi == rssi)
-		return;
-
-	dev->rssi = rssi;
-
-	adapter->found_devices = g_slist_sort(adapter->found_devices,
-						(GCompareFunc) dev_rssi_cmp);
-
-	g_slist_foreach(services, remove_same_uuid, dev);
-	g_slist_foreach(services, dev_prepend_uuid, dev);
-
-	if (flags >= 0)
-		dev->flags = flags;
-
-	if (name) {
-		g_free(dev->name);
-		dev->name = g_strdup(name);
-	}
-
-	/* FIXME: check if other information was changed before emitting the
-	 * signal */
-	adapter_emit_device_found(adapter, dev);
-}
-
 static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
 					const uint8_t *eir, const char *name)
 {
@@ -3035,13 +2999,14 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
 }
 
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
-				uint32_t class, int8_t rssi, uint8_t *data)
+					uint32_t class, int8_t rssi,
+					uint8_t *data, size_t eir_size)
 {
 	struct remote_dev_info *dev;
 	struct eir_data eir_data;
 	char *name;
-	gboolean new_dev, legacy;
-	name_status_t name_status;
+	gboolean new_dev, legacy, le;
+	name_status_t name_status = NAME_NOT_REQUIRED;
 	const char *dev_name;
 	int err;
 
@@ -3054,13 +3019,21 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 
 	name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
 
-	legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data, name);
+	if (eir_data.flags < 0) {
+		le = FALSE;
 
-	if (!name && main_opts.name_resolv &&
-			adapter_has_discov_sessions(adapter))
-		name_status = NAME_REQUIRED;
-	else
-		name_status = NAME_NOT_REQUIRED;
+		legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data,
+									name);
+
+		if (!name && main_opts.name_resolv &&
+				adapter_has_discov_sessions(adapter))
+			name_status = NAME_REQUIRED;
+		else
+			name_status = NAME_NOT_REQUIRED;
+	} else {
+		le = TRUE;
+		legacy = FALSE;
+	}
 
 	/* Complete EIR names are always used. Shortened EIR names are only
 	 * used if there is no name already in storage. */
@@ -3092,6 +3065,10 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 		dev->class = class;
 		dev->legacy = legacy;
 		dev->name_status = name_status;
+
+		if (eir_data.flags >= 0)
+			dev->flags = eir_data.flags;
+
 	} else if (dev->rssi == rssi)
 		goto done;
 
diff --git a/src/adapter.h b/src/adapter.h
index 4785d5c..4c07e92 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -108,12 +108,9 @@ int adapter_get_state(struct btd_adapter *adapter);
 int adapter_get_discover_type(struct btd_adapter *adapter);
 struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
 						struct remote_dev_info *match);
-void adapter_update_device_from_info(struct btd_adapter *adapter,
-					bdaddr_t bdaddr, int8_t rssi,
-					const char *name, GSList *services,
-					int flags);
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
-				uint32_t class, int8_t rssi, uint8_t *data);
+					uint32_t class, int8_t rssi,
+					uint8_t *data, size_t eir_size);
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 void adapter_emit_device_found(struct btd_adapter *adapter,
 						struct remote_dev_info *dev);
diff --git a/src/event.c b/src/event.c
index 2c893f0..115b285 100644
--- a/src/event.c
+++ b/src/event.c
@@ -281,19 +281,10 @@ void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
 	device_simple_pairing_complete(device, status);
 }
 
-static void free_eir_data(struct eir_data *eir)
-{
-	g_slist_foreach(eir->services, (GFunc) g_free, NULL);
-	g_slist_free(eir->services);
-	g_free(eir->name);
-}
-
 void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
 {
 	struct btd_adapter *adapter;
-	struct eir_data eir_data;
 	int8_t rssi;
-	int err;
 
 	adapter = manager_find_adapter(local);
 	if (adapter == NULL) {
@@ -301,19 +292,10 @@ void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
 		return;
 	}
 
-	memset(&eir_data, 0, sizeof(eir_data));
-	err = eir_parse(&eir_data, info->data, info->length);
-	if (err < 0)
-		error("Error parsing advertising data: %s (%d)",
-							strerror(-err), -err);
-
 	rssi = *(info->data + info->length);
 
-	adapter_update_device_from_info(adapter, info->bdaddr, rssi,
-					eir_data.name, eir_data.services,
-					eir_data.flags);
-
-	free_eir_data(&eir_data);
+	adapter_update_found_devices(adapter, &info->bdaddr, 0, rssi,
+						info->data, info->length);
 }
 
 static void update_lastseen(bdaddr_t *sba, bdaddr_t *dba)
@@ -355,7 +337,8 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	if (data)
 		write_remote_eir(local, peer, data);
 
-	adapter_update_found_devices(adapter, peer, class, rssi, data);
+	adapter_update_found_devices(adapter, peer, class, rssi,
+						data, EIR_DATA_LENGTH);
 }
 
 void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 07/12] Fix memory leak of EIR data
From: Claudio Takahasi @ 2011-05-18 19:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656764-9767-1-git-send-email-claudio.takahasi@openbossa.org>

---
 src/adapter.c |    1 +
 src/eir.c     |    7 +++++++
 src/eir.h     |    1 +
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index e77d3e9..83b010d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3084,6 +3084,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 
 done:
 	free(name);
+	eir_data_free(&eir_data);
 }
 
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr)
diff --git a/src/eir.c b/src/eir.c
index d827c7e..2fbd919 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -44,6 +44,13 @@
 #define EIR_TX_POWER                0x0A  /* transmit power level */
 #define EIR_DEVICE_ID               0x10  /* device ID */
 
+void eir_data_free(struct eir_data *eir)
+{
+	g_slist_foreach(eir->services, (GFunc) g_free, NULL);
+	g_slist_free(eir->services);
+	g_free(eir->name);
+}
+
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
 {
 	uint16_t len = 0;
diff --git a/src/eir.h b/src/eir.h
index c7699eb..aacd16a 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -36,6 +36,7 @@ struct eir_data {
 	gboolean name_complete;
 };
 
+void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length);
 void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 			uint16_t did_product, uint16_t did_version,
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 08/12] Remove btd_event_advertising_report
From: Claudio Takahasi @ 2011-05-18 19:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1305656772-9803-1-git-send-email-claudio.takahasi@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

Advertises should be notified using btd_event_device_found function
to keep the compatibility with mgmtops plugin.
---
 plugins/hciops.c |   13 ++++++++++---
 src/event.c      |   17 -----------------
 src/event.h      |    1 -
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index 07643a1..65ad4f3 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -2171,19 +2171,26 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
 {
 	struct dev_info *dev = &devs[index];
 	le_advertising_info *info;
-	uint8_t num_reports;
+	uint8_t num_reports, rssi;
 	const uint8_t RSSI_SIZE = 1;
 
 	num_reports = meta->data[0];
 
 	info = (le_advertising_info *) &meta->data[1];
-	btd_event_advertising_report(&dev->bdaddr, info);
+	rssi = *(info->data + info->length);
+
+	btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
+								info->data);
+
 	num_reports--;
 
 	while (num_reports--) {
 		info = (le_advertising_info *) (info->data + info->length +
 								RSSI_SIZE);
-		btd_event_advertising_report(&dev->bdaddr, info);
+		rssi = *(info->data + info->length);
+
+		btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
+								info->data);
 	}
 }
 
diff --git a/src/event.c b/src/event.c
index 115b285..3ee8802 100644
--- a/src/event.c
+++ b/src/event.c
@@ -281,23 +281,6 @@ void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
 	device_simple_pairing_complete(device, status);
 }
 
-void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
-{
-	struct btd_adapter *adapter;
-	int8_t rssi;
-
-	adapter = manager_find_adapter(local);
-	if (adapter == NULL) {
-		error("No matching adapter found");
-		return;
-	}
-
-	rssi = *(info->data + info->length);
-
-	adapter_update_found_devices(adapter, &info->bdaddr, 0, rssi,
-						info->data, info->length);
-}
-
 static void update_lastseen(bdaddr_t *sba, bdaddr_t *dba)
 {
 	time_t t;
diff --git a/src/event.h b/src/event.h
index 005d8a7..22c199e 100644
--- a/src/event.h
+++ b/src/event.h
@@ -23,7 +23,6 @@
  */
 
 int btd_event_request_pin(bdaddr_t *sba, bdaddr_t *dba);
-void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info);
 void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 						int8_t rssi, uint8_t *data);
 void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean legacy);
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 09/12] Change the order to write/read the remote's name
From: Claudio Takahasi @ 2011-05-18 19:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656780-9839-1-git-send-email-claudio.takahasi@openbossa.org>

When discovering, write the EIR "complete" name first before to read
the name. Only names retrieved from EIR "complete" name and HCI Remote
Name Request Complete event are stored. This patch doesn't change the
final result: the value of the name sent in the signal.
---
 src/adapter.c |   19 +++++--------------
 1 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 83b010d..b1cf603 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3007,7 +3007,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	char *name;
 	gboolean new_dev, legacy, le;
 	name_status_t name_status = NAME_NOT_REQUIRED;
-	const char *dev_name;
 	int err;
 
 	memset(&eir_data, 0, sizeof(eir_data));
@@ -3017,6 +3016,9 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 		return;
 	}
 
+	if (eir_data.name != NULL && eir_data.name_complete)
+		write_device_name(&adapter->bdaddr, bdaddr, eir_data.name);
+
 	name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
 
 	if (eir_data.flags < 0) {
@@ -3035,23 +3037,12 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 		legacy = FALSE;
 	}
 
-	/* Complete EIR names are always used. Shortened EIR names are only
-	 * used if there is no name already in storage. */
-	dev_name = name;
-	if (eir_data.name != NULL) {
-		if (eir_data.name_complete) {
-			write_device_name(&adapter->bdaddr, bdaddr,
-							eir_data.name);
-			name_status = NAME_NOT_REQUIRED;
-			dev_name = eir_data.name;
-		} else if (name == NULL)
-			dev_name = eir_data.name;
-	}
-
 	dev = get_found_dev(adapter, bdaddr, &new_dev);
 
 	if (new_dev) {
+		const char *dev_name = (name ? name : eir_data.name);
 		char *alias;
+
 		if (dev_name)
 			dev->name = g_strdup(dev_name);
 
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 10/12] Cleanup inserting new device found entry
From: Claudio Takahasi @ 2011-05-18 19:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1305656789-9875-1-git-send-email-claudio.takahasi@openbossa.org>

---
 src/adapter.c |   97 +++++++++++++++++++++++++++-----------------------------
 1 files changed, 47 insertions(+), 50 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index b1cf603..dc051cd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2914,29 +2914,24 @@ void adapter_emit_device_found(struct btd_adapter *adapter,
 	g_free(alias);
 }
 
-static struct remote_dev_info *get_found_dev(struct btd_adapter *adapter,
-						const bdaddr_t *bdaddr,
-						gboolean *new_dev)
+static struct remote_dev_info *found_device_new(const bdaddr_t *bdaddr,
+					gboolean le, const char *name,
+					const char *alias, uint32_t class,
+					gboolean legacy, name_status_t status,
+					int flags)
 {
-	struct remote_dev_info *dev, match;
+	struct remote_dev_info *dev;
 
-	memset(&match, 0, sizeof(struct remote_dev_info));
-	bacpy(&match.bdaddr, bdaddr);
-	match.name_status = NAME_ANY;
-
-	dev = adapter_search_found_devices(adapter, &match);
-	if (dev) {
-		*new_dev = FALSE;
-		/* Out of range list update */
-		adapter->oor_devices = g_slist_remove(adapter->oor_devices,
-							dev);
-	} else {
-		*new_dev = TRUE;
-		dev = g_new0(struct remote_dev_info, 1);
-		bacpy(&dev->bdaddr, bdaddr);
-		adapter->found_devices = g_slist_prepend(adapter->found_devices,
-									dev);
-	}
+	dev = g_new0(struct remote_dev_info, 1);
+	bacpy(&dev->bdaddr, bdaddr);
+	dev->le = le;
+	dev->name = g_strdup(name);
+	dev->alias = g_strdup(alias);
+	dev->class = class;
+	dev->legacy = legacy;
+	dev->name_status = status;
+	if (flags >= 0)
+		dev->flags = flags;
 
 	return dev;
 }
@@ -3002,11 +2997,11 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 					uint32_t class, int8_t rssi,
 					uint8_t *data, size_t eir_size)
 {
-	struct remote_dev_info *dev;
+	struct remote_dev_info *dev, match;
 	struct eir_data eir_data;
-	char *name;
-	gboolean new_dev, legacy, le;
-	name_status_t name_status = NAME_NOT_REQUIRED;
+	char *alias, *name;
+	gboolean legacy, le;
+	name_status_t name_status;
 	int err;
 
 	memset(&eir_data, 0, sizeof(eir_data));
@@ -3019,6 +3014,25 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	if (eir_data.name != NULL && eir_data.name_complete)
 		write_device_name(&adapter->bdaddr, bdaddr, eir_data.name);
 
+	/* Device already seen in the discovery session ? */
+	memset(&match, 0, sizeof(struct remote_dev_info));
+	bacpy(&match.bdaddr, bdaddr);
+	match.name_status = NAME_ANY;
+
+	dev = adapter_search_found_devices(adapter, &match);
+	if (dev) {
+		adapter->oor_devices = g_slist_remove(adapter->oor_devices,
+							dev);
+		if (dev->rssi != rssi)
+			goto done;
+
+		eir_data_free(&eir_data);
+
+		return;
+	}
+
+	/* New device in the discovery session */
+
 	name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
 
 	if (eir_data.flags < 0) {
@@ -3035,34 +3049,19 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	} else {
 		le = TRUE;
 		legacy = FALSE;
+		name_status = NAME_NOT_REQUIRED;
 	}
 
-	dev = get_found_dev(adapter, bdaddr, &new_dev);
-
-	if (new_dev) {
-		const char *dev_name = (name ? name : eir_data.name);
-		char *alias;
+	alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
 
-		if (dev_name)
-			dev->name = g_strdup(dev_name);
-
-		alias = read_stored_data(&adapter->bdaddr, bdaddr, "aliases");
-		if (alias) {
-			dev->alias = g_strdup(alias);
-			free(alias);
-		}
-
-		dev->le = FALSE;
-		dev->class = class;
-		dev->legacy = legacy;
-		dev->name_status = name_status;
+	dev = found_device_new(bdaddr, le, name, alias, class, legacy,
+						name_status, eir_data.flags);
+	free(name);
+	free(alias);
 
-		if (eir_data.flags >= 0)
-			dev->flags = eir_data.flags;
-
-	} else if (dev->rssi == rssi)
-		goto done;
+	adapter->found_devices = g_slist_prepend(adapter->found_devices, dev);
 
+done:
 	dev->rssi = rssi;
 
 	adapter->found_devices = g_slist_sort(adapter->found_devices,
@@ -3073,8 +3072,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 
 	adapter_emit_device_found(adapter, dev);
 
-done:
-	free(name);
 	eir_data_free(&eir_data);
 }
 
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 11/12] Replace EIR_DATA_LENGTH with HCI_MAX_EIR_LENGTH
From: Claudio Takahasi @ 2011-05-18 19:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1305656796-9911-1-git-send-email-claudio.takahasi@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

Both defines have the same value (240) and meaning.
---
 src/adapter.c |    2 +-
 src/eir.c     |    9 +++++----
 src/eir.h     |    2 --
 src/event.c   |    2 +-
 4 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index dc051cd..0210c30 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3005,7 +3005,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	int err;
 
 	memset(&eir_data, 0, sizeof(eir_data));
-	err = eir_parse(&eir_data, data, EIR_DATA_LENGTH);
+	err = eir_parse(&eir_data, data, HCI_MAX_EIR_LENGTH);
 	if (err < 0) {
 		error("Error parsing EIR data: %s (%d)", strerror(-err), -err);
 		return;
diff --git a/src/eir.c b/src/eir.c
index 2fbd919..7dfc444 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -27,6 +27,7 @@
 #include <glib.h>
 
 #include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
 #include <bluetooth/sdp.h>
 
 #include "glib-helper.h"
@@ -184,7 +185,7 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 			continue;
 
 		/* Stop if not enough space to put next UUID128 */
-		if ((len + 2 + SIZEOF_UUID128) > EIR_DATA_LENGTH) {
+		if ((len + 2 + SIZEOF_UUID128) > HCI_MAX_EIR_LENGTH) {
 			truncated = TRUE;
 			break;
 		}
@@ -229,7 +230,7 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 	GSList *l;
 	uint8_t *ptr = data;
 	uint16_t eir_len = 0;
-	uint16_t uuid16[EIR_DATA_LENGTH / 2];
+	uint16_t uuid16[HCI_MAX_EIR_LENGTH / 2];
 	int i, uuid_count = 0;
 	gboolean truncated = FALSE;
 	size_t name_len;
@@ -289,7 +290,7 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 			continue;
 
 		/* Stop if not enough space to put next UUID16 */
-		if ((eir_len + 2 + sizeof(uint16_t)) > EIR_DATA_LENGTH) {
+		if ((eir_len + 2 + sizeof(uint16_t)) > HCI_MAX_EIR_LENGTH) {
 			truncated = TRUE;
 			break;
 		}
@@ -322,6 +323,6 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 	}
 
 	/* Group all UUID128 types */
-	if (eir_len <= EIR_DATA_LENGTH - 2)
+	if (eir_len <= HCI_MAX_EIR_LENGTH - 2)
 		eir_generate_uuid128(uuids, ptr, &eir_len);
 }
diff --git a/src/eir.h b/src/eir.h
index aacd16a..ea38570 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -22,8 +22,6 @@
  *
  */
 
-#define EIR_DATA_LENGTH  240
-
 struct uuid_info {
 	uuid_t uuid;
 	uint8_t svc_hint;
diff --git a/src/event.c b/src/event.c
index 3ee8802..e28afa3 100644
--- a/src/event.c
+++ b/src/event.c
@@ -321,7 +321,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 		write_remote_eir(local, peer, data);
 
 	adapter_update_found_devices(adapter, peer, class, rssi,
-						data, EIR_DATA_LENGTH);
+						data, HCI_MAX_EIR_LENGTH);
 }
 
 void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
-- 
1.7.5.rc3


^ permalink raw reply related

* [PATCH v5 12/12] Drop variable EIR length
From: Claudio Takahasi @ 2011-05-18 19:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1305656803-9947-1-git-send-email-claudio.takahasi@openbossa.org>

From: Bruna Moreira <bruna.moreira@openbossa.org>

The functions eir_parse() and adapter_update_found_devices() now
assume that the EIR buffer has always 240 octets. For advertising
reports, the advertising data is stored on a buffer with 240 bytes,
padded with zeroes.
---
 plugins/hciops.c |   13 +++++++++----
 src/adapter.c    |    6 +++---
 src/adapter.h    |    4 ++--
 src/eir.c        |    8 ++++----
 src/eir.h        |    2 +-
 src/event.c      |    3 +--
 6 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/plugins/hciops.c b/plugins/hciops.c
index 65ad4f3..9b1225c 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -2171,7 +2171,7 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
 {
 	struct dev_info *dev = &devs[index];
 	le_advertising_info *info;
-	uint8_t num_reports, rssi;
+	uint8_t num_reports, rssi, eir[HCI_MAX_EIR_LENGTH];
 	const uint8_t RSSI_SIZE = 1;
 
 	num_reports = meta->data[0];
@@ -2179,8 +2179,10 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
 	info = (le_advertising_info *) &meta->data[1];
 	rssi = *(info->data + info->length);
 
-	btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
-								info->data);
+	memset(eir, 0, sizeof(eir));
+	memcpy(eir, info->data, info->length);
+
+	btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi, eir);
 
 	num_reports--;
 
@@ -2189,8 +2191,11 @@ static inline void le_advertising_report(int index, evt_le_meta_event *meta)
 								RSSI_SIZE);
 		rssi = *(info->data + info->length);
 
+		memset(eir, 0, sizeof(eir));
+		memcpy(eir, info->data, info->length);
+
 		btd_event_device_found(&dev->bdaddr, &info->bdaddr, 0, rssi,
-								info->data);
+									eir);
 	}
 }
 
diff --git a/src/adapter.c b/src/adapter.c
index 0210c30..c30febc 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2994,8 +2994,8 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
 }
 
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
-					uint32_t class, int8_t rssi,
-					uint8_t *data, size_t eir_size)
+						uint32_t class, int8_t rssi,
+						uint8_t *data)
 {
 	struct remote_dev_info *dev, match;
 	struct eir_data eir_data;
@@ -3005,7 +3005,7 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 	int err;
 
 	memset(&eir_data, 0, sizeof(eir_data));
-	err = eir_parse(&eir_data, data, HCI_MAX_EIR_LENGTH);
+	err = eir_parse(&eir_data, data);
 	if (err < 0) {
 		error("Error parsing EIR data: %s (%d)", strerror(-err), -err);
 		return;
diff --git a/src/adapter.h b/src/adapter.h
index 4c07e92..3526849 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -109,8 +109,8 @@ int adapter_get_discover_type(struct btd_adapter *adapter);
 struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
 						struct remote_dev_info *match);
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
-					uint32_t class, int8_t rssi,
-					uint8_t *data, size_t eir_size);
+						uint32_t class, int8_t rssi,
+						uint8_t *data);
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 void adapter_emit_device_found(struct btd_adapter *adapter,
 						struct remote_dev_info *dev);
diff --git a/src/eir.c b/src/eir.c
index 7dfc444..01b6ac5 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -52,7 +52,7 @@ void eir_data_free(struct eir_data *eir)
 	g_free(eir->name);
 }
 
-int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
+int eir_parse(struct eir_data *eir, uint8_t *eir_data)
 {
 	uint16_t len = 0;
 	size_t total;
@@ -69,10 +69,10 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
 	eir->flags = -1;
 
 	/* No EIR data to parse */
-	if (eir_data == NULL || eir_length == 0)
+	if (eir_data == NULL)
 		return 0;
 
-	while (len < eir_length - 1) {
+	while (len < HCI_MAX_EIR_LENGTH - 1) {
 		uint8_t field_len = eir_data[0];
 
 		/* Check for the end of EIR */
@@ -115,7 +115,7 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length)
 	}
 
 	/* Bail out if got incorrect length */
-	if (len > eir_length)
+	if (len > HCI_MAX_EIR_LENGTH)
 		return -EINVAL;
 
 	total = uuid16_count + uuid32_count + uuid128_count;
diff --git a/src/eir.h b/src/eir.h
index ea38570..d225973 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -35,7 +35,7 @@ struct eir_data {
 };
 
 void eir_data_free(struct eir_data *eir);
-int eir_parse(struct eir_data *eir, uint8_t *eir_data, size_t eir_length);
+int eir_parse(struct eir_data *eir, uint8_t *eir_data);
 void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 			uint16_t did_product, uint16_t did_version,
 			GSList *uuids, uint8_t *data);
diff --git a/src/event.c b/src/event.c
index e28afa3..2643a87 100644
--- a/src/event.c
+++ b/src/event.c
@@ -320,8 +320,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	if (data)
 		write_remote_eir(local, peer, data);
 
-	adapter_update_found_devices(adapter, peer, class, rssi,
-						data, HCI_MAX_EIR_LENGTH);
+	adapter_update_found_devices(adapter, peer, class, rssi, data);
 }
 
 void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
-- 
1.7.5.rc3


^ permalink raw reply related

* Re: [PATCH v2] Fix incorrect number of expected columns in a response to NEW_MISSED_CALLS_LIST
From: Johan Hedberg @ 2011-05-18 20:30 UTC (permalink / raw)
  To: Slawomir Bochenski; +Cc: linux-bluetooth
In-Reply-To: <1305710270-31716-1-git-send-email-lkslawek@gmail.com>

Hi Slawek,

On Wed, May 18, 2011, Slawomir Bochenski wrote:
> This fixes error "GLIB CRITICAL ** Tracker -
> tracker_db_cursor_get_value_type: assertion `column < n_columns' failed"
> occurring when pulling phone book or doing listing for missed calls. The
> number of expected columns in reply to NEW_MISSED_CALLS_LIST query was
> incorrectly set to PULL_QUERY_COL_AMOUNT (23) but the query actually
> returns 3 columns.
> ---
> Just a little modification of a commit message.
> 
>  plugins/phonebook-tracker.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)

Applied, but I had to first edit your commit message summary line to be
considerably shorter.

Johan

^ permalink raw reply

* Re: [PATCH] Rewrite of PBAP call history queries
From: Johan Hedberg @ 2011-05-18 20:42 UTC (permalink / raw)
  To: Slawomir Bochenski; +Cc: linux-bluetooth
In-Reply-To: <1305723910-13168-1-git-send-email-lkslawek@gmail.com>

Hi Slawek,

On Wed, May 18, 2011, Slawomir Bochenski wrote:
> Graph patterns used in queries for PullPhonebook and PullvCardListing in
> case of call history are now rewritten to share the same code and be
> simpler - previously they were doing almost the same, but exact code
> differed. So in this patch repeating parts of queries were reduced to one
> place for easy management.
> 
> Also new queries fix the behaviour in situation when there is more than
> one contact matching a phone number from call history entry - in this
> case no contact data is returned instead of returning random contact as
> it was the case before.
> ---
>  plugins/phonebook-tracker.c |  600 ++++--------------------------------------
>  1 files changed, 58 insertions(+), 542 deletions(-)

Applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH v5 06/12] Unify inquiry results and advertises
From: Johan Hedberg @ 2011-05-18 20:53 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1305747562-19595-1-git-send-email-claudio.takahasi@openbossa.org>

Hi Claudio,

On Wed, May 18, 2011, Claudio Takahasi wrote:
> Adapter needs to have only one method to allow discovery results
> integration for both interfaces: hciops and mgmtops. This patch
> moves the code related to advertises parsing to the same function
> that handles inquiry results.
> ---
>  src/adapter.c |   67 ++++++++++++++++++--------------------------------------
>  src/adapter.h |    7 +----
>  src/event.c   |   25 +++-----------------
>  3 files changed, 28 insertions(+), 71 deletions(-)

Patches 3, 4 and 5 have been pushed upstream, but this one causes a
compiler error with gcc 4.6:

src/adapter.c: In function ‘adapter_update_found_devices’:
src/adapter.c:3008:28: error: variable ‘le’ set but not used [-Werror=unused-but-set-variable]

Please fix and resend.

Johan

^ permalink raw reply

* Re: BT 3.0 HS Support in BlueZ
From: Mat Martineau @ 2011-05-18 20:58 UTC (permalink / raw)
  To: Gustavo F. Padovan
  Cc: Arun Kumar SINGH, Anurag Gupta, pkrystad, linux-bluetooth
In-Reply-To: <20110509225246.GB2203@joana>


Gustavo,

On Mon, 9 May 2011, Gustavo F. Padovan wrote:

> Hi Mat,
>
> * Mat Martineau <mathewm@codeaurora.org> [2011-05-05 16:27:17 -0700]:
>
>>
>> On Thu, 5 May 2011, Gustavo F. Padovan wrote:
>>
>>> Hi Arun,
>>>
>>> * Arun Kumar SINGH <arunkr.singh@stericsson.com> [2011-05-05 09:26:58 +0200]:
>>>
>>>> Hi Gustavo,
>>>>
>>>>>> Does anybody know if
>>>>> bluetooth 3.0 HS spec is
>>>>> supported in BlueZ?
>>>>>> Is AMP supported in BlueZ?
>>>>>
>>>>> There is two different
>>>>> implementations, one by
>>>>> Atheros and another by QuIC.
>>>>> Both never reach upstream,
>>>>> if you look to the list logs
>>>>> you will find them.
>>>>
>>>>
>>>> Any hopes of getting this unified version upstream anytime in near future? I guess this has been on the cards for some time now given that merge process started last august.
>>>
>>> I'm interested in have this on the stack but it doesn't depend on me.
>>> Patches for this are not arriving to the mailing list. Actually we had no real
>>> feedback for AMP since the meeting in Boston.
>>
>> Gustavo, Arun:
>>
>> We do still plan to upstream our Bluetooth 3.0 + HS implementation.  I
>> will start work on upstreaming later this month, but I need to merge
>> in all of the recent L2CAP refactoring changes.
>>
>> Also note that Qualcomm and Atheros have announced a merger.
>>
>> You can find the kernel AMP implementation in the codeaurora.org
>> Android git trees:
>>
>> git://codeaurora.org/kernel/msm.git
>> https://www.codeaurora.org/gitweb/quic/la/?p=kernel/msm.git;a=summary
>>
>> The android-msm-2.6.35 and msm-2.6.38 branches contain the AMP code.
>>
>>
>> Please let me know if you have any other questions about AMP.
>
> Isn't Extended Flow Specification a required feature for AMP? I haven't seen
> it in your implementation.

Extended Flowspec is needed to create an L2CAP channel directly on 
AMP, but the implementation you're looking at does not implement the 
"create channel" feature.  Channels are created on BR/EDR and moved 
to AMP, which does not require extended flowspec.


--
Mat Martineau
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

^ permalink raw reply

* [PATCH v6 06/12] Unify inquiry results and advertises
From: Claudio Takahasi @ 2011-05-18 21:33 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <20110518205342.GB31478@dell.amr.corp.intel.com>

Adapter needs to have only one method to allow discovery results
integration for both interfaces: hciops and mgmtops. This patch
moves the code related to advertises parsing to the same function
that handles inquiry results.
---
 src/adapter.c |   69 +++++++++++++++++++--------------------------------------
 src/adapter.h |    7 +----
 src/event.c   |   25 +++-----------------
 3 files changed, 29 insertions(+), 72 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index f1d9148..4c3d027 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2966,42 +2966,6 @@ static void dev_prepend_uuid(gpointer data, gpointer user_data)
 	dev->services = g_slist_prepend(dev->services, g_strdup(new_uuid));
 }
 
-void adapter_update_device_from_info(struct btd_adapter *adapter,
-					bdaddr_t bdaddr, int8_t rssi,
-					const char *name, GSList *services,
-					int flags)
-{
-	struct remote_dev_info *dev;
-	gboolean new_dev;
-
-	dev = get_found_dev(adapter, &bdaddr, &new_dev);
-
-	if (new_dev)
-		dev->le = TRUE;
-	else if (dev->rssi == rssi)
-		return;
-
-	dev->rssi = rssi;
-
-	adapter->found_devices = g_slist_sort(adapter->found_devices,
-						(GCompareFunc) dev_rssi_cmp);
-
-	g_slist_foreach(services, remove_same_uuid, dev);
-	g_slist_foreach(services, dev_prepend_uuid, dev);
-
-	if (flags >= 0)
-		dev->flags = flags;
-
-	if (name) {
-		g_free(dev->name);
-		dev->name = g_strdup(name);
-	}
-
-	/* FIXME: check if other information was changed before emitting the
-	 * signal */
-	adapter_emit_device_found(adapter, dev);
-}
-
 static gboolean pairing_is_legacy(bdaddr_t *local, bdaddr_t *peer,
 					const uint8_t *eir, const char *name)
 {
@@ -3035,13 +2999,14 @@ static char *read_stored_data(bdaddr_t *local, bdaddr_t *peer, const char *file)
 }
 
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
-				uint32_t class, int8_t rssi, uint8_t *data)
+					uint32_t class, int8_t rssi,
+					uint8_t *data, size_t eir_size)
 {
 	struct remote_dev_info *dev;
 	struct eir_data eir_data;
 	char *name;
-	gboolean new_dev, legacy;
-	name_status_t name_status;
+	gboolean new_dev, legacy, le;
+	name_status_t name_status = NAME_NOT_REQUIRED;
 	const char *dev_name;
 	int err;
 
@@ -3054,13 +3019,21 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 
 	name = read_stored_data(&adapter->bdaddr, bdaddr, "names");
 
-	legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data, name);
+	if (eir_data.flags < 0) {
+		le = FALSE;
 
-	if (!name && main_opts.name_resolv &&
-			adapter_has_discov_sessions(adapter))
-		name_status = NAME_REQUIRED;
-	else
-		name_status = NAME_NOT_REQUIRED;
+		legacy = pairing_is_legacy(&adapter->bdaddr, bdaddr, data,
+									name);
+
+		if (!name && main_opts.name_resolv &&
+				adapter_has_discov_sessions(adapter))
+			name_status = NAME_REQUIRED;
+		else
+			name_status = NAME_NOT_REQUIRED;
+	} else {
+		le = TRUE;
+		legacy = FALSE;
+	}
 
 	/* Complete EIR names are always used. Shortened EIR names are only
 	 * used if there is no name already in storage. */
@@ -3088,10 +3061,14 @@ void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
 			free(alias);
 		}
 
-		dev->le = FALSE;
+		dev->le = le;
 		dev->class = class;
 		dev->legacy = legacy;
 		dev->name_status = name_status;
+
+		if (eir_data.flags >= 0)
+			dev->flags = eir_data.flags;
+
 	} else if (dev->rssi == rssi)
 		goto done;
 
diff --git a/src/adapter.h b/src/adapter.h
index 4785d5c..4c07e92 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -108,12 +108,9 @@ int adapter_get_state(struct btd_adapter *adapter);
 int adapter_get_discover_type(struct btd_adapter *adapter);
 struct remote_dev_info *adapter_search_found_devices(struct btd_adapter *adapter,
 						struct remote_dev_info *match);
-void adapter_update_device_from_info(struct btd_adapter *adapter,
-					bdaddr_t bdaddr, int8_t rssi,
-					const char *name, GSList *services,
-					int flags);
 void adapter_update_found_devices(struct btd_adapter *adapter, bdaddr_t *bdaddr,
-				uint32_t class, int8_t rssi, uint8_t *data);
+					uint32_t class, int8_t rssi,
+					uint8_t *data, size_t eir_size);
 int adapter_remove_found_device(struct btd_adapter *adapter, bdaddr_t *bdaddr);
 void adapter_emit_device_found(struct btd_adapter *adapter,
 						struct remote_dev_info *dev);
diff --git a/src/event.c b/src/event.c
index 2c893f0..115b285 100644
--- a/src/event.c
+++ b/src/event.c
@@ -281,19 +281,10 @@ void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
 	device_simple_pairing_complete(device, status);
 }
 
-static void free_eir_data(struct eir_data *eir)
-{
-	g_slist_foreach(eir->services, (GFunc) g_free, NULL);
-	g_slist_free(eir->services);
-	g_free(eir->name);
-}
-
 void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
 {
 	struct btd_adapter *adapter;
-	struct eir_data eir_data;
 	int8_t rssi;
-	int err;
 
 	adapter = manager_find_adapter(local);
 	if (adapter == NULL) {
@@ -301,19 +292,10 @@ void btd_event_advertising_report(bdaddr_t *local, le_advertising_info *info)
 		return;
 	}
 
-	memset(&eir_data, 0, sizeof(eir_data));
-	err = eir_parse(&eir_data, info->data, info->length);
-	if (err < 0)
-		error("Error parsing advertising data: %s (%d)",
-							strerror(-err), -err);
-
 	rssi = *(info->data + info->length);
 
-	adapter_update_device_from_info(adapter, info->bdaddr, rssi,
-					eir_data.name, eir_data.services,
-					eir_data.flags);
-
-	free_eir_data(&eir_data);
+	adapter_update_found_devices(adapter, &info->bdaddr, 0, rssi,
+						info->data, info->length);
 }
 
 static void update_lastseen(bdaddr_t *sba, bdaddr_t *dba)
@@ -355,7 +337,8 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint32_t class,
 	if (data)
 		write_remote_eir(local, peer, data);
 
-	adapter_update_found_devices(adapter, peer, class, rssi, data);
+	adapter_update_found_devices(adapter, peer, class, rssi,
+						data, EIR_DATA_LENGTH);
 }
 
 void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer,
-- 
1.7.5.rc3


^ permalink raw reply related


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