libgnomevfsmm  2.26.0
mime-handlers.h
Go to the documentation of this file.
1 /* Copyright 2003 gnome-vfsmm Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free
15  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16  */
17 
18 
19 #ifndef _LIBGNOMEVFSMM_MIME_HANDLERS_H
20 #define _LIBGNOMEVFSMM_MIME_HANDLERS_H
21 
22 #include <glibmm.h>
23 
24 #include <libgnomevfsmm/enums.h>
28 
29 /*
30  * If the underlying GConf implementation does not use Orbit, then
31  * stub out the return of functions which are Bonobo-specific
32  */
33 #include <libgnomevfs/gnome-vfs-mime-handlers.h>
34 #ifdef DISABLE_ORBIT
35 typedef void Bonobo_ServerInfo;
36 #endif
37 
38 namespace Gnome
39 {
40 
41 namespace Vfs
42 {
43 
44 //TODO: Explain when/how someone might use this stuff.
45 //TODO: Consider renaming this to MimeDatabase or something similar. Murray.
46 //e.g. Direct people to
47 //- get_registered_types() to discover all MIME types.
48 //- get_description() to get a human-readable description of a MIME type.
49 //- get_all_applications() to get a list of applications that can handle the MIME type.
50 //TODO: Tell them how to get the MIME type for a file.
51 namespace Mime
52 {
53 
54 typedef Glib::ListHandle<Gnome::Vfs::MimeApplication*> ListHandleApps;
55 //Removed from gnome-vfs: typedef GList* ListHandleComps;
56 typedef Glib::ListHandle<Glib::ustring> ListHandleStrings;
57 
58 /*
59  * Accessor functions
60  */
61 
62 //TODO: The result is either APPLICATION or COMPONENT. These don't sound like actions,
63 // so my explanation seems necessary. Murray.
68 MimeActionType get_default_action_type(const Glib::ustring& mime_type);
69 
74 MimeApplication get_default_application(const Glib::ustring& mime_type);
75 
80 GnomeVFSMimeAction* get_default_action(const Glib::ustring& mime_type);
81 
82 // TODO: Figure out how the heck to wrap this Bonobo_ServerInfo thingy...
83 //Removed from gnome-vfs: Bonobo_ServerInfo* get_default_component(const Glib::ustring& mime_type);
84 
85 //TODO: What determines whether an application is in the short list or the all list? Murray.
86 //TODO: This is a list of pointers. Who deletes them? Murray
91 ListHandleApps get_short_list_applications(const Glib::ustring& mime_type);
92 
93 //TODO: This is a list of pointers. Who deletes them? Murray.
98 ListHandleApps get_all_applications(const Glib::ustring& mime_type);
99 
100 
101 //Removed from gnome-vfs: ListHandleComps get_short_list_components(const Glib::ustring& mime_type);
102 
103 
104 //Removed from gnome-vfs: ListHandleComps get_all_components(const Glib::ustring& mime_type);
105 
106 //TODO: If this is just a convenience function, then we should say so. Murray.
112 bool id_in_application_list(const Glib::ustring& id, const ListHandleApps& applications);
113 
114 //TODO: If this is just a convenience function, then we should say so. Murray.
120 
121 
122 //Removed from gnome-vfs: bool id_in_component_list(const Glib::ustring& iid, ListHandleComps components);
123 //Removed from gnome-vfs: ListHandleStrings id_list_from_component_list(ListHandleComps components);
124 
133 Glib::ustring get_icon(const Glib::ustring& mime_type);
134 
139 Glib::ustring get_description(const Glib::ustring& mime_type);
140 
146 bool can_be_executable(const Glib::ustring& mime_type);
147 
152 bool type_is_known(const Glib::ustring& mime_type);
153 
158 ListHandleStrings get_extensions_list(const Glib::ustring& mime_type);
159 
165 Glib::ustring get_extensions_string(const Glib::ustring& mime_type, bool pretty = false);
166 
171 
172 //TODO: What happens if the key is invalid? Murray.
173 //TODO: What is a key? Murray.
174 //TODO: What is a GnomeMimeContext? Murray.
175 //TODO: What data does this return? Murray.
181 Glib::ustring get_value(Glib::ustring& mime_type, Glib::ustring& key);
182 
187 ListHandleStrings get_key_list(Glib::ustring& mime_type);
188 
189 /*
190  * Mutator functions
191  * TODO: "Mutator" means nothing to me in this context. Murray.
192  */
193 
198 #ifdef GLIBMM_EXCEPTIONS_ENABLED
199 void set_default_action_type(const Glib::ustring& mime_type, MimeActionType action_type) throw(exception);
200 #else
201 void set_default_action_type(const Glib::ustring& mime_type, MimeActionType action_type, std::auto_ptr<Gnome::Vfs::exception>& error);
202 #endif //GLIBMM_EXCEPTIONS_ENABLED
203 
208 #ifdef GLIBMM_EXCEPTIONS_ENABLED
209 void set_default_application(const Glib::ustring& mime_type, const Glib::ustring& application_id) throw(exception);
210 #else
211 void set_default_application(const Glib::ustring& mime_type, const Glib::ustring& application_id, std::auto_ptr<Gnome::Vfs::exception>& error);
212 #endif //GLIBMM_EXCEPTIONS_ENABLED
213 
218 #ifdef GLIBMM_EXCEPTIONS_ENABLED
219 void set_default_component(const Glib::ustring& mime_type, const Glib::ustring& iid) throw(exception);
220 #else
221 void set_default_component(const Glib::ustring& mime_type, const Glib::ustring& iid, std::auto_ptr<Gnome::Vfs::exception>& error);
222 #endif //GLIBMM_EXCEPTIONS_ENABLED
223 
231 #ifdef GLIBMM_EXCEPTIONS_ENABLED
232 void set_icon(const Glib::ustring& mime_type, const Glib::ustring& filename) throw(exception);
233 #else
234 void set_icon(const Glib::ustring& mime_type, const Glib::ustring& filename, std::auto_ptr<Gnome::Vfs::exception>& error);
235 #endif //GLIBMM_EXCEPTIONS_ENABLED
236 
242 #ifdef GLIBMM_EXCEPTIONS_ENABLED
243 void set_description(const Glib::ustring& mime_type, const Glib::ustring& description) throw(exception);
244 #else
245 void set_description(const Glib::ustring& mime_type, const Glib::ustring& description, std::auto_ptr<Gnome::Vfs::exception>& error);
246 #endif //GLIBMM_EXCEPTIONS_ENABLED
247 
252 #ifdef GLIBMM_EXCEPTIONS_ENABLED
253 void set_can_be_executable(const Glib::ustring& mime_type, bool new_value) throw(exception);
254 #else
255 void set_can_be_executable(const Glib::ustring& mime_type, bool new_value, std::auto_ptr<Gnome::Vfs::exception>& error);
256 #endif //GLIBMM_EXCEPTIONS_ENABLED
257 
263 #ifdef GLIBMM_EXCEPTIONS_ENABLED
264 void set_short_list_applications(const Glib::ustring& mime_type, ListHandleStrings& application_ids) throw(exception);
265 #else
266 void set_short_list_applications(const Glib::ustring& mime_type, ListHandleStrings& application_ids, std::auto_ptr<Gnome::Vfs::exception>& error);
267 #endif //GLIBMM_EXCEPTIONS_ENABLED
268 
274 #ifdef GLIBMM_EXCEPTIONS_ENABLED
275 void set_short_list_components(const Glib::ustring& mime_type, ListHandleStrings& component_iids) throw(exception);
276 #else
277 void set_short_list_components(const Glib::ustring& mime_type, ListHandleStrings& component_iids, std::auto_ptr<Gnome::Vfs::exception>& error);
278 #endif //GLIBMM_EXCEPTIONS_ENABLED
279 
285 #ifdef GLIBMM_EXCEPTIONS_ENABLED
286 void add_application_to_short_list(const Glib::ustring& mime_type, Glib::ustring& application_id) throw(exception);
287 #else
288 void add_application_to_short_list(const Glib::ustring& mime_type, Glib::ustring& application_id, std::auto_ptr<Gnome::Vfs::exception>& error);
289 #endif //GLIBMM_EXCEPTIONS_ENABLED
290 
296 #ifdef GLIBMM_EXCEPTIONS_ENABLED
297 void remove_application_from_short_list(const Glib::ustring& mime_type, Glib::ustring& application_id) throw(exception);
298 #else
299 void remove_application_from_short_list(const Glib::ustring& mime_type, Glib::ustring& application_id, std::auto_ptr<Gnome::Vfs::exception>& error);
300 #endif //GLIBMM_EXCEPTIONS_ENABLED
301 
307 #ifdef GLIBMM_EXCEPTIONS_ENABLED
308 void add_component_to_short_list(const Glib::ustring& mime_type, Glib::ustring& component_iid) throw(exception);
309 #else
310 void add_component_to_short_list(const Glib::ustring& mime_type, Glib::ustring& component_iid, std::auto_ptr<Gnome::Vfs::exception>& error);
311 #endif //GLIBMM_EXCEPTIONS_ENABLED
312 
318 #ifdef GLIBMM_EXCEPTIONS_ENABLED
319 void remove_component_from_short_list(const Glib::ustring& mime_type, Glib::ustring& component_iid) throw(exception);
320 #else
321 void remove_component_from_short_list(const Glib::ustring& mime_type, Glib::ustring& component_iid, std::auto_ptr<Gnome::Vfs::exception>& error);
322 #endif //GLIBMM_EXCEPTIONS_ENABLED
323 
328 #ifdef GLIBMM_EXCEPTIONS_ENABLED
329 void add_extension(const Glib::ustring& mime_type, Glib::ustring& extension) throw(exception);
330 #else
331 void add_extension(const Glib::ustring& mime_type, Glib::ustring& extension, std::auto_ptr<Gnome::Vfs::exception>& error);
332 #endif //GLIBMM_EXCEPTIONS_ENABLED
333 
338 #ifdef GLIBMM_EXCEPTIONS_ENABLED
339 void remove_extension(const Glib::ustring& mime_type, Glib::ustring& extension) throw(exception);
340 #else
341 void remove_extension(const Glib::ustring& mime_type, Glib::ustring& extension, std::auto_ptr<Gnome::Vfs::exception>& error);
342 #endif //GLIBMM_EXCEPTIONS_ENABLED
343 
349 #ifdef GLIBMM_EXCEPTIONS_ENABLED
350 void set_extensions_list(const Glib::ustring& mime_type, const Glib::ustring& extensions_list) throw(exception);
351 #else
352 void set_extensions_list(const Glib::ustring& mime_type, const Glib::ustring& extensions_list, std::auto_ptr<Gnome::Vfs::exception>& error);
353 #endif //GLIBMM_EXCEPTIONS_ENABLED
354 
359 #ifdef GLIBMM_EXCEPTIONS_ENABLED
360 void extend_all_applications(const Glib::ustring& mime_type, ListHandleStrings& application_ids) throw(exception);
361 #else
362 void extend_all_applications(const Glib::ustring& mime_type, ListHandleStrings& application_ids, std::auto_ptr<Gnome::Vfs::exception>& error);
363 #endif //GLIBMM_EXCEPTIONS_ENABLED
364 
369 #ifdef GLIBMM_EXCEPTIONS_ENABLED
370 void remove_from_all_applications(const Glib::ustring& mime_type, ListHandleStrings& application_ids) throw(exception);
371 #else
372 void remove_from_all_applications(const Glib::ustring& mime_type, ListHandleStrings& application_ids, std::auto_ptr<Gnome::Vfs::exception>& error);
373 #endif //GLIBMM_EXCEPTIONS_ENABLED
374 
379 void registered_mime_type_delete(const Glib::ustring& mime_type);
380 
386 #ifdef GLIBMM_EXCEPTIONS_ENABLED
387 void set_registered_type_key(const Glib::ustring& mime_type, const Glib::ustring& key, const Glib::ustring& data) throw(exception);
388 #else
389 void set_registered_type_key(const Glib::ustring& mime_type, const Glib::ustring& key, const Glib::ustring& data, std::auto_ptr<Gnome::Vfs::exception>& error);
390 #endif //GLIBMM_EXCEPTIONS_ENABLED
391 
398 #ifdef GLIBMM_EXCEPTIONS_ENABLED
399 void set_value(const Glib::ustring& mime_type, const Glib::ustring& key, const Glib::ustring& value) throw(exception);
400 #else
401 void set_value(const Glib::ustring& mime_type, const Glib::ustring& key, const Glib::ustring& value, std::auto_ptr<Gnome::Vfs::exception>& error);
402 #endif //GLIBMM_EXCEPTIONS_ENABLED
403 
404 /*
405  * Mime Control
406  */
407 
412 void freeze();
413 
416 void thaw();
417 
421 void info_reload();
422 
425 void reset();
426 
427 } // namespace Mime
428 } // namespace Vfs
429 } // namespace Gnome
430 
431 #endif /* _LIBGNOMEVFSMM_MIME_HANDLERS_H */