本文整理汇总了Java中org.xmpp.packet.Message.getSubject方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getSubject方法的具体用法?Java Message.getSubject怎么用?Java Message.getSubject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.xmpp.packet.Message
的用法示例。
在下文中一共展示了Message.getSubject方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeSubject
import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Override
public void changeSubject(Message packet, MUCRole role) throws ForbiddenException {
if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) ||
MUCRole.Role.moderator == role.getRole()) {
// Set the new subject to the room
subject = packet.getSubject();
MUCPersistenceManager.updateRoomSubject(this);
// Notify all the occupants that the subject has changed
packet.setFrom(role.getRoleAddress());
send(packet);
// Fire event signifying that the room's subject has changed.
MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject);
// Let other cluster nodes that the room has been updated
CacheFactory.doClusterTask(new RoomUpdatedEvent(this));
}
else {
throw new ForbiddenException();
}
}
示例2: isSubjectChangeRequest
import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
* Returns true if the given message qualifies as a subject change request for
* the target MUC room, per XEP-0045. Note that this does not validate whether
* the sender has permission to make the change, because subject change requests
* may be loaded from history or processed "live" during a user's session.
*
* Refer to http://xmpp.org/extensions/xep-0045.html#subject-mod for details.
*
* @return true if the given packet is a subject change request
*/
public boolean isSubjectChangeRequest(Message message) {
// The subject is changed by sending a message of type "groupchat" to the <[email protected]>,
// where the <message/> MUST contain a <subject/> element that specifies the new subject
// but MUST NOT contain a <body/> element (or a <thread/> element).
// Unfortunately, many clients do not follow these strict guidelines from the specs, so we
// allow a lenient policy for detecting non-conforming subject change requests. This can be
// configured by setting the "xmpp.muc.subject.change.strict" property to false (true by default).
// An empty <subject/> value means that the room subject should be removed.
return Message.Type.groupchat == message.getType() &&
message.getSubject() != null &&
(!isSubjectChangeStrict() ||
(message.getBody() == null &&
message.getThread() == null));
}
示例3: changeSubject
import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void changeSubject(Message packet, MUCRole role) throws ForbiddenException {
if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) ||
MUCRole.Role.moderator == role.getRole()) {
// Do nothing if the new subject is the same as the existing one
if (packet.getSubject().equals(subject)) {
return;
}
// Set the new subject to the room
subject = packet.getSubject();
MUCPersistenceManager.updateRoomSubject(this);
// Notify all the occupants that the subject has changed
packet.setFrom(role.getRoleAddress());
send(packet);
// Fire event signifying that the room's subject has changed.
MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject);
}
else {
throw new ForbiddenException();
}
}
示例4: changeSubject
import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void changeSubject(Message packet, MUCRole role) throws ForbiddenException {
if ((canOccupantsChangeSubject() && role.getRole().compareTo(MUCRole.Role.visitor) < 0) ||
MUCRole.Role.moderator == role.getRole()) {
// Do nothing if the new subject is the same as the existing one
if (packet.getSubject().equals(subject)) {
return;
}
// Set the new subject to the room
subject = packet.getSubject();
MUCPersistenceManager.updateRoomSubject(this);
// Notify all the occupants that the subject has changed
packet.setFrom(role.getRoleAddress());
send(packet);
// Fire event signifying that the room's subject has changed.
MUCEventDispatcher.roomSubjectChanged(getJID(), role.getUserAddress(), subject);
if (!"local-only".equals(packet.getID())) {
// Let other cluster nodes that the room has been updated
CacheFactory.doClusterTask(new RoomUpdatedEvent(this));
}
}
else {
throw new ForbiddenException();
}
}
示例5: ConversationLogEntry
import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
* Creates a new ConversationLogEntry that registers that a given message was sent to a given
* room on a given date.
*
* @param date the date when the message was sent to the room.
* @param room the room that received the message.
* @param message the message to log as part of the conversation in the room.
* @param sender the real XMPPAddress of the sender (e.g. [email protected]).
*/
public ConversationLogEntry(Date date, MUCRoom room, Message message, JID sender) {
this.date = date;
this.subject = message.getSubject();
this.body = message.getBody();
this.stanza = message.toString();
this.sender = sender;
this.roomID = room.getID();
this.nickname = message.getFrom().getResource();
}
示例6: sendHistory
import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
* Sends the smallest amount of traffic that meets any combination of the requested criteria.
*
* @param joinRole the user that will receive the history.
* @param roomHistory the history of the room.
*/
public void sendHistory(LocalMUCRole joinRole, MUCRoomHistory roomHistory) {
if (!isConfigured()) {
Iterator<Message> history = roomHistory.getMessageHistory();
while (history.hasNext()) {
joinRole.send(history.next());
}
}
else {
if (getMaxChars() == 0) {
// The user requested to receive no history
return;
}
int accumulatedChars = 0;
int accumulatedStanzas = 0;
Element delayInformation;
LinkedList<Message> historyToSend = new LinkedList<>();
ListIterator<Message> iterator = roomHistory.getReverseMessageHistory();
while (iterator.hasPrevious()) {
Message message = iterator.previous();
// Update number of characters to send
String text = message.getBody() == null ? message.getSubject() : message.getBody();
if (text == null) {
// Skip this message since it has no body and no subject
continue;
}
accumulatedChars += text.length();
if (getMaxChars() > -1 && accumulatedChars > getMaxChars()) {
// Stop collecting history since we have exceded a limit
break;
}
// Update number of messages to send
accumulatedStanzas ++;
if (getMaxStanzas() > -1 && accumulatedStanzas > getMaxStanzas()) {
// Stop collecting history since we have exceded a limit
break;
}
if (getSeconds() > -1 || getSince() != null) {
delayInformation = message.getChildElement("delay", "urn:xmpp:delay");
try {
// Get the date when the historic message was sent
Date delayedDate = xmppDateTime.parseString(delayInformation.attributeValue("stamp"));
if (getSince() != null && delayedDate != null && delayedDate.before(getSince())) {
// Stop collecting history since we have exceded a limit
break;
}
if (getSeconds() > -1) {
Date current = new Date();
long diff = (current.getTime() - delayedDate.getTime()) / 1000;
if (getSeconds() <= diff) {
// Stop collecting history since we have exceded a limit
break;
}
}
}
catch (Exception e) {
Log.error("Error parsing date from historic message", e);
}
}
historyToSend.addFirst(message);
}
// Send the smallest amount of traffic to the user
for (Object aHistoryToSend : historyToSend) {
joinRole.send((Message) aHistoryToSend);
}
}
}
示例7: sendViolationNotification
import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendViolationNotification(Packet originalPacket) {
String subject = "Content filter notification! ("
+ originalPacket.getFrom().getNode() + ")";
String body;
if (originalPacket instanceof Message) {
Message originalMsg = (Message) originalPacket;
body = "Disallowed content detected in message from:"
+ originalMsg.getFrom()
+ " to:"
+ originalMsg.getTo()
+ ", message was "
+ (allowOnMatch ? "allowed" + (contentFilter.isMaskingContent() ? " and masked." : " but not masked.") : "rejected.")
+ (violationIncludeOriginalPacketEnabled ? "\nOriginal subject:"
+ (originalMsg.getSubject() != null ? originalMsg
.getSubject() : "")
+ "\nOriginal content:"
+ (originalMsg.getBody() != null ? originalMsg
.getBody() : "")
: "");
} else {
// presence
Presence originalPresence = (Presence) originalPacket;
body = "Disallowed status detected in presence from:"
+ originalPresence.getFrom()
+ ", status was "
+ (allowOnMatch ? "allowed" + (contentFilter.isMaskingContent() ? " and masked." : " but not masked.") : "rejected.")
+ (violationIncludeOriginalPacketEnabled ? "\nOriginal status:"
+ originalPresence.getStatus()
: "");
}
if (violationNotificationByIMEnabled) {
if (Log.isDebugEnabled()) {
Log.debug("Content filter: sending IM notification");
}
sendViolationNotificationIM(subject, body);
}
if (violationNotificationByEmailEnabled) {
if (Log.isDebugEnabled()) {
Log.debug("Content filter: sending email notification");
}
sendViolationNotificationEmail(subject, body);
}
}
示例8: logConversation
import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void logConversation(MUCRoom room, Message message, JID sender) {
// Only log messages that have a subject or body. Otherwise ignore it.
if (message.getSubject() != null || message.getBody() != null) {
logQueue.add(new ConversationLogEntry(new Date(), room, message, sender));
}
}
示例9: addMessage
import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
* Add a message to the current chat history. The strategy type will determine what
* actually happens to the message.
*
* @param packet The packet to add to the chatroom's history.
*/
public void addMessage(Message packet){
// get the conditions based on default or not
Type strategyType;
int strategyMaxNumber;
if (type == Type.defaulType && parent != null) {
strategyType = parent.getType();
strategyMaxNumber = parent.getMaxNumber();
}
else {
strategyType = type;
strategyMaxNumber = maxNumber;
}
// Room subject change messages are special
boolean subjectChange = false;
if (packet.getSubject() != null && packet.getSubject().length() > 0){
subjectChange = true;
roomSubject = packet;
}
// store message according to active strategy
if (strategyType == Type.none){
if (subjectChange) {
history.clear();
history.add(packet);
}
}
else if (strategyType == Type.all) {
history.add(packet);
}
else if (strategyType == Type.number) {
if (history.size() >= strategyMaxNumber) {
// We have to remove messages so the new message won't exceed
// the max history size
// This is complicated somewhat because we must skip over the
// last room subject
// message because we want to preserve the room subject if
// possible.
Iterator historyIter = history.iterator();
while (historyIter.hasNext() && history.size() > strategyMaxNumber) {
if (historyIter.next() != roomSubject) {
historyIter.remove();
}
}
}
history.add(packet);
}
}
示例10: addMessage
import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
* Add a message to the current chat history. The strategy type will determine what
* actually happens to the message.
*
* @param packet The packet to add to the chatroom's history.
*/
public void addMessage(Message packet){
// get the conditions based on default or not
Type strategyType;
int strategyMaxNumber;
if (type == Type.defaulType && parent != null) {
strategyType = parent.getType();
strategyMaxNumber = parent.getMaxNumber();
}
else {
strategyType = type;
strategyMaxNumber = maxNumber;
}
// Room subject change messages are special
boolean subjectChange = false;
if (packet.getSubject() != null && packet.getSubject().length() > 0){
subjectChange = true;
roomSubject = packet;
}
// store message according to active strategy
if (strategyType == Type.none){
if (subjectChange) {
history.clear();
history.add(packet);
}
}
else if (strategyType == Type.all) {
history.add(packet);
}
else if (strategyType == Type.number) {
if (history.size() >= strategyMaxNumber) {
// We have to remove messages so the new message won't exceed
// the max history size
// This is complicated somewhat because we must skip over the
// last room subject
// message because we want to preserve the room subject if
// possible.
Iterator<Message> historyIter = history.iterator();
while (historyIter.hasNext() && history.size() > strategyMaxNumber) {
if (historyIter.next() != roomSubject) {
historyIter.remove();
}
}
}
history.add(packet);
}
}
示例11: ConversationLogEntry
import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
* Creates a new ConversationLogEntry that registers that a given message was sent to a given
* room on a given date.
*
* @param date the date when the message was sent to the room.
* @param room the room that received the message.
* @param message the message to log as part of the conversation in the room.
* @param sender the real XMPPAddress of the sender (e.g. [email protected]).
*/
public ConversationLogEntry(Date date, MUCRoom room, Message message, JID sender) {
this.date = date;
this.subject = message.getSubject();
this.body = message.getBody();
this.sender = sender;
this.roomID = room.getID();
this.nickname = message.getFrom().getResource();
}