本文整理汇总了Java中org.jivesoftware.smackx.entitycaps.EntityCapsManager类的典型用法代码示例。如果您正苦于以下问题:Java EntityCapsManager类的具体用法?Java EntityCapsManager怎么用?Java EntityCapsManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityCapsManager类属于org.jivesoftware.smackx.entitycaps包,在下文中一共展示了EntityCapsManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ServiceDiscoveryManager
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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();
}
示例2: ServiceDiscoveryManager
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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();
}
示例3: replay
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
@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);
}
}
示例4: parseExtension
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
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");
}
}
示例5: toXML
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
public String toXML() {
String xml = "<" + EntityCapsManager.ELEMENT + " xmlns=\"" + EntityCapsManager.NAMESPACE + "\" " +
"hash=\"" + hash + "\" " +
"node=\"" + node + "\" " +
"ver=\"" + ver + "\"/>";
return xml;
}
示例6: discoverInfo
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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;
}
示例7: discoverInfo
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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;
}
}
示例8: setEntityCapsManager
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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);
}
示例9: initServiceDiscovery
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
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);
}});
}
示例10: discoverInfo
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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;
}
}
示例11: setEntityCapsManager
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
/**
* 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);
}
示例12: getElementName
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
public String getElementName() {
return EntityCapsManager.ELEMENT;
}
示例13: getNamespace
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
public String getNamespace() {
return EntityCapsManager.NAMESPACE;
}
示例14: getEntityCapsManager
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
public EntityCapsManager getEntityCapsManager() {
return capsManager;
}
示例15: getEntityCapsManager
import org.jivesoftware.smackx.entitycaps.EntityCapsManager; //导入依赖的package包/类
public EntityCapsManager getEntityCapsManager(){
return capsManager;
}