home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / INTERNET / COMMUNIC / NETCAST.Z / marimb10.jar / netscape / netcast / TunerCommand.class (.txt) < prev   
Encoding:
Java Class File  |  1998-02-25  |  3.9 KB  |  125 lines

  1. package netscape.netcast;
  2.  
  3. import marimba.castanet.client.CastanetChannel;
  4. import marimba.castanet.client.CastanetTransmitter;
  5. import marimba.castanet.client.CastanetWorkspace;
  6.  
  7. class TunerCommand implements Runnable {
  8.    static final int START = 0;
  9.    static final int RESTART = 1;
  10.    static final int STOP = 2;
  11.    static final int SUBSCRIBE = 3;
  12.    static final int UNSUBSCRIBE = 4;
  13.    static final int UPDATE = 5;
  14.    static final int REMOVE = 6;
  15.    static final int CONFIRM_START = 7;
  16.    // $FF: renamed from: nc netscape.netcast.NSNetcast
  17.    NSNetcast field_0;
  18.    // $FF: renamed from: ws marimba.castanet.client.CastanetWorkspace
  19.    CastanetWorkspace field_1;
  20.    int cmd;
  21.    String transmitterName;
  22.    String channelName;
  23.    TunerCommand next;
  24.    String[] argv;
  25.  
  26.    TunerCommand(int cmd, String transmitterName, String channelName, String[] argv) {
  27.       this(NSCastanetWorkspace.getCastanetWorkspace(), cmd, transmitterName, channelName, argv);
  28.    }
  29.  
  30.    TunerCommand(int cmd, String transmitterName, String channelName) {
  31.       this(NSCastanetWorkspace.getCastanetWorkspace(), cmd, transmitterName, channelName, new String[0]);
  32.    }
  33.  
  34.    TunerCommand(CastanetWorkspace ws, int cmd, String transmitterName, String channelName, String[] argv) {
  35.       this.field_1 = ws;
  36.       this.cmd = cmd;
  37.       this.transmitterName = transmitterName;
  38.       this.channelName = channelName;
  39.       this.argv = argv;
  40.       NSCastanetWorkspace.add(this);
  41.    }
  42.  
  43.    CastanetChannel getChannel(boolean create) {
  44.       if (create && this.field_1.getEnvironment().networkEnabled()) {
  45.          CastanetTransmitter transmitter = this.field_1.getTransmitterCreate(this.transmitterName);
  46.          return transmitter != null ? transmitter.getChannelCreate(this.channelName) : null;
  47.       } else {
  48.          CastanetTransmitter transmitter = this.field_1.getTransmitter(this.transmitterName);
  49.          return transmitter != null ? transmitter.getChannel(this.channelName) : null;
  50.       }
  51.    }
  52.  
  53.    TunerCommand(CastanetWorkspace ws, int cmd, String transmitterName, String channelName) {
  54.       this(ws, cmd, transmitterName, channelName, new String[0]);
  55.    }
  56.  
  57.    public void run() {
  58.       switch (this.cmd) {
  59.          case 0:
  60.             StringBuffer buf = new StringBuffer();
  61.  
  62.             for(int i = 0; i < this.argv.length; ++i) {
  63.                buf.append(',');
  64.                buf.append(this.argv[i]);
  65.             }
  66.  
  67.             Channel.add("castanet://" + this.transmitterName + "/" + this.channelName + "?start" + buf, this.argv);
  68.             return;
  69.          case 1:
  70.             CastanetChannel channel = this.getChannel(true);
  71.             if (channel != null) {
  72.                channel.restart();
  73.                return;
  74.             }
  75.             break;
  76.          case 2:
  77.             CastanetChannel channel = this.getChannel(false);
  78.             if (channel != null) {
  79.                channel.stop();
  80.                return;
  81.             }
  82.             break;
  83.          case 3:
  84.             CastanetChannel channel = this.getChannel(true);
  85.             if (channel != null) {
  86.                channel.subscribe();
  87.                return;
  88.             }
  89.             break;
  90.          case 4:
  91.             CastanetChannel channel = this.getChannel(false);
  92.             if (channel != null) {
  93.                channel.unsubscribe();
  94.                return;
  95.             }
  96.             break;
  97.          case 5:
  98.             CastanetChannel channel = this.getChannel(false);
  99.             if (channel != null) {
  100.                channel.update();
  101.                return;
  102.             }
  103.             break;
  104.          case 6:
  105.             CastanetChannel channel = this.getChannel(false);
  106.             if (channel != null) {
  107.                channel.remove();
  108.                return;
  109.             }
  110.             break;
  111.          case 7:
  112.             StringBuffer buf = new StringBuffer();
  113.  
  114.             for(int i = 0; i < this.argv.length; ++i) {
  115.                buf.append(',');
  116.                buf.append(this.argv[i]);
  117.             }
  118.  
  119.             Channel.add("castanet://" + this.transmitterName + "/" + this.channelName + "?start" + buf, this.argv);
  120.             return;
  121.       }
  122.  
  123.    }
  124. }
  125.