1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2010-2011 Richard Hughes <richard@hughsie.com>
*
* Licensed under the GNU General Public License Version 2
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __CD_SENSOR_H
#define __CD_SENSOR_H
#include "config.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <colord-private.h>
#ifdef HAVE_UDEV
#include <gudev/gudev.h>
#endif
#ifdef HAVE_GUSB
#include <gusb.h>
#endif
#include "cd-common.h"
G_BEGIN_DECLS
#define CD_SENSOR_ERROR cd_sensor_error_quark()
#define CD_TYPE_SENSOR (cd_sensor_get_type ())
G_DECLARE_DERIVABLE_TYPE (CdSensor, cd_sensor, CD, SENSOR, GObject)
struct _CdSensorClass
{
GObjectClass parent_class;
};
typedef enum {
CD_SENSOR_DEBUG_MODE_REQUEST,
CD_SENSOR_DEBUG_MODE_RESPONSE,
CD_SENSOR_DEBUG_MODE_UNKNOWN
} CdSensorDebugMode;
/* when the data is unavailable */
#define CD_SENSOR_NO_VALUE -1.0f
CdSensor *cd_sensor_new (void);
GQuark cd_sensor_error_quark (void);
/* accessors */
const gchar *cd_sensor_get_id (CdSensor *sensor);
const gchar *cd_sensor_get_object_path (CdSensor *sensor);
const gchar *cd_sensor_get_device_path (CdSensor *sensor);
gboolean cd_sensor_register_object (CdSensor *sensor,
GDBusConnection *connection,
GDBusInterfaceInfo *info,
GError **error);
#ifdef HAVE_UDEV
gboolean cd_sensor_set_from_device (CdSensor *sensor,
GUdevDevice *device,
GError **error);
GUdevDevice *cd_sensor_get_device (CdSensor *sensor);
#endif
void cd_sensor_set_index (CdSensor *sensor,
guint idx);
#ifdef HAVE_GUSB
GUsbDevice *cd_sensor_open_usb_device (CdSensor *sensor,
gint config,
gint interface,
GError **error);
#endif
void cd_sensor_button_pressed (CdSensor *sensor);
gboolean cd_sensor_dump (CdSensor *sensor,
GString *data,
GError **error);
CdSensorKind cd_sensor_get_kind (CdSensor *sensor);
void cd_sensor_set_kind (CdSensor *sensor,
CdSensorKind kind);
gboolean cd_sensor_load (CdSensor *sensor,
GError **error);
void cd_sensor_set_state (CdSensor *sensor,
CdSensorState state);
void cd_sensor_set_state_in_idle (CdSensor *sensor,
CdSensorState state);
void cd_sensor_set_mode (CdSensor *sensor,
CdSensorCap mode);
CdSensorCap cd_sensor_get_mode (CdSensor *sensor);
void cd_sensor_set_serial (CdSensor *sensor,
const gchar *serial);
void cd_sensor_add_option (CdSensor *sensor,
const gchar *key,
GVariant *value);
void cd_sensor_add_cap (CdSensor *sensor,
CdSensorCap cap);
/* GModule */
void cd_sensor_get_sample_async (CdSensor *sensor,
CdSensorCap cap,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
CdColorXYZ *cd_sensor_get_sample_finish (CdSensor *sensor,
GAsyncResult *res,
GError **error);
void cd_sensor_get_spectrum_async (CdSensor *sensor,
CdSensorCap cap,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
CdSpectrum *cd_sensor_get_spectrum_finish (CdSensor *sensor,
GAsyncResult *res,
GError **error);
gboolean cd_sensor_coldplug (CdSensor *sensor,
GError **error);
gboolean cd_sensor_dump_device (CdSensor *sensor,
GString *data,
GError **error);
void cd_sensor_lock_async (CdSensor *sensor,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean cd_sensor_lock_finish (CdSensor *sensor,
GAsyncResult *res,
GError **error);
void _cd_sensor_lock_async (CdSensor *sensor,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _cd_sensor_lock_finish (CdSensor *sensor,
GAsyncResult *res,
GError **error);
void cd_sensor_unlock_async (CdSensor *sensor,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean cd_sensor_unlock_finish (CdSensor *sensor,
GAsyncResult *res,
GError **error);
void cd_sensor_set_options_async (CdSensor *sensor,
GHashTable *options,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean cd_sensor_set_options_finish (CdSensor *sensor,
GAsyncResult *res,
GError **error);
void cd_sensor_debug_data (CdSensorDebugMode debug_mode,
const guint8 *data,
gsize length);
G_END_DECLS
#endif /* __CD_SENSOR_H */
|