Blame gio/gsimplepermission.c

Packit ae235b
/*
Packit ae235b
 * Copyright © 2010 Codethink Limited
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General Public
Packit ae235b
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 *
Packit ae235b
 * Author: Ryan Lortie <desrt@desrt.ca>
Packit ae235b
 */
Packit ae235b
Packit ae235b
#include "config.h"
Packit ae235b
Packit ae235b
#include "gsimplepermission.h"
Packit ae235b
#include "gpermission.h"
Packit ae235b
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * SECTION:gsimplepermission
Packit ae235b
 * @title: GSimplePermission
Packit ae235b
 * @short_description: A GPermission that doesn't change value
Packit ae235b
 * @include: gio/gio.h
Packit ae235b
 *
Packit ae235b
 * #GSimplePermission is a trivial implementation of #GPermission that
Packit ae235b
 * represents a permission that is either always or never allowed.  The
Packit ae235b
 * value is given at construction and doesn't change.
Packit ae235b
 *
Packit ae235b
 * Calling request or release will result in errors.
Packit ae235b
 **/
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GSimplePermission:
Packit ae235b
 *
Packit ae235b
 * #GSimplePermission is an opaque data structure.  There are no methods
Packit ae235b
 * except for those defined by #GPermission.
Packit ae235b
 **/
Packit ae235b
Packit ae235b
typedef GPermissionClass GSimplePermissionClass;
Packit ae235b
Packit ae235b
struct _GSimplePermission
Packit ae235b
{
Packit ae235b
  GPermission parent_instance;
Packit ae235b
};
Packit ae235b
Packit ae235b
G_DEFINE_TYPE (GSimplePermission, g_simple_permission, G_TYPE_PERMISSION)
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_simple_permission_init (GSimplePermission *simple)
Packit ae235b
{
Packit ae235b
}
Packit ae235b
Packit ae235b
static void
Packit ae235b
g_simple_permission_class_init (GSimplePermissionClass *class)
Packit ae235b
{
Packit ae235b
}
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * g_simple_permission_new:
Packit ae235b
 * @allowed: %TRUE if the action is allowed
Packit ae235b
 *
Packit ae235b
 * Creates a new #GPermission instance that represents an action that is
Packit ae235b
 * either always or never allowed.
Packit ae235b
 *
Packit ae235b
 * Returns: the #GSimplePermission, as a #GPermission
Packit ae235b
 *
Packit ae235b
 * Since: 2.26
Packit ae235b
 **/
Packit ae235b
GPermission *
Packit ae235b
g_simple_permission_new (gboolean allowed)
Packit ae235b
{
Packit ae235b
  GPermission *permission = g_object_new (G_TYPE_SIMPLE_PERMISSION, NULL);
Packit ae235b
Packit ae235b
  g_permission_impl_update (permission, allowed, FALSE, FALSE);
Packit ae235b
Packit ae235b
  return permission;
Packit ae235b
}