Commit ba49dc5a authored by Matt Tucker's avatar Matt Tucker Committed by matt

Fixed text.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@4188 b35dd754-fafc-0310-a699-88a17e54d16e
parent 82911ecd
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</CLASSES> </CLASSES>
<JAVADOC /> <JAVADOC />
<SOURCES> <SOURCES>
<root url="file://$MODULE_DIR$/../whack/source/java" /> <root url="file://J:/whack/source/java" />
<root url="jar://$MODULE_DIR$/build/lib/merge/whack.jar!/" /> <root url="jar://$MODULE_DIR$/build/lib/merge/whack.jar!/" />
</SOURCES> </SOURCES>
</library> </library>
......
...@@ -23,9 +23,10 @@ import java.util.Map; ...@@ -23,9 +23,10 @@ import java.util.Map;
public interface PropertyEventListener { public interface PropertyEventListener {
/** /**
* A property was set. * A property was set. The parameter map <tt>params</tt> will contain the
* the value of the property under the key <tt>value</tt>.
* *
* @param property the property. * @param property the name of the property.
* @param params event parameters. * @param params event parameters.
*/ */
public void propertySet(String property, Map params); public void propertySet(String property, Map params);
...@@ -33,15 +34,16 @@ public interface PropertyEventListener { ...@@ -33,15 +34,16 @@ public interface PropertyEventListener {
/** /**
* A property was deleted. * A property was deleted.
* *
* @param property the deleted. * @param property the name of the property deleted.
* @param params event parameters. * @param params event parameters.
*/ */
public void propertyDeleted(String property, Map params); public void propertyDeleted(String property, Map params);
/** /**
* An XML property was set. * An XML property was set. The parameter map <tt>params</tt> will contain the
* the value of the property under the key <tt>value</tt>.
* *
* @param property the property. * @param property the name of the property.
* @param params event parameters. * @param params event parameters.
*/ */
public void xmlPropertySet(String property, Map params); public void xmlPropertySet(String property, Map params);
...@@ -49,7 +51,7 @@ public interface PropertyEventListener { ...@@ -49,7 +51,7 @@ public interface PropertyEventListener {
/** /**
* An XML property was deleted. * An XML property was deleted.
* *
* @param property the property. * @param property the name of the property.
* @param params event parameters. * @param params event parameters.
*/ */
public void xmlPropertyDeleted(String property, Map params); public void xmlPropertyDeleted(String property, Map params);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
package org.jivesoftware.wildfire.plugin; package org.jivesoftware.wildfire.plugin;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.PresenceManager; import org.jivesoftware.wildfire.PresenceManager;
import org.jivesoftware.wildfire.XMPPServer; import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.container.Plugin; import org.jivesoftware.wildfire.container.Plugin;
...@@ -19,42 +20,93 @@ import org.jivesoftware.wildfire.container.PluginManager; ...@@ -19,42 +20,93 @@ import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.user.User; import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserManager; import org.jivesoftware.wildfire.user.UserManager;
import org.jivesoftware.wildfire.user.UserNotFoundException; import org.jivesoftware.wildfire.user.UserNotFoundException;
import org.xmpp.component.ComponentManager;
import org.xmpp.component.ComponentManagerFactory;
import org.xmpp.component.Component;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.xmpp.packet.Packet;
import java.io.File; import java.io.File;
import java.util.HashMap;
import java.lang.Thread;
/** /**
* Plugin that includes a servlet that provides information about the presence type of the * Plugin that includes a servlet that provides information about the presence type of the
* users in the server. For security reasons, the XMPP spec does not allow anyone to see * users in the server. For security reasons, the XMPP spec does not allow anyone to see
* the presence of any user. Only the users that are subscribed to the presence of other * the presence of any user. Only the users that are subscribed to the presence of other
* users may see their presences.<p> * users may see their presences.<p/>
* *
* However, in order to make the servlet more useful it is possible to configure this plugin * However, in order to make the servlet more useful it is possible to configure this plugin
* so that anyone or only the users that are subscribed to a user presence may see the presence * so that anyone or only the users that are subscribed to a user presence may see the presence
* of other users.<p> * of other users.<p/>
* *
* Currently, the servlet provides information about user presences in two formats. In XML format * Currently, the servlet provides information about user presences in two formats. In XML format
* or using images. * or using images.
* *
* @author Gaston Dombiak * @author Gaston Dombiak
*/ */
public class PresencePlugin implements Plugin { public class PresencePlugin implements Plugin, Component {
private UserManager userManager; private UserManager userManager;
private PresenceManager presenceManager; private PresenceManager presenceManager;
private PluginManager pluginManager;
private ComponentManager componentManager;
private String hostname; private String hostname;
private HashMap<String, Presence> probedPresence;
public void initializePlugin(PluginManager manager, File pluginDirectory) { public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
XMPPServer server = XMPPServer.getInstance(); XMPPServer server = XMPPServer.getInstance();
userManager = server.getUserManager(); userManager = server.getUserManager();
presenceManager = server.getPresenceManager(); presenceManager = server.getPresenceManager();
hostname = server.getServerInfo().getName(); hostname = server.getServerInfo().getName();
probedPresence = new HashMap<String, Presence>();
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent("presence", this);
}
catch (Exception e) {
componentManager.getLog().error(e);
}
} }
public void destroyPlugin() { public void destroyPlugin() {
userManager = null; userManager = null;
presenceManager = null; presenceManager = null;
try {
componentManager.removeComponent("presence");
componentManager = null;
}
catch (Exception e) {
componentManager.getLog().error(e);
}
}
public String getName() {
return pluginManager.getName(this);
}
public String getDescription() {
return pluginManager.getDescription(this);
}
public void initialize(JID jid, ComponentManager componentManager) {
}
public void start() {
}
public void shutdown() {
}
public void processPacket(Packet packet) {
if (packet instanceof Presence) {
Presence presence = (Presence) packet;
probedPresence.put(presence.getFrom().toString(), presence);
}
} }
/** /**
...@@ -98,9 +150,32 @@ public class PresencePlugin implements Plugin { ...@@ -98,9 +150,32 @@ public class PresencePlugin implements Plugin {
throw new UserNotFoundException("Domain does not matches local server domain"); throw new UserNotFoundException("Domain does not matches local server domain");
} }
if (!hostname.equals(targetJID.getDomain())) { if (!hostname.equals(targetJID.getDomain())) {
// Sender is requesting information about component presence // Sender is requesting information about component presence, so we send a
// TODO Implement this // presence probe to the component.
throw new UserNotFoundException("Presence of components not supported yet!"); presenceManager.probePresence(new JID("presence." + hostname), targetJID);
int count = 0;
while (!probedPresence.containsKey(jid)) {
try {
Thread.sleep(100);
}
catch (InterruptedException e) {
// don't care!
}
count++;
if (count > 300) {
// After 30 seconds, timeout
throw new UserNotFoundException("Request for user presence has timed-out.");
}
}
// Clean-up
Presence presence = probedPresence.get(jid);
probedPresence.remove(jid);
return presence;
} }
if (targetJID.getNode() == null || if (targetJID.getNode() == null ||
!UserManager.getInstance().isRegisteredUser(targetJID.getNode())) { !UserManager.getInstance().isRegisteredUser(targetJID.getNode())) {
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
</tab> </tab>
<tab id="tab-users"> <tab id="tab-users">
<sidebar id="sidebar-users"> <sidebar id="sidebar-users">
<item id="advance-user-search" name="Advance User Search" <item id="advance-user-search" name="Advanced User Search"
url="advance-user-search.jsp" url="advance-user-search.jsp"
description="Advanced user search" /> description="Advanced user search" />
</sidebar> </sidebar>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment