diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-05 13:29:20 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-05 13:29:20 +0200 |
commit | 34228d0e7820eedec1d610d28db99fb91783de60 (patch) | |
tree | 983b6dc5e6f978aa204b898f78a4d17ca0ecd05b /src | |
parent | b8d289a9324431534f1acfa6fe684decb01f22fb (diff) |
improved logging for avatar fetches
Diffstat (limited to 'src')
-rw-r--r-- | src/eu/siacs/conversations/services/XmppConnectionService.java | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index a294e970..9e171751 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -784,17 +784,18 @@ public class XmppConnectionService extends Service { return this.conversations; } - + public void populateWithOrderedConversations(List<Conversation> list) { - populateWithOrderedConversations(list,true); + populateWithOrderedConversations(list, true); } - public void populateWithOrderedConversations(List<Conversation> list, boolean includeConferences) { + public void populateWithOrderedConversations(List<Conversation> list, + boolean includeConferences) { list.clear(); if (includeConferences) { list.addAll(getConversations()); } else { - for(Conversation conversation : getConversations()) { + for (Conversation conversation : getConversations()) { if (conversation.getMode() == Conversation.MODE_SINGLE) { list.add(conversation); } @@ -1094,7 +1095,7 @@ public class XmppConnectionService extends Service { public void setOnRenameListener(OnRenameListener listener) { this.renameListener = listener; } - + public void providePasswordForMuc(Conversation conversation, String password) { if (conversation.getMode() == Conversation.MODE_MULTI) { conversation.getMucOptions().setPassword(password); @@ -1362,34 +1363,50 @@ public class XmppConnectionService extends Service { public void fetchAvatar(Account account, final Avatar avatar, final UiCallback<Avatar> callback) { - Log.d(Config.LOGTAG, account.getJid() + ": retrieving avatar for " - + avatar.owner); IqPacket packet = this.mIqGenerator.retrieveAvatar(avatar); sendIqPacket(account, packet, new OnIqPacketReceived() { @Override public void onIqPacketReceived(Account account, IqPacket result) { - avatar.image = mIqParser.avatarData(result); - if (avatar.image != null) { - if (getFileBackend().save(avatar)) { - if (account.getJid().equals(avatar.owner)) { - if (account.setAvatar(avatar.getFilename())) { - databaseBackend.updateAccount(account); + final String ERROR = account.getJid() + + ": fetching avatar for " + avatar.owner + " failed "; + if (result.getType() == IqPacket.TYPE_RESULT) { + avatar.image = mIqParser.avatarData(result); + if (avatar.image != null) { + if (getFileBackend().save(avatar)) { + if (account.getJid().equals(avatar.owner)) { + if (account.setAvatar(avatar.getFilename())) { + databaseBackend.updateAccount(account); + } + } else { + Contact contact = account.getRoster() + .getContact(avatar.owner); + contact.setAvatar(avatar.getFilename()); } - } else { - Contact contact = account.getRoster().getContact( - avatar.owner); - contact.setAvatar(avatar.getFilename()); - } - if (callback != null) { - callback.success(avatar); + if (callback != null) { + callback.success(avatar); + } + Log.d(Config.LOGTAG, account.getJid() + + ": succesfully fetched avatar for " + + avatar.owner); + return; } - return; + } else { + + Log.d(Config.LOGTAG, ERROR + "(parsing error)"); + } + } else { + Element error = result.findChild("error"); + if (error==null) { + Log.d(Config.LOGTAG, ERROR + "(server error)"); + } else { + Log.d(Config.LOGTAG, ERROR + error.toString()); } } if (callback != null) { callback.error(0, null); } + } }); } |