Commit Graph

140 Commits

Author SHA1 Message Date
Bastien Nocera
9645cbffa8 gio: Add portal version of GPowerProfileMonitor 2021-08-13 01:32:31 +02:00
Patrick Griffis
889bdb994f Add GPowerProfileMonitor 2021-07-28 15:56:02 +02:00
Philip Withnall
be012a8067 giomodule: Port to new g_module_open_full() API
Port all existing calls in GLib to the new API so that they can receive
more detailed error information (although none of them actually make use
of it at the moment).

This also serves to test the new API better through use.

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

Helps: #203
2021-07-21 21:54:35 +01:00
Emmanuel Fleury
5fec112453 Fix signedness warning in gio/giomodule.c
gio/giomodule.c: In function ‘print_help’:
glib/gmacros.h:806:26: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’}
  806 | #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
      |                          ^
../glib.git/gio/giomodule.c:733:19: note: in expansion of macro ‘MAX’
  733 |           width = MAX (width, strlen (g_io_extension_get_name (extension)));
      |                   ^~~
2021-04-05 12:03:51 +02:00
Руслан Ижбулатов
03b574ae66 Don't leak a handle from _g_io_win32_get_module()
This call increments the DLL refcount by default and
needs a flag to avoid that.
2021-03-25 15:20:49 +00:00
Philip Withnall
b6a1fa47fe Merge branch 'settings-test-cleanups' into 'master'
Various memory leak cleanups to GSettings tests

See merge request GNOME/glib!610
2021-01-20 13:15:26 +00:00
Philip Withnall
22b924b64a giomodule: Don’t mandatorily cache GIOModule implementations
While all of the current callers of _g_io_module_get_default() want to
cache the returned GObject for the lifetime of the process, that doesn’t
necessarily have to be the case, so let callers make that decision on a
case-by-case basis.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2021-01-20 12:51:41 +00:00
Philip Withnall
ba414ee100 giomodule: Ignore GIO_MODULE_DIR when running as setuid
Even if the modules in the given directory never get chosen to be used,
loading arbitrary code from a user-provided directory is not safe when
running as setuid, as the process’ environment comes from an untrusted
source.

Also ignore `GIO_EXTRA_MODULES`.

Spotted by Simon McVittie.

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

Fixes: #2168
2021-01-07 15:02:24 +00:00
Timm Bäder
fe441c8ca5 giomodule: Don't allocate GHashTable for no entries
This seems to happen in 3 out of 4 cases when calling gtk_init(), so
avoid allocating the GHashTable in that case.
2020-12-31 14:58:40 +01:00
Руслан Ижбулатов
427d4fad24 GWin32AppInfo: Use a thread for async appinfo tree rebuilds 2020-11-17 18:11:56 +00:00
Philip Withnall
648986a290 glib: Avoid redefining GLIB_DISABLE_DEPRECATION_WARNINGS
It may be defined by the environment (we document that as being allowed)
— if so, individual files should not try to redefine it, as that causes
a preprocessor warning.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-27 15:41:09 +01:00
Léo Stefanesco
497c511a98 Fix giomodule.cache being wrongly considered stale
In ostree based systems, such as flatpak and fedora silverblue, the
time of modification of every system file is epoch 0, including
giomodule.cache, which means that every module is loaded and unloaded
every time.

The solution is to use the change time of the file as well. In a typical
system, it is equal to the mtime, and in an ostree based system, since
the directory is mounted as read-only, the user cannot add a module and
we must assume that the cache file corresponds to the modules.
2020-07-03 15:16:33 +02:00
Philip Withnall
00bfb3ab44 tree: Fix various typos and outdated terminology
This was mostly machine generated with the following command:
```
codespell \
    --builtin clear,rare,usage \
    --skip './po/*' --skip './.git/*' --skip './NEWS*' \
    --write-changes .
```
using the latest git version of `codespell` as per [these
instructions](https://github.com/codespell-project/codespell#user-content-updating).

Then I manually checked each change using `git add -p`, made a few
manual fixups and dropped a load of incorrect changes.

There are still some outdated or loaded terms used in GLib, mostly to do
with git branch terminology. They will need to be changed later as part
of a wider migration of git terminology.

If I’ve missed anything, please file an issue!

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-12 15:01:08 +01:00
Christoph Reiter
a8263add45 Merge branch 'fix-gio-module-path-msvc' into 'master'
giomodule: gio modules are no longer installed in bindir on MSVC

See merge request GNOME/glib!1254
2019-12-12 18:29:07 +00:00
Bastien Nocera
cd6612dfb7 gio: Add GMemoryMonitor to monitor for low-memory
Add a memory monitor object, with D-Bus and Portal based
implementations. The D-Bus implementation uses the Linux-only
low-memory-monitor Freedesktop project.

Low Memory Monitor D-Bus API:
https://hadess.pages.freedesktop.org/low-memory-monitor/

Android API:
https://developer.android.com/reference/android/content/ComponentCallbacks2.html#onTrimMemory(int)

iOS API:
https://developer.apple.com/documentation/uikit/app_and_environment/managing_your_app_s_life_cycle/responding_to_memory_warnings

Win32 API:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.systemevents.lowmemory?view=netframework-4.8

Tizen API:
https://samsung.github.io/TizenFX/master/api/Tizen.Applications.EventManager.SystemEvents.LowMemory.html
2019-12-11 11:44:42 +00:00
Nirbheek Chauhan
5f0d0efeb6 giomodule: gio modules are no longer installed in bindir on MSVC
Ever since the port to Meson, gio modules (f.ex., by glib-networking)
are installed inside libdir both for MinGW and MSVC.
2019-11-27 16:10:51 +05:30
Matthias Clasen
5f8d787815 Ensure that the keyfile settings backend exists
We need to bring the type into existence.

Closes: https://gitlab.gnome.org/GNOME/glib/issues/1822
2019-07-08 10:32:18 -04:00
Philip Withnall
e62e89f2f8 Fix various deprecation warnings in code and tests
This code uses, or tests, deprecated functions, types or macros; so
needs to be compiled with deprecation warnings disabled.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-30 10:38:45 +01:00
Ignacio Casal Quinteiro
55870d4b42 Properly ensure the cocoa notification backend type 2019-03-29 15:52:38 +01:00
Sebastian Dröge
b4a5157f95 Fix compiler warning about uninitialized variable in giomodule
It could've never been uninitialized in this code but the code flow is
not obvious to the compiler. Initialize it to NULL and for clarity also
add an assertion that it is not NULL anymore on usage.

In file included from ../glib/glib.h:62,
                 from ../gobject/gbinding.h:28,
                 from ../glib/glib-object.h:23,
                 from ../gio/gioenums.h:28,
                 from ../gio/giotypes.h:28,
                 from ../gio/giomodule.h:28,
                 from ../gio/giomodule.c:25:
../gio/giomodule.c: In function ‘_g_io_module_get_default’:
../glib/gmessages.h:343:25: warning: ‘extension’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define g_debug(...)    g_log (G_LOG_DOMAIN,         \
                         ^~~~~
../gio/giomodule.c:912:17: note: ‘extension’ was declared here
   GIOExtension *extension, *preferred;
                 ^~~~~~~~~
2019-01-24 16:35:13 +02:00
Matthias Clasen
df5b482781 gio: Support "help" in extension point env vars
Interpret the value "help" for environment variables that
are passed to _g_io_module_get_default(), and print the
names and priorities of available extensions.

This lets users explore what is available, and can be helpful
in figuring out why a certain extension was chosen as default.

It is similar in spirit to what we already do with environment
variables like G_DEBUG.
2019-01-22 13:18:42 -05:00
Philip Withnall
92b3f22ad5 giomodule: Print the type of each default GIO module
This is useful for debugging in many situations. It’ll be printed with
G_MESSAGES_DEBUG=GLib-GIO or G_MESSAGES_DEBUG=all.

Mostly I need it for debugging the default GNetworkMonitor, but it will
work for all GIO module implementations.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-01-21 16:27:58 +00:00
Matthias Clasen
e0b120cc3c Add debug spew to module loading
This is useful to verify which modules are loaded, and why.
2018-07-20 18:53:09 -04:00
Philip Withnall
b868cf5864 gio: Add dummy win32 notification backend
This adds a null notification backend implementation for win32, purely
to avoid crashes due to a missing backend when applications use
GNotification. This backend does nothing except print a warning when a
notification is supposed to be emitted.

In future, it can be expanded to use win32 API to present toaster
notifications appropriately.

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

https://bugzilla.gnome.org/show_bug.cgi?id=776583
2018-04-10 10:39:40 +01:00
Philip Withnall
891026d9fc giomodule: Fix a copy/paste error in some internal documentation
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-03-21 15:32:13 +00:00
Philip Withnall
3787e42932 gio: Rename GNetworkMonitorWindows to GWin32NetworkMonitor
This makes it more consistent with other GWin32* objects. No functional
changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-18 10:12:26 +00:00
Jan-Michael Brummer
f9aacf3952 GNetworkMonitorWindows: Add IPv4/IPv6 network monitor backend for windows
Added a Windows backend to GNetworkMonitor, using NotifyRouteChange2()
(available on Vista and later). It marshals the route change callbacks
to the thread-specific default main context the GNetworkMonitor was
constructed in.

https://bugzilla.gnome.org/show_bug.cgi?id=685442
2018-01-17 12:31:26 +00:00
Xavier Claessens
7f69b828fc GIOModule: Use unique names for load/unload symbols
GIO modules should include their name into their exported symbols to
make them unique. This avoids symbol clash when building modules
statically.

extract_name() function is copied from GStreamer which recently
switched to the same symbol naming scheme.

https://bugzilla.gnome.org/show_bug.cgi?id=684282
2018-01-04 11:01:40 -05:00
Philip Withnall
3eacec1587 Use hash tables as sets in various places
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
2017-10-26 12:27:17 +01: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
TingPing
90dfea2b61 Implement GAppInfo on OSX
This is an implementation of most of GAppInfo using the OS X
NSBundle APIs.

Missing at this point are things that don't have equivalents
in OS X, such as hidden desktop files, last-used, manual type
associations, and g_app_info_get_all().

https://bugzilla.gnome.org/show_bug.cgi?id=734946
2017-03-13 10:33:23 -04:00
Matthias Clasen
a28429a3c6 Fix a typo 2017-03-08 22:36:05 -05:00
Matthias Clasen
04ad811e50 Add a forgotten g_type_ensure call
One of the types in this function was not wrapped in a
g_type_ensure_call, an obvious oversight.
2017-03-08 22:27:06 -05:00
John Ralls
d1a03bc728 Enable building gcocoanotification only if OS X min version >= 10.9
This changes the configure checks to check for what is actually
required to build this code.

https://bugzilla.gnome.org/show_bug.cgi?id=747146
2017-03-08 22:26:00 -05:00
Jan Tojnar
1a845115a2 gio: Check for NUll when getting extensions
When unregistered extension point (i.e. NULL pointer) is passed
to `g_io_extension_point_get_extensions`, it causes a segfault.

This commit adds an assertion, to prevent this.

https://bugzilla.gnome.org/show_bug.cgi?id=779183
2017-02-27 14:43:44 +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
Chun-wei Fan
b5258d9d76 gio: Build the portal code only on *NIX
xdg-desktop-portal support is only usable on *NIX platforms, so don't build
them on non-*NIX platforms.  Also clean up gio/Makefile.am a bit to split out
the listings for the platform-specific sources from the platform-neutral
sources, and assemble them for the final list of sources required for libgio.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-13 10:43:05 +08:00
Matthias Clasen
bd3fb2a15f Add a portal backend for GNotification
This talks to the org.freedesktop.portal.Notification portal
instead of directly to gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:48:34 -04:00
Matthias Clasen
e362a01446 Add a portalized proxy resolver implementation
The backend for this lives in xdg-desktop-portal,
and is in turn using GProxyResolver.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:48:34 -04:00
Matthias Clasen
cea5626c49 Add a portalized network monitor implementation
The backend for this lives in xdg-desktop-portal,
and is in turn using GNetworkMonitor.

When network is not available in the sandbox, there is
no point in reporting accurately about the network
status outside the sandbox. Just return 'no connection'
in this case.

https://bugzilla.gnome.org/show_bug.cgi?id=768498
2016-07-07 23:48:34 -04:00
Christoph Reiter
f8189ddf98 gio: Add filename type annotations
https://bugzilla.gnome.org/show_bug.cgi?id=767245
2016-06-04 20:38:42 +02:00
Víctor Manuel Jáquez Leal
3bb8294e00 giomodule: return a copy of module name
This is a regression from commit 6dedc0.

The clients expect to free the received module name, so the function
must return a copy.

https://bugzilla.gnome.org/show_bug.cgi?id=756952
2015-10-22 11:21:47 +02:00
Ignacio Casal Quinteiro
144a87a643 Use bin/gio/modules when building with visual studio 2015-10-22 09:22:01 +02:00
Ignacio Casal Quinteiro
6dedc0364a Factor out a get_gio_module_dir
This also fixes some memory leaks on windows
2015-10-22 08:42:22 +02:00
Ignacio Casal Quinteiro
ad0f340c27 win32: let glib to use the right path separator for the modules 2015-10-20 16:13:08 +02:00
Patrick Griffis
36e093a31a Implement GNotification on OSX
https://bugzilla.gnome.org/show_bug.cgi?id=747146
2015-06-05 14:55:58 -04:00
Ryan Lortie
2737ab3201 substantially rework file monitors
Remove all event merging and dispatch logic from GFileMonitor.  The only
implementation of GFileMonitor outside of glib is in gvfs and it already
does these things properly.

Get rid of GLocalDirectoryMonitor.  We will use a single class,
GLocalFileMonitor, for both directory and file monitoring.  This will
prevent every single backend from having to create two objects
separately (eg: ginotifydirectorymonitor.c and ginotifyfilemonitor.c).

Introduce GFileMonitorSource as a thread-safe cross-context dispatch
mechanism.  Put it in GLocalFileMonitor.  All backends will be expected
to dispatch via the source and not touch the GFileMonitor object at all
from the worker thread.

Remove all construct properties from GLocalFileMonitor and remove the
"context" construct property from GFileMonitor.  All backends must now
get the information about what file to monitor from the ->start() call
which is mandatory to implement.

Remove the implementation of rate limiting in GFileMonitor and add an
implementation in GLocalFileMonitor.  gvfs never did anything with this
anyway, but if it wanted to, it would have to implement it for itself.
This was done in order to get the rate_limit field into the
GFileMonitorSource so that it could be safely accessed from the worker
thread.

Expose g_local_file_is_remote() internally for NFS detection.

With the "is_remote" functionality exposed, we can now move all
functions for creating local file monitors to a proper location in
glocalfilemonitor.c

Port the inotify backend to adjust to the changes above.  None of the
other backends are ported yet.  Those will come in future commits.
2015-03-20 11:59:47 -04:00
Paolo Borelli
ed4a742946 HTTP proxy support
Based on code from "WockyHttpProxy" written by Nicolas Dufresne
and Marc-André Lureau. Initial glib patch by Brian J. Murrell.

https://bugzilla.gnome.org/show_bug.cgi?id=733876
2015-03-06 21:23:58 +01:00
Xavier Claessens
74c22150cf docs: fix up docs issues in gio/ 2015-02-05 16:20:43 +01:00