Skip to content

migrate to gdbus - #421

Open
mbkma wants to merge 1 commit into
masterfrom
gdbus
Open

migrate to gdbus#421
mbkma wants to merge 1 commit into
masterfrom
gdbus

Conversation

@mbkma

@mbkma mbkma commented Mar 15, 2026

Copy link
Copy Markdown
Member

see GNOME/gnome-power-manager@7568769f for a reference, though this is not a 1:1 copy

please test thoroughly as I can not test it on real hardware right now.

see GNOME/gnome-power-manager@7568769f for a reference, though this is not a 1:1 copy
Comment thread src/gpm-main.c

error = NULL;
if (!gpm_manager_register_dbus (manager, session_connection, &error)) {
g_error ("Failed to export D-Bus objects: %s", error->message);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g_error causes a core dump, this should be g_warning

Comment thread src/gpm-manager.c
Comment on lines +125 to +129
!gpm_backlight_register_dbus (manager->priv->backlight, connection, error))
return FALSE;

if (manager->priv->kbd_backlight != NULL) {
gpm_kbd_backlight_register_dbus (manager->priv->kbd_backlight, connection, error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions (*_register_dbus) seem and behave somewhat similarly, but one returns void and the other gboolean, which means these two conditional blocks behave differently.

Comment thread src/gpm-networkmanager.c
Comment on lines -65 to +68
dbus_g_proxy_call_no_reply (nm_proxy, "sleep", G_TYPE_INVALID);

result = g_dbus_proxy_call_sync (nm_proxy,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.

Comment thread src/gpm-networkmanager.c
Comment on lines -99 to +120
dbus_g_proxy_call_no_reply (nm_proxy, "wake", G_TYPE_INVALID);

result = g_dbus_proxy_call_sync (nm_proxy,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.

Comment thread src/gpm-screensaver.c
Comment on lines -66 to +68
dbus_g_proxy_call_no_reply (screensaver->priv->proxy,
"Lock", G_TYPE_INVALID);
result = g_dbus_proxy_call_sync (screensaver->priv->proxy,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.

Comment thread src/gpm-screensaver.c
Comment on lines -218 to +253
dbus_g_proxy_call_no_reply (screensaver->priv->proxy,
"SimulateUserActivity",
G_TYPE_INVALID);
result = g_dbus_proxy_call_sync (screensaver->priv->proxy,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dbus_g_proxy_call_no_reply is async, but you're replacing it with the sync variant. You should use g_dbus_proxy_call.

Comment thread src/gpm-kbd-backlight.c
Comment on lines +153 to +183
gpm_kbd_backlight_register_dbus (GpmKbdBacklight *backlight,
GDBusConnection *connection,
GError **error)
{
GDBusNodeInfo *node_info;

g_return_if_fail (GPM_IS_KBD_BACKLIGHT (backlight));
g_return_if_fail (G_IS_DBUS_CONNECTION (connection));

if (backlight->priv->bus_connection != NULL)
return;

node_info = g_dbus_node_info_new_for_xml (gpm_kbd_backlight_introspection_xml, error);
if (node_info == NULL)
return;

backlight->priv->bus_object_id =
g_dbus_connection_register_object (connection,
GPM_DBUS_PATH_KBD_BACKLIGHT,
node_info->interfaces[0],
&gpm_kbd_backlight_interface_vtable,
backlight,
NULL,
error);
g_dbus_node_info_unref (node_info);

if (backlight->priv->bus_object_id == 0)
return;

backlight->priv->bus_connection = g_object_ref (connection);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: This entire function has some strange indentation issues

Comment thread src/gpm-main.c
dbus_g_error_domain_register (GPM_MANAGER_ERROR, NULL, GPM_MANAGER_TYPE_ERROR);
dbus_g_connection_register_g_object (connection, GPM_DBUS_PATH, object);
if (gpm_manager_node_info == NULL) {
gpm_manager_node_info = g_dbus_node_info_new_for_xml (gpm_manager_introspection_xml, &error);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be freed with g_dbus_node_info_unref, but since gpm_manager_node_info is a global static, it should probably be freed on process exit.

Comment thread src/gpm-screensaver.c
GS_LISTENER_PATH,
GS_LISTENER_INTERFACE);
screensaver->priv->proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GNOME uses G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS for these, not sure if it's better or not, but it seems like GNOME's version does fewer things. This might be related to the sync calls, so not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants