Commit 5f654804 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[GATE-14] Working on base IRC support. [GATE-5] Start of support for...

[GATE-14] Working on base IRC support.  [GATE-5] Start of support for non-server side nicknames and such.  There are currently problems with the db upgrade files.  Namely they don't appear to actually be triggering.  This is bad seeing as the code is expecting the changes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@5305 b35dd754-fafc-0310-a699-88a17e54d16e
parent dfc6432a
......@@ -12,7 +12,7 @@
<date>07/02/2006</date>
<minServerVersion>3.1.0</minServerVersion>
<databaseKey>gateway</databaseKey>
<databaseVersion>0</databaseVersion>
<databaseVersion>1</databaseVersion>
<licenseType>gpl</licenseType>
<!-- Admin console meta-data -->
......
......@@ -4,6 +4,7 @@ CREATE TABLE gatewayRegistration (
transportType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
nickname VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
......@@ -11,4 +12,13 @@ CREATE TABLE gatewayRegistration (
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
......@@ -4,6 +4,7 @@ CREATE TABLE gatewayRegistration (
transportType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
nickname VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
......@@ -11,4 +12,13 @@ CREATE TABLE gatewayRegistration (
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
......@@ -4,6 +4,7 @@ CREATE TABLE gatewayRegistration (
transportType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
nickname VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
PRIMARY KEY (registrationID),
......@@ -11,4 +12,13 @@ CREATE TABLE gatewayRegistration (
INDEX gatewayReg_type_idx(transportType)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255),
INDEX gatewayPsRs_regid_idx(registrationID),
INDEX gatewayPsRs_uname_idx(username)
);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
......@@ -4,6 +4,7 @@ CREATE TABLE gatewayRegistration (
transportType VARCHAR2(15) NOT NULL,
username VARCHAR2(255) NOT NULL,
password VARCHAR2(255),
nickname VARCHAR2(255),
registrationDate INTEGER NOT NULL,
lastLogin INTEGER,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
......@@ -11,6 +12,15 @@ CREATE TABLE gatewayRegistration (
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR2(255) NOT NULL,
nickname VARCHAR2(255),
groups VARCHAR2(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
commit;
\ No newline at end of file
commit;
CREATE TABLE gatewayRegistration (
registrationID BIGINT NOT NULL,
jid VARCHAR(255) NOT NULL,
jid VARCHAR(255) NOT NULL,
transportType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
nickname VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
......@@ -11,4 +12,13 @@ CREATE TABLE gatewayRegistration (
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
......@@ -4,6 +4,7 @@ CREATE TABLE gatewayRegistration (
transportType NVARCHAR(15) NOT NULL,
username NVARCHAR(255) NOT NULL,
password NVARCHAR(255),
nickname NVARCHAR(255),
registrationDate INTEGER NOT NULL,
lastLogin INTEGER,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
......@@ -11,4 +12,13 @@ CREATE TABLE gatewayRegistration (
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID INTEGER NOT NULL,
username NVARCHAR(255) NOT NULL,
nickname NVARCHAR(255),
groups NVARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
......@@ -4,6 +4,7 @@ CREATE TABLE gatewayRegistration (
transportType NVARCHAR(15) NOT NULL,
username NVARCHAR(255) NOT NULL,
password NVARCHAR(255),
nickname NVARCHAR(255),
registrationDate INTEGER NOT NULL,
lastLogin INTEGER,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
......@@ -11,4 +12,13 @@ CREATE TABLE gatewayRegistration (
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
CREATE TABLE gatewayPseudoRoster (
registrationID INTEGER NOT NULL,
username NVARCHAR(255) NOT NULL,
nickname NVARCHAR(255),
groups NVARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 1);
-- Add nickname to registration table
ALTER TABLE gatewayRegistration ADD COLUMN nickname VARCHAR(255);
-- Add pseudo roster table
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
-- Update database version
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
// Add nickname to registration table
ALTER TABLE gatewayRegistration ADD COLUMN nickname VARCHAR(255) BEFORE registrationDate;
// Add pseudo roster table
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
// Update database version
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
# Add nickname to registration table
ALTER TABLE gatewayRegistration ADD COLUMN nickname VARCHAR(255) NULL AFTER password;
# Add pseudo roster table
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255),
INDEX gatewayPsRs_regid_idx(registrationID),
INDEX gatewayPsRs_uname_idx(username)
);
# Update database version
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
-- Add nickname column to registration table
ALTER TABLE gatewayRegistration ADD nickname VARCHAR2(255) NULL;
-- Add pseudo roster table
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR2(255) NOT NULL,
nickname VARCHAR2(255),
groups VARCHAR2(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
-- Update database version
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
commit;
-- Add nickname column to registration table
ALTER TABLE gatewayRegistration ADD COLUMN nickname VARCHAR(255);
-- Add pseudo roster table
CREATE TABLE gatewayPseudoRoster (
registrationID BIGINT NOT NULL,
username VARCHAR(255) NOT NULL,
nickname VARCHAR(255),
groups VARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
-- Update database version
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
/* Add nickname column to registration table */
ALTER TABLE gatewayRegistration ADD nickname NVARCHAR(255);
/* Add pseudo roster table */
CREATE TABLE gatewayPseudoRoster (
registrationID INTEGER NOT NULL,
username NVARCHAR(255) NOT NULL,
nickname NVARCHAR(255),
groups NVARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
/* Update database version */
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
/* Add nickname column to registration table */
ALTER TABLE gatewayRegistration ADD nickname NVARCHAR(255);
/* Add pseudo roster table */
CREATE TABLE gatewayPseudoRoster (
registrationID INTEGER NOT NULL,
username NVARCHAR(255) NOT NULL,
nickname NVARCHAR(255),
groups NVARCHAR(255)
);
CREATE INDEX gatewayPsRs_regid_idx ON gatewayPseudoRoster (registrationID);
CREATE INDEX gatewayPsRs_uname_idx ON gatewayPseudoRoster (username);
/* Update database version */
UPDATE jiveVersion SET version = 1 WHERE name = "gateway";
......@@ -507,6 +507,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
// User wants to register with the transport.
String username = null;
String password = null;
String nickname = null;
try {
DataForm form = new DataForm(packet.getChildElement().element("x"));
......@@ -519,6 +520,10 @@ public abstract class BaseTransport implements Component, RosterEventListener {
else if (var.equals("password")) {
password = field.getValues().get(0);
}
else if (var.equals("nickname")) {
nickname = field.getValues().get(0);
}
}
}
catch (Exception e) {
......@@ -528,6 +533,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
if (packet.getType() == IQ.Type.set) {
Element userEl = packet.getChildElement().element("username");
Element passEl = packet.getChildElement().element("password");
Element nickEl = packet.getChildElement().element("nickname");
if (userEl != null) {
username = userEl.getTextTrim();
......@@ -537,7 +543,11 @@ public abstract class BaseTransport implements Component, RosterEventListener {
password = passEl.getTextTrim();
}
if (username == null || password == null) {
if (nickEl != null) {
nickname = nickEl.getTextTrim();
}
if (username == null || (isPasswordRequired() && password == null) || (isNicknameRequired() && nickname == null)) {
// Found nothing from stanza, lets yell.
IQ result = IQ.createResultIQ(packet);
result.setError(Condition.bad_request);
......@@ -551,7 +561,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
reply.add(result);
try {
this.addNewRegistration(from, username, password);
this.addNewRegistration(from, username, password, nickname);
}
catch (UserNotFoundException e) {
Log.error("Someone attempted to register with the gateway who is not registered with the server: " + from);
......@@ -585,6 +595,14 @@ public abstract class BaseTransport implements Component, RosterEventListener {
passwordField.setVariable("password");
passwordField.setType(FormField.Type.text_private);
String nicknameTerm = getTerminologyNickname();
if (nicknameTerm != null) {
FormField nicknameField = form.addField();
nicknameField.setLabel(nicknameTerm);
nicknameField.setVariable("nick");
nicknameField.setType(FormField.Type.text_single);
}
response.add(form.getElement());
response.addElement("instructions").addText(getTerminologyRegistration());
......@@ -594,10 +612,16 @@ public abstract class BaseTransport implements Component, RosterEventListener {
response.addElement("registered");
response.addElement("username").addText(registration.getUsername());
response.addElement("password").addText(registration.getPassword());
if (nicknameTerm != null) {
response.addElement("nickname").addText(registration.getNickname());
}
}
else {
response.addElement("username");
response.addElement("password");
if (nicknameTerm != null) {
response.addElement("nickname");
}
}
result.setChildElement(response);
......@@ -1034,9 +1058,10 @@ public abstract class BaseTransport implements Component, RosterEventListener {
* @param jid JID of user to add registration to.
* @param username Legacy username of registration.
* @param password Legacy password of registration.
* @param nickname Legacy nickname of registration.
* @throws UserNotFoundException if registration or roster not found.
*/
public void addNewRegistration(JID jid, String username, String password) throws UserNotFoundException {
public void addNewRegistration(JID jid, String username, String password, String nickname) throws UserNotFoundException {
Collection<Registration> registrations = registrationManager.getRegistrations(jid, this.transportType);
Boolean foundReg = false;
for (Registration registration : registrations) {
......@@ -1050,7 +1075,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
}
if (!foundReg) {
registrationManager.createRegistration(jid, this.transportType, username, password);
registrationManager.createRegistration(jid, this.transportType, username, password, nickname);
}
......@@ -1283,6 +1308,15 @@ public abstract class BaseTransport implements Component, RosterEventListener {
*/
public abstract String getTerminologyPassword();
/**
* Returns the terminology used for a nickname on the legacy service.
*
* You can return null to indicate that this is not supported by the legacy service.
*
* @return String term for nickname.
*/
public abstract String getTerminologyNickname();
/**
* Returns instructions for registration in legacy complient terminology.
*
......@@ -1292,4 +1326,14 @@ public abstract class BaseTransport implements Component, RosterEventListener {
*/
public abstract String getTerminologyRegistration();
/**
* Returns true or false whether the password is required.
*/
public abstract Boolean isPasswordRequired();
/**
* Returns true or false whether the nickname is required.
*/
public abstract Boolean isNicknameRequired();
}
......@@ -60,6 +60,10 @@ public class GatewayPlugin implements Plugin {
transports.put("icq", new TransportInstance(TransportType.icq, "ICQ Transport", "org.jivesoftware.wildfire.gateway.protocols.oscar.OSCARTransport", componentManager));
maybeStartService("icq");
/* Set up IRC transport. */
transports.put("irc", new TransportInstance(TransportType.irc, "IRC Transport", "org.jivesoftware.wildfire.gateway.protocols.irc.IRCTransport", componentManager));
maybeStartService("irc");
/* Set up Yahoo transport. */
transports.put("yahoo", new TransportInstance(TransportType.yahoo, "Yahoo! Transport", "org.jivesoftware.wildfire.gateway.protocols.yahoo.YahooTransport", componentManager));
maybeStartService("yahoo");
......
......@@ -36,9 +36,9 @@ public class Registration {
private static final String INSERT_REGISTRATION =
"INSERT INTO gatewayRegistration(registrationID, jid, transportType, " +
"username, password, registrationDate) VALUES (?,?,?,?,?,?)";
"username, password, nickname, registrationDate) VALUES (?,?,?,?,?,?,?)";
private static final String LOAD_REGISTRATION =
"SELECT jid, transportType, username, password, registrationDate, lastLogin " +
"SELECT jid, transportType, username, password, nickname, registrationDate, lastLogin " +
"FROM gatewayRegistration WHERE registrationID=?";
private static final String SET_LAST_LOGIN =
"UPDATE gatewayRegistration SET lastLogin=? WHERE registrationID=?";
......@@ -46,12 +46,15 @@ public class Registration {
"UPDATE gatewayRegistration SET password=? WHERE registrationID=?";
private static final String SET_USERNAME =
"UPDATE gatewayRegistration SET username=? WHERE registrationID=?";
private static final String SET_NICKNAME =
"UPDATE gatewayRegistration SET nickname=? WHERE registrationID=?";
private long registrationID;
private JID jid;
private TransportType transportType;
private String username;
private String password;
private String nickname;
private Date registrationDate;
private Date lastLogin;
......@@ -63,7 +66,7 @@ public class Registration {
* @param username the username on the transport.
* @param password the password on the transport.
*/
public Registration(JID jid, TransportType transportType, String username, String password) {
public Registration(JID jid, TransportType transportType, String username, String password, String nickname) {
if (jid == null || transportType == null || username == null) {
throw new NullPointerException("Arguments cannot be null.");
}
......@@ -72,6 +75,7 @@ public class Registration {
this.transportType = transportType;
this.username = username;
this.password = password;
this.nickname = nickname;
this.registrationDate = new Date();
try {
insertIntoDb();
......@@ -139,6 +143,15 @@ public class Registration {
return password;
}
/**
* Returns the nickname used for logging in to the transport.
*
* @return the nickname.
*/
public String getNickname() {
return nickname;
}
/**
* Sets the password used for logging in to the transport.
* @param password
......@@ -174,14 +187,40 @@ public class Registration {
* @param username
*/
public void setUsername(String username) {
if (username == null) {
throw new NullPointerException("Arguments cannot be null.");
}
this.username = username;
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SET_USERNAME);
if (username != null) {
pstmt.setString(1, username);
pstmt.setString(1, username);
pstmt.setLong(2, registrationID);
pstmt.executeUpdate();
}
catch (SQLException sqle) {
Log.error(sqle);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
/**
* Sets the nickname used for logging in to the transport.
* @param nickname
*/
public void setNickname(String nickname) {
this.nickname = nickname;
Connection con = null;
PreparedStatement pstmt = null;
try {
con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SET_NICKNAME);
if (nickname != null) {
pstmt.setString(1, nickname);
}
else {
pstmt.setNull(1, Types.VARCHAR);
......@@ -267,7 +306,13 @@ public class Registration {
else {
pstmt.setNull(5, Types.VARCHAR);
}
pstmt.setLong(6, registrationDate.getTime());
if (nickname != null) {
pstmt.setString(6, nickname);
}
else {
pstmt.setNull(6, Types.VARCHAR);
}
pstmt.setLong(7, registrationDate.getTime());
pstmt.executeUpdate();
}
catch (SQLException sqle) {
......@@ -296,8 +341,9 @@ public class Registration {
this.username = rs.getString(3);
// The password is stored in encrypted form, so decrypt it.
this.password = AuthFactory.decryptPassword(rs.getString(4));
this.registrationDate = new Date(rs.getLong(5));
long loginDate = rs.getLong(6);
this.nickname = rs.getString(5);
this.registrationDate = new Date(rs.getLong(6));
long loginDate = rs.getLong(7);
if (rs.wasNull()) {
this.lastLogin = null;
}
......
......@@ -60,12 +60,13 @@ public class RegistrationManager implements Startable {
* @param transportType the type of the transport.
* @param username the username on the transport service.
* @param password the password on the transport service.
* @param nickname the nickname on the transport service.
* @return a new registration.
*/
public Registration createRegistration(JID jid, TransportType transportType, String username,
String password)
String password, String nickname)
{
return new Registration(jid, transportType, username, password);
return new Registration(jid, transportType, username, password, nickname);
}
/**
......
/**
* $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.protocols.irc;
import org.schwering.irc.lib.IRCEventListener;
import org.schwering.irc.lib.IRCUser;
import org.schwering.irc.lib.IRCModeParser;
import org.xmpp.packet.Message;
import org.xmpp.packet.Presence;
import java.util.Date;
/**
* Handles listening for IRC events.
*
* @author Daniel Henninger
*/
public class IRCListener implements IRCEventListener {
public IRCListener(IRCSession session) {
this.session = session;
}
/**
* Session this listener is associated with.
*/
IRCSession session;
/**
* Retrieves the session this listener is associated with.
*/
public IRCSession getSession() {
return session;
}
public void onRegistered() {
getSession().getRegistration().setLastLogin(new Date());
Presence p = new Presence();
p.setFrom(getSession().getTransport().getJID());
p.setTo(getSession().getJID());
getSession().getTransport().sendPacket(p);
}
public void onDisconnected() {
getSession().logOut();
}
public void onError(String string) {
}
public void onError(int i, String string) {
}
public void onInvite(String string, IRCUser ircUser, String string1) {
}
public void onJoin(String string, IRCUser ircUser) {
}
public void onKick(String string, IRCUser ircUser, String string1, String string2) {
}
public void onMode(String string, IRCUser ircUser, IRCModeParser ircModeParser) {
}
public void onMode(IRCUser ircUser, String string, String string1) {
}
public void onNick(IRCUser ircUser, String string) {
}
public void onNotice(String string, IRCUser ircUser, String string1) {
}
public void onPart(String string, IRCUser ircUser, String string1) {
}
public void onPing(String string) {
}
public void onPrivmsg(String chan, IRCUser ircUser, String msg) {
Message m = new Message();
m.setType(Message.Type.chat);
m.setFrom(getSession().getTransport().convertIDToJID(ircUser.getNick()));
m.setTo(getSession().getJIDWithHighestPriority());
m.setBody(msg);
getSession().getTransport().sendPacket(m);
}
public void onQuit(IRCUser ircUser, String string) {
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getSession().getJID());
p.setFrom(getSession().getTransport().getJID());
getSession().getTransport().sendPacket(p);
}
public void onReply(int i, String string, String string1) {
}
public void onTopic(String string, IRCUser ircUser, String string1) {
}
public void unknown(String string, String string1, String string2, String string3) {
}
}
/**
* $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.protocols.irc;
import org.jivesoftware.wildfire.gateway.TransportSession;
import org.jivesoftware.wildfire.gateway.PresenceType;
import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.roster.RosterItem;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
import org.schwering.irc.lib.IRCConnection;
import java.io.IOException;
/**
* Represents an IRC session.
*
* This is the interface with which the base transport functionality will
* communicate with IRC.
*
* @author Daniel Henninger
*/
public class IRCSession extends TransportSession {
/**
* Create a MSN Session instance.
*
* @param registration Registration informationed used for logging in.
* @param jid JID associated with this session.
* @param transport Transport instance associated with this session.
* @param priority Priority of this session.
*/
public IRCSession(Registration registration, JID jid, IRCTransport transport, Integer priority) {
super(registration, jid, transport, priority);
conn = new IRCConnection("irc.freenode.net", new int[] { 6667, 7000 }, registration.getPassword(), registration.getNickname(), registration.getUsername(), "Wildfire User");
conn.setPong(true);
conn.setDaemon(false);
conn.setColors(false);
conn.addIRCEventListener(new IRCListener(this));
}
/**
* IRC connection.
*/
IRCConnection conn;
/**
* Logs the session into IRC.
*
* @param presenceType Initial presence state.
* @param verboseStatus Initial full status information.
*/
public void logIn(PresenceType presenceType, String verboseStatus) {
if (!isLoggedIn()) {
try {
conn.connect();
}
catch (IOException e) {
Log.error("IO error while connecting to IRC: "+e.toString());
}
}
}
/**
* Logs the session out of IRC.
*/
public void logOut() {
if (isLoggedIn()) {
conn.close();
}
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateStatus(org.jivesoftware.wildfire.gateway.PresenceType, String)
*/
public void updateStatus(PresenceType presenceType, String verboseStatus) {
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#isLoggedIn()
*/
public Boolean isLoggedIn() {
return conn.isConnected();
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#addContact(org.jivesoftware.wildfire.roster.RosterItem)
*/
public void addContact(RosterItem item) {
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#removeContact(org.jivesoftware.wildfire.roster.RosterItem)
*/
public void removeContact(RosterItem item) {
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#updateContact(org.jivesoftware.wildfire.roster.RosterItem)
*/
public void updateContact(RosterItem item) {
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#sendMessage(org.xmpp.packet.JID, String)
*/
public void sendMessage(JID jid, String message) {
conn.doPrivmsg(getTransport().convertJIDToID(jid), message);
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#retrieveContactStatus(org.xmpp.packet.JID)
*/
public void retrieveContactStatus(JID jid) {
}
/**
* @see org.jivesoftware.wildfire.gateway.TransportSession#resendContactStatuses(org.xmpp.packet.JID)
*/
public void resendContactStatuses(JID jid) {
}
}
/**
* $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.protocols.irc;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.jivesoftware.wildfire.gateway.TransportSession;
import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.PresenceType;
import org.jivesoftware.util.Log;
import org.xmpp.packet.JID;
/***
* IRC Transport Interface.
*
* This handles the bulk of the XMPP work via BaseTransport and provides
* some gateway specific interactions.
*
* @author Daniel Henninger
*/
public class IRCTransport extends BaseTransport {
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyUsername()
*/
public String getTerminologyUsername() {
return "Username";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyPassword()
*/
public String getTerminologyPassword() {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyNickname()
*/
public String getTerminologyNickname() {
return "Nickname";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
public String getTerminologyRegistration() {
return "Please enter your IRC username, password, and nickname. Nickname is the primary username used while username and password are used for authentication. If no password is required, leave it blank.";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isPasswordRequired()
*/
public Boolean isPasswordRequired() { return false; }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isNicknameRequired()
*/
public Boolean isNicknameRequired() { return true; }
/**
* Handles creating a IRC session and triggering a login.
*
* @param registration Registration information to be used to log in.
* @param jid JID that is logged into the transport.
* @param presenceType Type of presence.
* @param verboseStatus Longer status description.
*/
public TransportSession registrationLoggedIn(Registration registration, JID jid, PresenceType presenceType, String verboseStatus, Integer priority) {
Log.debug("Logging in to IRC gateway.");
TransportSession session = new IRCSession(registration, jid, this, priority);
// Thread sessionThread = new Thread(session);
// sessionThread.start();
((IRCSession)session).logIn(presenceType, verboseStatus);
return session;
}
/**
* Handles logging out of a IRC session.
*
* @param session The session to be disconnected.
*/
public void registrationLoggedOut(TransportSession session) {
Log.debug("Logging out of IRC gateway.");
((IRCSession)session).logOut();
// session.sessionDone();
}
}
......@@ -43,6 +43,13 @@ public class MSNTransport extends BaseTransport {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyNickname()
*/
public String getTerminologyNickname() {
return null;
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
......@@ -50,6 +57,16 @@ public class MSNTransport extends BaseTransport {
return "Please enter your MSN Passport e-mail address and password.";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isPasswordRequired()
*/
public Boolean isPasswordRequired() { return true; }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isNicknameRequired()
*/
public Boolean isNicknameRequired() { return false; }
/**
* Handles creating a MSN session and triggering a login.
*
......
......@@ -42,6 +42,13 @@ public class OSCARTransport extends BaseTransport {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyNickname()
*/
public String getTerminologyNickname() {
return null;
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
......@@ -54,6 +61,16 @@ public class OSCARTransport extends BaseTransport {
}
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isPasswordRequired()
*/
public Boolean isPasswordRequired() { return true; }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isNicknameRequired()
*/
public Boolean isNicknameRequired() { return false; }
/**
* Handles creating an OSCAR session and triggering a login.
*
......
......@@ -43,6 +43,13 @@ public class YahooTransport extends BaseTransport {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyNickname()
*/
public String getTerminologyNickname() {
return null;
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
......@@ -50,6 +57,16 @@ public class YahooTransport extends BaseTransport {
return "Please enter your Yahoo! ID and password.";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isPasswordRequired()
*/
public Boolean isPasswordRequired() { return true; }
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#isNicknameRequired()
*/
public Boolean isNicknameRequired() { return false; }
/**
* Handles creating a Yahoo session and triggering a login.
*
......
......@@ -22,7 +22,7 @@
HashMap<String,Boolean> trEnabled = new HashMap<String,Boolean>();
trEnabled.put("aim", plugin.getTransportInstance("aim").isEnabled());
trEnabled.put("icq", plugin.getTransportInstance("icq").isEnabled());
//trEnabled.put("irc", plugin.getTransportInstance("irc").isEnabled());
trEnabled.put("irc", plugin.getTransportInstance("irc").isEnabled());
trEnabled.put("msn", plugin.getTransportInstance("msn").isEnabled());
trEnabled.put("yahoo", plugin.getTransportInstance("yahoo").isEnabled());
......@@ -60,7 +60,8 @@
try {
Registration reg = new Registration(regId);
reg.setUsername(ParamUtils.getParameter(request, "username"));
reg.setPassword(ParamUtils.getParameter(request, "password"));
reg.setPassword(ParamUtils.getParameter(request, "password")); reg.setPassword(ParamUtils.getParameter(request, "password"));
reg.setNickname(ParamUtils.getParameter(request, "nickname"));
response.sendRedirect("gateway-registrations.jsp?success=true");
return;
}
......@@ -83,12 +84,13 @@
String typeStr = ParamUtils.getParameter(request, "gatewayType");
String username = ParamUtils.getParameter(request, "gatewayUser");
String password = ParamUtils.getParameter(request, "gatewayPass");
String nickname = ParamUtils.getParameter(request, "gatewayNick");
if (!trEnabled.get(typeStr)) {
response.sendRedirect("gateway-registrations.jsp?success=false");
return;
}
try {
plugin.getTransportInstance(typeStr).getTransport().addNewRegistration(jid, username, password);
plugin.getTransportInstance(typeStr).getTransport().addNewRegistration(jid, username, password, nickname);
response.sendRedirect("gateway-registrations.jsp?success=true");
return;
}
......@@ -296,7 +298,8 @@ below and update the view.</p>
<option value="0" SELECTED> -- select -- </option>
<% if (trEnabled.get("aim")) { %> <option value="aim">AIM</option> <% } %>
<% if (trEnabled.get("icq")) { %> <option value="icq">ICQ</option> <% } %>
<% if (trEnabled.get("msn")) { %> <option value="msn">MSN</option> <% } %>
<% if (trEnabled.get("irc")) { %> <option value="irc">IRC</option> <% } %>
<% if (trEnabled.get("msn")) { %> <option value="msn">MSN</option> <% } %>
<% if (trEnabled.get("yahoo")) { %> <option value="yahoo">Yahoo</option> <% } %>
</select><br>
<strong>gateway</strong>
......@@ -309,7 +312,11 @@ below and update the view.</p>
<input type="password" name="gatewayPass" size="12" maxlength="50" value=""><br>
<strong>password</strong>
</div>
<div class="jive-registrations-addButtons">
<div class="jive-registrations-addNickname">
<input type="text" name="gatewayNick" size="12" maxlength="50" value=""><br>
<strong>nickname</strong>
</div>
<div class="jive-registrations-addButtons">
<input type="submit" name="Submit" value="Add" class="savechanges"> &nbsp;
<input type="reset" name="reset" value="Cancel" class="cancel" onClick="toggleAdd();">
</div>
......@@ -393,7 +400,12 @@ below and update the view.</p>
<img src="images/icq.gif" alt="" border="0">
<span>ICQ</span>
</label>
<label for="filterMSNcheckbox">
<label for="filterIRCcheckbox">
<input type="checkbox" name="filter[]" value="icq" <%= ((filteropts.contains("irc")) ? "checked" : "") %> id="filterIRCcheckbox">
<img src="images/irc.gif" alt="" border="0">
<span>IRC</span>
</label>
<label for="filterMSNcheckbox">
<input type="checkbox" name="filter[]" value="msn" <%= ((filteropts.contains("msn")) ? "checked" : "") %> id="filterMSNcheckbox">
<img src="images/msn.gif" alt="" border="0">
<span>MSN</span>
......
......@@ -73,6 +73,7 @@
GatewaySettings aimSettings = new GatewaySettings(out, plugin, TransportType.aim, "AOL Instant Messenger");
GatewaySettings icqSettings = new GatewaySettings(out, plugin, TransportType.icq, "ICQ");
GatewaySettings ircSettings = new GatewaySettings(out, plugin, TransportType.irc, "IRC");
GatewaySettings msnSettings = new GatewaySettings(out, plugin, TransportType.msn, "MSN Messenger");
GatewaySettings yahooSettings = new GatewaySettings(out, plugin, TransportType.yahoo, "Yahoo! Messenger");
%>
......@@ -101,6 +102,7 @@
<% aimSettings.printSettingsDialog(); %>
<% icqSettings.printSettingsDialog(); %>
<% ircSettings.printSettingsDialog(); %>
<% msnSettings.printSettingsDialog(); %>
<% yahooSettings.printSettingsDialog(); %>
......
......@@ -279,6 +279,14 @@ a.jive-gatewayButtonOn {
background: url(../images/icq-gray.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-IRCon {
background: url(../images/irc.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-IRCoff {
background: url(../images/irc-gray.gif) no-repeat left;
background-position: 2px 1px;
}
.jive-gateway-MSNon {
background: url(../images/msn.gif) no-repeat left;
background-position: 2px 1px;
......@@ -314,14 +322,14 @@ table tr.jive-registrations-editVisible {
tr.jive-registrations-edit, tr.jive-registrations-editVisible td {
background-color: #f6f6f6;
}
.jive-registrations-editUsername, .jive-registrations-editPassword {
.jive-registrations-editUsername, .jive-registrations-editPassword, .jive-registrations-editNickname {
float: left;
}
.jive-registrations-editUsername strong, .jive-registrations-editPassword strong {
.jive-registrations-editUsername strong, .jive-registrations-editPassword strong, .jive-registrations-editNickname strong {
font-size: .9em;
color: #203050;
}
.jive-registrations-editUsername input, .jive-registrations-editPassword input {
.jive-registrations-editUsername input, .jive-registrations-editPassword input, .jive-registrations-editNickname input {
width: 110px;
height: 21px;
border: 1px solid #888888;
......@@ -330,6 +338,9 @@ tr.jive-registrations-edit, tr.jive-registrations-editVisible td {
.jive-registrations-editPassword {
padding-left: 8px;
}
.jive-registrations-editNickname {
padding-left: 8px;
}
.jive-registrations-editButtons {
float: left;
padding-left: 15px;
......@@ -384,7 +395,8 @@ tr.jive-registrations-edit, tr.jive-registrations-editVisible td {
.jive-registrations-addJid input,
.jive-registrations-addGateway select,
.jive-registrations-addUsername input,
.jive-registrations-addPassword input {
.jive-registrations-addPassword input,
.jive-registrations-addNickname input{
width: 130px;
height: 20px;
border: 1px solid #888888;
......
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