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/gdatetime.h>
27#include <glib/gerror.h>
28#include <time.h>
29
30G_BEGIN_DECLS
31
32/**
33 * G_BOOKMARK_FILE_ERROR:
34 *
35 * Error domain for bookmark file parsing.
36 *
37 * Errors in this domain will be from the #GBookmarkFileError
38 * enumeration. See #GError for information on error domains.
39 */
40#define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ())
41
42
43/**
44 * GBookmarkFileError:
45 * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed
46 * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found
47 * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did
48 * not register a bookmark
49 * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found
50 * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed
51 * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was
52 * in an unknown encoding
53 * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing
54 * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found
55 *
56 * Error codes returned by bookmark file parsing.
57 */
58typedef enum
59{
60 G_BOOKMARK_FILE_ERROR_INVALID_URI,
61 G_BOOKMARK_FILE_ERROR_INVALID_VALUE,
62 G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
63 G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
64 G_BOOKMARK_FILE_ERROR_READ,
65 G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
66 G_BOOKMARK_FILE_ERROR_WRITE,
67 G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
68} GBookmarkFileError;
69
70GLIB_AVAILABLE_IN_ALL
71GQuark g_bookmark_file_error_quark (void);
72
73/**
74 * GBookmarkFile:
75 *
76 * An opaque data structure representing a set of bookmarks.
77 */
78typedef struct _GBookmarkFile GBookmarkFile;
79
80GLIB_AVAILABLE_IN_ALL
81GBookmarkFile *g_bookmark_file_new (void);
82GLIB_AVAILABLE_IN_ALL
83void g_bookmark_file_free (GBookmarkFile *bookmark);
84
85GLIB_AVAILABLE_IN_ALL
86gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark,
87 const gchar *filename,
88 GError **error);
89GLIB_AVAILABLE_IN_ALL
90gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark,
91 const gchar *data,
92 gsize length,
93 GError **error);
94GLIB_AVAILABLE_IN_ALL
95gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark,
96 const gchar *file,
97 gchar **full_path,
98 GError **error);
99GLIB_AVAILABLE_IN_ALL
100gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark,
101 gsize *length,
102 GError **error) G_GNUC_MALLOC;
103GLIB_AVAILABLE_IN_ALL
104gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark,
105 const gchar *filename,
106 GError **error);
107
108GLIB_AVAILABLE_IN_ALL
109void g_bookmark_file_set_title (GBookmarkFile *bookmark,
110 const gchar *uri,
111 const gchar *title);
112GLIB_AVAILABLE_IN_ALL
113gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark,
114 const gchar *uri,
115 GError **error) G_GNUC_MALLOC;
116GLIB_AVAILABLE_IN_ALL
117void g_bookmark_file_set_description (GBookmarkFile *bookmark,
118 const gchar *uri,
119 const gchar *description);
120GLIB_AVAILABLE_IN_ALL
121gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark,
122 const gchar *uri,
123 GError **error) G_GNUC_MALLOC;
124GLIB_AVAILABLE_IN_ALL
125void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark,
126 const gchar *uri,
127 const gchar *mime_type);
128GLIB_AVAILABLE_IN_ALL
129gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark,
130 const gchar *uri,
131 GError **error) G_GNUC_MALLOC;
132GLIB_AVAILABLE_IN_ALL
133void g_bookmark_file_set_groups (GBookmarkFile *bookmark,
134 const gchar *uri,
135 const gchar **groups,
136 gsize length);
137GLIB_AVAILABLE_IN_ALL
138void g_bookmark_file_add_group (GBookmarkFile *bookmark,
139 const gchar *uri,
140 const gchar *group);
141GLIB_AVAILABLE_IN_ALL
142gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark,
143 const gchar *uri,
144 const gchar *group,
145 GError **error);
146GLIB_AVAILABLE_IN_ALL
147gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark,
148 const gchar *uri,
149 gsize *length,
150 GError **error);
151GLIB_AVAILABLE_IN_ALL
152void g_bookmark_file_add_application (GBookmarkFile *bookmark,
153 const gchar *uri,
154 const gchar *name,
155 const gchar *exec);
156GLIB_AVAILABLE_IN_ALL
157gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark,
158 const gchar *uri,
159 const gchar *name,
160 GError **error);
161GLIB_AVAILABLE_IN_ALL
162gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark,
163 const gchar *uri,
164 gsize *length,
165 GError **error);
166GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info)
167gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
168 const gchar *uri,
169 const gchar *name,
170 const gchar *exec,
171 gint count,
172 time_t stamp,
173 GError **error);
174GLIB_AVAILABLE_IN_2_66
175gboolean g_bookmark_file_set_application_info (GBookmarkFile *bookmark,
176 const char *uri,
177 const char *name,
178 const char *exec,
179 int count,
180 GDateTime *stamp,
181 GError **error);
182GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info)
183gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
184 const gchar *uri,
185 const gchar *name,
186 gchar **exec,
187 guint *count,
188 time_t *stamp,
189 GError **error);
190GLIB_AVAILABLE_IN_2_66
191gboolean g_bookmark_file_get_application_info (GBookmarkFile *bookmark,
192 const char *uri,
193 const char *name,
194 char **exec,
195 unsigned int *count,
196 GDateTime **stamp,
197 GError **error);
198GLIB_AVAILABLE_IN_ALL
199void g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
200 const gchar *uri,
201 gboolean is_private);
202GLIB_AVAILABLE_IN_ALL
203gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark,
204 const gchar *uri,
205 GError **error);
206GLIB_AVAILABLE_IN_ALL
207void g_bookmark_file_set_icon (GBookmarkFile *bookmark,
208 const gchar *uri,
209 const gchar *href,
210 const gchar *mime_type);
211GLIB_AVAILABLE_IN_ALL
212gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark,
213 const gchar *uri,
214 gchar **href,
215 gchar **mime_type,
216 GError **error);
217GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time)
218void g_bookmark_file_set_added (GBookmarkFile *bookmark,
219 const gchar *uri,
220 time_t added);
221GLIB_AVAILABLE_IN_2_66
222void g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark,
223 const char *uri,
224 GDateTime *added);
225GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time)
226time_t g_bookmark_file_get_added (GBookmarkFile *bookmark,
227 const gchar *uri,
228 GError **error);
229GLIB_AVAILABLE_IN_2_66
230GDateTime *g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark,
231 const char *uri,
232 GError **error);
233GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time)
234void g_bookmark_file_set_modified (GBookmarkFile *bookmark,
235 const gchar *uri,
236 time_t modified);
237GLIB_AVAILABLE_IN_2_66
238void g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark,
239 const char *uri,
240 GDateTime *modified);
241GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time)
242time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark,
243 const gchar *uri,
244 GError **error);
245GLIB_AVAILABLE_IN_2_66
246GDateTime *g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark,
247 const char *uri,
248 GError **error);
249GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time)
250void g_bookmark_file_set_visited (GBookmarkFile *bookmark,
251 const gchar *uri,
252 time_t visited);
253GLIB_AVAILABLE_IN_2_66
254void g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark,
255 const char *uri,
256 GDateTime *visited);
257GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time)
258time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark,
259 const gchar *uri,
260 GError **error);
261GLIB_AVAILABLE_IN_2_66
262GDateTime *g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark,
263 const char *uri,
264 GError **error);
265GLIB_AVAILABLE_IN_ALL
266gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark,
267 const gchar *uri);
268GLIB_AVAILABLE_IN_ALL
269gint g_bookmark_file_get_size (GBookmarkFile *bookmark);
270GLIB_AVAILABLE_IN_ALL
271gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark,
272 gsize *length);
273GLIB_AVAILABLE_IN_ALL
274gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark,
275 const gchar *uri,
276 const gchar *group,
277 GError **error);
278GLIB_AVAILABLE_IN_ALL
279gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark,
280 const gchar *uri,
281 const gchar *name,
282 GError **error);
283GLIB_AVAILABLE_IN_ALL
284gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark,
285 const gchar *uri,
286 GError **error);
287GLIB_AVAILABLE_IN_ALL
288gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark,
289 const gchar *old_uri,
290 const gchar *new_uri,
291 GError **error);
292
293G_END_DECLS
294
295#endif /* __G_BOOKMARK_FILE_H__ */
296

source code of include/glib-2.0/glib/gbookmarkfile.h