Merge remote branch 'gvdb/master'
[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  * 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 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
21 #error "Only <glib.h> can be included directly."
22 #endif
23
24 #ifndef __G_BOOKMARK_FILE_H__
25 #define __G_BOOKMARK_FILE_H__
26
27 #include <glib/gerror.h>
28 #include <time.h>
29
30 G_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  */
57 typedef 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
69 GQuark g_bookmark_file_error_quark (void);
70
71 /**
72  * GBookmarkFile:
73  *
74  * The <structname>GBookmarkFile</structname> struct contains only
75  * private data and should not be directly accessed.
76  */
77 typedef struct _GBookmarkFile GBookmarkFile;
78
79 GBookmarkFile *g_bookmark_file_new                 (void);
80 void           g_bookmark_file_free                (GBookmarkFile  *bookmark);
81
82 gboolean       g_bookmark_file_load_from_file      (GBookmarkFile  *bookmark,
83                                                     const gchar    *filename,
84                                                     GError        **error);
85 gboolean       g_bookmark_file_load_from_data      (GBookmarkFile  *bookmark,
86                                                     const gchar    *data,
87                                                     gsize           length,
88                                                     GError        **error);
89 gboolean       g_bookmark_file_load_from_data_dirs (GBookmarkFile  *bookmark,
90                                                     const gchar    *file,
91                                                     gchar         **full_path,
92                                                     GError        **error);
93 gchar *        g_bookmark_file_to_data             (GBookmarkFile  *bookmark,
94                                                     gsize          *length,
95                                                     GError        **error) G_GNUC_MALLOC;
96 gboolean       g_bookmark_file_to_file             (GBookmarkFile  *bookmark,
97                                                     const gchar    *filename,
98                                                     GError        **error);
99
100 void           g_bookmark_file_set_title           (GBookmarkFile  *bookmark,
101                                                     const gchar    *uri,
102                                                     const gchar    *title);
103 gchar *        g_bookmark_file_get_title           (GBookmarkFile  *bookmark,
104                                                     const gchar    *uri,
105                                                     GError        **error) G_GNUC_MALLOC;
106 void           g_bookmark_file_set_description     (GBookmarkFile  *bookmark,
107                                                     const gchar    *uri,
108                                                     const gchar    *description);
109 gchar *        g_bookmark_file_get_description     (GBookmarkFile  *bookmark,
110                                                     const gchar    *uri,
111                                                     GError        **error) G_GNUC_MALLOC;
112 void           g_bookmark_file_set_mime_type       (GBookmarkFile  *bookmark,
113                                                     const gchar    *uri,
114                                                     const gchar    *mime_type);
115 gchar *        g_bookmark_file_get_mime_type       (GBookmarkFile  *bookmark,
116                                                     const gchar    *uri,
117                                                     GError        **error) G_GNUC_MALLOC;
118 void           g_bookmark_file_set_groups          (GBookmarkFile  *bookmark,
119                                                     const gchar    *uri,
120                                                     const gchar   **groups,
121                                                     gsize           length);
122 void           g_bookmark_file_add_group           (GBookmarkFile  *bookmark,
123                                                     const gchar    *uri,
124                                                     const gchar    *group);
125 gboolean       g_bookmark_file_has_group           (GBookmarkFile  *bookmark,
126                                                     const gchar    *uri,
127                                                     const gchar    *group,
128                                                     GError        **error);
129 gchar **       g_bookmark_file_get_groups          (GBookmarkFile  *bookmark,
130                                                     const gchar    *uri,
131                                                     gsize          *length,
132                                                     GError        **error) G_GNUC_MALLOC;
133 void           g_bookmark_file_add_application     (GBookmarkFile  *bookmark,
134                                                     const gchar    *uri,
135                                                     const gchar    *name,
136                                                     const gchar    *exec);
137 gboolean       g_bookmark_file_has_application     (GBookmarkFile  *bookmark,
138                                                     const gchar    *uri,
139                                                     const gchar    *name,
140                                                     GError        **error);
141 gchar **       g_bookmark_file_get_applications    (GBookmarkFile  *bookmark,
142                                                     const gchar    *uri,
143                                                     gsize          *length,
144                                                     GError        **error) G_GNUC_MALLOC;
145 gboolean       g_bookmark_file_set_app_info        (GBookmarkFile  *bookmark,
146                                                     const gchar    *uri,
147                                                     const gchar    *name,
148                                                     const gchar    *exec,
149                                                     gint            count,
150                                                     time_t          stamp,
151                                                     GError        **error);
152 gboolean       g_bookmark_file_get_app_info        (GBookmarkFile  *bookmark,
153                                                     const gchar    *uri,
154                                                     const gchar    *name,
155                                                     gchar         **exec,
156                                                     guint          *count,
157                                                     time_t         *stamp,
158                                                     GError        **error);
159 void           g_bookmark_file_set_is_private      (GBookmarkFile  *bookmark,
160                                                     const gchar    *uri,
161                                                     gboolean        is_private);
162 gboolean       g_bookmark_file_get_is_private      (GBookmarkFile  *bookmark,
163                                                     const gchar    *uri,
164                                                     GError        **error);
165 void           g_bookmark_file_set_icon            (GBookmarkFile  *bookmark,
166                                                     const gchar    *uri,
167                                                     const gchar    *href,
168                                                     const gchar    *mime_type);
169 gboolean       g_bookmark_file_get_icon            (GBookmarkFile  *bookmark,
170                                                     const gchar    *uri,
171                                                     gchar         **href,
172                                                     gchar         **mime_type,
173                                                     GError        **error);
174 void           g_bookmark_file_set_added           (GBookmarkFile  *bookmark,
175                                                     const gchar    *uri,
176                                                     time_t          added);
177 time_t         g_bookmark_file_get_added           (GBookmarkFile  *bookmark,
178                                                     const gchar    *uri,
179                                                     GError        **error);
180 void           g_bookmark_file_set_modified        (GBookmarkFile  *bookmark,
181                                                     const gchar    *uri,
182                                                     time_t          modified);
183 time_t         g_bookmark_file_get_modified        (GBookmarkFile  *bookmark,
184                                                     const gchar    *uri,
185                                                     GError        **error);
186 void           g_bookmark_file_set_visited         (GBookmarkFile  *bookmark,
187                                                     const gchar    *uri,
188                                                     time_t          visited);
189 time_t         g_bookmark_file_get_visited         (GBookmarkFile  *bookmark,
190                                                     const gchar    *uri, 
191                                                     GError        **error);
192 gboolean       g_bookmark_file_has_item            (GBookmarkFile  *bookmark,
193                                                     const gchar    *uri);
194 gint           g_bookmark_file_get_size            (GBookmarkFile  *bookmark);
195 gchar **       g_bookmark_file_get_uris            (GBookmarkFile  *bookmark,
196                                                     gsize          *length) G_GNUC_MALLOC;
197 gboolean       g_bookmark_file_remove_group        (GBookmarkFile  *bookmark,
198                                                     const gchar    *uri,
199                                                     const gchar    *group,
200                                                     GError        **error);
201 gboolean       g_bookmark_file_remove_application  (GBookmarkFile  *bookmark,
202                                                     const gchar    *uri,
203                                                     const gchar    *name,
204                                                     GError        **error);
205 gboolean       g_bookmark_file_remove_item         (GBookmarkFile  *bookmark,
206                                                     const gchar    *uri,
207                                                     GError        **error);
208 gboolean       g_bookmark_file_move_item           (GBookmarkFile  *bookmark,
209                                                     const gchar    *old_uri,
210                                                     const gchar    *new_uri,
211                                                     GError        **error);
212
213 G_END_DECLS
214
215 #endif /* __G_BOOKMARK_FILE_H__ */