Linux bluetooth development
 help / color / mirror / Atom feed
* Re: [PATCH]Bluetooth:net/bluetooth/hci_core.c Fix system crash when creating a new device with bluetooth-applet
From: Suraj Sumangala @ 2010-09-01  8:57 UTC (permalink / raw)
  To: Gustavo F. Padovan
  Cc: Justin P. Mattock, linux-bluetooth@vger.kernel.org,
	marcel@holtmann.org, Suraj Sumangala,
	linux-kernel@vger.kernel.org
In-Reply-To: <20100901010821.GA28764@vigoh>

Hi Justin,

On 9/1/2010 1:30 PM, Gustavo F. Padovan wrote:
> Hi Justin,
>
> * Justin P. Mattock<justinmattock@gmail.com>  [2010-08-31 10:13:47 -0700]:
>
>> When using bluetooth-applet adding my apple magic mouse I'm getting a total system freeze.
>> I used firescope to grab the crash data(below) The results of the bisect pointed to here:
>> Bluetooth: Implemented HCI frame reassembly from RX stream
>> commit:9981151086385eecc2febf4ba95a14593f834b3d
>>
>> after looking through, and at the crash log, I couldn't help but notice something in there
>> with IRQ, then after looking at hci_h4.c /* H4 receiver States */ #58 I noticed
>> #define H4_W4_PACKET_TYPE 0 is at zero as well as  #define STREAM_REASSEMBLY 0
>> so changing  STREAM_REASSEMBLY to a different number that isn't taken gets my machine to connect
>> perfectly to my magic mouse. Please have a look and let me know if this is a good
>> solution and/or send me something else to test out.
>
> Your patch seems very wrong, H4_W4_PACKET_TYPE and STREAM_REASSEMBLY
> have nothing to do with each other, your commit message doesn't make
> sense. Also the patch corrupts 'struct hci_dev'.
> If you pay attention on the code flow you can check that
> STREAM_REASSEMBLY is never used in the crash log you sent.
Gustavo is correct. This should not have any effect on the code flow for 
you as you are using USB transport and STREAM_REASSEMBLY is relevant 
only for UART transport.

So, I guess your problem is not 100% reproducible.
>
>>
>> crash:
>>
>>
>> <1>[ 1755.556472] BUG: unable to handle kernel paging request at ffff880224d0c548
>> <1>[ 1755.556485] IP: [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.556507] PGD 1609063 PUD 0
>> <0>[ 1755.556515] Oops: 0000 [#1] SMP
>> <0>[ 1755.556522] last sysfs file: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_now
>> <4>[ 1755.556530] CPU 0
>> <4>[ 1755.556533] Modules linked in: usb_storage xfrm4_mode_transport xcbc rmd160 sha512_generic sco bnep xt_tcpudp ipt_LOG iptable_nat nf_nat xt_state nf_conntrack_ftp nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 iptable_filter ip_tables x_tables ath9k firewire_ohci ath9k_common firewire_core ath9k_hw battery ac ohci1394 evdev thermal ath sky2 joydev button snd_hda_codec_idt snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_timer i2c_i801 snd soundcore snd_page_alloc video aes_x86_64 lzo lzo_compress tun kvm_intel ipcomp xfrm_ipcomp crypto_null sha256_generic cbc des_generic cast5 blowfish serpent camellia twofish_generic twofish_x86_64 twofish_common ctr ah4 esp4 authenc raw1394 ieee1394 uhci_hcd ehci_hcd hci_uart rfcomm btusb hidp l2cap bluetooth coretemp acpi_cpufreq processor mperf appletouch applesmc
>> <4>[ 1755.556676]
>> <4>[ 1755.556682] Pid: 0, comm: swapper Not tainted 2.6.36-rc3 #3 Mac-F42187C8/MacBookPro2,2
>> <4>[ 1755.556688] RIP: 0010:[<ffffffffa0042bec>]  [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.556705] RSP: 0018:ffff880001803ca8  EFLAGS: 00010092
>> <4>[ 1755.556710] RAX: 000000003df64001 RBX: 0000000000000014 RCX: 0000000000000014
>> <4>[ 1755.556716] RDX: ffff8800372018d8 RSI: 0000000000000002 RDI: ffff8800351ec240
>> <4>[ 1755.556722] RBP: ffff880001803cf8 R08: ffff88003df64001 R09: ffff88000180f398
>> <4>[ 1755.556728] R10: dead000000100100 R11: dead000000200200 R12: ffff8800351ec240
>> <4>[ 1755.556733] R13: 0000000000000002 R14: 000000003df64001 R15: 0000000000000001
>> <4>[ 1755.556740] FS:  0000000000000000(0000) GS:ffff880001800000(0000) knlGS:0000000000000000
>> <4>[ 1755.556746] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> <4>[ 1755.556752] CR2: ffff880224d0c548 CR3: 0000000001608000 CR4: 00000000000006f0
>> <4>[ 1755.556758] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> <4>[ 1755.556763] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
>> <4>[ 1755.556770] Process swapper (pid: 0, threadinfo ffffffff815f0000, task ffffffff81610020)
>> <0>[ 1755.556774] Stack:
>> <4>[ 1755.556778]  ffffea0000b9fdc8 ffff88003df64000 ffff8800372018d8 ffffffffa00a189f
>> <4>[ 1755.556787]<0>  ffff880001803d08 0000000000000014 0000000000000002 ffff8800372018d8
>> <4>[ 1755.556797]<0>  ffff8800351ec240 0000000000000001 ffff880001803d38 ffffffffa0042dc5
>> <0>[ 1755.556809] Call Trace:
>> <0>[ 1755.556813]<IRQ>
>> <4>[ 1755.556825]  [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3 [uhci_hcd]
>> <4>[ 1755.556839]  [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65 [bluetooth]
>> <4>[ 1755.556851]  [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6 [btusb]
>> <4>[ 1755.556862]  [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>> <4>[ 1755.556873]  [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9 [uhci_hcd]
>> <4>[ 1755.556884]  [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e [uhci_hcd]
>> <4>[ 1755.556896]  [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>> <4>[ 1755.556903]  [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>> <4>[ 1755.556913]  [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>> <4>[ 1755.556922]  [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>> <4>[ 1755.556931]  [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>> <4>[ 1755.556938]  [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>> <4>[ 1755.556948]  [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>> <0>[ 1755.556952]<EOI>
>> <4>[ 1755.556966]  [<ffffffffa0022e7b>] ? acpi_idle_enter_bm+0x252/0x28a [processor]
>> <4>[ 1755.556979]  [<ffffffffa0022e74>] ? acpi_idle_enter_bm+0x24b/0x28a [processor]
>> <4>[ 1755.556988]  [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>> <4>[ 1755.556996]  [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119
>> <4>[ 1755.557004]  [<ffffffff81025db4>] cpu_idle+0x62/0xc5
>> <4>[ 1755.557014]  [<ffffffff813d1bd4>] rest_init+0x68/0x6a
>> <4>[ 1755.557024]  [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>> <4>[ 1755.557033]  [<ffffffff8168c2a6>] x86_64_start_reservations+0xad/0xb1
>> <4>[ 1755.557042]  [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>> <4>[ 1755.557050]  [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>> <0>[ 1755.557055] Code: 41 5c 41 5d 41 5e c9 c3 55 49 63 c0 48 89 e5 41 57 41 56 45 89 c6 41 55 41 89 f5 41 54 49 89 fc 53 89 cb 48 83 ec 28 48 89 55 c0<48>  8b 94 c7 00 03 00 00 48 85 d2 0f 85 61 01 00 00 41 8d 45 fe
>> <1>[ 1755.557139] RIP  [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.557154]  RSP<ffff880001803ca8>
>> <0>[ 1755.557158] CR2: ffff880224d0c548
>> <4>[ 1755.557164] ---[ end trace 6c64514f0ad01ea5 ]---
>> <0>[ 1755.557169] Kernel panic - not syncing: Fatal exception in interrupt
>> <4>[ 1755.557176] Pid: 0, comm: swapper Tainted: G      D     2.6.36-rc3 #3
>> <4>[ 1755.557180] Call Trace:
>> <4>[ 1755.557183]<IRQ>   [<ffffffff813e47d2>] panic+0x8c/0x189
>> <4>[ 1755.557199]  [<ffffffff813ed90c>] oops_end+0x87/0x94
>> <4>[ 1755.557206]  [<ffffffff813e4737>] no_context+0x1f4/0x203
>> <4>[ 1755.557216]  [<ffffffff8104487f>] __bad_area_nosemaphore+0x17f/0x1a2
>> <4>[ 1755.557224]  [<ffffffff810448b0>] bad_area_nosemaphore+0xe/0x10
>> <4>[ 1755.557233]  [<ffffffff813ef9fd>] do_page_fault+0x1ee/0x3c2
>> <4>[ 1755.557243]  [<ffffffff810e4748>] ? check_object+0x151/0x202
>> <4>[ 1755.557254]  [<ffffffffa00a336f>] ? uhci_alloc_td.isra.22+0x16/0x44 [uhci_hcd]
>> <4>[ 1755.557265]  [<ffffffffa00a3b17>] ? uhci_submit_common.isra.24+0x233/0x2d3 [uhci_hcd]
>> <4>[ 1755.557273]  [<ffffffff813ecde5>] page_fault+0x25/0x30
>> <4>[ 1755.557287]  [<ffffffffa0042bec>] ? hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.557298]  [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3 [uhci_hcd]
>> <4>[ 1755.557311]  [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65 [bluetooth]
>> <4>[ 1755.557322]  [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6 [btusb]
>> <4>[ 1755.557330]  [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>> <4>[ 1755.557340]  [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9 [uhci_hcd]
>> <4>[ 1755.557351]  [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e [uhci_hcd]
>> <4>[ 1755.557362]  [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>> <4>[ 1755.557369]  [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>> <4>[ 1755.557377]  [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>> <4>[ 1755.557386]  [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>> <4>[ 1755.557393]  [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>> <4>[ 1755.557401]  [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>> <4>[ 1755.557408]  [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>> <4>[ 1755.557413]<EOI>   [<ffffffffa0022e7b>] ? acpi_idle_enter_bm+0x252/0x28a [processor]
>> <4>[ 1755.557420]  [<ffffffffa0022e74>] ? acpi_idle_enter_bm+0x24b/0x28a [processor]
>> <4>[ 1755.557420]  [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>> <4>[ 1755.557420]  [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119>  <4>[ 1755.557420]  [<ffffffff81025db4>] cpu_idle+0x62/0xc5>  <4>[ 1755.557420]  [<ffffffff813d1bd4>] rest_init+0x68/0x6a>  <4>[ 1755.557420]  [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>> <4>[ 1755.557420]  [<ffffffff8168c2a6>] x86_64_start_reservations+0xad/0xb1
>> <4>[ 1755.557420]  [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>> <4>[ 1755.557420]  [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>
> Suraj, do you have any idea on that?
>

can you verify the return status of hci_reassembly()? I guess there 
could be some mismatch in the packet received.

Regards
Suraj

^ permalink raw reply

* [PATCH] Remove call to non-existing Adapter method call
From: Bartlomiej.Grzeskowiak @ 2010-09-01 10:09 UTC (permalink / raw)
  To: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]

Patch for /test/test-service file.

[-- Attachment #2: 0001-Remove-call-to-non-existing-Adapter-method-call.patch --]
[-- Type: application/octet-stream, Size: 1115 bytes --]

From 0bbfece9864c3ce14a541447a373bf101d5d8a5b Mon Sep 17 00:00:00 2001
From: Bartlomiej Grzeskowiak <bartlomiej.grzeskowiak@tieto.com>
Date: Tue, 31 Aug 2010 16:20:30 +0200
Subject: [PATCH] Remove call to non-existing Adapter method call

Use Service.AddRecord() instead of Adapter.AddRecord().
---
 test/test-service |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/test-service b/test/test-service
index dae40fc..8958201 100755
--- a/test/test-service
+++ b/test/test-service
@@ -22,8 +22,8 @@ if options.dev_id:
 else:
 	adapter_path = manager.DefaultAdapter()
 
-adapter = dbus.Interface(bus.get_object("org.bluez", adapter_path),
-							"org.bluez.Adapter")
+service = dbus.Interface(bus.get_object("org.bluez", adapter_path),
+						"org.bluez.Service")
 
 if (len(args) < 1):
 	print "Usage: %s <command>" % (sys.argv[0])
@@ -38,7 +38,7 @@ if (args[0] == "addrecord"):
 		f = open(args[1])
 		record = f.read()
 		f.close()
-		handle = adapter.AddRecord(record)
+		handle = service.AddRecord(record)
 		print "0x%x" % (handle)
 		time.sleep(120)
 	sys.exit(0)
-- 
1.5.6.3


^ permalink raw reply related

* [PATCH 1/2] Merging address fields to single field
From: Rafał Michalski @ 2010-09-01 10:21 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Rafał Michalski

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-Merging-address-fields-to-single-field.patch --]
[-- Type: text/x-patch, Size: 4046 bytes --]

From 0d3f5dfa332e62257183a1fff1aa6c39e4823caa Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@gmail.com>
Date: Wed, 1 Sep 2010 11:49:28 +0200
Subject: [PATCH 1/2] Merging address fields to single field

So far in code all seven address fields (pobox, extended, street,
locality, region, postal, country) was represented separately.
In vCard structure address is represented by one field so all
mentioned above fields are merged to single field.
---
 plugins/phonebook-tracker.c |   10 +++-------
 plugins/vcard.c             |   41 ++++++++++++++++-------------------------
 plugins/vcard.h             |    8 +-------
 3 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 1f1f693..bff85b8 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -803,13 +803,9 @@ add_entry:
 	contact->additional = g_strdup(reply[4]);
 	contact->prefix = g_strdup(reply[5]);
 	contact->suffix = g_strdup(reply[6]);
-	contact->pobox = g_strdup(reply[9]);
-	contact->extended = g_strdup(reply[10]);
-	contact->street = g_strdup(reply[11]);
-	contact->locality = g_strdup(reply[12]);
-	contact->region = g_strdup(reply[13]);
-	contact->postal = g_strdup(reply[14]);
-	contact->country = g_strdup(reply[15]);
+	contact->address = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+				reply[9], reply[10], reply[11], reply[12],
+				reply[13], reply[14], reply[15]);
 	contact->birthday = g_strdup(reply[18]);
 	contact->nickname = g_strdup(reply[19]);
 	contact->website = g_strdup(reply[20]);
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 09f4f40..33a1ede 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -31,6 +31,7 @@
 
 #include "vcard.h"
 
+#define ADDR_FIELD_AMOUNT 7
 #define LEN_MAX 128
 #define TYPE_INTERNATIONAL 145
 
@@ -157,20 +158,19 @@ static gboolean contact_fields_present(struct phonebook_contact * contact)
 
 static gboolean address_fields_present(struct phonebook_contact *contact)
 {
-	if (contact->pobox && strlen(contact->pobox))
-		return TRUE;
-	if (contact->extended && strlen(contact->extended))
-		return TRUE;
-	if (contact->street && strlen(contact->street))
-		return TRUE;
-	if (contact->locality && strlen(contact->locality))
-		return TRUE;
-	if (contact->region && strlen(contact->region))
-		return TRUE;
-	if (contact->postal && strlen(contact->postal))
-		return TRUE;
-	if (contact->country && strlen(contact->country))
-		return TRUE;
+	gchar **address_fields = g_strsplit(contact->address, ";",
+							ADDR_FIELD_AMOUNT);
+	int i = 0;
+
+	for (; i < ADDR_FIELD_AMOUNT; ++i) {
+
+		if (strlen(address_fields[i]) != 0) {
+			g_strfreev(address_fields);
+			return TRUE;
+		}
+	}
+
+	g_strfreev(address_fields);
 
 	return FALSE;
 }
@@ -384,10 +384,7 @@ static void vcard_printf_adr(GString *vcards,
 		return;
 	}
 
-	vcard_printf(vcards, "ADR:%s;%s;%s;%s;%s;%s;%s", contact->pobox,
-					contact->extended, contact->street,
-					contact->locality, contact->region,
-					contact->postal, contact->country);
+	vcard_printf(vcards, "ADR:%s", contact->address);
 }
 
 static void vcard_printf_datetime(GString *vcards,
@@ -529,13 +526,7 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_free(contact->additional);
 	g_free(contact->prefix);
 	g_free(contact->suffix);
-	g_free(contact->pobox);
-	g_free(contact->extended);
-	g_free(contact->street);
-	g_free(contact->locality);
-	g_free(contact->region);
-	g_free(contact->postal);
-	g_free(contact->country);
+	g_free(contact->address);
 	g_free(contact->birthday);
 	g_free(contact->nickname);
 	g_free(contact->website);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index a22dfc1..b1e971e 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -59,13 +59,7 @@ struct phonebook_contact {
 	GSList *emails;
 	char *prefix;
 	char *suffix;
-	char *pobox;
-	char *extended;
-	char *street;
-	char *locality;
-	char *region;
-	char *postal;
-	char *country;
+	char *address;
 	char *birthday;
 	char *nickname;
 	char *website;
-- 
1.6.3.3


^ permalink raw reply related

* [PATCH 2/2] Add handling for more than one address in vCard
From: Rafał Michalski @ 2010-09-01 10:23 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Rafał Michalski

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0002-Add-handling-for-more-than-one-address-in-vCard.patch --]
[-- Type: text/x-patch, Size: 14151 bytes --]

From f3d85a8a94fd2d44e16b64c486c29e642c7da192 Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@gmail.com>
Date: Wed, 1 Sep 2010 11:50:31 +0200
Subject: [PATCH 2/2] Add handling for more than one address in vCard

After pulling contacts only fields (pobox, extended, street, locality,
region, postal, country) of one address were present in downloaded vCard
structure (under ADR tag) in spite of that there can be more adresses
stored on phonebook. To solve this problem extending number of columns and
queries of database was needed especially. Distinguish between two types
of address (HOME and WORK) is supported.
---
 plugins/phonebook-tracker.c |  112 +++++++++++++++++++++++++++++++++++++-----
 plugins/vcard.c             |   78 ++++++++++++++++++++++++++----
 plugins/vcard.h             |   13 +++++-
 3 files changed, 179 insertions(+), 24 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index bff85b8..2fbcc6f 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -43,16 +43,17 @@
 #define TRACKER_RESOURCES_INTERFACE "org.freedesktop.Tracker1.Resources"
 
 #define TRACKER_DEFAULT_CONTACT_ME "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#default-contact-me"
-#define CONTACTS_ID_COL 28
-#define PULL_QUERY_COL_AMOUNT 29
+#define CONTACTS_ID_COL 35
+#define PULL_QUERY_COL_AMOUNT 36
 #define COL_HOME_NUMBER 0
 #define COL_HOME_EMAIL 7
 #define COL_WORK_NUMBER 8
 #define COL_FAX_NUMBER 16
 #define COL_WORK_EMAIL 17
-#define COL_DATE 25
-#define COL_SENT 26
-#define COL_ANSWERED 27
+#define COL_DATE 32
+#define COL_SENT 33
+#define COL_ANSWERED 34
+#define ADDR_FIELD_AMOUNT 7
 
 #define CONTACTS_QUERY_ALL						\
 	"SELECT ?v nco:fullname(?c) "					\
@@ -64,7 +65,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"\"NOTACALL\" \"false\" \"false\" ?c "				\
 	"WHERE { "							\
 		"?c a nco:PersonContact . "				\
@@ -84,6 +87,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"}"
@@ -112,7 +116,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -133,6 +139,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -161,7 +168,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -182,6 +191,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -210,7 +220,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew)"	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -230,6 +242,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} ORDER BY DESC(nmo:sentDate(?call))"
@@ -257,7 +270,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -277,6 +292,7 @@
 	"OPTIONAL { ?c nco:hasAffiliation ?a . "			\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} UNION { "							\
@@ -295,6 +311,7 @@
 	"OPTIONAL { ?c nco:hasAffiliation ?a . "			\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} } ORDER BY DESC(nmo:receivedDate(?call))"
@@ -329,7 +346,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f  nco:emailAddress(?ew)"	\
 	"nco:birthDate(<%s>) nco:nickname(<%s>) nco:websiteUrl(<%s>) "	\
 	"nco:photo(<%s>) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"\"NOTACALL\" \"false\" \"false\" <%s> "			\
 	"WHERE { "							\
 		"<%s> a nco:Contact . "					\
@@ -349,6 +368,7 @@
 		"<%s> nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . }" 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . }"		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"}"
@@ -721,6 +741,60 @@ static void add_email(struct phonebook_contact *contact, const char *address,
 	contact->emails = g_slist_append(contact->emails, email);
 }
 
+static struct phonebook_address *find_address(GSList *addresses,
+					const char *address, int type)
+{
+	GSList *l = addresses;
+
+	for (; l; l = l->next) {
+		struct phonebook_address *addr = l->data;
+		if (g_strcmp0(addr->addr, address) == 0 &&
+						addr->type == type)
+			return addr;
+	}
+
+	return NULL;
+}
+
+static gboolean address_fields_present(const char *address)
+{
+	gchar **address_fields = g_strsplit(address, ";",
+							ADDR_FIELD_AMOUNT);
+	int i = 0;
+
+	for (; i < ADDR_FIELD_AMOUNT; ++i) {
+
+		if (strlen(address_fields[i]) != 0) {
+			g_strfreev(address_fields);
+			return TRUE;
+		}
+	}
+
+	g_strfreev(address_fields);
+
+	return FALSE;
+}
+
+static void add_address(struct phonebook_contact *contact,
+					const char *address, int type)
+{
+	struct phonebook_address *addr;
+
+	if (address == NULL || address_fields_present(address) == FALSE)
+		return;
+
+	/* Not adding address if there is already added with the same value */
+	if (find_address(contact->addresses, address, type))
+		return;
+
+	addr = g_new0(struct phonebook_address, 1);
+
+	addr->addr = g_strdup(address);
+	addr->type = type;
+
+	contact->addresses = g_slist_append(contact->addresses, addr);
+}
+
 static GString *gen_vcards(GSList *contacts,
 					const struct apparam_field *params)
 {
@@ -753,6 +827,7 @@ static void pull_contacts(char **reply, int num_fields, void *user_data)
 	GString *vcards;
 	int last_index, i;
 	gboolean cdata_present = FALSE;
+	char *home_addr, *work_addr;
 
 	DBG("reply %p", reply);
 
@@ -803,9 +878,6 @@ add_entry:
 	contact->additional = g_strdup(reply[4]);
 	contact->prefix = g_strdup(reply[5]);
 	contact->suffix = g_strdup(reply[6]);
-	contact->address = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
-				reply[9], reply[10], reply[11], reply[12],
-				reply[13], reply[14], reply[15]);
 	contact->birthday = g_strdup(reply[18]);
 	contact->nickname = g_strdup(reply[19]);
 	contact->website = g_strdup(reply[20]);
@@ -827,6 +899,18 @@ add_numbers:
 	add_email(contact, reply[COL_HOME_EMAIL], EMAIL_TYPE_HOME);
 	add_email(contact, reply[COL_WORK_EMAIL], EMAIL_TYPE_WORK);
 
+	/* Adding addresses */
+	home_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+				reply[9], reply[10], reply[11], reply[12],
+				reply[13], reply[14], reply[15]);
+
+	work_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+				reply[25], reply[26], reply[27], reply[28],
+				reply[29], reply[30], reply[31]);
+
+	add_address(contact, home_addr, ADDR_TYPE_HOME);
+	add_address(contact, work_addr, ADDR_TYPE_WORK);
+
 	DBG("contact %p", contact);
 
 	/* Adding contacts data to wrapper struct - this data will be used to
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 33a1ede..19ecdd3 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -156,9 +156,9 @@ static gboolean contact_fields_present(struct phonebook_contact * contact)
 	return FALSE;
 }
 
-static gboolean address_fields_present(struct phonebook_contact *contact)
+static gboolean address_fields_present(const char *address)
 {
-	gchar **address_fields = g_strsplit(contact->address, ";",
+	gchar **address_fields = g_strsplit(address, ";",
 							ADDR_FIELD_AMOUNT);
 	int i = 0;
 
@@ -376,15 +376,54 @@ static void vcard_printf_org(GString *vcards,
 				contact->department, contact->title);
 }
 
-static void vcard_printf_adr(GString *vcards,
-					struct phonebook_contact *contact)
+static void vcard_printf_address(GString *vcards, uint8_t format,
+					const char *address,
+					enum phonebook_address_type category)
 {
-	if (address_fields_present(contact) == FALSE) {
+	char buf[LEN_MAX];
+	char field[ADDR_FIELD_AMOUNT][LEN_MAX];
+	const char *category_string = "";
+	int len, i;
+	gchar **address_fields;
+
+	if (!address || address_fields_present(address) == FALSE) {
 		vcard_printf(vcards, "ADR:");
 		return;
 	}
 
-	vcard_printf(vcards, "ADR:%s", contact->address);
+	switch (category) {
+	case ADDR_TYPE_HOME:
+		if (format == FORMAT_VCARD21)
+			category_string = "HOME";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=HOME";
+		break;
+	case ADDR_TYPE_WORK:
+		if (format == FORMAT_VCARD21)
+			category_string = "WORK";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=WORK";
+		break;
+	default:
+		if (format == FORMAT_VCARD21)
+			category_string = "OTHER";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=OTHER";
+		break;
+	}
+
+	address_fields = g_strsplit(address, ";", ADDR_FIELD_AMOUNT);
+
+	for (i = 0; i < ADDR_FIELD_AMOUNT; ++i) {
+		len = strlen(address_fields[i]);
+		add_slash(field[i], address_fields[i], LEN_MAX, len);
+	}
+
+	snprintf(buf, LEN_MAX, "%s;%s;%s;%s;%s;%s;%s",
+	field[0], field[1], field[2], field[3], field[4], field[5], field[6]);
+	g_strfreev(address_fields);
+
+	vcard_printf(vcards,"ADR;%s:%s", category_string, buf);
 }
 
 static void vcard_printf_datetime(GString *vcards,
@@ -465,8 +504,19 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 		}
 	}
 
-	if (filter & FILTER_ADR)
-		vcard_printf_adr(vcards, contact);
+	if (filter & FILTER_ADR) {
+		GSList *l = contact->addresses;
+
+		if (g_slist_length(l) == 0)
+			vcard_printf_address(vcards, format, NULL,
+							ADDR_TYPE_OTHER);
+
+		for (; l; l = l->next) {
+			struct phonebook_address *addr = l->data;
+			vcard_printf_address(vcards, format, addr->addr,
+								addr->type);
+		}
+	}
 
 	if (filter & FILTER_BDAY)
 		vcard_printf_tag(vcards, format, "BDAY", NULL,
@@ -509,6 +559,14 @@ static void email_free(gpointer data, gpointer user_data)
 	g_free(email);
 }
 
+static void address_free(gpointer data, gpointer user_data)
+{
+	struct phonebook_address *addr = data;
+
+	g_free(addr->addr);
+	g_free(addr);
+}
+
 void phonebook_contact_free(struct phonebook_contact *contact)
 {
 	if (contact == NULL)
@@ -520,13 +578,15 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_slist_foreach(contact->emails, email_free, NULL);
 	g_slist_free(contact->emails);
 
+	g_slist_foreach(contact->addresses, address_free, NULL);
+	g_slist_free(contact->addresses);
+
 	g_free(contact->fullname);
 	g_free(contact->given);
 	g_free(contact->family);
 	g_free(contact->additional);
 	g_free(contact->prefix);
 	g_free(contact->suffix);
-	g_free(contact->address);
 	g_free(contact->birthday);
 	g_free(contact->nickname);
 	g_free(contact->website);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index b1e971e..8be6df4 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -40,6 +40,12 @@ enum phonebook_call_type {
 	CALL_TYPE_OUTGOING,
 };
 
+enum phonebook_address_type {
+	ADDR_TYPE_HOME,
+	ADDR_TYPE_WORK,
+	ADDR_TYPE_OTHER,
+};
+
 struct phonebook_number {
 	char *tel;
 	int type;
@@ -50,6 +56,11 @@ struct phonebook_email {
 	int  type;
 };
 
+struct phonebook_address {
+	char *addr;
+	int type;
+};
+
 struct phonebook_contact {
 	char *fullname;
 	char *given;
@@ -59,7 +70,7 @@ struct phonebook_contact {
 	GSList *emails;
 	char *prefix;
 	char *suffix;
-	char *address;
+	GSList *addresses;
 	char *birthday;
 	char *nickname;
 	char *website;
-- 
1.6.3.3


^ permalink raw reply related

* Re: [PATCH] Remove call to non-existing Adapter method call
From: Johan Hedberg @ 2010-09-01 10:33 UTC (permalink / raw)
  To: Bartlomiej.Grzeskowiak; +Cc: linux-bluetooth
In-Reply-To: <178E2BE2B7167149B0CA14C646B156000A91FF47BC@EXMB01.eu.tieto.com>

Hi,

On Wed, Sep 01, 2010, Bartlomiej.Grzeskowiak@tieto.com wrote:
> Patch for /test/test-service file.

Thanks. The patch is now upstream.

Johan

^ permalink raw reply

* Re: [PATCH 1/2] Merging address fields to single field
From: Johan Hedberg @ 2010-09-01 10:36 UTC (permalink / raw)
  To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikL2mskaXPygeWvmdy6zjiRDExiq-yW+PaXoVsU@mail.gmail.com>

Hi Rafal,

On Wed, Sep 01, 2010, Rafał Michalski wrote:
> From: Rafal Michalski <michalski.raf@gmail.com>
> Date: Wed, 1 Sep 2010 11:49:28 +0200
> Subject: [PATCH 1/2] Merging address fields to single field
> 
> So far in code all seven address fields (pobox, extended, street,
> locality, region, postal, country) was represented separately.
> In vCard structure address is represented by one field so all
> mentioned above fields are merged to single field.
> ---
>  plugins/phonebook-tracker.c |   10 +++-------
>  plugins/vcard.c             |   41 ++++++++++++++++-------------------------
>  plugins/vcard.h             |    8 +-------
>  3 files changed, 20 insertions(+), 39 deletions(-)

Thanks. This patch is now upstream.

Johan

^ permalink raw reply

* Re: [PATCH 2/2] Add handling for more than one address in vCard
From: Johan Hedberg @ 2010-09-01 10:48 UTC (permalink / raw)
  To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikGen9zKWdi=J558PXOBKhreu=WJ9_KCrQ=n_sx@mail.gmail.com>

Hi Rafal,

On Wed, Sep 01, 2010, Rafał Michalski wrote:
> +static struct phonebook_address *find_address(GSList *addresses,
> +					const char *address, int type)
> +{
> +	GSList *l = addresses;
> +
> +	for (; l; l = l->next) {

Please avoid initialization upon declaration of variables when possible.
The first part of the for-statement is where you should usually
initialize the iterator, i.e. in this case do the l = addresses there.

> +static gboolean address_fields_present(const char *address)
> +{
> +	gchar **address_fields = g_strsplit(address, ";",
> +							ADDR_FIELD_AMOUNT);
> +	int i = 0;
> +
> +	for (; i < ADDR_FIELD_AMOUNT; ++i) {

Same here for i. Additionally you could rename address_fields to simply
fields since the function is short and the context pretty obvious.
You'll also avoid the split line that way (another thing I wouldn't
object to is to move the initialization separate from the variable
declaration).

> -static gboolean address_fields_present(struct phonebook_contact *contact)
> +static gboolean address_fields_present(const char *address)
>  {
> -	gchar **address_fields = g_strsplit(contact->address, ";",
> +	gchar **address_fields = g_strsplit(address, ";",
>  							ADDR_FIELD_AMOUNT);
>  	int i = 0;

Hmm, it seems you have the same function in vcard.c and
phonebook-tracker.c? Why not remove the phonebook-tracker.c one and
export the vcard.c version through vcard.h?

Johan

^ permalink raw reply

* [PATCH] Add handling for more than one address in vCard
From: Rafał Michalski @ 2010-09-01 11:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Rafał Michalski

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-Add-handling-for-more-than-one-address-in-vCard.patch --]
[-- Type: text/x-patch, Size: 14399 bytes --]

From 43270b7ca9e0b54b976a40162c6ad7c062cb206a Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@gmail.com>
Date: Wed, 1 Sep 2010 13:07:12 +0200
Subject: [PATCH] Add handling for more than one address in vCard

After pulling contacts only fields (pobox, extended, street, locality,
region, postal, country) of one address were present in downloaded vCard
structure (under ADR tag) in spite of that there can be more adresses
stored on phonebook. To solve this problem extending number of columns and
queries of database was needed especially. Distinguish between two types
of address (HOME and WORK) is supported.
---
 plugins/phonebook-tracker.c |   93 ++++++++++++++++++++++++++++++++++++------
 plugins/vcard.c             |   89 ++++++++++++++++++++++++++++++++++-------
 plugins/vcard.h             |   15 ++++++-
 3 files changed, 167 insertions(+), 30 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index bff85b8..193226f 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -43,16 +43,17 @@
 #define TRACKER_RESOURCES_INTERFACE "org.freedesktop.Tracker1.Resources"
 
 #define TRACKER_DEFAULT_CONTACT_ME "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#default-contact-me"
-#define CONTACTS_ID_COL 28
-#define PULL_QUERY_COL_AMOUNT 29
+#define CONTACTS_ID_COL 35
+#define PULL_QUERY_COL_AMOUNT 36
 #define COL_HOME_NUMBER 0
 #define COL_HOME_EMAIL 7
 #define COL_WORK_NUMBER 8
 #define COL_FAX_NUMBER 16
 #define COL_WORK_EMAIL 17
-#define COL_DATE 25
-#define COL_SENT 26
-#define COL_ANSWERED 27
+#define COL_DATE 32
+#define COL_SENT 33
+#define COL_ANSWERED 34
+#define ADDR_FIELD_AMOUNT 7
 
 #define CONTACTS_QUERY_ALL						\
 	"SELECT ?v nco:fullname(?c) "					\
@@ -64,7 +65,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"\"NOTACALL\" \"false\" \"false\" ?c "				\
 	"WHERE { "							\
 		"?c a nco:PersonContact . "				\
@@ -84,6 +87,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"}"
@@ -112,7 +116,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -133,6 +139,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -161,7 +168,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -182,6 +191,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} ORDER BY DESC(nmo:receivedDate(?call))"
@@ -210,7 +220,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew)"	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -230,6 +242,7 @@
 		"?c nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} ORDER BY DESC(nmo:sentDate(?call))"
@@ -257,7 +270,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f nco:emailAddress(?ew) "	\
 	"nco:birthDate(?c) nco:nickname(?c) nco:websiteUrl(?c) "	\
 	"nco:photo(?c) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"nmo:receivedDate(?call) "					\
 	"nmo:isSent(?call) nmo:isAnswered(?call) ?c "			\
 	"WHERE { "							\
@@ -277,6 +292,7 @@
 	"OPTIONAL { ?c nco:hasAffiliation ?a . "			\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} UNION { "							\
@@ -295,6 +311,7 @@
 	"OPTIONAL { ?c nco:hasAffiliation ?a . "			\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . } " 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . } "		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"} } ORDER BY DESC(nmo:receivedDate(?call))"
@@ -329,7 +346,9 @@
 	"nco:postalcode(?p) nco:country(?p) ?f  nco:emailAddress(?ew)"	\
 	"nco:birthDate(<%s>) nco:nickname(<%s>) nco:websiteUrl(<%s>) "	\
 	"nco:photo(<%s>) nco:fullname(?o) nco:department(?a) "		\
-	"nco:role(?a) "							\
+	"nco:role(?a) nco:pobox(?pw) nco:extendedAddress(?pw) "		\
+	"nco:streetAddress(?pw) nco:locality(?pw) nco:region(?pw) "	\
+	"nco:postalcode(?pw) nco:country(?pw) "				\
 	"\"NOTACALL\" \"false\" \"false\" <%s> "			\
 	"WHERE { "							\
 		"<%s> a nco:Contact . "					\
@@ -349,6 +368,7 @@
 		"<%s> nco:hasAffiliation ?a . "				\
 		"OPTIONAL { ?a nco:hasPhoneNumber ?w . }" 		\
 		"OPTIONAL { ?a nco:hasEmailAddress ?ew . }"		\
+		"OPTIONAL { ?a nco:hasPostalAddress ?pw . } "		\
 		"OPTIONAL { ?a nco:org ?o . } "				\
 	"} "								\
 	"}"
@@ -721,6 +741,41 @@ static void add_email(struct phonebook_contact *contact, const char *address,
 	contact->emails = g_slist_append(contact->emails, email);
 }
 
+static struct phonebook_address *find_address(GSList *addresses,
+					const char *address, int type)
+{
+	GSList *l;
+
+	for (l = addresses; l; l = l->next) {
+		struct phonebook_address *addr = l->data;
+		if (g_strcmp0(addr->addr, address) == 0 &&
+						addr->type == type)
+			return addr;
+	}
+
+	return NULL;
+}
+
+static void add_address(struct phonebook_contact *contact,
+					const char *address, int type)
+{
+	struct phonebook_address *addr;
+
+	if (address == NULL || address_fields_present(address) == FALSE)
+		return;
+
+	/* Not adding address if there is already added with the same value */
+	if (find_address(contact->addresses, address, type))
+		return;
+
+	addr = g_new0(struct phonebook_address, 1);
+
+	addr->addr = g_strdup(address);
+	addr->type = type;
+
+	contact->addresses = g_slist_append(contact->addresses, addr);
+}
+
 static GString *gen_vcards(GSList *contacts,
 					const struct apparam_field *params)
 {
@@ -753,6 +808,7 @@ static void pull_contacts(char **reply, int num_fields, void *user_data)
 	GString *vcards;
 	int last_index, i;
 	gboolean cdata_present = FALSE;
+	char *home_addr, *work_addr;
 
 	DBG("reply %p", reply);
 
@@ -803,9 +859,6 @@ add_entry:
 	contact->additional = g_strdup(reply[4]);
 	contact->prefix = g_strdup(reply[5]);
 	contact->suffix = g_strdup(reply[6]);
-	contact->address = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
-				reply[9], reply[10], reply[11], reply[12],
-				reply[13], reply[14], reply[15]);
 	contact->birthday = g_strdup(reply[18]);
 	contact->nickname = g_strdup(reply[19]);
 	contact->website = g_strdup(reply[20]);
@@ -827,6 +880,18 @@ add_numbers:
 	add_email(contact, reply[COL_HOME_EMAIL], EMAIL_TYPE_HOME);
 	add_email(contact, reply[COL_WORK_EMAIL], EMAIL_TYPE_WORK);
 
+	/* Adding addresses */
+	home_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+				reply[9], reply[10], reply[11], reply[12],
+				reply[13], reply[14], reply[15]);
+
+	work_addr = g_strdup_printf("%s;%s;%s;%s;%s;%s;%s",
+				reply[25], reply[26], reply[27], reply[28],
+				reply[29], reply[30], reply[31]);
+
+	add_address(contact, home_addr, ADDR_TYPE_HOME);
+	add_address(contact, work_addr, ADDR_TYPE_WORK);
+
 	DBG("contact %p", contact);
 
 	/* Adding contacts data to wrapper struct - this data will be used to
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 33a1ede..6d74e06 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -156,21 +156,20 @@ static gboolean contact_fields_present(struct phonebook_contact * contact)
 	return FALSE;
 }
 
-static gboolean address_fields_present(struct phonebook_contact *contact)
+gboolean address_fields_present(const char *address)
 {
-	gchar **address_fields = g_strsplit(contact->address, ";",
-							ADDR_FIELD_AMOUNT);
-	int i = 0;
+	gchar **fields = g_strsplit(address, ";", ADDR_FIELD_AMOUNT);
+	int i;
 
-	for (; i < ADDR_FIELD_AMOUNT; ++i) {
+	for (i = 0; i < ADDR_FIELD_AMOUNT; ++i) {
 
-		if (strlen(address_fields[i]) != 0) {
-			g_strfreev(address_fields);
+		if (strlen(fields[i]) != 0) {
+			g_strfreev(fields);
 			return TRUE;
 		}
 	}
 
-	g_strfreev(address_fields);
+	g_strfreev(fields);
 
 	return FALSE;
 }
@@ -376,15 +375,54 @@ static void vcard_printf_org(GString *vcards,
 				contact->department, contact->title);
 }
 
-static void vcard_printf_adr(GString *vcards,
-					struct phonebook_contact *contact)
+static void vcard_printf_address(GString *vcards, uint8_t format,
+					const char *address,
+					enum phonebook_address_type category)
 {
-	if (address_fields_present(contact) == FALSE) {
+	char buf[LEN_MAX];
+	char field[ADDR_FIELD_AMOUNT][LEN_MAX];
+	const char *category_string = "";
+	int len, i;
+	gchar **address_fields;
+
+	if (!address || address_fields_present(address) == FALSE) {
 		vcard_printf(vcards, "ADR:");
 		return;
 	}
 
-	vcard_printf(vcards, "ADR:%s", contact->address);
+	switch (category) {
+	case ADDR_TYPE_HOME:
+		if (format == FORMAT_VCARD21)
+			category_string = "HOME";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=HOME";
+		break;
+	case ADDR_TYPE_WORK:
+		if (format == FORMAT_VCARD21)
+			category_string = "WORK";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=WORK";
+		break;
+	default:
+		if (format == FORMAT_VCARD21)
+			category_string = "OTHER";
+		else if (format == FORMAT_VCARD30)
+			category_string = "TYPE=OTHER";
+		break;
+	}
+
+	address_fields = g_strsplit(address, ";", ADDR_FIELD_AMOUNT);
+
+	for (i = 0; i < ADDR_FIELD_AMOUNT; ++i) {
+		len = strlen(address_fields[i]);
+		add_slash(field[i], address_fields[i], LEN_MAX, len);
+	}
+
+	snprintf(buf, LEN_MAX, "%s;%s;%s;%s;%s;%s;%s",
+	field[0], field[1], field[2], field[3], field[4], field[5], field[6]);
+	g_strfreev(address_fields);
+
+	vcard_printf(vcards,"ADR;%s:%s", category_string, buf);
 }
 
 static void vcard_printf_datetime(GString *vcards,
@@ -465,8 +503,19 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 		}
 	}
 
-	if (filter & FILTER_ADR)
-		vcard_printf_adr(vcards, contact);
+	if (filter & FILTER_ADR) {
+		GSList *l = contact->addresses;
+
+		if (g_slist_length(l) == 0)
+			vcard_printf_address(vcards, format, NULL,
+							ADDR_TYPE_OTHER);
+
+		for (; l; l = l->next) {
+			struct phonebook_address *addr = l->data;
+			vcard_printf_address(vcards, format, addr->addr,
+								addr->type);
+		}
+	}
 
 	if (filter & FILTER_BDAY)
 		vcard_printf_tag(vcards, format, "BDAY", NULL,
@@ -509,6 +558,14 @@ static void email_free(gpointer data, gpointer user_data)
 	g_free(email);
 }
 
+static void address_free(gpointer data, gpointer user_data)
+{
+	struct phonebook_address *addr = data;
+
+	g_free(addr->addr);
+	g_free(addr);
+}
+
 void phonebook_contact_free(struct phonebook_contact *contact)
 {
 	if (contact == NULL)
@@ -520,13 +577,15 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_slist_foreach(contact->emails, email_free, NULL);
 	g_slist_free(contact->emails);
 
+	g_slist_foreach(contact->addresses, address_free, NULL);
+	g_slist_free(contact->addresses);
+
 	g_free(contact->fullname);
 	g_free(contact->given);
 	g_free(contact->family);
 	g_free(contact->additional);
 	g_free(contact->prefix);
 	g_free(contact->suffix);
-	g_free(contact->address);
 	g_free(contact->birthday);
 	g_free(contact->nickname);
 	g_free(contact->website);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index b1e971e..d012106 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -40,6 +40,12 @@ enum phonebook_call_type {
 	CALL_TYPE_OUTGOING,
 };
 
+enum phonebook_address_type {
+	ADDR_TYPE_HOME,
+	ADDR_TYPE_WORK,
+	ADDR_TYPE_OTHER,
+};
+
 struct phonebook_number {
 	char *tel;
 	int type;
@@ -50,6 +56,11 @@ struct phonebook_email {
 	int  type;
 };
 
+struct phonebook_address {
+	char *addr;
+	int type;
+};
+
 struct phonebook_contact {
 	char *fullname;
 	char *given;
@@ -59,7 +70,7 @@ struct phonebook_contact {
 	GSList *emails;
 	char *prefix;
 	char *suffix;
-	char *address;
+	GSList *addresses;
 	char *birthday;
 	char *nickname;
 	char *website;
@@ -75,3 +86,5 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 					uint64_t filter, uint8_t format);
 
 void phonebook_contact_free(struct phonebook_contact *contact);
+
+gboolean address_fields_present(const char *address);
-- 
1.6.3.3


^ permalink raw reply related

* [PATCH] Bluetooth: fix MTU L2CAP configuration parameter
From: Emeltchenko Andrei @ 2010-09-01 12:17 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>

When receiving L2CAP negative configuration response with respect
to MTU parameter we modify wrong field. MTU here means proposed
value of MTU that the remote device intends to transmit. So for local
L2CAP socket it is pi->imtu.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
 net/bluetooth/l2cap.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c784703..9fad312 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -2771,10 +2771,10 @@ static int l2cap_parse_conf_rsp(struct sock *sk, void *rsp, int len, void *data,
 		case L2CAP_CONF_MTU:
 			if (val < L2CAP_DEFAULT_MIN_MTU) {
 				*result = L2CAP_CONF_UNACCEPT;
-				pi->omtu = L2CAP_DEFAULT_MIN_MTU;
+				pi->imtu = L2CAP_DEFAULT_MIN_MTU;
 			} else
-				pi->omtu = val;
-			l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu);
+				pi->imtu = val;
+			l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu);
 			break;
 
 		case L2CAP_CONF_FLUSH_TO:
-- 
1.7.0.4


^ permalink raw reply related

* Re: [PATCH]Bluetooth:net/bluetooth/hci_core.c Fix system crash when creating a new device with bluetooth-applet
From: Justin P. Mattock @ 2010-09-01 12:26 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth, marcel, suraj, linux-kernel
In-Reply-To: <20100901010821.GA28764@vigoh>

On 09/01/2010 01:00 AM, Gustavo F. Padovan wrote:
> Hi Justin,
>
> * Justin P. Mattock<justinmattock@gmail.com>  [2010-08-31 10:13:47 -0700]:
>
>> When using bluetooth-applet adding my apple magic mouse I'm getting a total system freeze.
>> I used firescope to grab the crash data(below) The results of the bisect pointed to here:
>> Bluetooth: Implemented HCI frame reassembly from RX stream
>> commit:9981151086385eecc2febf4ba95a14593f834b3d
>>
>> after looking through, and at the crash log, I couldn't help but notice something in there
>> with IRQ, then after looking at hci_h4.c /* H4 receiver States */ #58 I noticed
>> #define H4_W4_PACKET_TYPE 0 is at zero as well as  #define STREAM_REASSEMBLY 0
>> so changing  STREAM_REASSEMBLY to a different number that isn't taken gets my machine to connect
>> perfectly to my magic mouse. Please have a look and let me know if this is a good
>> solution and/or send me something else to test out.
>
> Your patch seems very wrong, H4_W4_PACKET_TYPE and STREAM_REASSEMBLY
> have nothing to do with each other, your commit message doesn't make
> sense. Also the patch corrupts 'struct hci_dev'.
> If you pay attention on the code flow you can check that
> STREAM_REASSEMBLY is never used in the crash log you sent.
>

yeah I admit, I didnt really know what todo with this..(but gave it a try)


>>
>> crash:
>>
>>
>> <1>[ 1755.556472] BUG: unable to handle kernel paging request at ffff880224d0c548
>> <1>[ 1755.556485] IP: [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.556507] PGD 1609063 PUD 0
>> <0>[ 1755.556515] Oops: 0000 [#1] SMP
>> <0>[ 1755.556522] last sysfs file: /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_now
>> <4>[ 1755.556530] CPU 0
>> <4>[ 1755.556533] Modules linked in: usb_storage xfrm4_mode_transport xcbc rmd160 sha512_generic sco bnep xt_tcpudp ipt_LOG iptable_nat nf_nat xt_state nf_conntrack_ftp nf_conntrack_ipv4 nf_conntrack nf_defrag_ipv4 iptable_filter ip_tables x_tables ath9k firewire_ohci ath9k_common firewire_core ath9k_hw battery ac ohci1394 evdev thermal ath sky2 joydev button snd_hda_codec_idt snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_timer i2c_i801 snd soundcore snd_page_alloc video aes_x86_64 lzo lzo_compress tun kvm_intel ipcomp xfrm_ipcomp crypto_null sha256_generic cbc des_generic cast5 blowfish serpent camellia twofish_generic twofish_x86_64 twofish_common ctr ah4 esp4 authenc raw1394 ieee1394 uhci_hcd ehci_hcd hci_uart rfcomm btusb hidp l2cap bluetooth coretemp acpi_cpufreq processor mperf appletouch applesmc
>> <4>[ 1755.556676]
>> <4>[ 1755.556682] Pid: 0, comm: swapper Not tainted 2.6.36-rc3 #3 Mac-F42187C8/MacBookPro2,2
>> <4>[ 1755.556688] RIP: 0010:[<ffffffffa0042bec>]  [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.556705] RSP: 0018:ffff880001803ca8  EFLAGS: 00010092
>> <4>[ 1755.556710] RAX: 000000003df64001 RBX: 0000000000000014 RCX: 0000000000000014
>> <4>[ 1755.556716] RDX: ffff8800372018d8 RSI: 0000000000000002 RDI: ffff8800351ec240
>> <4>[ 1755.556722] RBP: ffff880001803cf8 R08: ffff88003df64001 R09: ffff88000180f398
>> <4>[ 1755.556728] R10: dead000000100100 R11: dead000000200200 R12: ffff8800351ec240
>> <4>[ 1755.556733] R13: 0000000000000002 R14: 000000003df64001 R15: 0000000000000001
>> <4>[ 1755.556740] FS:  0000000000000000(0000) GS:ffff880001800000(0000) knlGS:0000000000000000
>> <4>[ 1755.556746] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>> <4>[ 1755.556752] CR2: ffff880224d0c548 CR3: 0000000001608000 CR4: 00000000000006f0
>> <4>[ 1755.556758] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> <4>[ 1755.556763] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
>> <4>[ 1755.556770] Process swapper (pid: 0, threadinfo ffffffff815f0000, task ffffffff81610020)
>> <0>[ 1755.556774] Stack:
>> <4>[ 1755.556778]  ffffea0000b9fdc8 ffff88003df64000 ffff8800372018d8 ffffffffa00a189f
>> <4>[ 1755.556787]<0>  ffff880001803d08 0000000000000014 0000000000000002 ffff8800372018d8
>> <4>[ 1755.556797]<0>  ffff8800351ec240 0000000000000001 ffff880001803d38 ffffffffa0042dc5
>> <0>[ 1755.556809] Call Trace:
>> <0>[ 1755.556813]<IRQ>
>> <4>[ 1755.556825]  [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3 [uhci_hcd]
>> <4>[ 1755.556839]  [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65 [bluetooth]
>> <4>[ 1755.556851]  [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6 [btusb]
>> <4>[ 1755.556862]  [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>> <4>[ 1755.556873]  [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9 [uhci_hcd]
>> <4>[ 1755.556884]  [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e [uhci_hcd]
>> <4>[ 1755.556896]  [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>> <4>[ 1755.556903]  [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>> <4>[ 1755.556913]  [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>> <4>[ 1755.556922]  [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>> <4>[ 1755.556931]  [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>> <4>[ 1755.556938]  [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>> <4>[ 1755.556948]  [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>> <0>[ 1755.556952]<EOI>
>> <4>[ 1755.556966]  [<ffffffffa0022e7b>] ? acpi_idle_enter_bm+0x252/0x28a [processor]
>> <4>[ 1755.556979]  [<ffffffffa0022e74>] ? acpi_idle_enter_bm+0x24b/0x28a [processor]
>> <4>[ 1755.556988]  [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>> <4>[ 1755.556996]  [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119
>> <4>[ 1755.557004]  [<ffffffff81025db4>] cpu_idle+0x62/0xc5
>> <4>[ 1755.557014]  [<ffffffff813d1bd4>] rest_init+0x68/0x6a
>> <4>[ 1755.557024]  [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>> <4>[ 1755.557033]  [<ffffffff8168c2a6>] x86_64_start_reservations+0xad/0xb1
>> <4>[ 1755.557042]  [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>> <4>[ 1755.557050]  [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>> <0>[ 1755.557055] Code: 41 5c 41 5d 41 5e c9 c3 55 49 63 c0 48 89 e5 41 57 41 56 45 89 c6 41 55 41 89 f5 41 54 49 89 fc 53 89 cb 48 83 ec 28 48 89 55 c0<48>  8b 94 c7 00 03 00 00 48 85 d2 0f 85 61 01 00 00 41 8d 45 fe
>> <1>[ 1755.557139] RIP  [<ffffffffa0042bec>] hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.557154]  RSP<ffff880001803ca8>
>> <0>[ 1755.557158] CR2: ffff880224d0c548
>> <4>[ 1755.557164] ---[ end trace 6c64514f0ad01ea5 ]---
>> <0>[ 1755.557169] Kernel panic - not syncing: Fatal exception in interrupt
>> <4>[ 1755.557176] Pid: 0, comm: swapper Tainted: G      D     2.6.36-rc3 #3
>> <4>[ 1755.557180] Call Trace:
>> <4>[ 1755.557183]<IRQ>   [<ffffffff813e47d2>] panic+0x8c/0x189
>> <4>[ 1755.557199]  [<ffffffff813ed90c>] oops_end+0x87/0x94
>> <4>[ 1755.557206]  [<ffffffff813e4737>] no_context+0x1f4/0x203
>> <4>[ 1755.557216]  [<ffffffff8104487f>] __bad_area_nosemaphore+0x17f/0x1a2
>> <4>[ 1755.557224]  [<ffffffff810448b0>] bad_area_nosemaphore+0xe/0x10
>> <4>[ 1755.557233]  [<ffffffff813ef9fd>] do_page_fault+0x1ee/0x3c2
>> <4>[ 1755.557243]  [<ffffffff810e4748>] ? check_object+0x151/0x202
>> <4>[ 1755.557254]  [<ffffffffa00a336f>] ? uhci_alloc_td.isra.22+0x16/0x44 [uhci_hcd]
>> <4>[ 1755.557265]  [<ffffffffa00a3b17>] ? uhci_submit_common.isra.24+0x233/0x2d3 [uhci_hcd]
>> <4>[ 1755.557273]  [<ffffffff813ecde5>] page_fault+0x25/0x30
>> <4>[ 1755.557287]  [<ffffffffa0042bec>] ? hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>> <4>[ 1755.557298]  [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3 [uhci_hcd]
>> <4>[ 1755.557311]  [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65 [bluetooth]
>> <4>[ 1755.557322]  [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6 [btusb]
>> <4>[ 1755.557330]  [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>> <4>[ 1755.557340]  [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9 [uhci_hcd]
>> <4>[ 1755.557351]  [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e [uhci_hcd]
>> <4>[ 1755.557362]  [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>> <4>[ 1755.557369]  [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>> <4>[ 1755.557377]  [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>> <4>[ 1755.557386]  [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>> <4>[ 1755.557393]  [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>> <4>[ 1755.557401]  [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>> <4>[ 1755.557408]  [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>> <4>[ 1755.557413]<EOI>   [<ffffffffa0022e7b>] ? acpi_idle_enter_bm+0x252/0x28a [processor]
>> <4>[ 1755.557420]  [<ffffffffa0022e74>] ? acpi_idle_enter_bm+0x24b/0x28a [processor]
>> <4>[ 1755.557420]  [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>> <4>[ 1755.557420]  [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119>  <4>[ 1755.557420]  [<ffffffff81025db4>] cpu_idle+0x62/0xc5>  <4>[ 1755.557420]  [<ffffffff813d1bd4>] rest_init+0x68/0x6a>  <4>[ 1755.557420]  [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>> <4>[ 1755.557420]  [<ffffffff8168c2a6>] x86_64_start_reservations+0xad/0xb1
>> <4>[ 1755.557420]  [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>> <4>[ 1755.557420]  [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>
> Suraj, do you have any idea on that?
>

let me know if you guys need any info about this(vary reproducible from 
here)

Justin P. Mattock

^ permalink raw reply

* Re: [PATCH]Bluetooth:net/bluetooth/hci_core.c Fix system crash when creating a new device with bluetooth-applet
From: Justin P. Mattock @ 2010-09-01 12:30 UTC (permalink / raw)
  To: Suraj Sumangala
  Cc: Gustavo F. Padovan, linux-bluetooth@vger.kernel.org,
	marcel@holtmann.org, Suraj Sumangala,
	linux-kernel@vger.kernel.org
In-Reply-To: <4C7E156A.3050403@Atheros.com>

On 09/01/2010 01:57 AM, Suraj Sumangala wrote:
> Hi Justin,
>
> On 9/1/2010 1:30 PM, Gustavo F. Padovan wrote:
>> Hi Justin,
>>
>> * Justin P. Mattock<justinmattock@gmail.com> [2010-08-31 10:13:47 -0700]:
>>
>>> When using bluetooth-applet adding my apple magic mouse I'm getting a
>>> total system freeze.
>>> I used firescope to grab the crash data(below) The results of the
>>> bisect pointed to here:
>>> Bluetooth: Implemented HCI frame reassembly from RX stream
>>> commit:9981151086385eecc2febf4ba95a14593f834b3d
>>>
>>> after looking through, and at the crash log, I couldn't help but
>>> notice something in there
>>> with IRQ, then after looking at hci_h4.c /* H4 receiver States */ #58
>>> I noticed
>>> #define H4_W4_PACKET_TYPE 0 is at zero as well as #define
>>> STREAM_REASSEMBLY 0
>>> so changing STREAM_REASSEMBLY to a different number that isn't taken
>>> gets my machine to connect
>>> perfectly to my magic mouse. Please have a look and let me know if
>>> this is a good
>>> solution and/or send me something else to test out.
>>
>> Your patch seems very wrong, H4_W4_PACKET_TYPE and STREAM_REASSEMBLY
>> have nothing to do with each other, your commit message doesn't make
>> sense. Also the patch corrupts 'struct hci_dev'.
>> If you pay attention on the code flow you can check that
>> STREAM_REASSEMBLY is never used in the crash log you sent.
> Gustavo is correct. This should not have any effect on the code flow for
> you as you are using USB transport and STREAM_REASSEMBLY is relevant
> only for UART transport.
>
> So, I guess your problem is not 100% reproducible.

easily reproducible open bluetooth applet connect new device once I see 
the spinning animation ring say connected the whole system just locks 
up.(keep in mind this is with a apple magic mouse)

>>
>>>
>>> crash:
>>>
>>>
>>> <1>[ 1755.556472] BUG: unable to handle kernel paging request at
>>> ffff880224d0c548
>>> <1>[ 1755.556485] IP: [<ffffffffa0042bec>]
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.556507] PGD 1609063 PUD 0
>>> <0>[ 1755.556515] Oops: 0000 [#1] SMP
>>> <0>[ 1755.556522] last sysfs file:
>>> /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0A:00/power_supply/BAT0/voltage_now
>>>
>>> <4>[ 1755.556530] CPU 0
>>> <4>[ 1755.556533] Modules linked in: usb_storage xfrm4_mode_transport
>>> xcbc rmd160 sha512_generic sco bnep xt_tcpudp ipt_LOG iptable_nat
>>> nf_nat xt_state nf_conntrack_ftp nf_conntrack_ipv4 nf_conntrack
>>> nf_defrag_ipv4 iptable_filter ip_tables x_tables ath9k firewire_ohci
>>> ath9k_common firewire_core ath9k_hw battery ac ohci1394 evdev thermal
>>> ath sky2 joydev button snd_hda_codec_idt snd_hda_intel snd_hda_codec
>>> snd_hwdep snd_pcm snd_timer i2c_i801 snd soundcore snd_page_alloc
>>> video aes_x86_64 lzo lzo_compress tun kvm_intel ipcomp xfrm_ipcomp
>>> crypto_null sha256_generic cbc des_generic cast5 blowfish serpent
>>> camellia twofish_generic twofish_x86_64 twofish_common ctr ah4 esp4
>>> authenc raw1394 ieee1394 uhci_hcd ehci_hcd hci_uart rfcomm btusb hidp
>>> l2cap bluetooth coretemp acpi_cpufreq processor mperf appletouch
>>> applesmc
>>> <4>[ 1755.556676]
>>> <4>[ 1755.556682] Pid: 0, comm: swapper Not tainted 2.6.36-rc3 #3
>>> Mac-F42187C8/MacBookPro2,2
>>> <4>[ 1755.556688] RIP: 0010:[<ffffffffa0042bec>] [<ffffffffa0042bec>]
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.556705] RSP: 0018:ffff880001803ca8 EFLAGS: 00010092
>>> <4>[ 1755.556710] RAX: 000000003df64001 RBX: 0000000000000014 RCX:
>>> 0000000000000014
>>> <4>[ 1755.556716] RDX: ffff8800372018d8 RSI: 0000000000000002 RDI:
>>> ffff8800351ec240
>>> <4>[ 1755.556722] RBP: ffff880001803cf8 R08: ffff88003df64001 R09:
>>> ffff88000180f398
>>> <4>[ 1755.556728] R10: dead000000100100 R11: dead000000200200 R12:
>>> ffff8800351ec240
>>> <4>[ 1755.556733] R13: 0000000000000002 R14: 000000003df64001 R15:
>>> 0000000000000001
>>> <4>[ 1755.556740] FS: 0000000000000000(0000)
>>> GS:ffff880001800000(0000) knlGS:0000000000000000
>>> <4>[ 1755.556746] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
>>> <4>[ 1755.556752] CR2: ffff880224d0c548 CR3: 0000000001608000 CR4:
>>> 00000000000006f0
>>> <4>[ 1755.556758] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
>>> 0000000000000000
>>> <4>[ 1755.556763] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7:
>>> 0000000000000400
>>> <4>[ 1755.556770] Process swapper (pid: 0, threadinfo
>>> ffffffff815f0000, task ffffffff81610020)
>>> <0>[ 1755.556774] Stack:
>>> <4>[ 1755.556778] ffffea0000b9fdc8 ffff88003df64000 ffff8800372018d8
>>> ffffffffa00a189f
>>> <4>[ 1755.556787]<0> ffff880001803d08 0000000000000014
>>> 0000000000000002 ffff8800372018d8
>>> <4>[ 1755.556797]<0> ffff8800351ec240 0000000000000001
>>> ffff880001803d38 ffffffffa0042dc5
>>> <0>[ 1755.556809] Call Trace:
>>> <0>[ 1755.556813]<IRQ>
>>> <4>[ 1755.556825] [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3
>>> [uhci_hcd]
>>> <4>[ 1755.556839] [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65
>>> [bluetooth]
>>> <4>[ 1755.556851] [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6
>>> [btusb]
>>> <4>[ 1755.556862] [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>>> <4>[ 1755.556873] [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9
>>> [uhci_hcd]
>>> <4>[ 1755.556884] [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e
>>> [uhci_hcd]
>>> <4>[ 1755.556896] [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>>> <4>[ 1755.556903] [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>>> <4>[ 1755.556913] [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>>> <4>[ 1755.556922] [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>>> <4>[ 1755.556931] [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>>> <4>[ 1755.556938] [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>>> <4>[ 1755.556948] [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>>> <0>[ 1755.556952]<EOI>
>>> <4>[ 1755.556966] [<ffffffffa0022e7b>] ?
>>> acpi_idle_enter_bm+0x252/0x28a [processor]
>>> <4>[ 1755.556979] [<ffffffffa0022e74>] ?
>>> acpi_idle_enter_bm+0x24b/0x28a [processor]
>>> <4>[ 1755.556988] [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>>> <4>[ 1755.556996] [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119
>>> <4>[ 1755.557004] [<ffffffff81025db4>] cpu_idle+0x62/0xc5
>>> <4>[ 1755.557014] [<ffffffff813d1bd4>] rest_init+0x68/0x6a
>>> <4>[ 1755.557024] [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>>> <4>[ 1755.557033] [<ffffffff8168c2a6>]
>>> x86_64_start_reservations+0xad/0xb1
>>> <4>[ 1755.557042] [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>>> <4>[ 1755.557050] [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>>> <0>[ 1755.557055] Code: 41 5c 41 5d 41 5e c9 c3 55 49 63 c0 48 89 e5
>>> 41 57 41 56 45 89 c6 41 55 41 89 f5 41 54 49 89 fc 53 89 cb 48 83 ec
>>> 28 48 89 55 c0<48> 8b 94 c7 00 03 00 00 48 85 d2 0f 85 61 01 00 00 41
>>> 8d 45 fe
>>> <1>[ 1755.557139] RIP [<ffffffffa0042bec>]
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.557154] RSP<ffff880001803ca8>
>>> <0>[ 1755.557158] CR2: ffff880224d0c548
>>> <4>[ 1755.557164] ---[ end trace 6c64514f0ad01ea5 ]---
>>> <0>[ 1755.557169] Kernel panic - not syncing: Fatal exception in
>>> interrupt
>>> <4>[ 1755.557176] Pid: 0, comm: swapper Tainted: G D 2.6.36-rc3 #3
>>> <4>[ 1755.557180] Call Trace:
>>> <4>[ 1755.557183]<IRQ> [<ffffffff813e47d2>] panic+0x8c/0x189
>>> <4>[ 1755.557199] [<ffffffff813ed90c>] oops_end+0x87/0x94
>>> <4>[ 1755.557206] [<ffffffff813e4737>] no_context+0x1f4/0x203
>>> <4>[ 1755.557216] [<ffffffff8104487f>]
>>> __bad_area_nosemaphore+0x17f/0x1a2
>>> <4>[ 1755.557224] [<ffffffff810448b0>] bad_area_nosemaphore+0xe/0x10
>>> <4>[ 1755.557233] [<ffffffff813ef9fd>] do_page_fault+0x1ee/0x3c2
>>> <4>[ 1755.557243] [<ffffffff810e4748>] ? check_object+0x151/0x202
>>> <4>[ 1755.557254] [<ffffffffa00a336f>] ?
>>> uhci_alloc_td.isra.22+0x16/0x44 [uhci_hcd]
>>> <4>[ 1755.557265] [<ffffffffa00a3b17>] ?
>>> uhci_submit_common.isra.24+0x233/0x2d3 [uhci_hcd]
>>> <4>[ 1755.557273] [<ffffffff813ecde5>] page_fault+0x25/0x30
>>> <4>[ 1755.557287] [<ffffffffa0042bec>] ?
>>> hci_reassembly.part.13.constprop.18+0x23/0x1b5 [bluetooth]
>>> <4>[ 1755.557298] [<ffffffffa00a189f>] ? uhci_free_urb_priv+0xa6/0xb3
>>> [uhci_hcd]
>>> <4>[ 1755.557311] [<ffffffffa0042dc5>] hci_recv_fragment+0x47/0x65
>>> [bluetooth]
>>> <4>[ 1755.557322] [<ffffffffa00705ee>] btusb_bulk_complete+0x56/0xd6
>>> [btusb]
>>> <4>[ 1755.557330] [<ffffffff812c1df9>] usb_hcd_giveback_urb+0x5d/0x8d
>>> <4>[ 1755.557340] [<ffffffffa00a217b>] uhci_giveback_urb+0x11a/0x1a9
>>> [uhci_hcd]
>>> <4>[ 1755.557351] [<ffffffffa00a2a1a>] uhci_scan_schedule+0x544/0x84e
>>> [uhci_hcd]
>>> <4>[ 1755.557362] [<ffffffffa00a3343>] uhci_irq+0xee/0x104 [uhci_hcd]
>>> <4>[ 1755.557369] [<ffffffff812c1a08>] usb_hcd_irq+0x43/0x79
>>> <4>[ 1755.557377] [<ffffffff81098c0b>] handle_IRQ_event+0x6e/0x14b
>>> <4>[ 1755.557386] [<ffffffff8109aa52>] handle_fasteoi_irq+0x92/0xd2
>>> <4>[ 1755.557393] [<ffffffff81029ab6>] handle_irq+0x86/0x8c
>>> <4>[ 1755.557401] [<ffffffff8102975c>] do_IRQ+0x57/0xbe
>>> <4>[ 1755.557408] [<ffffffff813ecb93>] ret_from_intr+0x0/0x11
>>> <4>[ 1755.557413]<EOI> [<ffffffffa0022e7b>] ?
>>> acpi_idle_enter_bm+0x252/0x28a [processor]
>>> <4>[ 1755.557420] [<ffffffffa0022e74>] ?
>>> acpi_idle_enter_bm+0x24b/0x28a [processor]
>>> <4>[ 1755.557420] [<ffffffff8130a5d5>] ? menu_select+0x16f/0x296
>>> <4>[ 1755.557420] [<ffffffff81309501>] cpuidle_idle_call+0x9f/0x119>
>>> <4>[ 1755.557420] [<ffffffff81025db4>] cpu_idle+0x62/0xc5> <4>[
>>> 1755.557420] [<ffffffff813d1bd4>] rest_init+0x68/0x6a> <4>[
>>> 1755.557420] [<ffffffff8168cb7b>] start_kernel+0x365/0x370
>>> <4>[ 1755.557420] [<ffffffff8168c2a6>]
>>> x86_64_start_reservations+0xad/0xb1
>>> <4>[ 1755.557420] [<ffffffff8168c140>] ? early_idt_handler+0x0/0x71
>>> <4>[ 1755.557420] [<ffffffff8168c3a3>] x86_64_start_kernel+0xf9/0x108
>>
>> Suraj, do you have any idea on that?
>>
>
> can you verify the return status of hci_reassembly()? I guess there
> could be some mismatch in the packet received.
>
> Regards
> Suraj
>
>

Ill have to look into to that and see.

Justin P. Mattock

^ permalink raw reply

* Re: [PATCH] Add handling for more than one address in vCard
From: Johan Hedberg @ 2010-09-01 13:44 UTC (permalink / raw)
  To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTinHqG2Vbfr5qyEX0v8dAxATWy3nO_r25TkY8io3@mail.gmail.com>

Hi Rafal,

On Wed, Sep 01, 2010, Rafał Michalski wrote:
> From: Rafal Michalski <michalski.raf@gmail.com>
> Date: Wed, 1 Sep 2010 13:07:12 +0200
> Subject: [PATCH] Add handling for more than one address in vCard
> 
> After pulling contacts only fields (pobox, extended, street, locality,
> region, postal, country) of one address were present in downloaded vCard
> structure (under ADR tag) in spite of that there can be more adresses
> stored on phonebook. To solve this problem extending number of columns and
> queries of database was needed especially. Distinguish between two types
> of address (HOME and WORK) is supported.
> ---
>  plugins/phonebook-tracker.c |   93 ++++++++++++++++++++++++++++++++++++------
>  plugins/vcard.c             |   89 ++++++++++++++++++++++++++++++++++-------
>  plugins/vcard.h             |   15 ++++++-
>  3 files changed, 167 insertions(+), 30 deletions(-)

Thanks. This patch is now upstream.

Johan

^ permalink raw reply

* AVRCP future
From: Sander van Grieken @ 2010-09-01 14:03 UTC (permalink / raw)
  To: linux-bluetooth

Hi All,

I've been looking into AVRCP a bit lately, since I'm interested in the 'Remote Control 
from Separate Controller' usecase as described in the AVRCP spec, section 2.3.1.1.

However, from the BlueZ source, it seems an AVRCP connection is only set up/allowed when 
there is a AVD sink present, which is in violation of the bluetooth spec, section 2.3.2

Also, the recent progress made by João Paulo Rechi Vita bind the control and audio stream 
closely together (basically disabling the control once audio is not pulseaudio-routed to 
the bluetooth peer).

Now, my questions:

- Is anyone working on AVRCP, besides jprvita?
- Aside from the proposed D-Bus API in doc/control-api.txt, has anyone done some research 
how an AVRCP1.4 interface should look?
- Are there objections to conforming to section 2.3.2, i.e. untying the AVRCP connection 
from the A2DP connection?

I'm willing to put some effort in improving AVRCP, but before I go off blindly coding such 
stuff, please give as much feedback as possible :)

grtz,
Sander

^ permalink raw reply

* Re: [PATCH] Get IEEE1284 for a single printer
From: Bastien Nocera @ 2010-09-01 14:35 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20100608092621.GA8254@jh-x301>

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

On Tue, 2010-06-08 at 17:26 +0800, Johan Hedberg wrote:
> Hi Bastien,
> 
> On Tue, Jun 08, 2010, Bastien Nocera wrote:
> > > I have nothing against pushing the patch upstream as long as its coding
> > > style issues are fixed:
> > <snip>
> > > Mixed tabs and spaces.
> > 
> > You do realise that all those are cut'n'paste from another function in
> > the same source file?
> 
> Nope, didn't realize that. So the whole file needs coding style cleanups
> then.

I've only fixed the style problems in the patch itself. I'm happy to do
the rest of the file, if you have a "indent" magic incantation for it.

> > > > +			fprintf(stderr, "Invalid Bluetooth address '%s'\n", argv[2]);
> > > 
> > > Too long line.
> > 
> > Right, I'll fix that.

Done.

Updated patch attached.

[-- Attachment #2: 0001-cups-Add-ability-to-print-IEEE1284-device-ID.patch --]
[-- Type: text/x-patch, Size: 3158 bytes --]

>From 35c984cfbe0a17bb3dd7231450f72854b3ffb7d0 Mon Sep 17 00:00:00 2001
From: Bastien Nocera <hadess@hadess.net>
Date: Sun, 6 Jun 2010 15:48:26 +0100
Subject: [PATCH] (cups) Add ability to print IEEE1284 device ID

Add ability to print IEEE1284 device ID for Bluetooth
printers to allow auto-configuration once paired.
---
 cups/main.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/cups/main.c b/cups/main.c
index 9659a11..b420643 100644
--- a/cups/main.c
+++ b/cups/main.c
@@ -605,6 +605,79 @@ static gboolean list_printers(void)
 	return TRUE;
 }
 
+static gboolean print_ieee1284(const char *bdaddr)
+{
+	DBusMessage *message, *reply, *adapter_reply;
+	DBusMessageIter iter;
+	char *object_path = NULL;
+	char *adapter;
+	char *id;
+
+	adapter_reply = NULL;
+
+	conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+	if (conn == NULL)
+		return FALSE;
+
+	message = dbus_message_new_method_call("org.bluez", "/",
+			"org.bluez.Manager",
+			"DefaultAdapter");
+
+	adapter_reply = dbus_connection_send_with_reply_and_block(conn,
+			message, -1, NULL);
+
+	dbus_message_unref(message);
+
+	if (dbus_message_get_args(adapter_reply, NULL,
+			DBUS_TYPE_OBJECT_PATH, &adapter,
+			DBUS_TYPE_INVALID) == FALSE)
+		return FALSE;
+
+	message = dbus_message_new_method_call("org.bluez", adapter,
+			"org.bluez.Adapter",
+			"FindDevice");
+	dbus_message_iter_init_append(message, &iter);
+	dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &bdaddr);
+
+	if (adapter_reply != NULL)
+		dbus_message_unref(adapter_reply);
+
+	reply = dbus_connection_send_with_reply_and_block(conn,
+			message, -1, NULL);
+
+	dbus_message_unref(message);
+
+	if (!reply) {
+		message = dbus_message_new_method_call("org.bluez", adapter,
+				"org.bluez.Adapter",
+				"CreateDevice");
+		dbus_message_iter_init_append(message, &iter);
+		dbus_message_iter_append_basic(&iter,
+				DBUS_TYPE_STRING, &bdaddr);
+
+		reply = dbus_connection_send_with_reply_and_block(conn,
+				message, -1, NULL);
+
+		dbus_message_unref(message);
+
+		if (!reply)
+			return FALSE;
+	}
+	if (dbus_message_get_args(reply, NULL,
+			DBUS_TYPE_OBJECT_PATH, &object_path,
+			DBUS_TYPE_INVALID) == FALSE) {
+		return FALSE;
+	}
+
+	id = device_get_ieee1284_id(adapter, object_path);
+	if (id == NULL)
+		return FALSE;
+	printf("%s", id);
+	g_free(id);
+
+	return TRUE;
+}
+
 /*
  *  Usage: printer-uri job-id user title copies options [file]
  *
@@ -642,10 +715,20 @@ int main(int argc, char *argv[])
 			return CUPS_BACKEND_OK;
 		else
 			return CUPS_BACKEND_FAILED;
+	} else if (argc == 3 && strcmp(argv[1], "--get-deviceid") == 0) {
+		if (bachk(argv[2]) < 0) {
+			fprintf(stderr, "Invalid Bluetooth address '%s'\n",
+					argv[2]);
+			return CUPS_BACKEND_FAILED;
+		}
+		if (print_ieee1284(argv[2]) == FALSE)
+			return CUPS_BACKEND_FAILED;
+		return CUPS_BACKEND_OK;
 	}
 
 	if (argc < 6 || argc > 7) {
 		fprintf(stderr, "Usage: bluetooth job-id user title copies options [file]\n");
+		fprintf(stderr, "       bluetooth --get-deviceid [bdaddr]\n");
 		return CUPS_BACKEND_FAILED;
 	}
 
-- 
1.7.0.1


^ permalink raw reply related

* Re: [PATCH 1/2] hid/hid-sony: Apply sixaxis quirks only to sixaxis
From: Bastien Nocera @ 2010-09-01 16:13 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: linux-input, linux-bluetooth, cbe-oss-dev
In-Reply-To: <1272917756-31098-2-git-send-email-ospite@studenti.unina.it>

On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> Be more explicit and avoid calling sony_set_operational_usb() when we
> have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.
> 
> While at it, rename the sony_set_operational routines to
> sixaxis_set_operational as they are sixaxis specific.
> 
> This is also in preparation for the sysfs interface to set and get bdaddr
> over usb and for some other Sixaxis report fixup.
> 
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>

Signed-off-by: Bastien Nocera <hadess@hadess.net>

> ---
>  drivers/hid/hid-sony.c |   28 ++++++++++++++--------------
>  1 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index 402d557..d61f268 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -24,7 +24,9 @@
>  
>  #include "hid-ids.h"
>  
> -#define VAIO_RDESC_CONSTANT 0x0001
> +#define VAIO_RDESC_CONSTANT     (1 << 0)
> +#define SIXAXIS_CONTROLLER_USB  (1 << 1)
> +#define SIXAXIS_CONTROLLER_BT   (1 << 2)
>  
>  struct sony_sc {
>  	unsigned long quirks;
> @@ -49,7 +51,7 @@ static void sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
>   * to "operational".  Without this, the ps3 controller will not report any
>   * events.
>   */
> -static int sony_set_operational_usb(struct hid_device *hdev)
> +static int sixaxis_set_operational_usb(struct hid_device *hdev)
>  {
>  	struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
>  	struct usb_device *dev = interface_to_usbdev(intf);
> @@ -74,7 +76,7 @@ static int sony_set_operational_usb(struct hid_device *hdev)
>  	return ret;
>  }
>  
> -static int sony_set_operational_bt(struct hid_device *hdev)
> +static int sixaxis_set_operational_bt(struct hid_device *hdev)
>  {
>  	unsigned char buf[] = { 0xf4,  0x42, 0x03, 0x00, 0x00 };
>  	return hdev->hid_output_raw_report(hdev, buf, sizeof(buf), HID_FEATURE_REPORT);
> @@ -108,16 +110,12 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  		goto err_free;
>  	}
>  
> -	switch (hdev->bus) {
> -	case BUS_USB:
> -		ret = sony_set_operational_usb(hdev);
> -		break;
> -	case BUS_BLUETOOTH:
> -		ret = sony_set_operational_bt(hdev);
> -		break;
> -	default:
> +	if (sc->quirks & SIXAXIS_CONTROLLER_USB)
> +		ret = sixaxis_set_operational_usb(hdev);
> +	else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
> +		ret = sixaxis_set_operational_bt(hdev);
> +	else
>  		ret = 0;
> -	}
>  
>  	if (ret < 0)
>  		goto err_stop;
> @@ -137,8 +135,10 @@ static void sony_remove(struct hid_device *hdev)
>  }
>  
>  static const struct hid_device_id sony_devices[] = {
> -	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
> -	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER) },
> +	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
> +		.driver_data = SIXAXIS_CONTROLLER_USB },
> +	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
> +		.driver_data = SIXAXIS_CONTROLLER_BT },
>  	{ HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE),
>  		.driver_data = VAIO_RDESC_CONSTANT },
>  	{ }



^ permalink raw reply

* Re: [PATCH 2/2] hid/hid-sony: get and set Sixaxis bdaddr via sysfs
From: Bastien Nocera @ 2010-09-01 16:17 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: linux-input, linux-bluetooth, cbe-oss-dev
In-Reply-To: <1272917756-31098-3-git-send-email-ospite@studenti.unina.it>

On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> Expose to userspace a simple way to get device bdaddr, and get/set master
> bdaddr on Sixaxis controller.
> 
> Right now userspace softwares which manage pairing the controller with a
> bluetooth adapter, rely on libusb and hence have to detach and reattach
> usbhid, which is not very nice.
> 
> Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> ---
> 
> As said, ideally this should be done with an interface such as hidraw, but its
> limitations prevent us from doing it the right way; and I am not going to
> touch hidraw myself anytime soon.

Rest looks alright to me. Thanks!

>  drivers/hid/hid-sony.c |  148 +++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 145 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c
> index d61f268..1b611ec 100644
> --- a/drivers/hid/hid-sony.c
> +++ b/drivers/hid/hid-sony.c
> @@ -47,6 +47,131 @@ static void sony_report_fixup(struct hid_device *hdev, __u8 *rdesc,
>  }
>  
>  /*
> + * Show and set the master bdaddr for PS3 controller, without disconnecting
> + * the device.
> + */
> +static ssize_t show_sixaxis_master_bdaddr(struct device *dev,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct usb_interface *intf = to_usb_interface(dev);
> +	struct usb_device *udev = interface_to_usbdev(intf);
> +	__u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> +	int ret;
> +	unsigned char *mbuf = kmalloc(9, GFP_KERNEL);
> +
> +	if (!mbuf)
> +		return -ENOMEM;
> +
> +	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> +				 HID_REQ_GET_REPORT,
> +				 USB_DIR_IN | USB_TYPE_CLASS |
> +				 USB_RECIP_INTERFACE,
> +				 (3 << 8) | 0xf5, ifnum, mbuf, 8,
> +				 USB_CTRL_GET_TIMEOUT);
> +	if (ret < 0)
> +		dev_err(dev, "%s failed to get master bdaddr, ret: %d\n",
> +				__func__, ret);
> +	else
> +		/* 18 is strlen("00:00:00:00:00:00\n") */

Could you please check for the actual returned length of mbuf here?

> +		ret = snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x\n",
> +				mbuf[2], mbuf[3], mbuf[4],
> +				mbuf[5], mbuf[6], mbuf[7]);
> +
> +	kfree(mbuf);
> +
> +	return ret;
> +}
> +
> +static ssize_t store_sixaxis_master_bdaddr(struct device *dev,
> +		struct device_attribute *attr, const char *buf, size_t count)
> +{
> +	struct usb_interface *intf = to_usb_interface(dev);
> +	struct usb_device *udev = interface_to_usbdev(intf);
> +	__u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> +	int ret;
> +	unsigned char *mbuf = kmalloc(9, GFP_KERNEL);

Check for count != 6 and bail?
And also check for mbuf != NULL.

> +	mbuf[0] = 0x01;
> +	mbuf[1] = 0x00;
> +	ret = sscanf(buf, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
> +			&mbuf[2], &mbuf[3], &mbuf[4],
> +			&mbuf[5], &mbuf[6], &mbuf[7]);
> +	if (ret != 6) {
> +		dev_err(dev, "%s failed, ret: %d\n", __func__, ret);
> +		return -EINVAL;
> +	}
> +
> +	ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
> +				 HID_REQ_SET_REPORT,
> +				 USB_DIR_OUT | USB_TYPE_CLASS |
> +				 USB_RECIP_INTERFACE,
> +				 (3 << 8) | 0xf5, ifnum, mbuf, 8,
> +				 USB_CTRL_GET_TIMEOUT);
> +
> +	kfree(mbuf);
> +
> +	if (ret < 0) {
> +		dev_err(dev, "%s failed to set master bdaddr, ret: %d\n",
> +				__func__, ret);
> +		return ret;
> +	}
> +
> +	return count;
> +}
> +
> +/*
> + * Show the bdaddr for PS3 controller, without disconnecting the device.
> + */
> +static ssize_t show_sixaxis_bdaddr(struct device *dev,
> +		struct device_attribute *attr, char *buf)
> +{
> +	struct usb_interface *intf = to_usb_interface(dev);
> +	struct usb_device *udev = interface_to_usbdev(intf);
> +	__u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
> +	int ret;
> +	unsigned char *mbuf = kmalloc(18, GFP_KERNEL);
> +
> +	if (!mbuf)
> +		return -ENOMEM;
> +
> +	ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
> +				 HID_REQ_GET_REPORT,
> +				 USB_DIR_IN | USB_TYPE_CLASS |
> +				 USB_RECIP_INTERFACE,
> +				 (3 << 8) | 0xf2, ifnum, mbuf, 17,
> +				 USB_CTRL_GET_TIMEOUT);
> +	if (ret < 0)
> +		dev_err(dev, "%s failed to get device bdaddr, ret: %d\n",
> +				__func__, ret);
> +	else
> +		/* 18 is strlen("00:00:00:00:00:00\n") */

length of mbuf != 9?

> +		ret = snprintf(buf, 18, "%02x:%02x:%02x:%02x:%02x:%02x\n",
> +				mbuf[4], mbuf[5], mbuf[6],
> +				mbuf[7], mbuf[8], mbuf[9]);
> +
> +	kfree(mbuf);
> +
> +	return ret;
> +}
> +
> +static DEVICE_ATTR(sixaxis_master_bdaddr, S_IWUSR|S_IRUGO,
> +		show_sixaxis_master_bdaddr, store_sixaxis_master_bdaddr);
> +
> +static DEVICE_ATTR(sixaxis_bdaddr, S_IRUGO,
> +		show_sixaxis_bdaddr, NULL);
> +
> +static struct attribute *sixaxis_attributes[] = {
> +	&dev_attr_sixaxis_master_bdaddr.attr,
> +	&dev_attr_sixaxis_bdaddr.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group sixaxis_attr_group = {
> +	.attrs = sixaxis_attributes,
> +};
> +
> +
> +/*
>   * Sending HID_REQ_GET_REPORT changes the operation mode of the ps3 controller
>   * to "operational".  Without this, the ps3 controller will not report any
>   * events.
> @@ -57,8 +182,9 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
>  	struct usb_device *dev = interface_to_usbdev(intf);
>  	__u16 ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
>  	int ret;
> -	char *buf = kmalloc(18, GFP_KERNEL);
> +	unsigned char *buf = kmalloc(18, GFP_KERNEL);

buf != NULL.

> +	dev_info(&hdev->dev, "Calling %s\n", __func__);
>  	if (!buf)
>  		return -ENOMEM;
>  
> @@ -70,6 +196,9 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
>  				 USB_CTRL_GET_TIMEOUT);
>  	if (ret < 0)
>  		dev_err(&hdev->dev, "can't set operational mode\n");
> +	else
> +		dev_info(&hdev->dev, "Sony PS3 Controller bdaddr: %02x:%02x:%02x:%02x:%02x:%02x\n",
> +				buf[4], buf[5], buf[6], buf[7], buf[8], buf[9]);
>  
>  	kfree(buf);
>  
> @@ -110,9 +239,17 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
>  		goto err_free;
>  	}
>  
> -	if (sc->quirks & SIXAXIS_CONTROLLER_USB)
> +	if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
> +		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> +		ret = sysfs_create_group(&intf->dev.kobj, &sixaxis_attr_group);
> +		if (ret < 0) {
> +			dev_err(&hdev->dev,
> +				"cannot register sixaxis sysfs hooks\n");
> +			goto err_stop;
> +		}
> +
>  		ret = sixaxis_set_operational_usb(hdev);
> -	else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
> +	} else if (sc->quirks & SIXAXIS_CONTROLLER_BT)
>  		ret = sixaxis_set_operational_bt(hdev);
>  	else
>  		ret = 0;
> @@ -130,6 +267,11 @@ err_free:
>  
>  static void sony_remove(struct hid_device *hdev)
>  {
> +	struct sony_sc *sc = hid_get_drvdata(hdev);
> +	if (sc->quirks & SIXAXIS_CONTROLLER_USB) {
> +		struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> +		sysfs_remove_group(&intf->dev.kobj, &sixaxis_attr_group);
> +	}
>  	hid_hw_stop(hdev);
>  	kfree(hid_get_drvdata(hdev));
>  }



^ permalink raw reply

* Re: [PATCH 1/2] hid/hid-sony: Apply sixaxis quirks only to sixaxis
From: Antonio Ospite @ 2010-09-01 17:20 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-input, linux-bluetooth, cbe-oss-dev, Jiri Kosina
In-Reply-To: <1283357615.2361.20.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]

On Wed, 01 Sep 2010 17:13:35 +0100
Bastien Nocera <hadess@hadess.net> wrote:

> On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> > Be more explicit and avoid calling sony_set_operational_usb() when we
> > have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.
> > 
> > While at it, rename the sony_set_operational routines to
> > sixaxis_set_operational as they are sixaxis specific.
> > 
> > This is also in preparation for the sysfs interface to set and get bdaddr
> > over usb and for some other Sixaxis report fixup.
> > 
> > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> 
> Signed-off-by: Bastien Nocera <hadess@hadess.net>
>

Thanks Bastien for bringing this up again, I was going to repost
this patch sometime this month.

Added Jiri to CC as I forgot to do that back then.

Regards,
   Antonio

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply

* Re: [PATCH 2/2] hid/hid-sony: get and set Sixaxis bdaddr via sysfs
From: Antonio Ospite @ 2010-09-01 17:28 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-input, linux-bluetooth, cbe-oss-dev, Jiri Kosina
In-Reply-To: <1283357874.2361.24.camel@localhost.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]

On Wed, 01 Sep 2010 17:17:54 +0100
Bastien Nocera <hadess@hadess.net> wrote:

> On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> > Expose to userspace a simple way to get device bdaddr, and get/set master
> > bdaddr on Sixaxis controller.
> > 
> > Right now userspace softwares which manage pairing the controller with a
> > bluetooth adapter, rely on libusb and hence have to detach and reattach
> > usbhid, which is not very nice.
> > 
> > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> > ---
> > 
> > As said, ideally this should be done with an interface such as hidraw, but its
> > limitations prevent us from doing it the right way; and I am not going to
> > touch hidraw myself anytime soon.
> 
> Rest looks alright to me. Thanks!

Bastien, Jiri, this patch can be DISCARDED. The hidraw work from Alan
Ott (waiting for Marcel to ACK the bluetooth part) will make this kernel
approach overkill.

I already have some bluez patches based on Alan's work, but I am waiting
for the needed changes to land into linus tree before submitting them.

Sorry for making you wasting some time reviewing this one, I told you on
IRC it could be discarded, but we know: "IRCs volant, emails manent".

Regards,
   Antonio

-- 
Antonio Ospite
http://ao2.it

PGP public key ID: 0x4553B001

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply

* Re: [PATCH 2/2] hid/hid-sony: get and set Sixaxis bdaddr via sysfs
From: Bastien Nocera @ 2010-09-01 17:41 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: linux-input, linux-bluetooth, cbe-oss-dev, Jiri Kosina
In-Reply-To: <20100901192854.9370c605.ospite@studenti.unina.it>

On Wed, 2010-09-01 at 19:28 +0200, Antonio Ospite wrote:
> On Wed, 01 Sep 2010 17:17:54 +0100
> Bastien Nocera <hadess@hadess.net> wrote:
> 
> > On Mon, 2010-05-03 at 22:15 +0200, Antonio Ospite wrote:
> > > Expose to userspace a simple way to get device bdaddr, and get/set master
> > > bdaddr on Sixaxis controller.
> > > 
> > > Right now userspace softwares which manage pairing the controller with a
> > > bluetooth adapter, rely on libusb and hence have to detach and reattach
> > > usbhid, which is not very nice.
> > > 
> > > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> > > ---
> > > 
> > > As said, ideally this should be done with an interface such as hidraw, but its
> > > limitations prevent us from doing it the right way; and I am not going to
> > > touch hidraw myself anytime soon.
> > 
> > Rest looks alright to me. Thanks!
> 
> Bastien, Jiri, this patch can be DISCARDED. The hidraw work from Alan
> Ott (waiting for Marcel to ACK the bluetooth part) will make this kernel
> approach overkill.
> 
> I already have some bluez patches based on Alan's work, but I am waiting
> for the needed changes to land into linus tree before submitting them.
> 
> Sorry for making you wasting some time reviewing this one, I told you on
> IRC it could be discarded, but we know: "IRCs volant, emails manent".

Given the time it took me to review it, it's my own damn fault anyway ;)


^ permalink raw reply

* Re: [PATCH] Get IEEE1284 for a single printer
From: Johan Hedberg @ 2010-09-01 18:49 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth
In-Reply-To: <1283351741.2361.19.camel@localhost.localdomain>

Hi Bastien,

On Wed, Sep 01, 2010, Bastien Nocera wrote:
> From: Bastien Nocera <hadess@hadess.net>
> Date: Sun, 6 Jun 2010 15:48:26 +0100
> Subject: [PATCH] (cups) Add ability to print IEEE1284 device ID
> 
> Add ability to print IEEE1284 device ID for Bluetooth
> printers to allow auto-configuration once paired.
> ---
>  cups/main.c |   83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 83 insertions(+), 0 deletions(-)

Thanks for the updated patch. It's now pushed upstream.

> I've only fixed the style problems in the patch itself. I'm happy to do
> the rest of the file, if you have a "indent" magic incantation for it.

In my experience indent can produce quite a mess compared to fixing
style issues manually. Anyway, I went ahead and did the cleanup myself
for the issues that I could quickly spot and pushed the fixes as a
separate patch upstream.

Johan

^ permalink raw reply

* Re: AVRCP future
From: Johan Hedberg @ 2010-09-01 18:57 UTC (permalink / raw)
  To: Sander van Grieken; +Cc: linux-bluetooth
In-Reply-To: <201009011603.02153.sander@outrightsolutions.nl>

Hi Sander,

On Wed, Sep 01, 2010, Sander van Grieken wrote:
> - Is anyone working on AVRCP, besides jprvita?

Maybe, but nothing I'm aware of.

> - Aside from the proposed D-Bus API in doc/control-api.txt, has anyone
> done some research how an AVRCP1.4 interface should look?

Mostly just ideas that haven't really been written down. It'd be easier
if we talked about specific features though than about a profile version
since different features will require different design solutions and
API's. E.g. in the MeeGo case we'd probably be talking to tracker in
order to implement media browsing, however other platforms might have a
different storage backend which means that we'll need some sort of
backend driver abstraction (we have a similar situation already in obexd
PBAP and contact storage).

> - Are there objections to conforming to section 2.3.2, i.e. untying
> the AVRCP connection from the A2DP connection?

If by that you mean adding Connect() and Disconnect() method calls to
the org.bluez.Control D-Bus interface, then I'd be happy to accept
patches for it. However, the automated connecting of AVRCP as triggered
by an A2DP connection should stay in order to keep good interoperability
and make things easy for the user interface code.

Johan

^ permalink raw reply

* [PATCH] Add handling of UID contact's field in vCard
From: Rafał Michalski @ 2010-09-02  7:04 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Rafał Michalski

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0001-Add-handling-of-UID-contact-s-field-in-vCard.patch --]
[-- Type: text/x-patch, Size: 2012 bytes --]

From 4c3ee0455ea066b5fd4cb07a54c0bc6e0012d848 Mon Sep 17 00:00:00 2001
From: Rafal Michalski <michalski.raf@gmail.com>
Date: Wed, 1 Sep 2010 16:08:35 +0200
Subject: [PATCH] Add handling of UID contact's field in vCard

After pulling contacts this field wasn't presented in downloaded vCard
structure in spite of that it existed (not empty). Now it shows downloaded
UID (using database query).
---
 plugins/phonebook-tracker.c |    1 +
 plugins/vcard.c             |    4 ++++
 plugins/vcard.h             |    1 +
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/plugins/phonebook-tracker.c b/plugins/phonebook-tracker.c
index 193226f..bdd9587 100644
--- a/plugins/phonebook-tracker.c
+++ b/plugins/phonebook-tracker.c
@@ -866,6 +866,7 @@ add_entry:
 	contact->company = g_strdup(reply[22]);
 	contact->department = g_strdup(reply[23]);
 	contact->title = g_strdup(reply[24]);
+	contact->uid = g_strdup(reply[CONTACTS_ID_COL]);
 
 	set_call_type(contact, reply[COL_DATE], reply[COL_SENT],
 			reply[COL_ANSWERED]);
diff --git a/plugins/vcard.c b/plugins/vcard.c
index 6d74e06..4a77eb3 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -468,6 +468,9 @@ void phonebook_add_contact(GString *vcards, struct phonebook_contact *contact,
 
 	vcard_printf_begin(vcards, format);
 
+	if (filter & FILTER_UID)
+		vcard_printf_tag(vcards, format, "UID", NULL, contact->uid);
+
 	if (filter & FILTER_N)
 		vcard_printf_name(vcards, contact);
 
@@ -580,6 +583,7 @@ void phonebook_contact_free(struct phonebook_contact *contact)
 	g_slist_foreach(contact->addresses, address_free, NULL);
 	g_slist_free(contact->addresses);
 
+	g_free(contact->uid);
 	g_free(contact->fullname);
 	g_free(contact->given);
 	g_free(contact->family);
diff --git a/plugins/vcard.h b/plugins/vcard.h
index d012106..4d134c2 100644
--- a/plugins/vcard.h
+++ b/plugins/vcard.h
@@ -62,6 +62,7 @@ struct phonebook_address {
 };
 
 struct phonebook_contact {
+	char *uid;
 	char *fullname;
 	char *given;
 	char *family;
-- 
1.6.3.3


^ permalink raw reply related

* Re: [PATCH 1/2] hid/hid-sony: Apply sixaxis quirks only to sixaxis
From: Jiri Kosina @ 2010-09-02  7:41 UTC (permalink / raw)
  To: Antonio Ospite; +Cc: Bastien Nocera, linux-input, linux-bluetooth, cbe-oss-dev
In-Reply-To: <20100901192055.2f23c8c7.ospite@studenti.unina.it>

On Wed, 1 Sep 2010, Antonio Ospite wrote:

> > > Be more explicit and avoid calling sony_set_operational_usb() when we
> > > have USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE.
> > > 
> > > While at it, rename the sony_set_operational routines to
> > > sixaxis_set_operational as they are sixaxis specific.
> > > 
> > > This is also in preparation for the sysfs interface to set and get bdaddr
> > > over usb and for some other Sixaxis report fixup.
> > > 
> > > Signed-off-by: Antonio Ospite <ospite@studenti.unina.it>
> > 
> > Signed-off-by: Bastien Nocera <hadess@hadess.net>
> >
> 
> Thanks Bastien for bringing this up again, I was going to repost
> this patch sometime this month.
> 
> Added Jiri to CC as I forgot to do that back then.

Thanks, I have missed that one on linux-input@.

Applied now.

-- 
Jiri Kosina
SUSE Labs, Novell Inc.

^ permalink raw reply

* Re: [PATCH] Add handling of UID contact's field in vCard
From: Johan Hedberg @ 2010-09-02  8:10 UTC (permalink / raw)
  To: Rafał Michalski; +Cc: linux-bluetooth
In-Reply-To: <AANLkTi=nEVCDx3L3B5d0Xet7uJU0XXpBqgCYf0AQ5fz9@mail.gmail.com>

Hi Rafal,

On Thu, Sep 02, 2010, Rafał Michalski wrote:
> From: Rafal Michalski <michalski.raf@gmail.com>
> Date: Wed, 1 Sep 2010 16:08:35 +0200
> Subject: [PATCH] Add handling of UID contact's field in vCard
> 
> After pulling contacts this field wasn't presented in downloaded vCard
> structure in spite of that it existed (not empty). Now it shows downloaded
> UID (using database query).
> ---
>  plugins/phonebook-tracker.c |    1 +
>  plugins/vcard.c             |    4 ++++
>  plugins/vcard.h             |    1 +
>  3 files changed, 6 insertions(+), 0 deletions(-)

Thanks. The patch has been pushed upstream.

Johan

^ permalink raw reply

* Re: AVRCP future
From: Sander van Grieken @ 2010-09-02  8:20 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20100901185729.GB30041@jh-x301>

Hi Johan, 

Thanks for your feedback.

On Wednesday 01 September 2010 20:57:29 Johan Hedberg wrote:
> Hi Sander,
> 
> On Wed, Sep 01, 2010, Sander van Grieken wrote:
> > - Is anyone working on AVRCP, besides jprvita?
> 
> Maybe, but nothing I'm aware of.
> 
> > - Aside from the proposed D-Bus API in doc/control-api.txt, has anyone
> > done some research how an AVRCP1.4 interface should look?
> 
> Mostly just ideas that haven't really been written down. 

Argh, there a wiki would come in handy ;) It has probably gone over the list a few times, 
but I just joined the list and the web archives are.. cumbersome, and google didn't find 
much of avrcp in the list.

> It'd be easier
> if we talked about specific features though than about a profile version
> since different features will require different design solutions and
> API's. E.g. in the MeeGo case we'd probably be talking to tracker in
> order to implement media browsing, however other platforms might have a
> different storage backend which means that we'll need some sort of
> backend driver abstraction (we have a similar situation already in obexd
> PBAP and contact storage).

I'm not in favor of having (multiple) storage plugins. Simply because a storage backend is 
not a player. This distinction is important. MeeGo/tracker is a semantic index, so in 
theory you could browse the media through it, but the player might have 'smart' playlist, 
or is only able to play media of a certain kind. Also the current playlist is a player-
only thing (and is also a browsable item). So I think browsing should go _through_ the 
player.

I was more thinking of exposing a dbus interface that allows a player (or any TG) to 
register itself as a TG, then acting on signals/sending events/responses.

> > - Are there objections to conforming to section 2.3.2, i.e. untying
> > the AVRCP connection from the A2DP connection?
> 
> If by that you mean adding Connect() and Disconnect() method calls to
> the org.bluez.Control D-Bus interface, then I'd be happy to accept
> patches for it. However, the automated connecting of AVRCP as triggered
> by an A2DP connection should stay in order to keep good interoperability
> and make things easy for the user interface code.

Agreed.

> 
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply


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