join muc even if initial conference configuration fetch failed

This commit is contained in:
Daniel Gultsch 2015-10-22 11:20:36 +02:00
parent 3c45f00443
commit 1bd68a42b2
2 changed files with 43 additions and 2 deletions

View File

@ -1683,8 +1683,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
if (account.getStatus() == Account.State.ONLINE || now) { if (account.getStatus() == Account.State.ONLINE || now) {
conversation.resetMucOptions(); conversation.resetMucOptions();
fetchConferenceConfiguration(conversation, new OnConferenceConfigurationFetched() { fetchConferenceConfiguration(conversation, new OnConferenceConfigurationFetched() {
@Override
public void onConferenceConfigurationFetched(Conversation conversation) { private void join(Conversation conversation) {
Account account = conversation.getAccount(); Account account = conversation.getAccount();
final String nick = conversation.getMucOptions().getProposedNick(); final String nick = conversation.getMucOptions().getProposedNick();
final Jid joinJid = conversation.getMucOptions().createJoinJid(nick); final Jid joinJid = conversation.getMucOptions().createJoinJid(nick);
@ -1723,6 +1723,27 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
getMessageArchiveService().catchupMUC(conversation); getMessageArchiveService().catchupMUC(conversation);
} }
} }
@Override
public void onConferenceConfigurationFetched(Conversation conversation) {
join(conversation);
}
@Override
public void onFetchFailed(final Conversation conversation, Element error) {
conversation.getMucOptions().setOnJoinListener(new MucOptions.OnJoinListener() {
@Override
public void onSuccess() {
fetchConferenceConfiguration(conversation);
}
@Override
public void onFailure() {
}
});
join(conversation);
}
}); });
} else { } else {
@ -1913,6 +1934,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
callback.onConferenceConfigurationFetched(conversation); callback.onConferenceConfigurationFetched(conversation);
} }
updateConversationUi(); updateConversationUi();
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
if (callback != null) {
callback.onFetchFailed(conversation, packet.getError());
}
} }
} }
}); });
@ -2901,6 +2926,8 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
public interface OnConferenceConfigurationFetched { public interface OnConferenceConfigurationFetched {
void onConferenceConfigurationFetched(Conversation conversation); void onConferenceConfigurationFetched(Conversation conversation);
void onFetchFailed(Conversation conversation, Element error);
} }
public interface OnConferenceOptionsPushed { public interface OnConferenceOptionsPushed {

View File

@ -1,5 +1,7 @@
package eu.siacs.conversations.xmpp.stanzas; package eu.siacs.conversations.xmpp.stanzas;
import eu.siacs.conversations.xml.Element;
abstract public class AbstractAcknowledgeableStanza extends AbstractStanza { abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {
protected AbstractAcknowledgeableStanza(String name) { protected AbstractAcknowledgeableStanza(String name) {
@ -14,4 +16,16 @@ abstract public class AbstractAcknowledgeableStanza extends AbstractStanza {
public void setId(final String id) { public void setId(final String id) {
setAttribute("id", id); setAttribute("id", id);
} }
public Element getError() {
Element error = findChild("error");
if (error != null) {
for(Element element : error.getChildren()) {
if (!element.getName().equals("text")) {
return element;
}
}
}
return null;
}
} }