~ubuntu-branches/ubuntu/intrepid/rhythmbox/intrepid

« back to all changes in this revision

Viewing changes to shell/rb-removable-media-manager.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2008-09-03 10:54:50 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20080903105450-mslsln15n2ap6g7o
Tags: 0.11.6svn20080903-0ubuntu1
* New upstream snapshot:
  - doesn't crash when eject an audio player (lp: #263268)
* debian/patches/80_new_libmtp_build.patch:
  - the change is in the new version
* debian/rules:
  - don't specify a gecko variant that's not required in the new version

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 *
29
29
 */
30
30
 
 
31
/**
 
32
 * SECTION:rb-removable-media-maanger
 
33
 * @short_description: handling of removable media such as audio CDs and DAP devices
 
34
 * 
 
35
 * The removable media manager maintains the mapping between GIO GVolume and GMount
 
36
 * objects and rhythmbox sources, and also performs track transfers between
 
37
 * removable media sources and the library.
 
38
 */
 
39
 
31
40
#include "config.h"
32
41
 
33
42
#include <string.h>
167
176
        object_class->set_property = rb_removable_media_manager_set_property;
168
177
        object_class->get_property = rb_removable_media_manager_get_property;
169
178
 
 
179
        /**
 
180
         * RBRemovableMediaManager:source:
 
181
         *
 
182
         * The current selected source.
 
183
         */
170
184
        g_object_class_install_property (object_class,
171
185
                                         PROP_SOURCE,
172
186
                                         g_param_spec_object ("source",
174
188
                                                              "RBSource object",
175
189
                                                              RB_TYPE_SOURCE,
176
190
                                                              G_PARAM_READWRITE));
 
191
        /**
 
192
         * RBRemovableMediaManager:shell:
 
193
         *
 
194
         * The #RBShell instance.
 
195
         */
177
196
        g_object_class_install_property (object_class,
178
197
                                         PROP_SHELL,
179
198
                                         g_param_spec_object ("shell",
182
201
                                                              RB_TYPE_SHELL,
183
202
                                                              G_PARAM_READWRITE));
184
203
 
 
204
        /**
 
205
         * RBRemovableMediaManager:scanned:
 
206
         *
 
207
         * This is set to TRUE when the removable media manager has scanned
 
208
         * all existing volumes and mounts.  When a plugin that handles removable
 
209
         * media is activated, it should request a new scan if this property is
 
210
         * already set to TRUE.
 
211
         */
185
212
        g_object_class_install_property (object_class,
186
213
                                         PROP_SCANNED,
187
214
                                         g_param_spec_boolean ("scanned",
190
217
                                                               FALSE,
191
218
                                                               G_PARAM_READABLE));
192
219
 
 
220
        /**
 
221
         * RBRemovableMediaManager::medium-added:
 
222
         * @mgr: the #RBRemovableMediaManager
 
223
         * @source: the newly added #RBSource
 
224
         *
 
225
         * Emitted when a new source is added for a removable medium.
 
226
         */
193
227
        rb_removable_media_manager_signals[MEDIUM_ADDED] =
194
228
                g_signal_new ("medium_added",
195
229
                              RB_TYPE_REMOVABLE_MEDIA_MANAGER,
200
234
                              G_TYPE_NONE,
201
235
                              1, G_TYPE_OBJECT);
202
236
 
 
237
        /**
 
238
         * RBRemovableMediaManager::transfer-progress:
 
239
         * @mgr: the #RBRemovableMediaManager
 
240
         * @done: number of tracks that have been fully transferred
 
241
         * @total: total number of tracks to transfer
 
242
         * @progress: fraction of the current track that has been transferred
 
243
         *
 
244
         * Emitted throughout the track transfer process to allow UI elements
 
245
         * showing transfer progress to be updated.
 
246
         */
203
247
        rb_removable_media_manager_signals[TRANSFER_PROGRESS] =
204
248
                g_signal_new ("transfer-progress",
205
249
                              RB_TYPE_REMOVABLE_MEDIA_MANAGER,
210
254
                              G_TYPE_NONE,
211
255
                              3, G_TYPE_INT, G_TYPE_INT, G_TYPE_DOUBLE);
212
256
 
 
257
        /**
 
258
         * RBRemovableMediaManager::create-source-volume
 
259
         * @mgr: the #RBRemovableMediaManager
 
260
         * @volume: the #GVolume 
 
261
         *
 
262
         * Emitted when a new volume is added to allow plugins to create a
 
263
         * corresponding #RBSource.  The first signal handler that returns
 
264
         * a source wins.  A plugin should only use this signal if it
 
265
         * doesn't require the volume to be mounted.  If the volume must be
 
266
         * mounted to be useful, use the create-source-mount signal instead.
 
267
         */
213
268
        rb_removable_media_manager_signals[CREATE_SOURCE_VOLUME] =
214
269
                g_signal_new ("create-source-volume",
215
270
                              RB_TYPE_REMOVABLE_MEDIA_MANAGER,
219
274
                              rb_marshal_OBJECT__OBJECT,
220
275
                              RB_TYPE_SOURCE,
221
276
                              1, G_TYPE_VOLUME);
 
277
 
 
278
        /**
 
279
         * RBRemovableMediaManager::create-source-mount
 
280
         * @mgr: the #RBRemovableMediaManager
 
281
         * @mount: the #GMount
 
282
         *
 
283
         * Emitted when a new mount is added to allow plugins to create a
 
284
         * corresponding #RBSource.  The first signal handler that returns
 
285
         * a source wins.  If a source was created for the #GVolume
 
286
         * for a mount, then this signal will not be emitted.
 
287
         */
222
288
        rb_removable_media_manager_signals[CREATE_SOURCE_MOUNT] =
223
289
                g_signal_new ("create-source-mount",
224
290
                              RB_TYPE_REMOVABLE_MEDIA_MANAGER,
356
422
        }
357
423
}
358
424
 
 
425
/**
 
426
 * rb_removable_media_manager_new:
 
427
 * @shell: the #RBShell
 
428
 *
 
429
 * Creates the #RBRemovableMediaManager instance.
 
430
 */
359
431
RBRemovableMediaManager *
360
432
rb_removable_media_manager_new (RBShell *shell)
361
433
{
813
885
        rb_removable_media_manager_scan (manager);
814
886
}
815
887
 
 
888
/**
 
889
 * rb_removable_media_manager_scan:
 
890
 * @manager: the #RBRemovableMediaManager
 
891
 *
 
892
 * Initiates a new scan of all attached media.  Newly activated plugins that use
 
893
 * the create-source-volume or create-source-mount signals should call this if
 
894
 * the 'scanned' property is %TRUE.  Otherwise, the first scan will catch any
 
895
 * existing volumes or mounts that the plugin is interested in.
 
896
 */
816
897
void
817
898
rb_removable_media_manager_scan (RBRemovableMediaManager *manager)
818
899
{
895
976
static void
896
977
error_cb (RBEncoder *encoder, GError *error, TransferData *data)
897
978
{
 
979
        /* ignore 'file exists' */
 
980
        if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
 
981
                rb_debug ("ignoring 'file exists' error for %s", data->dest);
 
982
                data->failed = TRUE;
 
983
                return;
 
984
        }
 
985
 
898
986
        rb_debug ("Error transferring track to %s: %s", data->dest, error->message);
899
987
        rb_error_dialog (NULL, _("Error transferring track"), "%s", error->message);
900
988
 
970
1058
        rb_encoder_encode (encoder, data->entry, data->dest, data->mime_types);
971
1059
}
972
1060
 
 
1061
/**
 
1062
 * rb_removable_media_manager_queue_transfer:
 
1063
 * @manager: the #RBRemovableMediaManager
 
1064
 * @entry: the #RhythmDBEntry to transfer
 
1065
 * @dest: the destination URI
 
1066
 * @mime_types: a list of acceptable output MIME types
 
1067
 * @callback: function to call when the transfer is complete
 
1068
 * @userdata: data to pass to the callback
 
1069
 *
 
1070
 * Initiates a track transfer.  This will transfer the track identified by the
 
1071
 * #RhythmDBEntry to the given destination, transcoding it if its
 
1072
 * current media type is not in the list of acceptable output types.
 
1073
 */
973
1074
void
974
1075
rb_removable_media_manager_queue_transfer (RBRemovableMediaManager *manager,
975
1076
                                          RhythmDBEntry *entry,