mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-14 06:51:08 +01:00
Merge branch '4.2' into master-paul-merged
This commit is contained in:
commit
431e5b3c67
434 changed files with 1770 additions and 1517 deletions
|
|
@ -96,7 +96,7 @@ public final class EntityCapsManager extends Manager {
|
|||
|
||||
private static boolean autoEnableEntityCaps = true;
|
||||
|
||||
private static Map<XMPPConnection, EntityCapsManager> instances = new WeakHashMap<>();
|
||||
private static final Map<XMPPConnection, EntityCapsManager> instances = new WeakHashMap<>();
|
||||
|
||||
private static final StanzaFilter PRESENCES_WITH_CAPS = new AndFilter(new StanzaTypeFilter(Presence.class), new StanzaExtensionFilter(
|
||||
ELEMENT, NAMESPACE));
|
||||
|
|
@ -104,7 +104,7 @@ public final class EntityCapsManager extends Manager {
|
|||
/**
|
||||
* Map of "node + '#' + hash" to DiscoverInfo data
|
||||
*/
|
||||
static final LruCache<String, DiscoverInfo> CAPS_CACHE = new LruCache<String, DiscoverInfo>(1000);
|
||||
static final LruCache<String, DiscoverInfo> CAPS_CACHE = new LruCache<>(1000);
|
||||
|
||||
/**
|
||||
* Map of Full JID -> DiscoverInfo/null. In case of c2s connection the
|
||||
|
|
@ -415,8 +415,8 @@ public final class EntityCapsManager extends Manager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get our own caps version. The version depends on the enabled features. A
|
||||
* caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='
|
||||
* Get our own caps version. The version depends on the enabled features.
|
||||
* A caps version looks like '66/0NaeaBKkwk85efJTGmU47vXI='
|
||||
*
|
||||
* @return our own caps version
|
||||
*/
|
||||
|
|
@ -495,7 +495,7 @@ public final class EntityCapsManager extends Manager {
|
|||
if (connection != null)
|
||||
JID_TO_NODEVER_CACHE.put(connection.getUser(), new NodeVerHash(entityNode, currentCapsVersion));
|
||||
|
||||
final List<Identity> identities = new LinkedList<Identity>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
|
||||
final List<Identity> identities = new LinkedList<>(ServiceDiscoveryManager.getInstanceFor(connection).getIdentities());
|
||||
sdm.setNodeInformationProvider(localNodeVer, new AbstractNodeInformationProvider() {
|
||||
List<String> features = sdm.getFeatures();
|
||||
List<ExtensionElement> packetExtensions = sdm.getExtendedInfoAsList();
|
||||
|
|
@ -529,7 +529,7 @@ public final class EntityCapsManager extends Manager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Verify DisoverInfo and Caps Node as defined in XEP-0115 5.4 Processing
|
||||
* Verify DiscoverInfo and Caps Node as defined in XEP-0115 5.4 Processing
|
||||
* Method.
|
||||
*
|
||||
* @see <a href="http://xmpp.org/extensions/xep-0115.html#ver-proc">XEP-0115
|
||||
|
|
@ -567,7 +567,7 @@ public final class EntityCapsManager extends Manager {
|
|||
* @return true if the stanza(/packet) extensions is ill-formed
|
||||
*/
|
||||
protected static boolean verifyPacketExtensions(DiscoverInfo info) {
|
||||
List<FormField> foundFormTypes = new LinkedList<FormField>();
|
||||
List<FormField> foundFormTypes = new LinkedList<>();
|
||||
for (ExtensionElement pe : info.getExtensions()) {
|
||||
if (pe.getNamespace().equals(DataForm.NAMESPACE)) {
|
||||
DataForm df = (DataForm) pe;
|
||||
|
|
@ -626,10 +626,9 @@ public final class EntityCapsManager extends Manager {
|
|||
// [NAME]. Note that each slash is included even if the LANG or
|
||||
// NAME is not included (in accordance with XEP-0030, the category and
|
||||
// type MUST be included.
|
||||
SortedSet<DiscoverInfo.Identity> sortedIdentities = new TreeSet<DiscoverInfo.Identity>();
|
||||
SortedSet<DiscoverInfo.Identity> sortedIdentities = new TreeSet<>();
|
||||
|
||||
for (DiscoverInfo.Identity i : discoverInfo.getIdentities())
|
||||
sortedIdentities.add(i);
|
||||
sortedIdentities.addAll(discoverInfo.getIdentities());
|
||||
|
||||
// 3. For each identity, append the 'category/type/lang/name' to S,
|
||||
// followed by the '<' character.
|
||||
|
|
@ -645,7 +644,7 @@ public final class EntityCapsManager extends Manager {
|
|||
}
|
||||
|
||||
// 4. Sort the supported service discovery features.
|
||||
SortedSet<String> features = new TreeSet<String>();
|
||||
SortedSet<String> features = new TreeSet<>();
|
||||
for (Feature f : discoverInfo.getFeatures())
|
||||
features.add(f.getVar());
|
||||
|
||||
|
|
@ -664,7 +663,7 @@ public final class EntityCapsManager extends Manager {
|
|||
// 6. If the service discovery information response includes
|
||||
// XEP-0128 data forms, sort the forms by the FORM_TYPE (i.e.,
|
||||
// by the XML character data of the <value/> element).
|
||||
SortedSet<FormField> fs = new TreeSet<FormField>(new Comparator<FormField>() {
|
||||
SortedSet<FormField> fs = new TreeSet<>(new Comparator<FormField>() {
|
||||
@Override
|
||||
public int compare(FormField f1, FormField f2) {
|
||||
return f1.getVariable().compareTo(f2.getVariable());
|
||||
|
|
@ -725,10 +724,8 @@ public final class EntityCapsManager extends Manager {
|
|||
}
|
||||
|
||||
private static void formFieldValuesToCaps(List<String> i, StringBuilder sb) {
|
||||
SortedSet<String> fvs = new TreeSet<String>();
|
||||
for (String s : i) {
|
||||
fvs.add(s);
|
||||
}
|
||||
SortedSet<String> fvs = new TreeSet<>();
|
||||
fvs.addAll(i);
|
||||
for (String fv : fvs) {
|
||||
sb.append(fv);
|
||||
sb.append('<');
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
|
|||
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
|
||||
private static final Logger LOGGER = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName());
|
||||
|
||||
private File cacheDir;
|
||||
private StringEncoder filenameEncoder;
|
||||
private final File cacheDir;
|
||||
private final StringEncoder filenameEncoder;
|
||||
|
||||
/**
|
||||
* Creates a new SimpleDirectoryPersistentCache Object. Make sure that the
|
||||
|
|
@ -108,13 +108,15 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
|
||||
private File getFileFor(String nodeVer) {
|
||||
String filename = filenameEncoder.encode(nodeVer);
|
||||
File nodeFile = new File(cacheDir, filename);
|
||||
return nodeFile;
|
||||
return new File(cacheDir, filename);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void emptyCache() {
|
||||
File[] files = cacheDir.listFiles();
|
||||
if (files == null) {
|
||||
return;
|
||||
}
|
||||
for (File f : files) {
|
||||
f.delete();
|
||||
}
|
||||
|
|
@ -145,7 +147,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
*/
|
||||
private static DiscoverInfo restoreInfoFromFile(File file) throws Exception {
|
||||
DataInputStream dis = new DataInputStream(new FileInputStream(file));
|
||||
String fileContent = null;
|
||||
String fileContent;
|
||||
try {
|
||||
fileContent = dis.readUTF();
|
||||
} finally {
|
||||
|
|
@ -154,8 +156,6 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
if (fileContent == null) {
|
||||
return null;
|
||||
}
|
||||
DiscoverInfo info = (DiscoverInfo) PacketParserUtils.parseStanza(fileContent);
|
||||
|
||||
return info;
|
||||
return PacketParserUtils.parseStanza(fileContent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ public class CapsExtensionProvider extends ExtensionElementProvider<CapsExtensio
|
|||
@Override
|
||||
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
|
||||
SmackException {
|
||||
String hash = null;
|
||||
String version = null;
|
||||
String node = null;
|
||||
String hash, version, node;
|
||||
if (parser.getEventType() == XmlPullParser.START_TAG
|
||||
&& parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
|
||||
hash = parser.getAttributeValue(null, "hash");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue