Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartkk0 <thebartkk@gmail.com>2022-03-09 17:52:47 +0300
committerDaniel Lublin <daniel@lublin.se>2022-03-10 15:06:42 +0300
commit70b22b613331c778b39e196ec9ff6cc02f0814eb (patch)
treea32f2c058718f4102a81cca8addfe0611ec9e9c8
parent9e10cafaeaf314f8cdc40a5fc7108f9ad1cf0df2 (diff)
Implement ServerSettings
-rw-r--r--src/main/java/se/lublin/humla/HumlaService.java10
-rw-r--r--src/main/java/se/lublin/humla/IHumlaSession.java7
-rw-r--r--src/main/java/se/lublin/humla/model/IServerSettings.java15
-rw-r--r--src/main/java/se/lublin/humla/model/ServerSettings.java51
-rw-r--r--src/main/java/se/lublin/humla/protocol/ModelHandler.java12
5 files changed, 95 insertions, 0 deletions
diff --git a/src/main/java/se/lublin/humla/HumlaService.java b/src/main/java/se/lublin/humla/HumlaService.java
index 1600587..6715316 100644
--- a/src/main/java/se/lublin/humla/HumlaService.java
+++ b/src/main/java/se/lublin/humla/HumlaService.java
@@ -55,6 +55,7 @@ import se.lublin.humla.model.IChannel;
import se.lublin.humla.model.IUser;
import se.lublin.humla.model.Message;
import se.lublin.humla.model.Server;
+import se.lublin.humla.model.ServerSettings;
import se.lublin.humla.model.TalkState;
import se.lublin.humla.model.User;
import se.lublin.humla.model.WhisperTarget;
@@ -1180,6 +1181,15 @@ public class HumlaService extends Service implements IHumlaService, IHumlaSessio
return null;
}
+ @Override
+ public ServerSettings getServerSettings() {
+ try {
+ return getModelHandler().getServerSettings();
+ } catch (NotSynchronizedException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
/**
* The current connection state of the service.
*/
diff --git a/src/main/java/se/lublin/humla/IHumlaSession.java b/src/main/java/se/lublin/humla/IHumlaSession.java
index 2162a0f..999db0a 100644
--- a/src/main/java/se/lublin/humla/IHumlaSession.java
+++ b/src/main/java/se/lublin/humla/IHumlaSession.java
@@ -5,6 +5,7 @@ import java.util.List;
import se.lublin.humla.model.IChannel;
import se.lublin.humla.model.IUser;
import se.lublin.humla.model.Message;
+import se.lublin.humla.model.ServerSettings;
import se.lublin.humla.model.WhisperTarget;
import se.lublin.humla.net.HumlaUDPMessageType;
import se.lublin.humla.util.VoiceTargetMode;
@@ -208,4 +209,10 @@ public interface IHumlaSession {
* @return the set whisper target, or null if the user is not whispering.
*/
WhisperTarget getWhisperTarget();
+
+ /**
+ * Gets the current server settings.
+ * @return Settings of the current server.
+ */
+ ServerSettings getServerSettings();
}
diff --git a/src/main/java/se/lublin/humla/model/IServerSettings.java b/src/main/java/se/lublin/humla/model/IServerSettings.java
new file mode 100644
index 0000000..7663cec
--- /dev/null
+++ b/src/main/java/se/lublin/humla/model/IServerSettings.java
@@ -0,0 +1,15 @@
+package se.lublin.humla.model;
+
+public interface IServerSettings {
+ boolean getAllowHtml();
+
+ int getMessageLength();
+
+ int getImageMessageLength();
+
+ int getMaxBandwidth();
+
+ int getMaxUsers();
+
+ String getWelcomeText();
+}
diff --git a/src/main/java/se/lublin/humla/model/ServerSettings.java b/src/main/java/se/lublin/humla/model/ServerSettings.java
new file mode 100644
index 0000000..5b8f6e3
--- /dev/null
+++ b/src/main/java/se/lublin/humla/model/ServerSettings.java
@@ -0,0 +1,51 @@
+package se.lublin.humla.model;
+
+import se.lublin.humla.protobuf.Mumble;
+
+public class ServerSettings implements IServerSettings{
+ private boolean mAllowHtml;
+ private int mMessageLength;
+ private int mImageMessageLength;
+ private int mMaxBandwidth;
+ private int mMaxUsers;
+ private String mWelcomeText;
+
+ public ServerSettings(Mumble.ServerConfig msg){
+ mAllowHtml = msg.getAllowHtml();
+ mMessageLength = msg.getMessageLength();
+ mImageMessageLength = msg.getImageMessageLength();
+ mMaxBandwidth = msg.getMaxBandwidth();
+ mMaxUsers = msg.getMaxUsers();
+ mWelcomeText = msg.getWelcomeText();
+ }
+
+ @Override
+ public boolean getAllowHtml() {
+ return mAllowHtml;
+ }
+
+ @Override
+ public int getMessageLength() {
+ return mMessageLength;
+ }
+
+ @Override
+ public int getImageMessageLength() {
+ return mImageMessageLength;
+ }
+
+ @Override
+ public int getMaxBandwidth() {
+ return mMaxBandwidth;
+ }
+
+ @Override
+ public int getMaxUsers() {
+ return mMaxUsers;
+ }
+
+ @Override
+ public String getWelcomeText() {
+ return mWelcomeText;
+ }
+}
diff --git a/src/main/java/se/lublin/humla/protocol/ModelHandler.java b/src/main/java/se/lublin/humla/protocol/ModelHandler.java
index d79e0ef..f8d18bc 100644
--- a/src/main/java/se/lublin/humla/protocol/ModelHandler.java
+++ b/src/main/java/se/lublin/humla/protocol/ModelHandler.java
@@ -30,7 +30,9 @@ import java.util.Map;
import se.lublin.humla.R;
import se.lublin.humla.model.Channel;
+import se.lublin.humla.model.IServerSettings;
import se.lublin.humla.model.Message;
+import se.lublin.humla.model.ServerSettings;
import se.lublin.humla.model.User;
import se.lublin.humla.protobuf.Mumble;
import se.lublin.humla.util.HumlaLogger;
@@ -52,6 +54,7 @@ public class ModelHandler extends HumlaTCPMessageListener.Stub {
private final List<Integer> mLocalIgnoreHistory;
private final IHumlaObserver mObserver;
private final HumlaLogger mLogger;
+ private ServerSettings mServerSettings;
private int mPermissions;
private int mSession;
@@ -75,6 +78,10 @@ public class ModelHandler extends HumlaTCPMessageListener.Stub {
return mUsers.get(session);
}
+ public ServerSettings getServerSettings() {
+ return mServerSettings;
+ }
+
/**
* Creates a stub channel with the given ID.
* Useful for keeping user references when we get a UserState message before a ChannelState.
@@ -491,4 +498,9 @@ public class ModelHandler extends HumlaTCPMessageListener.Stub {
mSession = msg.getSession();
mLogger.logInfo(msg.getWelcomeText());
}
+
+ @Override
+ public void messageServerConfig(Mumble.ServerConfig msg) {
+ mServerSettings = new ServerSettings(msg);
+ }
}