{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) -} module GI.Gio.Interfaces.Proxy ( -- * Exported types Proxy(..) , noProxy , ProxyK , toProxy , -- * Methods -- ** proxyConnect proxyConnect , -- ** proxyConnectAsync proxyConnectAsync , -- ** proxyConnectFinish proxyConnectFinish , -- ** proxySupportsHostname proxySupportsHostname , ) where import Prelude () import Data.GI.Base.ShortPrelude import qualified Data.Text as T import qualified Data.ByteString.Char8 as B import qualified Data.Map as Map import GI.Gio.Types import GI.Gio.Callbacks import qualified GI.GObject as GObject -- interface Proxy newtype Proxy = Proxy (ForeignPtr Proxy) noProxy :: Maybe Proxy noProxy = Nothing type instance AttributeList Proxy = ProxyAttributeList type ProxyAttributeList = ('[ ] :: [(Symbol, *)]) type instance SignalList Proxy = ProxySignalList type ProxySignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)]) foreign import ccall "g_proxy_get_type" c_g_proxy_get_type :: IO GType type instance ParentTypes Proxy = ProxyParentTypes type ProxyParentTypes = '[GObject.Object] instance GObject Proxy where gobjectIsInitiallyUnowned _ = False gobjectType _ = c_g_proxy_get_type class GObject o => ProxyK o instance (GObject o, IsDescendantOf Proxy o) => ProxyK o toProxy :: ProxyK o => o -> IO Proxy toProxy = unsafeCastTo Proxy -- method Proxy::connect -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "IOStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "proxy_address", argType = TInterface "Gio" "ProxyAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "IOStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "proxy_address", argType = TInterface "Gio" "ProxyAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gio" "IOStream" -- throws : True -- Skip return : False foreign import ccall "g_proxy_connect" g_proxy_connect :: Ptr Proxy -> -- _obj : TInterface "Gio" "Proxy" Ptr IOStream -> -- connection : TInterface "Gio" "IOStream" Ptr ProxyAddress -> -- proxy_address : TInterface "Gio" "ProxyAddress" Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable" Ptr (Ptr GError) -> -- error IO (Ptr IOStream) proxyConnect :: (MonadIO m, ProxyK a, IOStreamK b, ProxyAddressK c, CancellableK d) => a -> -- _obj b -> -- connection c -> -- proxy_address Maybe (d) -> -- cancellable m IOStream proxyConnect _obj connection proxy_address cancellable = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let connection' = unsafeManagedPtrCastPtr connection let proxy_address' = unsafeManagedPtrCastPtr proxy_address maybeCancellable <- case cancellable of Nothing -> return nullPtr Just jCancellable -> do let jCancellable' = unsafeManagedPtrCastPtr jCancellable return jCancellable' onException (do result <- propagateGError $ g_proxy_connect _obj' connection' proxy_address' maybeCancellable checkUnexpectedReturnNULL "g_proxy_connect" result result' <- (wrapObject IOStream) result touchManagedPtr _obj touchManagedPtr connection touchManagedPtr proxy_address whenJust cancellable touchManagedPtr return result' ) (do return () ) -- method Proxy::connect_async -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "IOStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "proxy_address", argType = TInterface "Gio" "ProxyAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing},Arg {argName = "user_data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "connection", argType = TInterface "Gio" "IOStream", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "proxy_address", argType = TInterface "Gio" "ProxyAddress", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "cancellable", argType = TInterface "Gio" "Cancellable", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "callback", argType = TInterface "Gio" "AsyncReadyCallback", direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeAsync, argClosure = 5, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_proxy_connect_async" g_proxy_connect_async :: Ptr Proxy -> -- _obj : TInterface "Gio" "Proxy" Ptr IOStream -> -- connection : TInterface "Gio" "IOStream" Ptr ProxyAddress -> -- proxy_address : TInterface "Gio" "ProxyAddress" Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable" FunPtr AsyncReadyCallbackC -> -- callback : TInterface "Gio" "AsyncReadyCallback" Ptr () -> -- user_data : TBasicType TVoid IO () proxyConnectAsync :: (MonadIO m, ProxyK a, IOStreamK b, ProxyAddressK c, CancellableK d) => a -> -- _obj b -> -- connection c -> -- proxy_address Maybe (d) -> -- cancellable Maybe (AsyncReadyCallback) -> -- callback m () proxyConnectAsync _obj connection proxy_address cancellable callback = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let connection' = unsafeManagedPtrCastPtr connection let proxy_address' = unsafeManagedPtrCastPtr proxy_address maybeCancellable <- case cancellable of Nothing -> return nullPtr Just jCancellable -> do let jCancellable' = unsafeManagedPtrCastPtr jCancellable return jCancellable' ptrcallback <- callocMem :: IO (Ptr (FunPtr AsyncReadyCallbackC)) maybeCallback <- case callback of Nothing -> return (castPtrToFunPtr nullPtr) Just jCallback -> do jCallback' <- mkAsyncReadyCallback (asyncReadyCallbackWrapper (Just ptrcallback) jCallback) poke ptrcallback jCallback' return jCallback' let user_data = nullPtr g_proxy_connect_async _obj' connection' proxy_address' maybeCancellable maybeCallback user_data touchManagedPtr _obj touchManagedPtr connection touchManagedPtr proxy_address whenJust cancellable touchManagedPtr return () -- method Proxy::connect_finish -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "result", argType = TInterface "Gio" "AsyncResult", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gio" "IOStream" -- throws : True -- Skip return : False foreign import ccall "g_proxy_connect_finish" g_proxy_connect_finish :: Ptr Proxy -> -- _obj : TInterface "Gio" "Proxy" Ptr AsyncResult -> -- result : TInterface "Gio" "AsyncResult" Ptr (Ptr GError) -> -- error IO (Ptr IOStream) proxyConnectFinish :: (MonadIO m, ProxyK a, AsyncResultK b) => a -> -- _obj b -> -- result m IOStream proxyConnectFinish _obj result_ = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj let result_' = unsafeManagedPtrCastPtr result_ onException (do result <- propagateGError $ g_proxy_connect_finish _obj' result_' checkUnexpectedReturnNULL "g_proxy_connect_finish" result result' <- (wrapObject IOStream) result touchManagedPtr _obj touchManagedPtr result_ return result' ) (do return () ) -- method Proxy::supports_hostname -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "Proxy", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TBoolean -- throws : False -- Skip return : False foreign import ccall "g_proxy_supports_hostname" g_proxy_supports_hostname :: Ptr Proxy -> -- _obj : TInterface "Gio" "Proxy" IO CInt proxySupportsHostname :: (MonadIO m, ProxyK a) => a -> -- _obj m Bool proxySupportsHostname _obj = liftIO $ do let _obj' = unsafeManagedPtrCastPtr _obj result <- g_proxy_supports_hostname _obj' let result' = (/= 0) result touchManagedPtr _obj return result'