{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (garetxe@gmail.com) SRV (service) records are used by some network protocols to provide service-specific aliasing and load-balancing. For example, XMPP (Jabber) uses SRV records to locate the XMPP server for a domain; rather than connecting directly to "example.com" or assuming a specific server hostname like "xmpp.example.com", an XMPP client would look up the "xmpp-client" SRV record for "example.com", and then connect to whatever host was pointed to by that record. You can use g_resolver_lookup_service() or g_resolver_lookup_service_async() to find the #GSrvTargets for a given service. However, if you are simply planning to connect to the remote service, you can use #GNetworkService's #GSocketConnectable interface and not need to worry about #GSrvTarget at all. -} module GI.Gio.Structs.SrvTarget ( -- * Exported types SrvTarget(..) , noSrvTarget , -- * Methods -- ** srvTargetCopy srvTargetCopy , -- ** srvTargetFree srvTargetFree , -- ** srvTargetGetHostname srvTargetGetHostname , -- ** srvTargetGetPort srvTargetGetPort , -- ** srvTargetGetPriority srvTargetGetPriority , -- ** srvTargetGetWeight srvTargetGetWeight , -- ** srvTargetNew srvTargetNew , ) 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 newtype SrvTarget = SrvTarget (ForeignPtr SrvTarget) foreign import ccall "g_srv_target_get_type" c_g_srv_target_get_type :: IO GType instance BoxedObject SrvTarget where boxedType _ = c_g_srv_target_get_type noSrvTarget :: Maybe SrvTarget noSrvTarget = Nothing -- method SrvTarget::new -- method type : Constructor -- Args : [Arg {argName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "priority", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "weight", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "port", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "priority", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "weight", argType = TBasicType TUInt16, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gio" "SrvTarget" -- throws : False -- Skip return : False foreign import ccall "g_srv_target_new" g_srv_target_new :: CString -> -- hostname : TBasicType TUTF8 Word16 -> -- port : TBasicType TUInt16 Word16 -> -- priority : TBasicType TUInt16 Word16 -> -- weight : TBasicType TUInt16 IO (Ptr SrvTarget) srvTargetNew :: (MonadIO m) => T.Text -> -- hostname Word16 -> -- port Word16 -> -- priority Word16 -> -- weight m SrvTarget srvTargetNew hostname port priority weight = liftIO $ do hostname' <- textToCString hostname result <- g_srv_target_new hostname' port priority weight checkUnexpectedReturnNULL "g_srv_target_new" result result' <- (wrapBoxed SrvTarget) result freeMem hostname' return result' -- method SrvTarget::copy -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TInterface "Gio" "SrvTarget" -- throws : False -- Skip return : False foreign import ccall "g_srv_target_copy" g_srv_target_copy :: Ptr SrvTarget -> -- _obj : TInterface "Gio" "SrvTarget" IO (Ptr SrvTarget) srvTargetCopy :: (MonadIO m) => SrvTarget -> -- _obj m SrvTarget srvTargetCopy _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_srv_target_copy _obj' checkUnexpectedReturnNULL "g_srv_target_copy" result result' <- (wrapBoxed SrvTarget) result touchManagedPtr _obj return result' -- method SrvTarget::free -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TVoid -- throws : False -- Skip return : False foreign import ccall "g_srv_target_free" g_srv_target_free :: Ptr SrvTarget -> -- _obj : TInterface "Gio" "SrvTarget" IO () srvTargetFree :: (MonadIO m) => SrvTarget -> -- _obj m () srvTargetFree _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj g_srv_target_free _obj' touchManagedPtr _obj return () -- method SrvTarget::get_hostname -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUTF8 -- throws : False -- Skip return : False foreign import ccall "g_srv_target_get_hostname" g_srv_target_get_hostname :: Ptr SrvTarget -> -- _obj : TInterface "Gio" "SrvTarget" IO CString srvTargetGetHostname :: (MonadIO m) => SrvTarget -> -- _obj m T.Text srvTargetGetHostname _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_srv_target_get_hostname _obj' checkUnexpectedReturnNULL "g_srv_target_get_hostname" result result' <- cstringToText result touchManagedPtr _obj return result' -- method SrvTarget::get_port -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUInt16 -- throws : False -- Skip return : False foreign import ccall "g_srv_target_get_port" g_srv_target_get_port :: Ptr SrvTarget -> -- _obj : TInterface "Gio" "SrvTarget" IO Word16 srvTargetGetPort :: (MonadIO m) => SrvTarget -> -- _obj m Word16 srvTargetGetPort _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_srv_target_get_port _obj' touchManagedPtr _obj return result -- method SrvTarget::get_priority -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUInt16 -- throws : False -- Skip return : False foreign import ccall "g_srv_target_get_priority" g_srv_target_get_priority :: Ptr SrvTarget -> -- _obj : TInterface "Gio" "SrvTarget" IO Word16 srvTargetGetPriority :: (MonadIO m) => SrvTarget -> -- _obj m Word16 srvTargetGetPriority _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_srv_target_get_priority _obj' touchManagedPtr _obj return result -- method SrvTarget::get_weight -- method type : OrdinaryMethod -- Args : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- Lengths : [] -- hInArgs : [Arg {argName = "_obj", argType = TInterface "Gio" "SrvTarget", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}] -- returnType : TBasicType TUInt16 -- throws : False -- Skip return : False foreign import ccall "g_srv_target_get_weight" g_srv_target_get_weight :: Ptr SrvTarget -> -- _obj : TInterface "Gio" "SrvTarget" IO Word16 srvTargetGetWeight :: (MonadIO m) => SrvTarget -> -- _obj m Word16 srvTargetGetWeight _obj = liftIO $ do let _obj' = unsafeManagedPtrGetPtr _obj result <- g_srv_target_get_weight _obj' touchManagedPtr _obj return result