In doing so, ensure that g_option_context_set_ignore_unknown_options()
is always called if completion is being done.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=793597
In this situation:
$ gdbus emit --session --object-path /org/foo/bar --sig<tab><tab><tab>
We will currently insert --signal three times.
We should only do that once.
https://bugzilla.gnome.org/show_bug.cgi?id=793597
Commit faf9440908 made the bash completion more
robust, but in doing so it made the optional --dest argument to `gdbus emit'
mandatory by mistake.
Remove the error case when --dest is not specified. To keep the completion
working, we shuffle the cases around. --dest should be offered up for
completion after --session/--system/--address have been supplied, so we can
complete its argument. Additionally, if --dest isn't specified then we can't
complete --object-path or --signal, so guard these completions accordingly.
https://bugzilla.gnome.org/show_bug.cgi?id=793597
When completing, we parse the options that the user has typed so far. Up
until now we've been doing this without ignoring unknown options. This
leads to broken completions when the user has typed an incomplete
parameter.
For example, when doing the following:
$ gdbus emit --session --obj<tab>
We expect --object-path to be completed, but it is currently not. What
happens is that we fail to parse the options, therefore don't act on
--session and so don't connect to the session bus, then we early-exit
because we need to know which bus to operate on for later completions.
Instead we can ignore the half-completed --obj, parse --session, get
connected to the bus and then move on to the later completion code.
https://bugzilla.gnome.org/show_bug.cgi?id=793597
Where we were already treating GHashTables as sets, modify them to use
the set-specific APIs g_hash_table_add() and g_hash_table_contains(), to
make that usage more obvious and less prone to being broken.
Heavily based on patches by Garrett Regier <garrettregier@gmail.com>.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=749371
• `gdbus monitor` can’t work at all for non-message-bus connections,
since it can’t subscribe to signals.
• Other tab completions for names depend on the connection being a
message bus connection, but we still need to print `--dest` (etc.)
when tab completing them, even if we can’t print a list of
available names.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
https://bugzilla.gnome.org/show_bug.cgi?id=788594
request_completion is checked several blocks higher in the function.
Spotted by Coverity.
Coverity ID: 1373215
Signed-off-by: Philip Withnall <withnall@endlessm.com>
This is effectively the mc-wait-for-name tool from
telepathy-mission-control; moving it in to gdbus-tool will make it more
widely useful without making people depend on telepathy-mission-control
for no other reason. The code here is reimplemented from scratch to use
GDBus.
It blocks until the specified well-known name is owned by some process
on the bus (which can be the session, system, or any other bus). By
passing --activate, the same (or a different) name can be auto-started
on the bus first.
A timeout can be specified to ensure the process doesn’t block forever.
https://bugzilla.gnome.org/show_bug.cgi?id=745971
gdbus-tool prints a hint about the expected arguments to a function call
in case of errors. Unfortunately, it prints this message on all errors.
I've seen this confuse users several times -- they go on tweaking the
arguments trying to get the correct type, even though they had it
correct in the first place.
Let's limit the hint to the case where it was actually invalid arguments
that triggered the problem. Also, adjust the code that prints the
message so that it will also report on the case that no arguments were
expected.
We could possibly get closer to what we want by comparing the list of
expected arguments with the parameter list, as it was parsed from the
user, but that would involve composing the expected type. Let's keep
this simple for now.
https://bugzilla.gnome.org/show_bug.cgi?id=765710
Passing an nonsense string for the --dest argument can lead
to a segfault of gdbus. Thats not nice, so use our existing
validation function for bus names here.
https://bugzilla.gnome.org/show_bug.cgi?id=747541
Use g_variant_parse_error_print_context() to format the error message
from the GVariant parser.
There is a slightly dubious interaction with the "parse me harder"
functionality here. We're probably going to have to deal with that
separately.
https://bugzilla.gnome.org/show_bug.cgi?id=715028
Back in the far-off twentieth century, it was normal on unix
workstations for U+0060 GRAVE ACCENT to be drawn as "‛" and for U+0027
APOSTROPHE to be drawn as "’". This led to the convention of using
them as poor-man's ‛smart quotes’ in ASCII-only text.
However, "'" is now universally drawn as a vertical line, and "`" at a
45-degree angle, making them an `odd couple' when used together.
Unfortunately, there are lots of very old strings in glib, and also
lots of new strings in which people have kept up the old tradition,
perhaps entirely unaware that it used to not look stupid.
Fix this by just using 'dumb quotes' everywhere.
https://bugzilla.gnome.org/show_bug.cgi?id=700746
Rather than using "extern" declarations of these win32 functions
everywhere they're needed, just prototype them in glib-private.h.
(Which also fixes the fact that they weren't prototyped in the files
where they're defined.)
https://bugzilla.gnome.org/show_bug.cgi?id=688109
Very many testcases, some GLib tools (resource compiler, etc) and
GApplication were calling g_type_init().
Remove those uses, as they are no longer required.
https://bugzilla.gnome.org/show_bug.cgi?id=686161
See https://bugs.freedesktop.org/show_bug.cgi?id=37890#c6 where it was
discovered that dbus-send(1) actually doesn't work (either libdbus-1's
flush implementation or dbus-send(1)'s usage of it is broken) so it's
useful to have here.
Signed-off-by: David Zeuthen <davidz@redhat.com>
This is currently unused but will probably be useful in the
future. For example, we could have a _ARG0_IS_PATH to specify that
arg0 should be used for arg0path.
This commit breaks API and ABI. Users of
g_dbus_connection_signal_subscribe() will need to port to this new
version.
Signed-off-by: David Zeuthen <davidz@redhat.com>
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.
Fix an unintentional double free introduced in commit
4ad4c306c3.
This bug manifested itself when trying to complete this
$ gdbus introspect --system --dest <tab>
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).
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).
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';
};
};
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);
};
};
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).
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>