download own vcard avatar if none is set. fixes #2008
This commit is contained in:
parent
edf0ae9aa6
commit
c3b11e515e
|
@ -116,7 +116,7 @@ public class MucOptions {
|
|||
|
||||
public enum Error {
|
||||
NO_RESPONSE,
|
||||
SEVRER_NOT_FOUND,
|
||||
SERVER_NOT_FOUND,
|
||||
NONE,
|
||||
NICK_IN_USE,
|
||||
PASSWORD_REQUIRED,
|
||||
|
|
|
@ -184,10 +184,16 @@ public class PresenceParser extends AbstractParser implements
|
|||
final String resource = from.isBareJid() ? "" : from.getResourcepart();
|
||||
contact.setPresenceName(packet.findChildContent("nick", "http://jabber.org/protocol/nick"));
|
||||
Avatar avatar = Avatar.parsePresence(packet.findChild("x", "vcard-temp:x:update"));
|
||||
if (avatar != null && !contact.isSelf()) {
|
||||
if (avatar != null && (!contact.isSelf() || account.getAvatar() == null)) {
|
||||
avatar.owner = from.toBareJid();
|
||||
if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) {
|
||||
if (contact.setAvatar(avatar)) {
|
||||
if (avatar.owner.equals(account.getJid().toBareJid())) {
|
||||
account.setAvatar(avatar.getFilename());
|
||||
mXmppConnectionService.databaseBackend.updateAccount(account);
|
||||
mXmppConnectionService.getAvatarService().clear(account);
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
mXmppConnectionService.updateAccountUi();
|
||||
} else if (contact.setAvatar(avatar)) {
|
||||
mXmppConnectionService.getAvatarService().clear(contact);
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
mXmppConnectionService.updateRosterUi();
|
||||
|
|
|
@ -2036,7 +2036,7 @@ public class XmppConnectionService extends Service {
|
|||
@Override
|
||||
public void onFetchFailed(final Conversation conversation, Element error) {
|
||||
if (error != null && "remote-server-not-found".equals(error.getName())) {
|
||||
conversation.getMucOptions().setError(MucOptions.Error.SEVRER_NOT_FOUND);
|
||||
conversation.getMucOptions().setError(MucOptions.Error.SERVER_NOT_FOUND);
|
||||
} else {
|
||||
join(conversation);
|
||||
fetchConferenceConfiguration(conversation);
|
||||
|
@ -2739,12 +2739,19 @@ public class XmppConnectionService extends Service {
|
|||
Log.d(Config.LOGTAG, account.getJid().toBareJid()
|
||||
+ ": successfully fetched vCard avatar for " + avatar.owner);
|
||||
if (avatar.owner.isBareJid()) {
|
||||
Contact contact = account.getRoster()
|
||||
.getContact(avatar.owner);
|
||||
contact.setAvatar(avatar);
|
||||
getAvatarService().clear(contact);
|
||||
if (account.getJid().toBareJid().equals(avatar.owner) && account.getAvatar() == null) {
|
||||
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": had no avatar. replacing with vcard");
|
||||
account.setAvatar(avatar.getFilename());
|
||||
databaseBackend.updateAccount(account);
|
||||
getAvatarService().clear(account);
|
||||
updateAccountUi();
|
||||
} else {
|
||||
Contact contact = account.getRoster().getContact(avatar.owner);
|
||||
contact.setAvatar(avatar);
|
||||
getAvatarService().clear(contact);
|
||||
updateRosterUi();
|
||||
}
|
||||
updateConversationUi();
|
||||
updateRosterUi();
|
||||
} else {
|
||||
Conversation conversation = find(account, avatar.owner.toBareJid());
|
||||
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
|
||||
|
|
|
@ -43,7 +43,6 @@ import java.util.UUID;
|
|||
|
||||
import eu.siacs.conversations.Config;
|
||||
import eu.siacs.conversations.R;
|
||||
import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||
import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Contact;
|
||||
import eu.siacs.conversations.entities.Conversation;
|
||||
|
@ -865,7 +864,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||
case NO_RESPONSE:
|
||||
showSnackbar(R.string.joining_conference, 0, null);
|
||||
break;
|
||||
case SEVRER_NOT_FOUND:
|
||||
case SERVER_NOT_FOUND:
|
||||
showSnackbar(R.string.remote_server_not_found,R.string.leave, leaveMuc);
|
||||
break;
|
||||
case PASSWORD_REQUIRED:
|
||||
|
|
Loading…
Reference in a new issue