* tools/Info.cs: Add --list-backends, --list-static-indexes to
[beagle.git] / beagled / PropertyKeywordFu.cs
blobf95f0ffdf428060c6d4e6db21bccacfe5084b8c4
1 //
2 // PropertyKeywordFu.cs
3 //
4 // Copyright (C) 2005 Debajyoti Bera
5 //
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a
9 // copy of this software and associated documentation files (the "Software"),
10 // to deal in the Software without restriction, including without limitation
11 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 // and/or sell copies of the Software, and to permit persons to whom the
13 // Software is furnished to do so, subject to the following conditions:
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24 // DEALINGS IN THE SOFTWARE.
27 using System;
28 using System.Collections;
29 using System.IO;
30 using System.Text;
32 using Beagle;
33 using FSQ=Beagle.Daemon.FileSystemQueryable;
35 // FIXME crude hack, the list of property names should be registered by queryables
36 // while calling AddNewKeyword etc.
38 namespace Beagle.Daemon {
40 public class PropertyDetail {
41 private PropertyType type;
42 private string property_name;
43 // a short description, so that frontends can get the description from here
44 // and they dont need to guess the meaning of a query keyword (being too nice ?!)
45 private string short_desc;
47 public PropertyType Type {
48 get { return type;}
51 public string PropertyName {
52 get { return property_name;}
55 public string Description {
56 get { return short_desc; }
59 public PropertyDetail (PropertyType type, string property_name) {
60 this.type = type;
61 this.property_name = property_name;
62 this.short_desc = "";
65 public PropertyDetail (PropertyType type, string property_name, string desc) {
66 this.type = type;
67 this.property_name = property_name;
68 this.short_desc = desc;
72 public class PropertyKeywordFu {
73 // mapping
74 private static Hashtable property_table;
76 // static class
77 private PropertyKeywordFu () { }
79 static PropertyKeywordFu () {
80 PopulatePropertyTable ();
83 public static IDictionaryEnumerator MappingEnumerator {
84 get { return property_table.GetEnumerator ();}
87 // FIXME handle i18n issues... user might use a i18n-ised string for "title"
88 private static void PopulatePropertyTable () {
89 property_table = new Hashtable ();
91 // Mapping between human query keywords and beagle index property keywords
92 // ---------------- Dublin Core mappings --------------------
94 // title - corresponds to dc:title
95 // FIXME change fixme:title to dc:title in some filters and backends
96 property_table.Add ("title",
97 new PropertyDetail (PropertyType.Text, "dc:title", "Title"));
99 // creator - maps to DC element "creator"
100 property_table.Add ("creator",
101 new PropertyDetail (PropertyType.Text, "dc:creator", "Creator of the content"));
103 // author - maps to DC element "creator"
104 property_table.Add ("author",
105 new PropertyDetail (PropertyType.Text, "dc:creator", "Author of the content"));
107 // artist - maps to DC element "creator"
108 property_table.Add ("artist",
109 new PropertyDetail (PropertyType.Text, "fixme:artist", "Artist"));
111 // date of content creation - maps to DC element "date"
112 // well we dont support date queries as of now ...
113 //property_table.Add ("date",
114 // new PropertyDetail (PropertyType.Date, "dc:date", "Date of creation"));
116 // ---------------- content mappings for media ------------------------
118 // album
119 property_table.Add ("album",
120 new PropertyDetail (PropertyType.Text, "fixme:album", "Album of the media"));
122 // image tag
123 // FIXME: If there is tag information somewhere else, then change the name to imagetag
124 property_table.Add ("tag",
125 new PropertyDetail (PropertyType.Text, "image:tag", "FSpot, Digikam image tags"));
127 // ---------------- content mappings for email ------------------------
129 // "from" name
130 property_table.Add ("mailfrom",
131 new PropertyDetail (PropertyType.Text, "fixme:from_name", "Email sender name"));
133 // "from" email address
134 property_table.Add ("mailfromaddr",
135 new PropertyDetail (PropertyType.Text, "fixme:from_address", "Email sender address"));
137 // "to" name
138 property_table.Add ("mailto",
139 new PropertyDetail (PropertyType.Text, "fixme:to_name", "Email receipient name"));
141 // "to" email address
142 property_table.Add ("mailtoaddr",
143 new PropertyDetail (PropertyType.Text, "fixme:to_address", "Email receipient address"));
145 // mailing list name
146 property_table.Add ("mailinglist",
147 new PropertyDetail (PropertyType.Keyword, "fixme:mlist", "Mailing list id"));
149 // ---------------- other mappings --------------------
150 // file extension - extension:mp3
151 property_table.Add ("extension",
152 new PropertyDetail (PropertyType.Keyword, FSQ.FileSystemQueryable.FilenameExtensionPropKey, "File extension, e.g. extension:jpeg. Use extension: to search in files with no extension."));
154 // file extension - ext:mp3
155 property_table.Add ("ext",
156 new PropertyDetail (PropertyType.Keyword, FSQ.FileSystemQueryable.FilenameExtensionPropKey, "File extension, e.g. ext:mp3. Use ext: to search in files with no extension."));
158 // user comment/description/etc - comment:beaglewiki
159 property_table.Add ("comment",
160 new PropertyDetail (PropertyType.Text, "fixme:comment", "User comments"));
163 // FIXME add more mappings to support more query
166 // return false if property not found!
167 public static bool GetPropertyDetails (string keyword, out string name, out PropertyType type) {
168 PropertyDetail property_detail = property_table [keyword] as PropertyDetail;
169 name = (property_detail == null ? null : property_detail.PropertyName);
170 type = (property_detail == null ? PropertyType.Text : property_detail.Type);
171 return (property_detail != null);