Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 371 lines (335 sloc) 14.617 kB
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
1 // Copyright (C) 2012 Henner Zeller <h.zeller@acm.org>
2 //
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
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 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 #include <arpa/inet.h>
17 #include <fcntl.h>
036c6e1 @hzeller o not wide cellspacing needed anymore.
authored
18 #include <math.h>
b5c1e96 @hzeller o more useful output on status server.
authored
19 #include <stdio.h>
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
20 #include <stdlib.h>
21 #include <sys/select.h>
22 #include <sys/socket.h>
23 #include <sys/time.h>
24 #include <sys/types.h>
25
26 #include <microhttpd.h>
27
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
28 #include <boost/thread/locks.hpp>
29
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
30 #include "folve-filesystem.h"
c1a03f2 @hzeller o Needed convenient sub-second resolution time. Added CurrentTime()
authored
31 #include "status-server.h"
32 #include "util.h"
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
33
8268c37 @hzeller o Bubble up error messages in status server.
authored
34 using folve::Appendf;
35
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
36 // TODO: someone with a bit more stylesheet-fu can attempt to make this
d280fce @hzeller o Reload page with a meta-refresn.
authored
37 // more pretty and the HTML more compact. Maybe even with some Ajax-y inline
38 // update of progress bars ?
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
39
f1ef960 @hzeller o a bit HTML polishing.
authored
40 static const size_t kMaxRetired = 20;
b698853 @hzeller o README updates.
authored
41 static const int kProgressWidth = 300;
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
42 static const char kActiveProgress[] = "#7070ff";
43 static const char kRetiredProgress[] = "#d0d0d0";
249865a @hzeller o Make debug mode switchable in UI.
authored
44 static const char kSettingsUrl[] = "/settings";
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
45
78e66dd @hzeller o I need to find my browser-tab :) Add favicon.
authored
46 // Aaah, I need to find the right Browser-Tab :)
47 // Sneak in a favicon without another resource access.
48 // TODO: make a nice icon, recognizable as something that has to do with "
49 // files and music ...
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
50 static const char kHtmlHeader[] = "<html><head>"
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
51 "<title>Folve</title>\n"
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
52 "<link rel='icon' type='image/png' "
78e66dd @hzeller o I need to find my browser-tab :) Add favicon.
authored
53 "href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2"
54 "AAAAAXNSR0IArs4c6QAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wJDwUlEA/UBrsA"
55 "AABSSURBVCjPrZIxDgAgDAKh8f9froOTirU1ssKFYqS7Q4mktAxFRQDJcsPORMDYsDCXhn331"
b15aaf9 @hzeller o add title.
authored
56 "9GPwHJVuaFl3l4D1+h0UjIdbTh9SpP2KQ2AgSfVAdEQGx23tOopAAAAAElFTkSuQmCC'/>\n"
d280fce @hzeller o Reload page with a meta-refresn.
authored
57 // TODO: make refresh configurable.
58 "<meta http-equiv='refresh' content='1'>\n"
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
59 "</head>\n";
78e66dd @hzeller o I need to find my browser-tab :) Add favicon.
authored
60
b698853 @hzeller o README updates.
authored
61 // Callback function called by micro http daemon. Gets the StatusServer pointer
62 // in the user_argument.
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
63 int StatusServer::HandleHttp(void* user_argument,
64 struct MHD_Connection *connection,
65 const char *url, const char *method,
66 const char *version,
67 const char *upload_data, size_t *upload_size,
68 void**) {
69 StatusServer* server = (StatusServer*) user_argument;
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
70 struct MHD_Response *response;
71 int ret;
72
249865a @hzeller o Make debug mode switchable in UI.
authored
73 if (strcmp(url, kSettingsUrl) == 0) {
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
74 server->SetFilter(MHD_lookup_connection_value(connection,
75 MHD_GET_ARGUMENT_KIND, "f"));
249865a @hzeller o Make debug mode switchable in UI.
authored
76 server->SetDebug(MHD_lookup_connection_value(connection,
77 MHD_GET_ARGUMENT_KIND, "d"));
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
78 // We redirect to slash after this, to remove parameters from the GET-URL
79 response = MHD_create_response_from_data(0, (void*)"", MHD_NO, MHD_NO);
80 MHD_add_response_header(response, "Location", "/");
81 ret = MHD_queue_response(connection, 302, response);
82 } else {
83 const std::string &page = server->CreatePage();
84 response = MHD_create_response_from_data(page.length(), (void*) page.data(),
85 MHD_NO, MHD_NO);
86 MHD_add_response_header(response, "Content-Type",
87 "text/html; charset=utf-8");
88 ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
89 }
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
90 // Tell aggressive cachers not to do so.
91 MHD_add_response_header(response, "Cache-Control", "no-cache");
92 MHD_add_response_header(response, "Expires", "24 Nov 1972 23:42:42 GMT");
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
93 MHD_destroy_response(response);
94 return ret;
95 }
96
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
97 StatusServer::StatusServer(FolveFilesystem *fs)
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
98 : expunged_retired_(0), total_seconds_filtered_(0),
99 total_seconds_music_seen_(0),
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
100 filesystem_(fs), daemon_(NULL), filter_switched_(false) {
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
101 fs->handler_cache()->SetObserver(this);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
102 }
103
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
104 void StatusServer::SetFilter(const char *filter) {
105 if (filter == NULL || *filter == '\0') return;
106 char *end;
107 int index = strtol(filter, &end, 10);
108 if (end == NULL || *end != '\0') return;
109 filter_switched_ = (index != filesystem_->current_cfg_index());
110 filesystem_->SwitchCurrentConfigIndex(index);
111 }
112
249865a @hzeller o Make debug mode switchable in UI.
authored
113 void StatusServer::SetDebug(const char *dbg) {
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
114 if (!filesystem_->is_debug_ui_enabled()) return;
7689c9a @hzeller o preparation to extract classes from folve-filesystem into their
authored
115 folve::EnableDebugLog(dbg != NULL && *dbg == '1');
249865a @hzeller o Make debug mode switchable in UI.
authored
116 }
117
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
118 bool StatusServer::Start(int port) {
119 daemon_ = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, port, NULL, NULL,
120 &HandleHttp, this,
121 MHD_OPTION_END);
122 return daemon_ != NULL;
123 }
124
125 StatusServer::~StatusServer() {
b698853 @hzeller o README updates.
authored
126 if (daemon_) MHD_stop_daemon(daemon_);
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
127 }
128
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
129 // FileHandlerCache::Observer interface.
130 void StatusServer::RetireHandlerEvent(FileHandler *handler) {
131 HandlerStats stats;
132 handler->GetHandlerStatus(&stats); // Get last available stats.
133 if (stats.progress >= 0) {
8268c37 @hzeller o Bubble up error messages in status server.
authored
134 total_seconds_music_seen_ += stats.duration_seconds;
135 total_seconds_filtered_ += stats.duration_seconds * stats.progress;
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
136 }
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
137 stats.last_access = folve::CurrentTime();
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
138 stats.status = HandlerStats::RETIRED;
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
139 boost::lock_guard<boost::mutex> l(retired_mutex_);
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
140 retired_.push_front(stats);
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
141 while (retired_.size() > kMaxRetired) {
142 ++expunged_retired_;
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
143 retired_.pop_back();
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
144 }
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
145 }
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
146
f1ef960 @hzeller o a bit HTML polishing.
authored
147 // As ugly #defines, so that gcc can warn about printf() format problems.
148 #define sMessageRowHtml \
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
149 "<td>%s</td><td colspan='3' style='font-size:small;'>%s</td>"
b5c1e96 @hzeller o more useful output on status server.
authored
150
f1ef960 @hzeller o a bit HTML polishing.
authored
151 #define sProgressRowHtml \
152 "<td>%s</td>" \
153 "<td>%s</td>" \
154 "<td><div style='background:white;width:%dpx;border:1px solid black;'>\n" \
155 " <div style='width:%d%%;background:%s;'>&nbsp;</div>\n</div></td>" \
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
156 "<td>%s</td>"
f1ef960 @hzeller o a bit HTML polishing.
authored
157
158 #define sTimeColumns \
159 "<td align='right'>%2d:%02d</td><td>/</td><td align='right'>%2d:%02d</td>"
160 #define sDecibelColumn \
161 "<td align='right' style='background:%s;'>%.1f dB</td>"
b5c1e96 @hzeller o more useful output on status server.
authored
162
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
163 static void AppendFileInfo(std::string *result, const char *progress_style,
164 const HandlerStats &stats) {
bcb77e7 @hzeller o Ran with Amarok over my files. Looks like it sometimes only 'almost'
authored
165 result->append("<tr style='text-wrap:none;white-space:nowrap;'>");
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
166 const char *status = "";
167 switch (stats.status) {
168 case HandlerStats::OPEN: status = "open"; break;
169 case HandlerStats::IDLE: status = "idle"; break;
bcb77e7 @hzeller o Ran with Amarok over my files. Looks like it sometimes only 'almost'
authored
170 case HandlerStats::RETIRED: status = "&nbsp;----&nbsp;"; break;
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
171 // no default to let the compiler detect new values.
172 }
f1ef960 @hzeller o a bit HTML polishing.
authored
173
8268c37 @hzeller o Bubble up error messages in status server.
authored
174 if (!stats.message.empty()) {
175 Appendf(result, sMessageRowHtml, status, stats.message.c_str());
176 } else if (stats.progress == 0) {
177 Appendf(result, sMessageRowHtml, status, "Only header accessed");
b5c1e96 @hzeller o more useful output on status server.
authored
178 } else {
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
179 Appendf(result, sProgressRowHtml, status,
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
180 stats.in_gapless ? "&rarr;" : "",
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
181 kProgressWidth, (int) (100 * stats.progress), progress_style,
f1ef960 @hzeller o a bit HTML polishing.
authored
182 stats.out_gapless ? "&rarr;" : "");
183 }
184 const int secs = stats.duration_seconds;
185 const int fract_sec = stats.progress * secs;
6d4f28b @hzeller o if there is a time, show it.
authored
186 if (secs >= 0 && fract_sec >= 0) {
f1ef960 @hzeller o a bit HTML polishing.
authored
187 Appendf(result, sTimeColumns,
188 fract_sec / 60, fract_sec % 60,
189 secs / 60, secs % 60);
190 } else {
191 result->append("<td colspan='3'>-</td>");
b5c1e96 @hzeller o more useful output on status server.
authored
192 }
f00e6a4 @hzeller o Don't do unprotected read on status information such as
authored
193
036c6e1 @hzeller o not wide cellspacing needed anymore.
authored
194 if (stats.max_output_value > 1e-6) {
f1ef960 @hzeller o a bit HTML polishing.
authored
195 Appendf(result, sDecibelColumn,
196 stats.max_output_value > 1.0 ? "#FF0505" : "white",
7b499ea @hzeller o Uh, log() is actually ln() and log10f() is log() :)
authored
197 20 * log10f(stats.max_output_value));
f1ef960 @hzeller o a bit HTML polishing.
authored
198 } else {
199 result->append("<td>-</td>");
200 }
201
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
202 Appendf(result, "<td bgcolor='#c0c0c0'>&nbsp;%s&nbsp;</td>",
203 stats.format.c_str());
204 Appendf(result,"<td "
205 "style='font-size:small;text-wrap:none;white-space:nowrap'>%s</td>",
206 stats.filename.c_str());
b5c1e96 @hzeller o more useful output on status server.
authored
207 result->append("</tr>\n");
208 }
209
d280fce @hzeller o Reload page with a meta-refresn.
authored
210 void StatusServer::PrepareConfigDirectoriesForUI() {
211 // Essentially only keep the directory name.
212 if (!ui_config_directories_.empty()) return;
213 ui_config_directories_.push_back("[None : Pass Through]");
214 for (size_t i = 1; i < filesystem_->config_dirs().size(); ++i) {
215 std::string d = filesystem_->config_dirs()[i];
216 while (d.length() > 0 && d[d.length() - 1] == '/') {
217 d.resize(d.length() - 1); // trim trailing slashes.
218 }
219 const std::string::size_type slash_pos = d.find_last_of('/');
220 if (slash_pos != std::string::npos) {
221 d = d.substr(slash_pos + 1);
222 }
223 d[0] = toupper(d[0]);
224 ui_config_directories_.push_back(d);
225 }
226 }
227
228 static void CreateSelection(std::string *result,
229 const std::vector<std::string> &options,
230 int selected) {
231 if (options.size() == 1) {
232 result->append(options[0]); // no reason to make this a form :)
233 return;
234 }
235 result->append("<b>");
236 for (size_t i = 0; i < options.size(); ++i) {
237 const std::string &c = options[i];
238 if (i != 0 ) result->append("&nbsp;|&nbsp;");
239 const bool active = (int) i == selected;
240 if (active) result->append("<span style='background:#a0a0ff'>");
241 Appendf(result, "<input type='radio' onchange='this.form.submit();' "
242 "id='f%zd' name='f' value='%zd'%s>"
243 "<label for='f%zd'>%s</label>\n",
244 i, i, active ? " checked='checked'" : "",
245 i, c.c_str());
246 if (active) result->append("</span>");
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
247 }
d280fce @hzeller o Reload page with a meta-refresn.
authored
248 result->append("</b>");
249 }
250
251 void StatusServer::AppendSettingsForm() {
252 Appendf(&content_, "<form id='settings-form' action='%s'>\n"
253 "<label for='cfg_sel'>Config directory </label>", kSettingsUrl);
254 PrepareConfigDirectoriesForUI();
255 CreateSelection(&content_, ui_config_directories_,
256 filesystem_->current_cfg_index());
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
257 if (filesystem_->config_dirs().size() == 1) {
d280fce @hzeller o Reload page with a meta-refresn.
authored
258 content_.append(" (This is a boring configuration, add filter directories "
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
259 "with -c &lt;dir&gt; [-c &lt;another-dir&gt; ...] :-) )");
260 } else if (filter_switched_) {
d280fce @hzeller o Reload page with a meta-refresn.
authored
261 content_.append("&nbsp;<span style='font-size:small;background:#FFFFa0;'>"
262 " (Affects re- or newly opened files.) </span>");
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
263 filter_switched_ = false; // only show once.
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
264 }
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
265 if (filesystem_->is_debug_ui_enabled()) {
d280fce @hzeller o Reload page with a meta-refresn.
authored
266 Appendf(&content_, "<span style='float:right;font-size:small;'>"
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
267 "<label for='dbg_sel'>Folve debug to syslog</label>"
268 "<input id='dbg_sel' onchange='this.form.submit();' "
269 "type='checkbox' name='d' value='1'%s/></span>",
7689c9a @hzeller o preparation to extract classes from folve-filesystem into their
authored
270 folve::IsDebugLogEnabled() ? " checked" : "");
8c7e5c1 @hzeller o Only if -D is given, the debug toggle is active in the UI.
authored
271 }
d280fce @hzeller o Reload page with a meta-refresn.
authored
272 content_.append("</form>");
273 content_.append("<script>document.forms['settings-form'].reset();</script>");
274 content_.append("<hr/>");
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
275 }
276
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
277 struct CompareStats {
278 bool operator() (const HandlerStats &a, const HandlerStats &b) {
279 if (a.status < b.status) return true; // open before idle.
280 else if (a.status > b.status) return false;
281 return b.last_access < a.last_access; // reverse time.
282 }
283 };
284
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
285 const std::string &StatusServer::CreatePage() {
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
286 const double start = folve::CurrentTime();
b698853 @hzeller o README updates.
authored
287 // We re-use a string to avoid re-allocing memory every time we generate
288 // a page. Since we run with MHD_USE_SELECT_INTERNALLY, this is only accessed
289 // by one thread.
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
290 content_.clear();
291 content_.append(kHtmlHeader);
292 content_.append("<body style='font-family:Sans-Serif;'>\n");
293 Appendf(&content_, "<center style='background-color:#A0FFA0;'>"
53130a3 @hzeller o link to github page
authored
294 "Welcome to "
ee675fe @hzeller o Provide a way to select between different filter diretories.
authored
295 "<a href='https://github.com/hzeller/folve#readme'>Folve</a> "
296 FOLVE_VERSION "</center>\n"
297 "Convolving audio files from <code>%s</code>\n",
298 filesystem_->underlying_dir().c_str());
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
299
d280fce @hzeller o Reload page with a meta-refresn.
authored
300 AppendSettingsForm();
27c44cd @hzeller o Use fuse option handling to extract our flags and options.
authored
301
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
302 std::vector<HandlerStats> stat_list;
303 filesystem_->handler_cache()->GetStats(&stat_list);
304
562b493 @hzeller o Print out config file name while spotting a problem
authored
305 // Get statistics of active files to add to the existing ones.
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
306 double active_music_seen = 0.0;
307 double active_filtered = 0.0;
308 for (size_t i = 0; i < stat_list.size(); ++i) {
309 const HandlerStats &stats = stat_list[i];
310 if (stats.progress >= 0) {
8268c37 @hzeller o Bubble up error messages in status server.
authored
311 active_music_seen += stats.duration_seconds;
312 active_filtered += stats.duration_seconds * stats.progress;
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
313 }
314 }
315 const int t_seen = total_seconds_music_seen_ + active_music_seen;
316 const int t_filtered = total_seconds_filtered_ + active_filtered;
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
317 Appendf(&content_, "Total opening files <b>%d</b> "
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
318 ".. and re-opened from recency cache <b>%d</b><br/>",
319 filesystem_->total_file_openings(),
320 filesystem_->total_file_reopen());
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
321 Appendf(&content_, "Total music seen <b>%dd %d:%02d:%02d</b> ",
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
322 t_seen / 86400, (t_seen % 86400) / 3600,
323 (t_seen % 3600) / 60, t_seen % 60);
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
324 Appendf(&content_, ".. and convolved <b>%dd %d:%02d:%02d</b> ",
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
325 t_filtered / 86400, (t_filtered % 86400) / 3600,
326 (t_filtered % 3600) / 60, t_filtered % 60);
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
327 Appendf(&content_, "(%.1f%%)<br/>",
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
328 (t_seen == 0) ? 0.0 : (100.0 * t_filtered / t_seen));
329
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
330 Appendf(&content_, "<h3>Accessed Recently</h3>\n%zd in recency cache\n",
bea11d6 @hzeller o Don't use snprintf, but use a new function Appendf() to assemble
authored
331 stat_list.size());
332
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
333 if (filesystem_->gapless_processing()) {
d93a35b @hzeller o Uh, typo in gapless message.
authored
334 content_.append("<br/>&rarr; : denotes gapless transfers\n");
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
335 }
036c6e1 @hzeller o not wide cellspacing needed anymore.
authored
336 content_.append("<table>\n");
08bbf28 @hzeller o First shot at gapless. Works pretty well for my test-case.
authored
337 Appendf(&content_, "<tr><th>Stat</th><td><!--gapless in--></td>"
338 "<th width='%dpx'>Progress</th>" // progress bar.
339 "<td><!-- gapless out --></td>"
f1ef960 @hzeller o a bit HTML polishing.
authored
340 "<th>Pos</th><td></td><th>Len</th><th>Max out</th><th>Format</th>"
b698853 @hzeller o README updates.
authored
341 "<th align='left'>File</th></tr>\n", kProgressWidth);
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
342 CompareStats comparator;
343 std::sort(stat_list.begin(), stat_list.end(), comparator);
344 for (size_t i = 0; i < stat_list.size(); ++i) {
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
345 AppendFileInfo(&content_, kActiveProgress, stat_list[i]);
b5c1e96 @hzeller o more useful output on status server.
authored
346 }
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
347 content_.append("</table><hr/>\n");
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
348
349 if (retired_.size() > 0) {
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
350 content_.append("<h3>Retired</h3>\n");
351 content_.append("<table>\n");
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
352 boost::lock_guard<boost::mutex> l(retired_mutex_);
b698853 @hzeller o README updates.
authored
353 for (RetiredList::const_iterator it = retired_.begin();
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
354 it != retired_.end(); ++it) {
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
355 AppendFileInfo(&content_, kRetiredProgress, *it);
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
356 }
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
357 content_.append("</table>\n");
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
358 if (expunged_retired_ > 0) {
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
359 Appendf(&content_, "... (%d more)<p></p>", expunged_retired_);
1e9ff21 @hzeller o main: report if parameters are not directories.
authored
360 }
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
361 content_.append("<hr/>");
223f392 @hzeller o Have a separate HandlerStats object that contains relevant
authored
362 }
363
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
364 const double duration = folve::CurrentTime() - start;
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
365 Appendf(&content_,
a9d3e53 @hzeller o Found a project name: "Folve". Some renamings because of that.
authored
366 "<span style='float:left;font-size:small;'>page-gen %.2fms</span>"
367 "<span style='float:right;font-size:small;'>HZ</span>"
e619ff2 @hzeller o Redirect to / after settings. That way, a reload won't change any
authored
368 "</body></html>\n", duration * 1000.0);
7d695c6 @hzeller o Rename current_page_ to content_ to be more generic.
authored
369 return content_;
8d1fbe7 @hzeller o Move fuse-convolve.c to fuse-convolve.cc. Make filter-interface
authored
370 }
Something went wrong with that request. Please try again.