~kelemeng/banshee/bug743928

« back to all changes in this revision

Viewing changes to src/Backends/Banshee.Hal/Banshee.HalBackend/DeviceMediaCapabilities.cs

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2011-05-14 22:25:36 UTC
  • mfrom: (6.3.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20110514222536-u1x7ikxdqkmfvyuz
Tags: 2.1.0-1ubuntu1
* [2396c18] Merge from Debian Unstable, remaining changes:
  + Enable SoundMenu and Disable NotificationArea by default
  + Disable boo and karma extensions
  + Enable and recommnd u1ms and soundmenu extensions
  + Move desktop file for Meego UI to /usr/share/une/applications
  + Change the url for the Amazon store redirector
  + Create the U1MS widget earlier and bump libu1 requirement
* [9d7c600] Drop upstreamed u1ms-initialize-earlier patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// DeviceMediaCapabilities.cs
3
 
//
4
 
// Author:
5
 
//   Gabriel Burt <gburt@novell.com>
6
 
//
7
 
// Copyright (C) 2008 Novell, Inc.
8
 
//
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:
16
 
//
17
 
// The above copyright notice and this permission notice shall be
18
 
// included in all copies or substantial portions of the Software.
19
 
//
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.
27
 
//
28
 
 
29
 
using System;
30
 
using System.Collections.Generic;
31
 
 
32
 
using Banshee.Hardware;
33
 
 
34
 
namespace Banshee.HalBackend
35
 
{
36
 
    public class DeviceMediaCapabilities : IDeviceMediaCapabilities
37
 
    {
38
 
        private Hal.Device device;
39
 
 
40
 
        public DeviceMediaCapabilities (Hal.Device device)
41
 
        {
42
 
            this.device = device;
43
 
        }
44
 
 
45
 
        private int? cover_art_size;
46
 
        public int CoverArtSize {
47
 
            get {
48
 
                if (cover_art_size == null) {
49
 
                    cover_art_size = SafelyGetInt ("portable_audio_player.cover_art_size", -1);
50
 
                }
51
 
                return cover_art_size.Value;
52
 
            }
53
 
        }               
54
 
 
55
 
        private int? folder_depth;
56
 
        public int FolderDepth {
57
 
            get {
58
 
                if (folder_depth == null) {
59
 
                    folder_depth = SafelyGetInt ("portable_audio_player.folder_depth", -1);
60
 
                }
61
 
                return folder_depth.Value;
62
 
            }
63
 
        }
64
 
 
65
 
        private string [] audio_folders;
66
 
        public string [] AudioFolders {
67
 
            get {
68
 
                if (audio_folders == null) {
69
 
                    audio_folders = SafelyGetStringList ("portable_audio_player.audio_folders");
70
 
                }
71
 
                return audio_folders;
72
 
            }
73
 
        }
74
 
 
75
 
        private string [] video_folders;
76
 
        public string [] VideoFolders {
77
 
            get {
78
 
                if (video_folders == null) {
79
 
                    video_folders = SafelyGetStringList ("portable_audio_player.video_folders");
80
 
                }
81
 
                return video_folders;
82
 
            }
83
 
        }
84
 
 
85
 
        private string cover_art_file_name;
86
 
        public string CoverArtFileName {
87
 
            get {
88
 
                if (cover_art_file_name == null) {
89
 
                    cover_art_file_name = SafelyGetString ("portable_audio_player.cover_art_file_name");
90
 
                }
91
 
                return cover_art_file_name;
92
 
            }
93
 
        }
94
 
 
95
 
        private string cover_art_file_type;
96
 
        public string CoverArtFileType {
97
 
            get {
98
 
                if (cover_art_file_type == null) {
99
 
                    cover_art_file_type = SafelyGetString ("portable_audio_player.cover_art_file_type");
100
 
                }
101
 
                return cover_art_file_type;
102
 
            }
103
 
        }
104
 
 
105
 
        private string [] playlist_formats;
106
 
        public string [] PlaylistFormats {
107
 
            get {
108
 
                if (playlist_formats == null) {
109
 
                    playlist_formats = SafelyGetStringList ("portable_audio_player.playlist_format");
110
 
                }
111
 
                return playlist_formats;
112
 
            }
113
 
        }
114
 
 
115
 
        private string playlist_path;
116
 
        public string PlaylistPath {
117
 
            get {
118
 
                if (playlist_path == null) {
119
 
                    playlist_path = SafelyGetString ("portable_audio_player.playlist_path");
120
 
                }
121
 
                return playlist_path;
122
 
            }
123
 
        }
124
 
 
125
 
        private string [] playback_formats;
126
 
        public string [] PlaybackMimeTypes {
127
 
            get {
128
 
                if (playback_formats == null) {
129
 
                    playback_formats = SafelyGetStringList ("portable_audio_player.output_formats");
130
 
                }
131
 
                return playback_formats;
132
 
            }
133
 
        }
134
 
 
135
 
        private string SafelyGetString (string name)
136
 
        {
137
 
            try {
138
 
                if (device.PropertyExists (name)) {
139
 
                    return device[name];
140
 
                }
141
 
            } catch {}
142
 
            return null;
143
 
        }
144
 
 
145
 
        private string[] SafelyGetStringList (string name)
146
 
        {
147
 
            try {
148
 
                if (device.PropertyExists (name)) {
149
 
                    return device.GetPropertyStringList (name);
150
 
                }
151
 
            } catch {}
152
 
            return new string [0];
153
 
        }
154
 
 
155
 
        private int SafelyGetInt (string name, int def)
156
 
        {
157
 
            try {
158
 
                if (device.PropertyExists (name)) {
159
 
                    return device.GetPropertyInteger (name);
160
 
                }
161
 
            } catch {}
162
 
            return def;
163
 
        }
164
 
 
165
 
        public bool IsType (string type)
166
 
        {
167
 
            if (device.PropertyExists ("portable_audio_player.type")) {
168
 
                if (device ["portable_audio_player.type"] == type) {
169
 
                    return true;
170
 
                }
171
 
            }
172
 
 
173
 
            if (device.PropertyExists ("portable_audio_player.access_method.protocols")) {
174
 
                if (Array.IndexOf (device.GetPropertyStringList ("portable_audio_player.access_method.protocols"), type) != -1) {
175
 
                    return true;
176
 
                }
177
 
            }
178
 
 
179
 
            return false;
180
 
        }
181
 
    }
182
 
}