Mailing list header changes (fuck you Google)
[citadel.git] / webcit / sysmsgs.c
1 /*
2  * Copyright (c) 1996-2012 by the citadel.org team
3  *
4  * This program is open source software.  You can redistribute it and/or
5  * modify it under the terms of the GNU General Public License, version 3.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  */
12
13 #include "webcit.h"
14
15 /**
16  *  save a screen which was displayed with display_edit()
17  *  description the window title???
18  *  enter_cmd which command to enter at the citadel server???
19  *  regoto should we go to that room again after executing that command?
20  */
21 void save_edit(char *description, char *enter_cmd, int regoto)
22 {
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         } else {
63                 display_main_menu();
64                 return;
65         }
66 }
67
68
69 void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
70 void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
71
72 void 
73 InitModule_SYSMSG
74 (void)
75 {
76         WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
77         WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);
78 }