module Gnome.Keyring.Item.Internal where
import Data.Set (Set, toList)
import Data.Text.Lazy (Text)
import Gnome.Keyring.Operation.Internal
import Gnome.Keyring.Types
import Gnome.Keyring.AccessControl.Internal
import Gnome.Keyring.Attribute.Internal
import Gnome.Keyring.ItemInfo.Internal
import Foreign
import Foreign.C
import Gnome.Keyring.FFI
data ItemInfoFlag
= ItemInfoBasics
| ItemInfoSecret
deriving (Show, Eq)
peekItemID :: (Storable a, Integral a) => Ptr a -> IO ItemID
peekItemID = fmap (ItemID . fromIntegral) . peek
cItemID :: Integral a => ItemID -> a
cItemID (ItemID x) = fromIntegral x
cItemInfoFlags :: Bits a => Set ItemInfoFlag -> a
cItemInfoFlags = foldr (.|.) 0 . map flagValue . toList where
flagValue ItemInfoBasics = 0
flagValue ItemInfoSecret = 1
data GetItemIDCallback = GetItemIDCallback GetWordCallback
instance Callback GetItemIDCallback ItemID where
callbackToPtr (GetItemIDCallback x) = callbackToPtr x
freeCallback (GetItemIDCallback x) = freeCallback x
buildCallback onSuccess = let
onSuccess' = onSuccess . ItemID
in fmap GetItemIDCallback . buildCallback onSuccess'
data GetItemInfoCallback = GetItemInfoCallback GetItemInfoCallbackPtr
instance Callback GetItemInfoCallback ItemInfo where
callbackToPtr (GetItemInfoCallback x) = castFunPtr x
freeCallback (GetItemInfoCallback x) = freeHaskellFunPtr x
buildCallback onSuccess onError = do
funptr <- wrapGetItemInfoCallback $ \cres ptr _ ->
case result cres of
RESULT_OK -> peekItemInfo ptr >>= onSuccess
x -> onError $ resultToError x
return $ GetItemInfoCallback funptr
type RawGetItemInfoCallback = CInt -> Ptr () -> Ptr () -> IO ()
type GetItemInfoCallbackPtr = FunPtr ((CInt -> ((Ptr ()) -> ((Ptr ()) -> (IO ())))))
foreign import ccall "wrapper"
wrapGetItemInfoCallback :: RawGetItemInfoCallback -> IO GetItemInfoCallbackPtr
data GetAttributesCallback = GetAttributesCallback GetAttributesCallbackPtr
instance Callback GetAttributesCallback [Attribute] where
callbackToPtr (GetAttributesCallback x) = castFunPtr x
freeCallback (GetAttributesCallback x) = freeHaskellFunPtr x
buildCallback onSuccess onError = do
funptr <- wrapGetAttributesCallback $ \cres ptr _ ->
case result cres of
RESULT_OK -> peekAttributeList ptr >>= onSuccess
x -> onError $ resultToError x
return $ GetAttributesCallback funptr
type RawGetAttributesCallback = CInt -> Ptr () -> Ptr () -> IO ()
type GetAttributesCallbackPtr = FunPtr ((CInt -> ((Ptr ()) -> ((Ptr ()) -> (IO ())))))
foreign import ccall "wrapper"
wrapGetAttributesCallback :: RawGetAttributesCallback -> IO GetAttributesCallbackPtr
itemCreate :: Maybe KeyringName
-> ItemType
-> Text
-> [Attribute]
-> Text
-> Bool
-> Operation ItemID
itemCreate k t dn as s u = operation
(item_create k t dn as s u)
(item_create_sync k t dn as s u)
item_create :: Maybe Text -> ItemType -> Text -> [Attribute] -> Text -> Bool -> GetItemIDCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_create a1 a2 a3 a4 a5 a6 a7 a8 a9 =
withNullableText a1 $ \a1' ->
let {a2' = fromItemType a2} in
withText a3 $ \a3' ->
withAttributeList a4 $ \a4' ->
withText a5 $ \a5' ->
let {a6' = fromBool a6} in
let {a7' = callbackToPtr a7} in
let {a8' = id a8} in
let {a9' = id a9} in
item_create'_ a1' a2' a3' a4' a5' a6' a7' a8' a9' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_create_sync :: Maybe Text -> ItemType -> Text -> [Attribute] -> Text -> Bool -> IO (Result, ItemID)
item_create_sync a1 a2 a3 a4 a5 a6 =
withNullableText a1 $ \a1' ->
let {a2' = fromItemType a2} in
withText a3 $ \a3' ->
withAttributeList a4 $ \a4' ->
withText a5 $ \a5' ->
let {a6' = fromBool a6} in
alloca $ \a7' ->
item_create_sync'_ a1' a2' a3' a4' a5' a6' a7' >>= \res ->
peekItemID a7'>>= \a7'' ->
let {res' = result res} in
return (res', a7'')
itemDelete :: Maybe KeyringName -> ItemID -> Operation ()
itemDelete k item = operation (item_delete k item) (item_delete_sync k item)
item_delete :: Maybe Text -> ItemID -> DoneCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_delete a1 a2 a3 a4 a5 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
let {a3' = callbackToPtr a3} in
let {a4' = id a4} in
let {a5' = id a5} in
item_delete'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_delete_sync :: Maybe Text -> ItemID -> IO ((Result, ()))
item_delete_sync a1 a2 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
item_delete_sync'_ a1' a2' >>= \res ->
let {res' = resultAndTuple res} in
return (res')
itemGetInfo :: Maybe KeyringName -> ItemID -> Operation ItemInfo
itemGetInfo k item = operation
(item_get_info k item)
(item_get_info_sync k item)
item_get_info :: Maybe Text -> ItemID -> GetItemInfoCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_get_info a1 a2 a3 a4 a5 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
let {a3' = callbackToPtr a3} in
let {a4' = id a4} in
let {a5' = id a5} in
item_get_info'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_get_info_sync :: Maybe Text -> ItemID -> IO (Result, ItemInfo)
item_get_info_sync a1 a2 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
alloca $ \a3' ->
item_get_info_sync'_ a1' a2' a3' >>= \res ->
stealItemInfo a3'>>= \a3'' ->
let {res' = result res} in
return (res', a3'')
itemGetInfoFull :: Maybe KeyringName -> ItemID -> Set ItemInfoFlag
-> Operation ItemInfo
itemGetInfoFull k item flags = operation
(item_get_info_full k item flags)
(item_get_info_full_sync k item flags)
item_get_info_full :: Maybe Text -> ItemID -> Set ItemInfoFlag -> GetItemInfoCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_get_info_full a1 a2 a3 a4 a5 a6 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
let {a3' = cItemInfoFlags a3} in
let {a4' = callbackToPtr a4} in
let {a5' = id a5} in
let {a6' = id a6} in
item_get_info_full'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_get_info_full_sync :: Maybe Text -> ItemID -> Set ItemInfoFlag -> IO (Result, ItemInfo)
item_get_info_full_sync a1 a2 a3 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
let {a3' = cItemInfoFlags a3} in
alloca $ \a4' ->
item_get_info_full_sync'_ a1' a2' a3' a4' >>= \res ->
stealItemInfo a4'>>= \a4'' ->
let {res' = result res} in
return (res', a4'')
itemSetInfo :: Maybe KeyringName -> ItemID -> ItemInfo -> Operation ()
itemSetInfo k item info = operation
(item_set_info k item info)
(item_set_info_sync k item info)
item_set_info :: Maybe Text -> ItemID -> ItemInfo -> DoneCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_set_info a1 a2 a3 a4 a5 a6 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
withItemInfo a3 $ \a3' ->
let {a4' = callbackToPtr a4} in
let {a5' = id a5} in
let {a6' = id a6} in
item_set_info'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_set_info_sync :: Maybe Text -> ItemID -> ItemInfo -> IO ((Result, ()))
item_set_info_sync a1 a2 a3 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
withItemInfo a3 $ \a3' ->
item_set_info_sync'_ a1' a2' a3' >>= \res ->
let {res' = resultAndTuple res} in
return (res')
itemGetAttributes :: Maybe KeyringName -> ItemID -> Operation [Attribute]
itemGetAttributes k item = operation
(item_get_attributes k item)
(item_get_attributes_sync k item)
item_get_attributes :: Maybe Text -> ItemID -> GetAttributesCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_get_attributes a1 a2 a3 a4 a5 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
let {a3' = callbackToPtr a3} in
let {a4' = id a4} in
let {a5' = id a5} in
item_get_attributes'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_get_attributes_sync :: Maybe Text -> ItemID -> IO (Result, [Attribute])
item_get_attributes_sync a1 a2 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
alloca $ \a3' ->
item_get_attributes_sync'_ a1' a2' a3' >>= \res ->
stealAttributeList a3'>>= \a3'' ->
let {res' = result res} in
return (res', a3'')
itemSetAttributes :: Maybe KeyringName -> ItemID -> [Attribute] -> Operation ()
itemSetAttributes k item as = operation
(item_set_attributes k item as)
(item_set_attributes_sync k item as)
item_set_attributes :: Maybe Text -> ItemID -> [Attribute] -> DoneCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_set_attributes a1 a2 a3 a4 a5 a6 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
withAttributeList a3 $ \a3' ->
let {a4' = callbackToPtr a4} in
let {a5' = id a5} in
let {a6' = id a6} in
item_set_attributes'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_set_attributes_sync :: Maybe Text -> ItemID -> [Attribute] -> IO ((Result, ()))
item_set_attributes_sync a1 a2 a3 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
withAttributeList a3 $ \a3' ->
item_set_attributes_sync'_ a1' a2' a3' >>= \res ->
let {res' = resultAndTuple res} in
return (res')
itemGetACL :: Maybe KeyringName -> ItemID -> Operation [AccessControl]
itemGetACL k item = operation
(item_get_acl k item)
(item_get_acl_sync k item)
item_get_acl :: Maybe Text -> ItemID -> GetACLCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_get_acl a1 a2 a3 a4 a5 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
let {a3' = callbackToPtr a3} in
let {a4' = id a4} in
let {a5' = id a5} in
item_get_acl'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_get_acl_sync :: Maybe Text -> ItemID -> IO (Result, [AccessControl])
item_get_acl_sync a1 a2 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
alloca $ \a3' ->
item_get_acl_sync'_ a1' a2' a3' >>= \res ->
stealACL a3'>>= \a3'' ->
let {res' = result res} in
return (res', a3'')
itemSetACL :: Maybe KeyringName -> ItemID -> [AccessControl] -> Operation ()
itemSetACL k item acl = operation
(item_set_acl k item acl)
(item_set_acl_sync k item acl)
item_set_acl :: Maybe Text -> ItemID -> [AccessControl] -> DoneCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_set_acl a1 a2 a3 a4 a5 a6 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
withACL a3 $ \a3' ->
let {a4' = callbackToPtr a4} in
let {a5' = id a5} in
let {a6' = id a6} in
item_set_acl'_ a1' a2' a3' a4' a5' a6' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_set_acl_sync :: Maybe Text -> ItemID -> [AccessControl] -> IO ((Result, ()))
item_set_acl_sync a1 a2 a3 =
withNullableText a1 $ \a1' ->
let {a2' = cItemID a2} in
withACL a3 $ \a3' ->
item_set_acl_sync'_ a1' a2' a3' >>= \res ->
let {res' = resultAndTuple res} in
return (res')
itemGrantAccessRights :: Maybe KeyringName
-> Text
-> Text
-> ItemID
-> Set AccessType
-> Operation ()
itemGrantAccessRights k d p item r = operation
(item_grant_access_rights k d p item r)
(item_grant_access_rights_sync k d p item r)
item_grant_access_rights :: Maybe Text -> Text -> Text -> ItemID -> Set AccessType -> DoneCallback -> Ptr () -> DestroyNotifyPtr -> IO (CancellationKey)
item_grant_access_rights a1 a2 a3 a4 a5 a6 a7 a8 =
withNullableText a1 $ \a1' ->
withText a2 $ \a2' ->
withText a3 $ \a3' ->
let {a4' = cItemID a4} in
let {a5' = cAccessTypes a5} in
let {a6' = callbackToPtr a6} in
let {a7' = id a7} in
let {a8' = id a8} in
item_grant_access_rights'_ a1' a2' a3' a4' a5' a6' a7' a8' >>= \res ->
let {res' = CancellationKey res} in
return (res')
item_grant_access_rights_sync :: Maybe Text -> Text -> Text -> ItemID -> Set AccessType -> IO ((Result, ()))
item_grant_access_rights_sync a1 a2 a3 a4 a5 =
withNullableText a1 $ \a1' ->
withText a2 $ \a2' ->
withText a3 $ \a3' ->
let {a4' = cItemID a4} in
let {a5' = cAccessTypes a5} in
item_grant_access_rights_sync'_ a1' a2' a3' a4' a5' >>= \res ->
let {res' = resultAndTuple res} in
return (res')
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_create"
item_create'_ :: ((Ptr CChar) -> (CInt -> ((Ptr CChar) -> ((Ptr ()) -> ((Ptr CChar) -> (CInt -> ((FunPtr (CInt -> (CUInt -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ())))))))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_create_sync"
item_create_sync'_ :: ((Ptr CChar) -> (CInt -> ((Ptr CChar) -> ((Ptr ()) -> ((Ptr CChar) -> (CInt -> ((Ptr CUInt) -> (IO CInt))))))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_delete"
item_delete'_ :: ((Ptr CChar) -> (CUInt -> ((FunPtr (CInt -> ((Ptr ()) -> (IO ())))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ())))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_delete_sync"
item_delete_sync'_ :: ((Ptr CChar) -> (CUInt -> (IO CInt)))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_info"
item_get_info'_ :: ((Ptr CChar) -> (CUInt -> ((GetItemInfoCallbackPtr) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ())))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_info_sync"
item_get_info_sync'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_info_full"
item_get_info_full'_ :: ((Ptr CChar) -> (CUInt -> (CUInt -> ((GetItemInfoCallbackPtr) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ()))))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_info_full_sync"
item_get_info_full_sync'_ :: ((Ptr CChar) -> (CUInt -> (CUInt -> ((Ptr (Ptr ())) -> (IO CInt)))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_set_info"
item_set_info'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr ()) -> ((FunPtr (CInt -> ((Ptr ()) -> (IO ())))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ()))))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_set_info_sync"
item_set_info_sync'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr ()) -> (IO CInt))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_attributes"
item_get_attributes'_ :: ((Ptr CChar) -> (CUInt -> ((GetAttributesCallbackPtr) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ())))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_attributes_sync"
item_get_attributes_sync'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_set_attributes"
item_set_attributes'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr ()) -> ((FunPtr (CInt -> ((Ptr ()) -> (IO ())))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ()))))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_set_attributes_sync"
item_set_attributes_sync'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr ()) -> (IO CInt))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_acl"
item_get_acl'_ :: ((Ptr CChar) -> (CUInt -> ((FunPtr (CInt -> ((Ptr ()) -> ((Ptr ()) -> (IO ()))))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ())))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_get_acl_sync"
item_get_acl_sync'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr (Ptr ())) -> (IO CInt))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_set_acl"
item_set_acl'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr ()) -> ((FunPtr (CInt -> ((Ptr ()) -> (IO ())))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ()))))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_set_acl_sync"
item_set_acl_sync'_ :: ((Ptr CChar) -> (CUInt -> ((Ptr ()) -> (IO CInt))))
foreign import ccall safe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_grant_access_rights"
item_grant_access_rights'_ :: ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> (CUInt -> (CInt -> ((FunPtr (CInt -> ((Ptr ()) -> (IO ())))) -> ((Ptr ()) -> ((FunPtr ((Ptr ()) -> (IO ()))) -> (IO (Ptr ()))))))))))
foreign import ccall unsafe "Gnome/Keyring/Item/Internal.chs.h gnome_keyring_item_grant_access_rights_sync"
item_grant_access_rights_sync'_ :: ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr CChar) -> (CUInt -> (CInt -> (IO CInt))))))