Commit 34e704fc authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

Added ability for custom registration tags per transport [GATE-26], working on...

Added ability for custom registration tags per transport [GATE-26], working on tracking down/testing [GATE-3], more work on [GATE-20].  Much more information kept/handled for yahoo and msn transports.  MSN errors should be handled a lot better, needs to be tested.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@5260 b35dd754-fafc-0310-a699-88a17e54d16e
parent 7b1a7b7c
......@@ -573,19 +573,21 @@ public abstract class BaseTransport implements Component, RosterEventListener {
IQ result = IQ.createResultIQ(packet);
DataForm form = new DataForm(DataForm.Type.form);
form.addInstruction("Please enter your " + this.getName() + " username and password.");
form.addInstruction(getTerminologyRegistration());
FormField usernameField = form.addField();
usernameField.setLabel("Username");
usernameField.setLabel(getTerminologyUsername());
usernameField.setVariable("username");
usernameField.setType(FormField.Type.text_single);
FormField passwordField = form.addField();
passwordField.setLabel("Password");
passwordField.setLabel(getTerminologyPassword());
passwordField.setVariable("password");
passwordField.setType(FormField.Type.text_private);
response.addElement("instructions").addText("Please enter your " + this.getName() + " username and password.");
response.add(form.getElement());
response.addElement("instructions").addText(getTerminologyRegistration());
Collection<Registration> registrations = registrationManager.getRegistrations(from, this.transportType);
if (registrations.iterator().hasNext()) {
Registration registration = registrations.iterator().next();
......@@ -733,6 +735,13 @@ public abstract class BaseTransport implements Component, RosterEventListener {
return transportType.toString();
}
/**
* Returns the type of the transport.
*/
public TransportType getType() {
return transportType;
}
/**
* Returns the description of the transport.
*/
......@@ -843,7 +852,7 @@ public abstract class BaseTransport implements Component, RosterEventListener {
// TODO: Should we throw exception or something?
}
catch (Exception ee) {
Log.error("createRosterItem caused exception: " + ee.getMessage());
Log.error("createRosterItem caused exception: " + ee.toString());
// TODO: Should we throw exception or something?
}
}
......@@ -1260,4 +1269,27 @@ public abstract class BaseTransport implements Component, RosterEventListener {
*/
public abstract void registrationLoggedOut(TransportSession session);
/**
* Returns the terminology used for a username on the legacy service.
*
* @return String term for username.
*/
public abstract String getTerminologyUsername();
/**
* Returns the terminology used for a password on the legacy service.
*
* @return String term for password.
*/
public abstract String getTerminologyPassword();
/**
* Returns instructions for registration in legacy complient terminology.
*
* You would write this out as if the entry textfields for the username and password
* are after it/on the same page. So something along these lines would be good:
* Please enter your legacy username and password.
*/
public abstract String getTerminologyRegistration();
}
......@@ -86,14 +86,14 @@ public class MSNListener extends MsnAdapter {
* Handles incoming datacast messages from MSN.
*/
public void datacastMessageReceived(MsnSwitchboard switchboard, MsnDatacastMessage message, MsnContact friend) {
Log.debug("MSN: Received database msn to " + switchboard + " from " + friend + ": " + message);
Log.debug("MSN: Received datacast message to " + switchboard + " from " + friend + ": " + message);
}
/**
* Handles incoming unknown messages from MSN.
*/
public void unknownMessageReceived(MsnSwitchboard switchboard, MsnUnknownMessage message, MsnContact friend) {
Log.debug("MSN: Received database msn to " + switchboard + " from " + friend + ": " + message);
Log.debug("MSN: Received unknown message to " + switchboard + " from " + friend + ": " + message);
}
/**
......@@ -101,7 +101,6 @@ public class MSNListener extends MsnAdapter {
*/
public void loginCompleted(MsnMessenger messenger) {
Log.debug("MSN login completed");
msnSession.getRegistration().setLastLogin(new Date());
msnSession.setLoginStatus(true);
}
......@@ -158,6 +157,55 @@ public class MSNListener extends MsnAdapter {
*/
public void exceptionCaught(MsnMessenger messenger, Throwable throwable) {
Log.debug("Caught MSN exception: "+messenger+":"+throwable.toString());
if (throwable.getClass().getName().equals("IncorrectPasswordException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("The password you registered with is incorrect. Please re-register with the correct password.");
msnSession.getTransport().sendPacket(m);
msnSession.logOut();
}
else if (throwable.getClass().getName().equals("MsnProtocolException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("MSN error: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("MsgNotSendException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("Unable to send MSN message. Reason: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("UnknownMessageException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("Unknown message from MSN: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else if (throwable.getClass().getName().equals("UnsupportedProtocolException")) {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("MSN protocol error: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
else {
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(msnSession.getJIDWithHighestPriority());
m.setFrom(msnSession.getTransport().getJID());
m.setBody("Unknown error from MSN: "+throwable.toString());
msnSession.getTransport().sendPacket(m);
}
}
}
......@@ -93,12 +93,12 @@ public class MSNSession extends TransportSession {
public void logOut() {
if (this.isLoggedIn()) {
msnMessenger.logout();
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
loginStatus = false;
}
Presence p = new Presence(Presence.Type.unavailable);
p.setTo(getJID());
p.setFrom(getTransport().getJID());
getTransport().sendPacket(p);
loginStatus = false;
}
/**
......
......@@ -29,6 +29,27 @@ import net.sf.jml.MsnUserStatus;
*/
public class MSNTransport extends BaseTransport {
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyUsername()
*/
public String getTerminologyUsername() {
return "E-mail Address";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyPassword()
*/
public String getTerminologyPassword() {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
public String getTerminologyRegistration() {
return "Please enter your MSN Passport e-mail address and password.";
}
/**
* Handles creating a MSN session and triggering a login.
*
......
......@@ -10,10 +10,7 @@
package org.jivesoftware.wildfire.gateway.protocols.oscar;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.jivesoftware.wildfire.gateway.PresenceType;
import org.jivesoftware.wildfire.gateway.Registration;
import org.jivesoftware.wildfire.gateway.TransportSession;
import org.jivesoftware.wildfire.gateway.*;
import org.xmpp.packet.JID;
/**
......@@ -26,6 +23,37 @@ import org.xmpp.packet.JID;
*/
public class OSCARTransport extends BaseTransport {
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyUsername()
*/
public String getTerminologyUsername() {
if (getType().equals(TransportType.icq)) {
return "UIN/ICQ#";
}
else {
return "ScreenName";
}
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyPassword()
*/
public String getTerminologyPassword() {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
public String getTerminologyRegistration() {
if (getType().equals(TransportType.icq)) {
return "Please enter your ICQ# (UIN) and password.";
}
else {
return "Please enter your AIM ScreenName and password.";
}
}
/**
* Handles creating an OSCAR session and triggering a login.
*
......
......@@ -14,6 +14,7 @@ import org.jivesoftware.util.Log;
import org.xmpp.packet.Message;
import org.xmpp.packet.Presence;
import ymsg.network.YahooUser;
import ymsg.network.StatusConstants;
import ymsg.network.event.SessionChatEvent;
import ymsg.network.event.SessionConferenceEvent;
import ymsg.network.event.SessionErrorEvent;
......@@ -154,29 +155,47 @@ public class YahooSessionListener implements SessionListener {
* @see ymsg.network.event.SessionListener#listReceived(ymsg.network.event.SessionEvent)
*/
public void listReceived(SessionEvent event) {
Log.debug(event.toString());
// We just got the entire contact list. Lets sync up.
yahooSession.syncUsers();
}
/**
* @see ymsg.network.event.SessionListener#buzzReceived(ymsg.network.event.SessionEvent)
*/
public void buzzReceived(SessionEvent event) {
Log.debug(event.toString());
Message m = new Message();
m.setType(Message.Type.chat);
m.setTo(yahooSession.getJIDWithHighestPriority());
m.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom()));
m.setBody(messageDecoder.decodeToText(event.getMessage()));
yahooSession.getTransport().sendPacket(m);
}
/**
* @see ymsg.network.event.SessionListener#errorPacketReceived(ymsg.network.event.SessionErrorEvent)
*/
public void errorPacketReceived(SessionErrorEvent event) {
Log.error(event.toString());
//Log.error(event.toString());
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(yahooSession.getJIDWithHighestPriority());
m.setFrom(yahooSession.getTransport().getJID());
m.setBody("Error from yahoo: "+event.getMessage());
yahooSession.getTransport().sendPacket(m);
}
/**
* @see ymsg.network.event.SessionListener#inputExceptionThrown(ymsg.network.event.SessionExceptionEvent)
*/
public void inputExceptionThrown(SessionExceptionEvent event) {
event.getException().printStackTrace();
Log.error(event.toString());
//event.getException().printStackTrace();
//Log.error(event.toString());
Message m = new Message();
m.setType(Message.Type.error);
m.setTo(yahooSession.getJIDWithHighestPriority());
m.setFrom(yahooSession.getTransport().getJID());
m.setBody("Input error from yahoo: "+event.getMessage());
yahooSession.getTransport().sendPacket(m);
}
/**
......@@ -184,20 +203,31 @@ public class YahooSessionListener implements SessionListener {
*/
public void notifyReceived(SessionNotifyEvent event) {
Log.debug(event.toString());
if (event.getType().equals(StatusConstants.NOTIFY_TYPING)) {
// Ooh, a typing notification. We'll use this in the future.
}
}
/**
* @see ymsg.network.event.SessionListener#contactRequestReceived(ymsg.network.event.SessionEvent)
*/
public void contactRequestReceived(SessionEvent event) {
Log.debug(event.toString());
Presence p = new Presence(Presence.Type.subscribe);
p.setTo(yahooSession.getJID());
p.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom()));
yahooSession.getTransport().sendPacket(p);
}
/**
* @see ymsg.network.event.SessionListener#contactRejectionReceived(ymsg.network.event.SessionEvent)
*/
public void contactRejectionReceived(SessionEvent event) {
// TODO: Is this correct? unsubscribed for a rejection?
Log.debug(event.toString());
Presence p = new Presence(Presence.Type.unsubscribed);
p.setTo(yahooSession.getJID());
p.setFrom(yahooSession.getTransport().convertIDToJID(event.getFrom()));
yahooSession.getTransport().sendPacket(p);
}
/**
......
......@@ -29,6 +29,27 @@ import ymsg.network.StatusConstants;
*/
public class YahooTransport extends BaseTransport {
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyUsername()
*/
public String getTerminologyUsername() {
return "Yahoo! ID";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyPassword()
*/
public String getTerminologyPassword() {
return "Password";
}
/**
* @see org.jivesoftware.wildfire.gateway.BaseTransport#getTerminologyRegistration()
*/
public String getTerminologyRegistration() {
return "Please enter your Yahoo! ID and password.";
}
/**
* Handles creating a Yahoo session and triggering a login.
*
......
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