aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java7
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java15
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java12
-rw-r--r--src/main/java/de/pixart/messenger/utils/StringUtils.java46
4 files changed, 62 insertions, 18 deletions
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 7fc2e2d50..bbfab612d 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -26,7 +26,6 @@ import de.pixart.messenger.crypto.axolotl.AxolotlService;
import de.pixart.messenger.crypto.axolotl.NotEncryptedForThisDeviceException;
import de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage;
import de.pixart.messenger.entities.Account;
-import de.pixart.messenger.entities.Bookmark;
import de.pixart.messenger.entities.Contact;
import de.pixart.messenger.entities.Conversation;
import de.pixart.messenger.entities.Message;
@@ -759,12 +758,6 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
if (conversation.getMucOptions().setSubject(subject)) {
mXmppConnectionService.updateConversation(conversation);
}
- final Bookmark bookmark = conversation.getBookmark();
- if (bookmark != null && bookmark.getBookmarkName() == null) {
- if (bookmark.setBookmarkName(subject)) {
- mXmppConnectionService.pushBookmarks(account);
- }
- }
mXmppConnectionService.updateConversationUi();
return;
}
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 95acb6bf0..ceb37a2fd 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -125,6 +125,7 @@ import de.pixart.messenger.utils.ReplacingSerialSingleThreadExecutor;
import de.pixart.messenger.utils.ReplacingTaskManager;
import de.pixart.messenger.utils.Resolver;
import de.pixart.messenger.utils.SerialSingleThreadExecutor;
+import de.pixart.messenger.utils.StringUtils;
import de.pixart.messenger.utils.WakeLockHelper;
import de.pixart.messenger.utils.XmppUri;
import de.pixart.messenger.xml.Element;
@@ -2699,13 +2700,25 @@ public class XmppConnectionService extends Service {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
- if (conversation.getMucOptions().updateConfiguration(new ServiceDiscoveryResult(packet))) {
+ 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 (bookmark != null && (sameBefore || bookmark.getBookmarkName() == null)) {
+ if (bookmark.setBookmarkName(mucOptions.getName())) {
+ pushBookmarks(account);
+ }
+ }
+
if (callback != null) {
callback.onConferenceConfigurationFetched(conversation);
}
+
updateConversationUi();
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
if (callback != null) {
diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
index 8e8178609..8a8099060 100644
--- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java
@@ -60,6 +60,7 @@ import de.pixart.messenger.utils.XmppUri;
import rocks.xmpp.addr.Jid;
import static de.pixart.messenger.entities.Bookmark.printableValue;
+import static de.pixart.messenger.utils.StringUtils.changed;
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConfigurationPushed, TextWatcher {
public static final String ACTION_VIEW_MUC = "view_muc";
@@ -410,14 +411,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
}
- private static String blankOnNull(String input) {
- return input == null ? "" : input;
- }
-
- private static boolean changed(String one, String two) {
- return !blankOnNull(one).equals(blankOnNull(two));
- }
-
@Override
protected String getShareableUri(boolean http) {
if (mConversation != null) {
@@ -595,8 +588,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
protected void saveAsBookmark() {
- xmppConnectionService.saveConversationAsBookmark(mConversation,
- mConversation.getMucOptions().getSubject());
+ xmppConnectionService.saveConversationAsBookmark(mConversation, mConversation.getMucOptions().getName());
updateView();
}
diff --git a/src/main/java/de/pixart/messenger/utils/StringUtils.java b/src/main/java/de/pixart/messenger/utils/StringUtils.java
new file mode 100644
index 000000000..3980e9a4a
--- /dev/null
+++ b/src/main/java/de/pixart/messenger/utils/StringUtils.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2018, Daniel Gultsch All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package de.pixart.messenger.utils;
+
+public class StringUtils {
+
+ private static String blankOnNull(String input) {
+ return input == null ? "" : input;
+ }
+
+ public static boolean equals(String one, String two) {
+ return blankOnNull(one).equals(blankOnNull(two));
+ }
+
+ public static boolean changed(String one, String two) {
+ return !equals(one, two);
+ }
+
+}