-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.WebKit2.Functions
    ( 

 -- * Methods
-- ** getMajorVersion #method:getMajorVersion#

    getMajorVersion                         ,


-- ** getMicroVersion #method:getMicroVersion#

    getMicroVersion                         ,


-- ** getMinorVersion #method:getMinorVersion#

    getMinorVersion                         ,


-- ** uriForDisplay #method:uriForDisplay#

    uriForDisplay                           ,


-- ** userMediaPermissionIsForAudioDevice #method:userMediaPermissionIsForAudioDevice#

    userMediaPermissionIsForAudioDevice     ,


-- ** userMediaPermissionIsForVideoDevice #method:userMediaPermissionIsForVideoDevice#

    userMediaPermissionIsForVideoDevice     ,




    ) 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.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
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 GHC.OverloadedLabels as OL

import {-# SOURCE #-} qualified GI.WebKit2.Objects.UserMediaPermissionRequest as WebKit2.UserMediaPermissionRequest

-- function webkit_user_media_permission_is_for_video_device
-- Args: [ Arg
--           { argCName = "request"
--           , argType =
--               TInterface
--                 Name
--                   { namespace = "WebKit2" , name = "UserMediaPermissionRequest" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitUserMediaPermissionRequest"
--                 , 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_user_media_permission_is_for_video_device" webkit_user_media_permission_is_for_video_device :: 
    Ptr WebKit2.UserMediaPermissionRequest.UserMediaPermissionRequest -> -- request : TInterface (Name {namespace = "WebKit2", name = "UserMediaPermissionRequest"})
    IO CInt

-- | /No description available in the introspection data./
-- 
-- /Since: 2.8/
userMediaPermissionIsForVideoDevice ::
    (B.CallStack.HasCallStack, MonadIO m, WebKit2.UserMediaPermissionRequest.IsUserMediaPermissionRequest a) =>
    a
    -- ^ /@request@/: a t'GI.WebKit2.Objects.UserMediaPermissionRequest.UserMediaPermissionRequest'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if access to a video device was requested.
userMediaPermissionIsForVideoDevice :: a -> m Bool
userMediaPermissionIsForVideoDevice request :: a
request = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr UserMediaPermissionRequest
request' <- a -> IO (Ptr UserMediaPermissionRequest)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    CInt
result <- Ptr UserMediaPermissionRequest -> IO CInt
webkit_user_media_permission_is_for_video_device Ptr UserMediaPermissionRequest
request'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function webkit_user_media_permission_is_for_audio_device
-- Args: [ Arg
--           { argCName = "request"
--           , argType =
--               TInterface
--                 Name
--                   { namespace = "WebKit2" , name = "UserMediaPermissionRequest" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #WebKitUserMediaPermissionRequest"
--                 , 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_user_media_permission_is_for_audio_device" webkit_user_media_permission_is_for_audio_device :: 
    Ptr WebKit2.UserMediaPermissionRequest.UserMediaPermissionRequest -> -- request : TInterface (Name {namespace = "WebKit2", name = "UserMediaPermissionRequest"})
    IO CInt

-- | /No description available in the introspection data./
-- 
-- /Since: 2.8/
userMediaPermissionIsForAudioDevice ::
    (B.CallStack.HasCallStack, MonadIO m, WebKit2.UserMediaPermissionRequest.IsUserMediaPermissionRequest a) =>
    a
    -- ^ /@request@/: a t'GI.WebKit2.Objects.UserMediaPermissionRequest.UserMediaPermissionRequest'
    -> m Bool
    -- ^ __Returns:__ 'P.True' if access to an audio device was requested.
userMediaPermissionIsForAudioDevice :: a -> m Bool
userMediaPermissionIsForAudioDevice request :: a
request = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr UserMediaPermissionRequest
request' <- a -> IO (Ptr UserMediaPermissionRequest)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
request
    CInt
result <- Ptr UserMediaPermissionRequest -> IO CInt
webkit_user_media_permission_is_for_audio_device Ptr UserMediaPermissionRequest
request'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
request
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function webkit_uri_for_display
-- Args: [ Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the URI to be converted"
--                 , 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_uri_for_display" webkit_uri_for_display :: 
    CString ->                              -- uri : TBasicType TUTF8
    IO CString

-- | Use this function to format a URI for display. The URIs used internally by
-- WebKit may contain percent-encoded characters or Punycode, which are not
-- generally suitable to display to users. This function provides protection
-- against IDN homograph attacks, so in some cases the host part of the returned
-- URI may be in Punycode if the safety check fails.
-- 
-- /Since: 2.24/
uriForDisplay ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@uri@/: the URI to be converted
    -> m (Maybe T.Text)
    -- ^ __Returns:__ /@uri@/ suitable for display, or 'P.Nothing' in
    --    case of error.
uriForDisplay :: Text -> m (Maybe Text)
uriForDisplay uri :: Text
uri = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    CString
result <- CString -> IO CString
webkit_uri_for_display CString
uri'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- function webkit_get_minor_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_get_minor_version" webkit_get_minor_version :: 
    IO Word32

-- | Returns the minor version number of the WebKit library.
-- (e.g. in WebKit version 1.8.3 this is 8.)
-- 
-- This function is in the library, so it represents the WebKit library
-- your code is running against. Contrast with the 'GI.WebKit2.Constants.MINOR_VERSION'
-- macro, which represents the minor version of the WebKit headers you
-- have included when compiling your code.
getMinorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the minor version number of the WebKit library
getMinorVersion :: m Word32
getMinorVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
webkit_get_minor_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function webkit_get_micro_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_get_micro_version" webkit_get_micro_version :: 
    IO Word32

-- | Returns the micro version number of the WebKit library.
-- (e.g. in WebKit version 1.8.3 this is 3.)
-- 
-- This function is in the library, so it represents the WebKit library
-- your code is running against. Contrast with the 'GI.WebKit2.Constants.MICRO_VERSION'
-- macro, which represents the micro version of the WebKit headers you
-- have included when compiling your code.
getMicroVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the micro version number of the WebKit library
getMicroVersion :: m Word32
getMicroVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
webkit_get_micro_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function webkit_get_major_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "webkit_get_major_version" webkit_get_major_version :: 
    IO Word32

-- | Returns the major version number of the WebKit library.
-- (e.g. in WebKit version 1.8.3 this is 1.)
-- 
-- This function is in the library, so it represents the WebKit library
-- your code is running against. Contrast with the 'GI.WebKit2.Constants.MAJOR_VERSION'
-- macro, which represents the major version of the WebKit headers you
-- have included when compiling your code.
getMajorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the major version number of the WebKit library
getMajorVersion :: m Word32
getMajorVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
webkit_get_major_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result