mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-2337 ContactList.sendMessages(): early return
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
This commit is contained in:
@ -1705,37 +1705,35 @@ public class ContactList extends JPanel implements ActionListener,
|
|||||||
|
|
||||||
|
|
||||||
private void sendMessages(Collection<ContactItem> items) {
|
private void sendMessages(Collection<ContactItem> items) {
|
||||||
StringBuilder buf = new StringBuilder();
|
|
||||||
InputDialog dialog = new InputDialog();
|
InputDialog dialog = new InputDialog();
|
||||||
final String messageText = dialog.getInput(Res.getString("title.broadcast.message"), Res.getString("message.enter.broadcast.message"), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), SparkManager.getMainWindow());
|
final String messageText = dialog.getInput(Res.getString("title.broadcast.message"), Res.getString("message.enter.broadcast.message"), SparkRes.getImageIcon(SparkRes.BLANK_IMAGE), SparkManager.getMainWindow());
|
||||||
if (ModelUtil.hasLength(messageText)) {
|
if (!ModelUtil.hasLength(messageText)) {
|
||||||
|
return;
|
||||||
final Map<String, Message> broadcastMessages = new HashMap<>();
|
}
|
||||||
for (ContactItem item : items) {
|
StringBuilder buf = new StringBuilder();
|
||||||
final Message message = new Message();
|
final Map<String, Message> broadcastMessages = new HashMap<>();
|
||||||
message.setTo(item.getJid());
|
for (ContactItem item : items) {
|
||||||
final Map<String, Object> properties = new HashMap<>();
|
final Message message = new Message();
|
||||||
properties.put("broadcast", true);
|
message.setTo(item.getJid());
|
||||||
message.addExtension(new JivePropertiesExtension(properties));
|
final Map<String, Object> properties = new HashMap<>();
|
||||||
message.setBody(messageText);
|
properties.put("broadcast", true);
|
||||||
if (!broadcastMessages.containsKey(item.getJid().toString())) {
|
message.addExtension(new JivePropertiesExtension(properties));
|
||||||
buf.append(item.getDisplayName()).append("\n");
|
message.setBody(messageText);
|
||||||
broadcastMessages.put(item.getJid().toString(), message);
|
if (!broadcastMessages.containsKey(item.getJid().toString())) {
|
||||||
}
|
buf.append(item.getDisplayName()).append('\n');
|
||||||
|
broadcastMessages.put(item.getJid().toString(), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Message message : broadcastMessages.values()) {
|
|
||||||
try {
|
|
||||||
SparkManager.getConnection().sendStanza(message);
|
|
||||||
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
|
||||||
Log.warning("Unable to send broadcast to " + message.getTo(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
|
|
||||||
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.hasbeenbroadcast.to", buf.toString()), Res.getString("title.notification"), JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Message message : broadcastMessages.values()) {
|
||||||
|
try {
|
||||||
|
SparkManager.getConnection().sendStanza(message);
|
||||||
|
} catch (SmackException.NotConnectedException | InterruptedException e) {
|
||||||
|
Log.warning("Unable to send broadcast to " + message.getTo(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UIManager.put("OptionPane.okButtonText", Res.getString("ok"));
|
||||||
|
JOptionPane.showMessageDialog(SparkManager.getMainWindow(), Res.getString("message.hasbeenbroadcast.to", buf.toString()), Res.getString("title.notification"), JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For plugin use only
|
// For plugin use only
|
||||||
|
|||||||
Reference in New Issue
Block a user