/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1133 by iliev, Mon Mar 26 08:27:06 2007 UTC revision 1345 by iliev, Thu Sep 13 21:46:25 2007 UTC
# Line 24  Line 24 
24  #include "lscpserver.h"  #include "lscpserver.h"
25  #include "lscpresultset.h"  #include "lscpresultset.h"
26  #include "lscpevent.h"  #include "lscpevent.h"
 #include "../common/global.h"  
27    
28  #include <fcntl.h>  #include <fcntl.h>
29    
30  #if HAVE_SQLITE3  #if ! HAVE_SQLITE3
31  # include "sqlite3.h"  #define DOESNT_HAVE_SQLITE3 "No database support. SQLITE3 was not installed when linuxsampler was built."
32  #endif  #endif
33    
34  #include "../engines/EngineFactory.h"  #include "../engines/EngineFactory.h"
# Line 53  Line 52 
52  fd_set LSCPServer::fdSet;  fd_set LSCPServer::fdSet;
53  int LSCPServer::currentSocket = -1;  int LSCPServer::currentSocket = -1;
54  std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>();  std::vector<yyparse_param_t> LSCPServer::Sessions = std::vector<yyparse_param_t>();
55    std::vector<yyparse_param_t>::iterator itCurrentSession = std::vector<yyparse_param_t>::iterator();
56  std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>();  std::map<int,String> LSCPServer::bufferedNotifies = std::map<int,String>();
57  std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>();  std::map<int,String> LSCPServer::bufferedCommands = std::map<int,String>();
58  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> >();
# Line 81  LSCPServer::LSCPServer(Sampler* pSampler Line 81  LSCPServer::LSCPServer(Sampler* pSampler
81      LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_info, "MIDI_INSTRUMENT_MAP_INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_info, "MIDI_INSTRUMENT_MAP_INFO");
82      LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_count, "MIDI_INSTRUMENT_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_count, "MIDI_INSTRUMENT_COUNT");
83      LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_info, "MIDI_INSTRUMENT_INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_info, "MIDI_INSTRUMENT_INFO");
84        LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_dir_count, "DB_INSTRUMENT_DIRECTORY_COUNT");
85        LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_dir_info, "DB_INSTRUMENT_DIRECTORY_INFO");
86        LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_count, "DB_INSTRUMENT_COUNT");
87        LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO");
88        LSCPEvent::RegisterEvent(LSCPEvent::event_db_instrs_job_info, "DB_INSTRUMENTS_JOB_INFO");
89      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");      LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS");
90      LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT");      LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT");
91      LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO");      LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO");
# Line 139  void LSCPServer::EventHandler::TotalVoic Line 144  void LSCPServer::EventHandler::TotalVoic
144      LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount));      LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount));
145  }  }
146    
147    #if HAVE_SQLITE3
148    void LSCPServer::DbInstrumentsEventHandler::DirectoryCountChanged(String Dir) {
149        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_count, InstrumentsDb::toEscapedPath(Dir)));
150    }
151    
152    void LSCPServer::DbInstrumentsEventHandler::DirectoryInfoChanged(String Dir) {
153        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, InstrumentsDb::toEscapedPath(Dir)));
154    }
155    
156    void LSCPServer::DbInstrumentsEventHandler::DirectoryNameChanged(String Dir, String NewName) {
157        Dir = "'" + InstrumentsDb::toEscapedPath(Dir) + "'";
158        NewName = "'" + InstrumentsDb::toEscapedName(NewName) + "'";
159        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_dir_info, "NAME", Dir, NewName));
160    }
161    
162    void LSCPServer::DbInstrumentsEventHandler::InstrumentCountChanged(String Dir) {
163        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_count, InstrumentsDb::toEscapedPath(Dir)));
164    }
165    
166    void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) {
167        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, InstrumentsDb::toEscapedPath(Instr)));
168    }
169    
170    void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) {
171        Instr = "'" + InstrumentsDb::toEscapedPath(Instr) + "'";
172        NewName = "'" + InstrumentsDb::toEscapedName(NewName) + "'";
173        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName));
174    }
175    
176    void LSCPServer::DbInstrumentsEventHandler::JobStatusChanged(int JobId) {
177        LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instrs_job_info, JobId));
178    }
179    #endif // HAVE_SQLITE3
180    
181    
182  /**  /**
183   * Blocks the calling thread until the LSCP Server is initialized and   * Blocks the calling thread until the LSCP Server is initialized and
# Line 180  int LSCPServer::Main() { Line 219  int LSCPServer::Main() {
219    
220      listen(hSocket, 1);      listen(hSocket, 1);
221      Initialized.Set(true);      Initialized.Set(true);
222        
223      // Registering event listeners      // Registering event listeners
224      pSampler->AddChannelCountListener(&eventHandler);      pSampler->AddChannelCountListener(&eventHandler);
225      pSampler->AddAudioDeviceCountListener(&eventHandler);      pSampler->AddAudioDeviceCountListener(&eventHandler);
# Line 194  int LSCPServer::Main() { Line 233  int LSCPServer::Main() {
233      MidiInstrumentMapper::AddMidiInstrumentInfoListener(&eventHandler);      MidiInstrumentMapper::AddMidiInstrumentInfoListener(&eventHandler);
234      MidiInstrumentMapper::AddMidiInstrumentMapCountListener(&eventHandler);      MidiInstrumentMapper::AddMidiInstrumentMapCountListener(&eventHandler);
235      MidiInstrumentMapper::AddMidiInstrumentMapInfoListener(&eventHandler);      MidiInstrumentMapper::AddMidiInstrumentMapInfoListener(&eventHandler);
236    #if HAVE_SQLITE3
237        InstrumentsDb::GetInstrumentsDb()->AddInstrumentsDbListener(&dbInstrumentsEventHandler);
238    #endif
239      // now wait for client connections and handle their requests      // now wait for client connections and handle their requests
240      sockaddr_in client;      sockaddr_in client;
241      int length = sizeof(client);      int length = sizeof(client);
# Line 287  int LSCPServer::Main() { Line 328  int LSCPServer::Main() {
328                                  int dummy; // just a temporary hack to fulfill the restart() function prototype                                  int dummy; // just a temporary hack to fulfill the restart() function prototype
329                                  restart(NULL, dummy); // restart the 'scanner'                                  restart(NULL, dummy); // restart the 'scanner'
330                                  currentSocket = (*iter).hSession;  //a hack                                  currentSocket = (*iter).hSession;  //a hack
331                                    itCurrentSession = iter; // another hack
332                                  dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str()));                                  dmsg(2,("LSCPServer: [%s]\n",bufferedCommands[currentSocket].c_str()));
333                                  if ((*iter).bVerbose) { // if echo mode enabled                                  if ((*iter).bVerbose) { // if echo mode enabled
334                                      AnswerClient(bufferedCommands[currentSocket]);                                      AnswerClient(bufferedCommands[currentSocket]);
335                                  }                                  }
336                                  int result = yyparse(&(*iter));                                  int result = yyparse(&(*iter));
337                                  currentSocket = -1;     //continuation of a hack                                  currentSocket = -1;     //continuation of a hack
338                                    itCurrentSession = Sessions.end(); // hack as well
339                                  dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket));                                  dmsg(3,("LSCPServer: Done parsing on socket %d.\n", currentSocket));
340                                  if (result == LSCP_QUIT) { //Was it a quit command by any chance?                                  if (result == LSCP_QUIT) { //Was it a quit command by any chance?
341                                          CloseConnection(iter);                                          CloseConnection(iter);
# Line 385  extern int GetLSCPCommand( void *buf, in Line 428  extern int GetLSCPCommand( void *buf, in
428          return command.size();          return command.size();
429  }  }
430    
431    extern yyparse_param_t* GetCurrentYaccSession() {
432        return &(*itCurrentSession);
433    }
434    
435  /**  /**
436   * Will be called to try to read the command from the socket   * Will be called to try to read the command from the socket
437   * If command is read, it will return true. Otherwise false is returned.   * If command is read, it will return true. Otherwise false is returned.
# Line 565  String LSCPServer::DestroyMidiInputDevic Line 612  String LSCPServer::DestroyMidiInputDevic
612      return result.Produce();      return result.Produce();
613  }  }
614    
615    EngineChannel* LSCPServer::GetEngineChannel(uint uiSamplerChannel) {
616        SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
617        if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
618    
619        EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
620        if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
621    
622        return pEngineChannel;
623    }
624    
625  /**  /**
626   * Will be called by the parser to load an instrument.   * Will be called by the parser to load an instrument.
627   */   */
# Line 1899  String LSCPServer::GetMidiInstrumentMap( Line 1956  String LSCPServer::GetMidiInstrumentMap(
1956      LSCPResultSet result;      LSCPResultSet result;
1957      try {      try {
1958          result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID));          result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID));
1959            result.Add("DEFAULT", MidiInstrumentMapper::GetDefaultMap() == MidiMapID);
1960      } catch (Exception e) {      } catch (Exception e) {
1961          result.Error(e);          result.Error(e);
1962      }      }
# Line 1947  String LSCPServer::CreateFxSend(uint uiS Line 2005  String LSCPServer::CreateFxSend(uint uiS
2005      dmsg(2,("LSCPServer: CreateFxSend()\n"));      dmsg(2,("LSCPServer: CreateFxSend()\n"));
2006      LSCPResultSet result;      LSCPResultSet result;
2007      try {      try {
2008          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
2009    
2010          FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name);          FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name);
2011          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)");
# Line 1967  String LSCPServer::DestroyFxSend(uint ui Line 2021  String LSCPServer::DestroyFxSend(uint ui
2021      dmsg(2,("LSCPServer: DestroyFxSend()\n"));      dmsg(2,("LSCPServer: DestroyFxSend()\n"));
2022      LSCPResultSet result;      LSCPResultSet result;
2023      try {      try {
2024          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
2025    
2026          FxSend* pFxSend = NULL;          FxSend* pFxSend = NULL;
2027          for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {          for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
# Line 1992  String LSCPServer::GetFxSends(uint uiSam Line 2042  String LSCPServer::GetFxSends(uint uiSam
2042      dmsg(2,("LSCPServer: GetFxSends()\n"));      dmsg(2,("LSCPServer: GetFxSends()\n"));
2043      LSCPResultSet result;      LSCPResultSet result;
2044      try {      try {
2045          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
2046    
2047          result.Add(pEngineChannel->GetFxSendCount());          result.Add(pEngineChannel->GetFxSendCount());
2048      } catch (Exception e) {      } catch (Exception e) {
# Line 2010  String LSCPServer::ListFxSends(uint uiSa Line 2056  String LSCPServer::ListFxSends(uint uiSa
2056      LSCPResultSet result;      LSCPResultSet result;
2057      String list;      String list;
2058      try {      try {
2059          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
2060    
2061          for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {          for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
2062              FxSend* pFxSend = pEngineChannel->GetFxSend(i);              FxSend* pFxSend = pEngineChannel->GetFxSend(i);
# Line 2028  String LSCPServer::ListFxSends(uint uiSa Line 2070  String LSCPServer::ListFxSends(uint uiSa
2070      return result.Produce();      return result.Produce();
2071  }  }
2072    
2073    FxSend* LSCPServer::GetFxSend(uint uiSamplerChannel, uint FxSendID) {
2074        EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel);
2075    
2076        FxSend* pFxSend = NULL;
2077        for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {
2078            if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {
2079                pFxSend = pEngineChannel->GetFxSend(i);
2080                break;
2081            }
2082        }
2083        if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");
2084        return pFxSend;
2085    }
2086    
2087  String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) {  String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) {
2088      dmsg(2,("LSCPServer: GetFxSendInfo()\n"));      dmsg(2,("LSCPServer: GetFxSendInfo()\n"));
2089      LSCPResultSet result;      LSCPResultSet result;
2090      try {      try {
2091          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel);
2092          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));          FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID);
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
   
         FxSend* pFxSend = NULL;  
         for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {  
             if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {  
                 pFxSend = pEngineChannel->GetFxSend(i);  
                 break;  
             }  
         }  
         if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");  
2093    
2094          // gather audio routing informations          // gather audio routing informations
2095          String AudioRouting;          String AudioRouting;
# Line 2065  String LSCPServer::GetFxSendInfo(uint ui Line 2109  String LSCPServer::GetFxSendInfo(uint ui
2109      return result.Produce();      return result.Produce();
2110  }  }
2111    
2112  String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) {  String LSCPServer::SetFxSendName(uint uiSamplerChannel, uint FxSendID, String Name) {
2113      dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n"));      dmsg(2,("LSCPServer: SetFxSendName()\n"));
2114      LSCPResultSet result;      LSCPResultSet result;
2115      try {      try {
2116          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
2117    
2118          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          pFxSend->SetName(Name);
2119          if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));
2120        } catch (Exception e) {
2121            result.Error(e);
2122        }
2123        return result.Produce();
2124    }
2125    
2126          FxSend* pFxSend = NULL;  String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) {
2127          for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {      dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n"));
2128              if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {      LSCPResultSet result;
2129                  pFxSend = pEngineChannel->GetFxSend(i);      try {
2130                  break;          FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID);
             }  
         }  
         if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");  
2131    
2132          pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel);          pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel);
2133          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));
# Line 2096  String LSCPServer::SetFxSendMidiControll Line 2141  String LSCPServer::SetFxSendMidiControll
2141      dmsg(2,("LSCPServer: SetFxSendMidiController()\n"));      dmsg(2,("LSCPServer: SetFxSendMidiController()\n"));
2142      LSCPResultSet result;      LSCPResultSet result;
2143      try {      try {
2144          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
   
         FxSend* pFxSend = NULL;  
         for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {  
             if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {  
                 pFxSend = pEngineChannel->GetFxSend(i);  
                 break;  
             }  
         }  
         if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");  
2145    
2146          pFxSend->SetMidiController(MidiController);          pFxSend->SetMidiController(MidiController);
2147          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));
# Line 2123  String LSCPServer::SetFxSendLevel(uint u Line 2155  String LSCPServer::SetFxSendLevel(uint u
2155      dmsg(2,("LSCPServer: SetFxSendLevel()\n"));      dmsg(2,("LSCPServer: SetFxSendLevel()\n"));
2156      LSCPResultSet result;      LSCPResultSet result;
2157      try {      try {
2158          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID);
         if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));  
   
         EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();  
         if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");  
   
         FxSend* pFxSend = NULL;  
         for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) {  
             if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) {  
                 pFxSend = pEngineChannel->GetFxSend(i);  
                 break;  
             }  
         }  
         if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel");  
2159    
2160          pFxSend->SetLevel((float)dLevel);          pFxSend->SetLevel((float)dLevel);
2161          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID));
# Line 2146  String LSCPServer::SetFxSendLevel(uint u Line 2165  String LSCPServer::SetFxSendLevel(uint u
2165      return result.Produce();      return result.Produce();
2166  }  }
2167    
2168    String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) {
2169        dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel));
2170        LSCPResultSet result;
2171        try {
2172            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
2173            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
2174            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
2175            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();
2178            InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager();
2179            if (!pInstrumentManager) throw Exception("Engine does not provide an instrument manager");
2180            InstrumentManager::instrument_id_t instrumentID;
2181            instrumentID.FileName = pEngineChannel->InstrumentFileName();
2182            instrumentID.Index    = pEngineChannel->InstrumentIndex();
2183            pInstrumentManager->LaunchInstrumentEditor(instrumentID);
2184        } catch (Exception e) {
2185            result.Error(e);
2186        }
2187        return result.Produce();
2188    }
2189    
2190  /**  /**
2191   * Will be called by the parser to reset a particular sampler channel.   * Will be called by the parser to reset a particular sampler channel.
2192   */   */
# Line 2185  String LSCPServer::GetServerInfo() { Line 2226  String LSCPServer::GetServerInfo() {
2226      result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler");      result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler");
2227      result.Add("VERSION", VERSION);      result.Add("VERSION", VERSION);
2228      result.Add("PROTOCOL_VERSION", ToString(LSCP_RELEASE_MAJOR) + "." + ToString(LSCP_RELEASE_MINOR));      result.Add("PROTOCOL_VERSION", ToString(LSCP_RELEASE_MAJOR) + "." + ToString(LSCP_RELEASE_MINOR));
2229    #if HAVE_SQLITE3
2230        result.Add("INSTRUMENTS_DB_SUPPORT", "yes");
2231    #else
2232        result.Add("INSTRUMENTS_DB_SUPPORT", "no");
2233    #endif
2234    
2235      return result.Produce();      return result.Produce();
2236  }  }
2237    
# Line 2252  String LSCPServer::UnsubscribeNotificati Line 2299  String LSCPServer::UnsubscribeNotificati
2299      return result.Produce();      return result.Produce();
2300  }  }
2301    
2302  static int select_callback(void * lscpResultSet, int argc,  String LSCPServer::AddDbInstrumentDirectory(String Dir) {
2303                          char **argv, char **azColName)      dmsg(2,("LSCPServer: AddDbInstrumentDirectory(Dir=%s)\n", Dir.c_str()));
2304  {      LSCPResultSet result;
2305      LSCPResultSet* resultSet = (LSCPResultSet*) lscpResultSet;  #if HAVE_SQLITE3
2306      resultSet->Add(argc, argv);      try {
2307      return 0;          InstrumentsDb::GetInstrumentsDb()->AddDirectory(Dir);
2308        } catch (Exception e) {
2309             result.Error(e);
2310        }
2311    #else
2312        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2313    #endif
2314        return result.Produce();
2315    }
2316    
2317    String LSCPServer::RemoveDbInstrumentDirectory(String Dir, bool Force) {
2318        dmsg(2,("LSCPServer: RemoveDbInstrumentDirectory(Dir=%s,Force=%d)\n", Dir.c_str(), Force));
2319        LSCPResultSet result;
2320    #if HAVE_SQLITE3
2321        try {
2322            InstrumentsDb::GetInstrumentsDb()->RemoveDirectory(Dir, Force);
2323        } catch (Exception e) {
2324             result.Error(e);
2325        }
2326    #else
2327        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2328    #endif
2329        return result.Produce();
2330    }
2331    
2332    String LSCPServer::GetDbInstrumentDirectoryCount(String Dir, bool Recursive) {
2333        dmsg(2,("LSCPServer: GetDbInstrumentDirectoryCount(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive));
2334        LSCPResultSet result;
2335    #if HAVE_SQLITE3
2336        try {
2337            result.Add(InstrumentsDb::GetInstrumentsDb()->GetDirectoryCount(Dir, Recursive));
2338        } catch (Exception e) {
2339             result.Error(e);
2340        }
2341    #else
2342        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2343    #endif
2344        return result.Produce();
2345    }
2346    
2347    String LSCPServer::GetDbInstrumentDirectories(String Dir, bool Recursive) {
2348        dmsg(2,("LSCPServer: GetDbInstrumentDirectories(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive));
2349        LSCPResultSet result;
2350    #if HAVE_SQLITE3
2351        try {
2352            String list;
2353            StringListPtr dirs = InstrumentsDb::GetInstrumentsDb()->GetDirectories(Dir, Recursive);
2354    
2355            for (int i = 0; i < dirs->size(); i++) {
2356                if (list != "") list += ",";
2357    
2358                if (Recursive) list += "'" + InstrumentsDb::toEscapedPath(dirs->at(i)) + "'";
2359                else list += "'" + InstrumentsDb::toEscapedName(dirs->at(i)) + "'";
2360            }
2361    
2362            result.Add(list);
2363        } catch (Exception e) {
2364             result.Error(e);
2365        }
2366    #else
2367        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2368    #endif
2369        return result.Produce();
2370  }  }
2371    
2372  String LSCPServer::QueryDatabase(String query) {  String LSCPServer::GetDbInstrumentDirectoryInfo(String Dir) {
2373        dmsg(2,("LSCPServer: GetDbInstrumentDirectoryInfo(Dir=%s)\n", Dir.c_str()));
2374      LSCPResultSet result;      LSCPResultSet result;
2375  #if HAVE_SQLITE3  #if HAVE_SQLITE3
2376      char* zErrMsg = NULL;      try {
2377      sqlite3 *db;          DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir);
     String selectStr = "SELECT " + query;  
2378    
2379      int rc = sqlite3_open("linuxsampler.db", &db);          result.Add("DESCRIPTION", InstrumentsDb::toEscapedText(info.Description));
2380      if (rc == SQLITE_OK)          result.Add("CREATED", info.Created);
2381      {          result.Add("MODIFIED", info.Modified);
2382              rc = sqlite3_exec(db, selectStr.c_str(), select_callback, &result, &zErrMsg);      } catch (Exception e) {
2383             result.Error(e);
2384      }      }
2385      if ( rc != SQLITE_OK )  #else
2386      {      result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2387              result.Error(String(zErrMsg), rc);  #endif
2388        return result.Produce();
2389    }
2390    
2391    String LSCPServer::SetDbInstrumentDirectoryName(String Dir, String Name) {
2392        dmsg(2,("LSCPServer: SetDbInstrumentDirectoryName(Dir=%s,Name=%s)\n", Dir.c_str(), Name.c_str()));
2393        LSCPResultSet result;
2394    #if HAVE_SQLITE3
2395        try {
2396            InstrumentsDb::GetInstrumentsDb()->RenameDirectory(Dir, Name);
2397        } catch (Exception e) {
2398             result.Error(e);
2399      }      }
     sqlite3_close(db);  
2400  #else  #else
2401      result.Error(String("SQLITE3 was not installed when linuxsampler was built. SELECT statement is not available."), 0);      result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2402  #endif  #endif
2403      return result.Produce();      return result.Produce();
2404  }  }
2405    
2406    String LSCPServer::MoveDbInstrumentDirectory(String Dir, String Dst) {
2407        dmsg(2,("LSCPServer: MoveDbInstrumentDirectory(Dir=%s,Dst=%s)\n", Dir.c_str(), Dst.c_str()));
2408        LSCPResultSet result;
2409    #if HAVE_SQLITE3
2410        try {
2411            InstrumentsDb::GetInstrumentsDb()->MoveDirectory(Dir, Dst);
2412        } catch (Exception e) {
2413             result.Error(e);
2414        }
2415    #else
2416        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2417    #endif
2418        return result.Produce();
2419    }
2420    
2421    String LSCPServer::CopyDbInstrumentDirectory(String Dir, String Dst) {
2422        dmsg(2,("LSCPServer: CopyDbInstrumentDirectory(Dir=%s,Dst=%s)\n", Dir.c_str(), Dst.c_str()));
2423        LSCPResultSet result;
2424    #if HAVE_SQLITE3
2425        try {
2426            InstrumentsDb::GetInstrumentsDb()->CopyDirectory(Dir, Dst);
2427        } catch (Exception e) {
2428             result.Error(e);
2429        }
2430    #else
2431        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2432    #endif
2433        return result.Produce();
2434    }
2435    
2436    String LSCPServer::SetDbInstrumentDirectoryDescription(String Dir, String Desc) {
2437        dmsg(2,("LSCPServer: SetDbInstrumentDirectoryDescription(Dir=%s,Desc=%s)\n", Dir.c_str(), Desc.c_str()));
2438        LSCPResultSet result;
2439    #if HAVE_SQLITE3
2440        try {
2441            InstrumentsDb::GetInstrumentsDb()->SetDirectoryDescription(Dir, Desc);
2442        } catch (Exception e) {
2443             result.Error(e);
2444        }
2445    #else
2446        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2447    #endif
2448        return result.Produce();
2449    }
2450    
2451    String LSCPServer::AddDbInstruments(String DbDir, String FilePath, int Index, bool bBackground) {
2452        dmsg(2,("LSCPServer: AddDbInstruments(DbDir=%s,FilePath=%s,Index=%d,bBackground=%d)\n", DbDir.c_str(), FilePath.c_str(), Index, bBackground));
2453        LSCPResultSet result;
2454    #if HAVE_SQLITE3
2455        try {
2456            int id;
2457            InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb();
2458            id = db->AddInstruments(DbDir, FilePath, Index, bBackground);
2459            if (bBackground) result = id;
2460        } catch (Exception e) {
2461             result.Error(e);
2462        }
2463    #else
2464        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2465    #endif
2466        return result.Produce();
2467    }
2468    
2469    String LSCPServer::AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground) {
2470        dmsg(2,("LSCPServer: AddDbInstruments(ScanMode=%s,DbDir=%s,FsDir=%s,bBackground=%d)\n", ScanMode.c_str(), DbDir.c_str(), FsDir.c_str(), bBackground));
2471        LSCPResultSet result;
2472    #if HAVE_SQLITE3
2473        try {
2474            int id;
2475            InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb();
2476            if (ScanMode.compare("RECURSIVE") == 0) {
2477               id = db->AddInstruments(RECURSIVE, DbDir, FsDir, bBackground);
2478            } else if (ScanMode.compare("NON_RECURSIVE") == 0) {
2479               id = db->AddInstruments(NON_RECURSIVE, DbDir, FsDir, bBackground);
2480            } else if (ScanMode.compare("FLAT") == 0) {
2481               id = db->AddInstruments(FLAT, DbDir, FsDir, bBackground);
2482            } else {
2483                throw Exception("Unknown scan mode: " + ScanMode);
2484            }
2485    
2486            if (bBackground) result = id;
2487        } catch (Exception e) {
2488             result.Error(e);
2489        }
2490    #else
2491        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2492    #endif
2493        return result.Produce();
2494    }
2495    
2496    String LSCPServer::RemoveDbInstrument(String Instr) {
2497        dmsg(2,("LSCPServer: RemoveDbInstrument(Instr=%s)\n", Instr.c_str()));
2498        LSCPResultSet result;
2499    #if HAVE_SQLITE3
2500        try {
2501            InstrumentsDb::GetInstrumentsDb()->RemoveInstrument(Instr);
2502        } catch (Exception e) {
2503             result.Error(e);
2504        }
2505    #else
2506        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2507    #endif
2508        return result.Produce();
2509    }
2510    
2511    String LSCPServer::GetDbInstrumentCount(String Dir, bool Recursive) {
2512        dmsg(2,("LSCPServer: GetDbInstrumentCount(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive));
2513        LSCPResultSet result;
2514    #if HAVE_SQLITE3
2515        try {
2516            result.Add(InstrumentsDb::GetInstrumentsDb()->GetInstrumentCount(Dir, Recursive));
2517        } catch (Exception e) {
2518             result.Error(e);
2519        }
2520    #else
2521        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2522    #endif
2523        return result.Produce();
2524    }
2525    
2526    String LSCPServer::GetDbInstruments(String Dir, bool Recursive) {
2527        dmsg(2,("LSCPServer: GetDbInstruments(Dir=%s,Recursive=%d)\n", Dir.c_str(), Recursive));
2528        LSCPResultSet result;
2529    #if HAVE_SQLITE3
2530        try {
2531            String list;
2532            StringListPtr instrs = InstrumentsDb::GetInstrumentsDb()->GetInstruments(Dir, Recursive);
2533    
2534            for (int i = 0; i < instrs->size(); i++) {
2535                if (list != "") list += ",";
2536    
2537                if (Recursive) list += "'" + InstrumentsDb::toEscapedPath(instrs->at(i)) + "'";
2538                else list += "'" + InstrumentsDb::toEscapedName(instrs->at(i)) + "'";
2539            }
2540    
2541            result.Add(list);
2542        } catch (Exception e) {
2543             result.Error(e);
2544        }
2545    #else
2546        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2547    #endif
2548        return result.Produce();
2549    }
2550    
2551    String LSCPServer::GetDbInstrumentInfo(String Instr) {
2552        dmsg(2,("LSCPServer: GetDbInstrumentInfo(Instr=%s)\n", Instr.c_str()));
2553        LSCPResultSet result;
2554    #if HAVE_SQLITE3
2555        try {
2556            DbInstrument info = InstrumentsDb::GetInstrumentsDb()->GetInstrumentInfo(Instr);
2557    
2558            result.Add("INSTRUMENT_FILE", info.InstrFile);
2559            result.Add("INSTRUMENT_NR", info.InstrNr);
2560            result.Add("FORMAT_FAMILY", info.FormatFamily);
2561            result.Add("FORMAT_VERSION", info.FormatVersion);
2562            result.Add("SIZE", (int)info.Size);
2563            result.Add("CREATED", info.Created);
2564            result.Add("MODIFIED", info.Modified);
2565            result.Add("DESCRIPTION", InstrumentsDb::toEscapedText(info.Description));
2566            result.Add("IS_DRUM", info.IsDrum);
2567            result.Add("PRODUCT", InstrumentsDb::toEscapedText(info.Product));
2568            result.Add("ARTISTS", InstrumentsDb::toEscapedText(info.Artists));
2569            result.Add("KEYWORDS", InstrumentsDb::toEscapedText(info.Keywords));
2570        } catch (Exception e) {
2571             result.Error(e);
2572        }
2573    #else
2574        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2575    #endif
2576        return result.Produce();
2577    }
2578    
2579    String LSCPServer::GetDbInstrumentsJobInfo(int JobId) {
2580        dmsg(2,("LSCPServer: GetDbInstrumentsJobInfo(JobId=%d)\n", JobId));
2581        LSCPResultSet result;
2582    #if HAVE_SQLITE3
2583        try {
2584            ScanJob job = InstrumentsDb::GetInstrumentsDb()->Jobs.GetJobById(JobId);
2585    
2586            result.Add("FILES_TOTAL", job.FilesTotal);
2587            result.Add("FILES_SCANNED", job.FilesScanned);
2588            result.Add("SCANNING", job.Scanning);
2589            result.Add("STATUS", job.Status);
2590        } catch (Exception e) {
2591             result.Error(e);
2592        }
2593    #else
2594        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2595    #endif
2596        return result.Produce();
2597    }
2598    
2599    String LSCPServer::SetDbInstrumentName(String Instr, String Name) {
2600        dmsg(2,("LSCPServer: SetDbInstrumentName(Instr=%s,Name=%s)\n", Instr.c_str(), Name.c_str()));
2601        LSCPResultSet result;
2602    #if HAVE_SQLITE3
2603        try {
2604            InstrumentsDb::GetInstrumentsDb()->RenameInstrument(Instr, Name);
2605        } catch (Exception e) {
2606             result.Error(e);
2607        }
2608    #else
2609        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2610    #endif
2611        return result.Produce();
2612    }
2613    
2614    String LSCPServer::MoveDbInstrument(String Instr, String Dst) {
2615        dmsg(2,("LSCPServer: MoveDbInstrument(Instr=%s,Dst=%s)\n", Instr.c_str(), Dst.c_str()));
2616        LSCPResultSet result;
2617    #if HAVE_SQLITE3
2618        try {
2619            InstrumentsDb::GetInstrumentsDb()->MoveInstrument(Instr, Dst);
2620        } catch (Exception e) {
2621             result.Error(e);
2622        }
2623    #else
2624        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2625    #endif
2626        return result.Produce();
2627    }
2628    
2629    String LSCPServer::CopyDbInstrument(String Instr, String Dst) {
2630        dmsg(2,("LSCPServer: CopyDbInstrument(Instr=%s,Dst=%s)\n", Instr.c_str(), Dst.c_str()));
2631        LSCPResultSet result;
2632    #if HAVE_SQLITE3
2633        try {
2634            InstrumentsDb::GetInstrumentsDb()->CopyInstrument(Instr, Dst);
2635        } catch (Exception e) {
2636             result.Error(e);
2637        }
2638    #else
2639        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2640    #endif
2641        return result.Produce();
2642    }
2643    
2644    String LSCPServer::SetDbInstrumentDescription(String Instr, String Desc) {
2645        dmsg(2,("LSCPServer: SetDbInstrumentDescription(Instr=%s,Desc=%s)\n", Instr.c_str(), Desc.c_str()));
2646        LSCPResultSet result;
2647    #if HAVE_SQLITE3
2648        try {
2649            InstrumentsDb::GetInstrumentsDb()->SetInstrumentDescription(Instr, Desc);
2650        } catch (Exception e) {
2651             result.Error(e);
2652        }
2653    #else
2654        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2655    #endif
2656        return result.Produce();
2657    }
2658    
2659    String LSCPServer::FindDbInstrumentDirectories(String Dir, std::map<String,String> Parameters, bool Recursive) {
2660        dmsg(2,("LSCPServer: FindDbInstrumentDirectories(Dir=%s)\n", Dir.c_str()));
2661        LSCPResultSet result;
2662    #if HAVE_SQLITE3
2663        try {
2664            SearchQuery Query;
2665            std::map<String,String>::iterator iter;
2666            for (iter = Parameters.begin(); iter != Parameters.end(); iter++) {
2667                if (iter->first.compare("NAME") == 0) {
2668                    Query.Name = iter->second;
2669                } else if (iter->first.compare("CREATED") == 0) {
2670                    Query.SetCreated(iter->second);
2671                } else if (iter->first.compare("MODIFIED") == 0) {
2672                    Query.SetModified(iter->second);
2673                } else if (iter->first.compare("DESCRIPTION") == 0) {
2674                    Query.Description = iter->second;
2675                } else {
2676                    throw Exception("Unknown search criteria: " + iter->first);
2677                }
2678            }
2679    
2680            String list;
2681            StringListPtr pDirectories =
2682                InstrumentsDb::GetInstrumentsDb()->FindDirectories(Dir, &Query, Recursive);
2683    
2684            for (int i = 0; i < pDirectories->size(); i++) {
2685                if (list != "") list += ",";
2686                list += "'" + InstrumentsDb::toEscapedPath(pDirectories->at(i)) + "'";
2687            }
2688    
2689            result.Add(list);
2690        } catch (Exception e) {
2691             result.Error(e);
2692        }
2693    #else
2694        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2695    #endif
2696        return result.Produce();
2697    }
2698    
2699    String LSCPServer::FindDbInstruments(String Dir, std::map<String,String> Parameters, bool Recursive) {
2700        dmsg(2,("LSCPServer: FindDbInstruments(Dir=%s)\n", Dir.c_str()));
2701        LSCPResultSet result;
2702    #if HAVE_SQLITE3
2703        try {
2704            SearchQuery Query;
2705            std::map<String,String>::iterator iter;
2706            for (iter = Parameters.begin(); iter != Parameters.end(); iter++) {
2707                if (iter->first.compare("NAME") == 0) {
2708                    Query.Name = iter->second;
2709                } else if (iter->first.compare("FORMAT_FAMILIES") == 0) {
2710                    Query.SetFormatFamilies(iter->second);
2711                } else if (iter->first.compare("SIZE") == 0) {
2712                    Query.SetSize(iter->second);
2713                } else if (iter->first.compare("CREATED") == 0) {
2714                    Query.SetCreated(iter->second);
2715                } else if (iter->first.compare("MODIFIED") == 0) {
2716                    Query.SetModified(iter->second);
2717                } else if (iter->first.compare("DESCRIPTION") == 0) {
2718                    Query.Description = iter->second;
2719                } else if (iter->first.compare("IS_DRUM") == 0) {
2720                    if (!strcasecmp(iter->second.c_str(), "true")) {
2721                        Query.InstrType = SearchQuery::DRUM;
2722                    } else {
2723                        Query.InstrType = SearchQuery::CHROMATIC;
2724                    }
2725                } else if (iter->first.compare("PRODUCT") == 0) {
2726                     Query.Product = iter->second;
2727                } else if (iter->first.compare("ARTISTS") == 0) {
2728                     Query.Artists = iter->second;
2729                } else if (iter->first.compare("KEYWORDS") == 0) {
2730                     Query.Keywords = iter->second;
2731                } else {
2732                    throw Exception("Unknown search criteria: " + iter->first);
2733                }
2734            }
2735    
2736            String list;
2737            StringListPtr pInstruments =
2738                InstrumentsDb::GetInstrumentsDb()->FindInstruments(Dir, &Query, Recursive);
2739    
2740            for (int i = 0; i < pInstruments->size(); i++) {
2741                if (list != "") list += ",";
2742                list += "'" + InstrumentsDb::toEscapedPath(pInstruments->at(i)) + "'";
2743            }
2744    
2745            result.Add(list);
2746        } catch (Exception e) {
2747             result.Error(e);
2748        }
2749    #else
2750        result.Error(String(DOESNT_HAVE_SQLITE3), 0);
2751    #endif
2752        return result.Produce();
2753    }
2754    
2755    
2756  /**  /**
2757   * 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
2758   * mode is enabled, all commands from the client will (immediately) be   * mode is enabled, all commands from the client will (immediately) be

Legend:
Removed from v.1133  
changed lines
  Added in v.1345

  ViewVC Help
Powered by ViewVC