mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-26 00:02:06 +01:00
Moved identityName and identityType from SmackConfiguration to ServiceDiscoveryManager.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2359 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
1a008f53c2
commit
3c80abdf45
3 changed files with 53 additions and 58 deletions
|
@ -79,8 +79,6 @@ public final class SmackConfiguration {
|
||||||
|
|
||||||
private static int packetReplyTimeout = 5000;
|
private static int packetReplyTimeout = 5000;
|
||||||
private static int keepAliveInterval = 30000;
|
private static int keepAliveInterval = 30000;
|
||||||
private static String identityName = "Smack";
|
|
||||||
private static String identityType = "pc";
|
|
||||||
|
|
||||||
private SmackConfiguration() {
|
private SmackConfiguration() {
|
||||||
}
|
}
|
||||||
|
@ -122,12 +120,6 @@ public final class SmackConfiguration {
|
||||||
else if (parser.getName().equals("keepAliveInterval")) {
|
else if (parser.getName().equals("keepAliveInterval")) {
|
||||||
keepAliveInterval = parseIntProperty(parser, keepAliveInterval);
|
keepAliveInterval = parseIntProperty(parser, keepAliveInterval);
|
||||||
}
|
}
|
||||||
else if (parser.getName().equals("identityName")) {
|
|
||||||
identityName = parser.nextText();
|
|
||||||
}
|
|
||||||
else if (parser.getName().equals("identityType")) {
|
|
||||||
identityType = parser.nextText();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
eventType = parser.next();
|
eventType = parser.next();
|
||||||
}
|
}
|
||||||
|
@ -203,52 +195,6 @@ public final class SmackConfiguration {
|
||||||
keepAliveInterval = interval;
|
keepAliveInterval = interval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of the client that will be returned when asked for the client identity
|
|
||||||
* in a disco request. The name could be any value you need to identity this client.
|
|
||||||
*
|
|
||||||
* @return the name of the client that will be returned when asked for the client identity
|
|
||||||
* in a disco request.
|
|
||||||
*/
|
|
||||||
public static String getIdentityName() {
|
|
||||||
return identityName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name of the client that will be returned when asked for the client identity
|
|
||||||
* in a disco request. The name could be any value you need to identity this client.
|
|
||||||
*
|
|
||||||
* @param name the name of the client that will be returned when asked for the client identity
|
|
||||||
* in a disco request.
|
|
||||||
*/
|
|
||||||
public static void setIdentityName(String name) {
|
|
||||||
identityName = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the type of client that will be returned when asked for the client identity in a
|
|
||||||
* disco request. The valid types are defined by the category client. Follow this link to learn
|
|
||||||
* the possible types: <a href="http://www.jabber.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
|
|
||||||
*
|
|
||||||
* @return the type of client that will be returned when asked for the client identity in a
|
|
||||||
* disco request.
|
|
||||||
*/
|
|
||||||
public static String getIdentityType() {
|
|
||||||
return identityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the type of client that will be returned when asked for the client identity in a
|
|
||||||
* disco request. The valid types are defined by the category client. Follow this link to learn
|
|
||||||
* the possible types: <a href="http://www.jabber.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
|
|
||||||
*
|
|
||||||
* @param type the type of client that will be returned when asked for the client identity in a
|
|
||||||
* disco request.
|
|
||||||
*/
|
|
||||||
public static void setIdentityType(String type) {
|
|
||||||
identityType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void parseClassToLoad(XmlPullParser parser) throws Exception {
|
private static void parseClassToLoad(XmlPullParser parser) throws Exception {
|
||||||
String className = parser.nextText();
|
String className = parser.nextText();
|
||||||
// Attempt to load the class so that the class can get initialized
|
// Attempt to load the class so that the class can get initialized
|
||||||
|
|
|
@ -72,6 +72,9 @@ import org.jivesoftware.smackx.packet.*;
|
||||||
*/
|
*/
|
||||||
public class ServiceDiscoveryManager {
|
public class ServiceDiscoveryManager {
|
||||||
|
|
||||||
|
private static String identityName = "Smack";
|
||||||
|
private static String identityType = "pc";
|
||||||
|
|
||||||
private static Map instances = new Hashtable();
|
private static Map instances = new Hashtable();
|
||||||
|
|
||||||
private XMPPConnection connection;
|
private XMPPConnection connection;
|
||||||
|
@ -109,6 +112,52 @@ public class ServiceDiscoveryManager {
|
||||||
return (ServiceDiscoveryManager) instances.get(connection);
|
return (ServiceDiscoveryManager) instances.get(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the name of the client that will be returned when asked for the client identity
|
||||||
|
* in a disco request. The name could be any value you need to identity this client.
|
||||||
|
*
|
||||||
|
* @return the name of the client that will be returned when asked for the client identity
|
||||||
|
* in a disco request.
|
||||||
|
*/
|
||||||
|
public static String getIdentityName() {
|
||||||
|
return identityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the client that will be returned when asked for the client identity
|
||||||
|
* in a disco request. The name could be any value you need to identity this client.
|
||||||
|
*
|
||||||
|
* @param name the name of the client that will be returned when asked for the client identity
|
||||||
|
* in a disco request.
|
||||||
|
*/
|
||||||
|
public static void setIdentityName(String name) {
|
||||||
|
identityName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of client that will be returned when asked for the client identity in a
|
||||||
|
* disco request. The valid types are defined by the category client. Follow this link to learn
|
||||||
|
* the possible types: <a href="http://www.jabber.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
|
||||||
|
*
|
||||||
|
* @return the type of client that will be returned when asked for the client identity in a
|
||||||
|
* disco request.
|
||||||
|
*/
|
||||||
|
public static String getIdentityType() {
|
||||||
|
return identityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the type of client that will be returned when asked for the client identity in a
|
||||||
|
* disco request. The valid types are defined by the category client. Follow this link to learn
|
||||||
|
* the possible types: <a href="http://www.jabber.org/registrar/disco-categories.html#client">Jabber::Registrar</a>.
|
||||||
|
*
|
||||||
|
* @param type the type of client that will be returned when asked for the client identity in a
|
||||||
|
* disco request.
|
||||||
|
*/
|
||||||
|
public static void setIdentityType(String type) {
|
||||||
|
identityType = type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the packet listeners of the connection that will answer to any
|
* Initializes the packet listeners of the connection that will answer to any
|
||||||
* service discovery request.
|
* service discovery request.
|
||||||
|
@ -171,8 +220,8 @@ public class ServiceDiscoveryManager {
|
||||||
response.setPacketID(discoverInfo.getPacketID());
|
response.setPacketID(discoverInfo.getPacketID());
|
||||||
// Set this client identity
|
// Set this client identity
|
||||||
DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
|
DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
|
||||||
SmackConfiguration.getIdentityName());
|
getIdentityName());
|
||||||
identity.setType(SmackConfiguration.getIdentityType());
|
identity.setType(getIdentityType());
|
||||||
response.addIdentity(identity);
|
response.addIdentity(identity);
|
||||||
// Add the registered features to the response
|
// Add the registered features to the response
|
||||||
synchronized (features) {
|
synchronized (features) {
|
||||||
|
|
|
@ -89,10 +89,10 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
|
||||||
Iterator identities = info.getIdentities();
|
Iterator identities = info.getIdentities();
|
||||||
assertTrue("No identities were found", identities.hasNext());
|
assertTrue("No identities were found", identities.hasNext());
|
||||||
DiscoverInfo.Identity identity = (DiscoverInfo.Identity)identities.next();
|
DiscoverInfo.Identity identity = (DiscoverInfo.Identity)identities.next();
|
||||||
assertEquals("Name in identity is wrong", SmackConfiguration.getIdentityName(),
|
assertEquals("Name in identity is wrong", ServiceDiscoveryManager.getIdentityName(),
|
||||||
identity.getName());
|
identity.getName());
|
||||||
assertEquals("Category in identity is wrong", "client", identity.getCategory());
|
assertEquals("Category in identity is wrong", "client", identity.getCategory());
|
||||||
assertEquals("Type in identity is wrong", SmackConfiguration.getIdentityType(),
|
assertEquals("Type in identity is wrong", ServiceDiscoveryManager.getIdentityType(),
|
||||||
identity.getType());
|
identity.getType());
|
||||||
assertFalse("More identities were found", identities.hasNext());
|
assertFalse("More identities were found", identities.hasNext());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue