session-details.jsp 10.9 KB
Newer Older
Matt Tucker's avatar
Matt Tucker committed
1 2 3
<%--
  -	$Revision$
  -	$Date$
Bill Lynch's avatar
Bill Lynch committed
4
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6 7
  -
  - This software is published under the terms of the GNU Public License (GPL),
8 9
  - a copy of which is included in this distribution, or a commercial license
  - agreement with Jive.
Matt Tucker's avatar
Matt Tucker committed
10
--%>
Bill Lynch's avatar
Bill Lynch committed
11

12
<%@ page import="org.jivesoftware.openfire.PresenceManager,
13 14 15 16
                 org.jivesoftware.openfire.SessionManager,
                 org.jivesoftware.openfire.session.ClientSession,
                 org.jivesoftware.openfire.user.User,
                 org.jivesoftware.openfire.user.UserManager,
17 18
                 org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.ParamUtils,
19 20
                 java.text.NumberFormat,
                 java.util.Collection"
Bill Lynch's avatar
Bill Lynch committed
21 22
    errorPage="error.jsp"
%>
Matt Tucker's avatar
Matt Tucker committed
23

24
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
25
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>
26

Bill Lynch's avatar
Bill Lynch committed
27
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager" />
28
<% webManager.init(request, response, session, application, out ); %>
Matt Tucker's avatar
Matt Tucker committed
29

30
<% // Get parameters
Matt Tucker's avatar
Matt Tucker committed
31 32 33 34 35 36 37 38 39
    String jid = ParamUtils.getParameter(request, "jid");

    // Handle a "go back" click:
    if (request.getParameter("back") != null) {
        response.sendRedirect("session-summary.jsp");
        return;
    }

    // Get the session & address objects
Derek DeMoro's avatar
Derek DeMoro committed
40
    SessionManager sessionManager = webManager.getSessionManager();
Derek DeMoro's avatar
Derek DeMoro committed
41
    JID address = new JID(jid);
42 43 44
    org.jivesoftware.openfire.session.ClientSession currentSess = sessionManager.getSession(address);
    boolean isAnonymous = webManager.getXMPPServer().isLocal(address) &&
            !UserManager.getInstance().isRegisteredUser(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
45 46

    // Get a presence manager
Derek DeMoro's avatar
Derek DeMoro committed
47
    PresenceManager presenceManager = webManager.getPresenceManager();
Matt Tucker's avatar
Matt Tucker committed
48 49 50 51

    // Get user object
    User user = null;
    if (!isAnonymous) {
Derek DeMoro's avatar
Derek DeMoro committed
52
        user = webManager.getUserManager().getUser(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
53 54 55 56
    }

    // Handle a "message" click:
    if (request.getParameter("message") != null) {
57
        response.sendRedirect("user-message.jsp?username=" + URLEncoder.encode(user.getUsername(), "UTF-8"));
Matt Tucker's avatar
Matt Tucker committed
58 59 60 61
        return;
    }

    // See if there are multiple sessions for this user:
62
    Collection<ClientSession> sessions = null;
Derek DeMoro's avatar
Derek DeMoro committed
63
    int sessionCount = sessionManager.getSessionCount(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
64
    if (!isAnonymous && sessionCount > 1) {
Derek DeMoro's avatar
Derek DeMoro committed
65
        sessions = sessionManager.getSessions(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
66 67 68 69 70 71
    }

    // Number dateFormatter for all numbers on this page:
    NumberFormat numFormatter = NumberFormat.getNumberInstance();
%>

72 73 74 75 76 77
<html>
    <head>
        <title><fmt:message key="session.details.title"/></title>
        <meta name="pageID" content="session-summary"/>
    </head>
    <body>
Matt Tucker's avatar
Matt Tucker committed
78 79

<p>
80
<fmt:message key="session.details.info">
81
    <fmt:param value="<%= "<b>" + StringUtils.escapeForXML(address.toString()) + "</b>" %>" />
82
    <fmt:param value="<%= address.getNode() == null ? "" : "<b>"+address.getNode()+"</b>" %>" />
83 84
</fmt:message>

Matt Tucker's avatar
Matt Tucker committed
85 86 87
</p>

<div class="jive-table">
Bill Lynch's avatar
Bill Lynch committed
88 89 90 91
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
    <tr>
        <th colspan="2">
92
            <fmt:message key="session.details.title" />
Bill Lynch's avatar
Bill Lynch committed
93 94 95 96 97 98
        </th>
    </tr>
</thead>
<tbody>
    <tr>
        <td class="c1">
99
            <fmt:message key="session.details.session_id" />
Bill Lynch's avatar
Bill Lynch committed
100 101
        </td>
        <td>
102
            <%= StringUtils.escapeForXML(address.toString()) %>
Bill Lynch's avatar
Bill Lynch committed
103 104 105 106
        </td>
    </tr>
    <tr>
        <td class="c1">
107
            <fmt:message key="session.details.username" />
Bill Lynch's avatar
Bill Lynch committed
108 109
        </td>
        <td>
Derek DeMoro's avatar
Derek DeMoro committed
110
            <%  String n = address.getNode(); %>
111
            <%  if (isAnonymous) { %>
Bill Lynch's avatar
Bill Lynch committed
112

113
                <i> <fmt:message key="session.details.anonymous" /> </i> - <%= address.getResource()==null?"":StringUtils.escapeForXML(address.getResource()) %>
Bill Lynch's avatar
Bill Lynch committed
114 115 116

            <%  } else { %>

117
                <a href="user-properties.jsp?username=<%= URLEncoder.encode(n, "UTF-8") %>"><%= JID.unescapeNode(n) %></a>
118
                - <%= address.getResource()==null?"":StringUtils.escapeForXML(address.getResource()) %>
Bill Lynch's avatar
Bill Lynch committed
119 120 121 122 123 124

            <%  } %>
        </td>
    </tr>
    <tr>
        <td class="c1">
125
            <fmt:message key="session.details.status" />:
Bill Lynch's avatar
Bill Lynch committed
126 127 128 129 130 131
        </td>
        <td>
            <%
                int status = currentSess.getStatus();
                if (status == Session.STATUS_CLOSED) {
            %>
132
                <fmt:message key="session.details.close" />
Bill Lynch's avatar
Bill Lynch committed
133 134 135 136 137

            <%
                } else if (status == Session.STATUS_CONNECTED) {
            %>

138
                <fmt:message key="session.details.connect" />
Bill Lynch's avatar
Bill Lynch committed
139 140 141 142 143

            <%
                } else if (status == Session.STATUS_AUTHENTICATED) {
            %>

144
                <fmt:message key="session.details.authenticated" />
Bill Lynch's avatar
Bill Lynch committed
145 146 147 148 149

            <%
                } else {
            %>

150
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
151 152 153 154 155 156 157 158

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
159
            <fmt:message key="session.details.presence" />:
Bill Lynch's avatar
Bill Lynch committed
160 161 162
        </td>
        <td>
            <%
Derek DeMoro's avatar
Derek DeMoro committed
163
                Presence.Show show = currentSess.getPresence().getShow();
164 165
                String statusTxt = currentSess.getPresence().getStatus();
                if (statusTxt != null) {
166
                    statusTxt = " -- " + StringUtils.escapeForXML(statusTxt);
167 168 169 170
                }
                else {
                    statusTxt = "";
                }
171 172 173 174 175 176
                if (!currentSess.getPresence().isAvailable()) {
            %>
                <img src="images/user-clear-16x16.gif" width="16" height="16" border="0" title="<fmt:message key="user.properties.offline" />" alt="<fmt:message key="user.properties.offline" />">
                <fmt:message key="user.properties.offline" />
            <%
                } else if (show == Presence.Show.away) {
Bill Lynch's avatar
Bill Lynch committed
177
            %>
178
                <img src="images/im_away.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.away" />" alt="<fmt:message key="session.details.away" />">
179
                <fmt:message key="session.details.away" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
180 181

            <%
Derek DeMoro's avatar
Derek DeMoro committed
182
                } else if (show == Presence.Show.chat) {
Bill Lynch's avatar
Bill Lynch committed
183
            %>
184
                <img src="images/im_free_chat.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.chat_available" />" alt="<fmt:message key="session.details.chat_available" />">
185
                <fmt:message key="session.details.chat_available" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
186
            <%
Derek DeMoro's avatar
Derek DeMoro committed
187
                } else if (show == Presence.Show.dnd) {
Bill Lynch's avatar
Bill Lynch committed
188 189
            %>

190
                <img src="images/im_dnd.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.not_disturb" />" alt="<fmt:message key="session.details.not_disturb" />">
191
                <fmt:message key="session.details.not_disturb" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
192 193

            <%
Derek DeMoro's avatar
Derek DeMoro committed
194
                } else if (show == null) {
Bill Lynch's avatar
Bill Lynch committed
195 196
            %>

197
                <img src="images/im_available.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.online" />" alt="<fmt:message key="session.details.online" />">
198
                <fmt:message key="session.details.online" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
199 200

            <%
Derek DeMoro's avatar
Derek DeMoro committed
201
                } else if (show == Presence.Show.xa) {
Bill Lynch's avatar
Bill Lynch committed
202 203
            %>

204
                <img src="images/im_away.gif" width="16" height="16" border="0" title="<fmt:message key="session.details.extended" />" alt="<fmt:message key="session.details.extended" />">
205
                <fmt:message key="session.details.extended" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
206 207 208 209 210

            <%
                } else {
            %>

211
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
212 213 214 215 216 217

            <%
                }
            %>
        </td>
    </tr>
218 219 220 221 222 223 224 225
    <tr>
        <td class="c1">
            <fmt:message key="session.details.priority" />
        </td>
        <td>
            <%= currentSess.getPresence().getPriority() %>
        </td>
    </tr>
Bill Lynch's avatar
Bill Lynch committed
226 227
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
228
            <fmt:message key="session.details.session_created" />
Bill Lynch's avatar
Bill Lynch committed
229 230
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
231
            <%= JiveGlobals.formatDateTime(currentSess.getCreationDate()) %>
Bill Lynch's avatar
Bill Lynch committed
232 233 234 235
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
236
            <fmt:message key="session.details.last_active" />
Bill Lynch's avatar
Bill Lynch committed
237 238
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
239
            <%= JiveGlobals.formatDateTime(currentSess.getLastActiveDate()) %>
Bill Lynch's avatar
Bill Lynch committed
240 241 242 243
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
244
            <fmt:message key="session.details.statistics" />
Bill Lynch's avatar
Bill Lynch committed
245 246
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
247
            <fmt:message key="session.details.received" />
Bill Lynch's avatar
Bill Lynch committed
248 249 250 251 252
            <%= numFormatter.format(currentSess.getNumClientPackets()) %>/<%= numFormatter.format(currentSess.getNumServerPackets()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
253
            <fmt:message key="session.details.hostname" />
Bill Lynch's avatar
Bill Lynch committed
254 255
        </td>
        <td>
256
            <%= currentSess.getHostAddress() %>
Bill Lynch's avatar
Bill Lynch committed
257
            /
258
            <%= currentSess.getHostName() %>
Bill Lynch's avatar
Bill Lynch committed
259 260 261
        </td>
    </tr>
</tbody>
Matt Tucker's avatar
Matt Tucker committed
262 263 264 265 266 267 268
</table>
</div>

<%  // Show a list of multiple user sessions if there is more than 1 session:
    if (sessionCount > 1) {
%>
    <p>
269
    <b><fmt:message key="session.details.multiple_session" /></b>
Matt Tucker's avatar
Matt Tucker committed
270 271 272 273 274 275
    </p>

    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
        <th>&nbsp;</th>
276 277
        <th><fmt:message key="session.details.name" /></th>
        <th><fmt:message key="session.details.resource" /></th>
278
        <th nowrap colspan="2"><fmt:message key="session.details.status" /></th>
279
        <th nowrap colspan="2"><fmt:message key="session.details.if_presence" /></th>
280
        <th><fmt:message key="session.details.priority" /></th>
281 282
        <th nowrap><fmt:message key="session.details.clientip" /></th>
        <th nowrap><fmt:message key="session.details.close_connect" /></th>
Matt Tucker's avatar
Matt Tucker committed
283 284 285 286
    </tr>

    <%  int count = 0;
        String linkURL = "session-details.jsp";
287
        for (ClientSession sess : sessions) {
Matt Tucker's avatar
Matt Tucker committed
288 289 290
            count++;
            boolean current = sess.getAddress().equals(address);
    %>
291
        <%@ include file="session-row.jspf" %>
Matt Tucker's avatar
Matt Tucker committed
292 293 294 295 296 297 298 299 300 301 302 303 304 305

    <%  } %>

    </table>
    </div>

    <br>

    <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
        <td width="1%" nowrap>

            <div class="jive-table">
            <table cellpadding="0" cellspacing="0" border="0">
306
            <tr class="jive-current"><td><img src="images/blank.gif" width="12" height="12" border="0" alt=""></td></tr>
Matt Tucker's avatar
Matt Tucker committed
307 308 309 310 311 312
            </table>
            </div>

        </td>
        <td width="99%">

313
            &nbsp; = <fmt:message key="session.details.session_detail" />
Matt Tucker's avatar
Matt Tucker committed
314 315 316 317 318 319 320 321 322 323

        </td>
    </tr>
    </table>

<%  } %>

<br>

<form action="session-details.jsp">
324
<input type="hidden" name="jid" value="<%= URLEncoder.encode(jid, "UTF-8") %>">
Matt Tucker's avatar
Matt Tucker committed
325
<center>
Bill Lynch's avatar
Bill Lynch committed
326 327 328 329 330
<%--<%  if (!isAnonymous && presenceManager.isAvailable(user)) { %>--%>
<%----%>
<%--    <input type="submit" name="message" value="Message this Session">--%>
<%----%>
<%--<%  } %>--%>
Matt Tucker's avatar
Matt Tucker committed
331
<input type="submit" name="back" value="<fmt:message key="session.details.back_button" />">   
Matt Tucker's avatar
Matt Tucker committed
332 333 334
</center>
</form>

335 336
    </body>
</html>