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

项目:xmppsupport_v2    文件:ServiceDiscoveryManager.java   
/**
 * Creates a new ServiceDiscoveryManager for a given connection. This means
 * that the service manager will respond to any service discovery request
 * that the connection may receive.
 * 
 * @param connection
 *            the connection to which a ServiceDiscoveryManager is going to
 *            be created.
 */
public ServiceDiscoveryManager(Connection connection) {
    this.connection = connection;

    // For every XMPPConnection, add one EntityCapsManager.
    if (connection instanceof XMPPConnection
            && ((XMPPConnection) connection).isEntityCapsEnabled()) {
        EntityCapsManager capsManager = new EntityCapsManager(this);
        setEntityCapsManager(capsManager);
        capsManager.addCapsVerListener(new CapsPresenceRenewer(
                (XMPPConnection) connection, capsManager));
    }

    renewEntityCapsVersion();

    init();
}
项目:telegraph    文件:ServiceDiscoveryManager.java   
/**
 * Creates a new ServiceDiscoveryManager for a given connection. This means that the 
 * service manager will respond to any service discovery request that the connection may
 * receive. 
 * 
 * @param connection the connection to which a ServiceDiscoveryManager is going to be created.
 */
public ServiceDiscoveryManager(Connection connection) {
    this.connection = connection;

    // For every XMPPConnection, add one EntityCapsManager.
    if (connection instanceof XMPPConnection
            && ((XMPPConnection) connection).isEntityCapsEnabled()) {
        EntityCapsManager capsManager = new EntityCapsManager(this);
        setEntityCapsManager(capsManager);
        capsManager.addCapsVerListener(new CapsPresenceRenewer((XMPPConnection) connection, capsManager));
    }

    renewEntityCapsVersion();

    init();
}
项目:androidPN-client.    文件:SimpleDirectoryPersistentCache.java   
@Override
public void replay() throws IOException {
    File[] files = cacheDir.listFiles();
    for (File f : files) {
        String node = filenameEncoder.decode(f.getName());
        DiscoverInfo info = restoreInfoFromFile(f);
        if (info == null)
            continue;

        EntityCapsManager.addDiscoverInfoByNode(node, info);
    }
}
项目:androidPN-client.    文件:CapsExtensionProvider.java   
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException,
        XMPPException {
    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 XMPPException("Malformed Caps element");
    }

    parser.next();

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

    if (hash != null && version != null && node != null) {
        return new CapsExtension(node, version, hash);
    } else {
        throw new XMPPException("Caps elment with missing attributes");
    }
}
项目:androidPN-client.    文件:CapsExtension.java   
public String toXML() {
    String xml = "<" + EntityCapsManager.ELEMENT + " xmlns=\"" + EntityCapsManager.NAMESPACE + "\" " +
        "hash=\"" + hash + "\" " +
        "node=\"" + node + "\" " +
        "ver=\"" + ver + "\"/>";

    return xml;
}
项目:androidPN-client.    文件: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 XMPPException if the operation failed for some reason.
 */
public DiscoverInfo discoverInfo(String entityID) throws XMPPException {
    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;
}
项目:xmppsupport_v2    文件:ServiceDiscoveryManager.java   
/**
 * Returns the discovered information of a given XMPP entity addressed by
 * its JID.
 * 
 * @param entityID
 *            the address of the XMPP entity.
 * @return the discovered information.
 * @throws XMPPException
 *             if the operation failed for some reason.
 */
public DiscoverInfo discoverInfo(String entityID) throws XMPPException {
    // Check if the have it cached in the Entity Capabilities Manager
    DiscoverInfo info = discoverInfoByCaps(entityID);

    if (info != null) {
        return info;
    } else {
        // If the caps node is known, use it in the request.
        String node = null;

        if (capsManager != null) {
            // Get the newest node#version
            node = capsManager.getNodeVersionByUser(entityID);
        }

        // Check if we cached DiscoverInfo for nonCaps entity
        if (cacheNonCaps && node == null
                && nonCapsCache.containsKey(entityID)) {
            return nonCapsCache.get(entityID);
        }
        // Discover by requesting from the remote client
        info = discoverInfo(entityID, node);

        // If the node version is known, store the new entry.
        if (node != null && capsManager != null) {
            EntityCapsManager.addDiscoverInfoByNode(node, info);
        }
        // If this is a non caps entity store the discover in nonCapsCache
        // map
        else if (cacheNonCaps && node == null) {
            nonCapsCache.put(entityID, info);
        }
        return info;
    }
}
项目:xmppsupport_v2    文件:ServiceDiscoveryManager.java   
/**
 * Entity Capabilities
 */

public void setEntityCapsManager(EntityCapsManager manager) {
    capsManager = manager;
    if (connection.getCapsNode() != null && connection.getHost() != null) {
        capsManager.addUserCapsNode(connection.getHost(),
                connection.getCapsNode());
    }
    capsManager.addPacketListener(connection);
}
项目:java-bells    文件:SimpleDirectoryPersistentCache.java   
@Override
public void replay() throws IOException {
    File[] files = cacheDir.listFiles();
    for (File f : files) {
        String node = filenameEncoder.decode(f.getName());
        DiscoverInfo info = restoreInfoFromFile(f);
        if (info == null)
            continue;

        EntityCapsManager.addDiscoverInfoByNode(node, info);
    }
}
项目:java-bells    文件:CapsExtensionProvider.java   
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException,
        XMPPException {
    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 XMPPException("Malformed Caps element");
    }

    parser.next();

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

    if (hash != null && version != null && node != null) {
        return new CapsExtension(node, version, hash);
    } else {
        throw new XMPPException("Caps elment with missing attributes");
    }
}
项目:java-bells    文件:CapsExtension.java   
public String toXML() {
    String xml = "<" + EntityCapsManager.ELEMENT + " xmlns=\"" + EntityCapsManager.NAMESPACE + "\" " +
        "hash=\"" + hash + "\" " +
        "node=\"" + node + "\" " +
        "ver=\"" + ver + "\"/>";

    return xml;
}
项目:java-bells    文件: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 XMPPException if the operation failed for some reason.
 */
public DiscoverInfo discoverInfo(String entityID) throws XMPPException {
    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;
}
项目:maven-yaxim    文件:SmackableImp.java   
private void initServiceDiscovery() {
    // register connection features
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mXMPPConnection);

    // init Entity Caps manager with storage in app's cache dir
    try {
        if (capsCacheDir == null) {
            capsCacheDir = new File(mService.getCacheDir(), "entity-caps-cache");
            capsCacheDir.mkdirs();
            EntityCapsManager.setPersistentCache(new SimpleDirectoryPersistentCache(capsCacheDir));
        }
    } catch (java.io.IOException e) {
        Log.e(TAG, "Could not init Entity Caps cache: " + e.getLocalizedMessage());
    }

    // reference PingManager, set ping flood protection to 10s
    PingManager.getInstanceFor(mXMPPConnection).setPingMinimumInterval(10*1000);

    // set Version for replies
    String app_name = mService.getString(org.yaxim.androidclient.R.string.app_name);
    String build_version[] = mService.getString(org.yaxim.androidclient.R.string.build_version).split(" ");
    Version.Manager.getInstanceFor(mXMPPConnection).setVersion(
            new Version(app_name, build_version[1], "Android"));

    // reference DeliveryReceiptManager, add listener
    DeliveryReceiptManager dm = DeliveryReceiptManager.getInstanceFor(mXMPPConnection);
    dm.enableAutoReceipts();
    dm.addReceiptReceivedListener(new ReceiptReceivedListener() { // DOES NOT WORK IN CARBONS
        public void onReceiptReceived(String fromJid, String toJid, String receiptId) {
            Log.d(TAG, "got delivery receipt for " + receiptId);
            changeMessageDeliveryStatus(receiptId, ChatConstants.DS_ACKED);
        }});
}
项目:telegraph    文件:ServiceDiscoveryManager.java   
/**
  * Returns the discovered information of a given XMPP entity addressed by its JID.
  * 
  * @param entityID the address of the XMPP entity.
  * @return the discovered information.
  * @throws XMPPException if the operation failed for some reason.
  */
 public DiscoverInfo discoverInfo(String entityID) throws XMPPException {
     // Check if the have it cached in the Entity Capabilities Manager
     DiscoverInfo info = discoverInfoByCaps(entityID);

     if (info != null) {
         return info;
     } else {
         // If the caps node is known, use it in the request.
         String node = null;

         if (capsManager != null) {
             // Get the newest node#version
             node = capsManager.getNodeVersionByUser(entityID);
         }

// Check if we cached DiscoverInfo for nonCaps entity
if (cacheNonCaps 
        && node == null
        && nonCapsCache.containsKey(entityID)) {
    return nonCapsCache.get(entityID);
}
         // Discover by requesting from the remote client
         info = discoverInfo(entityID, node);

         // If the node version is known, store the new entry.
         if (node != null && capsManager != null) {
             EntityCapsManager.addDiscoverInfoByNode(node, info);
         }
         // If this is a non caps entity store the discover in nonCapsCache map
         else if (cacheNonCaps && node == null) {
            nonCapsCache.put(entityID, info);
         }
         return info;
     }
 }
项目:telegraph    文件:ServiceDiscoveryManager.java   
/**
 * Entity Capabilities
 */

public void setEntityCapsManager(EntityCapsManager manager) {
    capsManager = manager;
    if (connection.getCapsNode() != null 
            && connection.getHost() != null) {
        capsManager.addUserCapsNode(connection.getHost(), connection.getCapsNode());
    }
    capsManager.addPacketListener(connection);
}
项目:asmack-mini    文件:SimpleDirectoryPersistentCache.java   
@Override
public void replay() throws IOException {
    File[] files = cacheDir.listFiles();
    for (File f : files) {
        String node = filenameEncoder.decode(f.getName());
        DiscoverInfo info = restoreInfoFromFile(f);
        if (info == null)
            continue;

        EntityCapsManager.addDiscoverInfoByNode(node, info);
    }
}
项目:asmack-mini    文件:CapsExtensionProvider.java   
public PacketExtension parseExtension(XmlPullParser parser) throws XmlPullParserException, IOException,
        XMPPException {
    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 XMPPException("Malformed Caps element");
    }

    parser.next();

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

    if (hash != null && version != null && node != null) {
        return new CapsExtension(node, version, hash);
    } else {
        throw new XMPPException("Caps elment with missing attributes");
    }
}
项目:asmack-mini    文件:CapsExtension.java   
public String toXML() {
    String xml = "<" + EntityCapsManager.ELEMENT + " xmlns=\"" + EntityCapsManager.NAMESPACE + "\" " +
        "hash=\"" + hash + "\" " +
        "node=\"" + node + "\" " +
        "ver=\"" + ver + "\"/>";

    return xml;
}
项目:asmack-mini    文件: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 XMPPException if the operation failed for some reason.
 */
public DiscoverInfo discoverInfo(String entityID) throws XMPPException {
    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;
}
项目:androidPN-client.    文件:CapsExtension.java   
public String getElementName() {
    return EntityCapsManager.ELEMENT;
}
项目:androidPN-client.    文件:CapsExtension.java   
public String getNamespace() {
    return EntityCapsManager.NAMESPACE;
}
项目:xmppsupport_v2    文件:ServiceDiscoveryManager.java   
public EntityCapsManager getEntityCapsManager() {
    return capsManager;
}
项目:java-bells    文件:CapsExtension.java   
public String getElementName() {
    return EntityCapsManager.ELEMENT;
}
项目:java-bells    文件:CapsExtension.java   
public String getNamespace() {
    return EntityCapsManager.NAMESPACE;
}
项目:telegraph    文件:ServiceDiscoveryManager.java   
public EntityCapsManager getEntityCapsManager(){
    return capsManager;
}
项目:asmack-mini    文件:CapsExtension.java   
public String getElementName() {
    return EntityCapsManager.ELEMENT;
}
项目:asmack-mini    文件:CapsExtension.java   
public String getNamespace() {
    return EntityCapsManager.NAMESPACE;
}
项目:androidPN-client.    文件:ServiceDiscoveryManager.java   
/**
 * Loads the ServiceDiscoveryManager with an EntityCapsManger
 * that speeds up certain lookups
 * @param manager
 */
public void setEntityCapsManager(EntityCapsManager manager) {
    capsManager = manager;
}
项目:java-bells    文件:ServiceDiscoveryManager.java   
/**
 * Loads the ServiceDiscoveryManager with an EntityCapsManger
 * that speeds up certain lookups
 * @param manager
 */
public void setEntityCapsManager(EntityCapsManager manager) {
    capsManager = manager;
}
项目:asmack-mini    文件:ServiceDiscoveryManager.java   
/**
 * Loads the ServiceDiscoveryManager with an EntityCapsManger
 * that speeds up certain lookups
 * @param manager
 */
public void setEntityCapsManager(EntityCapsManager manager) {
    capsManager = manager;
}