2006-01-23 21:09:06 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Copyright 2003-2006 Jive Software.
|
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2006-01-23 21:09:06 +01:00
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
package org.jivesoftware.smackx.address;
|
2006-01-23 21:09:06 +01:00
|
|
|
|
2017-06-14 17:12:43 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
import org.jivesoftware.smackx.address.packet.MultipleAddresses;
|
2006-01-23 21:09:06 +01:00
|
|
|
|
2017-06-14 17:12:43 +02:00
|
|
|
import org.jxmpp.jid.Jid;
|
2006-01-23 21:09:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* MultipleRecipientInfo keeps information about the multiple recipients extension included
|
|
|
|
* in a received packet. Among the information we can find the list of TO and CC addresses.
|
|
|
|
*
|
|
|
|
* @author Gaston Dombiak
|
|
|
|
*/
|
|
|
|
public class MultipleRecipientInfo {
|
|
|
|
|
|
|
|
MultipleAddresses extension;
|
|
|
|
|
|
|
|
MultipleRecipientInfo(MultipleAddresses extension) {
|
|
|
|
this.extension = extension;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-02-15 11:35:08 +01:00
|
|
|
* Returns the list of {@link org.jivesoftware.smackx.address.packet.MultipleAddresses.Address}
|
2006-01-23 21:09:06 +01:00
|
|
|
* that were the primary recipients of the packet.
|
|
|
|
*
|
|
|
|
* @return list of primary recipients of the packet.
|
|
|
|
*/
|
2012-10-26 12:47:55 +02:00
|
|
|
public List<MultipleAddresses.Address> getTOAddresses() {
|
2014-10-11 17:06:20 +02:00
|
|
|
return extension.getAddressesOfType(MultipleAddresses.Type.to);
|
2006-01-23 21:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-02-15 11:35:08 +01:00
|
|
|
* Returns the list of {@link org.jivesoftware.smackx.address.packet.MultipleAddresses.Address}
|
2006-01-23 21:09:06 +01:00
|
|
|
* that were the secondary recipients of the packet.
|
|
|
|
*
|
|
|
|
* @return list of secondary recipients of the packet.
|
|
|
|
*/
|
2012-10-26 12:47:55 +02:00
|
|
|
public List<MultipleAddresses.Address> getCCAddresses() {
|
2014-10-11 17:06:20 +02:00
|
|
|
return extension.getAddressesOfType(MultipleAddresses.Type.cc);
|
2006-01-23 21:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-19 18:10:36 +02:00
|
|
|
* Returns the JID of a MUC room to which responses should be sent or <code>null</code> if
|
2006-01-23 21:09:06 +01:00
|
|
|
* no specific address was provided. When no specific address was provided then the reply
|
|
|
|
* can be sent to any or all recipients. Otherwise, the user should join the specified room
|
|
|
|
* and send the reply to the room.
|
|
|
|
*
|
2019-07-19 18:10:36 +02:00
|
|
|
* @return the JID of a MUC room to which responses should be sent or <code>null</code> if
|
2006-01-23 21:09:06 +01:00
|
|
|
* no specific address was provided.
|
|
|
|
*/
|
2015-05-27 19:29:51 +02:00
|
|
|
// TODO should return EntityBareJid
|
2015-02-14 17:15:02 +01:00
|
|
|
public Jid getReplyRoom() {
|
2014-10-11 17:06:20 +02:00
|
|
|
List<MultipleAddresses.Address> replyRoom = extension.getAddressesOfType(MultipleAddresses.Type.replyroom);
|
2015-03-23 09:27:15 +01:00
|
|
|
return replyRoom.isEmpty() ? null : replyRoom.get(0).getJid();
|
2006-01-23 21:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-03-31 14:17:30 +02:00
|
|
|
* Returns true if the received stanza should not be replied. Use
|
2014-03-10 09:45:50 +01:00
|
|
|
* {@link MultipleRecipientManager#reply(org.jivesoftware.smack.XMPPConnection, org.jivesoftware.smack.packet.Message, org.jivesoftware.smack.packet.Message)}
|
2018-05-09 23:06:12 +02:00
|
|
|
* to send replies.
|
2006-01-23 21:09:06 +01:00
|
|
|
*
|
2018-03-31 14:17:30 +02:00
|
|
|
* @return true if the received stanza should not be replied.
|
2006-01-23 21:09:06 +01:00
|
|
|
*/
|
|
|
|
public boolean shouldNotReply() {
|
2014-10-11 17:06:20 +02:00
|
|
|
return !extension.getAddressesOfType(MultipleAddresses.Type.noreply).isEmpty();
|
2006-01-23 21:09:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-07-19 18:10:36 +02:00
|
|
|
* Returns the address to which all replies are requested to be sent or <code>null</code> if
|
2006-01-23 21:09:06 +01:00
|
|
|
* no specific address was provided. When no specific address was provided then the reply
|
|
|
|
* can be sent to any or all recipients.
|
|
|
|
*
|
2019-07-19 18:10:36 +02:00
|
|
|
* @return the address to which all replies are requested to be sent or <code>null</code> if
|
2006-01-23 21:09:06 +01:00
|
|
|
* no specific address was provided.
|
|
|
|
*/
|
|
|
|
public MultipleAddresses.Address getReplyAddress() {
|
2014-10-11 17:06:20 +02:00
|
|
|
List<MultipleAddresses.Address> replyTo = extension.getAddressesOfType(MultipleAddresses.Type.replyto);
|
2015-03-23 09:27:15 +01:00
|
|
|
return replyTo.isEmpty() ? null : replyTo.get(0);
|
2006-01-23 21:09:06 +01:00
|
|
|
}
|
|
|
|
}
|