gi-gio
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.Gio.Interfaces.NetworkMonitor

Description

GNetworkMonitor provides an easy-to-use cross-platform API for monitoring network connectivity. On Linux, the available implementations are based on the kernel's netlink interface and on NetworkManager.

There is also an implementation for use inside Flatpak sandboxes.

Since: 2.32

Synopsis

Exported types

newtype NetworkMonitor Source #

Memory-managed wrapper type.

Instances

Instances details
Eq NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

GObject NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

ManagedPtrNewtype NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

TypedObject NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

Methods

glibType :: IO GType #

HasParentTypes NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

HasAttributeList NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

(info ~ ResolveNetworkMonitorMethod t NetworkMonitor, OverloadedMethod info NetworkMonitor p, HasField t NetworkMonitor p) => HasField (t :: Symbol) NetworkMonitor (p :: Type) Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

Methods

getField :: NetworkMonitor -> p #

(info ~ ResolveNetworkMonitorMethod t NetworkMonitor, OverloadedMethodInfo info NetworkMonitor) => IsLabel t (MethodProxy info NetworkMonitor) Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

(info ~ ResolveNetworkMonitorMethod t NetworkMonitor, OverloadedMethod info NetworkMonitor p) => IsLabel t (NetworkMonitor -> p) Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

Methods

fromLabel :: NetworkMonitor -> p #

IsGValue (Maybe NetworkMonitor) Source #

Convert NetworkMonitor to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttributeList NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type ParentTypes NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type SignalList NetworkMonitor Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

class (GObject o, IsDescendantOf NetworkMonitor o) => IsNetworkMonitor o Source #

Type class for types which can be safely cast to NetworkMonitor, for instance with toNetworkMonitor.

Instances

Instances details
(GObject o, IsDescendantOf NetworkMonitor o) => IsNetworkMonitor o Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

toNetworkMonitor :: (MonadIO m, IsNetworkMonitor o) => o -> m NetworkMonitor Source #

Cast to NetworkMonitor, for types for which this is known to be safe. For general casts, use castTo.

Methods

type family ResolveNetworkMonitorMethod (t :: Symbol) o where ... Source #

Equations

ResolveNetworkMonitorMethod "bindProperty" o = ObjectBindPropertyMethodInfo 
ResolveNetworkMonitorMethod "bindPropertyFull" o = ObjectBindPropertyFullMethodInfo 
ResolveNetworkMonitorMethod "canReach" o = NetworkMonitorCanReachMethodInfo 
ResolveNetworkMonitorMethod "canReachAsync" o = NetworkMonitorCanReachAsyncMethodInfo 
ResolveNetworkMonitorMethod "canReachFinish" o = NetworkMonitorCanReachFinishMethodInfo 
ResolveNetworkMonitorMethod "forceFloating" o = ObjectForceFloatingMethodInfo 
ResolveNetworkMonitorMethod "freezeNotify" o = ObjectFreezeNotifyMethodInfo 
ResolveNetworkMonitorMethod "getv" o = ObjectGetvMethodInfo 
ResolveNetworkMonitorMethod "init" o = InitableInitMethodInfo 
ResolveNetworkMonitorMethod "isFloating" o = ObjectIsFloatingMethodInfo 
ResolveNetworkMonitorMethod "notify" o = ObjectNotifyMethodInfo 
ResolveNetworkMonitorMethod "notifyByPspec" o = ObjectNotifyByPspecMethodInfo 
ResolveNetworkMonitorMethod "ref" o = ObjectRefMethodInfo 
ResolveNetworkMonitorMethod "refSink" o = ObjectRefSinkMethodInfo 
ResolveNetworkMonitorMethod "runDispose" o = ObjectRunDisposeMethodInfo 
ResolveNetworkMonitorMethod "stealData" o = ObjectStealDataMethodInfo 
ResolveNetworkMonitorMethod "stealQdata" o = ObjectStealQdataMethodInfo 
ResolveNetworkMonitorMethod "thawNotify" o = ObjectThawNotifyMethodInfo 
ResolveNetworkMonitorMethod "unref" o = ObjectUnrefMethodInfo 
ResolveNetworkMonitorMethod "watchClosure" o = ObjectWatchClosureMethodInfo 
ResolveNetworkMonitorMethod "getConnectivity" o = NetworkMonitorGetConnectivityMethodInfo 
ResolveNetworkMonitorMethod "getData" o = ObjectGetDataMethodInfo 
ResolveNetworkMonitorMethod "getNetworkAvailable" o = NetworkMonitorGetNetworkAvailableMethodInfo 
ResolveNetworkMonitorMethod "getNetworkMetered" o = NetworkMonitorGetNetworkMeteredMethodInfo 
ResolveNetworkMonitorMethod "getProperty" o = ObjectGetPropertyMethodInfo 
ResolveNetworkMonitorMethod "getQdata" o = ObjectGetQdataMethodInfo 
ResolveNetworkMonitorMethod "setData" o = ObjectSetDataMethodInfo 
ResolveNetworkMonitorMethod "setDataFull" o = ObjectSetDataFullMethodInfo 
ResolveNetworkMonitorMethod "setProperty" o = ObjectSetPropertyMethodInfo 
ResolveNetworkMonitorMethod l o = MethodResolutionFailed l o :: Type 

canReach

networkMonitorCanReach Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a, IsSocketConnectable b, IsCancellable c) 
=> a

monitor: a NetworkMonitor

-> b

connectable: a SocketConnectable

-> Maybe c

cancellable: a Cancellable, or Nothing

-> m ()

(Can throw GError)

Attempts to determine whether or not the host pointed to by connectable can be reached, without actually trying to connect to it.

This may return True even when NetworkMonitor:networkAvailable is False, if, for example, monitor can determine that connectable refers to a host on a local network.

If monitor believes that an attempt to connect to connectable will succeed, it will return True. Otherwise, it will return False and set error to an appropriate error (such as IOErrorEnumHostUnreachable).

Note that although this does not attempt to connect to connectable, it may still block for a brief period of time (eg, trying to do multicast DNS on the local network), so if you do not want to block, you should use networkMonitorCanReachAsync.

Since: 2.32

canReachAsync

networkMonitorCanReachAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a, IsSocketConnectable b, IsCancellable c) 
=> a

monitor: a NetworkMonitor

-> b

connectable: a SocketConnectable

-> Maybe c

cancellable: a Cancellable, or Nothing

-> Maybe AsyncReadyCallback

callback: a AsyncReadyCallback to call when the request is satisfied

-> m () 

Asynchronously attempts to determine whether or not the host pointed to by connectable can be reached, without actually trying to connect to it.

For more details, see networkMonitorCanReach.

When the operation is finished, callback will be called. You can then call networkMonitorCanReachFinish to get the result of the operation.

canReachFinish

networkMonitorCanReachFinish Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a, IsAsyncResult b) 
=> a

monitor: a NetworkMonitor

-> b

result: a AsyncResult

-> m ()

(Can throw GError)

Finishes an async network connectivity test. See networkMonitorCanReachAsync.

getConnectivity

networkMonitorGetConnectivity Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a) 
=> a

monitor: the NetworkMonitor

-> m NetworkConnectivity

Returns: the network connectivity state

Gets a more detailed networking state than networkMonitorGetNetworkAvailable.

If NetworkMonitor:networkAvailable is False, then the connectivity state will be NetworkConnectivityLocal.

If NetworkMonitor:networkAvailable is True, then the connectivity state will be NetworkConnectivityFull (if there is full Internet connectivity), NetworkConnectivityLimited (if the host has a default route, but appears to be unable to actually reach the full Internet), or NetworkConnectivityPortal (if the host is trapped behind a "captive portal" that requires some sort of login or acknowledgement before allowing full Internet access).

Note that in the case of NetworkConnectivityLimited and NetworkConnectivityPortal, it is possible that some sites are reachable but others are not. In this case, applications can attempt to connect to remote servers, but should gracefully fall back to their "offline" behavior if the connection attempt fails.

Since: 2.44

getDefault

networkMonitorGetDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m NetworkMonitor

Returns: a NetworkMonitor, which will be a dummy object if no network monitor is available

Gets the default NetworkMonitor for the system.

Since: 2.32

getNetworkAvailable

networkMonitorGetNetworkAvailable Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a) 
=> a

monitor: the NetworkMonitor

-> m Bool

Returns: whether the network is available

Checks if the network is available. "Available" here means that the system has a default route available for at least one of IPv4 or IPv6. It does not necessarily imply that the public Internet is reachable. See NetworkMonitor:networkAvailable for more details.

Since: 2.32

getNetworkMetered

networkMonitorGetNetworkMetered Source #

Arguments

:: (HasCallStack, MonadIO m, IsNetworkMonitor a) 
=> a

monitor: the NetworkMonitor

-> m Bool

Returns: whether the connection is metered

Checks if the network is metered. See NetworkMonitor:networkMetered for more details.

Since: 2.46

Properties

connectivity

More detailed information about the host's network connectivity. See networkMonitorGetConnectivity and NetworkConnectivity for more details.

Since: 2.44

data NetworkMonitorConnectivityPropertyInfo Source #

Instances

Instances details
AttrInfo NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

Associated Types

type AttrAllowedOps NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrBaseTypeConstraint NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrGetType NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrSetTypeConstraint NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferTypeConstraint NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferType NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrLabel NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrOrigin NetworkMonitorConnectivityPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrAllowedOps NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrBaseTypeConstraint NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrGetType NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrLabel NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrOrigin NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrSetTypeConstraint NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferType NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferTypeConstraint NetworkMonitorConnectivityPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

getNetworkMonitorConnectivity :: (MonadIO m, IsNetworkMonitor o) => o -> m NetworkConnectivity Source #

Get the value of the “connectivity” property. When overloading is enabled, this is equivalent to

get networkMonitor #connectivity

networkAvailable

Whether the network is considered available. That is, whether the system has a default route for at least one of IPv4 or IPv6.

Real-world networks are of course much more complicated than this; the machine may be connected to a wifi hotspot that requires payment before allowing traffic through, or may be connected to a functioning router that has lost its own upstream connectivity. Some hosts might only be accessible when a VPN is active. Other hosts might only be accessible when the VPN is not active. Thus, it is best to use networkMonitorCanReach or networkMonitorCanReachAsync to test for reachability on a host-by-host basis. (On the other hand, when the property is False, the application can reasonably expect that no remote hosts at all are reachable, and should indicate this to the user in its UI.)

See also NetworkMonitor::networkChanged.

Since: 2.32

data NetworkMonitorNetworkAvailablePropertyInfo Source #

Instances

Instances details
AttrInfo NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

Associated Types

type AttrAllowedOps NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrBaseTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrGetType NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrSetTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferType NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrLabel NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrOrigin NetworkMonitorNetworkAvailablePropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrAllowedOps NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrBaseTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrGetType NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrLabel NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrOrigin NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrSetTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferType NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

getNetworkMonitorNetworkAvailable :: (MonadIO m, IsNetworkMonitor o) => o -> m Bool Source #

Get the value of the “network-available” property. When overloading is enabled, this is equivalent to

get networkMonitor #networkAvailable

networkMetered

Whether the network is considered metered.

That is, whether the system has traffic flowing through the default connection that is 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. Anything more than a few hundreds of kilobytes of data usage per hour should be avoided without asking permission from the user.

If more information is required about specific devices then the system network management API should be used instead (for example, NetworkManager or ConnMan).

If this information is not available then no networks will be marked as metered.

See also NetworkMonitor:networkAvailable.

Since: 2.46

data NetworkMonitorNetworkMeteredPropertyInfo Source #

Instances

Instances details
AttrInfo NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

Associated Types

type AttrAllowedOps NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrBaseTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrGetType NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrSetTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferType NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrLabel NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrOrigin NetworkMonitorNetworkMeteredPropertyInfo 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrAllowedOps NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrBaseTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrGetType NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrLabel NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrOrigin NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrSetTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferType NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

type AttrTransferTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo Source # 
Instance details

Defined in GI.Gio.Interfaces.NetworkMonitor

getNetworkMonitorNetworkMetered :: (MonadIO m, IsNetworkMonitor o) => o -> m Bool Source #

Get the value of the “network-metered” property. When overloading is enabled, this is equivalent to

get networkMonitor #networkMetered

Signals

networkChanged

type NetworkMonitorNetworkChangedCallback Source #

Arguments

 = Bool

networkAvailable: the current value of NetworkMonitor:networkAvailable

-> IO () 

Emitted when the network configuration changes.

Since: 2.32

afterNetworkMonitorNetworkChanged :: (IsNetworkMonitor a, MonadIO m) => a -> ((?self :: a) => NetworkMonitorNetworkChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the networkChanged signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after networkMonitor #networkChanged callback

By default the object invoking the signal is not passed to the callback. If you need to access it, you can use the implit ?self parameter. Note that this requires activating the ImplicitParams GHC extension.

onNetworkMonitorNetworkChanged :: (IsNetworkMonitor a, MonadIO m) => a -> ((?self :: a) => NetworkMonitorNetworkChangedCallback) -> m SignalHandlerId Source #

Connect a signal handler for the networkChanged signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on networkMonitor #networkChanged callback