{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- A t'GI.Gio.Objects.DBusObjectProxy.DBusObjectProxy' is an object used to represent a remote object
-- with one or more D-Bus interfaces. Normally, you don\'t instantiate
-- a t'GI.Gio.Objects.DBusObjectProxy.DBusObjectProxy' yourself - typically t'GI.Gio.Objects.DBusObjectManagerClient.DBusObjectManagerClient'
-- is used to obtain it.
-- 
-- /Since: 2.30/

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

module GI.Gio.Objects.DBusObjectProxy
    ( 

-- * Exported types
    DBusObjectProxy(..)                     ,
    IsDBusObjectProxy                       ,
    toDBusObjectProxy                       ,
    noDBusObjectProxy                       ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveDBusObjectProxyMethod            ,
#endif


-- ** getConnection #method:getConnection#

#if defined(ENABLE_OVERLOADING)
    DBusObjectProxyGetConnectionMethodInfo  ,
#endif
    dBusObjectProxyGetConnection            ,


-- ** new #method:new#

    dBusObjectProxyNew                      ,




 -- * Properties
-- ** gConnection #attr:gConnection#
-- | The connection of the proxy.
-- 
-- /Since: 2.30/

#if defined(ENABLE_OVERLOADING)
    DBusObjectProxyGConnectionPropertyInfo  ,
#endif
    constructDBusObjectProxyGConnection     ,
#if defined(ENABLE_OVERLOADING)
    dBusObjectProxyGConnection              ,
#endif
    getDBusObjectProxyGConnection           ,


-- ** gObjectPath #attr:gObjectPath#
-- | The object path of the proxy.
-- 
-- /Since: 2.30/

#if defined(ENABLE_OVERLOADING)
    DBusObjectProxyGObjectPathPropertyInfo  ,
#endif
    constructDBusObjectProxyGObjectPath     ,
#if defined(ENABLE_OVERLOADING)
    dBusObjectProxyGObjectPath              ,
#endif
    getDBusObjectProxyGObjectPath           ,




    ) 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.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
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 Data.Text as T
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 GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Interfaces.DBusObject as Gio.DBusObject
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusConnection as Gio.DBusConnection

-- | Memory-managed wrapper type.
newtype DBusObjectProxy = DBusObjectProxy (ManagedPtr DBusObjectProxy)
    deriving (DBusObjectProxy -> DBusObjectProxy -> Bool
(DBusObjectProxy -> DBusObjectProxy -> Bool)
-> (DBusObjectProxy -> DBusObjectProxy -> Bool)
-> Eq DBusObjectProxy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBusObjectProxy -> DBusObjectProxy -> Bool
$c/= :: DBusObjectProxy -> DBusObjectProxy -> Bool
== :: DBusObjectProxy -> DBusObjectProxy -> Bool
$c== :: DBusObjectProxy -> DBusObjectProxy -> Bool
Eq)
foreign import ccall "g_dbus_object_proxy_get_type"
    c_g_dbus_object_proxy_get_type :: IO GType

instance GObject DBusObjectProxy where
    gobjectType :: IO GType
gobjectType = IO GType
c_g_dbus_object_proxy_get_type
    

-- | Convert 'DBusObjectProxy' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue DBusObjectProxy where
    toGValue :: DBusObjectProxy -> IO GValue
toGValue o :: DBusObjectProxy
o = do
        GType
gtype <- IO GType
c_g_dbus_object_proxy_get_type
        DBusObjectProxy -> (Ptr DBusObjectProxy -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr DBusObjectProxy
o (GType
-> (GValue -> Ptr DBusObjectProxy -> IO ())
-> Ptr DBusObjectProxy
-> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr DBusObjectProxy -> IO ()
forall a. GObject a => GValue -> Ptr a -> IO ()
B.GValue.set_object)
        
    fromGValue :: GValue -> IO DBusObjectProxy
fromGValue gv :: GValue
gv = do
        Ptr DBusObjectProxy
ptr <- GValue -> IO (Ptr DBusObjectProxy)
forall b. GObject b => GValue -> IO (Ptr b)
B.GValue.get_object GValue
gv :: IO (Ptr DBusObjectProxy)
        (ManagedPtr DBusObjectProxy -> DBusObjectProxy)
-> Ptr DBusObjectProxy -> IO DBusObjectProxy
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
B.ManagedPtr.newObject ManagedPtr DBusObjectProxy -> DBusObjectProxy
DBusObjectProxy Ptr DBusObjectProxy
ptr
        
    

-- | Type class for types which can be safely cast to `DBusObjectProxy`, for instance with `toDBusObjectProxy`.
class (GObject o, O.IsDescendantOf DBusObjectProxy o) => IsDBusObjectProxy o
instance (GObject o, O.IsDescendantOf DBusObjectProxy o) => IsDBusObjectProxy o

instance O.HasParentTypes DBusObjectProxy
type instance O.ParentTypes DBusObjectProxy = '[GObject.Object.Object, Gio.DBusObject.DBusObject]

-- | Cast to `DBusObjectProxy`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toDBusObjectProxy :: (MonadIO m, IsDBusObjectProxy o) => o -> m DBusObjectProxy
toDBusObjectProxy :: o -> m DBusObjectProxy
toDBusObjectProxy = IO DBusObjectProxy -> m DBusObjectProxy
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusObjectProxy -> m DBusObjectProxy)
-> (o -> IO DBusObjectProxy) -> o -> m DBusObjectProxy
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ManagedPtr DBusObjectProxy -> DBusObjectProxy)
-> o -> IO DBusObjectProxy
forall o o'.
(HasCallStack, GObject o, GObject o') =>
(ManagedPtr o' -> o') -> o -> IO o'
unsafeCastTo ManagedPtr DBusObjectProxy -> DBusObjectProxy
DBusObjectProxy

-- | A convenience alias for `Nothing` :: `Maybe` `DBusObjectProxy`.
noDBusObjectProxy :: Maybe DBusObjectProxy
noDBusObjectProxy :: Maybe DBusObjectProxy
noDBusObjectProxy = Maybe DBusObjectProxy
forall a. Maybe a
Nothing

#if defined(ENABLE_OVERLOADING)
type family ResolveDBusObjectProxyMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusObjectProxyMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDBusObjectProxyMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDBusObjectProxyMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDBusObjectProxyMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDBusObjectProxyMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveDBusObjectProxyMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDBusObjectProxyMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDBusObjectProxyMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDBusObjectProxyMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDBusObjectProxyMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDBusObjectProxyMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDBusObjectProxyMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDBusObjectProxyMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDBusObjectProxyMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDBusObjectProxyMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDBusObjectProxyMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDBusObjectProxyMethod "getConnection" o = DBusObjectProxyGetConnectionMethodInfo
    ResolveDBusObjectProxyMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDBusObjectProxyMethod "getInterface" o = Gio.DBusObject.DBusObjectGetInterfaceMethodInfo
    ResolveDBusObjectProxyMethod "getInterfaces" o = Gio.DBusObject.DBusObjectGetInterfacesMethodInfo
    ResolveDBusObjectProxyMethod "getObjectPath" o = Gio.DBusObject.DBusObjectGetObjectPathMethodInfo
    ResolveDBusObjectProxyMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDBusObjectProxyMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDBusObjectProxyMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDBusObjectProxyMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveDBusObjectProxyMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusObjectProxyMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDBusObjectProxyMethod t DBusObjectProxy, O.MethodInfo info DBusObjectProxy p) => OL.IsLabel t (DBusObjectProxy -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif

-- VVV Prop "g-connection"
   -- Type: TInterface (Name {namespace = "Gio", name = "DBusConnection"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Get the value of the “@g-connection@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' dBusObjectProxy #gConnection
-- @
getDBusObjectProxyGConnection :: (MonadIO m, IsDBusObjectProxy o) => o -> m (Maybe Gio.DBusConnection.DBusConnection)
getDBusObjectProxyGConnection :: o -> m (Maybe DBusConnection)
getDBusObjectProxyGConnection obj :: o
obj = IO (Maybe DBusConnection) -> m (Maybe DBusConnection)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe DBusConnection) -> m (Maybe DBusConnection))
-> IO (Maybe DBusConnection) -> m (Maybe DBusConnection)
forall a b. (a -> b) -> a -> b
$ o
-> String
-> (ManagedPtr DBusConnection -> DBusConnection)
-> IO (Maybe DBusConnection)
forall a b.
(GObject a, GObject b) =>
a -> String -> (ManagedPtr b -> b) -> IO (Maybe b)
B.Properties.getObjectPropertyObject o
obj "g-connection" ManagedPtr DBusConnection -> DBusConnection
Gio.DBusConnection.DBusConnection

-- | Construct a `GValueConstruct` with valid value for the “@g-connection@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructDBusObjectProxyGConnection :: (IsDBusObjectProxy o, Gio.DBusConnection.IsDBusConnection a) => a -> IO (GValueConstruct o)
constructDBusObjectProxyGConnection :: a -> IO (GValueConstruct o)
constructDBusObjectProxyGConnection val :: a
val = String -> Maybe a -> IO (GValueConstruct o)
forall a o.
GObject a =>
String -> Maybe a -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyObject "g-connection" (a -> Maybe a
forall a. a -> Maybe a
Just a
val)

#if defined(ENABLE_OVERLOADING)
data DBusObjectProxyGConnectionPropertyInfo
instance AttrInfo DBusObjectProxyGConnectionPropertyInfo where
    type AttrAllowedOps DBusObjectProxyGConnectionPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint DBusObjectProxyGConnectionPropertyInfo = IsDBusObjectProxy
    type AttrSetTypeConstraint DBusObjectProxyGConnectionPropertyInfo = Gio.DBusConnection.IsDBusConnection
    type AttrTransferTypeConstraint DBusObjectProxyGConnectionPropertyInfo = Gio.DBusConnection.IsDBusConnection
    type AttrTransferType DBusObjectProxyGConnectionPropertyInfo = Gio.DBusConnection.DBusConnection
    type AttrGetType DBusObjectProxyGConnectionPropertyInfo = (Maybe Gio.DBusConnection.DBusConnection)
    type AttrLabel DBusObjectProxyGConnectionPropertyInfo = "g-connection"
    type AttrOrigin DBusObjectProxyGConnectionPropertyInfo = DBusObjectProxy
    attrGet = getDBusObjectProxyGConnection
    attrSet = undefined
    attrTransfer _ v = do
        unsafeCastTo Gio.DBusConnection.DBusConnection v
    attrConstruct = constructDBusObjectProxyGConnection
    attrClear = undefined
#endif

-- VVV Prop "g-object-path"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Get the value of the “@g-object-path@” property.
-- When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to
-- 
-- @
-- 'Data.GI.Base.Attributes.get' dBusObjectProxy #gObjectPath
-- @
getDBusObjectProxyGObjectPath :: (MonadIO m, IsDBusObjectProxy o) => o -> m (Maybe T.Text)
getDBusObjectProxyGObjectPath :: o -> m (Maybe Text)
getDBusObjectProxyGObjectPath obj :: o
obj = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ o -> String -> IO (Maybe Text)
forall a. GObject a => a -> String -> IO (Maybe Text)
B.Properties.getObjectPropertyString o
obj "g-object-path"

-- | Construct a `GValueConstruct` with valid value for the “@g-object-path@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructDBusObjectProxyGObjectPath :: (IsDBusObjectProxy o) => T.Text -> IO (GValueConstruct o)
constructDBusObjectProxyGObjectPath :: Text -> IO (GValueConstruct o)
constructDBusObjectProxyGObjectPath val :: Text
val = String -> Maybe Text -> IO (GValueConstruct o)
forall o. String -> Maybe Text -> IO (GValueConstruct o)
B.Properties.constructObjectPropertyString "g-object-path" (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
val)

#if defined(ENABLE_OVERLOADING)
data DBusObjectProxyGObjectPathPropertyInfo
instance AttrInfo DBusObjectProxyGObjectPathPropertyInfo where
    type AttrAllowedOps DBusObjectProxyGObjectPathPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrBaseTypeConstraint DBusObjectProxyGObjectPathPropertyInfo = IsDBusObjectProxy
    type AttrSetTypeConstraint DBusObjectProxyGObjectPathPropertyInfo = (~) T.Text
    type AttrTransferTypeConstraint DBusObjectProxyGObjectPathPropertyInfo = (~) T.Text
    type AttrTransferType DBusObjectProxyGObjectPathPropertyInfo = T.Text
    type AttrGetType DBusObjectProxyGObjectPathPropertyInfo = (Maybe T.Text)
    type AttrLabel DBusObjectProxyGObjectPathPropertyInfo = "g-object-path"
    type AttrOrigin DBusObjectProxyGObjectPathPropertyInfo = DBusObjectProxy
    attrGet = getDBusObjectProxyGObjectPath
    attrSet = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructDBusObjectProxyGObjectPath
    attrClear = undefined
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList DBusObjectProxy
type instance O.AttributeList DBusObjectProxy = DBusObjectProxyAttributeList
type DBusObjectProxyAttributeList = ('[ '("gConnection", DBusObjectProxyGConnectionPropertyInfo), '("gObjectPath", DBusObjectProxyGObjectPathPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING)
dBusObjectProxyGConnection :: AttrLabelProxy "gConnection"
dBusObjectProxyGConnection = AttrLabelProxy

dBusObjectProxyGObjectPath :: AttrLabelProxy "gObjectPath"
dBusObjectProxyGObjectPath = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList DBusObjectProxy = DBusObjectProxySignalList
type DBusObjectProxySignalList = ('[ '("interfaceAdded", Gio.DBusObject.DBusObjectInterfaceAddedSignalInfo), '("interfaceRemoved", Gio.DBusObject.DBusObjectInterfaceRemovedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method DBusObjectProxy::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "connection"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "DBusConnection" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GDBusConnection" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "object_path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the object path" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gio" , name = "DBusObjectProxy" })
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_proxy_new" g_dbus_object_proxy_new :: 
    Ptr Gio.DBusConnection.DBusConnection -> -- connection : TInterface (Name {namespace = "Gio", name = "DBusConnection"})
    CString ->                              -- object_path : TBasicType TUTF8
    IO (Ptr DBusObjectProxy)

-- | Creates a new t'GI.Gio.Objects.DBusObjectProxy.DBusObjectProxy' for the given connection and
-- object path.
-- 
-- /Since: 2.30/
dBusObjectProxyNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.DBusConnection.IsDBusConnection a) =>
    a
    -- ^ /@connection@/: a t'GI.Gio.Objects.DBusConnection.DBusConnection'
    -> T.Text
    -- ^ /@objectPath@/: the object path
    -> m DBusObjectProxy
    -- ^ __Returns:__ a new t'GI.Gio.Objects.DBusObjectProxy.DBusObjectProxy'
dBusObjectProxyNew :: a -> Text -> m DBusObjectProxy
dBusObjectProxyNew connection :: a
connection objectPath :: Text
objectPath = IO DBusObjectProxy -> m DBusObjectProxy
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusObjectProxy -> m DBusObjectProxy)
-> IO DBusObjectProxy -> m DBusObjectProxy
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusConnection
connection' <- a -> IO (Ptr DBusConnection)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
connection
    CString
objectPath' <- Text -> IO CString
textToCString Text
objectPath
    Ptr DBusObjectProxy
result <- Ptr DBusConnection -> CString -> IO (Ptr DBusObjectProxy)
g_dbus_object_proxy_new Ptr DBusConnection
connection' CString
objectPath'
    Text -> Ptr DBusObjectProxy -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dBusObjectProxyNew" Ptr DBusObjectProxy
result
    DBusObjectProxy
result' <- ((ManagedPtr DBusObjectProxy -> DBusObjectProxy)
-> Ptr DBusObjectProxy -> IO DBusObjectProxy
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr DBusObjectProxy -> DBusObjectProxy
DBusObjectProxy) Ptr DBusObjectProxy
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
connection
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
objectPath'
    DBusObjectProxy -> IO DBusObjectProxy
forall (m :: * -> *) a. Monad m => a -> m a
return DBusObjectProxy
result'

#if defined(ENABLE_OVERLOADING)
#endif

-- method DBusObjectProxy::get_connection
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "proxy"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "DBusObjectProxy" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GDBusObjectProxy"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Gio" , name = "DBusConnection" })
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_object_proxy_get_connection" g_dbus_object_proxy_get_connection :: 
    Ptr DBusObjectProxy ->                  -- proxy : TInterface (Name {namespace = "Gio", name = "DBusObjectProxy"})
    IO (Ptr Gio.DBusConnection.DBusConnection)

-- | Gets the connection that /@proxy@/ is for.
-- 
-- /Since: 2.30/
dBusObjectProxyGetConnection ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusObjectProxy a) =>
    a
    -- ^ /@proxy@/: a t'GI.Gio.Objects.DBusObjectProxy.DBusObjectProxy'
    -> m Gio.DBusConnection.DBusConnection
    -- ^ __Returns:__ A t'GI.Gio.Objects.DBusConnection.DBusConnection'. Do not free, the
    --   object is owned by /@proxy@/.
dBusObjectProxyGetConnection :: a -> m DBusConnection
dBusObjectProxyGetConnection proxy :: a
proxy = IO DBusConnection -> m DBusConnection
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DBusConnection -> m DBusConnection)
-> IO DBusConnection -> m DBusConnection
forall a b. (a -> b) -> a -> b
$ do
    Ptr DBusObjectProxy
proxy' <- a -> IO (Ptr DBusObjectProxy)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
proxy
    Ptr DBusConnection
result <- Ptr DBusObjectProxy -> IO (Ptr DBusConnection)
g_dbus_object_proxy_get_connection Ptr DBusObjectProxy
proxy'
    Text -> Ptr DBusConnection -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "dBusObjectProxyGetConnection" Ptr DBusConnection
result
    DBusConnection
result' <- ((ManagedPtr DBusConnection -> DBusConnection)
-> Ptr DBusConnection -> IO DBusConnection
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
newObject ManagedPtr DBusConnection -> DBusConnection
Gio.DBusConnection.DBusConnection) Ptr DBusConnection
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
proxy
    DBusConnection -> IO DBusConnection
forall (m :: * -> *) a. Monad m => a -> m a
return DBusConnection
result'

#if defined(ENABLE_OVERLOADING)
data DBusObjectProxyGetConnectionMethodInfo
instance (signature ~ (m Gio.DBusConnection.DBusConnection), MonadIO m, IsDBusObjectProxy a) => O.MethodInfo DBusObjectProxyGetConnectionMethodInfo a signature where
    overloadedMethod = dBusObjectProxyGetConnection

#endif