available-plugins.jsp 18.8 KB
Newer Older
Gaston Dombiak's avatar
Gaston Dombiak committed
1 2 3 4 5 6 7
<%--
  - Copyright (C) 2006 Jive Software. All rights reserved.
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
--%>

8 9 10 11 12 13 14 15 16 17 18 19
<%@ page errorPage="error.jsp" import="org.jivesoftware.util.ByteFormat,
                                       org.jivesoftware.util.Version,
                                       org.jivesoftware.wildfire.XMPPServer,
                                       org.jivesoftware.wildfire.container.Plugin"
    %>
<%@ page import="org.jivesoftware.wildfire.container.PluginManager" %>
<%@ page import="org.jivesoftware.wildfire.update.AvailablePlugin" %>
<%@ page import="org.jivesoftware.wildfire.update.UpdateManager" %>
<%@ page import="java.io.File" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Collections" %>
20
<%@ page import="java.util.Comparator" %>
21 22 23 24
<%@ page import="java.util.List" %>
<%@ page import="org.jivesoftware.util.JiveGlobals"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
25
<%@ page import="org.jivesoftware.util.WebManager"%><%@ page import="org.jivesoftware.util.LocaleUtils"%>
Gaston Dombiak's avatar
Gaston Dombiak committed
26 27 28 29

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

Derek DeMoro's avatar
Derek DeMoro committed
30 31 32
<%
    WebManager webManager = new WebManager();
%>
Gaston Dombiak's avatar
Gaston Dombiak committed
33 34 35 36 37 38

<%
    boolean downloadRequested = request.getParameter("download") != null;
    String url = request.getParameter("url");

    UpdateManager updateManager = XMPPServer.getInstance().getUpdateManager();
39 40 41 42 43
    List<AvailablePlugin> plugins = updateManager.getNotInstalledPlugins();

    // Sort plugins alphabetically
    Collections.sort(plugins, new Comparator() {
        public int compare(Object o1, Object o2) {
44
            return ((AvailablePlugin)o1).getName().compareTo(((AvailablePlugin)o2).getName());
45 46
        }
    });
Gaston Dombiak's avatar
Gaston Dombiak committed
47 48 49 50 51 52 53 54 55

    if (downloadRequested) {
        // Download and install new plugin
        updateManager.downloadPlugin(url);
    }

%>

<html>
56 57 58
<head>
<title><fmt:message key="plugin.available.title"/></title>
<meta name="pageID" content="available-plugins"/>
59 60 61 62 63 64 65 66 67 68

<style type="text/css">

.light-gray-border {
    border-color: #bbb;
    border-style: solid;
    border-width: 1px 1px 1px 1px;
    padding: 5px;
}

Derek DeMoro's avatar
Derek DeMoro committed
69

70 71 72 73 74 75 76 77 78 79 80 81

.table-header {
    text-align: left;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    border-color: #bbb;
    border-style: solid;
    border-width: 1px 0px 1px 0px;
    padding: 5px;
}

82 83 84 85 86 87 88 89 90 91 92
.table-header-align-right {
    text-align: right;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    border-color: #bbb;
    border-style: solid;
    border-width: 1px 0px 1px 0px;
    padding: 5px;
}

93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
.row-header {
    text-align: left;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    border-color: #bbb;
    border-style: solid;
    border-width: 1px 1px 1px 0px;
    padding: 5px;
}

.table-header-left {
    text-align: left;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    border-color: #bbb;
    border-style: solid;
    border-width: 1px 0px 1px 1px;
    padding: 5px;

}

.table-header-right {
    text-align: left;
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 8pt;
    font-weight: bold;
    border-color: #bbb;
    border-style: solid;
    border-width: 1px 1px 1px 0px;
    padding: 5px;
}

.line-bottom-border {
    font-family: verdana, arial, helvetica, sans-serif;
    font-size: 9pt;
    border-color: #bbb;
    border-style: solid;
    border-width: 0px 0px 1px 0px;
    padding: 5px;
}


</style>

139
<script src="dwr/engine.js" type="text/javascript"></script>
140 141
<script src="dwr/util.js" type="text/javascript"></script>
<script src="dwr/interface/downloader.js" type="text/javascript"></script>
142
<script type="text/javascript">
143 144

    var downloading;
145
    function downloadPlugin(url, id) {
146
        downloading = true;
147
        document.getElementById(id + "-image").innerHTML = '<img src="images/working-16x16.gif" border="0"/>';
Derek DeMoro's avatar
Derek DeMoro committed
148
        document.getElementById(id).style.background = "#FFFFCC";
149 150 151 152 153
        setTimeout("startDownload('" + url + "','" + id + "')", 5000);
    }

    function startDownload(url, id) {
        downloader.installPlugin(downloadComplete, url, id);
154 155
    }

156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
    function downloadComplete(status) {
        downloading = false;
        if (!status.successfull) {
            document.getElementById(status.hashCode + "-image").innerHTML = '<img src="images/add-16x16.gif" border="0"/>';
            document.getElementById(status.hashCode).style.background = "#FFFFFF";
            document.getElementById("errorMessage").style.display = '';
            document.getElementById(status.hashCode).style.display = '';
            document.getElementById(status.hashCode + "-row").style.display = 'none';
            setTimeout("closeErrorMessage()", 5000);
        }
        else {
            document.getElementById(status.hashCode).style.display = 'none';
            document.getElementById(status.hashCode + "-row").style.display = '';
            setTimeout("fadeIt('" + status.hashCode + "')", 3000);
        }
171 172
    }

173 174
    function closeErrorMessage(){
        Effect.Fade("errorMessage");
175 176 177 178 179
    }

    function fadeIt(id) {
        Effect.Fade(id + "-row");
    }
180 181


182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
    DWREngine.setErrorHandler(handleError);

    function handleError(error) {
    }

    // Handle leaving of page validation.
    window.onbeforeunload = function (evt) {
        if (!downloading) {
            return;
        }
        var message = '<fmt:message key="plugin.available.cancel.redirect" />';
        if (typeof evt == 'undefined') {
            evt = window.event;
        }
        if (evt) {
            evt.returnValue = message;
        }
        return message;
    }
201

Derek DeMoro's avatar
Derek DeMoro committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215
    function updatePluginsList(){
        document.getElementById("reloaderID").innerHTML = '<img src="images/working-16x16.gif" border="0"/>';
        downloader.updatePluginsList(pluginsListUpdated);
    }

    function updatePluginsListNow(){
        document.getElementById("reloader2").innerHTML = '<img src="images/working-16x16.gif" border="0"/>';
        downloader.updatePluginsList(pluginsListUpdated);
    }

    function pluginsListUpdated(){
        window.location.href = "available-plugins.jsp";
    }

216

217 218 219 220
</script>
</head>

<body>
Gaston Dombiak's avatar
Gaston Dombiak committed
221 222

<p>
223
    <fmt:message key="plugin.available.info"/>
Gaston Dombiak's avatar
Gaston Dombiak committed
224
</p>
225

Gaston Dombiak's avatar
Gaston Dombiak committed
226 227
<p>

228
<%if(plugins.size() == 0){ %>
229
<div style="padding:10px;background:#FFEBB5;border:1px solid #DEB24A;width:75%;">
Derek DeMoro's avatar
Derek DeMoro committed
230
    <fmt:message key="plugin.available.no.list" />&nbsp;<span id="reloaderID"><a href="javascript:updatePluginsList();"><fmt:message key="plugin.available.list" /></a></span>
231 232
</div>
<br/>
233
<div style="width:75%;">
234 235 236 237 238 239 240 241 242 243 244
    <p>
   <fmt:message key="plugin.available.no.list.description" />
</p>

<% if(!updateManager.isServiceEnabled()){ %>
<fmt:message key="plugin.available.auto.update.currently" /> <b><fmt:message key="plugin.available.auto.update.currently.disabled" /></b>. <a href="manage-updates.jsp"><fmt:message key="plugin.available.click.here" /></a> <fmt:message key="plugin.available.change" />
<% } %>
</div>
<% } else {%>


245 246 247
<div id="errorMessage" class="error" style="display:none;">
    <fmt:message key="plugin.available.error.downloading" />
</div>
248 249


250
<div class="light-gray-border" style="padding:10px;">
Gaston Dombiak's avatar
Gaston Dombiak committed
251 252
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<thead>
253 254
    <tr style="background:#F7F7FF;">
        <td class="table-header-left">&nbsp;</td>
Derek DeMoro's avatar
Derek DeMoro committed
255
        <td nowrap colspan="2" class="table-header"><fmt:message key="plugin.available.open_source"/></td>
256 257 258 259 260
        <td nowrap class="table-header"><fmt:message key="plugin.available.description"/></td>
        <td nowrap class="table-header"><fmt:message key="plugin.available.version"/></td>
        <td nowrap class="table-header"><fmt:message key="plugin.available.author"/></td>
        <td nowrap class="table-header">File Size</td>
        <td nowrap class="table-header-right"><fmt:message key="plugin.available.install"/></td>
Gaston Dombiak's avatar
Gaston Dombiak committed
261 262 263 264 265
    </tr>
</thead>
<tbody>

<%
266
    // If only the admin plugin is installed, show "none".
Gaston Dombiak's avatar
Gaston Dombiak committed
267 268
    if (plugins.isEmpty()) {
%>
269 270 271
<tr>
    <td align="center" colspan="8"><fmt:message key="plugin.available.no_plugin"/></td>
</tr>
Gaston Dombiak's avatar
Gaston Dombiak committed
272 273 274 275 276 277 278 279
<%
    }

    for (AvailablePlugin plugin : plugins) {
        String pluginName = plugin.getName();
        String pluginDescription = plugin.getDescription();
        String pluginAuthor = plugin.getAuthor();
        String pluginVersion = plugin.getLatestVersion();
280 281 282 283 284 285
        ByteFormat byteFormat = new ByteFormat();
        String fileSize = byteFormat.format(plugin.getFileSize());

        if (plugin.isCommercial()) {
            continue;
        }
Gaston Dombiak's avatar
Gaston Dombiak committed
286
%>
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
<tr id="<%= plugin.hashCode()%>">
    <td width="1%" class="line-bottom-border">
        <% if (plugin.getIcon() != null) { %>
        <img src="<%= plugin.getIcon() %>" width="16" height="16" alt="Plugin">
        <% }
        else { %>
        <img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin">
        <% } %>
    </td>
    <td width="20%" nowrap class="line-bottom-border">
        <%= (pluginName != null ? pluginName : "") %> &nbsp;
    </td>
    <td nowrap valign="top" class="line-bottom-border">
        <% if (plugin.getReadme() != null) { %>
        <a href="<%= plugin.getReadme() %>"
            ><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
        <% }
        else { %> &nbsp; <% } %>
        <% if (plugin.getChangelog() != null) { %>
        <a href="<%= plugin.getChangelog() %>"
            ><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
        <% }
        else { %> &nbsp; <% } %>
    </td>
    <td width="60%" class="line-bottom-border">
        <%= pluginDescription != null ? pluginDescription : "" %>
    </td>
    <td width="5%" align="center" valign="top" class="line-bottom-border">
        <%= pluginVersion != null ? pluginVersion : "" %>
    </td>
    <td width="15%" nowrap valign="top" class="line-bottom-border">
        <%= pluginAuthor != null ? pluginAuthor : "" %>  &nbsp;
    </td>
320
    <td width="15%" nowrap valign="top" class="line-bottom-border" align="right">
321 322 323 324 325 326 327 328 329 330 331 332 333
        <%= fileSize %>
    </td>
    <td width="1%" align="center" valign="top" class="line-bottom-border">
        <%
            String updateURL = plugin.getURL();
            if (updateManager.isPluginDownloaded(updateURL)) {
        %>
        &nbsp;
        <%  }
        else { %>
        <%

        %>
334 335
        <a href="javascript:downloadPlugin('<%=updateURL%>', '<%= plugin.hashCode()%>')"><span id="<%= plugin.hashCode() %>-image"><img src="images/add-16x16.gif" width="16" height="16" border="0"
                                                                                                                                        alt="<fmt:message key="plugin.available.download" />"></span></a>
336 337 338 339

        <% } %>
    </td>
</tr>
340
<tr id="<%= plugin.hashCode()%>-row" style="display:none;background: #E7FBDE;">
341 342 343
    <td width="1%" class="line-bottom-border">
        <img src="<%= plugin.getIcon()%>" width="16" height="16"/>
    </td>
344
    <td colspan="6" nowrap class="line-bottom-border"><%= plugin.getName()%> <fmt:message key="plugin.available.installation.success" /></td>
345 346 347 348
    <td class="line-bottom-border" align="center">
        <img src="images/success-16x16.gif" height="16" width="16"/>
    </td>
</tr>
349 350 351
<%
    }
%>
352 353 354
<tr><td><br/></td></tr>
<tr style="background:#F7F7FF;">
    <td class="table-header-left">&nbsp;</td>
Derek DeMoro's avatar
Derek DeMoro committed
355
    <td nowrap colspan="7" class="row-header"><fmt:message key="plugin.available.commercial_plugins" /></td>
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
</tr>
<%
    for (AvailablePlugin plugin : plugins) {
        String pluginName = plugin.getName();
        String pluginDescription = plugin.getDescription();
        String pluginAuthor = plugin.getAuthor();
        String pluginVersion = plugin.getLatestVersion();
        ByteFormat byteFormat = new ByteFormat();
        String fileSize = byteFormat.format(plugin.getFileSize());

        if (!plugin.isCommercial()) {
            continue;
        }
%>
<tr id="<%= plugin.hashCode()%>">
    <td width="1%" class="line-bottom-border">
        <% if (plugin.getIcon() != null) { %>
        <img src="<%= plugin.getIcon() %>" width="16" height="16" alt="Plugin">
        <% }
        else { %>
        <img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin">
        <% } %>
    </td>
    <td width="20%" nowrap class="line-bottom-border">
        <%= (pluginName != null ? pluginName : "") %> &nbsp;
    </td>
    <td nowrap valign="top" class="line-bottom-border">
        <% if (plugin.getReadme() != null) { %>
        <a href="<%= plugin.getReadme() %>"
            ><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
        <% }
        else { %> &nbsp; <% } %>
        <% if (plugin.getChangelog() != null) { %>
        <a href="<%= plugin.getChangelog() %>"
            ><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
        <% }
        else { %> &nbsp; <% } %>
    </td>
    <td width="60%" class="line-bottom-border">
        <%= pluginDescription != null ? pluginDescription : "" %>
    </td>
    <td width="5%" align="center" valign="top" class="line-bottom-border">
        <%= pluginVersion != null ? pluginVersion : "" %>
    </td>
    <td width="15%" nowrap valign="top" class="line-bottom-border">
        <%= pluginAuthor != null ? pluginAuthor : "" %>  &nbsp;
    </td>
    <td width="15%" nowrap valign="top" class="line-bottom-border">
        <%= fileSize  %>
    </td>
    <td width="1%" align="center" valign="top" class="line-bottom-border">
        <%
            String updateURL = plugin.getURL();
            if (updateManager.isPluginDownloaded(updateURL)) {
        %>
        &nbsp;
        <%  }
        else { %>

        <span id="<%= plugin.hashCode() %>-image"><a href="javascript:downloadPlugin('<%=updateURL%>', '<%= plugin.hashCode()%>')"><img src="images/add-16x16.gif" width="16" height="16" border="0"
                                                                                                                                        alt="<fmt:message key="plugin.available.download" />"></a></span>
        <% } %>
    </td>
</tr>
420 421
<tr id="<%= plugin.hashCode()%>-row" style="display:none;background: #E7FBDE;">
     <td width="1%" class="line-bottom-border">
422 423
        <img src="<%= plugin.getIcon()%>" width="16" height="16"/>
    </td>
424 425
    <td colspan="6" nowrap class="line-bottom-border"><%= plugin.getName()%> <fmt:message key="plugin.available.installation.success" /></td>
    <td class="line-bottom-border" align="center">
426 427 428
        <img src="images/success-16x16.gif" height="16" width="16"/>
    </td>
</tr>
429
<%
Gaston Dombiak's avatar
Gaston Dombiak committed
430 431
    }
%>
432

Gaston Dombiak's avatar
Gaston Dombiak committed
433 434
</tbody>
</table>
435

Gaston Dombiak's avatar
Gaston Dombiak committed
436 437
</div>

438 439 440 441 442 443 444 445
<br/>


<%
    final XMPPServer server = XMPPServer.getInstance();
    Version version = server.getServerInfo().getVersion();
    List<Plugin> outdatedPlugins = new ArrayList<Plugin>();
    for (Plugin plugin : server.getPluginManager().getPlugins()) {
446
        String pluginVersion = server.getPluginManager().getMinServerVersion(plugin);
447 448 449 450 451 452 453 454
        if (pluginVersion != null && pluginVersion.compareTo(version.getVersionString()) > 0) {
            outdatedPlugins.add(plugin);
        }
    }

    if (outdatedPlugins.size() > 0) {
%>
    <div class="light-gray-border" style="padding:10px;">
Derek DeMoro's avatar
Derek DeMoro committed
455
    <p><fmt:message key="plugin.available.outdated" /><a href="http://www.jivesoftware.org/wildfire" target="_blank"><fmt:message key="plugin.available.outdated.update" /></a></p>
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
    <table cellpadding="0" cellspacing="0" border="0" width="100%">


        <%
            PluginManager pluginManager = server.getPluginManager();
            for (Plugin plugin : outdatedPlugins) {
                String pluginName = pluginManager.getName(plugin);
                String pluginDescription = pluginManager.getDescription(plugin);
                String pluginAuthor = pluginManager.getAuthor(plugin);
                String pluginVersion = pluginManager.getVersion(plugin);
                File pluginDir = pluginManager.getPluginDirectory(plugin);
                File icon = new File(pluginDir, "logo_small.png");
                boolean readmeExists = new File(pluginDir, "readme.html").exists();
                boolean changelogExists = new File(pluginDir, "changelog.html").exists();
                if (!icon.exists()) {
                    icon = new File(pluginDir, "logo_small.gif");
                }
        %>
        <tr>
            <td class="line-bottom-border" width="1%">
                <% if (icon.exists()) { %>
477
                <img src="/geticon?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showIcon=true&decorator=none" width="16" height="16" alt="Plugin">
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
                <% }
                else { %>
                <img src="images/plugin-16x16.gif" width="16" height="16" alt="Plugin">
                <% } %>
            </td>
            <td class="line-bottom-border" width="1%" nowrap>
                <%= pluginName%>
            </td>
            <td nowrap class="line-bottom-border">
                <p><% if (readmeExists) { %>
                    <a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showReadme=true&decorator=none"
                        ><img src="images/doc-readme-16x16.gif" width="16" height="16" border="0" alt="README"></a>
                    <% }
                    else { %> &nbsp; <% } %>
                    <% if (changelogExists) { %>
                    <a href="plugin-admin.jsp?plugin=<%= URLEncoder.encode(pluginDir.getName(), "utf-8") %>&showChangelog=true&decorator=none"
                        ><img src="images/doc-changelog-16x16.gif" width="16" height="16" border="0" alt="changelog"></a>
                    <% }
                    else { %> &nbsp; <% } %></p>
            </td>
            <td class="line-bottom-border">
                <%= pluginDescription %>
            </td>
            <td class="line-bottom-border">
                <%= pluginVersion%>
            </td>
            <td class="line-bottom-border">
                <%= pluginAuthor%>
            </td>
        </tr>
        <% }%>
  </table>

        <%} %>

</div>
<br/>
515
 <%
516
        String time = JiveGlobals.getProperty("update.lastCheck");
517
        if(time != null){
518
        Date date = new Date(Long.parseLong(time));
519
        time = JiveGlobals.formatDate(date);
520
        }
521 522
    %>
       <p>
523
           <% if(time != null) { %>
524
        <fmt:message key="plugin.available.autoupdate" /> <%= time%>.
525
           <% } %>
526
           <% if(updateManager.isServiceEnabled()){%>
527 528 529 530
              <fmt:message key="plugin.available.autoupdate.on" />
           <% } else { %>
                <fmt:message key="plugin.available.autoupdate.off" />
           <% } %>
Derek DeMoro's avatar
Derek DeMoro committed
531
           &nbsp;<span id="reloader2"><a href="javascript:updatePluginsListNow()"><fmt:message key="plugin.available.manual.update" /></a></span>
532 533
        </p>
           <% } %>
534

535
</body>
Gaston Dombiak's avatar
Gaston Dombiak committed
536
</html>