treewide: Migrate to UPower D-Bus API from ayatana power indicator
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -44,7 +44,7 @@ SRC = \
 | 
				
			|||||||
  mce_proxy.c
 | 
					  mce_proxy.c
 | 
				
			||||||
GEN_SRC = \
 | 
					GEN_SRC = \
 | 
				
			||||||
  com.canonical.Unity.Screen.c \
 | 
					  com.canonical.Unity.Screen.c \
 | 
				
			||||||
  org.ayatana.indicator.power.Battery.c
 | 
					  org.freedesktop.UPower.Device.c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#  mce_inactivity.c \
 | 
					#  mce_inactivity.c \
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,39 +0,0 @@
 | 
				
			|||||||
<?xml version="1.0" encoding="UTF-8" ?>
 | 
					 | 
				
			||||||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
 | 
					 | 
				
			||||||
<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
 | 
					 | 
				
			||||||
  <interface name="org.ayatana.indicator.power.Battery">
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <property name="PowerLevel" type="s" access="read">
 | 
					 | 
				
			||||||
      <doc:doc>
 | 
					 | 
				
			||||||
        <doc:description>
 | 
					 | 
				
			||||||
          <doc:para>The battery's power level. Possible values: 'ok', 'low', 'very_low', 'critical'</doc:para>
 | 
					 | 
				
			||||||
        </doc:description>
 | 
					 | 
				
			||||||
      </doc:doc>
 | 
					 | 
				
			||||||
    </property>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <property name="PowerPercentage" type="i" access="read">
 | 
					 | 
				
			||||||
      <doc:doc>
 | 
					 | 
				
			||||||
        <doc:description>
 | 
					 | 
				
			||||||
          <doc:para>The battery's power level in percentage.</doc:para>
 | 
					 | 
				
			||||||
        </doc:description>
 | 
					 | 
				
			||||||
      </doc:doc>
 | 
					 | 
				
			||||||
    </property>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <property name="IsWarning" type="b" access="read">
 | 
					 | 
				
			||||||
      <doc:doc>
 | 
					 | 
				
			||||||
        <doc:description>
 | 
					 | 
				
			||||||
          <doc:para>Whether or not ayatana-indicator-power-service is warning the user about low battery power.</doc:para>
 | 
					 | 
				
			||||||
        </doc:description>
 | 
					 | 
				
			||||||
      </doc:doc>
 | 
					 | 
				
			||||||
    </property>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <property name="IsDischarging" type="b" access="read">
 | 
					 | 
				
			||||||
      <doc:doc>
 | 
					 | 
				
			||||||
        <doc:description>
 | 
					 | 
				
			||||||
          <doc:para>Whether or not the battery is discharging</doc:para>
 | 
					 | 
				
			||||||
        </doc:description>
 | 
					 | 
				
			||||||
      </doc:doc>
 | 
					 | 
				
			||||||
    </property>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  </interface>
 | 
					 | 
				
			||||||
</node>
 | 
					 | 
				
			||||||
							
								
								
									
										833
									
								
								spec/org.freedesktop.UPower.Device.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										833
									
								
								spec/org.freedesktop.UPower.Device.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,833 @@
 | 
				
			|||||||
 | 
					<!DOCTYPE node PUBLIC
 | 
				
			||||||
 | 
					"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
 | 
				
			||||||
 | 
					"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" [
 | 
				
			||||||
 | 
					  <!ENTITY ERROR_GENERAL "org.freedesktop.UPower.Device.GeneralError">
 | 
				
			||||||
 | 
					]>
 | 
				
			||||||
 | 
					<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
 | 
				
			||||||
 | 
					  <interface name="org.freedesktop.UPower.Device">
 | 
				
			||||||
 | 
					    <doc:doc>
 | 
				
			||||||
 | 
					      <doc:description>
 | 
				
			||||||
 | 
					        <doc:para>
 | 
				
			||||||
 | 
					          Objects implementing this interface are usually discovered through
 | 
				
			||||||
 | 
					          the <doc:tt>org.freedesktop.UPower</doc:tt> interface on
 | 
				
			||||||
 | 
					          the <doc:tt>/org/freedesktop/UPower</doc:tt> object on
 | 
				
			||||||
 | 
					          the D-Bus system bus service with the well-known
 | 
				
			||||||
 | 
					          name <doc:tt>org.freedesktop.UPower</doc:tt> using
 | 
				
			||||||
 | 
					          the
 | 
				
			||||||
 | 
					          <doc:ref type="method" to="Power.EnumerateDevices">EnumerateDevices</doc:ref>
 | 
				
			||||||
 | 
					          method.
 | 
				
			||||||
 | 
					        </doc:para>
 | 
				
			||||||
 | 
					        <doc:para>
 | 
				
			||||||
 | 
					          <doc:example language="shell" title="simple example">
 | 
				
			||||||
 | 
					            <doc:code>
 | 
				
			||||||
 | 
					$ dbus-send --print-reply \
 | 
				
			||||||
 | 
					            --system \
 | 
				
			||||||
 | 
					            --dest=org.freedesktop.UPower \
 | 
				
			||||||
 | 
					            /org/freedesktop/UPower/devices/battery_BAT0 \
 | 
				
			||||||
 | 
					            org.freedesktop.DBus.Properties.GetAll \
 | 
				
			||||||
 | 
					            string:org.freedesktop.UPower.Device
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					method return sender=:1.386 -> dest=:1.477 reply_serial=2
 | 
				
			||||||
 | 
					   array [
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "native-path"
 | 
				
			||||||
 | 
					         variant             string "/sys/devices/LNXSYSTM:00/device:00/PNP0A08:00/device:01/PNP0C09:00/PNP0C0A:00/power_supply/BAT0"
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "vendor"
 | 
				
			||||||
 | 
					         variant             string "SONY"
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "model"
 | 
				
			||||||
 | 
					         variant             string "42T4568"
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "serial"
 | 
				
			||||||
 | 
					         variant             string "4179"
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "update-time"
 | 
				
			||||||
 | 
					         variant             uint64 1226417875
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "type"
 | 
				
			||||||
 | 
					         variant             uint 2
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "power-supply"
 | 
				
			||||||
 | 
					         variant             boolean true
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "has-history"
 | 
				
			||||||
 | 
					         variant             boolean true
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "has-statistics"
 | 
				
			||||||
 | 
					         variant             boolean true
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "online"
 | 
				
			||||||
 | 
					         variant             boolean false
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "energy"
 | 
				
			||||||
 | 
					         variant             double 72.85
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "energy-empty"
 | 
				
			||||||
 | 
					         variant             double 0
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "energy-full"
 | 
				
			||||||
 | 
					         variant             double 74.55
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "energy-full-design"
 | 
				
			||||||
 | 
					         variant             double 74.88
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "energy-rate"
 | 
				
			||||||
 | 
					         variant             double 0
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "voltage"
 | 
				
			||||||
 | 
					         variant             double 16.415
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "time-to-empty"
 | 
				
			||||||
 | 
					         variant             int64 0
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "time-to-full"
 | 
				
			||||||
 | 
					         variant             int64 0
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "percentage"
 | 
				
			||||||
 | 
					         variant             double 97.7197
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "is-present"
 | 
				
			||||||
 | 
					         variant             boolean true
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "state"
 | 
				
			||||||
 | 
					         variant             uint 3
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "is-rechargeable"
 | 
				
			||||||
 | 
					         variant             boolean true
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "capacity"
 | 
				
			||||||
 | 
					         variant             double 100
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					      dict entry(
 | 
				
			||||||
 | 
					         string "technology"
 | 
				
			||||||
 | 
					         variant             uint 1
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					   ]
 | 
				
			||||||
 | 
					            </doc:code>
 | 
				
			||||||
 | 
					          </doc:example>
 | 
				
			||||||
 | 
					        </doc:para>
 | 
				
			||||||
 | 
					        <doc:para>
 | 
				
			||||||
 | 
					          Unless otherwise noted, an empty string or the value 0 in a
 | 
				
			||||||
 | 
					          property on this interface means not set.
 | 
				
			||||||
 | 
					        </doc:para>
 | 
				
			||||||
 | 
					      </doc:description>
 | 
				
			||||||
 | 
					    </doc:doc>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <!-- ************************************************************ -->
 | 
				
			||||||
 | 
					    <method name="Refresh">
 | 
				
			||||||
 | 
					      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Refreshes the data collected from the power source.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					        <doc:permission>Callers will need to make sure that the daemon was started in debug mode</doc:permission>
 | 
				
			||||||
 | 
					        <doc:errors>
 | 
				
			||||||
 | 
					          <doc:error name="&ERROR_GENERAL;">if an error occured while refreshing</doc:error>
 | 
				
			||||||
 | 
					        </doc:errors>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </method>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <!-- ************************************************************ -->
 | 
				
			||||||
 | 
					    <method name="GetHistory">
 | 
				
			||||||
 | 
					      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
 | 
				
			||||||
 | 
					      <arg name="type" direction="in" type="s">
 | 
				
			||||||
 | 
					        <doc:doc><doc:summary>The type of history.
 | 
				
			||||||
 | 
					        Valid types are <doc:tt>rate</doc:tt> or <doc:tt>charge</doc:tt>.</doc:summary></doc:doc>
 | 
				
			||||||
 | 
					      </arg>
 | 
				
			||||||
 | 
					      <arg name="timespan" direction="in" type="u">
 | 
				
			||||||
 | 
					        <doc:doc><doc:summary>The amount of data to return in seconds, or 0 for all.</doc:summary></doc:doc>
 | 
				
			||||||
 | 
					      </arg>
 | 
				
			||||||
 | 
					      <arg name="resolution" direction="in" type="u">
 | 
				
			||||||
 | 
					        <doc:doc>
 | 
				
			||||||
 | 
					          <doc:summary>
 | 
				
			||||||
 | 
					            The approximate number of points to return.
 | 
				
			||||||
 | 
					            A higher resolution is more accurate, at the expense of plotting speed.
 | 
				
			||||||
 | 
					          </doc:summary>
 | 
				
			||||||
 | 
					        </doc:doc>
 | 
				
			||||||
 | 
					      </arg>
 | 
				
			||||||
 | 
					      <arg name="data" direction="out" type="a(udu)">
 | 
				
			||||||
 | 
					        <doc:doc><doc:summary>
 | 
				
			||||||
 | 
					            The history data for the power device, if the device supports history.
 | 
				
			||||||
 | 
					            Data is ordered from the earliest in time, to the newest data point.
 | 
				
			||||||
 | 
					            Each element contains the following members:
 | 
				
			||||||
 | 
					            <doc:list>
 | 
				
			||||||
 | 
					              <doc:item>
 | 
				
			||||||
 | 
					                <doc:term>time</doc:term>
 | 
				
			||||||
 | 
					                <doc:definition>
 | 
				
			||||||
 | 
					                  The time value in seconds from the <doc:tt>gettimeofday()</doc:tt> method.
 | 
				
			||||||
 | 
					                </doc:definition>
 | 
				
			||||||
 | 
					              </doc:item>
 | 
				
			||||||
 | 
					              <doc:item>
 | 
				
			||||||
 | 
					                <doc:term>value</doc:term>
 | 
				
			||||||
 | 
					                <doc:definition>
 | 
				
			||||||
 | 
					                  The data value, for instance the rate in W or the charge in %.
 | 
				
			||||||
 | 
					                </doc:definition>
 | 
				
			||||||
 | 
					              </doc:item>
 | 
				
			||||||
 | 
					              <doc:item>
 | 
				
			||||||
 | 
					                <doc:term>state</doc:term>
 | 
				
			||||||
 | 
					                <doc:definition>
 | 
				
			||||||
 | 
					                  The state of the device, for instance <doc:tt>charging</doc:tt> or
 | 
				
			||||||
 | 
					                  <doc:tt>discharging</doc:tt>.
 | 
				
			||||||
 | 
					                </doc:definition>
 | 
				
			||||||
 | 
					              </doc:item>
 | 
				
			||||||
 | 
					            </doc:list>
 | 
				
			||||||
 | 
					        </doc:summary></doc:doc>
 | 
				
			||||||
 | 
					      </arg>
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Gets history for the power device that is persistent across reboots.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </method>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <!-- ************************************************************ -->
 | 
				
			||||||
 | 
					    <method name="GetStatistics">
 | 
				
			||||||
 | 
					      <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
 | 
				
			||||||
 | 
					      <arg name="type" direction="in" type="s">
 | 
				
			||||||
 | 
					        <doc:doc><doc:summary>The mode for the statistics.
 | 
				
			||||||
 | 
					        Valid types are <doc:tt>charging</doc:tt> or <doc:tt>discharging</doc:tt>.</doc:summary></doc:doc>
 | 
				
			||||||
 | 
					      </arg>
 | 
				
			||||||
 | 
					      <arg name="data" direction="out" type="a(dd)">
 | 
				
			||||||
 | 
					        <doc:doc><doc:summary>
 | 
				
			||||||
 | 
					            The statistics data for the power device.
 | 
				
			||||||
 | 
					            Each element contains the following members:
 | 
				
			||||||
 | 
					            <doc:list>
 | 
				
			||||||
 | 
					              <doc:item>
 | 
				
			||||||
 | 
					                <doc:term>value</doc:term>
 | 
				
			||||||
 | 
					                <doc:definition>
 | 
				
			||||||
 | 
					                  The value of the percentage point, usually in seconds
 | 
				
			||||||
 | 
					                </doc:definition>
 | 
				
			||||||
 | 
					              </doc:item>
 | 
				
			||||||
 | 
					              <doc:item>
 | 
				
			||||||
 | 
					                <doc:term>accuracy</doc:term>
 | 
				
			||||||
 | 
					                <doc:definition>
 | 
				
			||||||
 | 
					                  The accuracy of the prediction in percent.
 | 
				
			||||||
 | 
					                </doc:definition>
 | 
				
			||||||
 | 
					              </doc:item>
 | 
				
			||||||
 | 
					            </doc:list>
 | 
				
			||||||
 | 
					        </doc:summary></doc:doc>
 | 
				
			||||||
 | 
					      </arg>
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Gets statistics for the power device that may be interesting
 | 
				
			||||||
 | 
					            to show on a graph in the session.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </method>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <!-- ************************************************************ -->
 | 
				
			||||||
 | 
					    <property name="NativePath" type="s" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            OS specific native path of the power source. On Linux this
 | 
				
			||||||
 | 
					            is the sysfs path, for
 | 
				
			||||||
 | 
					            example <doc:tt>/sys/devices/LNXSYSTM:00/device:00/PNP0C0A:00/power_supply/BAT0</doc:tt>. Is
 | 
				
			||||||
 | 
					            blank if the device is being driven by a user space
 | 
				
			||||||
 | 
					            driver.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Vendor" type="s" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Name of the vendor of the battery.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Model" type="s" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Name of the model of this battery.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Serial" type="s" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Unique serial number of the battery.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="UpdateTime" type="t" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The point in time (seconds since the Epoch Jan 1, 1970
 | 
				
			||||||
 | 
					            0:00 UTC) that data was read from the power source.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Type" type="u" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Type of power source.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					          <doc:list>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>1</doc:term><doc:definition>Line Power</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>2</doc:term><doc:definition>Battery</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>3</doc:term><doc:definition>Ups</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>4</doc:term><doc:definition>Monitor</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>5</doc:term><doc:definition>Mouse</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>6</doc:term><doc:definition>Keyboard</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>7</doc:term><doc:definition>Pda</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>8</doc:term><doc:definition>Phone</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>9</doc:term><doc:definition>Media Player</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>10</doc:term><doc:definition>Tablet</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>11</doc:term><doc:definition>Computer</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>12</doc:term><doc:definition>Gaming Input</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>13</doc:term><doc:definition>Pen</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>14</doc:term><doc:definition>Touchpad</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>15</doc:term><doc:definition>Modem</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>16</doc:term><doc:definition>Network</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>17</doc:term><doc:definition>Headset</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>18</doc:term><doc:definition>Speakers</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>19</doc:term><doc:definition>Headphones</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>20</doc:term><doc:definition>Video</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>21</doc:term><doc:definition>Other Audio</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>22</doc:term><doc:definition>Remote Control</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>23</doc:term><doc:definition>Printer</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>24</doc:term><doc:definition>Scanner</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>25</doc:term><doc:definition>Camera</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>26</doc:term><doc:definition>Wearable</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>27</doc:term><doc:definition>Toy</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>28</doc:term><doc:definition>Bluetooth Genreic</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					          </doc:list>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            If the value is set to "Battery", you will need to verify that the
 | 
				
			||||||
 | 
					            property <doc:ref type="property" to="Source:PowerSupply">power-supply</doc:ref>
 | 
				
			||||||
 | 
					            has the value "true" before considering it as a laptop battery. Otherwise it
 | 
				
			||||||
 | 
					            will likely be the battery for a device of an unknown type.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="PowerSupply" type="b" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            If the power device is used to supply the system.
 | 
				
			||||||
 | 
					            This would be set TRUE for laptop batteries and UPS devices,
 | 
				
			||||||
 | 
					            but set FALSE for wireless mice or PDAs.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="HasHistory" type="b" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            If the power device has history.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="HasStatistics" type="b" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            If the power device has statistics.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Online" type="b" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Whether power is currently being provided through line power.
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "line-power".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Energy" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Amount of energy (measured in Wh) currently available in
 | 
				
			||||||
 | 
					            the power source.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="EnergyEmpty" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Amount of energy (measured in Wh) in the power source when
 | 
				
			||||||
 | 
					            it's considered to be empty.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="EnergyFull" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Amount of energy (measured in Wh) in the power source when
 | 
				
			||||||
 | 
					            it's considered full.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="EnergyFullDesign" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Amount of energy (measured in Wh) the power source is
 | 
				
			||||||
 | 
					            designed to hold when it's considered full.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="EnergyRate" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Amount of energy being drained from the source, measured
 | 
				
			||||||
 | 
					            in W. If positive, the source is being discharged, if
 | 
				
			||||||
 | 
					            negative it's being charged.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Voltage" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Voltage in the Cell or being recorded by the meter.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="ChargeCycles" type="i" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The number of charge cycles as defined by the TCO certification, or -1 if
 | 
				
			||||||
 | 
					            that value is unknown or not applicable.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Luminosity" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Luminosity being recorded by the meter.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="TimeToEmpty" type="x" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Number of seconds until the power source is considered empty.
 | 
				
			||||||
 | 
					            Is set to 0 if unknown.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="TimeToFull" type="x" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Number of seconds until the power source is considered full.
 | 
				
			||||||
 | 
					            Is set to 0 if unknown.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Percentage" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The amount of energy left in the power source expressed as
 | 
				
			||||||
 | 
					            a percentage between 0 and 100. Typically this is the same as
 | 
				
			||||||
 | 
					            (<doc:ref type="property" to="Source:Energy">energy</doc:ref> -
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:EnergyEmpty">energy-empty</doc:ref>) /
 | 
				
			||||||
 | 
					            (<doc:ref type="property" to="Source:EnergyFull">energy-full</doc:ref> -
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:EnergyEmpty">energy-empty</doc:ref>).
 | 
				
			||||||
 | 
					            However, some primitive power sources are capable of only
 | 
				
			||||||
 | 
					            reporting percentages and in this case the energy-*
 | 
				
			||||||
 | 
					            properties will be unset while this property is set.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The percentage will be an approximation if the <doc:ref type="property" to="BatteryLevel">battery level</doc:ref>
 | 
				
			||||||
 | 
					            is set to something other than None. The percentage is kept for compatibility reasons.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Temperature" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The temperature of the device in degrees Celsius. This property is
 | 
				
			||||||
 | 
					            only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="IsPresent" type="b" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            If the power source is present in the bay.
 | 
				
			||||||
 | 
					            This field is required as some batteries are hot-removable, for example
 | 
				
			||||||
 | 
					            expensive UPS and most laptop batteries.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="State" type="u" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The battery power state.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					          <doc:list>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>1</doc:term><doc:definition>Charging</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>2</doc:term><doc:definition>Discharging</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>3</doc:term><doc:definition>Empty</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>4</doc:term><doc:definition>Fully charged</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>5</doc:term><doc:definition>Pending charge</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>6</doc:term><doc:definition>Pending discharge</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					          </doc:list>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="IsRechargeable" type="b" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            If the power source is rechargeable.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Capacity" type="d" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The capacity of the power source expressed as a percentage between 0 and 100.
 | 
				
			||||||
 | 
					            The capacity of the battery will reduce with age.
 | 
				
			||||||
 | 
					            A capacity value less than 75% is usually a sign that you should renew your battery.
 | 
				
			||||||
 | 
					            Typically this value is the same as
 | 
				
			||||||
 | 
					            (<doc:ref type="property" to="Source:FullDesign">full-design</doc:ref> /
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Full">full</doc:ref>) * 100.
 | 
				
			||||||
 | 
					            However, some primitive power sources are not capable reporting capacity
 | 
				
			||||||
 | 
					            and in this case the capacity property will be unset.
 | 
				
			||||||
 | 
					          </doc:para><doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="Technology" type="u" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Technology used in the battery:
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					          <doc:list>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>1</doc:term><doc:definition>Lithium ion</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>2</doc:term><doc:definition>Lithium polymer</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>3</doc:term><doc:definition>Lithium iron phosphate</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>4</doc:term><doc:definition>Lead acid</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>5</doc:term><doc:definition>Nickel cadmium</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>6</doc:term><doc:definition>Nickel metal hydride</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					          </doc:list>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            This property is only valid if the property
 | 
				
			||||||
 | 
					            <doc:ref type="property" to="Source:Type">type</doc:ref>
 | 
				
			||||||
 | 
					            has the value "battery".
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="WarningLevel" type="u" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            Warning level of the battery:
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					          <doc:list>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>1</doc:term><doc:definition>None</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>2</doc:term><doc:definition>Discharging (only for UPSes)</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>3</doc:term><doc:definition>Low</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>4</doc:term><doc:definition>Critical</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>5</doc:term><doc:definition>Action</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					          </doc:list>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="BatteryLevel" type="u" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            The level of the battery for devices which do not report a percentage but rather a coarse battery level. If the value
 | 
				
			||||||
 | 
					            is None, then the device does not support coarse battery reporting, and the percentage should be used instead.
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					          <doc:list>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>0</doc:term><doc:definition>Unknown</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>1</doc:term><doc:definition>None (the battery does not use a coarse level of battery reporting)</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>3</doc:term><doc:definition>Low</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>4</doc:term><doc:definition>Critical</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>6</doc:term><doc:definition>Normal</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>7</doc:term><doc:definition>High</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					            <doc:item>
 | 
				
			||||||
 | 
					              <doc:term>8</doc:term><doc:definition>Full</doc:definition>
 | 
				
			||||||
 | 
					            </doc:item>
 | 
				
			||||||
 | 
					          </doc:list>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    <property name="IconName" type="s" access="read">
 | 
				
			||||||
 | 
					      <doc:doc>
 | 
				
			||||||
 | 
					        <doc:description>
 | 
				
			||||||
 | 
					          <doc:para>
 | 
				
			||||||
 | 
					            <p>An icon name, following the <a href="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon Naming Specification</a></p>
 | 
				
			||||||
 | 
					            <p>Note that the icons might not match end-user expectations in terms of presentation relative to the amount of battery left or perceived to be left. It is recommended that front-ends use the BatteryLevel property first, if available, followed by the Percentage, to present a more realistic battery level to the user.</p>
 | 
				
			||||||
 | 
					          </doc:para>
 | 
				
			||||||
 | 
					        </doc:description>
 | 
				
			||||||
 | 
					      </doc:doc>
 | 
				
			||||||
 | 
					    </property>
 | 
				
			||||||
 | 
					  </interface>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</node>
 | 
				
			||||||
@@ -41,7 +41,7 @@
 | 
				
			|||||||
#include <gutil_misc.h>
 | 
					#include <gutil_misc.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Generated headers */
 | 
					/* Generated headers */
 | 
				
			||||||
#include "org.ayatana.indicator.power.Battery.h"
 | 
					#include "org.freedesktop.UPower.Device.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define MCE_BATTERY_STATUS_OK "ok"
 | 
					#define MCE_BATTERY_STATUS_OK "ok"
 | 
				
			||||||
#define MCE_BATTERY_STATUS_LOW "low"
 | 
					#define MCE_BATTERY_STATUS_LOW "low"
 | 
				
			||||||
@@ -109,23 +109,6 @@ mce_battery_check_valid(
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
mce_battery_level_update(
 | 
					 | 
				
			||||||
    MceBattery* self,
 | 
					 | 
				
			||||||
    gint level)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    MceBatteryPriv* priv = self->priv;
 | 
					 | 
				
			||||||
    const guint new_level = (level < 0) ? 0 : (level > 100) ? 100 : level;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (self->level != new_level) {
 | 
					 | 
				
			||||||
        self->level = new_level;
 | 
					 | 
				
			||||||
        g_signal_emit(self, mce_battery_signals[SIGNAL_LEVEL_CHANGED], 0);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    priv->flags |= BATTERY_HAVE_LEVEL;
 | 
					 | 
				
			||||||
    mce_battery_check_valid(self);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static
 | 
					static
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
mce_battery_status_update(
 | 
					mce_battery_status_update(
 | 
				
			||||||
@@ -155,6 +138,35 @@ mce_battery_status_update(
 | 
				
			|||||||
    mce_battery_check_valid(self);
 | 
					    mce_battery_check_valid(self);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					mce_battery_level_update(
 | 
				
			||||||
 | 
					    MceBattery* self,
 | 
				
			||||||
 | 
					    gdouble level)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    // values from ayatana-indicator-power/src/notifier.c
 | 
				
			||||||
 | 
					    char* status;
 | 
				
			||||||
 | 
					    if (level <= 2)
 | 
				
			||||||
 | 
					        status = MCE_BATTERY_STATUS_CRITICAL;
 | 
				
			||||||
 | 
					    else if (level <= 5)
 | 
				
			||||||
 | 
					        status = MCE_BATTERY_STATUS_EMPTY;
 | 
				
			||||||
 | 
					    else if (level <= 10)
 | 
				
			||||||
 | 
					        status = MCE_BATTERY_STATUS_LOW;
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					        status = MCE_BATTERY_STATUS_OK;
 | 
				
			||||||
 | 
					    mce_battery_status_update(self, status);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    MceBatteryPriv* priv = self->priv;
 | 
				
			||||||
 | 
					    const guint new_level = (level < 0) ? 0 : (level > 100) ? 100 : level;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (self->level != new_level) {
 | 
				
			||||||
 | 
					        self->level = new_level;
 | 
				
			||||||
 | 
					        g_signal_emit(self, mce_battery_signals[SIGNAL_LEVEL_CHANGED], 0);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    priv->flags |= BATTERY_HAVE_LEVEL;
 | 
				
			||||||
 | 
					    mce_battery_check_valid(self);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_properties_changed (GDBusProxy          *proxy,
 | 
					on_properties_changed (GDBusProxy          *proxy,
 | 
				
			||||||
                       GVariant            *changed_properties,
 | 
					                       GVariant            *changed_properties,
 | 
				
			||||||
@@ -168,14 +180,10 @@ on_properties_changed (GDBusProxy          *proxy,
 | 
				
			|||||||
  g_variant_iter_init (&iter, changed_properties);
 | 
					  g_variant_iter_init (&iter, changed_properties);
 | 
				
			||||||
  while (g_variant_iter_next (&iter, "{&sv}", &key, &value))
 | 
					  while (g_variant_iter_next (&iter, "{&sv}", &key, &value))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!g_strcmp0(key, "PowerPercentage")) {
 | 
					        if (!g_strcmp0(key, "Percentage")) {
 | 
				
			||||||
            gint level;
 | 
					            gdouble level;
 | 
				
			||||||
            g_variant_get (value, "i", &level);
 | 
					            g_variant_get (value, "d", &level);
 | 
				
			||||||
            mce_battery_level_update(MCE_BATTERY(user_data), level);
 | 
					            mce_battery_level_update(MCE_BATTERY(user_data), level);
 | 
				
			||||||
        } else if (!g_strcmp0(key, "PowerLevel")) {
 | 
					 | 
				
			||||||
            const char* status;
 | 
					 | 
				
			||||||
            g_variant_get (value, "s", &status);
 | 
					 | 
				
			||||||
            mce_battery_status_update(MCE_BATTERY(user_data), status);
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      g_variant_unref (value);
 | 
					      g_variant_unref (value);
 | 
				
			||||||
@@ -196,16 +204,13 @@ mce_battery_query(
 | 
				
			|||||||
     * for the valid signal before we can connect the battery state
 | 
					     * for the valid signal before we can connect the battery state
 | 
				
			||||||
     * signal and submit the initial query.
 | 
					     * signal and submit the initial query.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if (proxy->ayatana_request && !priv->battery_ind_id) {
 | 
					    if (proxy->upower_request && !priv->battery_ind_id) {
 | 
				
			||||||
        priv->battery_ind_id = g_signal_connect(proxy->ayatana_request, "g-properties-changed",
 | 
					        priv->battery_ind_id = g_signal_connect(proxy->upower_request, "g-properties-changed",
 | 
				
			||||||
            G_CALLBACK(on_properties_changed), self);
 | 
					            G_CALLBACK(on_properties_changed), self);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (proxy->ayatana_request && proxy->valid) {
 | 
					    if (proxy->upower_request && proxy->valid) {
 | 
				
			||||||
        const char* status = org_ayatana_indicator_power_battery_get_power_level(proxy->ayatana_request);
 | 
					        gdouble level = org_freedesktop_upower_device_get_percentage(proxy->upower_request);
 | 
				
			||||||
        mce_battery_status_update(self, status);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        u_int32_t level = org_ayatana_indicator_power_battery_get_power_percentage(proxy->ayatana_request);
 | 
					 | 
				
			||||||
        mce_battery_level_update(self, level);
 | 
					        mce_battery_level_update(self, level);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,7 +45,18 @@
 | 
				
			|||||||
#define MCE_CHARGER_STATE_UNKNOWN   "unknown"
 | 
					#define MCE_CHARGER_STATE_UNKNOWN   "unknown"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Generated headers */
 | 
					/* Generated headers */
 | 
				
			||||||
#include "org.ayatana.indicator.power.Battery.h"
 | 
					#include "org.freedesktop.UPower.Device.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enum upower_state {
 | 
				
			||||||
 | 
					    UPOWER_STATE_UNKNOWN,
 | 
				
			||||||
 | 
					    UPOWER_STATE_CHARGING,
 | 
				
			||||||
 | 
					    UPOWER_STATE_DISCHARGING,
 | 
				
			||||||
 | 
					    UPOWER_STATE_EMPTY,
 | 
				
			||||||
 | 
					    UPOWER_STATE_FULLY_CHARGED,
 | 
				
			||||||
 | 
					    UPOWER_STATE_PENDING_CHARGE,
 | 
				
			||||||
 | 
					    UPOWER_STATE_PENDING_DISCHARGE,
 | 
				
			||||||
 | 
					    UPOWER_STATE_COUNT
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct mce_charger_priv {
 | 
					struct mce_charger_priv {
 | 
				
			||||||
    MceProxy* proxy;
 | 
					    MceProxy* proxy;
 | 
				
			||||||
@@ -102,6 +113,24 @@ mce_charger_state_update(
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void
 | 
				
			||||||
 | 
					mce_charger_update_charging_state (
 | 
				
			||||||
 | 
					    MceCharger* self,
 | 
				
			||||||
 | 
					    enum upower_state state)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    gboolean discharging;
 | 
				
			||||||
 | 
					    switch (state) {
 | 
				
			||||||
 | 
					      case UPOWER_STATE_CHARGING:
 | 
				
			||||||
 | 
					      case UPOWER_STATE_FULLY_CHARGED:
 | 
				
			||||||
 | 
					        discharging = 0;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      default:
 | 
				
			||||||
 | 
					        discharging = 1;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    mce_charger_state_update(self, discharging ? MCE_CHARGER_STATE_OFF : MCE_CHARGER_STATE_ON);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void
 | 
					static void
 | 
				
			||||||
on_properties_changed (GDBusProxy          *proxy,
 | 
					on_properties_changed (GDBusProxy          *proxy,
 | 
				
			||||||
                       GVariant            *changed_properties,
 | 
					                       GVariant            *changed_properties,
 | 
				
			||||||
@@ -115,10 +144,10 @@ on_properties_changed (GDBusProxy          *proxy,
 | 
				
			|||||||
  g_variant_iter_init (&iter, changed_properties);
 | 
					  g_variant_iter_init (&iter, changed_properties);
 | 
				
			||||||
  while (g_variant_iter_next (&iter, "{&sv}", &key, &value))
 | 
					  while (g_variant_iter_next (&iter, "{&sv}", &key, &value))
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!g_strcmp0(key, "IsDischarging")) {
 | 
					        if (!g_strcmp0(key, "State")) {
 | 
				
			||||||
            gboolean state;
 | 
					            enum upower_state state;
 | 
				
			||||||
            g_variant_get (value, "b", &state);
 | 
					            g_variant_get (value, "u", &state);
 | 
				
			||||||
            mce_charger_state_update(MCE_CHARGER(user_data), state ? MCE_CHARGER_STATE_OFF : MCE_CHARGER_STATE_ON);
 | 
					            mce_charger_update_charging_state(MCE_CHARGER(user_data), state);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      g_variant_unref (value);
 | 
					      g_variant_unref (value);
 | 
				
			||||||
@@ -139,14 +168,14 @@ mce_charger_state_query(
 | 
				
			|||||||
     * for the valid signal before we can connect the charger state
 | 
					     * for the valid signal before we can connect the charger state
 | 
				
			||||||
     * signal and submit the initial query.
 | 
					     * signal and submit the initial query.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if (proxy->ayatana_request && !priv->charger_state_ind_id) {
 | 
					    if (proxy->upower_request && !priv->charger_state_ind_id) {
 | 
				
			||||||
        priv->charger_state_ind_id = g_signal_connect(proxy->ayatana_request, "g-properties-changed",
 | 
					        priv->charger_state_ind_id = g_signal_connect(proxy->upower_request, "g-properties-changed",
 | 
				
			||||||
                G_CALLBACK(on_properties_changed), self);
 | 
					                G_CALLBACK(on_properties_changed), self);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (proxy->ayatana_request && proxy->valid) {
 | 
					    if (proxy->upower_request && proxy->valid) {
 | 
				
			||||||
        gboolean state = org_ayatana_indicator_power_battery_get_is_discharging(proxy->ayatana_request);
 | 
					        enum upower_state state = org_freedesktop_upower_device_get_state(proxy->upower_request);
 | 
				
			||||||
        mce_charger_state_update(self, state ? MCE_CHARGER_STATE_OFF : MCE_CHARGER_STATE_ON);
 | 
					        mce_charger_update_charging_state(self, state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -274,7 +303,7 @@ mce_charger_finalize(
 | 
				
			|||||||
    MceChargerPriv* priv = self->priv;
 | 
					    MceChargerPriv* priv = self->priv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (priv->charger_state_ind_id) {
 | 
					    if (priv->charger_state_ind_id) {
 | 
				
			||||||
        g_signal_handler_disconnect(priv->proxy->ayatana_request,
 | 
					        g_signal_handler_disconnect(priv->proxy->upower_request,
 | 
				
			||||||
            priv->charger_state_ind_id);
 | 
					            priv->charger_state_ind_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    mce_proxy_remove_handler(priv->proxy, priv->proxy_valid_id);
 | 
					    mce_proxy_remove_handler(priv->proxy, priv->proxy_valid_id);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,18 +39,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* Generated headers */
 | 
					/* Generated headers */
 | 
				
			||||||
#include "com.canonical.Unity.Screen.h"
 | 
					#include "com.canonical.Unity.Screen.h"
 | 
				
			||||||
#include "org.ayatana.indicator.power.Battery.h"
 | 
					#include "org.freedesktop.UPower.Device.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
GLOG_MODULE_DEFINE("mce");
 | 
					GLOG_MODULE_DEFINE("mce");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct mce_proxy_priv {
 | 
					struct mce_proxy_priv {
 | 
				
			||||||
    GDBusConnection* bus;
 | 
					    GDBusConnection* bus;
 | 
				
			||||||
    GDBusConnection* session_bus;
 | 
					 | 
				
			||||||
    guint mce_watch_id;
 | 
					    guint mce_watch_id;
 | 
				
			||||||
    guint ayatana_watch_id;
 | 
					    guint upower_watch_id;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    gboolean unity_valid;
 | 
					    gboolean unity_valid;
 | 
				
			||||||
    gboolean ayatana_valid;
 | 
					    gboolean upower_valid;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum mce_proxy_signal {
 | 
					enum mce_proxy_signal {
 | 
				
			||||||
@@ -63,8 +62,8 @@ enum mce_proxy_signal {
 | 
				
			|||||||
#define MCE_SERVICE "com.canonical.Unity.Screen"
 | 
					#define MCE_SERVICE "com.canonical.Unity.Screen"
 | 
				
			||||||
#define MCE_REQUEST_PATH "/com/canonical/Unity/Screen"
 | 
					#define MCE_REQUEST_PATH "/com/canonical/Unity/Screen"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define AYATANA_SERVICE "org.ayatana.indicator.power"
 | 
					#define UPOWER_SERVICE "org.freedesktop.UPower"
 | 
				
			||||||
#define AYATANA_REQUEST_PATH "/org/ayatana/indicator/power/Battery"
 | 
					#define UPOWER_REQUEST_PATH "/org/freedesktop/UPower/devices/DisplayDevice"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static guint mce_proxy_signals[SIGNAL_COUNT] = { 0 };
 | 
					static guint mce_proxy_signals[SIGNAL_COUNT] = { 0 };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -120,9 +119,9 @@ mce_proxy_init_check(
 | 
				
			|||||||
            MCE_SERVICE, G_BUS_NAME_WATCHER_FLAGS_NONE,
 | 
					            MCE_SERVICE, G_BUS_NAME_WATCHER_FLAGS_NONE,
 | 
				
			||||||
            mce_name_appeared, mce_name_vanished, self, NULL);
 | 
					            mce_name_appeared, mce_name_vanished, self, NULL);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (self->ayatana_request && !priv->ayatana_watch_id) {
 | 
					    if (self->upower_request && !priv->upower_watch_id) {
 | 
				
			||||||
        priv->ayatana_watch_id = g_bus_watch_name_on_connection(priv->session_bus,
 | 
					        priv->upower_watch_id = g_bus_watch_name_on_connection(priv->bus,
 | 
				
			||||||
            AYATANA_SERVICE, G_BUS_NAME_WATCHER_FLAGS_NONE,
 | 
					            UPOWER_SERVICE, G_BUS_NAME_WATCHER_FLAGS_NONE,
 | 
				
			||||||
            mce_name_appeared, mce_name_vanished, self, NULL);
 | 
					            mce_name_appeared, mce_name_vanished, self, NULL);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -150,7 +149,7 @@ mce_proxy_request_proxy_new_finished(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static
 | 
					static
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
mce_proxy_request_proxy_session_new_finished(
 | 
					mce_proxy_request_proxy_upower_new_finished(
 | 
				
			||||||
    GObject* object,
 | 
					    GObject* object,
 | 
				
			||||||
    GAsyncResult* result,
 | 
					    GAsyncResult* result,
 | 
				
			||||||
    gpointer arg)
 | 
					    gpointer arg)
 | 
				
			||||||
@@ -158,12 +157,12 @@ mce_proxy_request_proxy_session_new_finished(
 | 
				
			|||||||
    MceProxy* self = MCE_PROXY(arg);
 | 
					    MceProxy* self = MCE_PROXY(arg);
 | 
				
			||||||
    GError* error = NULL;
 | 
					    GError* error = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GASSERT(!self->ayatana_request);
 | 
					    GASSERT(!self->upower_request);
 | 
				
			||||||
    self->ayatana_request = org_ayatana_indicator_power_battery_proxy_new_finish(result, &error);
 | 
					    self->upower_request = org_freedesktop_upower_device_proxy_new_finish(result, &error);
 | 
				
			||||||
    if (self->ayatana_request) {
 | 
					    if (self->upower_request) {
 | 
				
			||||||
        mce_proxy_init_check(self);
 | 
					        mce_proxy_init_check(self);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        GERR("Failed to initialize MCE ayatana request proxy: %s", GERRMSG(error));
 | 
					        GERR("Failed to initialize MCE upower request proxy: %s", GERRMSG(error));
 | 
				
			||||||
        g_error_free(error);
 | 
					        g_error_free(error);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    mce_proxy_unref(self);
 | 
					    mce_proxy_unref(self);
 | 
				
			||||||
@@ -187,6 +186,11 @@ mce_proxy_bus_get_finished(
 | 
				
			|||||||
            MCE_SERVICE, MCE_REQUEST_PATH, NULL,
 | 
					            MCE_SERVICE, MCE_REQUEST_PATH, NULL,
 | 
				
			||||||
            mce_proxy_request_proxy_new_finished,
 | 
					            mce_proxy_request_proxy_new_finished,
 | 
				
			||||||
            mce_proxy_ref(self));
 | 
					            mce_proxy_ref(self));
 | 
				
			||||||
 | 
					        org_freedesktop_upower_device_proxy_new(priv->bus,
 | 
				
			||||||
 | 
					            G_DBUS_PROXY_FLAGS_NONE,
 | 
				
			||||||
 | 
					            UPOWER_SERVICE, UPOWER_REQUEST_PATH, NULL,
 | 
				
			||||||
 | 
					            mce_proxy_request_proxy_upower_new_finished,
 | 
				
			||||||
 | 
					            mce_proxy_ref(self));
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        GERR("Failed to attach to system bus: %s", GERRMSG(error));
 | 
					        GERR("Failed to attach to system bus: %s", GERRMSG(error));
 | 
				
			||||||
        g_error_free(error);
 | 
					        g_error_free(error);
 | 
				
			||||||
@@ -194,31 +198,6 @@ mce_proxy_bus_get_finished(
 | 
				
			|||||||
    mce_proxy_unref(self);
 | 
					    mce_proxy_unref(self);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static
 | 
					 | 
				
			||||||
void
 | 
					 | 
				
			||||||
mce_proxy_session_bus_get_finished(
 | 
					 | 
				
			||||||
    GObject* object,
 | 
					 | 
				
			||||||
    GAsyncResult* result,
 | 
					 | 
				
			||||||
    gpointer arg)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    MceProxy* self = MCE_PROXY(arg);
 | 
					 | 
				
			||||||
    MceProxyPriv* priv = self->priv;
 | 
					 | 
				
			||||||
    GError* error = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    priv->session_bus = g_bus_get_finish(result, &error);
 | 
					 | 
				
			||||||
    if (priv->session_bus) {
 | 
					 | 
				
			||||||
        org_ayatana_indicator_power_battery_proxy_new(priv->session_bus,
 | 
					 | 
				
			||||||
            G_DBUS_PROXY_FLAGS_NONE,
 | 
					 | 
				
			||||||
            AYATANA_SERVICE, AYATANA_REQUEST_PATH, NULL,
 | 
					 | 
				
			||||||
            mce_proxy_request_proxy_session_new_finished,
 | 
					 | 
				
			||||||
            mce_proxy_ref(self));
 | 
					 | 
				
			||||||
    } else{
 | 
					 | 
				
			||||||
        GERR("Failed to attach to session bus: %s", GERRMSG(error));
 | 
					 | 
				
			||||||
        g_error_free(error);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    mce_proxy_unref(self);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
MceProxy*
 | 
					MceProxy*
 | 
				
			||||||
mce_proxy_new()
 | 
					mce_proxy_new()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -233,8 +212,6 @@ mce_proxy_new()
 | 
				
			|||||||
        mce_proxy_instance = g_object_new(MCE_PROXY_TYPE, NULL);
 | 
					        mce_proxy_instance = g_object_new(MCE_PROXY_TYPE, NULL);
 | 
				
			||||||
        g_bus_get(G_BUS_TYPE_SYSTEM, NULL, mce_proxy_bus_get_finished,
 | 
					        g_bus_get(G_BUS_TYPE_SYSTEM, NULL, mce_proxy_bus_get_finished,
 | 
				
			||||||
            mce_proxy_ref(mce_proxy_instance));
 | 
					            mce_proxy_ref(mce_proxy_instance));
 | 
				
			||||||
        g_bus_get(G_BUS_TYPE_SESSION, NULL, mce_proxy_session_bus_get_finished,
 | 
					 | 
				
			||||||
            mce_proxy_ref(mce_proxy_instance));
 | 
					 | 
				
			||||||
        g_object_add_weak_pointer(G_OBJECT(mce_proxy_instance),
 | 
					        g_object_add_weak_pointer(G_OBJECT(mce_proxy_instance),
 | 
				
			||||||
            (gpointer*)(&mce_proxy_instance));
 | 
					            (gpointer*)(&mce_proxy_instance));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -300,21 +277,18 @@ mce_proxy_finalize(
 | 
				
			|||||||
    if (priv->mce_watch_id) {
 | 
					    if (priv->mce_watch_id) {
 | 
				
			||||||
        g_bus_unwatch_name(priv->mce_watch_id);
 | 
					        g_bus_unwatch_name(priv->mce_watch_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (priv->ayatana_watch_id) {
 | 
					    if (priv->upower_watch_id) {
 | 
				
			||||||
        g_bus_unwatch_name(priv->ayatana_watch_id);
 | 
					        g_bus_unwatch_name(priv->upower_watch_id);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (self->unity_request) {
 | 
					    if (self->unity_request) {
 | 
				
			||||||
        g_object_unref(self->unity_request);
 | 
					        g_object_unref(self->unity_request);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (self->ayatana_request) {
 | 
					    if (self->upower_request) {
 | 
				
			||||||
        g_object_unref(self->ayatana_request);
 | 
					        g_object_unref(self->upower_request);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (priv->bus) {
 | 
					    if (priv->bus) {
 | 
				
			||||||
        g_object_unref(priv->bus);
 | 
					        g_object_unref(priv->bus);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    if (priv->session_bus) {
 | 
					 | 
				
			||||||
        g_object_unref(priv->session_bus);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
 | 
					    G_OBJECT_CLASS(PARENT_CLASS)->finalize(object);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,14 +43,14 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
typedef struct mce_proxy_priv MceProxyPriv;
 | 
					typedef struct mce_proxy_priv MceProxyPriv;
 | 
				
			||||||
struct _ComCanonicalUnityScreen;
 | 
					struct _ComCanonicalUnityScreen;
 | 
				
			||||||
struct _OrgAyatanaIndicatorPowerBattery;
 | 
					struct _OrgFreedesktopUPowerDevice;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef struct mce_proxy {
 | 
					typedef struct mce_proxy {
 | 
				
			||||||
    GObject object;
 | 
					    GObject object;
 | 
				
			||||||
    MceProxyPriv* priv;
 | 
					    MceProxyPriv* priv;
 | 
				
			||||||
    gboolean valid;
 | 
					    gboolean valid;
 | 
				
			||||||
    struct _ComCanonicalUnityScreen* unity_request;
 | 
					    struct _ComCanonicalUnityScreen* unity_request;
 | 
				
			||||||
    struct _OrgAyatanaIndicatorPowerBattery* ayatana_request;
 | 
					    struct _OrgFreedesktopUPowerDevice* upower_request;
 | 
				
			||||||
} MceProxy;
 | 
					} MceProxy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef void
 | 
					typedef void
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user