Debian Codegraph @

src/sensors/munki/munki-enum.c

raw
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2013 Richard Hughes <[email protected]>
4 *
5 * Licensed under the GNU General Public License Version 2
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 /**
23 * SECTION:munki-enum
24 * @short_description: Types used by munki and libmunki
25 *
26 * These helper functions provide a way to marshal enumerated values to
27 * text and back again.
28 *
29 * See also: #CdClient, #CdDevice
30 */
31
32 #include "config.h"
33
34 #include <glib.h>
35
36 #include "munki-enum.h"
37
38 /**
39 * munki_command_value_to_string:
40 **/
41 const gchar *
42 munki_command_value_to_string (guint8 value)
43 {
44 if (value == MUNKI_COMMAND_DIAL_ROTATE)
45 return "dial-rotate";
46 if (value == MUNKI_COMMAND_BUTTON_PRESSED)
47 return "button-released";
48 if (value == MUNKI_COMMAND_BUTTON_RELEASED)
49 return "button-released";
50 return NULL;
51 }
52
53 /**
54 * munki_button_state_to_string:
55 **/
56 const gchar *
57 munki_button_state_to_string (guint8 value)
58 {
59 if (value == MUNKI_BUTTON_STATE_RELEASED)
60 return "released";
61 if (value == MUNKI_BUTTON_STATE_PRESSED)
62 return "pressed";
63 return NULL;
64 }
65
66 /**
67 * munki_dial_position_to_string:
68 **/
69 const gchar *
70 munki_dial_position_to_string (guint8 value)
71 {
72 if (value == MUNKI_DIAL_POSITION_PROJECTOR)
73 return "projector";
74 if (value == MUNKI_DIAL_POSITION_SURFACE)
75 return "surface";
76 if (value == MUNKI_DIAL_POSITION_CALIBRATION)
77 return "calibration";
78 if (value == MUNKI_DIAL_POSITION_AMBIENT)
79 return "ambient";
80 return NULL;
81 }
82
83 /**
84 * munki_endpoint_to_string:
85 **/
86 const gchar *
87 munki_endpoint_to_string (guint value)
88 {
89 if (value == MUNKI_EP_CONTROL)
90 return "control";
91 if (value == MUNKI_EP_DATA)
92 return "data";
93 if (value == MUNKI_EP_EVENT)
94 return "event";
95 return NULL;
96 }