gbookmarkfile.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. #ifndef __G_BOOKMARK_FILE_H__
  20. #define __G_BOOKMARK_FILE_H__
  21. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  22. #error "Only <glib.h> can be included directly."
  23. #endif
  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. GLIB_AVAILABLE_IN_ALL
  62. GQuark g_bookmark_file_error_quark (void);
  63. /**
  64. * GBookmarkFile:
  65. *
  66. * The <structname>GBookmarkFile</structname> struct contains only
  67. * private data and should not be directly accessed.
  68. */
  69. typedef struct _GBookmarkFile GBookmarkFile;
  70. GLIB_AVAILABLE_IN_ALL
  71. GBookmarkFile *g_bookmark_file_new (void);
  72. GLIB_AVAILABLE_IN_ALL
  73. void g_bookmark_file_free (GBookmarkFile *bookmark);
  74. GLIB_AVAILABLE_IN_ALL
  75. gboolean g_bookmark_file_load_from_file (GBookmarkFile *bookmark,
  76. const gchar *filename,
  77. GError **error);
  78. GLIB_AVAILABLE_IN_ALL
  79. gboolean g_bookmark_file_load_from_data (GBookmarkFile *bookmark,
  80. const gchar *data,
  81. gsize length,
  82. GError **error);
  83. GLIB_AVAILABLE_IN_ALL
  84. gboolean g_bookmark_file_load_from_data_dirs (GBookmarkFile *bookmark,
  85. const gchar *file,
  86. gchar **full_path,
  87. GError **error);
  88. GLIB_AVAILABLE_IN_ALL
  89. gchar * g_bookmark_file_to_data (GBookmarkFile *bookmark,
  90. gsize *length,
  91. GError **error) G_GNUC_MALLOC;
  92. GLIB_AVAILABLE_IN_ALL
  93. gboolean g_bookmark_file_to_file (GBookmarkFile *bookmark,
  94. const gchar *filename,
  95. GError **error);
  96. GLIB_AVAILABLE_IN_ALL
  97. void g_bookmark_file_set_title (GBookmarkFile *bookmark,
  98. const gchar *uri,
  99. const gchar *title);
  100. GLIB_AVAILABLE_IN_ALL
  101. gchar * g_bookmark_file_get_title (GBookmarkFile *bookmark,
  102. const gchar *uri,
  103. GError **error) G_GNUC_MALLOC;
  104. GLIB_AVAILABLE_IN_ALL
  105. void g_bookmark_file_set_description (GBookmarkFile *bookmark,
  106. const gchar *uri,
  107. const gchar *description);
  108. GLIB_AVAILABLE_IN_ALL
  109. gchar * g_bookmark_file_get_description (GBookmarkFile *bookmark,
  110. const gchar *uri,
  111. GError **error) G_GNUC_MALLOC;
  112. GLIB_AVAILABLE_IN_ALL
  113. void g_bookmark_file_set_mime_type (GBookmarkFile *bookmark,
  114. const gchar *uri,
  115. const gchar *mime_type);
  116. GLIB_AVAILABLE_IN_ALL
  117. gchar * g_bookmark_file_get_mime_type (GBookmarkFile *bookmark,
  118. const gchar *uri,
  119. GError **error) G_GNUC_MALLOC;
  120. GLIB_AVAILABLE_IN_ALL
  121. void g_bookmark_file_set_groups (GBookmarkFile *bookmark,
  122. const gchar *uri,
  123. const gchar **groups,
  124. gsize length);
  125. GLIB_AVAILABLE_IN_ALL
  126. void g_bookmark_file_add_group (GBookmarkFile *bookmark,
  127. const gchar *uri,
  128. const gchar *group);
  129. GLIB_AVAILABLE_IN_ALL
  130. gboolean g_bookmark_file_has_group (GBookmarkFile *bookmark,
  131. const gchar *uri,
  132. const gchar *group,
  133. GError **error);
  134. GLIB_AVAILABLE_IN_ALL
  135. gchar ** g_bookmark_file_get_groups (GBookmarkFile *bookmark,
  136. const gchar *uri,
  137. gsize *length,
  138. GError **error) G_GNUC_MALLOC;
  139. GLIB_AVAILABLE_IN_ALL
  140. void g_bookmark_file_add_application (GBookmarkFile *bookmark,
  141. const gchar *uri,
  142. const gchar *name,
  143. const gchar *exec);
  144. GLIB_AVAILABLE_IN_ALL
  145. gboolean g_bookmark_file_has_application (GBookmarkFile *bookmark,
  146. const gchar *uri,
  147. const gchar *name,
  148. GError **error);
  149. GLIB_AVAILABLE_IN_ALL
  150. gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark,
  151. const gchar *uri,
  152. gsize *length,
  153. GError **error) G_GNUC_MALLOC;
  154. GLIB_AVAILABLE_IN_ALL
  155. gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
  156. const gchar *uri,
  157. const gchar *name,
  158. const gchar *exec,
  159. gint count,
  160. time_t stamp,
  161. GError **error);
  162. GLIB_AVAILABLE_IN_ALL
  163. gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
  164. const gchar *uri,
  165. const gchar *name,
  166. gchar **exec,
  167. guint *count,
  168. time_t *stamp,
  169. GError **error);
  170. GLIB_AVAILABLE_IN_ALL
  171. void g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
  172. const gchar *uri,
  173. gboolean is_private);
  174. GLIB_AVAILABLE_IN_ALL
  175. gboolean g_bookmark_file_get_is_private (GBookmarkFile *bookmark,
  176. const gchar *uri,
  177. GError **error);
  178. GLIB_AVAILABLE_IN_ALL
  179. void g_bookmark_file_set_icon (GBookmarkFile *bookmark,
  180. const gchar *uri,
  181. const gchar *href,
  182. const gchar *mime_type);
  183. GLIB_AVAILABLE_IN_ALL
  184. gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark,
  185. const gchar *uri,
  186. gchar **href,
  187. gchar **mime_type,
  188. GError **error);
  189. GLIB_AVAILABLE_IN_ALL
  190. void g_bookmark_file_set_added (GBookmarkFile *bookmark,
  191. const gchar *uri,
  192. time_t added);
  193. GLIB_AVAILABLE_IN_ALL
  194. time_t g_bookmark_file_get_added (GBookmarkFile *bookmark,
  195. const gchar *uri,
  196. GError **error);
  197. GLIB_AVAILABLE_IN_ALL
  198. void g_bookmark_file_set_modified (GBookmarkFile *bookmark,
  199. const gchar *uri,
  200. time_t modified);
  201. GLIB_AVAILABLE_IN_ALL
  202. time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark,
  203. const gchar *uri,
  204. GError **error);
  205. GLIB_AVAILABLE_IN_ALL
  206. void g_bookmark_file_set_visited (GBookmarkFile *bookmark,
  207. const gchar *uri,
  208. time_t visited);
  209. GLIB_AVAILABLE_IN_ALL
  210. time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark,
  211. const gchar *uri,
  212. GError **error);
  213. GLIB_AVAILABLE_IN_ALL
  214. gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark,
  215. const gchar *uri);
  216. GLIB_AVAILABLE_IN_ALL
  217. gint g_bookmark_file_get_size (GBookmarkFile *bookmark);
  218. GLIB_AVAILABLE_IN_ALL
  219. gchar ** g_bookmark_file_get_uris (GBookmarkFile *bookmark,
  220. gsize *length) G_GNUC_MALLOC;
  221. GLIB_AVAILABLE_IN_ALL
  222. gboolean g_bookmark_file_remove_group (GBookmarkFile *bookmark,
  223. const gchar *uri,
  224. const gchar *group,
  225. GError **error);
  226. GLIB_AVAILABLE_IN_ALL
  227. gboolean g_bookmark_file_remove_application (GBookmarkFile *bookmark,
  228. const gchar *uri,
  229. const gchar *name,
  230. GError **error);
  231. GLIB_AVAILABLE_IN_ALL
  232. gboolean g_bookmark_file_remove_item (GBookmarkFile *bookmark,
  233. const gchar *uri,
  234. GError **error);
  235. GLIB_AVAILABLE_IN_ALL
  236. gboolean g_bookmark_file_move_item (GBookmarkFile *bookmark,
  237. const gchar *old_uri,
  238. const gchar *new_uri,
  239. GError **error);
  240. G_END_DECLS
  241. #endif /* __G_BOOKMARK_FILE_H__ */