mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
manager: Use GEnum to register DBus errors from FprintError
Given that mk_genenum already parses FprintError, add the nick metadata to the errors so that it matches the wanted DBus error and automatically generate the errors list. In this way we'll have to only touch one definition to get everything updated
This commit is contained in:
committed by
Benjamin Berg
parent
4c78012103
commit
4e707f0d31
@ -30,7 +30,6 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "fprintd.h"
|
||||
#include "fprintd-enums.h"
|
||||
#include "storage.h"
|
||||
|
||||
static const char *FINGERS_NAMES[] = {
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
#include <glib.h>
|
||||
#include <gio/gio.h>
|
||||
#include <fprint.h>
|
||||
#include "fprintd-enums.h"
|
||||
#include "fprintd-dbus.h"
|
||||
|
||||
/* General */
|
||||
@ -33,16 +34,23 @@
|
||||
GQuark fprint_error_quark(void);
|
||||
|
||||
#define FPRINT_ERROR fprint_error_quark()
|
||||
#define FPRINT_ERROR_DBUS_INTERFACE "net.reactivated.Fprint.Error"
|
||||
typedef enum {
|
||||
FPRINT_ERROR_CLAIM_DEVICE, /* developer didn't claim the device */
|
||||
FPRINT_ERROR_ALREADY_IN_USE, /* device is already claimed by somebody else */
|
||||
FPRINT_ERROR_INTERNAL, /* internal error occurred */
|
||||
FPRINT_ERROR_PERMISSION_DENIED, /* PolicyKit refused the action */
|
||||
FPRINT_ERROR_NO_ENROLLED_PRINTS, /* No prints are enrolled */
|
||||
FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /* No actions currently in progress */
|
||||
FPRINT_ERROR_INVALID_FINGERNAME, /* the finger name passed was invalid */
|
||||
FPRINT_ERROR_NO_SUCH_DEVICE, /* device does not exist */
|
||||
/* developer didn't claim the device */
|
||||
FPRINT_ERROR_CLAIM_DEVICE, /*< nick=net.reactivated.Fprint.Error.ClaimDevice >*/
|
||||
/* device is already claimed by somebody else */
|
||||
FPRINT_ERROR_ALREADY_IN_USE, /*< nick=net.reactivated.Fprint.Error.AlreadyInUse >*/
|
||||
/* internal error occurred */
|
||||
FPRINT_ERROR_INTERNAL, /*< nick=net.reactivated.Fprint.Error.Internal >*/
|
||||
/* PolicyKit refused the action */
|
||||
FPRINT_ERROR_PERMISSION_DENIED, /*< nick=net.reactivated.Fprint.Error.PermissionDenied >*/
|
||||
/* No prints are enrolled */
|
||||
FPRINT_ERROR_NO_ENROLLED_PRINTS, /*< nick=net.reactivated.Fprint.Error.NoEnrolledPrints >*/
|
||||
/* No actions currently in progress */
|
||||
FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /*< nick=net.reactivated.Fprint.Error.NoActionInProgress >*/
|
||||
/* the finger name passed was invalid */
|
||||
FPRINT_ERROR_INVALID_FINGERNAME, /*< nick=net.reactivated.Fprint.Error.InvalidFingername >*/
|
||||
/* device does not exist */
|
||||
FPRINT_ERROR_NO_SUCH_DEVICE, /*< nick=net.reactivated.Fprint.Error.NoSuchDevice >*/
|
||||
} FprintError;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@ -394,28 +394,25 @@ static gboolean fprint_manager_get_default_device(FprintManager *manager,
|
||||
}
|
||||
}
|
||||
|
||||
#define ERROR_ENTRY(name, dbus_name) \
|
||||
{ FPRINT_ERROR_ ## name, FPRINT_ERROR_DBUS_INTERFACE "." dbus_name }
|
||||
GDBusErrorEntry fprint_error_entries[] =
|
||||
{
|
||||
ERROR_ENTRY (CLAIM_DEVICE, "ClaimDevice"),
|
||||
ERROR_ENTRY (ALREADY_IN_USE, "AlreadyInUse"),
|
||||
ERROR_ENTRY (INTERNAL, "Internal"),
|
||||
ERROR_ENTRY (PERMISSION_DENIED, "PermissionDenied"),
|
||||
ERROR_ENTRY (NO_ENROLLED_PRINTS, "NoEnrolledPrints"),
|
||||
ERROR_ENTRY (NO_ACTION_IN_PROGRESS, "NoActionInProgress"),
|
||||
ERROR_ENTRY (INVALID_FINGERNAME, "InvalidFingername"),
|
||||
ERROR_ENTRY (NO_SUCH_DEVICE, "NoSuchDevice"),
|
||||
};
|
||||
|
||||
GQuark fprint_error_quark (void)
|
||||
{
|
||||
static volatile gsize quark = 0;
|
||||
if (!quark) {
|
||||
g_dbus_error_register_error_domain ("fprintd-error-quark",
|
||||
&quark,
|
||||
fprint_error_entries,
|
||||
G_N_ELEMENTS (fprint_error_entries));
|
||||
if (g_once_init_enter (&quark)) {
|
||||
g_autoptr(GEnumClass) errors_enum = NULL;
|
||||
GQuark domain;
|
||||
unsigned i;
|
||||
|
||||
domain = g_quark_from_static_string ("fprintd-error-quark");
|
||||
errors_enum = g_type_class_ref (FPRINT_TYPE_ERROR);
|
||||
|
||||
for (i = 0; i < errors_enum->n_values; ++i) {
|
||||
GEnumValue *value = &errors_enum->values[i];
|
||||
|
||||
g_dbus_error_register_error (domain, value->value,
|
||||
value->value_nick);
|
||||
}
|
||||
|
||||
g_once_init_leave (&quark, domain);
|
||||
}
|
||||
return (GQuark) quark;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user