After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 622920 - Migrate from dbus-glib to glib's GDBus
Migrate from dbus-glib to glib's GDBus
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: general
SVN TRUNK
Other Linux
: Normal normal
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks: 622451 622871
 
 
Reported: 2010-06-27 11:35 UTC by André Klapper
Modified: 2010-10-28 12:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Port to GDBus (31.43 KB, patch)
2010-10-05 20:16 UTC, Giovanni Campagna
none Details | Review
Port to GDBus (31.52 KB, patch)
2010-10-07 14:58 UTC, Giovanni Campagna
none Details | Review
Port to GDBus (51.56 KB, patch)
2010-10-25 14:26 UTC, Giovanni Campagna
none Details | Review
Fix use of GVariant types and DBus signatures (2.12 KB, patch)
2010-10-27 20:41 UTC, Giovanni Campagna
none Details | Review

Description André Klapper 2010-06-27 11:35:14 UTC
For GLib 2.25.5 GDBus D-Bus support was merged, providing an API to replace dbus-glib.

See http://library.gnome.org/devel/gio/unstable/gdbus.html and http://library.gnome.org/devel/gio/unstable/ch28.html .

According to a quick grep this module seems to use dbus-glib:

./gnome-power-manager/configure.ac:  dbus-glib-1 >= 0.70
Comment 1 Richard Hughes 2010-06-27 12:42:52 UTC
It's on my TODO list. Help more than welcome. Thanks.
Comment 2 Giovanni Campagna 2010-10-05 20:16:59 UTC
Created attachment 171787 [details] [review]
Port to GDBus

Port completely and drop the dependency from dbus-glib to the new
GDBus API, preparing for DBus API additions soon.
Comment 3 Christian Persch 2010-10-05 20:36:22 UTC
Review of attachment 171787 [details] [review]:

::: src/gpm-backlight.c
@@ +661,3 @@
+			GPM_DBUS_INTERFACE_BACKLIGHT,
+			"BrightnessChanged",
+			g_variant_new ("u", percentage),

You need a tuple here, so "(u)".

@@ +705,3 @@
+			g_error_free (error);
+		} else {
+			g_dbus_method_invocation_return_value (invocation, g_variant_new ("u", value));

"(u)".

@@ +712,3 @@
+		GError *error;
+		guint value;
+		g_variant_get (parameters, "u", &value);

"(u)".

@@ +776,3 @@
+			self,
+			NULL,
+			NULL);

You can now unref node_info.

::: src/gpm-manager.c
@@ +2016,3 @@
+			NULL,
+			NULL);
+

Can now unref node_info.

::: src/gpm-phone.c
@@ +219,3 @@
+		guint number;
+
+		g_variant_get (parameters, "u", &number);

"(u)".

::: src/gpm-screensaver.c
@@ +252,3 @@
+	ret = g_dbus_proxy_call_sync (screensaver->priv->proxy,
+				 "UnThrottle",
+				 g_variant_new ("s", cookie),

"(s)".

@@ +301,3 @@
 
+	if (ret != NULL) {
+		g_variant_get (ret, "b", &active);

"(b)".
Comment 4 Richard Hughes 2010-10-06 09:16:40 UTC
Giovanni, I very much appreciate you working on this, thanks.
Comment 5 Giovanni Campagna 2010-10-07 14:58:30 UTC
Created attachment 171903 [details] [review]
Port to GDBus

Fixed
Comment 6 Richard Hughes 2010-10-09 07:51:19 UTC
Could you please split this into one patch per file please, so for instance the screensaver changes would be 0001, and the manager changes would be 0002, etc. Thanks. Then it's much easier to commit some bits and rework other bits.

Thanks.
Comment 7 Richard Hughes 2010-10-18 09:59:04 UTC
Giovanni, did you compile gpm with your patch? I've spent more than an hour on it already just to compile and fix up all the missing bits.

I'll post something here when I've got things working.

Richard.
Comment 8 Giovanni Campagna 2010-10-18 13:44:43 UTC
I tried compiling just now, but it seems to fail on unrelated Gtk changes (GtkComboBox). I am sure it compiled, back when I submitted it a week ago.
Comment 9 Giovanni Campagna 2010-10-25 14:26:50 UTC
Created attachment 173178 [details] [review]
Port to GDBus

Port completely and drop the dependency from dbus-glib to the new
GDBus API, preparing for DBus API additions soon.

Previous patch was incomplete, this one should work.
Comment 10 Richard Hughes 2010-10-26 09:13:57 UTC
I went a bit further and make a few source files go away. Thanks for all your help, appreciated.

commit 7568769fb1e46de1b8ed8601fe106df9b367bb45
Author: Richard Hughes <richard@hughsie.com>
Date:   Tue Oct 26 11:13:04 2010 +0100

    Migrate from dbus-glib to GDBus, based on a patch from Giovanni Campagna, many thanks
Comment 11 Richard Hughes 2010-10-27 09:15:58 UTC
commit 802bbba78f4f6143eea81a796abe374a4963a36b
Author: Richard Hughes <richard@hughsie.com>
Date:   Wed Oct 27 11:14:46 2010 +0100

    Add two methods to the DBus interface for gnome-shell
    
    These return a tuple, and a tuple array of the following:
    
    s  device_id
    u  type of device
    s  display device summary
    u  percentage charge
    u  device state
    u  time remaining until change or discharge
    
    All the enumerated values are from UPower.

:100644 100644 79bf84c... 120ca10... M  src/gpm-manager.c

commit a85e6cf90e385fe5174c95b9ed1b6387313bc4e5
Author: Richard Hughes <richard@hughsie.com>
Date:   Wed Oct 27 10:46:52 2010 +0100

    Add two properties to the DBus interface for gnome-shell

:100644 100644 c44872f... 79bf84c... M  src/gpm-manager.c
Comment 12 Giovanni Campagna 2010-10-27 20:39:39 UTC
Some minor fixes are still needed for this to work, as it currently asserts while building variants.
Patch coming.
Comment 13 Giovanni Campagna 2010-10-27 20:41:43 UTC
Created attachment 173350 [details] [review]
Fix use of GVariant types and DBus signatures

Prevent an assertion by using a GVariantBuilder for "as", and correctly
pass a guint when a "u" is expected instead of a "s"
Comment 14 Richard Hughes 2010-10-28 12:33:15 UTC
(In reply to comment #13)
> Created an attachment (id=173350) [details] [review]
> Fix use of GVariant types and DBus signatures
> 
> Prevent an assertion by using a GVariantBuilder for "as", and correctly
> pass a guint when a "u" is expected instead of a "s"

Applied. In the future, obviously correct patches like this please just commit without asking -- you know what you are doing. Thanks.