session-details.jsp 9.63 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

Matt Tucker's avatar
Matt Tucker committed
11
<%@ page import="org.jivesoftware.util.*,
Matt Tucker's avatar
Matt Tucker committed
12
                 java.util.*,
Matt Tucker's avatar
Matt Tucker committed
13 14
                 org.jivesoftware.messenger.*,
                 java.text.NumberFormat,
Derek DeMoro's avatar
Derek DeMoro committed
15
                 org.jivesoftware.admin.*,
Derek DeMoro's avatar
Derek DeMoro committed
16 17
                 org.jivesoftware.messenger.user.User,
                 org.xmpp.packet.JID,
18 19
                 org.xmpp.packet.Presence,
                 java.net.URLEncoder"
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 30 31 32 33 34 35 36 37 38

<%  // Get parameters
    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
    ClientSession currentSess = sessionManager.getSession(address);
Derek DeMoro's avatar
Derek DeMoro committed
42
    boolean isAnonymous = address.getNode() == null || "".equals(address.getNode());
Matt Tucker's avatar
Matt Tucker committed
43 44

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

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

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

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

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

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

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

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

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

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

            <%  } else { %>

                <a href="user-properties.jsp?username=<%= n %>"><%= n %></a>
Matt Tucker's avatar
Matt Tucker committed
116
                - <%= address.getResource()==null?"":address.getResource() %>
Bill Lynch's avatar
Bill Lynch committed
117 118 119 120 121 122

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

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

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

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

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

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

148
                <fmt:message key="session.details.authenticated" />
Bill Lynch's avatar
Bill Lynch committed
149 150 151 152 153

            <%
                } else {
            %>

154
                <fmt:message key="session.details.unknown" />
Bill Lynch's avatar
Bill Lynch committed
155 156 157 158 159 160 161 162

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

Matt Tucker's avatar
Matt Tucker committed
178
                <img src="images/im_away.gif" width="16" height="16" border="0" title="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
            %>
Matt Tucker's avatar
Matt Tucker committed
184
                <img src="images/im_free_chat.gif" width="16" height="16" border="0" title="Available to Chat">
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
            %>

Matt Tucker's avatar
Matt Tucker committed
190
                <img src="images/im_dnd.gif" width="16" height="16" border="0" title="Do 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
            %>

Matt Tucker's avatar
Matt Tucker committed
197
                <img src="images/im_available.gif" width="16" height="16" border="0" title="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
            %>

Matt Tucker's avatar
Matt Tucker committed
204
                <img src="images/im_away.gif" width="16" height="16" border="0" title="Extended Away">
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 218 219

            <%
                }
            %>
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
220
            <fmt:message key="session.details.session_created" />
Bill Lynch's avatar
Bill Lynch committed
221 222
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
223
            <%= JiveGlobals.formatDateTime(currentSess.getCreationDate()) %>
Bill Lynch's avatar
Bill Lynch committed
224 225 226 227
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
228
            <fmt:message key="session.details.last_active" />
Bill Lynch's avatar
Bill Lynch committed
229 230
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
231
            <%= JiveGlobals.formatDateTime(currentSess.getLastActiveDate()) %>
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.statistics" />
Bill Lynch's avatar
Bill Lynch committed
237 238
        </td>
        <td>
Matt Tucker's avatar
Matt Tucker committed
239
            <fmt:message key="session.details.received" />
Bill Lynch's avatar
Bill Lynch committed
240 241 242 243 244
            <%= numFormatter.format(currentSess.getNumClientPackets()) %>/<%= numFormatter.format(currentSess.getNumServerPackets()) %>
        </td>
    </tr>
    <tr>
        <td class="c1">
Matt Tucker's avatar
Matt Tucker committed
245
            <fmt:message key="session.details.hostname" />
Bill Lynch's avatar
Bill Lynch committed
246 247 248 249 250 251 252 253
        </td>
        <td>
            <%= currentSess.getConnection().getInetAddress().getHostAddress() %>
            /
            <%= currentSess.getConnection().getInetAddress().getHostName() %>
        </td>
    </tr>
</tbody>
Matt Tucker's avatar
Matt Tucker committed
254 255 256 257 258 259 260
</table>
</div>

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

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

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

    <%  } %>

    </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%">

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

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

<%  } %>

<br>

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

326 327
    </body>
</html>