vmx-manager r80 - in trunk: . dbus-sharp hal-sharp src



Author: jwillcox
Date: Fri May  2 20:45:20 2008
New Revision: 80
URL: http://svn.gnome.org/viewvc/vmx-manager?rev=80&view=rev

Log:
2008-05-02  James Willcox  <snorp novell com>

        * configure.ac: bump to 0.2.9
        * src/Utility.cs: Be more careful getting default network type
        * Removed bundled dbus-sharp, rely on external one




Removed:
   trunk/dbus-sharp/
Modified:
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/configure.ac
   trunk/hal-sharp/Device.cs
   trunk/hal-sharp/Makefile.am
   trunk/hal-sharp/Manager.cs
   trunk/src/Utility.cs

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Fri May  2 20:45:20 2008
@@ -1,4 +1,4 @@
-SUBDIRS = dbus-sharp hal-sharp src data po
+SUBDIRS = hal-sharp src data po
 
 EXTRA_DIST =			\
 	intltool-extract.in	\

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Fri May  2 20:45:20 2008
@@ -5,7 +5,7 @@
 
 AC_PROG_INTLTOOL([0.21])
 
-PKG_CHECK_MODULES(VMXMAN, gtk-sharp-2.0 glade-sharp-2.0 gnome-sharp-2.0)
+PKG_CHECK_MODULES(VMXMAN, gtk-sharp-2.0 glade-sharp-2.0 gnome-sharp-2.0 ndesk-dbus-glib-1.0)
 VMXMAN_LIBS="$VMXMAN_LIBS -r:Mono.Posix"
 AC_SUBST(VMXMAN_LIBS)
 
@@ -25,8 +25,6 @@
 
 AC_OUTPUT([
 Makefile
-dbus-sharp/Makefile
-dbus-sharp/NDesk.DBus.GLib.dll.config
 hal-sharp/Makefile
 src/Makefile
 src/vmx-manager

Modified: trunk/hal-sharp/Device.cs
==============================================================================
--- trunk/hal-sharp/Device.cs	(original)
+++ trunk/hal-sharp/Device.cs	Fri May  2 20:45:20 2008
@@ -37,7 +37,11 @@
                                        // in a variant, nor does it have a 
                                        // GetPropertyUInt64
                                        // should be object GetProperty(string key)
-                                      
+
+        void StringListPrepend(string key, string value);
+        void StringListAppend(string key, string value);
+        void StringListRemove(string key, string value);
+        
         string GetPropertyString(string key);
         int GetPropertyInteger(string key);
         bool GetPropertyBoolean(string key);
@@ -55,6 +59,32 @@
         void Unlock();
     }
     
+    internal enum DType : byte
+    {
+      Invalid = (byte)'\0',
+      Byte = (byte)'y',
+      Boolean = (byte)'b',
+      Int16 = (byte)'n',
+      UInt16 = (byte)'q',
+      Int32 = (byte)'i',
+      UInt32 = (byte)'u',
+      Int64 = (byte)'x',
+      UInt64 = (byte)'t',
+      Single = (byte)'f',
+      Double = (byte)'d',
+      String = (byte)'s',
+      ObjectPath = (byte)'o',
+      Signature = (byte)'g',
+      Array = (byte)'a',
+      Struct = (byte)'r',
+      DictEntry = (byte)'e',
+      Variant = (byte)'v',
+      StructBegin = (byte)'(',
+      StructEnd = (byte)')',
+      DictEntryBegin = (byte)'{',
+      DictEntryEnd = (byte)'}',
+    }
+    
     public enum PropertyType
     {
         Invalid = DType.Invalid,
@@ -94,18 +124,14 @@
         {
             this.udi = udi;
             
-            if(!Bus.System.NameHasOwner("org.freedesktop.Hal")) {
-                throw new ApplicationException("Could not find org.freedesktop.Hal");
-            }
-            
-            device = Bus.System.GetObject<IDevice>("org.freedesktop.Hal", new ObjectPath(udi));
+            device = CastDevice<IDevice>();
             device.PropertyModified += OnPropertyModified;
         }
         
         public static Device [] UdisToDevices(string [] udis)
         {
             if(udis == null || udis.Length == 0) {
-                return null;
+                return new Device[0];
             }
             
             Device [] devices = new Device[udis.Length];
@@ -128,6 +154,16 @@
             }
         }
         
+        public string [] GetChildren(Manager manager)
+        {
+            return manager.FindDeviceByStringMatch("info.parent", Udi);
+        }
+        
+        public Device [] GetChildrenAsDevice(Manager manager)
+        {
+            return manager.FindDeviceByStringMatchAsDevice("info.parent", Udi);
+        }
+        
         public void Lock(string reason)
         {
             device.Lock(reason);
@@ -173,6 +209,21 @@
             return PropertyExists(key) ? device.GetPropertyType(key) : PropertyType.Invalid;
         }
         
+        public void StringListPrepend(string key, string value)
+        {
+            device.SetPropertyString(key, value);
+        }
+        
+        public void StringListAppend(string key, string value)
+        {
+            device.StringListAppend(key, value);
+        }
+        
+        public void StringListRemove(string key, string value)
+        {
+            device.StringListRemove(key, value);
+        }
+        
         public void SetPropertyString(string key, string value)
         {
             device.SetPropertyString(key, value);
@@ -222,6 +273,15 @@
         {
             return device.QueryCapability(capability);
         }
+        
+        public T CastDevice<T>()
+        {
+            if(!Bus.System.NameHasOwner("org.freedesktop.Hal")) {
+                throw new ApplicationException("Could not find org.freedesktop.Hal");
+            }
+            
+            return Bus.System.GetObject<T>("org.freedesktop.Hal", new ObjectPath(Udi));
+        }
 
         public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
         {
@@ -277,6 +337,26 @@
             get { return udi; }
         }
         
+        public bool IsVolume {
+            get {
+                if(!PropertyExists("info.interfaces")) {
+                    return false;
+                }
+                
+                foreach(string @interface in GetPropertyStringList("info.interfaces")) {
+                    if(@interface == "org.freedesktop.Hal.Device.Volume") {
+                       return true;
+                    }
+                }
+                
+                return false;
+            }
+        }
+        
+        public Volume Volume {
+            get { return new Volume(Udi); }
+        }
+        
         public Device Parent {
             get {
                 if(PropertyExists("info.parent")) {

Modified: trunk/hal-sharp/Makefile.am
==============================================================================
--- trunk/hal-sharp/Makefile.am	(original)
+++ trunk/hal-sharp/Makefile.am	Fri May  2 20:45:20 2008
@@ -6,12 +6,13 @@
 
 ASSEMBLY_SOURCES = \
 	$(srcdir)/Manager.cs \
-	$(srcdir)/Device.cs
+	$(srcdir)/Device.cs \
+	$(srcdir)/Volume.cs
 
 all: $(ASSEMBLY)
 
 $(ASSEMBLY): $(ASSEMBLY_SOURCES)
-	$(MCS) -debug -target:library -out:$@ $(VMXMAN_LIBS) -r:$(top_builddir)/dbus-sharp/NDesk.DBus.dll $(ASSEMBLY_SOURCES)
+	$(MCS) -debug -target:library -out:$@ $(VMXMAN_LIBS) -pkg:ndesk-dbus-1.0 $(ASSEMBLY_SOURCES)
 
 EXTRA_DIST = $(ASSEMBLY_SOURCES)
 CLEANFILES = $(hal_SCRIPTS) *.pidb

Modified: trunk/hal-sharp/Manager.cs
==============================================================================
--- trunk/hal-sharp/Manager.cs	(original)
+++ trunk/hal-sharp/Manager.cs	Fri May  2 20:45:20 2008
@@ -98,6 +98,10 @@
             manager = Bus.System.GetObject<IManager>("org.freedesktop.Hal",
                 new ObjectPath("/org/freedesktop/Hal/Manager"));
             
+            if(manager == null) {
+                throw new ApplicationException("The /org/freedesktop/Hal/Manager object could not be located on the DBUs interface org.freedesktop.Hal");
+            }
+
             manager.DeviceAdded += OnDeviceAdded;
             manager.DeviceRemoved += OnDeviceRemoved;
             manager.NewCapability += OnNewCapability;

Modified: trunk/src/Utility.cs
==============================================================================
--- trunk/src/Utility.cs	(original)
+++ trunk/src/Utility.cs	Fri May  2 20:45:20 2008
@@ -369,10 +369,14 @@
         }
 
         public static NetworkType GetDefaultNetworkType () {
-            Hal.Device computer = new Hal.Device ("/org/freedesktop/Hal/devices/computer");
-            if (computer.GetPropertyString ("system.formfactor") == "laptop") {
-                return NetworkType.Nat;
-            } else {
+            try {
+                Hal.Device computer = new Hal.Device ("/org/freedesktop/Hal/devices/computer");
+                if (computer.GetPropertyString ("system.formfactor") == "laptop") {
+                    return NetworkType.Nat;
+                } else {
+                    return NetworkType.Bridged;
+                }
+            } catch (Exception e) {
                 return NetworkType.Bridged;
             }
         }



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