19
20
#include "shared/report.h"
21
#include "drivers/lcd.h"
23
24
#include "clients.h"
24
#include "client_data.h"
25
25
#include "widget.h"
26
26
#include "screenlist.h"
27
27
#include "screen.h"
28
#include "menuscreens.h"
29
30
#include "render.h"
31
32
int default_duration = 0;
32
33
int default_timeout = -1;
46
screen_create (char * id, Client * client)
39
s = malloc (sizeof (screen));
50
debug( RPT_DEBUG, "%s( id=\"%.40s\", client=[%d] )", __FUNCTION__, id, (client?client->sock:-1));
52
s = malloc (sizeof (Screen));
41
report(RPT_ERR, "screen_create: Error allocating new screen");
54
report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
58
report (RPT_ERR, "%s: Need id string", __FUNCTION__);
61
/* Client can be NULL for serverscreens and other client-less screens */
65
report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
47
s->priority = DEFAULT_SCREEN_PRIORITY;
70
s->priority = PRI_INFO;
48
71
s->duration = default_duration;
49
s->heartbeat = DEFAULT_HEARTBEAT;
50
s->wid = lcd_ptr->wid;
51
s->hgt = lcd_ptr->hgt;
72
s->backlight = BACKLIGHT_OPEN;
73
s->heartbeat = HEARTBEAT_OPEN;
74
s->width = display_props->width;
75
s->height = display_props->height;
55
s->timeout = default_timeout; /*ignored unless greater than 0.*/
56
s->backlight_state = BACKLIGHT_NOTSET; /*Lets the screen do it's own*/
79
s->timeout = default_timeout; /*ignored unless greater than 0.*/
80
s->backlight = BACKLIGHT_OPEN; /*Lets the screen do it's own*/
57
81
/*or do what the client says.*/
82
s->cursor = CURSOR_OFF;
59
s->widgets = LL_new ();
61
report(RPT_ERR, "screen_create: Error allocating widget list");
86
s->widgetlist = LL_new ();
88
report(RPT_ERR, "%s: Error allocating", __FUNCTION__);
92
menuscreen_add_screen (s);
69
screen_destroy (screen * s)
98
screen_destroy (Screen * s)
76
LL_Rewind (s->widgets);
102
debug( RPT_DEBUG, "%s( s=[%.40s] )", __FUNCTION__, s->id );
104
menuscreen_remove_screen (s);
106
screenlist_remove (s);
108
for (w=LL_GetFirst(s->widgetlist); w; w=LL_GetNext(s->widgetlist)) {
78
109
/* Free a widget...*/
79
w = LL_Get (s->widgets);
80
110
widget_destroy (w);
81
} while (LL_Next (s->widgets) == 0);
82
LL_Destroy (s->widgets);
112
LL_Destroy (s->widgetlist);
97
screen_find (client * c, char *id)
125
screen_add_widget (Screen * s, Widget * w)
127
debug( RPT_DEBUG, "%s( s=[%.40s], widget=[%.40s] )", __FUNCTION__, s->id, w->id );
129
LL_Push (s->widgetlist, (void *) w);
135
screen_remove_widget (Screen * s, Widget * w)
137
debug( RPT_DEBUG, "%s( s=[%.40s], widget=[%.40s] )", __FUNCTION__, s->id, w->id );
139
LL_Remove (s->widgetlist, (void *) w);
145
screen_find_widget (Screen * s, char *id)
106
debug (RPT_INFO, "client_find_screen(%s)", id);
108
LL_Rewind (c->data->screenlist);
110
s = LL_Get (c->data->screenlist);
111
if ((s) && (0 == strcmp (s->id, id))) {
112
debug (RPT_DEBUG, "client_find_screen: Found %s", id);
115
} while (LL_Next (c->data->screenlist) == 0);
154
debug( RPT_DEBUG, "%s( s=[%.40s], id=\"%.40s\" )", __FUNCTION__, s->id, id );
156
for ( w=LL_GetFirst(s->widgetlist); w; w=LL_GetNext(s->widgetlist) ) {
157
if (0 == strcmp (w->id, id)) {
158
debug (RPT_DEBUG, "%s: Found %s", __FUNCTION__, id);
161
/* Search subscreens recursively */
162
if (w->type == WID_FRAME) {
163
w = widget_search_subs (w, id);
168
debug (RPT_DEBUG, "%s: Not found", __FUNCTION__);
121
screen_add (client * c, char *id)
173
screen_pri_name_to_pri (char * priname)
130
/* Make sure this screen doesn't already exist...*/
131
s = screen_find (c, id);
136
s = screen_create ();
138
report (RPT_ERR, "screen_add: Error creating screen");
146
report (RPT_ERR, "screen_add: Error allocating name");
149
/* TODO: Check for errors here?*/
150
LL_Push (c->data->screenlist, (void *) s);
152
/* Now, add it to the screenlist...*/
153
if (screenlist_add (s) < 0) {
154
report (RPT_ERR, "screen_add: Error queueing new screen");
175
Priority pri = WID_NONE;
178
for (i = 0; pri_names[i]; i++) {
179
if (strcmp (pri_names[i], priname) == 0) {
181
break; /* it's valid: skip out...*/
162
screen_remove (client * c, char *id)
188
screen_pri_to_pri_name (Priority pri)
171
/* Make sure this screen *does* exist...*/
172
s = screen_find (c, id);
174
report (RPT_ERR, "screen_remove: Error finding screen %s", id);
177
/* TODO: Check for errors here?*/
178
LL_Remove (c->data->screenlist, (void *) s);
180
/* Now, remove it from the screenlist...*/
181
if (screenlist_remove_all (s) < 0) {
182
/* Not a serious error..*/
183
report (RPT_ERR, "screen_remove: Error dequeueing screen");
187
/* TODO: Check for errors here too?*/
190
return pri_names[pri];