New e-d-s backend which indexes all local addressbooks and calendars.
[beagle.git] / Util / Tag.cs
blob2e97baf36cd3bdc8b800827bf8324bd57170be16
1 //
2 // Tag.cs : Uniform interface for all audio tag types. It handles the most common
3 // fields used in music files.
4 //
5 // Author:
6 // Raphaël Slinckx <raf.raf@wol.be>
7 //
8 // Copyright 2004 (C) Raphaël Slinckx
9 //
12 // Permission is hereby granted, free of charge, to any person obtaining a
13 // copy of this software and associated documentation files (the "Software"),
14 // to deal in the Software without restriction, including without limitation
15 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
16 // and/or sell copies of the Software, and to permit persons to whom the
17 // Software is furnished to do so, subject to the following conditions:
19 // The above copyright notice and this permission notice shall be included in
20 // all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28 // DEALINGS IN THE SOFTWARE.
31 using System;
32 using System.IO;
33 using System.Text;
34 using System.Collections;
36 namespace Beagle.Util.AudioUtil {
38 public class Tag {
40 protected Hashtable fields;
42 public Tag ()
44 fields = new Hashtable ();
45 fields["TITLE"] = "";
46 fields["ALBUM"] = "";
47 fields["ARTIST"] = "";
48 fields["GENRE"] = "";
49 fields["TRACK"] = "";
50 fields["YEAR"] = "";
51 fields["COMMENT"] = "";
52 fields["VENDOR"] = "";
55 public string Title {
56 get {
57 return (string) fields["TITLE"];
59 set {
60 if(value == null)
61 fields["TITLE"] = "";
62 fields["TITLE"] = value;
66 public string Album {
67 get {
68 return (string) fields["ALBUM"];
70 set {
71 if(value == null)
72 fields["ALBUM"] = "";
73 fields["ALBUM"] = value;
78 public string Artist {
79 get {
80 return (string) fields["ARTIST"];
82 set {
83 if(value == null)
84 fields["ARTIST"] = "";
85 fields["ARTIST"] = value;
90 public string Genre {
91 get {
92 return (string) fields["GENRE"];
94 set {
95 if(value == null)
96 fields["GENRE"] = "";
97 fields["GENRE"] = value;
101 public string Track {
102 get {
103 return (string) fields["TRACK"];
105 set {
106 if(value == null)
107 fields["TRACK"] = "";
108 fields["TRACK"] = value;
112 public string Year {
113 get {
114 return (string) fields["YEAR"];
116 set {
117 if(value == null)
118 fields["YEAR"] = "";
119 fields["YEAR"] = value;
123 public string Comment {
124 get {
125 return (string) fields["COMMENT"];
127 set {
128 if(value == null)
129 fields["COMMENT"] = "";
130 fields["COMMENT"] = value;
134 public string Vendor {
135 get {
136 return (string) fields["VENDOR"];
138 set {
139 if(value == null)
140 fields["VENDOR"] = "";
141 fields["VENDOR"] = value;
145 public override string ToString ()
147 string s = "Tag content:\n";
148 foreach (DictionaryEntry en in fields) {
149 s += "\t";
150 s += en.Key;
151 s += " : ";
152 s += en.Value;
153 s += "\n";
155 return s.Substring (0, s.Length-1);
158 public void Merge (Tag tag)
160 if( Title.Trim () == "")
161 Title = tag.Title;
162 if( Artist.Trim () == "")
163 Artist = tag.Artist;
164 if( Album.Trim () == "")
165 Album = tag.Album;
166 if( Year.Trim () == "")
167 Year = tag.Year;
168 if( Comment.Trim () == "")
169 Comment = tag.Comment;
170 if( Track.Trim () == "")
171 Track = tag.Track;
172 if( Genre.Trim () == "")
173 Genre = tag.Genre;