/[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 1337 by iliev, Sun Sep 9 23:27:23 2007 UTC revision 1345 by iliev, Thu Sep 13 21:46:25 2007 UTC
# Line 146  void LSCPServer::EventHandler::TotalVoic Line 146  void LSCPServer::EventHandler::TotalVoic
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::toEscapedName(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::toEscapedName(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    
# Line 2354  String LSCPServer::GetDbInstrumentDirect Line 2354  String LSCPServer::GetDbInstrumentDirect
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) + "'";  
2358                if (Recursive) list += "'" + InstrumentsDb::toEscapedPath(dirs->at(i)) + "'";
2359                else list += "'" + InstrumentsDb::toEscapedName(dirs->at(i)) + "'";
2360          }          }
2361    
2362          result.Add(list);          result.Add(list);
# Line 2374  String LSCPServer::GetDbInstrumentDirect Line 2376  String LSCPServer::GetDbInstrumentDirect
2376      try {      try {
2377          DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir);          DbDirectory info = InstrumentsDb::GetInstrumentsDb()->GetDirectoryInfo(Dir);
2378    
2379          result.Add("DESCRIPTION", info.Description);          result.Add("DESCRIPTION", InstrumentsDb::toEscapedText(info.Description));
2380          result.Add("CREATED", info.Created);          result.Add("CREATED", info.Created);
2381          result.Add("MODIFIED", info.Modified);          result.Add("MODIFIED", info.Modified);
2382      } catch (Exception e) {      } catch (Exception e) {
# Line 2531  String LSCPServer::GetDbInstruments(Stri Line 2533  String LSCPServer::GetDbInstruments(Stri
2533    
2534          for (int i = 0; i < instrs->size(); i++) {          for (int i = 0; i < instrs->size(); i++) {
2535              if (list != "") list += ",";              if (list != "") list += ",";
2536              list += "'" + instrs->at(i) + "'";  
2537                if (Recursive) list += "'" + InstrumentsDb::toEscapedPath(instrs->at(i)) + "'";
2538                else list += "'" + InstrumentsDb::toEscapedName(instrs->at(i)) + "'";
2539          }          }
2540    
2541          result.Add(list);          result.Add(list);
# Line 2558  String LSCPServer::GetDbInstrumentInfo(S Line 2562  String LSCPServer::GetDbInstrumentInfo(S
2562          result.Add("SIZE", (int)info.Size);          result.Add("SIZE", (int)info.Size);
2563          result.Add("CREATED", info.Created);          result.Add("CREATED", info.Created);
2564          result.Add("MODIFIED", info.Modified);          result.Add("MODIFIED", info.Modified);
2565          result.Add("DESCRIPTION", FilterEndlines(info.Description));          result.Add("DESCRIPTION", InstrumentsDb::toEscapedText(info.Description));
2566          result.Add("IS_DRUM", info.IsDrum);          result.Add("IS_DRUM", info.IsDrum);
2567          result.Add("PRODUCT", FilterEndlines(info.Product));          result.Add("PRODUCT", InstrumentsDb::toEscapedText(info.Product));
2568          result.Add("ARTISTS", FilterEndlines(info.Artists));          result.Add("ARTISTS", InstrumentsDb::toEscapedText(info.Artists));
2569          result.Add("KEYWORDS", FilterEndlines(info.Keywords));          result.Add("KEYWORDS", InstrumentsDb::toEscapedText(info.Keywords));
2570      } catch (Exception e) {      } catch (Exception e) {
2571           result.Error(e);           result.Error(e);
2572      }      }
# Line 2679  String LSCPServer::FindDbInstrumentDirec Line 2683  String LSCPServer::FindDbInstrumentDirec
2683    
2684          for (int i = 0; i < pDirectories->size(); i++) {          for (int i = 0; i < pDirectories->size(); i++) {
2685              if (list != "") list += ",";              if (list != "") list += ",";
2686              list += "'" + pDirectories->at(i) + "'";              list += "'" + InstrumentsDb::toEscapedPath(pDirectories->at(i)) + "'";
2687          }          }
2688    
2689          result.Add(list);          result.Add(list);
# Line 2735  String LSCPServer::FindDbInstruments(Str Line 2739  String LSCPServer::FindDbInstruments(Str
2739    
2740          for (int i = 0; i < pInstruments->size(); i++) {          for (int i = 0; i < pInstruments->size(); i++) {
2741              if (list != "") list += ",";              if (list != "") list += ",";
2742              list += "'" + pInstruments->at(i) + "'";              list += "'" + InstrumentsDb::toEscapedPath(pInstruments->at(i)) + "'";
2743          }          }
2744    
2745          result.Add(list);          result.Add(list);
# Line 2767  String LSCPServer::SetEcho(yyparse_param Line 2771  String LSCPServer::SetEcho(yyparse_param
2771      }      }
2772      return result.Produce();      return result.Produce();
2773  }  }
   
 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;  
 }  

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

  ViewVC Help
Powered by ViewVC