mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-30 20:52:21 -05:00
improved logging for avatar fetches
This commit is contained in:
parent
b8d289a932
commit
34228d0e78
@ -784,17 +784,18 @@ public class XmppConnectionService extends Service {
|
|||||||
|
|
||||||
return this.conversations;
|
return this.conversations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void populateWithOrderedConversations(List<Conversation> list) {
|
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();
|
list.clear();
|
||||||
if (includeConferences) {
|
if (includeConferences) {
|
||||||
list.addAll(getConversations());
|
list.addAll(getConversations());
|
||||||
} else {
|
} else {
|
||||||
for(Conversation conversation : getConversations()) {
|
for (Conversation conversation : getConversations()) {
|
||||||
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
if (conversation.getMode() == Conversation.MODE_SINGLE) {
|
||||||
list.add(conversation);
|
list.add(conversation);
|
||||||
}
|
}
|
||||||
@ -1094,7 +1095,7 @@ public class XmppConnectionService extends Service {
|
|||||||
public void setOnRenameListener(OnRenameListener listener) {
|
public void setOnRenameListener(OnRenameListener listener) {
|
||||||
this.renameListener = listener;
|
this.renameListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void providePasswordForMuc(Conversation conversation, String password) {
|
public void providePasswordForMuc(Conversation conversation, String password) {
|
||||||
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
conversation.getMucOptions().setPassword(password);
|
conversation.getMucOptions().setPassword(password);
|
||||||
@ -1362,34 +1363,50 @@ public class XmppConnectionService extends Service {
|
|||||||
|
|
||||||
public void fetchAvatar(Account account, final Avatar avatar,
|
public void fetchAvatar(Account account, final Avatar avatar,
|
||||||
final UiCallback<Avatar> callback) {
|
final UiCallback<Avatar> callback) {
|
||||||
Log.d(Config.LOGTAG, account.getJid() + ": retrieving avatar for "
|
|
||||||
+ avatar.owner);
|
|
||||||
IqPacket packet = this.mIqGenerator.retrieveAvatar(avatar);
|
IqPacket packet = this.mIqGenerator.retrieveAvatar(avatar);
|
||||||
sendIqPacket(account, packet, new OnIqPacketReceived() {
|
sendIqPacket(account, packet, new OnIqPacketReceived() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onIqPacketReceived(Account account, IqPacket result) {
|
public void onIqPacketReceived(Account account, IqPacket result) {
|
||||||
avatar.image = mIqParser.avatarData(result);
|
final String ERROR = account.getJid()
|
||||||
if (avatar.image != null) {
|
+ ": fetching avatar for " + avatar.owner + " failed ";
|
||||||
if (getFileBackend().save(avatar)) {
|
if (result.getType() == IqPacket.TYPE_RESULT) {
|
||||||
if (account.getJid().equals(avatar.owner)) {
|
avatar.image = mIqParser.avatarData(result);
|
||||||
if (account.setAvatar(avatar.getFilename())) {
|
if (avatar.image != null) {
|
||||||
databaseBackend.updateAccount(account);
|
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 {
|
if (callback != null) {
|
||||||
Contact contact = account.getRoster().getContact(
|
callback.success(avatar);
|
||||||
avatar.owner);
|
}
|
||||||
contact.setAvatar(avatar.getFilename());
|
Log.d(Config.LOGTAG, account.getJid()
|
||||||
|
+ ": succesfully fetched avatar for "
|
||||||
|
+ avatar.owner);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (callback != null) {
|
} else {
|
||||||
callback.success(avatar);
|
|
||||||
}
|
Log.d(Config.LOGTAG, ERROR + "(parsing error)");
|
||||||
return;
|
}
|
||||||
|
} 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) {
|
if (callback != null) {
|
||||||
callback.error(0, null);
|
callback.error(0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user