2 * The main menu and other things
4 * Copyright (c) 1996-2021 by the citadel.org team
6 * This program is open source software. We call it open source, not
7 * free software, because Richard Stallman is a communist and an asshole.
9 * The program is licensed under the General Public License, version 3.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
20 void display_main_menu(void) {
22 output_headers(1, 0, 0, 0, 1, 0);
23 DoTemplate(HKEY("display_main_menu"), NULL, &NoCtx);
28 // System administration menu
29 void display_aide_menu(void) {
31 output_headers(1, 0, 0, 0, 1, 0);
32 DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
37 // Handle generic server commands, possibly entered from a screen, possibly set up as a way to avoid custom code
38 void do_generic(void) {
39 WCTemplputParams SubTP;
46 if (!havebstr("sc_button")) {
52 serv_puts(bstr("g_cmd"));
53 StrBuf_ServGetln(Buf);
55 switch (GetServerStatus(Buf, NULL)) {
58 if ( (StrLength(Buf)==3) &&
59 !strcmp(ChrPtr(Buf), "000")) {
60 StrBufAppendBufPlain(Buf, HKEY("\000"), 0);
64 LineBuf = NewStrBuf();
65 StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
67 if (StrBuf_ServGetln(LineBuf) < 0)
69 if ( (StrLength(LineBuf)==3) &&
70 !strcmp(ChrPtr(LineBuf), "000")) {
73 StrBufAppendBuf(Buf, LineBuf, 0);
74 StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
81 text_to_server(bstr("g_input"));
85 len = atol(&ChrPtr(Buf)[4]);
86 StrBuf_ServGetBLOBBuffered(Buf, len);
89 len = atol(&ChrPtr(Buf)[4]);
92 serv_write(junk, len);
97 // We may have been supplied with instructions regarding the location
98 // to which we must return after posting. If found, go there.
99 if (havebstr("return_to")) {
100 syslog(LOG_DEBUG, "return_to = %s", bstr("return_to"));
101 http_redirect(bstr("return_to"));
104 // Otherwise, do the generic result screen.
107 output_headers(1, 0, 0, 0, 1, 0);
109 StackContext(NULL, &SubTP, Buf, CTX_STRBUF, 0, NULL);
111 DoTemplate(HKEY("aide_display_generic_result"), NULL, &SubTP);
113 UnStackContext(&SubTP);
121 // Display the wait / input dialog while restarting the server.
122 void display_shutdown(void) {
128 if (strcmp(when, "now") == 0){
129 serv_printf("DOWN 1");
130 StrBuf_ServGetln(Line);
131 GetServerStatusMsg(Line, NULL, 1, 5);
134 output_headers(1, 0, 0, 0, 1, 0);
135 DoTemplate(HKEY("aide_display_serverrestart"), NULL, &NoCtx);
137 lingering_close(WC->Hdr->http_sock);
142 else if (strcmp(when, "page") == 0) {
145 message = bstr("message");
146 if ((message == NULL) || (IsEmptyStr(message)))
149 output_headers(1, 0, 0, 0, 1, 0);
150 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
155 serv_printf("SEXP broadcast|%s", message);
156 StrBuf_ServGetln(Line);
157 GetServerStatusMsg(Line, NULL, 1, 0);
160 output_headers(1, 0, 0, 0, 1, 0);
161 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
165 else if (!strcmp(when, "idle")) {
166 serv_printf("SCDN 3");
167 StrBuf_ServGetln(Line);
168 GetServerStatusMsg(Line, NULL, 1, 2);
171 output_headers(1, 0, 0, 0, 1, 0);
172 DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
183 WebcitAddUrlHandler(HKEY("display_aide_menu"), "", 0, display_aide_menu, 0);
184 WebcitAddUrlHandler(HKEY("server_shutdown"), "", 0, display_shutdown, 0);
185 WebcitAddUrlHandler(HKEY("display_main_menu"), "", 0, display_main_menu, 0);
186 WebcitAddUrlHandler(HKEY("do_generic"), "", 0, do_generic, 0);