-- GENERATED by C->Haskell Compiler, version 0.13.11 (gtk2hs branch) "Bin IO", 27 May 2012 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
--  GIMP Toolkit (GTK) Binding for Haskell: binding to gstreamer -*-haskell-*-
--
--  Author : Peter Gavin
--  Created: 1-Apr-2007
--
--  Copyright (c) 2007 Peter Gavin
--
--  This library is free software: you can redistribute it and/or
--  modify it under the terms of the GNU Lesser General Public License
--  as published by the Free Software Foundation, either version 3 of
--  the License, or (at your option) any later version.
--  
--  This library is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
--  Lesser General Public License for more details.
--  
--  You should have received a copy of the GNU Lesser General Public
--  License along with this program.  If not, see
--  <http://www.gnu.org/licenses/>.
--  
--  GStreamer, the C library which this Haskell library depends on, is
--  available under LGPL Version 2. The documentation included with
--  this library is based on the original GStreamer documentation.
--  
-- | Maintainer  : gtk2hs-devel@lists.sourceforge.net
--   Stability   : alpha
--   Portability : portable (depends on GHC)
module Media.Streaming.GStreamer.Core.Registry (
  
  Registry,
  RegistryClass,
  castToRegistry,
  gTypeRegistry,

  defaultRegistry,
  registryGetFeatureList,
  registryGetFeatureListByPlugin,
  registryGetPathList,
  registryGetPluginList,
  registryAddPlugin,
  registryRemovePlugin,
  registryPluginFilter,
  registryFeatureFilter,
  registryFindPlugin,
  registryFindFeature,
  registryLookupFeature,
  registryScanPath,
  registryXMLReadCache,
  registryXMLWriteCache,
  registryLookup,
  registryRemoveFeature,
  registryAddFeature,
  defaultRegistryCheckFeatureVersion,
  defaultRegistryGetPathList,
  defaultRegistryAddPlugin,
  defaultRegistryScanPath,
  defaultRegistryFindPlugin,
  defaultRegistryFindFeature,
  defaultRegistryFeatureFilter,
  onRegistryFeatureAdded,
  afterRegistryFeatureAdded,
  onRegistryPluginAdded,
  afterRegistryPluginAdded
  
  ) where

import Control.Monad (liftM)
import Media.Streaming.GStreamer.Core.Types
{-# LINE 69 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
import Media.Streaming.GStreamer.Core.Signals
{-# LINE 70 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
import System.Glib.GType
{-# LINE 71 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
import System.Glib.FFI
import System.Glib.UTFString
import System.Glib.Signals
import System.Glib.GList
{-# LINE 75 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}


{-# LINE 77 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}

defaultRegistry :: Registry
defaultRegistry =
    unsafePerformIO $ gst_registry_get_default >>= peekObject

registryGetFeatureList :: RegistryClass registry
                       => registry
                       -> GType
                       -> IO [PluginFeature]
registryGetFeatureList registry gType =
    (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_get_feature_list argPtr1 arg2) (toRegistry registry) gType >>=
            fromGList >>= mapM takeObject

registryGetFeatureListByPlugin :: RegistryClass registry
                               => registry
                               -> String
                               -> IO [PluginFeature]
registryGetFeatureListByPlugin registry name =
    withUTFString name $ \cName ->
        (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_get_feature_list_by_plugin argPtr1 arg2) (toRegistry registry) cName >>=
            fromGList >>= mapM takeObject

registryGetPathList :: RegistryClass registry
                    => registry
                    -> IO [FilePath]
registryGetPathList registry =
    (\(Registry arg1) -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_get_path_list argPtr1) (toRegistry registry) >>=
        fromGList >>= mapM peekUTFString

registryGetPluginList :: RegistryClass registry
                      => registry
                      -> IO [Plugin]
registryGetPluginList registry =
    (\(Registry arg1) -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_get_plugin_list argPtr1) (toRegistry registry) >>=
        fromGList >>= mapM takeObject

registryAddPlugin :: (RegistryClass registry, PluginClass plugin)
                  => registry
                  -> plugin
                  -> IO Bool
registryAddPlugin registry plugin =
    liftM toBool $ (\(Registry arg1) (Plugin arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gst_registry_add_plugin argPtr1 argPtr2) (toRegistry registry) (toPlugin plugin)

registryRemovePlugin :: (RegistryClass registry, PluginClass plugin)
                     => registry
                     -> plugin
                     -> IO ()
registryRemovePlugin registry plugin =
    (\(Registry arg1) (Plugin arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gst_registry_remove_plugin argPtr1 argPtr2) (toRegistry registry) (toPlugin plugin)

type CPluginFilter = Ptr Plugin
                  -> ((Ptr ()))
{-# LINE 129 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
                  -> IO (CInt)
{-# LINE 130 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
marshalPluginFilter :: PluginFilter
                    -> IO ((FunPtr ((Ptr Plugin) -> ((Ptr ()) -> (IO CInt)))))
{-# LINE 132 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
marshalPluginFilter pluginFilter =
    makePluginFilter cPluginFilter
    where cPluginFilter :: CPluginFilter
          cPluginFilter pluginPtr _ =
               liftM fromBool $ peekObject pluginPtr >>= pluginFilter
foreign import ccall "wrapper"
    makePluginFilter :: CPluginFilter
                     -> IO ((FunPtr ((Ptr Plugin) -> ((Ptr ()) -> (IO CInt)))))
{-# LINE 140 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}

registryPluginFilter :: RegistryClass registry
                     => registry
                     -> PluginFilter
                     -> Bool
                     -> IO [Plugin]
registryPluginFilter registry pluginFilter first =
    do cPluginFilter <- marshalPluginFilter pluginFilter
       (\(Registry arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_plugin_filter argPtr1 arg2 arg3 arg4) (toRegistry registry)
                                         cPluginFilter
                                         (fromBool first)
                                         nullPtr >>=
           fromGList >>= mapM takeObject


type CPluginFeatureFilter = Ptr PluginFeature
                         -> ((Ptr ()))
{-# LINE 157 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
                         -> IO (CInt)
{-# LINE 158 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
marshalPluginFeatureFilter :: PluginFeatureFilter
                           -> IO ((FunPtr ((Ptr PluginFeature) -> ((Ptr ()) -> (IO CInt)))))
{-# LINE 160 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}
marshalPluginFeatureFilter pluginFeatureFilter =
    makePluginFeatureFilter cPluginFeatureFilter
    where cPluginFeatureFilter :: CPluginFeatureFilter
          cPluginFeatureFilter pluginFeaturePtr _ =
               liftM fromBool $ peekObject pluginFeaturePtr >>= pluginFeatureFilter
foreign import ccall "wrapper"
    makePluginFeatureFilter :: CPluginFeatureFilter
                            -> IO ((FunPtr ((Ptr PluginFeature) -> ((Ptr ()) -> (IO CInt)))))
{-# LINE 168 "./Media/Streaming/GStreamer/Core/Registry.chs" #-}

registryFeatureFilter :: RegistryClass registry
                     => registry
                     -> PluginFeatureFilter
                     -> Bool
                     -> IO [PluginFeature]
registryFeatureFilter registry featureFilter first =
    do cPluginFeatureFilter <- marshalPluginFeatureFilter featureFilter
       (\(Registry arg1) arg2 arg3 arg4 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_feature_filter argPtr1 arg2 arg3 arg4) (toRegistry registry)
                                         cPluginFeatureFilter
                                         (fromBool first)
                                         nullPtr >>=
           fromGList >>= mapM takeObject


registryFindPlugin :: RegistryClass registry
                   => registry
                   -> String
                   -> IO (Maybe Plugin)
registryFindPlugin registry name =
    (withUTFString name $ (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_find_plugin argPtr1 arg2) (toRegistry registry)) >>=
        maybePeek takeObject

registryFindFeature :: RegistryClass registry
                    => registry
                    -> String
                    -> GType
                    -> IO (Maybe PluginFeature)
registryFindFeature registry name gType =
    withUTFString name $ \cName ->
        (\(Registry arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_find_feature argPtr1 arg2 arg3) (toRegistry registry)
                                         cName
                                         gType >>=
            maybePeek takeObject

registryLookupFeature :: RegistryClass registry
                      => registry
                      -> String
                      -> IO (Maybe PluginFeature)
registryLookupFeature registry name =
    (withUTFString name $ (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_lookup_feature argPtr1 arg2) (toRegistry registry)) >>=
        maybePeek takeObject

registryScanPath :: RegistryClass registry
                 => registry
                 -> FilePath
                 -> IO Bool
registryScanPath registry path =
    liftM toBool $
        withUTFString path $
            (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_scan_path argPtr1 arg2) (toRegistry registry)

registryXMLReadCache :: RegistryClass registry
                     => registry
                     -> FilePath
                     -> IO Bool
registryXMLReadCache registry location =
    liftM toBool $
        withUTFString location $
            (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_xml_read_cache argPtr1 arg2) (toRegistry registry)

registryXMLWriteCache :: RegistryClass registry
                      => registry
                      -> FilePath
                      -> IO Bool
registryXMLWriteCache registry location =
    liftM toBool $
        withUTFString location $
            (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_xml_write_cache argPtr1 arg2) (toRegistry registry)

registryLookup :: RegistryClass registry
               => registry
               -> FilePath
               -> IO Plugin
registryLookup registry filename =
    (withUTFString filename $
         (\(Registry arg1) arg2 -> withForeignPtr arg1 $ \argPtr1 ->gst_registry_lookup argPtr1 arg2) (toRegistry registry)) >>=
        takeObject

registryRemoveFeature :: (RegistryClass registry, PluginFeatureClass pluginFeature)
                      => registry
                      -> pluginFeature
                      -> IO ()
registryRemoveFeature registry pluginFeature =
    (\(Registry arg1) (PluginFeature arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gst_registry_remove_feature argPtr1 argPtr2) (toRegistry registry) (toPluginFeature pluginFeature)

registryAddFeature :: (RegistryClass registry, PluginFeatureClass pluginFeature)
                   => registry
                   -> pluginFeature
                   -> IO Bool
registryAddFeature registry pluginFeature =
    liftM toBool $
        (\(Registry arg1) (PluginFeature arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gst_registry_add_feature argPtr1 argPtr2) (toRegistry registry) (toPluginFeature pluginFeature)

defaultRegistryCheckFeatureVersion :: String
                                   -> Word
                                   -> Word
                                   -> Word
                                   -> IO Bool
defaultRegistryCheckFeatureVersion feature minMajor minMinor minMicro =
    liftM toBool $ withUTFString feature $ \cFeature ->
        gst_default_registry_check_feature_version cFeature
                                                          (fromIntegral minMajor)
                                                          (fromIntegral minMinor)
                                                          (fromIntegral minMicro)

defaultRegistryGetPathList :: IO [FilePath]
defaultRegistryGetPathList =
    registryGetPathList defaultRegistry

defaultRegistryAddPlugin :: PluginClass plugin
                         => plugin
                         -> IO Bool
defaultRegistryAddPlugin =
    registryAddPlugin defaultRegistry

defaultRegistryScanPath :: String
                        -> IO Bool
defaultRegistryScanPath =
    registryScanPath defaultRegistry

defaultRegistryFindPlugin :: String
                          -> IO (Maybe Plugin)
defaultRegistryFindPlugin =
    registryFindPlugin defaultRegistry

defaultRegistryFindFeature :: String
                           -> GType
                           -> IO (Maybe PluginFeature)
defaultRegistryFindFeature =
    registryFindFeature defaultRegistry

defaultRegistryFeatureFilter :: PluginFeatureFilter
                             -> Bool
                             -> IO [PluginFeature]
defaultRegistryFeatureFilter =
    registryFeatureFilter defaultRegistry

onRegistryFeatureAdded, afterRegistryFeatureAdded :: RegistryClass registry
                                                  => registry
                                                  -> (PluginFeature -> IO ())
                                                  -> IO (ConnectId registry)
onRegistryFeatureAdded =
    connect_OBJECT__NONE "feature-added" False
afterRegistryFeatureAdded =
    connect_OBJECT__NONE "feature-added" False

onRegistryPluginAdded, afterRegistryPluginAdded :: RegistryClass registry
                                                => registry
                                                -> (Plugin -> IO ())
                                                -> IO (ConnectId registry)
onRegistryPluginAdded =
    connect_OBJECT__NONE "plugin-added" False
afterRegistryPluginAdded =
    connect_OBJECT__NONE "plugin-added" False

foreign import ccall safe "gst_registry_get_default"
  gst_registry_get_default :: (IO (Ptr Registry))

foreign import ccall safe "gst_registry_get_feature_list"
  gst_registry_get_feature_list :: ((Ptr Registry) -> (CULong -> (IO (Ptr ()))))

foreign import ccall safe "gst_registry_get_feature_list_by_plugin"
  gst_registry_get_feature_list_by_plugin :: ((Ptr Registry) -> ((Ptr CChar) -> (IO (Ptr ()))))

foreign import ccall safe "gst_registry_get_path_list"
  gst_registry_get_path_list :: ((Ptr Registry) -> (IO (Ptr ())))

foreign import ccall safe "gst_registry_get_plugin_list"
  gst_registry_get_plugin_list :: ((Ptr Registry) -> (IO (Ptr ())))

foreign import ccall safe "gst_registry_add_plugin"
  gst_registry_add_plugin :: ((Ptr Registry) -> ((Ptr Plugin) -> (IO CInt)))

foreign import ccall safe "gst_registry_remove_plugin"
  gst_registry_remove_plugin :: ((Ptr Registry) -> ((Ptr Plugin) -> (IO ())))

foreign import ccall safe "gst_registry_plugin_filter"
  gst_registry_plugin_filter :: ((Ptr Registry) -> ((FunPtr ((Ptr Plugin) -> ((Ptr ()) -> (IO CInt)))) -> (CInt -> ((Ptr ()) -> (IO (Ptr ()))))))

foreign import ccall safe "gst_registry_feature_filter"
  gst_registry_feature_filter :: ((Ptr Registry) -> ((FunPtr ((Ptr PluginFeature) -> ((Ptr ()) -> (IO CInt)))) -> (CInt -> ((Ptr ()) -> (IO (Ptr ()))))))

foreign import ccall safe "gst_registry_find_plugin"
  gst_registry_find_plugin :: ((Ptr Registry) -> ((Ptr CChar) -> (IO (Ptr Plugin))))

foreign import ccall safe "gst_registry_find_feature"
  gst_registry_find_feature :: ((Ptr Registry) -> ((Ptr CChar) -> (CULong -> (IO (Ptr PluginFeature)))))

foreign import ccall safe "gst_registry_lookup_feature"
  gst_registry_lookup_feature :: ((Ptr Registry) -> ((Ptr CChar) -> (IO (Ptr PluginFeature))))

foreign import ccall safe "gst_registry_scan_path"
  gst_registry_scan_path :: ((Ptr Registry) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gst_registry_xml_read_cache"
  gst_registry_xml_read_cache :: ((Ptr Registry) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gst_registry_xml_write_cache"
  gst_registry_xml_write_cache :: ((Ptr Registry) -> ((Ptr CChar) -> (IO CInt)))

foreign import ccall safe "gst_registry_lookup"
  gst_registry_lookup :: ((Ptr Registry) -> ((Ptr CChar) -> (IO (Ptr Plugin))))

foreign import ccall safe "gst_registry_remove_feature"
  gst_registry_remove_feature :: ((Ptr Registry) -> ((Ptr PluginFeature) -> (IO ())))

foreign import ccall safe "gst_registry_add_feature"
  gst_registry_add_feature :: ((Ptr Registry) -> ((Ptr PluginFeature) -> (IO CInt)))

foreign import ccall safe "gst_default_registry_check_feature_version"
  gst_default_registry_check_feature_version :: ((Ptr CChar) -> (CUInt -> (CUInt -> (CUInt -> (IO CInt)))))