Search in sources :

Example 6 with InvalidJidException

use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.

the class OtrService method setSmpStatus.

private void setSmpStatus(SessionID id, int status) {
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            conversation.smp().status = status;
            mXmppConnectionService.updateConversationUi();
        }
    } catch (final InvalidJidException ignored) {
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation)

Example 7 with InvalidJidException

use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.

the class OtrService method askForSecret.

@Override
public void askForSecret(SessionID id, InstanceTag instanceTag, String question) {
    try {
        final Jid jid = Jid.fromSessionID(id);
        Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
        if (conversation != null) {
            conversation.smp().hint = question;
            conversation.smp().status = Conversation.Smp.STATUS_CONTACT_REQUESTED;
            mXmppConnectionService.updateConversationUi();
        }
    } catch (InvalidJidException e) {
        Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": smp in invalid session " + id.toString());
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation)

Example 8 with InvalidJidException

use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.

the class PushManagementService method registerPushTokenOnServer.

public void registerPushTokenOnServer(final Account account) {
    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": has push support");
    retrieveGcmInstanceToken(new OnGcmInstanceTokenRetrieved() {

        @Override
        public void onGcmInstanceTokenRetrieved(String token) {
            try {
                final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID);
                IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(Jid.fromString(APP_SERVER), token, deviceId);
                mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {

                    @Override
                    public void onIqPacketReceived(Account account, IqPacket packet) {
                        Element command = packet.findChild("command", "http://jabber.org/protocol/commands");
                        if (packet.getType() == IqPacket.TYPE.RESULT && command != null) {
                            Element x = command.findChild("x", "jabber:x:data");
                            if (x != null) {
                                Data data = Data.parse(x);
                                try {
                                    String node = data.getValue("node");
                                    String secret = data.getValue("secret");
                                    Jid jid = Jid.fromString(data.getValue("jid"));
                                    if (node != null && secret != null) {
                                        enablePushOnServer(account, jid, node, secret);
                                    }
                                } catch (InvalidJidException e) {
                                    e.printStackTrace();
                                }
                            }
                        } else {
                            Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": invalid response from app server");
                        }
                    }
                });
            } catch (InvalidJidException ignored) {
            }
        }
    });
}
Also used : Account(eu.siacs.conversations.entities.Account) OnIqPacketReceived(eu.siacs.conversations.xmpp.OnIqPacketReceived) Jid(eu.siacs.conversations.xmpp.jid.Jid) Element(eu.siacs.conversations.xml.Element) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Data(eu.siacs.conversations.xmpp.forms.Data) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 9 with InvalidJidException

use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.

the class SettingsActivity method deleteOmemoIdentities.

private void deleteOmemoIdentities() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle(R.string.pref_delete_omemo_identities);
    final List<CharSequence> accounts = new ArrayList<>();
    for (Account account : xmppConnectionService.getAccounts()) {
        if (!account.isOptionSet(Account.OPTION_DISABLED)) {
            accounts.add(account.getJid().toBareJid().toString());
        }
    }
    final boolean[] checkedItems = new boolean[accounts.size()];
    builder.setMultiChoiceItems(accounts.toArray(new CharSequence[accounts.size()]), checkedItems, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            checkedItems[which] = isChecked;
            final AlertDialog alertDialog = (AlertDialog) dialog;
            for (boolean item : checkedItems) {
                if (item) {
                    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
                    return;
                }
            }
            alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
        }
    });
    builder.setNegativeButton(R.string.cancel, null);
    builder.setPositiveButton(R.string.delete_selected_keys, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            for (int i = 0; i < checkedItems.length; ++i) {
                if (checkedItems[i]) {
                    try {
                        Jid jid = Jid.fromString(accounts.get(i).toString());
                        Account account = xmppConnectionService.findAccountByJid(jid);
                        if (account != null) {
                            account.getAxolotlService().regenerateKeys(true);
                        }
                    } catch (InvalidJidException e) {
                    //
                    }
                }
            }
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
    dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
Also used : AlertDialog(android.app.AlertDialog) Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.jid.Jid) DialogInterface(android.content.DialogInterface) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) ArrayList(java.util.ArrayList)

Example 10 with InvalidJidException

use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.

the class ShareWithActivity method share.

private void share() {
    final Conversation conversation;
    if (share.uuid != null) {
        conversation = xmppConnectionService.findConversationByUuid(share.uuid);
        if (conversation == null) {
            return;
        }
    } else {
        Account account;
        try {
            account = xmppConnectionService.findAccountByJid(Jid.fromString(share.account));
        } catch (final InvalidJidException e) {
            account = null;
        }
        if (account == null) {
            return;
        }
        try {
            conversation = xmppConnectionService.findOrCreateConversation(account, Jid.fromString(share.contact), false);
        } catch (final InvalidJidException e) {
            return;
        }
    }
    share(conversation);
}
Also used : Account(eu.siacs.conversations.entities.Account) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation)

Aggregations

InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)30 Jid (eu.siacs.conversations.xmpp.jid.Jid)18 Account (eu.siacs.conversations.entities.Account)13 Conversation (eu.siacs.conversations.entities.Conversation)11 AlertDialog (android.app.AlertDialog)4 View (android.view.View)4 Message (eu.siacs.conversations.entities.Message)4 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)4 DialogInterface (android.content.DialogInterface)3 TextView (android.widget.TextView)3 Contact (eu.siacs.conversations.entities.Contact)3 IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)3 SuppressLint (android.annotation.SuppressLint)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 Bundle (android.os.Bundle)2 SpannableString (android.text.SpannableString)2 Pair (android.util.Pair)2 AdapterView (android.widget.AdapterView)2 ListView (android.widget.ListView)2 XmppAxolotlMessage (eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage)2