Search in sources :

Example 1 with TransferablePlaceholder

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

the class ConversationFragment method deleteFile.

private void deleteFile(Message message) {
    if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) {
        message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
        activity.onConversationsListItemUpdated();
        refresh();
    }
}
Also used : TransferablePlaceholder(de.pixart.messenger.entities.TransferablePlaceholder)

Example 2 with TransferablePlaceholder

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

the class HttpDownloadConnection method cancel.

@Override
public void cancel() {
    this.canceled = true;
    mHttpConnectionManager.finishConnection(this);
    if (message.isFileOrImage()) {
        message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
    } else {
        message.setTransferable(null);
    }
    mHttpConnectionManager.updateConversationUi(true);
}
Also used : TransferablePlaceholder(de.pixart.messenger.entities.TransferablePlaceholder)

Example 3 with TransferablePlaceholder

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

the class JingleConnection method cancel.

public void cancel() {
    this.disconnectSocks5Connections();
    if (this.transport != null && this.transport instanceof JingleInbandTransport) {
        this.transport.disconnect();
    }
    this.sendCancel();
    this.mJingleConnectionManager.finishConnection(this);
    if (responding()) {
        this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_FAILED));
        if (this.file != null) {
            file.delete();
        }
        this.mJingleConnectionManager.updateConversationUi(true);
    } else {
        this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_FAILED);
        this.message.setTransferable(null);
    }
}
Also used : TransferablePlaceholder(de.pixart.messenger.entities.TransferablePlaceholder)

Example 4 with TransferablePlaceholder

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

the class JingleConnection method fail.

private void fail(String errorMessage) {
    this.mJingleStatus = JINGLE_STATUS_FAILED;
    this.disconnectSocks5Connections();
    if (this.transport != null && this.transport instanceof JingleInbandTransport) {
        this.transport.disconnect();
    }
    FileBackend.close(mFileInputStream);
    FileBackend.close(mFileOutputStream);
    if (this.message != null) {
        if (responding()) {
            this.message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_FAILED));
            if (this.file != null) {
                file.delete();
            }
            this.mJingleConnectionManager.updateConversationUi(true);
        } else {
            this.mXmppConnectionService.markMessage(this.message, Message.STATUS_SEND_FAILED, errorMessage);
            this.message.setTransferable(null);
        }
    }
    this.mJingleConnectionManager.finishConnection(this);
}
Also used : TransferablePlaceholder(de.pixart.messenger.entities.TransferablePlaceholder)

Example 5 with TransferablePlaceholder

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

the class ConversationFragment method resendMessage.

public void resendMessage(final Message message) {
    if (message.isFileOrImage()) {
        DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message);
        if (file.exists()) {
            final Conversation conversation = message.getConversation();
            final XmppConnection xmppConnection = conversation.getAccount().getXmppConnection();
            if (!message.hasFileOnRemoteHost() && xmppConnection != null && !xmppConnection.getFeatures().httpUpload(message.getFileParams().size)) {
                activity.selectPresence(conversation, () -> {
                    message.setCounterpart(conversation.getNextCounterpart());
                    activity.xmppConnectionService.resendFailedMessages(message);
                    new Handler().post(() -> {
                        int size = messageList.size();
                        this.binding.messagesView.setSelection(size - 1);
                    });
                });
                return;
            }
        } else {
            Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show();
            message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED));
            activity.onConversationsListItemUpdated();
            refresh();
            return;
        }
    }
    activity.xmppConnectionService.resendFailedMessages(message);
    new Handler().post(() -> {
        int size = messageList.size();
        this.binding.messagesView.setSelection(size - 1);
    });
}
Also used : XmppConnection(de.pixart.messenger.xmpp.XmppConnection) TransferablePlaceholder(de.pixart.messenger.entities.TransferablePlaceholder) Handler(android.os.Handler) Conversation(de.pixart.messenger.entities.Conversation) DownloadableFile(de.pixart.messenger.entities.DownloadableFile) SuppressLint(android.annotation.SuppressLint)

Aggregations

TransferablePlaceholder (de.pixart.messenger.entities.TransferablePlaceholder)6 SuppressLint (android.annotation.SuppressLint)1 Handler (android.os.Handler)1 MenuItem (android.view.MenuItem)1 Conversation (de.pixart.messenger.entities.Conversation)1 DownloadableFile (de.pixart.messenger.entities.DownloadableFile)1 Message (de.pixart.messenger.entities.Message)1 Transferable (de.pixart.messenger.entities.Transferable)1 HttpDownloadConnection (de.pixart.messenger.http.HttpDownloadConnection)1 EditMessage (de.pixart.messenger.ui.widget.EditMessage)1 XmppConnection (de.pixart.messenger.xmpp.XmppConnection)1