You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

216 lines
8.7 KiB

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