mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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
This commit is contained in:
parent
7f195ac956
commit
6b652b1a2e
@ -118,9 +118,7 @@ g_network_monitor_get_network_available (GNetworkMonitor *monitor)
|
||||
* g_network_monitor_get_network_metered:
|
||||
* @monitor: the #GNetworkMonitor
|
||||
*
|
||||
* Checks if the network is metered. "Metered" here means that the
|
||||
* traffic flowing through the connection is subject to limitations,
|
||||
* for example set by service providers.
|
||||
* Checks if the network is metered.
|
||||
* See #GNetworkMonitor:network-metered for more details.
|
||||
*
|
||||
* Returns: whether the connection is metered
|
||||
@ -362,15 +360,21 @@ g_network_monitor_default_init (GNetworkMonitorInterface *iface)
|
||||
*
|
||||
* Whether the network is considered metered. That is, whether the
|
||||
* system has traffic flowing through the default connection that is
|
||||
* subject to limitations for example set by service providers.
|
||||
* subject to limitations set by service providers. For example, traffic
|
||||
* might be billed by the amount of data transmitted, or there might be a
|
||||
* quota on the amount of traffic per month. This is typical with tethered
|
||||
* connections (3G and 4G) and in such situations, bandwidth intensive
|
||||
* applications may wish to avoid network activity where possible if it will
|
||||
* cost the user money or use up their limited quota.
|
||||
*
|
||||
* If more information is required about specific devices then the
|
||||
* system network management API should be used instead.
|
||||
* system network management API should be used instead (for example,
|
||||
* NetworkManager or ConnMan).
|
||||
*
|
||||
* If this information is not available then no networks willl be
|
||||
* If this information is not available then no networks will be
|
||||
* marked as metered.
|
||||
*
|
||||
* See also #GNetworkMonitor::network-available.
|
||||
* See also #GNetworkMonitor:network-available.
|
||||
*
|
||||
* Since: 2.46
|
||||
*/
|
||||
|
@ -39,6 +39,7 @@ enum
|
||||
PROP_0,
|
||||
|
||||
PROP_NETWORK_AVAILABLE,
|
||||
PROP_NETWORK_METERED,
|
||||
PROP_CONNECTIVITY
|
||||
};
|
||||
|
||||
@ -119,6 +120,11 @@ g_network_monitor_base_get_property (GObject *object,
|
||||
g_value_set_boolean (value, monitor->priv->is_available);
|
||||
break;
|
||||
|
||||
case PROP_NETWORK_METERED:
|
||||
/* Default to FALSE in the unknown case. */
|
||||
g_value_set_boolean (value, FALSE);
|
||||
break;
|
||||
|
||||
case PROP_CONNECTIVITY:
|
||||
g_value_set_enum (value,
|
||||
monitor->priv->is_available ?
|
||||
@ -160,6 +166,7 @@ g_network_monitor_base_class_init (GNetworkMonitorBaseClass *monitor_class)
|
||||
gobject_class->finalize = g_network_monitor_base_finalize;
|
||||
|
||||
g_object_class_override_property (gobject_class, PROP_NETWORK_AVAILABLE, "network-available");
|
||||
g_object_class_override_property (gobject_class, PROP_NETWORK_METERED, "network-metered");
|
||||
g_object_class_override_property (gobject_class, PROP_CONNECTIVITY, "connectivity");
|
||||
}
|
||||
|
||||
|
@ -134,10 +134,13 @@ nm_metered_to_bool (guint nm_metered)
|
||||
{
|
||||
switch (nm_metered)
|
||||
{
|
||||
case 0: /* unknown */
|
||||
case 1: /* yes */
|
||||
case 3: /* guess-yes */
|
||||
return TRUE;
|
||||
case 0: /* unknown */
|
||||
/* We default to FALSE in the unknown-because-you're-not-running-NM
|
||||
* case, so we should return FALSE in the
|
||||
* unknown-when-you-are-running-NM case too. */
|
||||
case 2: /* no */
|
||||
case 4: /* guess-no */
|
||||
return FALSE;
|
||||
@ -170,7 +173,7 @@ sync_properties (GNetworkMonitorNM *nm,
|
||||
else
|
||||
{
|
||||
|
||||
/* this is only available post 1.0 */
|
||||
/* this is only available post NM 1.0 */
|
||||
v = g_dbus_proxy_get_cached_property (nm->priv->proxy, "Metered");
|
||||
if (v == NULL)
|
||||
{
|
||||
@ -202,7 +205,7 @@ sync_properties (GNetworkMonitorNM *nm,
|
||||
if (new_network_metered != nm->priv->network_metered)
|
||||
{
|
||||
nm->priv->network_metered = new_network_metered;
|
||||
g_object_notify (G_OBJECT (nm), "network-available");
|
||||
g_object_notify (G_OBJECT (nm), "network-metered");
|
||||
}
|
||||
if (new_connectivity != nm->priv->connectivity)
|
||||
{
|
||||
|
@ -499,6 +499,14 @@ watch_connectivity_changed (GNetworkMonitor *monitor,
|
||||
g_print ("Connectivity is %d\n", g_network_monitor_get_connectivity (monitor));
|
||||
}
|
||||
|
||||
static void
|
||||
watch_metered_changed (GNetworkMonitor *monitor,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_print ("Metered is %d\n", g_network_monitor_get_network_metered (monitor));
|
||||
}
|
||||
|
||||
static void
|
||||
do_watch_network (void)
|
||||
{
|
||||
@ -511,8 +519,11 @@ do_watch_network (void)
|
||||
G_CALLBACK (watch_network_changed), NULL);
|
||||
g_signal_connect (monitor, "notify::connectivity",
|
||||
G_CALLBACK (watch_connectivity_changed), NULL);
|
||||
g_signal_connect (monitor, "notify::network-metered",
|
||||
G_CALLBACK (watch_metered_changed), NULL);
|
||||
watch_network_changed (monitor, g_network_monitor_get_network_available (monitor), NULL);
|
||||
watch_connectivity_changed (monitor, NULL, NULL);
|
||||
watch_metered_changed (monitor, NULL, NULL);
|
||||
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
g_main_loop_run (loop);
|
||||
|
Loading…
Reference in New Issue
Block a user