|
a/src/main.cxx |
|
b/src/main.cxx |
|
... |
|
... |
126 |
|
126 |
|
127 |
string g_datadir(DATADIR "/");
|
127 |
string g_datadir(DATADIR "/");
|
128 |
|
128 |
|
129 |
// Global
|
129 |
// Global
|
130 |
string g_configfilename(CONFIGDIR "/upmpdcli.conf");
|
130 |
string g_configfilename(CONFIGDIR "/upmpdcli.conf");
|
|
|
131 |
PTMutexInit g_configlock;
|
131 |
ConfSimple *g_config;
|
132 |
ConfSimple *g_config;
|
132 |
|
133 |
|
133 |
static void onsig(int)
|
134 |
static void onsig(int)
|
134 |
{
|
135 |
{
|
135 |
LOGDEB("Got sig" << endl);
|
136 |
LOGDEB("Got sig" << endl);
|
|
... |
|
... |
171 |
string friendlyname(dfltFriendlyName);
|
172 |
string friendlyname(dfltFriendlyName);
|
172 |
bool ownqueue = true;
|
173 |
bool ownqueue = true;
|
173 |
bool enableAV = true;
|
174 |
bool enableAV = true;
|
174 |
bool enableOH = true;
|
175 |
bool enableOH = true;
|
175 |
bool ohmetapersist = true;
|
176 |
bool ohmetapersist = true;
|
176 |
bool externalvolumecontrol =false;
|
|
|
177 |
string upmpdcliuser("upmpdcli");
|
177 |
string upmpdcliuser("upmpdcli");
|
178 |
string pidfilename("/var/run/upmpdcli.pid");
|
178 |
string pidfilename("/var/run/upmpdcli.pid");
|
179 |
string iconpath(DATADIR "/icon.png");
|
179 |
string iconpath(DATADIR "/icon.png");
|
180 |
string presentationhtml(DATADIR "/presentation.html");
|
180 |
string presentationhtml(DATADIR "/presentation.html");
|
181 |
string iface;
|
181 |
string iface;
|
|
... |
|
... |
242 |
Usage();
|
242 |
Usage();
|
243 |
|
243 |
|
244 |
UpMpd::Options opts;
|
244 |
UpMpd::Options opts;
|
245 |
|
245 |
|
246 |
string cachedir;
|
246 |
string cachedir;
|
247 |
string onstart;
|
|
|
248 |
string onplay;
|
|
|
249 |
string onstop;
|
|
|
250 |
string onvolumechange;
|
|
|
251 |
string getexternalvolume;
|
|
|
252 |
if (!g_configfilename.empty()) {
|
247 |
if (!g_configfilename.empty()) {
|
253 |
g_config = new ConfSimple(g_configfilename.c_str(), 1, true);
|
248 |
g_config = new ConfSimple(g_configfilename.c_str(), 1, true);
|
254 |
if (!g_config || !g_config->ok()) {
|
249 |
if (!g_config || !g_config->ok()) {
|
255 |
cerr << "Could not open config: " << g_configfilename << endl;
|
250 |
cerr << "Could not open config: " << g_configfilename << endl;
|
256 |
return 1;
|
251 |
return 1;
|
|
... |
|
... |
279 |
enableAV = atoi(value.c_str()) != 0;
|
274 |
enableAV = atoi(value.c_str()) != 0;
|
280 |
}
|
275 |
}
|
281 |
if (g_config->get("ohmetapersist", value)) {
|
276 |
if (g_config->get("ohmetapersist", value)) {
|
282 |
ohmetapersist = atoi(value.c_str()) != 0;
|
277 |
ohmetapersist = atoi(value.c_str()) != 0;
|
283 |
}
|
278 |
}
|
284 |
if (g_config->get("externalvolumecontrol", value)) {
|
|
|
285 |
externalvolumecontrol = atoi(value.c_str()) != 0;
|
|
|
286 |
}
|
|
|
287 |
g_config->get("iconpath", iconpath);
|
279 |
g_config->get("iconpath", iconpath);
|
288 |
g_config->get("presentationhtml", presentationhtml);
|
280 |
g_config->get("presentationhtml", presentationhtml);
|
289 |
g_config->get("cachedir", cachedir);
|
281 |
g_config->get("cachedir", cachedir);
|
290 |
g_config->get("onstart", onstart);
|
|
|
291 |
g_config->get("onplay", onplay);
|
|
|
292 |
g_config->get("onstop", onstop);
|
|
|
293 |
g_config->get("onvolumechange", onvolumechange);
|
|
|
294 |
g_config->get("getexternalvolume", getexternalvolume);
|
|
|
295 |
if (!(op_flags & OPT_i)) {
|
282 |
if (!(op_flags & OPT_i)) {
|
296 |
g_config->get("upnpiface", iface);
|
283 |
g_config->get("upnpiface", iface);
|
297 |
if (iface.empty()) {
|
284 |
if (iface.empty()) {
|
298 |
g_config->get("upnpip", upnpip);
|
285 |
g_config->get("upnpip", upnpip);
|
299 |
}
|
286 |
}
|
|
... |
|
... |
471 |
|
458 |
|
472 |
// Initialize MPD client object. Retry until it works or power fail.
|
459 |
// Initialize MPD client object. Retry until it works or power fail.
|
473 |
MPDCli *mpdclip = 0;
|
460 |
MPDCli *mpdclip = 0;
|
474 |
int mpdretrysecs = 2;
|
461 |
int mpdretrysecs = 2;
|
475 |
for (;;) {
|
462 |
for (;;) {
|
476 |
mpdclip = new MPDCli(mpdhost, mpdport, mpdpassword, onstart, onplay,
|
463 |
mpdclip = new MPDCli(mpdhost, mpdport, mpdpassword);
|
477 |
onstop, onvolumechange, getexternalvolume,
|
|
|
478 |
externalvolumecontrol);
|
|
|
479 |
if (mpdclip == 0) {
|
464 |
if (mpdclip == 0) {
|
480 |
LOGFAT("Can't allocate MPD client object" << endl);
|
465 |
LOGFAT("Can't allocate MPD client object" << endl);
|
481 |
return 1;
|
466 |
return 1;
|
482 |
}
|
467 |
}
|
483 |
if (!mpdclip->ok()) {
|
468 |
if (!mpdclip->ok()) {
|