84 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_dir_info, "DB_INSTRUMENT_DIRECTORY_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_dir_info, "DB_INSTRUMENT_DIRECTORY_INFO"); |
85 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_count, "DB_INSTRUMENT_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_count, "DB_INSTRUMENT_COUNT"); |
86 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO"); |
87 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instrs_job_info, "DB_INSTRUMENTS_JOB_INFO"); |
88 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
89 |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
90 |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
165 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
166 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, Instr)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, Instr)); |
167 |
} |
} |
168 |
|
|
169 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
170 |
Instr = "'" + Instr + "'"; |
Instr = "'" + Instr + "'"; |
171 |
NewName = "'" + NewName + "'"; |
NewName = "'" + NewName + "'"; |
172 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
173 |
} |
} |
174 |
|
|
175 |
|
void LSCPServer::DbInstrumentsEventHandler::JobStatusChanged(int JobId) { |
176 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instrs_job_info, JobId)); |
177 |
|
} |
178 |
#endif // HAVE_SQLITE3 |
#endif // HAVE_SQLITE3 |
179 |
|
|
180 |
|
|
2417 |
return result.Produce(); |
return result.Produce(); |
2418 |
} |
} |
2419 |
|
|
2420 |
String LSCPServer::AddDbInstruments(String DbDir, String FilePath, int Index) { |
String LSCPServer::AddDbInstruments(String DbDir, String FilePath, int Index, bool bBackground) { |
2421 |
dmsg(2,("LSCPServer: AddDbInstruments(DbDir=%s,FilePath=%s,Index=%d)\n", DbDir.c_str(), FilePath.c_str(), Index)); |
dmsg(2,("LSCPServer: AddDbInstruments(DbDir=%s,FilePath=%s,Index=%d,bBackground=%d)\n", DbDir.c_str(), FilePath.c_str(), Index, bBackground)); |
|
LSCPResultSet result; |
|
|
#if HAVE_SQLITE3 |
|
|
try { |
|
|
InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index); |
|
|
} catch (Exception e) { |
|
|
result.Error(e); |
|
|
} |
|
|
#else |
|
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
|
|
#endif |
|
|
return result.Produce(); |
|
|
} |
|
|
|
|
|
String LSCPServer::AddDbInstrumentsFlat(String DbDir, String FsDir) { |
|
|
dmsg(2,("LSCPServer: AddDbInstrumentsFlat(DbDir=%s,FilePath=%s)\n", DbDir.c_str(), FsDir.c_str())); |
|
2422 |
LSCPResultSet result; |
LSCPResultSet result; |
2423 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2424 |
try { |
try { |
2425 |
InstrumentsDb::GetInstrumentsDb()->AddInstrumentsRecursive(DbDir, FsDir, true); |
int id; |
2426 |
|
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
2427 |
|
id = db->AddInstruments(DbDir, FilePath, Index, bBackground); |
2428 |
|
if (bBackground) result = id; |
2429 |
} catch (Exception e) { |
} catch (Exception e) { |
2430 |
result.Error(e); |
result.Error(e); |
2431 |
} |
} |
2435 |
return result.Produce(); |
return result.Produce(); |
2436 |
} |
} |
2437 |
|
|
2438 |
String LSCPServer::AddDbInstrumentsNonrecursive(String DbDir, String FsDir) { |
String LSCPServer::AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground) { |
2439 |
dmsg(2,("LSCPServer: AddDbInstrumentsNonrecursive(DbDir=%s,FilePath=%s)\n", DbDir.c_str(), FsDir.c_str())); |
dmsg(2,("LSCPServer: AddDbInstruments(ScanMode=%s,DbDir=%s,FsDir=%s,bBackground=%d)\n", ScanMode.c_str(), DbDir.c_str(), FsDir.c_str(), bBackground)); |
2440 |
LSCPResultSet result; |
LSCPResultSet result; |
2441 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2442 |
try { |
try { |
2443 |
InstrumentsDb::GetInstrumentsDb()->AddInstrumentsNonrecursive(DbDir, FsDir); |
int id; |
2444 |
|
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
2445 |
|
if (ScanMode.compare("RECURSIVE") == 0) { |
2446 |
|
id = db->AddInstruments(RECURSIVE, DbDir, FsDir, bBackground); |
2447 |
|
} else if (ScanMode.compare("NON_RECURSIVE") == 0) { |
2448 |
|
id = db->AddInstruments(NON_RECURSIVE, DbDir, FsDir, bBackground); |
2449 |
|
} else if (ScanMode.compare("FLAT") == 0) { |
2450 |
|
id = db->AddInstruments(FLAT, DbDir, FsDir, bBackground); |
2451 |
|
} else { |
2452 |
|
throw Exception("Unknown scan mode: " + ScanMode); |
2453 |
|
} |
2454 |
|
|
2455 |
|
if (bBackground) result = id; |
2456 |
} catch (Exception e) { |
} catch (Exception e) { |
2457 |
result.Error(e); |
result.Error(e); |
2458 |
} |
} |
2537 |
} catch (Exception e) { |
} catch (Exception e) { |
2538 |
result.Error(e); |
result.Error(e); |
2539 |
} |
} |
2540 |
|
#else |
2541 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2542 |
|
#endif |
2543 |
|
return result.Produce(); |
2544 |
|
} |
2545 |
|
|
2546 |
|
String LSCPServer::GetDbInstrumentsJobInfo(int JobId) { |
2547 |
|
dmsg(2,("LSCPServer: GetDbInstrumentsJobInfo(JobId=%d)\n", JobId)); |
2548 |
|
LSCPResultSet result; |
2549 |
|
#if HAVE_SQLITE3 |
2550 |
|
try { |
2551 |
|
ScanJob job = InstrumentsDb::GetInstrumentsDb()->Jobs.GetJobById(JobId); |
2552 |
|
|
2553 |
|
result.Add("FILES_TOTAL", job.FilesTotal); |
2554 |
|
result.Add("FILES_SCANNED", job.FilesScanned); |
2555 |
|
result.Add("SCANNING", job.Scanning); |
2556 |
|
result.Add("STATUS", job.Status); |
2557 |
|
} catch (Exception e) { |
2558 |
|
result.Error(e); |
2559 |
|
} |
2560 |
#else |
#else |
2561 |
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2562 |
#endif |
#endif |