26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
//#include "../common/global.h" |
//#include "../common/global.h" |
28 |
|
|
29 |
#ifdef HAVE_SQLITE3 |
#include <fcntl.h> |
30 |
#include "sqlite3.h" |
|
31 |
|
#if HAVE_SQLITE3 |
32 |
|
# include "sqlite3.h" |
33 |
#endif |
#endif |
34 |
|
|
35 |
#include "../engines/gig/Engine.h" |
#include "../engines/EngineFactory.h" |
36 |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
37 |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
38 |
|
|
62 |
|
|
63 |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) { |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) { |
64 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
65 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channels, "CHANNELS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
66 |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
67 |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
68 |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
69 |
LSCPEvent::RegisterEvent(LSCPEvent::event_info, "INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
70 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
71 |
|
hSocket = -1; |
72 |
|
} |
73 |
|
|
74 |
|
LSCPServer::~LSCPServer() { |
75 |
|
if (hSocket >= 0) close(hSocket); |
76 |
} |
} |
77 |
|
|
78 |
/** |
/** |
90 |
} |
} |
91 |
|
|
92 |
int LSCPServer::Main() { |
int LSCPServer::Main() { |
93 |
int hSocket = socket(AF_INET, SOCK_STREAM, 0); |
hSocket = socket(AF_INET, SOCK_STREAM, 0); |
94 |
if (hSocket < 0) { |
if (hSocket < 0) { |
95 |
std::cerr << "LSCPServer: Could not create server socket." << std::endl; |
std::cerr << "LSCPServer: Could not create server socket." << std::endl; |
96 |
//return -1; |
//return -1; |
173 |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
int dummy; // just a temporary hack to fulfill the restart() function prototype |
174 |
restart(NULL, dummy); // restart the 'scanner' |
restart(NULL, dummy); // restart the 'scanner' |
175 |
currentSocket = (*iter).hSession; //a hack |
currentSocket = (*iter).hSession; //a hack |
176 |
|
dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str())); |
177 |
if ((*iter).bVerbose) { // if echo mode enabled |
if ((*iter).bVerbose) { // if echo mode enabled |
178 |
AnswerClient(bufferedCommands[currentSocket]); |
AnswerClient(bufferedCommands[currentSocket]); |
179 |
} |
} |
460 |
try { |
try { |
461 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
462 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
463 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
464 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel yet"); |
465 |
if (!pSamplerChannel->GetAudioOutputDevice()) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
466 |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
467 |
if (bBackground) { |
if (bBackground) { |
468 |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngine); |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngineChannel); |
469 |
} |
} |
470 |
else { |
else { |
471 |
// tell the engine which instrument to load |
// tell the engine channel which instrument to load |
472 |
pEngine->PrepareLoadInstrument(Filename.c_str(), uiInstrument); |
pEngineChannel->PrepareLoadInstrument(Filename.c_str(), uiInstrument); |
473 |
// actually start to load the instrument (blocks until completed) |
// actually start to load the instrument (blocks until completed) |
474 |
pEngine->LoadInstrument(); |
pEngineChannel->LoadInstrument(); |
475 |
} |
} |
476 |
} |
} |
477 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
481 |
} |
} |
482 |
|
|
483 |
/** |
/** |
484 |
* Will be called by the parser to load and deploy an engine. |
* Will be called by the parser to assign a sampler engine type to a |
485 |
|
* sampler channel. |
486 |
*/ |
*/ |
487 |
String LSCPServer::LoadEngine(String EngineName, uint uiSamplerChannel) { |
String LSCPServer::SetEngineType(String EngineName, uint uiSamplerChannel) { |
488 |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
dmsg(2,("LSCPServer: LoadEngine(EngineName=%s,SamplerChannel=%d)\n", EngineName.c_str(), uiSamplerChannel)); |
489 |
LSCPResultSet result; |
LSCPResultSet result; |
490 |
try { |
try { |
|
Engine::type_t type; |
|
|
if ((EngineName == "GigEngine") || (EngineName == "gig")) type = Engine::type_gig; |
|
|
else throw LinuxSamplerException("Unknown engine type"); |
|
491 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
492 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
493 |
LockRTNotify(); |
LockRTNotify(); |
494 |
pSamplerChannel->LoadEngine(type); |
pSamplerChannel->SetEngineType(EngineName); |
495 |
UnlockRTNotify(); |
UnlockRTNotify(); |
496 |
} |
} |
497 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
550 |
} |
} |
551 |
|
|
552 |
/** |
/** |
553 |
* Will be called by the parser to get all available engines. |
* Will be called by the parser to get the amount of all available engines. |
554 |
*/ |
*/ |
555 |
String LSCPServer::GetAvailableEngines() { |
String LSCPServer::GetAvailableEngines() { |
556 |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
dmsg(2,("LSCPServer: GetAvailableEngines()\n")); |
557 |
LSCPResultSet result("GigEngine"); |
LSCPResultSet result("1"); |
558 |
|
return result.Produce(); |
559 |
|
} |
560 |
|
|
561 |
|
/** |
562 |
|
* Will be called by the parser to get a list of all available engines. |
563 |
|
*/ |
564 |
|
String LSCPServer::ListAvailableEngines() { |
565 |
|
dmsg(2,("LSCPServer: ListAvailableEngines()\n")); |
566 |
|
LSCPResultSet result("\'GIG\'"); |
567 |
return result.Produce(); |
return result.Produce(); |
568 |
} |
} |
569 |
|
|
570 |
/** |
/** |
571 |
* Will be called by the parser to get descriptions for a particular engine. |
* Will be called by the parser to get descriptions for a particular |
572 |
|
* sampler engine. |
573 |
*/ |
*/ |
574 |
String LSCPServer::GetEngineInfo(String EngineName) { |
String LSCPServer::GetEngineInfo(String EngineName) { |
575 |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
dmsg(2,("LSCPServer: GetEngineInfo(EngineName=%s)\n", EngineName.c_str())); |
576 |
LSCPResultSet result; |
LSCPResultSet result; |
577 |
try { |
try { |
578 |
if ((EngineName == "GigEngine") || (EngineName == "gig")) { |
Engine* pEngine = EngineFactory::Create(EngineName); |
579 |
Engine* pEngine = new LinuxSampler::gig::Engine; |
result.Add("DESCRIPTION", pEngine->Description()); |
580 |
result.Add("DESCRIPTION", pEngine->Description()); |
result.Add("VERSION", pEngine->Version()); |
581 |
result.Add("VERSION", pEngine->Version()); |
delete pEngine; |
|
delete pEngine; |
|
|
} |
|
|
else throw LinuxSamplerException("Unknown engine type"); |
|
582 |
} |
} |
583 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
584 |
result.Error(e); |
result.Error(e); |
596 |
try { |
try { |
597 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
598 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
599 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
600 |
|
|
601 |
//Defaults values |
//Defaults values |
602 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
608 |
int AudioOutputChannels = 0; |
int AudioOutputChannels = 0; |
609 |
String AudioRouting; |
String AudioRouting; |
610 |
|
|
611 |
if (pEngine) { |
if (pEngineChannel) { |
612 |
EngineName = pEngine->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
613 |
AudioOutputChannels = pEngine->Channels(); |
AudioOutputChannels = pEngineChannel->Channels(); |
614 |
Volume = pEngine->Volume(); |
Volume = pEngineChannel->Volume(); |
615 |
InstrumentStatus = pEngine->InstrumentStatus(); |
InstrumentStatus = pEngineChannel->InstrumentStatus(); |
616 |
InstrumentIndex = pEngine->InstrumentIndex(); |
InstrumentIndex = pEngineChannel->InstrumentIndex(); |
617 |
if (InstrumentIndex != -1) |
if (InstrumentIndex != -1) { |
618 |
{ |
InstrumentFileName = pEngineChannel->InstrumentFileName(); |
619 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentName = pEngineChannel->InstrumentName(); |
620 |
InstrumentName = pEngine->InstrumentName(); |
} |
621 |
} |
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
|
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
|
622 |
if (AudioRouting != "") AudioRouting += ","; |
if (AudioRouting != "") AudioRouting += ","; |
623 |
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
AudioRouting += ToString(pEngineChannel->OutputChannel(chan)); |
624 |
} |
} |
625 |
} |
} |
626 |
|
|
658 |
try { |
try { |
659 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
660 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
661 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
662 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel"); |
663 |
result.Add(pEngine->VoiceCount()); |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
664 |
|
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
665 |
} |
} |
666 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
667 |
result.Error(e); |
result.Error(e); |
679 |
try { |
try { |
680 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
681 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
682 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
683 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
684 |
result.Add(pEngine->DiskStreamCount()); |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
685 |
|
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
686 |
} |
} |
687 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
688 |
result.Error(e); |
result.Error(e); |
700 |
try { |
try { |
701 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
702 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
703 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
704 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
705 |
if (!pEngine->DiskStreamSupported()) |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
706 |
result.Add("NA"); |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
707 |
else { |
else { |
708 |
switch (ResponseType) { |
switch (ResponseType) { |
709 |
case fill_response_bytes: |
case fill_response_bytes: |
710 |
result.Add(pEngine->DiskStreamBufferFillBytes()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillBytes()); |
711 |
break; |
break; |
712 |
case fill_response_percentage: |
case fill_response_percentage: |
713 |
result.Add(pEngine->DiskStreamBufferFillPercentage()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage()); |
714 |
break; |
break; |
715 |
default: |
default: |
716 |
throw LinuxSamplerException("Unknown fill response type"); |
throw LinuxSamplerException("Unknown fill response type"); |
717 |
} |
} |
727 |
dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n")); |
dmsg(2,("LSCPServer: GetAvailableAudioOutputDrivers()\n")); |
728 |
LSCPResultSet result; |
LSCPResultSet result; |
729 |
try { |
try { |
730 |
|
int n = AudioOutputDeviceFactory::AvailableDrivers().size(); |
731 |
|
result.Add(n); |
732 |
|
} |
733 |
|
catch (LinuxSamplerException e) { |
734 |
|
result.Error(e); |
735 |
|
} |
736 |
|
return result.Produce(); |
737 |
|
} |
738 |
|
|
739 |
|
String LSCPServer::ListAvailableAudioOutputDrivers() { |
740 |
|
dmsg(2,("LSCPServer: ListAvailableAudioOutputDrivers()\n")); |
741 |
|
LSCPResultSet result; |
742 |
|
try { |
743 |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
String s = AudioOutputDeviceFactory::AvailableDriversAsString(); |
744 |
result.Add(s); |
result.Add(s); |
745 |
} |
} |
753 |
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
dmsg(2,("LSCPServer: GetAvailableMidiInputDrivers()\n")); |
754 |
LSCPResultSet result; |
LSCPResultSet result; |
755 |
try { |
try { |
756 |
|
int n = MidiInputDeviceFactory::AvailableDrivers().size(); |
757 |
|
result.Add(n); |
758 |
|
} |
759 |
|
catch (LinuxSamplerException e) { |
760 |
|
result.Error(e); |
761 |
|
} |
762 |
|
return result.Produce(); |
763 |
|
} |
764 |
|
|
765 |
|
String LSCPServer::ListAvailableMidiInputDrivers() { |
766 |
|
dmsg(2,("LSCPServer: ListAvailableMidiInputDrivers()\n")); |
767 |
|
LSCPResultSet result; |
768 |
|
try { |
769 |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
String s = MidiInputDeviceFactory::AvailableDriversAsString(); |
770 |
result.Add(s); |
result.Add(s); |
771 |
} |
} |
1193 |
try { |
try { |
1194 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1195 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1196 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1197 |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type yet assigned to sampler channel " + ToString(uiSamplerChannel)); |
1198 |
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
1199 |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1200 |
} |
} |
1201 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1202 |
result.Error(e); |
result.Error(e); |
1373 |
try { |
try { |
1374 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1375 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1376 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1377 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1378 |
pEngine->Volume(dVolume); |
pEngineChannel->Volume(dVolume); |
1379 |
} |
} |
1380 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1381 |
result.Error(e); |
result.Error(e); |
1392 |
try { |
try { |
1393 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1394 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1395 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1396 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel"); |
1397 |
pEngine->Reset(); |
if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel"); |
1398 |
|
pEngineChannel->GetEngine()->Reset(); |
1399 |
} |
} |
1400 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1401 |
result.Error(e); |
result.Error(e); |
1414 |
} |
} |
1415 |
|
|
1416 |
/** |
/** |
1417 |
|
* Will be called by the parser to return general informations about this |
1418 |
|
* sampler. |
1419 |
|
*/ |
1420 |
|
String LSCPServer::GetServerInfo() { |
1421 |
|
dmsg(2,("LSCPServer: GetServerInfo()\n")); |
1422 |
|
LSCPResultSet result; |
1423 |
|
result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler"); |
1424 |
|
result.Add("VERSION", VERSION); |
1425 |
|
result.Add("PROTOCOL_VERSION", "1.0"); |
1426 |
|
return result.Produce(); |
1427 |
|
} |
1428 |
|
|
1429 |
|
/** |
1430 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
1431 |
* server for receiving event messages. |
* server for receiving event messages. |
1432 |
*/ |
*/ |
1462 |
|
|
1463 |
String LSCPServer::QueryDatabase(String query) { |
String LSCPServer::QueryDatabase(String query) { |
1464 |
LSCPResultSet result; |
LSCPResultSet result; |
1465 |
#ifdef HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
1466 |
char* zErrMsg = NULL; |
char* zErrMsg = NULL; |
1467 |
sqlite3 *db; |
sqlite3 *db; |
1468 |
String selectStr = "SELECT " + query; |
String selectStr = "SELECT " + query; |
1474 |
} |
} |
1475 |
if ( rc != SQLITE_OK ) |
if ( rc != SQLITE_OK ) |
1476 |
{ |
{ |
1477 |
//result.Error(String(zErrMsg), rc); |
result.Error(String(zErrMsg), rc); |
|
result.Error(selectStr, 666); |
|
1478 |
} |
} |
1479 |
sqlite3_close(db); |
sqlite3_close(db); |
1480 |
#else |
#else |