~ubuntu-branches/debian/experimental/brasero/experimental

« back to all changes in this revision

Viewing changes to libbrasero-media/brasero-medium-monitor.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2011-03-29 16:33:51 UTC
  • mfrom: (1.3.18 upstream) (5.2.8 sid)
  • Revision ID: james.westby@ubuntu.com-20110329163351-ac3wgbh4mplmhnht
Tags: 2.91.93-1
* Only depend on growisofs instead of dvd+rw-tools.
* New upstream pre-release.
* Update build-dependencies, package names, and paths.
* Require totem-plparser 2.32 since its soname changed.
* Do not include GIR package for now, since the versioning is broken 
  (see Bugzilla #646069).
* 01_pkglibdir.patch: dropped, upstream now has a variable we can use 
  for that effect.
* 11_nautilus_menu_no_display.patch, 31_link_libice.patch, 
  50_checksum.patch: dropped, merged upstream.
* 90_relibtoolize.patch: dropped, unnecessary.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
#include "brasero-media-private.h"
43
43
 
 
44
#include "brasero-drive-priv.h"
 
45
 
44
46
#include "scsi-device.h"
45
47
#include "scsi-utils.h"
46
48
#include "scsi-spc1.h"
80
82
 
81
83
 
82
84
/**
83
 
 * These definitions go here as they shouldn't be public and they're used only 
84
 
 * here.
85
 
 */
86
 
 
87
 
gboolean
88
 
brasero_drive_probing (BraseroDrive *drive);
89
 
 
90
 
/**
91
85
 * brasero_medium_monitor_get_drive:
92
86
 * @monitor: a #BraseroMediumMonitor
93
87
 * @device: the path of the device
163
157
 *
164
158
 * Gets the list of available drives that are of the given type.
165
159
 *
166
 
 * Return value: a #GSList or NULL
 
160
 * Return value: (element-type BraseroMedia.Drive) (transfer full): a #GSList of  #BraseroDrive or NULL. The list must be freed and the element unreffed when finished.
167
161
 **/
168
162
GSList *
169
163
brasero_medium_monitor_get_drives (BraseroMediumMonitor *monitor,
212
206
 *
213
207
 * Obtains the list of available media that are of the given type.
214
208
 *
215
 
 * Return value: a #GSList or NULL
 
209
 * Return value: (element-type BraseroMedia.Medium) (transfer full): a #GSList of  #BraseroMedium or NULL. The list must be freed and the element unreffed when finished.
216
210
 **/
217
211
GSList *
218
212
brasero_medium_monitor_get_media (BraseroMediumMonitor *monitor,
329
323
                                        g_object_ref (medium);
330
324
                                        continue;
331
325
                                }
332
 
                                continue;
333
326
                        }
334
327
                }
335
328
 
375
368
brasero_medium_monitor_is_drive (BraseroMediumMonitor *monitor,
376
369
                                 const gchar *device)
377
370
{
378
 
        BraseroMediumMonitorPrivate *priv;
379
371
        BraseroDeviceHandle *handle;
380
372
        BraseroScsiErrCode code;
381
373
        gboolean result;
382
374
 
383
 
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (monitor);
384
 
 
385
375
        BRASERO_MEDIA_LOG ("Testing drive %s", device);
386
376
 
387
377
        handle = brasero_device_handle_open (device, FALSE, &code);
396
386
        return result;
397
387
}
398
388
 
 
389
static BraseroDrive *
 
390
brasero_medium_monitor_drive_new (BraseroMediumMonitor *self,
 
391
                                  const gchar *device,
 
392
                                  GDrive *gdrive)
 
393
{
 
394
        BraseroMediumMonitorPrivate *priv;
 
395
        BraseroDrive *drive;
 
396
 
 
397
        if (!brasero_medium_monitor_is_drive (self, device))
 
398
                return NULL;
 
399
 
 
400
        priv = BRASERO_MEDIUM_MONITOR_PRIVATE (self);
 
401
        drive = g_object_new (BRASERO_TYPE_DRIVE,
 
402
                              "device", device,
 
403
                              "gdrive", gdrive,
 
404
                              NULL);
 
405
 
 
406
        priv->drives = g_slist_prepend (priv->drives, drive);
 
407
 
 
408
        g_signal_connect (drive,
 
409
                          "medium-added",
 
410
                          G_CALLBACK (brasero_medium_monitor_medium_added_cb),
 
411
                          self);
 
412
        g_signal_connect (drive,
 
413
                          "medium-removed",
 
414
                          G_CALLBACK (brasero_medium_monitor_medium_removed_cb),
 
415
                          self);
 
416
 
 
417
        return drive;
 
418
}
 
419
 
399
420
static void
400
421
brasero_medium_monitor_device_added (BraseroMediumMonitor *self,
401
422
                                     const gchar *device,
425
446
        }
426
447
 
427
448
        /* Make sure it's an optical drive */
428
 
        if (!brasero_medium_monitor_is_drive (self, device))
 
449
        drive = brasero_medium_monitor_drive_new (self, device, gdrive);
 
450
        if (!drive)
429
451
                return;
430
452
 
431
453
        BRASERO_MEDIA_LOG ("New drive added");
432
 
 
433
 
        drive = g_object_new (BRASERO_TYPE_DRIVE,
434
 
                              "device", device,
435
 
                              "gdrive", gdrive,
436
 
                              NULL);
437
 
        priv->drives = g_slist_prepend (priv->drives, drive);
438
 
 
439
 
        /* connect to signals. This must come before the g_signal_emit () so we
440
 
         * are the first to get an update on the medium inside. */
441
 
        g_signal_connect (drive,
442
 
                          "medium-added",
443
 
                          G_CALLBACK (brasero_medium_monitor_medium_added_cb),
444
 
                          self);
445
 
        g_signal_connect (drive,
446
 
                          "medium-removed",
447
 
                          G_CALLBACK (brasero_medium_monitor_medium_removed_cb),
448
 
                          self);
449
 
 
450
454
        g_signal_emit (self,
451
455
                       medium_monitor_signals [DRIVE_ADDED],
452
456
                       0,
490
494
         * associated but a GVolume. */
491
495
        gdrive = g_volume_get_drive (gvolume);
492
496
        if (gdrive) {
 
497
                BRASERO_MEDIA_LOG ("Existing GDrive skipping");
493
498
                g_object_unref (gdrive);
494
499
                return;
495
500
        }
585
590
                                                                          brasero_medium_monitor_disconnected_real, 
586
591
                                                                          self);
587
592
        }
588
 
        else if (associated_gdrive) {
589
 
                /* do nothing and wait for a "drive-disconnected" signal */
 
593
        /* else do nothing and wait for a "drive-disconnected" signal */
 
594
 
 
595
        if (associated_gdrive)
590
596
                g_object_unref (associated_gdrive);
591
 
        }
592
597
 
593
598
        g_object_unref (drive);
594
599
}
660
665
                gdrive = iter->data;
661
666
 
662
667
                device = g_drive_get_identifier (gdrive, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
663
 
                if (brasero_medium_monitor_is_drive (object, device)) {
664
 
                        drive = g_object_new (BRASERO_TYPE_DRIVE,
665
 
                                              "device", device,
666
 
                                              "gdrive", gdrive,
667
 
                                              NULL);
668
 
 
669
 
                        priv->drives = g_slist_prepend (priv->drives, drive);
670
 
 
671
 
                        g_signal_connect (drive,
672
 
                                          "medium-added",
673
 
                                          G_CALLBACK (brasero_medium_monitor_medium_added_cb),
674
 
                                          object);
675
 
                        g_signal_connect (drive,
676
 
                                          "medium-removed",
677
 
                                          G_CALLBACK (brasero_medium_monitor_medium_removed_cb),
678
 
                                          object);
679
 
                }
 
668
                brasero_medium_monitor_drive_new (object, device, gdrive);
680
669
                g_free (device);
681
670
        }
682
671
        g_list_foreach (drives, (GFunc) g_object_unref, NULL);
702
691
                        continue;
703
692
                }
704
693
 
705
 
                if (brasero_medium_monitor_is_drive (object, device)) {
706
 
                        drive = g_object_new (BRASERO_TYPE_DRIVE,
707
 
                                              "device", device,
708
 
                                              "gdrive", NULL,
709
 
                                              NULL);
710
 
                        priv->drives = g_slist_prepend (priv->drives, drive);
711
 
 
712
 
                        g_signal_connect (drive,
713
 
                                          "medium-added",
714
 
                                          G_CALLBACK (brasero_medium_monitor_medium_added_cb),
715
 
                                          object);
716
 
                        g_signal_connect (drive,
717
 
                                          "medium-removed",
718
 
                                          G_CALLBACK (brasero_medium_monitor_medium_removed_cb),
719
 
                                          object);
720
 
                }
721
 
 
 
694
                brasero_medium_monitor_drive_new (object, device, NULL);
722
695
                g_free (device);
723
696
        }
724
697
        g_list_foreach (volumes, (GFunc) g_object_unref, NULL);