Commit 4a8318f9 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-761] Added in postgres db file. Web interface works pretty well now. Misc other fixes.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4661 b35dd754-fafc-0310-a699-88a17e54d16e
parent c4f7096f
CREATE TABLE gatewayRegistration (
registrationID BIGINT NOT NULL,
jid VARCHAR(1024) NOT NULL,
transportType VARCHAR(15) NOT NULL,
username VARCHAR(255) NOT NULL,
password VARCHAR(255),
registrationDate BIGINT NOT NULL,
lastLogin BIGINT,
CONSTRAINT gatewayReg_pk PRIMARY KEY (registrationID)
);
CREATE INDEX gatewayReg_jid_idx ON gatewayRegistration (jid);
CREATE INDEX gatewayReg_type_idx ON gatewayRegistration (transportType);
INSERT INTO jiveVersion (name, version) VALUES ('gateway', 0);
...@@ -44,6 +44,8 @@ public class Registration { ...@@ -44,6 +44,8 @@ public class Registration {
"UPDATE gatewayRegistration SET lastLogin=? WHERE registrationID=?"; "UPDATE gatewayRegistration SET lastLogin=? WHERE registrationID=?";
private static final String SET_PASSWORD = private static final String SET_PASSWORD =
"UPDATE gatewayRegistration SET password=? WHERE registrationID=?"; "UPDATE gatewayRegistration SET password=? WHERE registrationID=?";
private static final String SET_USERNAME =
"UPDATE gatewayRegistration SET username=? WHERE registrationID=?";
private long registrationID; private long registrationID;
private JID jid; private JID jid;
...@@ -167,6 +169,34 @@ public class Registration { ...@@ -167,6 +169,34 @@ public class Registration {
} }
} }
/**
* Sets the username used for logging in to the transport.
* @param username
*/
public void setUsername(String username) {
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);
}
else {
pstmt.setNull(1, Types.VARCHAR);
}
pstmt.setLong(2, registrationID);
pstmt.executeUpdate();
}
catch (SQLException sqle) {
Log.error(sqle);
}
finally {
DbConnectionManager.closeConnection(pstmt, con);
}
}
/** /**
* Returns the date that this transport registration was created. * Returns the date that this transport registration was created.
* *
...@@ -198,7 +228,7 @@ public class Registration { ...@@ -198,7 +228,7 @@ public class Registration {
try { try {
con = DbConnectionManager.getConnection(); con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(SET_LAST_LOGIN); pstmt = con.prepareStatement(SET_LAST_LOGIN);
pstmt.setNull(1, Types.VARCHAR); pstmt.setLong(1, lastLogin.getTime());
pstmt.setLong(2, registrationID); pstmt.setLong(2, registrationID);
pstmt.executeUpdate(); pstmt.executeUpdate();
} }
......
...@@ -35,14 +35,13 @@ public class RegistrationManager implements Startable { ...@@ -35,14 +35,13 @@ public class RegistrationManager implements Startable {
private static final String ALL_REGISTRATION_COUNT = private static final String ALL_REGISTRATION_COUNT =
"SELECT count(*) FROM gatewayRegistration"; "SELECT count(*) FROM gatewayRegistration";
private static final String ALL_REGISTRATIONS = private static final String ALL_REGISTRATIONS =
"SELECT registrationID FROM gatewayRegistration"; "SELECT registrationID FROM gatewayRegistration ORDER BY jid,transportType";
private static final String LOAD_REGISTRATION = private static final String LOAD_REGISTRATION =
"SELECT registrationID FROM gatewayRegistration WHERE jid=? AND transportType=? " + "SELECT registrationID FROM gatewayRegistration WHERE jid=? AND transportType=? AND username=?";
"AND username=?";
private static final String ALL_USER_REGISTRATIONS = private static final String ALL_USER_REGISTRATIONS =
"SELECT registrationID FROM gatewayRegistration WHERE jid=?"; "SELECT registrationID FROM gatewayRegistration WHERE jid=? ORDER BY transportType";
private static final String ALL_GATEWAY_REGISTRATIONS = private static final String ALL_GATEWAY_REGISTRATIONS =
"SELECT registrationID FROM gatewayRegistration WHERE transportType=?"; "SELECT registrationID FROM gatewayRegistration WHERE transportType=? ORDER BY jid";
private static final String USER_GATEWAY_REGISTRATIONS = private static final String USER_GATEWAY_REGISTRATIONS =
"SELECT registrationID FROM gatewayRegistration WHERE jid=? AND transportType=?"; "SELECT registrationID FROM gatewayRegistration WHERE jid=? AND transportType=?";
...@@ -81,8 +80,7 @@ public class RegistrationManager implements Startable { ...@@ -81,8 +80,7 @@ public class RegistrationManager implements Startable {
con = DbConnectionManager.getConnection(); con = DbConnectionManager.getConnection();
pstmt = con.prepareStatement(DELETE_REGISTRATION); pstmt = con.prepareStatement(DELETE_REGISTRATION);
pstmt.setLong(1, registration.getRegistrationID()); pstmt.setLong(1, registration.getRegistrationID());
pstmt.executeQuery(); pstmt.executeUpdate();
} }
catch (SQLException sqle) { catch (SQLException sqle) {
Log.error(sqle); Log.error(sqle);
......
...@@ -13,7 +13,6 @@ package org.jivesoftware.wildfire.gateway; ...@@ -13,7 +13,6 @@ package org.jivesoftware.wildfire.gateway;
import org.jivesoftware.util.JiveGlobals; import org.jivesoftware.util.JiveGlobals;
import org.jivesoftware.util.Log; import org.jivesoftware.util.Log;
import org.jivesoftware.util.PropertyEventDispatcher; import org.jivesoftware.util.PropertyEventDispatcher;
import org.jivesoftware.wildfire.gateway.BaseTransport;
import org.xmpp.component.ComponentManager; import org.xmpp.component.ComponentManager;
import org.xmpp.packet.JID; import org.xmpp.packet.JID;
...@@ -109,7 +108,7 @@ public class TransportInstance { ...@@ -109,7 +108,7 @@ public class TransportInstance {
return; return;
} }
BaseTransport transport = null; transport = null;
Log.debug("Loading class "+nameOfClass); Log.debug("Loading class "+nameOfClass);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package org.jivesoftware.wildfire.gateway.protocols.msn; package org.jivesoftware.wildfire.gateway.protocols.msn;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import org.hn.sleek.jmml.Contact; import org.hn.sleek.jmml.Contact;
import org.hn.sleek.jmml.ContactList; import org.hn.sleek.jmml.ContactList;
...@@ -71,6 +72,8 @@ public class MSNSession extends TransportSession { ...@@ -71,6 +72,8 @@ public class MSNSession extends TransportSession {
msnManager.setPrivacyMode(true); msnManager.setPrivacyMode(true);
msnManager.setReverseListBehaviour(true); msnManager.setReverseListBehaviour(true);
getRegistration().setLastLogin(new Date());
} }
catch (MSNException e) { catch (MSNException e) {
Log.error("MSN exception thrown while logging in:", e); Log.error("MSN exception thrown while logging in:", e);
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
package org.jivesoftware.wildfire.gateway.protocols.oscar; package org.jivesoftware.wildfire.gateway.protocols.oscar;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -253,6 +254,7 @@ public class OSCARSession extends TransportSession { ...@@ -253,6 +254,7 @@ public class OSCARSession extends TransportSession {
* Apparantly we now have the entire list, lets sync. * Apparantly we now have the entire list, lets sync.
*/ */
void gotCompleteSSI() { void gotCompleteSSI() {
getRegistration().setLastLogin(new Date());
List<TransportBuddy> legacyusers = new ArrayList<TransportBuddy>(); List<TransportBuddy> legacyusers = new ArrayList<TransportBuddy>();
for (BuddyItem buddy : buddies.values()) { for (BuddyItem buddy : buddies.values()) {
//Log.debug("CompleteSSI: adding "+buddy.getScreenname()); //Log.debug("CompleteSSI: adding "+buddy.getScreenname());
......
...@@ -12,6 +12,7 @@ package org.jivesoftware.wildfire.gateway.protocols.yahoo; ...@@ -12,6 +12,7 @@ package org.jivesoftware.wildfire.gateway.protocols.yahoo;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.Collection; import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
...@@ -109,6 +110,8 @@ public class YahooSession extends TransportSession { ...@@ -109,6 +110,8 @@ public class YahooSession extends TransportSession {
yahooSession.setStatus(((YahooTransport)getTransport()).convertJabStatusToYahoo(pType)); yahooSession.setStatus(((YahooTransport)getTransport()).convertJabStatusToYahoo(pType));
getRegistration().setLastLogin(new Date());
syncUsers(); syncUsers();
} }
catch (LoginRefusedException e) { catch (LoginRefusedException e) {
......
This diff is collapsed.
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
<strong><%= this.description %></strong> <strong><%= this.description %></strong>
</label> </label>
<div class="jive-gatewayButtons"> <div class="jive-gatewayButtons">
<a href="#" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>options,jive<%= this.gatewayType.toString().toUpperCase() %>perms); return false" id="jive<%= this.gatewayType.toString().toUpperCase() %>optionsLink" <%= ((!this.gwEnabled) ? "style='display:none'" : "") %>>Options</a> <a href="#" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>options,jive<%= this.gatewayType.toString().toUpperCase() %>perms); return false" id="jive<%= this.gatewayType.toString().toUpperCase() %>optionsLink" <%= ((!this.gwEnabled) ? "style='display:none'" : "") %> style="display:none">Options</a>
<a href="#" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>perms,jive<%= this.gatewayType.toString().toUpperCase() %>options); return false" id="jive<%= this.gatewayType.toString().toUpperCase() %>permsLink" <%= ((!this.gwEnabled) ? "style='display:none'" : "") %>>Permissions</a> <a href="#" onclick="togglePanel(jive<%= this.gatewayType.toString().toUpperCase() %>perms,jive<%= this.gatewayType.toString().toUpperCase() %>options); return false" id="jive<%= this.gatewayType.toString().toUpperCase() %>permsLink" <%= ((!this.gwEnabled) ? "style='display:none'" : "") %> style="display:none">Permissions</a>
</div> </div>
</div> </div>
<div class="jive-gatewayPanel" id="jive<%= this.gatewayType.toString().toUpperCase() %>options" style="display: none;"> <div class="jive-gatewayPanel" id="jive<%= this.gatewayType.toString().toUpperCase() %>options" style="display: none;">
......
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