removed useless empty line
[psensor.git] / src / cfg.c
1 /*
2  * Copyright (C) 2010-2014 jeanfi@gmail.com
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19
20 #include <errno.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <string.h>
24 #include <ctype.h>
25 #include <sys/stat.h>
26 #include <sys/types.h>
27
28 #include <locale.h>
29 #include <libintl.h>
30 #define _(str) gettext(str)
31
32 #include <cfg.h>
33 #include <pio.h>
34 #include <plog.h>
35
36 static const char *ATT_SENSOR_ALARM_ENABLED = "alarm_enabled";
37 static const char *ATT_SENSOR_ALARM_HIGH_THRESHOLD = "alarm_high_threshold";
38 static const char *ATT_SENSOR_ALARM_LOW_THRESHOLD = "alarm_low_threshold";
39 static const char *ATT_SENSOR_COLOR = "color";
40 static const char *ATT_SENSOR_GRAPH_ENABLED = "graph_enabled";
41 static const char *ATT_SENSOR_NAME = "name";
42 static const char *ATT_SENSOR_APPINDICATOR_MENU_DISABLED
43 = "appindicator_menu_disabled";
44 static const char *ATT_SENSOR_APPINDICATOR_LABEL_ENABLED
45 = "appindicator_label_enabled";
46
47 static const char *ATT_SENSOR_POSITION = "position";
48
49 static const char *KEY_SENSOR_UPDATE_INTERVAL
50 = "/apps/psensor/sensor/update_interval";
51
52 static const char *KEY_GRAPH_UPDATE_INTERVAL
53 = "/apps/psensor/graph/update_interval";
54
55 static const char *KEY_GRAPH_MONITORING_DURATION
56 = "/apps/psensor/graph/monitoring_duration";
57
58 static const char *KEY_GRAPH_BACKGROUND_COLOR
59 = "/apps/psensor/graph/background_color";
60
61 static const char *DEFAULT_GRAPH_BACKGROUND_COLOR = "#e8f4e8f4a8f5";
62
63 static const char *KEY_GRAPH_BACKGROUND_ALPHA
64 = "/apps/psensor/graph/background_alpha";
65
66 static const char *KEY_GRAPH_FOREGROUND_COLOR
67 = "/apps/psensor/graph/foreground_color";
68 static const char *DEFAULT_GRAPH_FOREGROUND_COLOR = "#000000000000";
69
70 static const char *KEY_ALPHA_CHANNEL_ENABLED
71 = "/apps/psensor/graph/alpha_channel_enabled";
72
73 static const char *KEY_INTERFACE_SENSORLIST_POSITION
74 = "/apps/psensor/interface/sensorlist_position";
75
76 static const char *KEY_INTERFACE_WINDOW_DECORATION_DISABLED
77 = "/apps/psensor/interface/window_decoration_disabled";
78
79 static const char *KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED
80 = "/apps/psensor/interface/window_keep_below_enabled";
81
82 static const char *KEY_INTERFACE_MENU_BAR_DISABLED
83 = "/apps/psensor/interface/menu_bar_disabled";
84
85 static const char *KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED
86 = "/apps/psensor/interface/unity_launcher_count_disabled";
87
88 static const char *KEY_INTERFACE_HIDE_ON_STARTUP
89 = "/apps/psensor/interface/hide_on_startup";
90
91 static const char *KEY_INTERFACE_WINDOW_RESTORE_ENABLED
92 = "/apps/psensor/interface/window_restore_enabled";
93
94 static const char *KEY_INTERFACE_WINDOW_X = "/apps/psensor/interface/window_x";
95 static const char *KEY_INTERFACE_WINDOW_Y = "/apps/psensor/interface/window_y";
96 static const char *KEY_INTERFACE_WINDOW_W = "/apps/psensor/interface/window_w";
97 static const char *KEY_INTERFACE_WINDOW_H = "/apps/psensor/interface/window_h";
98
99 static const char *KEY_INTERFACE_WINDOW_DIVIDER_POS
100 = "/apps/psensor/interface/window_divider_pos";
101
102 static const char *KEY_INTERFACE_TEMPERATURE_UNIT
103 = "/apps/psensor/interface/temperature_unit";
104
105 static const char *KEY_SLOG_ENABLED = "/apps/psensor/slog/enabled";
106 static const char *KEY_SLOG_INTERVAL = "/apps/psensor/slog/interval";
107
108 static const char *KEY_NOTIFICATION_SCRIPT = "/apps/psensor/notif_script";
109
110 static GConfClient *client;
111
112 static char *user_dir;
113
114 static GKeyFile *key_file;
115
116 static char *sensor_config_path;
117
118 static char *get_string(const char *key, const char *default_value)
119 {
120         char *value;
121
122         value = gconf_client_get_string(client, key, NULL);
123
124         if (!value) {
125                 value = strdup(default_value);
126                 gconf_client_set_string(client, key, default_value, NULL);
127         }
128
129         return value;
130 }
131
132 char *config_get_notif_script()
133 {
134         char *str;
135
136         str =  gconf_client_get_string(client, KEY_NOTIFICATION_SCRIPT, NULL);
137         if (str && !strlen(str)) {
138                 free(str);
139                 str = NULL;
140         }
141
142         return str;
143 }
144
145 void config_set_notif_script(const char *str)
146 {
147         if (str && strlen(str) > 0)
148                 gconf_client_set_string(client,
149                                         KEY_NOTIFICATION_SCRIPT, str, NULL);
150         else
151                 gconf_client_set_string(client,
152                                         KEY_NOTIFICATION_SCRIPT, "", NULL);
153 }
154
155 static struct color *get_background_color()
156 {
157         char *scolor;
158         struct color *c;
159
160         scolor = get_string(KEY_GRAPH_BACKGROUND_COLOR,
161                             DEFAULT_GRAPH_BACKGROUND_COLOR);
162
163         c = str_to_color(scolor);
164         free(scolor);
165
166         if (!c)
167                 return color_new(0xffff, 0xffff, 0xffff);
168
169         return c;
170 }
171
172 static struct color *get_foreground_color()
173 {
174         char *scolor;
175         struct color *c;
176
177         scolor = get_string(KEY_GRAPH_FOREGROUND_COLOR,
178                             DEFAULT_GRAPH_FOREGROUND_COLOR);
179
180         c = str_to_color(scolor);
181         free(scolor);
182
183         if (!c)
184                 return color_new(0x0000, 0x0000, 0x0000);
185
186         return c;
187 }
188
189 static bool is_alpha_channel_enabled()
190 {
191         return gconf_client_get_bool(client, KEY_ALPHA_CHANNEL_ENABLED, NULL);
192 }
193
194 static enum sensorlist_position get_sensorlist_position()
195 {
196         return gconf_client_get_int(client,
197                                     KEY_INTERFACE_SENSORLIST_POSITION, NULL);
198 }
199
200 static void set_sensorlist_position(enum sensorlist_position pos)
201 {
202         gconf_client_set_int(client,
203                              KEY_INTERFACE_SENSORLIST_POSITION, pos, NULL);
204 }
205
206 static double get_graph_background_alpha()
207 {
208         double a;
209
210         a = gconf_client_get_float(client, KEY_GRAPH_BACKGROUND_ALPHA, NULL);
211         if (a == 0)
212                 gconf_client_set_float(client,
213                                        KEY_GRAPH_BACKGROUND_ALPHA, 1.0, NULL);
214         return a;
215 }
216
217 static void set_graph_background_alpha(double alpha)
218 {
219         gconf_client_set_float(client, KEY_GRAPH_BACKGROUND_ALPHA, alpha, NULL);
220 }
221
222 static void set_background_color(const struct color *color)
223 {
224         char *scolor;
225
226         scolor = color_to_str(color);
227         if (!scolor)
228                 scolor = strdup(DEFAULT_GRAPH_BACKGROUND_COLOR);
229
230         gconf_client_set_string(client,
231                                 KEY_GRAPH_BACKGROUND_COLOR, scolor, NULL);
232
233         free(scolor);
234 }
235
236 static void set_foreground_color(const struct color *color)
237 {
238         char *str;
239
240         str = color_to_str(color);
241         if (!str)
242                 str = strdup(DEFAULT_GRAPH_FOREGROUND_COLOR);
243
244         gconf_client_set_string(client, KEY_GRAPH_FOREGROUND_COLOR, str, NULL);
245
246         free(str);
247 }
248
249 bool is_slog_enabled()
250 {
251         return gconf_client_get_bool(client, KEY_SLOG_ENABLED, NULL);
252 }
253
254 static void set_slog_enabled(bool enabled)
255 {
256         gconf_client_set_bool(client, KEY_SLOG_ENABLED, enabled, NULL);
257 }
258
259 void config_slog_enabled_notify_add(GConfClientNotifyFunc cbk, void *data)
260 {
261         log_debug("config_slog_enabled_notify_add");
262         gconf_client_add_dir(client,
263                              KEY_SLOG_ENABLED,
264                              GCONF_CLIENT_PRELOAD_NONE,
265                              NULL);
266         gconf_client_notify_add(client,
267                                 KEY_SLOG_ENABLED,
268                                 cbk,
269                                 data,
270                                 NULL,
271                                 NULL);
272 }
273
274 int config_get_slog_interval()
275 {
276         int res;
277
278         res = gconf_client_get_int(client, KEY_SLOG_INTERVAL, NULL);
279
280         if (res <= 0)
281                 return 300;
282         else
283                 return res;
284 }
285
286 static void set_slog_interval(int interval)
287 {
288         if (interval <= 0)
289                 interval = 300;
290
291         gconf_client_set_int(client, KEY_SLOG_INTERVAL, interval, NULL);
292 }
293
294 static bool is_window_decoration_enabled()
295 {
296         return !gconf_client_get_bool(client,
297                                       KEY_INTERFACE_WINDOW_DECORATION_DISABLED,
298                                       NULL);
299 }
300
301 static bool is_window_keep_below_enabled()
302 {
303         return gconf_client_get_bool(client,
304                                      KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED,
305                                      NULL);
306 }
307
308 static void set_window_decoration_enabled(bool enabled)
309 {
310         gconf_client_set_bool
311                 (client,
312                  KEY_INTERFACE_WINDOW_DECORATION_DISABLED, !enabled, NULL);
313 }
314
315 static void set_window_keep_below_enabled(bool enabled)
316 {
317         gconf_client_set_bool(client,
318                               KEY_INTERFACE_WINDOW_KEEP_BELOW_ENABLED,
319                               enabled, NULL);
320 }
321
322 /*
323  * Initializes the GConf client.
324  */
325 static void init()
326 {
327         if (!client)
328                 client = gconf_client_get_default();
329 }
330
331 void config_cleanup()
332 {
333         if (client) {
334                 g_object_unref(client);
335                 client = NULL;
336         }
337
338         config_sync();
339
340         if (user_dir) {
341                 free(user_dir);
342                 user_dir = NULL;
343         }
344
345         if (key_file) {
346                 g_key_file_free(key_file);
347                 key_file = NULL;
348         }
349
350         if (sensor_config_path) {
351                 free(sensor_config_path);
352                 sensor_config_path = NULL;
353         }
354 }
355
356 struct config *config_load()
357 {
358         struct config *c;
359
360         init();
361
362         c = malloc(sizeof(struct config));
363
364         c->graph_bgcolor = get_background_color();
365         c->graph_fgcolor = get_foreground_color();
366         c->graph_bg_alpha = get_graph_background_alpha();
367         c->alpha_channel_enabled = is_alpha_channel_enabled();
368         c->sensorlist_position = get_sensorlist_position();
369         c->window_decoration_enabled = is_window_decoration_enabled();
370         c->window_keep_below_enabled = is_window_keep_below_enabled();
371         c->slog_enabled = is_slog_enabled();
372         c->slog_interval = config_get_slog_interval();
373
374         c->sensor_update_interval
375             = gconf_client_get_int(client, KEY_SENSOR_UPDATE_INTERVAL, NULL);
376         if (c->sensor_update_interval < 1)
377                 c->sensor_update_interval = 1;
378
379         c->graph_update_interval
380             = gconf_client_get_int(client, KEY_GRAPH_UPDATE_INTERVAL, NULL);
381         if (c->graph_update_interval < 1)
382                 c->graph_update_interval = 1;
383
384         c->graph_monitoring_duration
385             = gconf_client_get_int(client, KEY_GRAPH_MONITORING_DURATION, NULL);
386
387         if (c->graph_monitoring_duration < 1)
388                 c->graph_monitoring_duration = 10;
389
390         c->sensor_values_max_length
391             =
392             (c->graph_monitoring_duration * 60) / c->sensor_update_interval;
393         if (c->sensor_values_max_length < 3)
394                 c->sensor_values_max_length = 3;
395
396         c->menu_bar_disabled
397                 = gconf_client_get_bool(client,
398                                         KEY_INTERFACE_MENU_BAR_DISABLED,
399                                         NULL);
400
401         c->unity_launcher_count_disabled
402                 = gconf_client_get_bool
403                 (client,
404                  KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED,
405                  NULL);
406
407         c->hide_on_startup
408                 = gconf_client_get_bool(client,
409                                         KEY_INTERFACE_HIDE_ON_STARTUP,
410                                         NULL);
411
412         c->window_restore_enabled
413                 = gconf_client_get_bool(client,
414                                         KEY_INTERFACE_WINDOW_RESTORE_ENABLED,
415                                         NULL);
416
417         c->window_x = gconf_client_get_int(client,
418                                            KEY_INTERFACE_WINDOW_X,
419                                            NULL);
420         c->window_y = gconf_client_get_int(client,
421                                            KEY_INTERFACE_WINDOW_Y,
422                                            NULL);
423         c->window_w = gconf_client_get_int(client,
424                                            KEY_INTERFACE_WINDOW_W,
425                                            NULL);
426         c->window_h = gconf_client_get_int(client,
427                                            KEY_INTERFACE_WINDOW_H,
428                                            NULL);
429         c->window_divider_pos
430                 = gconf_client_get_int(client,
431                                        KEY_INTERFACE_WINDOW_DIVIDER_POS,
432                                        NULL);
433
434         if (!c->window_restore_enabled || !c->window_w || !c->window_h) {
435                 c->window_w = 800;
436                 c->window_h = 200;
437         }
438
439         c->temperature_unit = gconf_client_get_int
440                 (client, KEY_INTERFACE_TEMPERATURE_UNIT, NULL);
441
442         return c;
443 }
444
445 void config_save(const struct config *c)
446 {
447         set_background_color(c->graph_bgcolor);
448         set_foreground_color(c->graph_fgcolor);
449         set_graph_background_alpha(c->graph_bg_alpha);
450         set_sensorlist_position(c->sensorlist_position);
451         set_window_decoration_enabled(c->window_decoration_enabled);
452         set_window_keep_below_enabled(c->window_keep_below_enabled);
453         set_slog_enabled(c->slog_enabled);
454         set_slog_interval(c->slog_interval);
455
456         gconf_client_set_int(client,
457                              KEY_GRAPH_UPDATE_INTERVAL,
458                              c->graph_update_interval, NULL);
459
460         gconf_client_set_int(client,
461                              KEY_GRAPH_MONITORING_DURATION,
462                              c->graph_monitoring_duration, NULL);
463
464         gconf_client_set_int(client,
465                              KEY_SENSOR_UPDATE_INTERVAL,
466                              c->sensor_update_interval, NULL);
467
468         gconf_client_set_bool(client,
469                               KEY_INTERFACE_MENU_BAR_DISABLED,
470                               c->menu_bar_disabled, NULL);
471
472         gconf_client_set_bool(client,
473                               KEY_INTERFACE_UNITY_LAUNCHER_COUNT_DISABLED,
474                               c->unity_launcher_count_disabled, NULL);
475
476         gconf_client_set_bool(client,
477                               KEY_INTERFACE_HIDE_ON_STARTUP,
478                               c->hide_on_startup, NULL);
479
480         gconf_client_set_bool(client,
481                               KEY_INTERFACE_WINDOW_RESTORE_ENABLED,
482                               c->window_restore_enabled,
483                               NULL);
484
485         gconf_client_set_int(client, KEY_INTERFACE_WINDOW_X, c->window_x, NULL);
486         gconf_client_set_int(client, KEY_INTERFACE_WINDOW_Y, c->window_y, NULL);
487         gconf_client_set_int(client, KEY_INTERFACE_WINDOW_W, c->window_w, NULL);
488         gconf_client_set_int(client, KEY_INTERFACE_WINDOW_H, c->window_h, NULL);
489
490         gconf_client_set_int(client,
491                              KEY_INTERFACE_WINDOW_DIVIDER_POS,
492                              c->window_divider_pos,
493                              NULL);
494
495         gconf_client_set_int(client,
496                              KEY_INTERFACE_TEMPERATURE_UNIT,
497                              c->temperature_unit,
498                              NULL);
499 }
500
501 const char *get_psensor_user_dir()
502 {
503         const char *home;
504
505         log_fct_enter();
506
507         if (!user_dir) {
508                 home = getenv("HOME");
509
510                 if (!home)
511                         return NULL;
512
513                 user_dir = path_append(home, ".psensor");
514
515                 if (mkdir(user_dir, 0700) == -1 && errno != EEXIST) {
516                         log_err(_("Failed to create the directory %s: %s"),
517                                 user_dir,
518                                 strerror(errno));
519
520                         free(user_dir);
521                         user_dir = NULL;
522                 }
523         }
524
525         log_fct_exit();
526
527         return user_dir;
528 }
529
530 static const char *get_sensor_config_path()
531 {
532         const char *dir;
533
534         if (!sensor_config_path) {
535                 dir = get_psensor_user_dir();
536
537                 if (dir)
538                         sensor_config_path = path_append(dir, "psensor.cfg");
539         }
540
541         return sensor_config_path;
542 }
543
544 static GKeyFile *get_sensor_key_file()
545 {
546         int ret;
547         GError *err;
548         const char *path;
549
550         if (!key_file) {
551                 path = get_sensor_config_path();
552
553                 key_file = g_key_file_new();
554
555                 err = NULL;
556                 ret = g_key_file_load_from_file(key_file,
557                                                 path,
558                                                 G_KEY_FILE_KEEP_COMMENTS
559                                                 | G_KEY_FILE_KEEP_TRANSLATIONS,
560                                                 &err);
561
562                 if (!ret) {
563                         if (err->code == G_KEY_FILE_ERROR_NOT_FOUND) {
564                                 log_fct(_("The configuration file "
565                                           "does not exist."));
566                         } else {
567                                 log_err(_("Failed to parse configuration "
568                                           "file: %s"),
569                                         path);
570                         }
571                 }
572         }
573
574         return key_file;
575 }
576
577 static void save_sensor_key_file()
578 {
579         GKeyFile *kfile;
580         const char *path;
581         char *data;
582
583         log_fct_enter();
584
585         kfile = get_sensor_key_file();
586
587         data = g_key_file_to_data(kfile, NULL, NULL);
588
589         path = get_sensor_config_path();
590
591         if (!g_file_set_contents(path, data, -1, NULL))
592                 log_err(_("Failed to save configuration file %s."), path);
593
594         free(data);
595
596         log_fct_exit();
597 }
598
599 void config_sync()
600 {
601         log_fct_enter();
602         save_sensor_key_file();
603         log_fct_exit();
604 }
605
606 static void
607 config_sensor_set_string(const char *sid, const char *att, const char *str)
608 {
609         GKeyFile *kfile;
610
611         kfile = get_sensor_key_file();
612         g_key_file_set_string(kfile, sid, att, str);
613 }
614
615 static char *config_sensor_get_string(const char *sid, const char *att)
616 {
617         GKeyFile *kfile;
618
619         kfile = get_sensor_key_file();
620         return g_key_file_get_string(kfile, sid, att, NULL);
621 }
622
623 static bool config_sensor_get_bool(const char *sid, const char *att)
624 {
625
626         GKeyFile *kfile;
627
628         kfile = get_sensor_key_file();
629         return g_key_file_get_boolean(kfile, sid, att, NULL);
630 }
631
632 static void
633 config_sensor_set_bool(const char *sid, const char *att, bool enabled)
634 {
635         GKeyFile *kfile;
636
637         kfile = get_sensor_key_file();
638
639         g_key_file_set_boolean(kfile, sid, att, enabled);
640 }
641
642 static int config_sensor_get_int(const char *sid, const char *att)
643 {
644
645         GKeyFile *kfile;
646
647         kfile = get_sensor_key_file();
648         return g_key_file_get_integer(kfile, sid, att, NULL);
649 }
650
651 static void
652 config_sensor_set_int(const char *sid, const char *att, int i)
653 {
654         GKeyFile *kfile;
655
656         kfile = get_sensor_key_file();
657
658         g_key_file_set_integer(kfile, sid, att, i);
659 }
660
661 char *config_get_sensor_name(const char *sid)
662 {
663         return config_sensor_get_string(sid, ATT_SENSOR_NAME);
664 }
665
666 void config_set_sensor_name(const char *sid, const char *name)
667 {
668         config_sensor_set_string(sid, ATT_SENSOR_NAME, name);
669 }
670
671 void config_set_sensor_color(const char *sid, const struct color *color)
672 {
673         char *scolor;
674
675         scolor = color_to_str(color);
676
677         config_sensor_set_string(sid, ATT_SENSOR_COLOR, scolor);
678
679         free(scolor);
680 }
681
682 struct color *
683 config_get_sensor_color(const char *sid, const struct color *dft)
684 {
685         char *scolor;
686         struct color *color;
687
688         scolor = config_sensor_get_string(sid, ATT_SENSOR_COLOR);
689
690         if (scolor)
691                 color = str_to_color(scolor);
692         else
693                 color = NULL;
694
695         if (!color) {
696                 color = color_new(dft->red, dft->green, dft->blue);
697                 config_set_sensor_color(sid, color);
698         }
699
700         free(scolor);
701
702         return color;
703 }
704
705 bool config_is_sensor_enabled(const char *sid)
706 {
707         return config_sensor_get_bool(sid, ATT_SENSOR_GRAPH_ENABLED);
708 }
709
710 void config_set_sensor_enabled(const char *sid, bool enabled)
711 {
712         config_sensor_set_bool(sid, ATT_SENSOR_GRAPH_ENABLED, enabled);
713 }
714
715 int config_get_sensor_alarm_high_threshold(const char *sid)
716 {
717         return config_sensor_get_int(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD);
718 }
719
720 void config_set_sensor_alarm_high_threshold(const char *sid, int threshold)
721 {
722         config_sensor_set_int(sid, ATT_SENSOR_ALARM_HIGH_THRESHOLD, threshold);
723 }
724
725 int config_get_sensor_alarm_low_threshold(const char *sid)
726 {
727         return config_sensor_get_int(sid, ATT_SENSOR_ALARM_LOW_THRESHOLD);
728 }
729
730 void config_set_sensor_alarm_low_threshold(const char *sid, int threshold)
731 {
732         config_sensor_set_int(sid, ATT_SENSOR_ALARM_LOW_THRESHOLD, threshold);
733 }
734
735 bool config_is_appindicator_enabled(const char *sid)
736 {
737         return !config_sensor_get_bool(sid,
738                                        ATT_SENSOR_APPINDICATOR_MENU_DISABLED);
739 }
740
741 void config_set_appindicator_enabled(const char *sid, bool enabled)
742 {
743         return config_sensor_set_bool(sid,
744                                       ATT_SENSOR_APPINDICATOR_MENU_DISABLED,
745                                       !enabled);
746 }
747
748 int config_get_sensor_position(const char *sid)
749 {
750         return config_sensor_get_int(sid, ATT_SENSOR_POSITION);
751 }
752
753 void config_set_sensor_position(const char *sid, int pos)
754 {
755         return config_sensor_set_int(sid, ATT_SENSOR_POSITION, pos);
756 }
757
758 bool config_get_sensor_alarm_enabled(const char *sid)
759 {
760         return config_sensor_get_bool(sid, ATT_SENSOR_ALARM_ENABLED);
761 }
762
763 void config_set_sensor_alarm_enabled(const char *sid, bool enabled)
764 {
765         config_sensor_set_bool(sid, ATT_SENSOR_ALARM_ENABLED, enabled);
766 }
767
768 bool config_is_appindicator_label_enabled(const char *sid)
769 {
770         return config_sensor_get_bool(sid,
771                                       ATT_SENSOR_APPINDICATOR_LABEL_ENABLED);
772 }
773
774 void config_set_appindicator_label_enabled(const char *sid, bool enabled)
775 {
776         config_sensor_set_bool(sid,
777                                ATT_SENSOR_APPINDICATOR_LABEL_ENABLED,
778                                enabled);
779 }