Search in sources :

Example 11 with Account

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

the class MessageParser method extractStanzaId.

private static String extractStanzaId(Element packet, boolean isTypeGroupChat, Conversation conversation) {
    final Jid by;
    final boolean safeToExtract;
    if (isTypeGroupChat) {
        by = conversation.getJid().toBareJid();
        safeToExtract = conversation.getMucOptions().hasFeature(Namespace.STANZA_IDS);
    } else {
        Account account = conversation.getAccount();
        by = account.getJid().toBareJid();
        safeToExtract = account.getXmppConnection().getFeatures().stanzaIds();
    }
    return safeToExtract ? extractStanzaId(packet, by) : null;
}
Also used : Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.jid.Jid)

Example 12 with Account

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

the class DatabaseBackend method writeRoster.

public void writeRoster(final Roster roster) {
    final Account account = roster.getAccount();
    final SQLiteDatabase db = this.getWritableDatabase();
    db.beginTransaction();
    for (Contact contact : roster.getContacts()) {
        if (contact.getOption(Contact.Options.IN_ROSTER)) {
            db.insert(Contact.TABLENAME, null, contact.getContentValues());
        } else {
            String where = Contact.ACCOUNT + "=? AND " + Contact.JID + "=?";
            String[] whereArgs = { account.getUuid(), contact.getJid().toPreppedString() };
            db.delete(Contact.TABLENAME, where, whereArgs);
        }
    }
    db.setTransactionSuccessful();
    db.endTransaction();
    account.setRosterVersion(roster.getVersion());
    updateAccount(account);
}
Also used : Account(eu.siacs.conversations.entities.Account) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Contact(eu.siacs.conversations.entities.Contact)

Example 13 with Account

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

the class DatabaseBackend method getAccounts.

private List<Account> getAccounts(SQLiteDatabase db) {
    List<Account> list = new ArrayList<>();
    Cursor cursor = db.query(Account.TABLENAME, null, null, null, null, null, null);
    while (cursor.moveToNext()) {
        list.add(Account.fromCursor(cursor));
    }
    cursor.close();
    return list;
}
Also used : Account(eu.siacs.conversations.entities.Account) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 14 with Account

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

the class StartConversationActivity method handleJid.

private boolean handleJid(Invite invite) {
    Account account = xmppConnectionService.findAccountByJid(invite.getJid());
    if (account != null && !account.isOptionSet(Account.OPTION_DISABLED)) {
        if (invite.hasFingerprints() && xmppConnectionService.verifyFingerprints(account, invite.getFingerprints())) {
            Toast.makeText(this, R.string.verified_fingerprints, Toast.LENGTH_SHORT).show();
        }
        switchToAccount(account);
        finish();
        return true;
    }
    List<Contact> contacts = xmppConnectionService.findContacts(invite.getJid());
    if (invite.isMuc()) {
        Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid());
        if (muc != null) {
            switchToConversation(muc, invite.getBody(), false);
            return true;
        } else {
            showJoinConferenceDialog(invite.getJid().toBareJid().toString());
            return false;
        }
    } else if (contacts.size() == 0) {
        showCreateContactDialog(invite.getJid().toString(), invite);
        return false;
    } else if (contacts.size() == 1) {
        Contact contact = contacts.get(0);
        if (!invite.isSafeSource() && invite.hasFingerprints()) {
            displayVerificationWarningDialog(contact, invite);
        } else {
            if (invite.hasFingerprints()) {
                if (xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints())) {
                    Toast.makeText(this, R.string.verified_fingerprints, Toast.LENGTH_SHORT).show();
                }
            }
            switchToConversation(contact, invite.getBody());
        }
        return true;
    } else {
        if (mMenuSearchView != null) {
            mMenuSearchView.expandActionView();
            mSearchEditText.setText("");
            mSearchEditText.append(invite.getJid().toString());
            filter(invite.getJid().toString());
        } else {
            mInitialJid = invite.getJid().toString();
        }
        return true;
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) Conversation(eu.siacs.conversations.entities.Conversation) Contact(eu.siacs.conversations.entities.Contact)

Example 15 with Account

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

the class StartConversationActivity method onBackendConnected.

@Override
protected void onBackendConnected() {
    if (mPostponedActivityResult != null) {
        onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
        this.mPostponedActivityResult = null;
    }
    this.mActivatedAccounts.clear();
    for (Account account : xmppConnectionService.getAccounts()) {
        if (account.getStatus() != Account.State.DISABLED) {
            if (Config.DOMAIN_LOCK != null) {
                this.mActivatedAccounts.add(account.getJid().getLocalpart());
            } else {
                this.mActivatedAccounts.add(account.getJid().toBareJid().toString());
            }
        }
    }
    final Intent intent = getIntent();
    final ActionBar ab = getActionBar();
    boolean init = intent != null && intent.getBooleanExtra("init", false);
    boolean noConversations = xmppConnectionService.getConversations().size() == 0;
    if ((init || noConversations) && ab != null) {
        ab.setDisplayShowHomeEnabled(false);
        ab.setDisplayHomeAsUpEnabled(false);
        ab.setHomeButtonEnabled(false);
    }
    this.mKnownHosts = xmppConnectionService.getKnownHosts();
    this.mKnownConferenceHosts = xmppConnectionService.getKnownConferenceHosts();
    if (this.mPendingInvite != null) {
        mPendingInvite.invite();
        this.mPendingInvite = null;
        filter(null);
    } else if (!handleIntent(getIntent())) {
        if (mSearchEditText != null) {
            filter(mSearchEditText.getText().toString());
        } else {
            filter(null);
        }
    } else {
        filter(null);
    }
    setIntent(null);
}
Also used : Account(eu.siacs.conversations.entities.Account) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) ActionBar(android.app.ActionBar)

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