addOutbound.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event event)
{
XCDEAudioRemoteHostDialog d = new XCDEAudioRemoteHostDialog(new Shell());
ServerInfo info = d.open(new ServerInfo("",64656));
if (info == null || info.server.equals("") || info.port < 1 || info.port > 65536)
{
MessageDialog.openError(new Shell(),"Invalid Connection Configuration", "The connction configuaration you specified is invalid, please try again.");
return;
}
InetAddress addr = null;
try
{
addr = InetAddress.getByName(info.server);
}
catch (UnknownHostException e)
{
MessageDialog.openError(new Shell(),"Unknown Host", "The host " + info.server + " could not be found, please try again.");
return;
}
try
{
rtpManager.addTarget(new SessionAddress(addr,info.port));
}
catch (IOException e)
{
MessageDialog.openError(new Shell(),"I/O Exception", "An I/O Exception occured while trying to connect the audio");
e.printStackTrace(System.err);
return;
}
catch (InvalidSessionAddressException e)
{
MessageDialog.openError(new Shell(),"Invalid Session ADdress", "The session address specified is invalid");
e.printStackTrace(System.err);
return;
}
AudioTransmit at = new AudioTransmit(cdi.getLocator(),addr.getHostAddress(),Integer.toString(info.port));
// Start the transmission
String result = at.start();
// result will be non-null if there was an error. The return
// value is a String describing the possible error. Print it.
if (result != null)
{
MessageDialog.openError(new Shell(),"Error Starting Audio Stream","Error: " + result);
return;
}
out.put(info,at);
updateOutList();
}
});
Button removeOutbound = new Button(outGroupButtons,SWT.PUSH);
removeOutbound.setText("Remove target...");
removeOutbound.setImage(AbstractUIPlugin.imageDescriptorFromPlugin("XCDEVoice","icons/removeaudio.png").createImage());
removeOutbound.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event event)
{
int selIndex = outbound.getSelectionIndex();
if (selIndex == -1)
return;
String item = outbound.getItem(selIndex);
String[] parts = item.split(":");
ServerInfo toRemove = new ServerInfo(parts[0],Integer.parseInt(parts[1]));
AudioTransmit at = (AudioTransmit)out.get(toRemove);
if (at == null)
return;
at.stop();
try