## RBRemovableMediaSource RBRemovableMediaSource — Base class for sources representing removable media |

## Synopsis

                        RBRemovableMediaSource;
                        RBRemovableMediaSourceClass;
    char*               rb_removable_media_source_build_dest_uri
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry,
                                                             const char *mimetype,
                                                             const char *extension);
    void                rb_removable_media_source_track_added
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry,
                                                             const char *uri,
                                                             guint64 filesize,
                                                             const char *mimetype);
    void                rb_removable_media_source_track_add_error
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry,
                                                             const char *uri,
                                                             GError *error);
    GList *             rb_removable_media_source_get_mime_types
                                                            (RBRemovableMediaSource *source);
    GList *             rb_removable_media_source_get_format_descriptions
                                                            (RBRemovableMediaSource *source);
    gboolean            rb_removable_media_source_should_paste
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry);
    gboolean            rb_removable_media_source_should_paste_no_duplicate
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GtkContainer
                               +----GtkBox
                                     +----GtkHBox
                                           +----RBSource
                                                 +----RBBrowserSource
                                                       +----RBRemovableMediaSource

## Implemented Interfaces

RBRemovableMediaSource implements AtkImplementorIface, GtkBuildable and GtkOrientable.

## Properties

      "mount"                    GMount*               : Read / Write / Construct Only
      "volume"                   GVolume*              : Read / Write / Construct Only

## Description

This class provides support for transferring (and transcoding) entries to the device using drag and drop or cut and paste. The implementation must at minimum provide methods for returning a list of supported media types, and for constructing destination URIs for transfers.

## Details

### RBRemovableMediaSource

    typedef struct _RBRemovableMediaSource RBRemovableMediaSource;

### RBRemovableMediaSourceClass

    typedef struct {
    	RBBrowserSourceClass parent;

    	char*		(*impl_build_dest_uri) (RBRemovableMediaSource *source,
    						 RhythmDBEntry *entry,
    						 const char *mimetype,
    						 const char *extension);
    	GList*		(*impl_get_mime_types) (RBRemovableMediaSource *source);
    	gboolean (*impl_track_added) (RBRemovableMediaSource *source,
    						 RhythmDBEntry *entry,
    						 const char *uri,
    						 guint64 dest_size,
    						 const char *mimetype);
    	gboolean (*impl_track_add_error) (RBRemovableMediaSource *source,
    						 RhythmDBEntry *entry,
    						 const char *uri,
    						 GError *error);
    	gboolean (*impl_should_paste) (RBRemovableMediaSource *source,
    						 RhythmDBEntry *entry);
    } RBRemovableMediaSourceClass;

### rb_removable_media_source_build_dest_uri ()

    char*               rb_removable_media_source_build_dest_uri
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry,
                                                             const char *mimetype,
                                                             const char *extension);

Constructs a URI to use as the destination for a transfer or transcoding operation. The URI may be on the device itself, if the device is mounted into the normal filesystem or through gvfs, or it may be a temporary location used to store the file before uploading it to the device.

The destination URI should conform to the device's normal URI format, and should use the provided extension instead of the extension from the source entry.

`source` : | an RBRemovableMediaSource
`entry` : | the RhythmDBEntry to build a URI for
`mimetype` : | destination media type
`extension` : | extension associated with destination media type
Returns : | constructed URI

### rb_removable_media_source_track_added ()

    void                rb_removable_media_source_track_added
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry,
                                                             const char *uri,
                                                             guint64 filesize,
                                                             const char *mimetype);

This is called when a transfer to the device has completed. If the source's impl_track_added method returns `TRUE`, the destination URI will be added to the database using the entry type for the device.

If the source uses a temporary area as the destination for transfers, it can instead upload the destination file to the device and create an entry for it, then return `FALSE`.

`source` : | an RBRemovableMediaSource
`entry` : | the source RhythmDBEntry for the transfer
`uri` : | the destination URI
`filesize` : | size of the destination file
`mimetype` : | media type of the destination file

### rb_removable_media_source_track_add_error ()

    void                rb_removable_media_source_track_add_error
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry,
                                                             const char *uri,
                                                             GError *error);

This is called when a transfer fails. If the source's impl_track_add_error implementation returns `TRUE`, an error dialog will be displayed to the user containing the error message, unless the error indicates that the destination file already exists.

`source` : | an RBRemovableMediaSource
`entry` : | the source RhythmDBEntry for the transfer
`uri` : | the destination URI
`error` : | the transfer error information

### rb_removable_media_source_get_mime_types ()

    GList *             rb_removable_media_source_get_mime_types
                                                            (RBRemovableMediaSource *source);

Returns a GList of allocated media type strings describing the formats supported by the device. If possible, these should be sorted in order of preference, as the first entry in the list for which an encoder is available will be used.

Common media types include "audio/mpeg" for MP3, "application/ogg" for Ogg Vorbis, "audio/x-flac" for FLAC, and "audio/x-aac" for MP4/AAC.

`source` : | an RBRemovableMediaSource
Returns : | list of media types

### rb_removable_media_source_get_format_descriptions ()

    GList *             rb_removable_media_source_get_format_descriptions
                                                            (RBRemovableMediaSource *source);

Returns a GList of allocated media format descriptions for the formats supported by the device. The list and the strings it holds must be freed by the caller.

`source` : | a RBRemovableMediaSource
Returns : | list of descriptions.

### rb_removable_media_source_should_paste ()

    gboolean            rb_removable_media_source_should_paste
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry);

Checks whether `entry` should be transferred to the device. The source can check whether a matching entry already exists on the device, for instance. See `rb_removable_media_source_should_paste_no_duplicate` a useful implementation.

`source` : | an RBRemovableMediaSource
`entry` : | a RhythmDBEntry to consider pasting
Returns : | `TRUE` if the entry should be transferred to the device

### rb_removable_media_source_should_paste_no_duplicate ()

    gboolean            rb_removable_media_source_should_paste_no_duplicate
                                                            (RBRemovableMediaSource *source,
                                                             RhythmDBEntry *entry);

This implementation of rb_removable_media_should_paste checks for an existing entry on the device that matches the title, album, artist, and track number of the entry being considered.

`source` : | an RBRemovableMediaSource
`entry` : | a RhythmDBEntry to consider pasting
Returns : | `TRUE` if the entry should be transferred to the device.

## Property Details

### The `"mount"` property

      "mount"                    GMount*               : Read / Write / Construct Only

The GMount object that the source represents

### The `"volume"` property

      "volume"                   GVolume*              : Read / Write / Construct Only

The GVolume object that the source represents (optional)