Commit Graph

19 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
Julian Andres Klode
643fc7ea49 gnetworkmonitornm: Do not re-update cached property
GDBusProxy already takes care of updating the cached property
before emitting the signal, so there is no need to do this
a second time ourselves.
2021-10-12 17:31:42 +02:00
Julian Andres Klode
f419966808 gnetworkmonitornm: Stop using removed PropertiesChanged signal
Use the org.freedesktop.DBus.Properties interface to listen
to PropertiesChanged signals on /org/freedesktop/NetworkManager.

NetworkManager used to provide its own legacy PropertiesChanged
signal, but that was dropped in
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/853

This requires NetworkManager >= 1.2 (2016)

Fixes: #2505
Bug-Ubuntu: https://bugs.launchpad.net/bugs/1946196
2021-10-12 17:22:55 +02:00
Bastien Nocera
f299886f1f gnetworkmonitornm: Remove double-space 2019-07-29 17:28:01 +02:00
Bastien Nocera
109f247039 gnetworkmonitornm: Arguments to g-signal's callback are const 2019-07-29 17:28:01 +02:00
Bastien Nocera
7d3ecce346 gnetworkmonitornm: Disconnect g-signal from proxy
So that we're sure never to receive a signal if something is keeping the
proxy alive.
2019-07-29 17:28:01 +02:00
Philip Withnall
e37f0cbd89 gnetworkmonitornm: Consider NM_STATE_CONNECTED_SITE to be available
`NM_STATE_CONNECTED_SITE` is documented to mean that a default route is
available, but that the internet connectivity check failed. A default
route being available is compatible with the documentation for
GNetworkMonitor:network-available, which should be true if the system
has a default route for at least one of IPv4 and IPv6.

https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html

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

Fixes: #1788
2019-05-31 11:19:07 +01:00
Fabrice Bellet
719133e882 gnetworkmonitornm: Fix network available detection
The network-available property can be asserted by querying the NMState
describing the current overval network state, instead of the
NMConnectivityState. The advantage of the NMState is that is reflects
immediately the network state modification, while the connectivity
state is tested at a fixed frequency.
2019-04-29 12:05:54 +00:00
2932a58cd5 Handle an UNKNOWN NetworkManager connectivity as NONE
nm_conn_to_g_conn already handles UNKNOWN like NONE (returning
G_NETWORK_CONNECTIVITY_LOCAL in both cases). So in sync_properties
we should also set new_connectivity to G_NETWORK_CONNECTIVITY_LOCAL
for both NM_CONNECTIVITY_UNKNOWN and NM_CONNECTIVITY_NONE.

This has the added benefit that when NetworkManager returns the network
connectivity is UNKNOWN, we set network_available to FALSE as it should
be. Previously, there were cases in a laptop with no network access,
that g_network_monitor_get_network_available returned true, which was
wrong and is also fixed with this commit.
2019-03-12 18:39:42 +01:00
Philip Withnall
c5761146bc gnetworkmonitornm: Set a GError properly on an error handling path
All the other initialisation failure paths set a GError, but this one
didn’t. Set a GError to avoid breaking the invariant that returning
FALSE should always have a GError set.

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

https://gitlab.gnome.org/GNOME/glib/issues/1523
2018-09-13 10:25:05 +01:00
Philip Withnall
8266238f6d gnetworkmonitornm: Use g_strv_contains() rather than reinventing it
This introduces no functional changes.

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

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +00:00
Philip Withnall
35d4c7f898 gnetworkmonitornm: Fix some minor GVariant memory leaks
Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://bugzilla.gnome.org/show_bug.cgi?id=793880
2018-02-28 17:39:04 +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
Philip Withnall
ca0632ca5c gio: Handle NULL cached properties in NetworkManager monitor
g_dbus_proxy_get_cached_property() and
g_dbus_proxy_get_cached_property_names() can both return NULL if the
property cache is empty. Avoid a crash if this situation arises (which
it looks like it could, from reading the code) by gracefully bailing out
on NULL return values.

Coverity issues: #1257044, #1257045

https://bugzilla.gnome.org/show_bug.cgi?id=741229
2017-04-03 12:04:23 +01:00
Philip Withnall
6b652b1a2e gio: Fix application of GNetworkMonitor:network-metered patch
The wrong patch from https://bugzilla.gnome.org/show_bug.cgi?id=750282
was applied, causing test failures due to not implementing the property
on GNetworkMonitorBase (plus some other omissions).

Fix that by reverting commit a80e7db1a8
and re-applying the correct patch over the top.

https://bugzilla.gnome.org/show_bug.cgi?id=750282
2015-07-29 11:58:02 +01:00
Richard Hughes
a80e7db1a8 gio: Add network metered information to GNetworkMonitor
Add a property to GNetworkMonitor indicating if the network
is metered, e.g. subject to limitations set by service providers.

The default value is FALSE

https://bugzilla.gnome.org/show_bug.cgi?id=750282
2015-07-27 06:44:52 -04:00
Iain Lane
f7be461601 gnetworkmonitornm: Check if network-manager is running
We were asking for properties on NM's dbus interface, but if NM is not
running then there won't be any. Check if the name has an owner before
doing anything to it.

https://bugzilla.gnome.org/show_bug.cgi?id=741653
2015-01-13 12:11:06 +01:00
Timm Bäder
327d35ed41 gnetworkmonitornm: Prevent crash
g_dbus_proxy_get_cached_property_names can return NULL if there are no
cached properties, so don't try to access them in that case.
2015-01-05 11:51:46 +01:00
Bastien Nocera
485a6900fc gio: Add GNetworkMonitor impl based on NetworkManager
Which implements the new GNetworkConnectivity property.

https://bugzilla.gnome.org/show_bug.cgi?id=664562
2014-12-05 17:37:41 +01:00