module System.Gnome.VFS.Drive (
Drive,
DriveClass,
DriveID,
DeviceType,
castToDrive,
driveCompare,
driveGetActivationURI,
driveGetDevicePath,
driveGetDeviceType,
driveGetDisplayName,
driveGetHalUDI,
driveGetIcon,
driveGetID,
driveIsConnected,
driveIsMounted,
driveIsUserVisible,
driveGetMountedVolumes,
driveEject,
driveMount,
onDriveVolumeMounted,
afterDriveVolumeMounted,
onDriveVolumePreUnmount,
afterDriveVolumePreUnmount,
onDriveVolumeUnmounted,
afterDriveVolumeUnmounted
) where
import Control.Exception
import Control.Monad ( liftM )
import System.Glib.UTFString
import System.Glib.FFI
import System.Glib.GList ( fromGList )
import System.Glib.Signals
import System.Gnome.VFS.Marshal
import System.Gnome.VFS.Types
import System.Gnome.VFS.Signals
import System.Gnome.VFS.BasicTypes
driveCompare :: DriveClass drive =>
drive
-> drive
-> IO Ordering
driveCompare a b =
do result <- liftM fromIntegral $ (\(Drive arg1) (Drive arg2) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->gnome_vfs_drive_compare argPtr1 argPtr2) (castToDrive a) (castToDrive b)
let ordering | result < 0 = LT
| result > 0 = GT
| otherwise = EQ
return ordering
driveEject :: DriveClass drive =>
drive
-> VolumeOpSuccessCallback
-> VolumeOpFailureCallback
-> IO ()
driveEject drive successCallback failureCallback =
do cCallback <- volumeOpCallbackMarshal successCallback failureCallback
(\(Drive arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_eject argPtr1 arg2 arg3) (castToDrive drive) cCallback $ castFunPtrToPtr cCallback
marshalString cAction drive =
cAction (castToDrive drive) >>= readUTFString
marshalMaybeString cAction drive =
cAction (castToDrive drive) >>= (maybePeek readUTFString)
driveGetActivationURI :: DriveClass drive
=> drive
-> IO String
driveGetActivationURI =
marshalString (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_activation_uri argPtr1)
driveGetDevicePath :: DriveClass drive =>
drive
-> IO (Maybe String)
driveGetDevicePath =
marshalMaybeString (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_device_path argPtr1)
driveGetDeviceType :: DriveClass drive =>
drive
-> IO DeviceType
driveGetDeviceType drive =
liftM cToEnum $ (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_device_type argPtr1) (castToDrive drive)
driveGetDisplayName :: DriveClass drive =>
drive
-> IO String
driveGetDisplayName =
marshalString (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_display_name argPtr1)
driveGetHalUDI :: DriveClass drive =>
drive
-> IO (Maybe String)
driveGetHalUDI =
marshalMaybeString (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_hal_udi argPtr1)
driveGetIcon :: DriveClass drive =>
drive
-> IO FilePath
driveGetIcon =
marshalString (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_icon argPtr1)
driveGetID :: DriveClass drive =>
drive
-> IO DriveID
driveGetID drive =
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_id argPtr1) (castToDrive drive)
driveGetMountedVolumes :: DriveClass drive =>
drive
-> IO [Volume]
driveGetMountedVolumes drive =
(\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_get_mounted_volumes argPtr1) (castToDrive drive) >>=
fromGList >>=
mapM newVolume
marshalBool cAction drive =
liftM toBool $ cAction (castToDrive drive)
driveIsConnected :: DriveClass drive =>
drive
-> IO Bool
driveIsConnected =
marshalBool (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_is_connected argPtr1)
driveIsMounted :: DriveClass drive =>
drive
-> IO Bool
driveIsMounted =
marshalBool (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_is_mounted argPtr1)
driveIsUserVisible :: DriveClass drive =>
drive
-> IO Bool
driveIsUserVisible =
marshalBool (\(Drive arg1) -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_is_user_visible argPtr1)
driveMount :: DriveClass drive =>
drive
-> VolumeOpSuccessCallback
-> VolumeOpFailureCallback
-> IO ()
driveMount drive successCallback failureCallback =
do cCallback <- volumeOpCallbackMarshal successCallback failureCallback
(\(Drive arg1) arg2 arg3 -> withForeignPtr arg1 $ \argPtr1 ->gnome_vfs_drive_eject argPtr1 arg2 arg3) (castToDrive drive) cCallback $ castFunPtrToPtr cCallback
onDriveVolumeMounted,
afterDriveVolumeMounted,
onDriveVolumePreUnmount,
afterDriveVolumePreUnmount,
onDriveVolumeUnmounted,
afterDriveVolumeUnmounted
:: (DriveClass drive) =>
drive
-> (Volume -> IO ())
-> IO (ConnectId drive)
onDriveVolumeMounted = connect_OBJECT__NONE "volume-mounted" False
afterDriveVolumeMounted = connect_OBJECT__NONE "volume-mounted" True
onDriveVolumePreUnmount = connect_OBJECT__NONE "volume-pre-unmount" False
afterDriveVolumePreUnmount = connect_OBJECT__NONE "volume-pre-unmount" True
onDriveVolumeUnmounted = connect_OBJECT__NONE "volume-unmounted" False
afterDriveVolumeUnmounted = connect_OBJECT__NONE "volume-unmounted" True
foreign import ccall safe "gnome_vfs_drive_compare"
gnome_vfs_drive_compare :: ((Ptr Drive) -> ((Ptr Drive) -> (IO CInt)))
foreign import ccall safe "gnome_vfs_drive_eject"
gnome_vfs_drive_eject :: ((Ptr Drive) -> ((FunPtr (CInt -> ((Ptr CChar) -> ((Ptr CChar) -> ((Ptr ()) -> (IO ())))))) -> ((Ptr ()) -> (IO ()))))
foreign import ccall safe "gnome_vfs_drive_get_activation_uri"
gnome_vfs_drive_get_activation_uri :: ((Ptr Drive) -> (IO (Ptr CChar)))
foreign import ccall safe "gnome_vfs_drive_get_device_path"
gnome_vfs_drive_get_device_path :: ((Ptr Drive) -> (IO (Ptr CChar)))
foreign import ccall safe "gnome_vfs_drive_get_device_type"
gnome_vfs_drive_get_device_type :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "gnome_vfs_drive_get_display_name"
gnome_vfs_drive_get_display_name :: ((Ptr Drive) -> (IO (Ptr CChar)))
foreign import ccall safe "gnome_vfs_drive_get_hal_udi"
gnome_vfs_drive_get_hal_udi :: ((Ptr Drive) -> (IO (Ptr CChar)))
foreign import ccall safe "gnome_vfs_drive_get_icon"
gnome_vfs_drive_get_icon :: ((Ptr Drive) -> (IO (Ptr CChar)))
foreign import ccall safe "gnome_vfs_drive_get_id"
gnome_vfs_drive_get_id :: ((Ptr Drive) -> (IO CULong))
foreign import ccall safe "gnome_vfs_drive_get_mounted_volumes"
gnome_vfs_drive_get_mounted_volumes :: ((Ptr Drive) -> (IO (Ptr ())))
foreign import ccall safe "gnome_vfs_drive_is_connected"
gnome_vfs_drive_is_connected :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "gnome_vfs_drive_is_mounted"
gnome_vfs_drive_is_mounted :: ((Ptr Drive) -> (IO CInt))
foreign import ccall safe "gnome_vfs_drive_is_user_visible"
gnome_vfs_drive_is_user_visible :: ((Ptr Drive) -> (IO CInt))