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

'GI.Gio.Objects.DBusProxy.DBusProxy' is a base class used for proxies to access a D-Bus
interface on a remote object. A 'GI.Gio.Objects.DBusProxy.DBusProxy' can be constructed for
both well-known and unique names.

By default, 'GI.Gio.Objects.DBusProxy.DBusProxy' will cache all properties (and listen to
changes) of the remote object, and proxy all signals that gets
emitted. This behaviour can be changed by passing suitable
'GI.Gio.Flags.DBusProxyFlags' when the proxy is created. If the proxy is for a
well-known name, the property cache is flushed when the name owner
vanishes and reloaded when a name owner appears.

If a 'GI.Gio.Objects.DBusProxy.DBusProxy' is used for a well-known name, the owner of the
name is tracked and can be read from
'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-name-owner/@. Connect to the 'GI.GObject.Objects.Object.Object'::@/notify/@ signal to
get notified of changes. Additionally, only signals and property
changes emitted from the current name owner are considered and
calls are always sent to the current name owner. This avoids a
number of race conditions when the name is lost by one owner and
claimed by another. However, if no name owner currently exists,
then calls will be sent to the well-known name which may result in
the message bus launching an owner (unless
'GI.Gio.Flags.DBusProxyFlagsDoNotAutoStart' is set).

The generic 'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-properties-changed/@ and
'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-signal/@ signals are not very convenient to work with.
Therefore, the recommended way of working with proxies is to subclass
'GI.Gio.Objects.DBusProxy.DBusProxy', and have more natural properties and signals in your derived
class. This [example][gdbus-example-gdbus-codegen] shows how this can
easily be done using the [gdbus-codegen][gdbus-codegen] tool.

A 'GI.Gio.Objects.DBusProxy.DBusProxy' instance can be used from multiple threads but note
that all signals (e.g. 'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-signal/@, 'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-properties-changed/@
and 'GI.GObject.Objects.Object.Object'::@/notify/@) are emitted in the
[thread-default main context][g-main-context-push-thread-default]
of the thread where the instance was constructed.

An example using a proxy for a well-known name can be found in
<https://git.gnome.org/browse/glib/tree/gio/tests/gdbus-example-watch-proxy.c gdbus-example-watch-proxy.c>
-}

module GI.Gio.Objects.DBusProxy
    ( 

-- * Exported types
    DBusProxy(..)                           ,
    IsDBusProxy                             ,
    toDBusProxy                             ,
    noDBusProxy                             ,


 -- * Methods
-- ** call #method:call#
    DBusProxyCallMethodInfo                 ,
    dBusProxyCall                           ,


-- ** callFinish #method:callFinish#
    DBusProxyCallFinishMethodInfo           ,
    dBusProxyCallFinish                     ,


-- ** callSync #method:callSync#
    DBusProxyCallSyncMethodInfo             ,
    dBusProxyCallSync                       ,


-- ** callWithUnixFdList #method:callWithUnixFdList#
    DBusProxyCallWithUnixFdListMethodInfo   ,
    dBusProxyCallWithUnixFdList             ,


-- ** callWithUnixFdListFinish #method:callWithUnixFdListFinish#
    DBusProxyCallWithUnixFdListFinishMethodInfo,
    dBusProxyCallWithUnixFdListFinish       ,


-- ** callWithUnixFdListSync #method:callWithUnixFdListSync#
    DBusProxyCallWithUnixFdListSyncMethodInfo,
    dBusProxyCallWithUnixFdListSync         ,


-- ** getCachedProperty #method:getCachedProperty#
    DBusProxyGetCachedPropertyMethodInfo    ,
    dBusProxyGetCachedProperty              ,


-- ** getCachedPropertyNames #method:getCachedPropertyNames#
    DBusProxyGetCachedPropertyNamesMethodInfo,
    dBusProxyGetCachedPropertyNames         ,


-- ** getConnection #method:getConnection#
    DBusProxyGetConnectionMethodInfo        ,
    dBusProxyGetConnection                  ,


-- ** getDefaultTimeout #method:getDefaultTimeout#
    DBusProxyGetDefaultTimeoutMethodInfo    ,
    dBusProxyGetDefaultTimeout              ,


-- ** getFlags #method:getFlags#
    DBusProxyGetFlagsMethodInfo             ,
    dBusProxyGetFlags                       ,


-- ** getInterfaceInfo #method:getInterfaceInfo#
    DBusProxyGetInterfaceInfoMethodInfo     ,
    dBusProxyGetInterfaceInfo               ,


-- ** getInterfaceName #method:getInterfaceName#
    DBusProxyGetInterfaceNameMethodInfo     ,
    dBusProxyGetInterfaceName               ,


-- ** getName #method:getName#
    DBusProxyGetNameMethodInfo              ,
    dBusProxyGetName                        ,


-- ** getNameOwner #method:getNameOwner#
    DBusProxyGetNameOwnerMethodInfo         ,
    dBusProxyGetNameOwner                   ,


-- ** getObjectPath #method:getObjectPath#
    DBusProxyGetObjectPathMethodInfo        ,
    dBusProxyGetObjectPath                  ,


-- ** new #method:new#
    dBusProxyNew                            ,


-- ** newFinish #method:newFinish#
    dBusProxyNewFinish                      ,


-- ** newForBus #method:newForBus#
    dBusProxyNewForBus                      ,


-- ** newForBusFinish #method:newForBusFinish#
    dBusProxyNewForBusFinish                ,


-- ** newForBusSync #method:newForBusSync#
    dBusProxyNewForBusSync                  ,


-- ** newSync #method:newSync#
    dBusProxyNewSync                        ,


-- ** setCachedProperty #method:setCachedProperty#
    DBusProxySetCachedPropertyMethodInfo    ,
    dBusProxySetCachedProperty              ,


-- ** setDefaultTimeout #method:setDefaultTimeout#
    DBusProxySetDefaultTimeoutMethodInfo    ,
    dBusProxySetDefaultTimeout              ,


-- ** setInterfaceInfo #method:setInterfaceInfo#
    DBusProxySetInterfaceInfoMethodInfo     ,
    dBusProxySetInterfaceInfo               ,




 -- * Properties
-- ** gBusType #attr:gBusType#
    DBusProxyGBusTypePropertyInfo           ,
    constructDBusProxyGBusType              ,
    dBusProxyGBusType                       ,


-- ** gConnection #attr:gConnection#
    DBusProxyGConnectionPropertyInfo        ,
    constructDBusProxyGConnection           ,
    dBusProxyGConnection                    ,
    getDBusProxyGConnection                 ,


-- ** gDefaultTimeout #attr:gDefaultTimeout#
    DBusProxyGDefaultTimeoutPropertyInfo    ,
    constructDBusProxyGDefaultTimeout       ,
    dBusProxyGDefaultTimeout                ,
    getDBusProxyGDefaultTimeout             ,
    setDBusProxyGDefaultTimeout             ,


-- ** gFlags #attr:gFlags#
    DBusProxyGFlagsPropertyInfo             ,
    constructDBusProxyGFlags                ,
    dBusProxyGFlags                         ,
    getDBusProxyGFlags                      ,


-- ** gInterfaceInfo #attr:gInterfaceInfo#
    DBusProxyGInterfaceInfoPropertyInfo     ,
    clearDBusProxyGInterfaceInfo            ,
    constructDBusProxyGInterfaceInfo        ,
    dBusProxyGInterfaceInfo                 ,
    getDBusProxyGInterfaceInfo              ,
    setDBusProxyGInterfaceInfo              ,


-- ** gInterfaceName #attr:gInterfaceName#
    DBusProxyGInterfaceNamePropertyInfo     ,
    constructDBusProxyGInterfaceName        ,
    dBusProxyGInterfaceName                 ,
    getDBusProxyGInterfaceName              ,


-- ** gName #attr:gName#
    DBusProxyGNamePropertyInfo              ,
    constructDBusProxyGName                 ,
    dBusProxyGName                          ,
    getDBusProxyGName                       ,


-- ** gNameOwner #attr:gNameOwner#
    DBusProxyGNameOwnerPropertyInfo         ,
    dBusProxyGNameOwner                     ,
    getDBusProxyGNameOwner                  ,


-- ** gObjectPath #attr:gObjectPath#
    DBusProxyGObjectPathPropertyInfo        ,
    constructDBusProxyGObjectPath           ,
    dBusProxyGObjectPath                    ,
    getDBusProxyGObjectPath                 ,




 -- * Signals
-- ** gPropertiesChanged #signal:gPropertiesChanged#
    C_DBusProxyGPropertiesChangedCallback   ,
    DBusProxyGPropertiesChangedCallback     ,
    DBusProxyGPropertiesChangedSignalInfo   ,
    afterDBusProxyGPropertiesChanged        ,
    genClosure_DBusProxyGPropertiesChanged  ,
    mk_DBusProxyGPropertiesChangedCallback  ,
    noDBusProxyGPropertiesChangedCallback   ,
    onDBusProxyGPropertiesChanged           ,
    wrap_DBusProxyGPropertiesChangedCallback,


-- ** gSignal #signal:gSignal#
    C_DBusProxyGSignalCallback              ,
    DBusProxyGSignalCallback                ,
    DBusProxyGSignalSignalInfo              ,
    afterDBusProxyGSignal                   ,
    genClosure_DBusProxyGSignal             ,
    mk_DBusProxyGSignalCallback             ,
    noDBusProxyGSignalCallback              ,
    onDBusProxyGSignal                      ,
    wrap_DBusProxyGSignalCallback           ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Enums as Gio.Enums
import {-# SOURCE #-} qualified GI.Gio.Flags as Gio.Flags
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncInitable as Gio.AsyncInitable
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Interfaces.DBusInterface as Gio.DBusInterface
import {-# SOURCE #-} qualified GI.Gio.Interfaces.Initable as Gio.Initable
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.DBusConnection as Gio.DBusConnection
import {-# SOURCE #-} qualified GI.Gio.Objects.UnixFDList as Gio.UnixFDList
import {-# SOURCE #-} qualified GI.Gio.Structs.DBusInterfaceInfo as Gio.DBusInterfaceInfo

newtype DBusProxy = DBusProxy (ManagedPtr DBusProxy)
foreign import ccall "g_dbus_proxy_get_type"
    c_g_dbus_proxy_get_type :: IO GType

instance GObject DBusProxy where
    gobjectType _ = c_g_dbus_proxy_get_type
    

class GObject o => IsDBusProxy o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError DBusProxy a) =>
    IsDBusProxy a
#endif
instance IsDBusProxy DBusProxy
instance GObject.Object.IsObject DBusProxy
instance Gio.AsyncInitable.IsAsyncInitable DBusProxy
instance Gio.DBusInterface.IsDBusInterface DBusProxy
instance Gio.Initable.IsInitable DBusProxy

toDBusProxy :: IsDBusProxy o => o -> IO DBusProxy
toDBusProxy = unsafeCastTo DBusProxy

noDBusProxy :: Maybe DBusProxy
noDBusProxy = Nothing

type family ResolveDBusProxyMethod (t :: Symbol) (o :: *) :: * where
    ResolveDBusProxyMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveDBusProxyMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveDBusProxyMethod "call" o = DBusProxyCallMethodInfo
    ResolveDBusProxyMethod "callFinish" o = DBusProxyCallFinishMethodInfo
    ResolveDBusProxyMethod "callSync" o = DBusProxyCallSyncMethodInfo
    ResolveDBusProxyMethod "callWithUnixFdList" o = DBusProxyCallWithUnixFdListMethodInfo
    ResolveDBusProxyMethod "callWithUnixFdListFinish" o = DBusProxyCallWithUnixFdListFinishMethodInfo
    ResolveDBusProxyMethod "callWithUnixFdListSync" o = DBusProxyCallWithUnixFdListSyncMethodInfo
    ResolveDBusProxyMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveDBusProxyMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveDBusProxyMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolveDBusProxyMethod "initAsync" o = Gio.AsyncInitable.AsyncInitableInitAsyncMethodInfo
    ResolveDBusProxyMethod "initFinish" o = Gio.AsyncInitable.AsyncInitableInitFinishMethodInfo
    ResolveDBusProxyMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveDBusProxyMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveDBusProxyMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveDBusProxyMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveDBusProxyMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveDBusProxyMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveDBusProxyMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveDBusProxyMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveDBusProxyMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveDBusProxyMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveDBusProxyMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveDBusProxyMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveDBusProxyMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveDBusProxyMethod "getCachedProperty" o = DBusProxyGetCachedPropertyMethodInfo
    ResolveDBusProxyMethod "getCachedPropertyNames" o = DBusProxyGetCachedPropertyNamesMethodInfo
    ResolveDBusProxyMethod "getConnection" o = DBusProxyGetConnectionMethodInfo
    ResolveDBusProxyMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveDBusProxyMethod "getDefaultTimeout" o = DBusProxyGetDefaultTimeoutMethodInfo
    ResolveDBusProxyMethod "getFlags" o = DBusProxyGetFlagsMethodInfo
    ResolveDBusProxyMethod "getInfo" o = Gio.DBusInterface.DBusInterfaceGetInfoMethodInfo
    ResolveDBusProxyMethod "getInterfaceInfo" o = DBusProxyGetInterfaceInfoMethodInfo
    ResolveDBusProxyMethod "getInterfaceName" o = DBusProxyGetInterfaceNameMethodInfo
    ResolveDBusProxyMethod "getName" o = DBusProxyGetNameMethodInfo
    ResolveDBusProxyMethod "getNameOwner" o = DBusProxyGetNameOwnerMethodInfo
    ResolveDBusProxyMethod "getObject" o = Gio.DBusInterface.DBusInterfaceGetObjectMethodInfo
    ResolveDBusProxyMethod "getObjectPath" o = DBusProxyGetObjectPathMethodInfo
    ResolveDBusProxyMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveDBusProxyMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveDBusProxyMethod "setCachedProperty" o = DBusProxySetCachedPropertyMethodInfo
    ResolveDBusProxyMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveDBusProxyMethod "setDefaultTimeout" o = DBusProxySetDefaultTimeoutMethodInfo
    ResolveDBusProxyMethod "setInterfaceInfo" o = DBusProxySetInterfaceInfoMethodInfo
    ResolveDBusProxyMethod "setObject" o = Gio.DBusInterface.DBusInterfaceSetObjectMethodInfo
    ResolveDBusProxyMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveDBusProxyMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDBusProxyMethod t DBusProxy, O.MethodInfo info DBusProxy p) => O.IsLabelProxy t (DBusProxy -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDBusProxyMethod t DBusProxy, O.MethodInfo info DBusProxy p) => O.IsLabel t (DBusProxy -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal DBusProxy::g-properties-changed
type DBusProxyGPropertiesChangedCallback =
    GVariant ->
    [T.Text] ->
    IO ()

noDBusProxyGPropertiesChangedCallback :: Maybe DBusProxyGPropertiesChangedCallback
noDBusProxyGPropertiesChangedCallback = Nothing

type C_DBusProxyGPropertiesChangedCallback =
    Ptr () ->                               -- object
    Ptr GVariant ->
    Ptr CString ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_DBusProxyGPropertiesChangedCallback :: C_DBusProxyGPropertiesChangedCallback -> IO (FunPtr C_DBusProxyGPropertiesChangedCallback)

genClosure_DBusProxyGPropertiesChanged :: DBusProxyGPropertiesChangedCallback -> IO Closure
genClosure_DBusProxyGPropertiesChanged cb = do
    let cb' = wrap_DBusProxyGPropertiesChangedCallback cb
    mk_DBusProxyGPropertiesChangedCallback cb' >>= newCClosure


wrap_DBusProxyGPropertiesChangedCallback ::
    DBusProxyGPropertiesChangedCallback ->
    Ptr () ->
    Ptr GVariant ->
    Ptr CString ->
    Ptr () ->
    IO ()
wrap_DBusProxyGPropertiesChangedCallback _cb _ changedProperties invalidatedProperties _ = do
    changedProperties' <- newGVariantFromPtr changedProperties
    invalidatedProperties' <- unpackZeroTerminatedUTF8CArray invalidatedProperties
    _cb  changedProperties' invalidatedProperties'


onDBusProxyGPropertiesChanged :: (GObject a, MonadIO m) => a -> DBusProxyGPropertiesChangedCallback -> m SignalHandlerId
onDBusProxyGPropertiesChanged obj cb = liftIO $ connectDBusProxyGPropertiesChanged obj cb SignalConnectBefore
afterDBusProxyGPropertiesChanged :: (GObject a, MonadIO m) => a -> DBusProxyGPropertiesChangedCallback -> m SignalHandlerId
afterDBusProxyGPropertiesChanged obj cb = connectDBusProxyGPropertiesChanged obj cb SignalConnectAfter

connectDBusProxyGPropertiesChanged :: (GObject a, MonadIO m) =>
                                      a -> DBusProxyGPropertiesChangedCallback -> SignalConnectMode -> m SignalHandlerId
connectDBusProxyGPropertiesChanged obj cb after = liftIO $ do
    let cb' = wrap_DBusProxyGPropertiesChangedCallback cb
    cb'' <- mk_DBusProxyGPropertiesChangedCallback cb'
    connectSignalFunPtr obj "g-properties-changed" cb'' after

-- signal DBusProxy::g-signal
type DBusProxyGSignalCallback =
    Maybe T.Text ->
    T.Text ->
    GVariant ->
    IO ()

noDBusProxyGSignalCallback :: Maybe DBusProxyGSignalCallback
noDBusProxyGSignalCallback = Nothing

type C_DBusProxyGSignalCallback =
    Ptr () ->                               -- object
    CString ->
    CString ->
    Ptr GVariant ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_DBusProxyGSignalCallback :: C_DBusProxyGSignalCallback -> IO (FunPtr C_DBusProxyGSignalCallback)

genClosure_DBusProxyGSignal :: DBusProxyGSignalCallback -> IO Closure
genClosure_DBusProxyGSignal cb = do
    let cb' = wrap_DBusProxyGSignalCallback cb
    mk_DBusProxyGSignalCallback cb' >>= newCClosure


wrap_DBusProxyGSignalCallback ::
    DBusProxyGSignalCallback ->
    Ptr () ->
    CString ->
    CString ->
    Ptr GVariant ->
    Ptr () ->
    IO ()
wrap_DBusProxyGSignalCallback _cb _ senderName signalName parameters _ = do
    maybeSenderName <-
        if senderName == nullPtr
        then return Nothing
        else do
            senderName' <- cstringToText senderName
            return $ Just senderName'
    signalName' <- cstringToText signalName
    parameters' <- newGVariantFromPtr parameters
    _cb  maybeSenderName signalName' parameters'


onDBusProxyGSignal :: (GObject a, MonadIO m) => a -> DBusProxyGSignalCallback -> m SignalHandlerId
onDBusProxyGSignal obj cb = liftIO $ connectDBusProxyGSignal obj cb SignalConnectBefore
afterDBusProxyGSignal :: (GObject a, MonadIO m) => a -> DBusProxyGSignalCallback -> m SignalHandlerId
afterDBusProxyGSignal obj cb = connectDBusProxyGSignal obj cb SignalConnectAfter

connectDBusProxyGSignal :: (GObject a, MonadIO m) =>
                           a -> DBusProxyGSignalCallback -> SignalConnectMode -> m SignalHandlerId
connectDBusProxyGSignal obj cb after = liftIO $ do
    let cb' = wrap_DBusProxyGSignalCallback cb
    cb'' <- mk_DBusProxyGSignalCallback cb'
    connectSignalFunPtr obj "g-signal" cb'' after

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

constructDBusProxyGBusType :: (IsDBusProxy o) => Gio.Enums.BusType -> IO (GValueConstruct o)
constructDBusProxyGBusType val = constructObjectPropertyEnum "g-bus-type" val

data DBusProxyGBusTypePropertyInfo
instance AttrInfo DBusProxyGBusTypePropertyInfo where
    type AttrAllowedOps DBusProxyGBusTypePropertyInfo = '[ 'AttrConstruct]
    type AttrSetTypeConstraint DBusProxyGBusTypePropertyInfo = (~) Gio.Enums.BusType
    type AttrBaseTypeConstraint DBusProxyGBusTypePropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGBusTypePropertyInfo = ()
    type AttrLabel DBusProxyGBusTypePropertyInfo = "g-bus-type"
    type AttrOrigin DBusProxyGBusTypePropertyInfo = DBusProxy
    attrGet _ = undefined
    attrSet _ = undefined
    attrConstruct _ = constructDBusProxyGBusType
    attrClear _ = undefined

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

getDBusProxyGConnection :: (MonadIO m, IsDBusProxy o) => o -> m (Maybe Gio.DBusConnection.DBusConnection)
getDBusProxyGConnection obj = liftIO $ getObjectPropertyObject obj "g-connection" Gio.DBusConnection.DBusConnection

constructDBusProxyGConnection :: (IsDBusProxy o, Gio.DBusConnection.IsDBusConnection a) => a -> IO (GValueConstruct o)
constructDBusProxyGConnection val = constructObjectPropertyObject "g-connection" (Just val)

data DBusProxyGConnectionPropertyInfo
instance AttrInfo DBusProxyGConnectionPropertyInfo where
    type AttrAllowedOps DBusProxyGConnectionPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusProxyGConnectionPropertyInfo = Gio.DBusConnection.IsDBusConnection
    type AttrBaseTypeConstraint DBusProxyGConnectionPropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGConnectionPropertyInfo = (Maybe Gio.DBusConnection.DBusConnection)
    type AttrLabel DBusProxyGConnectionPropertyInfo = "g-connection"
    type AttrOrigin DBusProxyGConnectionPropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGConnection
    attrSet _ = undefined
    attrConstruct _ = constructDBusProxyGConnection
    attrClear _ = undefined

-- VVV Prop "g-default-timeout"
   -- Type: TBasicType TInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Nothing,Nothing)

getDBusProxyGDefaultTimeout :: (MonadIO m, IsDBusProxy o) => o -> m Int32
getDBusProxyGDefaultTimeout obj = liftIO $ getObjectPropertyInt32 obj "g-default-timeout"

setDBusProxyGDefaultTimeout :: (MonadIO m, IsDBusProxy o) => o -> Int32 -> m ()
setDBusProxyGDefaultTimeout obj val = liftIO $ setObjectPropertyInt32 obj "g-default-timeout" val

constructDBusProxyGDefaultTimeout :: (IsDBusProxy o) => Int32 -> IO (GValueConstruct o)
constructDBusProxyGDefaultTimeout val = constructObjectPropertyInt32 "g-default-timeout" val

data DBusProxyGDefaultTimeoutPropertyInfo
instance AttrInfo DBusProxyGDefaultTimeoutPropertyInfo where
    type AttrAllowedOps DBusProxyGDefaultTimeoutPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DBusProxyGDefaultTimeoutPropertyInfo = (~) Int32
    type AttrBaseTypeConstraint DBusProxyGDefaultTimeoutPropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGDefaultTimeoutPropertyInfo = Int32
    type AttrLabel DBusProxyGDefaultTimeoutPropertyInfo = "g-default-timeout"
    type AttrOrigin DBusProxyGDefaultTimeoutPropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGDefaultTimeout
    attrSet _ = setDBusProxyGDefaultTimeout
    attrConstruct _ = constructDBusProxyGDefaultTimeout
    attrClear _ = undefined

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

getDBusProxyGFlags :: (MonadIO m, IsDBusProxy o) => o -> m [Gio.Flags.DBusProxyFlags]
getDBusProxyGFlags obj = liftIO $ getObjectPropertyFlags obj "g-flags"

constructDBusProxyGFlags :: (IsDBusProxy o) => [Gio.Flags.DBusProxyFlags] -> IO (GValueConstruct o)
constructDBusProxyGFlags val = constructObjectPropertyFlags "g-flags" val

data DBusProxyGFlagsPropertyInfo
instance AttrInfo DBusProxyGFlagsPropertyInfo where
    type AttrAllowedOps DBusProxyGFlagsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint DBusProxyGFlagsPropertyInfo = (~) [Gio.Flags.DBusProxyFlags]
    type AttrBaseTypeConstraint DBusProxyGFlagsPropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGFlagsPropertyInfo = [Gio.Flags.DBusProxyFlags]
    type AttrLabel DBusProxyGFlagsPropertyInfo = "g-flags"
    type AttrOrigin DBusProxyGFlagsPropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGFlags
    attrSet _ = undefined
    attrConstruct _ = constructDBusProxyGFlags
    attrClear _ = undefined

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

getDBusProxyGInterfaceInfo :: (MonadIO m, IsDBusProxy o) => o -> m (Maybe Gio.DBusInterfaceInfo.DBusInterfaceInfo)
getDBusProxyGInterfaceInfo obj = liftIO $ getObjectPropertyBoxed obj "g-interface-info" Gio.DBusInterfaceInfo.DBusInterfaceInfo

setDBusProxyGInterfaceInfo :: (MonadIO m, IsDBusProxy o) => o -> Gio.DBusInterfaceInfo.DBusInterfaceInfo -> m ()
setDBusProxyGInterfaceInfo obj val = liftIO $ setObjectPropertyBoxed obj "g-interface-info" (Just val)

constructDBusProxyGInterfaceInfo :: (IsDBusProxy o) => Gio.DBusInterfaceInfo.DBusInterfaceInfo -> IO (GValueConstruct o)
constructDBusProxyGInterfaceInfo val = constructObjectPropertyBoxed "g-interface-info" (Just val)

clearDBusProxyGInterfaceInfo :: (MonadIO m, IsDBusProxy o) => o -> m ()
clearDBusProxyGInterfaceInfo obj = liftIO $ setObjectPropertyBoxed obj "g-interface-info" (Nothing :: Maybe Gio.DBusInterfaceInfo.DBusInterfaceInfo)

data DBusProxyGInterfaceInfoPropertyInfo
instance AttrInfo DBusProxyGInterfaceInfoPropertyInfo where
    type AttrAllowedOps DBusProxyGInterfaceInfoPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusProxyGInterfaceInfoPropertyInfo = (~) Gio.DBusInterfaceInfo.DBusInterfaceInfo
    type AttrBaseTypeConstraint DBusProxyGInterfaceInfoPropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGInterfaceInfoPropertyInfo = (Maybe Gio.DBusInterfaceInfo.DBusInterfaceInfo)
    type AttrLabel DBusProxyGInterfaceInfoPropertyInfo = "g-interface-info"
    type AttrOrigin DBusProxyGInterfaceInfoPropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGInterfaceInfo
    attrSet _ = setDBusProxyGInterfaceInfo
    attrConstruct _ = constructDBusProxyGInterfaceInfo
    attrClear _ = clearDBusProxyGInterfaceInfo

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

getDBusProxyGInterfaceName :: (MonadIO m, IsDBusProxy o) => o -> m (Maybe T.Text)
getDBusProxyGInterfaceName obj = liftIO $ getObjectPropertyString obj "g-interface-name"

constructDBusProxyGInterfaceName :: (IsDBusProxy o) => T.Text -> IO (GValueConstruct o)
constructDBusProxyGInterfaceName val = constructObjectPropertyString "g-interface-name" (Just val)

data DBusProxyGInterfaceNamePropertyInfo
instance AttrInfo DBusProxyGInterfaceNamePropertyInfo where
    type AttrAllowedOps DBusProxyGInterfaceNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusProxyGInterfaceNamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusProxyGInterfaceNamePropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGInterfaceNamePropertyInfo = (Maybe T.Text)
    type AttrLabel DBusProxyGInterfaceNamePropertyInfo = "g-interface-name"
    type AttrOrigin DBusProxyGInterfaceNamePropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGInterfaceName
    attrSet _ = undefined
    attrConstruct _ = constructDBusProxyGInterfaceName
    attrClear _ = undefined

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

getDBusProxyGName :: (MonadIO m, IsDBusProxy o) => o -> m (Maybe T.Text)
getDBusProxyGName obj = liftIO $ getObjectPropertyString obj "g-name"

constructDBusProxyGName :: (IsDBusProxy o) => T.Text -> IO (GValueConstruct o)
constructDBusProxyGName val = constructObjectPropertyString "g-name" (Just val)

data DBusProxyGNamePropertyInfo
instance AttrInfo DBusProxyGNamePropertyInfo where
    type AttrAllowedOps DBusProxyGNamePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusProxyGNamePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusProxyGNamePropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGNamePropertyInfo = (Maybe T.Text)
    type AttrLabel DBusProxyGNamePropertyInfo = "g-name"
    type AttrOrigin DBusProxyGNamePropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGName
    attrSet _ = undefined
    attrConstruct _ = constructDBusProxyGName
    attrClear _ = undefined

-- VVV Prop "g-name-owner"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

getDBusProxyGNameOwner :: (MonadIO m, IsDBusProxy o) => o -> m (Maybe T.Text)
getDBusProxyGNameOwner obj = liftIO $ getObjectPropertyString obj "g-name-owner"

data DBusProxyGNameOwnerPropertyInfo
instance AttrInfo DBusProxyGNameOwnerPropertyInfo where
    type AttrAllowedOps DBusProxyGNameOwnerPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusProxyGNameOwnerPropertyInfo = (~) ()
    type AttrBaseTypeConstraint DBusProxyGNameOwnerPropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGNameOwnerPropertyInfo = (Maybe T.Text)
    type AttrLabel DBusProxyGNameOwnerPropertyInfo = "g-name-owner"
    type AttrOrigin DBusProxyGNameOwnerPropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGNameOwner
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

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

getDBusProxyGObjectPath :: (MonadIO m, IsDBusProxy o) => o -> m (Maybe T.Text)
getDBusProxyGObjectPath obj = liftIO $ getObjectPropertyString obj "g-object-path"

constructDBusProxyGObjectPath :: (IsDBusProxy o) => T.Text -> IO (GValueConstruct o)
constructDBusProxyGObjectPath val = constructObjectPropertyString "g-object-path" (Just val)

data DBusProxyGObjectPathPropertyInfo
instance AttrInfo DBusProxyGObjectPathPropertyInfo where
    type AttrAllowedOps DBusProxyGObjectPathPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint DBusProxyGObjectPathPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint DBusProxyGObjectPathPropertyInfo = IsDBusProxy
    type AttrGetType DBusProxyGObjectPathPropertyInfo = (Maybe T.Text)
    type AttrLabel DBusProxyGObjectPathPropertyInfo = "g-object-path"
    type AttrOrigin DBusProxyGObjectPathPropertyInfo = DBusProxy
    attrGet _ = getDBusProxyGObjectPath
    attrSet _ = undefined
    attrConstruct _ = constructDBusProxyGObjectPath
    attrClear _ = undefined

instance O.HasAttributeList DBusProxy
type instance O.AttributeList DBusProxy = DBusProxyAttributeList
type DBusProxyAttributeList = ('[ '("gBusType", DBusProxyGBusTypePropertyInfo), '("gConnection", DBusProxyGConnectionPropertyInfo), '("gDefaultTimeout", DBusProxyGDefaultTimeoutPropertyInfo), '("gFlags", DBusProxyGFlagsPropertyInfo), '("gInterfaceInfo", DBusProxyGInterfaceInfoPropertyInfo), '("gInterfaceName", DBusProxyGInterfaceNamePropertyInfo), '("gName", DBusProxyGNamePropertyInfo), '("gNameOwner", DBusProxyGNameOwnerPropertyInfo), '("gObjectPath", DBusProxyGObjectPathPropertyInfo)] :: [(Symbol, *)])

dBusProxyGBusType :: AttrLabelProxy "gBusType"
dBusProxyGBusType = AttrLabelProxy

dBusProxyGConnection :: AttrLabelProxy "gConnection"
dBusProxyGConnection = AttrLabelProxy

dBusProxyGDefaultTimeout :: AttrLabelProxy "gDefaultTimeout"
dBusProxyGDefaultTimeout = AttrLabelProxy

dBusProxyGFlags :: AttrLabelProxy "gFlags"
dBusProxyGFlags = AttrLabelProxy

dBusProxyGInterfaceInfo :: AttrLabelProxy "gInterfaceInfo"
dBusProxyGInterfaceInfo = AttrLabelProxy

dBusProxyGInterfaceName :: AttrLabelProxy "gInterfaceName"
dBusProxyGInterfaceName = AttrLabelProxy

dBusProxyGName :: AttrLabelProxy "gName"
dBusProxyGName = AttrLabelProxy

dBusProxyGNameOwner :: AttrLabelProxy "gNameOwner"
dBusProxyGNameOwner = AttrLabelProxy

dBusProxyGObjectPath :: AttrLabelProxy "gObjectPath"
dBusProxyGObjectPath = AttrLabelProxy

data DBusProxyGPropertiesChangedSignalInfo
instance SignalInfo DBusProxyGPropertiesChangedSignalInfo where
    type HaskellCallbackType DBusProxyGPropertiesChangedSignalInfo = DBusProxyGPropertiesChangedCallback
    connectSignal _ = connectDBusProxyGPropertiesChanged

data DBusProxyGSignalSignalInfo
instance SignalInfo DBusProxyGSignalSignalInfo where
    type HaskellCallbackType DBusProxyGSignalSignalInfo = DBusProxyGSignalCallback
    connectSignal _ = connectDBusProxyGSignal

type instance O.SignalList DBusProxy = DBusProxySignalList
type DBusProxySignalList = ('[ '("gPropertiesChanged", DBusProxyGPropertiesChangedSignalInfo), '("gSignal", DBusProxyGSignalSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method DBusProxy::new_finish
-- method type : Constructor
-- Args : [Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to g_dbus_proxy_new().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusProxy"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_new_finish" g_dbus_proxy_new_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DBusProxy)

{- |
Finishes creating a 'GI.Gio.Objects.DBusProxy.DBusProxy'.

@since 2.26
-}
dBusProxyNewFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    {- ^ /@res@/: A 'GI.Gio.Interfaces.AsyncResult.AsyncResult' obtained from the 'GI.Gio.Callbacks.AsyncReadyCallback' function passed to 'GI.Gio.Objects.DBusProxy.dBusProxyNew'. -}
    -> m DBusProxy
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusProxy.DBusProxy' or 'Nothing' if /@error@/ is set. Free with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyNewFinish res = liftIO $ do
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_dbus_proxy_new_finish res'
        checkUnexpectedReturnNULL "dBusProxyNewFinish" result
        result' <- (wrapObject DBusProxy) result
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

-- method DBusProxy::new_for_bus_finish
-- method type : Constructor
-- Args : [Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to g_dbus_proxy_new_for_bus().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusProxy"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_new_for_bus_finish" g_dbus_proxy_new_for_bus_finish :: 
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DBusProxy)

{- |
Finishes creating a 'GI.Gio.Objects.DBusProxy.DBusProxy'.

@since 2.26
-}
dBusProxyNewForBusFinish ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.AsyncResult.IsAsyncResult a) =>
    a
    {- ^ /@res@/: A 'GI.Gio.Interfaces.AsyncResult.AsyncResult' obtained from the 'GI.Gio.Callbacks.AsyncReadyCallback' function passed to 'GI.Gio.Objects.DBusProxy.dBusProxyNewForBus'. -}
    -> m DBusProxy
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusProxy.DBusProxy' or 'Nothing' if /@error@/ is set. Free with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyNewForBusFinish res = liftIO $ do
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_dbus_proxy_new_for_bus_finish res'
        checkUnexpectedReturnNULL "dBusProxyNewForBusFinish" result
        result' <- (wrapObject DBusProxy) result
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

-- method DBusProxy::new_for_bus_sync
-- method type : Constructor
-- Args : [Arg {argCName = "bus_type", argType = TInterface (Name {namespace = "Gio", name = "BusType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GBusType.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags used when constructing the proxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GDBusInterfaceInfo specifying the minimal interface\n       that @proxy conforms to or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A bus name (well-known or unique).", 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 "An object path.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interface_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A D-Bus interface name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusProxy"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_new_for_bus_sync" g_dbus_proxy_new_for_bus_sync :: 
    CUInt ->                                -- bus_type : TInterface (Name {namespace = "Gio", name = "BusType"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"})
    Ptr Gio.DBusInterfaceInfo.DBusInterfaceInfo -> -- info : TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- object_path : TBasicType TUTF8
    CString ->                              -- interface_name : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DBusProxy)

{- |
Like 'GI.Gio.Objects.DBusProxy.dBusProxyNewSync' but takes a 'GI.Gio.Enums.BusType' instead of a 'GI.Gio.Objects.DBusConnection.DBusConnection'.

'GI.Gio.Objects.DBusProxy.DBusProxy' is used in this [example][gdbus-wellknown-proxy].

@since 2.26
-}
dBusProxyNewForBusSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Gio.Enums.BusType
    {- ^ /@busType@/: A 'GI.Gio.Enums.BusType'. -}
    -> [Gio.Flags.DBusProxyFlags]
    {- ^ /@flags@/: Flags used when constructing the proxy. -}
    -> Maybe (Gio.DBusInterfaceInfo.DBusInterfaceInfo)
    {- ^ /@info@/: A 'GI.Gio.Structs.DBusInterfaceInfo.DBusInterfaceInfo' specifying the minimal interface
       that /@proxy@/ conforms to or 'Nothing'. -}
    -> T.Text
    {- ^ /@name@/: A bus name (well-known or unique). -}
    -> T.Text
    {- ^ /@objectPath@/: An object path. -}
    -> T.Text
    {- ^ /@interfaceName@/: A D-Bus interface name. -}
    -> Maybe (a)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> m DBusProxy
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusProxy.DBusProxy' or 'Nothing' if error is set. Free with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyNewForBusSync busType flags info name objectPath interfaceName cancellable = liftIO $ do
    let busType' = (fromIntegral . fromEnum) busType
    let flags' = gflagsToWord flags
    maybeInfo <- case info of
        Nothing -> return nullPtr
        Just jInfo -> do
            jInfo' <- unsafeManagedPtrGetPtr jInfo
            return jInfo'
    name' <- textToCString name
    objectPath' <- textToCString objectPath
    interfaceName' <- textToCString interfaceName
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_dbus_proxy_new_for_bus_sync busType' flags' maybeInfo name' objectPath' interfaceName' maybeCancellable
        checkUnexpectedReturnNULL "dBusProxyNewForBusSync" result
        result' <- (wrapObject DBusProxy) result
        whenJust info touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem name'
        freeMem objectPath'
        freeMem interfaceName'
        return result'
     ) (do
        freeMem name'
        freeMem objectPath'
        freeMem interfaceName'
     )

-- method DBusProxy::new_sync
-- 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 = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags used when constructing the proxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.", 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 "An object path.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interface_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A D-Bus interface name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Gio", name = "DBusProxy"}))
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_new_sync" g_dbus_proxy_new_sync :: 
    Ptr Gio.DBusConnection.DBusConnection -> -- connection : TInterface (Name {namespace = "Gio", name = "DBusConnection"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"})
    Ptr Gio.DBusInterfaceInfo.DBusInterfaceInfo -> -- info : TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- object_path : TBasicType TUTF8
    CString ->                              -- interface_name : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr DBusProxy)

{- |
Creates a proxy for accessing /@interfaceName@/ on the remote object
at /@objectPath@/ owned by /@name@/ at /@connection@/ and synchronously
loads D-Bus properties unless the
'GI.Gio.Flags.DBusProxyFlagsDoNotLoadProperties' flag is used.

If the 'GI.Gio.Flags.DBusProxyFlagsDoNotConnectSignals' flag is not set, also sets up
match rules for signals. Connect to the 'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-signal/@ signal
to handle signals from the remote object.

If /@name@/ is a well-known name and the
'GI.Gio.Flags.DBusProxyFlagsDoNotAutoStart' and 'GI.Gio.Flags.DBusProxyFlagsDoNotAutoStartAtConstruction'
flags aren\'t set and no name owner currently exists, the message bus
will be requested to launch a name owner for the name.

This is a synchronous failable constructor. See 'GI.Gio.Objects.DBusProxy.dBusProxyNew'
and 'GI.Gio.Objects.DBusProxy.dBusProxyNewFinish' for the asynchronous version.

'GI.Gio.Objects.DBusProxy.DBusProxy' is used in this [example][gdbus-wellknown-proxy].

@since 2.26
-}
dBusProxyNewSync ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.DBusConnection.IsDBusConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@connection@/: A 'GI.Gio.Objects.DBusConnection.DBusConnection'. -}
    -> [Gio.Flags.DBusProxyFlags]
    {- ^ /@flags@/: Flags used when constructing the proxy. -}
    -> Maybe (Gio.DBusInterfaceInfo.DBusInterfaceInfo)
    {- ^ /@info@/: A 'GI.Gio.Structs.DBusInterfaceInfo.DBusInterfaceInfo' specifying the minimal interface that /@proxy@/ conforms to or 'Nothing'. -}
    -> Maybe (T.Text)
    {- ^ /@name@/: A bus name (well-known or unique) or 'Nothing' if /@connection@/ is not a message bus connection. -}
    -> T.Text
    {- ^ /@objectPath@/: An object path. -}
    -> T.Text
    {- ^ /@interfaceName@/: A D-Bus interface name. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> m DBusProxy
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusProxy.DBusProxy' or 'Nothing' if error is set. Free with 'GI.GObject.Objects.Object.objectUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyNewSync connection flags info name objectPath interfaceName cancellable = liftIO $ do
    connection' <- unsafeManagedPtrCastPtr connection
    let flags' = gflagsToWord flags
    maybeInfo <- case info of
        Nothing -> return nullPtr
        Just jInfo -> do
            jInfo' <- unsafeManagedPtrGetPtr jInfo
            return jInfo'
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    objectPath' <- textToCString objectPath
    interfaceName' <- textToCString interfaceName
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_dbus_proxy_new_sync connection' flags' maybeInfo maybeName objectPath' interfaceName' maybeCancellable
        checkUnexpectedReturnNULL "dBusProxyNewSync" result
        result' <- (wrapObject DBusProxy) result
        touchManagedPtr connection
        whenJust info touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem maybeName
        freeMem objectPath'
        freeMem interfaceName'
        return result'
     ) (do
        freeMem maybeName
        freeMem objectPath'
        freeMem interfaceName'
     )

-- method DBusProxy::call
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Name of method to invoke.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parameters", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusCallFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags from the #GDBusCallFlags enumeration.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout_msec", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The timeout in milliseconds (with %G_MAXINT meaning\n               \"infinite\") or -1 to use the proxy default timeout.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't\ncare about the result of the method invocation.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 7, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "The data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_call" g_dbus_proxy_call :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr GVariant ->                         -- parameters : TVariant
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusCallFlags"})
    Int32 ->                                -- timeout_msec : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Asynchronously invokes the /@methodName@/ method on /@proxy@/.

If /@methodName@/ contains any dots, then /@name@/ is split into interface and
method name parts. This allows using /@proxy@/ for invoking methods on
other interfaces.

If the 'GI.Gio.Objects.DBusConnection.DBusConnection' associated with /@proxy@/ is closed then
the operation will fail with 'GI.Gio.Enums.IOErrorEnumClosed'. If
/@cancellable@/ is canceled, the operation will fail with
'GI.Gio.Enums.IOErrorEnumCancelled'. If /@parameters@/ contains a value not
compatible with the D-Bus protocol, the operation fails with
'GI.Gio.Enums.IOErrorEnumInvalidArgument'.

If the /@parameters@/ 'GVariant' is floating, it is consumed. This allows
convenient \'inline\' use of @/g_variant_new()/@, e.g.:

=== /C code/
>
> g_dbus_proxy_call (proxy,
>                    "TwoStrings",
>                    g_variant_new ("(ss)",
>                                   "Thing One",
>                                   "Thing Two"),
>                    G_DBUS_CALL_FLAGS_NONE,
>                    -1,
>                    NULL,
>                    (GAsyncReadyCallback) two_strings_done,
>                    &data);


If /@proxy@/ has an expected interface (see
'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-interface-info/@) and /@methodName@/ is referenced by it,
then the return value is checked against the return type.

This is an asynchronous method. When the operation is finished,
/@callback@/ will be invoked in the
[thread-default main context][g-main-context-push-thread-default]
of the thread you are calling this method from.
You can then call 'GI.Gio.Objects.DBusProxy.dBusProxyCallFinish' to get the result of
the operation. See 'GI.Gio.Objects.DBusProxy.dBusProxyCallSync' for the synchronous
version of this method.

If /@callback@/ is 'Nothing' then the D-Bus method call message will be sent with
the 'GI.Gio.Flags.DBusMessageFlagsNoReplyExpected' flag set.

@since 2.26
-}
dBusProxyCall ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> T.Text
    {- ^ /@methodName@/: Name of method to invoke. -}
    -> Maybe (GVariant)
    {- ^ /@parameters@/: A 'GVariant' tuple with parameters for the signal or 'Nothing' if not passing parameters. -}
    -> [Gio.Flags.DBusCallFlags]
    {- ^ /@flags@/: Flags from the 'GI.Gio.Flags.DBusCallFlags' enumeration. -}
    -> Int32
    {- ^ /@timeoutMsec@/: The timeout in milliseconds (with @/G_MAXINT/@ meaning
               \"infinite\") or -1 to use the proxy default timeout. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: A 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied or 'Nothing' if you don\'t
care about the result of the method invocation. -}
    -> m ()
dBusProxyCall proxy methodName parameters flags timeoutMsec cancellable callback = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    methodName' <- textToCString methodName
    maybeParameters <- case parameters of
        Nothing -> return nullPtr
        Just jParameters -> do
            jParameters' <- unsafeManagedPtrGetPtr jParameters
            return jParameters'
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dbus_proxy_call proxy' methodName' maybeParameters flags' timeoutMsec maybeCancellable maybeCallback userData
    touchManagedPtr proxy
    whenJust parameters touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem methodName'
    return ()

data DBusProxyCallMethodInfo
instance (signature ~ (T.Text -> Maybe (GVariant) -> [Gio.Flags.DBusCallFlags] -> Int32 -> Maybe (b) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDBusProxy a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DBusProxyCallMethodInfo a signature where
    overloadedMethod _ = dBusProxyCall

-- method DBusProxy::call_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_call_finish" g_dbus_proxy_call_finish :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GVariant)

{- |
Finishes an operation started with 'GI.Gio.Objects.DBusProxy.dBusProxyCall'.

@since 2.26
-}
dBusProxyCallFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> b
    {- ^ /@res@/: A 'GI.Gio.Interfaces.AsyncResult.AsyncResult' obtained from the 'GI.Gio.Callbacks.AsyncReadyCallback' passed to 'GI.Gio.Objects.DBusProxy.dBusProxyCall'. -}
    -> m GVariant
    {- ^ __Returns:__ 'Nothing' if /@error@/ is set. Otherwise a 'GVariant' tuple with
return values. Free with 'GI.GLib.Structs.Variant.variantUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyCallFinish proxy res = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_dbus_proxy_call_finish proxy' res'
        checkUnexpectedReturnNULL "dBusProxyCallFinish" result
        result' <- wrapGVariantPtr result
        touchManagedPtr proxy
        touchManagedPtr res
        return result'
     ) (do
        return ()
     )

data DBusProxyCallFinishMethodInfo
instance (signature ~ (b -> m GVariant), MonadIO m, IsDBusProxy a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DBusProxyCallFinishMethodInfo a signature where
    overloadedMethod _ = dBusProxyCallFinish

-- method DBusProxy::call_sync
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Name of method to invoke.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parameters", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GVariant tuple with parameters for the signal\n             or %NULL if not passing parameters.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusCallFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags from the #GDBusCallFlags enumeration.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout_msec", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The timeout in milliseconds (with %G_MAXINT meaning\n               \"infinite\") or -1 to use the proxy default timeout.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_call_sync" g_dbus_proxy_call_sync :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr GVariant ->                         -- parameters : TVariant
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusCallFlags"})
    Int32 ->                                -- timeout_msec : TBasicType TInt
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GVariant)

{- |
Synchronously invokes the /@methodName@/ method on /@proxy@/.

If /@methodName@/ contains any dots, then /@name@/ is split into interface and
method name parts. This allows using /@proxy@/ for invoking methods on
other interfaces.

If the 'GI.Gio.Objects.DBusConnection.DBusConnection' associated with /@proxy@/ is disconnected then
the operation will fail with 'GI.Gio.Enums.IOErrorEnumClosed'. If
/@cancellable@/ is canceled, the operation will fail with
'GI.Gio.Enums.IOErrorEnumCancelled'. If /@parameters@/ contains a value not
compatible with the D-Bus protocol, the operation fails with
'GI.Gio.Enums.IOErrorEnumInvalidArgument'.

If the /@parameters@/ 'GVariant' is floating, it is consumed. This allows
convenient \'inline\' use of @/g_variant_new()/@, e.g.:

=== /C code/
>
> g_dbus_proxy_call_sync (proxy,
>                         "TwoStrings",
>                         g_variant_new ("(ss)",
>                                        "Thing One",
>                                        "Thing Two"),
>                         G_DBUS_CALL_FLAGS_NONE,
>                         -1,
>                         NULL,
>                         &error);


The calling thread is blocked until a reply is received. See
'GI.Gio.Objects.DBusProxy.dBusProxyCall' for the asynchronous version of this
method.

If /@proxy@/ has an expected interface (see
'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-interface-info/@) and /@methodName@/ is referenced by it,
then the return value is checked against the return type.

@since 2.26
-}
dBusProxyCallSync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> T.Text
    {- ^ /@methodName@/: Name of method to invoke. -}
    -> Maybe (GVariant)
    {- ^ /@parameters@/: A 'GVariant' tuple with parameters for the signal
             or 'Nothing' if not passing parameters. -}
    -> [Gio.Flags.DBusCallFlags]
    {- ^ /@flags@/: Flags from the 'GI.Gio.Flags.DBusCallFlags' enumeration. -}
    -> Int32
    {- ^ /@timeoutMsec@/: The timeout in milliseconds (with @/G_MAXINT/@ meaning
               \"infinite\") or -1 to use the proxy default timeout. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> m GVariant
    {- ^ __Returns:__ 'Nothing' if /@error@/ is set. Otherwise a 'GVariant' tuple with
return values. Free with 'GI.GLib.Structs.Variant.variantUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyCallSync proxy methodName parameters flags timeoutMsec cancellable = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    methodName' <- textToCString methodName
    maybeParameters <- case parameters of
        Nothing -> return nullPtr
        Just jParameters -> do
            jParameters' <- unsafeManagedPtrGetPtr jParameters
            return jParameters'
    let flags' = gflagsToWord flags
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_dbus_proxy_call_sync proxy' methodName' maybeParameters flags' timeoutMsec maybeCancellable
        checkUnexpectedReturnNULL "dBusProxyCallSync" result
        result' <- wrapGVariantPtr result
        touchManagedPtr proxy
        whenJust parameters touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem methodName'
        return result'
     ) (do
        freeMem methodName'
     )

data DBusProxyCallSyncMethodInfo
instance (signature ~ (T.Text -> Maybe (GVariant) -> [Gio.Flags.DBusCallFlags] -> Int32 -> Maybe (b) -> m GVariant), MonadIO m, IsDBusProxy a, Gio.Cancellable.IsCancellable b) => O.MethodInfo DBusProxyCallSyncMethodInfo a signature where
    overloadedMethod _ = dBusProxyCallSync

-- method DBusProxy::call_with_unix_fd_list
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Name of method to invoke.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parameters", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GVariant tuple with parameters for the signal or %NULL if not passing parameters.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusCallFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags from the #GDBusCallFlags enumeration.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout_msec", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The timeout in milliseconds (with %G_MAXINT meaning\n               \"infinite\") or -1 to use the proxy default timeout.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd_list", argType = TInterface (Name {namespace = "Gio", name = "UnixFDList"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GUnixFDList or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GAsyncReadyCallback to call when the request is satisfied or %NULL if you don't\ncare about the result of the method invocation.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 8, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "The data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_call_with_unix_fd_list" g_dbus_proxy_call_with_unix_fd_list :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr GVariant ->                         -- parameters : TVariant
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusCallFlags"})
    Int32 ->                                -- timeout_msec : TBasicType TInt
    Ptr Gio.UnixFDList.UnixFDList ->        -- fd_list : TInterface (Name {namespace = "Gio", name = "UnixFDList"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Like 'GI.Gio.Objects.DBusProxy.dBusProxyCall' but also takes a 'GI.Gio.Objects.UnixFDList.UnixFDList' object.

This method is only available on UNIX.

@since 2.30
-}
dBusProxyCallWithUnixFdList ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a, Gio.UnixFDList.IsUnixFDList b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> T.Text
    {- ^ /@methodName@/: Name of method to invoke. -}
    -> Maybe (GVariant)
    {- ^ /@parameters@/: A 'GVariant' tuple with parameters for the signal or 'Nothing' if not passing parameters. -}
    -> [Gio.Flags.DBusCallFlags]
    {- ^ /@flags@/: Flags from the 'GI.Gio.Flags.DBusCallFlags' enumeration. -}
    -> Int32
    {- ^ /@timeoutMsec@/: The timeout in milliseconds (with @/G_MAXINT/@ meaning
               \"infinite\") or -1 to use the proxy default timeout. -}
    -> Maybe (b)
    {- ^ /@fdList@/: A 'GI.Gio.Objects.UnixFDList.UnixFDList' or 'Nothing'. -}
    -> Maybe (c)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: A 'GI.Gio.Callbacks.AsyncReadyCallback' to call when the request is satisfied or 'Nothing' if you don\'t
care about the result of the method invocation. -}
    -> m ()
dBusProxyCallWithUnixFdList proxy methodName parameters flags timeoutMsec fdList cancellable callback = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    methodName' <- textToCString methodName
    maybeParameters <- case parameters of
        Nothing -> return nullPtr
        Just jParameters -> do
            jParameters' <- unsafeManagedPtrGetPtr jParameters
            return jParameters'
    let flags' = gflagsToWord flags
    maybeFdList <- case fdList of
        Nothing -> return nullPtr
        Just jFdList -> do
            jFdList' <- unsafeManagedPtrCastPtr jFdList
            return jFdList'
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dbus_proxy_call_with_unix_fd_list proxy' methodName' maybeParameters flags' timeoutMsec maybeFdList maybeCancellable maybeCallback userData
    touchManagedPtr proxy
    whenJust parameters touchManagedPtr
    whenJust fdList touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem methodName'
    return ()

data DBusProxyCallWithUnixFdListMethodInfo
instance (signature ~ (T.Text -> Maybe (GVariant) -> [Gio.Flags.DBusCallFlags] -> Int32 -> Maybe (b) -> Maybe (c) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsDBusProxy a, Gio.UnixFDList.IsUnixFDList b, Gio.Cancellable.IsCancellable c) => O.MethodInfo DBusProxyCallWithUnixFdListMethodInfo a signature where
    overloadedMethod _ = dBusProxyCallWithUnixFdList

-- method DBusProxy::call_with_unix_fd_list_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_fd_list", argType = TInterface (Name {namespace = "Gio", name = "UnixFDList"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return location for a #GUnixFDList or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "res", argType = TInterface (Name {namespace = "Gio", name = "AsyncResult"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GAsyncResult obtained from the #GAsyncReadyCallback passed to g_dbus_proxy_call_with_unix_fd_list().", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_call_with_unix_fd_list_finish" g_dbus_proxy_call_with_unix_fd_list_finish :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    Ptr (Ptr Gio.UnixFDList.UnixFDList) ->  -- out_fd_list : TInterface (Name {namespace = "Gio", name = "UnixFDList"})
    Ptr Gio.AsyncResult.AsyncResult ->      -- res : TInterface (Name {namespace = "Gio", name = "AsyncResult"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GVariant)

{- |
Finishes an operation started with 'GI.Gio.Objects.DBusProxy.dBusProxyCallWithUnixFdList'.

@since 2.30
-}
dBusProxyCallWithUnixFdListFinish ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a, Gio.AsyncResult.IsAsyncResult b) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> b
    {- ^ /@res@/: A 'GI.Gio.Interfaces.AsyncResult.AsyncResult' obtained from the 'GI.Gio.Callbacks.AsyncReadyCallback' passed to 'GI.Gio.Objects.DBusProxy.dBusProxyCallWithUnixFdList'. -}
    -> m (GVariant,Gio.UnixFDList.UnixFDList)
    {- ^ __Returns:__ 'Nothing' if /@error@/ is set. Otherwise a 'GVariant' tuple with
return values. Free with 'GI.GLib.Structs.Variant.variantUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyCallWithUnixFdListFinish proxy res = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    outFdList <- allocMem :: IO (Ptr (Ptr Gio.UnixFDList.UnixFDList))
    res' <- unsafeManagedPtrCastPtr res
    onException (do
        result <- propagateGError $ g_dbus_proxy_call_with_unix_fd_list_finish proxy' outFdList res'
        checkUnexpectedReturnNULL "dBusProxyCallWithUnixFdListFinish" result
        result' <- wrapGVariantPtr result
        outFdList' <- peek outFdList
        outFdList'' <- (wrapObject Gio.UnixFDList.UnixFDList) outFdList'
        touchManagedPtr proxy
        touchManagedPtr res
        freeMem outFdList
        return (result', outFdList'')
     ) (do
        freeMem outFdList
     )

data DBusProxyCallWithUnixFdListFinishMethodInfo
instance (signature ~ (b -> m (GVariant,Gio.UnixFDList.UnixFDList)), MonadIO m, IsDBusProxy a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo DBusProxyCallWithUnixFdListFinishMethodInfo a signature where
    overloadedMethod _ = dBusProxyCallWithUnixFdListFinish

-- method DBusProxy::call_with_unix_fd_list_sync
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Name of method to invoke.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "parameters", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GVariant tuple with parameters for the signal\n             or %NULL if not passing parameters.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusCallFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags from the #GDBusCallFlags enumeration.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout_msec", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The timeout in milliseconds (with %G_MAXINT meaning\n               \"infinite\") or -1 to use the proxy default timeout.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd_list", argType = TInterface (Name {namespace = "Gio", name = "UnixFDList"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GUnixFDList or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out_fd_list", argType = TInterface (Name {namespace = "Gio", name = "UnixFDList"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Return location for a #GUnixFDList or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : True
-- Skip return : False

foreign import ccall "g_dbus_proxy_call_with_unix_fd_list_sync" g_dbus_proxy_call_with_unix_fd_list_sync :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr GVariant ->                         -- parameters : TVariant
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusCallFlags"})
    Int32 ->                                -- timeout_msec : TBasicType TInt
    Ptr Gio.UnixFDList.UnixFDList ->        -- fd_list : TInterface (Name {namespace = "Gio", name = "UnixFDList"})
    Ptr (Ptr Gio.UnixFDList.UnixFDList) ->  -- out_fd_list : TInterface (Name {namespace = "Gio", name = "UnixFDList"})
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GVariant)

{- |
Like 'GI.Gio.Objects.DBusProxy.dBusProxyCallSync' but also takes and returns 'GI.Gio.Objects.UnixFDList.UnixFDList' objects.

This method is only available on UNIX.

@since 2.30
-}
dBusProxyCallWithUnixFdListSync ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a, Gio.UnixFDList.IsUnixFDList b, Gio.Cancellable.IsCancellable c) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> T.Text
    {- ^ /@methodName@/: Name of method to invoke. -}
    -> Maybe (GVariant)
    {- ^ /@parameters@/: A 'GVariant' tuple with parameters for the signal
             or 'Nothing' if not passing parameters. -}
    -> [Gio.Flags.DBusCallFlags]
    {- ^ /@flags@/: Flags from the 'GI.Gio.Flags.DBusCallFlags' enumeration. -}
    -> Int32
    {- ^ /@timeoutMsec@/: The timeout in milliseconds (with @/G_MAXINT/@ meaning
               \"infinite\") or -1 to use the proxy default timeout. -}
    -> Maybe (b)
    {- ^ /@fdList@/: A 'GI.Gio.Objects.UnixFDList.UnixFDList' or 'Nothing'. -}
    -> Maybe (c)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> m (GVariant,Gio.UnixFDList.UnixFDList)
    {- ^ __Returns:__ 'Nothing' if /@error@/ is set. Otherwise a 'GVariant' tuple with
return values. Free with 'GI.GLib.Structs.Variant.variantUnref'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
dBusProxyCallWithUnixFdListSync proxy methodName parameters flags timeoutMsec fdList cancellable = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    methodName' <- textToCString methodName
    maybeParameters <- case parameters of
        Nothing -> return nullPtr
        Just jParameters -> do
            jParameters' <- unsafeManagedPtrGetPtr jParameters
            return jParameters'
    let flags' = gflagsToWord flags
    maybeFdList <- case fdList of
        Nothing -> return nullPtr
        Just jFdList -> do
            jFdList' <- unsafeManagedPtrCastPtr jFdList
            return jFdList'
    outFdList <- allocMem :: IO (Ptr (Ptr Gio.UnixFDList.UnixFDList))
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    onException (do
        result <- propagateGError $ g_dbus_proxy_call_with_unix_fd_list_sync proxy' methodName' maybeParameters flags' timeoutMsec maybeFdList outFdList maybeCancellable
        checkUnexpectedReturnNULL "dBusProxyCallWithUnixFdListSync" result
        result' <- wrapGVariantPtr result
        outFdList' <- peek outFdList
        outFdList'' <- (wrapObject Gio.UnixFDList.UnixFDList) outFdList'
        touchManagedPtr proxy
        whenJust parameters touchManagedPtr
        whenJust fdList touchManagedPtr
        whenJust cancellable touchManagedPtr
        freeMem methodName'
        freeMem outFdList
        return (result', outFdList'')
     ) (do
        freeMem methodName'
        freeMem outFdList
     )

data DBusProxyCallWithUnixFdListSyncMethodInfo
instance (signature ~ (T.Text -> Maybe (GVariant) -> [Gio.Flags.DBusCallFlags] -> Int32 -> Maybe (b) -> Maybe (c) -> m (GVariant,Gio.UnixFDList.UnixFDList)), MonadIO m, IsDBusProxy a, Gio.UnixFDList.IsUnixFDList b, Gio.Cancellable.IsCancellable c) => O.MethodInfo DBusProxyCallWithUnixFdListSyncMethodInfo a signature where
    overloadedMethod _ = dBusProxyCallWithUnixFdListSync

-- method DBusProxy::get_cached_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Property name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_get_cached_property" g_dbus_proxy_get_cached_property :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    CString ->                              -- property_name : TBasicType TUTF8
    IO (Ptr GVariant)

{- |
Looks up the value for a property from the cache. This call does no
blocking IO.

If /@proxy@/ has an expected interface (see
'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-interface-info/@) and /@propertyName@/ is referenced by
it, then /@value@/ is checked against the type of the property.

@since 2.26
-}
dBusProxyGetCachedProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> T.Text
    {- ^ /@propertyName@/: Property name. -}
    -> m GVariant
    {- ^ __Returns:__ A reference to the 'GVariant' instance that holds the value
for /@propertyName@/ or 'Nothing' if the value is not in the cache. The
returned reference must be freed with 'GI.GLib.Structs.Variant.variantUnref'. -}
dBusProxyGetCachedProperty proxy propertyName = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    propertyName' <- textToCString propertyName
    result <- g_dbus_proxy_get_cached_property proxy' propertyName'
    checkUnexpectedReturnNULL "dBusProxyGetCachedProperty" result
    result' <- wrapGVariantPtr result
    touchManagedPtr proxy
    freeMem propertyName'
    return result'

data DBusProxyGetCachedPropertyMethodInfo
instance (signature ~ (T.Text -> m GVariant), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetCachedPropertyMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetCachedProperty

-- method DBusProxy::get_cached_property_names
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TCArray True (-1) (-1) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_get_cached_property_names" g_dbus_proxy_get_cached_property_names :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO (Ptr CString)

{- |
Gets the names of all cached properties on /@proxy@/.

@since 2.26
-}
dBusProxyGetCachedPropertyNames ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m [T.Text]
    {- ^ __Returns:__ A 'Nothing'-terminated array of strings or 'Nothing' if
         /@proxy@/ has no cached properties. Free the returned array with
         'GI.GLib.Functions.strfreev'. -}
dBusProxyGetCachedPropertyNames proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_cached_property_names proxy'
    checkUnexpectedReturnNULL "dBusProxyGetCachedPropertyNames" result
    result' <- unpackZeroTerminatedUTF8CArray result
    mapZeroTerminatedCArray freeMem result
    freeMem result
    touchManagedPtr proxy
    return result'

data DBusProxyGetCachedPropertyNamesMethodInfo
instance (signature ~ (m [T.Text]), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetCachedPropertyNamesMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetCachedPropertyNames

-- method DBusProxy::get_connection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", 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_proxy_get_connection" g_dbus_proxy_get_connection :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO (Ptr Gio.DBusConnection.DBusConnection)

{- |
Gets the connection /@proxy@/ is for.

@since 2.26
-}
dBusProxyGetConnection ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m Gio.DBusConnection.DBusConnection
    {- ^ __Returns:__ A 'GI.Gio.Objects.DBusConnection.DBusConnection' owned by /@proxy@/. Do not free. -}
dBusProxyGetConnection proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_connection proxy'
    checkUnexpectedReturnNULL "dBusProxyGetConnection" result
    result' <- (newObject Gio.DBusConnection.DBusConnection) result
    touchManagedPtr proxy
    return result'

data DBusProxyGetConnectionMethodInfo
instance (signature ~ (m Gio.DBusConnection.DBusConnection), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetConnectionMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetConnection

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

foreign import ccall "g_dbus_proxy_get_default_timeout" g_dbus_proxy_get_default_timeout :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO Int32

{- |
Gets the timeout to use if -1 (specifying default timeout) is
passed as /@timeoutMsec@/ in the 'GI.Gio.Objects.DBusProxy.dBusProxyCall' and
'GI.Gio.Objects.DBusProxy.dBusProxyCallSync' functions.

See the 'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-default-timeout/@ property for more details.

@since 2.26
-}
dBusProxyGetDefaultTimeout ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m Int32
    {- ^ __Returns:__ Timeout to use for /@proxy@/. -}
dBusProxyGetDefaultTimeout proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_default_timeout proxy'
    touchManagedPtr proxy
    return result

data DBusProxyGetDefaultTimeoutMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetDefaultTimeoutMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetDefaultTimeout

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

foreign import ccall "g_dbus_proxy_get_flags" g_dbus_proxy_get_flags :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO CUInt

{- |
Gets the flags that /@proxy@/ was constructed with.

@since 2.26
-}
dBusProxyGetFlags ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m [Gio.Flags.DBusProxyFlags]
    {- ^ __Returns:__ Flags from the 'GI.Gio.Flags.DBusProxyFlags' enumeration. -}
dBusProxyGetFlags proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_flags proxy'
    let result' = wordToGFlags result
    touchManagedPtr proxy
    return result'

data DBusProxyGetFlagsMethodInfo
instance (signature ~ (m [Gio.Flags.DBusProxyFlags]), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetFlagsMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetFlags

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

foreign import ccall "g_dbus_proxy_get_interface_info" g_dbus_proxy_get_interface_info :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO (Ptr Gio.DBusInterfaceInfo.DBusInterfaceInfo)

{- |
Returns the 'GI.Gio.Structs.DBusInterfaceInfo.DBusInterfaceInfo', if any, specifying the interface
that /@proxy@/ conforms to. See the 'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-interface-info/@
property for more details.

@since 2.26
-}
dBusProxyGetInterfaceInfo ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy' -}
    -> m Gio.DBusInterfaceInfo.DBusInterfaceInfo
    {- ^ __Returns:__ A 'GI.Gio.Structs.DBusInterfaceInfo.DBusInterfaceInfo' or 'Nothing'. Do not unref the returned
object, it is owned by /@proxy@/. -}
dBusProxyGetInterfaceInfo proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_interface_info proxy'
    checkUnexpectedReturnNULL "dBusProxyGetInterfaceInfo" result
    result' <- (wrapBoxed Gio.DBusInterfaceInfo.DBusInterfaceInfo) result
    touchManagedPtr proxy
    return result'

data DBusProxyGetInterfaceInfoMethodInfo
instance (signature ~ (m Gio.DBusInterfaceInfo.DBusInterfaceInfo), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetInterfaceInfoMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetInterfaceInfo

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

foreign import ccall "g_dbus_proxy_get_interface_name" g_dbus_proxy_get_interface_name :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO CString

{- |
Gets the D-Bus interface name /@proxy@/ is for.

@since 2.26
-}
dBusProxyGetInterfaceName ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m T.Text
    {- ^ __Returns:__ A string owned by /@proxy@/. Do not free. -}
dBusProxyGetInterfaceName proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_interface_name proxy'
    checkUnexpectedReturnNULL "dBusProxyGetInterfaceName" result
    result' <- cstringToText result
    touchManagedPtr proxy
    return result'

data DBusProxyGetInterfaceNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetInterfaceNameMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetInterfaceName

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

foreign import ccall "g_dbus_proxy_get_name" g_dbus_proxy_get_name :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO CString

{- |
Gets the name that /@proxy@/ was constructed for.

@since 2.26
-}
dBusProxyGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m T.Text
    {- ^ __Returns:__ A string owned by /@proxy@/. Do not free. -}
dBusProxyGetName proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_name proxy'
    checkUnexpectedReturnNULL "dBusProxyGetName" result
    result' <- cstringToText result
    touchManagedPtr proxy
    return result'

data DBusProxyGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetNameMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetName

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

foreign import ccall "g_dbus_proxy_get_name_owner" g_dbus_proxy_get_name_owner :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO CString

{- |
The unique name that owns the name that /@proxy@/ is for or 'Nothing' if
no-one currently owns that name. You may connect to the
'GI.GObject.Objects.Object.Object'::@/notify/@ signal to track changes to the
'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-name-owner/@ property.

@since 2.26
-}
dBusProxyGetNameOwner ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m T.Text
    {- ^ __Returns:__ The name owner or 'Nothing' if no name owner exists. Free with 'GI.GLib.Functions.free'. -}
dBusProxyGetNameOwner proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_name_owner proxy'
    checkUnexpectedReturnNULL "dBusProxyGetNameOwner" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr proxy
    return result'

data DBusProxyGetNameOwnerMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetNameOwnerMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetNameOwner

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

foreign import ccall "g_dbus_proxy_get_object_path" g_dbus_proxy_get_object_path :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    IO CString

{- |
Gets the object path /@proxy@/ is for.

@since 2.26
-}
dBusProxyGetObjectPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> m T.Text
    {- ^ __Returns:__ A string owned by /@proxy@/. Do not free. -}
dBusProxyGetObjectPath proxy = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    result <- g_dbus_proxy_get_object_path proxy'
    checkUnexpectedReturnNULL "dBusProxyGetObjectPath" result
    result' <- cstringToText result
    touchManagedPtr proxy
    return result'

data DBusProxyGetObjectPathMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxyGetObjectPathMethodInfo a signature where
    overloadedMethod _ = dBusProxyGetObjectPath

-- method DBusProxy::set_cached_property
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "property_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Property name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Value for the property or %NULL to remove it from the cache.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_set_cached_property" g_dbus_proxy_set_cached_property :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    CString ->                              -- property_name : TBasicType TUTF8
    Ptr GVariant ->                         -- value : TVariant
    IO ()

{- |
If /@value@/ is not 'Nothing', sets the cached value for the property with
name /@propertyName@/ to the value in /@value@/.

If /@value@/ is 'Nothing', then the cached value is removed from the
property cache.

If /@proxy@/ has an expected interface (see
'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-interface-info/@) and /@propertyName@/ is referenced by
it, then /@value@/ is checked against the type of the property.

If the /@value@/ 'GVariant' is floating, it is consumed. This allows
convenient \'inline\' use of @/g_variant_new()/@, e.g.

=== /C code/
>
> g_dbus_proxy_set_cached_property (proxy,
>                                   "SomeProperty",
>                                   g_variant_new ("(si)",
>                                                 "A String",
>                                                 42));


Normally you will not need to use this method since /@proxy@/
is tracking changes using the
@org.freedesktop.DBus.Properties.PropertiesChanged@
D-Bus signal. However, for performance reasons an object may
decide to not use this signal for some properties and instead
use a proprietary out-of-band mechanism to transmit changes.

As a concrete example, consider an object with a property
@ChatroomParticipants@ which is an array of strings. Instead of
transmitting the same (long) array every time the property changes,
it is more efficient to only transmit the delta using e.g. signals
@ChatroomParticipantJoined(String name)@ and
@ChatroomParticipantParted(String name)@.

@since 2.26
-}
dBusProxySetCachedProperty ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy' -}
    -> T.Text
    {- ^ /@propertyName@/: Property name. -}
    -> Maybe (GVariant)
    {- ^ /@value@/: Value for the property or 'Nothing' to remove it from the cache. -}
    -> m ()
dBusProxySetCachedProperty proxy propertyName value = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    propertyName' <- textToCString propertyName
    maybeValue <- case value of
        Nothing -> return nullPtr
        Just jValue -> do
            jValue' <- unsafeManagedPtrGetPtr jValue
            return jValue'
    g_dbus_proxy_set_cached_property proxy' propertyName' maybeValue
    touchManagedPtr proxy
    whenJust value touchManagedPtr
    freeMem propertyName'
    return ()

data DBusProxySetCachedPropertyMethodInfo
instance (signature ~ (T.Text -> Maybe (GVariant) -> m ()), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxySetCachedPropertyMethodInfo a signature where
    overloadedMethod _ = dBusProxySetCachedProperty

-- method DBusProxy::set_default_timeout
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "timeout_msec", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Timeout in milliseconds.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_set_default_timeout" g_dbus_proxy_set_default_timeout :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    Int32 ->                                -- timeout_msec : TBasicType TInt
    IO ()

{- |
Sets the timeout to use if -1 (specifying default timeout) is
passed as /@timeoutMsec@/ in the 'GI.Gio.Objects.DBusProxy.dBusProxyCall' and
'GI.Gio.Objects.DBusProxy.dBusProxyCallSync' functions.

See the 'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-default-timeout/@ property for more details.

@since 2.26
-}
dBusProxySetDefaultTimeout ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy'. -}
    -> Int32
    {- ^ /@timeoutMsec@/: Timeout in milliseconds. -}
    -> m ()
dBusProxySetDefaultTimeout proxy timeoutMsec = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    g_dbus_proxy_set_default_timeout proxy' timeoutMsec
    touchManagedPtr proxy
    return ()

data DBusProxySetDefaultTimeoutMethodInfo
instance (signature ~ (Int32 -> m ()), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxySetDefaultTimeoutMethodInfo a signature where
    overloadedMethod _ = dBusProxySetDefaultTimeout

-- method DBusProxy::set_interface_info
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "proxy", argType = TInterface (Name {namespace = "Gio", name = "DBusProxy"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GDBusProxy", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Minimum interface this proxy conforms to or %NULL to unset.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_set_interface_info" g_dbus_proxy_set_interface_info :: 
    Ptr DBusProxy ->                        -- proxy : TInterface (Name {namespace = "Gio", name = "DBusProxy"})
    Ptr Gio.DBusInterfaceInfo.DBusInterfaceInfo -> -- info : TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"})
    IO ()

{- |
Ensure that interactions with /@proxy@/ conform to the given
interface. See the 'GI.Gio.Objects.DBusProxy.DBusProxy':@/g-interface-info/@ property for more
details.

@since 2.26
-}
dBusProxySetInterfaceInfo ::
    (B.CallStack.HasCallStack, MonadIO m, IsDBusProxy a) =>
    a
    {- ^ /@proxy@/: A 'GI.Gio.Objects.DBusProxy.DBusProxy' -}
    -> Maybe (Gio.DBusInterfaceInfo.DBusInterfaceInfo)
    {- ^ /@info@/: Minimum interface this proxy conforms to or 'Nothing' to unset. -}
    -> m ()
dBusProxySetInterfaceInfo proxy info = liftIO $ do
    proxy' <- unsafeManagedPtrCastPtr proxy
    maybeInfo <- case info of
        Nothing -> return nullPtr
        Just jInfo -> do
            jInfo' <- unsafeManagedPtrGetPtr jInfo
            return jInfo'
    g_dbus_proxy_set_interface_info proxy' maybeInfo
    touchManagedPtr proxy
    whenJust info touchManagedPtr
    return ()

data DBusProxySetInterfaceInfoMethodInfo
instance (signature ~ (Maybe (Gio.DBusInterfaceInfo.DBusInterfaceInfo) -> m ()), MonadIO m, IsDBusProxy a) => O.MethodInfo DBusProxySetInterfaceInfoMethodInfo a signature where
    overloadedMethod _ = dBusProxySetInterfaceInfo

-- method DBusProxy::new
-- method type : MemberFunction
-- 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 = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags used when constructing the proxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A bus name (well-known or unique) or %NULL if @connection is not a message bus connection.", 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 "An object path.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interface_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A D-Bus interface name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Callback function to invoke when the proxy is ready.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 8, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_new" g_dbus_proxy_new :: 
    Ptr Gio.DBusConnection.DBusConnection -> -- connection : TInterface (Name {namespace = "Gio", name = "DBusConnection"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"})
    Ptr Gio.DBusInterfaceInfo.DBusInterfaceInfo -> -- info : TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- object_path : TBasicType TUTF8
    CString ->                              -- interface_name : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Creates a proxy for accessing /@interfaceName@/ on the remote object
at /@objectPath@/ owned by /@name@/ at /@connection@/ and asynchronously
loads D-Bus properties unless the
'GI.Gio.Flags.DBusProxyFlagsDoNotLoadProperties' flag is used. Connect to
the 'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-properties-changed/@ signal to get notified about
property changes.

If the 'GI.Gio.Flags.DBusProxyFlagsDoNotConnectSignals' flag is not set, also sets up
match rules for signals. Connect to the 'GI.Gio.Objects.DBusProxy.DBusProxy'::@/g-signal/@ signal
to handle signals from the remote object.

If /@name@/ is a well-known name and the
'GI.Gio.Flags.DBusProxyFlagsDoNotAutoStart' and 'GI.Gio.Flags.DBusProxyFlagsDoNotAutoStartAtConstruction'
flags aren\'t set and no name owner currently exists, the message bus
will be requested to launch a name owner for the name.

This is a failable asynchronous constructor - when the proxy is
ready, /@callback@/ will be invoked and you can use
'GI.Gio.Objects.DBusProxy.dBusProxyNewFinish' to get the result.

See 'GI.Gio.Objects.DBusProxy.dBusProxyNewSync' and for a synchronous version of this constructor.

'GI.Gio.Objects.DBusProxy.DBusProxy' is used in this [example][gdbus-wellknown-proxy].

@since 2.26
-}
dBusProxyNew ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.DBusConnection.IsDBusConnection a, Gio.Cancellable.IsCancellable b) =>
    a
    {- ^ /@connection@/: A 'GI.Gio.Objects.DBusConnection.DBusConnection'. -}
    -> [Gio.Flags.DBusProxyFlags]
    {- ^ /@flags@/: Flags used when constructing the proxy. -}
    -> Maybe (Gio.DBusInterfaceInfo.DBusInterfaceInfo)
    {- ^ /@info@/: A 'GI.Gio.Structs.DBusInterfaceInfo.DBusInterfaceInfo' specifying the minimal interface that /@proxy@/ conforms to or 'Nothing'. -}
    -> Maybe (T.Text)
    {- ^ /@name@/: A bus name (well-known or unique) or 'Nothing' if /@connection@/ is not a message bus connection. -}
    -> T.Text
    {- ^ /@objectPath@/: An object path. -}
    -> T.Text
    {- ^ /@interfaceName@/: A D-Bus interface name. -}
    -> Maybe (b)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: Callback function to invoke when the proxy is ready. -}
    -> m ()
dBusProxyNew connection flags info name objectPath interfaceName cancellable callback = liftIO $ do
    connection' <- unsafeManagedPtrCastPtr connection
    let flags' = gflagsToWord flags
    maybeInfo <- case info of
        Nothing -> return nullPtr
        Just jInfo -> do
            jInfo' <- unsafeManagedPtrGetPtr jInfo
            return jInfo'
    maybeName <- case name of
        Nothing -> return nullPtr
        Just jName -> do
            jName' <- textToCString jName
            return jName'
    objectPath' <- textToCString objectPath
    interfaceName' <- textToCString interfaceName
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dbus_proxy_new connection' flags' maybeInfo maybeName objectPath' interfaceName' maybeCancellable maybeCallback userData
    touchManagedPtr connection
    whenJust info touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem maybeName
    freeMem objectPath'
    freeMem interfaceName'
    return ()

-- method DBusProxy::new_for_bus
-- method type : MemberFunction
-- Args : [Arg {argCName = "bus_type", argType = TInterface (Name {namespace = "Gio", name = "BusType"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #GBusType.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "Flags used when constructing the proxy.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "info", argType = TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GDBusInterfaceInfo specifying the minimal interface that @proxy conforms to or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A bus name (well-known or unique).", 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 "An object path.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "interface_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A D-Bus interface name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cancellable", argType = TInterface (Name {namespace = "Gio", name = "Cancellable"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "A #GCancellable or %NULL.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "Callback function to invoke when the proxy is ready.", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = 8, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "User data to pass to @callback.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "g_dbus_proxy_new_for_bus" g_dbus_proxy_new_for_bus :: 
    CUInt ->                                -- bus_type : TInterface (Name {namespace = "Gio", name = "BusType"})
    CUInt ->                                -- flags : TInterface (Name {namespace = "Gio", name = "DBusProxyFlags"})
    Ptr Gio.DBusInterfaceInfo.DBusInterfaceInfo -> -- info : TInterface (Name {namespace = "Gio", name = "DBusInterfaceInfo"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- object_path : TBasicType TUTF8
    CString ->                              -- interface_name : TBasicType TUTF8
    Ptr Gio.Cancellable.Cancellable ->      -- cancellable : TInterface (Name {namespace = "Gio", name = "Cancellable"})
    FunPtr Gio.Callbacks.C_AsyncReadyCallback -> -- callback : TInterface (Name {namespace = "Gio", name = "AsyncReadyCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    IO ()

{- |
Like 'GI.Gio.Objects.DBusProxy.dBusProxyNew' but takes a 'GI.Gio.Enums.BusType' instead of a 'GI.Gio.Objects.DBusConnection.DBusConnection'.

'GI.Gio.Objects.DBusProxy.DBusProxy' is used in this [example][gdbus-wellknown-proxy].

@since 2.26
-}
dBusProxyNewForBus ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.Cancellable.IsCancellable a) =>
    Gio.Enums.BusType
    {- ^ /@busType@/: A 'GI.Gio.Enums.BusType'. -}
    -> [Gio.Flags.DBusProxyFlags]
    {- ^ /@flags@/: Flags used when constructing the proxy. -}
    -> Maybe (Gio.DBusInterfaceInfo.DBusInterfaceInfo)
    {- ^ /@info@/: A 'GI.Gio.Structs.DBusInterfaceInfo.DBusInterfaceInfo' specifying the minimal interface that /@proxy@/ conforms to or 'Nothing'. -}
    -> T.Text
    {- ^ /@name@/: A bus name (well-known or unique). -}
    -> T.Text
    {- ^ /@objectPath@/: An object path. -}
    -> T.Text
    {- ^ /@interfaceName@/: A D-Bus interface name. -}
    -> Maybe (a)
    {- ^ /@cancellable@/: A 'GI.Gio.Objects.Cancellable.Cancellable' or 'Nothing'. -}
    -> Maybe (Gio.Callbacks.AsyncReadyCallback)
    {- ^ /@callback@/: Callback function to invoke when the proxy is ready. -}
    -> m ()
dBusProxyNewForBus busType flags info name objectPath interfaceName cancellable callback = liftIO $ do
    let busType' = (fromIntegral . fromEnum) busType
    let flags' = gflagsToWord flags
    maybeInfo <- case info of
        Nothing -> return nullPtr
        Just jInfo -> do
            jInfo' <- unsafeManagedPtrGetPtr jInfo
            return jInfo'
    name' <- textToCString name
    objectPath' <- textToCString objectPath
    interfaceName' <- textToCString interfaceName
    maybeCancellable <- case cancellable of
        Nothing -> return nullPtr
        Just jCancellable -> do
            jCancellable' <- unsafeManagedPtrCastPtr jCancellable
            return jCancellable'
    ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
    maybeCallback <- case callback of
        Nothing -> return (castPtrToFunPtr nullPtr)
        Just jCallback -> do
            jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
            poke ptrcallback jCallback'
            return jCallback'
    let userData = nullPtr
    g_dbus_proxy_new_for_bus busType' flags' maybeInfo name' objectPath' interfaceName' maybeCancellable maybeCallback userData
    whenJust info touchManagedPtr
    whenJust cancellable touchManagedPtr
    freeMem name'
    freeMem objectPath'
    freeMem interfaceName'
    return ()