lib: set default rectype for Bookmarks to 1
[barry.git] / hal / hal-blackberry
blob4848148e27f1d565e7526f7efa586d8e7c6a97b5
1 #!/usr/bin/python
3 import sys, os
4 import dbus, dbus.glib
5 import commands
7 class HalBlackberry:
8 def __init__(self):
9 self._dbus = dbus.SystemBus()
10 self._serv = self._dbus.get_object( 'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager' )
11 self._hal = dbus.Interface( self._serv, 'org.freedesktop.Hal.Manager' )
12 self._device = None
13 self.get_properties()
14 self.gatherInfo()
16 def get_properties(self):
17 self.udi = os.getenv("UDI", "")
18 self.busnum = self.get_property( 'usb.bus_number' )
19 self.devnum = self.get_property( 'usb.linux.device_number' )
21 def get_property(self, name):
22 return self.device().GetProperty(name, dbus_interface="org.freedesktop.Hal.Device")
24 def gatherInfo(self):
25 text = commands.getoutput("/usr/bin/bidentify -B %i -N %i" % (self.busnum, self.devnum))
26 sys.stderr.write("Found '%s' at %s, %s\n" % (text, self.busnum, self.devnum))
27 b = text.split(", ")
28 desc = b[1]
29 pin = b[0]
31 self.set_property("sync.serial", pin)
32 self.set_property("info.product", desc)
34 def set_property(self, name, value):
35 return self.device().SetPropertyString(name, value, dbus_interface="org.freedesktop.Hal.Device")
37 def device(self):
38 if not self._device:
39 self._device = self._dbus.get_object("org.freedesktop.Hal", self.udi)
40 return self._device
42 h = HalBlackberry()