indent -kr -i8 -brf -bbb -fnc -l132 -nce on all of webcit-classic
[citadel.git] / webcit / sysmsgs.c
1
2 /*
3  * Copyright (c) 1996-2012 by the citadel.org team
4  *
5  * This program is open source software.  You can redistribute it and/or
6  * modify it under the terms of the GNU General Public License, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  */
13
14 #include "webcit.h"
15
16 /**
17  *  save a screen which was displayed with display_edit()
18  *  description the window title???
19  *  enter_cmd which command to enter at the citadel server???
20  *  regoto should we go to that room again after executing that command?
21  */
22 void save_edit(char *description, char *enter_cmd, int regoto) {
23         StrBuf *Line;
24         const StrBuf *templ;
25
26         if (!havebstr("save_button")) {
27                 AppendImportantMessage(_("Cancelled.  %s was not saved."), -1);
28                 display_main_menu();
29                 return;
30         }
31         templ = sbstr("template");
32         Line = NewStrBuf();
33         serv_puts(enter_cmd);
34         StrBuf_ServGetln(Line);
35         if (GetServerStatusMsg(Line, NULL, 1, 0) != 4) {
36                 putlbstr("success", 0);
37                 FreeStrBuf(&Line);
38                 if (templ != NULL) {
39                         output_headers(1, 0, 0, 0, 0, 0);
40                         DoTemplate(SKEY(templ), NULL, &NoCtx);
41                         end_burst();
42                 }
43                 else {
44                         display_main_menu();
45                 }
46                 return;
47         }
48         FreeStrBuf(&Line);
49         text_to_server(bstr("msgtext"));
50         serv_puts("000");
51
52         AppendImportantMessage(description, -1);
53         AppendImportantMessage(_(" has been saved."), -1);
54         putlbstr("success", 1);
55         if (templ != NULL) {
56                 output_headers(1, 0, 0, 0, 0, 0);
57                 DoTemplate(SKEY(templ), NULL, &NoCtx);
58                 end_burst();
59         }
60         else if (regoto) {
61                 smart_goto(WC->CurRoom.name);
62         }
63         else {
64                 display_main_menu();
65                 return;
66         }
67 }
68
69
70 void editinfo(void) {
71         save_edit(_("Room info"), "EINF 1", 1);
72 }
73 void editbio(void) {
74         save_edit(_("Your bio"), "EBIO", 0);
75 }
76
77 void InitModule_SYSMSG(void) {
78         WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
79         WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);
80 }