From 82e6627d57d0dcf51594d07b0d36626dfe78cfc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Wed, 18 Aug 2010 21:11:22 +0000 Subject: [PATCH] * move floor-save-handlers into roomops.c, remove floors.c --- webcit/floors.c | 221 ----------------------------------------------- webcit/roomops.c | 75 ++++++++++++++++ 2 files changed, 75 insertions(+), 221 deletions(-) delete mode 100644 webcit/floors.c diff --git a/webcit/floors.c b/webcit/floors.c deleted file mode 100644 index b183d6be1..000000000 --- a/webcit/floors.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 1996-2010 by the citadel.org team - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "webcit.h" -#include "webserver.h" - - - - -/* - * Display floor configuration. If prepend_html is not NULL, its contents - * will be displayed at the top of the screen. - */ -void display_floorconfig(StrBuf *prepend_html) -{ - char buf[SIZ]; - - int floornum; - char floorname[SIZ]; - int refcount; - - output_headers(1, 1, 2, 0, 0, 0); - wc_printf("
\n"); - wc_printf("

"); - wc_printf(_("Add/change/delete floors")); - wc_printf("

"); - wc_printf("
\n"); - - wc_printf("
\n"); - - if (prepend_html != NULL) { - wc_printf("
"); - StrBufAppendBuf(WC->WBuf, prepend_html, 0); - wc_printf("

\n"); - } - - serv_printf("LFLR"); - serv_getln(buf, sizeof buf); - if (buf[0] != '1') { - wc_printf("
"); - wc_printf(""); - wc_printf(_("Error")); - wc_printf("\n"); - wc_printf("
\n"); - wc_printf("%s
\n", &buf[4]); - wDumpContent(1); - return; - } - - wc_printf("
" - "\n" - "\n"); - - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - floornum = extract_int(buf, 0); - extract_token(floorname, buf, 1, '|', sizeof floorname); - refcount = extract_int(buf, 2); - - wc_printf(""); - - wc_printf("", _("Change name")); - - wc_printf("\n", refcount); - - wc_printf("", _("Change CSS")); - - wc_printf("\n"); - } - - wc_printf("" - "" - "\n", _("Create new floor")); - - wc_printf("
"); - wc_printf(_("Floor number")); - wc_printf(""); - wc_printf(_("Floor name")); - wc_printf(""); - wc_printf(_("Number of rooms")); - wc_printf(""); - wc_printf(_("Floor CSS")); - wc_printf("
%d", floornum); - if (refcount == 0) { - wc_printf("" - "" - "", floornum); - wc_printf(_("(delete floor)")); - wc_printf("
"); - } - wc_printf("" - "", floornum); - wc_printf(_("(edit graphic)")); - wc_printf("
"); - wc_printf("
" - "
" - "" - "\n", - floornum, floorname); - wc_printf("\n", WC->nonce); - wc_printf("" - "
%d" - "
" - "" - "\n", - floornum, floorname); - wc_printf("\n", WC->nonce); - wc_printf("" - "
 
"); - wc_printf("\n", WC->nonce); - wc_printf("\n" - "" - "
 
\n"); - wDumpContent(1); -} - - -/* - * delete the actual floor - */ -void delete_floor(void) { - int floornum; - StrBuf *Buf; - const char *Err; - - floornum = ibstr("floornum"); - Buf = NewStrBuf(); - serv_printf("KFLR %d|1", floornum); - - StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); - - if (GetServerStatus(Buf, NULL) == 2) { - StrBufPlain(Buf, _("Floor has been deleted."),-1); - } - else { - StrBufCutLeft(Buf, 4); - } - - FlushRoomlist(); - display_floorconfig(Buf); - FreeStrBuf(&Buf); -} - -/* - * start creating a new floor - */ -void create_floor(void) { - StrBuf *Buf; - const char *Err; - - Buf = NewStrBuf(); - serv_printf("CFLR %s|1", bstr("floorname")); - StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); - - if (GetServerStatus(Buf, NULL) == 2) { - StrBufPlain(Buf, _("New floor has been created."),-1); - } - else { - StrBufCutLeft(Buf, 4); - } - - FlushRoomlist(); - display_floorconfig(Buf); - FreeStrBuf(&Buf); -} - - -/* - * rename this floor - */ -void rename_floor(void) { - StrBuf *Buf; - - Buf = NewStrBuf(); - FlushRoomlist(); - - serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname")); - StrBuf_ServGetln(Buf); - - StrBufCutLeft(Buf, 4); - - display_floorconfig(Buf); - FreeStrBuf(&Buf); -} - -void _display_floorconfig(void) {display_floorconfig(NULL);} - -void -InitModule_FLOORS -(void) -{ - WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0); - WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0); - WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0); - WebcitAddUrlHandler(HKEY("display_floorconfig"), "", 0, _display_floorconfig, 0); -} diff --git a/webcit/roomops.c b/webcit/roomops.c index 3e3a18705..b5812499f 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -1667,6 +1667,77 @@ void netedit(void) { http_transmit_thing(ChrPtr(do_template("room_edit", NULL)), 0); } +/* + * delete the actual floor + */ +void delete_floor(void) { + int floornum; + StrBuf *Buf; + const char *Err; + + floornum = ibstr("floornum"); + Buf = NewStrBuf(); + serv_printf("KFLR %d|1", floornum); + + StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); + + if (GetServerStatus(Buf, NULL) == 2) { + StrBufPlain(Buf, _("Floor has been deleted."),-1); + } + else { + StrBufCutLeft(Buf, 4); + } + AppendImportantMessage (SKEY(Buf)); + + FlushRoomlist(); + http_transmit_thing(ChrPtr(do_template("floors", NULL)), 0); + FreeStrBuf(&Buf); +} + +/* + * start creating a new floor + */ +void create_floor(void) { + StrBuf *Buf; + const char *Err; + + Buf = NewStrBuf(); + serv_printf("CFLR %s|1", bstr("floorname")); + StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); + + if (GetServerStatus(Buf, NULL) == 2) { + StrBufPlain(Buf, _("New floor has been created."),-1); + } + else { + StrBufCutLeft(Buf, 4); + } + AppendImportantMessage (SKEY(Buf)); + FlushRoomlist(); + http_transmit_thing(ChrPtr(do_template("floors", NULL)), 0); + FreeStrBuf(&Buf); +} + + +/* + * rename this floor + */ +void rename_floor(void) { + StrBuf *Buf; + + Buf = NewStrBuf(); + FlushRoomlist(); + + serv_printf("EFLR %d|%s", ibstr("floornum"), bstr("floorname")); + StrBuf_ServGetln(Buf); + + StrBufCutLeft(Buf, 4); + AppendImportantMessage (SKEY(Buf)); + + http_transmit_thing(ChrPtr(do_template("floors", NULL)), 0); + FreeStrBuf(&Buf); +} + + /** * \brief Back end for change_view() @@ -2027,6 +2098,10 @@ InitModule_ROOMOPS RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE); + WebcitAddUrlHandler(HKEY("delete_floor"), "", 0, delete_floor, 0); + WebcitAddUrlHandler(HKEY("rename_floor"), "", 0, rename_floor, 0); + WebcitAddUrlHandler(HKEY("create_floor"), "", 0, create_floor, 0); + WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0); WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL); WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL); -- 2.30.2