aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-06-29 22:24:48 +0200
committerChristian Schneppe <christian@pix-art.de>2018-06-29 22:24:48 +0200
commitd9d6909c69b57b81380798fabe3a4e2d3d347cb1 (patch)
treec00e5f5558b51e6d15f48c0b99227a0b0819d4d0 /src/main/java/de/pixart/messenger
parentd269fd47eecc7b4f34634118926a19bc084d07a4 (diff)
fixed some extended muc info handling. match what ejabberd does
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Conversation.java9
-rw-r--r--src/main/java/de/pixart/messenger/entities/MucOptions.java25
2 files changed, 21 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Conversation.java b/src/main/java/de/pixart/messenger/entities/Conversation.java
index 4729eb976..18a20532a 100644
--- a/src/main/java/de/pixart/messenger/entities/Conversation.java
+++ b/src/main/java/de/pixart/messenger/entities/Conversation.java
@@ -920,7 +920,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
return false;
}
} else {
- String prev = this.attributes.getString(key);
+ final String prev = this.attributes.optString(key, null);
this.attributes.put(key, value);
return !value.equals(prev);
}
@@ -940,7 +940,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
this.attributes.put(key, array);
return true;
} catch (JSONException e) {
- e.printStackTrace();
return false;
}
}
@@ -948,11 +947,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
public String getAttribute(String key) {
synchronized (this.attributes) {
- try {
- return this.attributes.getString(key);
- } catch (JSONException e) {
- return null;
- }
+ return this.attributes.optString(key, null);
}
}
diff --git a/src/main/java/de/pixart/messenger/entities/MucOptions.java b/src/main/java/de/pixart/messenger/entities/MucOptions.java
index ecf016c48..39afe65a6 100644
--- a/src/main/java/de/pixart/messenger/entities/MucOptions.java
+++ b/src/main/java/de/pixart/messenger/entities/MucOptions.java
@@ -2,6 +2,7 @@ package de.pixart.messenger.entities;
import android.annotation.SuppressLint;
import android.support.annotation.NonNull;
+import android.util.Log;
import java.util.ArrayList;
import java.util.Collections;
@@ -377,9 +378,10 @@ public class MucOptions {
public boolean updateConfiguration(ServiceDiscoveryResult serviceDiscoveryResult) {
this.serviceDiscoveryResult = serviceDiscoveryResult;
String name;
- Field roomInfoName = getRoomInfoForm().getFieldByName("muc#roominfo_name");
- if (roomInfoName != null) {
- name = roomInfoName.getValue();
+ Field roomConfigName = getRoomInfoForm().getFieldByName("muc#roomconfig_roomname");
+ if (roomConfigName != null) {
+ Log.d(Config.LOGTAG, "value of room config name " + roomConfigName.getValue());
+ name = roomConfigName.getValue();
} else {
List<ServiceDiscoveryResult.Identity> identities = serviceDiscoveryResult.getIdentities();
String identityName = identities.size() > 0 ? identities.get(0).getName() : null;
@@ -414,7 +416,7 @@ public class MucOptions {
}
public boolean canInvite() {
- Field field = getRoomInfoForm().getFieldByName("muc#roominfo_allowinvites");
+ Field field = getRoomInfoForm().getFieldByName("muc#roomconfig_allowinvites");
return !membersOnly() || self.getRole().ranks(Role.MODERATOR) || (field != null && "1".equals(field.getValue()));
}
@@ -424,8 +426,19 @@ public class MucOptions {
}
public boolean allowPm() {
- Field field = getRoomInfoForm().getFieldByName("muc#roominfo_allowpm");
- return field != null && "1".equals(field.getValue());
+ final Field field = getRoomInfoForm().getFieldByName("muc#roomconfig_allowpm");
+ if (field == null) {
+ return true; //fall back if field does not exists
+ }
+ if ("anyone".equals(field.getValue())) {
+ return true;
+ } else if ("participants".equals(field.getValue())) {
+ return self.getRole().ranks(Role.PARTICIPANT);
+ } else if ("moderators".equals(field.getValue())) {
+ return self.getRole().ranks(Role.MODERATOR);
+ } else {
+ return false;
+ }
}
public boolean participating() {