On Mi, 2011-08-24 at 14:46 +0200, Chris Kühl wrote:
> The bluetooth-device-id-merge-prep is ready to be reviewed now.
I've merged the D-Bus server reorganization, dbus-test and
bluetooth-device-id-merge-prep branches. I fixed some minor problems
found with -Werror -Wall.
Attached an updated revision of the bluetooth-device-id-inspector.py
script. Should we maintain it in SyncEvolution?
My changes:
- more information for the user
- allow the user to skip devices
- don't include vendor in example product name
- skip devices which have PNPINFO_UUID information, but are not
online at the moment (script used to abort with an exception)
- write the user provided vendor/model information into the file
even if PNPINFO_UUID information isn't supported
The last point avoids the situation where the user is asked to send you
a file which says "This phone does not support Device ID profile"
without telling you what phone it is ;-)
Do we want to gather information about that? I think we should for the
sake of completeness, although I am not sure what to do with it in that
case.
Here's an example run:
Device name: localhost.localdomain-0
MAC Address: 00:22:43:AF:07:0D
Supports SyncML.
What company makes this phone? (examples: Nokia, Sony Ericsson), empty to
skip:
Device name: K750i
MAC Address: 00:0E:07:B1:90:17
Supports SyncML.
Looking up device information...
Failed, skipping device: org.bluez.Error.ConnectionAttemptFailed: Host is
down
Device name: 6310i
MAC Address: 00:60:57:33:6C:0C
What company makes this phone? (examples: Nokia, Sony Ericsson), empty to
skip: Nokia
What is the model of this phone? (example: N900, K750i), empty to skip: 6310i
Thanks, please send the file syncevo-phone-info-[6310i].txt to blixtra [at]
gmail.com
Device name: Nokia N70
MAC Address: 00:17:4B:1D:28:B2
Supports SyncML.
What company makes this phone? (examples: Nokia, Sony Ericsson), empty to
skip: Nokia
What is the model of this phone? (example: N900, K750i), empty to skip: N70
Thanks, please send the file syncevo-phone-info-[N70].txt to blixtra [at]
gmail.com
Device name: Nokia N900
MAC Address: 80:50:1B:BE:AA:2B
Supports SyncML.
What company makes this phone? (examples: Nokia, Sony Ericsson), empty to
skip: Nokia
What is the model of this phone? (example: N900, K750i), empty to skip: N900
Thanks, please send the file syncevo-phone-info-[N900].txt to blixtra [at]
gmail.com
Device Name: Nokia N97 mini
MAC Address: A0:4E:04:1E:AD:30
Supports SyncML.
Looking up device information...
What company makes this phone? (examples: Nokia, Sony Ericsson), empty to
skip: Nokia
What is the model of this phone? (example: N900, K750i), empty to skip: N97
mini
Device name: Nokia 7100s-2
MAC Address: C8:97:9F:5D:B7:FB
Supports SyncML.
Looking up device information...
Failed, skipping device: org.bluez.Error.ConnectionAttemptFailed: Host is
down
Of the various Nokia phones, only some supported the Device ID profile
and I had only turned on the N97. All resulting files also attached.
When I tried this in combination with the GTK sync-ui, I found that my
"Nokia N97" (user chosen name) was sometimes shown as "Nokia", sometimes
as "Nokia N97" in the UI.
Chris, I suspect that I gave you wrong guidance about the use use of
deviceName/peerName, or we have to extend the semantic. According to the
D-Bus API docs:
* deviceName: device template: the device name that the template
is for (copied verbatim from that device)
* templateName: device template: string identifying the class of
devices the templates works for, like "Nokia S40"; meant to be
shown to users; optional, fall back to first entry in
fingerPrint if not set
Now the syncevo-dbus-server sends deviceName=Nokia, templateName=Nokia
and peerName=Nokia N97 mini.
I think it should send:
* deviceName: the vendor/model information if available, otherwise
the user-configurable device name (can't be empty, because
traditionally it wasn't describe as optional)
* templateName: the "templateName" from the template, as it used
to (see above)
* peerName: the user-configurable name (optional, old
syncevo-dbus-servers do not provide it)
The syncevo-dbus-server's use of deviceName needs to be adapted to meet
this revised definition.
I suspect that the UI picks the first deviceName that it encounters and
ignores the peerName. Jussi, can you confirm that?
The UI should be adapted to use peerName instead of deviceName, if
peerName is available. That way the user would see his chosen name
instead of the vendor/model name, which will not be unique in the
(unlikely) case that the user has more than one. Not a big deal.
We might have the inverse situation, too: multiple different devices all
called "My Phone". I think users should (and can) avoid this, so we
should continue to display only the chosen name instead of adding the
vendor/model information - right?
--
Best Regards, Patrick Ohly
The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.
#! /usr/bin/python -u
import dbus
import string
import sys
# Defines
SYNCML_UUID = "00000002-0000-1000-8000-0002ee000002"
PNPINFO_UUID = "00001200-0000-1000-8000-00805f9b34fb"
PNPINFO_ATTRIB = "0x1200"
SOURCE_ATTRIB = "0x0205"
VENDOR_ATTRIB = "0x0201"
PRODUCT_ATTRIB = "0x0202"
def extractValueFromServiceRecord(servRec, attribId):
pos = string.find(servRec, attribId)
if(pos < 0):
return ""
pos = string.find(servRec, "value", pos + len(attribId))
pos = string.find(servRec, '"', pos) + 1
endPos = string.find(servRec,'"', pos)
return servRec[pos:endPos]
def getVendorAndProductId(pnpInfoServRec):
'''Get the vendor and product ids from xml formatted service record.'''
servRec = pnpInfoServRec.values()[0]
sourceVal = extractValueFromServiceRecord(servRec, SOURCE_ATTRIB)
vendorVal = extractValueFromServiceRecord(servRec, VENDOR_ATTRIB)
productVal = extractValueFromServiceRecord(servRec, PRODUCT_ATTRIB)
return (sourceVal, vendorVal, productVal)
def writeDeviceInfoToFile(ids, vendor, product, hasSyncML):
filename = "syncevo-phone-info-[%s].txt" % product
FILE = open(filename,"w")
FILE.write("Thanks, for helping us improve phone syncing on Linux.\n")
FILE.write("Please send this file or its contents to blixtra [at] gmail.com\n\n" )
FILE.write("SyncML support: %s\n" % hasSyncML)
if(len(ids) > 0):
FILE.write("Source: %s\n" % (ids[0]))
FILE.write("Vendor: %s=%s\n" % (ids[1], vendor))
FILE.write("product: %s=%s\n\n" % (ids[2], product))
else:
FILE.write("Vendor: %s\n" % vendor)
FILE.write("product: %s\n\n" % product)
FILE.write("This phone doesn't support the bluetooth Device ID profile.\n" )
FILE.close()
return filename
# Start main program
bus = dbus.SystemBus()
bluezIface = dbus.Interface(bus.get_object('org.bluez', '/'),
'org.bluez.Manager')
hasSyncmlSupport = False
hasPnpInfoSupport = False
ids = {}
adapters = bluezIface.ListAdapters()
for adapter in adapters:
adapterIface = dbus.Interface(bus.get_object('org.bluez', adapter),
'org.bluez.Adapter')
devices = adapterIface.ListDevices()
for device in devices:
try:
deviceIface = dbus.Interface(bus.get_object('org.bluez', device),
'org.bluez.Device')
props = deviceIface.GetProperties();
uuids = props["UUIDs"]
print "Device name:", props.get("Name", "???")
print "MAC Address:", props.get("Address", "???")
for uuid in uuids:
if SYNCML_UUID == uuid:
hasSyncmlSupport = True
print " Supports SyncML."
if PNPINFO_UUID == uuid:
hasPnpInfoSupport = True
print " Looking up device information..."
sys.stdout.flush()
serviceRecord = deviceIface.DiscoverServices(PNPINFO_ATTRIB)
ids = getVendorAndProductId(serviceRecord)
vendor = raw_input(" What company makes this phone? (examples: Nokia, Sony Ericsson), empty to skip: ")
if vendor:
product = raw_input(" What is the model of this phone? (example: N900, K750i), empty to skip: ")
if product:
# Write the results to a file
filename = writeDeviceInfoToFile(ids, vendor, product, hasSyncmlSupport)
print "Thanks, please send the file %s to blixtra [at] gmail.com" % filename
except dbus.exceptions.DBusException, ex:
print " Failed, skipping device: %s" % ex
Thanks, for helping us improve phone syncing on Linux.
Please send this file or its contents to blixtra [at] gmail.com
SyncML support: True
Vendor: Nokia
product: 6310i
This phone doesn't support the bluetooth Device ID profile.
Thanks, for helping us improve phone syncing on Linux.
Please send this file or its contents to blixtra [at] gmail.com
SyncML support: True
Vendor: Nokia
product: N70
This phone doesn't support the bluetooth Device ID profile.
Thanks, for helping us improve phone syncing on Linux.
Please send this file or its contents to blixtra [at] gmail.com
SyncML support: True
Source: 0x0001
Vendor: 0x0001=Nokia
product: 0x00ad=N97 mini
Thanks, for helping us improve phone syncing on Linux.
Please send this file or its contents to blixtra [at] gmail.com
SyncML support: True
Vendor: Nokia
product: N900
This phone doesn't support the bluetooth Device ID profile.
_______________________________________________
SyncEvolution mailing list
[email protected]
http://lists.syncevolution.org/listinfo/syncevolution