From d963d95e305ad7d9485912e8d33827cd37d54e61 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 16 Sep 2019 14:20:15 +0200 Subject: [PATCH] fixed some minor NPE --- .../services/XmppConnectionService.java | 41 ++++++++++--------- .../ui/ConversationFragment.java | 3 +- .../adapter/ChannelSearchResultAdapter.java | 4 +- .../ui/util/MucDetailsContextMenuHelper.java | 6 +-- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 2e90422fa..e51c83a6a 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2551,6 +2551,9 @@ public class XmppConnectionService extends Service { final MucOptions mucOptions = conversation.getMucOptions(); if (mucOptions.nonanonymous() && !mucOptions.membersOnly() && !conversation.getBooleanAttribute("accept_non_anonymous", false)) { + synchronized (account.inProgressConferenceJoins) { + account.inProgressConferenceJoins.remove(conversation); + } mucOptions.setError(MucOptions.Error.NON_ANONYMOUS); updateConversationUi(); if (onConferenceJoined != null) { @@ -2990,31 +2993,31 @@ public class XmppConnectionService extends Service { @Override public void onIqPacketReceived(Account account, IqPacket packet) { if (packet.getType() == IqPacket.TYPE.RESULT) { + final MucOptions mucOptions = conversation.getMucOptions(); + final Bookmark bookmark = conversation.getBookmark(); + final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName()); - final MucOptions mucOptions = conversation.getMucOptions(); - final Bookmark bookmark = conversation.getBookmark(); - final boolean sameBefore = StringUtils.equals(bookmark == null ? null : bookmark.getBookmarkName(), mucOptions.getName()); + if (mucOptions.updateConfiguration(new ServiceDiscoveryResult(packet))) { + Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc configuration changed for " + conversation.getJid().asBareJid()); + updateConversation(conversation); + } - if (mucOptions.updateConfiguration(new ServiceDiscoveryResult(packet))) { - Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": muc configuration changed for " + conversation.getJid().asBareJid()); - updateConversation(conversation); - } - - if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) { - if (bookmark.setBookmarkName(StringUtils.nullOnEmpty(mucOptions.getName()))) { - pushBookmarks(account); - } - } + if (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) { + if (bookmark.setBookmarkName(StringUtils.nullOnEmpty(mucOptions.getName()))) { + pushBookmarks(account); + } + } - if (callback != null) { - callback.onConferenceConfigurationFetched(conversation); - } + if (callback != null) { + callback.onConferenceConfigurationFetched(conversation); + } - - updateConversationUi(); - } else if (packet.getType() == IqPacket.TYPE.ERROR) { + updateConversationUi(); + } else if (packet.getType() == IqPacket.TYPE.TIMEOUT) { + Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received timeout waiting for conference configuration fetch"); + } else { if (callback != null) { callback.onFetchFailed(conversation, packet.getError()); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 3b4842437..161e5bf42 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1552,7 +1552,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke intent = GeoHelper.getFetchIntent(activity); break; } - if (intent.resolveActivity(getActivity().getPackageManager()) != null) { + final Context context = getActivity(); + if (context != null && intent.resolveActivity(context.getPackageManager()) != null) { if (chooser) { startActivityForResult( Intent.createChooser(intent, getString(R.string.perform_action_with)), diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java index 03f09f70c..d39910cfd 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/ChannelSearchResultAdapter.java @@ -16,6 +16,7 @@ import eu.siacs.conversations.R; import eu.siacs.conversations.databinding.SearchResultItemBinding; import eu.siacs.conversations.http.services.MuclumbusService; import eu.siacs.conversations.ui.util.AvatarWorkerTask; +import rocks.xmpp.addr.Jid; public class ChannelSearchResultAdapter extends ListAdapter { @@ -61,7 +62,8 @@ public class ChannelSearchResultAdapter extends ListAdapter listener.onChannelSearchResult(searchResult)); } diff --git a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java index 04198e781..28c869f1e 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java +++ b/src/main/java/eu/siacs/conversations/ui/util/MucDetailsContextMenuHelper.java @@ -147,6 +147,8 @@ public final class MucDetailsContextMenuHelper { activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.ADMIN, onAffiliationChanged); return true; case R.id.give_membership: + case R.id.remove_admin_privileges: + case R.id.revoke_owner_privileges: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); return true; case R.id.give_owner_privileges: @@ -155,10 +157,6 @@ public final class MucDetailsContextMenuHelper { case R.id.remove_membership: activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.NONE, onAffiliationChanged); return true; - case R.id.remove_admin_privileges: - case R.id.revoke_owner_privileges: - activity.xmppConnectionService.changeAffiliationInConference(conversation, jid, MucOptions.Affiliation.MEMBER, onAffiliationChanged); - return true; case R.id.remove_from_room: removeFromRoom(user, activity, onAffiliationChanged); return true;