/[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 1346 by iliev, Thu Sep 13 22:02:03 2007 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 34  import java.util.Vector; Line 34  import java.util.Vector;
34  import java.util.logging.Level;  import java.util.logging.Level;
35  import java.util.logging.Logger;  import java.util.logging.Logger;
36    
 import static org.linuxsampler.lscp.Parser.*;  
37  import org.linuxsampler.lscp.event.*;  import org.linuxsampler.lscp.event.*;
38    
39    import static org.linuxsampler.lscp.Parser.*;
40    
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 163  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 343  public class Client { Line 378  public class Client {
378                  if(!llFSI.isEmpty()) subscribe("FX_SEND_INFO");                  if(!llFSI.isEmpty()) subscribe("FX_SEND_INFO");
379                  if(!llSC.isEmpty()) subscribe("STREAM_COUNT");                  if(!llSC.isEmpty()) subscribe("STREAM_COUNT");
380                  if(!llVC.isEmpty()) subscribe("VOICE_COUNT");                  if(!llVC.isEmpty()) subscribe("VOICE_COUNT");
381                    if(!llTSC.isEmpty()) subscribe("TOTAL_STREAM_COUNT");
382                  if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT");                  if(!llTVC.isEmpty()) subscribe("TOTAL_VOICE_COUNT");
383                  if(!llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT");                  if(!llMIMC.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_COUNT");
384                  if(!llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO");                  if(!llMIMI.isEmpty()) subscribe("MIDI_INSTRUMENT_MAP_INFO");
# Line 353  public class Client { Line 389  public class Client {
389                          subscribe("DB_INSTRUMENT_DIRECTORY_INFO");                          subscribe("DB_INSTRUMENT_DIRECTORY_INFO");
390                          subscribe("DB_INSTRUMENT_COUNT");                          subscribe("DB_INSTRUMENT_COUNT");
391                          subscribe("DB_INSTRUMENT_INFO");                          subscribe("DB_INSTRUMENT_INFO");
392                            subscribe("DB_INSTRUMENTS_JOB_INFO");
393                  }                  }
394                  if(!llGI.isEmpty()) subscribe("GLOBAL_INFO");                  if(!llGI.isEmpty()) subscribe("GLOBAL_INFO");
395          }          }
# Line 484  public class Client { Line 521  public class Client {
521          private final Vector<ItemInfoListener> llMIDI = new Vector<ItemInfoListener>();          private final Vector<ItemInfoListener> llMIDI = new Vector<ItemInfoListener>();
522          private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>();          private final Vector<StreamCountListener> llSC = new Vector<StreamCountListener>();
523          private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>();          private final Vector<VoiceCountListener> llVC = new Vector<VoiceCountListener>();
524            private final Vector<TotalStreamCountListener> llTSC = new Vector<TotalStreamCountListener>();
525          private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>();          private final Vector<TotalVoiceCountListener> llTVC = new Vector<TotalVoiceCountListener>();
526                    
527          /** MIDI instrument map count listeners */          /** MIDI instrument map count listeners */
# Line 521  public class Client { Line 559  public class Client {
559                          !llMIDI.isEmpty() ||                          !llMIDI.isEmpty() ||
560                          !llSC.isEmpty()   ||                          !llSC.isEmpty()   ||
561                          !llVC.isEmpty()   ||                          !llVC.isEmpty()   ||
562                            !llTSC.isEmpty()  ||
563                          !llTVC.isEmpty()  ||                          !llTVC.isEmpty()  ||
564                          !llMIMC.isEmpty() ||                          !llMIMC.isEmpty() ||
565                          !llMIMI.isEmpty() ||                          !llMIMI.isEmpty() ||
# Line 545  public class Client { Line 584  public class Client {
584                                          s = s.substring("NAME ".length());                                          s = s.substring("NAME ".length());
585                                          list = parseEscapedStringList(s, ' ');                                          list = parseEscapedStringList(s, ' ');
586                                          if(list.length != 2) throw new LscpException();                                          if(list.length != 2) throw new LscpException();
587                                          list[1] = toNonEscapedText(list[1]);                                          list[1] = toNonEscapedString(list[1]);
588                                          e = new InstrumentsDbEvent(this, list[0], list[1]);                                          e = new InstrumentsDbEvent(this, list[0], list[1]);
589                                          for(InstrumentsDbListener l : llID) {                                          for(InstrumentsDbListener l : llID) {
590                                                  l.directoryNameChanged(e);                                                  l.directoryNameChanged(e);
# Line 574  public class Client { Line 613  public class Client {
613                                          s = s.substring("NAME ".length());                                          s = s.substring("NAME ".length());
614                                          list = parseEscapedStringList(s, ' ');                                          list = parseEscapedStringList(s, ' ');
615                                          if(list.length != 2) throw new LscpException();                                          if(list.length != 2) throw new LscpException();
616                                          list[1] = toNonEscapedText(list[1]);                                          list[1] = toNonEscapedString(list[1]);
617                                          e = new InstrumentsDbEvent(this, list[0], list[1]);                                          e = new InstrumentsDbEvent(this, list[0], list[1]);
618                                          for(InstrumentsDbListener l : llID) {                                          for(InstrumentsDbListener l : llID) {
619                                                  l.instrumentNameChanged(e);                                                  l.instrumentNameChanged(e);
# Line 661  public class Client { Line 700  public class Client {
700                          } catch(NumberFormatException x) {                          } catch(NumberFormatException x) {
701                                  getLogger().log(Level.WARNING, "Unknown CHANNEL_INFO format", x);                                  getLogger().log(Level.WARNING, "Unknown CHANNEL_INFO format", x);
702                          }                          }
703                    } else if(s.startsWith("TOTAL_STREAM_COUNT:")) {
704                            try {
705                                    s = s.substring("TOTAL_STREAM_COUNT:".length());
706                                    int i = Integer.parseInt(s);
707                                    TotalStreamCountEvent e = new TotalStreamCountEvent(this, i);
708                                    for(TotalStreamCountListener l : llTSC) l.totalStreamCountChanged(e);
709                            } catch(NumberFormatException x) {
710                                    getLogger().log (
711                                            Level.WARNING, "Unknown TOTAL_STREAM_COUNT format", x
712                                    );
713                            }
714                  } else if(s.startsWith("TOTAL_VOICE_COUNT:")) {                  } else if(s.startsWith("TOTAL_VOICE_COUNT:")) {
715                          try {                          try {
716                                  s = s.substring("TOTAL_VOICE_COUNT:".length());                                  s = s.substring("TOTAL_VOICE_COUNT:".length());
# Line 1133  public class Client { Line 1183  public class Client {
1183          /**          /**
1184           * Registers the specified listener for receiving event messages.           * Registers the specified listener for receiving event messages.
1185           * Listeners can be registered regardless of the connection state.           * Listeners can be registered regardless of the connection state.
1186             * @param l The <code>TotalStreamCountListener</code> to register.
1187             */
1188            public synchronized void
1189            addTotalStreamCountListener(TotalStreamCountListener l) {
1190                    if(llTSC.isEmpty()) subscribe("TOTAL_STREAM_COUNT");
1191                    llTSC.add(l);
1192            }
1193            
1194            /**
1195             * Removes the specified listener.
1196             * Listeners can be removed regardless of the connection state.
1197             * @param l The <code>TotalStreamCountListener</code> to remove.
1198             */
1199            public synchronized void
1200            removeTotalStreamCountListener(TotalStreamCountListener l) {
1201                    boolean b = llTSC.remove(l);
1202                    if(b && llTSC.isEmpty()) unsubscribe("TOTAL_STREAM_COUNT");
1203            }
1204            
1205            /**
1206             * Registers the specified listener for receiving event messages.
1207             * Listeners can be registered regardless of the connection state.
1208           * @param l The <code>TotalVoiceCountListener</code> to register.           * @param l The <code>TotalVoiceCountListener</code> to register.
1209           */           */
1210          public synchronized void          public synchronized void
# Line 1417  public class Client { Line 1489  public class Client {
1489                  args.append(' ').append(param);                  args.append(' ').append(param);
1490                                    
1491                  for(Parameter p : deplist) {                  for(Parameter p : deplist) {
1492                          if(p.getValue() == null) continue;                          if(p == null || p.getName() == null || p.getValue() == null) continue;
1493                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
1494                  }                  }
1495                                    
# Line 1481  public class Client { Line 1553  public class Client {
1553                  StringBuffer args = new StringBuffer(aoDriver);                  StringBuffer args = new StringBuffer(aoDriver);
1554                                    
1555                  for(Parameter p : paramList) {                  for(Parameter p : paramList) {
1556                          if(p.getValue() == null) continue;                          if(p == null || p.getName() == null || p.getValue() == null) continue;
1557                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
1558                  }                  }
1559                                    
# Line 2003  public class Client { Line 2075  public class Client {
2075                  args.append(' ').append(param);                  args.append(' ').append(param);
2076                                    
2077                  for(Parameter p : deplist) {                  for(Parameter p : deplist) {
2078                          if(p.getValue() == null) continue;                          if(p == null || p.getName() == null || p.getValue() == null) continue;
2079                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
2080                  }                  }
2081                                    
# Line 2068  public class Client { Line 2140  public class Client {
2140                  StringBuffer args = new StringBuffer(miDriver);                  StringBuffer args = new StringBuffer(miDriver);
2141                                    
2142                  for(Parameter p : paramList) {                  for(Parameter p : paramList) {
2143                          if(p.getValue() == null) continue;                          if(p == null || p.getName() == null || p.getValue() == null) continue;
2144                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());                          args.append(' ').append(p.getName()).append('=').append(p.getStringValue());
2145                  }                  }
2146                                    
# Line 2215  public class Client { Line 2287  public class Client {
2287                                  mid.setActive(Boolean.parseBoolean(s));                                  mid.setActive(Boolean.parseBoolean(s));
2288                          } else if(s.startsWith("PORTS: ")) {                          } else if(s.startsWith("PORTS: ")) {
2289                                  s = s.substring("PORTS: ".length());                                  s = s.substring("PORTS: ".length());
2290                                  int ports = Parser.parseInt(s);                                  
2291                                  MidiPort[] midiPorts = new MidiPort[ports > 0 ? ports : 0];                                  Parameter<Integer> ports = (Parameter<Integer>)
2292                                            getMidiInputDriverParameterInfo(drv, "PORTS");
2293                                    
2294                                    ports.parseValue(s);
2295                                    mid.setPortsParameter(ports);
2296                                    
2297                                    int j = ports.getValue();
2298                                    MidiPort[] midiPorts = new MidiPort[j > 0 ? j : 0];
2299                                                                    
2300                                  for(int i = 0; i < midiPorts.length; i++)                                  for(int i = 0; i < midiPorts.length; i++)
2301                                          midiPorts[i] = getMidiInputPortInfo(deviceId, i);                                          midiPorts[i] = getMidiInputPortInfo(deviceId, i);
# Line 2459  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 '" + 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 2562  public class Client { Line 2641  public class Client {
2641                                    
2642                  for(String s : lnS) {                  for(String s : lnS) {
2643                          if(s.startsWith("NAME: ")) {                          if(s.startsWith("NAME: ")) {
2644                                  name = s.substring("NAME: ".length());                                  name = toNonEscapedString(s.substring("NAME: ".length()));
2645                          } else if(s.startsWith("DEFAULT: ")) {                          } else if(s.startsWith("DEFAULT: ")) {
2646                                  b = Boolean.parseBoolean(s.substring("DEFAULT: ".length()));                                  b = Boolean.parseBoolean(s.substring("DEFAULT: ".length()));
2647                          } else {                          } else {
# Line 2610  public class Client { Line 2689  public class Client {
2689                                  throws IOException, LscpException, LSException {                                  throws IOException, LscpException, LSException {
2690                                    
2691                  verifyConnection();                  verifyConnection();
2692                    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 2659  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")) {
2746                          cmd.append(' ').append(info.getLoadMode().name());                          cmd.append(' ').append(info.getLoadMode().name());
2747                  }                  }
2748                  if(info.getName() != null) cmd.append(" '").append(info.getName()).append("'");                  
2749                    if(info.getName() != null) {
2750                            String s = toEscapedText(info.getName());
2751                            cmd.append(" '").append(s).append("'");
2752                    }
2753                                    
2754                  out.writeLine(cmd.toString());                  out.writeLine(cmd.toString());
2755                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
# Line 2754  public class Client { Line 2838  public class Client {
2838          }          }
2839                    
2840          /**          /**
2841           * Gets all MIDI instrument contained int the specified MIDI instrument map.           * Gets all MIDI instrument entries contained int the specified MIDI instrument map.
2842             * @param mapId The ID of the map, which instruments should be obtained.
2843             * @return An int array providing all MIDI instrument entries
2844             * in the specified MIDI instrument map.
2845             * @throws IOException If some I/O error occurs.
2846             * @throws LscpException If LSCP protocol corruption occurs.
2847             * @throws LSException If some other error occurs.
2848             */
2849            public synchronized int[][]
2850            getMidiInstrumentEntries(int mapId) throws IOException, LscpException, LSException {
2851                    verifyConnection();
2852                    out.writeLine("LIST MIDI_INSTRUMENTS " + String.valueOf(mapId));
2853                    if(getPrintOnlyMode()) return null;
2854                    
2855                    String[] entries = parseArray(getSingleLineResultSet().getResult());
2856                    int[][] e = new int[entries.length][3];
2857                    
2858                    for(int i = 0; i < entries.length; i++) {
2859                            Integer[] vals = parseIntList(entries[i]);
2860                            if(vals.length != 3) {
2861                                    throw new LscpException(LscpI18n.getLogMsg("CommandFailed!"));
2862                            }
2863                            
2864                            e[i][0] = vals[0];
2865                            e[i][1] = vals[1];
2866                            e[i][2] = vals[2];
2867                    }
2868                    
2869                    return e;
2870            }
2871            
2872            /**
2873             * Gets all MIDI instruments contained int the specified MIDI instrument map.
2874           * @param mapId The ID of the map, which instruments should be obtained.           * @param mapId The ID of the map, which instruments should be obtained.
2875           * @return A <code>MidiInstrumentInfo</code> array providing           * @return A <code>MidiInstrumentInfo</code> array providing
2876           * all MIDI instruments from all MIDI instrument maps.           * all MIDI instruments in the specified MIDI instrument map.
2877           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
2878           * @throws LscpException If LSCP protocol corruption occurs.           * @throws LscpException If LSCP protocol corruption occurs.
2879           * @throws LSException If some other error occurs.           * @throws LSException If some other error occurs.
# Line 2805  public class Client { Line 2921  public class Client {
2921                                          throws IOException, LscpException, LSException {                                          throws IOException, LscpException, LSException {
2922                    
2923                  verifyConnection();                  verifyConnection();
2924                    requestMidiInstrumentInfo(mapId, bank, program);
2925                    return getMidiInstrumentInfoResponse(mapId, bank, program);
2926            }
2927            
2928            private void
2929            requestMidiInstrumentInfo(int mapId, int bank, int program) throws IOException {
2930                  StringBuffer cmd = new StringBuffer("GET MIDI_INSTRUMENT INFO ");                  StringBuffer cmd = new StringBuffer("GET MIDI_INSTRUMENT INFO ");
2931                  cmd.append(mapId).append(' ');                  cmd.append(mapId).append(' ');
2932                  cmd.append(bank).append(' ');                  cmd.append(bank).append(' ');
2933                  cmd.append(program);                  cmd.append(program);
2934                                    
2935                  out.writeLine(cmd.toString());                  out.writeLine(cmd.toString());
2936                  if(getPrintOnlyMode()) return null;          }
2937            
2938            private MidiInstrumentInfo
2939            getMidiInstrumentInfoResponse(int mapId, int bank, int program)
2940                                            throws IOException, LscpException, LSException {
2941                                    
2942                    if(getPrintOnlyMode()) return null;
2943                  ResultSet rs = getMultiLineResultSet();                  ResultSet rs = getMultiLineResultSet();
2944                  MidiInstrumentEntry entry = new MidiInstrumentEntry(bank, program);                  MidiInstrumentEntry entry = new MidiInstrumentEntry(bank, program);
2945                  return new MidiInstrumentInfo(mapId, entry, rs.getMultiLineResult());                  return new MidiInstrumentInfo(mapId, entry, rs.getMultiLineResult());
# Line 2861  public class Client { Line 2988  public class Client {
2988          loadInstrument(String filename, int instrIdx, int samplerChn, boolean nonModal)          loadInstrument(String filename, int instrIdx, int samplerChn, boolean nonModal)
2989                                                  throws IOException, LscpException, LSException {                                                  throws IOException, LscpException, LSException {
2990                                    
                 filename = toEscapedString(filename);  
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 3044  public class Client { Line 3170  public class Client {
3170                  out.writeLine("LIST AVAILABLE_ENGINES");                  out.writeLine("LIST AVAILABLE_ENGINES");
3171                  if(getPrintOnlyMode()) return null;                  if(getPrintOnlyMode()) return null;
3172                                    
3173                  return parseQuotedStringList(getSingleLineResultSet().getResult());                  return parseStringList(getSingleLineResultSet().getResult());
3174          }          }
3175                    
3176          /**          /**
# Line 3515  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 += " '" + 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 3646  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 + " '" + 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 3745  public class Client { Line 3871  public class Client {
3871           * @see #getSamplerChannels           * @see #getSamplerChannels
3872           */           */
3873          public synchronized void          public synchronized void
3874          editInstrument(int samplerChn) throws IOException, LscpException, LSException {          editChannelInstrument(int samplerChn) throws IOException, LscpException, LSException {
3875                  verifyConnection();                  verifyConnection();
3876                  out.writeLine("EDIT INSTRUMENT " + samplerChn);                  out.writeLine("EDIT CHANNEL INSTRUMENT " + samplerChn);
3877                  if(getPrintOnlyMode()) return;                  if(getPrintOnlyMode()) return;
3878                                    
3879                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
# Line 3765  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 3800  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 3823  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 3861  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 3880  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());
4013                  for(int i = 0; i < names.length; i++) {                  for(int i = 0; i < names.length; i++) {
4014                          names[i] = toNonEscapedText(names[i]);                          names[i] = toNonEscapedString(names[i]);
4015                  }                  }
4016                  return names;                  return names;
4017          }          }
# Line 3902  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 3935  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 3951  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 4001  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 4019  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 4037  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 4055  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 4073  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 4094  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 4143  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 + "' '" + toEscapedString(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 4190  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 + "' '" + toEscapedString(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 4273  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(toEscapedString(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 4293  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 4310  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 4348  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 4367  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());
4500                  for(int i = 0; i < names.length; i++) {                  for(int i = 0; i < names.length; i++) {
4501                          names[i] = toNonEscapedText(names[i]);                          names[i] = toNonEscapedString(names[i]);
4502                  }                  }
4503                  return names;                  return names;
4504          }          }
# Line 4389  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 4418  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 4437  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 4486  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 4504  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 4522  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 4540  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 4558  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 4578  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 4623  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 4651  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 4704  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 4748  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 4761  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 4786  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 4807  public class Client { Line 4970  public class Client {
4970          }          }
4971                    
4972          /**          /**
4973             * Removes all instruments and directories and re-creates
4974             * the instruments database structure.
4975             * @throws IOException If some I/O error occurs.
4976             * @throws LscpException If LSCP protocol corruption occurs.
4977             * @throws LSException If the formatting of the instruments database failed.
4978             */
4979            public synchronized void
4980            formatInstrumentsDb() throws IOException, LscpException, LSException {
4981                    verifyConnection();
4982                    out.writeLine("FORMAT INSTRUMENTS_DB");
4983                    if(getPrintOnlyMode()) return;
4984                    
4985                    ResultSet rs = getEmptyResultSet();
4986            }
4987            
4988            /**
4989           * Resets the specified sampler channel.           * Resets the specified sampler channel.
4990           *           *
4991           * @param samplerChn The sampler channel number.           * @param samplerChn The sampler channel number.
# Line 4843  public class Client { Line 5022  public class Client {
5022          }          }
5023                    
5024          /**          /**
5025             * Gets the current number of all active streams.
5026             * @return The current number of all active streams.
5027             * @throws IOException If some I/O error occurs.
5028             * @throws LscpException If LSCP protocol corruption occurs.
5029             * @throws LSException If some other error occurs.
5030             */
5031            public synchronized int
5032            getTotalStreamCount() throws IOException, LscpException, LSException {
5033                    verifyConnection();
5034                    out.writeLine("GET TOTAL_STREAM_COUNT");
5035                    if(getPrintOnlyMode()) return -1;
5036                    
5037                    String s = getSingleLineResultSet().getResult();
5038                    return parseInt(s);
5039            }
5040            
5041            /**
5042           * Gets the current number of all active voices.           * Gets the current number of all active voices.
5043           * @return The current number of all active voices.           * @return The current number of all active voices.
5044           * @throws IOException If some I/O error occurs.           * @throws IOException If some I/O error occurs.
# Line 4931  public class Client { Line 5127  public class Client {
5127                  ResultSet rs = getEmptyResultSet();                  ResultSet rs = getEmptyResultSet();
5128          }          }
5129                    
5130            /**
5131             * Gets the number of instruments in the specified instrument file.
5132             * @param filename The absolute path name of the instrument file.
5133             * @return The number of instruments in the specified instrument file.
5134             * @throws IOException If some I/O error occurs.
5135             * @throws LscpException If LSCP protocol corruption occurs.
5136             * @throws LSException If the file is not found, or other error occur.
5137             */
5138            public synchronized int
5139            getFileInstrumentCount(String filename) throws IOException, LscpException, LSException {
5140                    verifyConnection();
5141                    out.writeLine("GET FILE INSTRUMENTS '" + conv(filename) +"'");
5142                    if(getPrintOnlyMode()) return -1;
5143                    
5144                    String s = getSingleLineResultSet().getResult();
5145                    return parseInt(s);
5146            }
5147            
5148            /**
5149             * Gets information about the instrument with index
5150             * <code>instrIdx</code> in the specified instrument file.
5151             * @param filename The absolute path name of the instrument file.
5152             * @param instrIdx The index of the instrument in the specified instrument file.
5153             * @throws IOException If some I/O error occurs.
5154             * @throws LscpException If LSCP protocol corruption occurs.
5155             * @throws LSException If failed to retrieve information.
5156             */
5157            public synchronized Instrument
5158            getFileInstrumentInfo(String filename, int instrIdx)
5159                                    throws IOException, LscpException, LSException {
5160                    
5161                    verifyConnection();
5162                    out.writeLine("GET FILE INSTRUMENT INFO '" + conv(filename) + "' " + String.valueOf(instrIdx));
5163                    if(getPrintOnlyMode()) return null;
5164                    
5165                    ResultSet rs = getMultiLineResultSet();
5166                    Instrument instr = new FileInstrument(rs.getMultiLineResult()) { };
5167                    
5168                    return instr;
5169            }
5170            
5171            /**
5172             * Gets the list of instruments in the specified instrument file.
5173             * @param filename The absolute path name of the instrument file.
5174             * @return An <code>Instrument</code> array providing
5175             * information about all instruments in the specified instrument file.
5176             * @throws IOException If some I/O error occurs.
5177             * @throws LscpException If LSCP protocol corruption occurs.
5178             * @throws LSException If the specified file name is invalid.
5179             */
5180            public synchronized Instrument[]
5181            getFileInstruments(String filename) throws IOException, LscpException, LSException {
5182                    int l = getFileInstrumentCount(filename);
5183                    if(l < 0) return null;
5184                    Instrument[] instrS = new FileInstrument[l];
5185                    
5186                    for(int i = 0; i < instrS.length; i++) {
5187                            instrS[i] = getFileInstrumentInfo(filename, i);
5188                    }
5189                    return instrS;
5190            }
5191            
5192            private static class FileInstrument extends AbstractInstrument {
5193                    FileInstrument(String[] resultSet) throws LscpException {
5194                            super(resultSet);
5195                    }
5196                    
5197                    public String
5198                    getEngine() {
5199                            // TODO: engine lookup?
5200                            return getFormatFamily();
5201                    }
5202                    
5203                    public boolean
5204                    parse(String s) throws LscpException {
5205                            if(s.startsWith("PRODUCT: ") || s.startsWith("ARTISTS: ")) return true;
5206                            return super.parse(s);
5207                    }
5208            }
5209            
5210          private void          private void
5211          getEmptyResultSets(int count, String err) throws LSException {          getEmptyResultSets(int count, String err) throws LSException {
5212                  StringBuffer sb = new StringBuffer();                  StringBuffer sb = new StringBuffer();

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

  ViewVC Help
Powered by ViewVC