Skip to content

HTTPS clone URL

Subversion checkout URL

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