use of de.pixart.messenger.entities.Contact in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method updateSnackBar.
private void updateSnackBar(final Conversation conversation) {
final Account account = conversation.getAccount();
final XmppConnection connection = account.getXmppConnection();
final Contact contact = conversation.getContact();
final int mode = conversation.getMode();
if (account.getStatus() == Account.State.DISABLED) {
showSnackbar(R.string.this_account_is_disabled, R.string.enable, this.mEnableAccountListener);
} else if (conversation.isBlocked()) {
showSnackbar(R.string.contact_blocked, R.string.unblock, this.mUnblockClickListener);
} else if (contact != null && !contact.showInRoster() && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
showSnackbar(R.string.contact_added_you, R.string.add_back, this.mAddBackClickListener, this.mLongPressBlockListener);
} else if (contact != null && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
showSnackbar(R.string.contact_asks_for_presence_subscription, R.string.allow, this.mAllowPresenceSubscription, this.mLongPressBlockListener);
} else if (mode == Conversation.MODE_MULTI && !conversation.getMucOptions().online() && account.getStatus() == Account.State.ONLINE) {
switch(conversation.getMucOptions().getError()) {
case NICK_IN_USE:
showSnackbar(R.string.nick_in_use, R.string.edit, clickToMuc);
break;
case NO_RESPONSE:
showSnackbar(R.string.joining_conference, 0, null);
break;
case SERVER_NOT_FOUND:
if (conversation.receivedMessagesCount() > 0) {
showSnackbar(R.string.remote_server_not_found, R.string.try_again, joinMuc);
} else {
showSnackbar(R.string.remote_server_not_found, R.string.leave, leaveMuc);
}
break;
case PASSWORD_REQUIRED:
showSnackbar(R.string.conference_requires_password, R.string.enter_password, enterPassword);
break;
case BANNED:
showSnackbar(R.string.conference_banned, R.string.leave, leaveMuc);
break;
case MEMBERS_ONLY:
showSnackbar(R.string.conference_members_only, R.string.leave, leaveMuc);
break;
case KICKED:
showSnackbar(R.string.conference_kicked, R.string.join, joinMuc);
break;
case UNKNOWN:
showSnackbar(R.string.conference_unknown_error, R.string.leave, leaveMuc);
break;
case INVALID_NICK:
showSnackbar(R.string.invalid_muc_nick, R.string.edit, clickToMuc);
case SHUTDOWN:
showSnackbar(R.string.conference_shutdown, R.string.try_again, joinMuc);
break;
default:
hideSnackbar();
break;
}
} else if ((mode == Conversation.MODE_MULTI && !conversation.getMucOptions().participating())) {
showSnackbar(R.string.no_write_access_in_public_muc, R.string.ok, clickToMuc);
} else if (account.hasPendingPgpIntent(conversation)) {
showSnackbar(R.string.openpgp_messages_found, R.string.decrypt, clickToDecryptListener);
} else if (mode == Conversation.MODE_SINGLE && conversation.smpRequested()) {
showSnackbar(R.string.smp_requested, R.string.verify, this.mAnswerSmpClickListener);
} else if (mode == Conversation.MODE_SINGLE && conversation.hasValidOtrSession() && (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!conversation.isOtrFingerprintVerified())) {
showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, clickToVerify);
} else if (connection != null && connection.getFeatures().blocking() && conversation.countMessages() != 0 && !conversation.isBlocked() && conversation.isWithStranger()) {
showSnackbar(R.string.received_message_from_stranger, R.string.block, mBlockClickListener);
} else if (activity.xmppConnectionService.warnUnecryptedChat()) {
AxolotlService axolotlService = account.getAxolotlService();
if ((mode == Conversation.MODE_SINGLE) && (conversation.getNextEncryption() == Message.ENCRYPTION_NONE && ((Config.supportOmemo() && axolotlService != null && conversation.getAccount().getAxolotlService().isConversationAxolotlCapable(conversation)) || (Config.supportOpenPgp() && account.isPgpDecryptionServiceConnected()) || Config.supportOtr()))) {
if (ENCRYPTION_EXCEPTIONS.contains(conversation.getJid().toString()) || conversation.getJid().toString().equals(account.getJid().getDomainpart())) {
hideSnackbar();
} else {
showSnackbar(R.string.conversation_unencrypted_hint, R.string.ok, mHideUnencryptionHint, null);
}
} else if ((mode == Conversation.MODE_MULTI && conversation.getMucOptions().membersOnly() && conversation.getMucOptions().nonanonymous()) && (conversation.getNextEncryption() == Message.ENCRYPTION_NONE && ((Config.supportOmemo() && axolotlService != null && conversation.getAccount().getAxolotlService().isConversationAxolotlCapable(conversation)) || (Config.supportOpenPgp() && account.isPgpDecryptionServiceConnected())))) {
if (ENCRYPTION_EXCEPTIONS.contains(conversation.getJid().toString()) || conversation.getJid().toString().equals(account.getJid().getDomainpart())) {
Log.d(Config.LOGTAG, "Don't show unencrypted warning because " + conversation.getJid().toString() + " is on exception list");
hideSnackbar();
} else {
showSnackbar(R.string.conversation_unencrypted_hint, R.string.ok, mHideUnencryptionHint, null);
}
} else {
hideSnackbar();
}
} else {
hideSnackbar();
}
}
use of de.pixart.messenger.entities.Contact in project Pix-Art-Messenger by kriztan.
the class AvatarService method drawTile.
private boolean drawTile(Canvas canvas, MucOptions.User user, int left, int top, int right, int bottom) {
Contact contact = user.getContact();
if (contact != null) {
Uri uri = null;
if (contact.getAvatar() != null) {
uri = mXmppConnectionService.getFileBackend().getAvatarUri(contact.getAvatar());
} else if (contact.getProfilePhoto() != null) {
uri = Uri.parse(contact.getProfilePhoto());
}
if (drawTile(canvas, uri, left, top, right, bottom)) {
return true;
}
} else if (user.getAvatar() != null) {
Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(user.getAvatar());
if (drawTile(canvas, uri, left, top, right, bottom)) {
return true;
}
} else if (user.getAvatar() != null) {
Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(user.getAvatar());
if (drawTile(canvas, uri, left, top, right, bottom)) {
return true;
}
} else if (user.getAvatar() != null) {
Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(user.getAvatar());
if (drawTile(canvas, uri, left, top, right, bottom)) {
return true;
}
}
if (contact != null) {
String seed = contact.getJid().toBareJid().toString();
drawTile(canvas, contact.getDisplayName(), seed, left, top, right, bottom);
} else {
String seed = user.getRealJid() == null ? null : user.getRealJid().toBareJid().toString();
drawTile(canvas, user.getName(), seed, left, top, right, bottom);
}
return true;
}
use of de.pixart.messenger.entities.Contact in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method fetchConferenceMembers.
private void fetchConferenceMembers(final Conversation conversation) {
final Account account = conversation.getAccount();
final AxolotlService axolotlService = account.getAxolotlService();
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()) {
boolean isNew = conversation.getMucOptions().updateUser(user);
Contact contact = user.getContact();
if (isNew && user.getRealJid() != null && (contact == null || !contact.mutualPresenceSubscription()) && axolotlService.hasEmptyDeviceList(user.getRealJid())) {
axolotlService.fetchDeviceIds(user.getRealJid());
}
}
}
}
} 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());
}
use of de.pixart.messenger.entities.Contact in project Pix-Art-Messenger by kriztan.
the class UIHelper method getDisplayName.
public static String getDisplayName(MucOptions.User user) {
Contact contact = user.getContact();
if (contact != null) {
return contact.getDisplayName();
} else {
final String name = user.getName();
if (name != null) {
return name;
}
final Jid realJid = user.getRealJid();
if (realJid != null) {
return JidHelper.localPartOrFallback(realJid);
}
return null;
}
}
Aggregations