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")) && (!havebstr("ok_button")) && (!havebstr("cancel_button")) ) {
51 if (havebstr("cancel_button")) {
52 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
55 if (havebstr("ok_button")) {
57 serv_puts(bstr("g_cmd"));
58 StrBuf_ServGetln(Buf);
60 switch (GetServerStatus(Buf, NULL)) {
63 if ( (StrLength(Buf)==3) &&
64 !strcmp(ChrPtr(Buf), "000")) {
65 StrBufAppendBufPlain(Buf, HKEY("\000"), 0);
69 LineBuf = NewStrBuf();
70 StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
72 if (StrBuf_ServGetln(LineBuf) < 0)
74 if ( (StrLength(LineBuf)==3) &&
75 !strcmp(ChrPtr(LineBuf), "000")) {
78 StrBufAppendBuf(Buf, LineBuf, 0);
79 StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
86 text_to_server(bstr("g_input"));
90 len = atol(&ChrPtr(Buf)[4]);
91 StrBuf_ServGetBLOBBuffered(Buf, len);
94 len = atol(&ChrPtr(Buf)[4]);
97 serv_write(junk, len);
104 // We may have been supplied with instructions regarding the location
105 // to which we must return after posting. If found, go there.
106 if (havebstr("return_to")) {
107 syslog(LOG_DEBUG, "return_to = %s", bstr("return_to"));
108 http_redirect(bstr("return_to"));
111 // Otherwise, do the generic result screen.
114 output_headers(1, 0, 0, 0, 1, 0);
116 StackContext(NULL, &SubTP, Buf, CTX_STRBUF, 0, NULL);
118 DoTemplate(HKEY("aide_display_generic_result"), NULL, &SubTP);
120 UnStackContext(&SubTP);
127 // Display the wait / input dialog while restarting the server.
128 void display_shutdown(void) {
134 if (strcmp(when, "now") == 0){
135 serv_printf("DOWN 1");
136 StrBuf_ServGetln(Line);
137 GetServerStatusMsg(Line, NULL, 1, 5);
140 output_headers(1, 0, 0, 0, 1, 0);
141 DoTemplate(HKEY("aide_display_serverrestart"), NULL, &NoCtx);
143 lingering_close(WC->Hdr->http_sock);
148 else if (strcmp(when, "page") == 0) {
151 message = bstr("message");
152 if ((message == NULL) || (IsEmptyStr(message)))
155 output_headers(1, 0, 0, 0, 1, 0);
156 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
161 serv_printf("SEXP broadcast|%s", message);
162 StrBuf_ServGetln(Line);
163 GetServerStatusMsg(Line, NULL, 1, 0);
166 output_headers(1, 0, 0, 0, 1, 0);
167 DoTemplate(HKEY("aide_display_serverrestart_page"), NULL, &NoCtx);
171 else if (!strcmp(when, "idle")) {
172 serv_printf("SCDN 3");
173 StrBuf_ServGetln(Line);
174 GetServerStatusMsg(Line, NULL, 1, 2);
177 output_headers(1, 0, 0, 0, 1, 0);
178 DoTemplate(HKEY("aide_display_menu"), NULL, &NoCtx);
189 WebcitAddUrlHandler(HKEY("display_aide_menu"), "", 0, display_aide_menu, 0);
190 WebcitAddUrlHandler(HKEY("server_shutdown"), "", 0, display_shutdown, 0);
191 WebcitAddUrlHandler(HKEY("display_main_menu"), "", 0, display_main_menu, 0);
192 WebcitAddUrlHandler(HKEY("do_generic"), "", 0, do_generic, 0);