Re: Send a message using Gio::Dbus
- From: José Alburquerque <jaalburquerque gmail com>
- To: Yoann LE BARS <yoann le-bars net>
- Cc: gtkmm-list gnome org
- Subject: Re: Send a message using Gio::Dbus
- Date: Wed, 13 Mar 2013 17:47:05 -0400
On Sat, 2013-03-09 at 02:15 +0100, Yoann LE BARS wrote:
Hello everybody out there!
No, actually, what I have done does not work.
I have tried and make my code cleaner, including concerning messages it
send. To achieve this, I have changed the enumeration this way:
enum TypeConnexion {FREEDESKTOP, GNOME, NONE};
Then, I have changed initialisation of the proxy to this:
proxy =
Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SESSION,
"org.freedesktop.PowerManagement",
"org/freedesktop/PowerManagement",
"org.freedesktop.PowerManagement");
if (proxy) {
connectionType = FREEDESKTOP;
}
else {
std::ostringstream message;
message << "No Freedesktop type D-Bus connection available, "
<< "trying Gnome type.\n";
g_message(message.str().c_str());
proxy =
Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SESSION,
"org.gnome.SessionManager",
"/org/gnome/SessionManager",
"org.gnome.SessionManager");
if (proxy) {
connectionType = GNOME;
}
else {
g_message("No D-Bus connection available.");
connectionType = NONE;
}
}
Running it on Gnome 3, what I expect is failure while attempting to
connect to ["org.freedesktop.PowerManagement",
"org/freedesktop/PowerManagement", "org.freedesktop.PowerManagement"] ,
then outputting this message:
'No Freedesktop type D-Bus connection available, trying Gnome type.'
Then, the proxy should connect to ["org.gnome.SessionManager",
"/org/gnome/SessionManager", "org.gnome.SessionManager"] with success,
"connectionType" is set to "GNOME" and this is it.
Here is the output I get:
(tutoriel4:8403): GLib-GIO-CRITICAL **:
g_dbus_connection_signal_subscribe: assertion `object_path == NULL ||
g_variant_is_object_path (object_path)' failed
(tutoriel4:8403): GLib-GIO-CRITICAL **:
g_dbus_connection_signal_subscribe: assertion `object_path == NULL ||
g_variant_is_object_path (object_path)' failed
(tutoriel4:8403): GLib-GIO-CRITICAL **:
g_dbus_connection_call_sync_internal: assertion `object_path != NULL &&
g_variant_is_object_path (object_path)' failed
(tutoriel4:8403): GLib-GIO-CRITICAL **:
g_dbus_connection_call_sync_internal: assertion `object_path != NULL &&
g_variant_is_object_path (object_path)' failed
These warnings lead me to believe that there is a problem with how the
strings are being passed to the C API. I'll have to look into it.
I have tried and switch into full-screen mode (which implies to inhibit
screen-saver), then back to windowed mode (which implies to uninhibit
screen-saver).
I expected the first two messages: these are the result of attempting
to connect to an un-existing bus. But, clearly then the chosen
alternative is "if (proxy)" and connectionType is set to "FREEDESKTOP".
As a consequence, it then try and send request in Freedesktop mode,
which fails (the two last messages).
It seems to me that "proxy" is set whether connection succeeded or not.
This is the reason previously I had to use "if (!proxy)" to obtain the
desired results, but it was an error.
So it is all back to this question: does anyone know a way to determine
which connection is available?
Regards.
Yoann
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
https://mail.gnome.org/mailman/listinfo/gtkmm-list
--
José
--
José
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]