-- GENERATED by C->Haskell Compiler, version 0.16.0 Crystal Seed, 24 Jan 2009 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./Gnome/Keyring/Misc.chs" #-}-- Copyright (C) 2009 John Millikin <jmillikin@gmail.com>
-- 
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- any later version.
-- 
-- This program 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 General Public License for more details.
-- 
-- You should have received a copy of the GNU General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.
-- 
{-# LANGUAGE ForeignFunctionInterface #-}

{-# LINE 18 "./Gnome/Keyring/Misc.chs" #-}

module Gnome.Keyring.Misc where
import Gnome.Keyring.Types (CancellationKey (..))

-- Import unqualified for c2hs
import Foreign
import Foreign.C

-- | Check whether the client can communicate with a GNOME Keyring server.
-- 
available :: IO (Bool)
available =
  available'_ >>= \res ->
  let {res' = toBool res} in
  return (res')
{-# LINE 30 "./Gnome/Keyring/Misc.chs" #-}

unpackKey :: CancellationKey -> Ptr ()
unpackKey (CancellationKey x) = x

-- | Cancel an asynchronous request. The request will return
-- 'ErrorCancelled'.
-- 
cancel :: CancellationKey -> IO (())
cancel a1 =
  let {a1' = unpackKey a1} in 
  cancel'_ a1' >>= \res ->
  let {res' = id res} in
  return (res')
{-# LINE 40 "./Gnome/Keyring/Misc.chs" #-}

foreign import ccall unsafe "Gnome/Keyring/Misc.chs.h gnome_keyring_is_available"
  available'_ :: (IO CInt)

foreign import ccall safe "Gnome/Keyring/Misc.chs.h gnome_keyring_cancel_request"
  cancel'_ :: ((Ptr ()) -> (IO ()))