Merge branch 'test-ip_mreq_source-android-only' into 'master'
[glib.git] / gio / gsimplepermission.c
blob5ec88b8a0337f569e8354e0efb2b62a9b5b9b5fb
1 /*
2 * Copyright © 2010 Codethink Limited
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.1 of the License, or (at your option) any later version.
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.
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/>.
17 * Author: Ryan Lortie <desrt@desrt.ca>
20 #include "config.h"
22 #include "gsimplepermission.h"
23 #include "gpermission.h"
26 /**
27 * SECTION:gsimplepermission
28 * @title: GSimplePermission
29 * @short_description: A GPermission that doesn't change value
30 * @include: gio/gio.h
32 * #GSimplePermission is a trivial implementation of #GPermission that
33 * represents a permission that is either always or never allowed. The
34 * value is given at construction and doesn't change.
36 * Calling request or release will result in errors.
37 **/
39 /**
40 * GSimplePermission:
42 * #GSimplePermission is an opaque data structure. There are no methods
43 * except for those defined by #GPermission.
44 **/
46 typedef GPermissionClass GSimplePermissionClass;
48 struct _GSimplePermission
50 GPermission parent_instance;
53 G_DEFINE_TYPE (GSimplePermission, g_simple_permission, G_TYPE_PERMISSION)
55 static void
56 g_simple_permission_init (GSimplePermission *simple)
60 static void
61 g_simple_permission_class_init (GSimplePermissionClass *class)
65 /**
66 * g_simple_permission_new:
67 * @allowed: %TRUE if the action is allowed
69 * Creates a new #GPermission instance that represents an action that is
70 * either always or never allowed.
72 * Returns: the #GSimplePermission, as a #GPermission
74 * Since: 2.26
75 **/
76 GPermission *
77 g_simple_permission_new (gboolean allowed)
79 GPermission *permission = g_object_new (G_TYPE_SIMPLE_PERMISSION, NULL);
81 g_permission_impl_update (permission, allowed, FALSE, FALSE);
83 return permission;