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