KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jdesktop > jdic > filetypes > internal > GnomeVfsWrapper


1 /*
2  * Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is
3  * subject to license terms.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the Lesser GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  */

20
21 package org.jdesktop.jdic.filetypes.internal;
22
23
24 /**
25  * Java wrapper class for GnomeVFS API both on Linux and Solaris platforms.
26  * <P>
27  * GnomeVFS, a filesystem abstraction library, contains convenient file utilities,
28  * including a comphrehensive MIME database/Application registry.
29  * <P>
30  * The MIME database/Application registry are stored as plain text files:
31  * $gnome_prefix/share/mime-info/*.mime, *.keys and $gnome_prefix/share/application-registry/*.applications.
32  */

33
34 /*
35  * Following gives an example on mime type text/html stored in
36  * the MIME database/Application registry. Each of the Java wrapper method for native
37  * functions gives the result corresponding to this example.
38  * ----------------------------------------------------------------------
39  * 1. $gnome_prefix/share/mime-info/gnome-vfs.keys:
40  * text/html
41  * description=HTML page
42  * [az]description=...
43  * ......
44  * [zh_TW]description=...
45  * default_action_type=application
46  * default_application_id=htmlview
47  * short_list_component_iids=OAFIID:nautilus_mozilla_content_view:1ee70717-57bf-4079-aae5-922abdd576b1,OAFIID
48  * :Nautilus_Text_View
49  * short_list_component_iids_for_novice_user_level=OAFIID:nautilus_mozilla_content_view
50  * :1ee70717-57bf-4079-aae5-922abdd576b1,OAFIID:nautilus_text_view:fa466311-17c1-435c-8231-c9fc434b6437
51  * short_list_component_iids_for_intermediate_user_level=OAFIID:nautilus_mozilla_content_view
52  * :1ee70717-57bf-4079-aae5-922abdd576b1,OAFIID:nautilus_text_view:fa466311-17c1-435c-8231-c9fc434b6437
53  * short_list_component_iids_for_advanced_user_level=OAFIID:nautilus_mozilla_content_view
54  * :1ee70717-57bf-4079-aae5-922abdd576b1,OAFIID:nautilus_text_view:fa466311-17c1-435c-8231-c9fc434b6437
55  * short_list_application_ids_for_novice_user_level=htmlview,mozilla,netscape,galeon
56  * short_list_application_ids_for_intermediate_user_level=htmlview,mozilla,netscape,galeon
57  * short_list_application_ids_for_advanced_user_level=htmlview,mozilla,netscape,lynx,galeon
58  * category=Documents/World Wide Web
59  * use_category_default=yes
60  *
61  * 2. $gnome_prefix/share/mime-info/gnome-vfs.mime
62  * text/html
63  * ext: html htm HTML
64  *
65  * 3. $gnome_prefix/share/mime-info/test-html.keys: overrides the items in system default gnome-vfs.keys
66  * ext/html:
67  * open=vi %f
68  * view=vi %f
69  * icon-filename=/usr/share/pixmaps/html.png
70  *
71  * 4. $gnome_prefix/share/mime-info/test-html.mime: overrides the items in system default gnome-vfs.mime
72  * text/html
73  * ext: testhtml testhtm
74  *
75  * 5. $gnome_prefix/share/application-registry/gnome-vfs.application
76  * htmlview
77  * command=htmlview
78  * name=htmlview
79  * can_open_multiple_files=true
80  * expects_uris=true
81  * requires_terminal=false
82  * supported_uri_schemes=file,http,ftp,telnet,gopher
83  * mime_types=text/html,x-directory/webdav,x-directory/webdav-prefer-directory,image/gif,
84  * image/jpeg,text/xml
85  *
86  * 6. $gnome_prefix/share/application-registry/test-html.application:
87  * overrides the system default gnome-vfs.mime.
88  * -----------------------------------------------------------------------
89  */

90
91 public class GnomeVfsWrapper {
92     static {
93         System.loadLibrary("jdic");
94     }
95
96     /* Description and icon_filename keys used on GNOME desktop */
97     public final static String JavaDoc GNOME_VFS_MIME_KEY_DESCRIPTION = "description";
98     public final static String JavaDoc GNOME_VFS_MIME_DEFAULT_KEY_ICON_FILENAME = "icon_filename";
99     
100     /**
101      * Suppress default constructor for noninstantiability.
102      */

103     private GnomeVfsWrapper() {}
104
105     /**
106      * Returns the the mime type of the specified uri.
107      * <PRE>
108      * For example:
109      * for uri file:/test.html, returns text/html.
110      * for uri http://sceri.prc.sun.com/index.html, it also returns text/html.
111      * </PRE>
112      */

113     public static native String JavaDoc gnome_vfs_get_mime_type(String JavaDoc uri);
114
115     /**
116      * Query the MIME database for a description of the specified MIME type.
117      * <PRE>
118      * For example:
119      * for text/html, returns HTML page.
120      * </PRE>
121      */

122     public static native String JavaDoc gnome_vfs_mime_get_description(String JavaDoc mimeType);
123
124     /**
125      * Query the MIME database for an icon representing the specified MIME type.
126      * <PRE>
127      * For example:
128      * for text/html, returns /usr/share/pixmaps/html.png.
129      * </PRE>
130      */

131     public static native String JavaDoc gnome_vfs_mime_get_icon(String JavaDoc mimeType);
132
133     /**
134      * Return a string array with all of the keys associated with the mime_type.
135      * <PRE>
136      * For example:
137      * for text/html, returns
138      * short_list_application_ids_for_intermediate_user_level
139      * short_list_application_ids_for_novice_user_level
140      * short_list_component_iids_for_intermediate_user_level
141      * short_list_component_iids_for_novice_user_level
142      * default_action_type
143      * category
144      * short_list_application_ids_for_advanced_user_level
145      * short_list_component_iids
146      * short_list_component_iids_for_advanced_user_level
147      * default_application_id
148      * </PRE>
149      */

150     public static native String JavaDoc[] gnome_vfs_mime_get_key_list(String JavaDoc mimeType);
151   
152     /**
153      * Retrieve the value associated with key for te given mime type.
154      * <P>
155      * The following keys are used in GNOME desktop:
156      * open, icon-filename, view, ascii-view, fm-open, fm-view, fm-ascii-view.
157      * <PRE>
158      * For example:
159      * for text/html and key is "open", returns vi %f.
160      * if key is category, returns Documents/World Wide Web.
161      * </PRE>
162      */

163     public static native String JavaDoc gnome_vfs_mime_get_value(String JavaDoc mimeType, String JavaDoc key);
164   
165     /**
166      * Query the MIME database for the application to be executed on files of MIME type by default.
167      * Returns the command string running this application.
168      * <PRE>
169      * For example:
170      * for text/html, returns htmlview.
171      * </PRE>
172      */

173     public static native String JavaDoc gnome_vfs_mime_get_default_application_command(String JavaDoc mimeType);
174
175     /**
176      * Return all the mime types registered in the MIME type database.
177      */

178     public static native String JavaDoc[] gnome_vfs_get_registered_mime_types();
179   
180     /**
181      * Return a list of extensions for this mime-type.
182      * <PRE>
183      * For example:
184      * for text/html, returns testhtml and testhtm from test-html.mime)
185      * not the system default html, htm and HTML from gnome-vfs.mime.
186      * </PRE>
187      */

188     public static native String JavaDoc[] gnome_vfs_mime_get_extensions_list(String JavaDoc mimeType);
189   
190     /**
191      * Return the value of the specified environment variable, or NULL if there is no match.
192      * This method is not related with Gnome VFS API or library.
193      */

194     public static native String JavaDoc getenv(String JavaDoc envName);
195 }
196
Popular Tags