~ubuntu-branches/ubuntu/quantal/rhythmbox/quantal-proposed

« back to all changes in this revision

Viewing changes to plugins/generic-player/rb-generic-player-source.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher, Rico Tzschichholz
  • Date: 2011-12-05 19:31:23 UTC
  • mfrom: (1.1.60)
  • Revision ID: package-import@ubuntu.com-20111205193123-89047p8yplb0w1vx
Tags: 2.90.1~20111126.89c872b0-0ubuntu1
* Upload the new version to Ubuntu, should solve those issues:
  - the lack of rhythmbox-client command (lp: #875064)
  - the music sharing preferences dialog (lp: #894153)
  - several segfaults (lp: #859195, #814614)
* debian/control.in:
  - let the rhythmbox gir depends on gir1.2-peas-1.0 (lp: #874973)

[ Rico Tzschichholz ]
* New upstream git snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "rb-generic-player-source.h"
43
43
#include "rb-generic-player-playlist-source.h"
44
44
#include "rb-removable-media-manager.h"
 
45
#include "rb-transfer-target.h"
 
46
#include "rb-device-source.h"
45
47
#include "rb-debug.h"
46
48
#include "rb-util.h"
47
49
#include "rb-file-helpers.h"
54
56
#include "rb-sync-settings.h"
55
57
#include "rb-missing-plugins.h"
56
58
 
 
59
static void rb_generic_player_device_source_init (RBDeviceSourceInterface *interface);
 
60
static void rb_generic_player_source_transfer_target_init (RBTransferTargetInterface *interface);
 
61
 
57
62
static void impl_constructed (GObject *object);
58
63
static void impl_dispose (GObject *object);
59
64
static void impl_set_property (GObject *object,
72
77
static void impl_get_status (RBDisplayPage *page, char **text, char **progress_text, float *progress);
73
78
 
74
79
static gboolean impl_can_paste (RBSource *source);
 
80
static RBTrackTransferBatch *impl_paste (RBSource *source, GList *entries);
75
81
static gboolean impl_can_delete (RBSource *source);
76
82
static void impl_delete (RBSource *source);
77
83
 
78
 
static char* impl_build_dest_uri (RBRemovableMediaSource *source,
 
84
static char* impl_build_dest_uri (RBTransferTarget *target,
79
85
                                  RhythmDBEntry *entry,
80
86
                                  const char *media_type,
81
87
                                  const char *extension);
102
108
enum
103
109
{
104
110
        PROP_0,
 
111
        PROP_MOUNT,
105
112
        PROP_IGNORE_ENTRY_TYPE,
106
113
        PROP_ERROR_ENTRY_TYPE,
107
114
        PROP_DEVICE_INFO
126
133
        gboolean read_only;
127
134
 
128
135
        MPIDDevice *device_info;
 
136
        GMount *mount;
129
137
 
130
138
} RBGenericPlayerSourcePrivate;
131
139
 
132
 
G_DEFINE_DYNAMIC_TYPE (RBGenericPlayerSource, rb_generic_player_source, RB_TYPE_MEDIA_PLAYER_SOURCE)
 
140
G_DEFINE_DYNAMIC_TYPE_EXTENDED (
 
141
        RBGenericPlayerSource,
 
142
        rb_generic_player_source,
 
143
        RB_TYPE_MEDIA_PLAYER_SOURCE,
 
144
        0,
 
145
        G_IMPLEMENT_INTERFACE_DYNAMIC (RB_TYPE_DEVICE_SOURCE, rb_generic_player_device_source_init)
 
146
        G_IMPLEMENT_INTERFACE_DYNAMIC (RB_TYPE_TRANSFER_TARGET, rb_generic_player_source_transfer_target_init))
 
147
 
133
148
#define GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_GENERIC_PLAYER_SOURCE, RBGenericPlayerSourcePrivate))
134
149
 
135
150
static void
139
154
        RBDisplayPageClass *page_class = RB_DISPLAY_PAGE_CLASS (klass);
140
155
        RBSourceClass *source_class = RB_SOURCE_CLASS (klass);
141
156
        RBMediaPlayerSourceClass *mps_class = RB_MEDIA_PLAYER_SOURCE_CLASS (klass);
142
 
        RBRemovableMediaSourceClass *rms_class = RB_REMOVABLE_MEDIA_SOURCE_CLASS (klass);
143
157
 
144
158
        object_class->set_property = impl_set_property;
145
159
        object_class->get_property = impl_get_property;
154
168
        source_class->impl_delete = impl_delete;
155
169
        source_class->impl_can_move_to_trash = (RBSourceFeatureFunc) rb_false_function;
156
170
        source_class->impl_can_paste = impl_can_paste;
 
171
        source_class->impl_paste = impl_paste;
157
172
 
158
173
        mps_class->impl_get_entries = impl_get_entries;
159
174
        mps_class->impl_get_capacity = impl_get_capacity;
163
178
        mps_class->impl_add_playlist = impl_add_playlist;
164
179
        mps_class->impl_remove_playlists = impl_remove_playlists;
165
180
 
166
 
        rms_class->impl_build_dest_uri = impl_build_dest_uri;
167
 
        rms_class->impl_should_paste = rb_removable_media_source_should_paste_no_duplicate;
168
 
 
169
181
        klass->impl_get_mount_path = default_get_mount_path;
170
182
        klass->impl_load_playlists = default_load_playlists;
171
183
        klass->impl_uri_from_playlist_uri = default_uri_from_playlist_uri;
192
204
                                                              "device information object",
193
205
                                                              MPID_TYPE_DEVICE,
194
206
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
195
 
 
196
 
 
 
207
        g_object_class_install_property (object_class,
 
208
                                         PROP_MOUNT,
 
209
                                         g_param_spec_object ("mount",
 
210
                                                              "mount",
 
211
                                                              "GMount object",
 
212
                                                              G_TYPE_MOUNT,
 
213
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
197
214
 
198
215
        g_type_class_add_private (klass, sizeof (RBGenericPlayerSourcePrivate));
199
216
}
200
217
 
201
218
static void
 
219
rb_generic_player_device_source_init (RBDeviceSourceInterface *interface)
 
220
{
 
221
        /* nothing */
 
222
}
 
223
 
 
224
static void
 
225
rb_generic_player_source_transfer_target_init (RBTransferTargetInterface *interface)
 
226
{
 
227
        interface->build_dest_uri = impl_build_dest_uri;
 
228
}
 
229
 
 
230
static void
202
231
rb_generic_player_source_class_finalize (RBGenericPlayerSourceClass *klass)
203
232
{
204
233
}
215
244
        RBGenericPlayerSource *source;
216
245
        RBGenericPlayerSourcePrivate *priv;
217
246
        RhythmDBEntryType *entry_type;
218
 
        GMount *mount;
219
247
        char **playlist_formats;
220
248
        char **output_formats;
221
249
        char *mount_name;
229
257
 
230
258
        priv = GET_PRIVATE (source);
231
259
 
 
260
        rb_device_source_set_display_details (RB_DEVICE_SOURCE (source));
 
261
 
232
262
        g_object_get (source,
233
263
                      "shell", &shell,
234
264
                      "entry-type", &entry_type,
235
265
                      NULL);
236
266
 
237
267
        g_object_get (shell, "db", &priv->db, NULL);
238
 
        
 
268
 
239
269
        priv->import_errors = rb_import_errors_source_new (shell,
240
270
                                                           priv->error_type,
241
271
                                                           entry_type,
243
273
 
244
274
        g_object_unref (shell);
245
275
 
246
 
        g_object_get (source, "mount", &mount, NULL);
247
 
 
248
 
        root = g_mount_get_root (mount);
249
 
        mount_name = g_mount_get_name (mount);
 
276
        root = g_mount_get_root (priv->mount);
 
277
        mount_name = g_mount_get_name (priv->mount);
250
278
 
251
279
        info = g_file_query_filesystem_info (root, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, NULL, &error);
252
280
        if (error != NULL) {
260
288
 
261
289
        g_free (mount_name);
262
290
        g_object_unref (root);
263
 
        g_object_unref (mount);
264
291
 
265
292
        g_object_get (priv->device_info, "playlist-formats", &playlist_formats, NULL);
266
293
        if (playlist_formats != NULL && g_strv_length (playlist_formats) > 0) {
308
335
        case PROP_DEVICE_INFO:
309
336
                priv->device_info = g_value_dup_object (value);
310
337
                break;
 
338
        case PROP_MOUNT:
 
339
                priv->mount = g_value_dup_object (value);
 
340
                break;
311
341
        default:
312
342
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
313
343
                break;
329
359
        case PROP_DEVICE_INFO:
330
360
                g_value_set_object (value, priv->device_info);
331
361
                break;
 
362
        case PROP_MOUNT:
 
363
                g_value_set_object (value, priv->mount);
 
364
                break;
332
365
        default:
333
366
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
334
367
                break;
372
405
                priv->device_info = NULL;
373
406
        }
374
407
 
 
408
        if (priv->mount != NULL) {
 
409
                g_object_unref (priv->mount);
 
410
                priv->mount = NULL;
 
411
        }
 
412
 
375
413
        G_OBJECT_CLASS (rb_generic_player_source_parent_class)->dispose (object);
376
414
}
377
415
 
378
 
RBRemovableMediaSource *
 
416
RBSource *
379
417
rb_generic_player_source_new (GObject *plugin, RBShell *shell, GMount *mount, MPIDDevice *device_info)
380
418
{
381
419
        RBGenericPlayerSource *source;
437
475
                                                         "shell", shell,
438
476
                                                         "device-info", device_info,
439
477
                                                         "settings", g_settings_get_child (settings, "source"),
 
478
                                                         "toolbar-path", "/GenericPlayerSourceToolBar",
440
479
                                                         NULL));
441
480
        g_object_unref (settings);
442
481
 
443
482
        rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);
444
483
 
445
 
        return RB_REMOVABLE_MEDIA_SOURCE (source);
 
484
        return RB_SOURCE (source);
446
485
}
447
486
 
448
487
static void
478
517
        RBShell *shell;
479
518
 
480
519
        GDK_THREADS_ENTER ();
481
 
        
 
520
 
482
521
        g_object_get (source, "shell", &shell, NULL);
483
522
        rb_shell_append_display_page (shell, RB_DISPLAY_PAGE (priv->import_errors), RB_DISPLAY_PAGE (source));
484
523
        g_object_unref (shell);
488
527
 
489
528
        g_object_unref (priv->import_job);
490
529
        priv->import_job = NULL;
491
 
        
 
530
 
492
531
        rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (source));
493
532
 
494
533
        GDK_THREADS_LEAVE ();
555
594
        RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source);
556
595
 
557
596
        if (priv->mount_path == NULL) {
558
 
                GMount *mount;
559
597
                GFile *root;
560
598
 
561
 
                g_object_get (source, "mount", &mount, NULL);
562
 
 
563
 
                root = g_mount_get_root (mount);
 
599
                root = g_mount_get_root (priv->mount);
564
600
                if (root != NULL) {
565
601
                        priv->mount_path = g_file_get_uri (root);
566
602
                        g_object_unref (root);
567
603
                }
568
 
 
569
 
                g_object_unref (mount);
570
604
        }
571
605
 
572
606
        return g_strdup (priv->mount_path);
848
882
        return (priv->read_only == FALSE);
849
883
}
850
884
 
 
885
static RBTrackTransferBatch *
 
886
impl_paste (RBSource *source, GList *entries)
 
887
{
 
888
        return rb_transfer_target_transfer (RB_TRANSFER_TARGET (source), entries);
 
889
}
 
890
 
851
891
static gboolean
852
892
impl_can_delete (RBSource *source)
853
893
{
984
1024
}
985
1025
 
986
1026
static char *
987
 
impl_build_dest_uri (RBRemovableMediaSource *source,
 
1027
impl_build_dest_uri (RBTransferTarget *target,
988
1028
                     RhythmDBEntry *entry,
989
1029
                     const char *media_type,
990
1030
                     const char *extension)
991
1031
{
992
 
        RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (source);
 
1032
        RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (target);
993
1033
        const char *in_artist;
994
1034
        char *artist, *album, *title;
995
1035
        gulong track_number, disc_number;
1082
1122
        }
1083
1123
        g_strfreev (audio_folders);
1084
1124
 
1085
 
        mount_path = rb_generic_player_source_get_mount_path (RB_GENERIC_PLAYER_SOURCE (source));
 
1125
        mount_path = rb_generic_player_source_get_mount_path (RB_GENERIC_PLAYER_SOURCE (target));
1086
1126
        path = g_build_filename (mount_path, folders, file, NULL);
1087
1127
        g_free (file);
1088
1128
        g_free (mount_path);
1331
1371
        g_free (serial_id);
1332
1372
 
1333
1373
        str = g_string_new ("");
1334
 
        output_formats = rb_removable_media_source_get_format_descriptions (RB_REMOVABLE_MEDIA_SOURCE (source));
 
1374
        output_formats = rb_transfer_target_get_format_descriptions (RB_TRANSFER_TARGET (source));
1335
1375
        for (t = output_formats; t != NULL; t = t->next) {
1336
1376
                if (t != output_formats) {
1337
1377
                        g_string_append (str, "\n");