mtp-0.1.1.1: Bindings to libmtp

Portabilitynot portable
Stabilityunstable
MaintainerJoachim Fasting <joachim.fasting@gmail.com>

MTP

Contents

Description

Bindings to libmtp. High-level interface.

Usage:

 import qualified MTP
 main = do
 MTP.init
 MTP.withFirstDevice MTP.getDeviceVersion

Synopsis

Types

data MTPHandle Source

A handle to an MTP device connection.

data File Source

File metadata.

Instances

data Folder Source

Folder metadata.

data FileType Source

Filetype enumeration.

Constants

version :: IntegerSource

MTP library version.

Device management

init :: IO ()Source

Initialize MTP.

getFirstDevice :: IO MTPHandleSource

Connect to the first available MTP device.

releaseDevice :: MTPHandle -> IO ()Source

Close connection to a MTP device. The handle is unusable after this.

resetDevice :: MTPHandle -> IO ()Source

Reset device.

withFirstDevice :: (MTPHandle -> IO a) -> IO aSource

Open a connection to the first available MTP device and run an action, closing the connection afterwards.

getDeviceVersion :: MTPHandle -> IO StringSource

Get device hardware and firmware version.

getManufacturerName :: MTPHandle -> IO StringSource

Get the device manufacturer name.

getModelName :: MTPHandle -> IO StringSource

Get the device model name.

getSerialNumber :: MTPHandle -> IO StringSource

Get the device serial number.

getFriendlyName :: MTPHandle -> IO StringSource

Get the owner string aka. the "friendly name".

getBatteryLevel :: MTPHandle -> IO (Int, Int)Source

Get battery level, maximum and current.

getSupportedFileTypes :: MTPHandle -> IO [FileType]Source

Get a list of supported file types.

File management

getFileListing :: MTPHandle -> IO [File]Source

Get a list of all files stored on the device.

getFile :: MTPHandle -> Int -> FilePath -> IO ()Source

Copy a file from the device to a local file.

sendFile :: MTPHandle -> FilePath -> IO ()Source

Send a local file to the device.

hGetFile :: MTPHandle -> Int -> Handle -> IO ()Source

Get a file from the device to a file handle.

hSendFile :: MTPHandle -> Handle -> File -> IO ()Source

Send a file to the device from a file handle.

setFileName :: MTPHandle -> File -> String -> IO ()Source

Rename a file on the device.

Track management

emptyTrack :: TrackSource

An empty track.

doesTrackExist :: MTPHandle -> Int -> IO BoolSource

Test whether a track exists on the device.

getTrackListing :: MTPHandle -> IO [Track]Source

Get a list of all tracks stored on the device.

getTrack :: MTPHandle -> Int -> FilePath -> IO ()Source

Copy a track from the device to a local file.

sendTrack :: MTPHandle -> FilePath -> Track -> IO ()Source

Send a local track to the device, using the supplied metadata.

hGetTrack :: MTPHandle -> Int -> Handle -> IO ()Source

Copy a track from the device to a file handle.

hSendTrack :: MTPHandle -> Handle -> Track -> IO ()Source

Send a track to the device from a file handle.

updateTrack :: MTPHandle -> Track -> IO ()Source

Update track metadata.

getTrackMetadata :: MTPHandle -> Int -> IO (Maybe Track)Source

Get metadata for a single track.

setTrackName :: MTPHandle -> Track -> String -> IO ()Source

Rename a single track.

Folder management

createFolderSource

Arguments

:: MTPHandle 
-> String

Folder name

-> Int

Parent ID

-> Int

Storage ID

-> IO Int

ID to new folder

Create a new folder.

getFolderList :: MTPHandle -> IO [Folder]Source

Get a list of all folders on the device.

setFolderName :: MTPHandle -> Folder -> String -> IO ()Source

Rename a folder.

Audio/video playlist management

getPlaylistList :: MTPHandle -> IO [Playlist]Source

Get a list of playlists on the device.

getPlaylist :: MTPHandle -> Int -> IO (Maybe Playlist)Source

Get a single playlist by ID.

createPlaylist :: MTPHandle -> Playlist -> IO ()Source

Create a new playlist using the metadata supplied.

updatePlaylist :: MTPHandle -> Playlist -> IO ()Source

Update an existing playlist.

setPlaylistName :: MTPHandle -> Playlist -> String -> IO ()Source

Rename an existing playlist. The expected name suffix is ".pla".

Object management

deleteObject :: MTPHandle -> Int -> IO ()Source

Delete a single file, track, playlist, folder or any other object.

setObjectName :: MTPHandle -> Int -> String -> IO ()Source

Set the filename of any object.

Extras

findFileType :: FilePath -> FileTypeSource

Find the FileType for a given file name.