mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 08:58:54 +02:00
Bug 620582 - a simple GPermission implementation
add GSimplePermission, a trivial const implementation of GPermission can-request and can-release are always false for this implementation and the value of 'allowed' is decided at construction.
This commit is contained in:
@@ -158,6 +158,7 @@
|
|||||||
<chapter id='permissions'>
|
<chapter id='permissions'>
|
||||||
<title>Permissions</title>
|
<title>Permissions</title>
|
||||||
<xi:include href="xml/gpermission.xml"/>
|
<xi:include href="xml/gpermission.xml"/>
|
||||||
|
<xi:include href="xml/gsimplepermission.xml"/>
|
||||||
</chapter>
|
</chapter>
|
||||||
<chapter id="extending">
|
<chapter id="extending">
|
||||||
<title>Extending GIO</title>
|
<title>Extending GIO</title>
|
||||||
|
@@ -2611,3 +2611,11 @@ g_permission_get_type
|
|||||||
GPermissionPrivate
|
GPermissionPrivate
|
||||||
GPermissionClass
|
GPermissionClass
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>gsimplepermission</FILE>
|
||||||
|
GSimplePermission
|
||||||
|
g_simple_permission_new
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
g_simple_permission_get_type
|
||||||
|
</SECTION>
|
||||||
|
@@ -77,6 +77,7 @@ g_seekable_get_type
|
|||||||
g_settings_get_type
|
g_settings_get_type
|
||||||
g_settings_backend_get_type
|
g_settings_backend_get_type
|
||||||
g_simple_async_result_get_type
|
g_simple_async_result_get_type
|
||||||
|
g_simple_permission_get_type
|
||||||
g_socket_address_enumerator_get_type
|
g_socket_address_enumerator_get_type
|
||||||
g_socket_address_get_type
|
g_socket_address_get_type
|
||||||
g_socket_client_get_type
|
g_socket_client_get_type
|
||||||
|
@@ -333,6 +333,7 @@ libgio_2_0_la_SOURCES = \
|
|||||||
gresolver.c \
|
gresolver.c \
|
||||||
gseekable.c \
|
gseekable.c \
|
||||||
gsimpleasyncresult.c \
|
gsimpleasyncresult.c \
|
||||||
|
gsimplepermission.c \
|
||||||
gsocket.c \
|
gsocket.c \
|
||||||
gsocketaddress.c \
|
gsocketaddress.c \
|
||||||
gsocketaddressenumerator.c \
|
gsocketaddressenumerator.c \
|
||||||
@@ -478,6 +479,7 @@ gio_headers = \
|
|||||||
gresolver.h \
|
gresolver.h \
|
||||||
gseekable.h \
|
gseekable.h \
|
||||||
gsimpleasyncresult.h \
|
gsimpleasyncresult.h \
|
||||||
|
gsimplepermission.h \
|
||||||
gsocket.h \
|
gsocket.h \
|
||||||
gsocketaddress.h \
|
gsocketaddress.h \
|
||||||
gsocketaddressenumerator.h \
|
gsocketaddressenumerator.h \
|
||||||
|
@@ -1746,3 +1746,10 @@ g_permission_release_async
|
|||||||
g_permission_release_finish
|
g_permission_release_finish
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if IN_HEADER(__G_SIMPLE_PERMISSION_H__)
|
||||||
|
#if IN_FILE(__G_SIMPLE_PERMISSION_C__)
|
||||||
|
g_simple_permission_get_type
|
||||||
|
g_simple_permission_new
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
@@ -44,6 +44,7 @@ typedef struct _GConverterInputStream GConverterInputStream;
|
|||||||
typedef struct _GConverterOutputStream GConverterOutputStream;
|
typedef struct _GConverterOutputStream GConverterOutputStream;
|
||||||
typedef struct _GDataInputStream GDataInputStream;
|
typedef struct _GDataInputStream GDataInputStream;
|
||||||
typedef struct _GPermission GPermission;
|
typedef struct _GPermission GPermission;
|
||||||
|
typedef struct _GSimplePermission GSimplePermission;
|
||||||
typedef struct _GZlibCompressor GZlibCompressor;
|
typedef struct _GZlibCompressor GZlibCompressor;
|
||||||
typedef struct _GZlibDecompressor GZlibDecompressor;
|
typedef struct _GZlibDecompressor GZlibDecompressor;
|
||||||
|
|
||||||
|
84
gio/gsimplepermission.c
Normal file
84
gio/gsimplepermission.c
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2010 Codethink Limited
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the licence, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* Author: Ryan Lortie <desrt@desrt.ca>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gsimplepermission.h"
|
||||||
|
#include "gpermission.h"
|
||||||
|
|
||||||
|
#include "gioalias.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gsimplepermission
|
||||||
|
* @title: GSimplePermission
|
||||||
|
* @short_description: a #GPermission that doesn't change value
|
||||||
|
*
|
||||||
|
* #GSimplePermission is a trivial implementation of #GPermission that
|
||||||
|
* represents a permission that is either always or never allowed. The
|
||||||
|
* value is given at constuction and doesn't change.
|
||||||
|
*
|
||||||
|
* Calling request or release will result in errors.
|
||||||
|
**/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSimplePermission:
|
||||||
|
*
|
||||||
|
* #GSimplePermission is an opaque data structure. There are no methods
|
||||||
|
* except for those defined by #GPermission.
|
||||||
|
**/
|
||||||
|
|
||||||
|
typedef GPermissionClass GSimplePermissionClass;
|
||||||
|
|
||||||
|
struct _GSimplePermission
|
||||||
|
{
|
||||||
|
GPermission parent_instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (GSimplePermission, g_simple_permission, G_TYPE_PERMISSION)
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_simple_permission_init (GSimplePermission *simple)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
g_simple_permission_class_init (GSimplePermissionClass *class)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* g_simple_permission_new:
|
||||||
|
* @allowed: %TRUE if the action is allowed
|
||||||
|
* @returns: the #GSimplePermission, as a #GPermission
|
||||||
|
*
|
||||||
|
* Creates a new #GPermission instance that represents an action that is
|
||||||
|
* either always or never allowed.
|
||||||
|
**/
|
||||||
|
GPermission *
|
||||||
|
g_simple_permission_new (gboolean allowed)
|
||||||
|
{
|
||||||
|
GPermission *permission = g_object_new (G_TYPE_SIMPLE_PERMISSION, NULL);
|
||||||
|
|
||||||
|
g_permission_impl_update (permission, allowed, FALSE, FALSE);
|
||||||
|
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define __G_SIMPLE_PERMISSION_C__
|
||||||
|
#include "gioaliasdef.c"
|
45
gio/gsimplepermission.h
Normal file
45
gio/gsimplepermission.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright © 2010 Codethink Limited
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the licence, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* Author: Ryan Lortie <desrt@desrt.ca>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION)
|
||||||
|
#error "Only <gio/gio.h> can be included directly."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef __G_SIMPLE_PERMISSION_H__
|
||||||
|
#define __G_SIMPLE_PERMISSION_H__
|
||||||
|
|
||||||
|
#include <gio/giotypes.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define G_TYPE_SIMPLE_PERMISSION (g_simple_permission_get_type ())
|
||||||
|
#define G_SIMPLE_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), \
|
||||||
|
G_TYPE_SIMPLE_PERMISSION, \
|
||||||
|
GSimplePermission))
|
||||||
|
#define G_IS_SIMPLE_PERMISSION(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), \
|
||||||
|
G_TYPE_SIMPLE_PERMISSION))
|
||||||
|
|
||||||
|
GType g_simple_permission_get_type (void);
|
||||||
|
GPermission * g_simple_permission_new (gboolean allowed);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __G_SIMPLE_PERMISSION_H__ */
|
Reference in New Issue
Block a user