Java Code Examples for org.jivesoftware.smackx.disco.packet.DiscoverItems#Item
The following examples show how to use
org.jivesoftware.smackx.disco.packet.DiscoverItems#Item .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoomsListManager.java From mangosta-android with Apache License 2.0 | 6 votes |
private void findMUCLightName(Chat chat) { if (XMPPSession.getInstance().getXMPPConnection().isAuthenticated()) { DiscoverItems discoverItems = XMPPSession.getInstance().discoverMUCLightItems(); if (discoverItems != null) { List<DiscoverItems.Item> items = discoverItems.getItems(); for (DiscoverItems.Item item : items) { String itemJid = item.getEntityID().toString(); if (itemJid.equals(chat.getJid())) { chat.setName(item.getName()); } } } } }
Example 2
Source File: SipAccountPacket.java From Spark with Apache License 2.0 | 6 votes |
/** * Does a service discovery on the server to see if a SIPpark Manager is * enabled. * * @param con the XMPPConnection to use. * @return true if SIPpark Manager is available. */ public static boolean isSoftPhonePluginInstalled(XMPPConnection con) { if (!con.isConnected()) { return false; } ServiceDiscoveryManager disco = ServiceDiscoveryManager .getInstanceFor(con); try { DiscoverItems items = disco.discoverItems(con.getXMPPServiceDomain()); for ( DiscoverItems.Item item : items.getItems() ) { if ("SIP Controller".equals(item.getName())) { Log.debug("SIP Controller Found"); return true; } } } catch (XMPPException | SmackException e) { Log.error("isSparkPluginInstalled", e); } return false; }
Example 3
Source File: BookmarksUI.java From Spark with Apache License 2.0 | 6 votes |
private Collection<DomainBareJid> getConferenceServices(DomainBareJid server) throws Exception { List<DomainBareJid> answer = new ArrayList<>(); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection()); DiscoverItems items = discoManager.discoverItems(server); for (DiscoverItems.Item item : items.getItems()) { DomainBareJid entityID = item.getEntityID().asDomainBareJid(); // TODO: We should not simply assumet that this is MUC service just because it starts with a given prefix. if (entityID.toString().startsWith("conference") || entityID.toString().startsWith("private")) { answer.add(entityID); } else { try { DiscoverInfo info = discoManager.discoverInfo(item.getEntityID()); if (info.containsFeature("http://jabber.org/protocol/muc")) { answer.add(entityID); } } catch (XMPPException | SmackException e) { Log.error("Problem when loading conference service.", e); } } } return answer; }
Example 4
Source File: ConferenceServiceBrowser.java From Spark with Apache License 2.0 | 6 votes |
public Collection<String> getConferenceServices(String serverString) throws Exception { Jid server = JidCreate.from(serverString); List<String> answer = new ArrayList<>(); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection()); DiscoverItems items = discoManager.discoverItems(server); for (DiscoverItems.Item item : items.getItems() ) { if (item.getEntityID().toString().startsWith("conference") || item.getEntityID().toString().startsWith("private")) { answer.add(item.getEntityID().toString()); } else { try { DiscoverInfo info = discoManager.discoverInfo(item.getEntityID()); if (info.containsFeature("http://jabber.org/protocol/muc")) { answer.add(item.getEntityID().toString()); } } catch (XMPPException | SmackException e) { // Nothing to do } } } return answer; }
Example 5
Source File: CheckUpdates.java From Spark with Apache License 2.0 | 6 votes |
/** * Does a service discvery on the server to see if a Spark Manager * is enabled. * * @param con the XMPPConnection to use. * @return true if Spark Manager is available. */ public static boolean isSparkPluginInstalled(XMPPConnection con) { if (!con.isConnected()) { return false; } try { DiscoverItems items = SparkManager.getSessionManager().getDiscoveredItems(); for (DiscoverItems.Item item : items.getItems() ) { if ("Spark Updater".equals(item.getName())) { return true; } } } catch (Exception e) { Log.error(e); } return false; }
Example 6
Source File: MultiUserChatManager.java From Smack with Apache License 2.0 | 6 votes |
/** * Returns a List of the rooms where the requested user has joined. The Iterator will contain Strings where each * String represents a room (e.g. [email protected]). * * @param user the user to check. A fully qualified xmpp ID, e.g. [email protected]. * @return a List of the rooms where the requested user has joined. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public List<EntityBareJid> getJoinedRooms(EntityFullJid user) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Send the disco packet to the user DiscoverItems result = serviceDiscoveryManager.discoverItems(user, DISCO_NODE); List<DiscoverItems.Item> items = result.getItems(); List<EntityBareJid> answer = new ArrayList<>(items.size()); // Collect the entityID for each returned item for (DiscoverItems.Item item : items) { EntityBareJid muc = item.getEntityID().asEntityBareJidIfPossible(); if (muc == null) { LOGGER.warning("Not a bare JID: " + item.getEntityID()); continue; } answer.add(muc); } return answer; }
Example 7
Source File: JabberBrowser.java From Spark with Apache License 2.0 | 5 votes |
public Entity(final DiscoverItems.Item item) { this.item = item; setVerticalTextPosition(JLabel.BOTTOM); setHorizontalTextPosition(JLabel.CENTER); setText(item.getName()); setIcon(SparkRes.getImageIcon(SparkRes.USER1_MESSAGE_24x24)); addActionListener( e -> browseItem(item) ); }
Example 8
Source File: JabberBrowser.java From Spark with Apache License 2.0 | 5 votes |
private void browseItem(DiscoverItems.Item discoveredItem) { addAddress(discoveredItem.getEntityID().toString()); browsePanel.removeAll(); ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); DiscoverItems result; try { result = discoManager.discoverItems(discoveredItem.getEntityID()); } catch (XMPPException | SmackException | InterruptedException e) { browsePanel.invalidate(); browsePanel.validate(); browsePanel.repaint(); return; } List<Entity> list = new ArrayList<>(); for (DiscoverItems.Item item : result.getItems() ) { Entity entity = new Entity(item); browsePanel.add(entity); list.add(entity); } GraphicUtils.makeSameSize((JComponent[])list.toArray(new JComponent[list.size()])); browsePanel.invalidate(); browsePanel.validate(); browsePanel.repaint(); }
Example 9
Source File: STUN.java From Smack with Apache License 2.0 | 5 votes |
/** * Check if the server support STUN Service. * * @param connection the connection * @return true if the server support STUN * @throws SmackException if Smack detected an exceptional situation. * @throws XMPPException if an XMPP protocol error was received. * @throws InterruptedException if the calling thread was interrupted. */ public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, InterruptedException { if (!connection.isConnected()) { return false; } LOGGER.fine("Service listing"); ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection); DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain()); for (DiscoverItems.Item item : items.getItems()) { DiscoverInfo info = disco.discoverInfo(item.getEntityID()); for (DiscoverInfo.Identity identity : info.getIdentities()) { if (identity.getCategory().equals("proxy") && identity.getType().equals("stun")) if (info.containsFeature(NAMESPACE)) return true; } LOGGER.fine(item.getName() + "-" + info.getType()); } return false; }
Example 10
Source File: MamManager.java From Smack with Apache License 2.0 | 5 votes |
public boolean isAdvancedConfigurationSupported() throws InterruptedException, XMPPException, SmackException { DiscoverItems discoverItems = adHocCommandManager.discoverCommands(archiveAddress); for (DiscoverItems.Item item : discoverItems.getItems()) { if (item.getNode().equals(ADVANCED_CONFIG_NODE)) { return true; } } return false; }
Example 11
Source File: MultiUserChatLightManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Returns a List of the rooms the user occupies. * * @param mucLightService TODO javadoc me please * @return a List of the rooms the user occupies. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public List<Jid> getOccupiedRooms(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection()).discoverItems(mucLightService); List<DiscoverItems.Item> items = result.getItems(); List<Jid> answer = new ArrayList<>(items.size()); for (DiscoverItems.Item item : items) { Jid mucLight = item.getEntityID(); answer.add(mucLight); } return answer; }
Example 12
Source File: JabberBrowser.java From Spark with Apache License 2.0 | 4 votes |
public DiscoverItems.Item getItem() { return item; }
Example 13
Source File: AbstractNodeInformationProvider.java From Smack with Apache License 2.0 | 4 votes |
@Override public List<DiscoverItems.Item> getNodeItems() { return null; }
Example 14
Source File: OfflineMessageHeader.java From Smack with Apache License 2.0 | 4 votes |
public OfflineMessageHeader(DiscoverItems.Item item) { super(); user = item.getEntityID(); jid = item.getName(); stamp = item.getNode(); }
Example 15
Source File: HostedRoom.java From Smack with Apache License 2.0 | 4 votes |
public HostedRoom(DiscoverItems.Item item) { jid = Objects.requireNonNull(item.getEntityID().asEntityBareJidIfPossible(), "The discovered item must be an entity bare JID"); name = item.getName(); }
Example 16
Source File: FastpathPlugin.java From Spark with Apache License 2.0 | 4 votes |
public void initialize() { new WorkgroupInitializer().initialize(); EventQueue.invokeLater(new Runnable() { @Override public void run() { container = new FastpathContainer(); workgroupLabel = new JLabel(FpRes.getString("workgroup")); comboBox = new JComboBox(); joinButton = new JButton(FpRes.getString("join"), null); logoutButton = new RolloverButton(FpRes.getString("logout"), null); // Initialize tab handler for Fastpath chats. fastpathTabHandler = new FastpathTabHandler(); mainPanel = new BackgroundPane(); } }); try { DiscoverItems items = SparkManager.getSessionManager().getDiscoveredItems(); for (DiscoverItems.Item item : items.getItems() ) { String entityID = item.getEntityID() != null ? item.getEntityID().toString() : ""; if (entityID.startsWith("workgroup")) { // Log into workgroup final DomainBareJid workgroupService = JidCreate.domainBareFromOrThrowUnchecked("workgroup." + SparkManager.getSessionManager().getServerAddress()); final EntityFullJid jid = SparkManager.getSessionManager().getJID(); SwingWorker worker = new SwingWorker() { public Object construct() { try { return Agent.getWorkgroups(workgroupService, jid, SparkManager.getConnection()); } catch (XMPPException | SmackException | InterruptedException e1) { return Collections.emptyList(); } } public void finished() { Collection<String> agents = (Collection<String>)get(); if (agents.size() == 0) { return; } showSelection(agents); } }; worker.start(); } } } catch (Exception e) { Log.error(e); } SparkManager.getConnection().addConnectionListener(this); }
Example 17
Source File: RoomManager.java From mangosta-android with Apache License 2.0 | 4 votes |
public void loadMUCLightRooms() { final XMPPTCPConnection connection = XMPPSession.getInstance().getXMPPConnection(); if (connection.isAuthenticated()) { DiscoverItems discoverItems = XMPPSession.getInstance().discoverMUCLightItems(); if (discoverItems != null) { RealmManager.getInstance().hideAllMUCLightChats(); List<DiscoverItems.Item> items = discoverItems.getItems(); Realm realm = RealmManager.getInstance().getRealm(); try { for (DiscoverItems.Item item : items) { String itemJid = item.getEntityID().toString(); if (itemJid.contains(XMPPSession.MUC_LIGHT_SERVICE_NAME)) { Chat chatRoom = realm.where(Chat.class).equalTo("jid", itemJid).findFirst(); if (chatRoom == null) { chatRoom = new Chat(); chatRoom.setJid(item.getEntityID().toString()); chatRoom.setType(Chat.TYPE_MUC_LIGHT); getSubject(chatRoom); } realm.beginTransaction(); chatRoom.setShow(true); chatRoom.setName(item.getName()); realm.copyToRealmOrUpdate(chatRoom); realm.commitTransaction(); // set last retrieved from MAM ChatMessage chatMessage = RealmManager.getInstance().getFirstMessageForChat(chatRoom.getJid()); if (chatMessage != null) { realm.beginTransaction(); chatRoom.setLastRetrievedFromMAM(chatMessage.getMessageId()); realm.copyToRealmOrUpdate(chatRoom); realm.commitTransaction(); } } } } finally { realm.close(); mListener.onRoomsLoaded(); } } } }
Example 18
Source File: GatewayPlugin.java From Spark with Apache License 2.0 | 4 votes |
private void populateTransports() throws Exception { DiscoverItems discoItems = SparkManager.getSessionManager().getDiscoveredItems(); for (DiscoverItems.Item item : discoItems.getItems() ) { String entityName = item.getEntityID().toString(); if (entityName != null) { if (entityName.startsWith("aim.")) { AIMTransport aim = new AIMTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), aim); } else if (entityName.startsWith("msn.")) { MSNTransport msn = new MSNTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), msn); } else if (entityName.startsWith("yahoo.")) { YahooTransport yahoo = new YahooTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), yahoo); } else if (entityName.startsWith("icq.")) { ICQTransport icq = new ICQTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), icq); } else if (entityName.startsWith("gtalk.")) { GTalkTransport gtalk = new GTalkTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), gtalk); } else if (entityName.startsWith("xmpp.")) { XMPPTransport xmppTransport = new XMPPTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), xmppTransport); } else if (entityName.startsWith("irc.")) { IRCTransport ircTransport = new IRCTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), ircTransport); } else if (entityName.startsWith("sip.") || entityName.startsWith("simple.")) { SimpleTransport simpleTransport = new SimpleTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), simpleTransport); } else if (entityName.startsWith("gadugadu.")) { GaduGaduTransport gadugaduTransport = new GaduGaduTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), gadugaduTransport); } else if (entityName.startsWith("qq.")) { QQTransport qqTransport = new QQTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), qqTransport); } else if (entityName.startsWith("sametime.")) { SametimeTransport sametimeTransport = new SametimeTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), sametimeTransport); } else if (entityName.startsWith("facebook.")) { FacebookTransport facebookTransport = new FacebookTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), facebookTransport); } else if (entityName.startsWith("myspace.") || entityName.startsWith("myspaceim.")) { MySpaceTransport myspaceTransport = new MySpaceTransport(item.getEntityID().asDomainBareJid()); TransportUtils.addTransport(item.getEntityID().asDomainBareJid(), myspaceTransport); } } } }
Example 19
Source File: OfflineMessageManager.java From Smack with Apache License 2.0 | 3 votes |
/** * Returns a List of <code>OfflineMessageHeader</code> that keep information about the * offline message. The OfflineMessageHeader includes a stamp that could be used to retrieve * the complete message or delete the specific message. * * @return a List of <code>OfflineMessageHeader</code> that keep information about the offline * message. * @throws XMPPErrorException If the user is not allowed to make this request or the server does * not support offline message retrieval. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public List<OfflineMessageHeader> getHeaders() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List<OfflineMessageHeader> answer = new ArrayList<>(); DiscoverItems items = serviceDiscoveryManager.discoverItems(null, namespace); for (DiscoverItems.Item item : items.getItems()) { answer.add(new OfflineMessageHeader(item)); } return answer; }
Example 20
Source File: NodeInformationProvider.java From Smack with Apache License 2.0 | 2 votes |
/** * Returns a list of the Items {@link org.jivesoftware.smackx.disco.packet.DiscoverItems.Item} * defined in the node. For example, the MUC protocol specifies that an XMPP client should * answer an Item for each joined room when asked for the rooms where the use has joined. * * @return a list of the Items defined in the node. */ List<DiscoverItems.Item> getNodeItems();