2448e4a3611da49a649e8305f880d78582e77e8b
[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 #ifndef __G_BOOKMARK_FILE_H__
21 #define __G_BOOKMARK_FILE_H__
22
23 #include <glib/gerror.h>
24 #include <time.h>
25
26 G_BEGIN_DECLS
27
28 /* GError enumeration
29  */
30 #define G_BOOKMARK_FILE_ERROR   (g_bookmark_file_error_quark ())
31
32 typedef enum
33 {
34   G_BOOKMARK_FILE_ERROR_INVALID_URI,
35   G_BOOKMARK_FILE_ERROR_INVALID_VALUE,
36   G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
37   G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
38   G_BOOKMARK_FILE_ERROR_READ,
39   G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
40   G_BOOKMARK_FILE_ERROR_WRITE,
41   G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
42 } GBookmarkFileError;
43
44 GQuark g_bookmark_file_error_quark (void);
45
46 /*
47  * GBookmarkFile
48  */
49 typedef struct _GBookmarkFile GBookmarkFile;
50
51 GBookmarkFile *g_bookmark_file_new                 (void);
52 void           g_bookmark_file_free                (GBookmarkFile  *bookmark);
53
54 gboolean       g_bookmark_file_load_from_file      (GBookmarkFile  *bookmark,
55                                                     const gchar    *filename,
56                                                     GError        **error);
57 gboolean       g_bookmark_file_load_from_data      (GBookmarkFile  *bookmark,
58                                                     const gchar    *data,
59                                                     gsize           length,
60                                                     GError        **error);
61 gboolean       g_bookmark_file_load_from_data_dirs (GBookmarkFile  *bookmark,
62                                                     const gchar    *file,
63                                                     gchar         **full_path,
64                                                     GError        **error);
65 gchar *        g_bookmark_file_to_data             (GBookmarkFile  *bookmark,
66                                                     gsize          *length,
67                                                     GError        **error) G_GNUC_MALLOC;
68 gboolean       g_bookmark_file_to_file             (GBookmarkFile  *bookmark,
69                                                     const gchar    *filename,
70                                                     GError        **error);
71
72 void           g_bookmark_file_set_title           (GBookmarkFile  *bookmark,
73                                                     const gchar    *uri,
74                                                     const gchar    *title);
75 gchar *        g_bookmark_file_get_title           (GBookmarkFile  *bookmark,
76                                                     const gchar    *uri,
77                                                     GError        **error) G_GNUC_MALLOC;
78 void           g_bookmark_file_set_description     (GBookmarkFile  *bookmark,
79                                                     const gchar    *uri,
80                                                     const gchar    *description);
81 gchar *        g_bookmark_file_get_description     (GBookmarkFile  *bookmark,
82                                                     const gchar    *uri,
83                                                     GError        **error) G_GNUC_MALLOC;
84 void           g_bookmark_file_set_mime_type       (GBookmarkFile  *bookmark,
85                                                     const gchar    *uri,
86                                                     const gchar    *mime_type);
87 gchar *        g_bookmark_file_get_mime_type       (GBookmarkFile  *bookmark,
88                                                     const gchar    *uri,
89                                                     GError        **error) G_GNUC_MALLOC;
90 void           g_bookmark_file_set_groups          (GBookmarkFile  *bookmark,
91                                                     const gchar    *uri,
92                                                     const gchar   **groups,
93                                                     gsize           length);
94 void           g_bookmark_file_add_group           (GBookmarkFile  *bookmark,
95                                                     const gchar    *uri,
96                                                     const gchar    *group);
97 gboolean       g_bookmark_file_has_group           (GBookmarkFile  *bookmark,
98                                                     const gchar    *uri,
99                                                     const gchar    *group,
100                                                     GError        **error);
101 gchar **       g_bookmark_file_get_groups          (GBookmarkFile  *bookmark,
102                                                     const gchar    *uri,
103                                                     gsize          *length,
104                                                     GError        **error) G_GNUC_MALLOC;
105 void           g_bookmark_file_add_application     (GBookmarkFile  *bookmark,
106                                                     const gchar    *uri,
107                                                     const gchar    *name,
108                                                     const gchar    *exec);
109 gboolean       g_bookmark_file_has_application     (GBookmarkFile  *bookmark,
110                                                     const gchar    *uri,
111                                                     const gchar    *name,
112                                                     GError        **error);
113 gchar **       g_bookmark_file_get_applications    (GBookmarkFile  *bookmark,
114                                                     const gchar    *uri,
115                                                     gsize          *length,
116                                                     GError        **error) G_GNUC_MALLOC;
117 gboolean       g_bookmark_file_set_app_info        (GBookmarkFile  *bookmark,
118                                                     const gchar    *uri,
119                                                     const gchar    *name,
120                                                     const gchar    *exec,
121                                                     gint            count,
122                                                     time_t          stamp,
123                                                     GError        **error);
124 gboolean       g_bookmark_file_get_app_info        (GBookmarkFile  *bookmark,
125                                                     const gchar    *uri,
126                                                     const gchar    *name,
127                                                     gchar         **exec,
128                                                     guint          *count,
129                                                     time_t         *stamp,
130                                                     GError        **error);
131 void           g_bookmark_file_set_is_private      (GBookmarkFile  *bookmark,
132                                                     const gchar    *uri,
133                                                     gboolean        is_private);
134 gboolean       g_bookmark_file_get_is_private      (GBookmarkFile  *bookmark,
135                                                     const gchar    *uri,
136                                                     GError        **error);
137 void           g_bookmark_file_set_icon            (GBookmarkFile  *bookmark,
138                                                     const gchar    *uri,
139                                                     const gchar    *href,
140                                                     const gchar    *mime_type);
141 gboolean       g_bookmark_file_get_icon            (GBookmarkFile  *bookmark,
142                                                     const gchar    *uri,
143                                                     gchar         **href,
144                                                     gchar         **mime_type,
145                                                     GError        **error);
146 void           g_bookmark_file_set_added           (GBookmarkFile  *bookmark,
147                                                     const gchar    *uri,
148                                                     time_t          added);
149 time_t         g_bookmark_file_get_added           (GBookmarkFile  *bookmark,
150                                                     const gchar    *uri,
151                                                     GError        **error);
152 void           g_bookmark_file_set_modified        (GBookmarkFile  *bookmark,
153                                                     const gchar    *uri,
154                                                     time_t          modified);
155 time_t         g_bookmark_file_get_modified        (GBookmarkFile  *bookmark,
156                                                     const gchar    *uri,
157                                                     GError        **error);
158 void           g_bookmark_file_set_visited         (GBookmarkFile  *bookmark,
159                                                     const gchar    *uri,
160                                                     time_t          visited);
161 time_t         g_bookmark_file_get_visited         (GBookmarkFile  *bookmark,
162                                                     const gchar    *uri, 
163                                                     GError        **error);
164 gboolean       g_bookmark_file_has_item            (GBookmarkFile  *bookmark,
165                                                     const gchar    *uri);
166 gint           g_bookmark_file_get_size            (GBookmarkFile  *bookmark);
167 gchar **       g_bookmark_file_get_uris            (GBookmarkFile  *bookmark,
168                                                     gsize          *length) G_GNUC_MALLOC;
169 gboolean       g_bookmark_file_remove_group        (GBookmarkFile  *bookmark,
170                                                     const gchar    *uri,
171                                                     const gchar    *group,
172                                                     GError        **error);
173 gboolean       g_bookmark_file_remove_application  (GBookmarkFile  *bookmark,
174                                                     const gchar    *uri,
175                                                     const gchar    *name,
176                                                     GError        **error);
177 gboolean       g_bookmark_file_remove_item         (GBookmarkFile  *bookmark,
178                                                     const gchar    *uri,
179                                                     GError        **error);
180 gboolean       g_bookmark_file_move_item           (GBookmarkFile  *bookmark,
181                                                     const gchar    *old_uri,
182                                                     const gchar    *new_uri,
183                                                     GError        **error);
184
185 G_END_DECLS
186
187 #endif /* __G_BOOKMARK_FILE_H__ */