PDA support in HAL - making synchronisation "just work"



(Crossposted to HAL and gnome-pilot mailing lists)

I've been looking at cleaning up parts of gnome-pilot, and feel that
some of it really belongs in HAL.

gnome-pilot has a daemon, gpilotd, which monitors for pilot devices, and
has a conduit system that can be invoked when a device connects.

Currently gnome-pilot's device monitoring requires the user to configure
the system, typing in names of devices, and potentially set up obscure
files on their computer (e.g. udev configuration).

If built on Linux with WITH_USB_VISOR, the gpilotd wakes up every 2
seconds and scans /proc/bus/usb/devices, looking for PDA devices based
on USB product/vendor ID pairs.

So I'm thinking that some of this really belongs in HAL instead; it
would be great if HAL could handle the low-level device detection work,
and provide desktop-level tools with a list of PDAs.  When the user
wants to synchronise their data, HAL should make some call out to an
appropriate tool, perhaps in a similar way to how gnome-volume-manager
can mount devices automagically (perhaps even using gnome-volume-
manager, for the case of the GNOME desktop).

gnome-pilot has an XML file (gnome-pilot/gpilotd/devices.xml) which
contains information on known USB PDA devices, in its own format.

Attached is an XSL file which transforms that file into a HAL .fdi file;
I've also attached a copy of the resulting file (after going through
xmllint --format).  I've been putting this file
into /usr/share/hal/fdi/50user for now.

The FDI file basically takes the list of specific USB vendor/product ID
pairs, and adds info.capability="pda" for every known pair; it also adds
a boolean "pda.use_net" based on the value in the original gnome-pilot
file.

Finally, I've attached a patch to hal-device-manager which adds an icon
for PDAs.  I'm currently using an icon from gnome-pilot as hal-pda.png -
however that module is under a GPL license; I've emailed the artist,
hoping for permission to relicense.

The obligatory screenshot of hal-device-manager using all of the above
is here:
http://people.redhat.com/dmalcolm/Screenshot-PDA-HAL.png

Thoughts?

Dave Malcolm
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

  <!-- Top level element -->
  <xsl:template match="/">
    <deviceinfo version="0.2">
      <xsl:apply-templates/>
    </deviceinfo>
  </xsl:template>

  <!-- Copy over comments from the source document -->
  <xsl:template match="comment()">
    <xsl:comment><xsl:value-of select="."></xsl:value-of></xsl:comment>
  </xsl:template>

  <xsl:template match="device">
    <device>
      <match key="info.bus" string="usb">

	<!-- Match on USB vendor ID -->
	<xsl:element name="match">
	  <xsl:attribute name="key">usb.vendor_id</xsl:attribute>
	  <xsl:attribute name="int">
	    <xsl:text>0x</xsl:text><xsl:value-of select="@vendor_id"/>
	  </xsl:attribute>

	  <!-- Match on USB product ID -->
	  <xsl:element name="match">
	    <xsl:attribute name="key">usb.product_id</xsl:attribute>
	    <xsl:attribute name="int">
	      <xsl:text>0x</xsl:text><xsl:value-of select="@product_id"/>
	    </xsl:attribute>

	    <!-- The keys to merge -->
	    <merge key="info.capability" type="string">pda</merge>

	    <!-- (need a better name for this key): -->
	    <merge key="pda.use_net" type="bool">
	      <xsl:choose>
		<xsl:when test="@use_net">
		  <xsl:value-of select="@use_net"/>
		</xsl:when>
		<xsl:otherwise>
		  <xsl:text>true</xsl:text>
		</xsl:otherwise>
	      </xsl:choose>
	    </merge>

	  </xsl:element>	    
	</xsl:element>
      </match>	
    </device>
  </xsl:template>

</xsl:stylesheet>
<?xml version="1.0"?>
<deviceinfo version="0.2">
<!-- Update this list by adding the hex values for the vendor and
 product ids under a new "device" node.  Set use_net=false *only* if
 the USB device uses the old PADP protocol over USB, this should not
 apply to any new devices and only applies to the Handspring visor as
 far as i know -->
<!-- Aceeca -->
<!-- Aceeca MEZ1000 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x4766">
        <match key="usb.product_id" int="0x0001">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Acer -->
<!-- Acer S50/S60 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0502">
        <match key="usb.product_id" int="0x0736">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Garmin -->
<!-- Garmin Ique 3600 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x091e">
        <match key="usb.product_id" int="0x0004">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Handspring -->
<!-- Handspring Visor and Treo 300 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x082d">
        <match key="usb.product_id" int="0x0100">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">false</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Handspring Treo -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x082d">
        <match key="usb.product_id" int="0x0200">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Handspring Treo 600 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x082d">
        <match key="usb.product_id" int="0x0300">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm -->
<!-- Palm M500 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0001">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm M505 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0002">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm M515 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0003">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm I705 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0020">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm Tungsten Z -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0031">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm M125 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0040">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm M130 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0050">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm Tungsten T -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0060">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm Tungsten Zire -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0070">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Palm M100 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x0830">
        <match key="usb.product_id" int="0x0080">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Samsung -->
<!-- Samsung SCH-I330 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x04e8">
        <match key="usb.product_id" int="0x8001">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Samsung SPH-I500 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x04e8">
        <match key="usb.product_id" int="0x6601">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony -->
<!-- Sony Clie 3.5 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x0038">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie 4.0 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x0066">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie S360 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x0095">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie 4.1 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x009a">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie NZ90V -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x00c9">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie NX60 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x00da">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie NZ90V -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x00e9">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie UX50 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x0144">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Sony Clie TJ25 -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x054c">
        <match key="usb.product_id" int="0x0169">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
<!-- Tapwave -->
<!-- Tapwave Zodiac -->
  <device>
    <match key="info.bus" string="usb">
      <match key="usb.vendor_id" int="0x12ef">
        <match key="usb.product_id" int="0x0100">
          <merge key="info.capability" type="string">pda</merge>
          <merge key="pda.use_net" type="bool">true</merge>
        </match>
      </match>
    </match>
  </device>
</deviceinfo>
Index: tools/device-manager/Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Makefile.am,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile.am
--- tools/device-manager/Makefile.am	1 Nov 2004 22:57:21 -0000	1.5
+++ tools/device-manager/Makefile.am	8 Nov 2004 20:43:49 -0000
@@ -27,7 +27,7 @@ dist_devicemanager_DATA =               
                        hal-cat-cardbus.png   hal-unknown.png       \
                        hal-cat-keyboard.png  hal-video.png         \
                        hal-computer.png      hal-serial-port.png   \
-                       hal-device-manager.glade
+                       hal-pda.png           hal-device-manager.glade
 
 # symlink into $(bindir) for convenience
 #install-data-local :
Index: tools/device-manager/Representation.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/Representation.py,v
retrieving revision 1.11
diff -u -p -r1.11 Representation.py
--- tools/device-manager/Representation.py	20 Sep 2004 18:31:15 -0000	1.11
+++ tools/device-manager/Representation.py	8 Nov 2004 20:43:49 -0000
@@ -39,6 +39,7 @@ class Representation:
         self.icons["audio"] = self.load_and_scale_icon(Const.DATADIR + "/hal-audio.png")
         self.icons["camera"] = self.load_and_scale_icon(Const.DATADIR + "/hal-camera.png")
         self.icons["serial"] = self.load_and_scale_icon(Const.DATADIR + "/hal-serial-port.png")
+        self.icons["pda"] = self.load_and_scale_icon(Const.DATADIR + "/hal-pda.png")
 
 
     def get_icon(self, device):
@@ -58,6 +59,12 @@ class Representation:
         elif bus=="pci":
             icon = self.icons["bus_pci"]
 
+        # Check for PDAs:
+        if device.properties.has_key("info.capability"):
+            cap = device.properties["info.capability"]
+            if cap=="pda":
+                icon = self.icons["pda"]
+
         # Then look at Category, if available
         if not device.properties.has_key("info.category"):
             return icon


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]