Debian Codegraph @

src/fprintd.h

raw
1 /*
2 * fprintd header file
3 * Copyright (C) 2008 Daniel Drake <[email protected]>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #pragma once
21
22 #include <glib.h>
23 #include <gio/gio.h>
24 #include <fprint.h>
25 #include "fprintd-enums.h"
26 #include "fprintd-dbus.h"
27
28 /* General */
29 #define TIMEOUT 30
30 #define FPRINT_SERVICE_NAME "net.reactivated.Fprint"
31 #define FPRINT_SERVICE_PATH "/net/reactivated/Fprint"
32
33 /* Errors */
34 GQuark fprint_error_quark (void);
35
36 #define FPRINT_ERROR fprint_error_quark ()
37 typedef enum {
38 /* developer didn't claim the device */
39 FPRINT_ERROR_CLAIM_DEVICE, /*< nick=net.reactivated.Fprint.Error.ClaimDevice >*/
40 /* device is already claimed by somebody else */
41 FPRINT_ERROR_ALREADY_IN_USE, /*< nick=net.reactivated.Fprint.Error.AlreadyInUse >*/
42 /* internal error occurred */
43 FPRINT_ERROR_INTERNAL, /*< nick=net.reactivated.Fprint.Error.Internal >*/
44 /* PolicyKit refused the action */
45 FPRINT_ERROR_PERMISSION_DENIED, /*< nick=net.reactivated.Fprint.Error.PermissionDenied >*/
46 /* No prints are enrolled */
47 FPRINT_ERROR_NO_ENROLLED_PRINTS, /*< nick=net.reactivated.Fprint.Error.NoEnrolledPrints >*/
48 /* Prints has already been enrolled */
49 FPRINT_ERROR_FINGER_ALREADY_ENROLLED, /*< nick=net.reactivated.Fprint.Error.FingerAlreadyEnrolled >*/
50 /* No actions currently in progress */
51 FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /*< nick=net.reactivated.Fprint.Error.NoActionInProgress >*/
52 /* the finger name passed was invalid */
53 FPRINT_ERROR_INVALID_FINGERNAME, /*< nick=net.reactivated.Fprint.Error.InvalidFingername >*/
54 /* device does not exist */
55 FPRINT_ERROR_NO_SUCH_DEVICE, /*< nick=net.reactivated.Fprint.Error.NoSuchDevice >*/
56 /* Prints cannot be deleted from the fprintd storage */
57 FPRINT_ERROR_PRINTS_NOT_DELETED, /*< nick=net.reactivated.Fprint.Error.PrintsNotDeleted >*/
58 /* Prints cannot be deleted from the device storage */
59 FPRINT_ERROR_PRINTS_NOT_DELETED_FROM_DEVICE, /*< nick=net.reactivated.Fprint.Error.PrintsNotDeletedFromDevice >*/
60 } FprintError;
61
62 /* Enum of possible permissions, orders and nick matter here:
63 - The order controls the priority of a required permission when various are
64 accepted: the lowest the value, the more priority it has.
65 - Nick must match the relative polkit rule.
66 */
67 typedef enum {
68 FPRINT_DEVICE_PERMISSION_NONE = 0,
69 FPRINT_DEVICE_PERMISSION_VERIFY = (1 << 0), /*< nick=net.reactivated.fprint.device.verify >*/
70 FPRINT_DEVICE_PERMISSION_ENROLL = (1 << 1), /*< nick=net.reactivated.fprint.device.enroll >*/
71 FPRINT_DEVICE_PERMISSION_SETUSERNAME = (1 << 2), /*< nick=net.reactivated.fprint.device.setusername >*/
72 } FprintDevicePermission;
73
74 /* Manager */
75 #define FPRINT_TYPE_MANAGER (fprint_manager_get_type ())
76 G_DECLARE_FINAL_TYPE (FprintManager, fprint_manager, FPRINT, MANAGER, GObject)
77
78 struct _FprintManager
79 {
80 GObject parent;
81 };
82
83 FprintManager *fprint_manager_new (GDBusConnection *connection,
84 gboolean no_timeout);
85
86 /* Device */
87 #define FPRINT_TYPE_DEVICE (fprint_device_get_type ())
88 G_DECLARE_FINAL_TYPE (FprintDevice, fprint_device, FPRINT, DEVICE,
89 FprintDBusDeviceSkeleton)
90
91 struct _FprintDevice
92 {
93 FprintDBusDeviceSkeleton parent;
94 };
95
96 FprintDevice *fprint_device_new (FpDevice *dev);
97 guint32 _fprint_device_get_id (FprintDevice *rdev);
98
99 void fprint_device_suspend (FprintDevice *rdev,
100 GAsyncReadyCallback callback,
101 void *user_data);
102 void fprint_device_resume (FprintDevice *rdev,
103 GAsyncReadyCallback callback,
104 void *user_data);
105
106 void fprint_device_suspend_finish (FprintDevice *rdev,
107 GAsyncResult *result,
108 GError **error);
109 void fprint_device_resume_finish (FprintDevice *rdev,
110 GAsyncResult *res,
111 GError **error);
112
113
114 /* Print */
115 /* TODO */
116
117
118 /* Some compatibility definitions for older GLib. Copied from from libfprint. */
119 #if !GLIB_CHECK_VERSION (2, 57, 0)
120 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GTypeClass, g_type_class_unref);
121 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GEnumClass, g_type_class_unref);
122 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GFlagsClass, g_type_class_unref);
123 G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref);
124 #else
125 /* Re-define G_SOURCE_FUNC as we are technically not allowed to use it with
126 * the version we depend on currently. */
127 #undef G_SOURCE_FUNC
128 #endif
129
130 #define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void))(f))