} else {
return null;
}
CommandImpl impl = new CommandImpl();
impl.setCommand(ProtocolConstants.COMMAND_SEND);
impl.setSendingFile(true);
impl.setPrivateMessage(true);
impl.setMsgFrom(sendername);
impl.setFileName(f.getName());
List list = new ArrayList();
if ((null == privateMsgTo) || (privateMsgTo.equals(""))
|| (privateMsgTo.contains(ProtocolConstants.SEND_TO_ALL))) {
showMessage.setTitle(" Error ");
info.setText("\n Please select valid users from left\n");
showMessage.add(info);
showMessage.setBounds(100, 300, 280, 100);
showMessage.setVisible(true);
playAlertSound();
return null;
}
String[] strArr = privateMsgTo.split(",");
for (String str : strArr) {
list.add(str);
}
impl.setRecipientNames(list);
try {
FileInputStream fis = new FileInputStream(f);
int size = fis.available();
// size should be less than 10 MB
// TODO make it configurable
if (size > maxUploadFileSize) {
fis.close();
showMessage.setTitle(" Error ");
info.setText("\n File size exceeds max. limit permitted\n");
showMessage.add(info);
showMessage.setBounds(100, 300, 280, 100);
showMessage.setVisible(true);
playAlertSound();
return null;
}
byte[] bytes = new byte[size];
fis.read(bytes);
impl.setFile(bytes);
fis.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}