diff --git a/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/client/XMPPClient.java b/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/client/XMPPClient.java index 7c9c4451485c5..feefba974c287 100644 --- a/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/client/XMPPClient.java +++ b/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/client/XMPPClient.java @@ -62,7 +62,7 @@ public class XMPPClient implements IncomingChatMessageListener, ConnectionListen private @Nullable HttpFileUploadManager httpFileUploadManager; private Set subscribers = new HashSet<>(); private final XMPPClientEventlistener eventListener; - private String username = ""; + private String nickname = ""; public XMPPClient(XMPPClientEventlistener eventListener) { this.eventListener = eventListener; @@ -78,7 +78,7 @@ public void unsubscribe(XMPPClientMessageSubscriber channel) { subscribers.remove(channel); } - public void connect(String host, Integer port, String login, String domain, String password, + public void connect(String host, Integer port, String login, String nick, String domain, String password, SecurityMode securityMode) throws XMPPClientConfigException, XMPPClientException { disconnect(); String serverHost = domain; @@ -86,7 +86,12 @@ public void connect(String host, Integer port, String login, String domain, Stri serverHost = host; } - username = login; + if (!nick.isEmpty()) { + nickname = nick; + } else { + nickname = login; + } + XMPPTCPConnectionConfiguration config; try { config = XMPPTCPConnectionConfiguration.builder() // @@ -171,7 +176,7 @@ public void sendGroupMessage(String to, String message) { MultiUserChat chat = multiUserChatManager.getMultiUserChat(jid); if (!chat.isJoined()) { - chat.join(Resourcepart.from(username)); + chat.join(Resourcepart.from(nickname)); } chat.sendMessage(message); diff --git a/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientConfiguration.java b/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientConfiguration.java index b2f0bfdef5583..ac1f9c08af40f 100644 --- a/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientConfiguration.java +++ b/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientConfiguration.java @@ -26,6 +26,7 @@ public class XMPPClientConfiguration { public @Nullable String host; public Integer port = 5222; public String username = ""; + public String nickname = ""; public String password = ""; public String domain = ""; public String securityMode = SecurityMode.required.toString(); diff --git a/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientHandler.java b/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientHandler.java index 3c7cfc2dbfd3d..3b1f381e8b7b5 100644 --- a/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientHandler.java +++ b/bundles/org.openhab.binding.xmppclient/src/main/java/org/openhab/binding/xmppclient/internal/handler/XMPPClientHandler.java @@ -95,8 +95,8 @@ private void doConnect() { } try { - xmppClient.connect(Objects.requireNonNullElse(config.host, ""), config.port, config.username, config.domain, - config.password, SecurityMode.valueOf(config.securityMode)); + xmppClient.connect(Objects.requireNonNullElse(config.host, ""), config.port, config.username, + config.nickname, config.domain, config.password, SecurityMode.valueOf(config.securityMode)); updateStatus(ThingStatus.ONLINE); } catch (XMPPClientConfigException e) { logger.debug("XMPP connection error", e); diff --git a/bundles/org.openhab.binding.xmppclient/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.xmppclient/src/main/resources/OH-INF/thing/thing-types.xml index ea506032b3c2e..db15e6ca45c83 100644 --- a/bundles/org.openhab.binding.xmppclient/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.xmppclient/src/main/resources/OH-INF/thing/thing-types.xml @@ -12,6 +12,11 @@ The XMPP Username (the left side of JID, e.g. user for JID user@example.com) + + + The XMPP Nickname to use in multi user chats. (Defaults to Username) + true + The XMPP Domain (the right side of JID, e.g. example.com for JID user@example.com)