* [PATCH] Fix not calling SetConfiguration on hfp/hsp endpoints before connected
From: Luiz Augusto von Dentz @ 2010-12-16 14:13 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
This cause some clients like PulseAudio to fail to find a proper
transport since connected state is send before transport configuration
is set.
To fix this now SetConfiguration is called early on when headset is still
in connecting phase, this matches sink/source where SetConfiguration is
also called before connected.
---
audio/media.c | 11 ++++-------
1 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/audio/media.c b/audio/media.c
index 0e6ccc9..b28bb33 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -151,16 +151,13 @@ static void headset_state_changed(struct audio_device *dev,
switch (new_state) {
case HEADSET_STATE_DISCONNECTED:
- if (old_state != HEADSET_STATE_CONNECTING)
- media_endpoint_clear_configuration(endpoint);
+ media_endpoint_clear_configuration(endpoint);
+ break;
case HEADSET_STATE_CONNECTING:
+ media_endpoint_set_configuration(endpoint, dev, NULL, 0,
+ headset_setconf_cb, dev);
break;
case HEADSET_STATE_CONNECTED:
- if (old_state != HEADSET_STATE_PLAY_IN_PROGRESS &&
- old_state != HEADSET_STATE_PLAYING)
- media_endpoint_set_configuration(endpoint, dev, NULL,
- 0, headset_setconf_cb,
- dev);
break;
case HEADSET_STATE_PLAY_IN_PROGRESS:
break;
--
1.7.1
^ permalink raw reply related
* [PATCH] Further optimalization of PBAP tracker queries
From: Radoslaw Jablonski @ 2010-12-16 11:55 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Radoslaw Jablonski
Now emails, addresses and telephone numbers of the same type
(work/home/other) are concatenated into sigle strings - this
gains huge difference in speed of queries when there are a lot
of contacts in database. Also changed functions for splitting
these fields on our backend side.
---
plugins/phonebook-tracker.c | 1242 +++++++++++++++++++++++++------------------
1 files changed, 712 insertions(+), 530 deletions(-)
diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index cdc1008..befca7a 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -46,103 +46,111 @@
#define AFFILATION_HOME "Home"
#define AFFILATION_WORK "Work"
#define ADDR_FIELD_AMOUNT 7
-#define PULL_QUERY_COL_AMOUNT 40
+#define PULL_QUERY_COL_AMOUNT 26
#define COUNT_QUERY_COL_AMOUNT 1
-#define COL_PHONE_NUMBER 0
+#define COL_PHONE_AFF 0 /* work/home phone numbers */
#define COL_FULL_NAME 1
#define COL_FAMILY_NAME 2
#define COL_GIVEN_NAME 3
#define COL_ADDITIONAL_NAME 4
#define COL_NAME_PREFIX 5
#define COL_NAME_SUFFIX 6
-#define COL_EMAIL 7
-#define COL_CELL_NUMBER 8
-
-#define COL_ADDR_POBOX 9
-#define COL_ADDR_EXT 10
-#define COL_ADDR_STREET 11
-#define COL_ADDR_LOCALITY 12
-#define COL_ADDR_REGION 13
-#define COL_ADDR_CODE 14
-#define COL_ADDR_COUNTRY 15
-
-#define COL_FAX_NUMBER 16
-#define COL_AFF_TYPE 17
-#define COL_BIRTH_DATE 18
-#define COL_NICKNAME 19
-#define COL_URL 20
-#define COL_PHOTO 21
-
-#define COL_ORG_NAME 22
-#define COL_ORG_DEPARTMENT 23
-#define COL_ORG_ROLE 24
-
-#define COL_UID 25
-#define COL_TITLE 26
-#define COL_OTHER_NUMBER 27
-
-#define COL_OTHER_ADDR_POBOX 28
-#define COL_OTHER_ADDR_EXT 29
-#define COL_OTHER_ADDR_STREET 30
-#define COL_OTHER_ADDR_LOCALITY 31
-#define COL_OTHER_ADDR_REGION 32
-#define COL_OTHER_ADDR_CODE 33
-#define COL_OTHER_ADDR_COUNTRY 34
-
-#define COL_OTHER_EMAIL 35
-#define COL_DATE 36
-#define COL_SENT 37
-#define COL_ANSWERED 38
-#define CONTACTS_ID_COL 39
+#define COL_EMAIL_CONTACT 7 /*email's for other category */
+#define COL_ADDR_AFF 8 /* addresses from affilation */
+#define COL_ADDR_CONTACT 9 /* addresses from contacts */
+#define COL_PHONE_CONTACT 10 /* phone numbers from contact's */
+#define COL_BIRTH_DATE 11
+#define COL_NICKNAME 12
+#define COL_URL 13
+#define COL_PHOTO 14
+#define COL_ORG_ROLE 15
+#define COL_UID 16
+#define COL_TITLE 17
+#define COL_AFF_TYPE 18
+#define COL_ORG_NAME 19
+#define COL_ORG_DEPARTMENT 20
+#define COL_EMAIL_AFF 21 /* email's from affilation (work/home) */
+#define COL_DATE 22
+#define COL_SENT 23
+#define COL_ANSWERED 24
+#define CONTACTS_ID_COL 25
#define CONTACT_ID_PREFIX "contact:"
+#define FAX_NUM_TYPE "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#FaxNumber"
+#define MOBILE_NUM_TYPE "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#CellPhoneNumber"
+
+#define MAIN_DELIM "\30" /* Main delimiter between phones, addresses, emails*/
+#define SUB_DELIM "\31" /* Delimiter used in telephone number strings*/
+#define MAX_FIELDS 100 /* Max amount of fields to be concatenated at once*/
+
#define CONTACTS_QUERY_ALL \
- "SELECT nco:phoneNumber(?v) nco:fullname(?c) " \
- "nco:nameFamily(?c) nco:nameGiven(?c) " \
- "nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
- "nco:nameHonorificSuffix(?c) nco:emailAddress(?e) ?vc " \
- "nco:pobox(?p) nco:extendedAddress(?p) " \
- "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
- "nco:postalcode(?p) nco:country(?p) ?f ?affType " \
- "nco:birthDate(?c) nco:nickname(?c) nco:url(?c) " \
- "?file nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) nco:contactUID(?c) " \
- "nco:title(?a) ?t nco:pobox(?po) nco:extendedAddress(?po) " \
- "nco:streetAddress(?po) nco:locality(?po) nco:region(?po) " \
- "nco:postalcode(?po) nco:country(?po) nco:emailAddress(?eo) " \
- "\"NOTACALL\" \"false\" \"false\" ?c " \
- "WHERE { " \
- "?c a nco:PersonContact . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { ?c nco:hasPhoneNumber ?h . " \
- "OPTIONAL {" \
- "?h a nco:FaxNumber ; " \
- "nco:phoneNumber ?f . " \
- "}" \
- "OPTIONAL {" \
- "?h a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc" \
- "}" \
- "OPTIONAL {" \
- "?h a nco:VoicePhoneNumber ; " \
- "nco:phoneNumber ?t" \
- "}" \
- "}" \
- "OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a rdfs:label ?affType .}" \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:hasPhoneNumber ?v . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "}"
+"SELECT " \
+"(SELECT GROUP_CONCAT(" \
+"nco:phoneNumber(?number), \"\30\")" \
+"WHERE {" \
+" ?_role nco:hasPhoneNumber ?number" \
+"}) " \
+"nco:fullname(?_contact) " \
+"nco:nameFamily(?_contact) " \
+"nco:nameGiven(?_contact) " \
+"nco:nameAdditional(?_contact) " \
+"nco:nameHonorificPrefix(?_contact) " \
+"nco:nameHonorificSuffix(?_contact) " \
+"(SELECT GROUP_CONCAT(?emailaddress_other, \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasEmailAddress " \
+ "[nco:emailAddress ?emailaddress_other]" \
+ "}) " \
+"(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), \"\") ),\";\")" \
+"WHERE {" \
+"?_role nco:hasPostalAddress ?aff_addr" \
+"}) " \
+"(SELECT GROUP_CONCAT(fn:concat(" \
+"tracker:coalesce(nco:pobox(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:extendedAddress(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:streetAddress(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:locality(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:region(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:postalcode(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:country(?oth_addr), \"\") ),\"\30\")" \
+"WHERE {" \
+" ?_contact nco:hasPostalAddress ?oth_addr" \
+"}) " \
+"(SELECT GROUP_CONCAT(fn:concat(rdf:type(?contact_number)," \
+"\"\31\", nco:phoneNumber(?contact_number)), \"\30\")" \
+"WHERE {" \
+" ?_contact nco:hasPhoneNumber ?contact_number" \
+"}) " \
+"nco:birthDate(?_contact) " \
+"nco:nickname(?_contact) " \
+"nco:url(?_contact) " \
+"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(?emailaddress, \"\30\")" \
+"WHERE {" \
+" ?_role nco:hasEmailAddress [ nco:emailAddress ?emailaddress ]" \
+"}) " \
+"\"NOTACALL\" \"false\" \"false\" " \
+"?_contact " \
+"WHERE {" \
+" ?_contact a nco:PersonContact ;" \
+" nco:nameFamily ?_key ." \
+" OPTIONAL {?_contact nco:hasAffiliation ?_role .}" \
+"}" \
+"ORDER BY ?_key tracker:id(?_contact)"
#define CONTACTS_QUERY_ALL_LIST \
"SELECT ?c nco:nameFamily(?c) " \
@@ -159,84 +167,114 @@
"} GROUP BY ?c"
#define MISSED_CALLS_QUERY \
- "SELECT nco:phoneNumber(?ap) nco:fullname(?c) " \
- "nco:nameFamily(?c) nco:nameGiven(?c) " \
- "nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
- "nco:nameHonorificSuffix(?c) nco:emailAddress(?e) ?vc " \
- "nco:pobox(?p) nco:extendedAddress(?p) " \
- "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
- "nco:postalcode(?p) nco:country(?p) \"\" ?affType " \
- "nco:birthDate(?c) nco:nickname(?c) nco:url(?c) " \
- "?file nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) nco:contactUID(?c) " \
- "nco:title(?a) nco:phoneNumber(?t) nco:pobox(?po) nco:extendedAddress(?po) " \
- "nco:streetAddress(?po) nco:locality(?po) nco:region(?po) " \
- "nco:postalcode(?po) nco:country(?po) nco:emailAddress(?eo) " \
- "nmo:receivedDate(?call) " \
- "nmo:isSent(?call) nmo:isAnswered(?call) ?x " \
+"SELECT " \
+"(SELECT nco:phoneNumber(?role_number) " \
+ "WHERE {" \
+ "?_role nco:hasPhoneNumber ?role_number " \
+ "FILTER (?role_number = ?_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(?emailaddress_other, \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasEmailAddress " \
+ "[nco:emailAddress ?emailaddress_other]" \
+ "}) " \
+"(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), \"\") ),\";\")" \
+ "WHERE {" \
+ "?_role nco:hasPostalAddress ?aff_addr" \
+ "}) " \
+"(SELECT GROUP_CONCAT(fn:concat(" \
+ "tracker:coalesce(nco:pobox(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:extendedAddress(?oth_addr), \"\"), \";\","\
+ "tracker:coalesce(nco:streetAddress(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:locality(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:region(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:postalcode(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:country(?oth_addr), \"\") ),\"\30\")" \
+ "WHERE {" \
+ "?_contact nco:hasPostalAddress ?oth_addr" \
+ "}) " \
+"(SELECT fn:concat(rdf:type(?contact_number)," \
+ "\"\31\", nco:phoneNumber(?contact_number))" \
+ "WHERE {" \
+ "{" \
+" ?_contact nco:hasPhoneNumber ?contact_number . " \
+" FILTER (?contact_number = ?_number) " \
+" } UNION { " \
+" ?_unb_contact nco:hasPhoneNumber ?contact_number . " \
+" } " \
+"}GROUP BY nco:phoneNumber(?contact_number) ) " \
+ "nco:birthDate(?_contact) " \
+ "nco:nickname(?_contact) " \
+ "nco:url(?_contact) " \
+ "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(?emailaddress, \"\30\") " \
"WHERE { " \
- "{ " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered false . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasPhoneNumber ?t . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { " \
- "?t a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc . " \
- "} " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?ap . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered false . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?ap . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL {?a rdfs:label ?affType . }" \
- "OPTIONAL {?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL {?a nco:hasPostalAddress ?p . }" \
- "OPTIONAL { ?a nco:org ?o . } " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered false . " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?t . } " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?t . } " \
- "FILTER ( !bound(?c) && !bound(?a) ) . " \
- "} " \
- "} ORDER BY DESC(nmo:receivedDate(?call)) "
+ "?_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 .} " \
+ "?_contact nco:nameFamily ?_key ." \
+"} UNION { " \
+ "?_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 . " \
+ "?_contact nco:nameFamily ?_key . " \
+ "?_contact nco:hasAffiliation ?_role . " \
+ "?_role nco:hasPhoneNumber ?_number . " \
+"} UNION { " \
+ "?_unb_contact a nco:Contact . " \
+ "?_unb_contact nco:hasPhoneNumber ?_number . " \
+ "?_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. } " \
+ "FILTER ( !bound(?_contact) && !bound(?_role) ) " \
+"} " \
+"} " \
+"ORDER BY DESC(nmo:sentDate(?_call)) "
#define MISSED_CALLS_LIST \
@@ -275,85 +313,114 @@
"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
#define INCOMING_CALLS_QUERY \
- "SELECT nco:phoneNumber(?ap) nco:fullname(?c) " \
- "nco:nameFamily(?c) nco:nameGiven(?c) " \
- "nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
- "nco:nameHonorificSuffix(?c) nco:emailAddress(?e) ?vc " \
- "nco:pobox(?p) nco:extendedAddress(?p) " \
- "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
- "nco:postalcode(?p) nco:country(?p) \"\" ?affType " \
- "nco:birthDate(?c) nco:nickname(?c) nco:url(?c) " \
- "?file nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) nco:contactUID(?c) " \
- "nco:title(?a) nco:phoneNumber(?t) nco:pobox(?po) " \
- "nco:extendedAddress(?po) " \
- "nco:streetAddress(?po) nco:locality(?po) nco:region(?po) " \
- "nco:postalcode(?po) nco:country(?po) nco:emailAddress(?eo) " \
- "nmo:receivedDate(?call) " \
- "nmo:isSent(?call) nmo:isAnswered(?call) ?x " \
+"SELECT " \
+"(SELECT nco:phoneNumber(?role_number) " \
+ "WHERE {" \
+" ?_role nco:hasPhoneNumber ?role_number" \
+" FILTER (?role_number = ?_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(?emailaddress_other, \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasEmailAddress " \
+ "[nco:emailAddress ?emailaddress_other]" \
+ "}) " \
+"(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), \"\") ),\";\")" \
+ "WHERE {" \
+ "?_role nco:hasPostalAddress ?aff_addr" \
+ "}) " \
+"(SELECT GROUP_CONCAT(fn:concat(" \
+ "tracker:coalesce(nco:pobox(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:extendedAddress(?oth_addr), \"\"), \";\","\
+ "tracker:coalesce(nco:streetAddress(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:locality(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:region(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:postalcode(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:country(?oth_addr), \"\") ),\"\30\")" \
+ "WHERE {" \
+ "?_contact nco:hasPostalAddress ?oth_addr" \
+ "}) " \
+"(SELECT fn:concat(rdf:type(?contact_number)," \
+ "\"\31\", nco:phoneNumber(?contact_number))" \
+ "WHERE {" \
+ "{" \
+" ?_contact nco:hasPhoneNumber ?contact_number . " \
+" FILTER (?contact_number = ?_number) " \
+" } UNION { " \
+" ?_unb_contact nco:hasPhoneNumber ?contact_number . " \
+" } " \
+ "}GROUP BY nco:phoneNumber(?contact_number) ) " \
+ "nco:birthDate(?_contact) " \
+ "nco:nickname(?_contact) " \
+ "nco:url(?_contact) " \
+ "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(?emailaddress, \"\30\") " \
"WHERE { " \
- "{ " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered true . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasPhoneNumber ?t . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { " \
- "?t a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc . " \
- "} " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?ap . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered true . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?ap . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL {?a rdfs:label ?affType . }" \
- "OPTIONAL {?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL {?a nco:hasPostalAddress ?p . }" \
- "OPTIONAL { ?a nco:org ?o . } " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false ; " \
- "nmo:isAnswered true . " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?t . } " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?t . } " \
- "FILTER ( !bound(?c) && !bound(?a) ) . " \
- "} " \
- "} ORDER BY DESC(nmo:receivedDate(?call)) "
+ "?_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 .} " \
+ "?_contact nco:nameFamily ?_key ." \
+"} UNION { " \
+ "?_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 . " \
+ "?_contact nco:nameFamily ?_key . " \
+ "?_contact nco:hasAffiliation ?_role . " \
+ "?_role nco:hasPhoneNumber ?_number . " \
+"} UNION { " \
+ "?_unb_contact a nco:Contact . " \
+ "?_unb_contact nco:hasPhoneNumber ?_number . " \
+ "?_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. } " \
+ "FILTER ( !bound(?_contact) && !bound(?_role) ) " \
+"} " \
+"} "\
+"ORDER BY DESC(nmo:sentDate(?_call)) "
#define INCOMING_CALLS_LIST \
"SELECT ?c nco:nameFamily(?c) " \
@@ -391,82 +458,111 @@
"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
#define OUTGOING_CALLS_QUERY \
- "SELECT nco:phoneNumber(?ap) nco:fullname(?c) " \
- "nco:nameFamily(?c) nco:nameGiven(?c) " \
- "nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
- "nco:nameHonorificSuffix(?c) nco:emailAddress(?e) ?vc " \
- "nco:pobox(?p) nco:extendedAddress(?p) " \
- "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
- "nco:postalcode(?p) nco:country(?p) \"\" ?affType " \
- "nco:birthDate(?c) nco:nickname(?c) nco:url(?c) " \
- "?file nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) nco:contactUID(?c) " \
- "nco:title(?a) nco:phoneNumber(?t) nco:pobox(?po) " \
- "nco:extendedAddress(?po) " \
- "nco:streetAddress(?po) nco:locality(?po) nco:region(?po) " \
- "nco:postalcode(?po) nco:country(?po) nco:emailAddress(?eo) " \
- "nmo:receivedDate(?call) " \
- "nmo:isSent(?call) nmo:isAnswered(?call) ?x " \
+"SELECT " \
+"(SELECT nco:phoneNumber(?role_number) " \
+ "WHERE {" \
+" ?_role nco:hasPhoneNumber ?role_number" \
+" FILTER (?role_number = ?_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(?emailaddress_other, \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasEmailAddress " \
+ "[nco:emailAddress ?emailaddress_other]" \
+ "}) " \
+"(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), \"\") ),\";\")" \
+ "WHERE {" \
+ "?_role nco:hasPostalAddress ?aff_addr" \
+ "}) " \
+"(SELECT GROUP_CONCAT(fn:concat(" \
+ "tracker:coalesce(nco:pobox(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:extendedAddress(?oth_addr), \"\"), \";\","\
+ "tracker:coalesce(nco:streetAddress(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:locality(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:region(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:postalcode(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:country(?oth_addr), \"\") ),\"\30\")" \
+ "WHERE {" \
+ "?_contact nco:hasPostalAddress ?oth_addr" \
+ "}) " \
+"(SELECT fn:concat(rdf:type(?contact_number)," \
+ "\"\31\", nco:phoneNumber(?contact_number))" \
+ "WHERE {" \
+ "{" \
+" ?_contact nco:hasPhoneNumber ?contact_number . " \
+" FILTER (?contact_number = ?_number) " \
+" } UNION { " \
+" ?_unb_contact nco:hasPhoneNumber ?contact_number . " \
+" } " \
+ "}GROUP BY nco:phoneNumber(?contact_number) ) " \
+ "nco:birthDate(?_contact) " \
+ "nco:nickname(?_contact) " \
+ "nco:url(?_contact) " \
+ "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(?emailaddress, \"\30\") " \
"WHERE { " \
- "{ " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:to ?x ; " \
- "nmo:isSent true . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasPhoneNumber ?t . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { " \
- "?t a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc . " \
- "} " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?ap . " \
- "?call a nmo:Call ; " \
- "nmo:to ?x ; " \
- "nmo:isSent true . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?ap . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL {?a rdfs:label ?affType . }" \
- "OPTIONAL {?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL {?a nco:hasPostalAddress ?p . }" \
- "OPTIONAL { ?a nco:org ?o . } " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:to ?x ; " \
- "nmo:isSent true . " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?t . } " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?t . } " \
- "FILTER ( !bound(?c) && !bound(?a) ) . " \
- "} " \
- "} ORDER BY DESC(nmo:sentDate(?call)) "
+ "?_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 .} " \
+ "?_contact nco:nameFamily ?_key ." \
+"} UNION { " \
+ "?_ncontact a nco:Contact . " \
+ "?_ncontact nco:hasPhoneNumber ?_number . " \
+ "?_call a nmo:Call ; " \
+ "nmo:to ?_ncontact ; " \
+ "nmo:isSent true . " \
+ "?_contact a nco:PersonContact . " \
+ "?_contact nco:nameFamily ?_key . " \
+ "?_contact nco:hasAffiliation ?_role . " \
+ "?_role nco:hasPhoneNumber ?_number . " \
+"} UNION { " \
+ "?_unb_contact a nco:Contact . " \
+ "?_unb_contact nco:hasPhoneNumber ?_number . " \
+ "?_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. } " \
+ "FILTER ( !bound(?_contact) && !bound(?_role) ) " \
+"} " \
+"} " \
+"ORDER BY DESC(nmo:sentDate(?_call)) "
#define OUTGOING_CALLS_LIST \
"SELECT ?c nco:nameFamily(?c) " \
@@ -501,139 +597,143 @@
"} GROUP BY ?call ORDER BY DESC(nmo:sentDate(?call))"
#define COMBINED_CALLS_QUERY \
- "SELECT nco:phoneNumber(?ap) nco:fullname(?c) " \
- "nco:nameFamily(?c) nco:nameGiven(?c) " \
- "nco:nameAdditional(?c) nco:nameHonorificPrefix(?c) " \
- "nco:nameHonorificSuffix(?c) nco:emailAddress(?e) ?vc " \
- "nco:pobox(?p) nco:extendedAddress(?p) " \
- "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
- "nco:postalcode(?p) nco:country(?p) \"\" ?affType " \
- "nco:birthDate(?c) nco:nickname(?c) nco:url(?c) " \
- "?file nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) nco:contactUID(?c) " \
- "nco:title(?a) nco:phoneNumber(?t) nco:pobox(?po) " \
- "nco:extendedAddress(?po) " \
- "nco:streetAddress(?po) nco:locality(?po) nco:region(?po) " \
- "nco:postalcode(?po) nco:country(?po) nco:emailAddress(?eo) " \
- "nmo:receivedDate(?call) " \
- "nmo:isSent(?call) nmo:isAnswered(?call) ?x " \
+"SELECT " \
+"(SELECT nco:phoneNumber(?role_number) " \
+ "WHERE {" \
+" ?_role nco:hasPhoneNumber ?role_number" \
+" FILTER (?role_number = ?_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(?emailaddress_other, \"\30\") " \
+ "WHERE {" \
+ "?_contact nco:hasEmailAddress " \
+ "[nco:emailAddress ?emailaddress_other]" \
+ "}) " \
+"(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), \"\") ),\";\")" \
+ "WHERE {" \
+ "?_role nco:hasPostalAddress ?aff_addr" \
+ "}) " \
+"(SELECT GROUP_CONCAT(fn:concat(" \
+ "tracker:coalesce(nco:pobox(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:extendedAddress(?oth_addr), \"\"), \";\","\
+ "tracker:coalesce(nco:streetAddress(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:locality(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:region(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:postalcode(?oth_addr), \"\"), \";\"," \
+ "tracker:coalesce(nco:country(?oth_addr), \"\") ),\"\30\")" \
+ "WHERE {" \
+ "?_contact nco:hasPostalAddress ?oth_addr" \
+ "}) " \
+"(SELECT fn:concat(rdf:type(?contact_number)," \
+ "\"\31\", nco:phoneNumber(?contact_number))" \
+ "WHERE {" \
+ "{" \
+" ?_contact nco:hasPhoneNumber ?contact_number . " \
+" FILTER (?contact_number = ?_number) " \
+" } UNION { " \
+" ?_unb_contact nco:hasPhoneNumber ?contact_number . " \
+" } " \
+ "}GROUP BY nco:phoneNumber(?contact_number) ) " \
+ "nco:birthDate(?_contact) " \
+ "nco:nickname(?_contact) " \
+ "nco:url(?_contact) " \
+ "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(?emailaddress, \"\30\") " \
"WHERE { " \
- "{ " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:to ?x ; " \
- "nmo:isSent true . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasPhoneNumber ?t . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { " \
- "?t a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc . " \
- "} " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?ap . " \
- "?call a nmo:Call ; " \
- "nmo:to ?x ; " \
- "nmo:isSent true . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?ap . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL {?a rdfs:label ?affType . }" \
- "OPTIONAL {?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL {?a nco:hasPostalAddress ?p . }" \
- "OPTIONAL { ?a nco:org ?o . } " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:to ?x ; " \
- "nmo:isSent true . " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?t . } " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?t . } " \
- "FILTER ( !bound(?c) && !bound(?a) ) . " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasPhoneNumber ?t . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { " \
- "?t a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc . " \
- "} " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "OPTIONAL { " \
- "?c nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?ap . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false . " \
- "?c a nco:PersonContact . " \
- "?c nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?ap . " \
- "OPTIONAL { " \
- "?c a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL {?a rdfs:label ?affType . }" \
- "OPTIONAL {?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL {?a nco:hasPostalAddress ?p . }" \
- "OPTIONAL { ?a nco:org ?o . } " \
- "OPTIONAL { ?a nco:title ?title } " \
- "OPTIONAL { ?c nco:hasPostalAddress ?po . } " \
- "OPTIONAL { ?c nco:hasEmailAddress ?eo . } " \
- "} UNION { " \
- "?x a nco:Contact . " \
- "?x nco:hasPhoneNumber ?t . " \
- "?call a nmo:Call ; " \
- "nmo:from ?x ; " \
- "nmo:isSent false . " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasPhoneNumber ?t . } " \
- "OPTIONAL {?c a nco:PersonContact ; " \
- "nco:hasAffiliation ?a . " \
- "?a nco:hasPhoneNumber ?t . } " \
- "FILTER ( !bound(?c) && !bound(?a) ) . " \
- "} " \
- "} ORDER BY DESC(nmo:receivedDate(?call)) "
+ "?_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 .} " \
+ "?_contact nco:nameFamily ?_key ." \
+"} UNION { " \
+ "?_ncontact a nco:Contact . " \
+ "?_ncontact nco:hasPhoneNumber ?_number . " \
+ "?_call a nmo:Call ; " \
+ "nmo:to ?_ncontact ; " \
+ "nmo:isSent true . " \
+ "?_contact a nco:PersonContact . " \
+ "?_contact nco:nameFamily ?_key . " \
+ "?_contact nco:hasAffiliation ?_role . " \
+ "?_role nco:hasPhoneNumber ?_number . " \
+"} UNION { " \
+ "?_unb_contact a nco:Contact . " \
+ "?_unb_contact nco:hasPhoneNumber ?_number . " \
+ "?_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. } " \
+ "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 .} " \
+ "?_contact nco:nameFamily ?_key ." \
+"} UNION { " \
+ "?_ncontact a nco:Contact . " \
+ "?_ncontact nco:hasPhoneNumber ?_number . " \
+ "?_call a nmo:Call ; " \
+ "nmo:from ?_ncontact ; " \
+ "nmo:isSent false . " \
+ "?_contact a nco:PersonContact . " \
+ "?_contact nco:nameFamily ?_key . " \
+ "?_contact nco:hasAffiliation ?_role . " \
+ "?_role nco:hasPhoneNumber ?_number . " \
+"} UNION { " \
+ "?_unb_contact a nco:Contact . " \
+ "?_unb_contact nco:hasPhoneNumber ?_number . " \
+ "?_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. } " \
+ "FILTER ( !bound(?_contact) && !bound(?_role) ) " \
+"} " \
+"} " \
+"ORDER BY DESC(nmo:sentDate(?_call)) "
#define COMBINED_CALLS_LIST \
"SELECT ?c nco:nameFamily(?c) nco:nameGiven(?c) " \
@@ -690,58 +790,77 @@
"} GROUP BY ?call ORDER BY DESC(nmo:receivedDate(?call))"
#define CONTACTS_QUERY_FROM_URI \
- "SELECT nco:phoneNumber(?v) nco:fullname(<%s>) " \
- "nco:nameFamily(<%s>) nco:nameGiven(<%s>) " \
- "nco:nameAdditional(<%s>) nco:nameHonorificPrefix(<%s>) " \
- "nco:nameHonorificSuffix(<%s>) nco:emailAddress(?e) ?vc " \
- "nco:pobox(?p) nco:extendedAddress(?p) " \
- "nco:streetAddress(?p) nco:locality(?p) nco:region(?p) " \
- "nco:postalcode(?p) nco:country(?p) ?f ?affType " \
- "nco:birthDate(<%s>) nco:nickname(<%s>) nco:url(<%s>) " \
- "?file nco:fullname(?o) nco:department(?a) " \
- "nco:role(?a) nco:contactUID(<%s>) " \
- "nco:title(?a) ?t nco:pobox(?po) nco:extendedAddress(?po) " \
- "nco:streetAddress(?po) nco:locality(?po) nco:region(?po) " \
- "nco:postalcode(?po) nco:country(?po) nco:emailAddress(?eo) " \
- "\"NOTACALL\" \"false\" \"false\" <%s> " \
- "WHERE { " \
- "<%s> a nco:PersonContact . " \
- "OPTIONAL { " \
- "<%s> a nco:PersonContact ; nco:photo ?pht . " \
- "?pht a nfo:FileDataObject ; nie:url ?file . " \
- "} " \
- "OPTIONAL { <%s> nco:hasPhoneNumber ?h . " \
- "OPTIONAL {" \
- "?h a nco:FaxNumber ; " \
- "nco:phoneNumber ?f . " \
- "}" \
- "OPTIONAL {" \
- "?h a nco:CellPhoneNumber ; " \
- "nco:phoneNumber ?vc" \
- "}" \
- "OPTIONAL {" \
- "?h a nco:VoicePhoneNumber ; " \
- "nco:phoneNumber ?t" \
- "}" \
- "}" \
- "OPTIONAL { " \
- "<%s> nco:hasAffiliation ?a . " \
- "OPTIONAL { ?a rdfs:label ?affType .}" \
- "OPTIONAL { ?a nco:hasEmailAddress ?e . } " \
- "OPTIONAL { ?a nco:hasPostalAddress ?p . } " \
- "OPTIONAL { ?a nco:hasPhoneNumber ?v . } " \
- "OPTIONAL { ?a nco:org ?o . } " \
- "} " \
- "OPTIONAL { <%s> nco:hasPostalAddress ?po . } " \
- "OPTIONAL { <%s> nco:hasEmailAddress ?eo . } " \
- "}"
+"SELECT " \
+"(SELECT GROUP_CONCAT(" \
+"nco:phoneNumber(?number), \"\30\")" \
+"WHERE {" \
+" ?_role nco:hasPhoneNumber ?number" \
+"}) " \
+"nco:fullname(<%s>) " \
+"nco:nameFamily(<%s>) " \
+"nco:nameGiven(<%s>) " \
+"nco:nameAdditional(<%s>) " \
+"nco:nameHonorificPrefix(<%s>) " \
+"nco:nameHonorificSuffix(<%s>) " \
+"(SELECT GROUP_CONCAT(?emailaddress_other, \"\30\")" \
+"WHERE {" \
+" <%s> nco:hasEmailAddress [nco:emailAddress ?emailaddress_other]"\
+"}) " \
+"(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), \"\") ),\";\")" \
+"WHERE {" \
+"?_role nco:hasPostalAddress ?aff_addr" \
+"}) " \
+"(SELECT GROUP_CONCAT(fn:concat(" \
+"tracker:coalesce(nco:pobox(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:extendedAddress(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:streetAddress(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:locality(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:region(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:postalcode(?oth_addr), \"\"), \";\"," \
+"tracker:coalesce(nco:country(?oth_addr), \"\") ),\"\30\")" \
+"WHERE {" \
+" <%s> nco:hasPostalAddress ?oth_addr" \
+"}) " \
+"(SELECT GROUP_CONCAT(fn:concat(rdf:type(?contact_number)," \
+"\"\31\", nco:phoneNumber(?contact_number)), \"\30\")" \
+"WHERE {" \
+" <%s> nco:hasPhoneNumber ?contact_number" \
+"}) " \
+"nco:birthDate(<%s>) " \
+"nco:nickname(<%s>) " \
+"nco:url(<%s>) " \
+"nie:url(nco:photo(<%s>)) " \
+"nco:role(?_role) " \
+"nco:contactUID(<%s>) " \
+"nco:title(?_role) " \
+"rdfs:label(?_role) " \
+"nco:fullname(nco:org(?_role))" \
+"nco:department(?_role) " \
+"(SELECT GROUP_CONCAT(?emailaddress, \"\30\")" \
+"WHERE {" \
+" ?_role nco:hasEmailAddress [ nco:emailAddress ?emailaddress ]" \
+"}) " \
+"\"NOTACALL\" \"false\" \"false\" " \
+"<%s> " \
+"WHERE {" \
+" <%s> a nco:PersonContact ;" \
+" nco:nameFamily ?_key ." \
+" OPTIONAL {<%s> nco:hasAffiliation ?_role .}" \
+"}" \
+"ORDER BY ?_key tracker:id(<%s>)"
#define CONTACTS_OTHER_QUERY_FROM_URI \
- "SELECT \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" "\
- "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" " \
- "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" " \
- "\"\" " \
- "nco:phoneNumber(?t) \"NOTACALL\" \"false\" \"false\" <%s> " \
+ "SELECT \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" " \
+ "fn:concat(\"TYPE_OTHER\", \"\31\", nco:phoneNumber(?t)) \"\" " \
+ "\"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" " \
+ " \"NOTACALL\" \"false\" \"false\" <%s> " \
"WHERE { " \
"<%s> a nco:Contact . " \
"OPTIONAL { <%s> nco:hasPhoneNumber ?t . } " \
@@ -1302,21 +1421,66 @@ 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)
+{
+ gchar **num_parts;
+ gchar *type, *number;
+
+ /* For phone taken directly from contacts data, phone number string
+ * is represented as number type and number string - those strings are
+ * separated by SUB_DELIM string */
+ num_parts = g_strsplit(pnumber, SUB_DELIM, 2);
+
+ if (num_parts) {
+ if (num_parts[0])
+ type = num_parts[0];
+ else
+ return;
+
+ if (num_parts[1])
+ number = num_parts[1];
+ else
+ return;
+ }
+
+ if (g_strrstr(type, FAX_NUM_TYPE))
+ add_phone_number(contact, number, TEL_TYPE_FAX);
+ 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);
+
+ g_strfreev(num_parts);
+}
+
static void contact_add_numbers(struct phonebook_contact *contact,
char **reply)
{
- add_phone_number(contact, reply[COL_PHONE_NUMBER],
+ gchar **aff_numbers, **con_numbers;
+ int i;
+
+
+ /* Filling phone numbers from contact's affilation */
+ aff_numbers = g_strsplit(reply[COL_PHONE_AFF], MAIN_DELIM, MAX_FIELDS);
+
+ if (aff_numbers) {
+ DBG("aff numbers[0] %s", aff_numbers[0]);
+ for(i = 0;aff_numbers[i]; ++i)
+ add_phone_number(contact, aff_numbers[i],
get_phone_type(reply[COL_AFF_TYPE]));
- add_phone_number(contact, reply[COL_FAX_NUMBER], TEL_TYPE_FAX);
- add_phone_number(contact, reply[COL_CELL_NUMBER], TEL_TYPE_MOBILE);
- if (g_strcmp0(reply[COL_OTHER_NUMBER], reply[COL_CELL_NUMBER]) == 0)
- return;
+ }
+ g_strfreev(aff_numbers);
- if (g_strcmp0(reply[COL_OTHER_NUMBER], reply[COL_PHONE_NUMBER]) == 0)
- return;
+ /* Filling phone numbers directly from contact's struct */
+ con_numbers = g_strsplit(reply[COL_PHONE_CONTACT], MAIN_DELIM,
+ MAX_FIELDS);
- add_phone_number(contact, reply[COL_OTHER_NUMBER], TEL_TYPE_OTHER);
+ 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)
@@ -1332,9 +1496,29 @@ static enum phonebook_email_type get_email_type(const char *affilation)
static void contact_add_emails(struct phonebook_contact *contact,
char **reply)
{
- add_email(contact, reply[COL_EMAIL],
+ gchar **aff_emails, **con_emails;
+ int i;
+
+ /* Emails from affilation */
+ aff_emails = g_strsplit(reply[COL_EMAIL_AFF], MAIN_DELIM, MAX_FIELDS);
+
+ if (aff_emails)
+ for(i = 0; aff_emails[i] != NULL; ++i)
+ add_email(contact, aff_emails[i],
get_email_type(reply[COL_AFF_TYPE]));
- add_email(contact, reply[COL_OTHER_EMAIL], EMAIL_TYPE_OTHER);
+
+ g_strfreev(aff_emails);
+
+ /* Emails taken directly from contact's data have always type OTHER */
+ con_emails = g_strsplit(reply[COL_EMAIL_CONTACT], MAIN_DELIM,
+ MAX_FIELDS);
+
+ if (con_emails)
+ for(i = 0; con_emails[i] != NULL; ++i)
+ add_email(contact, con_emails[i], EMAIL_TYPE_OTHER);
+
+ g_strfreev(con_emails);
+
}
static enum phonebook_address_type get_addr_type(const char *affilation)
@@ -1351,32 +1535,30 @@ static void contact_add_addresses(struct phonebook_contact *contact,
char **reply)
{
- char *main_addr, *other_addr;
+ gchar **aff_addr, **con_addr;
+ int i;
+
+ /* Addresses from affilation */
+ aff_addr = g_strsplit(reply[COL_ADDR_AFF], MAIN_DELIM,
+ MAX_FIELDS);
+
+ if (aff_addr)
+ for(i = 0; aff_addr[i] != NULL; ++i)
+ add_address(contact, aff_addr[i],
+ get_addr_type(reply[COL_AFF_TYPE]));
- main_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
- reply[COL_ADDR_POBOX],
- reply[COL_ADDR_EXT],
- reply[COL_ADDR_STREET],
- reply[COL_ADDR_LOCALITY],
- reply[COL_ADDR_REGION],
- reply[COL_ADDR_CODE],
- reply[COL_ADDR_COUNTRY]);
+ g_strfreev(aff_addr);
- other_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
- reply[COL_OTHER_ADDR_POBOX],
- reply[COL_OTHER_ADDR_EXT],
- reply[COL_OTHER_ADDR_STREET],
- reply[COL_OTHER_ADDR_LOCALITY],
- reply[COL_OTHER_ADDR_REGION],
- reply[COL_OTHER_ADDR_CODE],
- reply[COL_OTHER_ADDR_COUNTRY]);
+ /* Addresses from contact struct */
+ con_addr = g_strsplit(reply[COL_ADDR_CONTACT], MAIN_DELIM,
+ MAX_FIELDS);
- add_address(contact, main_addr, get_addr_type(reply[COL_AFF_TYPE]));
+ if (con_addr)
+ for(i = 0; con_addr[i] != NULL; ++i)
+ add_address(contact, con_addr[i], ADDR_TYPE_OTHER);
- add_address(contact, other_addr, ADDR_TYPE_OTHER);
+ g_strfreev(con_addr);
- g_free(main_addr);
- g_free(other_addr);
}
static void contact_add_organization(struct phonebook_contact *contact,
@@ -1667,7 +1849,7 @@ int phonebook_get_entry(const char *folder, const char *id,
if (strncmp(id, CONTACT_ID_PREFIX, strlen(CONTACT_ID_PREFIX)) == 0)
query = g_strdup_printf(CONTACTS_QUERY_FROM_URI, id, id, id, id,
id, id, id, id, id, id, id, id,
- id, id, id, id, id);
+ id, id, id, id, id, id);
else
query = g_strdup_printf(CONTACTS_OTHER_QUERY_FROM_URI,
id, id, id);
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 2/4] remove error_common_reply()
From: Johan Hedberg @ 2010-12-16 9:30 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1292450823-17640-2-git-send-email-padovan@profusion.mobi>
Hi Gustavo,
On Wed, Dec 15, 2010, Gustavo F. Padovan wrote:
> Remove old dbus error report function. This patch doesn't make things
> really really better, but is a start.
> ---
> audio/gateway.c | 18 ++++++++++--------
> audio/headset.c | 37 +++++++++++++++----------------------
> audio/sink.c | 7 ++++---
> audio/source.c | 7 ++++---
> src/error.c | 18 ------------------
> src/error.h | 3 ---
> 6 files changed, 33 insertions(+), 57 deletions(-)
Thanks. This patch has been pushed upstream. The other two will have to
wait since I can't apply them before the first one has been fixed.
Johan
^ permalink raw reply
* Re: [PATCH 1/4] add btd_error_agent_not_assigned()
From: Johan Hedberg @ 2010-12-16 9:29 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1292450823-17640-1-git-send-email-padovan@profusion.mobi>
Hi Gustavo,
On Wed, Dec 15, 2010, Gustavo F. Padovan wrote:
> +DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg)
> +{
> + return g_dbus_create_error(msg, ERROR_INTERFACE ".AgentNotAssigned",
> + "Agent Not Assigned");
> +}
> +
Could we make this AgentNotAvailable instead?
Johan
^ permalink raw reply
* Re: [PATCH] Fix crash while reading from mapped file
From: Luiz Augusto von Dentz @ 2010-12-16 9:28 UTC (permalink / raw)
To: Anderson Lizardo
Cc: Lukasz Pawlik, Bastien Nocera, Johan Hedberg, linux-bluetooth
In-Reply-To: <AANLkTim5y+g0n2-k8XMHE4kU-N-n-p4DvHVGg045Aoys@mail.gmail.com>
Hi,
On Wed, Dec 15, 2010 at 8:19 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> On Tue, Dec 14, 2010 at 2:20 PM, Lukasz Pawlik <lucas.pawlik@gmail.com> wrote:
>> Hi,
>>
>>> If somebody can explain what that code is supposed to do, then writing a
>>> glib-ish version should be trivial, without having to duplicate the
>>> contents again. Then again, using something like:
>>> g_mapped_file_new ();
>>> g_strsplit ();
>>> g_mapped_file_unref ();
>>
>> That won't fix anything since g_mapped_file_new uses mmap function so
>> contents may not be zero-terminated and we want use string function
>> next.
>
> What about using g_strstr_len() instead of strpbrk() on the original
> code? See http://library.gnome.org/devel/glib/unstable/glib-String-Utility-Functions.html#g-strstr-len
That looks to be a good replacement for strpbrk, probably 1 line patch.
--
Luiz Augusto von Dentz
Computer Engineer
^ permalink raw reply
* Re: [PATCH] Fix memory leak of gattrib commands queue
From: Johan Hedberg @ 2010-12-16 9:25 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1292443209-31156-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Wed, Dec 15, 2010, Claudio Takahasi wrote:
> ---
> attrib/gattrib.c | 1 +
> 1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/attrib/gattrib.c b/attrib/gattrib.c
> index 4ed29d9..eace01b 100644
> --- a/attrib/gattrib.c
> +++ b/attrib/gattrib.c
> @@ -177,6 +177,7 @@ void g_attrib_unref(GAttrib *attrib)
> while ((c = g_queue_pop_head(attrib->queue)))
> command_destroy(c);
>
> + g_queue_free(attrib->queue);
> attrib->queue = NULL;
>
> for (l = attrib->events; l; l = l->next)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 2/5] Change CreatePairedDevice to support LE devices
From: Johan Hedberg @ 2010-12-16 9:24 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth, Sheldon Demario
In-Reply-To: <1292442852-26457-2-git-send-email-claudio.takahasi@openbossa.org>
Hi,
On Wed, Dec 15, 2010, Claudio Takahasi wrote:
> CreatePairedDevice implements now the same behaviour of CreateDevice,
> triggering Discover All Primary Services when needed. SMP negotiation
> starts when the link is established. LE capable kernel is required to
> test this method properly.
>
> Limitation: For dual mode devices, Discover All Primary Services is not
> being executed after SDP search if GATT record is found.
> ---
> src/adapter.c | 46 ++++++++++++++++++++++++---
> src/device.c | 89 +++++++++++++++++++++++++++-------------------------
> src/device.h | 7 +++-
> src/glib-helper.c | 5 ++-
> src/glib-helper.h | 3 ++
> 5 files changed, 98 insertions(+), 52 deletions(-)
Couple of issue here:
> @@ -1642,6 +1646,8 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
> struct btd_device *device;
> const gchar *address, *agent_path, *capability, *sender;
> uint8_t cap;
> + device_type_t type;
> + int err;
>
> if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
> DBUS_TYPE_OBJECT_PATH, &agent_path,
> @@ -1666,12 +1672,40 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
> if (cap == IO_CAPABILITY_INVALID)
> return btd_error_invalid_args(msg);
>
> - device = adapter_get_device(conn, adapter, address);
> - if (!device)
> - return btd_error_failed(msg,
> - "Unable to create a new device object");
> + device = adapter_find_device(adapter, address);
> + if (!device) {
> + struct remote_dev_info *dev, match;
> +
> + memset(&match, 0, sizeof(struct remote_dev_info));
> + str2ba(address, &match.bdaddr);
> + match.name_status = NAME_ANY;
> +
> + dev = adapter_search_found_devices(adapter, &match);
> + if (dev && dev->flags)
> + type = flags2type(dev->flags);
> + else
> + type = DEVICE_TYPE_BREDR;
> +
> + if (type == DEVICE_TYPE_LE &&
> + !event_is_connectable(dev->evt_type))
> + return btd_error_failed(msg,
> + "Device is not connectable");
> +
> + device = adapter_create_device(conn, adapter, address, type);
> + if (!device)
> + return NULL;
> + } else
> + type = device_get_type(device);
> +
> + if (type != DEVICE_TYPE_LE)
> + return device_create_bonding(device, conn, msg,
> + agent_path, cap);
>
> - return device_create_bonding(device, conn, msg, agent_path, cap);
> + err = device_browse_primary(device, conn, msg, BT_IO_SEC_HIGH);
> + if (err < 0)
> + return btd_error_failed(msg, strerror(-err));
> +
> + return NULL;
> }
I don't really like the way this makes the create_paired_device function
quite long. Could you maybe refactor the if (!device) branch into a
separate function?
> diff --git a/src/device.h b/src/device.h
> index 784e931..cafa529 100644
> --- a/src/device.h
> +++ b/src/device.h
> @@ -24,6 +24,8 @@
>
> #define DEVICE_INTERFACE "org.bluez.Device"
>
> +#include "btio.h"
> +
Includes should be the first thing after the copyright/license comments
in the file. However, to keep a clear visibility of potential circular
dependencies Marcel has requested this kind of inclusion of an internal
header file from within an internal header file to be avoided. Instead
make sure you include btio.h from early enough in the respective .c
file. You could also reconsider if you really need BtIOSecLevel here.
Maybe a "gboolean secure" flag would be enough?
> --- a/src/glib-helper.h
> +++ b/src/glib-helper.h
> @@ -21,6 +21,8 @@
> *
> */
>
> +#include "btio.h"
> +
Same here.
I'm feeling a little bit ambivalent about your additions to
glib-helper.c. It never had a clearly defined scope and I had been
hoping to get rid of it completely. However now it seems you guys are
constantly adding new stuff there. Is it really so that you can't find a
more specific location for these functions? Could you describe in one or
two sentences the purpose and scope that you think the glib-helper.c
functions have?
Johan
^ permalink raw reply
* Re: [PATCH 1/5] Implement cancel primary discovery session
From: Johan Hedberg @ 2010-12-16 9:15 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1292442852-26457-1-git-send-email-claudio.takahasi@openbossa.org>
Hi Claudio,
On Wed, Dec 15, 2010, Claudio Takahasi wrote:
> Extend bt_cancel_discovery function to cancel an ongoing Discover
> All Primary Services procedure.
> ---
> src/device.c | 11 +++----
> src/glib-helper.c | 73 ++++++++++++++++++++++++++++++++++++++++++-----------
> 2 files changed, 63 insertions(+), 21 deletions(-)
Thanks. This patch has been pushed upstream.
Johan
^ permalink raw reply
* Re: [RFC] Bluetooth: Use non-flushable pb flag by default for ACL data on capable chipsets.
From: Andrei Emeltchenko @ 2010-12-16 9:00 UTC (permalink / raw)
To: Mat Martineau; +Cc: Gustavo F. Padovan, linux-bluetooth
In-Reply-To: <alpine.DEB.2.00.1012150817580.12898@linux-sea-02>
Hi,
On Wed, Dec 15, 2010 at 6:35 PM, Mat Martineau <mathewm@codeaurora.org> wrote:
>
> On Tue, 14 Dec 2010, Gustavo F. Padovan wrote:
>
>> Hi Andrei,
>>
>> * Emeltchenko Andrei <Andrei.Emeltchenko.news@gmail.com> [2010-12-13
>> 16:38:25 +0200]:
>>
>>> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>>>
>>> Modification of Nick Pelly <npelly@google.com> patch.
>>>
>>> With Bluetooth 2.1 ACL packets can be flushable or non-flushable. This
>>> commit
>>> makes ACL data packets non-flushable by default on compatible chipsets,
>>> and
>>> adds the BT_FLUSHABLE socket option to explicitly request flushable ACL
>>> data packets for a given L2CAP socket. This is useful for A2DP data which
>>> can
>>> be safely discarded if it can not be delivered within a short time (while
>>> other ACL data should not be discarded).
>>>
>>> Note that making ACL data flushable has no effect unless the automatic
>>> flush
>>> timeout for that ACL link is changed from its default of 0 (infinite).
>
> This is a great feature to add, not only for A2DP. Both ERTM and streaming
> mode only really make sense on unreliable links.
>
>>> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>>> ---
>>> include/net/bluetooth/bluetooth.h | 5 +++++
>>> include/net/bluetooth/hci.h | 2 ++
>>> include/net/bluetooth/hci_core.h | 1 +
>>> include/net/bluetooth/l2cap.h | 2 ++
>>> net/bluetooth/hci_core.c | 6 ++++--
>>> net/bluetooth/l2cap.c | 33
>>> +++++++++++++++++++++++++++++++--
>>> 6 files changed, 45 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/include/net/bluetooth/bluetooth.h
>>> b/include/net/bluetooth/bluetooth.h
>>> index 0c5e725..ed7d775 100644
>>> --- a/include/net/bluetooth/bluetooth.h
>>> +++ b/include/net/bluetooth/bluetooth.h
>>> @@ -64,6 +64,11 @@ struct bt_security {
>>>
>>> #define BT_DEFER_SETUP 7
>>>
>>> +#define BT_FLUSHABLE 8
>>> +
>>> +#define BT_FLUSHABLE_OFF 0
>>> +#define BT_FLUSHABLE_ON 1
>>> +
>>> #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" ,
>>> ## arg)
>>> #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__
>>> , ## arg)
>>> #define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ##
>>> arg)
>>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>>> index 29a7a8c..333d5cb 100644
>>> --- a/include/net/bluetooth/hci.h
>>> +++ b/include/net/bluetooth/hci.h
>>> @@ -150,6 +150,7 @@ enum {
>>> #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
>>>
>>> /* ACL flags */
>>> +#define ACL_START_NO_FLUSH 0x00
>>> #define ACL_CONT 0x01
>>> #define ACL_START 0x02
>>> #define ACL_ACTIVE_BCAST 0x04
>>> @@ -193,6 +194,7 @@ enum {
>>> #define LMP_EDR_ESCO_3M 0x40
>>> #define LMP_EDR_3S_ESCO 0x80
>>>
>>> +#define LMP_NO_FLUSH 0x01
>>> #define LMP_SIMPLE_PAIR 0x08
>>>
>>> /* Connection modes */
>>> diff --git a/include/net/bluetooth/hci_core.h
>>> b/include/net/bluetooth/hci_core.h
>>> index 1992fac..9778bc8 100644
>>> --- a/include/net/bluetooth/hci_core.h
>>> +++ b/include/net/bluetooth/hci_core.h
>>> @@ -456,6 +456,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
>>> #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
>>> #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
>>> #define lmp_ssp_capable(dev) ((dev)->features[6] &
>>> LMP_SIMPLE_PAIR)
>>> +#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
>>
>> IMHO lmp_flush_capable() makes more sense. We can avoid things like
>> (!lmp_no_flush_capable(dev)) and add two negatives in the same comparison.
>>
>>>
>>> /* ----- HCI protocols ----- */
>>> struct hci_proto {
>>> diff --git a/include/net/bluetooth/l2cap.h
>>> b/include/net/bluetooth/l2cap.h
>>> index 7ad25ca..af35711 100644
>>> --- a/include/net/bluetooth/l2cap.h
>>> +++ b/include/net/bluetooth/l2cap.h
>>> @@ -75,6 +75,7 @@ struct l2cap_conninfo {
>>> #define L2CAP_LM_TRUSTED 0x0008
>>> #define L2CAP_LM_RELIABLE 0x0010
>>> #define L2CAP_LM_SECURE 0x0020
>>> +#define L2CAP_LM_FLUSHABLE 0x0040
>>
>> Not using this anywhere.
>>
>>>
>>> /* L2CAP command codes */
>>> #define L2CAP_COMMAND_REJ 0x01
>>> @@ -327,6 +328,7 @@ struct l2cap_pinfo {
>>> __u8 sec_level;
>>> __u8 role_switch;
>>> __u8 force_reliable;
>>> + __u8 flushable;
>>>
>>> __u8 conf_req[64];
>>> __u8 conf_len;
>>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>>> index 51c61f7..c0d776b 100644
>>> --- a/net/bluetooth/hci_core.c
>>> +++ b/net/bluetooth/hci_core.c
>>> @@ -1380,7 +1380,7 @@ void hci_send_acl(struct hci_conn *conn, struct
>>> sk_buff *skb, __u16 flags)
>>>
>>> skb->dev = (void *) hdev;
>>> bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
>>> - hci_add_acl_hdr(skb, conn->handle, flags | ACL_START);
>>> + hci_add_acl_hdr(skb, conn->handle, flags);
>>>
>>> list = skb_shinfo(skb)->frag_list;
>>> if (!list) {
>>> @@ -1398,12 +1398,14 @@ void hci_send_acl(struct hci_conn *conn, struct
>>> sk_buff *skb, __u16 flags)
>>> spin_lock_bh(&conn->data_q.lock);
>>>
>>> __skb_queue_tail(&conn->data_q, skb);
>>> + flags &= ~ACL_START;
>>> + flags |= ACL_CONT;
>>> do {
>>> skb = list; list = list->next;
>>>
>>> skb->dev = (void *) hdev;
>>> bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
>>> - hci_add_acl_hdr(skb, conn->handle, flags |
>>> ACL_CONT);
>>> + hci_add_acl_hdr(skb, conn->handle, flags);
>>>
>>> BT_DBG("%s frag %p len %d", hdev->name, skb,
>>> skb->len);
>>>
>>> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
>>> index c791fcd..c7f25c2 100644
>>> --- a/net/bluetooth/l2cap.c
>>> +++ b/net/bluetooth/l2cap.c
>>> @@ -362,13 +362,19 @@ static inline u8 l2cap_get_ident(struct l2cap_conn
>>> *conn)
>>> static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8
>>> code, u16 len, void *data)
>>> {
>>> struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len,
>>> data);
>>> + u8 flags;
>>>
>>> BT_DBG("code 0x%2.2x", code);
>>>
>>> if (!skb)
>>> return;
>>>
>>> - hci_send_acl(conn->hcon, skb, 0);
>>> + if (lmp_no_flush_capable(conn->hcon->hdev))
>>> + flags = ACL_START_NO_FLUSH;
>>> + else
>>> + flags = ACL_START;
>>> +
>>> + hci_send_acl(conn->hcon, skb, flags);
>>
>> I also agree that l2cap commands should be non-flushable. Just pass
>> ACL_START_NO_FLUSH to hci_send_acl() here.
Gustavo if the controller does not support non flushable packets we
may have bug here.
>> You should add this check to l2cap_do_send() instead.
This is done for data packets.
>>> }
>>>
>>> static inline void l2cap_send_sframe(struct l2cap_pinfo *pi, u16
>>> control)
>>> @@ -900,6 +906,7 @@ static void l2cap_sock_init(struct sock *sk, struct
>>> sock *parent)
>>> pi->sec_level = l2cap_pi(parent)->sec_level;
>>> pi->role_switch = l2cap_pi(parent)->role_switch;
>>> pi->force_reliable = l2cap_pi(parent)->force_reliable;
>>> + pi->flushable = l2cap_pi(parent)->flushable;
>>> } else {
>>> pi->imtu = L2CAP_DEFAULT_MTU;
>>> pi->omtu = 0;
>>> @@ -915,6 +922,7 @@ static void l2cap_sock_init(struct sock *sk, struct
>>> sock *parent)
>>> pi->sec_level = BT_SECURITY_LOW;
>>> pi->role_switch = 0;
>>> pi->force_reliable = 0;
>>> + pi->flushable = BT_FLUSHABLE_OFF;
>>> }
>>>
>>> /* Default config options */
>>> @@ -2098,6 +2106,20 @@ static int l2cap_sock_setsockopt(struct socket
>>> *sock, int level, int optname, ch
>>> bt_sk(sk)->defer_setup = opt;
>>> break;
>>>
>>> + case BT_FLUSHABLE:
>>> + if (get_user(opt, (u32 __user *) optval)) {
>>> + err = -EFAULT;
>>> + break;
>>> + }
>>> +
>>> + if (opt > BT_FLUSHABLE_ON) {
>>> + err = -EINVAL;
>>> + break;
>>> + }
>>> +
>>> + l2cap_pi(sk)->flushable = opt;
>
> Does it make sense to check the HCI device for flush capability here? If the
> HCI device is not capable, this option should remain false. This would also
> let the application use getsockopt() to find out if the link is really
> flushable or not.
Thanks for the hint, I will add the check here and return -EINVAL then.
>> You are not using this flushable value anywhere. Something is wrong here.
>
> I agree - like Gustavo mentioned above, l2cap_do_send() needs to be checking
> l2cap_pi(sk)->flushable and setting the flags in hci_send_acl()
> appropriately.
Yes, I have lost one chunk when reformatting patches against different branches.
The lost chunk is below:
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c7f25c2..f7260ad 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -1458,10 +1458,16 @@ static void l2cap_drop_acked_frames(struct sock *sk)
static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
+ struct hci_conn *hcon = pi->conn->hcon;
BT_DBG("sk %p, skb %p len %d", sk, skb, skb->len);
- hci_send_acl(pi->conn->hcon, skb, 0);
+ if (lmp_no_flush_capable(hcon->hdev) && !l2cap_pi(sk)->flushable)
+ flags = ACL_START_NO_FLUSH;
+ else
+ flags = ACL_START;
+
+ hci_send_acl(pi->conn->hcon, skb, flags);
}
static void l2cap_streaming_send(struct sock *sk)
> There is one more thing missing: Even though there is an L2CAP socket
> option to set flush_to, and the flush_to is passed around during L2CAP
> configuration, there is no use of the "Write Automatic Flush Timeout" HCI
> command to tell the baseband what the flush timeout is! Since the flush
> timeout is shared across all connections on the ACL, how should BlueZ handle
> the case where different flush timeouts are set on connections that share
> the same ACL? (My guess is that either the longest or shortest timeout
> should be used, but there are good arguments either way)
>
> --
> Mat Martineau
> Employee of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
>
^ permalink raw reply related
* Re: HFP: typo in error path?
From: Daniel Wagner @ 2010-12-16 7:21 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20101216071015.GA32193@jh-x301>
Hi Johan,
On Thu, Dec 16, 2010 at 09:10:15AM +0200, Johan Hedberg wrote:
> > I'm reading a bit through the code and try to understand how the HF
> > role in HFP is implemented. I found following in audio/gateway.c:
> >
> > static gboolean sco_io_cb(GIOChannel *chan, GIOCondition cond,
> > struct audio_device *dev)
> > {
> > struct gateway *gw = dev->gateway;
> >
> > if (cond & G_IO_NVAL)
> > return FALSE;
> >
> > if (cond & (G_IO_ERR | G_IO_HUP)) {
> > DBG("sco connection is released");
> > g_io_channel_shutdown(gw->sco, TRUE, NULL);
> > g_io_channel_unref(gw->sco);
> > gw->sco = NULL;
> > change_state(dev, GATEWAY_STATE_CONNECTED);
> > return FALSE;
> > }
> >
> > return TRUE;
> > }
> >
> > I don't really understand what's going on here, but just from the
> > naming I think the change_state call should be
> > GATEWAY_STATE_DISCONNECTED. If my assumation is correct I can spin a
> > patch.
>
> Actually the current code is correct. This is the callback for SCO (like
> the function name suggests) so when SCO gets closed there's a transition
> from PLAYING to CONNECTED (meaning RFCOMM but no SCO). You can see the
> full set of state values in audio/gateway.h.
Thanks for the clarification, that make perfectly sense now :)
cheers,
daniel
^ permalink raw reply
* Re: HFP: typo in error path?
From: Johan Hedberg @ 2010-12-16 7:10 UTC (permalink / raw)
To: Daniel Wagner; +Cc: linux-bluetooth
In-Reply-To: <20101216064231.GA2033@candlejack.bmw-carit.intra>
Hi Daniel,
On Thu, Dec 16, 2010, Daniel Wagner wrote:
> I'm reading a bit through the code and try to understand how the HF
> role in HFP is implemented. I found following in audio/gateway.c:
>
> static gboolean sco_io_cb(GIOChannel *chan, GIOCondition cond,
> struct audio_device *dev)
> {
> struct gateway *gw = dev->gateway;
>
> if (cond & G_IO_NVAL)
> return FALSE;
>
> if (cond & (G_IO_ERR | G_IO_HUP)) {
> DBG("sco connection is released");
> g_io_channel_shutdown(gw->sco, TRUE, NULL);
> g_io_channel_unref(gw->sco);
> gw->sco = NULL;
> change_state(dev, GATEWAY_STATE_CONNECTED);
> return FALSE;
> }
>
> return TRUE;
> }
>
> I don't really understand what's going on here, but just from the
> naming I think the change_state call should be
> GATEWAY_STATE_DISCONNECTED. If my assumation is correct I can spin a
> patch.
Actually the current code is correct. This is the callback for SCO (like
the function name suggests) so when SCO gets closed there's a transition
from PLAYING to CONNECTED (meaning RFCOMM but no SCO). You can see the
full set of state values in audio/gateway.h.
Johan
^ permalink raw reply
* HFP: typo in error path?
From: Daniel Wagner @ 2010-12-16 6:42 UTC (permalink / raw)
To: linux-bluetooth
Hi,
I'm reading a bit through the code and try to understand how the HF
role in HFP is implemented. I found following in audio/gateway.c:
static gboolean sco_io_cb(GIOChannel *chan, GIOCondition cond,
struct audio_device *dev)
{
struct gateway *gw = dev->gateway;
if (cond & G_IO_NVAL)
return FALSE;
if (cond & (G_IO_ERR | G_IO_HUP)) {
DBG("sco connection is released");
g_io_channel_shutdown(gw->sco, TRUE, NULL);
g_io_channel_unref(gw->sco);
gw->sco = NULL;
change_state(dev, GATEWAY_STATE_CONNECTED);
return FALSE;
}
return TRUE;
}
I don't really understand what's going on here, but just from the
naming I think the change_state call should be
GATEWAY_STATE_DISCONNECTED. If my assumation is correct I can spin a
patch.
cheers,
daniel
^ permalink raw reply
* Re: [PATCH v7] Bluetooth: btwilink driver
From: Pavan Savoy @ 2010-12-16 6:09 UTC (permalink / raw)
To: Gustavo F. Padovan, marcel; +Cc: linux-bluetooth, linux-kernel
In-Reply-To: <AANLkTimewUbJMax-pv+-JSdnbNZvOU8yTVGV-T+BJBo1@mail.gmail.com>
On Thu, Dec 9, 2010 at 1:17 PM, Pavan Savoy <pavan_savoy@sify.com> wrote:
> Gustavo,
>
> On Tue, Dec 7, 2010 at 3:05 AM, Vitaly Wool <vitalywool@gmail.com> wrote:
>> Hi Gustavo,
>>
>> On Mon, Dec 6, 2010 at 10:23 PM, Gustavo F. Padovan
>> <padovan@profusion.mobi> wrote:
>>
>>> Can't you differentiate Bluetooth data in a generic way, withou looking=
if it
>>> is ACL, SCO or HCI EVENT? That done, you can just accumulate in a buffe=
r all
>>> the Bluetooth data you received in that stream then send it to Bluetoot=
h
>>> driver after finish that stream processing.
>>
>> I'm afraid he can't do this because he needs to route events to the
>> appropriate entity (BT/FM/GPS). I'm not sure how it can be done
>> without analyzing the incoming packet.
>
> Think of TI-ST driver as a extension to the HCI-H4 driver or HCI-LL
> with FM and GPS being the additional protocols, and more protocols
> coming in future...
> So some driver has to have a knowledge of the protocols which are on chip=
.
> the basic arch can be found @ http://omappedia.org/wiki/Wilink_ST
Gustavo, Marcel,
Any suggestion to this?
Is including net/bluetooth headers a problem?
and is this a big blocking factor to try and push it to mainline?
I know it would be a dumb question, but do you want me to redeclare
the ACL, SCO and Event headers structures?
All I need is the off-set of the structure where the payload length resides=
....
Please suggest ...
regards,
Pavan
> As Vitaly rightly pointed out, the TI-ST driver needs to peek into all
> the protocol's data be it BT, FM or GPS to assemble fragmented data
> (say ACL data coming out of TTY in 2 fragments) or fragment multiple
> protocol data (say HCI-Event + FM Channel 8 event data)....
> Note: we include even the FM and GPS headers to understand protocol
> frames, but they lack a standard unlike Bluetooth...
>
> Since there lacks a generic way to differentiate BT, FM or GPS data at
> TI-ST driver layer, =C2=A0please suggest what can be done ...
>
>
>> Thanks,
>> =C2=A0 Vitaly
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetoot=
h" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at =C2=A0http://vger.kernel.org/majordomo-info.html
>>
>
^ permalink raw reply
* Re: [PATCH] Added enc_read_blob_req() API to ATT transport, to enable the reading of attributes that exceed the length of the MTU.
From: Anderson Lizardo @ 2010-12-16 3:03 UTC (permalink / raw)
To: Brian Gix; +Cc: linux-bluetooth, padovan, rshaffer
In-Reply-To: <AANLkTikB4K__a3aS1L19nz4USmtEcU+GEufcFkqZLrUb@mail.gmail.com>
On Tue, Dec 14, 2010 at 4:29 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Another issue: looks your e-mail client replaced tabs with spaces (but
> it might just be Google messing up on my side).
BTW just checked and indeed it was just bad formatting by gmail
webmail (from my side). The tabs on your patch are correct. The other
comments I still think are valid.
Regards,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH 4/4] covert more dbus errors to btd_error_*
From: Gustavo F. Padovan @ 2010-12-15 22:07 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1292450823-17640-3-git-send-email-padovan@profusion.mobi>
---
audio/headset.c | 4 +---
serial/port.c | 8 +-------
serial/proxy.c | 12 ++----------
src/adapter.c | 10 ++--------
4 files changed, 6 insertions(+), 28 deletions(-)
diff --git a/audio/headset.c b/audio/headset.c
index be14d3b..b7489a9 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1873,9 +1873,7 @@ static DBusMessage *hs_set_gain(DBusConnection *conn,
err = headset_set_gain(device, gain, type);
if (err < 0)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".InvalidArgument",
- "Must be less than or equal to 15");
+ return btd_error_invalid_args(msg);
reply = dbus_message_new_method_return(msg);
if (!reply)
diff --git a/serial/port.c b/serial/port.c
index 33450b3..233e317 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -234,12 +234,6 @@ void port_release_all(void)
g_slist_free(devices);
}
-static inline DBusMessage *failed(DBusMessage *msg, const char *description)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "%s", description);
-}
-
static void open_notify(int fd, int err, struct serial_port *port)
{
struct serial_device *device = port->device;
@@ -495,7 +489,7 @@ static DBusMessage *port_connect(DBusConnection *conn,
}
if (port->listener_id)
- return failed(msg, "Port already in use");
+ return btd_error_failed(msg, "Port already in use");
port->listener_id = g_dbus_add_disconnect_watch(conn,
dbus_message_get_sender(msg),
diff --git a/serial/proxy.c b/serial/proxy.c
index 20aea7d..b1ee65e 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -131,12 +131,6 @@ static void proxy_free(struct serial_proxy *prx)
g_free(prx);
}
-static inline DBusMessage *failed(DBusMessage *msg, const char *description)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "%s", description);
-}
-
static void add_lang_attr(sdp_record_t *r)
{
sdp_lang_attr_t base_lang;
@@ -551,9 +545,7 @@ static DBusMessage *proxy_enable(DBusConnection *conn,
int err;
err = enable_proxy(prx);
- if (err == -EALREADY)
- return failed(msg, "Already enabled");
- else if (err < 0)
+ if (err < 0)
return btd_error_failed(msg, strerror(-err));
return dbus_message_new_method_return(msg);
@@ -565,7 +557,7 @@ static DBusMessage *proxy_disable(DBusConnection *conn,
struct serial_proxy *prx = data;
if (!prx->io)
- return failed(msg, "Not enabled");
+ return btd_error_failed(msg, "Not enabled");
/* Remove the watches and unregister the record */
disable_proxy(prx);
diff --git a/src/adapter.c b/src/adapter.c
index f0e1d36..27a8d39 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -140,12 +140,6 @@ struct btd_adapter {
static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
guint interval);
-static inline DBusMessage *not_in_progress(DBusMessage *msg, const char *str)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".NotInProgress",
- "%s", str);
-}
-
static int found_device_cmp(const struct remote_dev_info *d1,
const struct remote_dev_info *d2)
{
@@ -1226,7 +1220,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
ba2str(&adapter->bdaddr, srcaddr);
if (check_address(srcaddr) < 0)
- return adapter_not_ready(msg);
+ return btd_error_invalid_args(msg);
reply = dbus_message_new_method_return(msg);
if (!reply)
@@ -1505,7 +1499,7 @@ static DBusMessage *cancel_device_creation(DBusConnection *conn,
device = adapter_find_device(adapter, address);
if (!device || !device_is_creating(device, NULL))
- return not_in_progress(msg, "Device creation not in progress");
+ return btd_error_does_not_exist(msg);
if (!device_is_creating(device, sender))
return btd_error_not_authorized(msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 3/4] add btd_error_not_ready()
From: Gustavo F. Padovan @ 2010-12-15 22:07 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1292450823-17640-2-git-send-email-padovan@profusion.mobi>
---
audio/headset.c | 3 +--
src/adapter.c | 16 +++++-----------
src/error.c | 6 ++++++
src/error.h | 1 +
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/audio/headset.c b/audio/headset.c
index 55bdc61..be14d3b 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1696,8 +1696,7 @@ static DBusMessage *hs_connect(DBusConnection *conn, DBusMessage *msg,
return btd_error_already_connected(msg);
if (hs->hfp_handle && !ag.telephony_ready)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
- "Telephony subsystem not ready");
+ return btd_error_not_ready(msg);
device->auto_connect = FALSE;
diff --git a/src/adapter.c b/src/adapter.c
index 73c8a9b..f0e1d36 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -140,12 +140,6 @@ struct btd_adapter {
static void adapter_set_pairable_timeout(struct btd_adapter *adapter,
guint interval);
-static inline DBusMessage *adapter_not_ready(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
- "Adapter is not ready");
-}
-
static inline DBusMessage *not_in_progress(DBusMessage *msg, const char *str)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".NotInProgress",
@@ -554,7 +548,7 @@ static DBusMessage *set_pairable(DBusConnection *conn, DBusMessage *msg,
int err;
if (adapter->scan_mode == SCAN_DISABLED)
- return adapter_not_ready(msg);
+ return btd_error_not_ready(msg);
if (pairable == adapter->pairable)
goto done;
@@ -1166,7 +1160,7 @@ static DBusMessage *adapter_start_discovery(DBusConnection *conn,
int err;
if (!adapter->up)
- return adapter_not_ready(msg);
+ return btd_error_not_ready(msg);
req = find_session(adapter->disc_sessions, sender);
if (req) {
@@ -1198,7 +1192,7 @@ static DBusMessage *adapter_stop_discovery(DBusConnection *conn,
const char *sender = dbus_message_get_sender(msg);
if (!adapter->up)
- return adapter_not_ready(msg);
+ return btd_error_not_ready(msg);
req = find_session(adapter->disc_sessions, sender);
if (!req)
@@ -1575,7 +1569,7 @@ static DBusMessage *create_device(DBusConnection *conn,
return btd_error_invalid_args(msg);
if (!adapter->up)
- return adapter_not_ready(msg);
+ return btd_error_not_ready(msg);
if (adapter_find_device(adapter, address))
return btd_error_already_exists(msg);
@@ -1652,7 +1646,7 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
return btd_error_invalid_args(msg);
if (!adapter->up)
- return adapter_not_ready(msg);
+ return btd_error_not_ready(msg);
sender = dbus_message_get_sender(msg);
if (adapter->agent &&
diff --git a/src/error.c b/src/error.c
index 7d3afd4..8ee79b8 100644
--- a/src/error.c
+++ b/src/error.c
@@ -103,6 +103,12 @@ DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg)
"Agent Not Assigned");
}
+DBusMessage *btd_error_not_ready(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
+ "Resource Not Ready");
+}
+
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str)
{
return g_dbus_create_error(msg, ERROR_INTERFACE
diff --git a/src/error.h b/src/error.h
index b8c06ce..6cd3cbf 100644
--- a/src/error.h
+++ b/src/error.h
@@ -39,4 +39,5 @@ DBusMessage *btd_error_does_not_exist(DBusMessage *msg);
DBusMessage *btd_error_not_authorized(DBusMessage *msg);
DBusMessage *btd_error_no_such_adapter(DBusMessage *msg);
DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg);
+DBusMessage *btd_error_not_ready(DBusMessage *msg);
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 2/4] remove error_common_reply()
From: Gustavo F. Padovan @ 2010-12-15 22:07 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1292450823-17640-1-git-send-email-padovan@profusion.mobi>
Remove old dbus error report function. This patch doesn't make things
really really better, but is a start.
---
audio/gateway.c | 18 ++++++++++--------
audio/headset.c | 37 +++++++++++++++----------------------
audio/sink.c | 7 ++++---
audio/source.c | 7 ++++---
src/error.c | 18 ------------------
src/error.h | 3 ---
6 files changed, 33 insertions(+), 57 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 6a095ca..da899a0 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -254,10 +254,11 @@ static void rfcomm_connect_cb(GIOChannel *chan, GError *err,
return;
fail:
- if (gw->msg)
- error_common_reply(dev->conn, gw->msg,
- ERROR_INTERFACE ".Failed",
- "Connection attempt failed");
+ if (gw->msg) {
+ DBusMessage *reply;
+ reply = btd_error_failed(gw->msg, "Connect failed");
+ g_dbus_send_message(dev->conn, reply);
+ }
change_state(dev, GATEWAY_STATE_DISCONNECTED);
}
@@ -333,10 +334,11 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
return;
fail:
- if (gw->msg)
- error_common_reply(dev->conn, gw->msg,
- ERROR_INTERFACE ".NotSupported",
- "Not supported");
+ if (gw->msg) {
+ DBusMessage *reply = btd_error_failed(gw->msg,
+ gerr ? gerr->message : strerror(-err));
+ g_dbus_send_message(dev->conn, reply);
+ }
change_state(dev, GATEWAY_STATE_DISCONNECTED);
diff --git a/audio/headset.c b/audio/headset.c
index 34b2b89..55bdc61 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -176,19 +176,12 @@ struct event {
static GSList *headset_callbacks = NULL;
-static DBusHandlerResult error_not_supported(DBusConnection *conn,
- DBusMessage *msg)
+static void error_connect_failed(DBusConnection *conn, DBusMessage *msg,
+ int err)
{
- return error_common_reply(conn, msg, ERROR_INTERFACE ".NotSupported",
- "Not supported");
-}
-
-static DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn,
- DBusMessage *msg, int err)
-{
- return error_common_reply(conn, msg,
- ERROR_INTERFACE ".ConnectionAttemptFailed",
- err < 0 ? strerror(-err) : "Connection attempt failed");
+ DBusMessage *reply = btd_error_failed(msg,
+ err < 0 ? strerror(-err) : "Connect failed");
+ g_dbus_send_message(conn, reply);
}
static int rfcomm_connect(struct audio_device *device, headset_stream_cb_t cb,
@@ -567,9 +560,7 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
if (p != NULL) {
p->err = -errno;
if (p->msg)
- error_connection_attempt_failed(dev->conn,
- p->msg,
- p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
pending_connect_finalize(dev);
}
@@ -679,7 +670,7 @@ static void hfp_slc_complete(struct audio_device *dev)
p->err = sco_connect(dev, NULL, NULL, NULL);
if (p->err < 0) {
if (p->msg)
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
pending_connect_finalize(dev);
}
}
@@ -1397,7 +1388,7 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
failed:
if (p && p->msg)
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
pending_connect_finalize(dev);
if (hs->rfcomm)
headset_set_state(dev, HEADSET_STATE_CONNECTED);
@@ -1454,7 +1445,7 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
error("Unable to get service record: %s (%d)",
strerror(-err), -err);
p->err = -err;
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
goto failed;
}
@@ -1503,7 +1494,7 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
if (err < 0) {
error("Unable to connect: %s (%d)", strerror(-err), -err);
p->err = -err;
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
goto failed;
}
@@ -1513,8 +1504,10 @@ failed_not_supported:
if (p->svclass == HANDSFREE_SVCLASS_ID &&
get_records(dev, NULL, NULL, NULL) == 0)
return;
- if (p->msg)
- error_not_supported(dev->conn, p->msg);
+ if (p->msg) {
+ DBusMessage *reply = btd_error_not_supported(p->msg);
+ g_dbus_send_message(dev->conn, reply);
+ }
failed:
p->svclass = 0;
pending_connect_finalize(dev);
@@ -2667,7 +2660,7 @@ void headset_shutdown(struct audio_device *dev)
struct pending_connect *p = dev->headset->pending;
if (p && p->msg)
- error_connection_attempt_failed(dev->conn, p->msg, ECANCELED);
+ error_connect_failed(dev->conn, p->msg, ECANCELED);
pending_connect_finalize(dev);
headset_set_state(dev, HEADSET_STATE_DISCONNECTED);
diff --git a/audio/sink.c b/audio/sink.c
index 5746c55..2d5db18 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -253,10 +253,11 @@ static void stream_state_changed(struct avdtp_stream *stream,
sink->stream_state = new_state;
}
-static DBusHandlerResult error_failed(DBusConnection *conn,
- DBusMessage *msg, const char * desc)
+static void error_failed(DBusConnection *conn, DBusMessage *msg,
+ const char *desc)
{
- return error_common_reply(conn, msg, ERROR_INTERFACE ".Failed", desc);
+ DBusMessage *reply = btd_error_failed(msg, desc);
+ g_dbus_send_message(conn, reply);
}
static gboolean stream_setup_retry(gpointer user_data)
diff --git a/audio/source.c b/audio/source.c
index 29ceb0f..6d266f2 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -206,10 +206,11 @@ static void stream_state_changed(struct avdtp_stream *stream,
source->stream_state = new_state;
}
-static DBusHandlerResult error_failed(DBusConnection *conn,
- DBusMessage *msg, const char * desc)
+static void error_failed(DBusConnection *conn, DBusMessage *msg,
+ const char *desc)
{
- return error_common_reply(conn, msg, ERROR_INTERFACE ".Failed", desc);
+ DBusMessage *reply = btd_error_failed(msg, desc);
+ g_dbus_send_message(conn, reply);
}
static gboolean stream_setup_retry(gpointer user_data)
diff --git a/src/error.c b/src/error.c
index 25f89f6..7d3afd4 100644
--- a/src/error.c
+++ b/src/error.c
@@ -31,24 +31,6 @@
#include "error.h"
-/* Helper function - internal use only */
-DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
- const char *name, const char *descr)
-{
- DBusMessage *derr;
-
- if (!conn || !msg)
- return DBUS_HANDLER_RESULT_HANDLED;
-
- derr = dbus_message_new_error(msg, name, descr);
- if (!derr)
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
-
- g_dbus_send_message(conn, derr);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
DBusMessage *btd_error_invalid_args(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments",
diff --git a/src/error.h b/src/error.h
index 0f2eb22..b8c06ce 100644
--- a/src/error.h
+++ b/src/error.h
@@ -27,9 +27,6 @@
#define ERROR_INTERFACE "org.bluez.Error"
-DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
- const char *name, const char *descr);
-
DBusMessage *btd_error_invalid_args(DBusMessage *msg);
DBusMessage *btd_error_busy(DBusMessage *msg);
DBusMessage *btd_error_already_exists(DBusMessage *msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 1/4] add btd_error_agent_not_assigned()
From: Gustavo F. Padovan @ 2010-12-15 22:07 UTC (permalink / raw)
To: linux-bluetooth
---
audio/gateway.c | 3 +--
src/adapter.c | 3 +--
src/error.c | 6 ++++++
src/error.h | 1 +
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 4d38be7..6a095ca 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -367,8 +367,7 @@ static DBusMessage *ag_connect(DBusConnection *conn, DBusMessage *msg,
int err;
if (!gw->agent)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".Failed", "Agent not assigned");
+ return btd_error_agent_not_assigned(msg);
err = get_records(au_dev);
if (err < 0)
diff --git a/src/adapter.c b/src/adapter.c
index 2ff59a0..73c8a9b 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1412,8 +1412,7 @@ static DBusMessage *request_session(DBusConnection *conn,
int err;
if (!adapter->agent)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "No agent registered");
+ return btd_error_agent_not_assigned(msg);
if (!adapter->mode_sessions)
adapter->global_mode = adapter->mode;
diff --git a/src/error.c b/src/error.c
index 3a78628..25f89f6 100644
--- a/src/error.c
+++ b/src/error.c
@@ -115,6 +115,12 @@ DBusMessage *btd_error_no_such_adapter(DBusMessage *msg)
"No such adapter");
}
+DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AgentNotAssigned",
+ "Agent Not Assigned");
+}
+
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str)
{
return g_dbus_create_error(msg, ERROR_INTERFACE
diff --git a/src/error.h b/src/error.h
index faaef0a..0f2eb22 100644
--- a/src/error.h
+++ b/src/error.h
@@ -41,4 +41,5 @@ DBusMessage *btd_error_in_progress(DBusMessage *msg);
DBusMessage *btd_error_does_not_exist(DBusMessage *msg);
DBusMessage *btd_error_not_authorized(DBusMessage *msg);
DBusMessage *btd_error_no_such_adapter(DBusMessage *msg);
+DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg);
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 3/3] convert more dbus errors to btd_error_*
From: Gustavo F. Padovan @ 2010-12-15 21:29 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1292448568-16854-2-git-send-email-padovan@profusion.mobi>
---
audio/headset.c | 7 ++-----
serial/port.c | 8 +-------
serial/proxy.c | 12 ++----------
src/adapter.c | 10 ++--------
4 files changed, 7 insertions(+), 30 deletions(-)
diff --git a/audio/headset.c b/audio/headset.c
index 55bdc61..6fbb4dd 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1696,8 +1696,7 @@ static DBusMessage *hs_connect(DBusConnection *conn, DBusMessage *msg,
return btd_error_already_connected(msg);
if (hs->hfp_handle && !ag.telephony_ready)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
- "Telephony subsystem not ready");
+ return btd_error_failed(msg, "Telephony subsystem not ready");
device->auto_connect = FALSE;
@@ -1874,9 +1873,7 @@ static DBusMessage *hs_set_gain(DBusConnection *conn,
err = headset_set_gain(device, gain, type);
if (err < 0)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".InvalidArgument",
- "Must be less than or equal to 15");
+ return btd_error_invalid_args(msg);
reply = dbus_message_new_method_return(msg);
if (!reply)
diff --git a/serial/port.c b/serial/port.c
index 33450b3..233e317 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -234,12 +234,6 @@ void port_release_all(void)
g_slist_free(devices);
}
-static inline DBusMessage *failed(DBusMessage *msg, const char *description)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "%s", description);
-}
-
static void open_notify(int fd, int err, struct serial_port *port)
{
struct serial_device *device = port->device;
@@ -495,7 +489,7 @@ static DBusMessage *port_connect(DBusConnection *conn,
}
if (port->listener_id)
- return failed(msg, "Port already in use");
+ return btd_error_failed(msg, "Port already in use");
port->listener_id = g_dbus_add_disconnect_watch(conn,
dbus_message_get_sender(msg),
diff --git a/serial/proxy.c b/serial/proxy.c
index 20aea7d..b1ee65e 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -131,12 +131,6 @@ static void proxy_free(struct serial_proxy *prx)
g_free(prx);
}
-static inline DBusMessage *failed(DBusMessage *msg, const char *description)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "%s", description);
-}
-
static void add_lang_attr(sdp_record_t *r)
{
sdp_lang_attr_t base_lang;
@@ -551,9 +545,7 @@ static DBusMessage *proxy_enable(DBusConnection *conn,
int err;
err = enable_proxy(prx);
- if (err == -EALREADY)
- return failed(msg, "Already enabled");
- else if (err < 0)
+ if (err < 0)
return btd_error_failed(msg, strerror(-err));
return dbus_message_new_method_return(msg);
@@ -565,7 +557,7 @@ static DBusMessage *proxy_disable(DBusConnection *conn,
struct serial_proxy *prx = data;
if (!prx->io)
- return failed(msg, "Not enabled");
+ return btd_error_failed(msg, "Not enabled");
/* Remove the watches and unregister the record */
disable_proxy(prx);
diff --git a/src/adapter.c b/src/adapter.c
index 73c8a9b..2b66490 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -146,12 +146,6 @@ static inline DBusMessage *adapter_not_ready(DBusMessage *msg)
"Adapter is not ready");
}
-static inline DBusMessage *not_in_progress(DBusMessage *msg, const char *str)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".NotInProgress",
- "%s", str);
-}
-
static int found_device_cmp(const struct remote_dev_info *d1,
const struct remote_dev_info *d2)
{
@@ -1232,7 +1226,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
ba2str(&adapter->bdaddr, srcaddr);
if (check_address(srcaddr) < 0)
- return adapter_not_ready(msg);
+ return btd_error_invalid_args(msg);
reply = dbus_message_new_method_return(msg);
if (!reply)
@@ -1511,7 +1505,7 @@ static DBusMessage *cancel_device_creation(DBusConnection *conn,
device = adapter_find_device(adapter, address);
if (!device || !device_is_creating(device, NULL))
- return not_in_progress(msg, "Device creation not in progress");
+ return btd_error_does_not_exist(msg);
if (!device_is_creating(device, sender))
return btd_error_not_authorized(msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 2/3] remove error_common_reply()
From: Gustavo F. Padovan @ 2010-12-15 21:29 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1292448568-16854-1-git-send-email-padovan@profusion.mobi>
Remove old dbus error report function. This patch doesn't make things
really really better, but is a start.
---
audio/gateway.c | 18 ++++++++++--------
audio/headset.c | 37 +++++++++++++++----------------------
audio/sink.c | 7 ++++---
audio/source.c | 7 ++++---
src/error.c | 18 ------------------
src/error.h | 3 ---
6 files changed, 33 insertions(+), 57 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 6a095ca..da899a0 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -254,10 +254,11 @@ static void rfcomm_connect_cb(GIOChannel *chan, GError *err,
return;
fail:
- if (gw->msg)
- error_common_reply(dev->conn, gw->msg,
- ERROR_INTERFACE ".Failed",
- "Connection attempt failed");
+ if (gw->msg) {
+ DBusMessage *reply;
+ reply = btd_error_failed(gw->msg, "Connect failed");
+ g_dbus_send_message(dev->conn, reply);
+ }
change_state(dev, GATEWAY_STATE_DISCONNECTED);
}
@@ -333,10 +334,11 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
return;
fail:
- if (gw->msg)
- error_common_reply(dev->conn, gw->msg,
- ERROR_INTERFACE ".NotSupported",
- "Not supported");
+ if (gw->msg) {
+ DBusMessage *reply = btd_error_failed(gw->msg,
+ gerr ? gerr->message : strerror(-err));
+ g_dbus_send_message(dev->conn, reply);
+ }
change_state(dev, GATEWAY_STATE_DISCONNECTED);
diff --git a/audio/headset.c b/audio/headset.c
index 34b2b89..55bdc61 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -176,19 +176,12 @@ struct event {
static GSList *headset_callbacks = NULL;
-static DBusHandlerResult error_not_supported(DBusConnection *conn,
- DBusMessage *msg)
+static void error_connect_failed(DBusConnection *conn, DBusMessage *msg,
+ int err)
{
- return error_common_reply(conn, msg, ERROR_INTERFACE ".NotSupported",
- "Not supported");
-}
-
-static DBusHandlerResult error_connection_attempt_failed(DBusConnection *conn,
- DBusMessage *msg, int err)
-{
- return error_common_reply(conn, msg,
- ERROR_INTERFACE ".ConnectionAttemptFailed",
- err < 0 ? strerror(-err) : "Connection attempt failed");
+ DBusMessage *reply = btd_error_failed(msg,
+ err < 0 ? strerror(-err) : "Connect failed");
+ g_dbus_send_message(conn, reply);
}
static int rfcomm_connect(struct audio_device *device, headset_stream_cb_t cb,
@@ -567,9 +560,7 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
if (p != NULL) {
p->err = -errno;
if (p->msg)
- error_connection_attempt_failed(dev->conn,
- p->msg,
- p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
pending_connect_finalize(dev);
}
@@ -679,7 +670,7 @@ static void hfp_slc_complete(struct audio_device *dev)
p->err = sco_connect(dev, NULL, NULL, NULL);
if (p->err < 0) {
if (p->msg)
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
pending_connect_finalize(dev);
}
}
@@ -1397,7 +1388,7 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
failed:
if (p && p->msg)
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
pending_connect_finalize(dev);
if (hs->rfcomm)
headset_set_state(dev, HEADSET_STATE_CONNECTED);
@@ -1454,7 +1445,7 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
error("Unable to get service record: %s (%d)",
strerror(-err), -err);
p->err = -err;
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
goto failed;
}
@@ -1503,7 +1494,7 @@ static void get_record_cb(sdp_list_t *recs, int err, gpointer user_data)
if (err < 0) {
error("Unable to connect: %s (%d)", strerror(-err), -err);
p->err = -err;
- error_connection_attempt_failed(dev->conn, p->msg, p->err);
+ error_connect_failed(dev->conn, p->msg, p->err);
goto failed;
}
@@ -1513,8 +1504,10 @@ failed_not_supported:
if (p->svclass == HANDSFREE_SVCLASS_ID &&
get_records(dev, NULL, NULL, NULL) == 0)
return;
- if (p->msg)
- error_not_supported(dev->conn, p->msg);
+ if (p->msg) {
+ DBusMessage *reply = btd_error_not_supported(p->msg);
+ g_dbus_send_message(dev->conn, reply);
+ }
failed:
p->svclass = 0;
pending_connect_finalize(dev);
@@ -2667,7 +2660,7 @@ void headset_shutdown(struct audio_device *dev)
struct pending_connect *p = dev->headset->pending;
if (p && p->msg)
- error_connection_attempt_failed(dev->conn, p->msg, ECANCELED);
+ error_connect_failed(dev->conn, p->msg, ECANCELED);
pending_connect_finalize(dev);
headset_set_state(dev, HEADSET_STATE_DISCONNECTED);
diff --git a/audio/sink.c b/audio/sink.c
index 5746c55..2d5db18 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -253,10 +253,11 @@ static void stream_state_changed(struct avdtp_stream *stream,
sink->stream_state = new_state;
}
-static DBusHandlerResult error_failed(DBusConnection *conn,
- DBusMessage *msg, const char * desc)
+static void error_failed(DBusConnection *conn, DBusMessage *msg,
+ const char *desc)
{
- return error_common_reply(conn, msg, ERROR_INTERFACE ".Failed", desc);
+ DBusMessage *reply = btd_error_failed(msg, desc);
+ g_dbus_send_message(conn, reply);
}
static gboolean stream_setup_retry(gpointer user_data)
diff --git a/audio/source.c b/audio/source.c
index 29ceb0f..6d266f2 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -206,10 +206,11 @@ static void stream_state_changed(struct avdtp_stream *stream,
source->stream_state = new_state;
}
-static DBusHandlerResult error_failed(DBusConnection *conn,
- DBusMessage *msg, const char * desc)
+static void error_failed(DBusConnection *conn, DBusMessage *msg,
+ const char *desc)
{
- return error_common_reply(conn, msg, ERROR_INTERFACE ".Failed", desc);
+ DBusMessage *reply = btd_error_failed(msg, desc);
+ g_dbus_send_message(conn, reply);
}
static gboolean stream_setup_retry(gpointer user_data)
diff --git a/src/error.c b/src/error.c
index 25f89f6..7d3afd4 100644
--- a/src/error.c
+++ b/src/error.c
@@ -31,24 +31,6 @@
#include "error.h"
-/* Helper function - internal use only */
-DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
- const char *name, const char *descr)
-{
- DBusMessage *derr;
-
- if (!conn || !msg)
- return DBUS_HANDLER_RESULT_HANDLED;
-
- derr = dbus_message_new_error(msg, name, descr);
- if (!derr)
- return DBUS_HANDLER_RESULT_NEED_MEMORY;
-
- g_dbus_send_message(conn, derr);
-
- return DBUS_HANDLER_RESULT_HANDLED;
-}
-
DBusMessage *btd_error_invalid_args(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments",
diff --git a/src/error.h b/src/error.h
index 0f2eb22..b8c06ce 100644
--- a/src/error.h
+++ b/src/error.h
@@ -27,9 +27,6 @@
#define ERROR_INTERFACE "org.bluez.Error"
-DBusHandlerResult error_common_reply(DBusConnection *conn, DBusMessage *msg,
- const char *name, const char *descr);
-
DBusMessage *btd_error_invalid_args(DBusMessage *msg);
DBusMessage *btd_error_busy(DBusMessage *msg);
DBusMessage *btd_error_already_exists(DBusMessage *msg);
--
1.7.3.2
^ permalink raw reply related
* [PATCH 1/3] add btd_error_agent_not_assigned()
From: Gustavo F. Padovan @ 2010-12-15 21:29 UTC (permalink / raw)
To: linux-bluetooth
---
audio/gateway.c | 3 +--
src/adapter.c | 3 +--
src/error.c | 6 ++++++
src/error.h | 1 +
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/audio/gateway.c b/audio/gateway.c
index 4d38be7..6a095ca 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -367,8 +367,7 @@ static DBusMessage *ag_connect(DBusConnection *conn, DBusMessage *msg,
int err;
if (!gw->agent)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".Failed", "Agent not assigned");
+ return btd_error_agent_not_assigned(msg);
err = get_records(au_dev);
if (err < 0)
diff --git a/src/adapter.c b/src/adapter.c
index 2ff59a0..73c8a9b 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1412,8 +1412,7 @@ static DBusMessage *request_session(DBusConnection *conn,
int err;
if (!adapter->agent)
- return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
- "No agent registered");
+ return btd_error_agent_not_assigned(msg);
if (!adapter->mode_sessions)
adapter->global_mode = adapter->mode;
diff --git a/src/error.c b/src/error.c
index 3a78628..25f89f6 100644
--- a/src/error.c
+++ b/src/error.c
@@ -115,6 +115,12 @@ DBusMessage *btd_error_no_such_adapter(DBusMessage *msg)
"No such adapter");
}
+DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AgentNotAssigned",
+ "Agent Not Assigned");
+}
+
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str)
{
return g_dbus_create_error(msg, ERROR_INTERFACE
diff --git a/src/error.h b/src/error.h
index faaef0a..0f2eb22 100644
--- a/src/error.h
+++ b/src/error.h
@@ -41,4 +41,5 @@ DBusMessage *btd_error_in_progress(DBusMessage *msg);
DBusMessage *btd_error_does_not_exist(DBusMessage *msg);
DBusMessage *btd_error_not_authorized(DBusMessage *msg);
DBusMessage *btd_error_no_such_adapter(DBusMessage *msg);
+DBusMessage *btd_error_agent_not_assigned(DBusMessage *msg);
DBusMessage *btd_error_failed(DBusMessage *msg, const char *str);
--
1.7.3.2
^ permalink raw reply related
* [PATCH] Fix memory leak of gattrib commands queue
From: Claudio Takahasi @ 2010-12-15 20:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
---
attrib/gattrib.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/attrib/gattrib.c b/attrib/gattrib.c
index 4ed29d9..eace01b 100644
--- a/attrib/gattrib.c
+++ b/attrib/gattrib.c
@@ -177,6 +177,7 @@ void g_attrib_unref(GAttrib *attrib)
while ((c = g_queue_pop_head(attrib->queue)))
command_destroy(c);
+ g_queue_free(attrib->queue);
attrib->queue = NULL;
for (l = attrib->events; l; l = l->next)
--
1.7.3.3
^ permalink raw reply related
* [PATCH 5/5] Remove unneeded variable
From: Claudio Takahasi @ 2010-12-15 19:54 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292442852-26457-1-git-send-email-claudio.takahasi@openbossa.org>
---
src/glib-helper.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/glib-helper.c b/src/glib-helper.c
index edc46d8..8cf29ae 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -525,7 +525,6 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
{
struct gattrib_context *ctxt;
GIOChannel *io;
- GError *gerr = NULL;
ctxt = g_try_new0(struct gattrib_context, 1);
if (ctxt == NULL)
@@ -538,14 +537,14 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->destroy = destroy;
if (psm < 0)
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_CID, GATT_CID,
BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
else
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_PSM, psm,
--
1.7.3.3
^ permalink raw reply related
* [PATCH 4/5] Fix missing reply when create device is cancelled
From: Claudio Takahasi @ 2010-12-15 19:54 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292442852-26457-1-git-send-email-claudio.takahasi@openbossa.org>
When CancelDeviceCreation is called or when the device is removed for
any reason, the reply for the pending CreateDevice is not sent.
---
src/device.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/device.c b/src/device.c
index cf3b146..a881c4c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -730,8 +730,10 @@ void device_request_disconnect(struct btd_device *device, DBusMessage *msg)
if (device->bonding)
bonding_request_cancel(device->bonding);
- if (device->browse)
+ if (device->browse) {
+ discover_services_reply(device->browse, -ECANCELED, NULL);
browse_request_cancel(device->browse);
+ }
if (msg)
device->disconnects = g_slist_append(device->disconnects,
@@ -1043,8 +1045,10 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
if (device->bonding)
device_cancel_bonding(device, HCI_OE_USER_ENDED_CONNECTION);
- if (device->browse)
+ if (device->browse) {
+ discover_services_reply(device->browse, -ECANCELED, NULL);
browse_request_cancel(device->browse);
+ }
if (device->handle)
do_disconnect(device);
--
1.7.3.3
^ permalink raw reply related
* [PATCH 3/5] Return an error if adapter_create_device fails
From: Claudio Takahasi @ 2010-12-15 19:54 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292442852-26457-1-git-send-email-claudio.takahasi@openbossa.org>
This function can fail if the device object is already registered or if
the system doesn't have enough memory. Issue detected due wrong device
object reference counting that doesn't unregister the D-Bus object path
when the device is removed.
---
src/adapter.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index c1fddce..f71d063 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1595,7 +1595,8 @@ static DBusMessage *create_device(DBusConnection *conn,
device = adapter_create_device(conn, adapter, address, type);
if (!device)
- return NULL;
+ return btd_error_failed(msg,
+ "Unable to create a new device object");
if (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
/* Device is not connectable */
@@ -1693,7 +1694,8 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
device = adapter_create_device(conn, adapter, address, type);
if (!device)
- return NULL;
+ return btd_error_failed(msg,
+ "Unable to create a new device object");
} else
type = device_get_type(device);
--
1.7.3.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox