gpermission.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright © 2010 Codethink Limited
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the licence, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * Author: Ryan Lortie <desrt@desrt.ca>
  18. */
  19. #ifndef __G_PERMISSION_H__
  20. #define __G_PERMISSION_H__
  21. #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
  22. #error "Only <gio/gio.h> can be included directly."
  23. #endif
  24. #include <gio/giotypes.h>
  25. G_BEGIN_DECLS
  26. #define G_TYPE_PERMISSION (g_permission_get_type ())
  27. #define G_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
  28. G_TYPE_PERMISSION, GPermission))
  29. #define G_PERMISSION_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), \
  30. G_TYPE_PERMISSION, GPermissionClass))
  31. #define G_IS_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
  32. G_TYPE_PERMISSION))
  33. #define G_IS_PERMISSION_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), \
  34. G_TYPE_PERMISSION))
  35. #define G_PERMISSION_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_CLASS ((inst), \
  36. G_TYPE_PERMISSION, GPermissionClass))
  37. typedef struct _GPermissionPrivate GPermissionPrivate;
  38. typedef struct _GPermissionClass GPermissionClass;
  39. struct _GPermission
  40. {
  41. GObject parent_instance;
  42. /*< private >*/
  43. GPermissionPrivate *priv;
  44. };
  45. struct _GPermissionClass {
  46. GObjectClass parent_class;
  47. gboolean (*acquire) (GPermission *permission,
  48. GCancellable *cancellable,
  49. GError **error);
  50. void (*acquire_async) (GPermission *permission,
  51. GCancellable *cancellable,
  52. GAsyncReadyCallback callback,
  53. gpointer user_data);
  54. gboolean (*acquire_finish) (GPermission *permission,
  55. GAsyncResult *result,
  56. GError **error);
  57. gboolean (*release) (GPermission *permission,
  58. GCancellable *cancellable,
  59. GError **error);
  60. void (*release_async) (GPermission *permission,
  61. GCancellable *cancellable,
  62. GAsyncReadyCallback callback,
  63. gpointer user_data);
  64. gboolean (*release_finish) (GPermission *permission,
  65. GAsyncResult *result,
  66. GError **error);
  67. gpointer reserved[16];
  68. };
  69. GLIB_AVAILABLE_IN_ALL
  70. GType g_permission_get_type (void);
  71. GLIB_AVAILABLE_IN_ALL
  72. gboolean g_permission_acquire (GPermission *permission,
  73. GCancellable *cancellable,
  74. GError **error);
  75. GLIB_AVAILABLE_IN_ALL
  76. void g_permission_acquire_async (GPermission *permission,
  77. GCancellable *cancellable,
  78. GAsyncReadyCallback callback,
  79. gpointer user_data);
  80. GLIB_AVAILABLE_IN_ALL
  81. gboolean g_permission_acquire_finish (GPermission *permission,
  82. GAsyncResult *result,
  83. GError **error);
  84. GLIB_AVAILABLE_IN_ALL
  85. gboolean g_permission_release (GPermission *permission,
  86. GCancellable *cancellable,
  87. GError **error);
  88. GLIB_AVAILABLE_IN_ALL
  89. void g_permission_release_async (GPermission *permission,
  90. GCancellable *cancellable,
  91. GAsyncReadyCallback callback,
  92. gpointer user_data);
  93. GLIB_AVAILABLE_IN_ALL
  94. gboolean g_permission_release_finish (GPermission *permission,
  95. GAsyncResult *result,
  96. GError **error);
  97. GLIB_AVAILABLE_IN_ALL
  98. gboolean g_permission_get_allowed (GPermission *permission);
  99. GLIB_AVAILABLE_IN_ALL
  100. gboolean g_permission_get_can_acquire (GPermission *permission);
  101. GLIB_AVAILABLE_IN_ALL
  102. gboolean g_permission_get_can_release (GPermission *permission);
  103. GLIB_AVAILABLE_IN_ALL
  104. void g_permission_impl_update (GPermission *permission,
  105. gboolean allowed,
  106. gboolean can_acquire,
  107. gboolean can_release);
  108. G_END_DECLS
  109. #endif /* __G_PERMISSION_H__ */