use of org.jivesoftware.smackx.address.packet.MultipleAddresses in project Smack by igniterealtime.
the class MultipleRecipientManager method sendThroughService.
private static void sendThroughService(XMPPConnection connection, Stanza packet, Collection<? extends Jid> to, Collection<? extends Jid> cc, Collection<? extends Jid> bcc, Jid replyTo, Jid replyRoom, boolean noReply, DomainBareJid serviceAddress) throws NotConnectedException, InterruptedException {
// Create multiple recipient extension
MultipleAddresses multipleAddresses = new MultipleAddresses();
if (to != null) {
for (Jid jid : to) {
multipleAddresses.addAddress(MultipleAddresses.Type.to, jid, null, null, false, null);
}
}
if (cc != null) {
for (Jid jid : cc) {
multipleAddresses.addAddress(MultipleAddresses.Type.to, jid, null, null, false, null);
}
}
if (bcc != null) {
for (Jid jid : bcc) {
multipleAddresses.addAddress(MultipleAddresses.Type.bcc, jid, null, null, false, null);
}
}
if (noReply) {
multipleAddresses.setNoReply();
} else {
if (replyTo != null) {
multipleAddresses.addAddress(MultipleAddresses.Type.replyto, replyTo, null, null, false, null);
}
if (replyRoom != null) {
multipleAddresses.addAddress(MultipleAddresses.Type.replyroom, replyRoom, null, null, false, null);
}
}
// Set the multiple recipient service address as the target address
packet.setTo(serviceAddress);
// Add extension to packet
packet.addExtension(multipleAddresses);
// Send the packet
connection.sendStanza(packet);
}
Aggregations