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

[GATE-74] Lots of work messing with XMPP/GTalk transport. Nothing solid/functional yet.

Fixed typos in plugin.xml.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@7935 b35dd754-fafc-0310-a699-88a17e54d16e
parent 23af13f1
......@@ -19,15 +19,15 @@
<adminconsole>
<tab id="tab-server">
<sidebar id="gateways" name="${gateway.web.gateways}" description="${gateway.web.gateways.desc}">
<sidebar id="gateways" name="${gateway.gateways}" description="${gateway.gateways.desc}">
<item id="gateway-settings"
name="${gateway.web.settings}"
name="${gateway.settings}"
url="gateway-settings.jsp"
description="${gateway.web.settings.desc}"/>
description="${gateway.settings.desc}"/>
<item id="gateway-registrations"
name="${gateway.web.registrations}"
name="${gateway.registrations}"
url="gateway-registrations.jsp"
description="%{gateway.web.registrations.desc}"/>
description="%{gateway.registrations.desc}"/>
</sidebar>
</tab>
......
......@@ -307,6 +307,21 @@ gateway.irc.donotdisturb=Do Not Disturb
gateway.irc.errorreceived=IRC error received:
gateway.irc.errorreceivedwithcode=IRC error received (code {0}):
# XMPP Transport
gateway.xmpp.shortservice=XMPP
gateway.xmpp.service=XMPP
gateway.xmpp.name=XMPP Transport
gateway.xmpp.username=JID
gateway.xmpp.password=Password
gateway.xmpp.registration=Please enter your XMPP JID and password as it's used on the XMPP server pointed to by the transport.
# Google Talk Transport
gateway.gtalk.shortservice=GTalk
gateway.gtalk.service=Google Talk
gateway.gtalk.name=Google Talk Transport
gateway.gtalk.username=Address
gateway.gtalk.registration=Please enter your e-mail address and password used with GMail and GTalk.
# Web Interface (Settings)
gateway.web.settings.instructions=Select which gateways will be allowed, what features are available, and who can connect to each gateway service. Checking a gateway enables the service.
gateway.web.settings.tests=Tests
......
......@@ -81,6 +81,14 @@ public class GatewayPlugin implements Plugin {
/* Set up MSN transport. */
transports.put("msn", new TransportInstance(TransportType.msn, LocaleUtils.getLocalizedString("gateway.msn.name", "gateway"), "org.jivesoftware.openfire.gateway.protocols.msn.MSNTransport", componentManager));
maybeStartService("msn");
/* Set up XMPP transport. */
transports.put("xmpp", new TransportInstance(TransportType.xmpp, LocaleUtils.getLocalizedString("gateway.xmpp.name", "gateway"), "org.jivesoftware.openfire.gateway.protocols.xmpp.XMPPTransport", componentManager));
maybeStartService("xmpp");
/* Set up GTalk transport. */
transports.put("gtalk", new TransportInstance(TransportType.gtalk, LocaleUtils.getLocalizedString("gateway.gtalk.name", "gateway"), "org.jivesoftware.openfire.gateway.protocols.xmpp.XMPPTransport", componentManager));
maybeStartService("gtalk");
}
public void destroyPlugin() {
......
/**
* $Revision$
* $Date$
*
* Copyright (C) 2006-2007 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.openfire.gateway.protocols.xmpp;
import org.jivesoftware.smack.*;
import org.xmpp.packet.Presence;
import org.dom4j.Element;
import org.dom4j.DocumentHelper;
import java.util.Collection;
/**
* Handles incoming events from XMPP server.
*
* @author Daniel Henninger
*/
public class XMPPListener implements MessageListener, RosterListener, ConnectionListener, ChatManagerListener {
/**
* Creates an XMPP listener instance and ties to session.
*
* @param session Session this listener is associated with.
*/
public XMPPListener(XMPPSession session) {
this.xmppSession = session;
}
/**
* Session instance that the listener is associated with.
*/
public XMPPSession xmppSession = null;
/**
* Handlings incoming messages.
*
* @param chat Chat instance this message is associated with.
* @param message Message received.
*/
public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message message) {
xmppSession.getTransport().sendMessage(
xmppSession.getJIDWithHighestPriority(),
xmppSession.getTransport().convertIDToJID(message.getFrom()),
message.getBody()
);
}
public void entriesAdded(Collection<String> collection) {
//Ignoring for now
}
public void entriesUpdated(Collection<String> collection) {
//Ignoring for now
}
public void entriesDeleted(Collection<String> collection) {
//Ignoring for now
}
public void presenceChanged(org.jivesoftware.smack.packet.Presence presence) {
Element presElem = DocumentHelper.createElement(presence.toXML());
Presence p = new Presence(presElem);
p.setTo(xmppSession.getJID());
p.setFrom(xmppSession.getTransport().convertIDToJID(presence.getFrom()));
xmppSession.getTransport().sendPacket(p);
}
public void connectionClosed() {
Presence p = new Presence();
p.setType(Presence.Type.unavailable);
p.setTo(xmppSession.getJID());
p.setFrom(xmppSession.getTransport().getJID());
xmppSession.getTransport().sendPacket(p);
}
public void connectionClosedOnError(Exception exception) {
xmppSession.getTransport().sendMessage(
xmppSession.getJIDWithHighestPriority(),
xmppSession.getTransport().getJID(),
"Conection closed."
);
Presence p = new Presence();
p.setType(Presence.Type.unavailable);
p.setTo(xmppSession.getJID());
p.setFrom(xmppSession.getTransport().getJID());
xmppSession.getTransport().sendPacket(p);
}
public void reconnectingIn(int i) {
//Ignoring for now
}
public void reconnectionSuccessful() {
//Ignoring for now
}
public void reconnectionFailed(Exception exception) {
//Ignoring for now
}
public void chatCreated(Chat chat, boolean b) {
//More or less can ignore this.
}
}
......@@ -17,6 +17,7 @@ import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.Chat;
import org.xmpp.packet.JID;
import org.xmpp.packet.Presence;
......@@ -53,6 +54,11 @@ public class XMPPSession extends TransportSession {
*/
private XMPPConnection conn = null;
/**
* XMPP listener
*/
private XMPPListener listener = null;
/*
* XMPP connection configuration
*/
......@@ -61,10 +67,14 @@ public class XMPPSession extends TransportSession {
public void logIn(PresenceType presenceType, String verboseStatus) {
if (!this.isLoggedIn()) {
try {
listener = new XMPPListener(this);
setLoginStatus(TransportLoginStatus.LOGGING_IN);
conn = new XMPPConnection(config);
conn.connect();
conn.addConnectionListener(listener);
conn.login(this.getRegistration().getUsername(), this.getRegistration().getPassword(), "IMGateway");
conn.getRoster().addRosterListener(listener);
conn.getChatManager().addChatListener(listener);
}
catch (XMPPException e) {
Log.error(getTransport().getType()+" user is not able to log in: "+this.getRegistration().getUsername(), e);
......@@ -78,6 +88,9 @@ public class XMPPSession extends TransportSession {
public void logOut() {
if (this.isLoggedIn()) {
setLoginStatus(TransportLoginStatus.LOGGING_OUT);
conn.removeConnectionListener(listener);
conn.getRoster().removeRosterListener(listener);
conn.getChatManager().removeChatListener(listener);
conn.disconnect();
}
Presence p = new Presence(Presence.Type.unavailable);
......@@ -92,19 +105,22 @@ public class XMPPSession extends TransportSession {
}
public void addContact(RosterItem item) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void removeContact(RosterItem item) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void updateContact(RosterItem item) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void sendMessage(JID jid, String message) {
//To change body of implemented methods use File | Settings | File Templates.
Chat chat = conn.getChatManager().createChat(getTransport().convertJIDToID(jid), listener);
try {
chat.sendMessage(message);
}
catch (XMPPException e) {
// TODO: handle exception properly
}
}
public void sendServerMessage(String message) {
......@@ -112,15 +128,12 @@ public class XMPPSession extends TransportSession {
}
public void sendChatState(JID jid, ChatStateType chatState) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void retrieveContactStatus(JID jid) {
//To change body of implemented methods use File | Settings | File Templates.
}
public void resendContactStatuses(JID jid) {
//To change body of implemented methods use File | Settings | File Templates.
}
}
<?xml version="1.0" encoding="UTF-8"?>
<optionsconfig>
<leftpanel></leftpanel>
<rightpanel>
<item type="text" sysprop="plugin.gateway.gtalk.connecthost" var="host" desckey="gateway.web.settings.host" default="talk.google.com"/>
<item type="text" sysprop="plugin.gateway.gtalk.connectport" var="port" desckey="gateway.web.settings.port" default="5222"/>
</rightpanel>
</optionsconfig>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<optionsconfig>
<leftpanel></leftpanel>
<rightpanel>
<item type="text" sysprop="plugin.gateway.xmpp.connecthost" var="host" desckey="gateway.web.settings.host" default="jabber.org"/>
<item type="text" sysprop="plugin.gateway.xmpp.connectport" var="port" desckey="gateway.web.settings.port" default="5222"/>
</rightpanel>
</optionsconfig>
\ No newline at end of file
......@@ -25,9 +25,11 @@
(GatewayPlugin)XMPPServer.getInstance().getPluginManager().getPlugin("gateway");
HashMap<String,Boolean> trEnabled = new HashMap<String,Boolean>();
trEnabled.put("aim", plugin.getTransportInstance("aim").isEnabled());
trEnabled.put("gtalk", plugin.getTransportInstance("gtalk").isEnabled());
trEnabled.put("icq", plugin.getTransportInstance("icq").isEnabled());
trEnabled.put("irc", plugin.getTransportInstance("irc").isEnabled());
trEnabled.put("msn", plugin.getTransportInstance("msn").isEnabled());
trEnabled.put("xmpp", plugin.getTransportInstance("xmpp").isEnabled());
trEnabled.put("yahoo", plugin.getTransportInstance("yahoo").isEnabled());
webManager.init(request, response, session, application, out);
......@@ -65,6 +67,8 @@
if (webManager.getPageProperty("gateway-registrations", "filterMSN", 0) != 0) { filteropts.add("msn"); }
if (webManager.getPageProperty("gateway-registrations", "filterYAHOO", 0) != 0) { filteropts.add("yahoo"); }
if (webManager.getPageProperty("gateway-registrations", "filterIRC", 0) != 0) { filteropts.add("irc"); }
if (webManager.getPageProperty("gateway-registrations", "filterXMPP", 0) != 0) { filteropts.add("xmpp"); }
if (webManager.getPageProperty("gateway-registrations", "filterGTALK", 0) != 0) { filteropts.add("gtalk"); }
if (webManager.getPageProperty("gateway-registrations", "filterSIGNEDON", 0) != 0) { filteropts.add("signedon"); }
}
else {
......@@ -73,6 +77,8 @@
filteropts.add("msn");
filteropts.add("yahoo");
filteropts.add("irc");
filteropts.add("gtalk");
filteropts.add("xmpp");
}
webManager.setPageProperty("gateway-registrations", "filterSET", 1);
......@@ -81,6 +87,8 @@
webManager.setPageProperty("gateway-registrations", "filterMSN", filteropts.contains("msn") ? 1 : 0);
webManager.setPageProperty("gateway-registrations", "filterYAHOO", filteropts.contains("yahoo") ? 1 : 0);
webManager.setPageProperty("gateway-registrations", "filterIRC", filteropts.contains("irc") ? 1 : 0);
webManager.setPageProperty("gateway-registrations", "filterGTALK", filteropts.contains("gtalk") ? 1 : 0);
webManager.setPageProperty("gateway-registrations", "filterXMPP", filteropts.contains("xmpp") ? 1 : 0);
webManager.setPageProperty("gateway-registrations", "filterSIGNEDON", filteropts.contains("signedon") ? 1 : 0);
int resCount = 0;
......@@ -282,9 +290,11 @@
<select name="newRegistrationType" id="newRegistrationType" size="1">
<option value="0" SELECTED> -- select -- </option>
<% if (trEnabled.get("aim")) { %> <option value="aim"><fmt:message key="gateway.aim.shortservice" /></option> <% } %>
<% if (trEnabled.get("icq")) { %> <option value="icq"><fmt:message key="gateway.icq.shortservice" /></option> <% } %>
<% if (trEnabled.get("gtalk")) { %> <option value="gtalk"><fmt:message key="gateway.gtalk.shortservice" /></option> <% } %>
<% if (trEnabled.get("icq")) { %> <option value="icq"><fmt:message key="gateway.icq.shortservice" /></option> <% } %>
<% if (trEnabled.get("irc")) { %> <option value="irc"><fmt:message key="gateway.irc.shortservice" /></option> <% } %>
<% if (trEnabled.get("msn")) { %> <option value="msn"><fmt:message key="gateway.msn.shortservice" /></option> <% } %>
<% if (trEnabled.get("xmpp")) { %> <option value="xmpp"><fmt:message key="gateway.xmpp.shortservice" /></option> <% } %>
<% if (trEnabled.get("yahoo")) { %> <option value="yahoo"><fmt:message key="gateway.yahoo.shortservice" /></option> <% } %>
</select><br>
<strong><fmt:message key="gateway.web.registrations.gateway" /></strong>
......@@ -379,7 +389,12 @@
<img src="images/aim.gif" border="0" alt="<fmt:message key="gateway.aim.shortservice" />">
<!--<span><fmt:message key="gateway.aim.shortservice" /></span>-->
</label>
<label for="filterICQcheckbox">
<label for="filterGTALKcheckbox">
<input type="checkbox" name="filter[]" value="gtalk" <%= ((filteropts.contains("gtalk")) ? "checked" : "") %> id="filterGTALKcheckbox">
<img src="images/gtalk.gif" border="0" alt="<fmt:message key="gateway.gtalk.shortservice" />">
<!--<span><fmt:message key="gateway.gtalk.shortservice" /></span>-->
</label>
<label for="filterICQcheckbox">
<input type="checkbox" name="filter[]" value="icq" <%= ((filteropts.contains("icq")) ? "checked" : "") %> id="filterICQcheckbox">
<img src="images/icq.gif" border="0" alt="<fmt:message key="gateway.icq.shortservice" />">
<!--<span><fmt:message key="gateway.icq.shortservice" /></span>-->
......@@ -394,6 +409,11 @@
<img src="images/msn.gif" border="0" alt="<fmt:message key="gateway.msn.shortservice" />">
<!--<span><fmt:message key="gateway.msn.shortservice" /></span>-->
</label>
<label for="filterXMPPcheckbox">
<input type="checkbox" name="filter[]" value="xmpp" <%= ((filteropts.contains("xmpp")) ? "checked" : "") %> id="filterXMPPcheckbox">
<img src="images/xmpp.gif" border="0" alt="<fmt:message key="gateway.xmpp.shortservice" />">
<!--<span><fmt:message key="gateway.xmpp.shortservice" /></span>-->
</label>
<label for="filterYAHOOcheckbox">
<input type="checkbox" name="filter[]" value="yahoo" <%= ((filteropts.contains("yahoo")) ? "checked" : "") %> id="filterYAHOOcheckbox">
<img src="images/yahoo.gif" border="0" alt="<fmt:message key="gateway.yahoo.shortservice" />">
......
......@@ -352,9 +352,11 @@
}
GatewaySettings aimSettings = new GatewaySettings(out, plugin, TransportType.aim, LocaleUtils.getLocalizedString("gateway.aim.service", "gateway"));
GatewaySettings gtalkSettings = new GatewaySettings(out, plugin, TransportType.gtalk, LocaleUtils.getLocalizedString("gateway.gtalk.service", "gateway"));
GatewaySettings icqSettings = new GatewaySettings(out, plugin, TransportType.icq, LocaleUtils.getLocalizedString("gateway.icq.service", "gateway"));
GatewaySettings ircSettings = new GatewaySettings(out, plugin, TransportType.irc, LocaleUtils.getLocalizedString("gateway.irc.service", "gateway"));
GatewaySettings msnSettings = new GatewaySettings(out, plugin, TransportType.msn, LocaleUtils.getLocalizedString("gateway.msn.service", "gateway"));
GatewaySettings xmppSettings = new GatewaySettings(out, plugin, TransportType.xmpp, LocaleUtils.getLocalizedString("gateway.xmpp.service", "gateway"));
GatewaySettings yahooSettings = new GatewaySettings(out, plugin, TransportType.yahoo, LocaleUtils.getLocalizedString("gateway.yahoo.service", "gateway"));
%>
......@@ -615,7 +617,9 @@
<p><fmt:message key="gateway.web.settings.unstable.notice" /></p>
<% gtalkSettings.printSettingsDialog(); %>
<% icqSettings.printSettingsDialog(); %>
<% xmppSettings.printSettingsDialog(); %>
<% yahooSettings.printSettingsDialog(); %>
</form>
......
......@@ -320,6 +320,14 @@ a.jive-gatewayButtonOn {
background: url(../images/aim-gray.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-GTALKon {
background: url(../images/gtalk.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-GTALKoff {
background: url(../images/gtalk-gray.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-ICQon {
background: url(../images/icq.gif) no-repeat left;
background-position: 2px 1px;
......@@ -344,6 +352,14 @@ a.jive-gatewayButtonOn {
background: url(../images/msn-gray.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-XMPPon {
background: url(../images/xmpp.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-XMPPoff {
background: url(../images/xmpp-gray.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-YAHOOon {
background: url(../images/yahoo.gif) no-repeat left;
background-position: 0px 1px;
......
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