Commit Graph

63 Commits

Author SHA1 Message Date
Ryan Lortie
3160bcad6a GDBusConnection.call(): add 'reply_type' argument
This allows the caller to specify the reply type that they are expecting
for this call.  If the reply comes back with the wrong type, GDBus will
generate an appropriate error internally.

  - add a GVariantType * argument to g_dbus_connection_call() and
    _call_sync().

  - move the internal API for computing message types from introspection
    data to be based on GVariantType instead of strings.  Update users
    of this code.

  - have GDBusProxy pass this calculated GVariantType into
    g_dbus_connection_call().  Remove the checks done in GDBusProxy.

  - Update other users of the code (test cases, gdbus-tool, GSettings
    tool, etc).  In some cases, remove redundant checks; in some other
    cases, we are fixing bugs because no checking was done where it
    should have been.

Closes bug #619391.
2010-05-24 17:00:04 -04:00
David Zeuthen
a621e0ed10 gdbus(1): Don't fetch props if introspection data indicates none are available
Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-17 11:08:53 -04:00
David Zeuthen
4baf104f0a GDBus: Fix a double free
Fix an unintentional double free introduced in commit
4ad4c306c3.

This bug manifested itself when trying to complete this

 $ gdbus introspect --system --dest <tab>
2010-05-14 20:52:15 -04:00
Matthias Clasen
1d22b64843 Cleanups
Sort #includes a bit better, and don't include platform-specific
headers in gio.h.
2010-05-14 08:38:07 -04:00
Christian Persch
4ad4c306c3 Plug some mem leaks
g_variant_get (v, "s", &str) returns a string copy; use "&s" instead.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-13 16:43:41 -04:00
David Zeuthen
60e7ae26af GDBus: Add GDBusAuthObserver param in g_dbus_connection_new_for_address()
This is to match g_dbus_connection_new(). This extension allows us to
extend GDBusAuthObserver to also be used in client-side authentication
in the future (right now it's only used on the server-side).
2010-05-13 16:32:11 -04:00
David Zeuthen
ea1e0496b0 GDBus: add 'monitor' verb to gdbus(1)
This uncovered a bug in name watching if the name wasn't activatable.

Also provoked the need for on_connection variants of g_bus_watch_name
(added g_bus_watch_proxy's variant as well).
2010-05-12 23:12:14 -04:00
David Zeuthen
9695c23d4c GDBus: Make gdbus(1) print annotations when introspecting data
Also make the gdbus-example-server include some example
annotations. The output looks like this:

$ gdbus introspect --session --dest org.gtk.GDBus.TestServer --object-path /org/gtk/GDBus/TestObject
node /org/gtk/GDBus/TestObject {
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface_name,
          in  s property_name,
          out v value);
      GetAll(in  s interface_name,
             out a{sv} properties);
      Set(in  s interface_name,
          in  s property_name,
          in  v value);
    signals:
      PropertiesChanged(s interface_name,
                        a{sv} changed_properties);
  };
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s xml_data);
  };
  interface org.freedesktop.DBus.Peer {
    methods:
      Ping();
      GetMachineId(out s machine_uuid);
  };
  @org.gtk.GDBus.Annotation("OnInterface")
  @org.gtk.GDBus.Annotation("AlsoOnInterface")
  interface org.gtk.GDBus.TestInterface {
    methods:
      @org.gtk.GDBus.Annotation("OnMethod")
      HelloWorld(in  s greeting,
                 out s response);
      EmitSignal(@org.gtk.GDBus.Annotation.("OnArg")
                 in  d speed_in_mph);
      GimmeStdout();
    signals:
      @org.gtk.GDBus.Annotation("Onsignal")
      VelocityChanged(d speed_in_mph,
                      @org.gtk.GDBus.Annotation.("OnArg_NonFirst")
                      s speed_as_string);
    properties:
      @org.gtk.GDBus.Annotation("OnProperty")
        @org.gtk.GDBus.Annotation("OnAnnotation_YesThisIsCrazy")
      readonly s FluxCapicitorName = 'DeLorean';
      readwrite s Title = 'Back To C!';
      readonly s ReadingAlwaysThrowsError;
      readwrite s WritingAlwaysThrowsError = "There's no home like home";
      writeonly s OnlyWritable;
      readonly s Foo = 'Tick';
      readonly s Bar = 'Tock';
  };
};
2010-05-12 22:11:18 -04:00
David Zeuthen
2d208c9d36 GDBus: In gdbus(1), try Get() if GetAll() fails
This fixes a problem with services that doesn't implement GetAll() for
one reason or another.

$ gdbus introspect --session --dest org.freedesktop.ReserveDevice1.Audio0 --object-path /org/freedesktop/ReserveDevice1/Audio0
node /org/freedesktop/ReserveDevice1/Audio0 {
  interface org.freedesktop.ReserveDevice1 {
    methods:
      RequestRelease(in  i priority,
                     out b result);
    properties:
      readonly i Priority = 0;
      readonly s ApplicationName = 'PulseAudio Sound Server';
      readonly s ApplicationDeviceName = 'Internal Audio Analog Stereo';
  };
  interface org.freedesktop.DBus.Properties {
    methods:
      Get(in  s interface,
          in  s property,
          out v value);
  };
  interface org.freedesktop.DBus.Introspectable {
    methods:
      Introspect(out s data);
  };
};
2010-05-10 16:20:59 -04:00
David Zeuthen
869b4c6833 GDBus: Use call() instead of invoke_method()
Lots of people been suggesting this. We still use MethodInvocation /
method_invocation for handling incoming method calls so use call()
instead of invoke_method() helps to separate the client and server
facilities. Which is a good thing(tm).
2010-05-10 11:47:08 -04:00
Matthias Clasen
0cf467c2ca Update copyright years to include 2010 2010-05-09 13:14:55 -04:00
David Zeuthen
fb1b4599a0 GDBus: Fix up i18n 2010-05-06 16:34:23 -04:00
David Zeuthen
d0a14469d0 Initial GDBus code-drop from GDBus-standalone repo
Things compile and the test-suite passes. Still need to hook up
gio.symbols and docs. There are still a bunch of TODOs left in the
sources that needs to be addressed.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-06 14:21:32 -04:00