-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.NM.Functions
    ( 

 -- * Methods


-- ** connWireguardImport #method:connWireguardImport#

    connWireguardImport                     ,


-- ** ethtoolOptnameIsChannels #method:ethtoolOptnameIsChannels#

    ethtoolOptnameIsChannels                ,


-- ** ethtoolOptnameIsCoalesce #method:ethtoolOptnameIsCoalesce#

    ethtoolOptnameIsCoalesce                ,


-- ** ethtoolOptnameIsEee #method:ethtoolOptnameIsEee#

    ethtoolOptnameIsEee                     ,


-- ** ethtoolOptnameIsFeature #method:ethtoolOptnameIsFeature#

    ethtoolOptnameIsFeature                 ,


-- ** ethtoolOptnameIsPause #method:ethtoolOptnameIsPause#

    ethtoolOptnameIsPause                   ,


-- ** ethtoolOptnameIsRing #method:ethtoolOptnameIsRing#

    ethtoolOptnameIsRing                    ,


-- ** keyfileRead #method:keyfileRead#

    keyfileRead                             ,


-- ** keyfileWrite #method:keyfileWrite#

    keyfileWrite                            ,


-- ** utilsApModeSecurityValid #method:utilsApModeSecurityValid#

    utilsApModeSecurityValid                ,


-- ** utilsBase64secretDecode #method:utilsBase64secretDecode#

    utilsBase64secretDecode                 ,


-- ** utilsBin2hexstr #method:utilsBin2hexstr#

    utilsBin2hexstr                         ,


-- ** utilsBondModeIntToString #method:utilsBondModeIntToString#

    utilsBondModeIntToString                ,


-- ** utilsBondModeStringToInt #method:utilsBondModeStringToInt#

    utilsBondModeStringToInt                ,


-- ** utilsCheckVirtualDeviceCompatibility #method:utilsCheckVirtualDeviceCompatibility#

    utilsCheckVirtualDeviceCompatibility    ,


-- ** utilsEnsureGtypes #method:utilsEnsureGtypes#

    utilsEnsureGtypes                       ,


-- ** utilsEnumFromStr #method:utilsEnumFromStr#

    utilsEnumFromStr                        ,


-- ** utilsEnumGetValues #method:utilsEnumGetValues#

    utilsEnumGetValues                      ,


-- ** utilsEnumToStr #method:utilsEnumToStr#

    utilsEnumToStr                          ,


-- ** utilsEscapeSsid #method:utilsEscapeSsid#

    utilsEscapeSsid                         ,


-- ** utilsFileIsCertificate #method:utilsFileIsCertificate#

    utilsFileIsCertificate                  ,


-- ** utilsFileIsPkcs12 #method:utilsFileIsPkcs12#

    utilsFileIsPkcs12                       ,


-- ** utilsFileIsPrivateKey #method:utilsFileIsPrivateKey#

    utilsFileIsPrivateKey                   ,


-- ** utilsFileSearchInPaths #method:utilsFileSearchInPaths#

    utilsFileSearchInPaths                  ,


-- ** utilsGetTimestampMsec #method:utilsGetTimestampMsec#

    utilsGetTimestampMsec                   ,


-- ** utilsHexstr2bin #method:utilsHexstr2bin#

    utilsHexstr2bin                         ,


-- ** utilsHwaddrAtoba #method:utilsHwaddrAtoba#

    utilsHwaddrAtoba                        ,


-- ** utilsHwaddrAton #method:utilsHwaddrAton#

    utilsHwaddrAton                         ,


-- ** utilsHwaddrCanonical #method:utilsHwaddrCanonical#

    utilsHwaddrCanonical                    ,


-- ** utilsHwaddrLen #method:utilsHwaddrLen#

    utilsHwaddrLen                          ,


-- ** utilsHwaddrMatches #method:utilsHwaddrMatches#

    utilsHwaddrMatches                      ,


-- ** utilsHwaddrNtoa #method:utilsHwaddrNtoa#

    utilsHwaddrNtoa                         ,


-- ** utilsHwaddrValid #method:utilsHwaddrValid#

    utilsHwaddrValid                        ,


-- ** utilsIfaceValidName #method:utilsIfaceValidName#

    utilsIfaceValidName                     ,


-- ** utilsIp4AddressesFromVariant #method:utilsIp4AddressesFromVariant#

    utilsIp4AddressesFromVariant            ,


-- ** utilsIp4AddressesToVariant #method:utilsIp4AddressesToVariant#

    utilsIp4AddressesToVariant              ,


-- ** utilsIp4DnsFromVariant #method:utilsIp4DnsFromVariant#

    utilsIp4DnsFromVariant                  ,


-- ** utilsIp4DnsToVariant #method:utilsIp4DnsToVariant#

    utilsIp4DnsToVariant                    ,


-- ** utilsIp4GetDefaultPrefix #method:utilsIp4GetDefaultPrefix#

    utilsIp4GetDefaultPrefix                ,


-- ** utilsIp4NetmaskToPrefix #method:utilsIp4NetmaskToPrefix#

    utilsIp4NetmaskToPrefix                 ,


-- ** utilsIp4PrefixToNetmask #method:utilsIp4PrefixToNetmask#

    utilsIp4PrefixToNetmask                 ,


-- ** utilsIp4RoutesFromVariant #method:utilsIp4RoutesFromVariant#

    utilsIp4RoutesFromVariant               ,


-- ** utilsIp4RoutesToVariant #method:utilsIp4RoutesToVariant#

    utilsIp4RoutesToVariant                 ,


-- ** utilsIp6AddressesFromVariant #method:utilsIp6AddressesFromVariant#

    utilsIp6AddressesFromVariant            ,


-- ** utilsIp6AddressesToVariant #method:utilsIp6AddressesToVariant#

    utilsIp6AddressesToVariant              ,


-- ** utilsIp6DnsFromVariant #method:utilsIp6DnsFromVariant#

    utilsIp6DnsFromVariant                  ,


-- ** utilsIp6DnsToVariant #method:utilsIp6DnsToVariant#

    utilsIp6DnsToVariant                    ,


-- ** utilsIp6RoutesFromVariant #method:utilsIp6RoutesFromVariant#

    utilsIp6RoutesFromVariant               ,


-- ** utilsIp6RoutesToVariant #method:utilsIp6RoutesToVariant#

    utilsIp6RoutesToVariant                 ,


-- ** utilsIpAddressesFromVariant #method:utilsIpAddressesFromVariant#

    utilsIpAddressesFromVariant             ,


-- ** utilsIpAddressesToVariant #method:utilsIpAddressesToVariant#

    utilsIpAddressesToVariant               ,


-- ** utilsIpRoutesFromVariant #method:utilsIpRoutesFromVariant#

    utilsIpRoutesFromVariant                ,


-- ** utilsIpRoutesToVariant #method:utilsIpRoutesToVariant#

    utilsIpRoutesToVariant                  ,


-- ** utilsIpaddrValid #method:utilsIpaddrValid#

    utilsIpaddrValid                        ,


-- ** utilsIsEmptySsid #method:utilsIsEmptySsid#

    utilsIsEmptySsid                        ,


-- ** utilsIsJsonObject #method:utilsIsJsonObject#

    utilsIsJsonObject                       ,


-- ** utilsIsUuid #method:utilsIsUuid#

    utilsIsUuid                             ,


-- ** utilsIsValidIfaceName #method:utilsIsValidIfaceName#

    utilsIsValidIfaceName                   ,


-- ** utilsPrint #method:utilsPrint#

    utilsPrint                              ,


-- ** utilsSameSsid #method:utilsSameSsid#

    utilsSameSsid                           ,


-- ** utilsSecurityValid #method:utilsSecurityValid#

    utilsSecurityValid                      ,


-- ** utilsSriovVfFromStr #method:utilsSriovVfFromStr#

    utilsSriovVfFromStr                     ,


-- ** utilsSriovVfToStr #method:utilsSriovVfToStr#

    utilsSriovVfToStr                       ,


-- ** utilsSsidToUtf8 #method:utilsSsidToUtf8#

    utilsSsidToUtf8                         ,


-- ** utilsTcActionFromStr #method:utilsTcActionFromStr#

    utilsTcActionFromStr                    ,


-- ** utilsTcActionToStr #method:utilsTcActionToStr#

    utilsTcActionToStr                      ,


-- ** utilsTcQdiscFromStr #method:utilsTcQdiscFromStr#

    utilsTcQdiscFromStr                     ,


-- ** utilsTcQdiscToStr #method:utilsTcQdiscToStr#

    utilsTcQdiscToStr                       ,


-- ** utilsTcTfilterFromStr #method:utilsTcTfilterFromStr#

    utilsTcTfilterFromStr                   ,


-- ** utilsTcTfilterToStr #method:utilsTcTfilterToStr#

    utilsTcTfilterToStr                     ,


-- ** utilsUuidGenerate #method:utilsUuidGenerate#

    utilsUuidGenerate                       ,


-- ** utilsVersion #method:utilsVersion#

    utilsVersion                            ,


-- ** utilsWepKeyValid #method:utilsWepKeyValid#

    utilsWepKeyValid                        ,


-- ** utilsWifi2ghzFreqs #method:utilsWifi2ghzFreqs#

    utilsWifi2ghzFreqs                      ,


-- ** utilsWifi5ghzFreqs #method:utilsWifi5ghzFreqs#

    utilsWifi5ghzFreqs                      ,


-- ** utilsWifiChannelToFreq #method:utilsWifiChannelToFreq#

    utilsWifiChannelToFreq                  ,


-- ** utilsWifiFindNextChannel #method:utilsWifiFindNextChannel#

    utilsWifiFindNextChannel                ,


-- ** utilsWifiFreqToChannel #method:utilsWifiFreqToChannel#

    utilsWifiFreqToChannel                  ,


-- ** utilsWifiIsChannelValid #method:utilsWifiIsChannelValid#

    utilsWifiIsChannelValid                 ,


-- ** utilsWifiStrengthBars #method:utilsWifiStrengthBars#

    utilsWifiStrengthBars                   ,


-- ** utilsWpaPskValid #method:utilsWpaPskValid#

    utilsWpaPskValid                        ,




    ) 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

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Flags as GLib.Flags
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GLib.Structs.KeyFile as GLib.KeyFile
import qualified GI.GLib.Structs.VariantType as GLib.VariantType
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.NM.Callbacks as NM.Callbacks
import {-# SOURCE #-} qualified GI.NM.Enums as NM.Enums
import {-# SOURCE #-} qualified GI.NM.Flags as NM.Flags
import {-# SOURCE #-} qualified GI.NM.Interfaces.Connection as NM.Connection
import {-# SOURCE #-} qualified GI.NM.Objects.Setting as NM.Setting
import {-# SOURCE #-} qualified GI.NM.Objects.Setting8021x as NM.Setting8021x
import {-# SOURCE #-} qualified GI.NM.Objects.SettingAdsl as NM.SettingAdsl
import {-# SOURCE #-} qualified GI.NM.Objects.SettingBluetooth as NM.SettingBluetooth
import {-# SOURCE #-} qualified GI.NM.Objects.SettingBond as NM.SettingBond
import {-# SOURCE #-} qualified GI.NM.Objects.SettingBridge as NM.SettingBridge
import {-# SOURCE #-} qualified GI.NM.Objects.SettingBridgePort as NM.SettingBridgePort
import {-# SOURCE #-} qualified GI.NM.Objects.SettingCdma as NM.SettingCdma
import {-# SOURCE #-} qualified GI.NM.Objects.SettingConnection as NM.SettingConnection
import {-# SOURCE #-} qualified GI.NM.Objects.SettingDcb as NM.SettingDcb
import {-# SOURCE #-} qualified GI.NM.Objects.SettingDummy as NM.SettingDummy
import {-# SOURCE #-} qualified GI.NM.Objects.SettingGeneric as NM.SettingGeneric
import {-# SOURCE #-} qualified GI.NM.Objects.SettingGsm as NM.SettingGsm
import {-# SOURCE #-} qualified GI.NM.Objects.SettingIP4Config as NM.SettingIP4Config
import {-# SOURCE #-} qualified GI.NM.Objects.SettingIP6Config as NM.SettingIP6Config
import {-# SOURCE #-} qualified GI.NM.Objects.SettingIPConfig as NM.SettingIPConfig
import {-# SOURCE #-} qualified GI.NM.Objects.SettingIPTunnel as NM.SettingIPTunnel
import {-# SOURCE #-} qualified GI.NM.Objects.SettingInfiniband as NM.SettingInfiniband
import {-# SOURCE #-} qualified GI.NM.Objects.SettingMacsec as NM.SettingMacsec
import {-# SOURCE #-} qualified GI.NM.Objects.SettingMacvlan as NM.SettingMacvlan
import {-# SOURCE #-} qualified GI.NM.Objects.SettingOlpcMesh as NM.SettingOlpcMesh
import {-# SOURCE #-} qualified GI.NM.Objects.SettingOvsBridge as NM.SettingOvsBridge
import {-# SOURCE #-} qualified GI.NM.Objects.SettingOvsInterface as NM.SettingOvsInterface
import {-# SOURCE #-} qualified GI.NM.Objects.SettingOvsPatch as NM.SettingOvsPatch
import {-# SOURCE #-} qualified GI.NM.Objects.SettingOvsPort as NM.SettingOvsPort
import {-# SOURCE #-} qualified GI.NM.Objects.SettingPpp as NM.SettingPpp
import {-# SOURCE #-} qualified GI.NM.Objects.SettingPppoe as NM.SettingPppoe
import {-# SOURCE #-} qualified GI.NM.Objects.SettingProxy as NM.SettingProxy
import {-# SOURCE #-} qualified GI.NM.Objects.SettingSerial as NM.SettingSerial
import {-# SOURCE #-} qualified GI.NM.Objects.SettingTCConfig as NM.SettingTCConfig
import {-# SOURCE #-} qualified GI.NM.Objects.SettingTeam as NM.SettingTeam
import {-# SOURCE #-} qualified GI.NM.Objects.SettingTeamPort as NM.SettingTeamPort
import {-# SOURCE #-} qualified GI.NM.Objects.SettingTun as NM.SettingTun
import {-# SOURCE #-} qualified GI.NM.Objects.SettingVlan as NM.SettingVlan
import {-# SOURCE #-} qualified GI.NM.Objects.SettingVpn as NM.SettingVpn
import {-# SOURCE #-} qualified GI.NM.Objects.SettingVxlan as NM.SettingVxlan
import {-# SOURCE #-} qualified GI.NM.Objects.SettingWimax as NM.SettingWimax
import {-# SOURCE #-} qualified GI.NM.Objects.SettingWired as NM.SettingWired
import {-# SOURCE #-} qualified GI.NM.Objects.SettingWireless as NM.SettingWireless
import {-# SOURCE #-} qualified GI.NM.Objects.SettingWirelessSecurity as NM.SettingWirelessSecurity
import {-# SOURCE #-} qualified GI.NM.Structs.BridgeVlan as NM.BridgeVlan
import {-# SOURCE #-} qualified GI.NM.Structs.IPAddress as NM.IPAddress
import {-# SOURCE #-} qualified GI.NM.Structs.IPRoute as NM.IPRoute
import {-# SOURCE #-} qualified GI.NM.Structs.IPRoutingRule as NM.IPRoutingRule
import {-# SOURCE #-} qualified GI.NM.Structs.Range as NM.Range
import {-# SOURCE #-} qualified GI.NM.Structs.SriovVF as NM.SriovVF
import {-# SOURCE #-} qualified GI.NM.Structs.TCAction as NM.TCAction
import {-# SOURCE #-} qualified GI.NM.Structs.TCQdisc as NM.TCQdisc
import {-# SOURCE #-} qualified GI.NM.Structs.TCTfilter as NM.TCTfilter
import {-# SOURCE #-} qualified GI.NM.Structs.TeamLinkWatcher as NM.TeamLinkWatcher
import {-# SOURCE #-} qualified GI.NM.Structs.VariantAttributeSpec as NM.VariantAttributeSpec

#else
import qualified GI.GLib.Flags as GLib.Flags
import qualified GI.GLib.Structs.Bytes as GLib.Bytes
import qualified GI.GLib.Structs.KeyFile as GLib.KeyFile
import qualified GI.NM.Callbacks as NM.Callbacks
import {-# SOURCE #-} qualified GI.NM.Enums as NM.Enums
import {-# SOURCE #-} qualified GI.NM.Flags as NM.Flags
import {-# SOURCE #-} qualified GI.NM.Interfaces.Connection as NM.Connection
import {-# SOURCE #-} qualified GI.NM.Structs.IPAddress as NM.IPAddress
import {-# SOURCE #-} qualified GI.NM.Structs.IPRoute as NM.IPRoute
import {-# SOURCE #-} qualified GI.NM.Structs.SriovVF as NM.SriovVF
import {-# SOURCE #-} qualified GI.NM.Structs.TCAction as NM.TCAction
import {-# SOURCE #-} qualified GI.NM.Structs.TCQdisc as NM.TCQdisc
import {-# SOURCE #-} qualified GI.NM.Structs.TCTfilter as NM.TCTfilter

#endif

-- function utils_wpa_psk_valid
-- Args: [ Arg
--           { argCName = "psk"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string that might be a WPA PSK"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wpa_psk_valid" nm_utils_wpa_psk_valid :: 
    CString ->                              -- psk : TBasicType TUTF8
    IO CInt

-- | Checks if /@psk@/ is a valid WPA PSK
utilsWpaPskValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@psk@/: a string that might be a WPA PSK
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@psk@/ is a WPA PSK, 'P.False' if not
utilsWpaPskValid :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Bool
utilsWpaPskValid Text
psk = 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
    CString
psk' <- Text -> IO CString
textToCString Text
psk
    CInt
result <- CString -> IO CInt
nm_utils_wpa_psk_valid CString
psk'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
psk'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_wifi_strength_bars
-- Args: [ Arg
--           { argCName = "strength"
--           , argType = TBasicType TUInt8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the access point strength, from 0 to 100"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_strength_bars" nm_utils_wifi_strength_bars :: 
    Word8 ->                                -- strength : TBasicType TUInt8
    IO CString

-- | Converts /@strength@/ into a 4-character-wide graphical representation of
-- strength suitable for printing to stdout.
-- 
-- Previous versions used to take a guess at the terminal type and possibly
-- return a wide UTF-8 encoded string. Now it always returns a 7-bit
-- clean strings of one to 0 to 4 asterisks. Users that actually need
-- the functionality are encouraged to make their implementations instead.
utilsWifiStrengthBars ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word8
    -- ^ /@strength@/: the access point strength, from 0 to 100
    -> m T.Text
    -- ^ __Returns:__ the graphical representation of the access point strength
utilsWifiStrengthBars :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Word8 -> m Text
utilsWifiStrengthBars Word8
strength = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Word8 -> IO CString
nm_utils_wifi_strength_bars Word8
strength
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsWifiStrengthBars" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_wifi_is_channel_valid
-- Args: [ Arg
--           { argCName = "channel"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "channel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "band"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "frequency band for wireless (\"a\" or \"bg\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_is_channel_valid" nm_utils_wifi_is_channel_valid :: 
    Word32 ->                               -- channel : TBasicType TUInt32
    CString ->                              -- band : TBasicType TUTF8
    IO CInt

-- | Utility function to verify Wi-Fi channel validity.
utilsWifiIsChannelValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@channel@/: channel
    -> T.Text
    -- ^ /@band@/: frequency band for wireless (\"a\" or \"bg\")
    -> m Bool
    -- ^ __Returns:__ 'P.True' or 'P.False'
utilsWifiIsChannelValid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> Text -> m Bool
utilsWifiIsChannelValid Word32
channel Text
band = 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
    CString
band' <- Text -> IO CString
textToCString Text
band
    CInt
result <- Word32 -> CString -> IO CInt
nm_utils_wifi_is_channel_valid Word32
channel CString
band'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
band'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_wifi_freq_to_channel
-- Args: [ Arg
--           { argCName = "freq"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "frequency" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_freq_to_channel" nm_utils_wifi_freq_to_channel :: 
    Word32 ->                               -- freq : TBasicType TUInt32
    IO Word32

-- | Utility function to translate a Wi-Fi frequency to its corresponding channel.
utilsWifiFreqToChannel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@freq@/: frequency
    -> m Word32
    -- ^ __Returns:__ the channel represented by the frequency or 0
utilsWifiFreqToChannel :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> m Word32
utilsWifiFreqToChannel Word32
freq = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
nm_utils_wifi_freq_to_channel Word32
freq
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_wifi_find_next_channel
-- Args: [ Arg
--           { argCName = "channel"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "current channel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "direction"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "whether going downward (0 or less) or upward (1 or more)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "band"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "frequency band for wireless (\"a\" or \"bg\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_find_next_channel" nm_utils_wifi_find_next_channel :: 
    Word32 ->                               -- channel : TBasicType TUInt32
    Int32 ->                                -- direction : TBasicType TInt
    CString ->                              -- band : TBasicType TUTF8
    IO Word32

-- | Utility function to find out next\/previous Wi-Fi channel for a channel.
utilsWifiFindNextChannel ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@channel@/: current channel
    -> Int32
    -- ^ /@direction@/: whether going downward (0 or less) or upward (1 or more)
    -> T.Text
    -- ^ /@band@/: frequency band for wireless (\"a\" or \"bg\")
    -> m Word32
    -- ^ __Returns:__ the next channel in the specified direction or 0
utilsWifiFindNextChannel :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> Int32 -> Text -> m Word32
utilsWifiFindNextChannel Word32
channel Int32
direction Text
band = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
band' <- Text -> IO CString
textToCString Text
band
    Word32
result <- Word32 -> Int32 -> CString -> IO Word32
nm_utils_wifi_find_next_channel Word32
channel Int32
direction CString
band'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
band'
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_wifi_channel_to_freq
-- Args: [ Arg
--           { argCName = "channel"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "channel" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "band"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "frequency band for wireless (\"a\" or \"bg\")"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_channel_to_freq" nm_utils_wifi_channel_to_freq :: 
    Word32 ->                               -- channel : TBasicType TUInt32
    CString ->                              -- band : TBasicType TUTF8
    IO Word32

-- | Utility function to translate a Wi-Fi channel to its corresponding frequency.
utilsWifiChannelToFreq ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@channel@/: channel
    -> T.Text
    -- ^ /@band@/: frequency band for wireless (\"a\" or \"bg\")
    -> m Word32
    -- ^ __Returns:__ the frequency represented by the channel of the band,
    --          or -1 when the freq is invalid, or 0 when the band
    --          is invalid
utilsWifiChannelToFreq :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> Text -> m Word32
utilsWifiChannelToFreq Word32
channel Text
band = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    CString
band' <- Text -> IO CString
textToCString Text
band
    Word32
result <- Word32 -> CString -> IO Word32
nm_utils_wifi_channel_to_freq Word32
channel CString
band'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
band'
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_wifi_5ghz_freqs
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_5ghz_freqs" nm_utils_wifi_5ghz_freqs :: 
    IO Word32

-- | Utility function to return 5 GHz Wi-Fi frequencies (802.11a band).
-- 
-- /Since: 1.2/
utilsWifi5ghzFreqs ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ zero-terminated array of frequencies numbers (in MHz)
utilsWifi5ghzFreqs :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Word32
utilsWifi5ghzFreqs  = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
nm_utils_wifi_5ghz_freqs
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_wifi_2ghz_freqs
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wifi_2ghz_freqs" nm_utils_wifi_2ghz_freqs :: 
    IO Word32

-- | Utility function to return 2.4 GHz Wi-Fi frequencies (802.11bg band).
-- 
-- /Since: 1.2/
utilsWifi2ghzFreqs ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ zero-terminated array of frequencies numbers (in MHz)
utilsWifi2ghzFreqs :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Word32
utilsWifi2ghzFreqs  = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
nm_utils_wifi_2ghz_freqs
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_wep_key_valid
-- Args: [ Arg
--           { argCName = "key"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string that might be a WEP key"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "wep_type"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "WepKeyType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #NMWepKeyType type of the WEP key"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_wep_key_valid" nm_utils_wep_key_valid :: 
    CString ->                              -- key : TBasicType TUTF8
    CUInt ->                                -- wep_type : TInterface (Name {namespace = "NM", name = "WepKeyType"})
    IO CInt

-- | Checks if /@key@/ is a valid WEP key
utilsWepKeyValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@key@/: a string that might be a WEP key
    -> NM.Enums.WepKeyType
    -- ^ /@wepType@/: the t'GI.NM.Enums.WepKeyType' type of the WEP key
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@key@/ is a WEP key, 'P.False' if not
utilsWepKeyValid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> WepKeyType -> m Bool
utilsWepKeyValid Text
key WepKeyType
wepType = 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
    CString
key' <- Text -> IO CString
textToCString Text
key
    let wepType' :: CUInt
wepType' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt) -> (WepKeyType -> Int) -> WepKeyType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WepKeyType -> Int
forall a. Enum a => a -> Int
fromEnum) WepKeyType
wepType
    CInt
result <- CString -> CUInt -> IO CInt
nm_utils_wep_key_valid CString
key' CUInt
wepType'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
key'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_version" nm_utils_version :: 
    IO Word32

-- | /No description available in the introspection data./
-- 
-- /Since: 1.6/
utilsVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the version ID of the libnm version. That is, the @/NM_VERSION/@
    --   at runtime.
utilsVersion :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Word32
utilsVersion  = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
nm_utils_version
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_uuid_generate
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_uuid_generate" nm_utils_uuid_generate :: 
    IO CString

-- | /No description available in the introspection data./
utilsUuidGenerate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m T.Text
    -- ^ __Returns:__ a newly allocated UUID suitable for use as the t'GI.NM.Objects.SettingConnection.SettingConnection'
    -- object\'s [SettingConnection:id]("GI.NM.Objects.SettingConnection#g:attr:id"): property.  Should be freed with 'GI.GLib.Functions.free'
utilsUuidGenerate :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Text
utilsUuidGenerate  = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- IO CString
nm_utils_uuid_generate
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsUuidGenerate" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_tc_tfilter_to_str
-- Args: [ Arg
--           { argCName = "tfilter"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "TCTfilter" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %NMTCTfilter" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_tc_tfilter_to_str" nm_utils_tc_tfilter_to_str :: 
    Ptr NM.TCTfilter.TCTfilter ->           -- tfilter : TInterface (Name {namespace = "NM", name = "TCTfilter"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Turns the @/NMTCTfilter/@ into a tc style string representation of the queueing
-- discipline.
-- 
-- /Since: 1.12/
utilsTcTfilterToStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NM.TCTfilter.TCTfilter
    -- ^ /@tfilter@/: the @/NMTCTfilter/@
    -> m T.Text
    -- ^ __Returns:__ formatted string or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
utilsTcTfilterToStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TCTfilter -> m Text
utilsTcTfilterToStr TCTfilter
tfilter = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr TCTfilter
tfilter' <- TCTfilter -> IO (Ptr TCTfilter)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TCTfilter
tfilter
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr TCTfilter -> Ptr (Ptr GError) -> IO CString
nm_utils_tc_tfilter_to_str Ptr TCTfilter
tfilter'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsTcTfilterToStr" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        TCTfilter -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TCTfilter
tfilter
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function utils_tc_tfilter_from_str
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string representation of a tfilter"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "NM" , name = "TCTfilter" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_tc_tfilter_from_str" nm_utils_tc_tfilter_from_str :: 
    CString ->                              -- str : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr NM.TCTfilter.TCTfilter)

-- | Parses the tc style string tfilter representation of the queueing
-- discipline to a @/NMTCTfilter/@ instance. Supports a subset of the tc language.
-- 
-- /Since: 1.12/
utilsTcTfilterFromStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the string representation of a tfilter
    -> m NM.TCTfilter.TCTfilter
    -- ^ __Returns:__ the @/NMTCTfilter/@ or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
utilsTcTfilterFromStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m TCTfilter
utilsTcTfilterFromStr Text
str = IO TCTfilter -> m TCTfilter
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TCTfilter -> m TCTfilter) -> IO TCTfilter -> m TCTfilter
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    IO TCTfilter -> IO () -> IO TCTfilter
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr TCTfilter
result <- (Ptr (Ptr GError) -> IO (Ptr TCTfilter)) -> IO (Ptr TCTfilter)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr TCTfilter)) -> IO (Ptr TCTfilter))
-> (Ptr (Ptr GError) -> IO (Ptr TCTfilter)) -> IO (Ptr TCTfilter)
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr TCTfilter)
nm_utils_tc_tfilter_from_str CString
str'
        Text -> Ptr TCTfilter -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsTcTfilterFromStr" Ptr TCTfilter
result
        TCTfilter
result' <- ((ManagedPtr TCTfilter -> TCTfilter)
-> Ptr TCTfilter -> IO TCTfilter
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TCTfilter -> TCTfilter
NM.TCTfilter.TCTfilter) Ptr TCTfilter
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        TCTfilter -> IO TCTfilter
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return TCTfilter
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
     )


-- function utils_tc_qdisc_to_str
-- Args: [ Arg
--           { argCName = "qdisc"
--           , argType = TInterface Name { namespace = "NM" , name = "TCQdisc" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %NMTCQdisc" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_tc_qdisc_to_str" nm_utils_tc_qdisc_to_str :: 
    Ptr NM.TCQdisc.TCQdisc ->               -- qdisc : TInterface (Name {namespace = "NM", name = "TCQdisc"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Turns the @/NMTCQdisc/@ into a tc style string representation of the queueing
-- discipline.
-- 
-- /Since: 1.12/
utilsTcQdiscToStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NM.TCQdisc.TCQdisc
    -- ^ /@qdisc@/: the @/NMTCQdisc/@
    -> m T.Text
    -- ^ __Returns:__ formatted string or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
utilsTcQdiscToStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TCQdisc -> m Text
utilsTcQdiscToStr TCQdisc
qdisc = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr TCQdisc
qdisc' <- TCQdisc -> IO (Ptr TCQdisc)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TCQdisc
qdisc
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr TCQdisc -> Ptr (Ptr GError) -> IO CString
nm_utils_tc_qdisc_to_str Ptr TCQdisc
qdisc'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsTcQdiscToStr" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        TCQdisc -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TCQdisc
qdisc
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function utils_tc_qdisc_from_str
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string representation of a qdisc"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "NM" , name = "TCQdisc" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_tc_qdisc_from_str" nm_utils_tc_qdisc_from_str :: 
    CString ->                              -- str : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr NM.TCQdisc.TCQdisc)

-- | Parses the tc style string qdisc representation of the queueing
-- discipline to a @/NMTCQdisc/@ instance. Supports a subset of the tc language.
-- 
-- /Since: 1.12/
utilsTcQdiscFromStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the string representation of a qdisc
    -> m NM.TCQdisc.TCQdisc
    -- ^ __Returns:__ the @/NMTCQdisc/@ or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
utilsTcQdiscFromStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m TCQdisc
utilsTcQdiscFromStr Text
str = IO TCQdisc -> m TCQdisc
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TCQdisc -> m TCQdisc) -> IO TCQdisc -> m TCQdisc
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    IO TCQdisc -> IO () -> IO TCQdisc
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr TCQdisc
result <- (Ptr (Ptr GError) -> IO (Ptr TCQdisc)) -> IO (Ptr TCQdisc)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr TCQdisc)) -> IO (Ptr TCQdisc))
-> (Ptr (Ptr GError) -> IO (Ptr TCQdisc)) -> IO (Ptr TCQdisc)
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr TCQdisc)
nm_utils_tc_qdisc_from_str CString
str'
        Text -> Ptr TCQdisc -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsTcQdiscFromStr" Ptr TCQdisc
result
        TCQdisc
result' <- ((ManagedPtr TCQdisc -> TCQdisc) -> Ptr TCQdisc -> IO TCQdisc
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TCQdisc -> TCQdisc
NM.TCQdisc.TCQdisc) Ptr TCQdisc
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        TCQdisc -> IO TCQdisc
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return TCQdisc
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
     )


-- function utils_tc_action_to_str
-- Args: [ Arg
--           { argCName = "action"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "TCAction" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %NMTCAction" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_tc_action_to_str" nm_utils_tc_action_to_str :: 
    Ptr NM.TCAction.TCAction ->             -- action : TInterface (Name {namespace = "NM", name = "TCAction"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Turns the @/NMTCAction/@ into a tc style string representation of the queueing
-- discipline.
-- 
-- /Since: 1.12/
utilsTcActionToStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NM.TCAction.TCAction
    -- ^ /@action@/: the @/NMTCAction/@
    -> m T.Text
    -- ^ __Returns:__ formatted string or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
utilsTcActionToStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
TCAction -> m Text
utilsTcActionToStr TCAction
action = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr TCAction
action' <- TCAction -> IO (Ptr TCAction)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr TCAction
action
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr TCAction -> Ptr (Ptr GError) -> IO CString
nm_utils_tc_action_to_str Ptr TCAction
action'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsTcActionToStr" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        TCAction -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr TCAction
action
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function utils_tc_action_from_str
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the string representation of a action"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "NM" , name = "TCAction" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_tc_action_from_str" nm_utils_tc_action_from_str :: 
    CString ->                              -- str : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr NM.TCAction.TCAction)

-- | Parses the tc style string action representation of the queueing
-- discipline to a @/NMTCAction/@ instance. Supports a subset of the tc language.
-- 
-- /Since: 1.12/
utilsTcActionFromStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the string representation of a action
    -> m NM.TCAction.TCAction
    -- ^ __Returns:__ the @/NMTCAction/@ or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
utilsTcActionFromStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m TCAction
utilsTcActionFromStr Text
str = IO TCAction -> m TCAction
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO TCAction -> m TCAction) -> IO TCAction -> m TCAction
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    IO TCAction -> IO () -> IO TCAction
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr TCAction
result <- (Ptr (Ptr GError) -> IO (Ptr TCAction)) -> IO (Ptr TCAction)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr TCAction)) -> IO (Ptr TCAction))
-> (Ptr (Ptr GError) -> IO (Ptr TCAction)) -> IO (Ptr TCAction)
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr TCAction)
nm_utils_tc_action_from_str CString
str'
        Text -> Ptr TCAction -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsTcActionFromStr" Ptr TCAction
result
        TCAction
result' <- ((ManagedPtr TCAction -> TCAction) -> Ptr TCAction -> IO TCAction
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr TCAction -> TCAction
NM.TCAction.TCAction) Ptr TCAction
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        TCAction -> IO TCAction
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return TCAction
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
     )


-- function utils_ssid_to_utf8
-- Args: [ Arg
--           { argCName = "ssid"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to a buffer containing the SSID data"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of the SSID data in @ssid"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "len"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of the SSID data in @ssid"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ssid_to_utf8" nm_utils_ssid_to_utf8 :: 
    Ptr Word8 ->                            -- ssid : TCArray False (-1) 1 (TBasicType TUInt8)
    FCT.CSize ->                            -- len : TBasicType TSize
    IO CString

-- | Wi-Fi SSIDs are byte arrays, they are _not_ strings.  Thus, an SSID may
-- contain embedded NULLs and other unprintable characters.  Often it is
-- useful to print the SSID out for debugging purposes, but that should be the
-- _only_ use of this function.  Do not use this function for any persistent
-- storage of the SSID, since the printable SSID returned from this function
-- cannot be converted back into the real SSID of the access point.
-- 
-- This function does almost everything humanly possible to convert the input
-- into a printable UTF-8 string, using roughly the following procedure:
-- 
-- 1) if the input data is already UTF-8 safe, no conversion is performed
-- 2) attempts to get the current system language from the LANG environment
--    variable, and depending on the language, uses a table of alternative
--    encodings to try.  For example, if LANG=hu_HU, the table may first try
--    the ISO-8859-2 encoding, and if that fails, try the Windows-1250 encoding.
--    If all fallback encodings fail, replaces non-UTF-8 characters with \'?\'.
-- 3) If the system language was unable to be determined, falls back to the
--    ISO-8859-1 encoding, then to the Windows-1251 encoding.
-- 4) If step 3 fails, replaces non-UTF-8 characters with \'?\'.
-- 
-- Again, this function should be used for debugging and display purposes
-- _only_.
utilsSsidToUtf8 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    -- ^ /@ssid@/: pointer to a buffer containing the SSID data
    -> m T.Text
    -- ^ __Returns:__ an allocated string containing a UTF-8
    -- representation of the SSID, which must be freed by the caller using 'GI.GLib.Functions.free'.
    -- Returns 'P.Nothing' on errors.
utilsSsidToUtf8 :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ByteString -> m Text
utilsSsidToUtf8 ByteString
ssid = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let len :: CSize
len = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
ssid
    Ptr Word8
ssid' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
ssid
    CString
result <- Ptr Word8 -> CSize -> IO CString
nm_utils_ssid_to_utf8 Ptr Word8
ssid' CSize
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsSsidToUtf8" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
ssid'
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_sriov_vf_to_str
-- Args: [ Arg
--           { argCName = "vf"
--           , argType = TInterface Name { namespace = "NM" , name = "SriovVF" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %NMSriovVF" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "omit_index"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if %TRUE, the VF index will be omitted from output string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_sriov_vf_to_str" nm_utils_sriov_vf_to_str :: 
    Ptr NM.SriovVF.SriovVF ->               -- vf : TInterface (Name {namespace = "NM", name = "SriovVF"})
    CInt ->                                 -- omit_index : TBasicType TBoolean
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Converts a SR-IOV virtual function object to its string representation.
-- 
-- /Since: 1.14/
utilsSriovVfToStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NM.SriovVF.SriovVF
    -- ^ /@vf@/: the @/NMSriovVF/@
    -> Bool
    -- ^ /@omitIndex@/: if 'P.True', the VF index will be omitted from output string
    -> m T.Text
    -- ^ __Returns:__ a newly allocated string or 'P.Nothing' on error /(Can throw 'Data.GI.Base.GError.GError')/
utilsSriovVfToStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
SriovVF -> Bool -> m Text
utilsSriovVfToStr SriovVF
vf Bool
omitIndex = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr SriovVF
vf' <- SriovVF -> IO (Ptr SriovVF)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr SriovVF
vf
    let omitIndex' :: CInt
omitIndex' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
omitIndex
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr SriovVF -> CInt -> Ptr (Ptr GError) -> IO CString
nm_utils_sriov_vf_to_str Ptr SriovVF
vf' CInt
omitIndex'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsSriovVfToStr" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        SriovVF -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr SriovVF
vf
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function utils_sriov_vf_from_str
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the input string" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "NM" , name = "SriovVF" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_sriov_vf_from_str" nm_utils_sriov_vf_from_str :: 
    CString ->                              -- str : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr NM.SriovVF.SriovVF)

-- | Converts a string to a SR-IOV virtual function object.
-- 
-- /Since: 1.14/
utilsSriovVfFromStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the input string
    -> m NM.SriovVF.SriovVF
    -- ^ __Returns:__ the virtual function object /(Can throw 'Data.GI.Base.GError.GError')/
utilsSriovVfFromStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m SriovVF
utilsSriovVfFromStr Text
str = IO SriovVF -> m SriovVF
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO SriovVF -> m SriovVF) -> IO SriovVF -> m SriovVF
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    IO SriovVF -> IO () -> IO SriovVF
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr SriovVF
result <- (Ptr (Ptr GError) -> IO (Ptr SriovVF)) -> IO (Ptr SriovVF)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr SriovVF)) -> IO (Ptr SriovVF))
-> (Ptr (Ptr GError) -> IO (Ptr SriovVF)) -> IO (Ptr SriovVF)
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr SriovVF)
nm_utils_sriov_vf_from_str CString
str'
        Text -> Ptr SriovVF -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsSriovVfFromStr" Ptr SriovVF
result
        SriovVF
result' <- ((ManagedPtr SriovVF -> SriovVF) -> Ptr SriovVF -> IO SriovVF
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr SriovVF -> SriovVF
NM.SriovVF.SriovVF) Ptr SriovVF
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        SriovVF -> IO SriovVF
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return SriovVF
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
     )


-- function utils_security_valid
-- Args: [ Arg
--           { argCName = "type"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "UtilsSecurityType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the security type to check AP flags and device capabilities against,\ne.g. #NMU_SEC_STATIC_WEP"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "wifi_caps"
--           , argType =
--               TInterface
--                 Name { namespace = "NM" , name = "DeviceWifiCapabilities" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "bitfield of the capabilities of the specific Wi-Fi device, e.g.\n#NM_WIFI_DEVICE_CAP_CIPHER_WEP40"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "have_ap"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "whether the @ap_flags, @ap_wpa, and @ap_rsn arguments are valid"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "adhoc"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "whether the capabilities being tested are from an Ad-Hoc AP (IBSS)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ap_flags"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "80211ApFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "bitfield of AP capabilities, e.g. #NM_802_11_AP_FLAGS_PRIVACY"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ap_wpa"
--           , argType =
--               TInterface
--                 Name { namespace = "NM" , name = "80211ApSecurityFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "bitfield of AP capabilities derived from the AP's WPA beacon,\ne.g. (#NM_802_11_AP_SEC_PAIR_TKIP | #NM_802_11_AP_SEC_KEY_MGMT_PSK)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ap_rsn"
--           , argType =
--               TInterface
--                 Name { namespace = "NM" , name = "80211ApSecurityFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "bitfield of AP capabilities derived from the AP's RSN/WPA2 beacon,\ne.g. (#NM_802_11_AP_SEC_PAIR_CCMP | #NM_802_11_AP_SEC_PAIR_TKIP)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_security_valid" nm_utils_security_valid :: 
    CUInt ->                                -- type : TInterface (Name {namespace = "NM", name = "UtilsSecurityType"})
    CUInt ->                                -- wifi_caps : TInterface (Name {namespace = "NM", name = "DeviceWifiCapabilities"})
    CInt ->                                 -- have_ap : TBasicType TBoolean
    CInt ->                                 -- adhoc : TBasicType TBoolean
    CUInt ->                                -- ap_flags : TInterface (Name {namespace = "NM", name = "80211ApFlags"})
    CUInt ->                                -- ap_wpa : TInterface (Name {namespace = "NM", name = "80211ApSecurityFlags"})
    CUInt ->                                -- ap_rsn : TInterface (Name {namespace = "NM", name = "80211ApSecurityFlags"})
    IO CInt

-- | Given a set of device capabilities, and a desired security type to check
-- against, determines whether the combination of device, desired security
-- type, and AP capabilities intersect.
-- 
-- NOTE: this function cannot handle checking security for AP\/Hotspot mode;
-- use 'GI.NM.Functions.utilsApModeSecurityValid' instead.
utilsSecurityValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NM.Enums.UtilsSecurityType
    -- ^ /@type@/: the security type to check AP flags and device capabilities against,
    -- e.g. @/NMU_SEC_STATIC_WEP/@
    -> [NM.Flags.DeviceWifiCapabilities]
    -- ^ /@wifiCaps@/: bitfield of the capabilities of the specific Wi-Fi device, e.g.
    -- @/NM_WIFI_DEVICE_CAP_CIPHER_WEP40/@
    -> Bool
    -- ^ /@haveAp@/: whether the /@apFlags@/, /@apWpa@/, and /@apRsn@/ arguments are valid
    -> Bool
    -- ^ /@adhoc@/: whether the capabilities being tested are from an Ad-Hoc AP (IBSS)
    -> [NM.Flags.NM80211ApFlags]
    -- ^ /@apFlags@/: bitfield of AP capabilities, e.g. @/NM_802_11_AP_FLAGS_PRIVACY/@
    -> [NM.Flags.NM80211ApSecurityFlags]
    -- ^ /@apWpa@/: bitfield of AP capabilities derived from the AP\'s WPA beacon,
    -- e.g. (@/NM_802_11_AP_SEC_PAIR_TKIP/@ | @/NM_802_11_AP_SEC_KEY_MGMT_PSK/@)
    -> [NM.Flags.NM80211ApSecurityFlags]
    -- ^ /@apRsn@/: bitfield of AP capabilities derived from the AP\'s RSN\/WPA2 beacon,
    -- e.g. (@/NM_802_11_AP_SEC_PAIR_CCMP/@ | @/NM_802_11_AP_SEC_PAIR_TKIP/@)
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the device capabilities and AP capabilities intersect and are
    -- compatible with the desired /@type@/, 'P.False' if they are not
utilsSecurityValid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UtilsSecurityType
-> [DeviceWifiCapabilities]
-> Bool
-> Bool
-> [NM80211ApFlags]
-> [NM80211ApSecurityFlags]
-> [NM80211ApSecurityFlags]
-> m Bool
utilsSecurityValid UtilsSecurityType
type_ [DeviceWifiCapabilities]
wifiCaps Bool
haveAp Bool
adhoc [NM80211ApFlags]
apFlags [NM80211ApSecurityFlags]
apWpa [NM80211ApSecurityFlags]
apRsn = 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
    let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UtilsSecurityType -> Int) -> UtilsSecurityType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UtilsSecurityType -> Int
forall a. Enum a => a -> Int
fromEnum) UtilsSecurityType
type_
    let wifiCaps' :: CUInt
wifiCaps' = [DeviceWifiCapabilities] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [DeviceWifiCapabilities]
wifiCaps
    let haveAp' :: CInt
haveAp' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
haveAp
    let adhoc' :: CInt
adhoc' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
adhoc
    let apFlags' :: CUInt
apFlags' = [NM80211ApFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [NM80211ApFlags]
apFlags
    let apWpa' :: CUInt
apWpa' = [NM80211ApSecurityFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [NM80211ApSecurityFlags]
apWpa
    let apRsn' :: CUInt
apRsn' = [NM80211ApSecurityFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [NM80211ApSecurityFlags]
apRsn
    CInt
result <- CUInt
-> CUInt -> CInt -> CInt -> CUInt -> CUInt -> CUInt -> IO CInt
nm_utils_security_valid CUInt
type_' CUInt
wifiCaps' CInt
haveAp' CInt
adhoc' CUInt
apFlags' CUInt
apWpa' CUInt
apRsn'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_same_ssid
-- Args: [ Arg
--           { argCName = "ssid1"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the first SSID to compare"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len1"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of the SSID data in @ssid1"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ssid2"
--           , argType = TCArray False (-1) 3 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the second SSID to compare"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len2"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of the SSID data in @ssid2"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ignore_trailing_null"
--           , argType = TBasicType TBoolean
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "%TRUE to ignore one trailing NULL byte"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "len2"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of the SSID data in @ssid2"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          , Arg
--              { argCName = "len1"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of the SSID data in @ssid1"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_same_ssid" nm_utils_same_ssid :: 
    Ptr Word8 ->                            -- ssid1 : TCArray False (-1) 1 (TBasicType TUInt8)
    FCT.CSize ->                            -- len1 : TBasicType TSize
    Ptr Word8 ->                            -- ssid2 : TCArray False (-1) 3 (TBasicType TUInt8)
    FCT.CSize ->                            -- len2 : TBasicType TSize
    CInt ->                                 -- ignore_trailing_null : TBasicType TBoolean
    IO CInt

-- | Earlier versions of the Linux kernel added a NULL byte to the end of the
-- SSID to enable easy printing of the SSID on the console or in a terminal,
-- but this behavior was problematic (SSIDs are simply byte arrays, not strings)
-- and thus was changed.  This function compensates for that behavior at the
-- cost of some compatibility with odd SSIDs that may legitimately have trailing
-- NULLs, even though that is functionally pointless.
utilsSameSsid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    -- ^ /@ssid1@/: the first SSID to compare
    -> ByteString
    -- ^ /@ssid2@/: the second SSID to compare
    -> Bool
    -- ^ /@ignoreTrailingNull@/: 'P.True' to ignore one trailing NULL byte
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the SSIDs are the same, 'P.False' if they are not
utilsSameSsid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ByteString -> ByteString -> Bool -> m Bool
utilsSameSsid ByteString
ssid1 ByteString
ssid2 Bool
ignoreTrailingNull = 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
    let len2 :: CSize
len2 = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
ssid2
    let len1 :: CSize
len1 = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
ssid1
    Ptr Word8
ssid1' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
ssid1
    Ptr Word8
ssid2' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
ssid2
    let ignoreTrailingNull' :: CInt
ignoreTrailingNull' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
P.fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
P.fromEnum) Bool
ignoreTrailingNull
    CInt
result <- Ptr Word8 -> CSize -> Ptr Word8 -> CSize -> CInt -> IO CInt
nm_utils_same_ssid Ptr Word8
ssid1' CSize
len1 Ptr Word8
ssid2' CSize
len2 CInt
ignoreTrailingNull'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
ssid1'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
ssid2'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_print
-- Args: [ Arg
--           { argCName = "output_mode"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "if 1 it uses g_print(). If 2, it uses g_printerr().\n  If 0, it uses the same output as internal libnm debug logging\n  does. That is, depending on LIBNM_CLIENT_DEBUG's \"stdout\" flag\n  it uses g_print() or g_printerr() and if LIBNM_CLIENT_DEBUG_FILE is\n  set, it writes the output to file instead"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "msg"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the message to print. The function does not append\n  a trailing newline."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_print" nm_utils_print :: 
    Int32 ->                                -- output_mode : TBasicType TInt
    CString ->                              -- msg : TBasicType TUTF8
    IO ()

-- | The only purpose of this function is to give access to @/g_print()/@
-- or @/g_printerr()/@ from pygobject. libnm can do debug logging by
-- setting LIBNM_CLIENT_DEBUG and uses thereby @/g_printerr()/@ or
-- @/g_print()/@. A plain \"@/print()/@\" function in python is not in sync
-- with these functions (it implements additional buffering). By
-- using 'GI.NM.Functions.utilsPrint', the same logging mechanisms can be used.
-- 
-- LIBNM_CLIENT_DEBUG is a list of keywords separated by commas. The keyword
-- \"trace\" enables printing messages of the lowest up to the highest severity.
-- Likewise, the severities \"debug\", \"warn\" (\"warning\") and \"error\" are honored
-- in similar way. Setting the flags \"ERROR\" or \"WARN\" (\"WARNING\") implies that
-- respective levels are enabled, but also are ERROR messages printed with
-- @/g_critical()/@ and WARN messages with @/g_warning()/@. Together with G_DEBUG=\"fatal-warnings\"
-- or G_DEBUG=\"fatal-critical\" this can be used to abort the program on errors.
-- Note that all &lt;error&gt; messages imply an unexpected data on the D-Bus API
-- (due to a bug). &lt;warn&gt; also implies unexepected data, but that can happen
-- when using different versions of libnm and daemon. For testing, it is
-- good to turn these into assertions.
-- 
-- By default, messages are printed to stderr, unless LIBNM_CLIENT_DEBUG
-- contains \"stdout\" flag. Also, libnm honors LIBNM_CLIENT_DEBUG_FILE
-- environment. If this is set to a filename pattern (accepting \"%@/p/@\" for the
-- process ID), then the debug log is written to that file instead of
-- stderr\/stdout. With /@outputMode@/ zero, the same location will be written.
-- 
-- LIBNM_CLIENT_DEBUG_FILE is supported since 1.44. \"ERROR\", \"WARN\" and \"WARNING\"
-- are supported since 1.46.
-- 
-- /Since: 1.30/
utilsPrint ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    -- ^ /@outputMode@/: if 1 it uses @/g_print()/@. If 2, it uses @/g_printerr()/@.
    --   If 0, it uses the same output as internal libnm debug logging
    --   does. That is, depending on LIBNM_CLIENT_DEBUG\'s \"stdout\" flag
    --   it uses @/g_print()/@ or @/g_printerr()/@ and if LIBNM_CLIENT_DEBUG_FILE is
    --   set, it writes the output to file instead
    -> T.Text
    -- ^ /@msg@/: the message to print. The function does not append
    --   a trailing newline.
    -> m ()
utilsPrint :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Int32 -> Text -> m ()
utilsPrint Int32
outputMode Text
msg = 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
    CString
msg' <- Text -> IO CString
textToCString Text
msg
    Int32 -> CString -> IO ()
nm_utils_print Int32
outputMode CString
msg'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
msg'
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function utils_parse_variant_attributes
-- XXX Could not generate function utils_parse_variant_attributes

-- Not implemented: GHashTable element of type TVariant unsupported.

-- function utils_is_valid_iface_name
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Name of interface" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_is_valid_iface_name" nm_utils_is_valid_iface_name :: 
    CString ->                              -- name : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Validate the network interface name.
-- 
-- This function is a 1:1 copy of the kernel\'s interface validation
-- function in net\/core\/dev.c.
-- 
-- /Since: 1.6/
utilsIsValidIfaceName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@name@/: Name of interface
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
utilsIsValidIfaceName :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m ()
utilsIsValidIfaceName Maybe Text
name = 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
    CString
maybeName <- case Maybe Text
name of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jName -> do
            CString
jName' <- Text -> IO CString
textToCString Text
jName
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jName'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CInt
nm_utils_is_valid_iface_name CString
maybeName
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeName
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeName
     )


-- function utils_is_uuid
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a string that might be a UUID"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_is_uuid" nm_utils_is_uuid :: 
    CString ->                              -- str : TBasicType TUTF8
    IO CInt

{-# DEPRECATED utilsIsUuid ["(Since version 1.32)","older versions of NetworkManager had a wrong","  understanding of what makes a valid UUID. This function can thus","  accept some inputs as valid, which in fact are not valid UUIDs."] #-}
-- | Checks if /@str@/ is a UUID
utilsIsUuid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@str@/: a string that might be a UUID
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@str@/ is a UUID, 'P.False' if not
    -- 
    -- In older versions, 'GI.NM.Functions.utilsIsUuid' did not accept 'P.Nothing' as /@str@/
    -- argument. Don\'t pass 'P.Nothing' if you run against older versions of libnm.
utilsIsUuid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
utilsIsUuid Maybe Text
str = 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
    CString
maybeStr <- case Maybe Text
str of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jStr -> do
            CString
jStr' <- Text -> IO CString
textToCString Text
jStr
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jStr'
    CInt
result <- CString -> IO CInt
nm_utils_is_uuid CString
maybeStr
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeStr
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_is_json_object
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the JSON string to test"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_is_json_object" nm_utils_is_json_object :: 
    CString ->                              -- str : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | /No description available in the introspection data./
-- 
-- /Since: 1.6/
utilsIsJsonObject ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the JSON string to test
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
utilsIsJsonObject :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m ()
utilsIsJsonObject Text
str = 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
    CString
str' <- Text -> IO CString
textToCString Text
str
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CInt
nm_utils_is_json_object CString
str'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
     )


-- function utils_is_empty_ssid
-- Args: [ Arg
--           { argCName = "ssid"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to a buffer containing the SSID data"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of the SSID data in @ssid"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "len"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of the SSID data in @ssid"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_is_empty_ssid" nm_utils_is_empty_ssid :: 
    Ptr Word8 ->                            -- ssid : TCArray False (-1) 1 (TBasicType TUInt8)
    FCT.CSize ->                            -- len : TBasicType TSize
    IO CInt

-- | Different manufacturers use different mechanisms for not broadcasting the
-- AP\'s SSID.  This function attempts to detect blank\/empty SSIDs using a
-- number of known SSID-cloaking methods.
utilsIsEmptySsid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    -- ^ /@ssid@/: pointer to a buffer containing the SSID data
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the SSID is \"empty\", 'P.False' if it is not
utilsIsEmptySsid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ByteString -> m Bool
utilsIsEmptySsid ByteString
ssid = 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
    let len :: CSize
len = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
ssid
    Ptr Word8
ssid' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
ssid
    CInt
result <- Ptr Word8 -> CSize -> IO CInt
nm_utils_is_empty_ssid Ptr Word8
ssid' CSize
len
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
ssid'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_ipaddr_valid
-- Args: [ Arg
--           { argCName = "family"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "<literal>AF_INET</literal> or <literal>AF_INET6</literal>, or\n  <literal>AF_UNSPEC</literal> to accept either"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ip"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an IP address" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ipaddr_valid" nm_utils_ipaddr_valid :: 
    Int32 ->                                -- family : TBasicType TInt
    CString ->                              -- ip : TBasicType TUTF8
    IO CInt

-- | Checks if /@ip@/ contains a valid IP address of the given family.
utilsIpaddrValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    -- ^ /@family@/: \<literal>AF_INET\<\/literal> or \<literal>AF_INET6\<\/literal>, or
    --   \<literal>AF_UNSPEC\<\/literal> to accept either
    -> T.Text
    -- ^ /@ip@/: an IP address
    -> m Bool
    -- ^ __Returns:__ 'P.True' or 'P.False'
utilsIpaddrValid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Int32 -> Text -> m Bool
utilsIpaddrValid Int32
family Text
ip = 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
    CString
ip' <- Text -> IO CString
textToCString Text
ip
    CInt
result <- Int32 -> CString -> IO CInt
nm_utils_ipaddr_valid Int32
family CString
ip'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
ip'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_ip_routes_to_variant
-- Args: [ Arg
--           { argCName = "routes"
--           , argType =
--               TPtrArray (TInterface Name { namespace = "NM" , name = "IPRoute" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of #NMIPRoute objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip_routes_to_variant" nm_utils_ip_routes_to_variant :: 
    Ptr (GPtrArray (Ptr NM.IPRoute.IPRoute)) -> -- routes : TPtrArray (TInterface (Name {namespace = "NM", name = "IPRoute"}))
    IO (Ptr GVariant)

-- | Utility function to convert a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects representing
-- IPv4 or IPv6 routes into a t'GVariant' of type \'aa{sv}\' representing an array
-- of new-style NetworkManager IP routes. All routes will include \"dest\" (an IP
-- address string), \"prefix\" (an uint) and optionally \"next-hop\" (an IP address
-- string) and \"metric\" (an uint). Some routes may include additional attributes.
-- Note that invalid routes are discarded and only a warning is emitted, but the
-- valid routes are still returned.
-- 
-- /Since: 1.42/
utilsIpRoutesToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [NM.IPRoute.IPRoute]
    -- ^ /@routes@/: an array of t'GI.NM.Structs.IPRoute.IPRoute' objects
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@routes@/.
utilsIpRoutesToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[IPRoute] -> m GVariant
utilsIpRoutesToVariant [IPRoute]
routes = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    [Ptr IPRoute]
routes' <- (IPRoute -> IO (Ptr IPRoute)) -> [IPRoute] -> IO [Ptr IPRoute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM IPRoute -> IO (Ptr IPRoute)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [IPRoute]
routes
    Ptr (GPtrArray (Ptr IPRoute))
routes'' <- [Ptr IPRoute] -> IO (Ptr (GPtrArray (Ptr IPRoute)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr IPRoute]
routes'
    Ptr GVariant
result <- Ptr (GPtrArray (Ptr IPRoute)) -> IO (Ptr GVariant)
nm_utils_ip_routes_to_variant Ptr (GPtrArray (Ptr IPRoute))
routes''
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIpRoutesToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    (IPRoute -> IO ()) -> [IPRoute] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ IPRoute -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [IPRoute]
routes
    Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPRoute))
routes''
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip_routes_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant of type 'aa{sv}'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "family"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an IP address family"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TPtrArray
--                  (TInterface Name { namespace = "NM" , name = "IPRoute" }))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip_routes_from_variant" nm_utils_ip_routes_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    Int32 ->                                -- family : TBasicType TInt
    IO (Ptr (GPtrArray (Ptr NM.IPRoute.IPRoute)))

-- | Utility function to convert a t'GVariant' representing a list of new-style
-- NetworkManager IPv4 or IPv6 addresses (as described in the documentation for
-- 'GI.NM.Functions.utilsIpRoutesToVariant') into a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects.
-- Invalid routes are discarded but the valid routes are still returned.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
-- 
-- /Since: 1.42/
utilsIpRoutesFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: a t'GVariant' of type \'aa{sv}\'
    -> Int32
    -- ^ /@family@/: an IP address family
    -> m [NM.IPRoute.IPRoute]
    -- ^ __Returns:__ a newly allocated
    --   t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects
utilsIpRoutesFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> Int32 -> m [IPRoute]
utilsIpRoutesFromVariant GVariant
value Int32
family = IO [IPRoute] -> m [IPRoute]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [IPRoute] -> m [IPRoute]) -> IO [IPRoute] -> m [IPRoute]
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    Ptr (GPtrArray (Ptr IPRoute))
result <- Ptr GVariant -> Int32 -> IO (Ptr (GPtrArray (Ptr IPRoute)))
nm_utils_ip_routes_from_variant Ptr GVariant
value' Int32
family
    Text -> Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIpRoutesFromVariant" Ptr (GPtrArray (Ptr IPRoute))
result
    [Ptr IPRoute]
result' <- Ptr (GPtrArray (Ptr IPRoute)) -> IO [Ptr IPRoute]
forall a. Ptr (GPtrArray (Ptr a)) -> IO [Ptr a]
unpackGPtrArray Ptr (GPtrArray (Ptr IPRoute))
result
    [IPRoute]
result'' <- (Ptr IPRoute -> IO IPRoute) -> [Ptr IPRoute] -> IO [IPRoute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr IPRoute -> IPRoute) -> Ptr IPRoute -> IO IPRoute
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IPRoute -> IPRoute
NM.IPRoute.IPRoute) [Ptr IPRoute]
result'
    Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPRoute))
result
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    [IPRoute] -> IO [IPRoute]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [IPRoute]
result''


-- function utils_ip_addresses_to_variant
-- Args: [ Arg
--           { argCName = "addresses"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "NM" , name = "IPAddress" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of #NMIPAddress objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip_addresses_to_variant" nm_utils_ip_addresses_to_variant :: 
    Ptr (GPtrArray (Ptr NM.IPAddress.IPAddress)) -> -- addresses : TPtrArray (TInterface (Name {namespace = "NM", name = "IPAddress"}))
    IO (Ptr GVariant)

-- | Utility function to convert a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects representing
-- IPv4 or IPv6 addresses into a t'GVariant' of type \'aa{sv}\' representing an
-- array of new-style NetworkManager IP addresses. All addresses will include
-- \"address\" (an IP address string), and \"prefix\" (a uint). Some addresses may
-- include additional attributes.
-- 
-- /Since: 1.42/
utilsIpAddressesToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [NM.IPAddress.IPAddress]
    -- ^ /@addresses@/: an array of t'GI.NM.Structs.IPAddress.IPAddress' objects
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@addresses@/.
utilsIpAddressesToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[IPAddress] -> m GVariant
utilsIpAddressesToVariant [IPAddress]
addresses = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    [Ptr IPAddress]
addresses' <- (IPAddress -> IO (Ptr IPAddress))
-> [IPAddress] -> IO [Ptr IPAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM IPAddress -> IO (Ptr IPAddress)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [IPAddress]
addresses
    Ptr (GPtrArray (Ptr IPAddress))
addresses'' <- [Ptr IPAddress] -> IO (Ptr (GPtrArray (Ptr IPAddress)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr IPAddress]
addresses'
    Ptr GVariant
result <- Ptr (GPtrArray (Ptr IPAddress)) -> IO (Ptr GVariant)
nm_utils_ip_addresses_to_variant Ptr (GPtrArray (Ptr IPAddress))
addresses''
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIpAddressesToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    (IPAddress -> IO ()) -> [IPAddress] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ IPAddress -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [IPAddress]
addresses
    Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPAddress))
addresses''
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip_addresses_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant of type 'aa{sv}'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "family"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an IP address family"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TPtrArray
--                  (TInterface Name { namespace = "NM" , name = "IPAddress" }))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip_addresses_from_variant" nm_utils_ip_addresses_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    Int32 ->                                -- family : TBasicType TInt
    IO (Ptr (GPtrArray (Ptr NM.IPAddress.IPAddress)))

-- | Utility function to convert a t'GVariant' representing a list of new-style
-- NetworkManager IPv4 or IPv6 addresses (as described in the documentation for
-- 'GI.NM.Functions.utilsIpAddressesToVariant') into a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress'
-- objects. Note that invalid addresses are discarded but the valid addresses
-- are still returned.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
-- 
-- /Since: 1.42/
utilsIpAddressesFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: a t'GVariant' of type \'aa{sv}\'
    -> Int32
    -- ^ /@family@/: an IP address family
    -> m [NM.IPAddress.IPAddress]
    -- ^ __Returns:__ a newly allocated
    --   t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects
utilsIpAddressesFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> Int32 -> m [IPAddress]
utilsIpAddressesFromVariant GVariant
value Int32
family = IO [IPAddress] -> m [IPAddress]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [IPAddress] -> m [IPAddress])
-> IO [IPAddress] -> m [IPAddress]
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    Ptr (GPtrArray (Ptr IPAddress))
result <- Ptr GVariant -> Int32 -> IO (Ptr (GPtrArray (Ptr IPAddress)))
nm_utils_ip_addresses_from_variant Ptr GVariant
value' Int32
family
    Text -> Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIpAddressesFromVariant" Ptr (GPtrArray (Ptr IPAddress))
result
    [Ptr IPAddress]
result' <- Ptr (GPtrArray (Ptr IPAddress)) -> IO [Ptr IPAddress]
forall a. Ptr (GPtrArray (Ptr a)) -> IO [Ptr a]
unpackGPtrArray Ptr (GPtrArray (Ptr IPAddress))
result
    [IPAddress]
result'' <- (Ptr IPAddress -> IO IPAddress)
-> [Ptr IPAddress] -> IO [IPAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr IPAddress -> IPAddress)
-> Ptr IPAddress -> IO IPAddress
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IPAddress -> IPAddress
NM.IPAddress.IPAddress) [Ptr IPAddress]
result'
    Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPAddress))
result
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    [IPAddress] -> IO [IPAddress]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [IPAddress]
result''


-- function utils_ip6_routes_to_variant
-- Args: [ Arg
--           { argCName = "routes"
--           , argType =
--               TPtrArray (TInterface Name { namespace = "NM" , name = "IPRoute" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of #NMIPRoute objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip6_routes_to_variant" nm_utils_ip6_routes_to_variant :: 
    Ptr (GPtrArray (Ptr NM.IPRoute.IPRoute)) -> -- routes : TPtrArray (TInterface (Name {namespace = "NM", name = "IPRoute"}))
    IO (Ptr GVariant)

-- | Utility function to convert a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects representing
-- IPv6 routes into a t'GVariant' of type \'a(ayuayu)\' representing an array of
-- NetworkManager IPv6 routes (which are tuples of route, prefix, next hop, and
-- metric).
utilsIp6RoutesToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [NM.IPRoute.IPRoute]
    -- ^ /@routes@/: an array of t'GI.NM.Structs.IPRoute.IPRoute' objects
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@routes@/.
utilsIp6RoutesToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[IPRoute] -> m GVariant
utilsIp6RoutesToVariant [IPRoute]
routes = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    [Ptr IPRoute]
routes' <- (IPRoute -> IO (Ptr IPRoute)) -> [IPRoute] -> IO [Ptr IPRoute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM IPRoute -> IO (Ptr IPRoute)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [IPRoute]
routes
    Ptr (GPtrArray (Ptr IPRoute))
routes'' <- [Ptr IPRoute] -> IO (Ptr (GPtrArray (Ptr IPRoute)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr IPRoute]
routes'
    Ptr GVariant
result <- Ptr (GPtrArray (Ptr IPRoute)) -> IO (Ptr GVariant)
nm_utils_ip6_routes_to_variant Ptr (GPtrArray (Ptr IPRoute))
routes''
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp6RoutesToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    (IPRoute -> IO ()) -> [IPRoute] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ IPRoute -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [IPRoute]
routes
    Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPRoute))
routes''
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip6_routes_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GVariant of type 'a(ayuayu)'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TPtrArray
--                  (TInterface Name { namespace = "NM" , name = "IPRoute" }))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip6_routes_from_variant" nm_utils_ip6_routes_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    IO (Ptr (GPtrArray (Ptr NM.IPRoute.IPRoute)))

-- | Utility function to convert a t'GVariant' of type \'a(ayuayu)\' representing an
-- array of NetworkManager IPv6 routes (which are tuples of route, prefix, next
-- hop, and metric) into a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects. Note that invalid
-- routes are ignored but the valid ones are still returned.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
utilsIp6RoutesFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: t'GVariant' of type \'a(ayuayu)\'
    -> m [NM.IPRoute.IPRoute]
    -- ^ __Returns:__ a newly allocated
    --   t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects
utilsIp6RoutesFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m [IPRoute]
utilsIp6RoutesFromVariant GVariant
value = IO [IPRoute] -> m [IPRoute]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [IPRoute] -> m [IPRoute]) -> IO [IPRoute] -> m [IPRoute]
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    Ptr (GPtrArray (Ptr IPRoute))
result <- Ptr GVariant -> IO (Ptr (GPtrArray (Ptr IPRoute)))
nm_utils_ip6_routes_from_variant Ptr GVariant
value'
    Text -> Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp6RoutesFromVariant" Ptr (GPtrArray (Ptr IPRoute))
result
    [Ptr IPRoute]
result' <- Ptr (GPtrArray (Ptr IPRoute)) -> IO [Ptr IPRoute]
forall a. Ptr (GPtrArray (Ptr a)) -> IO [Ptr a]
unpackGPtrArray Ptr (GPtrArray (Ptr IPRoute))
result
    [IPRoute]
result'' <- (Ptr IPRoute -> IO IPRoute) -> [Ptr IPRoute] -> IO [IPRoute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr IPRoute -> IPRoute) -> Ptr IPRoute -> IO IPRoute
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IPRoute -> IPRoute
NM.IPRoute.IPRoute) [Ptr IPRoute]
result'
    Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPRoute))
result
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    [IPRoute] -> IO [IPRoute]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [IPRoute]
result''


-- function utils_ip6_dns_to_variant
-- Args: [ Arg
--           { argCName = "dns"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of IP address strings"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip6_dns_to_variant" nm_utils_ip6_dns_to_variant :: 
    CString ->                              -- dns : TBasicType TUTF8
    IO (Ptr GVariant)

-- | Utility function to convert an array of IP address strings int a t'GVariant' of
-- type \'aay\' representing an array of IPv6 addresses.
-- 
-- If a string cannot be parsed, it will be silently ignored.
utilsIp6DnsToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@dns@/: an array of IP address strings
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@dns@/.
utilsIp6DnsToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m GVariant
utilsIp6DnsToVariant Text
dns = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    CString
dns' <- Text -> IO CString
textToCString Text
dns
    Ptr GVariant
result <- CString -> IO (Ptr GVariant)
nm_utils_ip6_dns_to_variant CString
dns'
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp6DnsToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
dns'
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip6_dns_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant of type 'aay'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip6_dns_from_variant" nm_utils_ip6_dns_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    IO CString

-- | Utility function to convert a t'GVariant' of type \'aay\' representing a list of
-- IPv6 addresses into an array of IP address strings. Each \"ay\" entry must be
-- a IPv6 address in binary form (16 bytes long). Invalid entries are silently
-- ignored.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
utilsIp6DnsFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: a t'GVariant' of type \'aay\'
    -> m T.Text
    -- ^ __Returns:__ a 'P.Nothing'-terminated array of IP address strings.
utilsIp6DnsFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m Text
utilsIp6DnsFromVariant GVariant
value = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    CString
result <- Ptr GVariant -> IO CString
nm_utils_ip6_dns_from_variant Ptr GVariant
value'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp6DnsFromVariant" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_ip6_addresses_to_variant
-- Args: [ Arg
--           { argCName = "addresses"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "NM" , name = "IPAddress" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of #NMIPAddress objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "gateway"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the gateway IP address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip6_addresses_to_variant" nm_utils_ip6_addresses_to_variant :: 
    Ptr (GPtrArray (Ptr NM.IPAddress.IPAddress)) -> -- addresses : TPtrArray (TInterface (Name {namespace = "NM", name = "IPAddress"}))
    CString ->                              -- gateway : TBasicType TUTF8
    IO (Ptr GVariant)

-- | Utility function to convert a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects representing
-- IPv6 addresses into a t'GVariant' of type \'a(ayuay)\' representing an array of
-- NetworkManager IPv6 addresses (which are tuples of address, prefix, and
-- gateway).  The \"gateway\" field of the first address will get the value of
-- /@gateway@/ (if non-'P.Nothing'). In all of the other addresses, that field will be
-- all 0s.
utilsIp6AddressesToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [NM.IPAddress.IPAddress]
    -- ^ /@addresses@/: an array of t'GI.NM.Structs.IPAddress.IPAddress' objects
    -> Maybe (T.Text)
    -- ^ /@gateway@/: the gateway IP address
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@addresses@/.
utilsIp6AddressesToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[IPAddress] -> Maybe Text -> m GVariant
utilsIp6AddressesToVariant [IPAddress]
addresses Maybe Text
gateway = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    [Ptr IPAddress]
addresses' <- (IPAddress -> IO (Ptr IPAddress))
-> [IPAddress] -> IO [Ptr IPAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM IPAddress -> IO (Ptr IPAddress)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [IPAddress]
addresses
    Ptr (GPtrArray (Ptr IPAddress))
addresses'' <- [Ptr IPAddress] -> IO (Ptr (GPtrArray (Ptr IPAddress)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr IPAddress]
addresses'
    CString
maybeGateway <- case Maybe Text
gateway of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jGateway -> do
            CString
jGateway' <- Text -> IO CString
textToCString Text
jGateway
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jGateway'
    Ptr GVariant
result <- Ptr (GPtrArray (Ptr IPAddress)) -> CString -> IO (Ptr GVariant)
nm_utils_ip6_addresses_to_variant Ptr (GPtrArray (Ptr IPAddress))
addresses'' CString
maybeGateway
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp6AddressesToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    (IPAddress -> IO ()) -> [IPAddress] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ IPAddress -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [IPAddress]
addresses
    Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPAddress))
addresses''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeGateway
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip6_addresses_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant of type 'a(ayuay)'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_gateway"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on return, will\n  contain the IP gateway"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TPtrArray
--                  (TInterface Name { namespace = "NM" , name = "IPAddress" }))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip6_addresses_from_variant" nm_utils_ip6_addresses_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    Ptr CString ->                          -- out_gateway : TBasicType TUTF8
    IO (Ptr (GPtrArray (Ptr NM.IPAddress.IPAddress)))

-- | Utility function to convert a t'GVariant' of type \'a(ayuay)\' representing a
-- list of NetworkManager IPv6 addresses (which are tuples of address, prefix,
-- and gateway) into a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects. The \"gateway\" field
-- of the first address (if set) will be returned in /@outGateway@/; the \"gateway\"
-- fields of the other addresses are ignored. Note that invalid addresses are
-- discarded but the valid addresses are still returned.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
utilsIp6AddressesFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: a t'GVariant' of type \'a(ayuay)\'
    -> m (([NM.IPAddress.IPAddress], Maybe T.Text))
    -- ^ __Returns:__ a newly allocated
    --   t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects
utilsIp6AddressesFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m ([IPAddress], Maybe Text)
utilsIp6AddressesFromVariant GVariant
value = IO ([IPAddress], Maybe Text) -> m ([IPAddress], Maybe Text)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ([IPAddress], Maybe Text) -> m ([IPAddress], Maybe Text))
-> IO ([IPAddress], Maybe Text) -> m ([IPAddress], Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    Ptr CString
outGateway <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    Ptr (GPtrArray (Ptr IPAddress))
result <- Ptr GVariant -> Ptr CString -> IO (Ptr (GPtrArray (Ptr IPAddress)))
nm_utils_ip6_addresses_from_variant Ptr GVariant
value' Ptr CString
outGateway
    Text -> Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp6AddressesFromVariant" Ptr (GPtrArray (Ptr IPAddress))
result
    [Ptr IPAddress]
result' <- Ptr (GPtrArray (Ptr IPAddress)) -> IO [Ptr IPAddress]
forall a. Ptr (GPtrArray (Ptr a)) -> IO [Ptr a]
unpackGPtrArray Ptr (GPtrArray (Ptr IPAddress))
result
    [IPAddress]
result'' <- (Ptr IPAddress -> IO IPAddress)
-> [Ptr IPAddress] -> IO [IPAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr IPAddress -> IPAddress)
-> Ptr IPAddress -> IO IPAddress
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IPAddress -> IPAddress
NM.IPAddress.IPAddress) [Ptr IPAddress]
result'
    Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPAddress))
result
    CString
outGateway' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
outGateway
    Maybe Text
maybeOutGateway' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
outGateway' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
outGateway'' -> do
        Text
outGateway''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
outGateway''
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
outGateway'''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
outGateway'
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
outGateway
    ([IPAddress], Maybe Text) -> IO ([IPAddress], Maybe Text)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([IPAddress]
result'', Maybe Text
maybeOutGateway')


-- function utils_ip4_routes_to_variant
-- Args: [ Arg
--           { argCName = "routes"
--           , argType =
--               TPtrArray (TInterface Name { namespace = "NM" , name = "IPRoute" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of #NMIP4Route objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_routes_to_variant" nm_utils_ip4_routes_to_variant :: 
    Ptr (GPtrArray (Ptr NM.IPRoute.IPRoute)) -> -- routes : TPtrArray (TInterface (Name {namespace = "NM", name = "IPRoute"}))
    IO (Ptr GVariant)

-- | Utility function to convert a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects representing
-- IPv4 routes into a t'GVariant' of type \'aau\' representing an array of
-- NetworkManager IPv4 routes (which are tuples of route, prefix, next hop, and
-- metric).
utilsIp4RoutesToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [NM.IPRoute.IPRoute]
    -- ^ /@routes@/: an array of @/NMIP4Route/@ objects
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@routes@/.
utilsIp4RoutesToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[IPRoute] -> m GVariant
utilsIp4RoutesToVariant [IPRoute]
routes = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    [Ptr IPRoute]
routes' <- (IPRoute -> IO (Ptr IPRoute)) -> [IPRoute] -> IO [Ptr IPRoute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM IPRoute -> IO (Ptr IPRoute)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [IPRoute]
routes
    Ptr (GPtrArray (Ptr IPRoute))
routes'' <- [Ptr IPRoute] -> IO (Ptr (GPtrArray (Ptr IPRoute)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr IPRoute]
routes'
    Ptr GVariant
result <- Ptr (GPtrArray (Ptr IPRoute)) -> IO (Ptr GVariant)
nm_utils_ip4_routes_to_variant Ptr (GPtrArray (Ptr IPRoute))
routes''
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp4RoutesToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    (IPRoute -> IO ()) -> [IPRoute] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ IPRoute -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [IPRoute]
routes
    Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPRoute))
routes''
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip4_routes_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "#GVariant of type 'aau'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TPtrArray
--                  (TInterface Name { namespace = "NM" , name = "IPRoute" }))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_routes_from_variant" nm_utils_ip4_routes_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    IO (Ptr (GPtrArray (Ptr NM.IPRoute.IPRoute)))

-- | Utility function to convert a t'GVariant' of type \'aau\' representing an array
-- of NetworkManager IPv4 routes (which are tuples of route, prefix, next hop,
-- and metric) into a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects. Note that invalid routes
-- are discarded but the valid routes are still returned.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
utilsIp4RoutesFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: t'GVariant' of type \'aau\'
    -> m [NM.IPRoute.IPRoute]
    -- ^ __Returns:__ a newly allocated
    --   t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPRoute.IPRoute' objects
utilsIp4RoutesFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m [IPRoute]
utilsIp4RoutesFromVariant GVariant
value = IO [IPRoute] -> m [IPRoute]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [IPRoute] -> m [IPRoute]) -> IO [IPRoute] -> m [IPRoute]
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    Ptr (GPtrArray (Ptr IPRoute))
result <- Ptr GVariant -> IO (Ptr (GPtrArray (Ptr IPRoute)))
nm_utils_ip4_routes_from_variant Ptr GVariant
value'
    Text -> Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp4RoutesFromVariant" Ptr (GPtrArray (Ptr IPRoute))
result
    [Ptr IPRoute]
result' <- Ptr (GPtrArray (Ptr IPRoute)) -> IO [Ptr IPRoute]
forall a. Ptr (GPtrArray (Ptr a)) -> IO [Ptr a]
unpackGPtrArray Ptr (GPtrArray (Ptr IPRoute))
result
    [IPRoute]
result'' <- (Ptr IPRoute -> IO IPRoute) -> [Ptr IPRoute] -> IO [IPRoute]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr IPRoute -> IPRoute) -> Ptr IPRoute -> IO IPRoute
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IPRoute -> IPRoute
NM.IPRoute.IPRoute) [Ptr IPRoute]
result'
    Ptr (GPtrArray (Ptr IPRoute)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPRoute))
result
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    [IPRoute] -> IO [IPRoute]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [IPRoute]
result''


-- function utils_ip4_prefix_to_netmask
-- Args: [ Arg
--           { argCName = "prefix"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a CIDR prefix, must be not larger than 32."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_prefix_to_netmask" nm_utils_ip4_prefix_to_netmask :: 
    Word32 ->                               -- prefix : TBasicType TUInt32
    IO Word32

-- | /No description available in the introspection data./
utilsIp4PrefixToNetmask ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@prefix@/: a CIDR prefix, must be not larger than 32.
    -> m Word32
    -- ^ __Returns:__ the netmask represented by the prefix, in network byte order
utilsIp4PrefixToNetmask :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> m Word32
utilsIp4PrefixToNetmask Word32
prefix = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
nm_utils_ip4_prefix_to_netmask Word32
prefix
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_ip4_netmask_to_prefix
-- Args: [ Arg
--           { argCName = "netmask"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "an IPv4 netmask in network byte order.\n  Usually the netmask has all leading bits up to the prefix\n  set so that the netmask is identical to having the first\n  prefix bits of the address set.\n  If that is not the case and there are \"holes\" in the\n  mask, the prefix is determined based on the lowest bit\n  set."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_netmask_to_prefix" nm_utils_ip4_netmask_to_prefix :: 
    Word32 ->                               -- netmask : TBasicType TUInt32
    IO Word32

-- | /No description available in the introspection data./
utilsIp4NetmaskToPrefix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@netmask@/: an IPv4 netmask in network byte order.
    --   Usually the netmask has all leading bits up to the prefix
    --   set so that the netmask is identical to having the first
    --   prefix bits of the address set.
    --   If that is not the case and there are \"holes\" in the
    --   mask, the prefix is determined based on the lowest bit
    --   set.
    -> m Word32
    -- ^ __Returns:__ the CIDR prefix represented by the netmask
utilsIp4NetmaskToPrefix :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> m Word32
utilsIp4NetmaskToPrefix Word32
netmask = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
nm_utils_ip4_netmask_to_prefix Word32
netmask
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_ip4_get_default_prefix
-- Args: [ Arg
--           { argCName = "ip"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an IPv4 address (in network byte order)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_get_default_prefix" nm_utils_ip4_get_default_prefix :: 
    Word32 ->                               -- ip : TBasicType TUInt32
    IO Word32

-- | When the Internet was originally set up, various ranges of IP addresses were
-- segmented into three network classes: A, B, and C.  This function will return
-- a prefix that is associated with the IP address specified defining where it
-- falls in the predefined classes.
utilsIp4GetDefaultPrefix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@ip@/: an IPv4 address (in network byte order)
    -> m Word32
    -- ^ __Returns:__ the default class prefix for the given IP
utilsIp4GetDefaultPrefix :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Word32 -> m Word32
utilsIp4GetDefaultPrefix Word32
ip = IO Word32 -> m Word32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Word32 -> IO Word32
nm_utils_ip4_get_default_prefix Word32
ip
    Word32 -> IO Word32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function utils_ip4_dns_to_variant
-- Args: [ Arg
--           { argCName = "dns"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of IP address strings"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_dns_to_variant" nm_utils_ip4_dns_to_variant :: 
    CString ->                              -- dns : TBasicType TUTF8
    IO (Ptr GVariant)

-- | Utility function to convert an array of IP address strings int a t'GVariant' of
-- type \'au\' representing an array of IPv4 addresses.
utilsIp4DnsToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@dns@/: an array of IP address strings
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@dns@/.
utilsIp4DnsToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m GVariant
utilsIp4DnsToVariant Text
dns = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    CString
dns' <- Text -> IO CString
textToCString Text
dns
    Ptr GVariant
result <- CString -> IO (Ptr GVariant)
nm_utils_ip4_dns_to_variant CString
dns'
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp4DnsToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
dns'
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip4_dns_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant of type 'au'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_dns_from_variant" nm_utils_ip4_dns_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    IO CString

-- | Utility function to convert a t'GVariant' of type \'au\' representing a list of
-- IPv4 addresses into an array of IP address strings.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
utilsIp4DnsFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: a t'GVariant' of type \'au\'
    -> m T.Text
    -- ^ __Returns:__ a 'P.Nothing'-terminated array of IP address strings.
utilsIp4DnsFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m Text
utilsIp4DnsFromVariant GVariant
value = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    CString
result <- Ptr GVariant -> IO CString
nm_utils_ip4_dns_from_variant Ptr GVariant
value'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp4DnsFromVariant" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_ip4_addresses_to_variant
-- Args: [ Arg
--           { argCName = "addresses"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "NM" , name = "IPAddress" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of #NMIPAddress objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "gateway"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the gateway IP address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_addresses_to_variant" nm_utils_ip4_addresses_to_variant :: 
    Ptr (GPtrArray (Ptr NM.IPAddress.IPAddress)) -> -- addresses : TPtrArray (TInterface (Name {namespace = "NM", name = "IPAddress"}))
    CString ->                              -- gateway : TBasicType TUTF8
    IO (Ptr GVariant)

-- | Utility function to convert a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects representing
-- IPv4 addresses into a t'GVariant' of type \'aau\' representing an array of
-- NetworkManager IPv4 addresses (which are tuples of address, prefix, and
-- gateway). The \"gateway\" field of the first address will get the value of
-- /@gateway@/ (if non-'P.Nothing'). In all of the other addresses, that field will be 0.
utilsIp4AddressesToVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [NM.IPAddress.IPAddress]
    -- ^ /@addresses@/: an array of t'GI.NM.Structs.IPAddress.IPAddress' objects
    -> Maybe (T.Text)
    -- ^ /@gateway@/: the gateway IP address
    -> m GVariant
    -- ^ __Returns:__ a new floating t'GVariant' representing /@addresses@/.
utilsIp4AddressesToVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
[IPAddress] -> Maybe Text -> m GVariant
utilsIp4AddressesToVariant [IPAddress]
addresses Maybe Text
gateway = IO GVariant -> m GVariant
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    [Ptr IPAddress]
addresses' <- (IPAddress -> IO (Ptr IPAddress))
-> [IPAddress] -> IO [Ptr IPAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM IPAddress -> IO (Ptr IPAddress)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [IPAddress]
addresses
    Ptr (GPtrArray (Ptr IPAddress))
addresses'' <- [Ptr IPAddress] -> IO (Ptr (GPtrArray (Ptr IPAddress)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr IPAddress]
addresses'
    CString
maybeGateway <- case Maybe Text
gateway of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jGateway -> do
            CString
jGateway' <- Text -> IO CString
textToCString Text
jGateway
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jGateway'
    Ptr GVariant
result <- Ptr (GPtrArray (Ptr IPAddress)) -> CString -> IO (Ptr GVariant)
nm_utils_ip4_addresses_to_variant Ptr (GPtrArray (Ptr IPAddress))
addresses'' CString
maybeGateway
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp4AddressesToVariant" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.newGVariantFromPtr Ptr GVariant
result
    (IPAddress -> IO ()) -> [IPAddress] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ IPAddress -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [IPAddress]
addresses
    Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPAddress))
addresses''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeGateway
    GVariant -> IO GVariant
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function utils_ip4_addresses_from_variant
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant of type 'aau'"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_gateway"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on return, will\n  contain the IP gateway"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TPtrArray
--                  (TInterface Name { namespace = "NM" , name = "IPAddress" }))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ip4_addresses_from_variant" nm_utils_ip4_addresses_from_variant :: 
    Ptr GVariant ->                         -- value : TVariant
    Ptr CString ->                          -- out_gateway : TBasicType TUTF8
    IO (Ptr (GPtrArray (Ptr NM.IPAddress.IPAddress)))

-- | Utility function to convert a t'GVariant' of type \'aau\' representing a list of
-- NetworkManager IPv4 addresses (which are tuples of address, prefix, and
-- gateway) into a t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects. The \"gateway\" field of
-- the first address (if set) will be returned in /@outGateway@/; the \"gateway\" fields
-- of the other addresses are ignored. Note that invalid addresses are discarded
-- but the valid addresses are still returned.
-- 
-- Since 1.46, an empty list is returned if the variant type is not valid
-- (before it was checked as assertion)
utilsIp4AddressesFromVariant ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: a t'GVariant' of type \'aau\'
    -> m (([NM.IPAddress.IPAddress], Maybe T.Text))
    -- ^ __Returns:__ a newly allocated
    --   t'GI.GLib.Structs.PtrArray.PtrArray' of t'GI.NM.Structs.IPAddress.IPAddress' objects
utilsIp4AddressesFromVariant :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GVariant -> m ([IPAddress], Maybe Text)
utilsIp4AddressesFromVariant GVariant
value = IO ([IPAddress], Maybe Text) -> m ([IPAddress], Maybe Text)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ([IPAddress], Maybe Text) -> m ([IPAddress], Maybe Text))
-> IO ([IPAddress], Maybe Text) -> m ([IPAddress], Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    Ptr CString
outGateway <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    Ptr (GPtrArray (Ptr IPAddress))
result <- Ptr GVariant -> Ptr CString -> IO (Ptr (GPtrArray (Ptr IPAddress)))
nm_utils_ip4_addresses_from_variant Ptr GVariant
value' Ptr CString
outGateway
    Text -> Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsIp4AddressesFromVariant" Ptr (GPtrArray (Ptr IPAddress))
result
    [Ptr IPAddress]
result' <- Ptr (GPtrArray (Ptr IPAddress)) -> IO [Ptr IPAddress]
forall a. Ptr (GPtrArray (Ptr a)) -> IO [Ptr a]
unpackGPtrArray Ptr (GPtrArray (Ptr IPAddress))
result
    [IPAddress]
result'' <- (Ptr IPAddress -> IO IPAddress)
-> [Ptr IPAddress] -> IO [IPAddress]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ((ManagedPtr IPAddress -> IPAddress)
-> Ptr IPAddress -> IO IPAddress
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr IPAddress -> IPAddress
NM.IPAddress.IPAddress) [Ptr IPAddress]
result'
    Ptr (GPtrArray (Ptr IPAddress)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr IPAddress))
result
    CString
outGateway' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
outGateway
    Maybe Text
maybeOutGateway' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
outGateway' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
outGateway'' -> do
        Text
outGateway''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
outGateway''
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
outGateway'''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
outGateway'
    GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
outGateway
    ([IPAddress], Maybe Text) -> IO ([IPAddress], Maybe Text)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([IPAddress]
result'', Maybe Text
maybeOutGateway')


-- function utils_iface_valid_name
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "Name of interface" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_iface_valid_name" nm_utils_iface_valid_name :: 
    CString ->                              -- name : TBasicType TUTF8
    IO CInt

{-# DEPRECATED utilsIfaceValidName ["(Since version 1.6)","Use 'GI.NM.Functions.utilsIsValidIfaceName' instead, with better error reporting."] #-}
-- | Validate the network interface name.
utilsIfaceValidName ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@name@/: Name of interface
    -> m Bool
    -- ^ __Returns:__ 'P.True' if interface name is valid, otherwise 'P.False' is returned.
    -- 
    -- Before 1.20, this function did not accept 'P.Nothing' as /@name@/ argument. If you
    --   want to run against older versions of libnm, don\'t pass 'P.Nothing'.
utilsIfaceValidName :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
utilsIfaceValidName Maybe Text
name = 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
    CString
maybeName <- case Maybe Text
name of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jName -> do
            CString
jName' <- Text -> IO CString
textToCString Text
jName
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jName'
    CInt
result <- CString -> IO CInt
nm_utils_iface_valid_name CString
maybeName
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeName
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_hwaddr_valid
-- Args: [ Arg
--           { argCName = "asc"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the ASCII representation of a hardware address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TSSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of address that @asc is expected to convert to\n  (or -1 to accept any length up to %NM_UTILS_HWADDR_LEN_MAX)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_valid" nm_utils_hwaddr_valid :: 
    CString ->                              -- asc : TBasicType TUTF8
    DI.Int64 ->                             -- length : TBasicType TSSize
    IO CInt

-- | Parses /@asc@/ to see if it is a valid hardware address of the given
-- length.
utilsHwaddrValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@asc@/: the ASCII representation of a hardware address
    -> DI.Int64
    -- ^ /@length@/: the length of address that /@asc@/ is expected to convert to
    --   (or -1 to accept any length up to 'GI.NM.Constants.UTILS_HWADDR_LEN_MAX')
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@asc@/ appears to be a valid hardware address
    --   of the indicated length, 'P.False' if not.
utilsHwaddrValid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int64 -> m Bool
utilsHwaddrValid Text
asc Int64
length_ = 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
    CString
asc' <- Text -> IO CString
textToCString Text
asc
    CInt
result <- CString -> Int64 -> IO CInt
nm_utils_hwaddr_valid CString
asc' Int64
length_
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
asc'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_hwaddr_ntoa
-- Args: [ Arg
--           { argCName = "addr"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a binary hardware address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the length of @addr"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "length"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "the length of @addr"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_ntoa" nm_utils_hwaddr_ntoa :: 
    Ptr Word8 ->                            -- addr : TCArray False (-1) 1 (TBasicType TUInt8)
    FCT.CSize ->                            -- length : TBasicType TSize
    IO CString

-- | Converts /@addr@/ to textual form.
utilsHwaddrNtoa ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    -- ^ /@addr@/: a binary hardware address
    -> m T.Text
    -- ^ __Returns:__ the textual form of /@addr@/
utilsHwaddrNtoa :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ByteString -> m Text
utilsHwaddrNtoa ByteString
addr = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let length_ :: CSize
length_ = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
addr
    Ptr Word8
addr' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
addr
    CString
result <- Ptr Word8 -> CSize -> IO CString
nm_utils_hwaddr_ntoa Ptr Word8
addr' CSize
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsHwaddrNtoa" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
addr'
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_hwaddr_matches
-- Args: [ Arg
--           { argCName = "hwaddr1"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "pointer to a binary or ASCII hardware address, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hwaddr1_len"
--           , argType = TBasicType TSSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "size of @hwaddr1, or -1 if @hwaddr1 is ASCII"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hwaddr2"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "pointer to a binary or ASCII hardware address, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hwaddr2_len"
--           , argType = TBasicType TSSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "size of @hwaddr2, or -1 if @hwaddr2 is ASCII"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_matches" nm_utils_hwaddr_matches :: 
    Ptr () ->                               -- hwaddr1 : TBasicType TPtr
    DI.Int64 ->                             -- hwaddr1_len : TBasicType TSSize
    Ptr () ->                               -- hwaddr2 : TBasicType TPtr
    DI.Int64 ->                             -- hwaddr2_len : TBasicType TSSize
    IO CInt

-- | Generalized hardware address comparison function. Tests if /@hwaddr1@/ and
-- /@hwaddr2@/ \"equal\" (or more precisely, \"equivalent\"), with several advantages
-- over a simple @/memcmp()/@:
-- 
-- 1. If /@hwaddr1Len@/ or /@hwaddr2Len@/ is -1, then the corresponding address is
--    assumed to be ASCII rather than binary, and will be converted to binary
--    before being compared.
-- 
-- 2. If /@hwaddr1@/ or /@hwaddr2@/ is 'P.Nothing', it is treated instead as though it was
--    a zero-filled buffer /@hwaddr1Len@/ or /@hwaddr2Len@/ bytes long.
-- 
-- 3. If /@hwaddr1@/ and /@hwaddr2@/ are InfiniBand hardware addresses (that is, if
--    they are \<literal>INFINIBAND_ALEN\<\/literal> bytes long in binary form)
--    then only the last 8 bytes are compared, since those are the only bytes
--    that actually identify the hardware. (The other 12 bytes will change
--    depending on the configuration of the InfiniBand fabric that the device
--    is connected to.)
-- 
-- 
-- 
-- If a passed-in ASCII hardware address cannot be parsed, or would parse to an
-- address larger than 'GI.NM.Constants.UTILS_HWADDR_LEN_MAX', then it will silently fail to
-- match. (This means that externally-provided address strings do not need to be
-- sanity-checked before comparing them against known good addresses; they are
-- guaranteed to not match if they are invalid.)
utilsHwaddrMatches ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@hwaddr1@/: pointer to a binary or ASCII hardware address, or 'P.Nothing'
    -> DI.Int64
    -- ^ /@hwaddr1Len@/: size of /@hwaddr1@/, or -1 if /@hwaddr1@/ is ASCII
    -> Ptr ()
    -- ^ /@hwaddr2@/: pointer to a binary or ASCII hardware address, or 'P.Nothing'
    -> DI.Int64
    -- ^ /@hwaddr2Len@/: size of /@hwaddr2@/, or -1 if /@hwaddr2@/ is ASCII
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@hwaddr1@/ and /@hwaddr2@/ are equivalent, 'P.False' if they are
    --   different (or either of them is invalid).
utilsHwaddrMatches :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Ptr () -> Int64 -> Ptr () -> Int64 -> m Bool
utilsHwaddrMatches Ptr ()
hwaddr1 Int64
hwaddr1Len Ptr ()
hwaddr2 Int64
hwaddr2Len = 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
    CInt
result <- Ptr () -> Int64 -> Ptr () -> Int64 -> IO CInt
nm_utils_hwaddr_matches Ptr ()
hwaddr1 Int64
hwaddr1Len Ptr ()
hwaddr2 Int64
hwaddr2Len
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_hwaddr_len
-- Args: [ Arg
--           { argCName = "type"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the type of address; either <literal>ARPHRD_ETHER</literal> or\n<literal>ARPHRD_INFINIBAND</literal>"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TSize)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_len" nm_utils_hwaddr_len :: 
    Int32 ->                                -- type : TBasicType TInt
    IO FCT.CSize

-- | Returns the length in octets of a hardware address of type /@type@/.
-- 
-- Before 1.28, it was an error to call this function with any value other than
-- \<literal>ARPHRD_ETHER\<\/literal> or \<literal>ARPHRD_INFINIBAND\<\/literal>.
utilsHwaddrLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    -- ^ /@type@/: the type of address; either \<literal>ARPHRD_ETHER\<\/literal> or
    -- \<literal>ARPHRD_INFINIBAND\<\/literal>
    -> m FCT.CSize
    -- ^ __Returns:__ the length or zero if the type is unrecognized.
utilsHwaddrLen :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Int32 -> m CSize
utilsHwaddrLen Int32
type_ = IO CSize -> m CSize
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CSize -> m CSize) -> IO CSize -> m CSize
forall a b. (a -> b) -> a -> b
$ do
    CSize
result <- Int32 -> IO CSize
nm_utils_hwaddr_len Int32
type_
    CSize -> IO CSize
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CSize
result


-- function utils_hwaddr_canonical
-- Args: [ Arg
--           { argCName = "asc"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the ASCII representation of a hardware address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TSSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of address that @asc is expected to convert to\n  (or -1 to accept any length up to %NM_UTILS_HWADDR_LEN_MAX)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_canonical" nm_utils_hwaddr_canonical :: 
    CString ->                              -- asc : TBasicType TUTF8
    DI.Int64 ->                             -- length : TBasicType TSSize
    IO CString

-- | Parses /@asc@/ to see if it is a valid hardware address of the given
-- length, and if so, returns it in canonical form (uppercase, with
-- leading 0s as needed, and with colons rather than hyphens).
utilsHwaddrCanonical ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@asc@/: the ASCII representation of a hardware address
    -> DI.Int64
    -- ^ /@length@/: the length of address that /@asc@/ is expected to convert to
    --   (or -1 to accept any length up to 'GI.NM.Constants.UTILS_HWADDR_LEN_MAX')
    -> m T.Text
    -- ^ __Returns:__ the canonicalized address if /@asc@/ appears to
    --   be a valid hardware address of the indicated length, 'P.Nothing' if not.
utilsHwaddrCanonical :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> Int64 -> m Text
utilsHwaddrCanonical Text
asc Int64
length_ = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
asc' <- Text -> IO CString
textToCString Text
asc
    CString
result <- CString -> Int64 -> IO CString
nm_utils_hwaddr_canonical CString
asc' Int64
length_
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsHwaddrCanonical" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
asc'
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_hwaddr_aton
-- Args: [ Arg
--           { argCName = "asc"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the ASCII representation of a hardware address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "buffer"
--           , argType = TCArray False (-1) 2 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "buffer to store the result into"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the expected length in bytes of the result and\nthe size of the buffer in bytes."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "length"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText =
--                        Just
--                          "the expected length in bytes of the result and\nthe size of the buffer in bytes."
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUInt8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_aton" nm_utils_hwaddr_aton :: 
    CString ->                              -- asc : TBasicType TUTF8
    Ptr Word8 ->                            -- buffer : TCArray False (-1) 2 (TBasicType TUInt8)
    FCT.CSize ->                            -- length : TBasicType TSize
    IO Word8

-- | Parses /@asc@/ and converts it to binary form in /@buffer@/.
-- Bytes in /@asc@/ can be separated by colons (:), or hyphens (-), but not mixed.
utilsHwaddrAton ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@asc@/: the ASCII representation of a hardware address
    -> ByteString
    -- ^ /@buffer@/: buffer to store the result into
    -> m Word8
    -- ^ __Returns:__ /@buffer@/, or 'P.Nothing' if /@asc@/ couldn\'t be parsed
    --   or would be shorter or longer than /@length@/.
utilsHwaddrAton :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> ByteString -> m Word8
utilsHwaddrAton Text
asc ByteString
buffer = IO Word8 -> m Word8
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word8 -> m Word8) -> IO Word8 -> m Word8
forall a b. (a -> b) -> a -> b
$ do
    let length_ :: CSize
length_ = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
buffer
    CString
asc' <- Text -> IO CString
textToCString Text
asc
    Ptr Word8
buffer' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
buffer
    Word8
result <- CString -> Ptr Word8 -> CSize -> IO Word8
nm_utils_hwaddr_aton CString
asc' Ptr Word8
buffer' CSize
length_
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
asc'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
buffer'
    Word8 -> IO Word8
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Word8
result


-- function utils_hwaddr_atoba
-- Args: [ Arg
--           { argCName = "asc"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the ASCII representation of a hardware address"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the expected length in bytes of the result"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TByteArray
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hwaddr_atoba" nm_utils_hwaddr_atoba :: 
    CString ->                              -- asc : TBasicType TUTF8
    FCT.CSize ->                            -- length : TBasicType TSize
    IO (Ptr GByteArray)

-- | Parses /@asc@/ and converts it to binary form in a t'GI.GLib.Structs.ByteArray.ByteArray'. See
-- 'GI.NM.Functions.utilsHwaddrAton' if you don\'t want a t'GI.GLib.Structs.ByteArray.ByteArray'.
utilsHwaddrAtoba ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@asc@/: the ASCII representation of a hardware address
    -> FCT.CSize
    -- ^ /@length@/: the expected length in bytes of the result
    -> m ByteString
    -- ^ __Returns:__ a new t'GI.GLib.Structs.ByteArray.ByteArray', or 'P.Nothing' if /@asc@/ couldn\'t
    -- be parsed
utilsHwaddrAtoba :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> CSize -> m ByteString
utilsHwaddrAtoba Text
asc CSize
length_ = IO ByteString -> m ByteString
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ByteString -> m ByteString) -> IO ByteString -> m ByteString
forall a b. (a -> b) -> a -> b
$ do
    CString
asc' <- Text -> IO CString
textToCString Text
asc
    Ptr GByteArray
result <- CString -> CSize -> IO (Ptr GByteArray)
nm_utils_hwaddr_atoba CString
asc' CSize
length_
    Text -> Ptr GByteArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsHwaddrAtoba" Ptr GByteArray
result
    ByteString
result' <- Ptr GByteArray -> IO ByteString
unpackGByteArray Ptr GByteArray
result
    Ptr GByteArray -> IO ()
unrefGByteArray Ptr GByteArray
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
asc'
    ByteString -> IO ByteString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ByteString
result'


-- function utils_hexstr2bin
-- Args: [ Arg
--           { argCName = "hex"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a string of hexadecimal characters with optional ':' separators"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "Bytes" })
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_hexstr2bin" nm_utils_hexstr2bin :: 
    CString ->                              -- hex : TBasicType TUTF8
    IO (Ptr GLib.Bytes.Bytes)

-- | Converts a hexadecimal string /@hex@/ into an array of bytes.  The optional
-- separator \':\' may be used between single or pairs of hexadecimal characters,
-- eg \"00:11\" or \"0:1\".  Any \"0x\" at the beginning of /@hex@/ is ignored.  /@hex@/
-- may not start or end with \':\'.
utilsHexstr2bin ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@hex@/: a string of hexadecimal characters with optional \':\' separators
    -> m GLib.Bytes.Bytes
    -- ^ __Returns:__ the converted bytes, or 'P.Nothing' on error
utilsHexstr2bin :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Bytes
utilsHexstr2bin Text
hex = IO Bytes -> m Bytes
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bytes -> m Bytes) -> IO Bytes -> m Bytes
forall a b. (a -> b) -> a -> b
$ do
    CString
hex' <- Text -> IO CString
textToCString Text
hex
    Ptr Bytes
result <- CString -> IO (Ptr Bytes)
nm_utils_hexstr2bin CString
hex'
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsHexstr2bin" Ptr Bytes
result
    Bytes
result' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hex'
    Bytes -> IO Bytes
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'


-- function utils_get_timestamp_msec
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TInt64)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_get_timestamp_msec" nm_utils_get_timestamp_msec :: 
    IO Int64

-- | Gets current time in milliseconds of CLOCK_BOOTTIME.
-- 
-- /Since: 1.12/
utilsGetTimestampMsec ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Int64
    -- ^ __Returns:__ time in milliseconds
utilsGetTimestampMsec :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m Int64
utilsGetTimestampMsec  = IO Int64 -> m Int64
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int64 -> m Int64) -> IO Int64 -> m Int64
forall a b. (a -> b) -> a -> b
$ do
    Int64
result <- IO Int64
nm_utils_get_timestamp_msec
    Int64 -> IO Int64
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int64
result


-- function utils_format_variant_attributes
-- XXX Could not generate function utils_format_variant_attributes

-- Not implemented: GHashTable element of type TVariant unsupported.

-- function utils_file_search_in_paths
-- Args: [ Arg
--           { argCName = "progname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the helper program name, like \"iptables\"\n  Must be a non-empty string, without path separator (/)."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "try_first"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a custom path to try first before searching.\n  It is silently ignored if it is empty or not an absolute path."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "paths"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a %NULL terminated list of search paths.\n  Can be empty or %NULL, in which case only @try_first is checked."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "file_test_flags"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "FileTest" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the flags passed to g_file_test() when searching\n  for @progname. Set it to 0 to skip the g_file_test()."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "predicate"
--           , argType =
--               TInterface
--                 Name
--                   { namespace = "NM" , name = "UtilsFileSearchInPathsPredicate" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "if given, pass the file name to this function\n  for additional checks. This check is performed after the check for\n  @file_test_flags. You cannot omit both @file_test_flags and @predicate."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeCall
--           , argClosure = 5
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data for @predicate function."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "nm_utils_file_search_in_paths" nm_utils_file_search_in_paths :: 
    CString ->                              -- progname : TBasicType TUTF8
    CString ->                              -- try_first : TBasicType TUTF8
    CString ->                              -- paths : TBasicType TUTF8
    CUInt ->                                -- file_test_flags : TInterface (Name {namespace = "GLib", name = "FileTest"})
    FunPtr NM.Callbacks.C_UtilsFileSearchInPathsPredicate -> -- predicate : TInterface (Name {namespace = "NM", name = "UtilsFileSearchInPathsPredicate"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Searches for a /@progname@/ file in a list of search /@paths@/.
utilsFileSearchInPaths ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@progname@/: the helper program name, like \"iptables\"
    --   Must be a non-empty string, without path separator (\/).
    -> Maybe (T.Text)
    -- ^ /@tryFirst@/: a custom path to try first before searching.
    --   It is silently ignored if it is empty or not an absolute path.
    -> Maybe (T.Text)
    -- ^ /@paths@/: a 'P.Nothing' terminated list of search paths.
    --   Can be empty or 'P.Nothing', in which case only /@tryFirst@/ is checked.
    -> [GLib.Flags.FileTest]
    -- ^ /@fileTestFlags@/: the flags passed to 'GI.GLib.Functions.fileTest' when searching
    --   for /@progname@/. Set it to 0 to skip the 'GI.GLib.Functions.fileTest'.
    -> NM.Callbacks.UtilsFileSearchInPathsPredicate
    -- ^ /@predicate@/: if given, pass the file name to this function
    --   for additional checks. This check is performed after the check for
    --   /@fileTestFlags@/. You cannot omit both /@fileTestFlags@/ and /@predicate@/.
    -> m T.Text
    -- ^ __Returns:__ the full path to the helper, if found, or 'P.Nothing' if not found.
    --   The returned string is not owned by the caller, but later
    --   invocations of the function might overwrite it. /(Can throw 'Data.GI.Base.GError.GError')/
utilsFileSearchInPaths :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text
-> Maybe Text
-> Maybe Text
-> [FileTest]
-> UtilsFileSearchInPathsPredicate
-> m Text
utilsFileSearchInPaths Text
progname Maybe Text
tryFirst Maybe Text
paths [FileTest]
fileTestFlags UtilsFileSearchInPathsPredicate
predicate = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
progname' <- Text -> IO CString
textToCString Text
progname
    CString
maybeTryFirst <- case Maybe Text
tryFirst of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jTryFirst -> do
            CString
jTryFirst' <- Text -> IO CString
textToCString Text
jTryFirst
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jTryFirst'
    CString
maybePaths <- case Maybe Text
paths of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jPaths -> do
            CString
jPaths' <- Text -> IO CString
textToCString Text
jPaths
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jPaths'
    let fileTestFlags' :: CUInt
fileTestFlags' = [FileTest] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [FileTest]
fileTestFlags
    FunPtr C_UtilsFileSearchInPathsPredicate
predicate' <- C_UtilsFileSearchInPathsPredicate
-> IO (FunPtr C_UtilsFileSearchInPathsPredicate)
NM.Callbacks.mk_UtilsFileSearchInPathsPredicate (Maybe (Ptr (FunPtr C_UtilsFileSearchInPathsPredicate))
-> UtilsFileSearchInPathsPredicate_WithClosures
-> C_UtilsFileSearchInPathsPredicate
NM.Callbacks.wrap_UtilsFileSearchInPathsPredicate Maybe (Ptr (FunPtr C_UtilsFileSearchInPathsPredicate))
forall a. Maybe a
Nothing (UtilsFileSearchInPathsPredicate
-> UtilsFileSearchInPathsPredicate_WithClosures
NM.Callbacks.drop_closures_UtilsFileSearchInPathsPredicate UtilsFileSearchInPathsPredicate
predicate))
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString
-> CString
-> CString
-> CUInt
-> FunPtr C_UtilsFileSearchInPathsPredicate
-> Ptr ()
-> Ptr (Ptr GError)
-> IO CString
nm_utils_file_search_in_paths CString
progname' CString
maybeTryFirst CString
maybePaths CUInt
fileTestFlags' FunPtr C_UtilsFileSearchInPathsPredicate
predicate' Ptr ()
forall a. Ptr a
userData
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsFileSearchInPaths" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_UtilsFileSearchInPathsPredicate -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_UtilsFileSearchInPathsPredicate
predicate'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
progname'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTryFirst
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybePaths
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_UtilsFileSearchInPathsPredicate -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_UtilsFileSearchInPathsPredicate
predicate'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
progname'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeTryFirst
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybePaths
     )


-- function utils_file_is_private_key
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "name of the file to test"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_encrypted"
--           , argType = TBasicType TBoolean
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on return, whether the file is encrypted"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_file_is_private_key" nm_utils_file_is_private_key :: 
    CString ->                              -- filename : TBasicType TUTF8
    Ptr CInt ->                             -- out_encrypted : TBasicType TBoolean
    IO CInt

-- | Tests if /@filename@/ has a valid extension for an X.509 private key file
-- (\".der\", \".key\", \".pem\", or \".p12\"), and contains a private key in a format
-- recognized by NetworkManager.
utilsFileIsPrivateKey ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: name of the file to test
    -> m ((Bool, Bool))
    -- ^ __Returns:__ 'P.True' if the file is a private key, 'P.False' if it is not
utilsFileIsPrivateKey :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m (Bool, Bool)
utilsFileIsPrivateKey Text
filename = IO (Bool, Bool) -> m (Bool, Bool)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Bool) -> m (Bool, Bool))
-> IO (Bool, Bool) -> m (Bool, Bool)
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    Ptr CInt
outEncrypted <- IO (Ptr CInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CInt)
    CInt
result <- CString -> Ptr CInt -> IO CInt
nm_utils_file_is_private_key CString
filename' Ptr CInt
outEncrypted
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CInt
outEncrypted' <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
outEncrypted
    let outEncrypted'' :: Bool
outEncrypted'' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
outEncrypted'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Ptr CInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CInt
outEncrypted
    (Bool, Bool) -> IO (Bool, Bool)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Bool
outEncrypted'')


-- function utils_file_is_pkcs12
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "name of the file to test"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_file_is_pkcs12" nm_utils_file_is_pkcs12 :: 
    CString ->                              -- filename : TBasicType TUTF8
    IO CInt

-- | Tests if /@filename@/ is a PKCS#\<!-- -->12 file.
utilsFileIsPkcs12 ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: name of the file to test
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the file is PKCS#\<!-- -->12, 'P.False' if it is not
utilsFileIsPkcs12 :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Bool
utilsFileIsPkcs12 Text
filename = 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
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    CInt
result <- CString -> IO CInt
nm_utils_file_is_pkcs12 CString
filename'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_file_is_certificate
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "name of the file to test"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_file_is_certificate" nm_utils_file_is_certificate :: 
    CString ->                              -- filename : TBasicType TUTF8
    IO CInt

-- | Tests if /@filename@/ has a valid extension for an X.509 certificate file
-- (\".cer\", \".crt\", \".der\", or \".pem\"), and contains a certificate in a format
-- recognized by NetworkManager.
utilsFileIsCertificate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: name of the file to test
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the file is a certificate, 'P.False' if it is not
utilsFileIsCertificate :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Bool
utilsFileIsCertificate Text
filename = 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
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    CInt
result <- CString -> IO CInt
nm_utils_file_is_certificate CString
filename'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_escape_ssid
-- Args: [ Arg
--           { argCName = "ssid"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "pointer to a buffer containing the SSID data"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of the SSID data in @ssid"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "len"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of the SSID data in @ssid"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_escape_ssid" nm_utils_escape_ssid :: 
    Ptr Word8 ->                            -- ssid : TCArray False (-1) 1 (TBasicType TUInt8)
    FCT.CSize ->                            -- len : TBasicType TSize
    IO CString

{-# DEPRECATED utilsEscapeSsid ["(Since version 1.46)","use 'GI.NM.Functions.utilsSsidToUtf8' or 'GI.NM.Functions.utilsBin2hexstr'."] #-}
-- | This function does a quick printable character conversion of the SSID, simply
-- replacing embedded NULLs and non-printable characters with the hexadecimal
-- representation of that character.  Intended for debugging only, should not
-- be used for display of SSIDs.
-- 
-- Warning: this function uses a static buffer. It is not thread-safe. Don\'t
--   use this function.
utilsEscapeSsid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    -- ^ /@ssid@/: pointer to a buffer containing the SSID data
    -> m T.Text
    -- ^ __Returns:__ pointer to the escaped SSID, which uses an internal static buffer
    -- and will be overwritten by subsequent calls to this function
utilsEscapeSsid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ByteString -> m Text
utilsEscapeSsid ByteString
ssid = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let len :: CSize
len = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
ssid
    Ptr Word8
ssid' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
ssid
    CString
result <- Ptr Word8 -> CSize -> IO CString
nm_utils_escape_ssid Ptr Word8
ssid' CSize
len
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsEscapeSsid" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
ssid'
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_enum_to_str
-- Args: [ Arg
--           { argCName = "type"
--           , argType = TBasicType TGType
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %GType of the enum"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the value to be translated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_enum_to_str" nm_utils_enum_to_str :: 
    CGType ->                               -- type : TBasicType TGType
    Int32 ->                                -- value : TBasicType TInt
    IO CString

-- | Converts an enum value to its string representation. If the enum is a
-- @/G_TYPE_FLAGS/@ the function returns a comma-separated list of matching values.
-- If the value has no corresponding string representation, it is converted
-- to a number. For enums it is converted to a decimal number, for flags
-- to an (unsigned) hex number.
-- 
-- /Since: 1.2/
utilsEnumToStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@type@/: the @/GType/@ of the enum
    -> Int32
    -- ^ /@value@/: the value to be translated
    -> m T.Text
    -- ^ __Returns:__ a newly allocated string or 'P.Nothing'
utilsEnumToStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> Int32 -> m Text
utilsEnumToStr GType
type_ Int32
value = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let type_' :: CGType
type_' = GType -> CGType
gtypeToCGType GType
type_
    CString
result <- CGType -> Int32 -> IO CString
nm_utils_enum_to_str CGType
type_' Int32
value
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsEnumToStr" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_enum_get_values
-- Args: [ Arg
--           { argCName = "type"
--           , argType = TBasicType TGType
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %GType of the enum"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "from"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the first element to be returned"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "to"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the last element to be returned"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_enum_get_values" nm_utils_enum_get_values :: 
    CGType ->                               -- type : TBasicType TGType
    Int32 ->                                -- from : TBasicType TInt
    Int32 ->                                -- to : TBasicType TInt
    IO (Ptr CString)

-- | Returns the list of possible values for a given enum.
-- 
-- /Since: 1.2/
utilsEnumGetValues ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@type@/: the @/GType/@ of the enum
    -> Int32
    -- ^ /@from@/: the first element to be returned
    -> Int32
    -- ^ /@to@/: the last element to be returned
    -> m [T.Text]
    -- ^ __Returns:__ a NULL-terminated dynamically-allocated array of static strings
    -- or 'P.Nothing' on error
utilsEnumGetValues :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> Int32 -> Int32 -> m [Text]
utilsEnumGetValues GType
type_ Int32
from Int32
to = IO [Text] -> m [Text]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    let type_' :: CGType
type_' = GType -> CGType
gtypeToCGType GType
type_
    Ptr CString
result <- CGType -> Int32 -> Int32 -> IO (Ptr CString)
nm_utils_enum_get_values CGType
type_' Int32
from Int32
to
    Text -> Ptr CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsEnumGetValues" Ptr CString
result
    [Text]
result' <- HasCallStack => Ptr CString -> IO [Text]
Ptr CString -> IO [Text]
unpackZeroTerminatedUTF8CArray Ptr CString
result
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
result
    [Text] -> IO [Text]
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result'


-- function utils_enum_from_str
-- Args: [ Arg
--           { argCName = "type"
--           , argType = TBasicType TGType
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the %GType of the enum"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the input string" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_value"
--           , argType = TBasicType TInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the output value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "err_token"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "location to store\n  the first unrecognized token"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_enum_from_str" nm_utils_enum_from_str :: 
    CGType ->                               -- type : TBasicType TGType
    CString ->                              -- str : TBasicType TUTF8
    Ptr Int32 ->                            -- out_value : TBasicType TInt
    Ptr CString ->                          -- err_token : TBasicType TUTF8
    IO CInt

-- | Converts a string to the matching enum value.
-- 
-- If the enum is a @/G_TYPE_FLAGS/@ the function returns the logical OR of values
-- matching the comma-separated tokens in the string; if an unknown token is found
-- the function returns 'P.False' and stores a pointer to a newly allocated string
-- containing the unrecognized token in /@errToken@/.
-- 
-- /Since: 1.2/
utilsEnumFromStr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@type@/: the @/GType/@ of the enum
    -> T.Text
    -- ^ /@str@/: the input string
    -> m ((Bool, Int32, Maybe T.Text))
    -- ^ __Returns:__ 'P.True' if the conversion was successful, 'P.False' otherwise
utilsEnumFromStr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> Text -> m (Bool, Int32, Maybe Text)
utilsEnumFromStr GType
type_ Text
str = IO (Bool, Int32, Maybe Text) -> m (Bool, Int32, Maybe Text)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Int32, Maybe Text) -> m (Bool, Int32, Maybe Text))
-> IO (Bool, Int32, Maybe Text) -> m (Bool, Int32, Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    let type_' :: CGType
type_' = GType -> CGType
gtypeToCGType GType
type_
    CString
str' <- Text -> IO CString
textToCString Text
str
    Ptr Int32
outValue <- IO (Ptr Int32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Int32)
    Ptr CString
errToken <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    CInt
result <- CGType -> CString -> Ptr Int32 -> Ptr CString -> IO CInt
nm_utils_enum_from_str CGType
type_' CString
str' Ptr Int32
outValue Ptr CString
errToken
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Int32
outValue' <- Ptr Int32 -> IO Int32
forall a. Storable a => Ptr a -> IO a
peek Ptr Int32
outValue
    CString
errToken' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
errToken
    Maybe Text
maybeErrToken' <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
errToken' ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
errToken'' -> do
        Text
errToken''' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
errToken''
        Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
errToken'''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
errToken'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Ptr Int32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Int32
outValue
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
errToken
    (Bool, Int32, Maybe Text) -> IO (Bool, Int32, Maybe Text)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Int32
outValue', Maybe Text
maybeErrToken')


-- function utils_ensure_gtypes
-- Args: []
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ensure_gtypes" nm_utils_ensure_gtypes :: 
    IO ()

-- | This ensures that all NMSetting GTypes are created. For example,
-- after this call, g_type_from_name(\"NMSettingConnection\") will work.
-- 
-- This cannot fail and does nothing if the type already exists.
-- 
-- /Since: 1.42/
utilsEnsureGtypes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m ()
utilsEnsureGtypes :: forall (m :: * -> *). (HasCallStack, MonadIO m) => m ()
utilsEnsureGtypes  = 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
    IO ()
nm_utils_ensure_gtypes
    () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function utils_check_virtual_device_compatibility
-- Args: [ Arg
--           { argCName = "virtual_type"
--           , argType = TBasicType TGType
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a virtual connection type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "other_type"
--           , argType = TBasicType TGType
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a connection type to test against @virtual_type"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_check_virtual_device_compatibility" nm_utils_check_virtual_device_compatibility :: 
    CGType ->                               -- virtual_type : TBasicType TGType
    CGType ->                               -- other_type : TBasicType TGType
    IO CInt

-- | Determines if a connection of type /@virtualType@/ can (in the
-- general case) work with connections of type /@otherType@/.
-- 
-- If /@virtualType@/ is @/NM_TYPE_SETTING_VLAN/@, then this checks if
-- /@otherType@/ is a valid type for the parent of a VLAN.
-- 
-- If /@virtualType@/ is a \"controller\" type (eg, @/NM_TYPE_SETTING_BRIDGE/@),
-- then this checks if /@otherType@/ is a valid type for a port of that
-- controller.
-- 
-- Note that even if this returns 'P.True' it is not guaranteed that
-- \<emphasis>every\<\/emphasis> connection of type /@otherType@/ is
-- compatible with /@virtualType@/; it may depend on the exact
-- configuration of the two connections, or on the capabilities of an
-- underlying device driver.
utilsCheckVirtualDeviceCompatibility ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GType
    -- ^ /@virtualType@/: a virtual connection type
    -> GType
    -- ^ /@otherType@/: a connection type to test against /@virtualType@/
    -> m Bool
    -- ^ __Returns:__ 'P.True' or 'P.False'
utilsCheckVirtualDeviceCompatibility :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
GType -> GType -> m Bool
utilsCheckVirtualDeviceCompatibility GType
virtualType GType
otherType = 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
    let virtualType' :: CGType
virtualType' = GType -> CGType
gtypeToCGType GType
virtualType
    let otherType' :: CGType
otherType' = GType -> CGType
gtypeToCGType GType
otherType
    CInt
result <- CGType -> CGType -> IO CInt
nm_utils_check_virtual_device_compatibility CGType
virtualType' CGType
otherType'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function utils_bond_mode_string_to_int
-- Args: [ Arg
--           { argCName = "mode"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "bonding mode as string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_bond_mode_string_to_int" nm_utils_bond_mode_string_to_int :: 
    CString ->                              -- mode : TBasicType TUTF8
    IO Int32

-- | Convert bonding mode from string representation to numeric value.
-- See https:\/\/www.kernel.org\/doc\/Documentation\/networking\/bonding.txt for
-- available modes.
-- The /@mode@/ string can be either a descriptive name or a number (as string).
-- 
-- /Since: 1.2/
utilsBondModeStringToInt ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@mode@/: bonding mode as string
    -> m Int32
    -- ^ __Returns:__ numeric bond mode, or -1 on error
utilsBondModeStringToInt :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Text -> m Int32
utilsBondModeStringToInt Text
mode = IO Int32 -> m Int32
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    CString
mode' <- Text -> IO CString
textToCString Text
mode
    Int32
result <- CString -> IO Int32
nm_utils_bond_mode_string_to_int CString
mode'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
mode'
    Int32 -> IO Int32
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result


-- function utils_bond_mode_int_to_string
-- Args: [ Arg
--           { argCName = "mode"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "bonding mode as a numeric value"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_bond_mode_int_to_string" nm_utils_bond_mode_int_to_string :: 
    Int32 ->                                -- mode : TBasicType TInt
    IO CString

-- | Convert bonding mode from integer value to descriptive name.
-- See https:\/\/www.kernel.org\/doc\/Documentation\/networking\/bonding.txt for
-- available modes.
-- 
-- /Since: 1.2/
utilsBondModeIntToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Int32
    -- ^ /@mode@/: bonding mode as a numeric value
    -> m T.Text
    -- ^ __Returns:__ bonding mode string, or NULL on error
utilsBondModeIntToString :: forall (m :: * -> *). (HasCallStack, MonadIO m) => Int32 -> m Text
utilsBondModeIntToString Int32
mode = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
result <- Int32 -> IO CString
nm_utils_bond_mode_int_to_string Int32
mode
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsBondModeIntToString" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_bin2hexstr
-- Args: [ Arg
--           { argCName = "src"
--           , argType = TCArray False (-1) 1 (TBasicType TUInt8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an array of bytes" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the length of the @src array"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "final_len"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "an index where to cut off the returned string, or -1"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "len"
--              , argType = TBasicType TSize
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "the length of the @src array"
--                    , sinceVersion = Nothing
--                    }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , argCallbackUserData = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_bin2hexstr" nm_utils_bin2hexstr :: 
    Ptr Word8 ->                            -- src : TCArray False (-1) 1 (TBasicType TUInt8)
    FCT.CSize ->                            -- len : TBasicType TSize
    Int32 ->                                -- final_len : TBasicType TInt
    IO CString

-- | Converts the byte array /@src@/ into a hexadecimal string. If /@finalLen@/ is
-- greater than -1, the returned string is terminated at that index
-- (returned_string[final_len] == \'\\0\'),
utilsBin2hexstr ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    ByteString
    -- ^ /@src@/: an array of bytes
    -> Int32
    -- ^ /@finalLen@/: an index where to cut off the returned string, or -1
    -> m T.Text
    -- ^ __Returns:__ the textual form of /@bytes@/
utilsBin2hexstr :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
ByteString -> Int32 -> m Text
utilsBin2hexstr ByteString
src Int32
finalLen = IO Text -> m Text
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let len :: CSize
len = Int -> CSize
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CSize) -> Int -> CSize
forall a b. (a -> b) -> a -> b
$ ByteString -> Int
B.length ByteString
src
    Ptr Word8
src' <- ByteString -> IO (Ptr Word8)
packByteString ByteString
src
    CString
result <- Ptr Word8 -> CSize -> Int32 -> IO CString
nm_utils_bin2hexstr Ptr Word8
src' CSize
len Int32
finalLen
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"utilsBin2hexstr" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
src'
    Text -> IO Text
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function utils_base64secret_decode
-- Args: [ Arg
--           { argCName = "base64_key"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the (possibly invalid) base64 encode key."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "required_key_len"
--           , argType = TBasicType TSize
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the expected (binary) length of the key after\n  decoding. If the length does not match, the validation fails."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "out_key"
--           , argType = TBasicType TUInt8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "an optional output buffer for the binary\n  key. If given, it will be filled with exactly @required_key_len\n  bytes."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_base64secret_decode" nm_utils_base64secret_decode :: 
    CString ->                              -- base64_key : TBasicType TUTF8
    FCT.CSize ->                            -- required_key_len : TBasicType TSize
    Ptr Word8 ->                            -- out_key : TBasicType TUInt8
    IO CInt

-- | /No description available in the introspection data./
-- 
-- /Since: 1.16/
utilsBase64secretDecode ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@base64Key@/: the (possibly invalid) base64 encode key.
    -> FCT.CSize
    -- ^ /@requiredKeyLen@/: the expected (binary) length of the key after
    --   decoding. If the length does not match, the validation fails.
    -> m ((Bool, Word8))
    -- ^ __Returns:__ 'P.True' if the input key is a valid base64 encoded key
    --   with /@requiredKeyLen@/ bytes.
utilsBase64secretDecode :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> CSize -> m (Bool, Word8)
utilsBase64secretDecode Text
base64Key CSize
requiredKeyLen = IO (Bool, Word8) -> m (Bool, Word8)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Word8) -> m (Bool, Word8))
-> IO (Bool, Word8) -> m (Bool, Word8)
forall a b. (a -> b) -> a -> b
$ do
    CString
base64Key' <- Text -> IO CString
textToCString Text
base64Key
    Ptr Word8
outKey <- IO (Ptr Word8)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word8)
    CInt
result <- CString -> CSize -> Ptr Word8 -> IO CInt
nm_utils_base64secret_decode CString
base64Key' CSize
requiredKeyLen Ptr Word8
outKey
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Word8
outKey' <- Ptr Word8 -> IO Word8
forall a. Storable a => Ptr a -> IO a
peek Ptr Word8
outKey
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
base64Key'
    Ptr Word8 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word8
outKey
    (Bool, Word8) -> IO (Bool, Word8)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Word8
outKey')


-- function utils_ap_mode_security_valid
-- Args: [ Arg
--           { argCName = "type"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "UtilsSecurityType" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the security type to check device capabilities against,\ne.g. #NMU_SEC_STATIC_WEP"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "wifi_caps"
--           , argType =
--               TInterface
--                 Name { namespace = "NM" , name = "DeviceWifiCapabilities" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "bitfield of the capabilities of the specific Wi-Fi device, e.g.\n#NM_WIFI_DEVICE_CAP_CIPHER_WEP40"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_utils_ap_mode_security_valid" nm_utils_ap_mode_security_valid :: 
    CUInt ->                                -- type : TInterface (Name {namespace = "NM", name = "UtilsSecurityType"})
    CUInt ->                                -- wifi_caps : TInterface (Name {namespace = "NM", name = "DeviceWifiCapabilities"})
    IO CInt

-- | Given a set of device capabilities, and a desired security type to check
-- against, determines whether the combination of device capabilities and
-- desired security type are valid for AP\/Hotspot connections.
utilsApModeSecurityValid ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    NM.Enums.UtilsSecurityType
    -- ^ /@type@/: the security type to check device capabilities against,
    -- e.g. @/NMU_SEC_STATIC_WEP/@
    -> [NM.Flags.DeviceWifiCapabilities]
    -- ^ /@wifiCaps@/: bitfield of the capabilities of the specific Wi-Fi device, e.g.
    -- @/NM_WIFI_DEVICE_CAP_CIPHER_WEP40/@
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the device capabilities are compatible with the desired
    -- /@type@/, 'P.False' if they are not.
utilsApModeSecurityValid :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
UtilsSecurityType -> [DeviceWifiCapabilities] -> m Bool
utilsApModeSecurityValid UtilsSecurityType
type_ [DeviceWifiCapabilities]
wifiCaps = 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
    let type_' :: CUInt
type_' = (Int -> CUInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CUInt)
-> (UtilsSecurityType -> Int) -> UtilsSecurityType -> CUInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UtilsSecurityType -> Int
forall a. Enum a => a -> Int
fromEnum) UtilsSecurityType
type_
    let wifiCaps' :: CUInt
wifiCaps' = [DeviceWifiCapabilities] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [DeviceWifiCapabilities]
wifiCaps
    CInt
result <- CUInt -> CUInt -> IO CInt
nm_utils_ap_mode_security_valid CUInt
type_' CUInt
wifiCaps'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function keyfile_write
-- Args: [ Arg
--           { argCName = "connection"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "Connection" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #NMConnection to persist to keyfile."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "handler_flags"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "KeyfileHandlerFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #NMKeyfileHandlerFlags."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "handler"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "KeyfileWriteHandler" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "optional handler for events and\n  to override the default behavior."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeCall
--           , argClosure = 3
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "argument for @handler."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "GLib" , name = "KeyFile" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_keyfile_write" nm_keyfile_write :: 
    Ptr NM.Connection.Connection ->         -- connection : TInterface (Name {namespace = "NM", name = "Connection"})
    CUInt ->                                -- handler_flags : TInterface (Name {namespace = "NM", name = "KeyfileHandlerFlags"})
    FunPtr NM.Callbacks.C_KeyfileWriteHandler -> -- handler : TInterface (Name {namespace = "NM", name = "KeyfileWriteHandler"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GLib.KeyFile.KeyFile)

-- | /@connection@/ should verify as a valid profile according to
-- 'GI.NM.Interfaces.Connection.connectionVerify'. If it does not verify, the keyfile may
-- be incomplete and the parser may not be able to fully recreate
-- the original profile.
-- 
-- /Since: 1.30/
keyfileWrite ::
    (B.CallStack.HasCallStack, MonadIO m, NM.Connection.IsConnection a) =>
    a
    -- ^ /@connection@/: the t'GI.NM.Interfaces.Connection.Connection' to persist to keyfile.
    -> [NM.Flags.KeyfileHandlerFlags]
    -- ^ /@handlerFlags@/: the t'GI.NM.Flags.KeyfileHandlerFlags'.
    -> Maybe (NM.Callbacks.KeyfileWriteHandler)
    -- ^ /@handler@/: optional handler for events and
    --   to override the default behavior.
    -> m GLib.KeyFile.KeyFile
    -- ^ __Returns:__ a new t'GI.GLib.Structs.KeyFile.KeyFile' or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
keyfileWrite :: forall (m :: * -> *) a.
(HasCallStack, MonadIO m, IsConnection a) =>
a
-> [KeyfileHandlerFlags] -> Maybe KeyfileWriteHandler -> m KeyFile
keyfileWrite a
connection [KeyfileHandlerFlags]
handlerFlags Maybe KeyfileWriteHandler
handler = IO KeyFile -> m KeyFile
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO KeyFile -> m KeyFile) -> IO KeyFile -> m KeyFile
forall a b. (a -> b) -> a -> b
$ do
    Ptr Connection
connection' <- a -> IO (Ptr Connection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
connection
    let handlerFlags' :: CUInt
handlerFlags' = [KeyfileHandlerFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [KeyfileHandlerFlags]
handlerFlags
    FunPtr C_KeyfileWriteHandler
maybeHandler <- case Maybe KeyfileWriteHandler
handler of
        Maybe KeyfileWriteHandler
Nothing -> FunPtr C_KeyfileWriteHandler -> IO (FunPtr C_KeyfileWriteHandler)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_KeyfileWriteHandler
forall a. FunPtr a
FP.nullFunPtr
        Just KeyfileWriteHandler
jHandler -> do
            FunPtr C_KeyfileWriteHandler
jHandler' <- C_KeyfileWriteHandler -> IO (FunPtr C_KeyfileWriteHandler)
NM.Callbacks.mk_KeyfileWriteHandler (Maybe (Ptr (FunPtr C_KeyfileWriteHandler))
-> KeyfileWriteHandler_WithClosures -> C_KeyfileWriteHandler
NM.Callbacks.wrap_KeyfileWriteHandler Maybe (Ptr (FunPtr C_KeyfileWriteHandler))
forall a. Maybe a
Nothing (KeyfileWriteHandler -> KeyfileWriteHandler_WithClosures
NM.Callbacks.drop_closures_KeyfileWriteHandler KeyfileWriteHandler
jHandler))
            FunPtr C_KeyfileWriteHandler -> IO (FunPtr C_KeyfileWriteHandler)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_KeyfileWriteHandler
jHandler'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO KeyFile -> IO () -> IO KeyFile
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr KeyFile
result <- (Ptr (Ptr GError) -> IO (Ptr KeyFile)) -> IO (Ptr KeyFile)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr KeyFile)) -> IO (Ptr KeyFile))
-> (Ptr (Ptr GError) -> IO (Ptr KeyFile)) -> IO (Ptr KeyFile)
forall a b. (a -> b) -> a -> b
$ Ptr Connection
-> CUInt
-> FunPtr C_KeyfileWriteHandler
-> Ptr ()
-> Ptr (Ptr GError)
-> IO (Ptr KeyFile)
nm_keyfile_write Ptr Connection
connection' CUInt
handlerFlags' FunPtr C_KeyfileWriteHandler
maybeHandler Ptr ()
forall a. Ptr a
userData
        Text -> Ptr KeyFile -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"keyfileWrite" Ptr KeyFile
result
        KeyFile
result' <- ((ManagedPtr KeyFile -> KeyFile) -> Ptr KeyFile -> IO KeyFile
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr KeyFile -> KeyFile
GLib.KeyFile.KeyFile) Ptr KeyFile
result
        Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_KeyfileWriteHandler -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_KeyfileWriteHandler
maybeHandler
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
connection
        KeyFile -> IO KeyFile
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return KeyFile
result'
     ) (do
        Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_KeyfileWriteHandler -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_KeyfileWriteHandler
maybeHandler
        () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function keyfile_read
-- Args: [ Arg
--           { argCName = "keyfile"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "KeyFile" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the keyfile from which to create the connection"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "base_dir"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "when reading certificates from files with relative name,\n  the relative path is made absolute using @base_dir. This must\n  be an absolute path."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "handler_flags"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "KeyfileHandlerFlags" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the #NMKeyfileHandlerFlags."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "handler"
--           , argType =
--               TInterface Name { namespace = "NM" , name = "KeyfileReadHandler" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "read handler" , sinceVersion = Nothing }
--           , argScope = ScopeTypeCall
--           , argClosure = 4
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "user_data"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "user data for read handler"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "NM" , name = "Connection" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_keyfile_read" nm_keyfile_read :: 
    Ptr GLib.KeyFile.KeyFile ->             -- keyfile : TInterface (Name {namespace = "GLib", name = "KeyFile"})
    CString ->                              -- base_dir : TBasicType TUTF8
    CUInt ->                                -- handler_flags : TInterface (Name {namespace = "NM", name = "KeyfileHandlerFlags"})
    FunPtr NM.Callbacks.C_KeyfileReadHandler -> -- handler : TInterface (Name {namespace = "NM", name = "KeyfileReadHandler"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr NM.Connection.Connection)

-- | Tries to create a NMConnection from a keyfile. The resulting keyfile is
-- not normalized and might not even verify.
-- 
-- /Since: 1.30/
keyfileRead ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.KeyFile.KeyFile
    -- ^ /@keyfile@/: the keyfile from which to create the connection
    -> T.Text
    -- ^ /@baseDir@/: when reading certificates from files with relative name,
    --   the relative path is made absolute using /@baseDir@/. This must
    --   be an absolute path.
    -> [NM.Flags.KeyfileHandlerFlags]
    -- ^ /@handlerFlags@/: the t'GI.NM.Flags.KeyfileHandlerFlags'.
    -> Maybe (NM.Callbacks.KeyfileReadHandler)
    -- ^ /@handler@/: read handler
    -> m NM.Connection.Connection
    -- ^ __Returns:__ on success, returns the created connection. /(Can throw 'Data.GI.Base.GError.GError')/
keyfileRead :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
KeyFile
-> Text
-> [KeyfileHandlerFlags]
-> Maybe KeyfileReadHandler
-> m Connection
keyfileRead KeyFile
keyfile Text
baseDir [KeyfileHandlerFlags]
handlerFlags Maybe KeyfileReadHandler
handler = IO Connection -> m Connection
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Connection -> m Connection) -> IO Connection -> m Connection
forall a b. (a -> b) -> a -> b
$ do
    Ptr KeyFile
keyfile' <- KeyFile -> IO (Ptr KeyFile)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr KeyFile
keyfile
    CString
baseDir' <- Text -> IO CString
textToCString Text
baseDir
    let handlerFlags' :: CUInt
handlerFlags' = [KeyfileHandlerFlags] -> CUInt
forall b a. (Num b, IsGFlag a) => [a] -> b
gflagsToWord [KeyfileHandlerFlags]
handlerFlags
    FunPtr C_KeyfileReadHandler
maybeHandler <- case Maybe KeyfileReadHandler
handler of
        Maybe KeyfileReadHandler
Nothing -> FunPtr C_KeyfileReadHandler -> IO (FunPtr C_KeyfileReadHandler)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_KeyfileReadHandler
forall a. FunPtr a
FP.nullFunPtr
        Just KeyfileReadHandler
jHandler -> do
            FunPtr C_KeyfileReadHandler
jHandler' <- C_KeyfileReadHandler -> IO (FunPtr C_KeyfileReadHandler)
NM.Callbacks.mk_KeyfileReadHandler (Maybe (Ptr (FunPtr C_KeyfileReadHandler))
-> KeyfileReadHandler_WithClosures -> C_KeyfileReadHandler
NM.Callbacks.wrap_KeyfileReadHandler Maybe (Ptr (FunPtr C_KeyfileReadHandler))
forall a. Maybe a
Nothing (KeyfileReadHandler -> KeyfileReadHandler_WithClosures
NM.Callbacks.drop_closures_KeyfileReadHandler KeyfileReadHandler
jHandler))
            FunPtr C_KeyfileReadHandler -> IO (FunPtr C_KeyfileReadHandler)
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return FunPtr C_KeyfileReadHandler
jHandler'
    let userData :: Ptr a
userData = Ptr a
forall a. Ptr a
nullPtr
    IO Connection -> IO () -> IO Connection
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Connection
result <- (Ptr (Ptr GError) -> IO (Ptr Connection)) -> IO (Ptr Connection)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Connection)) -> IO (Ptr Connection))
-> (Ptr (Ptr GError) -> IO (Ptr Connection)) -> IO (Ptr Connection)
forall a b. (a -> b) -> a -> b
$ Ptr KeyFile
-> CString
-> CUInt
-> FunPtr C_KeyfileReadHandler
-> Ptr ()
-> Ptr (Ptr GError)
-> IO (Ptr Connection)
nm_keyfile_read Ptr KeyFile
keyfile' CString
baseDir' CUInt
handlerFlags' FunPtr C_KeyfileReadHandler
maybeHandler Ptr ()
forall a. Ptr a
userData
        Text -> Ptr Connection -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"keyfileRead" Ptr Connection
result
        Connection
result' <- ((ManagedPtr Connection -> Connection)
-> Ptr Connection -> IO Connection
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Connection -> Connection
NM.Connection.Connection) Ptr Connection
result
        Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_KeyfileReadHandler -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_KeyfileReadHandler
maybeHandler
        KeyFile -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr KeyFile
keyfile
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
baseDir'
        Connection -> IO Connection
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Connection
result'
     ) (do
        Ptr Any -> IO ()
forall a. Ptr a -> IO ()
safeFreeFunPtr (Ptr Any -> IO ()) -> Ptr Any -> IO ()
forall a b. (a -> b) -> a -> b
$ FunPtr C_KeyfileReadHandler -> Ptr Any
forall a b. FunPtr a -> Ptr b
castFunPtrToPtr FunPtr C_KeyfileReadHandler
maybeHandler
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
baseDir'
     )


-- function ethtool_optname_is_ring
-- Args: [ Arg
--           { argCName = "optname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the option name to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_ethtool_optname_is_ring" nm_ethtool_optname_is_ring :: 
    CString ->                              -- optname : TBasicType TUTF8
    IO CInt

-- | Checks whether /@optname@/ is a valid option name for a ring setting.
-- 
-- /Since: 1.26/
ethtoolOptnameIsRing ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@optname@/: the option name to check
    -> m Bool
    -- ^ __Returns:__ 'P.True', if /@optname@/ is valid
ethtoolOptnameIsRing :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
ethtoolOptnameIsRing Maybe Text
optname = 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
    CString
maybeOptname <- case Maybe Text
optname of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jOptname -> do
            CString
jOptname' <- Text -> IO CString
textToCString Text
jOptname
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOptname'
    CInt
result <- CString -> IO CInt
nm_ethtool_optname_is_ring CString
maybeOptname
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOptname
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function ethtool_optname_is_pause
-- Args: [ Arg
--           { argCName = "optname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the option name to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_ethtool_optname_is_pause" nm_ethtool_optname_is_pause :: 
    CString ->                              -- optname : TBasicType TUTF8
    IO CInt

-- | Checks whether /@optname@/ is a valid option name for a pause setting.
-- 
-- /Since: 1.32/
ethtoolOptnameIsPause ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@optname@/: the option name to check
    -> m Bool
    -- ^ __Returns:__ 'P.True', if /@optname@/ is valid
ethtoolOptnameIsPause :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
ethtoolOptnameIsPause Maybe Text
optname = 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
    CString
maybeOptname <- case Maybe Text
optname of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jOptname -> do
            CString
jOptname' <- Text -> IO CString
textToCString Text
jOptname
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOptname'
    CInt
result <- CString -> IO CInt
nm_ethtool_optname_is_pause CString
maybeOptname
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOptname
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function ethtool_optname_is_feature
-- Args: [ Arg
--           { argCName = "optname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the option name to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_ethtool_optname_is_feature" nm_ethtool_optname_is_feature :: 
    CString ->                              -- optname : TBasicType TUTF8
    IO CInt

-- | Checks whether /@optname@/ is a valid option name for an offload feature.
-- 
-- /Since: 1.20/
ethtoolOptnameIsFeature ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@optname@/: the option name to check
    -> m Bool
    -- ^ __Returns:__ 'P.True', if /@optname@/ is valid
    -- 
    -- Note that 'GI.NM.Functions.ethtoolOptnameIsFeature' was first added to the libnm header files
    -- in 1.14.0 but forgot to actually add to the library. This happened belatedly in 1.20.0 and
    -- the stable versions 1.18.2, 1.16.4 and 1.14.8 (with linker version \"libnm_1_14_8\").
ethtoolOptnameIsFeature :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
ethtoolOptnameIsFeature Maybe Text
optname = 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
    CString
maybeOptname <- case Maybe Text
optname of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jOptname -> do
            CString
jOptname' <- Text -> IO CString
textToCString Text
jOptname
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOptname'
    CInt
result <- CString -> IO CInt
nm_ethtool_optname_is_feature CString
maybeOptname
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOptname
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function ethtool_optname_is_eee
-- Args: [ Arg
--           { argCName = "optname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the option name to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_ethtool_optname_is_eee" nm_ethtool_optname_is_eee :: 
    CString ->                              -- optname : TBasicType TUTF8
    IO CInt

-- | Checks whether /@optname@/ is a valid option name for an eee setting.
-- 
-- /Since: 1.46/
ethtoolOptnameIsEee ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@optname@/: the option name to check
    -> m Bool
    -- ^ __Returns:__ 'P.True', if /@optname@/ is valid
ethtoolOptnameIsEee :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
ethtoolOptnameIsEee Maybe Text
optname = 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
    CString
maybeOptname <- case Maybe Text
optname of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jOptname -> do
            CString
jOptname' <- Text -> IO CString
textToCString Text
jOptname
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOptname'
    CInt
result <- CString -> IO CInt
nm_ethtool_optname_is_eee CString
maybeOptname
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOptname
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function ethtool_optname_is_coalesce
-- Args: [ Arg
--           { argCName = "optname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the option name to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_ethtool_optname_is_coalesce" nm_ethtool_optname_is_coalesce :: 
    CString ->                              -- optname : TBasicType TUTF8
    IO CInt

-- | Checks whether /@optname@/ is a valid option name for a coalesce setting.
-- 
-- /Since: 1.26/
ethtoolOptnameIsCoalesce ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@optname@/: the option name to check
    -> m Bool
    -- ^ __Returns:__ 'P.True', if /@optname@/ is valid
ethtoolOptnameIsCoalesce :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
ethtoolOptnameIsCoalesce Maybe Text
optname = 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
    CString
maybeOptname <- case Maybe Text
optname of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jOptname -> do
            CString
jOptname' <- Text -> IO CString
textToCString Text
jOptname
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOptname'
    CInt
result <- CString -> IO CInt
nm_ethtool_optname_is_coalesce CString
maybeOptname
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOptname
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function ethtool_optname_is_channels
-- Args: [ Arg
--           { argCName = "optname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the option name to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "nm_ethtool_optname_is_channels" nm_ethtool_optname_is_channels :: 
    CString ->                              -- optname : TBasicType TUTF8
    IO CInt

-- | Checks whether /@optname@/ is a valid option name for a channels setting.
-- 
-- /Since: 1.46/
ethtoolOptnameIsChannels ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Maybe (T.Text)
    -- ^ /@optname@/: the option name to check
    -> m Bool
    -- ^ __Returns:__ 'P.True', if /@optname@/ is valid
ethtoolOptnameIsChannels :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Maybe Text -> m Bool
ethtoolOptnameIsChannels Maybe Text
optname = 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
    CString
maybeOptname <- case Maybe Text
optname of
        Maybe Text
Nothing -> CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
FP.nullPtr
        Just Text
jOptname -> do
            CString
jOptname' <- Text -> IO CString
textToCString Text
jOptname
            CString -> IO CString
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOptname'
    CInt
result <- CString -> IO CInt
nm_ethtool_optname_is_channels CString
maybeOptname
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOptname
    Bool -> IO Bool
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function conn_wireguard_import
-- Args: [ Arg
--           { argCName = "filename"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "name of the file to attempt to read into a new #NMConnection"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "NM" , name = "Connection" })
-- throws : True
-- Skip return : False

foreign import ccall "nm_conn_wireguard_import" nm_conn_wireguard_import :: 
    CString ->                              -- filename : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr NM.Connection.Connection)

-- | /No description available in the introspection data./
-- 
-- /Since: 1.40/
connWireguardImport ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@filename@/: name of the file to attempt to read into a new t'GI.NM.Interfaces.Connection.Connection'
    -> m NM.Connection.Connection
    -- ^ __Returns:__ a new t'GI.NM.Interfaces.Connection.Connection' imported from /@path@/, or 'P.Nothing'
    -- on error or if the file with /@filename@/ was not recognized as a WireGuard config /(Can throw 'Data.GI.Base.GError.GError')/
connWireguardImport :: forall (m :: * -> *).
(HasCallStack, MonadIO m) =>
Text -> m Connection
connWireguardImport Text
filename = IO Connection -> m Connection
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Connection -> m Connection) -> IO Connection -> m Connection
forall a b. (a -> b) -> a -> b
$ do
    CString
filename' <- Text -> IO CString
textToCString Text
filename
    IO Connection -> IO () -> IO Connection
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Connection
result <- (Ptr (Ptr GError) -> IO (Ptr Connection)) -> IO (Ptr Connection)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Connection)) -> IO (Ptr Connection))
-> (Ptr (Ptr GError) -> IO (Ptr Connection)) -> IO (Ptr Connection)
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO (Ptr Connection)
nm_conn_wireguard_import CString
filename'
        Text -> Ptr Connection -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"connWireguardImport" Ptr Connection
result
        Connection
result' <- ((ManagedPtr Connection -> Connection)
-> Ptr Connection -> IO Connection
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Connection -> Connection
NM.Connection.Connection) Ptr Connection
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
        Connection -> IO Connection
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return Connection
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
filename'
     )