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);
}
}
}
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);
}
}
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());
}
}
}
}
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);
}
}
}
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;
}
}
}
}
Aggregations