Commit 340e52b9 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Release all resources so that plugin can unload properly.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1136 b35dd754-fafc-0310-a699-88a17e54d16e
parent e588ff93
...@@ -45,9 +45,9 @@ import org.xmpp.packet.Packet; ...@@ -45,9 +45,9 @@ import org.xmpp.packet.Packet;
*/ */
public class SearchPlugin implements Component, Plugin { public class SearchPlugin implements Component, Plugin {
private UserManager userManager = null; private UserManager userManager;
private ComponentManager componentManager = null; private ComponentManager componentManager;
private PluginManager pluginManager = null; private PluginManager pluginManager;
private static final String SERVICE_NAME = "search"; private static final String SERVICE_NAME = "search";
...@@ -126,10 +126,13 @@ public class SearchPlugin implements Component, Plugin { ...@@ -126,10 +126,13 @@ public class SearchPlugin implements Component, Plugin {
pluginManager = null; pluginManager = null;
try { try {
componentManager.removeComponent(SERVICE_NAME); componentManager.removeComponent(SERVICE_NAME);
} catch (Exception e) { componentManager = null;
}
catch (Exception e) {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
} userManager = null;
}
public void shutdown() { public void shutdown() {
} }
...@@ -148,11 +151,13 @@ public class SearchPlugin implements Component, Plugin { ...@@ -148,11 +151,13 @@ public class SearchPlugin implements Component, Plugin {
try { try {
IQ replyPacket = handleIQ(packet); IQ replyPacket = handleIQ(packet);
componentManager.sendPacket(this, replyPacket); componentManager.sendPacket(this, replyPacket);
} catch (ComponentException e) { }
catch (ComponentException e) {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
} else if ("http://jabber.org/protocol/disco#info".equals(namespace)) { }
else if ("http://jabber.org/protocol/disco#info".equals(namespace)) {
try { try {
IQ replyPacket = IQ.createResultIQ(packet); IQ replyPacket = IQ.createResultIQ(packet);
...@@ -163,7 +168,8 @@ public class SearchPlugin implements Component, Plugin { ...@@ -163,7 +168,8 @@ public class SearchPlugin implements Component, Plugin {
replyPacket.setChildElement(responseElement); replyPacket.setChildElement(responseElement);
componentManager.sendPacket(this, replyPacket); componentManager.sendPacket(this, replyPacket);
} catch (ComponentException e) { }
catch (ComponentException e) {
componentManager.getLog().error(e); componentManager.getLog().error(e);
} }
} }
...@@ -174,7 +180,8 @@ public class SearchPlugin implements Component, Plugin { ...@@ -174,7 +180,8 @@ public class SearchPlugin implements Component, Plugin {
if (IQ.Type.get.equals(packet.getType())) { if (IQ.Type.get.equals(packet.getType())) {
return processGetPacket(packet); return processGetPacket(packet);
} else if (IQ.Type.set.equals(packet.getType())) { }
else if (IQ.Type.set.equals(packet.getType())) {
return processSetPacket(packet); return processSetPacket(packet);
} }
...@@ -224,7 +231,7 @@ public class SearchPlugin implements Component, Plugin { ...@@ -224,7 +231,7 @@ public class SearchPlugin implements Component, Plugin {
queryField.getTextTrim()).iterator(); queryField.getTextTrim()).iterator();
} }
// filter out all duplicate users // Filter out all duplicate users.
if (foundIter != null) { if (foundIter != null) {
while (foundIter.hasNext()) { while (foundIter.hasNext()) {
User user = (User) foundIter.next(); User user = (User) foundIter.next();
...@@ -335,7 +342,8 @@ public class SearchPlugin implements Component, Plugin { ...@@ -335,7 +342,8 @@ public class SearchPlugin implements Component, Plugin {
} }
} }
} }
} else { }
else {
String prefix = query.substring(0, index); String prefix = query.substring(0, index);
Iterator users = userManager.getUsers().iterator(); Iterator users = userManager.getUsers().iterator();
while (users.hasNext()) { while (users.hasNext()) {
...@@ -344,9 +352,11 @@ public class SearchPlugin implements Component, Plugin { ...@@ -344,9 +352,11 @@ public class SearchPlugin implements Component, Plugin {
String userInfo = ""; String userInfo = "";
if (field.equals("Username")) { if (field.equals("Username")) {
userInfo = user.getUsername(); userInfo = user.getUsername();
} else if (field.equals("Name")) { }
else if (field.equals("Name")) {
userInfo = user.getName(); userInfo = user.getName();
} else if (field.equals("Email")) { }
else if (field.equals("Email")) {
userInfo = user.getEmail() == null ? "" : user.getEmail(); userInfo = user.getEmail() == null ? "" : user.getEmail();
} }
...@@ -360,4 +370,4 @@ public class SearchPlugin implements Component, Plugin { ...@@ -360,4 +370,4 @@ public class SearchPlugin implements Component, Plugin {
return foundUsers; return foundUsers;
} }
} }
\ No newline at end of file
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