#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Interfaces.Proxy
(
Proxy(..) ,
noProxy ,
IsProxy ,
toProxy ,
#if ENABLE_OVERLOADING
ProxyConnectMethodInfo ,
#endif
proxyConnect ,
#if ENABLE_OVERLOADING
ProxyConnectAsyncMethodInfo ,
#endif
proxyConnectAsync ,
#if ENABLE_OVERLOADING
ProxyConnectFinishMethodInfo ,
#endif
proxyConnectFinish ,
proxyGetDefaultForProtocol ,
#if ENABLE_OVERLOADING
ProxySupportsHostnameMethodInfo ,
#endif
proxySupportsHostname ,
) where
import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P
import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import {-# SOURCE #-} qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.IOStream as Gio.IOStream
import {-# SOURCE #-} qualified GI.Gio.Objects.ProxyAddress as Gio.ProxyAddress
newtype Proxy = Proxy (ManagedPtr Proxy)
noProxy :: Maybe Proxy
noProxy = Nothing
#if ENABLE_OVERLOADING
type instance O.SignalList Proxy = ProxySignalList
type ProxySignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_proxy_get_type"
c_g_proxy_get_type :: IO GType
instance GObject Proxy where
gobjectType = c_g_proxy_get_type
class (GObject o, O.IsDescendantOf Proxy o) => IsProxy o
instance (GObject o, O.IsDescendantOf Proxy o) => IsProxy o
instance O.HasParentTypes Proxy
type instance O.ParentTypes Proxy = '[GObject.Object.Object]
toProxy :: (MonadIO m, IsProxy o) => o -> m Proxy
toProxy = liftIO . unsafeCastTo Proxy
#if ENABLE_OVERLOADING
instance O.HasAttributeList Proxy
type instance O.AttributeList Proxy = ProxyAttributeList
type ProxyAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
#endif
#if ENABLE_OVERLOADING
type family ResolveProxyMethod (t :: Symbol) (o :: *) :: * where
ResolveProxyMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolveProxyMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolveProxyMethod "connect" o = ProxyConnectMethodInfo
ResolveProxyMethod "connectAsync" o = ProxyConnectAsyncMethodInfo
ResolveProxyMethod "connectFinish" o = ProxyConnectFinishMethodInfo
ResolveProxyMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolveProxyMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolveProxyMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolveProxyMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolveProxyMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolveProxyMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolveProxyMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolveProxyMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolveProxyMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolveProxyMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolveProxyMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolveProxyMethod "supportsHostname" o = ProxySupportsHostnameMethodInfo
ResolveProxyMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolveProxyMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolveProxyMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolveProxyMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolveProxyMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolveProxyMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolveProxyMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolveProxyMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
ResolveProxyMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolveProxyMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveProxyMethod t Proxy, O.MethodInfo info Proxy p) => OL.IsLabel t (Proxy -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif
foreign import ccall "g_proxy_connect" g_proxy_connect ::
Ptr Proxy ->
Ptr Gio.IOStream.IOStream ->
Ptr Gio.ProxyAddress.ProxyAddress ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO (Ptr Gio.IOStream.IOStream)
proxyConnect ::
(B.CallStack.HasCallStack, MonadIO m, IsProxy a, Gio.IOStream.IsIOStream b, Gio.ProxyAddress.IsProxyAddress c, Gio.Cancellable.IsCancellable d) =>
a
-> b
-> c
-> Maybe (d)
-> m Gio.IOStream.IOStream
proxyConnect proxy connection proxyAddress cancellable = liftIO $ do
proxy' <- unsafeManagedPtrCastPtr proxy
connection' <- unsafeManagedPtrCastPtr connection
proxyAddress' <- unsafeManagedPtrCastPtr proxyAddress
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ g_proxy_connect proxy' connection' proxyAddress' maybeCancellable
checkUnexpectedReturnNULL "proxyConnect" result
result' <- (wrapObject Gio.IOStream.IOStream) result
touchManagedPtr proxy
touchManagedPtr connection
touchManagedPtr proxyAddress
whenJust cancellable touchManagedPtr
return result'
) (do
return ()
)
#if ENABLE_OVERLOADING
data ProxyConnectMethodInfo
instance (signature ~ (b -> c -> Maybe (d) -> m Gio.IOStream.IOStream), MonadIO m, IsProxy a, Gio.IOStream.IsIOStream b, Gio.ProxyAddress.IsProxyAddress c, Gio.Cancellable.IsCancellable d) => O.MethodInfo ProxyConnectMethodInfo a signature where
overloadedMethod _ = proxyConnect
#endif
foreign import ccall "g_proxy_connect_async" g_proxy_connect_async ::
Ptr Proxy ->
Ptr Gio.IOStream.IOStream ->
Ptr Gio.ProxyAddress.ProxyAddress ->
Ptr Gio.Cancellable.Cancellable ->
FunPtr Gio.Callbacks.C_AsyncReadyCallback ->
Ptr () ->
IO ()
proxyConnectAsync ::
(B.CallStack.HasCallStack, MonadIO m, IsProxy a, Gio.IOStream.IsIOStream b, Gio.ProxyAddress.IsProxyAddress c, Gio.Cancellable.IsCancellable d) =>
a
-> b
-> c
-> Maybe (d)
-> Maybe (Gio.Callbacks.AsyncReadyCallback)
-> m ()
proxyConnectAsync proxy connection proxyAddress cancellable callback = liftIO $ do
proxy' <- unsafeManagedPtrCastPtr proxy
connection' <- unsafeManagedPtrCastPtr connection
proxyAddress' <- unsafeManagedPtrCastPtr proxyAddress
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
maybeCallback <- case callback of
Nothing -> return (castPtrToFunPtr nullPtr)
Just jCallback -> do
ptrcallback <- callocMem :: IO (Ptr (FunPtr Gio.Callbacks.C_AsyncReadyCallback))
jCallback' <- Gio.Callbacks.mk_AsyncReadyCallback (Gio.Callbacks.wrap_AsyncReadyCallback (Just ptrcallback) (Gio.Callbacks.drop_closures_AsyncReadyCallback jCallback))
poke ptrcallback jCallback'
return jCallback'
let userData = nullPtr
g_proxy_connect_async proxy' connection' proxyAddress' maybeCancellable maybeCallback userData
touchManagedPtr proxy
touchManagedPtr connection
touchManagedPtr proxyAddress
whenJust cancellable touchManagedPtr
return ()
#if ENABLE_OVERLOADING
data ProxyConnectAsyncMethodInfo
instance (signature ~ (b -> c -> Maybe (d) -> Maybe (Gio.Callbacks.AsyncReadyCallback) -> m ()), MonadIO m, IsProxy a, Gio.IOStream.IsIOStream b, Gio.ProxyAddress.IsProxyAddress c, Gio.Cancellable.IsCancellable d) => O.MethodInfo ProxyConnectAsyncMethodInfo a signature where
overloadedMethod _ = proxyConnectAsync
#endif
foreign import ccall "g_proxy_connect_finish" g_proxy_connect_finish ::
Ptr Proxy ->
Ptr Gio.AsyncResult.AsyncResult ->
Ptr (Ptr GError) ->
IO (Ptr Gio.IOStream.IOStream)
proxyConnectFinish ::
(B.CallStack.HasCallStack, MonadIO m, IsProxy a, Gio.AsyncResult.IsAsyncResult b) =>
a
-> b
-> m Gio.IOStream.IOStream
proxyConnectFinish proxy result_ = liftIO $ do
proxy' <- unsafeManagedPtrCastPtr proxy
result_' <- unsafeManagedPtrCastPtr result_
onException (do
result <- propagateGError $ g_proxy_connect_finish proxy' result_'
checkUnexpectedReturnNULL "proxyConnectFinish" result
result' <- (wrapObject Gio.IOStream.IOStream) result
touchManagedPtr proxy
touchManagedPtr result_
return result'
) (do
return ()
)
#if ENABLE_OVERLOADING
data ProxyConnectFinishMethodInfo
instance (signature ~ (b -> m Gio.IOStream.IOStream), MonadIO m, IsProxy a, Gio.AsyncResult.IsAsyncResult b) => O.MethodInfo ProxyConnectFinishMethodInfo a signature where
overloadedMethod _ = proxyConnectFinish
#endif
foreign import ccall "g_proxy_supports_hostname" g_proxy_supports_hostname ::
Ptr Proxy ->
IO CInt
proxySupportsHostname ::
(B.CallStack.HasCallStack, MonadIO m, IsProxy a) =>
a
-> m Bool
proxySupportsHostname proxy = liftIO $ do
proxy' <- unsafeManagedPtrCastPtr proxy
result <- g_proxy_supports_hostname proxy'
let result' = (/= 0) result
touchManagedPtr proxy
return result'
#if ENABLE_OVERLOADING
data ProxySupportsHostnameMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsProxy a) => O.MethodInfo ProxySupportsHostnameMethodInfo a signature where
overloadedMethod _ = proxySupportsHostname
#endif
foreign import ccall "g_proxy_get_default_for_protocol" g_proxy_get_default_for_protocol ::
CString ->
IO (Ptr Proxy)
proxyGetDefaultForProtocol ::
(B.CallStack.HasCallStack, MonadIO m) =>
T.Text
-> m Proxy
proxyGetDefaultForProtocol protocol = liftIO $ do
protocol' <- textToCString protocol
result <- g_proxy_get_default_for_protocol protocol'
checkUnexpectedReturnNULL "proxyGetDefaultForProtocol" result
result' <- (wrapObject Proxy) result
freeMem protocol'
return result'
#if ENABLE_OVERLOADING
#endif