Search in sources :

Example 46 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class MUCManager method onStanza.

@Override
public void onStanza(ConnectionItem connection, Stanza stanza) {
    if (!(connection instanceof AccountItem)) {
        return;
    }
    AccountJid account = ((AccountItem) connection).getAccount();
    Jid from = stanza.getFrom();
    if (from == null || !(stanza instanceof Message)) {
        return;
    }
    Message message = (Message) stanza;
    if (message.getType() != Message.Type.normal && message.getType() != Message.Type.chat) {
        return;
    }
    MUCUser mucUser = MUCUser.from(stanza);
    if (mucUser == null || mucUser.getInvite() == null) {
        return;
    }
    RoomChat roomChat = getRoomChat(account, from.asEntityBareJidIfPossible());
    if (roomChat == null || !roomChat.getState().inUse()) {
        UserJid inviter = null;
        try {
            inviter = UserJid.from(mucUser.getInvite().getFrom());
        } catch (UserJid.UserJidCreateException e) {
            LogManager.exception(this, e);
        }
        if (inviter == null) {
            try {
                inviter = UserJid.from(from);
            } catch (UserJid.UserJidCreateException e) {
                LogManager.exception(this, e);
            }
        }
        try {
            inviteProvider.add(new RoomInvite(account, UserJid.from(from), inviter, mucUser.getInvite().getReason(), mucUser.getPassword()), true);
        } catch (UserJid.UserJidCreateException e) {
            LogManager.exception(this, e);
        }
    }
}
Also used : MUCUser(org.jivesoftware.smackx.muc.packet.MUCUser) UserJid(com.xabber.android.data.entity.UserJid) AccountJid(com.xabber.android.data.entity.AccountJid) DomainBareJid(org.jxmpp.jid.DomainBareJid) EntityBareJid(org.jxmpp.jid.EntityBareJid) Jid(org.jxmpp.jid.Jid) Message(org.jivesoftware.smack.packet.Message) AccountItem(com.xabber.android.data.account.AccountItem) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid)

Example 47 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class OTRManager method askForSecret.

@Override
public void askForSecret(SessionID sessionID, InstanceTag receiverTag, String question) {
    try {
        AccountJid accountJid = AccountJid.from(sessionID.getAccountID());
        UserJid userJid = UserJid.from(sessionID.getUserID());
        // set notify intent to chat
        setNotifyIntentToChat(QuestionActivity.createIntent(Application.getInstance(), accountJid, userJid, question != null, true, question), accountJid, userJid);
        // show android notification
        SMRequest request = new SMRequest(AccountJid.from(sessionID.getAccountID()), UserJid.from(sessionID.getUserID()), question);
        smRequestProvider.add(request, true);
        // send event of adding auth request to fragment
        EventBus.getDefault().post(new AuthAskEvent(accountJid, userJid));
    } catch (UserJid.UserJidCreateException | XmppStringprepException e) {
        LogManager.exception(this, e);
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException)

Example 48 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class VCardManager method onRosterReceived.

@Override
public void onRosterReceived(AccountItem accountItem) {
    AccountJid account = accountItem.getAccount();
    if (!accountRequested.contains(account) && SettingsManager.connectionLoadVCard()) {
        BareJid bareAddress = accountItem.getRealJid().asBareJid();
        if (bareAddress != null && !names.containsKey(bareAddress)) {
            request(account, bareAddress);
            accountRequested.add(account);
        }
    }
    Collection<UserJid> blockedContacts = BlockingManager.getInstance().getBlockedContacts(account);
    Collection<RosterContact> accountRosterContacts = RosterManager.getInstance().getAccountRosterContacts(account);
    // Request vCards for new contacts.
    for (RosterContact contact : accountRosterContacts) {
        if (!names.containsKey(contact.getUser().getJid())) {
            if (!blockedContacts.contains(contact.getUser())) {
                request(account, contact.getUser().getJid());
            }
        }
    }
}
Also used : RosterContact(com.xabber.android.data.roster.RosterContact) EntityBareJid(org.jxmpp.jid.EntityBareJid) BareJid(org.jxmpp.jid.BareJid) AccountJid(com.xabber.android.data.entity.AccountJid) UserJid(com.xabber.android.data.entity.UserJid)

Example 49 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class ContactAddFragment method onItemSelected.

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    AccountJid selectedAccount = (AccountJid) accountView.getSelectedItem();
    if (selectedAccount == null) {
        onNothingSelected(parent);
        setAccount(null);
    } else {
        listenerActivity.onAccountSelected(selectedAccount);
        if (!selectedAccount.equals(getAccount())) {
            setAccount(selectedAccount);
            setAccountGroups();
            updateGroups();
        }
        if (getListView().getVisibility() == View.GONE) {
            getListView().setVisibility(View.VISIBLE);
        }
    }
}
Also used : AccountJid(com.xabber.android.data.entity.AccountJid)

Example 50 with AccountJid

use of com.xabber.android.data.entity.AccountJid in project xabber-android by redsolution.

the class ContactAddFragment method setUpAccountView.

private void setUpAccountView(Spinner view) {
    accountView = view;
    accountView.setAdapter(new AccountChooseAdapter(getActivity()));
    accountView.setOnItemSelectedListener(this);
    AccountJid account = getAccount();
    if (account != null) {
        for (int position = 0; position < accountView.getCount(); position++) {
            AccountJid itemAtPosition = (AccountJid) accountView.getItemAtPosition(position);
            LogManager.i(this, "itemAtPosition " + itemAtPosition + " account " + account);
            if (account.equals(accountView.getItemAtPosition(position))) {
                accountView.setSelection(position);
                break;
            }
        }
    }
}
Also used : AccountChooseAdapter(com.xabber.android.ui.adapter.AccountChooseAdapter) AccountJid(com.xabber.android.data.entity.AccountJid)

Aggregations

AccountJid (com.xabber.android.data.entity.AccountJid)74 UserJid (com.xabber.android.data.entity.UserJid)38 AccountItem (com.xabber.android.data.account.AccountItem)21 Jid (org.jxmpp.jid.Jid)13 Intent (android.content.Intent)11 ArrayList (java.util.ArrayList)11 View (android.view.View)10 NetworkException (com.xabber.android.data.NetworkException)9 AbstractChat (com.xabber.android.data.message.AbstractChat)7 Message (org.jivesoftware.smack.packet.Message)7 Presence (org.jivesoftware.smack.packet.Presence)7 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)6 TextView (android.widget.TextView)5 StatusMode (com.xabber.android.data.account.StatusMode)5 Resourcepart (org.jxmpp.jid.parts.Resourcepart)5 ImageView (android.widget.ImageView)4 AccountManager (com.xabber.android.data.account.AccountManager)4 RosterContact (com.xabber.android.data.roster.RosterContact)4 ContactVO (com.xabber.android.presentation.ui.contactlist.viewobjects.ContactVO)4 BarPainter (com.xabber.android.ui.color.BarPainter)4