mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
Merge from 3.3 branch
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13663 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
commit
dac68c64a9
163 changed files with 2304 additions and 2366 deletions
|
@ -506,7 +506,7 @@ public class EntityCapsManager {
|
|||
* @param info
|
||||
* @return true if it's valid and should be cache, false if not
|
||||
*/
|
||||
public static boolean verifyDiscvoerInfoVersion(String ver, String hash, DiscoverInfo info) {
|
||||
public static boolean verifyDiscoverInfoVersion(String ver, String hash, DiscoverInfo info) {
|
||||
// step 3.3 check for duplicate identities
|
||||
if (info.containsDuplicateIdentities())
|
||||
return false;
|
||||
|
@ -583,7 +583,7 @@ public class EntityCapsManager {
|
|||
// NAME is not included (in accordance with XEP-0030, the category and
|
||||
// type MUST be included.
|
||||
SortedSet<DiscoverInfo.Identity> sortedIdentities = new TreeSet<DiscoverInfo.Identity>();
|
||||
;
|
||||
|
||||
for (Iterator<DiscoverInfo.Identity> it = discoverInfo.getIdentities(); it.hasNext();)
|
||||
sortedIdentities.add(it.next());
|
||||
|
||||
|
@ -616,7 +616,7 @@ public class EntityCapsManager {
|
|||
// only use the data form for calculation is it has a hidden FORM_TYPE
|
||||
// field
|
||||
// see XEP-0115 5.4 step 3.6
|
||||
if (extendedInfo != null && extendedInfo.hasHiddenFromTypeField()) {
|
||||
if (extendedInfo != null && extendedInfo.hasHiddenFormTypeField()) {
|
||||
synchronized (extendedInfo) {
|
||||
// 6. If the service discovery information response includes
|
||||
// XEP-0128 data forms, sort the forms by the FORM_TYPE (i.e.,
|
||||
|
|
|
@ -24,15 +24,15 @@ public interface EntityCapsPersistentCache {
|
|||
* @param node
|
||||
* @param info
|
||||
*/
|
||||
abstract void addDiscoverInfoByNodePersistent(String node, DiscoverInfo info);
|
||||
void addDiscoverInfoByNodePersistent(String node, DiscoverInfo info);
|
||||
|
||||
/**
|
||||
* Replay the Caches data into EntityCapsManager
|
||||
*/
|
||||
abstract void replay() throws IOException;
|
||||
void replay() throws IOException;
|
||||
|
||||
/**
|
||||
* Empty the Cache
|
||||
*/
|
||||
abstract void emptyCache();
|
||||
void emptyCache();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.io.StringReader;
|
|||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.Base64Encoder;
|
||||
import org.jivesoftware.smack.util.Base32Encoder;
|
||||
import org.jivesoftware.smack.util.StringEncoder;
|
||||
import org.jivesoftware.smackx.entitycaps.EntityCapsManager;
|
||||
import org.jivesoftware.smackx.packet.DiscoverInfo;
|
||||
|
@ -47,19 +47,20 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
|
||||
|
||||
private File cacheDir;
|
||||
private StringEncoder stringEncoder;
|
||||
private StringEncoder filenameEncoder;
|
||||
|
||||
/**
|
||||
* Creates a new SimpleDirectoryPersistentCache Object. Make sure that the
|
||||
* cacheDir exists and that it's an directory.
|
||||
*
|
||||
* If your cacheDir is case insensitive then make sure to set the
|
||||
* StringEncoder to Base32.
|
||||
* <p>
|
||||
* Default filename encoder {@link Base32Encoder}, as this will work on all
|
||||
* filesystems, both case sensitive and case insensitive. It does however
|
||||
* produce longer filenames.
|
||||
*
|
||||
* @param cacheDir
|
||||
*/
|
||||
public SimpleDirectoryPersistentCache(File cacheDir) {
|
||||
this(cacheDir, Base64Encoder.getInstance());
|
||||
this(cacheDir, Base32Encoder.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,26 +68,25 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
* cacheDir exists and that it's an directory.
|
||||
*
|
||||
* If your cacheDir is case insensitive then make sure to set the
|
||||
* StringEncoder to Base32.
|
||||
* StringEncoder to {@link Base32Encoder} (which is the default).
|
||||
*
|
||||
* @param cacheDir
|
||||
* @param stringEncoder
|
||||
* @param cacheDir The directory where the cache will be stored.
|
||||
* @param filenameEncoder Encodes the node string into a filename.
|
||||
*/
|
||||
public SimpleDirectoryPersistentCache(File cacheDir, StringEncoder stringEncoder) {
|
||||
public SimpleDirectoryPersistentCache(File cacheDir, StringEncoder filenameEncoder) {
|
||||
if (!cacheDir.exists())
|
||||
throw new IllegalStateException("Cache directory \"" + cacheDir + "\" does not exist");
|
||||
if (!cacheDir.isDirectory())
|
||||
throw new IllegalStateException("Cache directory \"" + cacheDir + "\" is not a directory");
|
||||
|
||||
this.cacheDir = cacheDir;
|
||||
this.stringEncoder = stringEncoder;
|
||||
this.filenameEncoder = filenameEncoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDiscoverInfoByNodePersistent(String node, DiscoverInfo info) {
|
||||
String filename = stringEncoder.encode(node);
|
||||
String filename = filenameEncoder.encode(node);
|
||||
File nodeFile = new File(cacheDir, filename);
|
||||
|
||||
try {
|
||||
if (nodeFile.createNewFile())
|
||||
writeInfoToFile(nodeFile, info);
|
||||
|
@ -99,7 +99,7 @@ public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache
|
|||
public void replay() throws IOException {
|
||||
File[] files = cacheDir.listFiles();
|
||||
for (File f : files) {
|
||||
String node = stringEncoder.decode(f.getName());
|
||||
String node = filenameEncoder.decode(f.getName());
|
||||
DiscoverInfo info = restoreInfoFromFile(f);
|
||||
if (info == null)
|
||||
continue;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/**
|
||||
* Copyright 2009 Jonas Ådahl.
|
||||
* Copyright 2011-2013 Florian Schmaus
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue