s3/rpc_server/mdssvc: add attribute "kMDItemContentType"
[Samba.git] / source3 / rpc_server / mdssvc / sparql_mapping.c
blobc71c7a55131101a84190ce51d8ad949c8cf49d05
1 /*
2 Unix SMB/CIFS implementation.
3 Main metadata server / Spotlight routines
5 Copyright (C) Ralph Boehme 2012-2014
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "replace.h"
22 #include "sparql_mapping.h"
24 const struct sl_attr_map *sl_attr_map_by_spotlight(const char *sl_attr)
26 static const struct sl_attr_map spotlight_sparql_attr_map[] = {
28 .spotlight_attr = "*",
29 .type = ssmt_fts,
30 .sparql_attr = "fts:match",
33 /* Filesystem metadata */
35 .spotlight_attr = "kMDItemFSLabel",
36 .type = ssmt_num,
37 .sparql_attr = NULL,
40 .spotlight_attr = "kMDItemDisplayName",
41 .type = ssmt_str,
42 .sparql_attr = "nfo:fileName",
45 .spotlight_attr = "kMDItemFSName",
46 .type = ssmt_str,
47 .sparql_attr = "nfo:fileName",
50 .spotlight_attr = "kMDItemFSContentChangeDate",
51 .type = ssmt_date,
52 .sparql_attr = "nfo:fileLastModified",
55 .spotlight_attr = "kMDItemLastUsedDate",
56 .type = ssmt_date,
57 .sparql_attr = "nfo:fileLastAccessed",
60 /* Common metadata */
62 .spotlight_attr = "kMDItemTextContent",
63 .type = ssmt_fts,
64 .sparql_attr = "fts:match",
67 .spotlight_attr = "kMDItemContentCreationDate",
68 .type = ssmt_date,
69 .sparql_attr = "nie:contentCreated",
72 .spotlight_attr = "kMDItemContentModificationDate",
73 .type = ssmt_date,
74 .sparql_attr = "nfo:fileLastModified",
77 .spotlight_attr = "kMDItemAttributeChangeDate",
78 .type = ssmt_date,
79 .sparql_attr = "nfo:fileLastModified",
82 .spotlight_attr = "kMDItemAuthors",
83 .type = ssmt_str,
84 .sparql_attr = "dc:creator",
87 .spotlight_attr = "kMDItemCopyright",
88 .type = ssmt_str,
89 .sparql_attr = "nie:copyright",
92 .spotlight_attr = "kMDItemCountry",
93 .type = ssmt_str,
94 .sparql_attr = "nco:country",
97 .spotlight_attr = "kMDItemCreator",
98 .type = ssmt_str,
99 .sparql_attr = "dc:creator",
102 .spotlight_attr = "kMDItemDurationSeconds",
103 .type = ssmt_num,
104 .sparql_attr = "nfo:duration",
107 .spotlight_attr = "kMDItemNumberOfPages",
108 .type = ssmt_num,
109 .sparql_attr = "nfo:pageCount",
112 .spotlight_attr = "kMDItemTitle",
113 .type = ssmt_str,
114 .sparql_attr = "nie:title",
117 .spotlight_attr = "kMDItemCity",
118 .type = ssmt_str,
119 .sparql_attr = "nco:locality",
122 .spotlight_attr = "kMDItemCoverage",
123 .type = ssmt_str,
124 .sparql_attr = "nco:locality",
127 .spotlight_attr = "_kMDItemGroupId",
128 .type = ssmt_type,
129 .sparql_attr = NULL,
132 .spotlight_attr = "kMDItemContentTypeTree",
133 .type = ssmt_type,
134 .sparql_attr = NULL,
137 .spotlight_attr = "kMDItemContentType",
138 .type = ssmt_type,
139 .sparql_attr = NULL,
142 /* Image metadata */
144 .spotlight_attr = "kMDItemPixelWidth",
145 .type = ssmt_num,
146 .sparql_attr = "nfo:width",
149 .spotlight_attr = "kMDItemPixelHeight",
150 .type = ssmt_num,
151 .sparql_attr = "nfo:height",
154 .spotlight_attr = "kMDItemColorSpace",
155 .type = ssmt_str,
156 .sparql_attr = "nexif:colorSpace",
159 .spotlight_attr = "kMDItemBitsPerSample",
160 .type = ssmt_num,
161 .sparql_attr = "nfo:colorDepth",
164 .spotlight_attr = "kMDItemFocalLength",
165 .type = ssmt_num,
166 .sparql_attr = "nmm:focalLength",
169 .spotlight_attr = "kMDItemISOSpeed",
170 .type = ssmt_num,
171 .sparql_attr = "nmm:isoSpeed",
174 .spotlight_attr = "kMDItemOrientation",
175 .type = ssmt_bool,
176 .sparql_attr = "nfo:orientation",
179 .spotlight_attr = "kMDItemResolutionWidthDPI",
180 .type = ssmt_num,
181 .sparql_attr = "nfo:horizontalResolution",
184 .spotlight_attr = "kMDItemResolutionHeightDPI",
185 .type = ssmt_num,
186 .sparql_attr = "nfo:verticalResolution",
189 .spotlight_attr = "kMDItemExposureTimeSeconds",
190 .type = ssmt_num,
191 .sparql_attr = "nmm:exposureTime",
194 /* Audio metadata */
196 .spotlight_attr = "kMDItemComposer",
197 .type = ssmt_str,
198 .sparql_attr = "nmm:composer",
201 .spotlight_attr = "kMDItemMusicalGenre",
202 .type = ssmt_str,
203 .sparql_attr = "nfo:genre",
206 size_t i;
208 for (i = 0; i < ARRAY_SIZE(spotlight_sparql_attr_map); i++) {
209 const struct sl_attr_map *m = &spotlight_sparql_attr_map[i];
210 int cmp;
212 cmp = strcmp(m->spotlight_attr, sl_attr);
213 if (cmp == 0) {
214 return m;
218 return NULL;
221 const struct sl_type_map *sl_type_map_by_spotlight(const char *sl_type)
223 static const struct sl_type_map spotlight_sparql_type_map[] = {
225 .spotlight_type = "1",
226 .type = kMDTypeMapRDF,
227 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email",
230 .spotlight_type = "2",
231 .type = kMDTypeMapRDF,
232 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact",
235 .spotlight_type = "3",
236 .type = kMDTypeMapNotSup,
237 .sparql_type = NULL, /*PrefPane*/
240 .spotlight_type = "4",
241 .type = kMDTypeMapRDF,
242 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Font",
245 .spotlight_type = "5",
246 .type = kMDTypeMapRDF,
247 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Bookmark",
250 .spotlight_type = "6",
251 .type = kMDTypeMapRDF,
252 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact",
255 .spotlight_type = "7",
256 .type = kMDTypeMapRDF,
257 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video",
260 .spotlight_type = "8",
261 .type = kMDTypeMapRDF,
262 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Executable",
265 .spotlight_type = "9",
266 .type = kMDTypeMapRDF,
267 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Folder",
270 .spotlight_type = "10",
271 .type = kMDTypeMapRDF,
272 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio",
275 .spotlight_type = "11",
276 .type = kMDTypeMapMime,
277 .sparql_type = "application/pdf",
280 .spotlight_type = "12",
281 .type = kMDTypeMapRDF,
282 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Presentation",
285 .spotlight_type = "13",
286 .type = kMDTypeMapRDF,
287 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image",
290 .spotlight_type = "public.jpeg",
291 .type = kMDTypeMapMime,
292 .sparql_type = "image/jpeg",
295 .spotlight_type = "public.tiff",
296 .type = kMDTypeMapMime,
297 .sparql_type = "image/tiff",
300 .spotlight_type = "com.compuserve.gif",
301 .type = kMDTypeMapMime,
302 .sparql_type = "image/gif",
305 .spotlight_type = "public.png",
306 .type = kMDTypeMapMime,
307 .sparql_type = "image/png",
310 .spotlight_type = "com.microsoft.bmp",
311 .type = kMDTypeMapMime,
312 .sparql_type = "image/bmp",
315 .spotlight_type = "public.content",
316 .type = kMDTypeMapRDF,
317 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document",
320 .spotlight_type = "public.mp3",
321 .type = kMDTypeMapMime,
322 .sparql_type = "audio/mpeg",
325 .spotlight_type = "public.mpeg-4-audio",
326 .type = kMDTypeMapMime,
327 .sparql_type = "audio/x-aac",
330 .spotlight_type = "com.apple.application",
331 .type = kMDTypeMapRDF,
332 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Software",
335 .spotlight_type = "public.text",
336 .type = kMDTypeMapRDF,
337 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument",
340 .spotlight_type = "public.plain-text",
341 .type = kMDTypeMapMime,
342 .sparql_type = "text/plain",
345 .spotlight_type = "public.rtf",
346 .type = kMDTypeMapMime,
347 .sparql_type = "text/rtf",
350 .spotlight_type = "public.html",
351 .type = kMDTypeMapMime,
352 .sparql_type = "text/html",
355 .spotlight_type = "public.xml",
356 .type = kMDTypeMapMime,
357 .sparql_type = "text/xml",
360 .spotlight_type = "public.source-code",
361 .type = kMDTypeMapRDF,
362 .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#SourceCode",
365 size_t i;
367 for (i = 0; i < ARRAY_SIZE(spotlight_sparql_type_map); i++) {
368 const struct sl_type_map *m = &spotlight_sparql_type_map[i];
369 int cmp;
371 cmp = strcmp(m->spotlight_type, sl_type);
372 if (cmp == 0) {
373 return m;
377 return NULL;