...
 
Commits (55)
image: fedora:rawhide
variables:
DEPENDENCIES: libtool gtk-doc autoconf automake gettext-devel
gcc redhat-rpm-config gcc-c++ glibc-devel make
systemd sqlite-devel gobject-introspection-devel
libusbx-devel libgudev-devel libimobiledevice-devel
glib2-devel
umockdev python3-dbus python3-dbusmock
build_stable:
before_script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
script:
- mkdir _build
- cd _build
- ../autogen.sh
- make
- make install
- make check
- make distcheck
Common Cure Rights Commitment, version 1.0
Before filing or continuing to prosecute any legal proceeding or claim
(other than a Defensive Action) arising from termination of a Covered
License, we commit to extend to the person or entity ('you') accused
of violating the Covered License the following provisions regarding
cure and reinstatement, taken from GPL version 3. As used here, the
term 'this License' refers to the specific Covered License being
enforced.
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly
and finally terminates your license, and (b) permanently, if the
copyright holder fails to notify you of the violation by some
reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you
have received notice of violation of this License (for any work)
from that copyright holder, and you cure the violation prior to 30
days after your receipt of the notice.
We intend this Commitment to be irrevocable, and binding and
enforceable against us and assignees of or successors to our
copyrights.
Definitions
'Covered License' means the GNU General Public License, version 2
(GPLv2), the GNU Lesser General Public License, version 2.1
(LGPLv2.1), or the GNU Library General Public License, version 2
(LGPLv2), all as published by the Free Software Foundation.
'Defensive Action' means a legal proceeding or claim that We bring
against you in response to a prior proceeding or claim initiated by
you or your affiliate.
'We' means each contributor to this repository as of the date of
inclusion of this file, including subsidiaries of a corporate
contributor.
This work is available under a Creative Commons Attribution-ShareAlike
4.0 International license.
......@@ -52,7 +52,7 @@ pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = upower-glib.pc
# xsltproc barfs on 'make distcheck'; disable for now
DISTCHECK_CONFIGURE_FLAGS=--disable-man-pages --enable-gtk-doc \
DISTCHECK_CONFIGURE_FLAGS=--enable-man-pages --enable-gtk-doc \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \
--with-udevrulesdir='$${libdir}/udev/rules.d-distcheck'
......
Version 0.99.10
~~~~~~~~~~~~~~~
Released: 2019-02-20
Bugfixes:
- Set 'pending-charge' for DisplayDevice if at least one
battery is in the 'pending-charge' state
- Map pending-charge to fully-charged when charge is 100%
Version 0.99.9
~~~~~~~~~~~~~~
Released: 2018-10-25
Bugfixes:
- Fix lack of update after AC status changes, and broken keyboard
backlight, following the daemon lockdown added in 0.99.8
- Multiple API documentation fixes
- Out-of-tree build fixes
Version 0.99.8
~~~~~~~~~~~~~~
Released: 2018-06-18
New Features:
- Lock down systemd service file
- Add support for "Unknown" capacity level, and clarify handling
of devices with coarse battery levels
- Add a new version of up_client_get_devices() which unrefs contents
Bugfixes:
- Fix warnings when D-Bus related properties change
- Prevent crash after attaching an Apple TV, and support newer
versions of iOS
- Lower severity of "unhandled action" messages
- Fix battery status on MacBooks after a plug or unplug event
- Fix double-close on exit
Version 0.99.7
~~~~~~~~~~~~~~
Released: 2017-11-28
......
......@@ -13,21 +13,14 @@ if test -z $AUTORECONF; then
exit 1
fi
INTLTOOLIZE=`which intltoolize`
if test -z $INTLTOOLIZE; then
echo "*** No intltoolize found, please install the intltool package ***"
exit 1
fi
GTKDOCIZE=`which gtkdocize`
if test -z $GTKDOCIZE; then
echo "*** No GTK-Doc found, please install it ***"
exit 1
fi
gtkdocize
autopoint --force
AUTOPOINT='intltoolize --automake --copy' autoreconf --force --install --verbose
gtkdocize --copy || exit 1
autoreconf --verbose --force --install || exit 1
cd $olddir
test -n "$NOCONFIGURE" || "$srcdir/configure" "$@"
......
This project and its community follow the [Freedesktop.org code of conduct]
[Freedesktop.org code of conduct]: https://www.freedesktop.org/wiki/CodeOfConduct/
......@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
m4_define([up_major_version], [0])
m4_define([up_minor_version], [99])
m4_define([up_micro_version], [8])
m4_define([up_micro_version], [11])
m4_define([up_version],
[up_major_version.up_minor_version.up_micro_version])
......@@ -152,7 +152,7 @@ AX_CHECK_LINK_FLAG([-Wl,-z,relro,-z,now],
[RELRO_LDFLAGS="-Wl,-z,relro,-z,now"])
AC_SUBST([RELRO_LDFLAGS])
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.34.0 gobject-2.0])
PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.38.0 gobject-2.0])
PKG_CHECK_MODULES(GIO, [gio-2.0 >= 2.16.1])
PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0])
......@@ -229,9 +229,7 @@ if test "x$GCC" = "xyes"; then
fi
# i18n support
IT_PROG_INTLTOOL([0.40.0])
AM_GNU_GETTEXT_VERSION([0.17])
AM_GNU_GETTEXT_VERSION([0.19.8])
AM_GNU_GETTEXT([external])
AC_SUBST([GETTEXT_PACKAGE],[${PACKAGE_TARNAME}])
......@@ -253,7 +251,6 @@ tools/Makefile
doc/Makefile
doc/version.xml
doc/man/Makefile
doc/dbus/Makefile
rules/Makefile
libupower-glib/Makefile
libupower-glib/up-version.h
......
......@@ -336,6 +336,12 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
<doc:term>8</doc:term><doc:definition>Phone</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>
......@@ -745,7 +751,8 @@ method return sender=:1.386 -> dest=:1.477 reply_serial=2
<doc:doc>
<doc:description>
<doc:para>
An icon name, following the <a href="http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html">Icon Naming Specification</a>
<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>
......
SUBDIRS = man dbus
SUBDIRS = man
NULL =
......@@ -12,7 +12,7 @@ DOC_MODULE=UPower
DOC_MAIN_SGML_FILE=upower-docs.xml
# Extra options to supply to gtkdoc-scan
SCAN_OPTIONS=--ignore-headers=config.h
SCAN_OPTIONS=--ignore-headers=config.h --rebuild-types --rebuild-sections
# The directory containing the source code. Relative to $(srcdir)
DOC_SOURCE_DIR=../libupower-glib
......@@ -50,15 +50,40 @@ MKDB_OPTIONS=--sgml-mode --output-format=xml
# Extra options to supply to gtkdoc-mktmpl
MKTMPL_OPTIONS=
org.freedesktop.UPower.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.xml $(top_srcdir)/doc/spec-to-docbook.xsl
if $(AM_V_P); then set -x; else echo " GEN $@"; fi
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/spec-to-docbook.xsl $< | tail -n +2 >> $@
org.freedesktop.UPower.Device.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.Device.xml $(top_srcdir)/doc/spec-to-docbook.xsl
if $(AM_V_P); then set -x; else echo " GEN $@"; fi
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/spec-to-docbook.xsl $< | tail -n +2 >> $@
org.freedesktop.UPower.KbdBacklight.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.KbdBacklight.xml $(top_srcdir)/doc/spec-to-docbook.xsl
if $(AM_V_P); then set -x; else echo " GEN $@"; fi
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/spec-to-docbook.xsl $< | tail -n +2 >> $@
org.freedesktop.UPower.Wakeups.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.Wakeups.xml $(top_srcdir)/doc/spec-to-docbook.xsl
if $(AM_V_P); then set -x; else echo " GEN $@"; fi
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/spec-to-docbook.xsl $< | tail -n +2 >> $@
EXTRA_DIST = spec-to-docbook.xsl dbus-introspect-docs.dtd
BUILT_SOURCES = \
org.freedesktop.UPower.ref.xml \
org.freedesktop.UPower.Device.ref.xml \
org.freedesktop.UPower.KbdBacklight.ref.xml
# Non-autogenerated SGML files to be included in $(DOC_MAIN_SGML_FILE)
content_files = \
version.xml \
man/upower.xml \
man/upowerd.xml \
man/UPower.xml \
dbus/org.freedesktop.UPower.ref.xml \
dbus/org.freedesktop.UPower.Device.ref.xml \
dbus/org.freedesktop.UPower.KbdBacklight.ref.xml \
$(BUILT_SOURCES) \
$(NULL)
# Images to copy into HTML directory
......@@ -84,8 +109,6 @@ DISTCLEANFILES = \
if ENABLE_GTK_DOC
include $(top_srcdir)/gtk-doc.make
else
EXTRA_DIST =
endif
# Version information for marking the documentation
......
all : org.freedesktop.UPower.ref.xml org.freedesktop.UPower.Device.ref.xml org.freedesktop.UPower.KbdBacklight.ref.xml org.freedesktop.UPower.Wakeups.ref.xml
org.freedesktop.UPower.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.xml $(top_srcdir)/doc/dbus/spec-to-docbook.xsl
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/dbus/spec-to-docbook.xsl $< | tail -n +2 >> $@
org.freedesktop.UPower.Device.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.Device.xml $(top_srcdir)/doc/dbus/spec-to-docbook.xsl
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/dbus/spec-to-docbook.xsl $< | tail -n +2 >> $@
org.freedesktop.UPower.KbdBacklight.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.KbdBacklight.xml $(top_srcdir)/doc/dbus/spec-to-docbook.xsl
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/dbus/spec-to-docbook.xsl $< | tail -n +2 >> $@
org.freedesktop.UPower.Wakeups.ref.xml : $(top_srcdir)/dbus/org.freedesktop.UPower.Wakeups.xml $(top_srcdir)/doc/dbus/spec-to-docbook.xsl
echo "<?xml version=\"1.0\"?>""<!DOCTYPE refentry PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\" \"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd\">" > $@
$(XSLTPROC) $(top_srcdir)/doc/dbus/spec-to-docbook.xsl $< | tail -n +2 >> $@
EXTRA_DIST = spec-to-docbook.xsl dbus-introspect-docs.dtd
MAINTAINERCLEANFILES = *.ref.xml
clean-local :
rm -f *~ *.ref.xml
-include $(top_srcdir)/git.mk
......@@ -64,9 +64,9 @@
UPower daemon.
</para>
</partintro>
<xi:include href="dbus/org.freedesktop.UPower.ref.xml"/>
<xi:include href="dbus/org.freedesktop.UPower.Device.ref.xml"/>
<xi:include href="dbus/org.freedesktop.UPower.KbdBacklight.ref.xml"/>
<xi:include href="org.freedesktop.UPower.ref.xml"/>
<xi:include href="org.freedesktop.UPower.Device.ref.xml"/>
<xi:include href="org.freedesktop.UPower.KbdBacklight.ref.xml"/>
</reference>
<reference id="libupower-glib">
......
......@@ -4,6 +4,7 @@ AM_CPPFLAGS = \
-I$(top_builddir) \
-I$(top_srcdir) \
-I$(top_srcdir)/dbus \
-I$(top_builddir)/dbus \
-I$(top_srcdir)/libupower-glib \
-DUP_COMPILATION \
-DG_LOG_DOMAIN=\"libupower-glib\" \
......@@ -53,6 +54,7 @@ libupower_glib_la_LDFLAGS = \
-export-symbols-regex '^up_.*'
libupower_glib_la_CFLAGS = \
$(AM_CPPFLAGS) \
$(WARNINGFLAGS_C) \
$(NULL)
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-client
* @short_description: Main client object for accessing the UPower daemon
* @see_also: #UpDevice
*
* A helper GObject to use for accessing UPower information, and to be notified
* when it is changed.
*
* See also: #UpDevice
*/
#include "config.h"
......@@ -44,8 +43,6 @@ static void up_client_initable_iface_init (GInitableIface *iface);
static void up_client_init (UpClient *client);
static void up_client_finalize (GObject *object);
#define UP_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_CLIENT, UpClientPrivate))
/**
* UpClientPrivate:
*
......@@ -74,6 +71,7 @@ enum {
static guint signals [UP_CLIENT_LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT,
G_ADD_PRIVATE(UpClient)
G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, up_client_initable_iface_init))
/**
......@@ -152,7 +150,7 @@ up_client_get_devices2 (UpClient *client)
* @client: a #UpClient instance.
*
* Get the composite display device.
* Return value: (transfer full): a #UpClient object, or %NULL on error.
* Return value: (transfer full): a #UpDevice object, or %NULL on error.
*
* Since: 1.0
**/
......@@ -452,8 +450,6 @@ up_client_class_init (UpClientClass *klass)
G_STRUCT_OFFSET (UpClientClass, device_removed),
NULL, NULL, g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (UpClientPrivate));
}
/*
......@@ -464,7 +460,7 @@ static gboolean
up_client_initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
{
UpClient *client = UP_CLIENT (initable);
client->priv = UP_CLIENT_GET_PRIVATE (client);
client->priv = up_client_get_instance_private (client);
/* connect to main interface */
client->priv->proxy = up_exported_daemon_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
......@@ -525,7 +521,7 @@ up_client_finalize (GObject *object)
* @error: Return location for error or %NULL.
*
* Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
% this returns %NULL and sets @error.
* this returns %NULL and sets @error.
*
* Return value: a new UpClient object, or %NULL on failure.
*
......
......@@ -44,15 +44,15 @@ G_BEGIN_DECLS
typedef struct _UpClientPrivate UpClientPrivate;
typedef struct
{
typedef struct {
GObject parent;
UpClientPrivate *priv;
} UpClient;
typedef struct
{
typedef struct {
/*< private >*/
GObjectClass parent_class;
/*< public >*/
void (*device_added) (UpClient *client,
UpDevice *device);
void (*device_removed) (UpClient *client,
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-device
* @short_description: Client object for accessing information about UPower devices
* @see_also: #UpClient
*
* A helper GObject to use for accessing UPower devices, and to be notified
* when it is changed.
*
* See also: #UpClient
*/
#include "config.h"
......@@ -45,8 +44,6 @@ static void up_device_class_init (UpDeviceClass *klass);
static void up_device_init (UpDevice *device);
static void up_device_finalize (GObject *object);
#define UP_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE, UpDevicePrivate))
/**
* UpDevicePrivate:
*
......@@ -95,7 +92,7 @@ enum {
PROP_LAST
};
G_DEFINE_TYPE (UpDevice, up_device, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpDevice, up_device, G_TYPE_OBJECT)
/*
* up_device_changed_cb:
......@@ -1203,8 +1200,6 @@ up_device_class_init (UpDeviceClass *klass)
g_param_spec_string ("icon-name",
NULL, NULL, NULL,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpDevicePrivate));
}
static void
......@@ -1220,7 +1215,7 @@ value_free (GValue *value)
static void
up_device_init (UpDevice *device)
{
device->priv = UP_DEVICE_GET_PRIVATE (device);
device->priv = up_device_get_instance_private (device);
device->priv->offline_props = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
......
......@@ -44,16 +44,14 @@ G_BEGIN_DECLS
typedef struct _UpDevicePrivate UpDevicePrivate;
typedef struct
{
typedef struct {
GObject parent;
UpDevicePrivate *priv;
} UpDevice;
typedef struct
{
GObjectClass parent_class;
typedef struct {
/*< private >*/
GObjectClass parent_class;
/* Padding for future expansion */
void (*_up_device_reserved1) (void);
void (*_up_device_reserved2) (void);
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-history-item
* @short_description: Helper object representing one item of historical data.
* @see_also: #UpDevice, #UpClient
*
* This object represents one item of data which may be returned from the
* daemon in response to a query.
*
* See also: #UpDevice, #UpClient
*/
#include "config.h"
......@@ -40,8 +39,6 @@ static void up_history_item_class_init (UpHistoryItemClass *klass);
static void up_history_item_init (UpHistoryItem *history_item);
static void up_history_item_finalize (GObject *object);
#define UP_HISTORY_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_HISTORY_ITEM, UpHistoryItemPrivate))
struct UpHistoryItemPrivate
{
gdouble value;
......@@ -57,7 +54,7 @@ enum {
PROP_LAST
};
G_DEFINE_TYPE (UpHistoryItem, up_history_item, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpHistoryItem, up_history_item, G_TYPE_OBJECT)
/**
* up_history_item_set_value:
......@@ -322,8 +319,6 @@ up_history_item_class_init (UpHistoryItemClass *klass)
0, G_MAXUINT,
UP_DEVICE_STATE_UNKNOWN,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpHistoryItemPrivate));
}
/**
......@@ -332,7 +327,7 @@ up_history_item_class_init (UpHistoryItemClass *klass)
static void
up_history_item_init (UpHistoryItem *history_item)
{
history_item->priv = UP_HISTORY_ITEM_GET_PRIVATE (history_item);
history_item->priv = up_history_item_get_instance_private (history_item);
}
/**
......
......@@ -40,14 +40,12 @@ G_BEGIN_DECLS
typedef struct UpHistoryItemPrivate UpHistoryItemPrivate;
typedef struct
{
typedef struct {
GObject parent;
UpHistoryItemPrivate *priv;
} UpHistoryItem;
typedef struct
{
typedef struct {
GObjectClass parent_class;
} UpHistoryItemClass;
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-stats-item
* @short_description: Helper object representing one item of statistics data.
* @see_also: #UpDevice, #UpClient
*
* This object represents one item of data which may be returned from the
* daemon in response to a query.
*
* See also: #UpDevice, #UpClient
*/
#include "config.h"
......@@ -39,8 +38,6 @@ static void up_stats_item_class_init (UpStatsItemClass *klass);
static void up_stats_item_init (UpStatsItem *stats_item);
static void up_stats_item_finalize (GObject *object);
#define UP_STATS_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_STATS_ITEM, UpStatsItemPrivate))
struct UpStatsItemPrivate
{
gdouble value;
......@@ -54,7 +51,7 @@ enum {
PROP_LAST
};
G_DEFINE_TYPE (UpStatsItem, up_stats_item, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpStatsItem, up_stats_item, G_TYPE_OBJECT)
/**
* up_stats_item_set_value:
......@@ -194,8 +191,6 @@ up_stats_item_class_init (UpStatsItemClass *klass)
g_param_spec_double ("accuracy", NULL, NULL,
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpStatsItemPrivate));
}
/**
......@@ -205,7 +200,7 @@ up_stats_item_class_init (UpStatsItemClass *klass)
static void
up_stats_item_init (UpStatsItem *stats_item)
{
stats_item->priv = UP_STATS_ITEM_GET_PRIVATE (stats_item);
stats_item->priv = up_stats_item_get_instance_private (stats_item);
}
/**
......
......@@ -39,14 +39,12 @@ G_BEGIN_DECLS
typedef struct UpStatsItemPrivate UpStatsItemPrivate;
typedef struct
{
typedef struct {
GObject parent;
UpStatsItemPrivate *priv;
} UpStatsItem;
typedef struct
{
typedef struct {
GObjectClass parent_class;
} UpStatsItemClass;
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-types
* @short_description: Types used by UPower and libupower-glib
* @see_also: #UpClient, #UpDevice
*
* These helper functions provide a way to marshal enumerated values to
* text and back again.
*
* See also: #UpClient, #UpDevice
*/
#include "config.h"
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-version
* @short_description: Obtains the version for the installed UPower
* @see_also: #UpClient, #UpDevice
*
* These compile time macros allow the user to enable parts of client code
* depending on the version of libupower-glib installed.
*
* See also: #UpClient, #UpDevice
*/
#if !defined (__UPOWER_H_INSIDE__) && !defined (UP_COMPILATION)
......
......@@ -22,11 +22,10 @@
/**
* SECTION:up-wakeup-item
* @short_description: Helper object representing one item of wakeup data.
* @see_also: #UpDevice, #UpClient
*
* This object represents one item of data which may be returned from the
* daemon in response to a query.
*
* See also: #UpDevice, #UpClient
*/
#include "config.h"
......@@ -39,8 +38,6 @@ static void up_wakeup_item_class_init (UpWakeupItemClass *klass);
static void up_wakeup_item_init (UpWakeupItem *wakeup_item);
static void up_wakeup_item_finalize (GObject *object);
#define UP_WAKEUP_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_WAKEUP_ITEM, UpWakeupItemPrivate))
struct UpWakeupItemPrivate
{
gboolean is_userspace;
......@@ -62,7 +59,7 @@ enum {
PROP_LAST
};
G_DEFINE_TYPE (UpWakeupItem, up_wakeup_item, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpWakeupItem, up_wakeup_item, G_TYPE_OBJECT)
/**
* up_wakeup_item_get_is_userspace:
......@@ -410,8 +407,6 @@ up_wakeup_item_class_init (UpWakeupItemClass *klass)
g_param_spec_string ("details", NULL, NULL,
NULL,
G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (UpWakeupItemPrivate));
}
/**
......@@ -421,7 +416,7 @@ up_wakeup_item_class_init (UpWakeupItemClass *klass)
static void
up_wakeup_item_init (UpWakeupItem *wakeup_item)
{
wakeup_item->priv = UP_WAKEUP_ITEM_GET_PRIVATE (wakeup_item);
wakeup_item->priv = up_wakeup_item_get_instance_private (wakeup_item);
}
/**
......
......@@ -40,14 +40,12 @@ G_BEGIN_DECLS
typedef struct UpWakeupItemPrivate UpWakeupItemPrivate;
typedef struct
{
typedef struct {
GObject parent;
UpWakeupItemPrivate *priv;
} UpWakeupItem;
typedef struct
{
typedef struct {
GObjectClass parent_class;
} UpWakeupItemClass;
......
......@@ -32,8 +32,6 @@ static void up_wakeups_class_init (UpWakeupsClass *klass);
static void up_wakeups_init (UpWakeups *wakeups);
static void up_wakeups_finalize (GObject *object);
#define UP_WAKEUPS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_WAKEUPS, UpWakeupsPrivate))
struct UpWakeupsPrivate
{
UpExportedWakeups *proxy;
......@@ -47,7 +45,7 @@ enum {
static guint signals [UP_WAKEUPS_LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (UpWakeups, up_wakeups, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpWakeups, up_wakeups, G_TYPE_OBJECT)
/**
* up_wakeups_get_total_sync:
......@@ -233,8 +231,6 @@ up_wakeups_class_init (UpWakeupsClass *klass)
G_STRUCT_OFFSET (UpWakeupsClass, data_changed),
NULL, NULL, g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
g_type_class_add_private (klass, sizeof (UpWakeupsPrivate));
}
/**
......@@ -245,7 +241,7 @@ up_wakeups_init (UpWakeups *wakeups)
{
GError *error = NULL;
wakeups->priv = UP_WAKEUPS_GET_PRIVATE (wakeups);
wakeups->priv = up_wakeups_get_instance_private (wakeups);
/* connect to main interface */
wakeups->priv->proxy = up_exported_wakeups_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
......
......@@ -22,11 +22,10 @@
/**
* SECTION:upower
* @short_description: Client objects for accessing UPower
* @see_also: #UpClient, #UpDevice
*
* These objects allow client programs to trivially get details about the power
* state, and about devices on the system.
*
* See also: #UpClient, #UpDevice
*/
#ifndef __UPOWER_H__
......
Makefile.in.in
POTFILES
stamp-it
.intltool-merge-cache
*.pot
*.gmo
# Makefile variables for PO directory in any package using GNU gettext.
# Usually the message domain is the same as the package name.
DOMAIN = $(PACKAGE)
# These two variables depend on the location of this directory.
subdir = po
top_builddir = ..
# These options get passed to xgettext.
XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments
# This is the copyright holder that gets inserted into the header of the
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
# package. (Note that the msgstr strings, extracted from the package's
# sources, belong to the copyright holder of the package.) Translators are
# expected to transfer the copyright for their translations to this person
# or entity, or to disclaim their copyright. The empty string stands for
# the public domain; in this case the translators are expected to disclaim
# their copyright.
COPYRIGHT_HOLDER = The UPower authors.
# This tells whether or not to prepend "GNU " prefix to the package
# name that gets inserted into the header of the $(DOMAIN).pot file.
# Possible values are "yes", "no", or empty. If it is empty, try to
# detect it automatically by scanning the files in $(top_srcdir) for
# "GNU packagename" string.
PACKAGE_GNU = no
# This is the email address or URL to which the translators shall report
# bugs in the untranslated strings:
# - Strings which are not entire sentences, see the maintainer guidelines
# in the GNU gettext documentation, section 'Preparing Strings'.
# - Strings which use unclear terms or require additional context to be
# understood.
# - Strings which make invalid assumptions about notation of date, time or
# money.
# - Pluralisation problems.
# - Incorrect English spelling.
# - Incorrect formatting.
# It can be your email address, or a mailing list address where translators
# can write to without being subscribed, or the URL of a web page through
# which the translators can contact you.
MSGID_BUGS_ADDRESS = https://gitlab.freedesktop.org/upower/upower/issues
# This is the list of locale categories, beyond LC_MESSAGES, for which the
# message catalogs shall be used. It is usually empty.
EXTRA_LOCALE_CATEGORIES =
# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
# context. Possible values are "yes" and "no". Set this to yes if the
# package uses functions taking also a message context, like pgettext(), or
# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
USE_MSGCTXT = yes
# These options get passed to msgmerge.
# Useful options are in particular:
# --previous to keep previous msgids of translated messages,
# --quiet to reduce the verbosity.
MSGMERGE_OPTIONS =
# These options get passed to msginit.
# If you want to disable line wrapping when writing PO files, add
# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
# MSGINIT_OPTIONS.
MSGINIT_OPTIONS =
# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
# has changed. Possible values are "yes" and "no". Set this to no if
# the POT file is checked in the repository and the version control
# program ignores timestamps.
PO_DEPENDS_ON_POT = no
# This tells whether or not to forcibly update $(DOMAIN).pot and
# regenerate PO files on "make dist". Possible values are "yes" and
# "no". Set this to no if the POT file and PO files are maintained
# externally.
DIST_DEPENDS_ON_UPDATE_PO = no
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
src/up-main.c
tools/up-tool.c
......@@ -19,17 +19,3 @@ ATTR{idVendor}=="046d", ATTR{idProduct}=="c512", ENV{UPOWER_PRODUCT}="Keyboard+M
ATTR{idVendor}=="046d", ATTR{idProduct}=="c702", ENV{UPOWER_PRODUCT}="Presenter", ENV{UPOWER_BATTERY_TYPE}="mouse"
LABEL="up_csr_end"
# Unifying HID++ devices
SUBSYSTEM!="hid", GOTO="up_unifying_end"
# Kernel provides the battery information already
ATTRS{idVendor}=="046d", TEST=="builtin_power_supply", GOTO="up_unifying_end"
ATTRS{idVendor}=="046d", ENV{UPOWER_VENDOR}="Logitech, Inc."
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", DRIVER=="logitech-djdevice", ENV{UPOWER_BATTERY_TYPE}="unifying"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c532", DRIVER=="logitech-djdevice", ENV{UPOWER_BATTERY_TYPE}="unifying"
# These devices bind to the hid-logitech-hidpp module since Linux 3.19
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52b", DRIVER=="logitech-hidpp-device", ENV{UPOWER_BATTERY_TYPE}="unifying"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c532", DRIVER=="logitech-hidpp-device", ENV{UPOWER_BATTERY_TYPE}="unifying"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f", ENV{UPOWER_BATTERY_TYPE}="lg-wireless"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c531", ENV{UPOWER_BATTERY_TYPE}="lg-wireless"
LABEL="up_unifying_end"
##############################################################################################################
# Unifying HID++ devices
SUBSYSTEM!="hid", GOTO="up_unifying_end"
# Kernel provides the battery information already
ATTRS{idVendor}=="046d", TEST=="builtin_power_supply", GOTO="up_unifying_end"
ATTRS{idVendor}=="046d", ENV{UPOWER_VENDOR}="Logitech, Inc."
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c52f", ENV{UPOWER_BATTERY_TYPE}="lg-wireless"
ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c531", ENV{UPOWER_BATTERY_TYPE}="lg-wireless"
LABEL="up_unifying_end"
......@@ -3,7 +3,8 @@
udevrules_DATA = \
95-upower-wup.rules \
95-upower-hid.rules \
95-upower-csr.rules
95-upower-csr.rules \
95-upower-hidpp.rules
EXTRA_DIST = \
$(udevrules_DATA)
......
......@@ -15,6 +15,7 @@ AM_CPPFLAGS = \
$(PIE_CFLAGS) \
-I$(top_builddir)/src -I$(top_srcdir)/src \
-I$(top_builddir)/ -I$(top_srcdir)/ \
-DUPOWER_CONF_PATH=\""$(top_srcdir)/etc/UPower.conf"\" \
-DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
-DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
......@@ -162,7 +163,7 @@ dbusservice_DATA = $(dbusservice_in_files:.service.in=.service)
$(dbusservice_DATA): $(dbusservice_in_files) Makefile
@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@
dbusconfdir = $(sysconfdir)/dbus-1/system.d
dbusconfdir = $(datadir)/dbus-1/system.d
dbusconf_in_files = org.freedesktop.UPower.conf.in
dbusconf_DATA = $(dbusconf_in_files:.conf.in=.conf)
......
......@@ -35,8 +35,6 @@ static void up_backend_class_init (UpBackendClass *klass);
static void up_backend_init (UpBackend *backend);
static void up_backend_finalize (GObject *object);
#define UP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_BACKEND, UpBackendPrivate))
struct UpBackendPrivate
{
UpDaemon *daemon;
......@@ -57,7 +55,7 @@ enum {
static guint signals [SIGNAL_LAST] = { 0 };
G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpBackend, up_backend, G_TYPE_OBJECT)
#ifdef EGG_TEST
/**
......@@ -194,8 +192,6 @@ up_backend_class_init (UpBackendClass *klass)
G_STRUCT_OFFSET (UpBackendClass, device_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
g_type_class_add_private (klass, sizeof (UpBackendPrivate));
}
/**
......@@ -204,7 +200,7 @@ up_backend_class_init (UpBackendClass *klass)
static void
up_backend_init (UpBackend *backend)
{
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv = up_backend_get_instance_private (backend);
backend->priv->daemon = NULL;
backend->priv->device_list = NULL;
#ifdef EGG_TEST
......
......@@ -54,8 +54,6 @@ static gboolean up_backend_acpi_devd_notify (UpBackend *backend, const gchar *sy
static gboolean up_backend_create_new_device (UpBackend *backend, UpAcpiNative *native);
static void up_backend_lid_coldplug (UpBackend *backend);
#define UP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_BACKEND, UpBackendPrivate))
struct UpBackendPrivate
{
UpDaemon *daemon;
......@@ -74,7 +72,7 @@ enum {
static guint signals [SIGNAL_LAST] = { 0 };
G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpBackend, up_backend, G_TYPE_OBJECT)
static const gchar *handlers[] = {
"battery",
......@@ -404,8 +402,6 @@ up_backend_class_init (UpBackendClass *klass)
G_STRUCT_OFFSET (UpBackendClass, device_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
g_type_class_add_private (klass, sizeof (UpBackendPrivate));
}
/**
......@@ -414,7 +410,7 @@ up_backend_class_init (UpBackendClass *klass)
static void
up_backend_init (UpBackend *backend)
{
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv = up_backend_get_instance_private (backend);
backend->priv->handle_map = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
backend->priv->config = up_config_new ();
backend->priv->seat_manager_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
......
......@@ -42,6 +42,7 @@ libupshared_la_SOURCES = \
up-input.c \
up-input.h \
up-backend.c \
up-backend-linux-private.h \
up-native.c \
hidpp-device.c \
hidpp-device.h \
......@@ -75,4 +76,10 @@ libupshared_la_LIBADD = $(GIO_LIBS)
clean-local :
rm -f *~
uninstall-hook:
rm -f $(DESTDIR)$(localstatedir)/lib/upower/history-* && \
rmdir $(DESTDIR)$(localstatedir)/lib/upower && \
rmdir $(DESTDIR)$(localstatedir)/lib && \
rmdir $(DESTDIR)$(localstatedir)
-include $(top_srcdir)/git.mk
......@@ -163,8 +163,7 @@ typedef struct {
gchar *name;
} HidppDeviceMap;
G_DEFINE_TYPE (HidppDevice, hidpp_device, G_TYPE_OBJECT)
#define HIDPP_DEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), HIDPP_TYPE_DEVICE, HidppDevicePrivate))
G_DEFINE_TYPE_WITH_PRIVATE (HidppDevice, hidpp_device, G_TYPE_OBJECT)
/**
* hidpp_is_error:
......@@ -1033,7 +1032,7 @@ hidpp_device_init (HidppDevice *device)
{
HidppDeviceMap *map;
device->priv = HIDPP_DEVICE_GET_PRIVATE (device);
device->priv = hidpp_device_get_instance_private (device);
device->priv->fd = -1;
device->priv->feature_index = g_ptr_array_new_with_free_func (hidpp_device_free_feature);
device->priv->batt_status = HIDPP_DEVICE_BATT_STATUS_UNKNOWN;
......@@ -1089,7 +1088,6 @@ hidpp_device_class_init (HidppDeviceClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = hidpp_device_finalize;
g_type_class_add_private (klass, sizeof (HidppDevicePrivate));
}
/**
......
This diff is collapsed.
......@@ -43,23 +43,31 @@
#include "sysfs-utils.h"
double
sysfs_get_double_with_error (const char *dir, const char *attribute)
gboolean
sysfs_get_double_with_error (const char *dir,
const char *attribute,
double *value)
{
double result;
char *contents;
char *filename;
gboolean ret = FALSE;
double parsed;
g_return_val_if_fail (value != NULL, FALSE);
filename = g_build_filename (dir, attribute, NULL);
if (g_file_get_contents (filename, &contents, NULL, NULL)) {
result = g_ascii_strtod (contents, NULL);
parsed = g_ascii_strtod (contents, NULL);
if (errno == 0)
ret = TRUE;
g_free (contents);
} else {
result = -1.0;
}
g_free (filename);
return result;
if (ret)
*value = parsed;
return ret;
}
double
......@@ -77,7 +85,6 @@ sysfs_get_double (const char *dir, const char *attribute)
}
g_free (filename);
return result;
}
......
......@@ -28,6 +28,8 @@ char *sysfs_get_string (const char *dir, const char *attribute);
int sysfs_get_int (const char *dir, const char *attribute);
gboolean sysfs_get_bool (const char *dir, const char *attribute);
gboolean sysfs_file_exists (const char *dir, const char *attribute);
double sysfs_get_double_with_error (const char *dir, const char *attribute);
gboolean sysfs_get_double_with_error (const char *dir,
const char *attribute,
double *value);
#endif /* __SYSFS_UTILS_H__ */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2018 Bastien Nocera <hadess@hadess.net>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __UP_BACKEND_LINUX_PRIVATE_H
#define __UP_BACKEND_LINUX_PRIVATE_H
#include <glib.h>
gboolean up_backend_needs_poll_after_uevent (void);
#endif /* __UP_BACKEND_LINUX_PRIVATE_H */
......@@ -31,9 +31,12 @@
#include <gudev/gudev.h>
#include "up-backend.h"
#include "up-backend-linux-private.h"
#include "up-daemon.h"
#include "up-device.h"
#include "sysfs-utils.h"
#include "up-device-supply.h"
#include "up-device-csr.h"
#include "up-device-unifying.h"
......@@ -54,8 +57,6 @@ static void up_backend_finalize (GObject *object);
#define LOGIND_DBUS_PATH "/org/freedesktop/login1"
#define LOGIND_DBUS_INTERFACE "org.freedesktop.login1.Manager"
#define UP_BACKEND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_BACKEND, UpBackendPrivate))
struct UpBackendPrivate
{
UpDaemon *daemon;
......@@ -80,7 +81,7 @@ enum {
static guint signals [SIGNAL_LAST] = { 0 };
G_DEFINE_TYPE (UpBackend, up_backend, G_TYPE_OBJECT)
G_DEFINE_TYPE_WITH_PRIVATE (UpBackend, up_backend, G_TYPE_OBJECT)
static gboolean up_backend_device_add (UpBackend *backend, GUdevDevice *native);
static void up_backend_device_remove (UpBackend *backend, GUdevDevice *native);
......@@ -277,6 +278,28 @@ up_backend_uevent_signal_handler_cb (GUdevClient *client, const gchar *action,
}
}
static gpointer
is_macbook (gpointer data)
{
char *product;
gboolean ret = FALSE;
product = sysfs_get_string ("/sys/devices/virtual/dmi/id/", "product_name");
if (product == NULL)
return GINT_TO_POINTER(ret);
ret = g_str_has_prefix (product, "MacBook");
g_free (product);
return GINT_TO_POINTER(ret);
}
gboolean
up_backend_needs_poll_after_uevent (void)
{
static GOnce dmi_once = G_ONCE_INIT;
g_once (&dmi_once, is_macbook, NULL);
return GPOINTER_TO_INT(dmi_once.retval);
}
static gboolean
is_battery_iface_proxy (GDBusProxy *interface_proxy)
{
......@@ -780,8 +803,6 @@ up_backend_class_init (UpBackendClass *klass)
G_STRUCT_OFFSET (UpBackendClass, device_removed),
NULL, NULL, NULL,
G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
g_type_class_add_private (klass, sizeof (UpBackendPrivate));
}
static void
......@@ -790,7 +811,7 @@ up_backend_init (UpBackend *backend)
GDBusConnection *bus;
guint sleep_id;
backend->priv = UP_BACKEND_GET_PRIVATE (backend);
backend->priv = up_backend_get_instance_private (backend);
backend->priv->config = up_config_new ();
backend->priv->managed_devices = up_device_list_new ();
backend->priv->logind_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
......
......@@ -28,7 +28,6 @@
#include "up-device-bluez.h"
G_DEFINE_TYPE (UpDeviceBluez, up_device_bluez, UP_TYPE_DEVICE)
#define UP_DEVICE_BLUEZ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_BLUEZ, UpDeviceBluezPrivate))
static UpDeviceKind
appearance_to_kind (guint16 appearance)
......
......@@ -60,8 +60,7 @@ struct UpDeviceCsrPrivate
libusb_device *device;
};
G_DEFINE_TYPE (UpDeviceCsr, up_device_csr, UP_TYPE_DEVICE)
#define UP_DEVICE_CSR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_CSR, UpDeviceCsrPrivate))
G_DEFINE_TYPE_WITH_PRIVATE (UpDeviceCsr, up_device_csr, UP_TYPE_DEVICE)
static gboolean up_device_csr_refresh (UpDevice *device);
......@@ -291,7 +290,7 @@ static void
up_device_csr_init (UpDeviceCsr *csr)
{
gint retval;
csr->priv = UP_DEVICE_CSR_GET_PRIVATE (csr);
csr->priv = up_device_csr_get_instance_private (csr);
csr->priv->raw_value = -1;
retval = libusb_init (&csr->priv->ctx);
......@@ -332,8 +331,6 @@ up_device_csr_class_init (UpDeviceCsrClass *klass)
object_class->finalize = up_device_csr_finalize;
device_class->coldplug = up_device_csr_coldplug;
device_class->refresh = up_device_csr_refresh;
g_type_class_add_private (klass, sizeof (UpDeviceCsrPrivate));
}
/**
......
......@@ -90,8 +90,7 @@ struct UpDeviceHidPrivate
int fd;
};
G_DEFINE_TYPE (UpDeviceHid, up_device_hid, UP_TYPE_DEVICE)
#define UP_DEVICE_HID_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_HID, UpDeviceHidPrivate))
G_DEFINE_TYPE_WITH_PRIVATE (UpDeviceHid, up_device_hid, UP_TYPE_DEVICE)
static gboolean up_device_hid_refresh (UpDevice *device);
......@@ -180,7 +179,7 @@ up_device_hid_convert_device_technology (const gchar *type)
* up_device_hid_set_values:
**/
static gboolean
up_device_hid_set_values (UpDeviceHid *hid, int code, int value)
up_device_hid_set_values (UpDeviceHid *hid, guint32 code, gint32 value)
{
const gchar *type;
gboolean ret = TRUE;
......@@ -470,7 +469,7 @@ up_device_hid_get_on_battery (UpDevice *device, gboolean *on_battery)
static void
up_device_hid_init (UpDeviceHid *hid)
{
hid->priv = UP_DEVICE_HID_GET_PRIVATE (hid);
hid->priv = up_device_hid_get_instance_private (hid);
hid->priv->fd = -1;
hid->priv->poll_timer_id = g_timeout_add_seconds (UP_DEVICE_HID_REFRESH_TIMEOUT,
(GSourceFunc) up_device_hid_poll, hid);
......@@ -512,8 +511,6 @@ up_device_hid_class_init (UpDeviceHidClass *klass)
device_class->coldplug = up_device_hid_coldplug;
device_class->get_on_battery = up_device_hid_get_on_battery;
device_class->refresh = up_device_hid_refresh;
g_type_class_add_private (klass, sizeof (UpDeviceHidPrivate));
}
/**
......
......@@ -48,8 +48,7 @@ struct UpDeviceIdevicePrivate
lockdownd_client_t client;
};
G_DEFINE_TYPE (UpDeviceIdevice, up_device_idevice, UP_TYPE_DEVICE)
#define UP_DEVICE_IDEVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_IDEVICE, UpDeviceIdevicePrivate))
G_DEFINE_TYPE_WITH_PRIVATE (UpDeviceIdevice, up_device_idevice, UP_TYPE_DEVICE)
static gboolean up_device_idevice_refresh (UpDevice *device);
......@@ -347,7 +346,7 @@ out:
static void
up_device_idevice_init (UpDeviceIdevice *idevice)
{
idevice->priv = UP_DEVICE_IDEVICE_GET_PRIVATE (idevice);
idevice->priv = up_device_idevice_get_instance_private (idevice);
}
/**
......@@ -390,8 +389,6 @@ up_device_idevice_class_init (UpDeviceIdeviceClass *klass)
object_class->finalize = up_device_idevice_finalize;
device_class->coldplug = up_device_idevice_coldplug;
device_class->refresh = up_device_idevice_refresh;
g_type_class_add_private (klass, sizeof (UpDeviceIdevicePrivate));
}
/**
......
......@@ -38,6 +38,7 @@
#include "up-types.h"
#include "up-constants.h"
#include "up-device-supply.h"
#include "up-backend-linux-private.h"
#define UP_DEVICE_SUPPLY_CHARGED_THRESHOLD 90.0f /* % */
......@@ -63,15 +64,19 @@ struct UpDeviceSupplyPrivate
guint energy_old_first;
gdouble rate_old;
guint unknown_retries;
gint64 last_unknown_retry;
gboolean disable_battery_poll; /* from configuration */
gboolean is_power_supply;
gboolean shown_invalid_voltage_warning;
};
G_DEFINE_TYPE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE)
#define UP_DEVICE_SUPPLY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UP_TYPE_DEVICE_SUPPLY, UpDeviceSupplyPrivate))
G_DEFINE_TYPE_WITH_PRIVATE (UpDeviceSupply, up_device_supply, UP_TYPE_DEVICE)
static gboolean up_device_supply_refresh (UpDevice *device);
static void up_device_supply_setup_unknown_poll (UpDevice *device,
UpDeviceState state);
static UpDeviceKind up_device_supply_guess_type (GUdevDevice *native,
const char *native_path);
static RefreshResult
up_device_supply_refresh_line_power (UpDeviceSupply *supply)
......@@ -665,13 +670,6 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
}
state = up_device_supply_get_state (native_path);
*out_state = state;
/* reset unknown counter */
if (state != UP_DEVICE_STATE_UNKNOWN) {
g_debug ("resetting unknown timeout after %i retries", supply->priv->unknown_retries);
supply->priv->unknown_retries = 0;
}
/* this is the new value in uW */
energy_rate = fabs (sysfs_get_double (native_path, "power_now") / 1000000.0);
......@@ -735,6 +733,12 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
percentage = CLAMP(percentage, 0.0f, 100.0f);
}
/* Some devices report "Not charging" when the battery is full and AC
* power is connected. In this situation we should report fully-charged
* instead of pending-charge. */
if (state == UP_DEVICE_STATE_PENDING_CHARGE && percentage == 100.0)
state = UP_DEVICE_STATE_FULLY_CHARGED;
/* the battery isn't charging or discharging, it's just
* sitting there half full doing nothing: try to guess a state */
if (state == UP_DEVICE_STATE_UNKNOWN && supply->priv->is_power_supply) {
......@@ -835,6 +839,8 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
supply->priv->energy_old_first = 0;
}