forked from mer-hybris/mce-plugin-libhybris
-
Notifications
You must be signed in to change notification settings - Fork 2
/
plugin-config.h
124 lines (101 loc) · 3.42 KB
/
plugin-config.h
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
/** @file plugin-config.h
*
* mce-plugin-libhybris - Libhybris plugin for Mode Control Entity
* <p>
* Copyright (c) 2017 Jolla Ltd.
* Copyright (c) 2024 Jollyboys Ltd.
* <p>
* @author Simo Piiroinen <[email protected]>
*
* mce-plugin-libhybris is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
*
* mce-plugin-libhybris 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with mce-plugin-libhybris; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef PLUGIN_CONFIG_H_
# define PLUGIN_CONFIG_H_
# include "plugin-logging.h"
# include <stdbool.h>
# include <glib.h>
/* ========================================================================= *
* CONFIG
* ========================================================================= */
/** Configuration group for mce-plugin-libhybris related values */
#define MCE_CONF_LED_CONFIG_HYBRIS_GROUP "LEDConfigHybris"
/** Name of the LED backend to use */
#define MCE_CONF_LED_CONFIG_HYBRIS_BACKEND "BackEnd"
/** Optional enable/disable sw breathing setting */
#define MCE_CONF_LED_CONFIG_HYBRIS_BREATHING_ENABLED "QuirkBreathing"
/** Optional sw breathing type setting */
#define MCE_CONF_LED_CONFIG_HYBRIS_BREATHING_TYPE "QuirkBreathingType"
gchar * plugin_config_get_string(const gchar *group, const gchar *key, const gchar *defaultval);
typedef enum
{
/** Item is not valid / is a sentinel */
CONFTYPE_NONE,
/** Item is a file path */
CONFTYPE_FILE,
/** Item is a standalone string value */
CONFTYPE_STRING,
} conftype_t;
/** Inifile to object member mapping info */
typedef struct
{
/** Type of configuration value */
conftype_t type;
/** Ini-file key */
const char *key;
/** Fallback value in case key is not defined */
const char *def;
/** Offset within object where to store string value */
off_t off;
} objconf_t;
/** Object configuration entry sentinel */
#define OBJCONF_STOP \
{\
.type = CONFTYPE_NONE,\
}
/** Object configuration entry for standalone string value
*/
#define OBJCONF_STRING(obj_,memb_,key_,def_)\
{\
.type = CONFTYPE_STRING,\
.key = #key_,\
.def = def_,\
.off = offsetof(obj_,memb_),\
}
/** Object configuration entry for file path
*
* For object->member matches /sys/dir/member
*/
#define OBJCONF_FILE(obj_,memb_,key_)\
{\
.type = CONFTYPE_FILE,\
.key = #key_,\
.def = #memb_,\
.off = offsetof(obj_,memb_),\
}
/** Object configuration entry for file path
*
* For object->member does not match /sys/dir/member
*/
#define OBJCONF_FILE_EX(obj_,memb_,key_,def_)\
{\
.type = CONFTYPE_FILE,\
.key = #key_,\
.def = def_,\
.off = offsetof(obj_,memb_),\
}
void objconf_init(const objconf_t *cfg, void *obj);
void objconf_quit(const objconf_t *cfg, void *obj);
bool objconf_parse(const objconf_t *cfg, void *obj, const char *chn);
#endif /* PLUGIN_CONFIG_H_ */