On Tue, 2008-03-25 at 21:10 +0200, Markus Niemistö wrote:
> Bakulin Ilya wrote (2008-03-24 16:00:11):
> >
> > What exactly conflicts were caused?
>
> When I plug my PDA in HAL creates two
> devices: /org/freedesktop/Hal/devices/usb_device_bb4_ce_noserial_if0
> and /org/freedesktop/Hal/devices/usb_device_bb4_ce_noserial. Without removing
> the usb-rndis-ng rule sync-engine got confused because both device entries
> have sync capabilities and friends (thanks to that rule), but only one has
> the entries like pda.pocketpc.name. Depending on luck sync-engine might find
> first the device entry that hal-dccm handles, or the one that is unhandled
> and gets confused.
>
I had a go at sync-engine anyway :) Bear in mind that my python is not
very good.
Try the attached patch to a clean checkout of sync-engine. It's a little
more complicated than yours or Bakulin's because I want to keep support
for odccm. Bakulin, if you could try it as well that would be very
helpful.
Mark
diff -Nur sync-engine.orig/SyncEngine/auth.py sync-engine/SyncEngine/auth.py
--- sync-engine.orig/SyncEngine/auth.py 2007-05-08 20:51:51.000000000 +0100
+++ sync-engine/SyncEngine/auth.py 2008-03-25 19:30:06.000000000 +0000
@@ -12,10 +12,18 @@
import dbus
import os.path
import config
+import re
ODCCM_DEVICE_PASSWORD_FLAG_SET = 1
ODCCM_DEVICE_PASSWORD_FLAG_PROVIDE = 2
+
+HAL_DEVICE_PASSWORD_FLAG_UNSET = "unset"
+HAL_DEVICE_PASSWORD_FLAG_PROVIDE = "provide"
+HAL_DEVICE_PASSWORD_FLAG_PROVIDE_ON_DEVICE = "provide-on-device"
+HAL_DEVICE_PASSWORD_FLAG_CHECKING = "checking"
+HAL_DEVICE_PASSWORD_FLAG_UNLOCKED = "unlocked"
+
AUTH_TOOLS_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)),"../tools")
CLI_TOOL = os.path.join(AUTH_TOOLS_PATH,"authcli.py")
@@ -27,6 +35,12 @@
# Is authorization required to use this device?
def IsAuthRequired(device):
+ if re.compile('/org/freedesktop/Hal/devices/').match(device.object_path) != None:
+ flags = device.GetPropertyString("pda.pocketpc.password")
+ if flags == "provide":
+ return True
+ return False
+
flags = device.GetPasswordFlags()
if flags & ODCCM_DEVICE_PASSWORD_FLAG_PROVIDE:
return True
diff -Nur sync-engine.orig/SyncEngine/constants.py sync-engine/SyncEngine/constants.py
--- sync-engine.orig/SyncEngine/constants.py 2007-12-22 13:12:41.000000000 +0000
+++ sync-engine/SyncEngine/constants.py 2008-03-25 19:30:06.000000000 +0000
@@ -30,6 +30,11 @@
DBUS_ODCCM_IFACE = "org.synce.odccm.DeviceManager"
DBUS_ODCCM_OBJPATH = "/org/synce/odccm/DeviceManager"
+DBUS_HAL_BUSNAME = "org.freedesktop.Hal"
+DBUS_HAL_MANAGER_IFACE = "org.freedesktop.Hal.Manager"
+DBUS_HAL_MANAGER_OBJPATH = "/org/freedesktop/Hal/Manager"
+DBUS_HAL_DEVICE_IFACE = "org.freedesktop.Hal.Device"
+
SYNC_ITEM_CALENDAR = 0
SYNC_ITEM_CONTACTS = 1
SYNC_ITEM_EMAIL = 2
diff -Nur sync-engine.orig/SyncEngine/kernel.py sync-engine/SyncEngine/kernel.py
--- sync-engine.orig/SyncEngine/kernel.py 2008-03-15 19:54:56.000000000 +0000
+++ sync-engine/SyncEngine/kernel.py 2008-03-25 19:45:05.000000000 +0000
@@ -118,6 +118,22 @@
except:
self.isOdccmRunning = False
+
+ # Attempt to connect to Hal manager
+
+ try:
+ self.hal_manager = dbus.Interface(dbus.SystemBus().get_object(DBUS_HAL_BUSNAME, DBUS_HAL_MANAGER_OBJPATH), DBUS_HAL_MANAGER_IFACE)
+ self.hal_manager.connect_to_signal("DeviceAdded", self._CBHalDeviceConnected)
+ self.hal_manager.connect_to_signal("DeviceRemoved", self._CBHalDeviceDisconnected)
+
+ obj_paths = self.hal_manager.FindDeviceStringMatch("pda.platform", "pocketpc")
+
+ if len(obj_paths) > 0:
+ self.logger.info("__init__: connected device found")
+ self._CBHalDeviceConnected(obj_paths[0])
+ except Exception, inst:
+ self.logger.info("__init__: exception %s", inst)
+
#
# _CBODCCMStatusChanged
#
@@ -218,6 +234,68 @@
self.logger.info("_CBDeviceDisconnected: ignoring non-live device detach")
#
+ # _CBHalDeviceConnected
+ #
+ # INTERNAL
+ #
+ # Callback triggered when a device is connected through Hal.
+ #
+
+ def _CBHalDeviceConnected(self, obj_path):
+
+ if self.isOdccmRunning:
+ return
+
+ self.logger.info("_CBHalDeviceConnected: device connected at udi %s", obj_path)
+
+ if self.isConnected == False:
+
+ deviceObject = dbus.SystemBus().get_object(DBUS_HAL_BUSNAME, obj_path)
+ self.device = dbus.Interface(deviceObject,DBUS_HAL_DEVICE_IFACE)
+
+ # check if it's a pocketpc
+ if not self.device.PropertyExists("pda.pocketpc.name"):
+ self.device = None
+ return
+
+ # update config from file
+
+ self.config.UpdateConfig()
+
+ self.device.connect_to_signal("PropertyModified", self._CBHalDeviceAuthStateChanged)
+ self.deviceName = self.device.GetPropertyString("pda.pocketpc.name")
+ self.logger.info(" device %s connected" % self.deviceName)
+ self.devicePath = obj_path
+ if self._ProcessAuth():
+ self.OnConnect()
+ else:
+ if obj_path == self.devicePath:
+ self.logger.info("_CBHalDeviceConnected: device already connected")
+ else:
+ self.logger.info("_CBHalDeviceConnected: other device already connected - ignoring new device")
+
+ #
+ # _CBHalDeviceDisconnected
+ #
+ # INTERNAL
+ #
+ # Callback triggered when a device is disconnected through Hal
+ #
+
+ def _CBHalDeviceDisconnected(self, obj_path):
+
+ if self.isOdccmRunning:
+ return
+
+ self.logger.info("_CBHalDeviceDisconnected: device disconnected from udi %s", obj_path)
+ if self.devicePath == obj_path:
+ self.device=None
+ self.deviceName = ""
+ self.OnDisconnect()
+ else:
+ self.logger.info("_CBHalDeviceDisconnected: ignoring non-live device detach")
+
+ #
# _CheckDeviceConnected
#
# INTERNAL
@@ -244,6 +322,22 @@
self._ProcessAuth()
#
+ # _CBHalDeviceAuthStateChanged
+ #
+ # INTERNAL
+ #
+ # Callback triggered when a Hal device property is changed, for checking authorization state changes
+ #
+
+ def _CBHalDeviceAuthStateChanged(self,num_changes,properties):
+
+ for property in properties:
+ property_name, added, removed = property
+ if property_name == "pda.pocketpc.password":
+ self.logger.info("_CBHalDeviceAuthStateChanged: device authorization state changed: reauthorizing")
+ self._ProcessAuth()
+
+ #
# _CheckAndGetValidPartnership
#
# INTERNAL
diff -Nur sync-engine.orig/tools/authcli.py sync-engine/tools/authcli.py
--- sync-engine.orig/tools/authcli.py 2008-03-05 17:10:42.000000000 +0000
+++ sync-engine/tools/authcli.py 2008-03-25 19:30:06.000000000 +0000
@@ -12,10 +12,17 @@
import dbus.glib
import sys
import getpass
+import re
ODCCM_DEVICE_PASSWORD_FLAG_SET = 1
ODCCM_DEVICE_PASSWORD_FLAG_PROVIDE = 2
+HAL_DEVICE_PASSWORD_FLAG_UNSET = "unset"
+HAL_DEVICE_PASSWORD_FLAG_PROVIDE = "provide"
+HAL_DEVICE_PASSWORD_FLAG_PROVIDE_ON_DEVICE = "provide-on-device"
+HAL_DEVICE_PASSWORD_FLAG_CHECKING = "checking"
+HAL_DEVICE_PASSWORD_FLAG_UNLOCKED = "unlocked"
+
#
# AuthCli
#
@@ -26,6 +33,13 @@
def __init__(self,objpath):
bus = dbus.SystemBus()
+
+ if re.compile('/org/freedesktop/Hal/devices/').match(objpath) != None:
+ self.deviceObject = bus.get_object("org.freedesktop.Hal", objpath)
+ self.device = dbus.Interface(self.deviceObject, "org.freedesktop.Hal.Device")
+ self.deviceName = self.device.GetPropertyString("pda.pocketpc.name")
+ return
+
self.deviceObject = bus.get_object("org.synce.odccm", objpath)
self.device = dbus.Interface(self.deviceObject, "org.synce.odccm.Device")
self.deviceName = self.device.GetName()
@@ -35,6 +49,20 @@
# no need to run if for some reason we are called on a
# device that is not blocked
+ if re.compile('/org/freedesktop/Hal/devices/').match(self.device.object_path) != None:
+ flags = self.device.GetPropertyString("pda.pocketpc.password")
+ rc=1
+ if flags == "provide":
+ print
+ print "Authorization required for device %s." % self.deviceName
+
+ rc = 0
+ cnt = 3
+ while not rc and cnt:
+ rc = self.deviceObject.ProvidePassword(getpass.getpass("Password:"), dbus_interface='org.freedesktop.Hal.Device.Synce')
+ cnt -= 1
+ return rc
+
flags = self.device.GetPasswordFlags()
rc=1
if flags & ODCCM_DEVICE_PASSWORD_FLAG_PROVIDE:
diff -Nur sync-engine.orig/tools/authgui.py sync-engine/tools/authgui.py
--- sync-engine.orig/tools/authgui.py 2008-03-05 17:10:42.000000000 +0000
+++ sync-engine/tools/authgui.py 2008-03-25 19:30:07.000000000 +0000
@@ -12,10 +12,17 @@
import dbus.glib
import gtk
import sys
+import re
ODCCM_DEVICE_PASSWORD_FLAG_SET = 1
ODCCM_DEVICE_PASSWORD_FLAG_PROVIDE = 2
+HAL_DEVICE_PASSWORD_FLAG_UNSET = "unset"
+HAL_DEVICE_PASSWORD_FLAG_PROVIDE = "provide"
+HAL_DEVICE_PASSWORD_FLAG_PROVIDE_ON_DEVICE = "provide-on-device"
+HAL_DEVICE_PASSWORD_FLAG_CHECKING = "checking"
+HAL_DEVICE_PASSWORD_FLAG_UNLOCKED = "unlocked"
+
# EntryDialog
#
# Password entry dialog for GUI entry of password
@@ -55,6 +62,13 @@
def __init__(self,objpath):
bus = dbus.SystemBus()
+
+ if re.compile('/org/freedesktop/Hal/devices/').match(objpath) != None:
+ self.deviceObject = bus.get_object("org.freedesktop.Hal", objpath)
+ self.device = dbus.Interface(self.deviceObject, "org.freedesktop.Hal.Device")
+ self.deviceName = self.device.GetPropertyString("pda.pocketpc.name")
+ return
+
self.deviceObject = bus.get_object("org.synce.odccm", objpath)
self.device = dbus.Interface(self.deviceObject, "org.synce.odccm.Device")
self.deviceName = self.device.GetName()
@@ -63,6 +77,27 @@
# no need to run if for some reason we are called on a
# device that is not blocked
+
+ if re.compile('/org/freedesktop/Hal/devices/').match(self.device.object_path) != None:
+ flags = self.device.GetPropertyString("pda.pocketpc.password")
+ rc=1
+ if flags == "provide":
+ stopAsking = False
+ while not stopAsking:
+ dlg = EntryDialog(None, "SynCE: Password required to synchronize device",
+ "Enter password for device '%s'" % self.deviceName,
+ True)
+
+ if dlg.run() == gtk.RESPONSE_ACCEPT:
+ stopAsking = self.deviceObject.ProvidePassword(dlg.get_text(), dbus_interface='org.freedesktop.Hal.Device.Synce')
+ if stopAsking:
+ rc=1
+ else:
+ stopAsking = True
+ rc=0
+ dlg.destroy()
+ return rc
+
flags = self.device.GetPasswordFlags()
rc=1
-------------------------------------------------------------------------
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