001/**
002 *
003 * Copyright 2017 Paul Schaub
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.omemo.listener;
018
019import org.jivesoftware.smack.packet.Message;
020
021import org.jivesoftware.smackx.muc.MultiUserChat;
022import org.jivesoftware.smackx.omemo.internal.CipherAndAuthTag;
023import org.jivesoftware.smackx.omemo.internal.OmemoMessageInformation;
024
025import org.jxmpp.jid.BareJid;
026
027/**
028 * Listener interface that allows implementations to receive decrypted OMEMO MUC messages.
029 * @author Paul Schaub
030 */
031public interface OmemoMucMessageListener {
032
033    /**
034     * Gets called whenever an OMEMO message has been received in a MultiUserChat and successfully decrypted.
035     * @param muc MultiUserChat the message was sent in
036     * @param from the bareJid of the sender
037     * @param decryptedBody the decrypted Body of the message
038     * @param message the original message with encrypted element
039     * @param wrappingMessage in case of a carbon copy, this is the wrapping message
040     * @param omemoInformation information about the encryption of the message
041     */
042    void onOmemoMucMessageReceived(MultiUserChat muc, BareJid from, String decryptedBody, Message message,
043                                   Message wrappingMessage, OmemoMessageInformation omemoInformation);
044
045    /**
046     * Gets called, whenever an OmemoElement without a body (an OmemoKeyTransportElement) is received.
047     *
048     * @param muc               MultiUserChat the message was sent in
049     * @param from              bareJid of the sender
050     * @param cipherAndAuthTag  transportedKey along with an optional authTag
051     * @param message           Message that contained the KeyTransport
052     * @param wrappingMessage   Wrapping message (eg. carbon), or null
053     * @param omemoInformation  Information about the messages encryption etc.
054     */
055    void onOmemoKeyTransportReceived(MultiUserChat muc, BareJid from, CipherAndAuthTag cipherAndAuthTag, Message message, Message wrappingMessage, OmemoMessageInformation omemoInformation);
056}