module Binja.Plugin
  ( initPlugins,
    getInstallDirectory,
    getBundledPluginDirectory,
    getUserDirectory,
    getRepositoriesDirectory,
    getUserPluginDirectory,
  )
where

import Binja.FFI
import Binja.Types
import Binja.Utils
import Data.Bool (bool)

initPlugins :: Bool -> IO Bool
initPlugins :: Bool -> IO Bool
initPlugins = (CBool -> Bool) -> IO CBool -> IO Bool
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CBool -> Bool
toBool (IO CBool -> IO Bool) -> (Bool -> IO CBool) -> Bool -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CBool -> IO CBool
c_BNInitPlugins (CBool -> IO CBool) -> (Bool -> CBool) -> Bool -> IO CBool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CBool -> CBool -> Bool -> CBool
forall a. a -> a -> Bool -> a
bool (Word8 -> CBool
CBool Word8
0) (Word8 -> CBool
CBool Word8
1)

getInstallDirectory :: IO String
getInstallDirectory :: IO String
getInstallDirectory = CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO CString
c_BNGetInstallDirectory

getBundledPluginDirectory :: IO String
getBundledPluginDirectory :: IO String
getBundledPluginDirectory = CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO CString
c_BNGetBundledPluginDirectory

getUserDirectory :: IO String
getUserDirectory :: IO String
getUserDirectory = CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO CString
c_BNGetUserDirectory

getUserPluginDirectory :: IO String
getUserPluginDirectory :: IO String
getUserPluginDirectory = CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO CString
c_BNGetUserPluginDirectory

getRepositoriesDirectory :: IO String
getRepositoriesDirectory :: IO String
getRepositoriesDirectory = CString -> IO String
peekCString (CString -> IO String) -> IO CString -> IO String
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< IO CString
c_BNGetRepositoriesDirectory