Class Permission
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
Permission.Permission$Impl,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
Nested ClassesModifier and TypeClassDescriptionstatic classPermission.Builder<B extends Permission.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe Permission$Impl type represents a native instance of the abstract Permission class.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new Permission.Permission(MemorySegment address) Create a Permission proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacquire(@Nullable Cancellable cancellable) Attempts to acquire the permission represented bypermission.voidacquireAsync(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Attempts to acquire the permission represented bypermission.booleanacquireFinish(AsyncResult result) Collects the result of attempting to acquire the permission represented bypermission.protected PermissionasParent()Returns this instance as if it were its parent type.booleanGets the value of the 'allowed' property.booleanGets the value of the 'can-acquire' property.booleanGets the value of the 'can-release' property.static MemoryLayoutThe memory layout of the native struct.static @Nullable TypegetType()Get the GType of the Permission classvoidimplUpdate(boolean allowed, boolean canAcquire, boolean canRelease) This function is called by theGPermissionimplementation to update the properties of the permission.booleanrelease(@Nullable Cancellable cancellable) Attempts to release the permission represented bypermission.voidreleaseAsync(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Attempts to release the permission represented bypermission.booleanreleaseFinish(AsyncResult result) Collects the result of attempting to release the permission represented bypermission.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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
-
Permission
public Permission()Creates a new Permission.
-
-
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 Javasuperkeyword, 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 bypermission.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
trueis returned. Otherwise,falseis returned anderroris 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:
trueif the permission was successfully acquired- Throws:
GErrorException- seeGError- Since:
- 2.26
-
acquireAsync
Attempts to acquire the permission represented bypermission.This is the first half of the asynchronous version of g_permission_acquire().
- Parameters:
cancellable- aGCancellable, ornullcallback- theGAsyncReadyCallbackto call when done- Since:
- 2.26
-
acquireFinish
Collects the result of attempting to acquire the permission represented bypermission.This is the second half of the asynchronous version of g_permission_acquire().
- Parameters:
result- theGAsyncResultgiven to theGAsyncReadyCallback- Returns:
trueif the permission was successfully acquired- Throws:
GErrorException- seeGError- Since:
- 2.26
-
getAllowed
public boolean getAllowed()Gets the value of the 'allowed' property. This property istrueif the caller currently has permission to perform the action that this Permission represents the permission to perform.- Returns:
- the value of the 'allowed' property
- Since:
- 2.26
-
getCanAcquire
public boolean getCanAcquire()Gets the value of the 'can-acquire' property. This property istrueif it is generally possible to acquire the permission by calling g_permission_acquire().- Returns:
- the value of the 'can-acquire' property
- Since:
- 2.26
-
getCanRelease
public boolean getCanRelease()Gets the value of the 'can-release' property. This property istrueif it is generally possible to release the permission by calling g_permission_release().- Returns:
- the value of the 'can-release' property
- Since:
- 2.26
-
implUpdate
public void implUpdate(boolean allowed, boolean canAcquire, boolean canRelease) This function is called by theGPermissionimplementation to update the properties of the permission. You should never call this function except from aGPermissionimplementation.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- Since:
- 2.26
-
release
Attempts to release the permission represented bypermission.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
trueis returned. Otherwise,falseis returned anderroris 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:
trueif the permission was successfully released- Throws:
GErrorException- seeGError- Since:
- 2.26
-
releaseAsync
Attempts to release the permission represented bypermission.This is the first half of the asynchronous version of g_permission_release().
- Parameters:
cancellable- aGCancellable, ornullcallback- theGAsyncReadyCallbackto call when done- Since:
- 2.26
-
releaseFinish
Collects the result of attempting to release the permission represented bypermission.This is the second half of the asynchronous version of g_permission_release().
- Parameters:
result- theGAsyncResultgiven to theGAsyncReadyCallback- Returns:
trueif the permission was successfully released- Throws:
GErrorException- seeGError- Since:
- 2.26
-