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