KAuth 5.109.0
|
Support class with some KAUTHCORE_EXPORT methods useful to the helper's code. More...
Functions | |
int | callerUid () |
Obtains the caller user id if available. | |
int | helperMain (int argc, char **argv, const char *id, QObject *responder) |
Method that implements the main function of the helper tool. | |
bool | isStopped () |
Check if the caller asked the helper to stop the execution. | |
void | progressStep (const QVariantMap &data) |
Send a progressStep signal to the caller application. | |
void | progressStep (int step) |
Send a progressStep signal to the caller application. | |
Support class with some KAUTHCORE_EXPORT methods useful to the helper's code.
This class provides the API to write the helper tool that executes your actions. You don't create instances of HelperSupport. Instead, you use its KAUTHCORE_EXPORT methods.
This them you can notify the application of progress in your action's execution and you can check if the application asked you to terminate it.
int KAuth::HelperSupport::callerUid | ( | ) |
Obtains the caller user id if available.
This method offers a way to obtain the unprivileged client's UID if possible. For example when a D-Bus-based backend is used this will resolve the caller of the D-Bus method and obtain its process' UID.
int KAuth::HelperSupport::helperMain | ( | int | argc, |
char ** | argv, | ||
const char * | id, | ||
QObject * | responder | ||
) |
Method that implements the main function of the helper tool.
Do not call directly
This method is called in the proper way by the code generated by the KAUTH_HELPER_MAIN() macro, which creates a main() function for the helper tool. You shouldn't call this method directly.
argc | The argc parameter from the main() function. |
argv | The argv parameter from the main() function. |
id | The helper ID as passed to the macro |
responder | The responder object for the helper. The macro passes a default-constructed, heap-allocated object of the class specified as the last macro parameter |
bool KAuth::HelperSupport::isStopped | ( | ) |
Check if the caller asked the helper to stop the execution.
This method will return true
if the helper has been asked to stop the execution of the current action. If this happens, your helper should return (NOT exit). The meaning of the data you return in this case is application-dependent.
It's good practice to check it regularly if you have a long-running action
true
if the helper has been asked to stop, false
otherwisevoid KAuth::HelperSupport::progressStep | ( | const QVariantMap & | data | ) |
Send a progressStep signal to the caller application.
You can use this method to notify progress information about the action execution. When you call this method, the KAuth::ExecuteJob object associated with the current action will emit the progressStep(QVariantMap) signal. The meaning of the data passed here is totally application dependent.
If you only need a simple percentage value, use the other overload which takes an int.
data | The progress data |
void KAuth::HelperSupport::progressStep | ( | int | step | ) |
Send a progressStep signal to the caller application.
You can use this method to notify progress information about the action execution. When you call this method, the KAuth::ExecuteJob object associated with the current action will emit the KJob::percent(KJob*, unsigned long) signal. The meaning of the integer passed here is totally application dependent, but you'll want to use it as a sort of percentage. If you need to be more expressive, use the other overload which takes a QVariantMap
step | The progress indicator |