Java Code Examples for org.jivesoftware.smack.packet.Message#hasExtension()

The following examples show how to use org.jivesoftware.smack.packet.Message#hasExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMPPSession.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
private boolean isMessageCorrection(Message message) {
    return message.hasExtension(MessageCorrectExtension.ELEMENT, MessageCorrectExtension.NAMESPACE);
}
 
Example 2
Source File: XMPPSession.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
private void manageMessageReceived(Message message, Date delayDate, String messageId, boolean fromMam) {
    String[] jidList = message.getFrom().toString().split("/");

    ChatMessage chatMessage = new ChatMessage();
    chatMessage.setMessageId(messageId);

    String chatRoomJID;
    if (!jidList[0].equals(Preferences.getInstance().getUserXMPPJid())) {
        chatRoomJID = jidList[0];
    } else {
        chatRoomJID = message.getTo().toString().split("/")[0];
    }
    chatMessage.setRoomJid(chatRoomJID);

    // not saving messages with my affiliation changes to "none", and delete the chat in that case
    if (checkIfMyIsAffiliationNone(message)) {
        deleteChat(chatRoomJID);
        return;
    }

    if (message.hasExtension(JivePropertiesExtension.ELEMENT, JivePropertiesExtension.NAMESPACE)) {
        return;
    }

    RoomsListManager.getInstance().createChatIfNotExists(chatRoomJID, true);

    manageSender(jidList, chatMessage, chatRoomJID);

    chatMessage.setStatus(ChatMessage.STATUS_SENT);
    chatMessage.setUnread(true);

    if (isBoBMessage(message)) {
        BoBExtension bobExtension = BoBExtension.from(message);
        chatMessage.setContent(Base64.decodeToString(bobExtension.getBoBHash().getHash()));
        chatMessage.setType(ChatMessage.TYPE_STICKER);
    } else {
        chatMessage.setContent(message.getBody());
        chatMessage.setType(ChatMessage.TYPE_CHAT);
    }

    Realm realm = RealmManager.getInstance().getRealm();
    Chat chatRoom = realm.where(Chat.class).equalTo("jid", chatRoomJID).findFirst();
    realm.beginTransaction();

    if (canBeTextMessageOrSticker(message) && !fromMam) {
        chatRoom.addUnreadMessage();
    }

    // room name or subject change
    manageConfigurationsChange(message, chatMessage, chatRoom);

    // not saving invalid messages
    if (chatMessage.getContent() == null || chatMessage.getContent().isEmpty() || chatMessage.getUserSender() == null) {
        realm.commitTransaction();
        realm.close();
        return;
    }

    // assign date
    manageDelayDate(delayDate, chatMessage);

    realm.copyToRealmOrUpdate(chatMessage);
    realm.commitTransaction();
    realm.close();
}
 
Example 3
Source File: XMPPSession.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
private boolean isBoBMessage(Message message) {
    return message.hasExtension(BoBExtension.ELEMENT, BoBExtension.NAMESPACE);
}
 
Example 4
Source File: XMPPSession.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
private boolean hasConfigurationChangeExtension(Message message) {
    return message.hasExtension(MUCLightElements.ConfigurationsChangeExtension.ELEMENT, MUCLightElements.ConfigurationsChangeExtension.NAMESPACE);
}
 
Example 5
Source File: XMPPSession.java    From mangosta-android with Apache License 2.0 4 votes vote down vote up
private boolean hasAffiliationsChangeExtension(Message message) {
    return message.hasExtension(MUCLightElements.AffiliationsChangeExtension.ELEMENT, MUCLightElements.AffiliationsChangeExtension.NAMESPACE);
}
 
Example 6
Source File: FallbackIndicationElement.java    From Smack with Apache License 2.0 4 votes vote down vote up
public static boolean hasFallbackIndication(Message message) {
    return message.hasExtension(ELEMENT, NAMESPACE);
}
 
Example 7
Source File: UserTuneElement.java    From Smack with Apache License 2.0 4 votes vote down vote up
public static boolean hasUserTuneElement(Message message) {
    return message.hasExtension(UserTuneElement.class);
}
 
Example 8
Source File: FasteningElement.java    From Smack with Apache License 2.0 2 votes vote down vote up
/**
 * Return true if the provided {@link Message} contains a {@link FasteningElement}.
 *
 * @param message message
 * @return true if the stanza has an {@link FasteningElement}.
 */
public static boolean hasFasteningElement(Message message) {
    return message.hasExtension(ELEMENT, MessageFasteningManager.NAMESPACE);
}
 
Example 9
Source File: SpoilerElement.java    From Smack with Apache License 2.0 2 votes vote down vote up
/**
 * Returns true, if the message has at least one spoiler element.
 *
 * @param message message
 * @return true if message has spoiler extension
 */
public static boolean containsSpoiler(Message message) {
    return message.hasExtension(SpoilerElement.ELEMENT, NAMESPACE);
}
 
Example 10
Source File: MoodElement.java    From Smack with Apache License 2.0 2 votes vote down vote up
/**
 * Return true, if the {@code message} has a {@link MoodElement}, otherwise false.
 *
 * @param message message
 *
 * @return true of false
 */
public static boolean hasMoodElement(Message message) {
    return message.hasExtension(ELEMENT, NAMESPACE);
}