use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Spark by igniterealtime.
the class JabberBrowser method browseItem.
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 | SmackException 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();
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Spark by igniterealtime.
the class JabberBrowser method browse.
private void browse(String serviceName) {
browsePanel.removeAll();
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con);
DiscoverItems result;
try {
result = discoManager.discoverItems(serviceName);
} catch (XMPPException | SmackException e) {
Log.error(e);
return;
}
addAddress(serviceName);
for (DiscoverItems.Item item : result.getItems()) {
Entity entity = new Entity(item);
browsePanel.add(entity);
}
browsePanel.invalidate();
browsePanel.validate();
browsePanel.repaint();
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Spark by igniterealtime.
the class JinglePlugin method getPhoneActions.
public Collection<Action> getPhoneActions(final String jid) {
// Do not even disco gateway clients.
if (TransportUtils.isFromGateway(jid) || jingleManager == null) {
return Collections.emptyList();
}
Boolean supportsJingle = jingleFeature.get(XmppStringUtils.parseBareJid(jid));
if (supportsJingle == null) {
// Disco for event.
// Obtain the ServiceDiscoveryManager associated with my XMPPConnection
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(SparkManager.getConnection());
String fullJID = PresenceManager.getFullyQualifiedJID(jid);
// Get the items of a given XMPP entity
DiscoverInfo discoverInfo = null;
try {
discoverInfo = discoManager.discoverInfo(fullJID);
} catch (XMPPException | SmackException e) {
Log.debug("Unable to disco " + fullJID);
}
if (discoverInfo != null) {
// Get the discovered items of the queried XMPP entity
supportsJingle = discoverInfo.containsFeature(JINGLE_NAMESPACE);
jingleFeature.put(jid, supportsJingle);
} else {
jingleFeature.put(jid, false);
supportsJingle = false;
}
}
if (!supportsJingle) {
return Collections.emptyList();
}
final List<Action> actions = new ArrayList<>();
Action action = new AbstractAction() {
private static final long serialVersionUID = 1467355627829748086L;
public void actionPerformed(ActionEvent e) {
try {
placeCall(jid);
} catch (SmackException e1) {
Log.warning("Unable to place call to " + jid, e1);
}
}
};
action.putValue(Action.NAME, "<html><b>" + JingleResources.getString("label.computer.to.computer") + "</b></html>");
action.putValue(Action.SMALL_ICON, SparkRes.getImageIcon(SparkRes.COMPUTER_IMAGE_16x16));
actions.add(action);
return actions;
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Spark by igniterealtime.
the class SparkManager method removeFeature.
/**
* Removes a feature that can be discovered through Disco.
*
* @param namespace the namespace to remove.
*/
public static void removeFeature(String namespace) {
// Obtain the ServiceDiscoveryManager associated with my XMPPConnection
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(getConnection());
// Register that a new feature is supported by this XMPP entity
discoManager.removeFeature(namespace);
}
use of org.jivesoftware.smackx.disco.ServiceDiscoveryManager in project Zom-Android by zom.
the class XmppConnection method initServiceDiscovery.
/*
@Override
public void handle(Callback[] arg0) throws IOException {
for (Callback cb : arg0) {
debug(TAG, cb.toString());
}
}*/
/*
public class MySASLDigestMD5Mechanism extends SASLMechanism
{
public MySASLDigestMD5Mechanism(SASLAuthentication saslAuthentication)
{
super(saslAuthentication);
}
protected void authenticate()
throws IOException, XMPPException
{
String mechanisms[] = {
getName()
};
java.util.Map props = new HashMap();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", hostname, props, this);
super.authenticate();
}
public void authenticate(String username, String host, String password)
throws IOException, XMPPException
{
authenticationId = username;
this.password = password;
hostname = host;
String mechanisms[] = {
getName()
};
java.util.Map props = new HashMap();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, this);
super.authenticate();
}
public void authenticate(String username, String host, CallbackHandler cbh)
throws IOException, XMPPException
{
String mechanisms[] = {
getName()
};
java.util.Map props = new HashMap();
sc = Sasl.createSaslClient(mechanisms, null, "xmpp", host, props, cbh);
super.authenticate();
}
protected String getName()
{
return "DIGEST-MD5";
}
public void challengeReceived(String challenge)
throws IOException
{
//StringBuilder stanza = new StringBuilder();
byte response[];
if(challenge != null)
response = sc.evaluateChallenge(Base64.decode(challenge));
else
//response = sc.evaluateChallenge(null);
response = sc.evaluateChallenge(new byte[0]);
//String authenticationText = "";
Packet responseStanza;
//if(response != null)
//{
//authenticationText = Base64.encodeBytes(response, 8);
//if(authenticationText.equals(""))
//authenticationText = "=";
if (response == null){
responseStanza = new Response();
} else {
responseStanza = new Response(Base64.encodeBytes(response,Base64.DONT_BREAK_LINES));
}
//}
//stanza.append("<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">");
//stanza.append(authenticationText);
//stanza.append("</response>");
//getSASLAuthentication().send(stanza.toString());
getSASLAuthentication().send(responseStanza);
}
}
*/
private void initServiceDiscovery() {
debug(TAG, "init service discovery");
// register connection features
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mConnection);
if (!sdm.includesFeature(DISCO_FEATURE))
sdm.addFeature(DISCO_FEATURE);
if (!sdm.includesFeature(DeliveryReceipt.NAMESPACE))
sdm.addFeature(DeliveryReceipt.NAMESPACE);
sdm.addFeature(HttpFileUploadManager.NAMESPACE);
DeliveryReceiptManager.getInstanceFor(mConnection).autoAddDeliveryReceiptRequests();
DeliveryReceiptManager.getInstanceFor(mConnection).setAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.disabled);
}
Aggregations