#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Gio.Interfaces.PollableOutputStream
(
PollableOutputStream(..) ,
noPollableOutputStream ,
IsPollableOutputStream ,
toPollableOutputStream ,
#if ENABLE_OVERLOADING
PollableOutputStreamCanPollMethodInfo ,
#endif
pollableOutputStreamCanPoll ,
#if ENABLE_OVERLOADING
PollableOutputStreamCreateSourceMethodInfo,
#endif
pollableOutputStreamCreateSource ,
#if ENABLE_OVERLOADING
PollableOutputStreamIsWritableMethodInfo,
#endif
pollableOutputStreamIsWritable ,
#if ENABLE_OVERLOADING
PollableOutputStreamWriteNonblockingMethodInfo,
#endif
pollableOutputStreamWriteNonblocking ,
) 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.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.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.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import {-# SOURCE #-} qualified GI.Gio.Objects.OutputStream as Gio.OutputStream
newtype PollableOutputStream = PollableOutputStream (ManagedPtr PollableOutputStream)
noPollableOutputStream :: Maybe PollableOutputStream
noPollableOutputStream = Nothing
#if ENABLE_OVERLOADING
type instance O.SignalList PollableOutputStream = PollableOutputStreamSignalList
type PollableOutputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "g_pollable_output_stream_get_type"
c_g_pollable_output_stream_get_type :: IO GType
instance GObject PollableOutputStream where
gobjectType _ = c_g_pollable_output_stream_get_type
class GObject o => IsPollableOutputStream o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError PollableOutputStream a) =>
IsPollableOutputStream a
#endif
instance IsPollableOutputStream PollableOutputStream
instance Gio.OutputStream.IsOutputStream PollableOutputStream
instance GObject.Object.IsObject PollableOutputStream
toPollableOutputStream :: (MonadIO m, IsPollableOutputStream o) => o -> m PollableOutputStream
toPollableOutputStream = liftIO . unsafeCastTo PollableOutputStream
#if ENABLE_OVERLOADING
instance O.HasAttributeList PollableOutputStream
type instance O.AttributeList PollableOutputStream = PollableOutputStreamAttributeList
type PollableOutputStreamAttributeList = ('[ ] :: [(Symbol, *)])
#endif
#if ENABLE_OVERLOADING
#endif
#if ENABLE_OVERLOADING
type family ResolvePollableOutputStreamMethod (t :: Symbol) (o :: *) :: * where
ResolvePollableOutputStreamMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
ResolvePollableOutputStreamMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
ResolvePollableOutputStreamMethod "canPoll" o = PollableOutputStreamCanPollMethodInfo
ResolvePollableOutputStreamMethod "clearPending" o = Gio.OutputStream.OutputStreamClearPendingMethodInfo
ResolvePollableOutputStreamMethod "close" o = Gio.OutputStream.OutputStreamCloseMethodInfo
ResolvePollableOutputStreamMethod "closeAsync" o = Gio.OutputStream.OutputStreamCloseAsyncMethodInfo
ResolvePollableOutputStreamMethod "closeFinish" o = Gio.OutputStream.OutputStreamCloseFinishMethodInfo
ResolvePollableOutputStreamMethod "createSource" o = PollableOutputStreamCreateSourceMethodInfo
ResolvePollableOutputStreamMethod "flush" o = Gio.OutputStream.OutputStreamFlushMethodInfo
ResolvePollableOutputStreamMethod "flushAsync" o = Gio.OutputStream.OutputStreamFlushAsyncMethodInfo
ResolvePollableOutputStreamMethod "flushFinish" o = Gio.OutputStream.OutputStreamFlushFinishMethodInfo
ResolvePollableOutputStreamMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
ResolvePollableOutputStreamMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
ResolvePollableOutputStreamMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
ResolvePollableOutputStreamMethod "hasPending" o = Gio.OutputStream.OutputStreamHasPendingMethodInfo
ResolvePollableOutputStreamMethod "isClosed" o = Gio.OutputStream.OutputStreamIsClosedMethodInfo
ResolvePollableOutputStreamMethod "isClosing" o = Gio.OutputStream.OutputStreamIsClosingMethodInfo
ResolvePollableOutputStreamMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
ResolvePollableOutputStreamMethod "isWritable" o = PollableOutputStreamIsWritableMethodInfo
ResolvePollableOutputStreamMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
ResolvePollableOutputStreamMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
ResolvePollableOutputStreamMethod "ref" o = GObject.Object.ObjectRefMethodInfo
ResolvePollableOutputStreamMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
ResolvePollableOutputStreamMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
ResolvePollableOutputStreamMethod "splice" o = Gio.OutputStream.OutputStreamSpliceMethodInfo
ResolvePollableOutputStreamMethod "spliceAsync" o = Gio.OutputStream.OutputStreamSpliceAsyncMethodInfo
ResolvePollableOutputStreamMethod "spliceFinish" o = Gio.OutputStream.OutputStreamSpliceFinishMethodInfo
ResolvePollableOutputStreamMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
ResolvePollableOutputStreamMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
ResolvePollableOutputStreamMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
ResolvePollableOutputStreamMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
ResolvePollableOutputStreamMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
ResolvePollableOutputStreamMethod "write" o = Gio.OutputStream.OutputStreamWriteMethodInfo
ResolvePollableOutputStreamMethod "writeAll" o = Gio.OutputStream.OutputStreamWriteAllMethodInfo
ResolvePollableOutputStreamMethod "writeAllAsync" o = Gio.OutputStream.OutputStreamWriteAllAsyncMethodInfo
ResolvePollableOutputStreamMethod "writeAllFinish" o = Gio.OutputStream.OutputStreamWriteAllFinishMethodInfo
ResolvePollableOutputStreamMethod "writeAsync" o = Gio.OutputStream.OutputStreamWriteAsyncMethodInfo
ResolvePollableOutputStreamMethod "writeBytes" o = Gio.OutputStream.OutputStreamWriteBytesMethodInfo
ResolvePollableOutputStreamMethod "writeBytesAsync" o = Gio.OutputStream.OutputStreamWriteBytesAsyncMethodInfo
ResolvePollableOutputStreamMethod "writeBytesFinish" o = Gio.OutputStream.OutputStreamWriteBytesFinishMethodInfo
ResolvePollableOutputStreamMethod "writeFinish" o = Gio.OutputStream.OutputStreamWriteFinishMethodInfo
ResolvePollableOutputStreamMethod "writeNonblocking" o = PollableOutputStreamWriteNonblockingMethodInfo
ResolvePollableOutputStreamMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
ResolvePollableOutputStreamMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
ResolvePollableOutputStreamMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
ResolvePollableOutputStreamMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
ResolvePollableOutputStreamMethod "setPending" o = Gio.OutputStream.OutputStreamSetPendingMethodInfo
ResolvePollableOutputStreamMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
ResolvePollableOutputStreamMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolvePollableOutputStreamMethod t PollableOutputStream, O.MethodInfo info PollableOutputStream p) => O.IsLabelProxy t (PollableOutputStream -> p) where
fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolvePollableOutputStreamMethod t PollableOutputStream, O.MethodInfo info PollableOutputStream p) => O.IsLabel t (PollableOutputStream -> 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
#endif
foreign import ccall "g_pollable_output_stream_can_poll" g_pollable_output_stream_can_poll ::
Ptr PollableOutputStream ->
IO CInt
pollableOutputStreamCanPoll ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a) =>
a
-> m Bool
pollableOutputStreamCanPoll stream = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
result <- g_pollable_output_stream_can_poll stream'
let result' = (/= 0) result
touchManagedPtr stream
return result'
#if ENABLE_OVERLOADING
data PollableOutputStreamCanPollMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableOutputStream a) => O.MethodInfo PollableOutputStreamCanPollMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamCanPoll
#endif
foreign import ccall "g_pollable_output_stream_create_source" g_pollable_output_stream_create_source ::
Ptr PollableOutputStream ->
Ptr Gio.Cancellable.Cancellable ->
IO (Ptr GLib.Source.Source)
pollableOutputStreamCreateSource ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (b)
-> m GLib.Source.Source
pollableOutputStreamCreateSource stream cancellable = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
result <- g_pollable_output_stream_create_source stream' maybeCancellable
checkUnexpectedReturnNULL "pollableOutputStreamCreateSource" result
result' <- (wrapBoxed GLib.Source.Source) result
touchManagedPtr stream
whenJust cancellable touchManagedPtr
return result'
#if ENABLE_OVERLOADING
data PollableOutputStreamCreateSourceMethodInfo
instance (signature ~ (Maybe (b) -> m GLib.Source.Source), MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableOutputStreamCreateSourceMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamCreateSource
#endif
foreign import ccall "g_pollable_output_stream_is_writable" g_pollable_output_stream_is_writable ::
Ptr PollableOutputStream ->
IO CInt
pollableOutputStreamIsWritable ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a) =>
a
-> m Bool
pollableOutputStreamIsWritable stream = liftIO $ do
stream' <- unsafeManagedPtrCastPtr stream
result <- g_pollable_output_stream_is_writable stream'
let result' = (/= 0) result
touchManagedPtr stream
return result'
#if ENABLE_OVERLOADING
data PollableOutputStreamIsWritableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableOutputStream a) => O.MethodInfo PollableOutputStreamIsWritableMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamIsWritable
#endif
foreign import ccall "g_pollable_output_stream_write_nonblocking" g_pollable_output_stream_write_nonblocking ::
Ptr PollableOutputStream ->
Ptr Word8 ->
Word64 ->
Ptr Gio.Cancellable.Cancellable ->
Ptr (Ptr GError) ->
IO Int64
pollableOutputStreamWriteNonblocking ::
(B.CallStack.HasCallStack, MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) =>
a
-> Maybe (ByteString)
-> Maybe (b)
-> m Int64
pollableOutputStreamWriteNonblocking stream buffer cancellable = liftIO $ do
let count = case buffer of
Nothing -> 0
Just jBuffer -> fromIntegral $ B.length jBuffer
stream' <- unsafeManagedPtrCastPtr stream
maybeBuffer <- case buffer of
Nothing -> return nullPtr
Just jBuffer -> do
jBuffer' <- packByteString jBuffer
return jBuffer'
maybeCancellable <- case cancellable of
Nothing -> return nullPtr
Just jCancellable -> do
jCancellable' <- unsafeManagedPtrCastPtr jCancellable
return jCancellable'
onException (do
result <- propagateGError $ g_pollable_output_stream_write_nonblocking stream' maybeBuffer count maybeCancellable
touchManagedPtr stream
whenJust cancellable touchManagedPtr
freeMem maybeBuffer
return result
) (do
freeMem maybeBuffer
)
#if ENABLE_OVERLOADING
data PollableOutputStreamWriteNonblockingMethodInfo
instance (signature ~ (Maybe (ByteString) -> Maybe (b) -> m Int64), MonadIO m, IsPollableOutputStream a, Gio.Cancellable.IsCancellable b) => O.MethodInfo PollableOutputStreamWriteNonblockingMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamWriteNonblocking
#endif