Search in sources :

Example 61 with Account

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

the class ConferenceDetailsActivity method deleteBookmark.

protected void deleteBookmark() {
    Account account = mConversation.getAccount();
    Bookmark bookmark = mConversation.getBookmark();
    bookmark.unregisterConversation();
    account.getBookmarks().remove(bookmark);
    xmppConnectionService.pushBookmarks(account);
}
Also used : Account(eu.siacs.conversations.entities.Account) Bookmark(eu.siacs.conversations.entities.Bookmark)

Example 62 with Account

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

the class ConferenceDetailsActivity method onPrepareOptionsMenu.

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem menuItemSaveBookmark = menu.findItem(R.id.action_save_as_bookmark);
    MenuItem menuItemDeleteBookmark = menu.findItem(R.id.action_delete_bookmark);
    MenuItem menuItemAdvancedMode = menu.findItem(R.id.action_advanced_mode);
    MenuItem menuItemChangeSubject = menu.findItem(R.id.action_edit_subject);
    menuItemAdvancedMode.setChecked(mAdvancedMode);
    if (mConversation == null) {
        return true;
    }
    Account account = mConversation.getAccount();
    if (account.hasBookmarkFor(mConversation.getJid().toBareJid())) {
        menuItemSaveBookmark.setVisible(false);
        menuItemDeleteBookmark.setVisible(true);
    } else {
        menuItemDeleteBookmark.setVisible(false);
        menuItemSaveBookmark.setVisible(true);
    }
    menuItemChangeSubject.setVisible(mConversation.getMucOptions().canChangeSubject());
    return true;
}
Also used : Account(eu.siacs.conversations.entities.Account) MenuItem(android.view.MenuItem)

Example 63 with Account

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

the class ContactDetailsActivity method onBackendConnected.

public void onBackendConnected() {
    if (accountJid != null && contactJid != null) {
        Account account = xmppConnectionService.findAccountByJid(accountJid);
        if (account == null) {
            return;
        }
        this.contact = account.getRoster().getContact(contactJid);
        if (mPendingFingerprintVerificationUri != null) {
            processFingerprintVerification(mPendingFingerprintVerificationUri);
            mPendingFingerprintVerificationUri = null;
        }
        populateView();
    }
}
Also used : Account(eu.siacs.conversations.entities.Account)

Example 64 with Account

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

the class XmppConnectionService method updateAccountPasswordOnServer.

public void updateAccountPasswordOnServer(final Account account, final String newPassword, final OnAccountPasswordChanged callback) {
    final IqPacket iq = getIqGenerator().generateSetPassword(account, newPassword);
    sendIqPacket(account, iq, new OnIqPacketReceived() {

        @Override
        public void onIqPacketReceived(final Account account, final IqPacket packet) {
            if (packet.getType() == IqPacket.TYPE.RESULT) {
                account.setPassword(newPassword);
                account.setOption(Account.OPTION_MAGIC_CREATE, false);
                databaseBackend.updateAccount(account);
                callback.onPasswordChangeSucceeded();
            } else {
                callback.onPasswordChangeFailed();
            }
        }
    });
}
Also used : Account(eu.siacs.conversations.entities.Account) OnIqPacketReceived(eu.siacs.conversations.xmpp.OnIqPacketReceived) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 65 with Account

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

the class XmppConnectionService method fetchConferenceMembers.

private void fetchConferenceMembers(final Conversation conversation) {
    final Account account = conversation.getAccount();
    final String[] affiliations = { "member", "admin", "owner" };
    OnIqPacketReceived callback = new OnIqPacketReceived() {

        private int i = 0;

        private boolean success = true;

        @Override
        public void onIqPacketReceived(Account account, IqPacket packet) {
            Element query = packet.query("http://jabber.org/protocol/muc#admin");
            if (packet.getType() == IqPacket.TYPE.RESULT && query != null) {
                for (Element child : query.getChildren()) {
                    if ("item".equals(child.getName())) {
                        MucOptions.User user = AbstractParser.parseItem(conversation, child);
                        if (!user.realJidMatchesAccount()) {
                            conversation.getMucOptions().updateUser(user);
                        }
                    }
                }
            } else {
                success = false;
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not request affiliation " + affiliations[i] + " in " + conversation.getJid().toBareJid());
            }
            ++i;
            if (i >= affiliations.length) {
                List<Jid> members = conversation.getMucOptions().getMembers();
                if (success) {
                    List<Jid> cryptoTargets = conversation.getAcceptedCryptoTargets();
                    boolean changed = false;
                    for (ListIterator<Jid> iterator = cryptoTargets.listIterator(); iterator.hasNext(); ) {
                        Jid jid = iterator.next();
                        if (!members.contains(jid)) {
                            iterator.remove();
                            Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": removed " + jid + " from crypto targets of " + conversation.getName());
                            changed = true;
                        }
                    }
                    if (changed) {
                        conversation.setAcceptedCryptoTargets(cryptoTargets);
                        updateConversation(conversation);
                    }
                }
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": retrieved members for " + conversation.getJid().toBareJid() + ": " + conversation.getMucOptions().getMembers());
                getAvatarService().clear(conversation);
                updateMucRosterUi();
                updateConversationUi();
            }
        }
    };
    for (String affiliation : affiliations) {
        sendIqPacket(account, mIqGenerator.queryAffiliation(conversation, affiliation), callback);
    }
    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": fetching members for " + conversation.getName());
}
Also used : Account(eu.siacs.conversations.entities.Account) MucOptions(eu.siacs.conversations.entities.MucOptions) OnIqPacketReceived(eu.siacs.conversations.xmpp.OnIqPacketReceived) Jid(eu.siacs.conversations.xmpp.jid.Jid) Element(eu.siacs.conversations.xml.Element) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

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