2 * Handles HTTP upload of graphics files into the system.
4 * Copyright (c) 1996-2012 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU 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.
23 extern void output_static(const char* What);
25 void display_graphics_upload(char *filename)
30 serv_printf("UIMG 0||%s", filename);
31 StrBuf_ServGetln(Line);
32 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
38 output_headers(1, 0, 0, 0, 1, 0);
39 do_template("files_graphicsupload");
45 void do_graphics_upload(char *filename)
53 bytes_remaining = WCC->upload_length;
55 if (havebstr("cancel_button")) {
56 AppendImportantMessage(_("Graphics upload has been cancelled."), -1);
61 if (WCC->upload_length == 0) {
62 AppendImportantMessage(_("You didn't upload a file."), -1);
67 MimeType = GuessMimeType(ChrPtr(WCC->upload), bytes_remaining);
68 serv_printf("UIMG 1|%s|%s", MimeType, filename);
71 StrBuf_ServGetln(Line);
72 if (GetServerStatusMsg(Line, NULL, 1, 2) != 2) {
77 while (bytes_remaining) {
78 thisblock = ((bytes_remaining > 4096) ? 4096 : bytes_remaining);
79 serv_printf("WRIT %d", thisblock);
80 StrBuf_ServGetln(Line);
81 if (GetServerStatusMsg(Line, NULL, 1, 7) != 7) {
83 StrBuf_ServGetln(Line);
88 thisblock = extract_int(ChrPtr(Line) +4, 0);
89 serv_write(&ChrPtr(WCC->upload)[pos], thisblock);
91 bytes_remaining -= thisblock;
95 StrBuf_ServGetln(Line);
96 if (*ChrPtr(Line) != 'x') {
97 display_success(ChrPtr(Line) + 4);
105 void edithellopic(void) { do_graphics_upload("hello"); }
106 void editpic(void) { do_graphics_upload("_userpic_"); }
107 void editgoodbuyepic(void) { do_graphics_upload("UIMG 1|%s|goodbuye"); }
109 /* The users photo display / upload facility */
110 void display_editpic(void) {
111 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_userpic_")));
112 putbstr("__PICDESC", NewStrBufPlain(_("your photo"), -1));
113 putbstr("__UPLURL", NewStrBufPlain(HKEY("editpic")));
114 display_graphics_upload("editpic");
116 /* room picture dispay / upload facility */
117 void display_editroompic(void) {
118 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("_roompic_")));
119 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this room"), -1));
120 putbstr("__UPLURL", NewStrBufPlain(HKEY("editroompic")));
121 display_graphics_upload("editroompic");
124 /* the greetingpage hello pic */
125 void display_edithello(void) {
126 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("hello")));
127 putbstr("__PICDESC", NewStrBufPlain(_("the Greetingpicture for the login prompt"), -1));
128 putbstr("__UPLURL", NewStrBufPlain(HKEY("edithellopic")));
129 display_graphics_upload("edithellopic");
132 /* the logoff banner */
133 void display_editgoodbyepic(void) {
134 putbstr("__WHICHPIC", NewStrBufPlain(HKEY("UIMG 0|%s|goodbuye")));
135 putbstr("__PICDESC", NewStrBufPlain(_("the Logoff banner picture"), -1));
136 putbstr("__UPLURL", NewStrBufPlain(HKEY("editgoodbuyepic")));
137 display_graphics_upload("editgoodbuyepic");
140 void display_editfloorpic(void) {
143 PicAction = NewStrBuf();
144 StrBufPrintf(PicAction, "_floorpic_|%s", bstr("which_floor"));
145 putbstr("__WHICHPIC", PicAction);
146 putbstr("__PICDESC", NewStrBufPlain(_("the icon for this floor"), -1));
147 putbstr("__UPLURL", NewStrBufPlain(HKEY("editfloorpic")));
148 display_graphics_upload("editfloorpic");
151 void editroompic(void) {
153 snprintf(buf, SIZ, "_roompic_|%s",
155 do_graphics_upload(buf);
158 void editfloorpic(void){
160 snprintf(buf, SIZ, "_floorpic_|%s",
161 bstr("which_floor"));
162 do_graphics_upload(buf);
169 WebcitAddUrlHandler(HKEY("display_editpic"), "", 0, display_editpic, 0);
170 WebcitAddUrlHandler(HKEY("editpic"), "", 0, editpic, 0);
171 WebcitAddUrlHandler(HKEY("display_editroompic"), "", 0, display_editroompic, 0);
172 WebcitAddUrlHandler(HKEY("editroompic"), "", 0, editroompic, 0);
173 WebcitAddUrlHandler(HKEY("display_edithello"), "", 0, display_edithello, 0);
174 WebcitAddUrlHandler(HKEY("edithellopic"), "", 0, edithellopic, 0);
175 WebcitAddUrlHandler(HKEY("display_editgoodbuye"), "", 0, display_editgoodbyepic, 0);
176 WebcitAddUrlHandler(HKEY("editgoodbuyepic"), "", 0, editgoodbuyepic, 0);
177 WebcitAddUrlHandler(HKEY("display_editfloorpic"), "", 0, display_editfloorpic, 0);
178 WebcitAddUrlHandler(HKEY("editfloorpic"), "", 0, editfloorpic, 0);