1/* gbookmarkfile.h: parsing and building desktop bookmarks
2 *
3 * Copyright (C) 2005-2006 Emmanuele Bassi
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this library; if not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __G_BOOKMARK_FILE_H__
20#define __G_BOOKMARK_FILE_H__
21
22#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
23#error "Only <glib.h> can be included directly."
24#endif
25
26#include <glib/gerror.h>
27#include <time.h>
28
29G_BEGIN_DECLS
30
31/**
32 * G_BOOKMARK_FILE_ERROR:
33 *
34 * Error domain for bookmark file parsing.
35 * Errors in this domain will be from the #GBookmarkFileError
36 * enumeration. See #GError for information on error domains.
37 */
38#define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ())
39
40
41/**
42 * GBookmarkFileError:
43 * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed
44 * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found
45 * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did
46 * not register a bookmark
47 * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found
48 * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed
49 * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was
50 * in an unknown encoding
51 * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing
52 * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found
53 *
54 * Error codes returned by bookmark file parsing.
55 */
56typedef enum
57{
58 G_BOOKMARK_FILE_ERROR_INVALID_URI,
59 G_BOOKMARK_FILE_ERROR_INVALID_VALUE,
60 G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
61 G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
62 G_BOOKMARK_FILE_ERROR_READ,
63 G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
64 G_BOOKMARK_FILE_ERROR_WRITE,
65 G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
66} GBookmarkFileError;
67
68GLIB_AVAILABLE_IN_ALL
69GQuark g_bookmark_file_error_quark (void);
70
71/**
72 * GBookmarkFile:
73 *
74 * The `GBookmarkFile` structure contains only
75 * private data and should not be directly accessed.
76 */
77typedef struct _GBookmarkFile GBookmarkFile;
78
79GLIB_AVAILABLE_IN_ALL
80GBookmarkFile *g_bookmark_file_new (void);
81GLIB_AVAILABLE_IN_ALL
82void g_bookmark_file_free (GBookmarkFile *bookmark);
83
84GLIB_AVAILABLE_IN_ALL
85gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark,
86 const gchar *filename,
87 GError **error);
88GLIB_AVAILABLE_IN_ALL
89gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark,
90 const gchar *data,
91 gsize length,
92 GError **error);
93GLIB_AVAILABLE_IN_ALL
94gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark,
95 const gchar *file,
96 gchar **full_path,
97 GError **error);
98GLIB_AVAILABLE_IN_ALL
99gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark,
100 gsize *length,
101 GError **error) G_GNUC_MALLOC;
102GLIB_AVAILABLE_IN_ALL
103gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark,
104 const gchar *filename,
105 GError **error);
106
107GLIB_AVAILABLE_IN_ALL
108void g_bookmark_file_set_title (GBookmarkFile *bookmark,
109 const gchar *uri,
110 const gchar *title);
111GLIB_AVAILABLE_IN_ALL
112gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark,
113 const gchar *uri,
114 GError **error) G_GNUC_MALLOC;
115GLIB_AVAILABLE_IN_ALL
116void g_bookmark_file_set_description (GBookmarkFile *bookmark,
117 const gchar *uri,
118 const gchar *description);
119GLIB_AVAILABLE_IN_ALL
120gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark,
121 const gchar *uri,
122 GError **error) G_GNUC_MALLOC;
123GLIB_AVAILABLE_IN_ALL
124void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark,
125 const gchar *uri,
126 const gchar *mime_type);
127GLIB_AVAILABLE_IN_ALL
128gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark,
129 const gchar *uri,
130 GError **error) G_GNUC_MALLOC;
131GLIB_AVAILABLE_IN_ALL
132void g_bookmark_file_set_groups (GBookmarkFile *bookmark,
133 const gchar *uri,
134 const gchar **groups,
135 gsize length);
136GLIB_AVAILABLE_IN_ALL
137void g_bookmark_file_add_group (GBookmarkFile *bookmark,
138 const gchar *uri,
139 const gchar *group);
140GLIB_AVAILABLE_IN_ALL
141gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark,
142 const gchar *uri,
143 const gchar *group,
144 GError **error);
145GLIB_AVAILABLE_IN_ALL
146gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark,
147 const gchar *uri,
148 gsize *length,
149 GError **error);
150GLIB_AVAILABLE_IN_ALL
151void g_bookmark_file_add_application (GBookmarkFile *bookmark,
152 const gchar *uri,
153 const gchar *name,
154 const gchar *exec);
155GLIB_AVAILABLE_IN_ALL
156gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark,
157 const gchar *uri,
158 const gchar *name,
159 GError **error);
160GLIB_AVAILABLE_IN_ALL
161gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark,
162 const gchar *uri,
163 gsize *length,
164 GError **error);
165GLIB_AVAILABLE_IN_ALL
166gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
167 const gchar *uri,
168 const gchar *name,
169 const gchar *exec,
170 gint count,
171 time_t stamp,
172 GError **error);
173GLIB_AVAILABLE_IN_ALL
174gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
175 const gchar *uri,
176 const gchar *name,
177 gchar **exec,
178 guint *count,
179 time_t *stamp,
180 GError **error);
181GLIB_AVAILABLE_IN_ALL
182void g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
183 const gchar *uri,
184 gboolean is_private);
185GLIB_AVAILABLE_IN_ALL
186gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark,
187 const gchar *uri,
188 GError **error);
189GLIB_AVAILABLE_IN_ALL
190void g_bookmark_file_set_icon (GBookmarkFile *bookmark,
191 const gchar *uri,
192 const gchar *href,
193 const gchar *mime_type);
194GLIB_AVAILABLE_IN_ALL
195gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark,
196 const gchar *uri,
197 gchar **href,
198 gchar **mime_type,
199 GError **error);
200GLIB_AVAILABLE_IN_ALL
201void g_bookmark_file_set_added (GBookmarkFile *bookmark,
202 const gchar *uri,
203 time_t added);
204GLIB_AVAILABLE_IN_ALL
205time_t g_bookmark_file_get_added (GBookmarkFile *bookmark,
206 const gchar *uri,
207 GError **error);
208GLIB_AVAILABLE_IN_ALL
209void g_bookmark_file_set_modified (GBookmarkFile *bookmark,
210 const gchar *uri,
211 time_t modified);
212GLIB_AVAILABLE_IN_ALL
213time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark,
214 const gchar *uri,
215 GError **error);
216GLIB_AVAILABLE_IN_ALL
217void g_bookmark_file_set_visited (GBookmarkFile *bookmark,
218 const gchar *uri,
219 time_t visited);
220GLIB_AVAILABLE_IN_ALL
221time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark,
222 const gchar *uri,
223 GError **error);
224GLIB_AVAILABLE_IN_ALL
225gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark,
226 const gchar *uri);
227GLIB_AVAILABLE_IN_ALL
228gint g_bookmark_file_get_size (GBookmarkFile *bookmark);
229GLIB_AVAILABLE_IN_ALL
230gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark,
231 gsize *length);
232GLIB_AVAILABLE_IN_ALL
233gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark,
234 const gchar *uri,
235 const gchar *group,
236 GError **error);
237GLIB_AVAILABLE_IN_ALL
238gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark,
239 const gchar *uri,
240 const gchar *name,
241 GError **error);
242GLIB_AVAILABLE_IN_ALL
243gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark,
244 const gchar *uri,
245 GError **error);
246GLIB_AVAILABLE_IN_ALL
247gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark,
248 const gchar *old_uri,
249 const gchar *new_uri,
250 GError **error);
251
252G_END_DECLS
253
254#endif /* __G_BOOKMARK_FILE_H__ */
255