36 |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
37 |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
38 |
|
|
39 |
|
|
40 |
|
/** |
41 |
|
* Returns a copy of the given string where all special characters are |
42 |
|
* replaced by LSCP escape sequences ("\xHH"). This function shall be used |
43 |
|
* to escape LSCP response fields in case the respective response field is |
44 |
|
* actually defined as using escape sequences in the LSCP specs. |
45 |
|
* |
46 |
|
* @e Caution: DO NOT use this function for escaping path based responses, |
47 |
|
* use the Path class (src/common/Path.h) for this instead! |
48 |
|
*/ |
49 |
|
static String _escapeLscpResponse(String txt) { |
50 |
|
for (int i = 0; i < txt.length(); i++) { |
51 |
|
const char c = txt.c_str()[i]; |
52 |
|
if ( |
53 |
|
!(c >= '0' && c <= '9') && |
54 |
|
!(c >= 'a' && c <= 'z') && |
55 |
|
!(c >= 'A' && c <= 'Z') && |
56 |
|
!(c == ' ') && !(c == '!') && !(c == '#') && !(c == '$') && |
57 |
|
!(c == '%') && !(c == '&') && !(c == '(') && !(c == ')') && |
58 |
|
!(c == '*') && !(c == '+') && !(c == ',') && !(c == '-') && |
59 |
|
!(c == '.') && !(c == '/') && !(c == ':') && !(c == ';') && |
60 |
|
!(c == '<') && !(c == '=') && !(c == '>') && !(c == '?') && |
61 |
|
!(c == '@') && !(c == '[') && !(c == ']') && |
62 |
|
!(c == '^') && !(c == '_') && !(c == '`') && !(c == '{') && |
63 |
|
!(c == '|') && !(c == '}') && !(c == '~') |
64 |
|
) { |
65 |
|
// convert the "special" character into a "\xHH" LSCP escape sequence |
66 |
|
char buf[5]; |
67 |
|
snprintf(buf, sizeof(buf), "\\x%02x", static_cast<unsigned char>(c)); |
68 |
|
txt.replace(i, 1, buf); |
69 |
|
i += 3; |
70 |
|
} |
71 |
|
} |
72 |
|
return txt; |
73 |
|
} |
74 |
|
|
75 |
/** |
/** |
76 |
* Below are a few static members of the LSCPServer class. |
* Below are a few static members of the LSCPServer class. |
77 |
* The big assumption here is that LSCPServer is going to remain a singleton. |
* The big assumption here is that LSCPServer is going to remain a singleton. |
88 |
fd_set LSCPServer::fdSet; |
fd_set LSCPServer::fdSet; |
89 |
int LSCPServer::currentSocket = -1; |
int LSCPServer::currentSocket = -1; |
90 |
std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>(); |
std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>(); |
91 |
|
std::vector<yyparse_param_t>::iterator itCurrentSession = std::vector<yyparse_param_t>::iterator(); |
92 |
std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>(); |
std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>(); |
93 |
std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>(); |
std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>(); |
94 |
std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >(); |
std::map< LSCPEvent::event_t, std::list<int> > LSCPServer::eventSubscriptions = std::map< LSCPEvent::event_t, std::list<int> >(); |
182 |
|
|
183 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
184 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) { |
185 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, Dir)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, InstrumentsDb::toEscapedPath(Dir))); |
186 |
} |
} |
187 |
|
|
188 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryInfoChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryInfoChanged(String Dir) { |
189 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, Dir)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, InstrumentsDb::toEscapedPath(Dir))); |
190 |
} |
} |
191 |
|
|
192 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryNameChanged(String Dir, String NewName) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryNameChanged(String Dir, String NewName) { |
193 |
Dir = "'" + Dir + "'"; |
Dir = "'" + InstrumentsDb::toEscapedPath(Dir) + "'"; |
194 |
NewName = "'" + NewName + "'"; |
NewName = "'" + InstrumentsDb::toEscapedPath(NewName) + "'"; |
195 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, "NAME", Dir, NewName)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, "NAME", Dir, NewName)); |
196 |
} |
} |
197 |
|
|
198 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentCountChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentCountChanged(String Dir) { |
199 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_count, Dir)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_count, InstrumentsDb::toEscapedPath(Dir))); |
200 |
} |
} |
201 |
|
|
202 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
203 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, Instr)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, InstrumentsDb::toEscapedPath(Instr))); |
204 |
} |
} |
205 |
|
|
206 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
207 |
Instr = "'" + Instr + "'"; |
Instr = "'" + InstrumentsDb::toEscapedPath(Instr) + "'"; |
208 |
NewName = "'" + NewName + "'"; |
NewName = "'" + InstrumentsDb::toEscapedPath(NewName) + "'"; |
209 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
210 |
} |
} |
211 |
|
|
255 |
|
|
256 |
listen(hSocket, 1); |
listen(hSocket, 1); |
257 |
Initialized.Set(true); |
Initialized.Set(true); |
258 |
|
|
259 |
// Registering event listeners |
// Registering event listeners |
260 |
pSampler->AddChannelCountListener(&eventHandler); |
pSampler->AddChannelCountListener(&eventHandler); |
261 |
pSampler->AddAudioDeviceCountListener(&eventHandler); |
pSampler->AddAudioDeviceCountListener(&eventHandler); |
364 |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
365 |
restart(NULL, dummy); // restart the 'scanner' |
restart(NULL, dummy); // restart the 'scanner' |
366 |
currentSocket = (*iter).hSession; //a hack |
currentSocket = (*iter).hSession; //a hack |
367 |
|
itCurrentSession = iter; // another hack |
368 |
dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str())); |
dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str())); |
369 |
if ((*iter).bVerbose) { // if echo mode enabled |
if ((*iter).bVerbose) { // if echo mode enabled |
370 |
AnswerClient(bufferedCommands[currentSocket]); |
AnswerClient(bufferedCommands[currentSocket]); |
371 |
} |
} |
372 |
int result = yyparse(&(*iter)); |
int result = yyparse(&(*iter)); |
373 |
currentSocket = -1; //continuation of a hack |
currentSocket = -1; //continuation of a hack |
374 |
|
itCurrentSession = Sessions.end(); // hack as well |
375 |
dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket)); |
dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket)); |
376 |
if (result == LSCP_QUIT) { //Was it a quit command by any chance? |
if (result == LSCP_QUIT) { //Was it a quit command by any chance? |
377 |
CloseConnection(iter); |
CloseConnection(iter); |
464 |
return command.size(); |
return command.size(); |
465 |
} |
} |
466 |
|
|
467 |
|
extern yyparse_param_t* GetCurrentYaccSession() { |
468 |
|
return &(*itCurrentSession); |
469 |
|
} |
470 |
|
|
471 |
/** |
/** |
472 |
* Will be called to try to read the command from the socket |
* Will be called to try to read the command from the socket |
473 |
* If command is read, it will return true. Otherwise false is returned. |
* If command is read, it will return true. Otherwise false is returned. |
655 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
656 |
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
657 |
|
|
658 |
return pEngineChannel; |
return pEngineChannel; |
659 |
} |
} |
660 |
|
|
661 |
/** |
/** |
804 |
LockRTNotify(); |
LockRTNotify(); |
805 |
try { |
try { |
806 |
Engine* pEngine = EngineFactory::Create(EngineName); |
Engine* pEngine = EngineFactory::Create(EngineName); |
807 |
result.Add("DESCRIPTION", pEngine->Description()); |
result.Add("DESCRIPTION", _escapeLscpResponse(pEngine->Description())); |
808 |
result.Add("VERSION", pEngine->Version()); |
result.Add("VERSION", pEngine->Version()); |
809 |
EngineFactory::Destroy(pEngine); |
EngineFactory::Destroy(pEngine); |
810 |
} |
} |
877 |
if (pSamplerChannel->GetMidiInputChannel() == midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
if (pSamplerChannel->GetMidiInputChannel() == midi_chan_all) result.Add("MIDI_INPUT_CHANNEL", "ALL"); |
878 |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
else result.Add("MIDI_INPUT_CHANNEL", pSamplerChannel->GetMidiInputChannel()); |
879 |
|
|
880 |
|
// convert the filename into the correct encoding as defined for LSCP |
881 |
|
// (especially in terms of special characters -> escape sequences) |
882 |
|
if (InstrumentFileName != "NONE" && InstrumentFileName != "") { |
883 |
|
#if WIN32 |
884 |
|
InstrumentFileName = Path::fromWindows(InstrumentFileName).toLscp(); |
885 |
|
#else |
886 |
|
// assuming POSIX |
887 |
|
InstrumentFileName = Path::fromPosix(InstrumentFileName).toLscp(); |
888 |
|
#endif |
889 |
|
} |
890 |
|
|
891 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
892 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
893 |
result.Add("INSTRUMENT_NAME", InstrumentName); |
result.Add("INSTRUMENT_NAME", _escapeLscpResponse(InstrumentName)); |
894 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
895 |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
896 |
result.Add("SOLO", Solo); |
result.Add("SOLO", Solo); |
1832 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
1833 |
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
1834 |
else { // found |
else { // found |
1835 |
result.Add("NAME", iter->second.Name); |
|
1836 |
|
// convert the filename into the correct encoding as defined for LSCP |
1837 |
|
// (especially in terms of special characters -> escape sequences) |
1838 |
|
#if WIN32 |
1839 |
|
const String instrumentFileName = Path::fromWindows(iter->second.InstrumentFile).toLscp(); |
1840 |
|
#else |
1841 |
|
// assuming POSIX |
1842 |
|
const String instrumentFileName = Path::fromPosix(iter->second.InstrumentFile).toLscp(); |
1843 |
|
#endif |
1844 |
|
|
1845 |
|
result.Add("NAME", _escapeLscpResponse(iter->second.Name)); |
1846 |
result.Add("ENGINE_NAME", iter->second.EngineName); |
result.Add("ENGINE_NAME", iter->second.EngineName); |
1847 |
result.Add("INSTRUMENT_FILE", iter->second.InstrumentFile); |
result.Add("INSTRUMENT_FILE", instrumentFileName); |
1848 |
result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex); |
result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex); |
1849 |
String instrumentName; |
String instrumentName; |
1850 |
Engine* pEngine = EngineFactory::Create(iter->second.EngineName); |
Engine* pEngine = EngineFactory::Create(iter->second.EngineName); |
1857 |
} |
} |
1858 |
EngineFactory::Destroy(pEngine); |
EngineFactory::Destroy(pEngine); |
1859 |
} |
} |
1860 |
result.Add("INSTRUMENT_NAME", instrumentName); |
result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName)); |
1861 |
switch (iter->second.LoadMode) { |
switch (iter->second.LoadMode) { |
1862 |
case MidiInstrumentMapper::ON_DEMAND: |
case MidiInstrumentMapper::ON_DEMAND: |
1863 |
result.Add("LOAD_MODE", "ON_DEMAND"); |
result.Add("LOAD_MODE", "ON_DEMAND"); |
2012 |
dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n")); |
dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n")); |
2013 |
LSCPResultSet result; |
LSCPResultSet result; |
2014 |
try { |
try { |
2015 |
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
result.Add("NAME", _escapeLscpResponse(MidiInstrumentMapper::MapName(MidiMapID))); |
2016 |
result.Add("DEFAULT", MidiInstrumentMapper::GetDefaultMap() == MidiMapID); |
result.Add("DEFAULT", MidiInstrumentMapper::GetDefaultMap() == MidiMapID); |
2017 |
} catch (Exception e) { |
} catch (Exception e) { |
2018 |
result.Error(e); |
result.Error(e); |
2063 |
LSCPResultSet result; |
LSCPResultSet result; |
2064 |
try { |
try { |
2065 |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
2066 |
|
|
2067 |
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
2068 |
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
2069 |
|
|
2147 |
try { |
try { |
2148 |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
2149 |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
2150 |
|
|
2151 |
// gather audio routing informations |
// gather audio routing informations |
2152 |
String AudioRouting; |
String AudioRouting; |
2153 |
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
2156 |
} |
} |
2157 |
|
|
2158 |
// success |
// success |
2159 |
result.Add("NAME", pFxSend->Name()); |
result.Add("NAME", _escapeLscpResponse(pFxSend->Name())); |
2160 |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
2161 |
result.Add("LEVEL", ToString(pFxSend->Level())); |
result.Add("LEVEL", ToString(pFxSend->Level())); |
2162 |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
2222 |
return result.Produce(); |
return result.Produce(); |
2223 |
} |
} |
2224 |
|
|
2225 |
|
String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) { |
2226 |
|
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
2227 |
|
LSCPResultSet result; |
2228 |
|
try { |
2229 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2230 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2231 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2232 |
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
2233 |
|
if (pEngineChannel->InstrumentStatus() < 0) throw Exception("No instrument loaded to sampler channel"); |
2234 |
|
Engine* pEngine = pEngineChannel->GetEngine(); |
2235 |
|
InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
2236 |
|
if (!pInstrumentManager) throw Exception("Engine does not provide an instrument manager"); |
2237 |
|
InstrumentManager::instrument_id_t instrumentID; |
2238 |
|
instrumentID.FileName = pEngineChannel->InstrumentFileName(); |
2239 |
|
instrumentID.Index = pEngineChannel->InstrumentIndex(); |
2240 |
|
pInstrumentManager->LaunchInstrumentEditor(instrumentID); |
2241 |
|
} catch (Exception e) { |
2242 |
|
result.Error(e); |
2243 |
|
} |
2244 |
|
return result.Produce(); |
2245 |
|
} |
2246 |
|
|
2247 |
/** |
/** |
2248 |
* Will be called by the parser to reset a particular sampler channel. |
* Will be called by the parser to reset a particular sampler channel. |
2249 |
*/ |
*/ |
2279 |
*/ |
*/ |
2280 |
String LSCPServer::GetServerInfo() { |
String LSCPServer::GetServerInfo() { |
2281 |
dmsg(2,("LSCPServer: GetServerInfo()\n")); |
dmsg(2,("LSCPServer: GetServerInfo()\n")); |
2282 |
|
const std::string description = |
2283 |
|
_escapeLscpResponse("LinuxSampler - modular, streaming capable sampler"); |
2284 |
LSCPResultSet result; |
LSCPResultSet result; |
2285 |
result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler"); |
result.Add("DESCRIPTION", description); |
2286 |
result.Add("VERSION", VERSION); |
result.Add("VERSION", VERSION); |
2287 |
result.Add("PROTOCOL_VERSION", ToString(LSCP_RELEASE_MAJOR) + "." + ToString(LSCP_RELEASE_MINOR)); |
result.Add("PROTOCOL_VERSION", ToString(LSCP_RELEASE_MAJOR) + "." + ToString(LSCP_RELEASE_MINOR)); |
2288 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2290 |
#else |
#else |
2291 |
result.Add("INSTRUMENTS_DB_SUPPORT", "no"); |
result.Add("INSTRUMENTS_DB_SUPPORT", "no"); |
2292 |
#endif |
#endif |
2293 |
|
|
2294 |
return result.Produce(); |
return result.Produce(); |
2295 |
} |
} |
2296 |
|
|
2413 |
|
|
2414 |
for (int i = 0; i < dirs->size(); i++) { |
for (int i = 0; i < dirs->size(); i++) { |
2415 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2416 |
list += "'" + dirs->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(dirs->at(i)) + "'"; |
2417 |
} |
} |
2418 |
|
|
2419 |
result.Add(list); |
result.Add(list); |
2433 |
try { |
try { |
2434 |
DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir); |
DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir); |
2435 |
|
|
2436 |
result.Add("DESCRIPTION", info.Description); |
result.Add("DESCRIPTION", _escapeLscpResponse(info.Description)); |
2437 |
result.Add("CREATED", info.Created); |
result.Add("CREATED", info.Created); |
2438 |
result.Add("MODIFIED", info.Modified); |
result.Add("MODIFIED", info.Modified); |
2439 |
} catch (Exception e) { |
} catch (Exception e) { |
2539 |
} else { |
} else { |
2540 |
throw Exception("Unknown scan mode: " + ScanMode); |
throw Exception("Unknown scan mode: " + ScanMode); |
2541 |
} |
} |
2542 |
|
|
2543 |
if (bBackground) result = id; |
if (bBackground) result = id; |
2544 |
} catch (Exception e) { |
} catch (Exception e) { |
2545 |
result.Error(e); |
result.Error(e); |
2590 |
|
|
2591 |
for (int i = 0; i < instrs->size(); i++) { |
for (int i = 0; i < instrs->size(); i++) { |
2592 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2593 |
list += "'" + instrs->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(instrs->at(i)) + "'"; |
2594 |
} |
} |
2595 |
|
|
2596 |
result.Add(list); |
result.Add(list); |
2617 |
result.Add("SIZE", (int)info.Size); |
result.Add("SIZE", (int)info.Size); |
2618 |
result.Add("CREATED", info.Created); |
result.Add("CREATED", info.Created); |
2619 |
result.Add("MODIFIED", info.Modified); |
result.Add("MODIFIED", info.Modified); |
2620 |
result.Add("DESCRIPTION", FilterEndlines(info.Description)); |
result.Add("DESCRIPTION", _escapeLscpResponse(info.Description)); |
2621 |
result.Add("IS_DRUM", info.IsDrum); |
result.Add("IS_DRUM", info.IsDrum); |
2622 |
result.Add("PRODUCT", FilterEndlines(info.Product)); |
result.Add("PRODUCT", _escapeLscpResponse(info.Product)); |
2623 |
result.Add("ARTISTS", FilterEndlines(info.Artists)); |
result.Add("ARTISTS", _escapeLscpResponse(info.Artists)); |
2624 |
result.Add("KEYWORDS", FilterEndlines(info.Keywords)); |
result.Add("KEYWORDS", _escapeLscpResponse(info.Keywords)); |
2625 |
} catch (Exception e) { |
} catch (Exception e) { |
2626 |
result.Error(e); |
result.Error(e); |
2627 |
} |
} |
2738 |
|
|
2739 |
for (int i = 0; i < pDirectories->size(); i++) { |
for (int i = 0; i < pDirectories->size(); i++) { |
2740 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2741 |
list += "'" + pDirectories->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(pDirectories->at(i)) + "'"; |
2742 |
} |
} |
2743 |
|
|
2744 |
result.Add(list); |
result.Add(list); |
2794 |
|
|
2795 |
for (int i = 0; i < pInstruments->size(); i++) { |
for (int i = 0; i < pInstruments->size(); i++) { |
2796 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2797 |
list += "'" + pInstruments->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(pInstruments->at(i)) + "'"; |
2798 |
} |
} |
2799 |
|
|
2800 |
result.Add(list); |
result.Add(list); |
2807 |
return result.Produce(); |
return result.Produce(); |
2808 |
} |
} |
2809 |
|
|
2810 |
|
String LSCPServer::FormatInstrumentsDb() { |
2811 |
|
dmsg(2,("LSCPServer: FormatInstrumentsDb()\n")); |
2812 |
|
LSCPResultSet result; |
2813 |
|
#if HAVE_SQLITE3 |
2814 |
|
try { |
2815 |
|
InstrumentsDb::GetInstrumentsDb()->Format(); |
2816 |
|
} catch (Exception e) { |
2817 |
|
result.Error(e); |
2818 |
|
} |
2819 |
|
#else |
2820 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2821 |
|
#endif |
2822 |
|
return result.Produce(); |
2823 |
|
} |
2824 |
|
|
2825 |
|
|
2826 |
/** |
/** |
2827 |
* Will be called by the parser to enable or disable echo mode; if echo |
* Will be called by the parser to enable or disable echo mode; if echo |
2841 |
} |
} |
2842 |
return result.Produce(); |
return result.Produce(); |
2843 |
} |
} |
|
|
|
|
String LSCPServer::FilterEndlines(String s) { |
|
|
String s2 = s; |
|
|
for (int i = 0; i < s2.length(); i++) { |
|
|
if (s2.at(i) == '\r') s2.at(i) = ' '; |
|
|
else if (s2.at(i) == '\n') s2.at(i) = ' '; |
|
|
} |
|
|
|
|
|
return s2; |
|
|
} |
|