Commit Graph

77 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
Loic Le Page
3214a0f333 Fix redefinition of local variable in gio/gapplicationimpl-dbus.c 2022-04-01 15:10:50 +02:00
Emmanuel Fleury
579e9e49c5 Fix several warnings in gio/gapplicationimpl-dbus.c:g_application_impl_command_line()
gio/gapplicationimpl-dbus.c: In function ‘g_application_impl_command_line’:
gio/gapplicationimpl-dbus.c:772:3: error: ‘static’ is not at beginning of declaration
  772 |   const static GDBusInterfaceVTable vtable = {
      |   ^~~~~
gio/gapplicationimpl-dbus.c:774:3: error: missing initializer for field ‘get_property’ of ‘GDBusInterfaceVTable’ {aka ‘const struct _GDBusInterfaceVTable’}
  774 |   };
      |   ^
2021-01-21 11:59:09 +01:00
Emmanuel Fleury
cf5a6cfe3a Fix several warnings in gio/gapplicationimpl-dbus.c:g_application_impl_attempt_primary()
gio/gapplicationimpl-dbus.c: In function ‘g_application_impl_attempt_primary’:
gio/gapplicationimpl-dbus.c:364:3: error: ‘static’ is not at beginning of declaration
  364 |   const static GDBusInterfaceVTable vtable = {
      |   ^~~~~
gio/gapplicationimpl-dbus.c:368:3: error: missing initializer for field ‘padding’ of ‘GDBusInterfaceVTable’ {aka ‘const struct _GDBusInterfaceVTable’}
  368 |   };
      |   ^
2021-01-21 11:59:09 +01:00
Philip Withnall
539621d2d3 gapplication: Add postconditions on calls to GApplication.dbus_register
Try and catch programmer errors in third-party implementations of
`dbus_register()`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #1188
2020-12-11 22:33:13 +00:00
Philip Withnall
159a9c215a gio: Fix various typos of the name ‘D-Bus’
This introduces no functional changes.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
2020-10-26 14:28:15 +00:00
Philip Withnall
1b50643c99 gio: Fix various compiler warnings when compiling with G_DISABLE_ASSERT
Mostly unused variables which are only used in a g_assert() call
otherwise.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Helps: #1708
2019-03-08 19:46:21 +00:00
Matthias Clasen
3a4b18f903 GApplication: Add a way to replace a unique instance
While uniqueness is great, sometimes you want to restart
a newer version of the same app. These two flags make that
possible.

We also add a ::name-lost signal, that is emitted when it
happens. The default handler for this signal just calls
g_application_quit(), but applications may want to connect
and do cleanup or state-saving here.
2018-11-26 11:45:29 -05:00
Matthias Clasen
dd3e565e94 Use an existing enum value
We have an enum for this, no need to hardcode numbers.
2018-08-18 20:16:03 -04:00
Debarshi Ray
df06dc6550 GApplication: Don't call dbus_unregister multiple times
https://bugzilla.gnome.org/show_bug.cgi?id=725950
2017-07-24 19:52:48 +02: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
Colin Walters
acdcf5cd50 gapplicationimpl-dbus: Fix leak of fd list object
Spotted by static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Michael Catanzaro
c3842d1969 Fix old wiki links 2014-07-01 23:52:19 -05:00
Ryan Lortie
0e671286fc GApplication: parse command line options
Add support for parsing command line options with GApplication.

You can add GOptionGroup and GOptionEntry using two new APIs:
g_application_add_option_group() and
g_application_add_main_option_entries().

Also add a "handle-local-options" signal that allows handling of
commandline arguments in the local process without having to override
local_command_line.

As a special feature, you can have a %NULL @arg_data in a GOptionEntry
which will cause the argument to be stored in a GVariantDict.  This
dictionary is available for inspection and modification by the
"handle-local-options" signal and can be forwarded to the primary
instance in cases of command line invocation (where it can be fetched
using g_application_command_line_get_options()).

https://bugzilla.gnome.org/show_bug.cgi?id=721977
2014-02-06 12:02:53 +00:00
Daniel Mustieles
078dbda148 Updated FSF's address 2014-01-31 14:31:55 +01:00
Ryan Lortie
ffbf866d3b GApplication: fix bogus testcase
We had a GApplication testcase that handled both open and commandline.
This only way that this worked was by implementing the commandline
handler without actually setting the HANDLES_COMMAND_LINE flag.

This behaviour is now invalid, so just rip out the offending part of the
test.

https://bugzilla.gnome.org/show_bug.cgi?id=711099
2013-11-07 13:51:05 -05:00
Giovanni Campagna
415c6d2e27 gapplication: don't emit warnings for DBus calls
If a broken (or malicious) remote client calls Open or CommandLine
on a GApplication that does not implement those, return a DBus
error instead of going through and then emitting a warning.

https://bugzilla.gnome.org/show_bug.cgi?id=710885
2013-10-26 14:55:18 +02:00
Giovanni Campagna
3e48e3be40 gapplication: fix memory leak
g_variant_get_child_value() returns a new GVariant, which we must
free.

https://bugzilla.gnome.org/show_bug.cgi?id=710885
2013-10-26 14:55:18 +02:00
Ryan Lortie
4e1e36a7f0 Revert "gapplication: don't rely on cmdline being finalized immediately"
This reverts commit c5748328be.
2013-10-17 08:22:11 -04:00
Cosimo Cecchi
c5748328be gapplication: don't rely on cmdline being finalized immediately
The GApplicationCommandLine DBus implementation currently calls
g_dbus_method_invocation_return_value() in its finalize() implementation
only, relying on the object being destroyed after g_object_unref() is
called on it inside g_application_impl_method_call().

While this is usually fine for C applications, when overriding the
command_line vfunc from language bindings, the binding might add extra
references to the object, which might not be released immediately - e.g.
because they're garbage collected, or possibly even leaked. The same
scenario could happen in a C application that decides to keep a
reference to the passed-in GApplicationCommandLine object.

To ensure the CommandLine DBus method always gets a reply after the
invocation of command_line in the primary instance, explicitly send the
message back before dropping our reference to the object.

https://bugzilla.gnome.org/show_bug.cgi?id=708042
2013-10-16 23:06:13 -04:00
Ryan Lortie
8ead9055b9 GApplication: reply to ActivateAction
Send a reply for org.freedesktop.Application.ActivateAction calls.  We
missed this before because nobody was waiting for it.
2013-07-14 19:48:01 -04:00
Matthias Clasen
0aaac55d14 Update link to documentation 2013-06-06 00:06:46 -04:00
Ryan Lortie
b4df86fa19 GApplication: implement fd.o application spec
The freedesktop application specification is largely overlapping the
GLib application D-Bus interface but implementing it will allow for
applications to be launched directly from desktop files, which we want.

We keep the old Gtk interface for compatibility reasons and because it
has some functionality not in the freedesktop spec (Busy state,
CommandLine, etc.).

https://bugzilla.gnome.org/show_bug.cgi?id=699259
2013-06-05 12:50:50 -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
Ryan Lortie
0646e00e25 GApplication: don't leak 'hint' on remote Open
We were using format string "s" to deconstruct the open hint into a
'const gchar *' which, of course, we never freed.  Fix that.
2013-04-29 13:39:55 -07:00
Cosimo Cecchi
db325cd6a3 application: introduce methods to mark the application as busy
This feature is intended for clients that want to signal a desktop shell
their busy state, for instance because a long-running operation is
pending.
The API works in a similar way to g_application_hold and
g_application_release: applications can call g_application_mark_busy()
to increase a counter that will keep the application marked as busy
until the counter reaches zero again.

The busy state is exported read-only on the org.gtk.Application interface
for clients to use.

https://bugzilla.gnome.org/show_bug.cgi?id=672018
2013-04-04 13:13:53 -04:00
Colin Walters
f398bec5bc Add g_close(), use it
There are two benefits to this:

1) We can centralize any operating system specific knowledge of
   close-vs-EINTR handling.  For example, while on Linux we should never
   retry, if someone cared enough later about HP-UX, they could come by
   and change this one spot.
2) For places that do care about the return value and want to provide
   the caller with a GError, this function makes it convenient to do so.

Note that gspawn.c had an incorrect EINTR loop-retry around close().

https://bugzilla.gnome.org/show_bug.cgi?id=682819
2013-01-29 09:46:04 -05:00
Ryan Lortie
89d48d7800 Add g_application_command_line_get_stdin()
This returns a GInputStream corresponding to the stdin on the
commandline that caused this invocation.

The local case works on both UNIX (GUnixInputStream on stdin) and
Windows (GWin32InputStream on GetStdHandle(STD_INPUT_HANDLE)).  The
remote case works only on UNIX (by fd passing over D-Bus).

https://bugzilla.gnome.org/show_bug.cgi?id=668210
2012-12-27 11:00:49 -05:00
Ryan Lortie
7c98844760 various: add missing cases of #include "config.h" 2012-12-06 13:30:31 -05:00
Colin Walters
94ef8dff0d gdbusactiongroup: Add prototype for g_dbus_action_group_sync()
Even private functions that are actually called across compilation
units should have prototypes.  For g_dbus_action_group_sync(), create
one in gdbusactiongroup-private.h

https://bugzilla.gnome.org/show_bug.cgi?id=687385
2012-11-02 09:03:52 -04:00
Christian Persch
4979c1d075 application: Add dbus register/unregister hooks
When the application is using its D-Bus backend, it is useful to be able
to export extra D-Bus objects at the right time, i.e. *before* the application
tries to own the bus name. This is accomplished here by adding a hook
in GApplicationClass for this; and a corresponding hook that will be called
on unregistration to undo whatever the register hook did.

Bug #675509.
2012-05-29 19:01:42 +02:00
Christian Persch
ee1965b888 application: Save a few bytes in the library
There's really no need to put useless whitespace into the .so.
2012-05-24 17:34:08 +02:00
Ryan Lortie
eb5381b862 GApplication: add accessor for DBus information
Provide public access to the GDBusConnect and object path that
GApplication is using.  Prevents others from having to guess these
things for themselves based on the application ID.

https://bugzilla.gnome.org/show_bug.cgi?id=671249
2012-04-30 17:43:06 -04:00
Ryan Lortie
16f92a33ac GApplication: allow null application_id
GApplication application ID is now permitted to be NULL, in which case
G_APPLICATION_NON_UNIQUE will be implicitly enabled.

https://bugzilla.gnome.org/show_bug.cgi?id=671249
2012-04-30 17:38:15 -04:00
Ryan Lortie
a5caa564b7 GApplication: fix name unregister logic
We were attempting to unregister our ownership of our D-Bus name even in
the case that we were non-unique (ie: we didn't actually own the name).
Rework the logic a bit to prevent that: for non-unique, we leave
impl->bus_name as NULL and we only register/unregister if it is
non-NULL.
2012-03-03 11:48:12 -05:00
Ryan Lortie
40e9192d72 GApplication: put non-unique apps on D-Bus
For a number of reasons it might be useful to register the object paths
associated with a non-unique application so that the application can at
least field requests to its unique D-Bus name.

https://bugzilla.gnome.org/show_bug.cgi?id=647986
2012-02-09 12:15:49 -05:00
Ryan Lortie
54b986d918 GApplication: drop support for appmenu/menubars
This has been moved over to GtkApplication now.

https://bugzilla.gnome.org/show_bug.cgi?id=668118
2012-01-18 13:39:22 -05:00
Matthias Clasen
68706bfa2b Add references to the dbus interface docs on the wiki
And strip out the (now) redundant copy of that information
from the sources.
2011-12-20 12:15:05 -05:00
Ryan Lortie
0a22f63ebe Drop public menu APIs from GApplication
This is moving to Gtk, but we don't want to do it all right now.
2011-12-19 12:34:16 -05:00
Ryan Lortie
0971d36e4b GApplication: receiving end of GRemoteActionGroup
Use the fact that the action group exporter now speaks to
GRemoteActionGroup to get the platform data into GApplicion without
hacks.

https://bugzilla.gnome.org/show_bug.cgi?id=665737
2011-12-17 12:54:02 -05:00
Ryan Lortie
eefd08996f introduce GRemoteActionGroup
This interfaceifies the extra functions that were on GDBusActionGroup
for dealing with platform data.

The two main benefits of doing this:

  - no longer have to do a silly song and dance in GApplication to avoid
    calling GDBusActionGroup API from non-dbus-aware code

  - the interface can be reused by the action group exporter to avoid
    ugly and unbindable hook callbacks

https://bugzilla.gnome.org/show_bug.cgi?id=665737
2011-12-17 12:54:02 -05:00
Ryan Lortie
ee9f104432 GApplication: send platform data for actions again
Use the _full variants of the GDBusActionGroup API to send platform data
for action invocations once again.
2011-12-16 22:24:03 -05:00
Ryan Lortie
a6366dc289 GDBusActionGroup: make API just like GDBusMenuModel
Have one simple _get() API that returns the group immediately, in an
empty state.  The group is initialised on the first attempt to interact
with it.

Leave a secret 'back door' for GApplication to do a blocking
initialisation.
2011-12-08 18:07:47 -05:00
Ryan Lortie
0fdd9985bb GDBusActionGroup: drop ability to 'inject'
Also drop the GDBusActionGroupFlags that were only meant to facilitate
injection-based usage.
2011-12-08 18:05:15 -05:00
Ryan Lortie
77f6e6a97f GApplication dbus: publish the menus again 2011-12-08 18:05:14 -05:00
Ryan Lortie
f7886d6adb Action group exporter: clean up the API
Make it look more like a typical GDBusConnection API with integer
registration ID and corresponding unexport call.  Kill the 'query' call.
2011-12-08 18:05:14 -05:00
Ryan Lortie
5a32769300 GApplication: simplify dbus impl
The error handling on register() was just totally out of hand before.
Clean that mess up.

Take out the menu export for now as well.  It will be added back again
later.
2011-12-08 18:05:14 -05:00
Ryan Lortie
03d894d81f GApplication dbus: use XML for introspection
The hand-written structures are hard to read and cause quite a lot of
relocations at library load time.  Avoid that.
2011-12-08 18:05:14 -05:00
Ryan Lortie
3821627366 GApplication: make distinction about menus
Rename g_application_set_menu to g_application_set_app_menu and make a
couple of fixups.  Clarify the documentation about exactly what this
menu is meant to be.

Add g_application_set_menubar and document that as well.
2011-12-08 18:05:14 -05:00
Matthias Clasen
db34b1aebe Rename exporter APIs
There are no public 'exporter' objects, so don't allude to them
in the function names. At the same time, we want to make it clear
that these functions are D-Bus specific.

The new APIs are
g_action_group_dbus_export_start
g_action_group_dbus_export_query
g_action_group_dbus_export_stop
g_menu_model_dbus_export_start
g_menu_model_dbus_export_query
g_menu_model_dbus_export_stop
2011-12-08 18:05:12 -05:00