{-# LANGUAGE ImplicitParams, RankNTypes, TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.Gio.Interfaces.NetworkMonitor
(
NetworkMonitor(..) ,
IsNetworkMonitor ,
toNetworkMonitor ,
#if defined(ENABLE_OVERLOADING)
ResolveNetworkMonitorMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
NetworkMonitorCanReachMethodInfo ,
#endif
networkMonitorCanReach ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorCanReachAsyncMethodInfo ,
#endif
networkMonitorCanReachAsync ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorCanReachFinishMethodInfo ,
#endif
networkMonitorCanReachFinish ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorGetConnectivityMethodInfo ,
#endif
networkMonitorGetConnectivity ,
networkMonitorGetDefault ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorGetNetworkAvailableMethodInfo,
#endif
networkMonitorGetNetworkAvailable ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorGetNetworkMeteredMethodInfo,
#endif
networkMonitorGetNetworkMetered ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorConnectivityPropertyInfo ,
#endif
getNetworkMonitorConnectivity ,
#if defined(ENABLE_OVERLOADING)
networkMonitorConnectivity ,
#endif
#if defined(ENABLE_OVERLOADING)
NetworkMonitorNetworkAvailablePropertyInfo,
#endif
getNetworkMonitorNetworkAvailable ,
#if defined(ENABLE_OVERLOADING)
networkMonitorNetworkAvailable ,
#endif
#if defined(ENABLE_OVERLOADING)
NetworkMonitorNetworkMeteredPropertyInfo,
#endif
getNetworkMonitorNetworkMetered ,
#if defined(ENABLE_OVERLOADING)
networkMonitorNetworkMetered ,
#endif
NetworkMonitorNetworkChangedCallback ,
#if defined(ENABLE_OVERLOADING)
NetworkMonitorNetworkChangedSignalInfo ,
#endif
afterNetworkMonitorNetworkChanged ,
onNetworkMonitorNetworkChanged ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.PollFD as GLib.PollFD
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Callbacks as GObject.Callbacks
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.GObject.Structs.Parameter as GObject.Parameter
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
import {-# SOURCE #-} qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketAddress as Gio.SocketAddress
import {-# SOURCE #-} qualified GI.Gio.Objects.SocketAddressEnumerator as Gio.SocketAddressEnumerator
#else
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
import {-# SOURCE #-} qualified GI.Gio.Interfaces.SocketConnectable as Gio.SocketConnectable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
#endif
newtype NetworkMonitor = NetworkMonitor (SP.ManagedPtr NetworkMonitor)
deriving (NetworkMonitor -> NetworkMonitor -> Bool
(NetworkMonitor -> NetworkMonitor -> Bool)
-> (NetworkMonitor -> NetworkMonitor -> Bool) -> Eq NetworkMonitor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NetworkMonitor -> NetworkMonitor -> Bool
== :: NetworkMonitor -> NetworkMonitor -> Bool
$c/= :: NetworkMonitor -> NetworkMonitor -> Bool
/= :: NetworkMonitor -> NetworkMonitor -> Bool
Eq)
instance SP.ManagedPtrNewtype NetworkMonitor where
toManagedPtr :: NetworkMonitor -> ManagedPtr NetworkMonitor
toManagedPtr (NetworkMonitor ManagedPtr NetworkMonitor
p) = ManagedPtr NetworkMonitor
p
foreign import ccall "g_network_monitor_get_type"
c_g_network_monitor_get_type :: IO B.Types.GType
instance B.Types.TypedObject NetworkMonitor where
glibType :: IO GType
glibType = IO GType
c_g_network_monitor_get_type
instance B.Types.GObject NetworkMonitor
class (SP.GObject o, O.IsDescendantOf NetworkMonitor o) => IsNetworkMonitor o
instance (SP.GObject o, O.IsDescendantOf NetworkMonitor o) => IsNetworkMonitor o
instance O.HasParentTypes NetworkMonitor
type instance O.ParentTypes NetworkMonitor = '[Gio.Initable.Initable, GObject.Object.Object]
toNetworkMonitor :: (MIO.MonadIO m, IsNetworkMonitor o) => o -> m NetworkMonitor
toNetworkMonitor :: forall (m :: * -> *) o.
(MonadIO m, IsNetworkMonitor o) =>
o -> m NetworkMonitor
toNetworkMonitor = IO NetworkMonitor -> m NetworkMonitor
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO NetworkMonitor -> m NetworkMonitor)
-> (o -> IO NetworkMonitor) -> o -> m NetworkMonitor
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr NetworkMonitor -> NetworkMonitor)
-> o -> IO NetworkMonitor
forall o o'.
(HasCallStack, ManagedPtrNewtype o, TypedObject o,
ManagedPtrNewtype o', TypedObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
B.ManagedPtr.unsafeCastTo ManagedPtr NetworkMonitor -> NetworkMonitor
NetworkMonitor
instance B.GValue.IsGValue (Maybe NetworkMonitor) where
gvalueGType_ :: IO GType
gvalueGType_ = IO GType
c_g_network_monitor_get_type
gvalueSet_ :: Ptr GValue -> Maybe NetworkMonitor -> IO ()
gvalueSet_ Ptr GValue
gv Maybe NetworkMonitor
P.Nothing = Ptr GValue -> Ptr NetworkMonitor -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv (Ptr NetworkMonitor
forall a. Ptr a
FP.nullPtr :: FP.Ptr NetworkMonitor)
gvalueSet_ Ptr GValue
gv (P.Just NetworkMonitor
obj) = NetworkMonitor -> (Ptr NetworkMonitor -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr NetworkMonitor
obj (Ptr GValue -> Ptr NetworkMonitor -> IO ()
forall a. GObject a => Ptr GValue -> Ptr a -> IO ()
B.GValue.set_object Ptr GValue
gv)
gvalueGet_ :: Ptr GValue -> IO (Maybe NetworkMonitor)
gvalueGet_ Ptr GValue
gv = do
ptr <- Ptr GValue -> IO (Ptr NetworkMonitor)
forall a. GObject a => Ptr GValue -> IO (Ptr a)
B.GValue.get_object Ptr GValue
gv :: IO (FP.Ptr NetworkMonitor)
if ptr /= FP.nullPtr
then P.Just <$> B.ManagedPtr.newObject NetworkMonitor ptr
else return P.Nothing
getNetworkMonitorConnectivity :: (MonadIO m, IsNetworkMonitor o) => o -> m Gio.Enums.NetworkConnectivity
getNetworkMonitorConnectivity :: forall (m :: * -> *) o.
(MonadIO m, IsNetworkMonitor o) =>
o -> m NetworkConnectivity
getNetworkMonitorConnectivity o
obj = IO NetworkConnectivity -> m NetworkConnectivity
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO NetworkConnectivity -> m NetworkConnectivity)
-> IO NetworkConnectivity -> m NetworkConnectivity
forall a b. (a -> b) -> a -> b
$ o -> String -> IO NetworkConnectivity
forall a b. (GObject a, Enum b, BoxedEnum b) => a -> String -> IO b
B.Properties.getObjectPropertyEnum o
obj String
"connectivity"
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorConnectivityPropertyInfo
instance AttrInfo NetworkMonitorConnectivityPropertyInfo where
type AttrAllowedOps NetworkMonitorConnectivityPropertyInfo = '[ 'AttrGet]
type AttrBaseTypeConstraint NetworkMonitorConnectivityPropertyInfo = IsNetworkMonitor
type AttrSetTypeConstraint NetworkMonitorConnectivityPropertyInfo = (~) ()
type AttrTransferTypeConstraint NetworkMonitorConnectivityPropertyInfo = (~) ()
type AttrTransferType NetworkMonitorConnectivityPropertyInfo = ()
type AttrGetType NetworkMonitorConnectivityPropertyInfo = Gio.Enums.NetworkConnectivity
type AttrLabel NetworkMonitorConnectivityPropertyInfo = "connectivity"
type AttrOrigin NetworkMonitorConnectivityPropertyInfo = NetworkMonitor
attrGet = getNetworkMonitorConnectivity
attrSet = undefined
attrTransfer _ = undefined
attrConstruct = undefined
attrClear = undefined
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.connectivity"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#g:attr:connectivity"
})
#endif
getNetworkMonitorNetworkAvailable :: (MonadIO m, IsNetworkMonitor o) => o -> m Bool
getNetworkMonitorNetworkAvailable :: forall (m :: * -> *) o.
(MonadIO m, IsNetworkMonitor o) =>
o -> m Bool
getNetworkMonitorNetworkAvailable o
obj = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"network-available"
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorNetworkAvailablePropertyInfo
instance AttrInfo NetworkMonitorNetworkAvailablePropertyInfo where
type AttrAllowedOps NetworkMonitorNetworkAvailablePropertyInfo = '[ 'AttrGet]
type AttrBaseTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo = IsNetworkMonitor
type AttrSetTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo = (~) ()
type AttrTransferTypeConstraint NetworkMonitorNetworkAvailablePropertyInfo = (~) ()
type AttrTransferType NetworkMonitorNetworkAvailablePropertyInfo = ()
type AttrGetType NetworkMonitorNetworkAvailablePropertyInfo = Bool
type AttrLabel NetworkMonitorNetworkAvailablePropertyInfo = "network-available"
type AttrOrigin NetworkMonitorNetworkAvailablePropertyInfo = NetworkMonitor
attrGet = getNetworkMonitorNetworkAvailable
attrSet = undefined
attrTransfer _ = undefined
attrConstruct = undefined
attrClear = undefined
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkAvailable"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#g:attr:networkAvailable"
})
#endif
getNetworkMonitorNetworkMetered :: (MonadIO m, IsNetworkMonitor o) => o -> m Bool
getNetworkMonitorNetworkMetered :: forall (m :: * -> *) o.
(MonadIO m, IsNetworkMonitor o) =>
o -> m Bool
getNetworkMonitorNetworkMetered o
obj = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
MIO.liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ o -> String -> IO Bool
forall a. GObject a => a -> String -> IO Bool
B.Properties.getObjectPropertyBool o
obj String
"network-metered"
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorNetworkMeteredPropertyInfo
instance AttrInfo NetworkMonitorNetworkMeteredPropertyInfo where
type AttrAllowedOps NetworkMonitorNetworkMeteredPropertyInfo = '[ 'AttrGet]
type AttrBaseTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo = IsNetworkMonitor
type AttrSetTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo = (~) ()
type AttrTransferTypeConstraint NetworkMonitorNetworkMeteredPropertyInfo = (~) ()
type AttrTransferType NetworkMonitorNetworkMeteredPropertyInfo = ()
type AttrGetType NetworkMonitorNetworkMeteredPropertyInfo = Bool
type AttrLabel NetworkMonitorNetworkMeteredPropertyInfo = "network-metered"
type AttrOrigin NetworkMonitorNetworkMeteredPropertyInfo = NetworkMonitor
attrGet = getNetworkMonitorNetworkMetered
attrSet = undefined
attrTransfer _ = undefined
attrConstruct = undefined
attrClear = undefined
dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMetered"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#g:attr:networkMetered"
})
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList NetworkMonitor
type instance O.AttributeList NetworkMonitor = NetworkMonitorAttributeList
type NetworkMonitorAttributeList = ('[ '("connectivity", NetworkMonitorConnectivityPropertyInfo), '("networkAvailable", NetworkMonitorNetworkAvailablePropertyInfo), '("networkMetered", NetworkMonitorNetworkMeteredPropertyInfo)] :: [(Symbol, DK.Type)])
#endif
#if defined(ENABLE_OVERLOADING)
networkMonitorConnectivity :: AttrLabelProxy "connectivity"
networkMonitorConnectivity = AttrLabelProxy
networkMonitorNetworkAvailable :: AttrLabelProxy "networkAvailable"
networkMonitorNetworkAvailable = AttrLabelProxy
networkMonitorNetworkMetered :: AttrLabelProxy "networkMetered"
networkMonitorNetworkMetered = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveNetworkMonitorMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
ResolveNetworkMonitorMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveNetworkMonitorMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveNetworkMonitorMethod "canReach" o = NetworkMonitorCanReachMethodInfo
ResolveNetworkMonitorMethod "canReachAsync" o = NetworkMonitorCanReachAsyncMethodInfo
ResolveNetworkMonitorMethod "canReachFinish" o = NetworkMonitorCanReachFinishMethodInfo
ResolveNetworkMonitorMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveNetworkMonitorMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveNetworkMonitorMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveNetworkMonitorMethod "init" o = Gio.Initable.InitableInitMethodInfo
ResolveNetworkMonitorMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveNetworkMonitorMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveNetworkMonitorMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveNetworkMonitorMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveNetworkMonitorMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveNetworkMonitorMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveNetworkMonitorMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveNetworkMonitorMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveNetworkMonitorMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveNetworkMonitorMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveNetworkMonitorMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveNetworkMonitorMethod "getConnectivity" o = NetworkMonitorGetConnectivityMethodInfo
ResolveNetworkMonitorMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveNetworkMonitorMethod "getNetworkAvailable" o = NetworkMonitorGetNetworkAvailableMethodInfo
ResolveNetworkMonitorMethod "getNetworkMetered" o = NetworkMonitorGetNetworkMeteredMethodInfo
ResolveNetworkMonitorMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveNetworkMonitorMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveNetworkMonitorMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveNetworkMonitorMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveNetworkMonitorMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveNetworkMonitorMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveNetworkMonitorMethod t NetworkMonitor, O.OverloadedMethod info NetworkMonitor p) => OL.IsLabel t (NetworkMonitor -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveNetworkMonitorMethod t NetworkMonitor, O.OverloadedMethod info NetworkMonitor p, R.HasField t NetworkMonitor p) => R.HasField t NetworkMonitor p where
getField = O.overloadedMethod @info
#endif
instance (info ~ ResolveNetworkMonitorMethod t NetworkMonitor, O.OverloadedMethodInfo info NetworkMonitor) => OL.IsLabel t (O.MethodProxy info NetworkMonitor) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.MethodProxy
#else
fromLabel _ = O.MethodProxy
#endif
#endif
foreign import ccall "g_network_monitor_can_reach" g_network_monitor_can_reach ::
Ptr NetworkMonitor ->
Ptr Gio.SocketConnectable.SocketConnectable ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO CInt
networkMonitorCanReach ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkMonitor a, Gio.SocketConnectable.IsSocketConnectable b, Gio.Cancellable.IsCancellable c) =>
a
-> b
-> Maybe (c)
-> m ()
networkMonitorCanReach :: forall (m :: * -> *) a b c.
(HasCallStack, MonadIO m, IsNetworkMonitor a,
IsSocketConnectable b, IsCancellable c) =>
a -> b -> Maybe c -> m ()
networkMonitorCanReach a
monitor b
connectable Maybe c
cancellable = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
monitor' <- a -> IO (Ptr NetworkMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
monitor
connectable' <- unsafeManagedPtrCastPtr connectable
maybeCancellable <- case cancellable of
Maybe c
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just c
jCancellable -> do
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
return jCancellable'
onException (do
_ <- propagateGError $ g_network_monitor_can_reach monitor' connectable' maybeCancellable
touchManagedPtr monitor
touchManagedPtr connectable
whenJust cancellable touchManagedPtr
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorCanReachMethodInfo
instance (signature ~ (b -> Maybe (c) -> m ()), MonadIO m, IsNetworkMonitor a, Gio.SocketConnectable.IsSocketConnectable b, Gio.Cancellable.IsCancellable c) => O.OverloadedMethod NetworkMonitorCanReachMethodInfo a signature where
overloadedMethod = networkMonitorCanReach
instance O.OverloadedMethodInfo NetworkMonitorCanReachMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMonitorCanReach",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#v:networkMonitorCanReach"
})
#endif
foreign import ccall "g_network_monitor_can_reach_async" g_network_monitor_can_reach_async ::
Ptr NetworkMonitor ->
Ptr Gio.SocketConnectable.SocketConnectable ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
networkMonitorCanReachAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkMonitor a, Gio.SocketConnectable.IsSocketConnectable b, Gio.Cancellable.IsCancellable c) =>
a
-> b
-> Maybe (c)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
networkMonitorCanReachAsync :: forall (m :: * -> *) a b c.
(HasCallStack, MonadIO m, IsNetworkMonitor a,
IsSocketConnectable b, IsCancellable c) =>
a -> b -> Maybe c -> Maybe AsyncReadyCallback -> m ()
networkMonitorCanReachAsync a
monitor b
connectable Maybe c
cancellable Maybe AsyncReadyCallback
callback = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
monitor' <- a -> IO (Ptr NetworkMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
monitor
connectable' <- unsafeManagedPtrCastPtr connectable
maybeCancellable <- case cancellable of
Maybe c
Nothing -> Ptr Cancellable -> IO (Ptr Cancellable)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Cancellable
forall a. Ptr a
FP.nullPtr
Just c
jCancellable -> do
jCancellable' <- c -> IO (Ptr Cancellable)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jCancellable
return jCancellable'
maybeCallback <- case callback of
Maybe AsyncReadyCallback
Nothing -> FunPtr C_AsyncReadyCallback -> IO (FunPtr C_AsyncReadyCallback)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_AsyncReadyCallback
forall a. FunPtr a
FP.nullFunPtr
Just AsyncReadyCallback
jCallback -> do
ptrcallback <- IO (Ptr (FunPtr C_AsyncReadyCallback))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
poke ptrcallback jCallback'
return jCallback'
let userData = Ptr a
forall a. Ptr a
nullPtr
g_network_monitor_can_reach_async monitor' connectable' maybeCancellable maybeCallback userData
touchManagedPtr monitor
touchManagedPtr connectable
whenJust cancellable touchManagedPtr
return ()
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorCanReachAsyncMethodInfo
instance (signature ~ (b -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsNetworkMonitor a, Gio.SocketConnectable.IsSocketConnectable b, Gio.Cancellable.IsCancellable c) => O.OverloadedMethod NetworkMonitorCanReachAsyncMethodInfo a signature where
overloadedMethod = networkMonitorCanReachAsync
instance O.OverloadedMethodInfo NetworkMonitorCanReachAsyncMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMonitorCanReachAsync",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#v:networkMonitorCanReachAsync"
})
#endif
foreign import ccall "g_network_monitor_can_reach_finish" g_network_monitor_can_reach_finish ::
Ptr NetworkMonitor ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO CInt
networkMonitorCanReachFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkMonitor a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m ()
networkMonitorCanReachFinish :: forall (m :: * -> *) a b.
(HasCallStack, MonadIO m, IsNetworkMonitor a, IsAsyncResult b) =>
a -> b -> m ()
networkMonitorCanReachFinish a
monitor b
result_ = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
monitor' <- a -> IO (Ptr NetworkMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
monitor
result_' <- unsafeManagedPtrCastPtr result_
onException (do
_ <- propagateGError $ g_network_monitor_can_reach_finish monitor' result_'
touchManagedPtr monitor
touchManagedPtr result_
return ()
) (do
return ()
)
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorCanReachFinishMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsNetworkMonitor a, Gio.AsyncResult.IsAsyncResult b) => O.OverloadedMethod NetworkMonitorCanReachFinishMethodInfo a signature where
overloadedMethod = networkMonitorCanReachFinish
instance O.OverloadedMethodInfo NetworkMonitorCanReachFinishMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMonitorCanReachFinish",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#v:networkMonitorCanReachFinish"
})
#endif
foreign import ccall "g_network_monitor_get_connectivity" g_network_monitor_get_connectivity ::
Ptr NetworkMonitor ->
IO CUInt
networkMonitorGetConnectivity ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkMonitor a) =>
a
-> m Gio.Enums.NetworkConnectivity
networkMonitorGetConnectivity :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsNetworkMonitor a) =>
a -> m NetworkConnectivity
networkMonitorGetConnectivity a
monitor = IO NetworkConnectivity -> m NetworkConnectivity
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO NetworkConnectivity -> m NetworkConnectivity)
-> IO NetworkConnectivity -> m NetworkConnectivity
forall a b. (a -> b) -> a -> b
$ do
monitor' <- a -> IO (Ptr NetworkMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
monitor
result <- g_network_monitor_get_connectivity monitor'
let result' = (Int -> NetworkConnectivity
forall a. Enum a => Int -> a
toEnum (Int -> NetworkConnectivity)
-> (CUInt -> Int) -> CUInt -> NetworkConnectivity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
result
touchManagedPtr monitor
return result'
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorGetConnectivityMethodInfo
instance (signature ~ (m Gio.Enums.NetworkConnectivity), MonadIO m, IsNetworkMonitor a) => O.OverloadedMethod NetworkMonitorGetConnectivityMethodInfo a signature where
overloadedMethod = networkMonitorGetConnectivity
instance O.OverloadedMethodInfo NetworkMonitorGetConnectivityMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMonitorGetConnectivity",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#v:networkMonitorGetConnectivity"
})
#endif
foreign import ccall "g_network_monitor_get_network_available" g_network_monitor_get_network_available ::
Ptr NetworkMonitor ->
IO CInt
networkMonitorGetNetworkAvailable ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkMonitor a) =>
a
-> m Bool
networkMonitorGetNetworkAvailable :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsNetworkMonitor a) =>
a -> m Bool
networkMonitorGetNetworkAvailable a
monitor = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
monitor' <- a -> IO (Ptr NetworkMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
monitor
result <- g_network_monitor_get_network_available monitor'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr monitor
return result'
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorGetNetworkAvailableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsNetworkMonitor a) => O.OverloadedMethod NetworkMonitorGetNetworkAvailableMethodInfo a signature where
overloadedMethod = networkMonitorGetNetworkAvailable
instance O.OverloadedMethodInfo NetworkMonitorGetNetworkAvailableMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMonitorGetNetworkAvailable",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#v:networkMonitorGetNetworkAvailable"
})
#endif
foreign import ccall "g_network_monitor_get_network_metered" g_network_monitor_get_network_metered ::
Ptr NetworkMonitor ->
IO CInt
networkMonitorGetNetworkMetered ::
(B.CallStack.HasCallStack, MonadIO m, IsNetworkMonitor a) =>
a
-> m Bool
networkMonitorGetNetworkMetered :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsNetworkMonitor a) =>
a -> m Bool
networkMonitorGetNetworkMetered a
monitor = IO Bool -> m Bool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
monitor' <- a -> IO (Ptr NetworkMonitor)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
monitor
result <- g_network_monitor_get_network_metered monitor'
let result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
touchManagedPtr monitor
return result'
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorGetNetworkMeteredMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsNetworkMonitor a) => O.OverloadedMethod NetworkMonitorGetNetworkMeteredMethodInfo a signature where
overloadedMethod = networkMonitorGetNetworkMetered
instance O.OverloadedMethodInfo NetworkMonitorGetNetworkMeteredMethodInfo a where
overloadedMethodInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor.networkMonitorGetNetworkMetered",
O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#v:networkMonitorGetNetworkMetered"
})
#endif
foreign import ccall "g_network_monitor_get_default" g_network_monitor_get_default ::
IO (Ptr NetworkMonitor)
networkMonitorGetDefault ::
(B.CallStack.HasCallStack, MonadIO m) =>
m NetworkMonitor
networkMonitorGetDefault :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m NetworkMonitor
networkMonitorGetDefault = IO NetworkMonitor -> m NetworkMonitor
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO NetworkMonitor -> m NetworkMonitor)
-> IO NetworkMonitor -> m NetworkMonitor
forall a b. (a -> b) -> a -> b
$ do
result <- IO (Ptr NetworkMonitor)
g_network_monitor_get_default
checkUnexpectedReturnNULL "networkMonitorGetDefault" result
result' <- (newObject NetworkMonitor) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
type NetworkMonitorNetworkChangedCallback =
Bool
-> IO ()
type C_NetworkMonitorNetworkChangedCallback =
Ptr NetworkMonitor ->
CInt ->
Ptr () ->
IO ()
foreign import ccall "wrapper"
mk_NetworkMonitorNetworkChangedCallback :: C_NetworkMonitorNetworkChangedCallback -> IO (FunPtr C_NetworkMonitorNetworkChangedCallback)
wrap_NetworkMonitorNetworkChangedCallback ::
GObject a => (a -> NetworkMonitorNetworkChangedCallback) ->
C_NetworkMonitorNetworkChangedCallback
wrap_NetworkMonitorNetworkChangedCallback :: forall a.
GObject a =>
(a -> NetworkMonitorNetworkChangedCallback)
-> C_NetworkMonitorNetworkChangedCallback
wrap_NetworkMonitorNetworkChangedCallback a -> NetworkMonitorNetworkChangedCallback
gi'cb Ptr NetworkMonitor
gi'selfPtr CInt
networkAvailable Ptr ()
_ = do
let networkAvailable' :: Bool
networkAvailable' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
networkAvailable
Ptr NetworkMonitor -> (NetworkMonitor -> IO ()) -> IO ()
forall o b.
(HasCallStack, GObject o) =>
Ptr o -> (o -> IO b) -> IO b
B.ManagedPtr.withNewObject Ptr NetworkMonitor
gi'selfPtr ((NetworkMonitor -> IO ()) -> IO ())
-> (NetworkMonitor -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \NetworkMonitor
gi'self -> a -> NetworkMonitorNetworkChangedCallback
gi'cb (NetworkMonitor -> a
forall a b. Coercible a b => a -> b
Coerce.coerce NetworkMonitor
gi'self) Bool
networkAvailable'
onNetworkMonitorNetworkChanged :: (IsNetworkMonitor a, MonadIO m) => a -> ((?self :: a) => NetworkMonitorNetworkChangedCallback) -> m SignalHandlerId
onNetworkMonitorNetworkChanged :: forall a (m :: * -> *).
(IsNetworkMonitor a, MonadIO m) =>
a
-> ((?self::a) => NetworkMonitorNetworkChangedCallback)
-> m SignalHandlerId
onNetworkMonitorNetworkChanged a
obj (?self::a) => NetworkMonitorNetworkChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
let wrapped :: a -> NetworkMonitorNetworkChangedCallback
wrapped a
self = let ?self = a
?self::a
self in (?self::a) => NetworkMonitorNetworkChangedCallback
NetworkMonitorNetworkChangedCallback
cb
let wrapped' :: C_NetworkMonitorNetworkChangedCallback
wrapped' = (a -> NetworkMonitorNetworkChangedCallback)
-> C_NetworkMonitorNetworkChangedCallback
forall a.
GObject a =>
(a -> NetworkMonitorNetworkChangedCallback)
-> C_NetworkMonitorNetworkChangedCallback
wrap_NetworkMonitorNetworkChangedCallback a -> NetworkMonitorNetworkChangedCallback
wrapped
wrapped'' <- C_NetworkMonitorNetworkChangedCallback
-> IO (FunPtr C_NetworkMonitorNetworkChangedCallback)
mk_NetworkMonitorNetworkChangedCallback C_NetworkMonitorNetworkChangedCallback
wrapped'
connectSignalFunPtr obj "network-changed" wrapped'' SignalConnectBefore Nothing
afterNetworkMonitorNetworkChanged :: (IsNetworkMonitor a, MonadIO m) => a -> ((?self :: a) => NetworkMonitorNetworkChangedCallback) -> m SignalHandlerId
afterNetworkMonitorNetworkChanged :: forall a (m :: * -> *).
(IsNetworkMonitor a, MonadIO m) =>
a
-> ((?self::a) => NetworkMonitorNetworkChangedCallback)
-> m SignalHandlerId
afterNetworkMonitorNetworkChanged a
obj (?self::a) => NetworkMonitorNetworkChangedCallback
cb = IO SignalHandlerId -> m SignalHandlerId
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SignalHandlerId -> m SignalHandlerId)
-> IO SignalHandlerId -> m SignalHandlerId
forall a b. (a -> b) -> a -> b
$ do
let wrapped :: a -> NetworkMonitorNetworkChangedCallback
wrapped a
self = let ?self = a
?self::a
self in (?self::a) => NetworkMonitorNetworkChangedCallback
NetworkMonitorNetworkChangedCallback
cb
let wrapped' :: C_NetworkMonitorNetworkChangedCallback
wrapped' = (a -> NetworkMonitorNetworkChangedCallback)
-> C_NetworkMonitorNetworkChangedCallback
forall a.
GObject a =>
(a -> NetworkMonitorNetworkChangedCallback)
-> C_NetworkMonitorNetworkChangedCallback
wrap_NetworkMonitorNetworkChangedCallback a -> NetworkMonitorNetworkChangedCallback
wrapped
wrapped'' <- C_NetworkMonitorNetworkChangedCallback
-> IO (FunPtr C_NetworkMonitorNetworkChangedCallback)
mk_NetworkMonitorNetworkChangedCallback C_NetworkMonitorNetworkChangedCallback
wrapped'
connectSignalFunPtr obj "network-changed" wrapped'' SignalConnectAfter Nothing
#if defined(ENABLE_OVERLOADING)
data NetworkMonitorNetworkChangedSignalInfo
instance SignalInfo NetworkMonitorNetworkChangedSignalInfo where
type HaskellCallbackType NetworkMonitorNetworkChangedSignalInfo = NetworkMonitorNetworkChangedCallback
connectSignal obj cb connectMode detail = do
let cb' = wrap_NetworkMonitorNetworkChangedCallback cb
cb'' <- mk_NetworkMonitorNetworkChangedCallback cb'
connectSignalFunPtr obj "network-changed" cb'' connectMode detail
dbgSignalInfo = P.Just (O.ResolvedSymbolInfo {
O.resolvedSymbolName = "GI.Gio.Interfaces.NetworkMonitor::network-changed"
, O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-gio-2.0.35/docs/GI-Gio-Interfaces-NetworkMonitor.html#g:signal:networkChanged"})
#endif
#if defined(ENABLE_OVERLOADING)
type instance O.SignalList NetworkMonitor = NetworkMonitorSignalList
type NetworkMonitorSignalList = ('[ '("networkChanged", NetworkMonitorNetworkChangedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])
#endif