Search in sources :

Example 16 with Message

use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.

the class MessageAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup parent) {
    final Message message = getItem(position);
    final boolean omemoEncryption = message.getEncryption() == Message.ENCRYPTION_AXOLOTL;
    final boolean isInValidSession = message.isValidInSession() && (!omemoEncryption || message.isTrusted());
    final Conversation conversation = message.getConversation();
    final Account account = conversation.getAccount();
    final int type = getItemViewType(position);
    ViewHolder viewHolder;
    if (view == null) {
        viewHolder = new ViewHolder();
        switch(type) {
            case DATE_SEPARATOR:
                view = activity.getLayoutInflater().inflate(R.layout.message_date_bubble, parent, false);
                viewHolder.status_message = view.findViewById(R.id.status_message);
                break;
            case SENT:
                view = activity.getLayoutInflater().inflate(R.layout.message_sent, parent, false);
                viewHolder.message_box = view.findViewById(R.id.message_box);
                viewHolder.contact_picture = view.findViewById(R.id.message_photo);
                viewHolder.audioPlayer = view.findViewById(R.id.audio_player);
                viewHolder.download_button = view.findViewById(R.id.download_button);
                viewHolder.resend_button = view.findViewById(R.id.resend_button);
                viewHolder.indicator = view.findViewById(R.id.security_indicator);
                viewHolder.edit_indicator = view.findViewById(R.id.edit_indicator);
                viewHolder.image = view.findViewById(R.id.message_image);
                viewHolder.messageBody = view.findViewById(R.id.message_body);
                viewHolder.time = view.findViewById(R.id.message_time);
                viewHolder.indicatorReceived = view.findViewById(R.id.indicator_received);
                viewHolder.indicatorRead = view.findViewById(R.id.indicator_read);
                break;
            case RECEIVED:
                view = activity.getLayoutInflater().inflate(R.layout.message_received, parent, false);
                viewHolder.message_box = view.findViewById(R.id.message_box);
                viewHolder.contact_picture = view.findViewById(R.id.message_photo);
                viewHolder.audioPlayer = view.findViewById(R.id.audio_player);
                viewHolder.download_button = view.findViewById(R.id.download_button);
                viewHolder.indicator = view.findViewById(R.id.security_indicator);
                viewHolder.edit_indicator = view.findViewById(R.id.edit_indicator);
                viewHolder.image = view.findViewById(R.id.message_image);
                viewHolder.messageBody = view.findViewById(R.id.message_body);
                viewHolder.time = view.findViewById(R.id.message_time);
                viewHolder.indicatorReceived = view.findViewById(R.id.indicator_received);
                viewHolder.encryption = view.findViewById(R.id.message_encryption);
                break;
            case STATUS:
                view = activity.getLayoutInflater().inflate(R.layout.message_status, parent, false);
                viewHolder.contact_picture = view.findViewById(R.id.message_photo);
                viewHolder.status_message = view.findViewById(R.id.status_message);
                viewHolder.load_more_messages = view.findViewById(R.id.load_more_messages);
                break;
            default:
                throw new AssertionError("Unknown view type");
        }
        if (viewHolder.messageBody != null) {
            listSelectionManager.onCreate(viewHolder.messageBody, new MessageBodyActionModeCallback(viewHolder.messageBody));
            viewHolder.messageBody.setCopyHandler(this);
        }
        view.setTag(viewHolder);
    } else {
        viewHolder = (ViewHolder) view.getTag();
        if (viewHolder == null) {
            return view;
        }
    }
    // default: (type == SENT && (!isInValidSession || !mUseWhiteBackground));
    boolean darkBackground = false;
    if (type == DATE_SEPARATOR) {
        if (UIHelper.today(message.getTimeSent())) {
            viewHolder.status_message.setText(R.string.today);
        } else if (UIHelper.yesterday(message.getTimeSent())) {
            viewHolder.status_message.setText(R.string.yesterday);
        } else {
            viewHolder.status_message.setText(DateUtils.formatDateTime(activity, message.getTimeSent(), DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_YEAR));
        }
        return view;
    } else if (type == STATUS) {
        if ("LOAD_MORE".equals(message.getBody())) {
            viewHolder.status_message.setVisibility(View.GONE);
            viewHolder.contact_picture.setVisibility(View.GONE);
            viewHolder.load_more_messages.setVisibility(View.VISIBLE);
            viewHolder.load_more_messages.setOnClickListener(v -> loadMoreMessages(message.getConversation()));
        } else {
            viewHolder.status_message.setVisibility(View.VISIBLE);
            viewHolder.load_more_messages.setVisibility(View.GONE);
            viewHolder.status_message.setText(message.getBody());
            boolean showAvatar;
            if (conversation.getMode() == Conversation.MODE_SINGLE) {
                showAvatar = true;
                loadAvatar(message, viewHolder.contact_picture, activity.getPixel(32));
            } else if (message.getCounterpart() != null || message.getTrueCounterpart() != null || (message.getCounterparts() != null && message.getCounterparts().size() > 0)) {
                showAvatar = true;
                loadAvatar(message, viewHolder.contact_picture, activity.getPixel(32));
            } else {
                showAvatar = false;
            }
            if (showAvatar) {
                viewHolder.contact_picture.setAlpha(0.5f);
                viewHolder.contact_picture.setVisibility(View.VISIBLE);
            } else {
                viewHolder.contact_picture.setVisibility(View.GONE);
            }
        }
        return view;
    } else {
        loadAvatar(message, viewHolder.contact_picture, activity.getPixel(48));
    }
    viewHolder.contact_picture.setOnClickListener(v -> {
        if (MessageAdapter.this.mOnContactPictureClickedListener != null) {
            MessageAdapter.this.mOnContactPictureClickedListener.onContactPictureClicked(message);
        }
    });
    viewHolder.contact_picture.setOnLongClickListener(v -> {
        if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
            MessageAdapter.this.mOnContactPictureLongClickedListener.onContactPictureLongClicked(message);
            return true;
        } else {
            return false;
        }
    });
    final Transferable transferable = message.getTransferable();
    if (transferable != null && transferable.getStatus() != Transferable.STATUS_UPLOADING) {
        if (transferable.getStatus() == Transferable.STATUS_OFFER) {
            displayDownloadableMessage(viewHolder, message, activity.getString(R.string.download_x_file, UIHelper.getFileDescriptionString(activity, message)));
        } else if (transferable.getStatus() == Transferable.STATUS_OFFER_CHECK_FILESIZE) {
            displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)));
        } else {
            displayInfoMessage(viewHolder, UIHelper.getMessagePreview(activity, message).first, darkBackground);
        }
    } else if (message.getType() == Message.TYPE_IMAGE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
        displayImageMessage(viewHolder, message);
    } else if (message.getType() == Message.TYPE_FILE && message.getEncryption() != Message.ENCRYPTION_PGP && message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) {
        if (message.getFileParams().width > 0 && message.getFileParams().height > 0) {
            displayImageMessage(viewHolder, message);
        } else if (message.getFileParams().runtime > 0) {
            displayAudioMessage(viewHolder, message, darkBackground);
        } else {
            displayOpenableMessage(viewHolder, message);
        }
    } else if (message.getEncryption() == Message.ENCRYPTION_PGP) {
        if (account.isPgpDecryptionServiceConnected()) {
            if (!account.hasPendingPgpIntent(conversation)) {
                displayInfoMessage(viewHolder, activity.getString(R.string.message_decrypting), darkBackground);
            } else {
                displayInfoMessage(viewHolder, activity.getString(R.string.pgp_message), darkBackground);
            }
        } else {
            displayInfoMessage(viewHolder, activity.getString(R.string.install_openkeychain), darkBackground);
            viewHolder.message_box.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    activity.showInstallPgpDialog();
                }
            });
        }
    } else if (message.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
        displayDecryptionFailed(viewHolder, darkBackground);
    } else {
        if (message.isGeoUri()) {
            displayLocationMessage(viewHolder, message);
        } else if (message.bodyIsOnlyEmojis() && message.getType() != Message.TYPE_PRIVATE) {
            displayEmojiMessage(viewHolder, message.getBody().trim());
        } else if (message.isXmppUri()) {
            displayXmppMessage(viewHolder, message.getBody().trim());
        } else if (message.treatAsDownloadable()) {
            try {
                URL url = new URL(message.getBody());
                displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize_on_host, UIHelper.getFileDescriptionString(activity, message), url.getHost()));
            } catch (Exception e) {
                displayDownloadableMessage(viewHolder, message, activity.getString(R.string.check_x_filesize, UIHelper.getFileDescriptionString(activity, message)));
            }
        } else {
            displayTextMessage(viewHolder, message, darkBackground, type);
        }
    }
    if (type == RECEIVED) {
        if (isInValidSession) {
            viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received_white);
            viewHolder.encryption.setVisibility(View.GONE);
        } else {
            viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_received_lightred);
            viewHolder.encryption.setVisibility(View.VISIBLE);
            viewHolder.encryption.setTextColor(activity.getWarningTextColor());
            if (omemoEncryption && !message.isTrusted()) {
                viewHolder.encryption.setText(R.string.not_trusted);
            } else {
                viewHolder.encryption.setText(CryptoHelper.encryptionTypeToText(message.getEncryption()));
            }
        }
    }
    if (type == SENT) {
        if (mUseWhiteBackground) {
            viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_sent_white);
        } else {
            viewHolder.message_box.setBackgroundResource(R.drawable.message_bubble_sent_lightblue);
        }
    }
    displayStatus(viewHolder, message, type, darkBackground);
    return view;
}
Also used : EmojiWrapper(de.pixart.messenger.utils.EmojiWrapper) ActionMode(android.view.ActionMode) LinearLayout(android.widget.LinearLayout) DateUtils(android.text.format.DateUtils) PackageManager(android.content.pm.PackageManager) URL(java.net.URL) GeoHelper(de.pixart.messenger.utils.GeoHelper) Spannable(android.text.Spannable) Uri(android.net.Uri) WindowManager(android.view.WindowManager) ImageView(android.widget.ImageView) Drawable(android.graphics.drawable.Drawable) Account(de.pixart.messenger.entities.Account) Emoticons(de.pixart.messenger.utils.Emoticons) Manifest(android.Manifest) Matcher(java.util.regex.Matcher) Locale(java.util.Locale) View(android.view.View) Button(android.widget.Button) PreferenceManager(android.preference.PreferenceManager) XmppUri(de.pixart.messenger.utils.XmppUri) ForegroundColorSpan(android.text.style.ForegroundColorSpan) Log(android.util.Log) AsyncTask(android.os.AsyncTask) ClickableMovementMethod(de.pixart.messenger.ui.widget.ClickableMovementMethod) ContextCompat(android.support.v4.content.ContextCompat) AudioPlayer(de.pixart.messenger.services.AudioPlayer) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ActivityCompat(android.support.v4.app.ActivityCompat) DisplayMetrics(android.util.DisplayMetrics) ViewGroup(android.view.ViewGroup) ListSelectionManager(de.pixart.messenger.ui.widget.ListSelectionManager) List(java.util.List) TextView(android.widget.TextView) FileParams(de.pixart.messenger.entities.Message.FileParams) Transferable(de.pixart.messenger.entities.Transferable) ActivityNotFoundException(android.content.ActivityNotFoundException) RelativeLayout(android.widget.RelativeLayout) CryptoHelper(de.pixart.messenger.utils.CryptoHelper) Pattern(java.util.regex.Pattern) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DividerSpan(de.pixart.messenger.ui.text.DividerSpan) Typeface(android.graphics.Typeface) UIHelper(de.pixart.messenger.utils.UIHelper) Spanned(android.text.Spanned) MamReference(de.pixart.messenger.xmpp.mam.MamReference) MessageArchiveService(de.pixart.messenger.services.MessageArchiveService) ConversationActivity(de.pixart.messenger.ui.ConversationActivity) Intent(android.content.Intent) Linkify(android.text.util.Linkify) MenuItem(android.view.MenuItem) SpannableStringBuilder(android.text.SpannableStringBuilder) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) FileBackend(de.pixart.messenger.persistance.FileBackend) Conversation(de.pixart.messenger.entities.Conversation) Patterns(de.pixart.messenger.utils.Patterns) R(de.pixart.messenger.R) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) NotificationService(de.pixart.messenger.services.NotificationService) ShowFullscreenMessageActivity(de.pixart.messenger.ui.ShowFullscreenMessageActivity) Menu(android.view.Menu) WeakReference(java.lang.ref.WeakReference) Config(de.pixart.messenger.Config) Message(de.pixart.messenger.entities.Message) ConversationFragment(de.pixart.messenger.ui.ConversationFragment) SpannableString(android.text.SpannableString) FingerprintStatus(de.pixart.messenger.crypto.axolotl.FingerprintStatus) StyleSpan(android.text.style.StyleSpan) BackgroundColorSpan(android.text.style.BackgroundColorSpan) RelativeSizeSpan(android.text.style.RelativeSizeSpan) DownloadableFile(de.pixart.messenger.entities.DownloadableFile) ResolveInfo(android.content.pm.ResolveInfo) Color(android.graphics.Color) ColorInt(android.support.annotation.ColorInt) XmppActivity(de.pixart.messenger.ui.XmppActivity) ArrayAdapter(android.widget.ArrayAdapter) CopyTextView(de.pixart.messenger.ui.widget.CopyTextView) StylingHelper(de.pixart.messenger.utils.StylingHelper) Glide(com.bumptech.glide.Glide) SharedPreferences(android.content.SharedPreferences) Bitmap(android.graphics.Bitmap) FixedURLSpan(de.pixart.messenger.ui.text.FixedURLSpan) QuoteSpan(de.pixart.messenger.ui.text.QuoteSpan) Base64(android.util.Base64) Activity(android.app.Activity) Resources(android.content.res.Resources) OnClickListener(android.view.View.OnClickListener) Account(de.pixart.messenger.entities.Account) Message(de.pixart.messenger.entities.Message) Transferable(de.pixart.messenger.entities.Transferable) Conversation(de.pixart.messenger.entities.Conversation) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CopyTextView(de.pixart.messenger.ui.widget.CopyTextView) URL(java.net.URL) ActivityNotFoundException(android.content.ActivityNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) OnClickListener(android.view.View.OnClickListener)

Example 17 with Message

use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.

the class MessageAdapter method displayStatus.

private void displayStatus(ViewHolder viewHolder, final Message message, int type, boolean darkBackground) {
    String filesize = null;
    String info = null;
    boolean error = false;
    if (viewHolder.indicatorReceived != null) {
        viewHolder.indicatorReceived.setVisibility(View.GONE);
        viewHolder.indicatorRead.setVisibility(View.GONE);
    }
    if (viewHolder.edit_indicator != null) {
        if (message.edited()) {
            viewHolder.edit_indicator.setVisibility(View.VISIBLE);
            viewHolder.edit_indicator.setAlpha(0.7f);
        } else {
            viewHolder.edit_indicator.setVisibility(View.GONE);
        }
    }
    boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI && message.getMergedStatus() <= Message.STATUS_RECEIVED;
    if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.getTransferable() != null) {
        FileParams params = message.getFileParams();
        if (params.size > (1 * 1024 * 1024)) {
            filesize = Math.round(params.size * 1f / (1024 * 1024)) + " MiB";
        } else if (params.size >= (1 * 1024)) {
            filesize = Math.round(params.size * 1f / 1024) + " KiB";
        } else if (params.size > 0) {
            filesize = params.size + " B";
        }
        if (message.getTransferable() != null && message.getTransferable().getStatus() == Transferable.STATUS_FAILED) {
            error = true;
        }
    }
    switch(message.getMergedStatus()) {
        case Message.STATUS_WAITING:
            info = getContext().getString(R.string.waiting);
            break;
        case Message.STATUS_UNSEND:
            Transferable d = message.getTransferable();
            if (d != null) {
                info = getContext().getString(R.string.sending_file, d.getProgress());
            } else {
                info = getContext().getString(R.string.sending);
            }
            break;
        case Message.STATUS_OFFERED:
            info = getContext().getString(R.string.offering);
            break;
        case Message.STATUS_SEND_RECEIVED:
            if (mIndicateReceived) {
                viewHolder.indicatorReceived.setVisibility(View.VISIBLE);
            }
            break;
        case Message.STATUS_SEND_DISPLAYED:
            if (mIndicateReceived) {
                viewHolder.indicatorReceived.setVisibility(View.VISIBLE);
                viewHolder.indicatorRead.setVisibility(View.VISIBLE);
            }
            break;
        case Message.STATUS_SEND_FAILED:
            if (isResendable) {
                info = getContext().getString(R.string.send_failed_resend);
            } else {
                info = getContext().getString(R.string.send_failed);
            }
            error = true;
            break;
        default:
            if (multiReceived) {
                info = UIHelper.getMessageDisplayName(message);
            }
            break;
    }
    if (error && type == SENT) {
        viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_Waring);
        DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
        if (file.exists()) {
            if (activity.xmppConnectionService.mHttpConnectionManager.getAutoAcceptFileSize() >= message.getFileParams().size) {
                isResendable = true;
                viewHolder.resend_button.setVisibility(View.GONE);
            } else {
                isResendable = false;
                viewHolder.resend_button.setVisibility(View.VISIBLE);
            }
        }
        viewHolder.resend_button.setText(R.string.send_again);
        viewHolder.resend_button.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_resend_grey600_48dp, 0, 0, 0);
        viewHolder.resend_button.setOnClickListener(new OnClickListener() {

            final Message mMessage = message;

            @Override
            public void onClick(View v) {
                mConversationFragment.resendMessage(mMessage);
            }
        });
    } else if (!error && type == SENT) {
        viewHolder.resend_button.setVisibility(View.GONE);
        viewHolder.time.setTextColor(this.getMessageTextColor(darkBackground, false));
    } else {
        if (darkBackground) {
            viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption_OnDark);
        } else {
            viewHolder.time.setTextAppearance(getContext(), R.style.TextAppearance_Conversations_Caption);
        }
        viewHolder.time.setTextColor(this.getMessageTextColor(darkBackground, false));
    }
    if (message.getEncryption() == Message.ENCRYPTION_NONE) {
        viewHolder.indicator.setVisibility(View.GONE);
    } else {
        boolean verified = false;
        if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
            final FingerprintStatus status = message.getConversation().getAccount().getAxolotlService().getFingerprintTrust(message.getFingerprint());
            if (status != null && status.isVerified()) {
                verified = true;
            }
        }
        if (verified) {
            viewHolder.indicator.setImageResource(R.drawable.ic_verified_user_blue_18dp);
        } else {
            viewHolder.indicator.setImageResource(R.drawable.ic_lock_blue_18dp);
        }
        viewHolder.indicator.setAlpha(0.7f);
        viewHolder.indicator.setVisibility(View.VISIBLE);
    }
    String formatedTime = UIHelper.readableTimeDifferenceFull(getContext(), message.getMergedTimeSent());
    if (message.getStatus() <= Message.STATUS_RECEIVED) {
        if ((filesize != null) && (info != null)) {
            viewHolder.time.setText(formatedTime + " \u00B7 " + filesize + " \u00B7 " + info);
        } else if ((filesize == null) && (info != null)) {
            viewHolder.time.setText(formatedTime + " \u00B7 " + info);
        } else if ((filesize != null) && (info == null)) {
            viewHolder.time.setText(formatedTime + " \u00B7 " + filesize);
        } else {
            viewHolder.time.setText(formatedTime);
        }
    } else {
        if ((filesize != null) && (info != null)) {
            viewHolder.time.setText(filesize + " \u00B7 " + info);
        } else if ((filesize == null) && (info != null)) {
            if (error) {
                viewHolder.time.setText(info + " \u00B7 " + formatedTime);
            } else {
                viewHolder.time.setText(info);
            }
        } else if ((filesize != null) && (info == null)) {
            viewHolder.time.setText(filesize + " \u00B7 " + formatedTime);
        } else {
            viewHolder.time.setText(formatedTime);
        }
    }
}
Also used : Message(de.pixart.messenger.entities.Message) FingerprintStatus(de.pixart.messenger.crypto.axolotl.FingerprintStatus) FileParams(de.pixart.messenger.entities.Message.FileParams) Transferable(de.pixart.messenger.entities.Transferable) OnClickListener(android.view.View.OnClickListener) SpannableString(android.text.SpannableString) DownloadableFile(de.pixart.messenger.entities.DownloadableFile) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CopyTextView(de.pixart.messenger.ui.widget.CopyTextView)

Example 18 with Message

use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.

the class PgpDecryptionService method giveUpCurrentDecryption.

public void giveUpCurrentDecryption() {
    Message message;
    synchronized (this) {
        if (currentMessage != null) {
            return;
        }
        message = messages.peekFirst();
        if (message == null) {
            return;
        }
        discard(message);
    }
    synchronized (message) {
        if (message.getEncryption() == Message.ENCRYPTION_PGP) {
            message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
        }
    }
    mXmppConnectionService.updateMessage(message);
    continueDecryption(true);
}
Also used : Message(de.pixart.messenger.entities.Message)

Example 19 with Message

use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.

the class MessageParser method onMessagePacketReceived.

@Override
public void onMessagePacketReceived(Account account, MessagePacket original) {
    if (handleErrorMessage(account, original)) {
        return;
    }
    final MessagePacket packet;
    Long timestamp = null;
    final boolean isForwarded;
    boolean isCarbon = false;
    String serverMsgId = null;
    final Element fin = original.findChild("fin", Namespace.MAM_LEGACY);
    if (fin != null) {
        mXmppConnectionService.getMessageArchiveService().processFinLegacy(fin, original.getFrom());
        return;
    }
    final boolean mamLegacy = original.hasChild("result", Namespace.MAM_LEGACY);
    final Element result = original.findChild("result", mamLegacy ? Namespace.MAM_LEGACY : Namespace.MAM);
    final MessageArchiveService.Query query = result == null ? null : mXmppConnectionService.getMessageArchiveService().findQuery(result.getAttribute("queryid"));
    if (query != null && query.validFrom(original.getFrom())) {
        Pair<MessagePacket, Long> f = original.getForwardedMessagePacket("result", mamLegacy ? Namespace.MAM_LEGACY : Namespace.MAM);
        if (f == null) {
            return;
        }
        timestamp = f.second;
        packet = f.first;
        isForwarded = true;
        serverMsgId = result.getAttribute("id");
        query.incrementMessageCount();
    } else if (query != null) {
        Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": received mam result from invalid sender");
        return;
    } else if (original.fromServer(account)) {
        Pair<MessagePacket, Long> f;
        f = original.getForwardedMessagePacket("received", "urn:xmpp:carbons:2");
        f = f == null ? original.getForwardedMessagePacket("sent", "urn:xmpp:carbons:2") : f;
        packet = f != null ? f.first : original;
        if (handleErrorMessage(account, packet)) {
            return;
        }
        timestamp = f != null ? f.second : null;
        isCarbon = f != null;
        isForwarded = isCarbon;
    } else {
        packet = original;
        isForwarded = false;
    }
    if (timestamp == null) {
        timestamp = AbstractParser.parseTimestamp(original, AbstractParser.parseTimestamp(packet));
    }
    final String body = packet.getBody();
    final Element mucUserElement = packet.findChild("x", "http://jabber.org/protocol/muc#user");
    final String pgpEncrypted = packet.findChildContent("x", "jabber:x:encrypted");
    final Element replaceElement = packet.findChild("replace", "urn:xmpp:message-correct:0");
    final Element oob = packet.findChild("x", Namespace.OOB);
    final String oobUrl = oob != null ? oob.findChildContent("url") : null;
    final String replacementId = replaceElement == null ? null : replaceElement.getAttribute("id");
    final Element axolotlEncrypted = packet.findChild(XmppAxolotlMessage.CONTAINERTAG, AxolotlService.PEP_PREFIX);
    int status;
    final Jid counterpart;
    final Jid to = packet.getTo();
    final Jid from = packet.getFrom();
    final Element originId = packet.findChild("origin-id", Namespace.STANZA_IDS);
    final String remoteMsgId;
    if (originId != null && originId.getAttribute("id") != null) {
        remoteMsgId = originId.getAttribute("id");
    } else {
        remoteMsgId = packet.getId();
    }
    boolean notify = false;
    if (from == null) {
        Log.d(Config.LOGTAG, "no from in: " + packet.toString());
        return;
    }
    boolean isTypeGroupChat = packet.getType() == MessagePacket.TYPE_GROUPCHAT;
    if (query != null && !query.muc() && isTypeGroupChat) {
        Log.e(Config.LOGTAG, account.getJid().toBareJid() + ": received groupchat (" + from + ") message on regular MAM request. skipping");
        return;
    }
    boolean isProperlyAddressed = (to != null) && (!to.isBareJid() || account.countPresences() == 0);
    boolean isMucStatusMessage = from.isBareJid() && mucUserElement != null && mucUserElement.hasChild("status");
    boolean selfAddressed;
    if (packet.fromAccount(account)) {
        status = Message.STATUS_SEND;
        selfAddressed = to == null || account.getJid().toBareJid().equals(to.toBareJid());
        if (selfAddressed) {
            counterpart = from;
        } else {
            counterpart = to != null ? to : account.getJid();
        }
    } else {
        status = Message.STATUS_RECEIVED;
        counterpart = from;
        selfAddressed = false;
    }
    Invite invite = extractInvite(account, packet);
    if (invite != null && invite.execute(account)) {
        return;
    }
    if ((body != null || pgpEncrypted != null || (axolotlEncrypted != null && axolotlEncrypted.hasChild("payload")) || oobUrl != null) && !isMucStatusMessage) {
        final Conversation conversation = mXmppConnectionService.findOrCreateConversation(account, counterpart.toBareJid(), isTypeGroupChat, false, query, false);
        final boolean conversationMultiMode = conversation.getMode() == Conversation.MODE_MULTI;
        if (serverMsgId == null) {
            serverMsgId = extractStanzaId(packet, isTypeGroupChat, conversation);
        }
        if (selfAddressed) {
            if (mXmppConnectionService.markMessage(conversation, remoteMsgId, Message.STATUS_SEND_RECEIVED, serverMsgId)) {
                return;
            }
            status = Message.STATUS_RECEIVED;
            if (remoteMsgId != null && conversation.findMessageWithRemoteId(remoteMsgId, counterpart) != null) {
                return;
            }
        }
        if (isTypeGroupChat) {
            if (conversation.getMucOptions().isSelf(counterpart)) {
                status = Message.STATUS_SEND_RECEIVED;
                // not really carbon but received from another resource
                isCarbon = true;
                if (mXmppConnectionService.markMessage(conversation, remoteMsgId, status, serverMsgId)) {
                    return;
                } else if (remoteMsgId == null || Config.IGNORE_ID_REWRITE_IN_MUC) {
                    Message message = conversation.findSentMessageWithBody(packet.getBody());
                    if (message != null) {
                        mXmppConnectionService.markMessage(message, status);
                        return;
                    }
                }
            } else {
                status = Message.STATUS_RECEIVED;
            }
        }
        final Message message;
        if (body != null && body.startsWith("?OTR") && Config.supportOtr()) {
            if (!isForwarded && !isTypeGroupChat && isProperlyAddressed && !conversationMultiMode) {
                message = parseOtrChat(body, from, remoteMsgId, conversation);
                if (message == null) {
                    return;
                }
            } else {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": ignoring OTR message from " + from + " isForwarded=" + Boolean.toString(isForwarded) + ", isProperlyAddressed=" + Boolean.valueOf(isProperlyAddressed));
                message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
            }
        } else if (pgpEncrypted != null && Config.supportOpenPgp()) {
            message = new Message(conversation, pgpEncrypted, Message.ENCRYPTION_PGP, status);
        } else if (axolotlEncrypted != null && Config.supportOmemo()) {
            Jid origin;
            if (conversationMultiMode) {
                final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
                origin = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
                if (origin == null) {
                    Log.d(Config.LOGTAG, "axolotl message in non anonymous conference received");
                    return;
                }
            } else {
                origin = from;
            }
            message = parseAxolotlChat(axolotlEncrypted, origin, conversation, status, query != null);
            if (message == null) {
                if (query == null && extractChatState(mXmppConnectionService.find(account, counterpart.toBareJid()), isTypeGroupChat, packet)) {
                    mXmppConnectionService.updateConversationUi();
                }
                if (query != null && status == Message.STATUS_SEND && remoteMsgId != null) {
                    Message previouslySent = conversation.findSentMessageWithUuid(remoteMsgId);
                    if (previouslySent != null && previouslySent.getServerMsgId() == null && serverMsgId != null) {
                        previouslySent.setServerMsgId(serverMsgId);
                        mXmppConnectionService.databaseBackend.updateMessage(previouslySent);
                        Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": encountered previously sent OMEMO message without serverId. updating...");
                    }
                }
                return;
            }
            if (conversationMultiMode) {
                message.setTrueCounterpart(origin);
            }
        } else if (body == null && oobUrl != null) {
            message = new Message(conversation, oobUrl, Message.ENCRYPTION_NONE, status);
            message.setOob(true);
            if (CryptoHelper.isPgpEncryptedUrl(oobUrl)) {
                message.setEncryption(Message.ENCRYPTION_DECRYPTED);
            }
        } else {
            message = new Message(conversation, body, Message.ENCRYPTION_NONE, status);
        }
        message.setCounterpart(counterpart);
        message.setRemoteMsgId(remoteMsgId);
        message.setServerMsgId(serverMsgId);
        message.setCarbon(isCarbon);
        message.setTime(timestamp);
        if (body != null && body.equals(oobUrl)) {
            message.setOob(true);
            if (CryptoHelper.isPgpEncryptedUrl(oobUrl)) {
                message.setEncryption(Message.ENCRYPTION_DECRYPTED);
            }
        }
        message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
        if (conversationMultiMode) {
            final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
            Jid trueCounterpart;
            if (message.getEncryption() == Message.ENCRYPTION_AXOLOTL) {
                trueCounterpart = message.getTrueCounterpart();
            } else if (query != null && query.safeToExtractTrueCounterpart()) {
                trueCounterpart = getTrueCounterpart(mucUserElement, fallback);
            } else {
                trueCounterpart = fallback;
            }
            if (trueCounterpart != null && trueCounterpart.toBareJid().equals(account.getJid().toBareJid())) {
                status = isTypeGroupChat ? Message.STATUS_SEND_RECEIVED : Message.STATUS_SEND;
            }
            message.setStatus(status);
            message.setTrueCounterpart(trueCounterpart);
            if (!isTypeGroupChat) {
                message.setType(Message.TYPE_PRIVATE);
            }
        } else {
            updateLastseen(account, from);
        }
        if (replacementId != null && mXmppConnectionService.allowMessageCorrection()) {
            final Message replacedMessage = conversation.findMessageWithRemoteIdAndCounterpart(replacementId, counterpart, message.getStatus() == Message.STATUS_RECEIVED, message.isCarbon());
            if (replacedMessage != null) {
                final boolean fingerprintsMatch = replacedMessage.getFingerprint() == null || replacedMessage.getFingerprint().equals(message.getFingerprint());
                final boolean trueCountersMatch = replacedMessage.getTrueCounterpart() != null && replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart());
                final boolean duplicate = conversation.hasDuplicateMessage(message);
                if (fingerprintsMatch && (trueCountersMatch || !conversationMultiMode) && !duplicate) {
                    Log.d(Config.LOGTAG, "replaced message '" + replacedMessage.getBody() + "' with '" + message.getBody() + "'");
                    synchronized (replacedMessage) {
                        final String uuid = replacedMessage.getUuid();
                        replacedMessage.setUuid(UUID.randomUUID().toString());
                        replacedMessage.setBody(message.getBody());
                        replacedMessage.setEdited(replacedMessage.getRemoteMsgId());
                        replacedMessage.setRemoteMsgId(remoteMsgId);
                        if (replacedMessage.getServerMsgId() == null || message.getServerMsgId() != null) {
                            replacedMessage.setServerMsgId(message.getServerMsgId());
                        }
                        replacedMessage.setEncryption(message.getEncryption());
                        if (replacedMessage.getStatus() == Message.STATUS_RECEIVED) {
                            replacedMessage.markUnread();
                        }
                        extractChatState(mXmppConnectionService.find(account, counterpart.toBareJid()), isTypeGroupChat, packet);
                        mXmppConnectionService.updateMessage(replacedMessage, uuid);
                        mXmppConnectionService.getNotificationService().updateNotification(false);
                        if (mXmppConnectionService.confirmMessages() && replacedMessage.getStatus() == Message.STATUS_RECEIVED && (replacedMessage.trusted() || replacedMessage.getType() == Message.TYPE_PRIVATE) && remoteMsgId != null && !selfAddressed && !isTypeGroupChat) {
                            processMessageReceipts(account, packet, query);
                        }
                        if (replacedMessage.getEncryption() == Message.ENCRYPTION_PGP) {
                            conversation.getAccount().getPgpDecryptionService().discard(replacedMessage);
                            conversation.getAccount().getPgpDecryptionService().decrypt(replacedMessage, false);
                        }
                    }
                    return;
                } else {
                    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": received message correction but verification didn't check out");
                }
            }
        }
        long deletionDate = mXmppConnectionService.getAutomaticMessageDeletionDate();
        if (deletionDate != 0 && message.getTimeSent() < deletionDate) {
            Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": skipping message from " + message.getCounterpart().toString() + " because it was sent prior to our deletion date");
            return;
        }
        boolean checkForDuplicates = (isTypeGroupChat && packet.hasChild("delay", "urn:xmpp:delay")) || message.getType() == Message.TYPE_PRIVATE || message.getServerMsgId() != null;
        if (checkForDuplicates) {
            final Message duplicate = conversation.findDuplicateMessage(message);
            if (duplicate != null) {
                final boolean serverMsgIdUpdated;
                if (duplicate.getStatus() != Message.STATUS_RECEIVED && duplicate.getUuid().equals(message.getRemoteMsgId()) && duplicate.getServerMsgId() == null && message.getServerMsgId() != null) {
                    duplicate.setServerMsgId(message.getServerMsgId());
                    mXmppConnectionService.databaseBackend.updateMessage(message);
                    serverMsgIdUpdated = true;
                } else {
                    serverMsgIdUpdated = false;
                }
                Log.d(Config.LOGTAG, "skipping duplicate message with " + message.getCounterpart() + ". serverMsgIdUpdated=" + Boolean.toString(serverMsgIdUpdated));
                return;
            }
        }
        if (query != null && query.getPagingOrder() == MessageArchiveService.PagingOrder.REVERSE) {
            conversation.prepend(query.getActualInThisQuery(), message);
        } else {
            conversation.add(message);
        }
        if (query != null) {
            query.incrementActualMessageCount();
        }
        if (query == null || query.isCatchup()) {
            // either no mam or catchup
            if (status == Message.STATUS_SEND || status == Message.STATUS_SEND_RECEIVED) {
                mXmppConnectionService.markRead(conversation);
                if (query == null) {
                    activateGracePeriod(account);
                }
            } else {
                message.markUnread();
                notify = true;
            }
        }
        if (message.getEncryption() == Message.ENCRYPTION_PGP) {
            notify = conversation.getAccount().getPgpDecryptionService().decrypt(message, notify);
        }
        if (query == null) {
            extractChatState(mXmppConnectionService.find(account, counterpart.toBareJid()), isTypeGroupChat, packet);
            mXmppConnectionService.updateConversationUi();
        }
        if (mXmppConnectionService.confirmMessages() && message.getStatus() == Message.STATUS_RECEIVED && (message.trusted() || message.getType() == Message.TYPE_PRIVATE) && remoteMsgId != null && !selfAddressed && !isTypeGroupChat) {
            processMessageReceipts(account, packet, query);
        }
        if (message.getStatus() == Message.STATUS_RECEIVED && conversation.getOtrSession() != null && !conversation.getOtrSession().getSessionID().getUserID().equals(message.getCounterpart().getResourcepart())) {
            conversation.endOtrIfNeeded();
        }
        mXmppConnectionService.databaseBackend.createMessage(message);
        final HttpConnectionManager manager = this.mXmppConnectionService.getHttpConnectionManager();
        if (message.trusted() && message.treatAsDownloadable() && manager.getAutoAcceptFileSize() > 0) {
            manager.createNewDownloadConnection(message);
        } else if (notify) {
            if (query != null && query.isCatchup()) {
                mXmppConnectionService.getNotificationService().pushFromBacklog(message);
            } else {
                mXmppConnectionService.getNotificationService().push(message);
            }
        }
    } else if (!packet.hasChild("body")) {
        // no body
        final Conversation conversation = mXmppConnectionService.find(account, from.toBareJid());
        if (axolotlEncrypted != null) {
            Jid origin;
            if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
                final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
                origin = getTrueCounterpart(query != null ? mucUserElement : null, fallback);
                if (origin == null) {
                    Log.d(Config.LOGTAG, "omemo key transport message in non anonymous conference received");
                    return;
                }
            } else if (isTypeGroupChat) {
                return;
            } else {
                origin = from;
            }
            try {
                final XmppAxolotlMessage xmppAxolotlMessage = XmppAxolotlMessage.fromElement(axolotlEncrypted, origin.toBareJid());
                account.getAxolotlService().processReceivingKeyTransportMessage(xmppAxolotlMessage, query != null);
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": omemo key transport message received from " + origin);
            } catch (Exception e) {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": invalid omemo key transport message received " + e.getMessage());
                return;
            }
        }
        if (query == null && extractChatState(mXmppConnectionService.find(account, counterpart.toBareJid()), isTypeGroupChat, packet)) {
            mXmppConnectionService.updateConversationUi();
        }
        if (isTypeGroupChat) {
            if (packet.hasChild("subject")) {
                if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
                    conversation.setHasMessagesLeftOnServer(conversation.countMessages() > 0);
                    String subject = packet.findInternationalizedChildContent("subject");
                    if (conversation.getMucOptions().setSubject(subject)) {
                        mXmppConnectionService.updateConversation(conversation);
                    }
                    final Bookmark bookmark = conversation.getBookmark();
                    if (bookmark != null && bookmark.getBookmarkName() == null) {
                        if (bookmark.setBookmarkName(subject)) {
                            mXmppConnectionService.pushBookmarks(account);
                        }
                    }
                    mXmppConnectionService.updateConversationUi();
                    return;
                }
            }
        }
        if (conversation != null && mucUserElement != null && from.isBareJid()) {
            for (Element child : mucUserElement.getChildren()) {
                if ("status".equals(child.getName())) {
                    try {
                        int code = Integer.parseInt(child.getAttribute("code"));
                        if ((code >= 170 && code <= 174) || (code >= 102 && code <= 104)) {
                            mXmppConnectionService.fetchConferenceConfiguration(conversation);
                            break;
                        }
                    } catch (Exception e) {
                    // ignored
                    }
                } else if ("item".equals(child.getName())) {
                    MucOptions.User user = AbstractParser.parseItem(conversation, child);
                    Log.d(Config.LOGTAG, account.getJid() + ": changing affiliation for " + user.getRealJid() + " to " + user.getAffiliation() + " in " + conversation.getJid().toBareJid());
                    if (!user.realJidMatchesAccount()) {
                        boolean isNew = conversation.getMucOptions().updateUser(user);
                        mXmppConnectionService.getAvatarService().clear(conversation);
                        mXmppConnectionService.updateMucRosterUi();
                        mXmppConnectionService.updateConversationUi();
                        Contact contact = user.getContact();
                        if (!user.getAffiliation().ranks(MucOptions.Affiliation.MEMBER)) {
                            Jid jid = user.getRealJid();
                            List<Jid> cryptoTargets = conversation.getAcceptedCryptoTargets();
                            if (cryptoTargets.remove(user.getRealJid())) {
                                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
                                conversation.setAcceptedCryptoTargets(cryptoTargets);
                                mXmppConnectionService.updateConversation(conversation);
                            }
                        } else if (isNew && user.getRealJid() != null && conversation.getMucOptions().isPrivateAndNonAnonymous() && (contact == null || !contact.mutualPresenceSubscription()) && account.getAxolotlService().hasEmptyDeviceList(user.getRealJid())) {
                            account.getAxolotlService().fetchDeviceIds(user.getRealJid());
                        }
                    }
                }
            }
        }
    }
    Element received = packet.findChild("received", "urn:xmpp:chat-markers:0");
    if (received == null) {
        received = packet.findChild("received", "urn:xmpp:receipts");
    }
    if (received != null) {
        String id = received.getAttribute("id");
        if (packet.fromAccount(account)) {
            if (query != null && id != null && packet.getTo() != null) {
                query.pendingReceiptRequests.remove(new ReceiptRequest(packet.getTo(), id));
            }
        } else {
            mXmppConnectionService.markMessage(account, from.toBareJid(), received.getAttribute("id"), Message.STATUS_SEND_RECEIVED);
        }
    }
    Element displayed = packet.findChild("displayed", "urn:xmpp:chat-markers:0");
    if (displayed != null) {
        final String id = displayed.getAttribute("id");
        final Jid sender = displayed.getAttributeAsJid("sender");
        if (packet.fromAccount(account) && !selfAddressed) {
            dismissNotification(account, counterpart, query);
        } else if (isTypeGroupChat) {
            Conversation conversation = mXmppConnectionService.find(account, counterpart.toBareJid());
            if (conversation != null && id != null && sender != null) {
                Message message = conversation.findMessageWithRemoteId(id, sender);
                if (message != null) {
                    final Jid fallback = conversation.getMucOptions().getTrueCounterpart(counterpart);
                    final Jid trueJid = getTrueCounterpart((query != null && query.safeToExtractTrueCounterpart()) ? mucUserElement : null, fallback);
                    final boolean trueJidMatchesAccount = account.getJid().toBareJid().equals(trueJid == null ? null : trueJid.toBareJid());
                    if (trueJidMatchesAccount || conversation.getMucOptions().isSelf(counterpart)) {
                        if (!message.isRead() && (query == null || query.isCatchup())) {
                            // checking if message is unread fixes race conditions with reflections
                            mXmppConnectionService.markRead(conversation);
                        }
                    } else if (!counterpart.isBareJid() && trueJid != null) {
                        ReadByMarker readByMarker = ReadByMarker.from(counterpart, trueJid);
                        if (message.addReadByMarker(readByMarker)) {
                            Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": added read by (" + readByMarker.getRealJid() + ") to message '" + message.getBody() + "'");
                            mXmppConnectionService.updateMessage(message);
                            mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED);
                        }
                    }
                }
            }
        } else {
            final Message displayedMessage = mXmppConnectionService.markMessage(account, from.toBareJid(), id, Message.STATUS_SEND_DISPLAYED);
            Message message = displayedMessage == null ? null : displayedMessage.prev();
            while (message != null && message.getStatus() == Message.STATUS_SEND_RECEIVED && message.getTimeSent() < displayedMessage.getTimeSent()) {
                mXmppConnectionService.markMessage(message, Message.STATUS_SEND_DISPLAYED);
                message = message.prev();
            }
            if (displayedMessage != null && selfAddressed) {
                dismissNotification(account, counterpart, query);
            }
        }
    }
    Element event = original.findChild("event", "http://jabber.org/protocol/pubsub#event");
    if (event != null) {
        parseEvent(event, original.getFrom(), account);
    }
    final String nick = packet.findChildContent("nick", Namespace.NICK);
    if (nick != null) {
        Contact contact = account.getRoster().getContact(from);
        if (contact.setPresenceName(nick)) {
            mXmppConnectionService.getAvatarService().clear(contact);
        }
    }
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) XmppAxolotlMessage(de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage) Message(de.pixart.messenger.entities.Message) ReadByMarker(de.pixart.messenger.entities.ReadByMarker) Element(de.pixart.messenger.xml.Element) Conversation(de.pixart.messenger.entities.Conversation) XmppAxolotlMessage(de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage) Contact(de.pixart.messenger.entities.Contact) MessagePacket(de.pixart.messenger.xmpp.stanzas.MessagePacket) MucOptions(de.pixart.messenger.entities.MucOptions) MessageArchiveService(de.pixart.messenger.services.MessageArchiveService) Bookmark(de.pixart.messenger.entities.Bookmark) HttpConnectionManager(de.pixart.messenger.http.HttpConnectionManager) ReceiptRequest(de.pixart.messenger.entities.ReceiptRequest)

Example 20 with Message

use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.

the class MessageParser method parseAxolotlChat.

private Message parseAxolotlChat(Element axolotlMessage, Jid from, Conversation conversation, int status, boolean postpone) {
    final AxolotlService service = conversation.getAccount().getAxolotlService();
    final XmppAxolotlMessage xmppAxolotlMessage;
    try {
        xmppAxolotlMessage = XmppAxolotlMessage.fromElement(axolotlMessage, from.toBareJid());
    } catch (Exception e) {
        Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": invalid omemo message received " + e.getMessage());
        return null;
    }
    if (xmppAxolotlMessage.hasPayload()) {
        final XmppAxolotlMessage.XmppAxolotlPlaintextMessage plaintextMessage = service.processReceivingPayloadMessage(xmppAxolotlMessage, postpone);
        if (plaintextMessage != null) {
            Message finishedMessage = new Message(conversation, plaintextMessage.getPlaintext(), Message.ENCRYPTION_AXOLOTL, status);
            finishedMessage.setFingerprint(plaintextMessage.getFingerprint());
            Log.d(Config.LOGTAG, AxolotlService.getLogprefix(finishedMessage.getConversation().getAccount()) + " Received Message with session fingerprint: " + plaintextMessage.getFingerprint());
            return finishedMessage;
        }
    } else {
        Log.d(Config.LOGTAG, conversation.getAccount().getJid().toBareJid() + ": received OMEMO key transport message");
        service.processReceivingKeyTransportMessage(xmppAxolotlMessage, postpone);
    }
    return null;
}
Also used : AxolotlService(de.pixart.messenger.crypto.axolotl.AxolotlService) XmppAxolotlMessage(de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage) Message(de.pixart.messenger.entities.Message) XmppAxolotlMessage(de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage)

Aggregations

Message (de.pixart.messenger.entities.Message)47 XmppAxolotlMessage (de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage)16 Conversation (de.pixart.messenger.entities.Conversation)13 EditMessage (de.pixart.messenger.ui.widget.EditMessage)12 SuppressLint (android.annotation.SuppressLint)11 PendingIntent (android.app.PendingIntent)7 SpannableString (android.text.SpannableString)7 Account (de.pixart.messenger.entities.Account)7 Jid (de.pixart.messenger.xmpp.jid.Jid)7 ArrayList (java.util.ArrayList)5 Uri (android.net.Uri)4 Toast (android.widget.Toast)4 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)4 StyleSpan (android.text.style.StyleSpan)3 RelativeLayout (android.widget.RelativeLayout)3 Element (de.pixart.messenger.xml.Element)3 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)3 Date (java.util.Date)3 SharedPreferences (android.content.SharedPreferences)2 PackageManager (android.content.pm.PackageManager)2