Commit Graph

53 Commits

Author SHA1 Message Date
Philip Withnall
5942cd7984 gio: Add SPDX license headers automatically
Add SPDX license (but not copyright) headers to all files which follow a
certain pattern in their existing non-machine-readable header comment.

This commit was entirely generated using the command:
```
git ls-files gio/*.[ch] | xargs perl -0777 -pi -e 's/\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/\n \*\n \* SPDX-License-Identifier: LGPL-2.1-or-later\n \*\n \* This library is free software; you can redistribute it and\/or\n \* modify it under the terms of the GNU Lesser General Public/igs'
```

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Helps: #1415
2022-05-18 09:18:52 +01:00
Philip Withnall
7143457076 gdbusmethodinvocation: Drop redundant quote from warning message
Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 19:05:56 +00:00
Philip Withnall
76f5460107 gdbusmethodinvocation: Fix dead code for type checking GetAll
`property_info` is only ever set for `Get` and `Set` calls, not for
`GetAll`, as it only represents a single property. So this code was
never reachable.

Move it out so that it is reachable.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2022-03-17 19:05:56 +00:00
Philip Withnall
a3b8846e54 gdbusmethodinvocation: Fix a leak on an early return path
When doing an early return from `g_dbus_method_invocation_return_*()`
due to passing in the wrong type (or no return value when one was
expected), the parameters were not correctly sunk and were leaked.

Fix that. A unit test will be added in a following commit.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>

Coverity CID: #1474536
2022-03-17 19:04:42 +00:00
Sebastian Dröge
705a59a315 gio: Add missing nullable annotations 2020-11-11 13:15:21 +02:00
Philip Withnall
e430541378 docs: Remove XML-style comments from documentation strings
gtk-doc doesn’t support them any more since it was ported to Markdown,
so they end up appearing in the generated documentation, which isn’t
great.

Mostly, they were used to split up things invisibly, which we can do in
other ways.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-01-12 15:29:29 +00:00
Sébastien Wilmet
3bf4a720c3 gio/: LGPLv2+ -> LGPLv2.1+
Sub-directories inside gio/ already processed in a previous commit:
- fam/
- gdbus-2.0/ (which contains only codegen/)
- gvdb/
- inotify/
- tests/
- win32/
- xdgmime/

Other sub-directories inside gio/:
- completion/: no license headers
- kqueue/: not LGPL, BSD-style license

https://bugzilla.gnome.org/show_bug.cgi?id=776504
2017-05-29 19:53:34 +02:00
Emmanuele Bassi
f952fdf3fc Drop trailing semi-colon from G_DEFINE_ macro
It's unnecessary, and only adds visual noise; we have been fairly
inconsistent in the past, but the semi-colon-less version clearly
dominates in the code base.

https://bugzilla.gnome.org/show_bug.cgi?id=669355
2017-04-10 10:38:31 +01:00
Alexandros Frantzis
feae4e9f31 gdbus: Fix memory leak in gdbusmethodinvocation.c
https://bugzilla.gnome.org/show_bug.cgi?id=780924
2017-04-05 13:12:14 +01:00
Philip Withnall
a6e2213343 gdbus: Add example to docs for g_dbus_method_invocation_return_value()
Try to clarify that the variant passed to return_value() must be a
tuple.

https://bugzilla.gnome.org/show_bug.cgi?id=777592
2017-01-24 09:50:01 +00:00
Christian Hergert
18a33f72db introspection: use (nullable) or (optional) instead of (allow-none)
If we have an input parameter (or return value) we need to use (nullable).
However, if it is an (inout) or (out) parameter, (optional) is sufficient.

It looks like (nullable) could be used for everything according to the
Annotation documentation, but (optional) is more specific.
2016-11-22 14:14:37 -08:00
Debarshi Ray
00bf553a60 GDBusMethodInvocation: Clarify how the ownership is handled
https://bugzilla.gnome.org/show_bug.cgi?id=767952
2016-11-22 17:06:48 +01:00
Allison Ryan Lortie
86c5d8978d GDBusMethodInvocation: document behaviour change
We changed the behaviour of this API to adapt to a change in the D-Bus
specification.  Document the new behaviour, along with the time of the
change.

https://bugzilla.gnome.org/show_bug.cgi?id=755421
2016-01-13 10:51:44 -05:00
Lars Uebernickel
dbea81b02d gdbus: don't send unexpected replies
gdbus sets NO_REPLY_EXPECTED when no callback is given to
g_dbus_connection_call(). It makes sense that it also handles the server
side correctly by discarding replies to clients that don't want one.

https://bugzilla.gnome.org/show_bug.cgi?id=755421
2016-01-13 10:44:49 -05:00
Kalev Lember
02f9e84709 gdbus: Add a missing include
This fixes the build on non-unix platforms, such as win32 where
gunixfdlist.h is not included.
2015-08-22 23:13:33 +02:00
Dan Winship
8d8a1c205b fix previous 2015-08-19 16:21:46 -04:00
Dan Winship
c686245141 gdbus: don't warn when returning a value on a closed connection
g_dbus_method_invocation_return_value(), etc, don't have GError
parameters (which makes sense since they won't usually return errors,
and there's not much you could do if they did), so in the rare case
when something does go wrong, they print a warning.

However, there is at least one situation where the warning is a bad
idea: if you are using private bus connections, and a client connects,
makes a request, and then disconnects before getting the response.
Given that there's nothing the caller can do to prevent this case from
getting hit (since the client might not disconnect until after the
call to g_dbus_method_invocation_return_value() starts) and given that
the server can never actually know for sure that the client has
received the response (it might disconnect after reading the response,
but before processing it), just kill the warning in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=753839
2015-08-19 16:08:48 -04:00
Matthias Clasen
e7fd3de86d Eradicate links and xrefs
These are all replaced by markdown ref links.
2014-02-08 12:26:56 -05:00
Matthias Clasen
3232425785 Docs: replace <literal> by ` 2014-02-06 08:07:16 -05:00
Matthias Clasen
4d12e0d66f Docs: Don't use the emphasis tag
Most of the time, the text read just as well without the extra
boldness.
2014-01-31 20:34:33 -05:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Ryan Lortie
edf16aace4 GDBusMethodInvocation: add missing 'goto out'
We do a bunch of new validity checks for return values in response to
calls on the D-Bus property API but we miss the 'goto out' in one case.
Add it.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:41:12 -04:00
Ryan Lortie
317e8c132d GDBusMethodInvocation: add property return checks
Add some type checking for the values returned from async property
handling calls, similar in spirit to the type checking we do for normal
method calls.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:32 -04:00
Ryan Lortie
f754c4e85b GDBusConnection: allow async property handling
The existing advice in the documentation to "simply" register the
"org.freedesktop.DBus.Properties" interface if you want to handle
properties asynchronously is pretty unreasonable.  If you want to handle
this interface you have to deal with all properties for all interfaces
on the path, and you have to do all of the checking for yourself.  You
also have to provide your own introspection data.

Introduce a new convention for dealing with properties asynchronously.

If the user provides NULL for their get_property() or set_property()
functions in the vtable and has properties registered then the
properties are sent to the method_call() handler.  We get lucky here
that this function takes an "interface_name" parameter that we can set
to "org.freedesktop.DBus.Properties".

We also do the user the favour of setting the GDBusPropertyInfo on the
GDBusMethodInvocation for their convenience (for much the same reasons
as they might want the already-available GDBusMethodInfo).

Add a testcase as well as a bunch of documentation about this new
feature.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:31 -04:00
Ryan Lortie
c691f7b6ca GDBusMethodInvocation: add 'property_info'
Add a field on GDBusMethodInvocation for GDBusPropertyInfo.

For now, it is always %NULL.  It will be set in future patches.

https://bugzilla.gnome.org/show_bug.cgi?id=698375
2013-06-22 13:38:31 -04:00
Dan Winship
4b94c0831e Use 'dumb quotes' rather than `really dumb quotes'
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
2013-05-21 11:23:22 -03:00
Patrick Ohly
a8811fb864 GDBusMethodInvocation: leak and potential crash
_g_dbus_method_invocation_new is said to allow method_info == NULL,
but will crash inside g_dbus_method_info_ref when the method_info
really is NULL, because g_dbus_method_info_ref does not allow NULL as
parameter. Fixed by checking for NULL in _g_dbus_method_invocation_new
itself.

The leak itself happens because _g_dbus_method_invocation_new stores a
new reference to the method_info without also unreferencing it. Fixed
by adding the missing unref, protected by an if because the pointer
may be NULL.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=695376
2013-03-17 22:46:20 -04:00
Matthias Clasen
6bee6dbce5 Miscellaneous string fixes
Typo and punctuation fixes, and some rewording, based
on a patch by Philip Withnall, bug
https://bugzilla.gnome.org/review?bug=628193
2012-08-16 23:02:41 -04:00
Robert Ancell
4143842eb4 Add missing allow-none annotations for function parameters.
Found using:
find . -name '*.c' | xargs grep 'or %NULL' | grep ' \* @' | grep -v '@error' | grep -v allow-none
2012-03-31 20:34:28 +11:00
Brian Cameron
b5f1ea4bb1 void functions should not return. Fixes bug #656675. 2011-08-17 03:01:14 -05:00
David Zeuthen
c404dbed11 gdbus-codegen: Add support for new org.gtk.GDBus.C.UnixFD annotation
Also add convenience _with_unix_fd_list variants to GDBusConnection,
GDBusProxy and GDBusMethodInvocation types to easily support this.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-07-21 16:06:18 -04:00
David Zeuthen
5a811135f7 Add g_dbus_method_invocation_take_error() convenience method
Similar in spirit to g_simple_async_result_take_error().

Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-05-11 20:57:54 -04:00
Giovanni Campagna
53dc341b0d GDBusMethodInvocation: fix introspection annotations
In particular (transfer full), to avoid a refcounting bug and a
segmentation fault.

https://bugzilla.gnome.org/show_bug.cgi?id=646635
2011-05-09 19:04:25 +02:00
Colin Walters
e71fdf6b5a Drop translated g_warning/g_error
http://mail.gnome.org/archives/desktop-devel-list/2011-March/msg00069.html
2011-05-02 14:44:25 -04:00
Murray Cumming
32e26cf179 GDBusMethodInvocation: Improve get_parameters() documentation.
Note that the returned GVariant is always a tuple.
See bug #646420.
2011-04-03 09:13:15 +02:00
Johan Dahlin
30132c44c1 Add a lot of missing annotations 2010-09-24 18:24:41 -03:00
David Zeuthen
847e4dfe7d GDBusMethodInvocation: nuke constructor
... that is, make it private. This makes sense because users are never
expected to create such objects themselves - only the GDBus core will
need this.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-22 22:58:29 -04:00
David Zeuthen
d52e1c33f7 GDBus: Add `return' debug option
This prints all GDBusMethodInvocation API usage and is normally used
with the `incoming' option. Example:

 # G_DBUS_DEBUG=incoming,return ./polkitd --replace
 Entering main event loop
 Connected to the system bus
 Registering null backend at priority -10
 [...]
 Acquired the name org.freedesktop.PolicyKit1
 [...]

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.26
       serial 299
 ========================================================================
 GDBus-debug:Return:
  >>>> METHOD ERROR org.freedesktop.PolicyKit1.Error.Failed
       message `Cannot determine session the caller is in'
       in response to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       to name :1.26
       reply-serial 299

 [...]

 ========================================================================
 GDBus-debug:Incoming:
  <<<< METHOD INVOCATION org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       invoked by name :1.2402
       serial 25
 ========================================================================
 GDBus-debug:Return:
  >>>> METHOD RETURN
       in response to org.freedesktop.PolicyKit1.Authority.RegisterAuthenticationAgent()
       on object /org/freedesktop/PolicyKit1/Authority
       to name :1.2402
       reply-serial 25

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-08-04 16:59:26 -04:00
David Zeuthen
0b2b4deac5 GDBus: Add GDBusSendMessageFlags
This is currently unused but might be useful in the future. For
example, it might be nice with a way to bypass the current queue of
outgoing messages - having a flag enumeration allows us to add a
G_DBUS_SEND_MESSAGE_FLAGS_BYPASS_QUEUE etc. etc.

This commit breaks ABI and API. Users of the (rarely used) API to send
messages will have to port to this new API.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-19 16:07:57 -04:00
Ryan Lortie
5b946e0504 gio/: fully remove gioalias hacks 2010-07-07 19:53:22 -04:00
David Zeuthen
abc65b233c GDBus: Hide instance structures for classes we don't want to be subclassed
This also allows us to nuke the priv-> pointers and save a couple of
indirections.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-07 16:36:51 -04:00
David Zeuthen
2d2a321a4b GDBus: Hide class structures for classes we don't want to be subclassed
E.g. move these C structures out of public header files and into their
respective C files. Also nuke padding since this is no longer needed.

This leaves only GDBusProxy as an extendable type.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-07-07 15:57:37 -04:00
Christian Persch
06e74ca969 g_dbus_method_invocation_return_value consumes the floating variant
Bug #620953.
2010-06-08 17:41:47 +02:00
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
Matthias Clasen
ab2ff1a307 Remove properties from GDBusMethodInvocation class 2010-05-11 22:51:14 -04:00
Matthias Clasen
25a8aa5d88 Cosmetic fixes
Use P_() for properties, fix up indentation, etc.
2010-05-09 22:13:18 -04:00
Matthias Clasen
0cf467c2ca Update copyright years to include 2010 2010-05-09 13:14:55 -04:00
Matthias Clasen
8315eb77d5 Some documentation tweaks
Add links to the D-Bus docs in some places, and various
other additions.
2010-05-09 01:44:11 -04:00
David Zeuthen
46ce134d51 GDBus: Add new symbols to gio.symbols 2010-05-06 17:31:51 -04:00
David Zeuthen
fb1b4599a0 GDBus: Fix up i18n 2010-05-06 16:34:23 -04:00