{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Gio.Objects.UnixSocketAddress
    ( 

-- * Exported types
    UnixSocketAddress(..)                   ,
    UnixSocketAddressK                      ,
    toUnixSocketAddress                     ,
    noUnixSocketAddress                     ,


 -- * Methods
-- ** unixSocketAddressAbstractNamesSupported
    unixSocketAddressAbstractNamesSupported ,


-- ** unixSocketAddressGetAddressType
    unixSocketAddressGetAddressType         ,


-- ** unixSocketAddressGetIsAbstract
    unixSocketAddressGetIsAbstract          ,


-- ** unixSocketAddressGetPath
    unixSocketAddressGetPath                ,


-- ** unixSocketAddressGetPathLen
    unixSocketAddressGetPathLen             ,


-- ** unixSocketAddressNew
    unixSocketAddressNew                    ,


-- ** unixSocketAddressNewAbstract
    unixSocketAddressNewAbstract            ,


-- ** unixSocketAddressNewWithType
    unixSocketAddressNewWithType            ,




 -- * Properties
-- ** Abstract
    UnixSocketAddressAbstractPropertyInfo   ,
    constructUnixSocketAddressAbstract      ,
    getUnixSocketAddressAbstract            ,


-- ** AddressType
    UnixSocketAddressAddressTypePropertyInfo,
    constructUnixSocketAddressAddressType   ,
    getUnixSocketAddressAddressType         ,


-- ** Path
    UnixSocketAddressPathPropertyInfo       ,
    constructUnixSocketAddressPath          ,
    getUnixSocketAddressPath                ,


-- ** PathAsArray
    UnixSocketAddressPathAsArrayPropertyInfo,
    constructUnixSocketAddressPathAsArray   ,
    getUnixSocketAddressPathAsArray         ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Gio.Types
import GI.Gio.Callbacks
import qualified GI.GObject as GObject

newtype UnixSocketAddress = UnixSocketAddress (ForeignPtr UnixSocketAddress)
foreign import ccall "g_unix_socket_address_get_type"
    c_g_unix_socket_address_get_type :: IO GType

type instance ParentTypes UnixSocketAddress = UnixSocketAddressParentTypes
type UnixSocketAddressParentTypes = '[SocketAddress, GObject.Object, SocketConnectable]

instance GObject UnixSocketAddress where
    gobjectIsInitiallyUnowned _ = False
    gobjectType _ = c_g_unix_socket_address_get_type
    

class GObject o => UnixSocketAddressK o
instance (GObject o, IsDescendantOf UnixSocketAddress o) => UnixSocketAddressK o

toUnixSocketAddress :: UnixSocketAddressK o => o -> IO UnixSocketAddress
toUnixSocketAddress = unsafeCastTo UnixSocketAddress

noUnixSocketAddress :: Maybe UnixSocketAddress
noUnixSocketAddress = Nothing

-- VVV Prop "abstract"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getUnixSocketAddressAbstract :: (MonadIO m, UnixSocketAddressK o) => o -> m Bool
getUnixSocketAddressAbstract obj = liftIO $ getObjectPropertyBool obj "abstract"

constructUnixSocketAddressAbstract :: Bool -> IO ([Char], GValue)
constructUnixSocketAddressAbstract val = constructObjectPropertyBool "abstract" val

data UnixSocketAddressAbstractPropertyInfo
instance AttrInfo UnixSocketAddressAbstractPropertyInfo where
    type AttrAllowedOps UnixSocketAddressAbstractPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint UnixSocketAddressAbstractPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint UnixSocketAddressAbstractPropertyInfo = UnixSocketAddressK
    type AttrGetType UnixSocketAddressAbstractPropertyInfo = Bool
    type AttrLabel UnixSocketAddressAbstractPropertyInfo = "UnixSocketAddress::abstract"
    attrGet _ = getUnixSocketAddressAbstract
    attrSet _ = undefined
    attrConstruct _ = constructUnixSocketAddressAbstract

-- VVV Prop "address-type"
   -- Type: TInterface "Gio" "UnixSocketAddressType"
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getUnixSocketAddressAddressType :: (MonadIO m, UnixSocketAddressK o) => o -> m UnixSocketAddressType
getUnixSocketAddressAddressType obj = liftIO $ getObjectPropertyEnum obj "address-type"

constructUnixSocketAddressAddressType :: UnixSocketAddressType -> IO ([Char], GValue)
constructUnixSocketAddressAddressType val = constructObjectPropertyEnum "address-type" val

data UnixSocketAddressAddressTypePropertyInfo
instance AttrInfo UnixSocketAddressAddressTypePropertyInfo where
    type AttrAllowedOps UnixSocketAddressAddressTypePropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint UnixSocketAddressAddressTypePropertyInfo = (~) UnixSocketAddressType
    type AttrBaseTypeConstraint UnixSocketAddressAddressTypePropertyInfo = UnixSocketAddressK
    type AttrGetType UnixSocketAddressAddressTypePropertyInfo = UnixSocketAddressType
    type AttrLabel UnixSocketAddressAddressTypePropertyInfo = "UnixSocketAddress::address-type"
    attrGet _ = getUnixSocketAddressAddressType
    attrSet _ = undefined
    attrConstruct _ = constructUnixSocketAddressAddressType

-- VVV Prop "path"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getUnixSocketAddressPath :: (MonadIO m, UnixSocketAddressK o) => o -> m T.Text
getUnixSocketAddressPath obj = liftIO $ getObjectPropertyString obj "path"

constructUnixSocketAddressPath :: T.Text -> IO ([Char], GValue)
constructUnixSocketAddressPath val = constructObjectPropertyString "path" val

data UnixSocketAddressPathPropertyInfo
instance AttrInfo UnixSocketAddressPathPropertyInfo where
    type AttrAllowedOps UnixSocketAddressPathPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint UnixSocketAddressPathPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint UnixSocketAddressPathPropertyInfo = UnixSocketAddressK
    type AttrGetType UnixSocketAddressPathPropertyInfo = T.Text
    type AttrLabel UnixSocketAddressPathPropertyInfo = "UnixSocketAddress::path"
    attrGet _ = getUnixSocketAddressPath
    attrSet _ = undefined
    attrConstruct _ = constructUnixSocketAddressPath

-- VVV Prop "path-as-array"
   -- Type: TByteArray
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]

getUnixSocketAddressPathAsArray :: (MonadIO m, UnixSocketAddressK o) => o -> m ByteString
getUnixSocketAddressPathAsArray obj = liftIO $ getObjectPropertyByteArray obj "path-as-array"

constructUnixSocketAddressPathAsArray :: ByteString -> IO ([Char], GValue)
constructUnixSocketAddressPathAsArray val = constructObjectPropertyByteArray "path-as-array" val

data UnixSocketAddressPathAsArrayPropertyInfo
instance AttrInfo UnixSocketAddressPathAsArrayPropertyInfo where
    type AttrAllowedOps UnixSocketAddressPathAsArrayPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint UnixSocketAddressPathAsArrayPropertyInfo = (~) ByteString
    type AttrBaseTypeConstraint UnixSocketAddressPathAsArrayPropertyInfo = UnixSocketAddressK
    type AttrGetType UnixSocketAddressPathAsArrayPropertyInfo = ByteString
    type AttrLabel UnixSocketAddressPathAsArrayPropertyInfo = "UnixSocketAddress::path-as-array"
    attrGet _ = getUnixSocketAddressPathAsArray
    attrSet _ = undefined
    attrConstruct _ = constructUnixSocketAddressPathAsArray

type instance AttributeList UnixSocketAddress = UnixSocketAddressAttributeList
type UnixSocketAddressAttributeList = ('[ '("abstract", UnixSocketAddressAbstractPropertyInfo), '("address-type", UnixSocketAddressAddressTypePropertyInfo), '("family", SocketAddressFamilyPropertyInfo), '("path", UnixSocketAddressPathPropertyInfo), '("path-as-array", UnixSocketAddressPathAsArrayPropertyInfo)] :: [(Symbol, *)])

type instance SignalList UnixSocketAddress = UnixSocketAddressSignalList
type UnixSocketAddressSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method UnixSocketAddress::new
-- method type : Constructor
-- Args : [Arg {argName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "UnixSocketAddress"
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_new" g_unix_socket_address_new :: 
    CString ->                              -- path : TBasicType TUTF8
    IO (Ptr UnixSocketAddress)


unixSocketAddressNew ::
    (MonadIO m) =>
    T.Text ->                               -- path
    m UnixSocketAddress
unixSocketAddressNew path = liftIO $ do
    path' <- textToCString path
    result <- g_unix_socket_address_new path'
    checkUnexpectedReturnNULL "g_unix_socket_address_new" result
    result' <- (wrapObject UnixSocketAddress) result
    freeMem path'
    return result'

-- method UnixSocketAddress::new_abstract
-- method type : Constructor
-- Args : [Arg {argName = "path", argType = TCArray False (-1) 1 (TBasicType TInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path_len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "path_len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "path", argType = TCArray False (-1) 1 (TBasicType TInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "UnixSocketAddress"
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_new_abstract" g_unix_socket_address_new_abstract :: 
    Ptr Int8 ->                             -- path : TCArray False (-1) 1 (TBasicType TInt8)
    Int32 ->                                -- path_len : TBasicType TInt32
    IO (Ptr UnixSocketAddress)

{-# DEPRECATED unixSocketAddressNewAbstract ["Use g_unix_socket_address_new_with_type()."]#-}
unixSocketAddressNewAbstract ::
    (MonadIO m) =>
    [Int8] ->                               -- path
    m UnixSocketAddress
unixSocketAddressNewAbstract path = liftIO $ do
    let path_len = fromIntegral $ length path
    path' <- packStorableArray path
    result <- g_unix_socket_address_new_abstract path' path_len
    checkUnexpectedReturnNULL "g_unix_socket_address_new_abstract" result
    result' <- (wrapObject UnixSocketAddress) result
    freeMem path'
    return result'

-- method UnixSocketAddress::new_with_type
-- method type : Constructor
-- Args : [Arg {argName = "path", argType = TCArray False (-1) 1 (TBasicType TInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "path_len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "Gio" "UnixSocketAddressType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "path_len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "path", argType = TCArray False (-1) 1 (TBasicType TInt8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "type", argType = TInterface "Gio" "UnixSocketAddressType", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "UnixSocketAddress"
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_new_with_type" g_unix_socket_address_new_with_type :: 
    Ptr Int8 ->                             -- path : TCArray False (-1) 1 (TBasicType TInt8)
    Int32 ->                                -- path_len : TBasicType TInt32
    CUInt ->                                -- type : TInterface "Gio" "UnixSocketAddressType"
    IO (Ptr UnixSocketAddress)


unixSocketAddressNewWithType ::
    (MonadIO m) =>
    [Int8] ->                               -- path
    UnixSocketAddressType ->                -- type
    m UnixSocketAddress
unixSocketAddressNewWithType path type_ = liftIO $ do
    let path_len = fromIntegral $ length path
    path' <- packStorableArray path
    let type_' = (fromIntegral . fromEnum) type_
    result <- g_unix_socket_address_new_with_type path' path_len type_'
    checkUnexpectedReturnNULL "g_unix_socket_address_new_with_type" result
    result' <- (wrapObject UnixSocketAddress) result
    freeMem path'
    return result'

-- method UnixSocketAddress::get_address_type
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Gio" "UnixSocketAddressType"
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_get_address_type" g_unix_socket_address_get_address_type :: 
    Ptr UnixSocketAddress ->                -- _obj : TInterface "Gio" "UnixSocketAddress"
    IO CUInt


unixSocketAddressGetAddressType ::
    (MonadIO m, UnixSocketAddressK a) =>
    a ->                                    -- _obj
    m UnixSocketAddressType
unixSocketAddressGetAddressType _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_unix_socket_address_get_address_type _obj'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr _obj
    return result'

-- method UnixSocketAddress::get_is_abstract
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_get_is_abstract" g_unix_socket_address_get_is_abstract :: 
    Ptr UnixSocketAddress ->                -- _obj : TInterface "Gio" "UnixSocketAddress"
    IO CInt

{-# DEPRECATED unixSocketAddressGetIsAbstract ["Use g_unix_socket_address_get_address_type()"]#-}
unixSocketAddressGetIsAbstract ::
    (MonadIO m, UnixSocketAddressK a) =>
    a ->                                    -- _obj
    m Bool
unixSocketAddressGetIsAbstract _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_unix_socket_address_get_is_abstract _obj'
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method UnixSocketAddress::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_get_path" g_unix_socket_address_get_path :: 
    Ptr UnixSocketAddress ->                -- _obj : TInterface "Gio" "UnixSocketAddress"
    IO CString


unixSocketAddressGetPath ::
    (MonadIO m, UnixSocketAddressK a) =>
    a ->                                    -- _obj
    m T.Text
unixSocketAddressGetPath _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_unix_socket_address_get_path _obj'
    checkUnexpectedReturnNULL "g_unix_socket_address_get_path" result
    result' <- cstringToText result
    touchManagedPtr _obj
    return result'

-- method UnixSocketAddress::get_path_len
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "UnixSocketAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt64
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_get_path_len" g_unix_socket_address_get_path_len :: 
    Ptr UnixSocketAddress ->                -- _obj : TInterface "Gio" "UnixSocketAddress"
    IO Word64


unixSocketAddressGetPathLen ::
    (MonadIO m, UnixSocketAddressK a) =>
    a ->                                    -- _obj
    m Word64
unixSocketAddressGetPathLen _obj = liftIO $ do
    let _obj' = unsafeManagedPtrCastPtr _obj
    result <- g_unix_socket_address_get_path_len _obj'
    touchManagedPtr _obj
    return result

-- method UnixSocketAddress::abstract_names_supported
-- method type : MemberFunction
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_unix_socket_address_abstract_names_supported" g_unix_socket_address_abstract_names_supported :: 
    IO CInt


unixSocketAddressAbstractNamesSupported ::
    (MonadIO m) =>
    m Bool
unixSocketAddressAbstractNamesSupported  = liftIO $ do
    result <- g_unix_socket_address_abstract_names_supported
    let result' = (/= 0) result
    return result'