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 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 GLIB_AVAILABLE_IN_ALL 70 GQuark 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 */ 78 typedef struct _GBookmarkFile GBookmarkFile; 79 80 GLIB_AVAILABLE_IN_ALL 81 GBookmarkFile *g_bookmark_file_new (void); 82 GLIB_AVAILABLE_IN_ALL 83 void g_bookmark_file_free (GBookmarkFile *bookmark); 84 85 GLIB_AVAILABLE_IN_ALL 86 gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark, 87 const gchar *filename, 88 GError **error); 89 GLIB_AVAILABLE_IN_ALL 90 gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark, 91 const gchar *data, 92 gsize length, 93 GError **error); 94 GLIB_AVAILABLE_IN_ALL 95 gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark, 96 const gchar *file, 97 gchar **full_path, 98 GError **error); 99 GLIB_AVAILABLE_IN_ALL 100 gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark, 101 gsize *length, 102 GError **error) G_GNUC_MALLOC; 103 GLIB_AVAILABLE_IN_ALL 104 gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark, 105 const gchar *filename, 106 GError **error); 107 108 GLIB_AVAILABLE_IN_ALL 109 void g_bookmark_file_set_title (GBookmarkFile *bookmark, 110 const gchar *uri, 111 const gchar *title); 112 GLIB_AVAILABLE_IN_ALL 113 gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark, 114 const gchar *uri, 115 GError **error) G_GNUC_MALLOC; 116 GLIB_AVAILABLE_IN_ALL 117 void g_bookmark_file_set_description (GBookmarkFile *bookmark, 118 const gchar *uri, 119 const gchar *description); 120 GLIB_AVAILABLE_IN_ALL 121 gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark, 122 const gchar *uri, 123 GError **error) G_GNUC_MALLOC; 124 GLIB_AVAILABLE_IN_ALL 125 void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark, 126 const gchar *uri, 127 const gchar *mime_type); 128 GLIB_AVAILABLE_IN_ALL 129 gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark, 130 const gchar *uri, 131 GError **error) G_GNUC_MALLOC; 132 GLIB_AVAILABLE_IN_ALL 133 void g_bookmark_file_set_groups (GBookmarkFile *bookmark, 134 const gchar *uri, 135 const gchar **groups, 136 gsize length); 137 GLIB_AVAILABLE_IN_ALL 138 void g_bookmark_file_add_group (GBookmarkFile *bookmark, 139 const gchar *uri, 140 const gchar *group); 141 GLIB_AVAILABLE_IN_ALL 142 gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark, 143 const gchar *uri, 144 const gchar *group, 145 GError **error); 146 GLIB_AVAILABLE_IN_ALL 147 gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark, 148 const gchar *uri, 149 gsize *length, 150 GError **error); 151 GLIB_AVAILABLE_IN_ALL 152 void g_bookmark_file_add_application (GBookmarkFile *bookmark, 153 const gchar *uri, 154 const gchar *name, 155 const gchar *exec); 156 GLIB_AVAILABLE_IN_ALL 157 gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark, 158 const gchar *uri, 159 const gchar *name, 160 GError **error); 161 GLIB_AVAILABLE_IN_ALL 162 gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark, 163 const gchar *uri, 164 gsize *length, 165 GError **error); 166 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info) 167 gboolean 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); 174 GLIB_AVAILABLE_IN_2_66 175 gboolean 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); 182 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info) 183 gboolean 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); 190 GLIB_AVAILABLE_IN_2_66 191 gboolean 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); 198 GLIB_AVAILABLE_IN_ALL 199 void g_bookmark_file_set_is_private (GBookmarkFile *bookmark, 200 const gchar *uri, 201 gboolean is_private); 202 GLIB_AVAILABLE_IN_ALL 203 gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark, 204 const gchar *uri, 205 GError **error); 206 GLIB_AVAILABLE_IN_ALL 207 void g_bookmark_file_set_icon (GBookmarkFile *bookmark, 208 const gchar *uri, 209 const gchar *href, 210 const gchar *mime_type); 211 GLIB_AVAILABLE_IN_ALL 212 gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark, 213 const gchar *uri, 214 gchar **href, 215 gchar **mime_type, 216 GError **error); 217 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time) 218 void g_bookmark_file_set_added (GBookmarkFile *bookmark, 219 const gchar *uri, 220 time_t added); 221 GLIB_AVAILABLE_IN_2_66 222 void g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark, 223 const char *uri, 224 GDateTime *added); 225 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time) 226 time_t g_bookmark_file_get_added (GBookmarkFile *bookmark, 227 const gchar *uri, 228 GError **error); 229 GLIB_AVAILABLE_IN_2_66 230 GDateTime *g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark, 231 const char *uri, 232 GError **error); 233 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time) 234 void g_bookmark_file_set_modified (GBookmarkFile *bookmark, 235 const gchar *uri, 236 time_t modified); 237 GLIB_AVAILABLE_IN_2_66 238 void g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark, 239 const char *uri, 240 GDateTime *modified); 241 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time) 242 time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark, 243 const gchar *uri, 244 GError **error); 245 GLIB_AVAILABLE_IN_2_66 246 GDateTime *g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark, 247 const char *uri, 248 GError **error); 249 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time) 250 void g_bookmark_file_set_visited (GBookmarkFile *bookmark, 251 const gchar *uri, 252 time_t visited); 253 GLIB_AVAILABLE_IN_2_66 254 void g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark, 255 const char *uri, 256 GDateTime *visited); 257 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time) 258 time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark, 259 const gchar *uri, 260 GError **error); 261 GLIB_AVAILABLE_IN_2_66 262 GDateTime *g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark, 263 const char *uri, 264 GError **error); 265 GLIB_AVAILABLE_IN_ALL 266 gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark, 267 const gchar *uri); 268 GLIB_AVAILABLE_IN_ALL 269 gint g_bookmark_file_get_size (GBookmarkFile *bookmark); 270 GLIB_AVAILABLE_IN_ALL 271 gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark, 272 gsize *length); 273 GLIB_AVAILABLE_IN_ALL 274 gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark, 275 const gchar *uri, 276 const gchar *group, 277 GError **error); 278 GLIB_AVAILABLE_IN_ALL 279 gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark, 280 const gchar *uri, 281 const gchar *name, 282 GError **error); 283 GLIB_AVAILABLE_IN_ALL 284 gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, 285 const gchar *uri, 286 GError **error); 287 GLIB_AVAILABLE_IN_ALL 288 gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark, 289 const gchar *old_uri, 290 const gchar *new_uri, 291 GError **error); 292 293 G_END_DECLS 294 295 #endif /* __G_BOOKMARK_FILE_H__ */ 296