session-details.jsp 10.5 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-2005 Jive Software. All rights reserved.
Bill Lynch's avatar
Bill Lynch committed
6 7 8
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
Matt Tucker's avatar
Matt Tucker committed
9
--%>
Bill Lynch's avatar
Bill Lynch committed
10

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

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

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

29
<% // Get parameters
Matt Tucker's avatar
Matt Tucker committed
30 31 32 33 34 35 36 37 38
    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
39
    SessionManager sessionManager = webManager.getSessionManager();
Derek DeMoro's avatar
Derek DeMoro committed
40
    JID address = new JID(jid);
41 42 43
    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
44 45

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

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

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

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

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

71 72 73 74 75 76
<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
77 78

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

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

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

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

            <%  } else { %>

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

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

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

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

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

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

            <%
                } else {
            %>

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

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
158
            <fmt:message key="session.details.presence" />:
Bill Lynch's avatar
Bill Lynch committed
159 160 161
        </td>
        <td>
            <%
Derek DeMoro's avatar
Derek DeMoro committed
162
                Presence.Show show = currentSess.getPresence().getShow();
163 164
                String statusTxt = currentSess.getPresence().getStatus();
                if (statusTxt != null) {
165
                    statusTxt = " -- " + StringUtils.escapeForXML(statusTxt);
166 167 168 169
                }
                else {
                    statusTxt = "";
                }
Derek DeMoro's avatar
Derek DeMoro committed
170
                if (show == Presence.Show.away) {
Bill Lynch's avatar
Bill Lynch committed
171 172
            %>

173
                <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" />">
174
                <fmt:message key="session.details.away" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
175 176

            <%
Derek DeMoro's avatar
Derek DeMoro committed
177
                } else if (show == Presence.Show.chat) {
Bill Lynch's avatar
Bill Lynch committed
178
            %>
179
                <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" />">
180
                <fmt:message key="session.details.chat_available" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
181
            <%
Derek DeMoro's avatar
Derek DeMoro committed
182
                } else if (show == Presence.Show.dnd) {
Bill Lynch's avatar
Bill Lynch committed
183 184
            %>

185
                <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" />">
186
                <fmt:message key="session.details.not_disturb" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
187 188

            <%
Derek DeMoro's avatar
Derek DeMoro committed
189
                } else if (show == null) {
Bill Lynch's avatar
Bill Lynch committed
190 191
            %>

192
                <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" />">
193
                <fmt:message key="session.details.online" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
194 195

            <%
Derek DeMoro's avatar
Derek DeMoro committed
196
                } else if (show == Presence.Show.xa) {
Bill Lynch's avatar
Bill Lynch committed
197 198
            %>

199
                <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" />">
200
                <fmt:message key="session.details.extended" /> <%= statusTxt %>
Bill Lynch's avatar
Bill Lynch committed
201 202 203 204 205

            <%
                } else {
            %>

206
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
207 208 209 210 211 212

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

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

    <div class="jive-table">
    <table cellpadding="3" cellspacing="1" border="0" width="100%">
    <tr>
        <th>&nbsp;</th>
271 272
        <th><fmt:message key="session.details.name" /></th>
        <th><fmt:message key="session.details.resource" /></th>
273
        <th nowrap colspan="2"><fmt:message key="session.details.status" /></th>
274
        <th nowrap colspan="2"><fmt:message key="session.details.if_presence" /></th>
275
        <th><fmt:message key="session.details.priority" /></th>
276 277
        <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
278 279 280 281
    </tr>

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

    <%  } %>

    </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">
            <tr class="jive-current"><td><img src="images/blank.gif" width="12" height="12" border="0"></td></tr>
            </table>
            </div>

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

308
            &nbsp; = <fmt:message key="session.details.session_detail" />
Matt Tucker's avatar
Matt Tucker committed
309 310 311 312 313 314 315 316 317 318

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

<%  } %>

<br>

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

330 331
    </body>
</html>