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