本文整理汇总了Java中org.jivesoftware.smackx.packet.DiscoverInfo.containsFeature方法的典型用法代码示例。如果您正苦于以下问题:Java DiscoverInfo.containsFeature方法的具体用法?Java DiscoverInfo.containsFeature怎么用?Java DiscoverInfo.containsFeature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.packet.DiscoverInfo
的用法示例。
在下文中一共展示了DiscoverInfo.containsFeature方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServiceNames
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的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: RoomInfo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
RoomInfo(DiscoverInfo info) {
super();
this.room = info.getFrom();
// Get the information based on the discovered features
this.membersOnly = info.containsFeature("muc_membersonly");
this.moderated = info.containsFeature("muc_moderated");
this.nonanonymous = info.containsFeature("muc_nonanonymous");
this.passwordProtected = info.containsFeature("muc_passwordprotected");
this.persistent = info.containsFeature("muc_persistent");
// Get the information based on the discovered extended information
Form form = Form.getFormFrom(info);
if (form != null) {
this.description =
form.getField("muc#roominfo_description").getValues().next();
Iterator<String> values = form.getField("muc#roominfo_subject").getValues();
if (values.hasNext()) {
this.subject = values.next();
}
else {
this.subject = "";
}
this.occupantsCount =
Integer.parseInt(form.getField("muc#roominfo_occupants").getValues()
.next());
}
}
示例3: RoomInfo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
RoomInfo(DiscoverInfo info) {
super();
this.room = info.getFrom();
// Get the information based on the discovered features
this.membersOnly = info.containsFeature("muc_membersonly");
this.moderated = info.containsFeature("muc_moderated");
this.nonanonymous = info.containsFeature("muc_nonanonymous");
this.passwordProtected = info.containsFeature("muc_passwordprotected");
this.persistent = info.containsFeature("muc_persistent");
// Get the information based on the discovered extended information
Form form = Form.getFormFrom(info);
if (form != null) {
FormField descField = form.getField("muc#roominfo_description");
this.description = ( descField == null || !(descField.getValues().hasNext()) )? "" : descField.getValues().next();
FormField subjField = form.getField("muc#roominfo_subject");
this.subject = ( subjField == null || !(subjField.getValues().hasNext()) ) ? "" : subjField.getValues().next();
FormField occCountField = form.getField("muc#roominfo_occupants");
this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
.next());
}
}
示例4: getServiceNames
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的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;
}
示例5: RoomInfo
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
RoomInfo(DiscoverInfo info) {
super();
this.room = info.getFrom();
// Get the information based on the discovered features
this.membersOnly = info.containsFeature("muc_membersonly");
this.moderated = info.containsFeature("muc_moderated");
this.nonanonymous = info.containsFeature("muc_nonanonymous");
this.passwordProtected = info.containsFeature("muc_passwordprotected");
this.persistent = info.containsFeature("muc_persistent");
// Get the information based on the discovered extended information
Form form = Form.getFormFrom(info);
if (form != null) {
FormField descField = form.getField("muc#roominfo_description");
this.description = (descField == null || !(descField.getValues()
.hasNext())) ? "" : descField.getValues().next();
FormField subjField = form.getField("muc#roominfo_subject");
this.subject = (subjField == null || !(subjField.getValues()
.hasNext())) ? "" : subjField.getValues().next();
FormField occCountField = form.getField("muc#roominfo_occupants");
this.occupantsCount = occCountField == null ? -1 : Integer
.parseInt(occCountField.getValues().next());
}
}
示例6: getConferenceServices
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
private Collection<String> getConferenceServices(String server) throws Exception {
List<String> answer = new ArrayList<String>();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
DiscoverItems items = discoManager.discoverItems(server);
for (Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext();) {
DiscoverItems.Item item = (DiscoverItems.Item)it.next();
if (item.getEntityID().startsWith("conference") || item.getEntityID().startsWith("private")) {
answer.add(item.getEntityID());
}
else {
try {
DiscoverInfo info = discoManager.discoverInfo(item.getEntityID());
if (info.containsFeature("http://jabber.org/protocol/muc")) {
answer.add(item.getEntityID());
}
}
catch (XMPPException e) {
Log.error("Problem when loading conference service.", e);
}
}
}
return answer;
}
示例7: isServiceEnabled
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if the specified user handles XHTML messages.
*
* @param connection the connection to use to perform the service discovery
* @param userID the user to check. A fully qualified xmpp ID, e.g. [email protected]
* @return a boolean indicating whether the specified user handles XHTML messages
*/
public static boolean isServiceEnabled(Connection connection, String userID) {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(userID);
return result.containsFeature(namespace);
}
catch (XMPPException e) {
e.printStackTrace();
return false;
}
}
示例8: isServiceEnabled
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if the specified user supports the Multi-User Chat protocol.
*
* @param connection the connection to use to perform the service discovery.
* @param user the user to check. A fully qualified xmpp ID, e.g. [email protected]
* @return a boolean indicating whether the specified user supports the MUC protocol.
*/
public static boolean isServiceEnabled(Connection connection, String user) {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(user);
return result.containsFeature(discoNamespace);
}
catch (XMPPException e) {
e.printStackTrace();
return false;
}
}
示例9: isEmailAvailable
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的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: isLastActivitySupported
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if Last Activity (XEP-0012) is supported by a given JID
*
* @param connection the connection to be used
* @param jid a JID to be tested for Last Activity support
* @return true if Last Activity is supported, otherwise false
*/
public static boolean isLastActivitySupported(Connection connection, String jid) {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
return result.containsFeature(LastActivity.NAMESPACE);
}
catch (XMPPException e) {
return false;
}
}
示例11: isSupportedByServer
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if XMPP Carbons are supported by the server.
*
* @return true if supported
*/
public boolean isSupportedByServer() {
try {
DiscoverInfo result = ServiceDiscoveryManager
.getInstanceFor(connection).discoverInfo(connection.getServiceName());
return result.containsFeature(Carbon.NAMESPACE);
}
catch (XMPPException e) {
return false;
}
}
示例12: areEntityCapsSupported
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if Entity Caps are supported by a given JID
*
* @param jid
* @return
*/
public boolean areEntityCapsSupported(String jid) {
if (jid == null)
return false;
try {
DiscoverInfo result = sdm.discoverInfo(jid);
return result.containsFeature(NAMESPACE);
} catch (XMPPException e) {
return false;
}
}
示例13: isPingSupported
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if XMPP Ping is supported by a given JID
*
* @param jid
* @return
*/
public boolean isPingSupported(String jid) {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
return result.containsFeature(NAMESPACE);
}
catch (XMPPException e) {
return false;
}
}
示例14: isEmailAvailable
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的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;
}
}
示例15: isSupported
import org.jivesoftware.smackx.packet.DiscoverInfo; //导入方法依赖的package包/类
/**
* Returns true if Delivery Receipts are supported by a given JID
*
* @param jid
* @return true if supported
*/
public boolean isSupported(String jid) {
try {
DiscoverInfo result =
ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(jid);
return result.containsFeature(DeliveryReceipt.NAMESPACE);
}
catch (XMPPException e) {
return false;
}
}