Hi list,

I was trying to get synce to work with my WM6 PDA and FreeBSD 7 the other day. 
There was a few things I had to do. With the attached patches I am able to 
sync and access my device using palm/uppc-kmod driver from FreeBSD ports. I 
also used old opensync 0.22 framework. Of course I had to disable the 
Advanged network functionality on my PDA.

The first patch, hal-freebsd.patch, addresses a few FreeBSD specific hal DCCM 
issues. First, linux/if.h header doesn't exist on other platforms. I think 
net/if.h should work on Linux too, but I ifdef'd it just in case. Second 
issues was that usb-rndis-ng rule in 10-synce.fdi created some conflicts so I 
removed it. I also tried to make the FreeBSD ucom rule more general. Then I 
made some adjustments for hal-synce-legacy script. There were few other 
things I noticed: device file handling did not work at all on FreeBSD, 
FreeBSD ppp doesn't support linkname, and last, at least on my computer, HAL 
0.5.11rc2 doesn't set environmental variable HALD_ACTION. HAL also searches 
the scripts only from $prefix/libexec so I adjusted the Makefile accordingly.

The second patch, sync-engine-hal.patch, adds support for HAL DCCM for 
sync-engine. In addition to that it also fixes scripts list_partnerships.py, 
create_partnership.py and clean_partnerships.py. The first two scripts were 
using wrong (non existing) exception classes and the third was passing too 
few parameters.

The third issue the second patch fixes is something I had quite hard time to 
figure out. It seems that rapi contexts are created and stored into TLS so 
they are per thread. So when the rapi context is created in main thread in 
kernel.py and used later in another thread in synchandler.py, librapi method 
rapi_context_current() returns new, uninitialized context, that results in 
sync-engine crash. I fixed this by creating and using a new rapi context in 
SyncHandler.run() method. This makes the thing work.

At least hal-synce-legacy and 10-synce.fdi need some work to be platform 
independet, but now the thing works on FreeBSD. I hope these patches are 
useful and fixes get commited. At least sync-engine TLS issue should also be 
there on other platforms too.

Thanks,
        Markus Niemistö
Index: hal/src/utils.c
===================================================================
--- hal/src/utils.c	(revision 3326)
+++ hal/src/utils.c	(working copy)
@@ -5,7 +5,11 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#ifdef __linux__
 #include <linux/if.h>
+#else
+#include <net/if.h>
+#endif
 #include <sys/ioctl.h>
 #include <synce.h>
 #include <dbus/dbus-glib.h>
Index: hal/hal/10-synce.fdi
===================================================================
--- hal/hal/10-synce.fdi	(revision 3326)
+++ hal/hal/10-synce.fdi	(working copy)
@@ -19,25 +19,6 @@
     </match>
   </device>
 
-  <!-- usb-rndis-ng -->
-
-  <device>
-    <match key="@info.parent:pda.platform" string="pocketpc">
-      <append key="info.capabilities" type="strlist">sync</append>
-
-      <merge key="pda.platform" type="string">pocketpc</merge>
-
-      <merge key="usb.interface.description" type="string">Windows Mobile Data Provider</merge>
-      <merge key="info.category" type="string">pda</merge>
-      <merge key="sync.engine" type="string">opensync</merge>
-      <merge key="sync.plugin" type="string">synce</merge>
-
-      <merge key="usb.product" type="string">Windows Mobile Device</merge>
-
-      <append key="info.callouts.add" type="strlist">hal-synce-rndis</append>
-    </match>
-  </device>
-
   <!-- ipaq -->
 
   <device>
@@ -61,8 +42,8 @@
        should be more generic, but it's a good start -->
 
   <device>
-    <match key="freebsd.driver" contains="ucom">
-      <match key="info.vendor" string="HTC">
+    <match key="info.product" contains="Generic Serial">
+      <match key="freebsd.driver" string="ucom">
         <append key="info.capabilities" type="strlist">sync</append>
 
         <merge key="pda.platform" type="string">pocketpc</merge>
Index: hal/hal/Makefile.am
===================================================================
--- hal/hal/Makefile.am	(revision 3326)
+++ hal/hal/Makefile.am	(working copy)
@@ -2,7 +2,7 @@
 haldatadir = ${prefix}/share/hal/fdi/policy/20thirdparty
 haldata_DATA = 10-synce.fdi
 
-haldir = ${prefix}/lib/hal
+haldir = ${prefix}/libexec
 hal_SCRIPTS = \
 	hal-synce-rndis \
 	hal-synce-legacy 
Index: hal/hal/hal-synce-legacy.in
===================================================================
--- hal/hal/hal-synce-legacy.in	(revision 3326)
+++ hal/hal/hal-synce-legacy.in	(working copy)
@@ -1,8 +1,7 @@
 #!/bin/sh
 
+DEVICE_FILE="/dev/ttyU${HAL_PROP_FREEBSD_UNIT}"
 
-DEVICE_FILE=${HAL_PROP_LINUX_DEVICE_FILE}
-
 THIS=`basename $0`
 
 # logging functions
@@ -23,7 +22,7 @@
 PPPD=/usr/sbin/pppd
 VAR_PPP=/var/run
 
-DEVICE_PREFIX=synce-device
+DEVICE_PREFIX=ttyU
 PEER=$DEVICE_PREFIX
 PEER_FILE=${PPP_PEERS}/${PEER}
 COMMAND="${PPPD} call ${PEER}"
@@ -81,7 +80,7 @@
   ${INFO} "Bringing up serial link:   ${SYNCE_PPP:-$PPPD} ${SYNCE_DEV} ${SYNCE_DEVSPEED:-115200} connect ${SYNCE_PPP_CONNECT:[EMAIL PROTECTED]@} ${SYNCE_IPADDR:-$DEFAULT_IPS} ms-dns ${SYNCE_DNS:-$DEFAULT_LOCAL_IP} linkname ${SYNCE_DEVNAME:-$PEER} $pppopts $SYNCE_PPP_OPTIONS"
 
   # Now bring up the connection
-  ${SYNCE_PPP:-$PPPD} ${SYNCE_DEV} ${SYNCE_DEVSPEED:-115200} connect ${SYNCE_PPP_CONNECT:[EMAIL PROTECTED]@} ${SYNCE_IPADDR:-$DEFAULT_IPS} ms-dns ${SYNCE_DNS:-$DEFAULT_LOCAL_IP} linkname ${SYNCE_DEVNAME:-$PEER} $pppopts $SYNCE_PPP_OPTIONS
+  ${SYNCE_PPP:-$PPPD} ${SYNCE_DEV} ${SYNCE_DEVSPEED:-115200} connect ${SYNCE_PPP_CONNECT:[EMAIL PROTECTED]@} ${SYNCE_IPADDR:-$DEFAULT_IPS} ms-dns ${SYNCE_DNS:-$DEFAULT_LOCAL_IP} $pppopts $SYNCE_PPP_OPTIONS
 
   if [ "$?" != "0" ]; then
     ${ERROR} "Failed to initialize ppp connection"
@@ -119,11 +118,6 @@
 }
 
 
-if [ ${HALD_ACTION} == "add" ]; then
-    synce_serial_start_device
-    hal-dccm --device-ip=${SYNCE_REMOTEIP} --local-ip=${SYNCE_LOCALIP} --log-level=6
-fi
+synce_serial_start_device
+hal-dccm --device-ip=${SYNCE_REMOTEIP} --local-ip=${SYNCE_LOCALIP} --log-level=6
 
-if [ ${HALD_ACTION} == "remove" ]; then
-    synce_serial_abort_device
-fi
Index: sync-engine/tools/list_partnerships.py
===================================================================
--- sync-engine/tools/list_partnerships.py	(revision 3326)
+++ sync-engine/tools/list_partnerships.py	(working copy)
@@ -40,7 +40,7 @@
 		
 except dbus.DBusException,e:
 	
-	if e._dbus_error_name=="org.freedesktop.DBus.Python.SyncEngine.errors.Disconnected":
+	if e._dbus_error_name=="org.synce.SyncEngine.Error.Disconnected":
 		print "error: No device connected"
 	elif e._dbus_error_name=="org.freedesktop.DBus.Python.Exception":
 		print e
Index: sync-engine/tools/create_partnership.py
===================================================================
--- sync-engine/tools/create_partnership.py	(revision 3326)
+++ sync-engine/tools/create_partnership.py	(working copy)
@@ -57,12 +57,12 @@
 except dbus.DBusException,e:
 	
 	print "\nerror: failed to create partnership"
-	if e._dbus_error_name=="org.freedesktop.DBus.Python.SyncEngine.errors.Disconnected":
+	if e._dbus_error_name=="org.synce.SyncEngine.Error.Disconnected":
 		print "error: No device connected"
-	elif e._dbus_error_name=="org.freedesktop.DBus.Python.SyncEngine.errors.InvalidArgument":
+	elif e._dbus_error_name=="org.synce.SyncEngine.Error.InvalidArgument":
 		print "error: invalid argument"
 		PrintUsage()
-	elif e._dbus_error_name=="org.freedesktop.DBus.Python.SyncEngine.errors.NoFreeSlots":
+	elif e._dbus_error_name=="org.synce.SyncEngine.Error.NoFreeSlots":
 		print "error: Device has no free slots available in which to create the partnership"
 	elif e._dbus_error_name=="org.freedesktop.DBus.Python.Exception":
 		print e
Index: sync-engine/tools/clean_partnerships.py
===================================================================
--- sync-engine/tools/clean_partnerships.py	(revision 3326)
+++ sync-engine/tools/clean_partnerships.py	(working copy)
@@ -27,7 +27,7 @@
 		sys.stdout.flush()
 
 		for pship in partnerships:
-			engine.DeletePartnership(pship[0])
+			engine.DeletePartnership(pship[0], pship[1])
 
 		print "..done\n"
 
Index: sync-engine/SyncEngine/auth.py
===================================================================
--- sync-engine/SyncEngine/auth.py	(revision 3326)
+++ sync-engine/SyncEngine/auth.py	(working copy)
@@ -27,10 +27,7 @@
 # Is authorization required to use this device?
 	
 def IsAuthRequired(device):
-	flags = device.GetPasswordFlags()
-        if flags & ODCCM_DEVICE_PASSWORD_FLAG_PROVIDE:
-		return True
-	return False
+	return device.GetProperty('pda.pocketpc.password') != 'unset'
 
 ############################################################################
 # Authorize
Index: sync-engine/SyncEngine/synchandler.py
===================================================================
--- sync-engine/SyncEngine/synchandler.py	(revision 3326)
+++ sync-engine/SyncEngine/synchandler.py	(working copy)
@@ -22,11 +22,14 @@
 import threading
 import logging
 import time
+import rapicontext
+import pyrapi2
 
 class SyncHandler(threading.Thread):
 
     def __init__(self, engine, auto_sync):
         threading.Thread.__init__(self)
+
         self.logger = logging.getLogger("engine.synchandler.SyncHandler")
 
         self.engine = engine
@@ -44,7 +47,9 @@
 	# Clear the end-of-sync event
 	
 	self.evtSyncRunFinished.clear()
-	
+
+	self.rapi_context =rapicontext.RapiContext(pyrapi2.SYNCE_LOG_LEVEL_DEFAULT) 
+
 	# Temporarily uninstall the previous handler for the beginning of the
         # synchronization.  The previous handler was for the auto-syncs, which
         # we disable temporarily while we are syncing here
@@ -68,7 +73,7 @@
 	    partnernode.setProp("id",self.engine.PshipManager.GetCurrentPartnership().info.guid)
 
             self.logger.debug("run: sending request to device \n%s", doc_node.serialize("utf-8",1))
-            self.engine.rapi_session.sync_start(doc_node.serialize("utf-8",0))
+            self.rapi_context.sync_start(doc_node.serialize("utf-8",0))
 
         self.logger.debug("run: performing synchronization")
 
@@ -81,8 +86,8 @@
 	# this, otherwise we get RAPI timeouts.
 
         self.logger.debug("run: calling RAPI sync_pause and sync_resume")
-        self.engine.rapi_session.sync_pause()
-        self.engine.rapi_session.sync_resume()
+        self.rapi_context.sync_pause()
+        self.rapi_context.sync_resume()
 
         if not self.stopped:
             self.logger.debug("run: saving itemDB")
Index: sync-engine/SyncEngine/kernel.py
===================================================================
--- sync-engine/SyncEngine/kernel.py	(revision 3326)
+++ sync-engine/SyncEngine/kernel.py	(working copy)
@@ -106,12 +106,17 @@
 		# it to become available.
 
 		try:
-			self.device_manager = dbus.Interface(dbus.SystemBus().get_object(DBUS_ODCCM_BUSNAME, DBUS_ODCCM_OBJPATH), DBUS_ODCCM_IFACE)
+			# get a HAL object and an interface to HAL to make function calls
+			self.device_manager = dbus.Interface(dbus.SystemBus().get_object (
+				'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager'),
+				'org.freedesktop.Hal.Manager')
+
+			#self.device_manager = dbus.Interface(dbus.SystemBus().get_object(DBUS_ODCCM_BUSNAME, DBUS_ODCCM_OBJPATH), DBUS_ODCCM_IFACE)
 			self.device_manager.connect_to_signal("DeviceConnected", self._CBDeviceConnected)
 			self.device_manager.connect_to_signal("DeviceDisconnected", self._CBDeviceDisconnected)
 			self.isOdccmRunning = True
 
-			obj_paths = self.device_manager.GetConnectedDevices()
+			obj_paths = self.device_manager.FindDeviceByCapability ('sync')
 			if len(obj_paths) > 0:
 				self.logger.info("__init__: connected device found")
 				self._CBDeviceConnected(obj_paths[0])
@@ -153,17 +158,20 @@
 				self.devicePath = ""
 
 				try:
-					self.device_manager = dbus.Interface(dbus.SystemBus().get_object(DBUS_ODCCM_BUSNAME, DBUS_ODCCM_OBJPATH), DBUS_ODCCM_IFACE)
+					# get a HAL object and an interface to HAL to make function calls
+					self.device_manager = dbus.Interface(dbus.SystemBus().get_object (
+						'org.freedesktop.Hal', '/org/freedesktop/Hal/Manager'),
+						'org.freedesktop.Hal.Manager')
+
+					#self.device_manager = dbus.Interface(dbus.SystemBus().get_object(DBUS_ODCCM_BUSNAME, DBUS_ODCCM_OBJPATH), DBUS_ODCCM_IFACE)
 					self.device_manager.connect_to_signal("DeviceConnected", self._CBDeviceConnected)
 					self.device_manager.connect_to_signal("DeviceDisconnected", self._CBDeviceDisconnected)
-				
 					self.isOdccmRunning = True
 
-					obj_paths = self.device_manager.GetConnectedDevices()
+					obj_paths = self.device_manager.FindDeviceByCapability ('sync')
 					if len(obj_paths) > 0:
-						self.logger.info("_CBODCCMStatusChanged: connected device found")
-						self._CBDeviceConnected(obj_paths[0])
-						
+						self.logger.info("__init__: connected device found")
+						self._CBDeviceConnected(obj_paths[0])		
 				except:
 					self.isOdccmRunning = False
 
@@ -180,15 +188,12 @@
 		self.logger.info("_CBDeviceConnected: device connected at path %s", obj_path)
 
 		if self.isConnected == False:
-		
-			# update config from file
-	
+			# update config from file	
 			self.config.UpdateConfig()
 
-			deviceObject = dbus.SystemBus().get_object("org.synce.odccm",obj_path)
-			self.device = dbus.Interface(deviceObject,"org.synce.odccm.Device")
-       			self.device.connect_to_signal("PasswordFlagsChanged", self._CBDeviceAuthStateChanged)
-			self.deviceName = self.device.GetName()
+			deviceObject = dbus.SystemBus().get_object ('org.freedesktop.Hal', obj_path)
+			self.device = dbus.Interface(deviceObject,"org.freedesktop.Hal.Device")
+			self.deviceName = self.device.GetProperty('pda.pocketpc.name')
 			self.logger.info(" device %s connected" % self.deviceName)
 			self.devicePath = obj_path
        			if self._ProcessAuth():
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
SynCE-Devel mailing list
SynCE-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synce-devel

Reply via email to