本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverInfo.Identity方法的典型用法代码示例。如果您正苦于以下问题:Java DiscoverInfo.Identity方法的具体用法?Java DiscoverInfo.Identity怎么用?Java DiscoverInfo.Identity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.packet.DiscoverInfo
的用法示例。
在下文中一共展示了DiscoverInfo.Identity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReservedNickname
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns the reserved room nickname for the user in the room. A user may have a reserved
* nickname, for example through explicit room registration or database integration. In such
* cases it may be desirable for the user to discover the reserved nickname before attempting
* to enter the room.
*
* @return the reserved room nickname or <tt>null</tt> if none.
*/
public String getReservedNickname() {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(
room,
"x-roomuser-item");
// Look for an Identity that holds the reserved nickname and return its name
for (Iterator<DiscoverInfo.Identity> identities = result.getIdentities();
identities.hasNext();) {
DiscoverInfo.Identity identity = identities.next();
return identity.getName();
}
// If no Identity was found then the user does not have a reserved room nickname
return null;
}
catch (XMPPException e) {
e.printStackTrace();
return null;
}
}
示例2: getReservedNickname
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns the reserved room nickname for the user in the room. A user may
* have a reserved nickname, for example through explicit room registration
* or database integration. In such cases it may be desirable for the user
* to discover the reserved nickname before attempting to enter the room.
*
* @return the reserved room nickname or <tt>null</tt> if none.
*/
public String getReservedNickname() {
try {
DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(
connection).discoverInfo(room, "x-roomuser-item");
// Look for an Identity that holds the reserved nickname and return
// its name
for (Iterator<DiscoverInfo.Identity> identities = result
.getIdentities(); identities.hasNext();) {
DiscoverInfo.Identity identity = identities.next();
return identity.getName();
}
// If no Identity was found then the user does not have a reserved
// room nickname
return null;
} catch (XMPPException e) {
e.printStackTrace();
return null;
}
}
示例3: addDiscoverInfoTo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Add discover info response data.
*
* @param response
* the discover info response packet
*/
public void addDiscoverInfoTo(DiscoverInfo response) {
// Set this client identity
DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
getIdentityName());
identity.setType(getIdentityType());
response.addIdentity(identity);
// Add the registered features to the response
synchronized (features) {
for (Iterator<String> it = getFeatures(); it.hasNext();) {
response.addFeature(it.next());
}
if (extendedInfo != null) {
response.addExtension(extendedInfo);
}
}
}
示例4: discoverServerFeatures
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Discover the features provided by the server.
*/
private void discoverServerFeatures() {
try {
// jid et server
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mAdaptee);
DiscoverInfo info = sdm.discoverInfo(mAdaptee.getServiceName());
Iterator<DiscoverInfo.Identity> it = info.getIdentities();
while (it.hasNext()) {
DiscoverInfo.Identity identity = it.next();
if ("pubsub".equals(identity.getCategory()) && "pep".equals(identity.getType())) {
initPEP();
}
}
} catch (XMPPException e) {
Log.w(TAG, "Unable to discover server features", e);
}
}
示例5: addDiscoverInfoTo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Add discover info response data.
*
* @param response the discover info response packet
*/
public void addDiscoverInfoTo(DiscoverInfo response) {
// Set this client identity
DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
getIdentityName());
identity.setType(getIdentityType());
response.addIdentity(identity);
// Add the registered features to the response
synchronized (features) {
for (Iterator<String> it = getFeatures(); it.hasNext();) {
response.addFeature(it.next());
}
if (extendedInfo != null) {
response.addExtension(extendedInfo);
}
}
}
示例6: checkIsProxy
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Checks the service discovery item returned from a server component to verify if it is
* a File Transfer proxy or not.
*
* @param manager the service discovery manager which will be used to query the component
* @param item the discovered item on the server relating
* @return returns the JID of the proxy if it is a proxy or null if the item is not a proxy.
*/
private String checkIsProxy(ServiceDiscoveryManager manager, DiscoverItems.Item item) {
DiscoverInfo info;
try {
info = manager.discoverInfo(item.getEntityID());
}
catch (XMPPException e) {
return null;
}
Iterator<DiscoverInfo.Identity> itx = info.getIdentities();
while (itx.hasNext()) {
DiscoverInfo.Identity identity = itx.next();
if ("proxy".equalsIgnoreCase(identity.getCategory())
&& "bytestreams".equalsIgnoreCase(
identity.getType())) {
return info.getFrom();
}
}
return null;
}
开发者ID:phoenixNirvana,项目名称:NewCommunication-Android,代码行数:28,代码来源:Socks5TransferNegotiatorManager.java
示例7: addDiscoverInfoTo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Add discover info response data.
*
* @param response the discover info response packet
*/
public void addDiscoverInfoTo(DiscoverInfo response) {
// Set this client identity
DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
getIdentityName());
identity.setType(getIdentityType());
response.addIdentity(identity);
// Add the registered features to the response
synchronized (features) {
// Add Entity Capabilities (XEP-0115) feature node.
response.addFeature("http://jabber.org/protocol/caps");
for (Iterator<String> it = getFeatures(); it.hasNext();) {
response.addFeature(it.next());
}
if (extendedInfo != null) {
response.addExtension(extendedInfo);
}
}
}
示例8: getIdentities
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns all identities of this client as unmodifiable Collection
*
* @return
*/
public Set<DiscoverInfo.Identity> getIdentities() {
Set<Identity> res = new HashSet<Identity>(identities);
// Add the default identity that must exist
res.add(defaultIdentity);
return Collections.unmodifiableSet(res);
}
示例9: serviceAvailable
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Check if the server support RTPBridge Service.
*
* @param connection
* @return
*/
public static boolean serviceAvailable(Connection connection) {
if (!connection.isConnected()) {
return false;
}
LOGGER.debug("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager
.getInstanceFor(connection);
try {
// DiscoverItems items = disco.discoverItems(connection.getServiceName());
// Iterator iter = items.getItems();
// while (iter.hasNext()) {
// DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
// if (item.getEntityID().startsWith("rtpbridge.")) {
// return true;
// }
// }
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
Iterator<DiscoverInfo.Identity> iter = discoInfo.getIdentities();
while (iter.hasNext()) {
DiscoverInfo.Identity identity = iter.next();
if ((identity.getName() != null) && (identity.getName().startsWith("rtpbridge"))) {
return true;
}
}
}
catch (XMPPException e) {
e.printStackTrace();
}
return false;
}
示例10: serviceAvailable
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Check if the server support STUN Service.
*
* @param xmppConnection
* @return
*/
public static boolean serviceAvailable(Connection connection) {
if (!connection.isConnected()) {
return false;
}
LOGGER.debug("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager
.getInstanceFor(connection);
try {
DiscoverItems items = disco.discoverItems(connection.getServiceName());
Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) {
DiscoverItems.Item item = iter.next();
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
Iterator<DiscoverInfo.Identity> iter2 = info.getIdentities();
while (iter2.hasNext()) {
DiscoverInfo.Identity identity = iter2.next();
if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
if (info.containsFeature(NAMESPACE))
return true;
}
LOGGER.debug(item.getName()+"-"+info.getType());
}
}
catch (XMPPException e) {
e.printStackTrace();
}
return false;
}
示例11: getIdentityName
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns the name of the client that will be returned when asked for the client identity
* in a disco request. The name could be any value you need to identity this client.
*
* @return the name of the client that will be returned when asked for the client identity
* in a disco request.
*/
public static String getIdentityName() {
DiscoverInfo.Identity identity = identities.get(0);
if (identity != null) {
return identity.getName();
} else {
return null;
}
}
示例12: setIdentityType
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Sets the type of client that will be returned when asked for the client identity in a
* disco request. The valid types are defined by the category client. Follow this link to learn
* the possible types: <a href="http://xmpp.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
*
* @param type the type of client that will be returned when asked for the client identity in a
* disco request.
*/
public static void setIdentityType(String type) {
DiscoverInfo.Identity identity = identities.get(0);
if (identity != null) {
identity.setType(type);
} else {
identity = new DiscoverInfo.Identity(DEFAULT_IDENTITY_CATEGORY, DEFAULT_IDENTITY_NAME, type);
identities.add(identity);
}
}
示例13: getIdentityType
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns the type of client that will be returned when asked for the client identity in a
* disco request. The valid types are defined by the category client. Follow this link to learn
* the possible types: <a href="http://xmpp.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
*
* @return the type of client that will be returned when asked for the client identity in a
* disco request.
*/
public static String getIdentityType() {
DiscoverInfo.Identity identity = identities.get(0);
if (identity != null) {
return identity.getType();
} else {
return null;
}
}
示例14: parseIQ
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false;
DiscoverInfo.Feature feature = null;
DiscoverInfo.Identity identity = null;
String category = "";
String name = "";
String type = "";
String variable = "";
discoverInfo.setNode(parser.getAttributeValue("", "node"));
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("identity")) {
// Initialize the variables from the parsed XML
category = parser.getAttributeValue("", "category");
name = parser.getAttributeValue("", "name");
type = parser.getAttributeValue("", "type");
}
else if (parser.getName().equals("feature")) {
// Initialize the variables from the parsed XML
variable = parser.getAttributeValue("", "var");
}
// Otherwise, it must be a packet extension.
else {
discoverInfo.addExtension(PacketParserUtils.parsePacketExtension(parser
.getName(), parser.getNamespace(), parser));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("identity")) {
// Create a new identity and add it to the discovered info.
identity = new DiscoverInfo.Identity(category, name);
identity.setType(type);
discoverInfo.addIdentity(identity);
}
if (parser.getName().equals("feature")) {
// Create a new feature and add it to the discovered info.
discoverInfo.addFeature(variable);
}
if (parser.getName().equals("query")) {
done = true;
}
}
}
return discoverInfo;
}
示例15: parseIQ
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
DiscoverInfo discoverInfo = new DiscoverInfo();
boolean done = false;
DiscoverInfo.Feature feature = null;
DiscoverInfo.Identity identity = null;
String category = "";
String name = "";
String type = "";
String variable = "";
String lang = "";
discoverInfo.setNode(parser.getAttributeValue("", "node"));
while (!done) {
int eventType = parser.next();
if (eventType == XmlPullParser.START_TAG) {
if (parser.getName().equals("identity")) {
// Initialize the variables from the parsed XML
category = parser.getAttributeValue("", "category");
name = parser.getAttributeValue("", "name");
type = parser.getAttributeValue("", "type");
lang = parser.getAttributeValue(parser.getNamespace("xml"), "lang");
}
else if (parser.getName().equals("feature")) {
// Initialize the variables from the parsed XML
variable = parser.getAttributeValue("", "var");
}
// Otherwise, it must be a packet extension.
else {
discoverInfo.addExtension(PacketParserUtils.parsePacketExtension(parser
.getName(), parser.getNamespace(), parser));
}
} else if (eventType == XmlPullParser.END_TAG) {
if (parser.getName().equals("identity")) {
// Create a new identity and add it to the discovered info.
identity = new DiscoverInfo.Identity(category, name, type);
if (lang != null)
identity.setLanguage(lang);
discoverInfo.addIdentity(identity);
}
if (parser.getName().equals("feature")) {
// Create a new feature and add it to the discovered info.
discoverInfo.addFeature(variable);
}
if (parser.getName().equals("query")) {
done = true;
}
}
}
return discoverInfo;
}