Class Permission
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Permission.PermissionImpl
,SimplePermission
GPermission
represents the status of the caller’s permission to
perform a certain action.
You can query if the action is currently allowed and if it is possible to acquire the permission so that the action will be allowed in the future.
There is also an API to actually acquire the permission and one to release it.
As an example, a GPermission
might represent the ability for the
user to write to a Settings
object. This GPermission
object
could then be used to decide if it is appropriate to show a “Click here to
unlock” button in a dialog and to provide the mechanism to invoke
when that button is clicked.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Permission.Builder<B extends Permission.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
static class
The PermissionImpl type represents a native instance of the abstract Permission class.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionPermission
(MemorySegment address) Create a Permission proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
acquire
(@Nullable Cancellable cancellable) Attempts to acquire the permission represented by this Permission.void
acquireAsync
(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Attempts to acquire the permission represented by this Permission.boolean
acquireFinish
(AsyncResult result) Collects the result of attempting to acquire the permission represented by this Permission.protected Permission
asParent()
Returns this instance as if it were its parent type.static Permission.Builder
<? extends Permission.Builder> builder()
APermission.Builder
object constructs aPermission
with the specified properties.boolean
Gets the value of the 'allowed' property.boolean
Gets the value of the 'can-acquire' property.boolean
Gets the value of the 'can-release' property.static MemoryLayout
The memory layout of the native struct.static Type
getType()
Get the GType of the Permission classvoid
implUpdate
(boolean allowed, boolean canAcquire, boolean canRelease) This function is called by theGPermission
implementation to update the properties of the permission.boolean
release
(@Nullable Cancellable cancellable) Attempts to release the permission represented by this Permission.void
releaseAsync
(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Attempts to release the permission represented by this Permission.boolean
releaseFinish
(AsyncResult result) Collects the result of attempting to release the permission represented by this Permission.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Permission
Create a Permission proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
acquire
Attempts to acquire the permission represented by this Permission.The precise method by which this happens depends on the permission and the underlying authentication mechanism. A simple example is that a dialog may appear asking the user to enter their password.
You should check with g_permission_get_can_acquire() before calling this function.
If the permission is acquired then
true
is returned. Otherwise,false
is returned anderror
is set appropriately.This call is blocking, likely for a very long time (in the case that user interaction is required). See g_permission_acquire_async() for the non-blocking version.
- Parameters:
cancellable
- aGCancellable
, ornull
- Returns:
true
if the permission was successfully acquired- Throws:
GErrorException
- seeGError
-
acquireAsync
public void acquireAsync(@Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Attempts to acquire the permission represented by this Permission.This is the first half of the asynchronous version of g_permission_acquire().
- Parameters:
cancellable
- aGCancellable
, ornull
callback
- theGAsyncReadyCallback
to call when done
-
acquireFinish
Collects the result of attempting to acquire the permission represented by this Permission.This is the second half of the asynchronous version of g_permission_acquire().
- Parameters:
result
- theGAsyncResult
given to theGAsyncReadyCallback
- Returns:
true
if the permission was successfully acquired- Throws:
GErrorException
- seeGError
-
getAllowed
public boolean getAllowed()Gets the value of the 'allowed' property. This property istrue
if the caller currently has permission to perform the action that this Permission represents the permission to perform.- Returns:
- the value of the 'allowed' property
-
getCanAcquire
public boolean getCanAcquire()Gets the value of the 'can-acquire' property. This property istrue
if it is generally possible to acquire the permission by calling g_permission_acquire().- Returns:
- the value of the 'can-acquire' property
-
getCanRelease
public boolean getCanRelease()Gets the value of the 'can-release' property. This property istrue
if it is generally possible to release the permission by calling g_permission_release().- Returns:
- the value of the 'can-release' property
-
implUpdate
public void implUpdate(boolean allowed, boolean canAcquire, boolean canRelease) This function is called by theGPermission
implementation to update the properties of the permission. You should never call this function except from aGPermission
implementation.GObject notify signals are generated, as appropriate.
- Parameters:
allowed
- the new value for the 'allowed' propertycanAcquire
- the new value for the 'can-acquire' propertycanRelease
- the new value for the 'can-release' property
-
release
Attempts to release the permission represented by this Permission.The precise method by which this happens depends on the permission and the underlying authentication mechanism. In most cases the permission will be dropped immediately without further action.
You should check with g_permission_get_can_release() before calling this function.
If the permission is released then
true
is returned. Otherwise,false
is returned anderror
is set appropriately.This call is blocking, likely for a very long time (in the case that user interaction is required). See g_permission_release_async() for the non-blocking version.
- Parameters:
cancellable
- aGCancellable
, ornull
- Returns:
true
if the permission was successfully released- Throws:
GErrorException
- seeGError
-
releaseAsync
public void releaseAsync(@Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Attempts to release the permission represented by this Permission.This is the first half of the asynchronous version of g_permission_release().
- Parameters:
cancellable
- aGCancellable
, ornull
callback
- theGAsyncReadyCallback
to call when done
-
releaseFinish
Collects the result of attempting to release the permission represented by this Permission.This is the second half of the asynchronous version of g_permission_release().
- Parameters:
result
- theGAsyncResult
given to theGAsyncReadyCallback
- Returns:
true
if the permission was successfully released- Throws:
GErrorException
- seeGError
-
builder
APermission.Builder
object constructs aPermission
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withPermission.Builder.build()
.
-