Commit 36fd01be authored by Ryan Graham's avatar Ryan Graham Committed by ryang

fixes for various client compatiablity issues; jajc works properly...

fixes for various client compatiablity issues; jajc works properly (disco#info) and both psi and exodus can now add users directly from the search results


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1156 b35dd754-fafc-0310-a699-88a17e54d16e
parent f2836b87
version 1.0.4
---------------
* Added type and name attributes to the identity element when handling a disco#info query
* Added a check and appropriate response to a disco#items query
* Added a jid field when returning the search results
version 1.0.3 version 1.0.3
--------------- ---------------
* Fixed incompatiblity issue with psi * Fixed incompatiblity issue with psi
......
...@@ -5,6 +5,6 @@ ...@@ -5,6 +5,6 @@
<name>Search Plugin</name> <name>Search Plugin</name>
<description>Provides support for Jabber Search (JEP-0055)</description> <description>Provides support for Jabber Search (JEP-0055)</description>
<author>Ryan Graham</author> <author>Ryan Graham</author>
<version>1.0.3</version> <version>1.0.4</version>
<minServerVersion>2.1.2</minServerVersion> <minServerVersion>2.1.2</minServerVersion>
</plugin> </plugin>
\ No newline at end of file
...@@ -13,6 +13,7 @@ import java.util.*; ...@@ -13,6 +13,7 @@ import java.util.*;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.QName; import org.dom4j.QName;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.container.Plugin; import org.jivesoftware.messenger.container.Plugin;
import org.jivesoftware.messenger.container.PluginManager; import org.jivesoftware.messenger.container.PluginManager;
import org.jivesoftware.messenger.forms.DataForm; import org.jivesoftware.messenger.forms.DataForm;
...@@ -44,7 +45,7 @@ import org.xmpp.packet.Packet; ...@@ -44,7 +45,7 @@ import org.xmpp.packet.Packet;
* @author Ryan Graham * @author Ryan Graham
*/ */
public class SearchPlugin implements Component, Plugin { public class SearchPlugin implements Component, Plugin {
private XMPPServer server;
private UserManager userManager; private UserManager userManager;
private ComponentManager componentManager; private ComponentManager componentManager;
private PluginManager pluginManager; private PluginManager pluginManager;
...@@ -56,6 +57,7 @@ public class SearchPlugin implements Component, Plugin { ...@@ -56,6 +57,7 @@ public class SearchPlugin implements Component, Plugin {
private Collection<String> searchFields; private Collection<String> searchFields;
public SearchPlugin() { public SearchPlugin() {
server = XMPPServer.getInstance();
// See if the installed provider supports searching. If not, workaround // See if the installed provider supports searching. If not, workaround
// by providing our own searching. // by providing our own searching.
UserManager manager = UserManager.getInstance(); UserManager manager = UserManager.getInstance();
...@@ -131,6 +133,7 @@ public class SearchPlugin implements Component, Plugin { ...@@ -131,6 +133,7 @@ public class SearchPlugin implements Component, Plugin {
catch (Exception e) { catch (Exception e) {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
server = null;
userManager = null; userManager = null;
} }
...@@ -163,7 +166,9 @@ public class SearchPlugin implements Component, Plugin { ...@@ -163,7 +166,9 @@ public class SearchPlugin implements Component, Plugin {
Element responseElement = DocumentHelper.createElement(QName.get( Element responseElement = DocumentHelper.createElement(QName.get(
"query", "http://jabber.org/protocol/disco#info")); "query", "http://jabber.org/protocol/disco#info"));
responseElement.addElement("identity").addAttribute("category", "search"); responseElement.addElement("identity").addAttribute("category", "search")
.addAttribute("type", "text")
.addAttribute("name", "User Search");
responseElement.addElement("feature").addAttribute("var", "jabber:iq:search"); responseElement.addElement("feature").addAttribute("var", "jabber:iq:search");
replyPacket.setChildElement(responseElement); replyPacket.setChildElement(responseElement);
...@@ -173,6 +178,19 @@ public class SearchPlugin implements Component, Plugin { ...@@ -173,6 +178,19 @@ public class SearchPlugin implements Component, Plugin {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
} }
else if ("http://jabber.org/protocol/disco#items".equals(namespace)) {
try {
IQ replyPacket = IQ.createResultIQ(packet);
Element responseElement = DocumentHelper.createElement(QName.get(
"query", "http://jabber.org/protocol/disco#info"));
replyPacket.setChildElement(responseElement);
componentManager.sendPacket(this, replyPacket);
}
catch (ComponentException e) {
componentManager.getLog().error(e);
}
}
} }
} }
...@@ -199,8 +217,12 @@ public class SearchPlugin implements Component, Plugin { ...@@ -199,8 +217,12 @@ public class SearchPlugin implements Component, Plugin {
private IQ processSetPacket(IQ packet) { private IQ processSetPacket(IQ packet) {
XDataFormImpl searchResults = new XDataFormImpl(DataForm.TYPE_RESULT); XDataFormImpl searchResults = new XDataFormImpl(DataForm.TYPE_RESULT);
XFormFieldImpl field = new XFormFieldImpl("jid");
field.setLabel("JID");
searchResults.addReportedField(field);
for (String fieldName: searchFields) { for (String fieldName: searchFields) {
XFormFieldImpl field = new XFormFieldImpl(fieldName); field = new XFormFieldImpl(fieldName);
field.setLabel(initCap(fieldName)); field.setLabel(initCap(fieldName));
searchResults.addReportedField(field); searchResults.addReportedField(field);
} }
...@@ -246,11 +268,16 @@ public class SearchPlugin implements Component, Plugin { ...@@ -246,11 +268,16 @@ public class SearchPlugin implements Component, Plugin {
Iterator userIter = users.iterator(); Iterator userIter = users.iterator();
while (userIter.hasNext()) { while (userIter.hasNext()) {
User user = (User) userIter.next(); User user = (User) userIter.next();
String username = user.getName();
ArrayList<XFormFieldImpl> items = new ArrayList<XFormFieldImpl>(); ArrayList<XFormFieldImpl> items = new ArrayList<XFormFieldImpl>();
XFormFieldImpl fieldJID = new XFormFieldImpl("jid");
fieldJID.addValue(username + "@" + server.getServerInfo().getName());
items.add(fieldJID);
XFormFieldImpl fieldUsername = new XFormFieldImpl("Username"); XFormFieldImpl fieldUsername = new XFormFieldImpl("Username");
fieldUsername.addValue(user.getUsername()); fieldUsername.addValue(username);
items.add(fieldUsername); items.add(fieldUsername);
XFormFieldImpl fieldName = new XFormFieldImpl("Name"); XFormFieldImpl fieldName = new XFormFieldImpl("Name");
...@@ -329,12 +356,14 @@ public class SearchPlugin implements Component, Plugin { ...@@ -329,12 +356,14 @@ public class SearchPlugin implements Component, Plugin {
Log.error("Error getting user", e); Log.error("Error getting user", e);
} }
} else if (field.equals("Name")) { }
else if (field.equals("Name")) {
if (query.equalsIgnoreCase(user.getName())) { if (query.equalsIgnoreCase(user.getName())) {
foundUsers.add(user); foundUsers.add(user);
} }
} else if (field.equals("Email")) { }
else if (field.equals("Email")) {
if (user.getEmail() != null) { if (user.getEmail() != null) {
if (query.equalsIgnoreCase(user.getEmail())) { if (query.equalsIgnoreCase(user.getEmail())) {
foundUsers.add(user); foundUsers.add(user);
......
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