Merge lp:~mhr3/libzeitgeist/libzg-mimetypes-import into lp:libzeitgeist
- libzg-mimetypes-import
- Merge into trunk
Proposed by
Michal Hruby
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 171 | ||||
Proposed branch: | lp:~mhr3/libzeitgeist/libzg-mimetypes-import | ||||
Merge into: | lp:libzeitgeist | ||||
Diff against target: |
659 lines (+418/-213) 3 files modified
src/zeitgeist-mimetypes.c (+94/-213) tools/mimetypes2c.py (+88/-0) tools/zeitgeist-mimetypes.template (+236/-0) |
||||
To merge this branch: | bzr merge lp:~mhr3/libzeitgeist/libzg-mimetypes-import | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mikkel Kamstrup Erlandsen | Approve | ||
Review via email: mp+34649@code.launchpad.net |
Commit message
Description of the change
Adds the ability to generate the zeitgeist-mimetypes source file using the data from Zeitgeist's mimetypes module.
To post a comment you must log in.
Revision history for this message
Seif Lotfy (seif) wrote : | # |
Revision history for this message
Seif Lotfy (seif) wrote : | # |
> What is the major difference in zeitgeist-
> replaced or depend on the mimetypes2c ?
OK understood it now! Forget this comment! Good Job!
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
Sorry for not reacting earlier, I was very tied up this week. Will look on it Monday!
Revision history for this message
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
Very much sorry for the delay! As always, good work Michal! Approved!
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/zeitgeist-mimetypes.c' |
2 | --- src/zeitgeist-mimetypes.c 2010-08-09 14:11:40 +0000 |
3 | +++ src/zeitgeist-mimetypes.c 2010-09-06 00:12:59 +0000 |
4 | @@ -240,218 +240,100 @@ |
5 | { |
6 | if (mimes_loaded) return; |
7 | |
8 | - /* Star Office and OO.org */ |
9 | - zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.text.*", |
10 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
11 | - zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.presentation.*", |
12 | - ZEITGEIST_NFO_PRESENTATION); |
13 | - zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.spreadsheet.*", |
14 | - ZEITGEIST_NFO_SPREADSHEET); |
15 | - zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.graphics.*", |
16 | - ZEITGEIST_NFO_VECTOR_IMAGE); |
17 | - zeitgeist_register_mimetype_regex ("application/vnd\\..*", |
18 | - ZEITGEIST_NFO_DOCUMENT); |
19 | - |
20 | - /* x-applix-* */ |
21 | - zeitgeist_register_mimetype ("application/x-applix-word", |
22 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
23 | - zeitgeist_register_mimetype ("application/x-applix-spreadsheet", |
24 | - ZEITGEIST_NFO_SPREADSHEET); |
25 | - zeitgeist_register_mimetype ("application/x-applix-presents", |
26 | - ZEITGEIST_NFO_PRESENTATION); |
27 | - zeitgeist_register_mimetype_regex ("application/x-applix-.*", |
28 | - ZEITGEIST_NFO_DOCUMENT); |
29 | - |
30 | - /* x-kword, x-kspread, x-kpresenter, x-killustrator */ |
31 | - zeitgeist_register_mimetype ("application/x-kword", |
32 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
33 | - zeitgeist_register_mimetype ("application/x-kspread", |
34 | - ZEITGEIST_NFO_SPREADSHEET); |
35 | - zeitgeist_register_mimetype ("application/x-kpresenter", |
36 | - ZEITGEIST_NFO_PRESENTATION); |
37 | - zeitgeist_register_mimetype ("application/x-killustrator", |
38 | - ZEITGEIST_NFO_VECTOR_IMAGE); |
39 | - |
40 | - /* MS */ |
41 | - zeitgeist_register_mimetype ("application/ms-powerpoint", |
42 | - ZEITGEIST_NFO_PRESENTATION); |
43 | - zeitgeist_register_mimetype ("application/vnd.ms-powerpoint", |
44 | - ZEITGEIST_NFO_PRESENTATION); |
45 | - zeitgeist_register_mimetype ("application/msword", |
46 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
47 | - zeitgeist_register_mimetype ("application/msexcel", |
48 | - ZEITGEIST_NFO_SPREADSHEET); |
49 | - zeitgeist_register_mimetype ("application/ms-excel", |
50 | - ZEITGEIST_NFO_SPREADSHEET); |
51 | - zeitgeist_register_mimetype ("application/vnd.ms-excel", |
52 | - ZEITGEIST_NFO_SPREADSHEET); |
53 | - zeitgeist_register_mimetype_regex ("application/vnd.ms-excel.*", |
54 | - ZEITGEIST_NFO_SPREADSHEET); |
55 | - zeitgeist_register_mimetype_regex ("application/vnd.ms-powerpoint.*", |
56 | - ZEITGEIST_NFO_PRESENTATION); |
57 | - |
58 | - /* pdf, postscript et al */ |
59 | - zeitgeist_register_mimetype ("application/pdf", |
60 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
61 | - zeitgeist_register_mimetype ("application/postscript", |
62 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
63 | - zeitgeist_register_mimetype ("application/ps", |
64 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
65 | - zeitgeist_register_mimetype ("application/rtf", |
66 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
67 | - |
68 | - /* Gnome office */ |
69 | - zeitgeist_register_mimetype ("application/x-abiword", |
70 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
71 | - zeitgeist_register_mimetype ("application/x-gnucash", |
72 | - ZEITGEIST_NFO_SPREADSHEET); |
73 | - zeitgeist_register_mimetype ("application/x-gnumeric", |
74 | - ZEITGEIST_NFO_SPREADSHEET); |
75 | - |
76 | - /* TeX stuff */ |
77 | - zeitgeist_register_mimetype ("text/x-tex", |
78 | - ZEITGEIST_NFO_SOURCE_CODE); |
79 | - zeitgeist_register_mimetype ("text/x-latex", |
80 | - ZEITGEIST_NFO_SOURCE_CODE); |
81 | - zeitgeist_register_mimetype_regex (".*/x-dvi", |
82 | - ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
83 | - |
84 | - /* Plain text */ |
85 | + zeitgeist_register_mimetype ("application/ogg", ZEITGEIST_NFO_AUDIO); |
86 | + zeitgeist_register_mimetype ("text/x-credits", ZEITGEIST_NFO_SOURCE_CODE); |
87 | + zeitgeist_register_mimetype ("text/x-copying", ZEITGEIST_NFO_SOURCE_CODE); |
88 | + zeitgeist_register_mimetype ("application/x-perl", ZEITGEIST_NFO_SOURCE_CODE); |
89 | + zeitgeist_register_mimetype ("image/jpeg", ZEITGEIST_NFO_RASTER_IMAGE); |
90 | + zeitgeist_register_mimetype ("application/x-kspread", ZEITGEIST_NFO_SPREADSHEET); |
91 | + zeitgeist_register_mimetype ("application/postscript", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
92 | + zeitgeist_register_mimetype ("application/x-designer", ZEITGEIST_NFO_SOURCE_CODE); |
93 | + zeitgeist_register_mimetype ("image/png", ZEITGEIST_NFO_RASTER_IMAGE); |
94 | + zeitgeist_register_mimetype ("application/x-gnucash", ZEITGEIST_NFO_SPREADSHEET); |
95 | + zeitgeist_register_mimetype ("application/x-m4", ZEITGEIST_NFO_SOURCE_CODE); |
96 | + zeitgeist_register_mimetype ("application/ms-powerpoint", ZEITGEIST_NFO_PRESENTATION); |
97 | + zeitgeist_register_mimetype ("image/x-xcf", ZEITGEIST_NFO_RASTER_IMAGE); |
98 | + zeitgeist_register_mimetype ("application/x-java-archive", ZEITGEIST_NFO_SOURCE_CODE); |
99 | + zeitgeist_register_mimetype ("text/x-vala", ZEITGEIST_NFO_SOURCE_CODE); |
100 | + zeitgeist_register_mimetype ("text/x-python", ZEITGEIST_NFO_SOURCE_CODE); |
101 | + zeitgeist_register_mimetype ("text/x-lua", ZEITGEIST_NFO_SOURCE_CODE); |
102 | + zeitgeist_register_mimetype ("application/pdf", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
103 | + zeitgeist_register_mimetype ("text/x-csharp", ZEITGEIST_NFO_SOURCE_CODE); |
104 | + zeitgeist_register_mimetype ("text/x-gettext-translation-template", ZEITGEIST_NFO_SOURCE_CODE); |
105 | + zeitgeist_register_mimetype ("text/x-eiffel", ZEITGEIST_NFO_SOURCE_CODE); |
106 | + zeitgeist_register_mimetype ("application/xhtml+xml", ZEITGEIST_NFO_SOURCE_CODE); |
107 | + zeitgeist_register_mimetype ("application/ps", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
108 | + zeitgeist_register_mimetype ("text/x-java", ZEITGEIST_NFO_SOURCE_CODE); |
109 | + zeitgeist_register_mimetype ("text/x-gettext-translation", ZEITGEIST_NFO_SOURCE_CODE); |
110 | + zeitgeist_register_mimetype ("application/x-sql", ZEITGEIST_NFO_SOURCE_CODE); |
111 | + zeitgeist_register_mimetype ("application/x-killustrator", ZEITGEIST_NFO_VECTOR_IMAGE); |
112 | + zeitgeist_register_mimetype ("application/x-desktop", ZEITGEIST_NFO_SOURCE_CODE); |
113 | + zeitgeist_register_mimetype ("image/svg+xml", ZEITGEIST_NFO_VECTOR_IMAGE); |
114 | + zeitgeist_register_mimetype ("application/x-glade", ZEITGEIST_NFO_SOURCE_CODE); |
115 | + zeitgeist_register_mimetype ("application/x-php", ZEITGEIST_NFO_SOURCE_CODE); |
116 | + zeitgeist_register_mimetype ("application/x-shellscript", ZEITGEIST_NFO_SOURCE_CODE); |
117 | + zeitgeist_register_mimetype ("application/x-abiword", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
118 | + zeitgeist_register_mimetype ("image/gif", ZEITGEIST_NFO_RASTER_IMAGE); |
119 | + zeitgeist_register_mimetype ("application/javascript", ZEITGEIST_NFO_SOURCE_CODE); |
120 | + zeitgeist_register_mimetype ("text/x-c++src", ZEITGEIST_NFO_SOURCE_CODE); |
121 | + zeitgeist_register_mimetype ("application/xml", ZEITGEIST_NFO_SOURCE_CODE); |
122 | + zeitgeist_register_mimetype ("text/x-vhdl", ZEITGEIST_NFO_SOURCE_CODE); |
123 | + zeitgeist_register_mimetype ("application/vnd.ms-excel", ZEITGEIST_NFO_SPREADSHEET); |
124 | + zeitgeist_register_mimetype ("application/x-gnumeric", ZEITGEIST_NFO_SPREADSHEET); |
125 | + zeitgeist_register_mimetype ("application/x-fluid", ZEITGEIST_NFO_SOURCE_CODE); |
126 | + zeitgeist_register_mimetype ("text/x-dsrc", ZEITGEIST_NFO_SOURCE_CODE); |
127 | + zeitgeist_register_mimetype ("image/tiff", ZEITGEIST_NFO_RASTER_IMAGE); |
128 | + zeitgeist_register_mimetype ("text/x-makefile", ZEITGEIST_NFO_SOURCE_CODE); |
129 | + zeitgeist_register_mimetype ("text/x-objcsrc", ZEITGEIST_NFO_SOURCE_CODE); |
130 | + zeitgeist_register_mimetype ("text/x-haskell", ZEITGEIST_NFO_SOURCE_CODE); |
131 | + zeitgeist_register_mimetype ("application/vnd.corel-draw", ZEITGEIST_NFO_VECTOR_IMAGE); |
132 | + zeitgeist_register_mimetype ("application/x-object", ZEITGEIST_NFO_SOURCE_CODE); |
133 | + zeitgeist_register_mimetype ("text/x-idl", ZEITGEIST_NFO_SOURCE_CODE); |
134 | + zeitgeist_register_mimetype ("text/x-ocaml", ZEITGEIST_NFO_SOURCE_CODE); |
135 | + zeitgeist_register_mimetype ("text/x-c", ZEITGEIST_NFO_SOURCE_CODE); |
136 | + zeitgeist_register_mimetype ("application/x-ruby", ZEITGEIST_NFO_SOURCE_CODE); |
137 | + zeitgeist_register_mimetype ("application/x-applix-presents", ZEITGEIST_NFO_PRESENTATION); |
138 | + zeitgeist_register_mimetype ("application/ms-excel", ZEITGEIST_NFO_SPREADSHEET); |
139 | + zeitgeist_register_mimetype ("application/x-kword", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
140 | + zeitgeist_register_mimetype ("text/x-troff", ZEITGEIST_NFO_SOURCE_CODE); |
141 | + zeitgeist_register_mimetype ("application/x-kpresenter", ZEITGEIST_NFO_PRESENTATION); |
142 | + zeitgeist_register_mimetype ("application/rtf", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
143 | + zeitgeist_register_mimetype ("text/x-lisp", ZEITGEIST_NFO_SOURCE_CODE); |
144 | zeitgeist_register_mimetype ("text/plain", ZEITGEIST_NFO_TEXT_DOCUMENT); |
145 | - |
146 | - /* HTML files on disk are always HTML_DOCUMENTS while online we should |
147 | - * assume them to be WEBSITEs. By default we anticipate local files... */ |
148 | - zeitgeist_register_mimetype ("text/html", |
149 | - ZEITGEIST_NFO_HTML_DOCUMENT); |
150 | - |
151 | - /* Image types */ |
152 | - zeitgeist_register_mimetype ("application/vnd.corel-draw", |
153 | - ZEITGEIST_NFO_VECTOR_IMAGE); |
154 | - zeitgeist_register_mimetype ("image/jpeg", |
155 | - ZEITGEIST_NFO_RASTER_IMAGE); |
156 | - zeitgeist_register_mimetype ("image/png", |
157 | - ZEITGEIST_NFO_RASTER_IMAGE); |
158 | - zeitgeist_register_mimetype ("image/tiff", |
159 | - ZEITGEIST_NFO_RASTER_IMAGE); |
160 | - zeitgeist_register_mimetype ("image/gif", |
161 | - ZEITGEIST_NFO_RASTER_IMAGE); |
162 | - zeitgeist_register_mimetype ("image/x-xcf", |
163 | - ZEITGEIST_NFO_RASTER_IMAGE); |
164 | - zeitgeist_register_mimetype ("image/svg+xml", |
165 | - ZEITGEIST_NFO_VECTOR_IMAGE); |
166 | - zeitgeist_register_mimetype_regex ("image/.*", |
167 | - ZEITGEIST_NFO_IMAGE); |
168 | - |
169 | - /* Audio */ |
170 | - zeitgeist_register_mimetype ("application/ogg", |
171 | - ZEITGEIST_NFO_AUDIO); |
172 | - zeitgeist_register_mimetype ("audio/x-scpls", |
173 | - ZEITGEIST_NFO_MEDIA_LIST); |
174 | - zeitgeist_register_mimetype_regex ("audio/.*", |
175 | - ZEITGEIST_NFO_AUDIO); |
176 | - |
177 | - /* Video */ |
178 | - zeitgeist_register_mimetype_regex ("video/.*", |
179 | - ZEITGEIST_NFO_VIDEO); |
180 | - |
181 | - /* Development files */ |
182 | - zeitgeist_register_mimetype ("application/ecmascript", |
183 | - ZEITGEIST_NFO_SOURCE_CODE); |
184 | - zeitgeist_register_mimetype ("application/javascript", |
185 | - ZEITGEIST_NFO_SOURCE_CODE); |
186 | - zeitgeist_register_mimetype ("application/x-csh", |
187 | - ZEITGEIST_NFO_SOURCE_CODE); |
188 | - zeitgeist_register_mimetype ("application/x-designer", |
189 | - ZEITGEIST_NFO_SOURCE_CODE); |
190 | - zeitgeist_register_mimetype ("application/x-desktop", |
191 | - ZEITGEIST_NFO_SOURCE_CODE); |
192 | - zeitgeist_register_mimetype ("application/x-dia-diagram", |
193 | - ZEITGEIST_NFO_SOURCE_CODE); |
194 | - zeitgeist_register_mimetype ("application/x-fluid", |
195 | - ZEITGEIST_NFO_SOURCE_CODE); |
196 | - zeitgeist_register_mimetype ("application/x-glade", |
197 | - ZEITGEIST_NFO_SOURCE_CODE); |
198 | - zeitgeist_register_mimetype ("application/xhtml+xml", |
199 | - ZEITGEIST_NFO_SOURCE_CODE); |
200 | - zeitgeist_register_mimetype ("application/x-java-archive", |
201 | - ZEITGEIST_NFO_SOURCE_CODE); |
202 | - zeitgeist_register_mimetype ("application/x-m4", |
203 | - ZEITGEIST_NFO_SOURCE_CODE); |
204 | - zeitgeist_register_mimetype ("application/xml", |
205 | - ZEITGEIST_NFO_SOURCE_CODE); |
206 | - zeitgeist_register_mimetype ("application/x-object", |
207 | - ZEITGEIST_NFO_SOURCE_CODE); |
208 | - zeitgeist_register_mimetype ("application/x-perl", |
209 | - ZEITGEIST_NFO_SOURCE_CODE); |
210 | - zeitgeist_register_mimetype ("application/x-php", |
211 | - ZEITGEIST_NFO_SOURCE_CODE); |
212 | - zeitgeist_register_mimetype ("application/x-ruby", |
213 | - ZEITGEIST_NFO_SOURCE_CODE); |
214 | - zeitgeist_register_mimetype ("application/x-shellscript", |
215 | - ZEITGEIST_NFO_SOURCE_CODE); |
216 | - zeitgeist_register_mimetype ("application/x-sql", |
217 | - ZEITGEIST_NFO_SOURCE_CODE); |
218 | - zeitgeist_register_mimetype ("text/css", |
219 | - ZEITGEIST_NFO_SOURCE_CODE); |
220 | - zeitgeist_register_mimetype ("text/x-c", |
221 | - ZEITGEIST_NFO_SOURCE_CODE); |
222 | - zeitgeist_register_mimetype ("text/x-c++", |
223 | - ZEITGEIST_NFO_SOURCE_CODE); |
224 | - zeitgeist_register_mimetype ("text/x-chdr", |
225 | - ZEITGEIST_NFO_SOURCE_CODE); |
226 | - zeitgeist_register_mimetype ("text/x-copying", |
227 | - ZEITGEIST_NFO_SOURCE_CODE); |
228 | - zeitgeist_register_mimetype ("text/x-credits", |
229 | - ZEITGEIST_NFO_SOURCE_CODE); |
230 | - zeitgeist_register_mimetype ("text/x-csharp", |
231 | - ZEITGEIST_NFO_SOURCE_CODE); |
232 | - zeitgeist_register_mimetype ("text/x-c++src", |
233 | - ZEITGEIST_NFO_SOURCE_CODE); |
234 | - zeitgeist_register_mimetype ("text/x-csrc", |
235 | - ZEITGEIST_NFO_SOURCE_CODE); |
236 | - zeitgeist_register_mimetype ("text/x-dsrc", |
237 | - ZEITGEIST_NFO_SOURCE_CODE); |
238 | - zeitgeist_register_mimetype ("text/x-eiffel", |
239 | - ZEITGEIST_NFO_SOURCE_CODE); |
240 | - zeitgeist_register_mimetype ("text/x-gettext-translation", |
241 | - ZEITGEIST_NFO_SOURCE_CODE); |
242 | - zeitgeist_register_mimetype ("text/x-gettext-translation-template", |
243 | - ZEITGEIST_NFO_SOURCE_CODE); |
244 | - zeitgeist_register_mimetype ("text/x-haskell", |
245 | - ZEITGEIST_NFO_SOURCE_CODE); |
246 | - zeitgeist_register_mimetype ("text/x-idl", |
247 | - ZEITGEIST_NFO_SOURCE_CODE); |
248 | - zeitgeist_register_mimetype ("text/x-java", |
249 | - ZEITGEIST_NFO_SOURCE_CODE); |
250 | - zeitgeist_register_mimetype ("text/x-lisp", |
251 | - ZEITGEIST_NFO_SOURCE_CODE); |
252 | - zeitgeist_register_mimetype ("text/x-lua", |
253 | - ZEITGEIST_NFO_SOURCE_CODE); |
254 | - zeitgeist_register_mimetype ("text/x-makefile", |
255 | - ZEITGEIST_NFO_SOURCE_CODE); |
256 | - zeitgeist_register_mimetype ("text/x-objcsrc", |
257 | - ZEITGEIST_NFO_SOURCE_CODE); |
258 | - zeitgeist_register_mimetype ("text/x-ocaml", |
259 | - ZEITGEIST_NFO_SOURCE_CODE); |
260 | - zeitgeist_register_mimetype ("text/x-pascal", |
261 | - ZEITGEIST_NFO_SOURCE_CODE); |
262 | - zeitgeist_register_mimetype ("text/x-patch", |
263 | - ZEITGEIST_NFO_SOURCE_CODE); |
264 | - zeitgeist_register_mimetype ("text/x-python", |
265 | - ZEITGEIST_NFO_SOURCE_CODE); |
266 | - zeitgeist_register_mimetype ("text/x-sql", |
267 | - ZEITGEIST_NFO_SOURCE_CODE); |
268 | - zeitgeist_register_mimetype ("text/x-tcl", |
269 | - ZEITGEIST_NFO_SOURCE_CODE); |
270 | - zeitgeist_register_mimetype ("text/x-troff", |
271 | - ZEITGEIST_NFO_SOURCE_CODE); |
272 | - zeitgeist_register_mimetype ("text/x-vala", |
273 | - ZEITGEIST_NFO_SOURCE_CODE); |
274 | - zeitgeist_register_mimetype ("text/x-vhdl", |
275 | - ZEITGEIST_NFO_SOURCE_CODE); |
276 | - zeitgeist_register_mimetype ("text/x-m4", |
277 | - ZEITGEIST_NFO_SOURCE_CODE); |
278 | - |
279 | + zeitgeist_register_mimetype ("text/x-latex", ZEITGEIST_NFO_SOURCE_CODE); |
280 | + zeitgeist_register_mimetype ("application/x-applix-word", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
281 | + zeitgeist_register_mimetype ("text/x-chdr", ZEITGEIST_NFO_SOURCE_CODE); |
282 | + zeitgeist_register_mimetype ("application/vnd.ms-powerpoint", ZEITGEIST_NFO_PRESENTATION); |
283 | + zeitgeist_register_mimetype ("text/x-m4", ZEITGEIST_NFO_SOURCE_CODE); |
284 | + zeitgeist_register_mimetype ("audio/x-scpls", ZEITGEIST_NFO_MEDIA_LIST); |
285 | + zeitgeist_register_mimetype ("text/html", ZEITGEIST_NFO_HTML_DOCUMENT); |
286 | + zeitgeist_register_mimetype ("text/x-tex", ZEITGEIST_NFO_SOURCE_CODE); |
287 | + zeitgeist_register_mimetype ("application/x-dia-diagram", ZEITGEIST_NFO_SOURCE_CODE); |
288 | + zeitgeist_register_mimetype ("text/x-tcl", ZEITGEIST_NFO_SOURCE_CODE); |
289 | + zeitgeist_register_mimetype ("application/x-applix-spreadsheet", ZEITGEIST_NFO_SPREADSHEET); |
290 | + zeitgeist_register_mimetype ("text/x-sql", ZEITGEIST_NFO_SOURCE_CODE); |
291 | + zeitgeist_register_mimetype ("text/x-pascal", ZEITGEIST_NFO_SOURCE_CODE); |
292 | + zeitgeist_register_mimetype ("application/msexcel", ZEITGEIST_NFO_SPREADSHEET); |
293 | + zeitgeist_register_mimetype ("text/x-patch", ZEITGEIST_NFO_SOURCE_CODE); |
294 | + zeitgeist_register_mimetype ("text/x-csrc", ZEITGEIST_NFO_SOURCE_CODE); |
295 | + zeitgeist_register_mimetype ("text/x-c++", ZEITGEIST_NFO_SOURCE_CODE); |
296 | + zeitgeist_register_mimetype ("application/x-csh", ZEITGEIST_NFO_SOURCE_CODE); |
297 | + zeitgeist_register_mimetype ("application/ecmascript", ZEITGEIST_NFO_SOURCE_CODE); |
298 | + zeitgeist_register_mimetype ("text/css", ZEITGEIST_NFO_SOURCE_CODE); |
299 | + zeitgeist_register_mimetype ("application/msword", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
300 | + zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.text.*", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
301 | + zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.presentation.*", ZEITGEIST_NFO_PRESENTATION); |
302 | + zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.spreadsheet.*", ZEITGEIST_NFO_SPREADSHEET); |
303 | + zeitgeist_register_mimetype_regex ("application/vnd.oasis.opendocument.graphics.*", ZEITGEIST_NFO_VECTOR_IMAGE); |
304 | + zeitgeist_register_mimetype_regex ("application/vnd\\..*", ZEITGEIST_NFO_DOCUMENT); |
305 | + zeitgeist_register_mimetype_regex ("application/x-applix-.*", ZEITGEIST_NFO_DOCUMENT); |
306 | + zeitgeist_register_mimetype_regex ("application/vnd.ms-excel.*", ZEITGEIST_NFO_SPREADSHEET); |
307 | + zeitgeist_register_mimetype_regex ("application/vnd.ms-powerpoint.*", ZEITGEIST_NFO_PRESENTATION); |
308 | + zeitgeist_register_mimetype_regex (".*/x-dvi", ZEITGEIST_NFO_PAGINATED_TEXT_DOCUMENT); |
309 | + zeitgeist_register_mimetype_regex ("image/.*", ZEITGEIST_NFO_IMAGE); |
310 | + zeitgeist_register_mimetype_regex ("audio/.*", ZEITGEIST_NFO_AUDIO); |
311 | + zeitgeist_register_mimetype_regex ("video/.*", ZEITGEIST_NFO_VIDEO); |
312 | + |
313 | mimes_loaded = TRUE; |
314 | } |
315 | |
316 | @@ -465,8 +347,7 @@ |
317 | zeitgeist_register_uri_scheme ("https://", ZEITGEIST_NFO_REMOTE_DATA_OBJECT); |
318 | zeitgeist_register_uri_scheme ("ssh://", ZEITGEIST_NFO_REMOTE_DATA_OBJECT); |
319 | zeitgeist_register_uri_scheme ("sftp://", ZEITGEIST_NFO_REMOTE_DATA_OBJECT); |
320 | - // FIXME: Define more URI schemess |
321 | - |
322 | + |
323 | schemes_loaded = TRUE; |
324 | } |
325 | |
326 | |
327 | === added file 'tools/mimetypes2c.py' |
328 | --- tools/mimetypes2c.py 1970-01-01 00:00:00 +0000 |
329 | +++ tools/mimetypes2c.py 2010-09-06 00:12:59 +0000 |
330 | @@ -0,0 +1,88 @@ |
331 | +# |
332 | +# Utility to transcode the Zeitgeist ontology from Python code |
333 | +# to a C header file defining a collection of macros for the |
334 | +# members of the ontology |
335 | +# |
336 | + |
337 | +import sys |
338 | +import re |
339 | +import zeitgeist.datamodel as dm |
340 | +from zeitgeist.mimetypes import MIMES, MIMES_REGEX, SCHEMES |
341 | + |
342 | +def caseconv(name): |
343 | + """ |
344 | + Converts CamelCase to CAMEL_CASE |
345 | + """ |
346 | + result = "" |
347 | + for i in range(len(name) - 1) : |
348 | + if name[i].islower() and name[i+1].isupper(): |
349 | + result += name[i].upper() + "_" |
350 | + else: |
351 | + result += name[i].upper() |
352 | + result += name[-1].upper() |
353 | + return result |
354 | + |
355 | +def symbolname (symbol): |
356 | + try: |
357 | + ns, name = symbol[symbol.rfind("/")+1:].split("#") |
358 | + return "ZEITGEIST_%s_%s" % (ns.upper(), caseconv(name)) |
359 | + except Exception, e: |
360 | + return symbol.uri.rpartition("#")[2].upper() |
361 | + |
362 | +def output_load_funcs (mimes_body, schemes_body): |
363 | + mimes_header = """ |
364 | +static void |
365 | +_ensure_mimes_loaded (void) |
366 | +{ |
367 | + if (mimes_loaded) return; |
368 | + |
369 | +%s |
370 | + |
371 | + mimes_loaded = TRUE; |
372 | +} |
373 | +""" |
374 | + |
375 | + schemes_header = """ |
376 | +static void |
377 | +_ensure_schemes_loaded (void) |
378 | +{ |
379 | + if (schemes_loaded) return; |
380 | + |
381 | +%s |
382 | + |
383 | + schemes_loaded = TRUE; |
384 | +} |
385 | +""" |
386 | + |
387 | + # indent |
388 | + m = mimes_header[1:] % re.sub(r'(?m)^(.+)$', r' \1', mimes_body) |
389 | + s = schemes_header[1:] % re.sub(r'(?m)^(.+)$', r' \1', schemes_body) |
390 | + return '\n'.join([m, s]) |
391 | + |
392 | +def get_mimetypes_calls (simple_mimetypes, regex_mimetypes): |
393 | + calls = [] |
394 | + for mimetype, interpretation in simple_mimetypes.items(): |
395 | + calls.append('zeitgeist_register_mimetype ("%s", %s);' % (mimetype, symbolname(interpretation))) |
396 | + |
397 | + for mimetype_regex, interpretation in regex_mimetypes: |
398 | + mimetype = re.sub(r'\\', '\\' * 4, str(mimetype_regex)) |
399 | + calls.append('zeitgeist_register_mimetype_regex ("%s", %s);' % (mimetype, symbolname(interpretation))) |
400 | + |
401 | + return calls |
402 | + |
403 | +def get_schemes_calls (schemes): |
404 | + calls = [] |
405 | + for scheme, manifestation in schemes: |
406 | + calls.append('zeitgeist_register_uri_scheme ("%s", %s);' % (scheme, symbolname(manifestation))) |
407 | + |
408 | + return calls |
409 | + |
410 | +if __name__ == "__main__": |
411 | + all_mimes = get_mimetypes_calls(MIMES, MIMES_REGEX) |
412 | + all_schemes = get_schemes_calls(SCHEMES) |
413 | + |
414 | + assert(len(all_mimes) > 0 and len(all_schemes) > 0) |
415 | + |
416 | + f = open('zeitgeist-mimetypes.template', 'r') |
417 | + print f.read() |
418 | + print output_load_funcs('\n'.join(all_mimes), '\n'.join(all_schemes)) |
419 | |
420 | === added file 'tools/zeitgeist-mimetypes.template' |
421 | --- tools/zeitgeist-mimetypes.template 1970-01-01 00:00:00 +0000 |
422 | +++ tools/zeitgeist-mimetypes.template 2010-09-06 00:12:59 +0000 |
423 | @@ -0,0 +1,236 @@ |
424 | +/* |
425 | + * Copyright (C) 2010 Canonical, Ltd. |
426 | + * |
427 | + * This library is free software; you can redistribute it and/or modify |
428 | + * it under the terms of the GNU Lesser General Public License |
429 | + * version 3.0 as published by the Free Software Foundation. |
430 | + * |
431 | + * This library is distributed in the hope that it will be useful, |
432 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
433 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
434 | + * GNU Lesser General Public License version 3.0 for more details. |
435 | + * |
436 | + * You should have received a copy of the GNU Lesser General Public |
437 | + * License along with this library. If not, see |
438 | + * <http://www.gnu.org/licenses/>. |
439 | + * |
440 | + * Authored by |
441 | + * Mikkel Kamstrup Erlandsen <mikkel.kamstrup@canonical.com> |
442 | + */ |
443 | + |
444 | +#include "zeitgeist-mimetypes.h" |
445 | +#include "zeitgeist-ontology-interpretations.h" |
446 | +#include "zeitgeist-ontology-manifestations.h" |
447 | + |
448 | +static void _ensure_mimes_loaded (void); |
449 | +static void _ensure_schemes_loaded (void); |
450 | + |
451 | +static gboolean mimes_loaded = FALSE; |
452 | +static gboolean schemes_loaded = FALSE; |
453 | +static GHashTable *mimes = NULL; |
454 | +static GSList *mimes_r = NULL; |
455 | +static GSList *schemes = NULL; |
456 | + |
457 | +typedef struct |
458 | +{ |
459 | + gchar *scheme; |
460 | + gchar *manifestation_uri; |
461 | +} UriScheme; |
462 | + |
463 | +typedef struct |
464 | +{ |
465 | + GRegex *regex; |
466 | + gchar *interpretation_uri; |
467 | +} MimeRegex; |
468 | + |
469 | +static MimeRegex* |
470 | +mime_regex_new (const gchar *mimetype_regex, const gchar *interpretation_uri) |
471 | +{ |
472 | + MimeRegex *m = g_slice_new (MimeRegex); |
473 | + m->regex = g_regex_new (mimetype_regex, 0, 0, NULL); |
474 | + m->interpretation_uri = g_strdup (interpretation_uri); |
475 | + return m; |
476 | +} |
477 | + |
478 | +/*static void |
479 | +mime_regex_free (MimeRegex *m) |
480 | +{ |
481 | + g_regex_unref (m->regex); |
482 | + g_free (m->interpretation_uri); |
483 | + g_slice_free (MimeRegex, m); |
484 | +}*/ |
485 | + |
486 | +static UriScheme* |
487 | +uri_scheme_new (const gchar *uri_scheme, const gchar *manifestation_uri) |
488 | +{ |
489 | + UriScheme *s = g_slice_new (UriScheme); |
490 | + s->scheme = g_strdup (uri_scheme); |
491 | + s->manifestation_uri = g_strdup (manifestation_uri); |
492 | + return s; |
493 | +} |
494 | + |
495 | +/*static void |
496 | +uri_scheme_free (UriScheme *s) |
497 | +{ |
498 | + g_free (s->scheme); |
499 | + g_free (s->manifestation_uri); |
500 | + g_slice_free (UriScheme, s); |
501 | +}*/ |
502 | + |
503 | + |
504 | + |
505 | +/** |
506 | + * zeitgeist_register_mimetype: |
507 | + * @mimetype: A mimetype string. Fx. <emphasis>text/plain</emphasis> |
508 | + * @interpretation_uri: A URI defining the interpretation type to associate with @mimetype |
509 | + * |
510 | + * Associate a mimetype with a given interpretation type. Registered mimetypes |
511 | + * can be looked up with zeitgeist_interpretation_for_mimetype(). You can |
512 | + * register a regular expression as mimetype if you instead of this function |
513 | + * invoke zeitgeist_register_mimetype_regex(). |
514 | + * |
515 | + * Mimetypes are first looked up by their exact name and then if none is |
516 | + * found the regular expressions will be checked as fallbacks. |
517 | + * |
518 | + * This library will install a wide range a common mimetypes for you, so unless |
519 | + * you have very specific needs you will normally not have to call this |
520 | + * function. |
521 | + * |
522 | + * See the list of common |
523 | + * <link linkend="zeitgeist-1.0-Interpretation-Ontology">interpretation types</link>. |
524 | + */ |
525 | +void |
526 | +zeitgeist_register_mimetype (const gchar *mimetype, |
527 | + const gchar *interpretation_uri) |
528 | +{ |
529 | + if (mimes == NULL) |
530 | + mimes = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); |
531 | + |
532 | + g_hash_table_insert (mimes, g_strdup (mimetype), |
533 | + g_strdup (interpretation_uri)); |
534 | +} |
535 | + |
536 | +/** |
537 | + * zeitgeist_register_mimetype_regex: |
538 | + * @mimetype_regex: A regular expression matching a certain range of mimetypes. |
539 | + * Fx. <emphasis>text/.*</emphasis> to match all |
540 | + * <emphasis>text</emphasis> sub types. |
541 | + * @interpretation_uri: A URI defining the interpretation type to associate with |
542 | + * the matched mimetypes |
543 | + * |
544 | + * Associate a range of mimetypes with a given interpretation type. |
545 | + * Registered mimetypes can be looked up with |
546 | + * zeitgeist_interpretation_for_mimetype(). If you only need to register one |
547 | + * specific mimetype it is more efficient if you instead of this function |
548 | + * call zeitgeist_register_mimetype(). |
549 | + * |
550 | + * Mimetypes are first looked up by their exact name and then if none is |
551 | + * found the regular expressions will be checked as fallbacks. |
552 | + * |
553 | + * This library will install a wide range a common mimetypes for you, so unless |
554 | + * you have very specific needs you will normally not have to call this |
555 | + * function. |
556 | + * |
557 | + * See the list of common |
558 | + * <link linkend="zeitgeist-1.0-Interpretation-Ontology">interpretation types</link>. |
559 | + */ |
560 | +void |
561 | +zeitgeist_register_mimetype_regex (const gchar *mimetype_regex, |
562 | + const gchar *interpretation_uri) |
563 | +{ |
564 | + mimes_r = g_slist_append (mimes_r, |
565 | + mime_regex_new (mimetype_regex, |
566 | + interpretation_uri)); |
567 | +} |
568 | + |
569 | +/** |
570 | + * zeitgeist_interpretation_for_mimetype: |
571 | + * @mimetype: A mimetype string. Fx. <emphasis>text/plain</emphasis> |
572 | + * |
573 | + * Look up the interpretation type associated with @mimetype. Please see the |
574 | + * list of common |
575 | + * <link linkend="zeitgeist-1.0-Interpretation-Ontology">interpretation types</link>. |
576 | + * |
577 | + * Returns: A URI defining the interpretation type associated with @mimetype or |
578 | + * %NULL in case @mimetype is unknown. |
579 | + */ |
580 | +const gchar* |
581 | +zeitgeist_interpretation_for_mimetype (const gchar *mimetype) |
582 | +{ |
583 | + const gchar *result; |
584 | + GSList *iter; |
585 | + |
586 | + _ensure_mimes_loaded(); |
587 | + |
588 | + /* First look in our hash table */ |
589 | + result = g_hash_table_lookup (mimes, |
590 | + mimetype); |
591 | + if (result != NULL) |
592 | + return result; |
593 | + |
594 | + /* Check our regexes */ |
595 | + for (iter = mimes_r; iter; iter = iter->next) |
596 | + { |
597 | + MimeRegex *m = (MimeRegex*) iter->data; |
598 | + if (g_regex_match (m->regex, mimetype, 0, NULL)) |
599 | + return m->interpretation_uri; |
600 | + } |
601 | + |
602 | + return NULL; |
603 | +} |
604 | + |
605 | +/** |
606 | + * zeitgeist_register_uri_scheme: |
607 | + * @uri_scheme: A URI scheme such as <emphasis>http://</emphasis> |
608 | + * @manifestation_uri: A URI defining the manifestation type to associate with |
609 | + * @uri_scheme |
610 | + * |
611 | + * Associate a URI scheme with a given manifestation type. |
612 | + * You can find the manifestation type of a given URI by passing it to |
613 | + * zeitgeist_manifestation_for_uri(). |
614 | + * |
615 | + * This library will install a range a common URI schemes for you, so unless |
616 | + * you have very specific needs you will normally not have to call this |
617 | + * function. |
618 | + * |
619 | + * See the list of common |
620 | + * <link linkend="zeitgeist-1.0-Manifestation-Ontology">manifestation types</link>. |
621 | + */ |
622 | +void |
623 | +zeitgeist_register_uri_scheme (const gchar *uri_scheme, |
624 | + const gchar *manifestation_uri) |
625 | +{ |
626 | + schemes = g_slist_append (schemes, |
627 | + uri_scheme_new (uri_scheme, manifestation_uri)); |
628 | +} |
629 | + |
630 | +/** |
631 | + * zeitgeist_manifestation_for_uri: |
632 | + * @uri: A URI |
633 | + * |
634 | + * Look up a manifestation type for a given URI. Eg. if you pass in |
635 | + * <emphasis>file:///tmp/foo.txt</emphasis> you will get back |
636 | + * #ZEITGEIST_NFO_FILE_DATA_OBJECT. |
637 | + * |
638 | + * See the list of common |
639 | + * <link linkend="zeitgeist-1.0-Manifestation-Ontology">manifestation types</link>. |
640 | + * |
641 | + * Returns: A manifestation type for @uri or %NULL in case no suitable |
642 | + * manifestation type is known |
643 | + */ |
644 | +const gchar* |
645 | +zeitgeist_manifestation_for_uri (const gchar *uri) |
646 | +{ |
647 | + GSList *iter; |
648 | + |
649 | + _ensure_schemes_loaded(); |
650 | + |
651 | + for (iter = schemes; iter; iter = iter->next) |
652 | + { |
653 | + UriScheme *s = (UriScheme*) iter->data; |
654 | + if (g_str_has_prefix (uri, s->scheme)) |
655 | + return s->manifestation_uri; |
656 | + } |
657 | + |
658 | + return NULL; |
659 | +} |
What is the major difference in zeitgeist- mimetypes. c? Should that not be replaced or depend on the mimetypes2c ?