Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-02 08:36:59

0001 /* gbookmarkfile.h: parsing and building desktop bookmarks
0002  *
0003  * Copyright (C) 2005-2006 Emmanuele Bassi
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-or-later
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Lesser General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2.1 of the License, or (at your option) any later version.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Lesser General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Lesser General Public License
0018  * along with this library; if not, see <http://www.gnu.org/licenses/>.
0019  */
0020 
0021 #ifndef __G_BOOKMARK_FILE_H__
0022 #define __G_BOOKMARK_FILE_H__
0023 
0024 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
0025 #error "Only <glib.h> can be included directly."
0026 #endif
0027 
0028 #include <glib/gdatetime.h>
0029 #include <glib/gerror.h>
0030 #include <time.h>
0031 
0032 G_BEGIN_DECLS
0033 
0034 /**
0035  * G_BOOKMARK_FILE_ERROR:
0036  *
0037  * Error domain for bookmark file parsing.
0038  *
0039  * Errors in this domain will be from the #GBookmarkFileError
0040  * enumeration. See #GError for information on error domains.
0041  */
0042 #define G_BOOKMARK_FILE_ERROR   (g_bookmark_file_error_quark ())
0043 
0044 
0045 /**
0046  * GBookmarkFileError:
0047  * @G_BOOKMARK_FILE_ERROR_INVALID_URI: URI was ill-formed
0048  * @G_BOOKMARK_FILE_ERROR_INVALID_VALUE: a requested field was not found
0049  * @G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED: a requested application did
0050  *     not register a bookmark
0051  * @G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND: a requested URI was not found
0052  * @G_BOOKMARK_FILE_ERROR_READ: document was ill formed
0053  * @G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING: the text being parsed was
0054  *     in an unknown encoding
0055  * @G_BOOKMARK_FILE_ERROR_WRITE: an error occurred while writing
0056  * @G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND: requested file was not found
0057  *
0058  * Error codes returned by bookmark file parsing.
0059  */
0060 typedef enum
0061 {
0062   G_BOOKMARK_FILE_ERROR_INVALID_URI,
0063   G_BOOKMARK_FILE_ERROR_INVALID_VALUE,
0064   G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED,
0065   G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
0066   G_BOOKMARK_FILE_ERROR_READ,
0067   G_BOOKMARK_FILE_ERROR_UNKNOWN_ENCODING,
0068   G_BOOKMARK_FILE_ERROR_WRITE,
0069   G_BOOKMARK_FILE_ERROR_FILE_NOT_FOUND
0070 } GBookmarkFileError;
0071 
0072 GLIB_AVAILABLE_IN_ALL
0073 GQuark g_bookmark_file_error_quark (void);
0074 
0075 /**
0076  * GBookmarkFile:
0077  *
0078  * `GBookmarkFile` lets you parse, edit or create files containing bookmarks.
0079  *
0080  * Bookmarks refer to a URI, along with some meta-data about the resource
0081  * pointed by the URI like its MIME type, the application that is registering
0082  * the bookmark and the icon that should be used to represent the bookmark.
0083  * The data is stored using the
0084  * [Desktop Bookmark Specification](https://www.freedesktop.org/wiki/Specifications/desktop-bookmark-spec/).
0085  *
0086  * The syntax of the bookmark files is described in detail inside the
0087  * Desktop Bookmark Specification, here is a quick summary: bookmark
0088  * files use a sub-class of the XML Bookmark Exchange Language
0089  * specification, consisting of valid UTF-8 encoded XML, under the
0090  * `<xbel>` root element; each bookmark is stored inside a
0091  * `<bookmark>` element, using its URI: no relative paths can
0092  * be used inside a bookmark file. The bookmark may have a user defined
0093  * title and description, to be used instead of the URI. Under the
0094  * `<metadata>` element, with its owner attribute set to
0095  * `http://freedesktop.org`, is stored the meta-data about a resource
0096  * pointed by its URI. The meta-data consists of the resource's MIME
0097  * type; the applications that have registered a bookmark; the groups
0098  * to which a bookmark belongs to; a visibility flag, used to set the
0099  * bookmark as "private" to the applications and groups that has it
0100  * registered; the URI and MIME type of an icon, to be used when
0101  * displaying the bookmark inside a GUI.
0102  *
0103  * Here is an example of a bookmark file:
0104  * [bookmarks.xbel](https://gitlab.gnome.org/GNOME/glib/-/blob/HEAD/glib/tests/bookmarks.xbel)
0105  *
0106  * A bookmark file might contain more than one bookmark; each bookmark
0107  * is accessed through its URI.
0108  *
0109  * The important caveat of bookmark files is that when you add a new
0110  * bookmark you must also add the application that is registering it, using
0111  * [method@GLib.BookmarkFile.add_application] or [method@GLib.BookmarkFile.set_application_info].
0112  * If a bookmark has no applications then it won't be dumped when creating
0113  * the on disk representation, using [method@GLib.BookmarkFile.to_data] or
0114  * [method@GLib.BookmarkFile.to_file].
0115  *
0116  * Since: 2.12
0117  */
0118 typedef struct _GBookmarkFile GBookmarkFile;
0119 
0120 GLIB_AVAILABLE_IN_ALL
0121 GBookmarkFile *g_bookmark_file_new                 (void);
0122 GLIB_AVAILABLE_IN_ALL
0123 void           g_bookmark_file_free                (GBookmarkFile  *bookmark);
0124 
0125 GLIB_AVAILABLE_IN_2_76
0126 GBookmarkFile *g_bookmark_file_copy                (GBookmarkFile  *bookmark);
0127 
0128 GLIB_AVAILABLE_IN_ALL
0129 gboolean       g_bookmark_file_load_from_file      (GBookmarkFile  *bookmark,
0130                             const gchar    *filename,
0131                             GError        **error);
0132 GLIB_AVAILABLE_IN_ALL
0133 gboolean       g_bookmark_file_load_from_data      (GBookmarkFile  *bookmark,
0134                             const gchar    *data,
0135                             gsize           length,
0136                             GError        **error);
0137 GLIB_AVAILABLE_IN_ALL
0138 gboolean       g_bookmark_file_load_from_data_dirs (GBookmarkFile  *bookmark,
0139                             const gchar    *file,
0140                             gchar         **full_path,
0141                             GError        **error);
0142 GLIB_AVAILABLE_IN_ALL
0143 gchar *        g_bookmark_file_to_data             (GBookmarkFile  *bookmark,
0144                             gsize          *length,
0145                             GError        **error) G_GNUC_MALLOC;
0146 GLIB_AVAILABLE_IN_ALL
0147 gboolean       g_bookmark_file_to_file             (GBookmarkFile  *bookmark,
0148                             const gchar    *filename,
0149                             GError        **error);
0150 
0151 GLIB_AVAILABLE_IN_ALL
0152 void           g_bookmark_file_set_title           (GBookmarkFile  *bookmark,
0153                             const gchar    *uri,
0154                             const gchar    *title);
0155 GLIB_AVAILABLE_IN_ALL
0156 gchar *        g_bookmark_file_get_title           (GBookmarkFile  *bookmark,
0157                             const gchar    *uri,
0158                             GError        **error) G_GNUC_MALLOC;
0159 GLIB_AVAILABLE_IN_ALL
0160 void           g_bookmark_file_set_description     (GBookmarkFile  *bookmark,
0161                             const gchar    *uri,
0162                             const gchar    *description);
0163 GLIB_AVAILABLE_IN_ALL
0164 gchar *        g_bookmark_file_get_description     (GBookmarkFile  *bookmark,
0165                             const gchar    *uri,
0166                             GError        **error) G_GNUC_MALLOC;
0167 GLIB_AVAILABLE_IN_ALL
0168 void           g_bookmark_file_set_mime_type       (GBookmarkFile  *bookmark,
0169                             const gchar    *uri,
0170                             const gchar    *mime_type);
0171 GLIB_AVAILABLE_IN_ALL
0172 gchar *        g_bookmark_file_get_mime_type       (GBookmarkFile  *bookmark,
0173                             const gchar    *uri,
0174                             GError        **error) G_GNUC_MALLOC;
0175 GLIB_AVAILABLE_IN_ALL
0176 void           g_bookmark_file_set_groups          (GBookmarkFile  *bookmark,
0177                             const gchar    *uri,
0178                             const gchar   **groups,
0179                             gsize           length);
0180 GLIB_AVAILABLE_IN_ALL
0181 void           g_bookmark_file_add_group           (GBookmarkFile  *bookmark,
0182                             const gchar    *uri,
0183                             const gchar    *group);
0184 GLIB_AVAILABLE_IN_ALL
0185 gboolean       g_bookmark_file_has_group           (GBookmarkFile  *bookmark,
0186                             const gchar    *uri,
0187                             const gchar    *group,
0188                             GError        **error);
0189 GLIB_AVAILABLE_IN_ALL
0190 gchar **       g_bookmark_file_get_groups          (GBookmarkFile  *bookmark,
0191                             const gchar    *uri,
0192                             gsize          *length,
0193                             GError        **error);
0194 GLIB_AVAILABLE_IN_ALL
0195 void           g_bookmark_file_add_application     (GBookmarkFile  *bookmark,
0196                             const gchar    *uri,
0197                             const gchar    *name,
0198                             const gchar    *exec);
0199 GLIB_AVAILABLE_IN_ALL
0200 gboolean       g_bookmark_file_has_application     (GBookmarkFile  *bookmark,
0201                             const gchar    *uri,
0202                             const gchar    *name,
0203                             GError        **error);
0204 GLIB_AVAILABLE_IN_ALL
0205 gchar **       g_bookmark_file_get_applications    (GBookmarkFile  *bookmark,
0206                             const gchar    *uri,
0207                             gsize          *length,
0208                             GError        **error);
0209 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info)
0210 gboolean       g_bookmark_file_set_app_info        (GBookmarkFile  *bookmark,
0211                             const gchar    *uri,
0212                             const gchar    *name,
0213                             const gchar    *exec,
0214                             gint            count,
0215                             time_t          stamp,
0216                             GError        **error);
0217 GLIB_AVAILABLE_IN_2_66
0218 gboolean       g_bookmark_file_set_application_info (GBookmarkFile  *bookmark,
0219                                                      const char     *uri,
0220                                                      const char     *name,
0221                                                      const char     *exec,
0222                                                      int             count,
0223                                                      GDateTime      *stamp,
0224                                                      GError        **error);
0225 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info)
0226 gboolean       g_bookmark_file_get_app_info        (GBookmarkFile  *bookmark,
0227                             const gchar    *uri,
0228                             const gchar    *name,
0229                             gchar         **exec,
0230                             guint          *count,
0231                             time_t         *stamp,
0232                             GError        **error);
0233 GLIB_AVAILABLE_IN_2_66
0234 gboolean       g_bookmark_file_get_application_info (GBookmarkFile  *bookmark,
0235                                                      const char     *uri,
0236                                                      const char     *name,
0237                                                      char          **exec,
0238                                                      unsigned int   *count,
0239                                                      GDateTime     **stamp,
0240                                                      GError        **error);
0241 GLIB_AVAILABLE_IN_ALL
0242 void           g_bookmark_file_set_is_private      (GBookmarkFile  *bookmark,
0243                             const gchar    *uri,
0244                             gboolean        is_private);
0245 GLIB_AVAILABLE_IN_ALL
0246 gboolean       g_bookmark_file_get_is_private      (GBookmarkFile  *bookmark,
0247                             const gchar    *uri,
0248                             GError        **error);
0249 GLIB_AVAILABLE_IN_ALL
0250 void           g_bookmark_file_set_icon            (GBookmarkFile  *bookmark,
0251                             const gchar    *uri,
0252                             const gchar    *href,
0253                             const gchar    *mime_type);
0254 GLIB_AVAILABLE_IN_ALL
0255 gboolean       g_bookmark_file_get_icon            (GBookmarkFile  *bookmark,
0256                             const gchar    *uri,
0257                             gchar         **href,
0258                             gchar         **mime_type,
0259                             GError        **error);
0260 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time)
0261 void           g_bookmark_file_set_added           (GBookmarkFile  *bookmark,
0262                             const gchar    *uri,
0263                             time_t          added);
0264 GLIB_AVAILABLE_IN_2_66
0265 void           g_bookmark_file_set_added_date_time (GBookmarkFile  *bookmark,
0266                                                     const char     *uri,
0267                                                     GDateTime      *added);
0268 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time)
0269 time_t         g_bookmark_file_get_added           (GBookmarkFile  *bookmark,
0270                             const gchar    *uri,
0271                             GError        **error);
0272 GLIB_AVAILABLE_IN_2_66
0273 GDateTime     *g_bookmark_file_get_added_date_time (GBookmarkFile  *bookmark,
0274                                                     const char     *uri,
0275                                                     GError        **error);
0276 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time)
0277 void           g_bookmark_file_set_modified        (GBookmarkFile  *bookmark,
0278                             const gchar    *uri,
0279                             time_t          modified);
0280 GLIB_AVAILABLE_IN_2_66
0281 void           g_bookmark_file_set_modified_date_time (GBookmarkFile  *bookmark,
0282                                                        const char     *uri,
0283                                                        GDateTime      *modified);
0284 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time)
0285 time_t         g_bookmark_file_get_modified        (GBookmarkFile  *bookmark,
0286                             const gchar    *uri,
0287                             GError        **error);
0288 GLIB_AVAILABLE_IN_2_66
0289 GDateTime     *g_bookmark_file_get_modified_date_time (GBookmarkFile  *bookmark,
0290                                                        const char     *uri,
0291                                                        GError        **error);
0292 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time)
0293 void           g_bookmark_file_set_visited         (GBookmarkFile  *bookmark,
0294                             const gchar    *uri,
0295                             time_t          visited);
0296 GLIB_AVAILABLE_IN_2_66
0297 void           g_bookmark_file_set_visited_date_time (GBookmarkFile  *bookmark,
0298                                                       const char     *uri,
0299                                                       GDateTime      *visited);
0300 GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time)
0301 time_t         g_bookmark_file_get_visited         (GBookmarkFile  *bookmark,
0302                             const gchar    *uri, 
0303                             GError        **error);
0304 GLIB_AVAILABLE_IN_2_66
0305 GDateTime     *g_bookmark_file_get_visited_date_time (GBookmarkFile  *bookmark,
0306                                                       const char     *uri,
0307                                                       GError        **error);
0308 GLIB_AVAILABLE_IN_ALL
0309 gboolean       g_bookmark_file_has_item            (GBookmarkFile  *bookmark,
0310                             const gchar    *uri);
0311 GLIB_AVAILABLE_IN_ALL
0312 gint           g_bookmark_file_get_size            (GBookmarkFile  *bookmark);
0313 GLIB_AVAILABLE_IN_ALL
0314 gchar **       g_bookmark_file_get_uris            (GBookmarkFile  *bookmark,
0315                             gsize          *length);
0316 GLIB_AVAILABLE_IN_ALL
0317 gboolean       g_bookmark_file_remove_group        (GBookmarkFile  *bookmark,
0318                             const gchar    *uri,
0319                             const gchar    *group,
0320                             GError        **error);
0321 GLIB_AVAILABLE_IN_ALL
0322 gboolean       g_bookmark_file_remove_application  (GBookmarkFile  *bookmark,
0323                             const gchar    *uri,
0324                             const gchar    *name,
0325                             GError        **error);
0326 GLIB_AVAILABLE_IN_ALL
0327 gboolean       g_bookmark_file_remove_item         (GBookmarkFile  *bookmark,
0328                             const gchar    *uri,
0329                             GError        **error);
0330 GLIB_AVAILABLE_IN_ALL
0331 gboolean       g_bookmark_file_move_item           (GBookmarkFile  *bookmark,
0332                             const gchar    *old_uri,
0333                             const gchar    *new_uri,
0334                             GError        **error);
0335 
0336 G_END_DECLS
0337 
0338 #endif /* __G_BOOKMARK_FILE_H__ */