landry 2017-10-28 16:31:28 +00:00
parent be8e939613
commit d59d71a674
5 changed files with 8 additions and 189 deletions

View File

@ -1,11 +1,10 @@
# $OpenBSD: Makefile,v 1.53 2016/09/01 10:11:47 landry Exp $
# $OpenBSD: Makefile,v 1.54 2017/10/28 16:31:28 landry Exp $
ONLY_FOR_ARCHS =${APM_ARCHS}
COMMENT = userland power management interface
DISTNAME = upower-0.99.4
REVISION = 1
DISTNAME = upower-0.99.6
EXTRACT_SUFX = .tar.xz
CATEGORIES = sysutils
SHARED_LIBS += upower-glib 2.1 # 3.1

View File

@ -1,2 +1,2 @@
SHA256 (upower-0.99.4.tar.xz) = nKMlpszvUFUpsmjru9m+zQzmWmX2rH7jHi5bF2SAN7A=
SIZE (upower-0.99.4.tar.xz) = 426292
SHA256 (upower-0.99.6.tar.xz) = sZTR8iftM+dq4pqlwRrKutM0k48nJrjHkD+sB6EzUBU=
SIZE (upower-0.99.6.tar.xz) = 432056

View File

@ -1,151 +0,0 @@
$OpenBSD: patch-libupower-glib_up-client_c,v 1.5 2016/09/01 10:11:47 landry Exp $
Backport https://cgit.freedesktop.org/upower/patch/?id=932a6a39e35754be571e1274aec4730fd42dba13
https://bugs.freedesktop.org/show_bug.cgi?id=95350
--- libupower-glib/up-client.c.orig Wed Jul 29 14:47:49 2015
+++ libupower-glib/up-client.c Wed Aug 31 12:31:10 2016
@@ -39,9 +39,10 @@
#include "up-daemon-generated.h"
#include "up-device.h"
-static void up_client_class_init (UpClientClass *klass);
-static void up_client_init (UpClient *client);
-static void up_client_finalize (GObject *object);
+static void up_client_class_init (UpClientClass *klass);
+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))
@@ -73,7 +74,8 @@ enum {
static guint signals [UP_CLIENT_LAST_SIGNAL] = { 0 };
static gpointer up_client_object = NULL;
-G_DEFINE_TYPE (UpClient, up_client, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_CODE (UpClient, up_client, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, up_client_initable_iface_init))
/**
* up_client_get_devices:
@@ -434,11 +436,10 @@ up_client_class_init (UpClientClass *klass)
* up_client_init:
* @client: This class instance
*/
-static void
-up_client_init (UpClient *client)
+static gboolean
+up_client_initable_init (GInitable *initable, GCancellable *cancellable, GError **error)
{
- GError *error = NULL;
-
+ UpClient *client = UP_CLIENT (initable);
client->priv = UP_CLIENT_GET_PRIVATE (client);
/* connect to main interface */
@@ -446,13 +447,10 @@ up_client_init (UpClient *client)
G_DBUS_PROXY_FLAGS_NONE,
"org.freedesktop.UPower",
"/org/freedesktop/UPower",
- NULL,
- &error);
- if (client->priv->proxy == NULL) {
- g_warning ("Couldn't connect to proxy: %s", error->message);
- g_error_free (error);
- return;
- }
+ cancellable,
+ error);
+ if (client->priv->proxy == NULL)
+ return FALSE;
/* all callbacks */
g_signal_connect (client->priv->proxy, "device-added",
@@ -461,9 +459,26 @@ up_client_init (UpClient *client)
G_CALLBACK (up_device_removed_cb), client);
g_signal_connect (client->priv->proxy, "notify",
G_CALLBACK (up_client_notify_cb), client);
+
+ return TRUE;
}
+static void
+up_client_initable_iface_init (GInitableIface *iface)
+{
+ iface->init = up_client_initable_init;
+}
+
/*
+ * up_client_init:
+ * @client: This class instance
+ */
+static void
+up_client_init (UpClient *client)
+{
+}
+
+/*
* up_client_finalize:
*/
static void
@@ -482,23 +497,52 @@ up_client_finalize (GObject *object)
}
/**
- * up_client_new:
+ * up_client_new_full:
+ * @cancellable: (allow-none): A #GCancellable or %NULL.
+ * @error: Return location for error or %NULL.
*
- * Creates a new #UpClient object.
+ * Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
+ % this returns %NULL and sets @error.
*
- * Return value: a new UpClient object.
+ * Return value: a new UpClient object, or %NULL on failure.
*
- * Since: 0.9.0
+ * Since: 0.99.5
**/
UpClient *
-up_client_new (void)
+up_client_new_full (GCancellable *cancellable, GError **error)
{
if (up_client_object != NULL) {
g_object_ref (up_client_object);
} else {
- up_client_object = g_object_new (UP_TYPE_CLIENT, NULL);
- g_object_add_weak_pointer (up_client_object, &up_client_object);
+ up_client_object = g_initable_new (UP_TYPE_CLIENT, cancellable, error, NULL);
+ if (up_client_object)
+ g_object_add_weak_pointer (up_client_object, &up_client_object);
}
return UP_CLIENT (up_client_object);
+}
+
+/**
+ * up_client_new:
+ *
+ * Creates a new #UpClient object. If connecting to upowerd on D-Bus fails,
+ * this returns %NULL and prints out a warning with the error message.
+ * Consider using up_client_new_full() instead which allows you to handle errors
+ * and cancelling long operations yourself.
+ *
+ * Return value: a new UpClient object, or %NULL on failure.
+ *
+ * Since: 0.9.0
+ **/
+UpClient *
+up_client_new (void)
+{
+ GError *error = NULL;
+ UpClient *client;
+ client = up_client_new_full (NULL, &error);
+ if (client == NULL) {
+ g_warning ("Couldn't connect to proxy: %s", error->message);
+ g_error_free (error);
+ }
+ return client;
}

View File

@ -1,15 +0,0 @@
$OpenBSD: patch-libupower-glib_up-client_h,v 1.1 2016/09/01 10:11:47 landry Exp $
Backport https://cgit.freedesktop.org/upower/patch/?id=932a6a39e35754be571e1274aec4730fd42dba13
https://bugs.freedesktop.org/show_bug.cgi?id=95350
--- libupower-glib/up-client.h.orig Wed Apr 22 11:57:08 2015
+++ libupower-glib/up-client.h Wed Aug 31 12:31:10 2016
@@ -72,6 +72,7 @@ typedef struct
/* general */
GType up_client_get_type (void);
UpClient *up_client_new (void);
+UpClient *up_client_new_full (GCancellable *cancellable, GError **error);
/* sync versions */
UpDevice * up_client_get_display_device (UpClient *client);

View File

@ -1,13 +1,8 @@
$OpenBSD: patch-src_openbsd_up-backend_c,v 1.21 2016/08/29 08:40:38 jasper Exp $
$OpenBSD: patch-src_openbsd_up-backend_c,v 1.22 2017/10/28 16:31:28 landry Exp $
Add missing #include after https://cgit.freedesktop.org/upower/commit/?id=77239cc4470fc515e1c8c6c21005fa08f3b1b04e
Remove pointless upperbound, SENSOR_MAX_TYPES has no meaning here and we
break from the loop anyway when needed.
https://bugs.freedesktop.org/show_bug.cgi?id=95257
--- src/openbsd/up-backend.c.orig Wed Jul 29 14:47:49 2015
+++ src/openbsd/up-backend.c Wed May 4 10:44:04 2016
Index: src/openbsd/up-backend.c
--- src/openbsd/up-backend.c.orig
+++ src/openbsd/up-backend.c
@@ -24,6 +24,7 @@
#include "up-backend.h"
#include "up-daemon.h"
@ -16,12 +11,3 @@ https://bugs.freedesktop.org/show_bug.cgi?id=95257
#include <string.h> /* strcmp() */
static void up_backend_class_init (UpBackendClass *klass);
@@ -461,7 +462,7 @@ up_backend_update_lid_status(UpDaemon *daemon) {
/* go through all acpibtn devices, and check if one of the values match "lid"
if so, use that device.
*/
- for (dev = 0; SENSOR_MAX_TYPES; dev++) {
+ for (dev = 0; ; dev++) {
mib[2] = dev;
if (sysctl(mib, 3, &sensordev, &sdlen, NULL, 0) == -1) {
if (errno == ENXIO)