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

Working on registrations interface.

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk/src/plugins/gateway@4652 b35dd754-fafc-0310-a699-88a17e54d16e
parent ad42645f
......@@ -624,7 +624,7 @@ public abstract class BaseTransport implements Component {
* @return The legacy username as a JID.
*/
public JID convertIDToJID(String username) {
return new JID(username.replace('@', '%'), this.jid.getDomain(), null);
return new JID(username.replace('@', '%').replace(" ", ""), this.jid.getDomain(), null);
}
/**
......@@ -713,6 +713,20 @@ public abstract class BaseTransport implements Component {
return componentManager;
}
/**
* Returns the registration manager of the transport.
*/
public RegistrationManager getRegistrationManager() {
return registrationManager;
}
/**
* Returns the session manager of the transport.
*/
public TransportSessionManager getSessionManager() {
return sessionManager;
}
/**
* Retains the version string for later requests.
*/
......@@ -816,7 +830,7 @@ public abstract class BaseTransport implements Component {
*/
public void addOrUpdateRosterItem(JID userjid, String contactid, String nickname, String group) throws UserNotFoundException {
try {
addOrUpdateRosterItem(userjid, new JID(contactid, this.jid.toBareJID(), null), nickname, group);
addOrUpdateRosterItem(userjid, convertIDToJID(contactid), nickname, group);
}
catch (UserNotFoundException e) {
// Pass it on down.
......@@ -862,7 +876,7 @@ public abstract class BaseTransport implements Component {
void removeFromRoster(JID userjid, String contactid) throws UserNotFoundException {
// Clean up the user's contact list.
try {
removeFromRoster(userjid, new JID(contactid, this.jid.toBareJID(), null));
removeFromRoster(userjid, convertIDToJID(contactid));
}
catch (UserNotFoundException e) {
// Pass it on through.
......@@ -893,7 +907,7 @@ public abstract class BaseTransport implements Component {
Map<JID,TransportBuddy> legacymap = new HashMap<JID,TransportBuddy>();
for (TransportBuddy buddy : legacyitems) {
Log.debug("ROSTERSYNC: Mapping "+buddy.getName());
legacymap.put(new JID(buddy.getName(), this.jid.getDomain(), null), buddy);
legacymap.put(convertIDToJID(buddy.getName()), buddy);
}
// Now, lets go through the roster and see what matches up.
......
......@@ -39,7 +39,7 @@ public class GatewayPlugin implements Plugin {
/**
* Represents all configured transport handlers.
*/
private Hashtable<String,TransportInstance> transports;
public Hashtable<String,TransportInstance> transports;
/**
* Represents the base component manager.
......@@ -129,4 +129,13 @@ public class GatewayPlugin implements Plugin {
TransportInstance trInstance = transports.get(serviceName);
return trInstance.isEnabled();
}
/**
* Returns the transport instance, identified by subdomain.
*/
public TransportInstance getTransportInstance(String serviceName) {
TransportInstance trInstance = transports.get(serviceName);
return trInstance;
}
}
......@@ -30,7 +30,7 @@ public class TransportInstance {
private JID jid = null;
private String description = null;
private String nameOfClass = null;
private BaseTransport transport = null;
public BaseTransport transport = null;
private TransportType type = null;
private Boolean enabled = false;
private Boolean running = false;
......@@ -156,4 +156,11 @@ public class TransportInstance {
running = false;
}
/**
* Retrieves actual transport associated with this instance.
*/
public BaseTransport getTransport() {
return transport;
}
}
......@@ -132,12 +132,12 @@ public class OSCARSession extends TransportSession {
groupId = newGroupId;
}
request(new CreateItemsCmd(new SsiItem[] {
new BuddyItem(jid.getNode(), newBuddyId, groupId).toSsiItem() }));
new BuddyItem(getTransport().convertJIDToID(jid), newBuddyId, groupId).toSsiItem() }));
}
public void removeContact(JID jid) {
for (BuddyItem i : buddies.values()) {
if (i.getScreenname().equals(jid.getNode())) {
if (i.getScreenname().equals(getTransport().convertJIDToID(jid))) {
request(new DeleteItemsCmd(new SsiItem[] { i.toSsiItem() }));
buddies.remove(i.getId());
}
......@@ -145,7 +145,7 @@ public class OSCARSession extends TransportSession {
}
public void sendMessage(JID jid, String message) {
request(new SendImIcbm(jid.getNode(), message));
request(new SendImIcbm(getTransport().convertJIDToID(jid), message));
}
void startBosConn(String server, int port, ByteBlock cookie) {
......@@ -280,7 +280,7 @@ public class OSCARSession extends TransportSession {
* @param jid JID of contact to be probed.
*/
public void retrieveContactStatus(JID jid) {
bosConn.getAndSendStatus(jid.getNode());
bosConn.getAndSendStatus(getTransport().convertJIDToID(jid));
}
/**
......
......@@ -4,6 +4,7 @@
org.jivesoftware.wildfire.SessionManager,
org.jivesoftware.wildfire.XMPPServer,
org.jivesoftware.util.*,
org.jivesoftware.wildfire.gateway.GatewayPlugin,
org.jivesoftware.wildfire.gateway.Registration,
org.jivesoftware.wildfire.gateway.RegistrationManager"
errorPage="error.jsp"
......@@ -17,6 +18,8 @@
<%
webManager.init(request, response, session, application, out);
GatewayPlugin plugin = (GatewayPlugin)XMPPServer.getInstance().getPluginManager().getPlugin("gateway");
RegistrationManager registrationManager = new RegistrationManager();
Collection<Registration> registrations = registrationManager.getRegistrations();
int regCount = registrations.size();
......@@ -178,44 +181,58 @@ below and update the view.</p>
<%
for (Registration registration : registrations) {
long id = registration.getRegistrationID();
ClientSession clientSession = (ClientSession)sessionManager.getSessions(registration.getJID().getNode()).toArray()[0];
String status = "unavailable";
String linestatus = "offline";
if (clientSession != null) {
Presence presence = clientSession.getPresence();
if (presence == null) {
// not logged in, leave alone
}
else if (presence.getShow() == Presence.Show.xa) {
status = "away";
linestatus = "online";
}
else if (presence.getShow() == Presence.Show.away) {
status = "away";
linestatus = "online";
}
else if (presence.getShow() == Presence.Show.chat) {
status = "free_chat";
linestatus = "online";
}
else if (presence.getShow() == Presence.Show.dnd) {
status = "dnd";
linestatus = "online";
}
else if (presence.isAvailable()) {
status = "available";
linestatus = "online";
try {
ClientSession clientSession = (ClientSession)sessionManager.getSessions(registration.getJID().getNode()).toArray()[0];
if (clientSession != null) {
Presence presence = clientSession.getPresence();
if (presence == null) {
// not logged in, leave alone
}
else if (presence.getShow() == Presence.Show.xa) {
status = "away";
linestatus = "online";
}
else if (presence.getShow() == Presence.Show.away) {
status = "away";
linestatus = "online";
}
else if (presence.getShow() == Presence.Show.chat) {
status = "free_chat";
linestatus = "online";
}
else if (presence.getShow() == Presence.Show.dnd) {
status = "dnd";
linestatus = "online";
}
else if (presence.isAvailable()) {
status = "available";
linestatus = "online";
}
}
}
catch (Exception e) {
}
Date lastLogin = registration.getLastLogin();
String lastLoginStr = ((lastLogin != null) ? lastLogin.toString() : "never");
String lastLoginStr = ((lastLogin != null) ? lastLogin.toString() : "<i>never</i>");
boolean sessionActive = false;
try {
plugin.getTransportInstance(registration.getTransportType().toString()).getTransport().getSessionManager().getSession(registration.getJID());
sessionActive = true;
}
catch (Exception e) {
sessionActive = false;
Log.error("what the crap?", e);
}
%>
<tr id="jiveRegistration<%= id %>">
<td align="center">
<img src="/images/im_<%= status %>.gif" alt="<%= linestatus %>" border="0"></td>
<td><%= registration.getJID() %></td>
<td><span class="jive-gateway-<%= linestatus %> jive-gateway-<%= registration.getTransportType().toString().toUpperCase() %>on"><%= registration.getUsername() %></span></td>
<td><span class="jive-gateway-<%= linestatus %> jive-gateway-<%= registration.getTransportType().toString().toUpperCase() %><%= ((sessionActive) ? "on" : "off") %>"><%= registration.getUsername() %></span></td>
<td><%= lastLoginStr %></td>
<td align="center"><a href="#" onClick="toggleEdit(<%= id %>); return false"><img src="/images/edit-16x16.gif" alt="" border="0"></a></td>
<td align="center"><a href="#" onClick="alert('Are you sure you want to delete this registration?'); return false"><img src="/images/delete-16x16.gif" alt="" border="0"></a></td>
......
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