mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-27 19:38:55 +02:00
gio: add network connectivity state to GNetworkMonitor
Add a property to GNetworkMonitor indicating the level of network connectivity: none/local, limited, stuck behind a portal, or full. The default implementation just returns none or full depending on the value of is-available. https://bugzilla.gnome.org/show_bug.cgi?id=664562
This commit is contained in:
committed by
Bastien Nocera
parent
ed68d80e61
commit
8d08b82109
@@ -38,7 +38,8 @@ enum
|
||||
{
|
||||
PROP_0,
|
||||
|
||||
PROP_NETWORK_AVAILABLE
|
||||
PROP_NETWORK_AVAILABLE,
|
||||
PROP_CONNECTIVITY
|
||||
};
|
||||
|
||||
struct _GNetworkMonitorBasePrivate
|
||||
@@ -114,12 +115,20 @@ g_network_monitor_base_get_property (GObject *object,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_NETWORK_AVAILABLE:
|
||||
g_value_set_boolean (value, monitor->priv->is_available);
|
||||
break;
|
||||
case PROP_NETWORK_AVAILABLE:
|
||||
g_value_set_boolean (value, monitor->priv->is_available);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
case PROP_CONNECTIVITY:
|
||||
g_value_set_enum (value,
|
||||
monitor->priv->is_available ?
|
||||
G_NETWORK_CONNECTIVITY_FULL :
|
||||
G_NETWORK_CONNECTIVITY_LOCAL);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -151,6 +160,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_CONNECTIVITY, "connectivity");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Reference in New Issue
Block a user