Gio: bail from foreach iteration after finding null (bgo#721203)
[banshee.git] / src / Backends / Banshee.Gio / Banshee.Hardware.Gio / LowLevel / RawBlockDevice.cs
blob73448c631116bc761b790d63c45e6d83d0fa190b
1 //
2 // RawBlockDevice.cs
3 //
4 // Author:
5 // Alex Launi <alex.launi@gmail.com>
6 //
7 // Copyright (c) 2010 Alex Launi
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26 #if ENABLE_GIO_HARDWARE
27 using System;
28 using System.Collections.Generic;
30 using Banshee.Hardware;
32 namespace Banshee.Hardware.Gio
34 class RawBlockDevice : RawDevice
36 public RawBlockDevice (GLib.IDrive drive, Manager manager, GioDriveMetadataSource gioMetadata, UdevMetadataSource udevMetadata)
37 : base (manager, gioMetadata, udevMetadata)
39 Drive = drive;
42 GLib.IDrive Drive { get; set; }
44 public IEnumerable<Volume> Volumes {
45 get {
46 foreach (var notVolume in Drive.Volumes) {
47 var volume = GLib.VolumeAdapter.GetObject (notVolume as GLib.Object);
48 if (volume == null) {
49 yield return null;
50 continue;
52 var device = Manager.GudevDeviceFromGioVolume (volume);
53 if (device == null) {
54 yield return null;
55 continue;
57 yield return new Volume (new RawVolume (volume,
58 Manager,
59 new GioVolumeMetadataSource (volume),
60 new UdevMetadataSource (device)));
65 #region implemented abstract members of Banshee.Hardware.Gio.RawDevice
66 public override string Identifier {
67 get {
68 return Uuid;
72 public override string IdMediaPlayer {
73 get {
74 return UdevMetadata.IdMediaDevice;
78 public override bool IsRemovable {
79 get {
80 return Drive.CanEject ();
84 public override string Name {
85 get {
86 return Drive.Name;
90 public override string Model {
91 get {
92 return UdevMetadata.Model;
96 public override string Product {
97 get {
98 return "Product not implemented";
102 public override string Serial {
103 get {
104 return UdevMetadata.Serial;
108 public override string Subsystem {
109 get {
110 return UdevMetadata.Subsystem;
114 public override string Uuid {
115 get {
116 return UdevMetadata.Uuid;
120 public override string Vendor {
121 get {
122 return UdevMetadata.Vendor;
126 public override string GetPropertyString (string key)
128 return UdevMetadata.GetPropertyString (key);
131 public override double GetPropertyDouble (string key)
133 return UdevMetadata.GetPropertyDouble (key);
136 public override bool GetPropertyBoolean (string key)
138 return UdevMetadata.GetPropertyBoolean (key);
141 public override int GetPropertyInteger (string key)
143 return UdevMetadata.GetPropertyInteger (key);
146 public override ulong GetPropertyUInt64 (string key)
148 return UdevMetadata.GetPropertyUInt64 (key);
151 public override string[] GetPropertyStringList (string key)
153 return UdevMetadata.GetPropertyStringList (key);
156 public override bool PropertyExists (string key)
158 return UdevMetadata.PropertyExists (key);
160 #endregion
164 #endif