mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Merge branch '4.0'
Conflicts: build.gradle smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
This commit is contained in:
commit
3e18a23e47
4 changed files with 46 additions and 29 deletions
|
@ -214,6 +214,12 @@ subprojects {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
subprojects*.jar {
|
||||||
|
manifest {
|
||||||
|
from sharedManifest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def getGitCommit() {
|
def getGitCommit() {
|
||||||
def dotGit = new File("$projectDir/.git")
|
def dotGit = new File("$projectDir/.git")
|
||||||
if (!dotGit.isDirectory()) return 'non-git build'
|
if (!dotGit.isDirectory()) return 'non-git build'
|
||||||
|
|
|
@ -29,6 +29,7 @@ public enum SASLError {
|
||||||
invalid_authzid,
|
invalid_authzid,
|
||||||
invalid_mechanism,
|
invalid_mechanism,
|
||||||
malformed_request,
|
malformed_request,
|
||||||
|
mechanism_too_weak,
|
||||||
not_authorized,
|
not_authorized,
|
||||||
temporary_auth_failure;
|
temporary_auth_failure;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ import org.jxmpp.util.XmppStringUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A MultipleRecipientManager allows to send packets to multiple recipients by making use of
|
* A MultipleRecipientManager allows to send packets to multiple recipients by making use of
|
||||||
|
@ -44,7 +46,9 @@ import java.util.List;
|
||||||
* @author Gaston Dombiak
|
* @author Gaston Dombiak
|
||||||
*/
|
*/
|
||||||
public class MultipleRecipientManager {
|
public class MultipleRecipientManager {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = Logger.getLogger(MultipleRecipientManager.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a cache to hold the 100 most recently accessed elements for a period of
|
* Create a cache to hold the 100 most recently accessed elements for a period of
|
||||||
* 24 hours.
|
* 24 hours.
|
||||||
|
@ -204,7 +208,7 @@ public class MultipleRecipientManager {
|
||||||
*/
|
*/
|
||||||
public static MultipleRecipientInfo getMultipleRecipientInfo(Packet packet) {
|
public static MultipleRecipientInfo getMultipleRecipientInfo(Packet packet) {
|
||||||
MultipleAddresses extension = (MultipleAddresses) packet
|
MultipleAddresses extension = (MultipleAddresses) packet
|
||||||
.getExtension("addresses", "http://jabber.org/protocol/address");
|
.getExtension(MultipleAddresses.ELEMENT, MultipleAddresses.NAMESPACE);
|
||||||
return extension == null ? null : new MultipleRecipientInfo(extension);
|
return extension == null ? null : new MultipleRecipientInfo(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,34 +298,37 @@ public class MultipleRecipientManager {
|
||||||
String serviceName = connection.getServiceName();
|
String serviceName = connection.getServiceName();
|
||||||
String serviceAddress = (String) services.get(serviceName);
|
String serviceAddress = (String) services.get(serviceName);
|
||||||
if (serviceAddress == null) {
|
if (serviceAddress == null) {
|
||||||
synchronized (services) {
|
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
|
||||||
serviceAddress = (String) services.get(serviceName);
|
// Send the disco packet to the server itself
|
||||||
if (serviceAddress == null) {
|
DiscoverInfo info = sdm.discoverInfo(serviceName);
|
||||||
|
// Check if the server supports XEP-33
|
||||||
// Send the disco packet to the server itself
|
if (info.containsFeature(MultipleAddresses.NAMESPACE)) {
|
||||||
DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(
|
serviceAddress = serviceName;
|
||||||
serviceName);
|
}
|
||||||
// Check if the server supports JEP-33
|
else {
|
||||||
if (info.containsFeature("http://jabber.org/protocol/address")) {
|
// Get the disco items and send the disco packet to each server item
|
||||||
|
DiscoverItems items = sdm.discoverItems(serviceName);
|
||||||
|
for (DiscoverItems.Item item : items.getItems()) {
|
||||||
|
try {
|
||||||
|
info = sdm.discoverInfo(item.getEntityID(), item.getNode());
|
||||||
|
}
|
||||||
|
catch (XMPPErrorException|NoResponseException e) {
|
||||||
|
// Don't throw this exceptions if one of the server's items fail
|
||||||
|
LOGGER.log(Level.WARNING,
|
||||||
|
"Exception while discovering info of " + item.getEntityID()
|
||||||
|
+ " node: " + item.getNode(), e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (info.containsFeature(MultipleAddresses.NAMESPACE)) {
|
||||||
serviceAddress = serviceName;
|
serviceAddress = serviceName;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// Get the disco items and send the disco packet to each server item
|
|
||||||
DiscoverItems items = ServiceDiscoveryManager.getInstanceFor(connection).discoverItems(
|
|
||||||
serviceName);
|
|
||||||
for (DiscoverItems.Item item : items.getItems()) {
|
|
||||||
info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(
|
|
||||||
item.getEntityID(), item.getNode());
|
|
||||||
if (info.containsFeature("http://jabber.org/protocol/address")) {
|
|
||||||
serviceAddress = serviceName;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Cache the discovered information
|
|
||||||
services.put(serviceName, serviceAddress == null ? "" : serviceAddress);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Use the empty string to indicate that no service is known for this connection
|
||||||
|
serviceAddress = serviceAddress == null ? "" : serviceAddress;
|
||||||
|
// Cache the discovered information
|
||||||
|
services.put(serviceName, serviceAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "".equals(serviceAddress) ? null : serviceAddress;
|
return "".equals(serviceAddress) ? null : serviceAddress;
|
||||||
|
|
|
@ -30,6 +30,9 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class MultipleAddresses implements PacketExtension {
|
public class MultipleAddresses implements PacketExtension {
|
||||||
|
|
||||||
|
public static final String NAMESPACE = "http://jabber.org/protocol/address";
|
||||||
|
public static final String ELEMENT = "addresses";
|
||||||
|
|
||||||
public static final String BCC = "bcc";
|
public static final String BCC = "bcc";
|
||||||
public static final String CC = "cc";
|
public static final String CC = "cc";
|
||||||
public static final String NO_REPLY = "noreply";
|
public static final String NO_REPLY = "noreply";
|
||||||
|
@ -94,17 +97,17 @@ public class MultipleAddresses implements PacketExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getElementName() {
|
public String getElementName() {
|
||||||
return "addresses";
|
return ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return "http://jabber.org/protocol/address";
|
return NAMESPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toXML() {
|
public String toXML() {
|
||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append("<").append(getElementName());
|
buf.append("<").append(getElementName());
|
||||||
buf.append(" xmlns=\"").append(getNamespace()).append("\">");
|
buf.append(" xmlns=\"").append(NAMESPACE).append("\">");
|
||||||
// Loop through all the addresses and append them to the string buffer
|
// Loop through all the addresses and append them to the string buffer
|
||||||
for (Iterator<Address> i = addresses.iterator(); i.hasNext();) {
|
for (Iterator<Address> i = addresses.iterator(); i.hasNext();) {
|
||||||
Address address = (Address) i.next();
|
Address address = (Address) i.next();
|
||||||
|
|
Loading…
Reference in a new issue