catch exception while destroying rooms

This commit is contained in:
Daniel Gultsch 2020-12-18 21:18:09 +01:00 committed by Christian Schneppe
parent 43208fa088
commit 2836ac669c
2 changed files with 26 additions and 19 deletions

View file

@ -3639,26 +3639,29 @@ public class XmppConnectionService extends Service {
}
public void destroyRoom(final Conversation conversation, final OnRoomDestroy callback) {
IqPacket request = new IqPacket(IqPacket.TYPE.SET);
request.setTo(conversation.getJid().asBareJid());
request.query("http://jabber.org/protocol/muc#owner").addChild("destroy");
sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
if (callback != null) {
callback.onRoomDestroySucceeded();
}
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
if (callback != null) {
callback.onRoomDestroyFailed();
try {
IqPacket request = new IqPacket(IqPacket.TYPE.SET);
request.setTo(conversation.getJid().asBareJid());
request.query("http://jabber.org/protocol/muc#owner").addChild("destroy");
sendIqPacket(conversation.getAccount(), request, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
if (callback != null) {
callback.onRoomDestroySucceeded();
}
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
if (callback != null) {
callback.onRoomDestroyFailed();
}
}
}
}
});
});
} catch (Exception e) {
e.printStackTrace();
}
}
private void disconnect(Account account, boolean force) {
if ((account.getStatus() == Account.State.ONLINE)
|| (account.getStatus() == Account.State.DISABLED)) {

View file

@ -648,9 +648,13 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
if (extras != null && extras.containsKey("MUC_UUID")) {
Log.d(Config.LOGTAG, "Get " + intent.getAction() + " intent for " + extras.getString("MUC_UUID"));
Conversation conversation = xmppConnectionService.findConversationByUuid(extras.getString("MUC_UUID"));
ConversationsActivity.this.xmppConnectionService.clearConversationHistory(conversation);
xmppConnectionService.destroyRoom(conversation, ConversationsActivity.this);
endConversation(conversation);
try {
ConversationsActivity.this.xmppConnectionService.clearConversationHistory(conversation);
xmppConnectionService.destroyRoom(conversation, ConversationsActivity.this);
endConversation(conversation);
} catch (Exception e) {
e.printStackTrace();
}
}
}
setIntent(createLauncherIntent(this));