--- ../orig-source/./org/jivesoftware/smack/PacketWriter.java	2004-08-15 15:10:22.000000000 +0300
+++ ./org/jivesoftware/smack/PacketWriter.java	2004-08-24 13:31:52.000000000 +0300
@@ -221,9 +221,14 @@
             // Open the stream.
             StringBuffer stream = new StringBuffer();
             stream.append("<stream:stream");
-            stream.append(" to=\"" + connection.getHost() + "\"");
-            stream.append(" xmlns=\"jabber:client\"");
-            stream.append(" xmlns:stream=\"http://etherx.jabber.org/streams\">");
+            stream.append(" xmlns=\"");
+            stream.append(connection.getNamespace());
+            stream.append('"');
+            stream.append(" xmlns:stream=\"http://etherx.jabber.org/streams\"");
+            stream.append(" to=\"");
+            stream.append(connection.getLocalServiceName());
+            stream.append('"');
+            stream.append('>');
             writer.write(stream.toString());
             writer.flush();
             stream = null;
--- ../orig-source/./org/jivesoftware/smack/XMPPConnection.java	2004-08-15 15:10:22.000000000 +0300
+++ ./org/jivesoftware/smack/XMPPConnection.java	2004-08-24 13:13:45.000000000 +0300
@@ -109,6 +109,9 @@
     }
     private SmackDebugger debugger = null;
 
+    String namespace;
+    String localServiceName;
+    String remoteServiceName;
     String host;
     int port;
     Socket socket;
@@ -132,21 +135,25 @@
      * Creates a new connection to the specified XMPP server. The default port of 5222 will
      * be used.
      *
-     * @param host the name of the XMPP server to connect to; e.g. <tt>jivesoftware.com</tt>.
+     * @param namespace namespace for connection stream
+     * @param localServiceName the name of local service name; e.g. <tt>jud.jivesoftware.com</tt>.
+     * @param host the name of the XMPP host to connect to; e.g. <tt>jivesoftware.com</tt>.
      * @throws XMPPException if an error occurs while trying to establish the connection.
      *      Two possible errors can occur which will be wrapped by an XMPPException --
      *      UnknownHostException (XMPP error code 504), and IOException (XMPP error code
      *      502). The error codes and wrapped exceptions can be used to present more
      *      appropiate error messages to end-users.
      */
-    public XMPPConnection(String host) throws XMPPException {
-        this(host, 5222);
+    public XMPPConnection(String namespace, String localServiceName, String host) throws XMPPException {
+        this(namespace, localServiceName, host, 5222);
     }
 
     /**
      * Creates a new connection to the specified XMPP server on the given port.
      *
-     * @param host the name of the XMPP server to connect to; e.g. <tt>jivesoftware.com</tt>.
+     * @param namespace namespace for connection stream
+     * @param localServiceName the name of local service name; e.g. <tt>jud.jivesoftware.com</tt>.
+     * @param host the name of the XMPP host to connect to; e.g. <tt>jivesoftware.com</tt>.
      * @param port the port on the server that should be used; e.g. <tt>5222</tt>.
      * @throws XMPPException if an error occurs while trying to establish the connection.
      *      Two possible errors can occur which will be wrapped by an XMPPException --
@@ -154,7 +161,9 @@
      *      502). The error codes and wrapped exceptions can be used to present more
      *      appropiate error messages to end-users.
      */
-    public XMPPConnection(String host, int port) throws XMPPException {
+    public XMPPConnection(String namespace, String localServiceName, String host, int port) throws XMPPException {
+        this.namespace = namespace;
+        this.localServiceName = localServiceName;
         this.host = host;
         this.port = port;
         try {
@@ -181,7 +190,9 @@
      * <p>A custom SocketFactory allows fine-grained control of the actual connection to the XMPP server. A typical
      * use for a custom SocketFactory is when connecting through a SOCKS proxy.
      *
-     * @param host the name of the XMPP server to connect to; e.g. <tt>jivesoftware.com</tt>.
+     * @param namespace namespace for connection stream
+     * @param localServiceName the name of local service name; e.g. <tt>jud.jivesoftware.com</tt>.
+     * @param host the name of the XMPP host to connect to; e.g. <tt>jivesoftware.com</tt>.
      * @param port the port on the server that should be used; e.g. <tt>5222</tt>.
      * @param socketFactory a SocketFactory that will be used to create the socket to the XMPP server.
      * @throws XMPPException if an error occurs while trying to establish the connection.
@@ -190,7 +201,9 @@
      *      502). The error codes and wrapped exceptions can be used to present more
      *      appropiate error messages to end-users.
      */
-    public XMPPConnection(String host, int port, SocketFactory socketFactory) throws XMPPException {
+    public XMPPConnection(String namespace, String localServiceName, String host, int port, SocketFactory socketFactory) throws XMPPException {
+        this.namespace = namespace;
+        this.localServiceName = localServiceName;
         this.host = host;
         this.port = port;
         try {
@@ -223,6 +236,33 @@
     }
 
     /**
+     * Returns the local service name for this connection.
+     *
+     * @return the service name.
+     */
+    public String getLocalServiceName() {
+        return localServiceName;
+    }
+
+    /**
+     * Returns the remote service name for this connection.
+     *
+     * @return the service name.
+     */
+    public String getRemoteServiceName() {
+        return remoteServiceName;
+    }
+
+    /**
+     * Returns the namespace for this connection.
+     *
+     * @return the namespace name.
+     */
+    public String getNamespace() {
+        return namespace;
+    }
+
+    /**
      * Returns the host name of the XMPP server for this connection.
      *
      * @return the host name of the XMPP server.
--- ../orig-source/./org/jivesoftware/smack/packet/IQ.java	2004-08-15 15:10:22.000000000 +0300
+++ ./org/jivesoftware/smack/packet/IQ.java	2004-08-24 13:00:39.000000000 +0300
@@ -100,7 +100,7 @@
 
     public String toXML() {
         StringBuffer buf = new StringBuffer();
-        buf.append("<iq ");
+        buf.append("<iq xmlns=\"jabber:client\" ");
         if (getPacketID() != null) {
             buf.append("id=\"" + getPacketID() + "\" ");
         }
--- ../orig-source/./org/jivesoftware/smack/SSLXMPPConnection.java	2004-08-15 15:10:22.000000000 +0300
+++ ./org/jivesoftware/smack/SSLXMPPConnection.java	2004-08-24 13:14:05.000000000 +0300
@@ -78,6 +78,8 @@
      * Creates a new SSL connection to the specified host on the default
      * SSL port (5223).
      *
+     * @param namespace namespace for connection stream
+     * @param localServiceName the name of local service name; e.g. <tt>jud.jivesoftware.com</tt>.
      * @param host the XMPP host.
      * @throws XMPPException if an error occurs while trying to establish the connection.
      *      Two possible errors can occur which will be wrapped by an XMPPException --
@@ -85,13 +87,15 @@
      *      502). The error codes and wrapped exceptions can be used to present more
      *      appropiate error messages to end-users.
      */
-    public SSLXMPPConnection(String host) throws XMPPException {
-        this(host, 5223);
+    public SSLXMPPConnection(String namespace, String localServiceName, String host) throws XMPPException {
+        this(namespace, localServiceName, host, 5223);
     }
 
     /**
      * Creates a new SSL connection to the specified host on the specified port.
      *
+     * @param namespace namespace for connection stream
+     * @param localServiceName the name of local service name; e.g. <tt>jud.jivesoftware.com</tt>.
      * @param host the XMPP host.
      * @param port the port to use for the connection (default XMPP SSL port is 5223).
      * @throws XMPPException if an error occurs while trying to establish the connection.
@@ -100,8 +104,8 @@
      *      502). The error codes and wrapped exceptions can be used to present more
      *      appropiate error messages to end-users.
      */
-    public SSLXMPPConnection(String host, int port) throws XMPPException {
-        super(host, port, socketFactory);
+    public SSLXMPPConnection(String namespace, String localServiceName, String host, int port) throws XMPPException {
+        super(namespace, localServiceName, host, port, socketFactory);
     }
 
     public boolean isSecureConnection() {
--- ../orig-source/./org/jivesoftware/smack/PacketReader.java	2004-08-15 15:10:22.000000000 +0300
+++ ./org/jivesoftware/smack/PacketReader.java	2004-08-24 13:15:18.000000000 +0300
@@ -283,7 +283,7 @@
                     // the connectionID lock so that the packet reader startup can finish.
                     else if (parser.getName().equals("stream")) {
                         // Ensure the correct jabber:client namespace is being used.
-                        if ("jabber:client".equals(parser.getNamespace(null))) {
+                        if (connection.getNamespace().equals(parser.getNamespace(null))) {
                             // Get the connection id.
                             for (int i=0; i<parser.getAttributeCount(); i++) {
                                 if (parser.getAttributeName(i).equals("id")) {
@@ -295,7 +295,7 @@
                                 }
                                 else if (parser.getAttributeName(i).equals("from")) {
                                     // Use the server name that the server says that it is.
-                                    connection.host = parser.getAttributeValue(i);
+                                    connection.remoteServiceName = parser.getAttributeValue(i);
                                 }
                             }
                         }
--- ../orig-source/./org/jivesoftware/smackx/ServiceDiscoveryManager.java	2004-08-15 15:10:22.000000000 +0300
+++ ./org/jivesoftware/smackx/ServiceDiscoveryManager.java	2004-08-24 13:06:45.000000000 +0300
@@ -72,6 +72,7 @@
  */
 public class ServiceDiscoveryManager {
 
+    private static String identityCategory = "client";
     private static String identityName = "Smack";
     private static String identityType = "pc";
 
@@ -113,6 +114,24 @@
     }
 
     /**
+     * Returns the identity category.
+     *
+     * @return identity category
+     */
+    public static String getIdentityCategory() {
+        return identityCategory;
+    }
+
+    /**
+     * Sets the identity category.
+     *
+     * @param identityCategory identity category
+     */
+    public static void setIdentityCategory(String identityCategory) {
+        ServiceDiscoveryManager.identityCategory = identityCategory;
+    }
+
+    /**
      * 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.
      * 
@@ -189,6 +208,7 @@
                     DiscoverItems response = new DiscoverItems();
                     response.setType(IQ.Type.RESULT);
                     response.setTo(discoverItems.getFrom());
+                    response.setFrom(connection.getLocalServiceName());
                     response.setPacketID(discoverItems.getPacketID());
 
                     // Add the defined items related to the requested node. Look for 
@@ -217,9 +237,10 @@
                     DiscoverInfo response = new DiscoverInfo();
                     response.setType(IQ.Type.RESULT);
                     response.setTo(discoverInfo.getFrom());
+                    response.setFrom(connection.getLocalServiceName());
                     response.setPacketID(discoverInfo.getPacketID());
                     // Set this client identity
-                    DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
+                    DiscoverInfo.Identity identity = new DiscoverInfo.Identity(getIdentityCategory(),
                             getIdentityName());
                     identity.setType(getIdentityType());
                     response.addIdentity(identity);
