/[svn]/jlscp/trunk/src/org/linuxsampler/lscp/Client.java
ViewVC logotype

Diff of /jlscp/trunk/src/org/linuxsampler/lscp/Client.java

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

revision 1727 by iliev, Wed Mar 19 10:05:33 2008 UTC revision 1728 by iliev, Tue Apr 29 16:04:42 2008 UTC
# Line 1  Line 1 
1  /*  /*
2   *   jlscp - a java LinuxSampler control protocol API   *   jlscp - a java LinuxSampler control protocol API
3   *   *
4   *   Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of jlscp.   *   This file is part of jlscp.
7   *   *
# Line 41  import static org.linuxsampler.lscp.Pars Line 41  import static org.linuxsampler.lscp.Pars
41    
42  /**  /**
43   * This class is the abstraction representing a client endpoint for communication with LinuxSampler   * This class is the abstraction representing a client endpoint for communication with LinuxSampler
44   * instance. Since it implements all commands specified in the LSCP protocol v1.1, for more   * instance. Since it implements all commands specified in the LSCP protocol v1.2, for more
45   * information look at the   * information look at the
46   * <a href=http://www.linuxsampler.org/api/lscp-1.1.html>LSCP</a> specification.   * <a href=http://www.linuxsampler.org/api/lscp-1.2.html>LSCP</a> specification.
47   *   *
48   * <p> The following code establishes connection to LinuxSampler instance and gets the   * <p> The following code establishes connection to LinuxSampler instance and gets the
49   * LinuxSampler version:   * LinuxSampler version:
# Line 164  public class Client { Line 164  public class Client {
164                  if(printOnlyMode) setPrintOnlyMode(true);                  if(printOnlyMode) setPrintOnlyMode(true);
165          }          }
166                    
167            private boolean extendedCharacterEscaping = true;
168            
169            /**
170             * Sets whether strings sent to LinuxSampler should be more aggressively escaped.
171             */
172            public synchronized void
173            setExtendedCharacterEscaping(boolean b) { extendedCharacterEscaping = b; }
174            
175            /**
176             * Determines whether strings sent to LinuxSampler should be more aggressively escaped.
177             */
178            public synchronized boolean
179            getExtendedCharacterEscaping() { return extendedCharacterEscaping; }
180            
181            private String
182            toEscapedText(String s) {
183                    s = toEscapedString(s);
184                    return conv(s);
185            }
186            
187            private String
188            toEscapedFsEntry(String s) {
189                    s = toEscapedFileName(s);
190                    return conv(s);
191            }
192            
193            /**
194             * Applies an extended character escaping to the specified string if needed.
195             */
196            private String
197            conv(String s) {
198                    return getExtendedCharacterEscaping() ? toExtendedEscapeSequence(s) : s;
199            }
200            
201          /**          /**
202           * Determines whether the client is in print-only mode.           * Determines whether the client is in print-only mode.
203           * Print-only mode means that the client will just print all           * Print-only mode means that the client will just print all
# Line 2504  public class Client { Line 2538  public class Client {
2538          public synchronized int          public synchronized int
2539          addMidiInstrumentMap(String name) throws IOException, LSException, LscpException {          addMidiInstrumentMap(String name) throws IOException, LSException, LscpException {
2540                  verifyConnection();                  verifyConnection();
2541                  out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + toEscapedString(name) + "'");                  out.writeLine("ADD MIDI_INSTRUMENT_MAP '" + toEscapedText(name) + "'");
2542                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
2543                                    
2544                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 2655  public class Client { Line 2689  public class Client {
2689                                  throws IOException, LscpException, LSException {                                  throws IOException, LscpException, LSException {
2690                                    
2691                  verifyConnection();                  verifyConnection();
2692                  name = toEscapedString(name);                  name = toEscapedText(name);
2693                  out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " +  + mapId + " '" + name + "'");                  out.writeLine("SET MIDI_INSTRUMENT_MAP NAME " +  + mapId + " '" + name + "'");
2694                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
2695                                    
# Line 2705  public class Client { Line 2739  public class Client {
2739                  cmd.append(entry.getMidiBank()).append(' ');                  cmd.append(entry.getMidiBank()).append(' ');
2740                  cmd.append(entry.getMidiProgram()).append(' ');                  cmd.append(entry.getMidiProgram()).append(' ');
2741                  cmd.append(info.getEngine()).append(" '");                  cmd.append(info.getEngine()).append(" '");
2742                  cmd.append(info.getFilePath()).append("' ");                  cmd.append(conv(info.getFilePath())).append("' ");
2743                  cmd.append(info.getInstrumentIndex()).append(' ');                  cmd.append(info.getInstrumentIndex()).append(' ');
2744                  cmd.append(info.getVolume());                  cmd.append(info.getVolume());
2745                  if(!info.getLoadMode().name().equals("DEFAULT")) {                  if(!info.getLoadMode().name().equals("DEFAULT")) {
# Line 2713  public class Client { Line 2747  public class Client {
2747                  }                  }
2748                                    
2749                  if(info.getName() != null) {                  if(info.getName() != null) {
2750                          String s = toEscapedString(info.getName());                          String s = toEscapedText(info.getName());
2751                          cmd.append(" '").append(s).append("'");                          cmd.append(" '").append(s).append("'");
2752                  }                  }
2753                                    
# Line 2955  public class Client { Line 2989  public class Client {
2989                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
2990                                    
2991                  String cmd = nonModal ? "LOAD INSTRUMENT NON_MODAL " : "LOAD INSTRUMENT ";                  String cmd = nonModal ? "LOAD INSTRUMENT NON_MODAL " : "LOAD INSTRUMENT ";
2992                  String args = '\'' + filename + "' " + instrIdx + ' ' + samplerChn;                  String args = '\'' + conv(filename) + "' " + instrIdx + ' ' + samplerChn;
2993                                    
2994                  out.writeLine(cmd + args);                  out.writeLine(cmd + args);
2995                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
# Line 3607  public class Client { Line 3641  public class Client {
3641                                    
3642                  verifyConnection();                  verifyConnection();
3643                  String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl);                  String s = String.valueOf(channel) + " " + String.valueOf(midiCtrl);
3644                  if(name != null) s += " '" + toEscapedString(name) + "'";                  if(name != null) s += " '" + toEscapedText(name) + "'";
3645                  out.writeLine("CREATE FX_SEND " + s);                  out.writeLine("CREATE FX_SEND " + s);
3646                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
3647                                    
# Line 3738  public class Client { Line 3772  public class Client {
3772                                  throws IOException, LscpException, LSException {                                  throws IOException, LscpException, LSException {
3773                                    
3774                  verifyConnection();                  verifyConnection();
3775                  String args = " " + channel + " " + fxSend + " '" + toEscapedString(name) + "'";                  String args = " " + channel + " " + fxSend + " '" + toEscapedText(name) + "'";
3776                  out.writeLine("SET FX_SEND NAME" + args);                  out.writeLine("SET FX_SEND NAME" + args);
3777                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
3778                                    
# Line 3857  public class Client { Line 3891  public class Client {
3891          public synchronized void          public synchronized void
3892          addDbDirectory(String dir) throws IOException, LSException, LscpException {          addDbDirectory(String dir) throws IOException, LSException, LscpException {
3893                  verifyConnection();                  verifyConnection();
3894                  out.writeLine("ADD DB_INSTRUMENT_DIRECTORY '" + dir + "'");                  out.writeLine("ADD DB_INSTRUMENT_DIRECTORY '" + conv(dir) + "'");
3895                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
3896                                    
3897                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 3892  public class Client { Line 3926  public class Client {
3926                  verifyConnection();                  verifyConnection();
3927                  String s = "REMOVE DB_INSTRUMENT_DIRECTORY ";                  String s = "REMOVE DB_INSTRUMENT_DIRECTORY ";
3928                  if(force) s += "FORCE ";                  if(force) s += "FORCE ";
3929                  out.writeLine(s + "'" + dir + "'");                  out.writeLine(s + "'" + conv(dir) + "'");
3930                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
3931                                    
3932                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 3915  public class Client { Line 3949  public class Client {
3949                  String cmd = "REMOVE DB_INSTRUMENT_DIRECTORY ";                  String cmd = "REMOVE DB_INSTRUMENT_DIRECTORY ";
3950                  if(force) cmd += "FORCE ";                  if(force) cmd += "FORCE ";
3951                                    
3952                  for(String s : dirs) out.writeLine(cmd + "'" + s + "'");                  for(String s : dirs) out.writeLine(cmd + "'" + conv(s) + "'");
3953                                    
3954                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
3955                                    
# Line 3953  public class Client { Line 3987  public class Client {
3987                  String s;                  String s;
3988                  if(recursive) s = "GET DB_INSTRUMENT_DIRECTORIES RECURSIVE '";                  if(recursive) s = "GET DB_INSTRUMENT_DIRECTORIES RECURSIVE '";
3989                  else s = "GET DB_INSTRUMENT_DIRECTORIES '";                  else s = "GET DB_INSTRUMENT_DIRECTORIES '";
3990                  out.writeLine(s + dir + "'");                  out.writeLine(s + conv(dir) + "'");
3991                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
3992                                    
3993                  s = getSingleLineResultSet().getResult();                  s = getSingleLineResultSet().getResult();
# Line 3972  public class Client { Line 4006  public class Client {
4006          public synchronized String[]          public synchronized String[]
4007          getDbDirectoryNames(String dir) throws IOException, LscpException, LSException {          getDbDirectoryNames(String dir) throws IOException, LscpException, LSException {
4008                  verifyConnection();                  verifyConnection();
4009                  out.writeLine("LIST DB_INSTRUMENT_DIRECTORIES '" + dir + "'");                  out.writeLine("LIST DB_INSTRUMENT_DIRECTORIES '" + conv(dir) + "'");
4010                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4011                                    
4012                  String[] names = parseEscapedStringList(getSingleLineResultSet().getResult());                  String[] names = parseEscapedStringList(getSingleLineResultSet().getResult());
# Line 3994  public class Client { Line 4028  public class Client {
4028          public synchronized DbDirectoryInfo          public synchronized DbDirectoryInfo
4029          getDbDirectoryInfo(String dir) throws IOException, LscpException, LSException {          getDbDirectoryInfo(String dir) throws IOException, LscpException, LSException {
4030                  verifyConnection();                  verifyConnection();
4031                  out.writeLine("GET DB_INSTRUMENT_DIRECTORY INFO '" + dir + "'");                  out.writeLine("GET DB_INSTRUMENT_DIRECTORY INFO '" + conv(dir) + "'");
4032                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4033                                    
4034                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
# Line 4027  public class Client { Line 4061  public class Client {
4061                  if(!hasEndingFileSeparator(dir)) dir += "/";                  if(!hasEndingFileSeparator(dir)) dir += "/";
4062                  DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length];                  DbDirectoryInfo[] infoS = new DbDirectoryInfo[dirS.length];
4063                  for(int i = 0; i < dirS.length; i++) {                  for(int i = 0; i < dirS.length; i++) {
4064                          infoS[i] = getDbDirectoryInfo(dir + toEscapedFileName(dirS[i]));                          infoS[i] = getDbDirectoryInfo(conv(dir) + toEscapedFsEntry(dirS[i]));
4065                  }                  }
4066                  return infoS;                  return infoS;
4067          }          }
# Line 4043  public class Client { Line 4077  public class Client {
4077           *           *
4078          public synchronized DbDirectoryInfo[]          public synchronized DbDirectoryInfo[]
4079          getDbDirectories(String dir) throws IOException, LscpException, LSException {          getDbDirectories(String dir) throws IOException, LscpException, LSException {
4080                  String[] dirS = getDbDirectoryNames(dir);                  String[] dirS = getDbDirectoryNames(conv(dir));
4081                  if(dirS.length == 0) return new DbDirectoryInfo[0];                  if(dirS.length == 0) return new DbDirectoryInfo[0];
4082                                    
4083                  if(dir.charAt(dir.length() - 1) != '/') dir += "/";                  if(dir.charAt(dir.length() - 1) != '/') dir += "/"; // FIXME:
4084                                    
4085                  for(int i = 0; i < dirS.length; i++) {                  for(int i = 0; i < dirS.length; i++) {
4086                          out.writeLine("GET DB_INSTRUMENT_DIRECTORY INFO '" + dir + dirS[i] + "'");                          out.writeLine("GET DB_INSTRUMENT_DIRECTORY INFO '" + conv(dir + dirS[i]) + "'");
4087                  }                  }
4088                                    
4089                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
# Line 4093  public class Client { Line 4127  public class Client {
4127          public synchronized void          public synchronized void
4128          renameDbDirectory(String dir, String name) throws IOException, LSException, LscpException {          renameDbDirectory(String dir, String name) throws IOException, LSException, LscpException {
4129                  verifyConnection();                  verifyConnection();
4130                  name = toEscapedString(name);                  name = toEscapedText(name);
4131                  out.writeLine("SET DB_INSTRUMENT_DIRECTORY NAME '" + dir + "' '" + name + "'");                  out.writeLine("SET DB_INSTRUMENT_DIRECTORY NAME '" + conv(dir) + "' '" + conv(name) + "'");
4132                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4133                                    
4134                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4111  public class Client { Line 4145  public class Client {
4145          public synchronized void          public synchronized void
4146          moveDbDirectory(String dir, String dst) throws IOException, LSException, LscpException {          moveDbDirectory(String dir, String dst) throws IOException, LSException, LscpException {
4147                  verifyConnection();                  verifyConnection();
4148                  out.writeLine("MOVE DB_INSTRUMENT_DIRECTORY '" + dir + "' '" + dst + "'");                  out.writeLine("MOVE DB_INSTRUMENT_DIRECTORY '" + conv(dir) + "' '" + conv(dst) + "'");
4149                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4150                                    
4151                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4129  public class Client { Line 4163  public class Client {
4163          moveDbDirectories(String dirs[], String dst) throws IOException, LSException, LscpException {          moveDbDirectories(String dirs[], String dst) throws IOException, LSException, LscpException {
4164                  verifyConnection();                  verifyConnection();
4165                  for(String s : dirs) {                  for(String s : dirs) {
4166                          out.writeLine("MOVE DB_INSTRUMENT_DIRECTORY '" + s + "' '" + dst + "'");                          out.writeLine("MOVE DB_INSTRUMENT_DIRECTORY '" + conv(s) + "' '" + conv(dst) + "'");
4167                  }                  }
4168                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4169                                    
# Line 4147  public class Client { Line 4181  public class Client {
4181          public synchronized void          public synchronized void
4182          copyDbDirectory(String dir, String dst) throws IOException, LSException, LscpException {          copyDbDirectory(String dir, String dst) throws IOException, LSException, LscpException {
4183                  verifyConnection();                  verifyConnection();
4184                  out.writeLine("COPY DB_INSTRUMENT_DIRECTORY '" + dir + "' '" + dst + "'");                  out.writeLine("COPY DB_INSTRUMENT_DIRECTORY '" + conv(dir) + "' '" + conv(dst) + "'");
4185                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4186                                    
4187                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4165  public class Client { Line 4199  public class Client {
4199          copyDbDirectories(String[] dirs, String dst) throws IOException, LSException, LscpException {          copyDbDirectories(String[] dirs, String dst) throws IOException, LSException, LscpException {
4200                  verifyConnection();                  verifyConnection();
4201                  for(String s : dirs) {                  for(String s : dirs) {
4202                          out.writeLine("COPY DB_INSTRUMENT_DIRECTORY '" + s + "' '" + dst + "'");                          out.writeLine("COPY DB_INSTRUMENT_DIRECTORY '" + conv(s) + "' '" + conv(dst) + "'");
4203                  }                  }
4204                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4205                                    
# Line 4186  public class Client { Line 4220  public class Client {
4220                                    
4221                  verifyConnection();                  verifyConnection();
4222                  String s = "SET DB_INSTRUMENT_DIRECTORY DESCRIPTION '";                  String s = "SET DB_INSTRUMENT_DIRECTORY DESCRIPTION '";
4223                  out.writeLine(s + dir + "' '" + toEscapedString(desc) + "'");                  out.writeLine(s + conv(dir) + "' '" + toEscapedText(desc) + "'");
4224                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4225                                    
4226                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4235  public class Client { Line 4269  public class Client {
4269                  verifyConnection();                  verifyConnection();
4270                  String s = "ADD DB_INSTRUMENTS";                  String s = "ADD DB_INSTRUMENTS";
4271                  if(background) s += " NON_MODAL";                  if(background) s += " NON_MODAL";
4272                  s += " '" + dbDir + "' '" + filePath + "' ";                  s += " '" + conv(dbDir) + "' '" + conv(filePath) + "' ";
4273                  out.writeLine(s + String.valueOf(instrIndex));                  out.writeLine(s + String.valueOf(instrIndex));
4274                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
4275                                    
# Line 4282  public class Client { Line 4316  public class Client {
4316                  verifyConnection();                  verifyConnection();
4317                  String s = "ADD DB_INSTRUMENTS";                  String s = "ADD DB_INSTRUMENTS";
4318                  if(background) s += " NON_MODAL";                  if(background) s += " NON_MODAL";
4319                  out.writeLine(s + " '" + dbDir + "' '" + filePath + "'");                  out.writeLine(s + " '" + conv(dbDir) + "' '" + conv(filePath) + "'");
4320                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
4321                                    
4322                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4365  public class Client { Line 4399  public class Client {
4399                                  break;                                  break;
4400                  }                  }
4401                                    
4402                  sb.append(" '").append(dbDir).append("' '");                  sb.append(" '").append(conv(dbDir)).append("' '");
4403                  sb.append(fsDir).append("'");                  sb.append(conv(fsDir)).append("'");
4404                  out.writeLine(sb.toString());                  out.writeLine(sb.toString());
4405                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
4406                                    
# Line 4385  public class Client { Line 4419  public class Client {
4419          removeDbInstrument(String instr) throws IOException, LscpException, LSException {          removeDbInstrument(String instr) throws IOException, LscpException, LSException {
4420                                    
4421                  verifyConnection();                  verifyConnection();
4422                  out.writeLine("REMOVE DB_INSTRUMENT '" + instr + "'");                  out.writeLine("REMOVE DB_INSTRUMENT '" + conv(instr) + "'");
4423                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4424                                    
4425                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4402  public class Client { Line 4436  public class Client {
4436          removeDbInstruments(String[] instrs) throws IOException, LscpException, LSException {          removeDbInstruments(String[] instrs) throws IOException, LscpException, LSException {
4437                  verifyConnection();                  verifyConnection();
4438                  for(String s : instrs) {                  for(String s : instrs) {
4439                          out.writeLine("REMOVE DB_INSTRUMENT '" + s + "'");                          out.writeLine("REMOVE DB_INSTRUMENT '" + conv(s) + "'");
4440                  }                  }
4441                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4442                                    
# Line 4440  public class Client { Line 4474  public class Client {
4474                  String s;                  String s;
4475                  if(recursive) s = "GET DB_INSTRUMENTS RECURSIVE '";                  if(recursive) s = "GET DB_INSTRUMENTS RECURSIVE '";
4476                  else s = "GET DB_INSTRUMENTS '";                  else s = "GET DB_INSTRUMENTS '";
4477                  out.writeLine(s + dir + "'");                  out.writeLine(s + conv(dir) + "'");
4478                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
4479                                    
4480                  s = getSingleLineResultSet().getResult();                  s = getSingleLineResultSet().getResult();
# Line 4459  public class Client { Line 4493  public class Client {
4493          public synchronized String[]          public synchronized String[]
4494          getDbInstrumentNames(String dir) throws IOException, LscpException, LSException {          getDbInstrumentNames(String dir) throws IOException, LscpException, LSException {
4495                  verifyConnection();                  verifyConnection();
4496                  out.writeLine("LIST DB_INSTRUMENTS '" + dir + "'");                  out.writeLine("LIST DB_INSTRUMENTS '" + conv(dir) + "'");
4497                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4498                                    
4499                  String[] names = parseEscapedStringList(getSingleLineResultSet().getResult());                  String[] names = parseEscapedStringList(getSingleLineResultSet().getResult());
# Line 4481  public class Client { Line 4515  public class Client {
4515          public synchronized DbInstrumentInfo          public synchronized DbInstrumentInfo
4516          getDbInstrumentInfo(String instr) throws IOException, LscpException, LSException {          getDbInstrumentInfo(String instr) throws IOException, LscpException, LSException {
4517                  verifyConnection();                  verifyConnection();
4518                  out.writeLine("GET DB_INSTRUMENT INFO '" + instr + "'");                  out.writeLine("GET DB_INSTRUMENT INFO '" + conv(instr) + "'");
4519                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
4520                                    
4521                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
# Line 4510  public class Client { Line 4544  public class Client {
4544                                    
4545                  DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length];                  DbInstrumentInfo[] infoS = new DbInstrumentInfo[instrS.length];
4546                  for(int i = 0; i < instrS.length; i++) {                  for(int i = 0; i < instrS.length; i++) {
4547                          infoS[i] = getDbInstrumentInfo(dir + toEscapedFileName(instrS[i]));                          infoS[i] = getDbInstrumentInfo(conv(dir) + toEscapedFsEntry(instrS[i]));
4548                  }                  }
4549                  return infoS;                  return infoS;
4550          }          }
# Line 4529  public class Client { Line 4563  public class Client {
4563                  String[] instrS = getDbInstrumentNames(dir);                  String[] instrS = getDbInstrumentNames(dir);
4564                  if(instrS.length == 0) return new DbInstrumentInfo[0];                  if(instrS.length == 0) return new DbInstrumentInfo[0];
4565                                    
4566                  if(dir.charAt(dir.length() - 1) != '/') dir += "/";                  if(dir.charAt(dir.length() - 1) != '/') dir += "/"; FIXME:
4567                                    
4568                  for(int i = 0; i < instrS.length; i++) {                  for(int i = 0; i < instrS.length; i++) {
4569                          out.writeLine("GET DB_INSTRUMENT INFO '" + dir + instrS[i] + "'");                          out.writeLine("GET DB_INSTRUMENT INFO '" + conv(dir) + instrS[i] + "'");
4570                  }                  }
4571                                    
4572                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
# Line 4578  public class Client { Line 4612  public class Client {
4612                                  throws IOException, LSException, LscpException {                                  throws IOException, LSException, LscpException {
4613                                    
4614                  verifyConnection();                  verifyConnection();
4615                  name = toEscapedString(name);                  name = toEscapedText(name);
4616                  out.writeLine("SET DB_INSTRUMENT NAME '" + instr + "' '" + name + "'");                  out.writeLine("SET DB_INSTRUMENT NAME '" + conv(instr) + "' '" + conv(name) + "'");
4617                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4618                                    
4619                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4596  public class Client { Line 4630  public class Client {
4630          public synchronized void          public synchronized void
4631          moveDbInstrument(String instr, String dst) throws IOException, LSException, LscpException {          moveDbInstrument(String instr, String dst) throws IOException, LSException, LscpException {
4632                  verifyConnection();                  verifyConnection();
4633                  out.writeLine("MOVE DB_INSTRUMENT '" + instr + "' '" + dst + "'");                  out.writeLine("MOVE DB_INSTRUMENT '" + conv(instr) + "' '" + conv(dst) + "'");
4634                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4635                                    
4636                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4614  public class Client { Line 4648  public class Client {
4648          moveDbInstruments(String[] instrs, String dst) throws IOException, LSException, LscpException {          moveDbInstruments(String[] instrs, String dst) throws IOException, LSException, LscpException {
4649                  verifyConnection();                  verifyConnection();
4650                  for(String s : instrs) {                  for(String s : instrs) {
4651                          out.writeLine("MOVE DB_INSTRUMENT '" + s + "' '" + dst + "'");                          out.writeLine("MOVE DB_INSTRUMENT '" + conv(s) + "' '" + conv(dst) + "'");
4652                  }                  }
4653                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4654                                    
# Line 4632  public class Client { Line 4666  public class Client {
4666          public synchronized void          public synchronized void
4667          copyDbInstrument(String instr, String dst) throws IOException, LSException, LscpException {          copyDbInstrument(String instr, String dst) throws IOException, LSException, LscpException {
4668                  verifyConnection();                  verifyConnection();
4669                  out.writeLine("COPY DB_INSTRUMENT '" + instr + "' '" + dst + "'");                  out.writeLine("COPY DB_INSTRUMENT '" + conv(instr) + "' '" + conv(dst) + "'");
4670                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4671                                    
4672                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4650  public class Client { Line 4684  public class Client {
4684          copyDbInstruments(String[] instrs, String dst) throws IOException, LSException, LscpException {          copyDbInstruments(String[] instrs, String dst) throws IOException, LSException, LscpException {
4685                  verifyConnection();                  verifyConnection();
4686                  for(String s : instrs) {                  for(String s : instrs) {
4687                          out.writeLine("COPY DB_INSTRUMENT '" + s + "' '" + dst + "'");                          out.writeLine("COPY DB_INSTRUMENT '" + conv(s) + "' '" + conv(dst) + "'");
4688                  }                  }
4689                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4690                                    
# Line 4670  public class Client { Line 4704  public class Client {
4704                                  throws IOException, LSException, LscpException {                                  throws IOException, LSException, LscpException {
4705                                    
4706                  verifyConnection();                  verifyConnection();
4707                  desc = toEscapedString(desc);                  desc = toEscapedText(desc);
4708                  out.writeLine("SET DB_INSTRUMENT DESCRIPTION '" + instr + "' '" + desc + "'");                  out.writeLine("SET DB_INSTRUMENT DESCRIPTION '" + conv(instr) + "' '" + desc + "'");
4709                    if(getPrintOnlyMode()) return;
4710                    
4711                    ResultSet rs = getEmptyResultSet();
4712            }
4713            
4714            /**
4715             * Substitutes all occurrences of the instrument file
4716             * <code>oldPath</code> in the database, with <code>newPath</code>.
4717             * @param oldPath The absolute path name of the instrument file to substitute.
4718             * @param newPath The new absolute path name.
4719             * @throws IOException If some I/O error occurs.
4720             * @throws LSException If the operation failed.
4721             * @throws LscpException If LSCP protocol corruption occurs.
4722             */
4723            public synchronized void
4724            setDbInstrumentFilePath(String oldPath, String newPath)
4725                                    throws IOException, LSException, LscpException {
4726                    
4727                    verifyConnection();
4728                    out.writeLine("SET DB_INSTRUMENT FILE_PATH '" + conv(oldPath) + "' '" + conv(newPath) + "'");
4729                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
4730                                    
4731                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 4715  public class Client { Line 4769  public class Client {
4769                  StringBuffer sb = new StringBuffer();                  StringBuffer sb = new StringBuffer();
4770                  sb.append("FIND DB_INSTRUMENT_DIRECTORIES");                  sb.append("FIND DB_INSTRUMENT_DIRECTORIES");
4771                  if(nonRecursive) sb.append(" NON_RECURSIVE");                  if(nonRecursive) sb.append(" NON_RECURSIVE");
4772                  sb.append(" '").append(dir).append("'");                  sb.append(" '").append(conv(dir)).append("'");
4773                                    
4774                  if(query.name != null && query.name.length() > 0) {                  if(query.name != null && query.name.length() > 0) {
4775                          sb.append(" NAME='").append(toEscapedString(query.name)).append("'");                          sb.append(" NAME='").append(toEscapedText(query.name)).append("'");
4776                  }                  }
4777                                    
4778                  String s = query.getCreatedAfter();                  String s = query.getCreatedAfter();
# Line 4743  public class Client { Line 4797  public class Client {
4797                                    
4798                  if(query.description != null && query.description.length() > 0) {                  if(query.description != null && query.description.length() > 0) {
4799                          sb.append(" DESCRIPTION='");                          sb.append(" DESCRIPTION='");
4800                          sb.append(toEscapedString(query.description)).append("'");                          sb.append(toEscapedText(query.description)).append("'");
4801                  }                  }
4802                                    
4803                  out.writeLine(sb.toString());                  out.writeLine(sb.toString());
# Line 4796  public class Client { Line 4850  public class Client {
4850                  StringBuffer sb = new StringBuffer();                  StringBuffer sb = new StringBuffer();
4851                  sb.append("FIND DB_INSTRUMENTS");                  sb.append("FIND DB_INSTRUMENTS");
4852                  if(nonRecursive) sb.append(" NON_RECURSIVE");                  if(nonRecursive) sb.append(" NON_RECURSIVE");
4853                  sb.append(" '").append(dir).append("'");                  sb.append(" '").append(conv(dir)).append("'");
4854                                    
4855                  if(query.name != null && query.name.length() > 0) {                  if(query.name != null && query.name.length() > 0) {
4856                          sb.append(" NAME='").append(toEscapedString(query.name)).append("'");                          sb.append(" NAME='").append(toEscapedText(query.name)).append("'");
4857                  }                  }
4858                                    
4859                  if(query.formatFamilies.size() > 0) {                  if(query.formatFamilies.size() > 0) {
# Line 4840  public class Client { Line 4894  public class Client {
4894                                    
4895                  if(query.description != null && query.description.length() > 0) {                  if(query.description != null && query.description.length() > 0) {
4896                          sb.append(" DESCRIPTION='");                          sb.append(" DESCRIPTION='");
4897                          sb.append(toEscapedString(query.description)).append("'");                          sb.append(toEscapedText(query.description)).append("'");
4898                  }                  }
4899                                    
4900                  if(query.instrumentType != DbSearchQuery.InstrumentType.BOTH) {                  if(query.instrumentType != DbSearchQuery.InstrumentType.BOTH) {
# Line 4853  public class Client { Line 4907  public class Client {
4907                  }                  }
4908                                    
4909                  if(query.product != null && query.product.length() > 0) {                  if(query.product != null && query.product.length() > 0) {
4910                          sb.append(" PRODUCT='").append(toEscapedString(query.product)).append("'");                          sb.append(" PRODUCT='").append(toEscapedText(query.product)).append("'");
4911                  }                  }
4912                                    
4913                  if(query.artists != null && query.artists.length() > 0) {                  if(query.artists != null && query.artists.length() > 0) {
4914                          sb.append(" ARTISTS='").append(toEscapedString(query.artists)).append("'");                          sb.append(" ARTISTS='").append(toEscapedText(query.artists)).append("'");
4915                  }                  }
4916                                    
4917                  if(query.keywords != null && query.keywords.length() > 0) {                  if(query.keywords != null && query.keywords.length() > 0) {
4918                          sb.append(" KEYWORDS='");                          sb.append(" KEYWORDS='");
4919                          sb.append(toEscapedString(query.keywords)).append("'");                          sb.append(toEscapedText(query.keywords)).append("'");
4920                  }                  }
4921                                    
4922                  out.writeLine(sb.toString());                  out.writeLine(sb.toString());
# Line 4878  public class Client { Line 4932  public class Client {
4932          }          }
4933                    
4934          /**          /**
4935             * Returns a list of all instrument files in the database
4936             * that that doesn't exist in the filesystem.
4937             * @throws IOException If some I/O error occurs.
4938             * @throws LscpException If LSCP protocol corruption occurs.
4939             * @throws LSException If other error occurs.
4940             */
4941            public synchronized String[]
4942            findLostDbInstrumentFiles() throws IOException, LscpException, LSException {
4943                    
4944                    verifyConnection();
4945                    out.writeLine("FIND LOST DB_INSTRUMENT_FILES");
4946                    if(getPrintOnlyMode()) return null;
4947                    
4948                    return parseEscapedStringList(getSingleLineResultSet().getResult());
4949            }
4950            
4951            /**
4952           * Gets status information about the specified job.           * Gets status information about the specified job.
4953           * @param jobId The ID of the job.           * @param jobId The ID of the job.
4954           * @return A <code>ScanJobInfo</code> instance providing information           * @return A <code>ScanJobInfo</code> instance providing information
# Line 5067  public class Client { Line 5138  public class Client {
5138          public synchronized int          public synchronized int
5139          getFileInstrumentCount(String filename) throws IOException, LscpException, LSException {          getFileInstrumentCount(String filename) throws IOException, LscpException, LSException {
5140                  verifyConnection();                  verifyConnection();
5141                  out.writeLine("GET FILE INSTRUMENTS '" + filename +"'");                  out.writeLine("GET FILE INSTRUMENTS '" + conv(filename) +"'");
5142                  if(getPrintOnlyMode()) return -1;                  if(getPrintOnlyMode()) return -1;
5143                                    
5144                  String s = getSingleLineResultSet().getResult();                  String s = getSingleLineResultSet().getResult();
# Line 5088  public class Client { Line 5159  public class Client {
5159                                  throws IOException, LscpException, LSException {                                  throws IOException, LscpException, LSException {
5160                                    
5161                  verifyConnection();                  verifyConnection();
5162                  out.writeLine("GET FILE INSTRUMENT INFO '" + filename + "' " + String.valueOf(instrIdx));                  out.writeLine("GET FILE INSTRUMENT INFO '" + conv(filename) + "' " + String.valueOf(instrIdx));
5163                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
5164                                    
5165                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();

Legend:
Removed from v.1727  
changed lines
  Added in v.1728

  ViewVC Help
Powered by ViewVC