Search in sources :

Example 1 with XmppConnectionService

use of de.pixart.messenger.services.XmppConnectionService in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method onTextDeleted.

@Override
public void onTextDeleted() {
    final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService;
    if (service == null) {
        return;
    }
    Account.State status = conversation.getAccount().getStatus();
    if (status == Account.State.ONLINE && conversation.setOutgoingChatState(Config.DEFAULT_CHATSTATE)) {
        service.sendChatState(conversation);
    }
    updateSendButton();
}
Also used : Account(de.pixart.messenger.entities.Account) XmppConnectionService(de.pixart.messenger.services.XmppConnectionService)

Example 2 with XmppConnectionService

use of de.pixart.messenger.services.XmppConnectionService in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method onTypingStarted.

@Override
public void onTypingStarted() {
    final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService;
    if (service == null) {
        return;
    }
    final boolean broadcastLastActivity = activity.xmppConnectionService.broadcastLastActivity();
    Account.State status = conversation.getAccount().getStatus();
    if (status == Account.State.ONLINE && conversation.setOutgoingChatState(ChatState.COMPOSING)) {
        service.sendChatState(conversation);
    }
    if (broadcastLastActivity) {
        // send new presence but don't include idle because we are not
        service.sendPresence(conversation.getAccount(), false);
    }
    updateSendButton();
}
Also used : Account(de.pixart.messenger.entities.Account) XmppConnectionService(de.pixart.messenger.services.XmppConnectionService)

Example 3 with XmppConnectionService

use of de.pixart.messenger.services.XmppConnectionService in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method sendOtrMessage.

protected void sendOtrMessage(final Message message) {
    final ConversationActivity activity = (ConversationActivity) getActivity();
    final XmppConnectionService xmppService = activity.xmppConnectionService;
    activity.selectPresence(message.getConversation(), () -> {
        message.setCounterpart(conversation.getNextCounterpart());
        xmppService.sendMessage(message);
        messageSent();
    });
}
Also used : XmppConnectionService(de.pixart.messenger.services.XmppConnectionService)

Example 4 with XmppConnectionService

use of de.pixart.messenger.services.XmppConnectionService in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method sendPgpMessage.

protected void sendPgpMessage(final Message message) {
    final XmppConnectionService xmppService = activity.xmppConnectionService;
    final Contact contact = message.getConversation().getContact();
    if (!activity.hasPgp()) {
        activity.showInstallPgpDialog();
        return;
    }
    if (conversation.getAccount().getPgpSignature() == null) {
        activity.announcePgp(conversation.getAccount(), conversation, null, activity.onOpenPGPKeyPublished);
        return;
    }
    if (!mSendingPgpMessage.compareAndSet(false, true)) {
        Log.d(Config.LOGTAG, "sending pgp message already in progress");
    }
    if (conversation.getMode() == Conversation.MODE_SINGLE) {
        if (contact.getPgpKeyId() != 0) {
            xmppService.getPgpEngine().hasKey(contact, new UiCallback<Contact>() {

                @Override
                public void userInputRequried(PendingIntent pi, Contact contact) {
                    startPendingIntent(pi, REQUEST_ENCRYPT_MESSAGE);
                }

                @Override
                public void success(Contact contact) {
                    encryptTextMessage(message);
                }

                @Override
                public void error(int error, Contact contact) {
                    activity.runOnUiThread(() -> Toast.makeText(activity, R.string.unable_to_connect_to_keychain, Toast.LENGTH_SHORT).show());
                    mSendingPgpMessage.set(false);
                }
            });
        } else {
            showNoPGPKeyDialog(false, (dialog, which) -> {
                conversation.setNextEncryption(Message.ENCRYPTION_NONE);
                xmppService.updateConversation(conversation);
                message.setEncryption(Message.ENCRYPTION_NONE);
                xmppService.sendMessage(message);
                messageSent();
            });
        }
    } else {
        if (conversation.getMucOptions().pgpKeysInUse()) {
            if (!conversation.getMucOptions().everybodyHasKeys()) {
                Toast warning = Toast.makeText(getActivity(), R.string.missing_public_keys, Toast.LENGTH_LONG);
                warning.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
                warning.show();
            }
            encryptTextMessage(message);
        } else {
            showNoPGPKeyDialog(true, (dialog, which) -> {
                conversation.setNextEncryption(Message.ENCRYPTION_NONE);
                message.setEncryption(Message.ENCRYPTION_NONE);
                xmppService.updateConversation(conversation);
                xmppService.sendMessage(message);
                messageSent();
            });
        }
    }
}
Also used : XmppConnectionService(de.pixart.messenger.services.XmppConnectionService) Toast(android.widget.Toast) PendingIntent(android.app.PendingIntent) SuppressLint(android.annotation.SuppressLint) Contact(de.pixart.messenger.entities.Contact)

Example 5 with XmppConnectionService

use of de.pixart.messenger.services.XmppConnectionService in project Pix-Art-Messenger by kriztan.

the class ConversationFragment method onTypingStopped.

@Override
public void onTypingStopped() {
    final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService;
    if (service == null) {
        return;
    }
    Account.State status = conversation.getAccount().getStatus();
    if (status == Account.State.ONLINE && conversation.setOutgoingChatState(ChatState.PAUSED)) {
        service.sendChatState(conversation);
    }
}
Also used : Account(de.pixart.messenger.entities.Account) XmppConnectionService(de.pixart.messenger.services.XmppConnectionService)

Aggregations

XmppConnectionService (de.pixart.messenger.services.XmppConnectionService)6 Account (de.pixart.messenger.entities.Account)4 SuppressLint (android.annotation.SuppressLint)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 SharedPreferences (android.content.SharedPreferences)1 PackageInfo (android.content.pm.PackageInfo)1 PackageManager (android.content.pm.PackageManager)1 Signature (android.content.pm.Signature)1 AlertDialog (android.support.v7.app.AlertDialog)1 Toast (android.widget.Toast)1 Contact (de.pixart.messenger.entities.Contact)1 Conversation (de.pixart.messenger.entities.Conversation)1 Message (de.pixart.messenger.entities.Message)1 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1