2
// DeviceMediaCapabilities.cs
5
// Gabriel Burt <gburt@novell.com>
7
// Copyright (C) 2008 Novell, Inc.
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
using System.Collections.Generic;
32
using Banshee.Hardware;
34
namespace Banshee.HalBackend
36
public class DeviceMediaCapabilities : IDeviceMediaCapabilities
38
private Hal.Device device;
40
public DeviceMediaCapabilities (Hal.Device device)
45
private int? cover_art_size;
46
public int CoverArtSize {
48
if (cover_art_size == null) {
49
cover_art_size = SafelyGetInt ("portable_audio_player.cover_art_size", -1);
51
return cover_art_size.Value;
55
private int? folder_depth;
56
public int FolderDepth {
58
if (folder_depth == null) {
59
folder_depth = SafelyGetInt ("portable_audio_player.folder_depth", -1);
61
return folder_depth.Value;
65
private string [] audio_folders;
66
public string [] AudioFolders {
68
if (audio_folders == null) {
69
audio_folders = SafelyGetStringList ("portable_audio_player.audio_folders");
75
private string [] video_folders;
76
public string [] VideoFolders {
78
if (video_folders == null) {
79
video_folders = SafelyGetStringList ("portable_audio_player.video_folders");
85
private string cover_art_file_name;
86
public string CoverArtFileName {
88
if (cover_art_file_name == null) {
89
cover_art_file_name = SafelyGetString ("portable_audio_player.cover_art_file_name");
91
return cover_art_file_name;
95
private string cover_art_file_type;
96
public string CoverArtFileType {
98
if (cover_art_file_type == null) {
99
cover_art_file_type = SafelyGetString ("portable_audio_player.cover_art_file_type");
101
return cover_art_file_type;
105
private string [] playlist_formats;
106
public string [] PlaylistFormats {
108
if (playlist_formats == null) {
109
playlist_formats = SafelyGetStringList ("portable_audio_player.playlist_format");
111
return playlist_formats;
115
private string playlist_path;
116
public string PlaylistPath {
118
if (playlist_path == null) {
119
playlist_path = SafelyGetString ("portable_audio_player.playlist_path");
121
return playlist_path;
125
private string [] playback_formats;
126
public string [] PlaybackMimeTypes {
128
if (playback_formats == null) {
129
playback_formats = SafelyGetStringList ("portable_audio_player.output_formats");
131
return playback_formats;
135
private string SafelyGetString (string name)
138
if (device.PropertyExists (name)) {
145
private string[] SafelyGetStringList (string name)
148
if (device.PropertyExists (name)) {
149
return device.GetPropertyStringList (name);
152
return new string [0];
155
private int SafelyGetInt (string name, int def)
158
if (device.PropertyExists (name)) {
159
return device.GetPropertyInteger (name);
165
public bool IsType (string type)
167
if (device.PropertyExists ("portable_audio_player.type")) {
168
if (device ["portable_audio_player.type"] == type) {
173
if (device.PropertyExists ("portable_audio_player.access_method.protocols")) {
174
if (Array.IndexOf (device.GetPropertyStringList ("portable_audio_player.access_method.protocols"), type) != -1) {