146 |
|
|
147 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
148 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) { |
149 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, Dir)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, InstrumentsDb::toEscapedPath(Dir))); |
150 |
} |
} |
151 |
|
|
152 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryInfoChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryInfoChanged(String Dir) { |
153 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, Dir)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, InstrumentsDb::toEscapedPath(Dir))); |
154 |
} |
} |
155 |
|
|
156 |
void LSCPServer::DbInstrumentsEventHandler::DirectoryNameChanged(String Dir, String NewName) { |
void LSCPServer::DbInstrumentsEventHandler::DirectoryNameChanged(String Dir, String NewName) { |
157 |
Dir = "'" + Dir + "'"; |
Dir = "'" + InstrumentsDb::toEscapedPath(Dir) + "'"; |
158 |
NewName = "'" + NewName + "'"; |
NewName = "'" + InstrumentsDb::toEscapedPath(NewName) + "'"; |
159 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, "NAME", Dir, NewName)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, "NAME", Dir, NewName)); |
160 |
} |
} |
161 |
|
|
162 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentCountChanged(String Dir) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentCountChanged(String Dir) { |
163 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_count, Dir)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_count, InstrumentsDb::toEscapedPath(Dir))); |
164 |
} |
} |
165 |
|
|
166 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
167 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, Instr)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, InstrumentsDb::toEscapedPath(Instr))); |
168 |
} |
} |
169 |
|
|
170 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
171 |
Instr = "'" + Instr + "'"; |
Instr = "'" + InstrumentsDb::toEscapedPath(Instr) + "'"; |
172 |
NewName = "'" + NewName + "'"; |
NewName = "'" + InstrumentsDb::toEscapedPath(NewName) + "'"; |
173 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
174 |
} |
} |
175 |
|
|
2173 |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2174 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2175 |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
2176 |
|
if (pEngineChannel->InstrumentStatus() < 0) throw Exception("No instrument loaded to sampler channel"); |
2177 |
Engine* pEngine = pEngineChannel->GetEngine(); |
Engine* pEngine = pEngineChannel->GetEngine(); |
2178 |
InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
2179 |
if (!pInstrumentManager) throw Exception("Engine does not provide an instrument manager"); |
if (!pInstrumentManager) throw Exception("Engine does not provide an instrument manager"); |
2354 |
|
|
2355 |
for (int i = 0; i < dirs->size(); i++) { |
for (int i = 0; i < dirs->size(); i++) { |
2356 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2357 |
list += "'" + dirs->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(dirs->at(i)) + "'"; |
2358 |
} |
} |
2359 |
|
|
2360 |
result.Add(list); |
result.Add(list); |
2374 |
try { |
try { |
2375 |
DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir); |
DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir); |
2376 |
|
|
2377 |
result.Add("DESCRIPTION", info.Description); |
result.Add("DESCRIPTION", InstrumentsDb::toEscapedText(info.Description)); |
2378 |
result.Add("CREATED", info.Created); |
result.Add("CREATED", info.Created); |
2379 |
result.Add("MODIFIED", info.Modified); |
result.Add("MODIFIED", info.Modified); |
2380 |
} catch (Exception e) { |
} catch (Exception e) { |
2531 |
|
|
2532 |
for (int i = 0; i < instrs->size(); i++) { |
for (int i = 0; i < instrs->size(); i++) { |
2533 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2534 |
list += "'" + instrs->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(instrs->at(i)) + "'"; |
2535 |
} |
} |
2536 |
|
|
2537 |
result.Add(list); |
result.Add(list); |
2558 |
result.Add("SIZE", (int)info.Size); |
result.Add("SIZE", (int)info.Size); |
2559 |
result.Add("CREATED", info.Created); |
result.Add("CREATED", info.Created); |
2560 |
result.Add("MODIFIED", info.Modified); |
result.Add("MODIFIED", info.Modified); |
2561 |
result.Add("DESCRIPTION", FilterEndlines(info.Description)); |
result.Add("DESCRIPTION", InstrumentsDb::toEscapedText(info.Description)); |
2562 |
result.Add("IS_DRUM", info.IsDrum); |
result.Add("IS_DRUM", info.IsDrum); |
2563 |
result.Add("PRODUCT", FilterEndlines(info.Product)); |
result.Add("PRODUCT", InstrumentsDb::toEscapedText(info.Product)); |
2564 |
result.Add("ARTISTS", FilterEndlines(info.Artists)); |
result.Add("ARTISTS", InstrumentsDb::toEscapedText(info.Artists)); |
2565 |
result.Add("KEYWORDS", FilterEndlines(info.Keywords)); |
result.Add("KEYWORDS", InstrumentsDb::toEscapedText(info.Keywords)); |
2566 |
} catch (Exception e) { |
} catch (Exception e) { |
2567 |
result.Error(e); |
result.Error(e); |
2568 |
} |
} |
2679 |
|
|
2680 |
for (int i = 0; i < pDirectories->size(); i++) { |
for (int i = 0; i < pDirectories->size(); i++) { |
2681 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2682 |
list += "'" + pDirectories->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(pDirectories->at(i)) + "'"; |
2683 |
} |
} |
2684 |
|
|
2685 |
result.Add(list); |
result.Add(list); |
2735 |
|
|
2736 |
for (int i = 0; i < pInstruments->size(); i++) { |
for (int i = 0; i < pInstruments->size(); i++) { |
2737 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2738 |
list += "'" + pInstruments->at(i) + "'"; |
list += "'" + InstrumentsDb::toEscapedPath(pInstruments->at(i)) + "'"; |
2739 |
} |
} |
2740 |
|
|
2741 |
result.Add(list); |
result.Add(list); |
2767 |
} |
} |
2768 |
return result.Produce(); |
return result.Produce(); |
2769 |
} |
} |
|
|
|
|
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; |
|
|
} |
|