aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/parser/MessageParser.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-08-05 22:58:46 +0200
committeriNPUTmice <daniel@gultsch.de>2014-08-05 22:58:46 +0200
commitba63727f50c192e63e171bedca92d7003981800c (patch)
tree6b4956817a46266ec3de683bc6d7a4e46681a656 /src/eu/siacs/conversations/parser/MessageParser.java
parent08755e56a5bf861c97eefd545f629ac67a804275 (diff)
fetch missing avatars from server
Diffstat (limited to 'src/eu/siacs/conversations/parser/MessageParser.java')
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index 0a812669..b54f6b98 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -5,12 +5,14 @@ import android.util.Log;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionStatus;
import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.CryptoHelper;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
+import eu.siacs.conversations.xmpp.pep.Avatar;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
public class MessageParser extends AbstractParser implements
@@ -263,7 +265,22 @@ public class MessageParser extends AbstractParser implements
Element items = event.findChild("items");
String node = items.getAttribute("node");
if (node!=null) {
- Log.d("xmppService",account.getJid()+": "+node+" from "+from);
+ if (node.equals("urn:xmpp:avatar:metadata")) {
+ Avatar avatar = Avatar.parseMetadata(items);
+ avatar.owner = from;
+ if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) {
+ if (account.getJid().equals(from)) {
+ account.setAvatar(avatar.getFilename());
+ } else {
+ Contact contact = account.getRoster().getContact(from);
+ contact.setAvatar(avatar.getFilename());
+ }
+ } else {
+ mXmppConnectionService.fetchAvatar(account, avatar);
+ }
+ } else {
+ Log.d("xmppService",account.getJid()+": "+node+" from "+from);
+ }
} else {
Log.d("xmppService",event.toString());
}