{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

This object represents a single plugin, found by WebKitGTK+ while
scanning the various usual directories. This object can be used to
get more information about a plugin, and enable\/disable it,
allowing fine-grained control of plugins. The list of available
plugins can be obtained from the 'GI.WebKit.Objects.WebPluginDatabase.WebPluginDatabase' object.
-}

module GI.WebKit.Objects.WebPlugin
    ( 

-- * Exported types
    WebPlugin(..)                           ,
    IsWebPlugin                             ,
    toWebPlugin                             ,
    noWebPlugin                             ,


 -- * Methods
-- ** getDescription #method:getDescription#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    WebPluginGetDescriptionMethodInfo       ,
#endif
    webPluginGetDescription                 ,


-- ** getEnabled #method:getEnabled#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    WebPluginGetEnabledMethodInfo           ,
#endif
    webPluginGetEnabled                     ,


-- ** getName #method:getName#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    WebPluginGetNameMethodInfo              ,
#endif
    webPluginGetName                        ,


-- ** getPath #method:getPath#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    WebPluginGetPathMethodInfo              ,
#endif
    webPluginGetPath                        ,


-- ** setEnabled #method:setEnabled#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    WebPluginSetEnabledMethodInfo           ,
#endif
    webPluginSetEnabled                     ,




 -- * Properties
-- ** enabled #attr:enabled#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    WebPluginEnabledPropertyInfo            ,
#endif
    constructWebPluginEnabled               ,
    getWebPluginEnabled                     ,
    setWebPluginEnabled                     ,
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    webPluginEnabled                        ,
#endif




    ) 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 WebPlugin = WebPlugin (ManagedPtr WebPlugin)
foreign import ccall "webkit_web_plugin_get_type"
    c_webkit_web_plugin_get_type :: IO GType

instance GObject WebPlugin where
    gobjectType _ = c_webkit_web_plugin_get_type
    

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

toWebPlugin :: (MonadIO m, IsWebPlugin o) => o -> m WebPlugin
toWebPlugin = liftIO . unsafeCastTo WebPlugin

noWebPlugin :: Maybe WebPlugin
noWebPlugin = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveWebPluginMethod (t :: Symbol) (o :: *) :: * where
    ResolveWebPluginMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveWebPluginMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveWebPluginMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveWebPluginMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveWebPluginMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveWebPluginMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveWebPluginMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveWebPluginMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveWebPluginMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveWebPluginMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveWebPluginMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveWebPluginMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveWebPluginMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveWebPluginMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveWebPluginMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveWebPluginMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveWebPluginMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveWebPluginMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveWebPluginMethod "getDescription" o = WebPluginGetDescriptionMethodInfo
    ResolveWebPluginMethod "getEnabled" o = WebPluginGetEnabledMethodInfo
    ResolveWebPluginMethod "getName" o = WebPluginGetNameMethodInfo
    ResolveWebPluginMethod "getPath" o = WebPluginGetPathMethodInfo
    ResolveWebPluginMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveWebPluginMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveWebPluginMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveWebPluginMethod "setEnabled" o = WebPluginSetEnabledMethodInfo
    ResolveWebPluginMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveWebPluginMethod l o = O.MethodResolutionFailed l o

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

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveWebPluginMethod t WebPlugin, O.MethodInfo info WebPlugin p) => O.IsLabel t (WebPlugin -> 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

-- VVV Prop "enabled"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Just False,Just False)

getWebPluginEnabled :: (MonadIO m, IsWebPlugin o) => o -> m Bool
getWebPluginEnabled obj = liftIO $ getObjectPropertyBool obj "enabled"

setWebPluginEnabled :: (MonadIO m, IsWebPlugin o) => o -> Bool -> m ()
setWebPluginEnabled obj val = liftIO $ setObjectPropertyBool obj "enabled" val

constructWebPluginEnabled :: (IsWebPlugin o) => Bool -> IO (GValueConstruct o)
constructWebPluginEnabled val = constructObjectPropertyBool "enabled" val

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data WebPluginEnabledPropertyInfo
instance AttrInfo WebPluginEnabledPropertyInfo where
    type AttrAllowedOps WebPluginEnabledPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint WebPluginEnabledPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint WebPluginEnabledPropertyInfo = IsWebPlugin
    type AttrGetType WebPluginEnabledPropertyInfo = Bool
    type AttrLabel WebPluginEnabledPropertyInfo = "enabled"
    type AttrOrigin WebPluginEnabledPropertyInfo = WebPlugin
    attrGet _ = getWebPluginEnabled
    attrSet _ = setWebPluginEnabled
    attrConstruct _ = constructWebPluginEnabled
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList WebPlugin
type instance O.AttributeList WebPlugin = WebPluginAttributeList
type WebPluginAttributeList = ('[ '("enabled", WebPluginEnabledPropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
webPluginEnabled :: AttrLabelProxy "enabled"
webPluginEnabled = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList WebPlugin = WebPluginSignalList
type WebPluginSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method WebPlugin::get_description
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "WebKit", name = "WebPlugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPlugin", 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_web_plugin_get_description" webkit_web_plugin_get_description :: 
    Ptr WebPlugin ->                        -- plugin : TInterface (Name {namespace = "WebKit", name = "WebPlugin"})
    IO CString

{- |
/No description available in the introspection data./

@since 1.3.8
-}
webPluginGetDescription ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPlugin a) =>
    a
    {- ^ /@plugin@/: a 'GI.WebKit.Objects.WebPlugin.WebPlugin' -}
    -> m T.Text
    {- ^ __Returns:__ the description string for /@plugin@/. -}
webPluginGetDescription plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- webkit_web_plugin_get_description plugin'
    checkUnexpectedReturnNULL "webPluginGetDescription" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data WebPluginGetDescriptionMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsWebPlugin a) => O.MethodInfo WebPluginGetDescriptionMethodInfo a signature where
    overloadedMethod _ = webPluginGetDescription

#endif

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

foreign import ccall "webkit_web_plugin_get_enabled" webkit_web_plugin_get_enabled :: 
    Ptr WebPlugin ->                        -- plugin : TInterface (Name {namespace = "WebKit", name = "WebPlugin"})
    IO CInt

{- |
/No description available in the introspection data./

@since 1.3.8
-}
webPluginGetEnabled ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPlugin a) =>
    a
    {- ^ /@plugin@/: a 'GI.WebKit.Objects.WebPlugin.WebPlugin' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the plugin is enabled, 'False' otherwise -}
webPluginGetEnabled plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- webkit_web_plugin_get_enabled plugin'
    let result' = (/= 0) result
    touchManagedPtr plugin
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data WebPluginGetEnabledMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsWebPlugin a) => O.MethodInfo WebPluginGetEnabledMethodInfo a signature where
    overloadedMethod _ = webPluginGetEnabled

#endif

-- method WebPlugin::get_name
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "WebKit", name = "WebPlugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPlugin", 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_web_plugin_get_name" webkit_web_plugin_get_name :: 
    Ptr WebPlugin ->                        -- plugin : TInterface (Name {namespace = "WebKit", name = "WebPlugin"})
    IO CString

{- |
/No description available in the introspection data./

@since 1.3.8
-}
webPluginGetName ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPlugin a) =>
    a
    {- ^ /@plugin@/: a 'GI.WebKit.Objects.WebPlugin.WebPlugin' -}
    -> m T.Text
    {- ^ __Returns:__ the name string for /@plugin@/. -}
webPluginGetName plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- webkit_web_plugin_get_name plugin'
    checkUnexpectedReturnNULL "webPluginGetName" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data WebPluginGetNameMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsWebPlugin a) => O.MethodInfo WebPluginGetNameMethodInfo a signature where
    overloadedMethod _ = webPluginGetName

#endif

-- method WebPlugin::get_path
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "WebKit", name = "WebPlugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPlugin", 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_web_plugin_get_path" webkit_web_plugin_get_path :: 
    Ptr WebPlugin ->                        -- plugin : TInterface (Name {namespace = "WebKit", name = "WebPlugin"})
    IO CString

{- |
/No description available in the introspection data./

@since 1.4.0
-}
webPluginGetPath ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPlugin a) =>
    a
    {- ^ /@plugin@/: a 'GI.WebKit.Objects.WebPlugin.WebPlugin' -}
    -> m T.Text
    {- ^ __Returns:__ the absolute path to /@plugin@/ in system filename encoding
or 'Nothing' on failure to convert the filename from UTF-8. -}
webPluginGetPath plugin = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    result <- webkit_web_plugin_get_path plugin'
    checkUnexpectedReturnNULL "webPluginGetPath" result
    result' <- cstringToText result
    touchManagedPtr plugin
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data WebPluginGetPathMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsWebPlugin a) => O.MethodInfo WebPluginGetPathMethodInfo a signature where
    overloadedMethod _ = webPluginGetPath

#endif

-- method WebPlugin::set_enabled
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "plugin", argType = TInterface (Name {namespace = "WebKit", name = "WebPlugin"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #WebKitWebPlugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "enabled", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "whether to enable the plugin", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "webkit_web_plugin_set_enabled" webkit_web_plugin_set_enabled :: 
    Ptr WebPlugin ->                        -- plugin : TInterface (Name {namespace = "WebKit", name = "WebPlugin"})
    CInt ->                                 -- enabled : TBasicType TBoolean
    IO ()

{- |
Sets the enabled status of the /@plugin@/.

@since 1.3.8
-}
webPluginSetEnabled ::
    (B.CallStack.HasCallStack, MonadIO m, IsWebPlugin a) =>
    a
    {- ^ /@plugin@/: a 'GI.WebKit.Objects.WebPlugin.WebPlugin' -}
    -> Bool
    {- ^ /@enabled@/: whether to enable the plugin -}
    -> m ()
webPluginSetEnabled plugin enabled = liftIO $ do
    plugin' <- unsafeManagedPtrCastPtr plugin
    let enabled' = (fromIntegral . fromEnum) enabled
    webkit_web_plugin_set_enabled plugin' enabled'
    touchManagedPtr plugin
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data WebPluginSetEnabledMethodInfo
instance (signature ~ (Bool -> m ()), MonadIO m, IsWebPlugin a) => O.MethodInfo WebPluginSetEnabledMethodInfo a signature where
    overloadedMethod _ = webPluginSetEnabled

#endif