本文整理汇总了Java中org.jivesoftware.smackx.ServiceDiscoveryManager.discoverInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDiscoveryManager.discoverInfo方法的具体用法?Java ServiceDiscoveryManager.discoverInfo怎么用?Java ServiceDiscoveryManager.discoverInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.ServiceDiscoveryManager
的用法示例。
在下文中一共展示了ServiceDiscoveryManager.discoverInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServiceNames
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a collection with the XMPP addresses of the Multi-User Chat services.
*
* @param connection the XMPP connection to use for discovering Multi-User Chat services.
* @return a collection with the XMPP addresses of the Multi-User Chat services.
* @throws XMPPException if an error occured while trying to discover MUC services.
*/
public static Collection<String> getServiceNames(Connection connection) throws XMPPException {
final List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(connection.getServiceName());
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = it.next();
try {
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID());
}
}
catch (XMPPException e) {
// Trouble finding info in some cases. This is a workaround for
// discovering info on remote servers.
}
}
return answer;
}
示例2: getServiceNames
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a collection with the XMPP addresses of the Multi-User Chat
* services.
*
* @param connection
* the XMPP connection to use for discovering Multi-User Chat
* services.
* @return a collection with the XMPP addresses of the Multi-User Chat
* services.
* @throws XMPPException
* if an error occured while trying to discover MUC services.
*/
public static Collection<String> getServiceNames(Connection connection)
throws XMPPException {
final List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
.getInstanceFor(connection);
DiscoverItems items = discoManager.discoverItems(connection
.getServiceName());
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = it.next();
try {
DiscoverInfo info = discoManager.discoverInfo(item
.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID());
}
} catch (XMPPException e) {
// Trouble finding info in some cases. This is a workaround for
// discovering info on remote servers.
}
}
return answer;
}
示例3: getSpaceConfiguration
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Retrieves the configuration of the space.
* @param space The space to get the configuration for.
* @return The parsed result or, if there was an error, null.
* @throws SpaceManagementException Thrown when no response was received from the server.
*/
private SpaceConfiguration getSpaceConfiguration(Space space) throws SpaceManagementException{
if (space == null){
throw new IllegalArgumentException("The given space must not be null");
}
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverInfo info;
try {
info = discoveryManager.discoverInfo(SERVICE_PREFIX + space.getDomain(), space.getId());
} catch (XMPPException e) {
if (e.getXMPPError().getCode() == 404) {
return null;
} else {
throw new SpaceManagementException("The Server didn't respond.", Type.OTHER, e);
}
}
Element config = parsePacketToElement(info);
return parseSpaceConfiguration(config);
}
示例4: populateFeatureSet
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
private void populateFeatureSet() {
final ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
final DiscoverItems items = SparkManager.getSessionManager().getDiscoveredItems();
Iterator<DiscoverItems.Item> iter = items.getItems();
while (iter.hasNext()) {
DiscoverItems.Item item = iter.next();
String entity = item.getEntityID();
if (entity != null) {
if (entity.startsWith("manager.")) {
sparkManagerInstalled = true;
// Populate with feature sets.
try {
featureInfo = disco.discoverInfo(item.getEntityID());
}
catch (XMPPException e) {
Log.error("Error while retrieving feature list for SparkManager.", e);
}
}
}
}
}
示例5: checkIsProxy
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的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
示例6: discoverServerFeatures
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的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);
}
}
示例7: isRegistered
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Checks if the user is registered with a gateway.
*
* @param con the XMPPConnection.
* @param transport the transport.
* @return true if the user is registered with the transport.
*/
public static boolean isRegistered(XMPPConnection con, Transport transport) {
if (!con.isConnected()) {
return false;
}
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(con);
try {
DiscoverInfo info = discoveryManager.discoverInfo(transport.getServiceName());
return info.containsFeature("jabber:iq:registered");
}
catch (XMPPException e) {
Log.error(e);
}
return false;
}
示例8: isEmailAvailable
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* The workgroup service may be configured to send email. This queries the Workgroup Service
* to see if the email service has been configured and is available.
*
* @return true if the email service is available, otherwise return false.
*/
public boolean isEmailAvailable() {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
try {
String workgroupService = StringUtils.parseServer(workgroupJID);
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
}
catch (XMPPException e) {
return false;
}
}
示例9: isEmailAvailable
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* The workgroup service may be configured to send email. This queries the
* Workgroup Service to see if the email service has been configured and is
* available.
*
* @return true if the email service is available, otherwise return false.
*/
public boolean isEmailAvailable() {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager
.getInstanceFor(connection);
try {
String workgroupService = StringUtils.parseServer(workgroupJID);
DiscoverInfo infoResult = discoManager
.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
} catch (XMPPException e) {
return false;
}
}
示例10: serviceAvailable
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的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;
}
示例11: serviceAvailable
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的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;
}
示例12: isPasswordRequired
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns true if the room requires a password.
*
* @param roomJID the JID of the room.
* @return true if the room requires a password.
*/
public static boolean isPasswordRequired(String roomJID) {
// Check to see if the room is password protected
ServiceDiscoveryManager discover = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
try {
DiscoverInfo info = discover.discoverInfo(roomJID);
return info.containsFeature("muc_passwordprotected");
}
catch (XMPPException e) {
Log.error(e);
}
return false;
}
示例13: getCreationDate
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Retrieve the date (in yyyyMMdd) format of the time the room was created.
*
* @param roomJID the jid of the room.
* @return the formatted date.
* @throws Exception throws an exception if we are unable to retrieve the date.
*/
public static String getCreationDate(String roomJID) throws Exception {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
final DateFormat dateFormatter = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
DiscoverInfo infoResult = discoManager.discoverInfo(roomJID);
DataForm dataForm = (DataForm)infoResult.getExtension("x", "jabber:x:data");
if (dataForm == null) {
return "Not available";
}
Iterator<FormField> fieldIter = dataForm.getFields();
String creationDate = "";
while (fieldIter.hasNext()) {
FormField field = fieldIter.next();
String label = field.getLabel();
if (label != null && "Creation date".equalsIgnoreCase(label)) {
Iterator<String> valueIterator = field.getValues();
while (valueIterator.hasNext()) {
Object oo = valueIterator.next();
creationDate = "" + oo;
Date date = dateFormatter.parse(creationDate);
creationDate = DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.MEDIUM).format(date);
}
}
}
return creationDate;
}
示例14: determineProxies
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a list of JIDs of SOCKS5 proxies by querying the XMPP server. The SOCKS5 proxies are
* in the same order as returned by the XMPP server.
*
* @return list of JIDs of SOCKS5 proxies
* @throws XMPPException if there was an error querying the XMPP server for SOCKS5 proxies
*/
private List<String> determineProxies() throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
// get all items form XMPP server
DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(this.connection.getServiceName());
Iterator<Item> itemIterator = discoverItems.getItems();
// query all items if they are SOCKS5 proxies
while (itemIterator.hasNext()) {
Item item = itemIterator.next();
// skip blacklisted servers
if (this.proxyBlacklist.contains(item.getEntityID())) {
continue;
}
try {
DiscoverInfo proxyInfo;
proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
Iterator<Identity> identities = proxyInfo.getIdentities();
// item must have category "proxy" and type "bytestream"
while (identities.hasNext()) {
Identity identity = identities.next();
if ("proxy".equalsIgnoreCase(identity.getCategory())
&& "bytestreams".equalsIgnoreCase(identity.getType())) {
proxies.add(item.getEntityID());
break;
}
/*
* server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5
* bytestream should be established
*/
this.proxyBlacklist.add(item.getEntityID());
}
}
catch (XMPPException e) {
// blacklist errornous server
this.proxyBlacklist.add(item.getEntityID());
}
}
return proxies;
}
示例15: determineProxies
import org.jivesoftware.smackx.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a list of JIDs of SOCKS5 proxies by querying the XMPP server. The
* SOCKS5 proxies are in the same order as returned by the XMPP server.
*
* @return list of JIDs of SOCKS5 proxies
* @throws XMPPException
* if there was an error querying the XMPP server for SOCKS5
* proxies
*/
private List<String> determineProxies() throws XMPPException {
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager
.getInstanceFor(this.connection);
List<String> proxies = new ArrayList<String>();
// get all items form XMPP server
DiscoverItems discoverItems = serviceDiscoveryManager
.discoverItems(this.connection.getServiceName());
Iterator<Item> itemIterator = discoverItems.getItems();
// query all items if they are SOCKS5 proxies
while (itemIterator.hasNext()) {
Item item = itemIterator.next();
// skip blacklisted servers
if (this.proxyBlacklist.contains(item.getEntityID())) {
continue;
}
try {
DiscoverInfo proxyInfo;
proxyInfo = serviceDiscoveryManager.discoverInfo(item
.getEntityID());
Iterator<Identity> identities = proxyInfo.getIdentities();
// item must have category "proxy" and type "bytestream"
while (identities.hasNext()) {
Identity identity = identities.next();
if ("proxy".equalsIgnoreCase(identity.getCategory())
&& "bytestreams".equalsIgnoreCase(identity
.getType())) {
proxies.add(item.getEntityID());
break;
}
/*
* server is not a SOCKS5 proxy, blacklist server to skip
* next time a Socks5 bytestream should be established
*/
this.proxyBlacklist.add(item.getEntityID());
}
} catch (XMPPException e) {
// blacklist errornous server
this.proxyBlacklist.add(item.getEntityID());
}
}
return proxies;
}