Commit d21ae01d authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Work in progress on options interface.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@6337 b35dd754-fafc-0310-a699-88a17e54d16e
parent 94747885
...@@ -1705,4 +1705,15 @@ public abstract class BaseTransport implements Component, RosterEventListener { ...@@ -1705,4 +1705,15 @@ public abstract class BaseTransport implements Component, RosterEventListener {
*/ */
public abstract Boolean isUsernameValid(String username); public abstract Boolean isUsernameValid(String username);
/**
* Return an xml config for the options panel in the admin interface.
*
* Return nothing for no options. This is not officially documented anywhere yet.
* TODO: like.. document it somewhere. =)
*
* @param type The transport type to distinguish if needed.
* @return XML document describing the options interface.
*/
public static Element getOptionsConfig(TransportType type) { return DocumentHelper.createElement("optionconfig"); }
} }
...@@ -15,6 +15,7 @@ import org.jivesoftware.util.Log; ...@@ -15,6 +15,7 @@ import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventListener; import org.jivesoftware.util.PropertyEventListener;
import org.jivesoftware.util.PropertyEventDispatcher; import org.jivesoftware.util.PropertyEventDispatcher;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
import org.dom4j.Element;
import java.util.Map; import java.util.Map;
...@@ -226,4 +227,8 @@ public class TransportInstance implements PropertyEventListener { ...@@ -226,4 +227,8 @@ public class TransportInstance implements PropertyEventListener {
propertyDeleted(property, params); propertyDeleted(property, params);
} }
public Element getOptionsConfig() {
return transport.getOptionsConfig(this.type);
}
} }
...@@ -14,6 +14,8 @@ import org.jivesoftware.wildfire.gateway.*; ...@@ -14,6 +14,8 @@ import org.jivesoftware.wildfire.gateway.*;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
/*** /***
* IRC Transport Interface. * IRC Transport Interface.
...@@ -70,6 +72,26 @@ public class IRCTransport extends BaseTransport { ...@@ -70,6 +72,26 @@ public class IRCTransport extends BaseTransport {
return username.matches("\\w+"); return username.matches("\\w+");
} }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getOptionsConfig(org.jivesoftware.wildfire.gateway.TransportType)
* @param type The transport type to distinguish if needed.
* @return XML document describing the options interface.
*/
public static Element getOptionsConfig(TransportType type) {
Element optConfig = DocumentHelper.createElement("optionconfig");
Element leftPanel = optConfig.addElement("leftpanel");
Element rightPanel = optConfig.addElement("rightpanel");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.irc.connecthost")
.addAttribute("desc", "Host");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.irc.connectport")
.addAttribute("desc", "Port");
return optConfig;
}
/** /**
* Handles creating a IRC session and triggering a login. * Handles creating a IRC session and triggering a login.
* *
......
...@@ -15,6 +15,8 @@ import org.jivesoftware.util.LocaleUtils; ...@@ -15,6 +15,8 @@ import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.wildfire.gateway.*; import org.jivesoftware.wildfire.gateway.*;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
import net.sf.jml.MsnUserStatus; import net.sf.jml.MsnUserStatus;
/** /**
...@@ -72,6 +74,26 @@ public class MSNTransport extends BaseTransport { ...@@ -72,6 +74,26 @@ public class MSNTransport extends BaseTransport {
return username.matches("[^ \\p{Cntrl}()@,;:\\\\\"\\[\\]]+@[^ \\p{Cntrl}()@,;:\\\\\"\\[\\]]+"); return username.matches("[^ \\p{Cntrl}()@,;:\\\\\"\\[\\]]+@[^ \\p{Cntrl}()@,;:\\\\\"\\[\\]]+");
} }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getOptionsConfig(org.jivesoftware.wildfire.gateway.TransportType)
* @param type The transport type to distinguish if needed.
* @return XML document describing the options interface.
*/
public static Element getOptionsConfig(TransportType type) {
Element optConfig = DocumentHelper.createElement("optionconfig");
Element leftPanel = optConfig.addElement("leftpanel");
Element rightPanel = optConfig.addElement("rightpanel");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.msn.connecthost")
.addAttribute("desc", "Host");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.msn.connectport")
.addAttribute("desc", "Port");
return optConfig;
}
/** /**
* Handles creating a MSN session and triggering a login. * Handles creating a MSN session and triggering a login.
* *
......
...@@ -13,6 +13,8 @@ package org.jivesoftware.wildfire.gateway.protocols.oscar; ...@@ -13,6 +13,8 @@ package org.jivesoftware.wildfire.gateway.protocols.oscar;
import org.jivesoftware.util.LocaleUtils; import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.wildfire.gateway.*; import org.jivesoftware.wildfire.gateway.*;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
/** /**
* OSCAR Transport Interface. * OSCAR Transport Interface.
...@@ -74,6 +76,32 @@ public class OSCARTransport extends BaseTransport { ...@@ -74,6 +76,32 @@ public class OSCARTransport extends BaseTransport {
} }
} }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getOptionsConfig(org.jivesoftware.wildfire.gateway.TransportType)
* @param type The transport type to distinguish if needed.
* @return XML document describing the options interface.
*/
public static Element getOptionsConfig(TransportType type) {
Element optConfig = DocumentHelper.createElement("optionconfig");
Element leftPanel = optConfig.addElement("leftpanel");
Element rightPanel = optConfig.addElement("rightpanel");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway."+type.toString()+".connecthost")
.addAttribute("desc", "Host");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway."+type.toString()+".connectport")
.addAttribute("desc", "Port");
if (type == TransportType.icq) {
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.icq.encoding")
.addAttribute("desc", "Encoding");
}
return optConfig;
}
/** /**
* Handles creating an OSCAR session and triggering a login. * Handles creating an OSCAR session and triggering a login.
* *
......
...@@ -15,6 +15,8 @@ import org.jivesoftware.util.LocaleUtils; ...@@ -15,6 +15,8 @@ import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.wildfire.gateway.*; import org.jivesoftware.wildfire.gateway.*;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
import org.xmpp.packet.Presence; import org.xmpp.packet.Presence;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
import ymsg.network.StatusConstants; import ymsg.network.StatusConstants;
/** /**
...@@ -70,7 +72,27 @@ public class YahooTransport extends BaseTransport { ...@@ -70,7 +72,27 @@ public class YahooTransport extends BaseTransport {
*/ */
public Boolean isUsernameValid(String username) { public Boolean isUsernameValid(String username) {
return username.matches("\\w+"); return username.matches("\\w+");
} }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getOptionsConfig(org.jivesoftware.wildfire.gateway.TransportType)
* @param type The transport type to distinguish if needed.
* @return XML document describing the options interface.
*/
public static Element getOptionsConfig(TransportType type) {
Element optConfig = DocumentHelper.createElement("optionconfig");
Element leftPanel = optConfig.addElement("leftpanel");
Element rightPanel = optConfig.addElement("rightpanel");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.yahoo.connecthost")
.addAttribute("desc", "Host");
rightPanel.addElement("item")
.addAttribute("type", "text")
.addAttribute("sysprop", "plugin.gateway.yahoo.connectport")
.addAttribute("desc", "Port");
return optConfig;
}
/** /**
* Handles creating a Yahoo session and triggering a login. * Handles creating a Yahoo session and triggering a login.
......
...@@ -17,7 +17,8 @@ import org.jivesoftware.wildfire.gateway.GatewayPlugin; ...@@ -17,7 +17,8 @@ import org.jivesoftware.wildfire.gateway.GatewayPlugin;
/** /**
* Transport Instance Manager * Transport Instance Manager
* *
* Handles web interface interactions with the transport instances. * Handles web interface interactions with the transport instances, such as enabling or
* disabling them, configuring options, etc.
* *
* @author Daniel Henninger * @author Daniel Henninger
*/ */
......
...@@ -5,28 +5,61 @@ ...@@ -5,28 +5,61 @@
errorPage="error.jsp" errorPage="error.jsp"
%> %>
<%@ page import="org.jivesoftware.util.LocaleUtils"%> <%@ page import="org.jivesoftware.util.LocaleUtils"%>
<%@ page import="org.jivesoftware.wildfire.gateway.TransportInstance" %>
<%@ page import="org.dom4j.Element" %>
<%@ page import="org.dom4j.Attribute" %>
<%@ page import="org.jivesoftware.util.Log" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %> <%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
<% <%
GatewayPlugin plugin = (GatewayPlugin)XMPPServer.getInstance().getPluginManager().getPlugin("gateway"); final GatewayPlugin plugin =
(GatewayPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("gateway");
class GatewaySettings { class GatewaySettings {
String description = null; String description = null;
TransportType gatewayType = null; TransportType gatewayType = null;
boolean gwEnabled = false; boolean gwEnabled = false;
JspWriter out = null; JspWriter out = null;
GatewaySettings(JspWriter out, GatewayPlugin plugin, TransportType gatewayType, String desc) { GatewaySettings(JspWriter out, GatewayPlugin plugin, TransportType gatewayType,
String desc) {
this.description = desc; this.description = desc;
this.gatewayType = gatewayType; this.gatewayType = gatewayType;
this.gwEnabled = plugin.serviceEnabled(gatewayType.toString()); this.gwEnabled = plugin.serviceEnabled(gatewayType.toString());
this.out = out; this.out = out;
} }
void printConfigNode(Element node) {
try {
Log.debug("WHEE: " + node);
Attribute type = node.attribute("type");
if (type.equals("text")) {
Attribute desc = node.attribute("desc");
out.println("<tr valign='middle'>");
out.println("<td align='right' width='1%'>" + desc + ":</td>");
out.println("<td><input type='text' name='var' value='blar'/></td>");
out.println("</tr>");
// <tr valign="middle">
// <td align="right" width="1%">Host:</td>
// <td><input type="text" name="host" value="blar" onChange="getElementById('testhost').innerHTML = this.value" /></td>
// </tr>
}
}
catch (Exception e) {
// Uhm, yeah, that sucks.
}
}
void printSettingsDialog() { void printSettingsDialog() {
try { try {
TransportInstance trInstance = plugin.getTransportInstance(gatewayType.toString());
Element optConfig = trInstance.getOptionsConfig();
Element leftPanel = optConfig.element("leftpanel");
Element rightPanel = optConfig.element("rightpanel");
%> %>
<!-- BEGIN gateway - <%= this.gatewayType.toString().toUpperCase() %> --> <!-- BEGIN gateway - <%= this.gatewayType.toString().toUpperCase() %> -->
...@@ -57,32 +90,64 @@ ...@@ -57,32 +90,64 @@
<table border="0" cellpadding="0" cellspacing="0"> <table border="0" cellpadding="0" cellspacing="0">
<tr valign="top"> <tr valign="top">
<td align="left" width="50%"> <td align="left" width="50%">
<table border="0" cellpadding="1" cellspacing="2"> <%
<tr valign="middle"> if (leftPanel != null && leftPanel.nodeCount() > 0) {
<td width="1%"><input type="checkbox" name="filetransfer" value="enabled"></td> Log.debug("left WTF?");
<td>Enable file transfer</td> out.println("<table border='0' cellpadding='1' cellspacing='2'");
</tr> for (Object nodeObj : leftPanel.elements()) {
<tr valign="middle"> Log.debug("more left WTF?"+nodeObj);
<td width="1%"><input type="checkbox" name="reconnect" value="enabled"></td> Element node = (Element)nodeObj;
<td>Reconnect on disconnect</td> printConfigNode(node);
</tr> }
<tr valign="middle"> out.println("</table");
<td width="1%">&nbsp;</td> }
<td>Reconnect Attemps: <input type="text" style="margin: 0.0px; padding: 0.0px" name="reconnect_attempts" size="4" maxlength="4" value="10" /></td> // <tr valign = "middle" >
</tr> // <td width = "1%" ><input type = "checkbox"
</table> // name = "filetransfer"
// value = "enabled" ></td >
// <td > Enable
// file transfer</td >
// </tr >
// <tr valign = "middle" >
// <td width = "1%" ><input type = "checkbox"
// name = "reconnect"
// value = "enabled" ></td >
// <td > Reconnect
// on disconnect</td >
// </tr >
// <tr valign = "middle" >
// <td width = "1%" > & nbsp;</td >
// <td > Reconnect
// Attemps:<input type = "text"
// style = "margin: 0.0px; padding: 0.0px"
// name = "reconnect_attempts"
// size = "4"
// maxlength = "4"
// value = "10" / ></td >
// </tr >
%>
</td> </td>
<td align="left" width="50%"> <td align="left" width="50%">
<table border="0"> <%
<tr valign="middle"> if (rightPanel != null && rightPanel.nodeCount() > 0) {
<td align="right" width="1%">Host:</td> Log.debug("right WTF?");
<td><input type="text" name="host" value="blar" onChange="getElementById('testhost').innerHTML = this.value" /></td> out.println("<table border='0' cellpadding='1' cellspacing='2'");
</tr> for (Object nodeObj : rightPanel.elements()) {
<tr valign="middle"> Log.debug("more right WTF?"+nodeObj);
<td align="right" width="1%">Port:</td> Element node = (Element)nodeObj;
<td><input type="text" name="host" value="1234" onChange="getElementById('testport').innerHTML = this.value" /></td> printConfigNode(node);
</tr> }
</table> out.println("</table");
}
// <tr valign="middle">
// <td align="right" width="1%">Host:</td>
// <td><input type="text" name="host" value="blar" onChange="getElementById('testhost').innerHTML = this.value" /></td>
// </tr>
// <tr valign="middle">
// <td align="right" width="1%">Port:</td>
// <td><input type="text" name="host" value="1234" onChange="getElementById('testport').innerHTML = this.value" /></td>
// </tr>
%>
</td> </td>
</tr> </tr>
</table> </table>
...@@ -121,7 +186,7 @@ ...@@ -121,7 +186,7 @@
<% <%
} }
catch (Exception e) { catch (Exception e) {
// hrm // Uhm, yeah, that sucks.
} }
} }
} }
......
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