private static void sendThroughService(Connection connection, Packet packet, List<String> to,
List<String> cc, List<String> bcc, String replyTo, String replyRoom, boolean noReply,
String serviceAddress) {
// Create multiple recipient extension
MultipleAddresses multipleAddresses = new MultipleAddresses();
if (to != null) {
for (Iterator<String> it = to.iterator(); it.hasNext();) {
String jid = it.next();
multipleAddresses.addAddress(MultipleAddresses.TO, jid, null, null, false, null);
}
}
if (cc != null) {
for (Iterator<String> it = cc.iterator(); it.hasNext();) {
String jid = it.next();
multipleAddresses.addAddress(MultipleAddresses.CC, jid, null, null, false, null);
}
}
if (bcc != null) {
for (Iterator<String> it = bcc.iterator(); it.hasNext();) {
String jid = it.next();
multipleAddresses.addAddress(MultipleAddresses.BCC, jid, null, null, false, null);
}
}
if (noReply) {
multipleAddresses.setNoReply();
}
else {
if (replyTo != null && replyTo.trim().length() > 0) {
multipleAddresses
.addAddress(MultipleAddresses.REPLY_TO, replyTo, null, null, false, null);
}
if (replyRoom != null && replyRoom.trim().length() > 0) {
multipleAddresses.addAddress(MultipleAddresses.REPLY_ROOM, replyRoom, null, null,
false, null);
}
}
// Set the multiple recipient service address as the target address
packet.setTo(serviceAddress);