Base: LCDproc 0.5.2
[lcdproc-de200c.git] / contrib / patches / lcdprocserverOPT.diff
blobd28740026ad29e5e78a15883ae45305e03c891e7
1 diff -ruNp lcdproc-0.5.1-orig/server/drivers/CFontz633.c lcdproc-0.5.1-working/server/drivers/CFontz633.c
2 --- lcdproc-0.5.1-orig/server/drivers/CFontz633.c 2006-10-06 03:02:47.000000000 -0400
3 +++ lcdproc-0.5.1-working/server/drivers/CFontz633.c 2007-02-23 11:55:05.000000000 -0500
4 @@ -124,6 +124,9 @@ static void CFontz633_hidecursor (Driver
5 static void CFontz633_reboot (Driver *drvthis);
6 static void CFontz633_no_live_report (Driver *drvthis);
7 static void CFontz633_hardware_clear (Driver *drvthis);
8 +#ifndef OPT //store boot screen
9 +static void CFontz633_store_boot_state (Driver *drvthis);
10 +#endif //OPT
13 /**
14 @@ -303,6 +306,19 @@ CFontz633_init (Driver *drvthis)
15 CFontz633_no_live_report(drvthis);
16 CFontz633_hardware_clear(drvthis);
18 +#ifndef OPT //store boot screen
19 + /* get and store the power on boot line, repurposing the "size" buffer */
20 + strncpy(size, drvthis->config_get_string (drvthis->name, "BootDisplay", 0, "" ), sizeof(size));
21 + if ( size[0] ) {
22 + CFontz633_string (drvthis, 1, 1, size);
23 + if ( strlen(size) > p->width ) {
24 + CFontz633_string (drvthis, 1, 2, size + p->width);
25 + }
26 + CFontz633_flush (drvthis);
27 + CFontz633_store_boot_state (drvthis);
28 + }
29 +#endif //OPT
31 report(RPT_DEBUG, "%s: init() done", drvthis->name);
33 return 0;
34 @@ -1077,3 +1093,15 @@ CFontz633_string (Driver *drvthis, int x
38 +#ifndef OPT //store boot screen
39 +/*
40 + * Saves current state as boot state
41 + */
42 +static void
43 +CFontz633_store_boot_state (Driver *drvthis)
45 + PrivateData *p = drvthis->private_data;
47 + send_zerobyte_message(p->fd, CF633_Store_Current_State_As_Boot_State);
49 +#endif //OPT
50 diff -ruNp lcdproc-0.5.1-orig/server/menuscreens.c lcdproc-0.5.1-working/server/menuscreens.c
51 --- lcdproc-0.5.1-orig/server/menuscreens.c 2006-10-06 03:02:47.000000000 -0400
52 +++ lcdproc-0.5.1-working/server/menuscreens.c 2007-02-26 11:57:39.000000000 -0500
53 @@ -48,6 +48,10 @@ char * down_key;
54 char *left_key;
55 char *right_key;
57 +#ifndef OPT
58 +char * menuname; /* the name for the default menu */
59 +char * menuentryname; /* the name for the default menu's entry */
60 +#endif //OPT
61 Screen *menuscreen = NULL;
62 MenuItem *active_menuitem = NULL;
63 /** the "real" main_menu */
64 @@ -91,6 +95,11 @@ int menuscreens_init()
65 if (tmp)
66 right_key = strdup(tmp);
68 +#ifndef OPT //get main menu name and hybrid keys from config file
69 + /* Get main menu name from config file */
70 + menuname = strdup (config_get_string ("menu", "menuname", 0, "LCDproc Menu"));
71 + menuentryname = strdup (config_get_string ("menu", "menuentryname", 0, "Options"));
72 +#endif //OPT
74 /* Now reserve keys */
75 input_reserve_key(menu_key, true, NULL);
76 @@ -387,7 +396,13 @@ void menuscreen_key_handler (const char
77 /* Is the menu already active ? */
78 if (!active_menuitem) {
79 debug(RPT_DEBUG, "%s: Activating menu screen", __FUNCTION__);
80 - menuscreen_switch_item(menuscreen_get_main());
81 + Menu *main = menuscreen_get_main();
82 + /* Don't display an empty menu */
83 + if (!main || !LL_Get(main->data.menu.contents)) {
84 + debug (RPT_DEBUG, "%s: Ignoring empty menu", __FUNCTION__);
85 + return;
86 + }
87 + menuscreen_switch_item(main);
88 return;
91 @@ -437,55 +452,62 @@ void menuscreen_create_menu ()
93 debug(RPT_DEBUG, "%s()", __FUNCTION__);
95 +#ifndef OPT //main menu name from config file
96 + main_menu = menu_create ("mainmenu", NULL, menuname, NULL);
97 +#else //OPT
98 main_menu = menu_create("mainmenu", NULL, "LCDproc Menu", NULL);
99 +#endif //OPT
101 - options_menu = menu_create("options", NULL, "Options", NULL);
102 - menu_add_item(main_menu, options_menu);
104 -#ifdef LCDPROC_TESTMENUS
105 - screens_menu = menu_create("screens", NULL, "Screens", NULL);
106 - menu_add_item(main_menu, screens_menu);
107 -#endif /*LCDPROC_TESTMENUS*/
109 - /* menu's client is NULL since we're in the server */
110 - checkbox = menuitem_create_checkbox("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat);
111 - menu_add_item(options_menu, checkbox);
113 - /* menu's client is NULL since we're in the server */
114 - checkbox = menuitem_create_checkbox("backlight", backlight_handler, "Backlight", NULL, true, backlight);
115 - menu_add_item(options_menu, checkbox);
117 - for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) {
118 - int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0;
119 - int brightness_avail = (driver->get_brightness && driver->set_brightness) ? 1 : 0;
121 - if (contrast_avail || brightness_avail) {
122 - /* menu's client is NULL since we're in the server */
123 - driver_menu = menu_create(driver->name, NULL, driver->name, NULL);
124 - menu_set_association(driver_menu, driver);
125 - menu_add_item(options_menu, driver_menu);
126 - if (contrast_avail) {
127 - int contrast = driver->get_contrast(driver);
128 +#ifndef OPT
129 + if (config_get_bool("server", "LCDOptionsMenu", 0, 0)) {
130 + options_menu = menu_create("options", NULL, menuentryname, NULL);
131 + menu_add_item(main_menu, options_menu);
133 + /* menu's client is NULL since we're in the server */
134 + checkbox = menuitem_create_checkbox("heartbeat", heartbeat_handler, "Heartbeat", NULL, true, heartbeat);
135 + menu_add_item(options_menu, checkbox);
137 + /* menu's client is NULL since we're in the server */
138 + checkbox = menuitem_create_checkbox("backlight", backlight_handler, "Backlight", NULL, true, backlight);
139 + menu_add_item(options_menu, checkbox);
141 + for (driver = drivers_getfirst(); driver; driver = drivers_getnext()) {
142 + int contrast_avail = (driver->get_contrast && driver->set_contrast) ? 1 : 0;
143 + int brightness_avail = (driver->get_brightness && driver->set_brightness) ? 1 : 0;
145 + if (contrast_avail || brightness_avail) {
146 /* menu's client is NULL since we're in the server */
147 - slider = menuitem_create_slider("contrast", contrast_handler, "Contrast",
148 - NULL, "min", "max", 0, 1000, 25, contrast);
149 - menu_add_item(driver_menu, slider);
151 - if (brightness_avail) {
152 - int onbrightness = driver->get_brightness(driver, BACKLIGHT_ON);
153 - int offbrightness = driver->get_brightness(driver, BACKLIGHT_OFF);
155 - slider = menuitem_create_slider("onbrightness", brightness_handler, "On Brightness",
156 - NULL, "min", "max", 0, 1000, 25, onbrightness);
157 - menu_add_item(driver_menu, slider);
159 - slider = menuitem_create_slider("offbrightness", brightness_handler, "Off Brightness",
160 - NULL, "min", "max", 0, 1000, 25, offbrightness);
161 - menu_add_item(driver_menu, slider);
162 + driver_menu = menu_create(driver->name, NULL, driver->name, NULL);
163 + menu_set_association(driver_menu, driver);
164 + menu_add_item(options_menu, driver_menu);
165 + if (contrast_avail) {
166 + int contrast = driver->get_contrast(driver);
168 + /* menu's client is NULL since we're in the server */
169 + slider = menuitem_create_slider("contrast", contrast_handler, "Contrast",
170 + NULL, "min", "max", 0, 1000, 25, contrast);
171 + menu_add_item(driver_menu, slider);
173 + if (brightness_avail) {
174 + int onbrightness = driver->get_brightness(driver, BACKLIGHT_ON);
175 + int offbrightness = driver->get_brightness(driver, BACKLIGHT_OFF);
177 + slider = menuitem_create_slider("onbrightness", brightness_handler, "On Brightness",
178 + NULL, "min", "max", 0, 1000, 25, onbrightness);
179 + menu_add_item(driver_menu, slider);
181 + slider = menuitem_create_slider("offbrightness", brightness_handler, "Off Brightness",
182 + NULL, "min", "max", 0, 1000, 25, offbrightness);
183 + menu_add_item(driver_menu, slider);
188 + if (config_get_bool("server", "LCDScreensMenu", 0, 0)) {
189 + screens_menu = menu_create("screens", NULL, "Screens", NULL);
190 + menu_add_item(main_menu, screens_menu);
192 +#endif //OPT
194 #ifdef LCDPROC_TESTMENUS
195 test_menu = menu_create("test", NULL, "Test menu", NULL);
196 diff -ruNp lcdproc-0.5.1-orig/server/serverscreens.c lcdproc-0.5.1-working/server/serverscreens.c
197 --- lcdproc-0.5.1-orig/server/serverscreens.c 2006-10-06 03:02:47.000000000 -0400
198 +++ lcdproc-0.5.1-working/server/serverscreens.c 2007-02-23 11:48:56.000000000 -0500
199 @@ -33,6 +33,12 @@
200 #include "main.h"
201 #include "serverscreens.h"
203 +#ifndef OPT //startup screen title from config
204 +#include "shared/configfile.h"
206 +char * title;
207 +#endif //OPT
209 #define UNSET_INT -1
211 #define MAX_SERVERSCREEN_WIDTH 40
212 @@ -50,6 +56,11 @@
214 debug(RPT_DEBUG, "server_screen_init");
216 +#ifndef OPT //startup screen title from config
217 + /* Get server title name from config file */
218 + title = strdup(config_get_string("server", "title", 0, "LCDproc Server"));
219 +#endif //OPT
221 /* Create the screen */
222 server_screen = screen_create("_server_screen", NULL);
223 if (!server_screen) {
224 @@ -81,7 +92,11 @@
225 w->text = malloc(MAX_SERVERSCREEN_WIDTH+1);
226 if (line == 1) {
227 w->type = WID_TITLE;
228 +#ifndef OPT //startup screen titel from config
229 + strncpy(w->text, title, MAX_SERVERSCREEN_WIDTH);
230 +#else //OPT
231 strncpy(w->text, "LCDproc Server", MAX_SERVERSCREEN_WIDTH);
232 +#endif //OPT
233 } else {
234 w->text[0] = '\0';