gi-gio-0.2.44.12: GI/Gio/Interfaces/ProxyResolver.hs
{- |
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.ProxyResolver
(
-- * Exported types
ProxyResolver(..) ,
noProxyResolver ,
ProxyResolverK ,
toProxyResolver ,
-- * Methods
-- ** proxyResolverIsSupported
proxyResolverIsSupported ,
-- ** proxyResolverLookup
proxyResolverLookup ,
-- ** proxyResolverLookupAsync
proxyResolverLookupAsync ,
-- ** proxyResolverLookupFinish
proxyResolverLookupFinish ,
) 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 ProxyResolver
newtype ProxyResolver = ProxyResolver (ForeignPtr ProxyResolver)
noProxyResolver :: Maybe ProxyResolver
noProxyResolver = Nothing
type instance AttributeList ProxyResolver = ProxyResolverAttributeList
type ProxyResolverAttributeList = ('[ ] :: [(Symbol, *)])
type instance SignalList ProxyResolver = ProxyResolverSignalList
type ProxyResolverSignalList = ('[ '("notify", GObject.ObjectNotifySignalInfo), '("notify::[property]", GObjectNotifySignalInfo)] :: [(Symbol, *)])
foreign import ccall "g_proxy_resolver_get_type"
c_g_proxy_resolver_get_type :: IO GType
type instance ParentTypes ProxyResolver = ProxyResolverParentTypes
type ProxyResolverParentTypes = '[GObject.Object]
instance GObject ProxyResolver where
gobjectIsInitiallyUnowned _ = False
gobjectType _ = c_g_proxy_resolver_get_type
class GObject o => ProxyResolverK o
instance (GObject o, IsDescendantOf ProxyResolver o) => ProxyResolverK o
toProxyResolver :: ProxyResolverK o => o -> IO ProxyResolver
toProxyResolver = unsafeCastTo ProxyResolver
-- method ProxyResolver::is_supported
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "ProxyResolver", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "ProxyResolver", 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_resolver_is_supported" g_proxy_resolver_is_supported ::
Ptr ProxyResolver -> -- _obj : TInterface "Gio" "ProxyResolver"
IO CInt
proxyResolverIsSupported ::
(MonadIO m, ProxyResolverK a) =>
a -> -- _obj
m Bool
proxyResolverIsSupported _obj = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
result <- g_proxy_resolver_is_supported _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
-- method ProxyResolver::lookup
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "ProxyResolver", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, 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" "ProxyResolver", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, 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 : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : True
-- Skip return : False
foreign import ccall "g_proxy_resolver_lookup" g_proxy_resolver_lookup ::
Ptr ProxyResolver -> -- _obj : TInterface "Gio" "ProxyResolver"
CString -> -- uri : TBasicType TUTF8
Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable"
Ptr (Ptr GError) -> -- error
IO (Ptr CString)
proxyResolverLookup ::
(MonadIO m, ProxyResolverK a, CancellableK b) =>
a -> -- _obj
T.Text -> -- uri
Maybe (b) -> -- cancellable
m [T.Text]
proxyResolverLookup _obj uri cancellable = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
uri' <- textToCString uri
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
let jCancellable' = unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ g_proxy_resolver_lookup _obj' uri' maybeCancellable
checkUnexpectedReturnNULL "g_proxy_resolver_lookup" result
result' <- unpackZeroTerminatedUTF8CArray result
mapZeroTerminatedCArray freeMem result
freeMem result
touchManagedPtr _obj
whenJust cancellable touchManagedPtr
freeMem uri'
return result'
) (do
freeMem uri'
)
-- method ProxyResolver::lookup_async
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "ProxyResolver", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, 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 = 4, 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" "ProxyResolver", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, 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 = 4, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_proxy_resolver_lookup_async" g_proxy_resolver_lookup_async ::
Ptr ProxyResolver -> -- _obj : TInterface "Gio" "ProxyResolver"
CString -> -- uri : TBasicType TUTF8
Ptr Cancellable -> -- cancellable : TInterface "Gio" "Cancellable"
FunPtr AsyncReadyCallbackC -> -- callback : TInterface "Gio" "AsyncReadyCallback"
Ptr () -> -- user_data : TBasicType TVoid
IO ()
proxyResolverLookupAsync ::
(MonadIO m, ProxyResolverK a, CancellableK b) =>
a -> -- _obj
T.Text -> -- uri
Maybe (b) -> -- cancellable
Maybe (AsyncReadyCallback) -> -- callback
m ()
proxyResolverLookupAsync _obj uri cancellable callback = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
uri' <- textToCString uri
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_resolver_lookup_async _obj' uri' maybeCancellable maybeCallback user_data
touchManagedPtr _obj
whenJust cancellable touchManagedPtr
freeMem uri'
return ()
-- method ProxyResolver::lookup_finish
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "ProxyResolver", 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" "ProxyResolver", 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 : TCArray True (-1) (-1) (TBasicType TUTF8)
-- throws : True
-- Skip return : False
foreign import ccall "g_proxy_resolver_lookup_finish" g_proxy_resolver_lookup_finish ::
Ptr ProxyResolver -> -- _obj : TInterface "Gio" "ProxyResolver"
Ptr AsyncResult -> -- result : TInterface "Gio" "AsyncResult"
Ptr (Ptr GError) -> -- error
IO (Ptr CString)
proxyResolverLookupFinish ::
(MonadIO m, ProxyResolverK a, AsyncResultK b) =>
a -> -- _obj
b -> -- result
m [T.Text]
proxyResolverLookupFinish _obj result_ = liftIO $ do
let _obj' = unsafeManagedPtrCastPtr _obj
let result_' = unsafeManagedPtrCastPtr result_
onException (do
result <- propagateGError $ g_proxy_resolver_lookup_finish _obj' result_'
checkUnexpectedReturnNULL "g_proxy_resolver_lookup_finish" result
result' <- unpackZeroTerminatedUTF8CArray result
mapZeroTerminatedCArray freeMem result
freeMem result
touchManagedPtr _obj
touchManagedPtr result_
return result'
) (do
return ()
)