Search in sources :

Example 76 with Account

use of eu.siacs.conversations.entities.Account in project Conversations by siacs.

the class XmppConnectionService method pushConferenceConfiguration.

public void pushConferenceConfiguration(final Conversation conversation, final Bundle options, final OnConfigurationPushed callback) {
    IqPacket request = new IqPacket(IqPacket.TYPE.GET);
    request.setTo(conversation.getJid().toBareJid());
    request.query("http://jabber.org/protocol/muc#owner");
    sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() {

        @Override
        public void onIqPacketReceived(Account account, IqPacket packet) {
            if (packet.getType() == IqPacket.TYPE.RESULT) {
                Data data = Data.parse(packet.query().findChild("x", "jabber:x:data"));
                data.submit(options);
                IqPacket set = new IqPacket(IqPacket.TYPE.SET);
                set.setTo(conversation.getJid().toBareJid());
                set.query("http://jabber.org/protocol/muc#owner").addChild(data);
                sendIqPacket(account, set, new OnIqPacketReceived() {

                    @Override
                    public void onIqPacketReceived(Account account, IqPacket packet) {
                        if (callback != null) {
                            if (packet.getType() == IqPacket.TYPE.RESULT) {
                                callback.onPushSucceeded();
                            } else {
                                callback.onPushFailed();
                            }
                        }
                    }
                });
            } else {
                if (callback != null) {
                    callback.onPushFailed();
                }
            }
        }
    });
}
Also used : Account(eu.siacs.conversations.entities.Account) OnIqPacketReceived(eu.siacs.conversations.xmpp.OnIqPacketReceived) Data(eu.siacs.conversations.xmpp.forms.Data) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 77 with Account

use of eu.siacs.conversations.entities.Account in project Conversations by siacs.

the class XmppConnectionService method onOtrSessionEstablished.

public void onOtrSessionEstablished(Conversation conversation) {
    final Account account = conversation.getAccount();
    final Session otrSession = conversation.getOtrSession();
    Log.d(Config.LOGTAG, account.getJid().toBareJid() + " otr session established with " + conversation.getJid() + "/" + otrSession.getSessionID().getUserID());
    conversation.findUnsentMessagesWithEncryption(Message.ENCRYPTION_OTR, new Conversation.OnMessageFound() {

        @Override
        public void onMessageFound(Message message) {
            SessionID id = otrSession.getSessionID();
            try {
                message.setCounterpart(Jid.fromString(id.getAccountID() + "/" + id.getUserID()));
            } catch (InvalidJidException e) {
                return;
            }
            if (message.needsUploading()) {
                mJingleConnectionManager.createNewConnection(message);
            } else {
                MessagePacket outPacket = mMessageGenerator.generateOtrChat(message);
                if (outPacket != null) {
                    mMessageGenerator.addDelay(outPacket, message.getTimeSent());
                    message.setStatus(Message.STATUS_SEND);
                    databaseBackend.updateMessage(message);
                    sendMessagePacket(account, outPacket);
                }
            }
            updateConversationUi();
        }
    });
}
Also used : MessagePacket(eu.siacs.conversations.xmpp.stanzas.MessagePacket) Account(eu.siacs.conversations.entities.Account) XmppAxolotlMessage(eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage) Message(eu.siacs.conversations.entities.Message) InvalidJidException(eu.siacs.conversations.xmpp.jid.InvalidJidException) Conversation(eu.siacs.conversations.entities.Conversation) SessionID(net.java.otr4j.session.SessionID) Session(net.java.otr4j.session.Session)

Example 78 with Account

use of eu.siacs.conversations.entities.Account in project Conversations by siacs.

the class XmppConnectionService method resetAllAttemptCounts.

private void resetAllAttemptCounts(boolean reallyAll, boolean retryImmediately) {
    Log.d(Config.LOGTAG, "resetting all attempt counts");
    for (Account account : accounts) {
        if (account.hasErrorStatus() || reallyAll) {
            final XmppConnection connection = account.getXmppConnection();
            if (connection != null) {
                connection.resetAttemptCount(retryImmediately);
            }
        }
        if (account.setShowErrorNotification(true)) {
            databaseBackend.updateAccount(account);
        }
    }
    mNotificationService.updateErrorNotification();
}
Also used : XmppConnection(eu.siacs.conversations.xmpp.XmppConnection) Account(eu.siacs.conversations.entities.Account)

Example 79 with Account

use of eu.siacs.conversations.entities.Account in project Conversations by siacs.

the class BlocklistActivity method onBackendConnected.

@Override
public void onBackendConnected() {
    for (final Account account : xmppConnectionService.getAccounts()) {
        if (account.getJid().toString().equals(getIntent().getStringExtra(EXTRA_ACCOUNT))) {
            this.account = account;
            break;
        }
    }
    filterContacts();
    this.mKnownHosts = xmppConnectionService.getKnownHosts();
}
Also used : Account(eu.siacs.conversations.entities.Account)

Example 80 with Account

use of eu.siacs.conversations.entities.Account in project Conversations by siacs.

the class ChooseContactActivity method filterContacts.

protected void filterContacts(final String needle) {
    getListItems().clear();
    for (final Account account : xmppConnectionService.getAccounts()) {
        if (account.getStatus() != Account.State.DISABLED) {
            for (final Contact contact : account.getRoster().getContacts()) {
                if (contact.showInRoster() && !filterContacts.contains(contact.getJid().toBareJid().toString()) && contact.match(this, needle)) {
                    getListItems().add(contact);
                }
            }
        }
    }
    Collections.sort(getListItems());
    getListItemAdapter().notifyDataSetChanged();
}
Also used : Account(eu.siacs.conversations.entities.Account) Contact(eu.siacs.conversations.entities.Contact)

Aggregations

Account (eu.siacs.conversations.entities.Account)100 IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)41 OnIqPacketReceived (eu.siacs.conversations.xmpp.OnIqPacketReceived)33 Jid (eu.siacs.conversations.xmpp.jid.Jid)22 Element (eu.siacs.conversations.xml.Element)21 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)17 Conversation (eu.siacs.conversations.entities.Conversation)16 Contact (eu.siacs.conversations.entities.Contact)9 Message (eu.siacs.conversations.entities.Message)9 ArrayList (java.util.ArrayList)8 PendingIntent (android.app.PendingIntent)7 Intent (android.content.Intent)7 Bookmark (eu.siacs.conversations.entities.Bookmark)7 SuppressLint (android.annotation.SuppressLint)6 AlertDialog (android.app.AlertDialog)6 TextView (android.widget.TextView)6 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)6 FileNotFoundException (java.io.FileNotFoundException)6 DialogInterface (android.content.DialogInterface)5 View (android.view.View)5