Java 类org.jivesoftware.smackx.caps.EntityCapsManager 实例源码

项目:desktopclient-java    文件:Client.java   
private Client(Control control, Path appDir) {
    mControl = control;
    //mLimited = limited;

    mMessageSender = new KonMessageSender(this);

    // enable Smack debugging (print raw XML packets)
    //SmackConfiguration.DEBUG = true;

    mFeatures = new EnumMap<>(FeatureDiscovery.Feature.class);

    // setting caps cache
    // NOTE: the cache is actually not used right now: only client entity requests (==full JIDs)
    // can be cached
    File cacheDir = appDir.resolve(CAPS_CACHE_DIR).toFile();
    if (cacheDir.mkdir())
        LOGGER.info("created caps cache directory");

    if (!cacheDir.isDirectory()) {
        LOGGER.warning("invalid cache directory: "+cacheDir);
        return;
    }

    EntityCapsManager.setPersistentCache(
            new SimpleDirectoryPersistentCache(cacheDir));
}
项目:Smack    文件:CapsExtensionProvider.java   
public CapsExtension parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException,
        SmackException {
    String hash = null;
    String version = null;
    String node = null;
    if (parser.getEventType() == XmlPullParser.START_TAG
            && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT)) {
        hash = parser.getAttributeValue(null, "hash");
        version = parser.getAttributeValue(null, "ver");
        node = parser.getAttributeValue(null, "node");
    } else {
        throw new SmackException("Malformed Caps element");
    }

    parser.next();

    if (!(parser.getEventType() == XmlPullParser.END_TAG
            && parser.getName().equalsIgnoreCase(EntityCapsManager.ELEMENT))) {
        throw new SmackException("Malformed nested Caps element");
    }

    if (hash != null && version != null && node != null) {
        return new CapsExtension(node, version, hash);
    } else {
        throw new SmackException("Caps elment with missing attributes. Attributes: hash=" + hash + " version="
                        + version + " node=" + node);
    }
}
项目:Smack    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered information of a given XMPP entity addressed by its JID.
 * Use null as entityID to query the server
 * 
 * @param entityID the address of the XMPP entity or null.
 * @return the discovered information.
 * @throws XMPPErrorException 
 * @throws NoResponseException 
 * @throws NotConnectedException 
 */
public DiscoverInfo discoverInfo(String entityID) throws NoResponseException, XMPPErrorException, NotConnectedException {
    if (entityID == null)
        return discoverInfo(null, null);

    // Check if the have it cached in the Entity Capabilities Manager
    DiscoverInfo info = EntityCapsManager.getDiscoverInfoByUser(entityID);

    if (info != null) {
        // We were able to retrieve the information from Entity Caps and
        // avoided a disco request, hurray!
        return info;
    }

    // Try to get the newest node#version if it's known, otherwise null is
    // returned
    EntityCapsManager.NodeVerHash nvh = EntityCapsManager.getNodeVerHashByJid(entityID);

    // Discover by requesting the information from the remote entity
    // Note that wee need to use NodeVer as argument for Node if it exists
    info = discoverInfo(entityID, nvh != null ? nvh.getNodeVer() : null);

    // If the node version is known, store the new entry.
    if (nvh != null) {
        if (EntityCapsManager.verifyDiscoverInfoVersion(nvh.getVer(), nvh.getHash(), info))
            EntityCapsManager.addDiscoverInfoByNode(nvh.getNodeVer(), info);
    }

    return info;
}
项目:maxs    文件:XMPPEntityCapsCache.java   
private XMPPEntityCapsCache(Context context) {
    mXMPPEntityCapsTable = XMPPEntityCapsTable.getInstance(context);
    EntityCapsManager.setPersistentCache(this);

    mStorageLowReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            LOG.i("ACTION_DEVICE_STORAGE_LOW received, emptying EntityCapsCache");
            emptyCache();
        }
    };
    context.registerReceiver(mStorageLowReceiver, new IntentFilter(
            Intent.ACTION_DEVICE_STORAGE_LOW));
}
项目:Smack    文件:ServiceDiscoveryManager.java   
/**
 * Loads the ServiceDiscoveryManager with an EntityCapsManger that speeds up certain lookups.
 * 
 * @param manager
 */
public void setEntityCapsManager(EntityCapsManager manager) {
    capsManager = manager;
}