hal/tools/device-manager DeviceManager.py,1.20,1.21

David Zeuthen david at freedesktop.org
Wed Mar 2 11:19:15 PST 2005


Update of /cvs/hal/hal/tools/device-manager
In directory gabe:/tmp/cvs-serv21926/tools/device-manager

Modified Files:
	DeviceManager.py 
Log Message:
2005-03-02  David Zeuthen  <davidz at redhat.com>

	* tools/device-manager/DeviceManager.py: Move some things around
	only to discover that D-BUS python bindings need fixing to actually
	push signals we subscribe to without giving the path...

	* tools/lshal.c (device_condition): Fix this function so it works
	after the DeviceCondition format changes earlier

	* libhal/libhal.h: Export prototype for libhal_device_emit_condition

	* libhal/libhal.c (libhal_device_emit_condition): New function

	* hald/linux2/addons/addon-storage.c (main): Fix that we should
	be verbose

	* hald/linux2/addons/addon-acpi.c (read_line): Rewrite this
	to not malloc all over the place
	(main): Try two places for ACPI events. Rework parsing of events
	and send out DeviceConditions where appropriate

	* hald/hald_dbus.c (device_emit_condition): New function
	(hald_dbus_filter_function): Handle EmitCondition

2005-03-01  Richard Hughes  <richard at hughsie.com>

	* hald/linux2/addons/addon-acpi.c (main): Call
	libhal_device_rescan for each ACPI event.



Index: DeviceManager.py
===================================================================
RCS file: /cvs/hal/hal/tools/device-manager/DeviceManager.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- DeviceManager.py	22 Feb 2005 19:42:04 -0000	1.20
+++ DeviceManager.py	2 Mar 2005 19:19:13 -0000	1.21
@@ -4,6 +4,7 @@
 import gobject
 import gtk
 import dbus
+import dbus_bindings
 
 try:
     import gnome.ui
@@ -67,6 +68,17 @@
                                      "/org/freedesktop/Hal/Manager",
 				     expand_args=False)
 
+	#self.bus.add_signal_receiver(self.property_modified,
+	#			     "PropertyModified",
+	#			     "org.freedesktop.Hal.Device",
+	#			     "org.freedesktop.Hal",
+	#			     None)#"/org/freedesktop/Hal/devices/acpi_LID")
+	#self.bus.add_signal_receiver(self.device_condition,
+	#			     "Condition",
+	#			     "org.freedesktop.Hal.Device",
+	#			     "org.freedesktop.Hal",
+	#			     None)#"/org/freedesktop/Hal/devices/acpi_LID")
+
         # Add listeners for all devices
         try:
             device_names = self.hal_manager.GetAllDevices()
@@ -86,26 +98,26 @@
         self.main_window.show()
 
     def add_device_signal_recv (self, udi):
-	self.bus.add_signal_receiver(self.device_changed,
+	return
+	self.bus.add_signal_receiver(self.property_modified,
 				     "PropertyModified",
 				     "org.freedesktop.Hal.Device",
 				     "org.freedesktop.Hal",
 				     udi)
-	return
-	self.bus.add_signal_receiver(self.device_changed,
+	self.bus.add_signal_receiver(self.device_condition,
 				     "Condition",
 				     "org.freedesktop.Hal.Device",
 				     "org.freedesktop.Hal",
 				     udi)
 
     def remove_device_signal_recv (self, udi):
-	self.bus.remove_signal_receiver(self.device_changed,
+	return
+	self.bus.remove_signal_receiver(self.property_modified,
 				     "PropertyModified",
 				     "org.freedesktop.Hal.Device",
 				     "org.freedesktop.Hal",
 				     udi)
-	return
-	self.bus.remove_signal_receiver(self.device_changed,
+	self.bus.remove_signal_receiver(self.device_condition,
 				     "Condition",
 				     "org.freedesktop.Hal.Device",
 				     "org.freedesktop.Hal",
@@ -129,47 +141,50 @@
             self.update_device_notebook(device)
 
 
-    def device_changed(self, sender, num_changes, change_list):
+    def device_condition(self, sender, condition_name, condition_details):
         """This method is called when signals on the Device interface is
         received"""
 
 	device_udi = sender.path
-        if sender.signal_name=="Condition":
-            print "\nCondition %s, device=%s"%(device, sender.path)
-            print "  message = ", args 
-        elif sender.signal_name=="PropertyModified":
-            print "\nPropertyModified, device=%s"%sender.path
-            #print "dbus_obj_path", sender.path
-            for i in change_list:
-                property_name = i[0]
-                removed = i[1]
-                added = i[2]
+	print "\nCondition device=%s"%sender.path
+	print "  (condition_name, condition_details) = ('%s', '%s')"%(condition_name, condition_details)
 
-                print "  key=%s, rem=%d, add=%d"%(property_name, removed, added)
-                if property_name=="info.parent":
-                    self.update_device_list()        
-                else:
-                    device_udi_obj = self.hal_service.get_object(device_udi,
-                                                   "org.freedesktop.Hal.Device")
-                    device_obj = self.udi_to_device(device_udi)
+    def property_modified(self, sender, num_changes, change_list):
+        """This method is called when signals on the Device interface is
+        received"""
 
-                    if device_udi_obj.PropertyExists(property_name):
-                        device_obj.properties[property_name] = device_udi_obj.GetProperty(property_name)
-                        print "  value=%s"%(device_obj.properties[property_name])
-                    else:
-                        if device_obj != None:
-                            try:
-                                del device_obj.properties[property_name]
-                            except:
-                                pass
+	device_udi = sender.path
+	print "\nPropertyModified, device=%s"%sender.path
+	#print "dbus_obj_path", sender.path
+	for i in change_list:
+	    property_name = i[0]
+	    removed = i[1]
+	    added = i[2]
 
-                    device_focus_udi = self.get_current_focus_udi()
-                    if device_focus_udi != None:
-                        device = self.udi_to_device(device_udi)
-                        if device_focus_udi==device_udi:
-                            self.update_device_notebook(device)
+	    print "  key=%s, rem=%d, add=%d"%(property_name, removed, added)
+	    if property_name=="info.parent":
+		self.update_device_list()        
+	    else:
+		device_udi_obj = self.hal_service.get_object(device_udi,
+                                                   "org.freedesktop.Hal.Device")
+		device_obj = self.udi_to_device(device_udi)
 
+		if device_udi_obj.PropertyExists(property_name):
+		    device_obj.properties[property_name] = device_udi_obj.GetProperty(property_name)
+		    print "  value=%s"%(device_obj.properties[property_name])
+		else:
+		    if device_obj != None:
+			try:
+			    del device_obj.properties[property_name]
+			except:
+			    pass
 
+		device_focus_udi = self.get_current_focus_udi()
+		if device_focus_udi != None:
+		    device = self.udi_to_device(device_udi)
+		    if device_focus_udi==device_udi:
+			self.update_device_notebook(device)
+			
     def gdl_changed(self, sender):
         """This method is called when a HAL device is added or removed."""
 




More information about the hal-commit mailing list