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 Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 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 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 */
19
20#ifndef __G_BOOKMARK_FILE_H__
21#define __G_BOOKMARK_FILE_H__
22
23#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
24#error "Only <glib.h> can be included directly."
25#endif
26
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 * Errors in this domain will be from the #GBookmarkFileError
37 * enumeration. See #GError for information on error domains.
38 */
39#define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ())
40
41
42/**
43 * GBookmarkFileError:
44 * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed
45 * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found
46 * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did
47 * not register a bookmark
48 * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found
49 * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed
50 * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was
51 * in an unknown encoding
52 * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing
53 * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found
54 *
55 * Error codes returned by bookmark file parsing.
56 */
57typedef enum
58{
59 G_BOOKMARK_FILE_ERROR_INVALID_URI,
60 G_BOOKMARK_FILE_ERROR_INVALID_VALUE,
61 G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
62 G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
63 G_BOOKMARK_FILE_ERROR_READ,
64 G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
65 G_BOOKMARK_FILE_ERROR_WRITE,
66 G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
67} GBookmarkFileError;
68
69GLIB_AVAILABLE_IN_ALL
70GQuark g_bookmark_file_error_quark (void);
71
72/**
73 * GBookmarkFile:
74 *
75 * The `GBookmarkFile` structure contains only
76 * private data and should not be directly accessed.
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) G_GNUC_MALLOC;
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) G_GNUC_MALLOC;
166GLIB_AVAILABLE_IN_ALL
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_ALL
175gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
176 const gchar *uri,
177 const gchar *name,
178 gchar **exec,
179 guint *count,
180 time_t *stamp,
181 GError **error);
182GLIB_AVAILABLE_IN_ALL
183void g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
184 const gchar *uri,
185 gboolean is_private);
186GLIB_AVAILABLE_IN_ALL
187gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark,
188 const gchar *uri,
189 GError **error);
190GLIB_AVAILABLE_IN_ALL
191void g_bookmark_file_set_icon (GBookmarkFile *bookmark,
192 const gchar *uri,
193 const gchar *href,
194 const gchar *mime_type);
195GLIB_AVAILABLE_IN_ALL
196gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark,
197 const gchar *uri,
198 gchar **href,
199 gchar **mime_type,
200 GError **error);
201GLIB_AVAILABLE_IN_ALL
202void g_bookmark_file_set_added (GBookmarkFile *bookmark,
203 const gchar *uri,
204 time_t added);
205GLIB_AVAILABLE_IN_ALL
206time_t g_bookmark_file_get_added (GBookmarkFile *bookmark,
207 const gchar *uri,
208 GError **error);
209GLIB_AVAILABLE_IN_ALL
210void g_bookmark_file_set_modified (GBookmarkFile *bookmark,
211 const gchar *uri,
212 time_t modified);
213GLIB_AVAILABLE_IN_ALL
214time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark,
215 const gchar *uri,
216 GError **error);
217GLIB_AVAILABLE_IN_ALL
218void g_bookmark_file_set_visited (GBookmarkFile *bookmark,
219 const gchar *uri,
220 time_t visited);
221GLIB_AVAILABLE_IN_ALL
222time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark,
223 const gchar *uri,
224 GError **error);
225GLIB_AVAILABLE_IN_ALL
226gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark,
227 const gchar *uri);
228GLIB_AVAILABLE_IN_ALL
229gint g_bookmark_file_get_size (GBookmarkFile *bookmark);
230GLIB_AVAILABLE_IN_ALL
231gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark,
232 gsize *length) G_GNUC_MALLOC;
233GLIB_AVAILABLE_IN_ALL
234gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark,
235 const gchar *uri,
236 const gchar *group,
237 GError **error);
238GLIB_AVAILABLE_IN_ALL
239gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark,
240 const gchar *uri,
241 const gchar *name,
242 GError **error);
243GLIB_AVAILABLE_IN_ALL
244gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark,
245 const gchar *uri,
246 GError **error);
247GLIB_AVAILABLE_IN_ALL
248gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark,
249 const gchar *old_uri,
250 const gchar *new_uri,
251 GError **error);
252
253G_END_DECLS
254
255#endif /* __G_BOOKMARK_FILE_H__ */
256