2294 |
return result.Produce(); |
return result.Produce(); |
2295 |
} |
} |
2296 |
|
|
2297 |
String LSCPServer::GetDbInstrumentDirectoryCount(String Dir) { |
String LSCPServer::GetDbInstrumentDirectoryCount(String Dir, bool Recursive) { |
2298 |
dmsg(2,("LSCPServer: GetDbInstrumentDirectoryCount(Dir=%s)\n", Dir.c_str())); |
dmsg(2,("LSCPServer: GetDbInstrumentDirectoryCount(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive)); |
2299 |
LSCPResultSet result; |
LSCPResultSet result; |
2300 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2301 |
try { |
try { |
2302 |
result.Add(InstrumentsDb::GetInstrumentsDb()->GetDirectoryCount(Dir)); |
result.Add(InstrumentsDb::GetInstrumentsDb()->GetDirectoryCount(Dir, Recursive)); |
2303 |
} catch (Exception e) { |
} catch (Exception e) { |
2304 |
result.Error(e); |
result.Error(e); |
2305 |
} |
} |
2309 |
return result.Produce(); |
return result.Produce(); |
2310 |
} |
} |
2311 |
|
|
2312 |
String LSCPServer::GetDbInstrumentDirectories(String Dir) { |
String LSCPServer::GetDbInstrumentDirectories(String Dir, bool Recursive) { |
2313 |
dmsg(2,("LSCPServer: GetDbInstrumentDirectories(Dir=%s)\n", Dir.c_str())); |
dmsg(2,("LSCPServer: GetDbInstrumentDirectories(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive)); |
2314 |
LSCPResultSet result; |
LSCPResultSet result; |
2315 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2316 |
try { |
try { |
2317 |
String list; |
String list; |
2318 |
StringListPtr dirs = InstrumentsDb::GetInstrumentsDb()->GetDirectories(Dir); |
StringListPtr dirs = InstrumentsDb::GetInstrumentsDb()->GetDirectories(Dir, Recursive); |
2319 |
|
|
2320 |
for (int i = 0; i < dirs->size(); i++) { |
for (int i = 0; i < dirs->size(); i++) { |
2321 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2381 |
return result.Produce(); |
return result.Produce(); |
2382 |
} |
} |
2383 |
|
|
2384 |
|
String LSCPServer::CopyDbInstrumentDirectory(String Dir, String Dst) { |
2385 |
|
dmsg(2,("LSCPServer: CopyDbInstrumentDirectory(Dir=%s,Dst=%s)\n", Dir.c_str(), Dst.c_str())); |
2386 |
|
LSCPResultSet result; |
2387 |
|
#if HAVE_SQLITE3 |
2388 |
|
try { |
2389 |
|
InstrumentsDb::GetInstrumentsDb()->CopyDirectory(Dir, Dst); |
2390 |
|
} catch (Exception e) { |
2391 |
|
result.Error(e); |
2392 |
|
} |
2393 |
|
#else |
2394 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2395 |
|
#endif |
2396 |
|
return result.Produce(); |
2397 |
|
} |
2398 |
|
|
2399 |
String LSCPServer::SetDbInstrumentDirectoryDescription(String Dir, String Desc) { |
String LSCPServer::SetDbInstrumentDirectoryDescription(String Dir, String Desc) { |
2400 |
dmsg(2,("LSCPServer: SetDbInstrumentDirectoryDescription(Dir=%s,Desc=%s)\n", Dir.c_str(), Desc.c_str())); |
dmsg(2,("LSCPServer: SetDbInstrumentDirectoryDescription(Dir=%s,Desc=%s)\n", Dir.c_str(), Desc.c_str())); |
2401 |
LSCPResultSet result; |
LSCPResultSet result; |
2471 |
return result.Produce(); |
return result.Produce(); |
2472 |
} |
} |
2473 |
|
|
2474 |
String LSCPServer::GetDbInstrumentCount(String Dir) { |
String LSCPServer::GetDbInstrumentCount(String Dir, bool Recursive) { |
2475 |
dmsg(2,("LSCPServer: GetDbInstrumentCount(Dir=%s)\n", Dir.c_str())); |
dmsg(2,("LSCPServer: GetDbInstrumentCount(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive)); |
2476 |
LSCPResultSet result; |
LSCPResultSet result; |
2477 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2478 |
try { |
try { |
2479 |
result.Add(InstrumentsDb::GetInstrumentsDb()->GetInstrumentCount(Dir)); |
result.Add(InstrumentsDb::GetInstrumentsDb()->GetInstrumentCount(Dir, Recursive)); |
2480 |
} catch (Exception e) { |
} catch (Exception e) { |
2481 |
result.Error(e); |
result.Error(e); |
2482 |
} |
} |
2486 |
return result.Produce(); |
return result.Produce(); |
2487 |
} |
} |
2488 |
|
|
2489 |
String LSCPServer::GetDbInstruments(String Dir) { |
String LSCPServer::GetDbInstruments(String Dir, bool Recursive) { |
2490 |
dmsg(2,("LSCPServer: GetDbInstruments(Dir=%s)\n", Dir.c_str())); |
dmsg(2,("LSCPServer: GetDbInstruments(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive)); |
2491 |
LSCPResultSet result; |
LSCPResultSet result; |
2492 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2493 |
try { |
try { |
2494 |
String list; |
String list; |
2495 |
StringListPtr instrs = InstrumentsDb::GetInstrumentsDb()->GetInstruments(Dir); |
StringListPtr instrs = InstrumentsDb::GetInstrumentsDb()->GetInstruments(Dir, Recursive); |
2496 |
|
|
2497 |
for (int i = 0; i < instrs->size(); i++) { |
for (int i = 0; i < instrs->size(); i++) { |
2498 |
if (list != "") list += ","; |
if (list != "") list += ","; |
2567 |
return result.Produce(); |
return result.Produce(); |
2568 |
} |
} |
2569 |
|
|
2570 |
|
String LSCPServer::CopyDbInstrument(String Instr, String Dst) { |
2571 |
|
dmsg(2,("LSCPServer: CopyDbInstrument(Instr=%s,Dst=%s)\n", Instr.c_str(), Dst.c_str())); |
2572 |
|
LSCPResultSet result; |
2573 |
|
#if HAVE_SQLITE3 |
2574 |
|
try { |
2575 |
|
InstrumentsDb::GetInstrumentsDb()->CopyInstrument(Instr, Dst); |
2576 |
|
} catch (Exception e) { |
2577 |
|
result.Error(e); |
2578 |
|
} |
2579 |
|
#else |
2580 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2581 |
|
#endif |
2582 |
|
return result.Produce(); |
2583 |
|
} |
2584 |
|
|
2585 |
String LSCPServer::SetDbInstrumentDescription(String Instr, String Desc) { |
String LSCPServer::SetDbInstrumentDescription(String Instr, String Desc) { |
2586 |
dmsg(2,("LSCPServer: SetDbInstrumentDescription(Instr=%s,Desc=%s)\n", Instr.c_str(), Desc.c_str())); |
dmsg(2,("LSCPServer: SetDbInstrumentDescription(Instr=%s,Desc=%s)\n", Instr.c_str(), Desc.c_str())); |
2587 |
LSCPResultSet result; |
LSCPResultSet result; |
2591 |
} catch (Exception e) { |
} catch (Exception e) { |
2592 |
result.Error(e); |
result.Error(e); |
2593 |
} |
} |
2594 |
|
#else |
2595 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2596 |
|
#endif |
2597 |
|
return result.Produce(); |
2598 |
|
} |
2599 |
|
|
2600 |
|
String LSCPServer::FindDbInstrumentDirectories(String Dir, std::map<String,String> Parameters, bool Recursive) { |
2601 |
|
dmsg(2,("LSCPServer: FindDbInstrumentDirectories(Dir=%s)\n", Dir.c_str())); |
2602 |
|
LSCPResultSet result; |
2603 |
|
#if HAVE_SQLITE3 |
2604 |
|
try { |
2605 |
|
SearchQuery Query; |
2606 |
|
std::map<String,String>::iterator iter; |
2607 |
|
for (iter = Parameters.begin(); iter != Parameters.end(); iter++) { |
2608 |
|
if (iter->first.compare("NAME") == 0) { |
2609 |
|
Query.Name = iter->second; |
2610 |
|
} else if (iter->first.compare("CREATED") == 0) { |
2611 |
|
Query.SetCreated(iter->second); |
2612 |
|
} else if (iter->first.compare("MODIFIED") == 0) { |
2613 |
|
Query.SetModified(iter->second); |
2614 |
|
} else if (iter->first.compare("DESCRIPTION") == 0) { |
2615 |
|
Query.Description = iter->second; |
2616 |
|
} else { |
2617 |
|
throw Exception("Unknown search criteria: " + iter->first); |
2618 |
|
} |
2619 |
|
} |
2620 |
|
|
2621 |
|
String list; |
2622 |
|
StringListPtr pDirectories = |
2623 |
|
InstrumentsDb::GetInstrumentsDb()->FindDirectories(Dir, &Query, Recursive); |
2624 |
|
|
2625 |
|
for (int i = 0; i < pDirectories->size(); i++) { |
2626 |
|
if (list != "") list += ","; |
2627 |
|
list += "'" + pDirectories->at(i) + "'"; |
2628 |
|
} |
2629 |
|
|
2630 |
|
result.Add(list); |
2631 |
|
} catch (Exception e) { |
2632 |
|
result.Error(e); |
2633 |
|
} |
2634 |
|
#else |
2635 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2636 |
|
#endif |
2637 |
|
return result.Produce(); |
2638 |
|
} |
2639 |
|
|
2640 |
|
String LSCPServer::FindDbInstruments(String Dir, std::map<String,String> Parameters, bool Recursive) { |
2641 |
|
dmsg(2,("LSCPServer: FindDbInstruments(Dir=%s)\n", Dir.c_str())); |
2642 |
|
LSCPResultSet result; |
2643 |
|
#if HAVE_SQLITE3 |
2644 |
|
try { |
2645 |
|
SearchQuery Query; |
2646 |
|
std::map<String,String>::iterator iter; |
2647 |
|
for (iter = Parameters.begin(); iter != Parameters.end(); iter++) { |
2648 |
|
if (iter->first.compare("NAME") == 0) { |
2649 |
|
Query.Name = iter->second; |
2650 |
|
} else if (iter->first.compare("FORMAT_FAMILIES") == 0) { |
2651 |
|
Query.SetFormatFamilies(iter->second); |
2652 |
|
} else if (iter->first.compare("SIZE") == 0) { |
2653 |
|
Query.SetSize(iter->second); |
2654 |
|
} else if (iter->first.compare("CREATED") == 0) { |
2655 |
|
Query.SetCreated(iter->second); |
2656 |
|
} else if (iter->first.compare("MODIFIED") == 0) { |
2657 |
|
Query.SetModified(iter->second); |
2658 |
|
} else if (iter->first.compare("DESCRIPTION") == 0) { |
2659 |
|
Query.Description = iter->second; |
2660 |
|
} else if (iter->first.compare("IS_DRUM") == 0) { |
2661 |
|
if (!strcasecmp(iter->second.c_str(), "true")) { |
2662 |
|
Query.InstrType = SearchQuery::DRUM; |
2663 |
|
} else { |
2664 |
|
Query.InstrType = SearchQuery::CHROMATIC; |
2665 |
|
} |
2666 |
|
} else if (iter->first.compare("PRODUCT") == 0) { |
2667 |
|
Query.Product = iter->second; |
2668 |
|
} else if (iter->first.compare("ARTISTS") == 0) { |
2669 |
|
Query.Artists = iter->second; |
2670 |
|
} else if (iter->first.compare("KEYWORDS") == 0) { |
2671 |
|
Query.Keywords = iter->second; |
2672 |
|
} else { |
2673 |
|
throw Exception("Unknown search criteria: " + iter->first); |
2674 |
|
} |
2675 |
|
} |
2676 |
|
|
2677 |
|
String list; |
2678 |
|
StringListPtr pInstruments = |
2679 |
|
InstrumentsDb::GetInstrumentsDb()->FindInstruments(Dir, &Query, Recursive); |
2680 |
|
|
2681 |
|
for (int i = 0; i < pInstruments->size(); i++) { |
2682 |
|
if (list != "") list += ","; |
2683 |
|
list += "'" + pInstruments->at(i) + "'"; |
2684 |
|
} |
2685 |
|
|
2686 |
|
result.Add(list); |
2687 |
|
} catch (Exception e) { |
2688 |
|
result.Error(e); |
2689 |
|
} |
2690 |
#else |
#else |
2691 |
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2692 |
#endif |
#endif |