[C3SL-git] Framework 2.0 branch, master, updated. libfsobasics-0.9.0-1849-ga53266d

smartphones-commits at linuxtogo.org smartphones-commits at linuxtogo.org
Mon Jul 4 21:39:49 CEST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Framework 2.0".

The branch, master has been updated
       via  a53266d7b1f7d9cb57b43c48036acbe043ee57c1 (commit)
      from  b6d4d093f83e44150ec5eec81dcc487dda6704e2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a53266d7b1f7d9cb57b43c48036acbe043ee57c1
Author: Simon Busch <morphis at gravedo.de>
Date:   Mon Jul 4 21:09:09 2011 +0200

    fsodeviced: palmpre_quirks: add initial version of the usb gadget listener

-----------------------------------------------------------------------

Summary of changes:
 .../src/plugins/palmpre_quirks/powersupply.vala    |   83 ++++++++++++++++++++
 1 files changed, 83 insertions(+), 0 deletions(-)


Changes between commits b6d4d0..a53266
diff --git a/fsodeviced/src/plugins/palmpre_quirks/powersupply.vala b/fsodeviced/src/plugins/palmpre_quirks/powersupply.vala
index 8f19527..5b3b870 100644
--- a/fsodeviced/src/plugins/palmpre_quirks/powersupply.vala
+++ b/fsodeviced/src/plugins/palmpre_quirks/powersupply.vala
@@ -50,6 +50,86 @@ namespace PalmPre
         }
     }
 
+    private class UsbGadgetListener : FsoFramework.AbstractObject
+    {
+        public enum PowerSource
+        {
+            NONE,
+            BUS
+        }
+
+        public bool host_connected { get; private set; }
+        public PowerSource power_source { get; private set; }
+        public uint power_current_ma { get; private set; }
+
+        construct
+        {
+            FsoFramework.BaseKObjectNotifier.addMatch( "change", "platform", onPlatformChangeEvent );
+        }
+
+        private void onPlatformChangeEvent( GLib.HashTable<string, string> properties )
+        {
+            var modalias = properties.lookup( "MODALIAS" );
+            if ( modalias == null || modalias != "platform:usb_gadget" )
+                return;
+
+            var action = properties.lookup( "G_ACTION" );
+            if ( action == null )
+                return;
+
+            switch ( action )
+            {
+                case "POWER_STATE_CHANGED":
+                    handlePowerStateChanged( properties );
+                    break;
+                case "HOST_STATE_CHANGED":
+                    handleHostStateChanged( properties );
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        private void handlePowerStateChanged( GLib.HashTable<string, string> properties )
+        {
+            var powersource = properties.lookup( "G_POWER_SOURCE" );
+            if ( powersource != null )
+            {
+                switch ( powersource )
+                {
+                    case "bus":
+                        power_source = PowerSource.BUS;
+                        break;
+                    case "none":
+                        power_source = PowerSource.NONE;
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+            var currentma = properties.lookup( "G_CURRENT_MA" );
+            if ( currentma != null )
+            {
+                power_current_ma = int.parse( currentma );
+            }
+        }
+
+        private void handleHostStateChanged( GLib.HashTable<string, string> properties )
+        {
+            var hostconnected = properties.lookup( "G_HOST_CONNECTED" );
+            if ( hostconnected == null )
+                return;
+
+            host_connected = ( hostconnected == "1" );
+        }
+
+        public override string repr()
+        {
+            return "<>";
+        }
+    }
+
     /**
      * @class BatteryPowerSupply
      *
@@ -69,6 +149,7 @@ namespace PalmPre
         private FreeSmartphone.Device.PowerStatus _current_power_status = FreeSmartphone.Device.PowerStatus.UNKNOWN;
         private bool present;
         private bool _skip_authentication = false;
+        private UsbGadgetListener usbgadget_listener;
 
         //
         // Properties
@@ -242,6 +323,8 @@ namespace PalmPre
 
             FsoFramework.BaseKObjectNotifier.addMatch( "change", "platform", onPlatformChangeEvent );
 
+            usbgadget_listener = new UsbGadgetListener();
+
             logger.info( "Created new PowerSupply object." );
         }
 


hooks/post-receive
--
Framework 2.0



More information about the smartphones-commits mailing list