예제 #1
0
  private void browse(String serviceName) {
    browsePanel.removeAll();

    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
    DiscoverItems result;
    try {
      result = discoManager.discoverItems(serviceName);
    } catch (XMPPException e) {
      Log.error(e);
      return;
    }

    addAddress(serviceName);

    Iterator<DiscoverItems.Item> discoverItems = result.getItems();
    while (discoverItems.hasNext()) {
      DiscoverItems.Item item = discoverItems.next();
      Entity entity = new Entity(item);
      browsePanel.add(entity);
    }

    browsePanel.invalidate();
    browsePanel.validate();
    browsePanel.repaint();
  }
예제 #2
0
  private void browseItem(DiscoverItems.Item discoveredItem) {
    addAddress(discoveredItem.getEntityID());
    browsePanel.removeAll();
    ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
    DiscoverItems result;
    try {
      result = discoManager.discoverItems(discoveredItem.getEntityID());
    } catch (XMPPException e) {
      browsePanel.invalidate();
      browsePanel.validate();
      browsePanel.repaint();
      return;
    }

    Iterator<DiscoverItems.Item> discoverItems = result.getItems();
    List<Entity> list = new ArrayList<Entity>();

    while (discoverItems.hasNext()) {
      DiscoverItems.Item item = discoverItems.next();
      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();
  }
예제 #3
0
 /**
  * Tries to discover if the server of the given XMPPConnection provides also a MUC component. Will
  * return the MUCs Component ID if one is found otherwise returns null
  *
  * @param connection
  * @return
  * @throws XMPPException
  */
 public static String disocverMUC(XMPPConnection connection) throws XMPPException {
   ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
   DiscoverItems ditem = sdm.discoverItems(connection.getServiceName());
   Iterator<Item> it = ditem.getItems();
   while (it.hasNext()) {
     Item i = it.next();
     DiscoverInfo dinfo = sdm.discoverInfo(i.getEntityID());
     Iterator<Feature> itFeatures = dinfo.getFeatures();
     while (itFeatures.hasNext()) {
       Feature f = itFeatures.next();
       if (f.getVar().equals(MUC_FEATURE)) {
         return i.getEntityID();
       }
     }
   }
   return null;
 }
 private void initProxies() {
   proxies = new ArrayList<String>();
   ServiceDiscoveryManager manager = ServiceDiscoveryManager.getInstanceFor(connection);
   try {
     DiscoverItems discoItems = manager.discoverItems(connection.getServiceName());
     Iterator it = discoItems.getItems();
     while (it.hasNext()) {
       DiscoverItems.Item item = (DiscoverItems.Item) it.next();
       String proxy = checkIsProxy(manager, item);
       if (proxy != null) {
         proxies.add(proxy);
       }
     }
   } catch (XMPPException e) {
     return;
   }
   if (proxies.size() > 0) {
     initStreamHosts();
   }
 }
예제 #5
0
 /**
  * Discover the commands of an specific JID. The <code>jid</code> is a full JID.
  *
  * @param jid the full JID to retrieve the commands for.
  * @return the discovered items.
  * @throws XMPPException if the operation failed for some reason.
  */
 public DiscoverItems discoverCommands(String jid) throws XMPPException {
   ServiceDiscoveryManager serviceDiscoveryManager =
       ServiceDiscoveryManager.getInstanceFor(connection);
   return serviceDiscoveryManager.discoverItems(jid, discoNode);
 }