| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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 | 
					
						
							| 
									
										
										
										
											2017-05-27 18:21:30 +02:00
										 |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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 | 
					
						
							| 
									
										
										
										
											2014-01-23 12:58:29 +01:00
										 |  |  |  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
 | 
					
						
							| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Author: Ryan Lortie <desrt@desrt.ca> | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-06 14:22:48 -04:00
										 |  |  | #include "config.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  | #include "gsimplepermission.h"
 | 
					
						
							|  |  |  | #include "gpermission.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * SECTION:gsimplepermission | 
					
						
							|  |  |  |  * @title: GSimplePermission | 
					
						
							| 
									
										
										
										
											2010-11-28 23:55:43 -05:00
										 |  |  |  * @short_description: A GPermission that doesn't change value | 
					
						
							| 
									
										
										
										
											2014-01-07 22:55:43 -05:00
										 |  |  |  * @include: gio/gio.h | 
					
						
							| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * #GSimplePermission is a trivial implementation of #GPermission that | 
					
						
							|  |  |  |  * represents a permission that is either always or never allowed.  The | 
					
						
							| 
									
										
										
										
											2011-08-29 14:49:32 -04:00
										 |  |  |  * value is given at construction and doesn't change. | 
					
						
							| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Creates a new #GPermission instance that represents an action that is | 
					
						
							|  |  |  |  * either always or never allowed. | 
					
						
							| 
									
										
										
										
											2010-06-06 14:22:48 -04:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2011-11-21 11:02:30 -05:00
										 |  |  |  * Returns: the #GSimplePermission, as a #GPermission | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2010-06-06 14:22:48 -04:00
										 |  |  |  * Since: 2.26 | 
					
						
							| 
									
										
										
										
											2010-06-04 22:32:01 +02:00
										 |  |  |  **/ | 
					
						
							|  |  |  | 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; | 
					
						
							|  |  |  | } |