Commit 37bb5df7 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-8] Options interface now functional.

[GATE-92] As part of above, can now set icq encoding from web interface.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@6350 b35dd754-fafc-0310-a699-88a17e54d16e
parent 42223153
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* This software is published under the terms of the GNU Public License (GPL), * This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution. * a copy of which is included in this distribution.
*/ */
package org.jivesoftware.wildfire.gateway.web; package org.jivesoftware.wildfire.gateway.web;
import org.jivesoftware.wildfire.container.PluginManager; import org.jivesoftware.wildfire.container.PluginManager;
...@@ -20,15 +19,17 @@ import org.dom4j.Document; ...@@ -20,15 +19,17 @@ import org.dom4j.Document;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.Attribute; import org.dom4j.Attribute;
import java.util.HashMap;
/** /**
* Transport Instance Manager * Transport Configuration Manager (for web interface)
* *
* Handles web interface interactions with the transport instances, such as enabling or * Handles web interface interactions with the transport instances, such as enabling or
* disabling them, configuring options, etc. * disabling them, configuring options, etc.
* *
* @author Daniel Henninger * @author Daniel Henninger
*/ */
public class TransportInstanceManager { public class ConfigManager {
/** /**
* Toggles whether a transport is enabled or disabled. * Toggles whether a transport is enabled or disabled.
...@@ -55,7 +56,7 @@ public class TransportInstanceManager { ...@@ -55,7 +56,7 @@ public class TransportInstanceManager {
* @param transportName Name of the transport to have it's options saved (type of transport) * @param transportName Name of the transport to have it's options saved (type of transport)
* @param options Options passed from options form. * @param options Options passed from options form.
*/ */
public void saveSettings(String transportName, TransportOptions options) { public void saveSettings(String transportName, HashMap<String,String> options) {
PluginManager pluginManager = XMPPServer.getInstance().getPluginManager(); PluginManager pluginManager = XMPPServer.getInstance().getPluginManager();
GatewayPlugin plugin = (GatewayPlugin)pluginManager.getPlugin("gateway"); GatewayPlugin plugin = (GatewayPlugin)pluginManager.getPlugin("gateway");
Document optConfig = plugin.getOptionsConfig(TransportType.valueOf(transportName)); Document optConfig = plugin.getOptionsConfig(TransportType.valueOf(transportName));
...@@ -83,7 +84,7 @@ public class TransportInstanceManager { ...@@ -83,7 +84,7 @@ public class TransportInstanceManager {
* @param node Node describing the configuration item. * @param node Node describing the configuration item.
* @param options Options passed from form. * @param options Options passed from form.
*/ */
private void saveOptionSetting(Element node, TransportOptions options) { private void saveOptionSetting(Element node, HashMap<String,String> options) {
Attribute type = node.attribute("type"); Attribute type = node.attribute("type");
if (type.getText().equals("text")) { if (type.getText().equals("text")) {
// Required fields // Required fields
...@@ -98,13 +99,13 @@ public class TransportInstanceManager { ...@@ -98,13 +99,13 @@ public class TransportInstanceManager {
// Process any variables that we are setting. // Process any variables that we are setting.
if (var.getText().equals("host")) { if (var.getText().equals("host")) {
JiveGlobals.setProperty(sysprop.getText(), options.host); JiveGlobals.setProperty(sysprop.getText(), options.get("host"));
} }
else if (var.getText().equals("port")) { else if (var.getText().equals("port")) {
JiveGlobals.setProperty(sysprop.getText(), options.port); JiveGlobals.setProperty(sysprop.getText(), options.get("port"));
} }
else if (var.getText().equals("encoding")) { else if (var.getText().equals("encoding")) {
JiveGlobals.setProperty(sysprop.getText(), options.encoding); JiveGlobals.setProperty(sysprop.getText(), options.get("encoding"));
} }
} }
else if (type.getText().equals("toggle")) { else if (type.getText().equals("toggle")) {
...@@ -127,5 +128,5 @@ public class TransportInstanceManager { ...@@ -127,5 +128,5 @@ public class TransportInstanceManager {
} }
} }
} }
} }
...@@ -43,11 +43,9 @@ public class GatewayDWR extends DWRServlet { ...@@ -43,11 +43,9 @@ public class GatewayDWR extends DWRServlet {
document.appendChild(root); document.appendChild(root);
Element allowElement = document.createElement("allow"); Element allowElement = document.createElement("allow");
Element timElement = buildCreator("TransportInstanceManager", "org.jivesoftware.wildfire.gateway.web.TransportInstanceManager"); Element timElement = buildCreator("ConfigManager", "org.jivesoftware.wildfire.gateway.web.ConfigManager");
allowElement.appendChild(timElement); allowElement.appendChild(timElement);
//allowElement.appendChild(buildCreator("TransportInstanceManager", "org.jivesoftware.wildfire.gateway.web.TransportInstanceManager"));
root.appendChild(allowElement); root.appendChild(allowElement);
} }
catch (ParserConfigurationException e) { catch (ParserConfigurationException e) {
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006 Jive Software. All rights reserved.
*
* This software is published under the terms of the GNU Public License (GPL),
* a copy of which is included in this distribution.
*/
package org.jivesoftware.wildfire.gateway.web;
/**
* List of all possible options used by the admin options interface for any particular transport.
*
* @author Daniel Henninger
*/
public class TransportOptions {
public String host;
public String port;
public String encoding;
}
...@@ -59,10 +59,10 @@ ...@@ -59,10 +59,10 @@
String setting = JiveGlobals.getProperty(sysprop.getText(), defStr); String setting = JiveGlobals.getProperty(sysprop.getText(), defStr);
String checkId = gatewayType.toString()+var.getText(); String inputId = gatewayType.toString()+var.getText();
out.println("<tr valign='middle'>"); out.println("<tr valign='middle'>");
out.println("<td align='right' width='1%'><label for='" + checkId + "'>" + desc.getText() + "</label>:</td>"); out.println("<td align='right' width='1%'><label for='" + inputId + "'>" + desc.getText() + "</label>:</td>");
out.println("<td><input type='text' id='" + checkId + "' name='" + var.getText() + "'"+(size != null ? " size='"+size.getText()+"'" : "")+(size != null ? " maxlength='"+maxlen.getText()+"'" : "")+" value='"+setting+"'/></td>"); out.println("<td><input type='text' id='" + inputId + "' name='" + inputId + "'"+(size != null ? " size='"+size.getText()+"'" : "")+(size != null ? " maxlength='"+maxlen.getText()+"'" : "")+" value='"+setting+"'/></td>");
out.println("</tr>"); out.println("</tr>");
} }
else if (type.getText().equals("toggle")) { else if (type.getText().equals("toggle")) {
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
String jsStr = gatewayType.toString()+(++jsID); String jsStr = gatewayType.toString()+(++jsID);
String checkId = gatewayType.toString()+var.getText(); String checkId = gatewayType.toString()+var.getText();
out.println("<tr valign='top'>"); out.println("<tr valign='top'>");
out.println("<td align='right' width='1%'><input type='checkbox' id='" + checkId +"' name='" + var.getText() + "' value='true' "+(setting ? " checked='checked'" : "")+" onClick='elem = document.getElementById(\""+jsStr+"\"); if (elem) { if (this.checked) { elem.style.display=\"table\"} else { elem.style.display=\"none\"} }'/></td>"); out.println("<td align='right' width='1%'><input type='checkbox' id='" + checkId +"' name='" + checkId + "' value='true' "+(setting ? " checked='checked'" : "")+" onClick='elem = document.getElementById(\""+jsStr+"\"); if (elem) { if (this.checked) { elem.style.display=\"table\"} else { elem.style.display=\"none\"} }'/></td>");
out.print("<td><label for='" + checkId + "'>" + desc.getText() + "</label>"); out.print("<td><label for='" + checkId + "'>" + desc.getText() + "</label>");
for (Object itemObj : node.elements("item")) { for (Object itemObj : node.elements("item")) {
Element item = (Element)itemObj; Element item = (Element)itemObj;
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<!-- BEGIN gateway - <%= this.gatewayType.toString().toUpperCase() %> --> <!-- BEGIN gateway - <%= this.gatewayType.toString().toUpperCase() %> -->
<div <%= ((!this.gwEnabled) ? " class='jive-gateway jive-gatewayDisabled'" : "class='jive-gateway'") %> id="jive<%= this.gatewayType.toString().toUpperCase() %>"> <div <%= ((!this.gwEnabled) ? " class='jive-gateway jive-gatewayDisabled'" : "class='jive-gateway'") %> id="jive<%= this.gatewayType.toString().toUpperCase() %>">
<label for="jive<%= this.gatewayType.toString().toUpperCase() %>checkbox"> <label for="jive<%= this.gatewayType.toString().toUpperCase() %>checkbox">
<input type="checkbox" name="gateway" value="<%= this.gatewayType.toString().toLowerCase() %>" id="jive<%= this.gatewayType.toString().toUpperCase() %>checkbox" <%= ((this.gwEnabled) ? "checked" : "") %> onClick="TransportInstanceManager.toggleTransport('<%= this.gatewayType.toString().toLowerCase() %>'); checkToggle(jive<%= this.gatewayType.toString().toUpperCase() %>); return true"> <input type="checkbox" name="gateway" value="<%= this.gatewayType.toString().toLowerCase() %>" id="jive<%= this.gatewayType.toString().toUpperCase() %>checkbox" <%= ((this.gwEnabled) ? "checked" : "") %> onClick="ConfigManager.toggleTransport('<%= this.gatewayType.toString().toLowerCase() %>'); checkToggle(jive<%= this.gatewayType.toString().toUpperCase() %>); return true">
<img src="images/<%= this.gatewayType.toString().toLowerCase() %>.gif" alt="" border="0"> <img src="images/<%= this.gatewayType.toString().toLowerCase() %>.gif" alt="" border="0">
<strong><%= this.description %></strong> <strong><%= this.description %></strong>
</label> </label>
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<form id="jive<%= this.gatewayType.toString().toUpperCase() %>testsform" action=""> <form id="jive<%= this.gatewayType.toString().toUpperCase() %>testsform" action="">
<span style="font-weight: bold">Connect to host:</span> <span id="testhost">[reading]</span><br /> <span style="font-weight: bold">Connect to host:</span> <span id="testhost">[reading]</span><br />
<span style="font-weight: bold">Connect to port:</span> <span id="testport">[reading]</span><br /> <span style="font-weight: bold">Connect to port:</span> <span id="testport">[reading]</span><br />
<input type="submit" name="submit" value="Test Connection" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>tests,jive<%= this.gatewayType.toString().toUpperCase() %>tests); return false" class="jive-formButton"> <input type="submit" name="submit" value="Test Connection" onclick="return false" class="jive-formButton">
</form> </form>
</div> </div>
</div> </div>
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
</tr> </tr>
</table> </table>
<input type="button" name="submit" value="Save Options" onclick="saveOptions('<%= this.gatewayType.toString() %>'); return false" class="jive-formButton"> <input type="button" name="submit" value="Save Options" onclick="saveOptions('<%= this.gatewayType.toString() %>'); return false" class="jive-formButton">
<input type="reset" name="cancel" value="Cancel" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>options,jive<%= this.gatewayType.toString().toUpperCase() %>perms); return false" class="jive-formButton"> <input type="reset" name="cancel" value="Cancel Changes" class="jive-formButton">
</form> </form>
</div> </div>
</div> </div>
...@@ -202,8 +202,8 @@ ...@@ -202,8 +202,8 @@
</div> </div>
<input type="radio" name="userreg" value="manual" onClick="getElementById('userreg_specific').style.display = 'none'"> Manual registration only (see the Registrations section to manage)<br> <input type="radio" name="userreg" value="manual" onClick="getElementById('userreg_specific').style.display = 'none'"> Manual registration only (see the Registrations section to manage)<br>
<input type="submit" name="submit" value="Save Permissions" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>perms,jive<%= this.gatewayType.toString().toUpperCase() %>options); return false" class="jive-formButton"> <input type="submit" name="submit" value="Save Permissions" onclick="return false" class="jive-formButton">
<input type="reset" name="cancel" value="Cancel" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>perms,jive<%= this.gatewayType.toString().toUpperCase() %>options); return false" class="jive-formButton"> <input type="reset" name="cancel" value="Cancel Changes" class="jive-formButton">
</form> </form>
</div> </div>
</div> </div>
...@@ -234,27 +234,41 @@ ...@@ -234,27 +234,41 @@
<title>Gateway Settings</title> <title>Gateway Settings</title>
<meta name="pageID" content="gateway-settings"> <meta name="pageID" content="gateway-settings">
<style type="text/css"> <style type="text/css">
<!-- @import url("style/gateways.css"); --> <!-- @import url("style/gateways.css"); -->
</style> </style>
<script src="dwr/engine.js" type="text/javascript"></script> <script src="dwr/engine.js" type="text/javascript"></script>
<script src="dwr/util.js" type="text/javascript"></script> <script src="dwr/util.js" type="text/javascript"></script>
<script src="dwr/interface/TransportInstanceManager.js" type="text/javascript"></script> <script src="dwr/interface/ConfigManager.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript" src="scripts/gateways.js"></script> <script language="JavaScript" type="text/javascript" src="scripts/gateways.js"></script>
<script type="text/javascript" > <script type="text/javascript" >
DWREngine.setErrorHandler(handleError); DWREngine.setErrorHandler(handleError);
window.onerror = handleError;
function handleError(error) { function handleError(error) {
alert(error); // swallow errors
} }
var settings; var settings;
// If you add new option types, you to the transport option configs, you will also need
// to add the option 'var' ids here.
var optionTypes = new Array(
"host",
"port",
"encoding"
);
function saveOptions(transportID) { function saveOptions(transportID) {
var transportSettings = new Array(); var transportSettings = new Object();
transportSettings["host"] = DWRUtil.getValue(transportID+"host"); var x;
transportSettings["port"] = DWRUtil.getValue(transportID+"port"); for (x in optionTypes) {
transportSettings["encoding"] = DWRUtil.getValue(transportID+"encoding"); var optType = optionTypes[x];
TransportInstanceManager.saveSettings(null, transportID, transportSettings); var optionId = transportID+optType;
var testoption = document.getElementById(optionId);
if (testoption != null) {
transportSettings[optType] = DWRUtil.getValue(optionId);
}
}
ConfigManager.saveSettings(transportID, transportSettings);
} }
</script> </script>
</head> </head>
......
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