Line data Source code
1 : /*
2 : Unix SMB/CIFS implementation.
3 : Main metadata server / Spotlight routines
4 :
5 : Copyright (C) Ralph Boehme 2012-2014
6 :
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.
11 :
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.
16 :
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/>.
19 : */
20 :
21 : #include "replace.h"
22 : #include "sparql_mapping.h"
23 :
24 0 : const struct sl_attr_map *sl_attr_map_by_spotlight(const char *sl_attr)
25 : {
26 : static const struct sl_attr_map spotlight_sparql_attr_map[] = {
27 : {
28 : .spotlight_attr = "*",
29 : .type = ssmt_fts,
30 : .sparql_attr = "fts:match",
31 : },
32 :
33 : /* Filesystem metadata */
34 : {
35 : .spotlight_attr = "kMDItemFSLabel",
36 : .type = ssmt_num,
37 : .sparql_attr = NULL,
38 : },
39 : {
40 : .spotlight_attr = "kMDItemDisplayName",
41 : .type = ssmt_str,
42 : .sparql_attr = "nfo:fileName",
43 : },
44 : {
45 : .spotlight_attr = "kMDItemFSName",
46 : .type = ssmt_str,
47 : .sparql_attr = "nfo:fileName",
48 : },
49 : {
50 : .spotlight_attr = "kMDItemFSContentChangeDate",
51 : .type = ssmt_date,
52 : .sparql_attr = "nfo:fileLastModified",
53 : },
54 : {
55 : .spotlight_attr = "kMDItemLastUsedDate",
56 : .type = ssmt_date,
57 : .sparql_attr = "nfo:fileLastAccessed",
58 : },
59 :
60 : /* Common metadata */
61 : {
62 : .spotlight_attr = "kMDItemTextContent",
63 : .type = ssmt_fts,
64 : .sparql_attr = "fts:match",
65 : },
66 : {
67 : .spotlight_attr = "kMDItemContentCreationDate",
68 : .type = ssmt_date,
69 : .sparql_attr = "nie:contentCreated",
70 : },
71 : {
72 : .spotlight_attr = "kMDItemContentModificationDate",
73 : .type = ssmt_date,
74 : .sparql_attr = "nfo:fileLastModified",
75 : },
76 : {
77 : .spotlight_attr = "kMDItemAttributeChangeDate",
78 : .type = ssmt_date,
79 : .sparql_attr = "nfo:fileLastModified",
80 : },
81 : {
82 : .spotlight_attr = "kMDItemAuthors",
83 : .type = ssmt_str,
84 : .sparql_attr = "dc:creator",
85 : },
86 : {
87 : .spotlight_attr = "kMDItemCopyright",
88 : .type = ssmt_str,
89 : .sparql_attr = "nie:copyright",
90 : },
91 : {
92 : .spotlight_attr = "kMDItemCountry",
93 : .type = ssmt_str,
94 : .sparql_attr = "nco:country",
95 : },
96 : {
97 : .spotlight_attr = "kMDItemCreator",
98 : .type = ssmt_str,
99 : .sparql_attr = "dc:creator",
100 : },
101 : {
102 : .spotlight_attr = "kMDItemDurationSeconds",
103 : .type = ssmt_num,
104 : .sparql_attr = "nfo:duration",
105 : },
106 : {
107 : .spotlight_attr = "kMDItemNumberOfPages",
108 : .type = ssmt_num,
109 : .sparql_attr = "nfo:pageCount",
110 : },
111 : {
112 : .spotlight_attr = "kMDItemTitle",
113 : .type = ssmt_str,
114 : .sparql_attr = "nie:title",
115 : },
116 : {
117 : .spotlight_attr = "kMDItemCity",
118 : .type = ssmt_str,
119 : .sparql_attr = "nco:locality",
120 : },
121 : {
122 : .spotlight_attr = "kMDItemCoverage",
123 : .type = ssmt_str,
124 : .sparql_attr = "nco:locality",
125 : },
126 : {
127 : .spotlight_attr = "_kMDItemGroupId",
128 : .type = ssmt_type,
129 : .sparql_attr = NULL,
130 : },
131 : {
132 : .spotlight_attr = "kMDItemContentTypeTree",
133 : .type = ssmt_type,
134 : .sparql_attr = NULL,
135 : },
136 : {
137 : .spotlight_attr = "kMDItemContentType",
138 : .type = ssmt_type,
139 : .sparql_attr = NULL,
140 : },
141 :
142 : /* Image metadata */
143 : {
144 : .spotlight_attr = "kMDItemPixelWidth",
145 : .type = ssmt_num,
146 : .sparql_attr = "nfo:width",
147 : },
148 : {
149 : .spotlight_attr = "kMDItemPixelHeight",
150 : .type = ssmt_num,
151 : .sparql_attr = "nfo:height",
152 : },
153 : {
154 : .spotlight_attr = "kMDItemColorSpace",
155 : .type = ssmt_str,
156 : .sparql_attr = "nexif:colorSpace",
157 : },
158 : {
159 : .spotlight_attr = "kMDItemBitsPerSample",
160 : .type = ssmt_num,
161 : .sparql_attr = "nfo:colorDepth",
162 : },
163 : {
164 : .spotlight_attr = "kMDItemFocalLength",
165 : .type = ssmt_num,
166 : .sparql_attr = "nmm:focalLength",
167 : },
168 : {
169 : .spotlight_attr = "kMDItemISOSpeed",
170 : .type = ssmt_num,
171 : .sparql_attr = "nmm:isoSpeed",
172 : },
173 : {
174 : .spotlight_attr = "kMDItemOrientation",
175 : .type = ssmt_bool,
176 : .sparql_attr = "nfo:orientation",
177 : },
178 : {
179 : .spotlight_attr = "kMDItemResolutionWidthDPI",
180 : .type = ssmt_num,
181 : .sparql_attr = "nfo:horizontalResolution",
182 : },
183 : {
184 : .spotlight_attr = "kMDItemResolutionHeightDPI",
185 : .type = ssmt_num,
186 : .sparql_attr = "nfo:verticalResolution",
187 : },
188 : {
189 : .spotlight_attr = "kMDItemExposureTimeSeconds",
190 : .type = ssmt_num,
191 : .sparql_attr = "nmm:exposureTime",
192 : },
193 :
194 : /* Audio metadata */
195 : {
196 : .spotlight_attr = "kMDItemComposer",
197 : .type = ssmt_str,
198 : .sparql_attr = "nmm:composer",
199 : },
200 : {
201 : .spotlight_attr = "kMDItemMusicalGenre",
202 : .type = ssmt_str,
203 : .sparql_attr = "nfo:genre",
204 : },
205 : };
206 : size_t i;
207 :
208 0 : for (i = 0; i < ARRAY_SIZE(spotlight_sparql_attr_map); i++) {
209 0 : const struct sl_attr_map *m = &spotlight_sparql_attr_map[i];
210 : int cmp;
211 :
212 0 : cmp = strcmp(m->spotlight_attr, sl_attr);
213 0 : if (cmp == 0) {
214 0 : return m;
215 : }
216 : }
217 :
218 0 : return NULL;
219 : }
220 :
221 0 : const struct sl_type_map *sl_type_map_by_spotlight(const char *sl_type)
222 : {
223 : static const struct sl_type_map spotlight_sparql_type_map[] = {
224 : {
225 : .spotlight_type = "1",
226 : .type = kMDTypeMapRDF,
227 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email",
228 : },
229 : {
230 : .spotlight_type = "2",
231 : .type = kMDTypeMapRDF,
232 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact",
233 : },
234 : {
235 : .spotlight_type = "3",
236 : .type = kMDTypeMapNotSup,
237 : .sparql_type = NULL, /*PrefPane*/
238 : },
239 : {
240 : .spotlight_type = "4",
241 : .type = kMDTypeMapRDF,
242 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Font",
243 : },
244 : {
245 : .spotlight_type = "5",
246 : .type = kMDTypeMapRDF,
247 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Bookmark",
248 : },
249 : {
250 : .spotlight_type = "6",
251 : .type = kMDTypeMapRDF,
252 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact",
253 : },
254 : {
255 : .spotlight_type = "7",
256 : .type = kMDTypeMapRDF,
257 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video",
258 : },
259 : {
260 : .spotlight_type = "8",
261 : .type = kMDTypeMapRDF,
262 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Executable",
263 : },
264 : {
265 : .spotlight_type = "9",
266 : .type = kMDTypeMapRDF,
267 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Folder",
268 : },
269 : {
270 : .spotlight_type = "10",
271 : .type = kMDTypeMapRDF,
272 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio",
273 : },
274 : {
275 : .spotlight_type = "11",
276 : .type = kMDTypeMapMime,
277 : .sparql_type = "application/pdf",
278 : },
279 : {
280 : .spotlight_type = "12",
281 : .type = kMDTypeMapRDF,
282 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Presentation",
283 : },
284 : {
285 : .spotlight_type = "13",
286 : .type = kMDTypeMapRDF,
287 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image",
288 : },
289 : {
290 : .spotlight_type = "public.jpeg",
291 : .type = kMDTypeMapMime,
292 : .sparql_type = "image/jpeg",
293 : },
294 : {
295 : .spotlight_type = "public.tiff",
296 : .type = kMDTypeMapMime,
297 : .sparql_type = "image/tiff",
298 : },
299 : {
300 : .spotlight_type = "com.compuserve.gif",
301 : .type = kMDTypeMapMime,
302 : .sparql_type = "image/gif",
303 : },
304 : {
305 : .spotlight_type = "public.png",
306 : .type = kMDTypeMapMime,
307 : .sparql_type = "image/png",
308 : },
309 : {
310 : .spotlight_type = "com.microsoft.bmp",
311 : .type = kMDTypeMapMime,
312 : .sparql_type = "image/bmp",
313 : },
314 : {
315 : .spotlight_type = "public.content",
316 : .type = kMDTypeMapRDF,
317 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document",
318 : },
319 : {
320 : .spotlight_type = "public.mp3",
321 : .type = kMDTypeMapMime,
322 : .sparql_type = "audio/mpeg",
323 : },
324 : {
325 : .spotlight_type = "public.mpeg-4-audio",
326 : .type = kMDTypeMapMime,
327 : .sparql_type = "audio/x-aac",
328 : },
329 : {
330 : .spotlight_type = "com.apple.application",
331 : .type = kMDTypeMapRDF,
332 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Software",
333 : },
334 : {
335 : .spotlight_type = "public.text",
336 : .type = kMDTypeMapRDF,
337 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument",
338 : },
339 : {
340 : .spotlight_type = "public.plain-text",
341 : .type = kMDTypeMapMime,
342 : .sparql_type = "text/plain",
343 : },
344 : {
345 : .spotlight_type = "public.rtf",
346 : .type = kMDTypeMapMime,
347 : .sparql_type = "text/rtf",
348 : },
349 : {
350 : .spotlight_type = "public.html",
351 : .type = kMDTypeMapMime,
352 : .sparql_type = "text/html",
353 : },
354 : {
355 : .spotlight_type = "public.xml",
356 : .type = kMDTypeMapMime,
357 : .sparql_type = "text/xml",
358 : },
359 : {
360 : .spotlight_type = "public.source-code",
361 : .type = kMDTypeMapRDF,
362 : .sparql_type = "http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#SourceCode",
363 : },
364 : };
365 : size_t i;
366 :
367 0 : for (i = 0; i < ARRAY_SIZE(spotlight_sparql_type_map); i++) {
368 0 : const struct sl_type_map *m = &spotlight_sparql_type_map[i];
369 : int cmp;
370 :
371 0 : cmp = strcmp(m->spotlight_type, sl_type);
372 0 : if (cmp == 0) {
373 0 : return m;
374 : }
375 : }
376 :
377 0 : return NULL;
378 : }
|