{- |
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.WebKit2.Objects.Notification
    ( 

-- * Exported types
    Notification(..)                        ,
    IsNotification                          ,
    toNotification                          ,
    noNotification                          ,


 -- * Methods
-- ** clicked #method:clicked#
    NotificationClickedMethodInfo           ,
    notificationClicked                     ,


-- ** close #method:close#
    NotificationCloseMethodInfo             ,
    notificationClose                       ,


-- ** getBody #method:getBody#
    NotificationGetBodyMethodInfo           ,
    notificationGetBody                     ,


-- ** getId #method:getId#
    NotificationGetIdMethodInfo             ,
    notificationGetId                       ,


-- ** getTitle #method:getTitle#
    NotificationGetTitleMethodInfo          ,
    notificationGetTitle                    ,




 -- * Properties
-- ** body #attr:body#
    NotificationBodyPropertyInfo            ,
    getNotificationBody                     ,
    notificationBody                        ,


-- ** id #attr:id#
    NotificationIdPropertyInfo              ,
    getNotificationId                       ,
    notificationId                          ,


-- ** title #attr:title#
    NotificationTitlePropertyInfo           ,
    getNotificationTitle                    ,
    notificationTitle                       ,




 -- * Signals
-- ** clicked #signal:clicked#
    C_NotificationClickedCallback           ,
    NotificationClickedCallback             ,
    NotificationClickedSignalInfo           ,
    afterNotificationClicked                ,
    genClosure_NotificationClicked          ,
    mk_NotificationClickedCallback          ,
    noNotificationClickedCallback           ,
    onNotificationClicked                   ,
    wrap_NotificationClickedCallback        ,


-- ** closed #signal:closed#
    C_NotificationClosedCallback            ,
    NotificationClosedCallback              ,
    NotificationClosedSignalInfo            ,
    afterNotificationClosed                 ,
    genClosure_NotificationClosed           ,
    mk_NotificationClosedCallback           ,
    noNotificationClosedCallback            ,
    onNotificationClosed                    ,
    wrap_NotificationClosedCallback         ,




    ) 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.GObject.Objects.Object as GObject.Object

newtype Notification = Notification (ManagedPtr Notification)
foreign import ccall "webkit_notification_get_type"
    c_webkit_notification_get_type :: IO GType

instance GObject Notification where
    gobjectType _ = c_webkit_notification_get_type
    

class GObject o => IsNotification o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Notification a) =>
    IsNotification a
#endif
instance IsNotification Notification
instance GObject.Object.IsObject Notification

toNotification :: IsNotification o => o -> IO Notification
toNotification = unsafeCastTo Notification

noNotification :: Maybe Notification
noNotification = Nothing

type family ResolveNotificationMethod (t :: Symbol) (o :: *) :: * where
    ResolveNotificationMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveNotificationMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveNotificationMethod "clicked" o = NotificationClickedMethodInfo
    ResolveNotificationMethod "close" o = NotificationCloseMethodInfo
    ResolveNotificationMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveNotificationMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveNotificationMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveNotificationMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveNotificationMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveNotificationMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveNotificationMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveNotificationMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveNotificationMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveNotificationMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveNotificationMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveNotificationMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveNotificationMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveNotificationMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveNotificationMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveNotificationMethod "getBody" o = NotificationGetBodyMethodInfo
    ResolveNotificationMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveNotificationMethod "getId" o = NotificationGetIdMethodInfo
    ResolveNotificationMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveNotificationMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveNotificationMethod "getTitle" o = NotificationGetTitleMethodInfo
    ResolveNotificationMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveNotificationMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveNotificationMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveNotificationMethod t Notification, O.MethodInfo info Notification p) => O.IsLabelProxy t (Notification -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveNotificationMethod t Notification, O.MethodInfo info Notification p) => O.IsLabel t (Notification -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal Notification::clicked
type NotificationClickedCallback =
    IO ()

noNotificationClickedCallback :: Maybe NotificationClickedCallback
noNotificationClickedCallback = Nothing

type C_NotificationClickedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_NotificationClickedCallback :: C_NotificationClickedCallback -> IO (FunPtr C_NotificationClickedCallback)

genClosure_NotificationClicked :: NotificationClickedCallback -> IO Closure
genClosure_NotificationClicked cb = do
    let cb' = wrap_NotificationClickedCallback cb
    mk_NotificationClickedCallback cb' >>= newCClosure


wrap_NotificationClickedCallback ::
    NotificationClickedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_NotificationClickedCallback _cb _ _ = do
    _cb 


onNotificationClicked :: (GObject a, MonadIO m) => a -> NotificationClickedCallback -> m SignalHandlerId
onNotificationClicked obj cb = liftIO $ connectNotificationClicked obj cb SignalConnectBefore
afterNotificationClicked :: (GObject a, MonadIO m) => a -> NotificationClickedCallback -> m SignalHandlerId
afterNotificationClicked obj cb = connectNotificationClicked obj cb SignalConnectAfter

connectNotificationClicked :: (GObject a, MonadIO m) =>
                              a -> NotificationClickedCallback -> SignalConnectMode -> m SignalHandlerId
connectNotificationClicked obj cb after = liftIO $ do
    let cb' = wrap_NotificationClickedCallback cb
    cb'' <- mk_NotificationClickedCallback cb'
    connectSignalFunPtr obj "clicked" cb'' after

-- signal Notification::closed
type NotificationClosedCallback =
    IO ()

noNotificationClosedCallback :: Maybe NotificationClosedCallback
noNotificationClosedCallback = Nothing

type C_NotificationClosedCallback =
    Ptr () ->                               -- object
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_NotificationClosedCallback :: C_NotificationClosedCallback -> IO (FunPtr C_NotificationClosedCallback)

genClosure_NotificationClosed :: NotificationClosedCallback -> IO Closure
genClosure_NotificationClosed cb = do
    let cb' = wrap_NotificationClosedCallback cb
    mk_NotificationClosedCallback cb' >>= newCClosure


wrap_NotificationClosedCallback ::
    NotificationClosedCallback ->
    Ptr () ->
    Ptr () ->
    IO ()
wrap_NotificationClosedCallback _cb _ _ = do
    _cb 


onNotificationClosed :: (GObject a, MonadIO m) => a -> NotificationClosedCallback -> m SignalHandlerId
onNotificationClosed obj cb = liftIO $ connectNotificationClosed obj cb SignalConnectBefore
afterNotificationClosed :: (GObject a, MonadIO m) => a -> NotificationClosedCallback -> m SignalHandlerId
afterNotificationClosed obj cb = connectNotificationClosed obj cb SignalConnectAfter

connectNotificationClosed :: (GObject a, MonadIO m) =>
                             a -> NotificationClosedCallback -> SignalConnectMode -> m SignalHandlerId
connectNotificationClosed obj cb after = liftIO $ do
    let cb' = wrap_NotificationClosedCallback cb
    cb'' <- mk_NotificationClosedCallback cb'
    connectSignalFunPtr obj "closed" cb'' after

-- VVV Prop "body"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getNotificationBody :: (MonadIO m, IsNotification o) => o -> m T.Text
getNotificationBody obj = liftIO $ checkUnexpectedNothing "getNotificationBody" $ getObjectPropertyString obj "body"

data NotificationBodyPropertyInfo
instance AttrInfo NotificationBodyPropertyInfo where
    type AttrAllowedOps NotificationBodyPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint NotificationBodyPropertyInfo = (~) ()
    type AttrBaseTypeConstraint NotificationBodyPropertyInfo = IsNotification
    type AttrGetType NotificationBodyPropertyInfo = T.Text
    type AttrLabel NotificationBodyPropertyInfo = "body"
    type AttrOrigin NotificationBodyPropertyInfo = Notification
    attrGet _ = getNotificationBody
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "id"
   -- Type: TBasicType TUInt64
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getNotificationId :: (MonadIO m, IsNotification o) => o -> m Word64
getNotificationId obj = liftIO $ getObjectPropertyUInt64 obj "id"

data NotificationIdPropertyInfo
instance AttrInfo NotificationIdPropertyInfo where
    type AttrAllowedOps NotificationIdPropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint NotificationIdPropertyInfo = (~) ()
    type AttrBaseTypeConstraint NotificationIdPropertyInfo = IsNotification
    type AttrGetType NotificationIdPropertyInfo = Word64
    type AttrLabel NotificationIdPropertyInfo = "id"
    type AttrOrigin NotificationIdPropertyInfo = Notification
    attrGet _ = getNotificationId
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

-- VVV Prop "title"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getNotificationTitle :: (MonadIO m, IsNotification o) => o -> m T.Text
getNotificationTitle obj = liftIO $ checkUnexpectedNothing "getNotificationTitle" $ getObjectPropertyString obj "title"

data NotificationTitlePropertyInfo
instance AttrInfo NotificationTitlePropertyInfo where
    type AttrAllowedOps NotificationTitlePropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint NotificationTitlePropertyInfo = (~) ()
    type AttrBaseTypeConstraint NotificationTitlePropertyInfo = IsNotification
    type AttrGetType NotificationTitlePropertyInfo = T.Text
    type AttrLabel NotificationTitlePropertyInfo = "title"
    type AttrOrigin NotificationTitlePropertyInfo = Notification
    attrGet _ = getNotificationTitle
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined

instance O.HasAttributeList Notification
type instance O.AttributeList Notification = NotificationAttributeList
type NotificationAttributeList = ('[ '("body", NotificationBodyPropertyInfo), '("id", NotificationIdPropertyInfo), '("title", NotificationTitlePropertyInfo)] :: [(Symbol, *)])

notificationBody :: AttrLabelProxy "body"
notificationBody = AttrLabelProxy

notificationId :: AttrLabelProxy "id"
notificationId = AttrLabelProxy

notificationTitle :: AttrLabelProxy "title"
notificationTitle = AttrLabelProxy

data NotificationClickedSignalInfo
instance SignalInfo NotificationClickedSignalInfo where
    type HaskellCallbackType NotificationClickedSignalInfo = NotificationClickedCallback
    connectSignal _ = connectNotificationClicked

data NotificationClosedSignalInfo
instance SignalInfo NotificationClosedSignalInfo where
    type HaskellCallbackType NotificationClosedSignalInfo = NotificationClosedCallback
    connectSignal _ = connectNotificationClosed

type instance O.SignalList Notification = NotificationSignalList
type NotificationSignalList = ('[ '("clicked", NotificationClickedSignalInfo), '("closed", NotificationClosedSignalInfo), '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

-- method Notification::clicked
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "notification", argType = TInterface (Name {namespace = "WebKit2", name = "Notification"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNotification", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_notification_clicked" webkit_notification_clicked :: 
    Ptr Notification ->                     -- notification : TInterface (Name {namespace = "WebKit2", name = "Notification"})
    IO ()

{- |
Tells WebKit the notification has been clicked. This will emit the
'GI.WebKit2.Objects.Notification.Notification'::@/clicked/@ signal.

@since 2.12
-}
notificationClicked ::
    (B.CallStack.HasCallStack, MonadIO m, IsNotification a) =>
    a
    {- ^ /@notification@/: a 'GI.WebKit2.Objects.Notification.Notification' -}
    -> m ()
notificationClicked notification = liftIO $ do
    notification' <- unsafeManagedPtrCastPtr notification
    webkit_notification_clicked notification'
    touchManagedPtr notification
    return ()

data NotificationClickedMethodInfo
instance (signature ~ (m ()), MonadIO m, IsNotification a) => O.MethodInfo NotificationClickedMethodInfo a signature where
    overloadedMethod _ = notificationClicked

-- method Notification::close
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "notification", argType = TInterface (Name {namespace = "WebKit2", name = "Notification"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNotification", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_notification_close" webkit_notification_close :: 
    Ptr Notification ->                     -- notification : TInterface (Name {namespace = "WebKit2", name = "Notification"})
    IO ()

{- |
Closes the notification.

@since 2.8
-}
notificationClose ::
    (B.CallStack.HasCallStack, MonadIO m, IsNotification a) =>
    a
    {- ^ /@notification@/: a 'GI.WebKit2.Objects.Notification.Notification' -}
    -> m ()
notificationClose notification = liftIO $ do
    notification' <- unsafeManagedPtrCastPtr notification
    webkit_notification_close notification'
    touchManagedPtr notification
    return ()

data NotificationCloseMethodInfo
instance (signature ~ (m ()), MonadIO m, IsNotification a) => O.MethodInfo NotificationCloseMethodInfo a signature where
    overloadedMethod _ = notificationClose

-- method Notification::get_body
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "notification", argType = TInterface (Name {namespace = "WebKit2", name = "Notification"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNotification", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_notification_get_body" webkit_notification_get_body :: 
    Ptr Notification ->                     -- notification : TInterface (Name {namespace = "WebKit2", name = "Notification"})
    IO CString

{- |
Obtains the body for the notification.

@since 2.8
-}
notificationGetBody ::
    (B.CallStack.HasCallStack, MonadIO m, IsNotification a) =>
    a
    {- ^ /@notification@/: a 'GI.WebKit2.Objects.Notification.Notification' -}
    -> m T.Text
    {- ^ __Returns:__ the body for the notification -}
notificationGetBody notification = liftIO $ do
    notification' <- unsafeManagedPtrCastPtr notification
    result <- webkit_notification_get_body notification'
    checkUnexpectedReturnNULL "notificationGetBody" result
    result' <- cstringToText result
    touchManagedPtr notification
    return result'

data NotificationGetBodyMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsNotification a) => O.MethodInfo NotificationGetBodyMethodInfo a signature where
    overloadedMethod _ = notificationGetBody

-- method Notification::get_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "notification", argType = TInterface (Name {namespace = "WebKit2", name = "Notification"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNotification", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt64)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_notification_get_id" webkit_notification_get_id :: 
    Ptr Notification ->                     -- notification : TInterface (Name {namespace = "WebKit2", name = "Notification"})
    IO Word64

{- |
Obtains the unique id for the notification.

@since 2.8
-}
notificationGetId ::
    (B.CallStack.HasCallStack, MonadIO m, IsNotification a) =>
    a
    {- ^ /@notification@/: a 'GI.WebKit2.Objects.Notification.Notification' -}
    -> m Word64
    {- ^ __Returns:__ the unique id for the notification -}
notificationGetId notification = liftIO $ do
    notification' <- unsafeManagedPtrCastPtr notification
    result <- webkit_notification_get_id notification'
    touchManagedPtr notification
    return result

data NotificationGetIdMethodInfo
instance (signature ~ (m Word64), MonadIO m, IsNotification a) => O.MethodInfo NotificationGetIdMethodInfo a signature where
    overloadedMethod _ = notificationGetId

-- method Notification::get_title
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "notification", argType = TInterface (Name {namespace = "WebKit2", name = "Notification"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitNotification", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_notification_get_title" webkit_notification_get_title :: 
    Ptr Notification ->                     -- notification : TInterface (Name {namespace = "WebKit2", name = "Notification"})
    IO CString

{- |
Obtains the title for the notification.

@since 2.8
-}
notificationGetTitle ::
    (B.CallStack.HasCallStack, MonadIO m, IsNotification a) =>
    a
    {- ^ /@notification@/: a 'GI.WebKit2.Objects.Notification.Notification' -}
    -> m T.Text
    {- ^ __Returns:__ the title for the notification -}
notificationGetTitle notification = liftIO $ do
    notification' <- unsafeManagedPtrCastPtr notification
    result <- webkit_notification_get_title notification'
    checkUnexpectedReturnNULL "notificationGetTitle" result
    result' <- cstringToText result
    touchManagedPtr notification
    return result'

data NotificationGetTitleMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsNotification a) => O.MethodInfo NotificationGetTitleMethodInfo a signature where
    overloadedMethod _ = notificationGetTitle