@Override
public void onBeforeMessageSent(final BeforeMessageSentEvent event) {
// Only Messages are listened not presence events
// But sendStateMessage goes through here.
final Message message = event.getMessage();
final boolean alreadyWithState = getStateFromMessage(message) != null;
if (!alreadyWithState && ownState != ChatState.active && message.getXML().getFirstChild(bodySubjectThreadMatchter) != null) {
if (ownState == ChatState.composing) {
pauseTimer.cancel();
}
logger.finer("Setting own status to: " + ownState + " because we send a body or a subject");
ownState = ChatState.active;
message.getXML().addChild(ChatState.active.toString(), XmppNamespaces.CHATSTATES);
}
if (ownState != ChatState.inactive) {
inactiveTimer.schedule(inactiveDelay);
}
}