| 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/gerror.h> |
| 27 | #include <time.h> |
| 28 | |
| 29 | G_BEGIN_DECLS |
| 30 | |
| 31 | /** |
| 32 | * G_BOOKMARK_FILE_ERROR: |
| 33 | * |
| 34 | * Error domain for bookmark file parsing. |
| 35 | * Errors in this domain will be from the #GBookmarkFileError |
| 36 | * enumeration. See #GError for information on error domains. |
| 37 | */ |
| 38 | #define G_BOOKMARK_FILE_ERROR (g_bookmark_file_error_quark ()) |
| 39 | |
| 40 | |
| 41 | /** |
| 42 | * GBookmarkFileError: |
| 43 | * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed |
| 44 | * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found |
| 45 | * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did |
| 46 | * not register a bookmark |
| 47 | * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found |
| 48 | * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed |
| 49 | * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was |
| 50 | * in an unknown encoding |
| 51 | * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing |
| 52 | * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found |
| 53 | * |
| 54 | * Error codes returned by bookmark file parsing. |
| 55 | */ |
| 56 | typedef enum |
| 57 | { |
| 58 | G_BOOKMARK_FILE_ERROR_INVALID_URI, |
| 59 | G_BOOKMARK_FILE_ERROR_INVALID_VALUE, |
| 60 | G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED, |
| 61 | G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND, |
| 62 | G_BOOKMARK_FILE_ERROR_READ, |
| 63 | G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING, |
| 64 | G_BOOKMARK_FILE_ERROR_WRITE, |
| 65 | G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND |
| 66 | } GBookmarkFileError; |
| 67 | |
| 68 | GLIB_AVAILABLE_IN_ALL |
| 69 | GQuark g_bookmark_file_error_quark (void); |
| 70 | |
| 71 | /** |
| 72 | * GBookmarkFile: |
| 73 | * |
| 74 | * The `GBookmarkFile` structure contains only |
| 75 | * private data and should not be directly accessed. |
| 76 | */ |
| 77 | typedef struct _GBookmarkFile GBookmarkFile; |
| 78 | |
| 79 | GLIB_AVAILABLE_IN_ALL |
| 80 | GBookmarkFile *g_bookmark_file_new (void); |
| 81 | GLIB_AVAILABLE_IN_ALL |
| 82 | void g_bookmark_file_free (GBookmarkFile *bookmark); |
| 83 | |
| 84 | GLIB_AVAILABLE_IN_ALL |
| 85 | gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark, |
| 86 | const gchar *filename, |
| 87 | GError **error); |
| 88 | GLIB_AVAILABLE_IN_ALL |
| 89 | gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark, |
| 90 | const gchar *data, |
| 91 | gsize length, |
| 92 | GError **error); |
| 93 | GLIB_AVAILABLE_IN_ALL |
| 94 | gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark, |
| 95 | const gchar *file, |
| 96 | gchar **full_path, |
| 97 | GError **error); |
| 98 | GLIB_AVAILABLE_IN_ALL |
| 99 | gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark, |
| 100 | gsize *length, |
| 101 | GError **error) G_GNUC_MALLOC; |
| 102 | GLIB_AVAILABLE_IN_ALL |
| 103 | gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark, |
| 104 | const gchar *filename, |
| 105 | GError **error); |
| 106 | |
| 107 | GLIB_AVAILABLE_IN_ALL |
| 108 | void g_bookmark_file_set_title (GBookmarkFile *bookmark, |
| 109 | const gchar *uri, |
| 110 | const gchar *title); |
| 111 | GLIB_AVAILABLE_IN_ALL |
| 112 | gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark, |
| 113 | const gchar *uri, |
| 114 | GError **error) G_GNUC_MALLOC; |
| 115 | GLIB_AVAILABLE_IN_ALL |
| 116 | void g_bookmark_file_set_description (GBookmarkFile *bookmark, |
| 117 | const gchar *uri, |
| 118 | const gchar *description); |
| 119 | GLIB_AVAILABLE_IN_ALL |
| 120 | gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark, |
| 121 | const gchar *uri, |
| 122 | GError **error) G_GNUC_MALLOC; |
| 123 | GLIB_AVAILABLE_IN_ALL |
| 124 | void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark, |
| 125 | const gchar *uri, |
| 126 | const gchar *mime_type); |
| 127 | GLIB_AVAILABLE_IN_ALL |
| 128 | gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark, |
| 129 | const gchar *uri, |
| 130 | GError **error) G_GNUC_MALLOC; |
| 131 | GLIB_AVAILABLE_IN_ALL |
| 132 | void g_bookmark_file_set_groups (GBookmarkFile *bookmark, |
| 133 | const gchar *uri, |
| 134 | const gchar **groups, |
| 135 | gsize length); |
| 136 | GLIB_AVAILABLE_IN_ALL |
| 137 | void g_bookmark_file_add_group (GBookmarkFile *bookmark, |
| 138 | const gchar *uri, |
| 139 | const gchar *group); |
| 140 | GLIB_AVAILABLE_IN_ALL |
| 141 | gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark, |
| 142 | const gchar *uri, |
| 143 | const gchar *group, |
| 144 | GError **error); |
| 145 | GLIB_AVAILABLE_IN_ALL |
| 146 | gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark, |
| 147 | const gchar *uri, |
| 148 | gsize *length, |
| 149 | GError **error); |
| 150 | GLIB_AVAILABLE_IN_ALL |
| 151 | void g_bookmark_file_add_application (GBookmarkFile *bookmark, |
| 152 | const gchar *uri, |
| 153 | const gchar *name, |
| 154 | const gchar *exec); |
| 155 | GLIB_AVAILABLE_IN_ALL |
| 156 | gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark, |
| 157 | const gchar *uri, |
| 158 | const gchar *name, |
| 159 | GError **error); |
| 160 | GLIB_AVAILABLE_IN_ALL |
| 161 | gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark, |
| 162 | const gchar *uri, |
| 163 | gsize *length, |
| 164 | GError **error); |
| 165 | GLIB_AVAILABLE_IN_ALL |
| 166 | gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark, |
| 167 | const gchar *uri, |
| 168 | const gchar *name, |
| 169 | const gchar *exec, |
| 170 | gint count, |
| 171 | time_t stamp, |
| 172 | GError **error); |
| 173 | GLIB_AVAILABLE_IN_ALL |
| 174 | gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark, |
| 175 | const gchar *uri, |
| 176 | const gchar *name, |
| 177 | gchar **exec, |
| 178 | guint *count, |
| 179 | time_t *stamp, |
| 180 | GError **error); |
| 181 | GLIB_AVAILABLE_IN_ALL |
| 182 | void g_bookmark_file_set_is_private (GBookmarkFile *bookmark, |
| 183 | const gchar *uri, |
| 184 | gboolean is_private); |
| 185 | GLIB_AVAILABLE_IN_ALL |
| 186 | gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark, |
| 187 | const gchar *uri, |
| 188 | GError **error); |
| 189 | GLIB_AVAILABLE_IN_ALL |
| 190 | void g_bookmark_file_set_icon (GBookmarkFile *bookmark, |
| 191 | const gchar *uri, |
| 192 | const gchar *href, |
| 193 | const gchar *mime_type); |
| 194 | GLIB_AVAILABLE_IN_ALL |
| 195 | gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark, |
| 196 | const gchar *uri, |
| 197 | gchar **href, |
| 198 | gchar **mime_type, |
| 199 | GError **error); |
| 200 | GLIB_AVAILABLE_IN_ALL |
| 201 | void g_bookmark_file_set_added (GBookmarkFile *bookmark, |
| 202 | const gchar *uri, |
| 203 | time_t added); |
| 204 | GLIB_AVAILABLE_IN_ALL |
| 205 | time_t g_bookmark_file_get_added (GBookmarkFile *bookmark, |
| 206 | const gchar *uri, |
| 207 | GError **error); |
| 208 | GLIB_AVAILABLE_IN_ALL |
| 209 | void g_bookmark_file_set_modified (GBookmarkFile *bookmark, |
| 210 | const gchar *uri, |
| 211 | time_t modified); |
| 212 | GLIB_AVAILABLE_IN_ALL |
| 213 | time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark, |
| 214 | const gchar *uri, |
| 215 | GError **error); |
| 216 | GLIB_AVAILABLE_IN_ALL |
| 217 | void g_bookmark_file_set_visited (GBookmarkFile *bookmark, |
| 218 | const gchar *uri, |
| 219 | time_t visited); |
| 220 | GLIB_AVAILABLE_IN_ALL |
| 221 | time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark, |
| 222 | const gchar *uri, |
| 223 | GError **error); |
| 224 | GLIB_AVAILABLE_IN_ALL |
| 225 | gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark, |
| 226 | const gchar *uri); |
| 227 | GLIB_AVAILABLE_IN_ALL |
| 228 | gint g_bookmark_file_get_size (GBookmarkFile *bookmark); |
| 229 | GLIB_AVAILABLE_IN_ALL |
| 230 | gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark, |
| 231 | gsize *length); |
| 232 | GLIB_AVAILABLE_IN_ALL |
| 233 | gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark, |
| 234 | const gchar *uri, |
| 235 | const gchar *group, |
| 236 | GError **error); |
| 237 | GLIB_AVAILABLE_IN_ALL |
| 238 | gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark, |
| 239 | const gchar *uri, |
| 240 | const gchar *name, |
| 241 | GError **error); |
| 242 | GLIB_AVAILABLE_IN_ALL |
| 243 | gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark, |
| 244 | const gchar *uri, |
| 245 | GError **error); |
| 246 | GLIB_AVAILABLE_IN_ALL |
| 247 | gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark, |
| 248 | const gchar *old_uri, |
| 249 | const gchar *new_uri, |
| 250 | GError **error); |
| 251 | |
| 252 | G_END_DECLS |
| 253 | |
| 254 | #endif /* __G_BOOKMARK_FILE_H__ */ |
| 255 | |