module GI.Gio.Interfaces.PollableOutputStream
(
PollableOutputStream(..) ,
noPollableOutputStream ,
IsPollableOutputStream ,
toPollableOutputStream ,
PollableOutputStreamCanPollMethodInfo ,
pollableOutputStreamCanPoll ,
PollableOutputStreamCreateSourceMethodInfo,
pollableOutputStreamCreateSource ,
PollableOutputStreamIsWritableMethodInfo,
pollableOutputStreamIsWritable ,
PollableOutputStreamWriteNonblockingMethodInfo,
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.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 qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Gio.Objects.OutputStream as Gio.OutputStream
newtype PollableOutputStream = PollableOutputStream (ManagedPtr PollableOutputStream)
noPollableOutputStream :: Maybe PollableOutputStream
noPollableOutputStream = Nothing
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 "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 "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
ResolvePollableOutputStreamMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
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
fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
instance O.HasAttributeList PollableOutputStream
type instance O.AttributeList PollableOutputStream = PollableOutputStreamAttributeList
type PollableOutputStreamAttributeList = ('[ ] :: [(Symbol, *)])
type instance O.SignalList PollableOutputStream = PollableOutputStreamSignalList
type PollableOutputStreamSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])
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 (GObject a, O.UnknownAncestorError PollableOutputStream a) =>
IsPollableOutputStream a
#endif
instance IsPollableOutputStream PollableOutputStream
instance Gio.OutputStream.IsOutputStream PollableOutputStream
instance GObject.Object.IsObject PollableOutputStream
toPollableOutputStream :: IsPollableOutputStream o => o -> IO PollableOutputStream
toPollableOutputStream = unsafeCastTo PollableOutputStream
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'
data PollableOutputStreamCanPollMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableOutputStream a) => O.MethodInfo PollableOutputStreamCanPollMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamCanPoll
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'
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
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'
data PollableOutputStreamIsWritableMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsPollableOutputStream a) => O.MethodInfo PollableOutputStreamIsWritableMethodInfo a signature where
overloadedMethod _ = pollableOutputStreamIsWritable
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
)
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