Coverage Report

Created: 2025-06-13 06:55

/src/glib/gio/gsimplepermission.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright © 2010 Codethink Limited
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 *
19
 * Author: Ryan Lortie <desrt@desrt.ca>
20
 */
21
22
#include "config.h"
23
24
#include "gsimplepermission.h"
25
#include "gpermission.h"
26
27
28
/**
29
 * SECTION:gsimplepermission
30
 * @title: GSimplePermission
31
 * @short_description: A GPermission that doesn't change value
32
 * @include: gio/gio.h
33
 *
34
 * #GSimplePermission is a trivial implementation of #GPermission that
35
 * represents a permission that is either always or never allowed.  The
36
 * value is given at construction and doesn't change.
37
 *
38
 * Calling request or release will result in errors.
39
 **/
40
41
/**
42
 * GSimplePermission:
43
 *
44
 * #GSimplePermission is an opaque data structure.  There are no methods
45
 * except for those defined by #GPermission.
46
 **/
47
48
typedef GPermissionClass GSimplePermissionClass;
49
50
struct _GSimplePermission
51
{
52
  GPermission parent_instance;
53
};
54
55
G_DEFINE_TYPE (GSimplePermission, g_simple_permission, G_TYPE_PERMISSION)
56
57
static void
58
g_simple_permission_init (GSimplePermission *simple)
59
0
{
60
0
}
61
62
static void
63
g_simple_permission_class_init (GSimplePermissionClass *class)
64
0
{
65
0
}
66
67
/**
68
 * g_simple_permission_new:
69
 * @allowed: %TRUE if the action is allowed
70
 *
71
 * Creates a new #GPermission instance that represents an action that is
72
 * either always or never allowed.
73
 *
74
 * Returns: the #GSimplePermission, as a #GPermission
75
 *
76
 * Since: 2.26
77
 **/
78
GPermission *
79
g_simple_permission_new (gboolean allowed)
80
0
{
81
0
  GPermission *permission = g_object_new (G_TYPE_SIMPLE_PERMISSION, NULL);
82
83
0
  g_permission_impl_update (permission, allowed, FALSE, FALSE);
84
85
0
  return permission;
86
0
}