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 @@
</CLASSES>
<JAVADOC />
<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!/" />
</SOURCES>
</library>
......
......@@ -23,9 +23,10 @@ import java.util.Map;
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.
*/
public void propertySet(String property, Map params);
......@@ -33,15 +34,16 @@ public interface PropertyEventListener {
/**
* A property was deleted.
*
* @param property the deleted.
* @param property the name of the property deleted.
* @param params event parameters.
*/
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.
*/
public void xmlPropertySet(String property, Map params);
......@@ -49,7 +51,7 @@ public interface PropertyEventListener {
/**
* An XML property was deleted.
*
* @param property the property.
* @param property the name of the property.
* @param params event parameters.
*/
public void xmlPropertyDeleted(String property, Map params);
......
......@@ -12,6 +12,7 @@
package org.jivesoftware.wildfire.plugin;
import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log;
import org.jivesoftware.wildfire.PresenceManager;
import org.jivesoftware.wildfire.XMPPServer;
import org.jivesoftware.wildfire.container.Plugin;
......@@ -19,42 +20,93 @@ import org.jivesoftware.wildfire.container.PluginManager;
import org.jivesoftware.wildfire.user.User;
import org.jivesoftware.wildfire.user.UserManager;
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.Presence;
import org.xmpp.packet.Packet;
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
* 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
* 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
* 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
* or using images.
*
* @author Gaston Dombiak
*/
public class PresencePlugin implements Plugin {
public class PresencePlugin implements Plugin, Component {
private UserManager userManager;
private PresenceManager presenceManager;
private PluginManager pluginManager;
private ComponentManager componentManager;
private String hostname;
private HashMap<String, Presence> probedPresence;
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
XMPPServer server = XMPPServer.getInstance();
userManager = server.getUserManager();
presenceManager = server.getPresenceManager();
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() {
userManager = 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 {
throw new UserNotFoundException("Domain does not matches local server domain");
}
if (!hostname.equals(targetJID.getDomain())) {
// Sender is requesting information about component presence
// TODO Implement this
throw new UserNotFoundException("Presence of components not supported yet!");
// Sender is requesting information about component presence, so we send a
// presence probe to the component.
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 ||
!UserManager.getInstance().isRegisteredUser(targetJID.getNode())) {
......
......@@ -19,7 +19,7 @@
</tab>
<tab id="tab-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"
description="Advanced user search" />
</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