Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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