Search in sources :

Example 61 with Conversation

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

the class OtrService method verify.

@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
    Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")");
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            if (approved) {
                conversation.getContact().addOtrFingerprint(fingerprint);
            }
            conversation.smp().hint = null;
            conversation.smp().status = Conversation.Smp.STATUS_VERIFIED;
            mXmppConnectionService.updateConversationUi();
            mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
        }
    } catch (final InvalidJidException ignored) {
    }
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) Conversation(de.pixart.messenger.entities.Conversation)

Example 62 with Conversation

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

the class ConversationFragment method saveMessageDraftStopAudioPlayer.

private void saveMessageDraftStopAudioPlayer() {
    final Conversation previousConversation = this.conversation;
    if (this.activity == null || this.binding == null || previousConversation == null) {
        return;
    }
    Log.d(Config.LOGTAG, "ConversationFragment.saveMessageDraftStopAudioPlayer()");
    final String msg = this.binding.textinput.getText().toString();
    if (previousConversation.setNextMessage(msg)) {
        activity.xmppConnectionService.updateConversation(previousConversation);
    }
    updateChatState(this.conversation, msg);
    messageListAdapter.stopAudioPlayer();
}
Also used : Conversation(de.pixart.messenger.entities.Conversation)

Example 63 with Conversation

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

the class ConversationFragment method sendMessage.

private void sendMessage() {
    final String body = binding.textinput.getText().toString();
    final Conversation conversation = this.conversation;
    if (body.length() == 0 || conversation == null) {
        return;
    }
    final Message message;
    if (conversation.getCorrectingMessage() == null) {
        message = new Message(conversation, body, conversation.getNextEncryption());
        if (conversation.getMode() == Conversation.MODE_MULTI) {
            final Jid nextCounterpart = conversation.getNextCounterpart();
            if (nextCounterpart != null) {
                message.setCounterpart(nextCounterpart);
                message.setTrueCounterpart(conversation.getMucOptions().getTrueCounterpart(nextCounterpart));
                message.setType(Message.TYPE_PRIVATE);
            }
        }
    } else {
        message = conversation.getCorrectingMessage();
        message.setBody(body);
        message.setEdited(message.getUuid());
        message.setUuid(UUID.randomUUID().toString());
    }
    switch(message.getConversation().getNextEncryption()) {
        case Message.ENCRYPTION_OTR:
            sendOtrMessage(message);
            break;
        case Message.ENCRYPTION_PGP:
            sendPgpMessage(message);
            break;
        case Message.ENCRYPTION_AXOLOTL:
            if (!trustKeysIfNeeded(REQUEST_TRUST_KEYS_TEXT)) {
                sendAxolotlMessage(message);
            }
            break;
        default:
            sendPlainTextMessage(message);
    }
}
Also used : EditMessage(de.pixart.messenger.ui.widget.EditMessage) Message(de.pixart.messenger.entities.Message) Jid(de.pixart.messenger.xmpp.jid.Jid) Conversation(de.pixart.messenger.entities.Conversation)

Example 64 with Conversation

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

the class ConversationsOverviewFragment method getSuggestion.

public static Conversation getSuggestion(Activity activity) {
    final Conversation exception;
    Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
    if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
        exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek();
    } else {
        exception = null;
    }
    return getSuggestion(activity, exception);
}
Also used : Conversation(de.pixart.messenger.entities.Conversation) Fragment(android.app.Fragment)

Example 65 with Conversation

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

the class XmppConnectionService method deleteAccount.

public void deleteAccount(final Account account) {
    synchronized (this.conversations) {
        for (final Conversation conversation : conversations) {
            if (conversation.getAccount() == account) {
                if (conversation.getMode() == Conversation.MODE_MULTI) {
                    leaveMuc(conversation);
                } else if (conversation.getMode() == Conversation.MODE_SINGLE) {
                    conversation.endOtrIfNeeded();
                }
                conversations.remove(conversation);
            }
        }
        if (account.getXmppConnection() != null) {
            new Thread(() -> disconnect(account, true)).start();
        }
        final Runnable runnable = () -> {
            if (!databaseBackend.deleteAccount(account)) {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": unable to delete account");
            }
        };
        mDatabaseWriterExecutor.execute(runnable);
        this.accounts.remove(account);
        updateAccountUi();
        getNotificationService().updateErrorNotification();
        syncEnabledAccountSetting();
    }
}
Also used : Conversation(de.pixart.messenger.entities.Conversation)

Aggregations

Conversation (de.pixart.messenger.entities.Conversation)69 Jid (de.pixart.messenger.xmpp.jid.Jid)20 Account (de.pixart.messenger.entities.Account)18 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)16 Message (de.pixart.messenger.entities.Message)15 Contact (de.pixart.messenger.entities.Contact)11 MucOptions (de.pixart.messenger.entities.MucOptions)9 Intent (android.content.Intent)7 SuppressLint (android.annotation.SuppressLint)6 Uri (android.net.Uri)6 SpannableString (android.text.SpannableString)6 View (android.view.View)6 XmppAxolotlMessage (de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage)6 DownloadableFile (de.pixart.messenger.entities.DownloadableFile)6 Element (de.pixart.messenger.xml.Element)6 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)6 IOException (java.io.IOException)6 Fragment (android.app.Fragment)5 SharedPreferences (android.content.SharedPreferences)5 Bitmap (android.graphics.Bitmap)5