mirror of
https://github.com/igniterealtime/Spark.git
synced 2026-03-30 11:24:19 +00:00
the plugin repository can now be configure in default.properties
for a sample structure of how the plugin-repository must look like see documentation/sample_plugin_repository.xml git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12484 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
wolf.posdorfer
parent
fb64898298
commit
7becd91a8d
28
documentation/sample_plugin_repository.xml
Normal file
28
documentation/sample_plugin_repository.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<plugins>
|
||||
<plugin>
|
||||
<name>Testplugin1</name>
|
||||
<version>1.0</version>
|
||||
<author>Some Guy</author>
|
||||
<homePage>http://www.jivesoftware.com</homePage>
|
||||
<email>someguy@somewebsite.com</email>
|
||||
<description>Used for doing stuff</description>
|
||||
<class>org.jivesoftware.spark.test.plugin.stuff</class>
|
||||
<minSparkVersion>2.6.0</minSparkVersion>
|
||||
<downloadURL>http://localhost/test.jar</downloadURL>
|
||||
<changeLog>http://www.google.de/search?q=changelog</changeLog>
|
||||
<readme>http://www.google.de/search?q=readme</readme>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<name>Other Plugin</name>
|
||||
<version>1.0</version>
|
||||
<author>Joe Mamma</author>
|
||||
<homePage>http://www.jivesoftware.com</homePage>
|
||||
<email>Joe@Mama.com</email>
|
||||
<description>Adds some weird features you dont want</description>
|
||||
<class>org.weird.feature.class.mainclass</class>
|
||||
<minSparkVersion>2.6.0</minSparkVersion>
|
||||
<downloadURL>http://localhost/test.jar</downloadURL>
|
||||
<changeLog>http://www.google.de/search?q=changelog</changeLog>
|
||||
<readme>http://www.google.de/search?q=readme</readme>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@ -98,7 +98,7 @@ public class Default {
|
||||
}
|
||||
|
||||
public static boolean getBoolean(String propertyName) {
|
||||
return getString(propertyName).equals("true");
|
||||
return getString(propertyName).replace(" ","").equals("true");
|
||||
}
|
||||
|
||||
public static ImageIcon getImageIcon(String imageName) {
|
||||
|
||||
@ -114,7 +114,15 @@ HELP_FORUM_TEXT =
|
||||
################ Plugins ################
|
||||
#################################################
|
||||
|
||||
|
||||
# This is the default location where Plugins can be downloaded from
|
||||
# for a sample structure see trunk/documentation/sample_plugin_repository.xml
|
||||
# default: http://www.igniterealtime.org/updater/plugins.jsp
|
||||
PLUGIN_REPOSITORY = http://www.igniterealtime.org/updater/plugins.jsp
|
||||
# Use Sparks global Proxy to connect to the repository?
|
||||
# if your repository lies within your network, this probably needs to be disabled
|
||||
# default: true
|
||||
PLUGIN_REPOSITORY_USE_PROXY = true
|
||||
#http://www.igniterealtime.org/updater/plugins.jsp
|
||||
# Disable Installing of Plugins
|
||||
# set true if you want to disable installing of Plugins
|
||||
INSTALL_PLUGINS_DISABLED =
|
||||
|
||||
@ -767,30 +767,29 @@ public class PluginManager implements MainWindowListener {
|
||||
* @throws Exception thrown if there was a problem loading the plugin.
|
||||
*/
|
||||
public void addPlugin(PublicPlugin plugin) throws Exception {
|
||||
expandNewPlugins();
|
||||
expandNewPlugins();
|
||||
|
||||
URL url = new URL(plugin.getDownloadURL());
|
||||
String name = URLFileSystem.getName(url);
|
||||
File pluginDownload = new File(PluginManager.PLUGINS_DIRECTORY, name);
|
||||
URL url = new URL(plugin.getDownloadURL());
|
||||
String name = URLFileSystem.getName(url);
|
||||
File pluginDownload = new File(PluginManager.PLUGINS_DIRECTORY, name);
|
||||
|
||||
((PluginClassLoader)getParentClassLoader()).addPlugin(pluginDownload);
|
||||
|
||||
pluginClass = loadPublicPlugin(pluginDownload);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((PluginClassLoader) getParentClassLoader()).addPlugin(pluginDownload);
|
||||
|
||||
pluginClass = loadPublicPlugin(pluginDownload);
|
||||
|
||||
try {
|
||||
EventQueue.invokeAndWait(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Log.debug("Trying to initialize " + pluginClass);
|
||||
pluginClass.initialize();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
Log.error(e);
|
||||
}
|
||||
|
||||
Log.debug("Trying to initialize " + pluginClass);
|
||||
pluginClass.initialize();
|
||||
}
|
||||
});
|
||||
}
|
||||
catch(Exception e){
|
||||
Log.error(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -32,8 +32,8 @@ public class PublicPlugin {
|
||||
private String description;
|
||||
private String homePage;
|
||||
private String downloadURL;
|
||||
private boolean changeLogAvailable;
|
||||
private boolean readMeAvailable;
|
||||
private String changeLogURL;
|
||||
private String readMeURL;
|
||||
private boolean smallIconAvailable;
|
||||
private boolean largeIconAvailable;
|
||||
private String minVersion;
|
||||
@ -112,20 +112,20 @@ public class PublicPlugin {
|
||||
this.downloadURL = downloadURL;
|
||||
}
|
||||
|
||||
public boolean isChangeLogAvailable() {
|
||||
return changeLogAvailable;
|
||||
public String getChangeLog() {
|
||||
return changeLogURL;
|
||||
}
|
||||
|
||||
public void setChangeLogAvailable(boolean changeLogAvailable) {
|
||||
this.changeLogAvailable = changeLogAvailable;
|
||||
public void setChangeLogURL(String changeLogURL) {
|
||||
this.changeLogURL = changeLogURL;
|
||||
}
|
||||
|
||||
public boolean isReadMeAvailable() {
|
||||
return readMeAvailable;
|
||||
public String getReadMeURL() {
|
||||
return readMeURL;
|
||||
}
|
||||
|
||||
public void setReadMeAvailable(boolean readMeAvailable) {
|
||||
this.readMeAvailable = readMeAvailable;
|
||||
public void setReadMeURL(String readMeURL) {
|
||||
this.readMeURL = readMeURL;
|
||||
}
|
||||
|
||||
public boolean isSmallIconAvailable() {
|
||||
|
||||
@ -52,6 +52,7 @@ import javax.swing.JPanel;
|
||||
import javax.swing.JProgressBar;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JViewport;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
@ -93,7 +94,7 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
|
||||
private boolean loaded = false;
|
||||
|
||||
private String retrieveListURL = "http://www.igniterealtime.org/updater/plugins.jsp";
|
||||
private String retrieveListURL = Default.getString("PLUGIN_REPOSITORY");
|
||||
|
||||
private JProgressBar progressBar;
|
||||
|
||||
@ -145,7 +146,8 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
|
||||
tabbedPane.addChangeListener(new ChangeListener() {
|
||||
public void stateChanged(ChangeEvent changeEvent) {
|
||||
if (tabbedPane.getSelectedIndex() == 1) {
|
||||
if (tabbedPane.getSelectedComponent().equals(
|
||||
((JViewport)availablePanel.getParent()).getParent())) {
|
||||
loadAvailablePlugins();
|
||||
loaded = true;
|
||||
}
|
||||
@ -278,14 +280,18 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
// Get HTTP client
|
||||
Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 443));
|
||||
final HttpClient httpclient = new HttpClient();
|
||||
String proxyHost = System.getProperty("http.proxyHost");
|
||||
String proxyPort = System.getProperty("http.proxyPort");
|
||||
if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) {
|
||||
try {
|
||||
httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Log.error(e);
|
||||
|
||||
if(Default.getBoolean("PLUGIN_REPOSITORY_USE_PROXY"))
|
||||
{
|
||||
String proxyHost = System.getProperty("http.proxyHost");
|
||||
String proxyPort = System.getProperty("http.proxyPort");
|
||||
if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) {
|
||||
try {
|
||||
httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,14 +352,18 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
final HttpClient httpclient = new HttpClient();
|
||||
String proxyHost = System.getProperty("http.proxyHost");
|
||||
String proxyPort = System.getProperty("http.proxyPort");
|
||||
if (ModelUtil.hasLength(proxyHost) && ModelUtil.hasLength(proxyPort)) {
|
||||
try {
|
||||
httpclient.getHostConfiguration().setProxy(proxyHost, Integer.parseInt(proxyPort));
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (Default.getBoolean("PLUGIN_REPOSITORY_USE_PROXY")) {
|
||||
if (ModelUtil.hasLength(proxyHost)
|
||||
&& ModelUtil.hasLength(proxyPort)) {
|
||||
try {
|
||||
httpclient.getHostConfiguration().setProxy(proxyHost,
|
||||
Integer.parseInt(proxyPort));
|
||||
} catch (NumberFormatException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Execute request
|
||||
|
||||
|
||||
@ -514,14 +524,14 @@ public class PluginViewer extends JPanel implements Plugin {
|
||||
publicPlugin.setDownloadURL(downloadURL);
|
||||
}
|
||||
|
||||
Node changeLog = plugin.selectSingleNode("changeLog");
|
||||
if (changeLog != null) {
|
||||
publicPlugin.setChangeLogAvailable(true);
|
||||
Node changeLogNode = plugin.selectSingleNode("changeLog");
|
||||
if (changeLogNode != null) {
|
||||
publicPlugin.setChangeLogURL(changeLogNode.getText());
|
||||
}
|
||||
|
||||
Node readMe = plugin.selectSingleNode("readme");
|
||||
if (readMe != null) {
|
||||
publicPlugin.setReadMeAvailable(true);
|
||||
Node readMeNode = plugin.selectSingleNode("readme");
|
||||
if (readMeNode != null) {
|
||||
publicPlugin.setReadMeURL(readMeNode.getText());
|
||||
}
|
||||
|
||||
Node smallIcon = plugin.selectSingleNode("smallIcon");
|
||||
|
||||
@ -51,12 +51,12 @@ import org.jivesoftware.spark.util.log.Log;
|
||||
public class SparkPlugUI extends JPanel {
|
||||
|
||||
private static final long serialVersionUID = -4206533328807591854L;
|
||||
private PublicPlugin plugin;
|
||||
private PublicPlugin _plugin;
|
||||
private final JButton installButton = new JButton();
|
||||
private JLabel imageIcon = new JLabel();
|
||||
|
||||
public SparkPlugUI(PublicPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
_plugin = plugin;
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
setBackground(Color.white);
|
||||
@ -78,8 +78,8 @@ public class SparkPlugUI extends JPanel {
|
||||
|
||||
titleLabel.setText(plugin.getName());
|
||||
if (plugin.getVersion() != null && plugin.getAuthor() != null) {
|
||||
versionLabel.setText(plugin.getVersion() + " by "
|
||||
+ plugin.getAuthor());
|
||||
versionLabel.setText(_plugin.getVersion() + " by "
|
||||
+ _plugin.getAuthor());
|
||||
}
|
||||
descriptionLabel.setText(plugin.getDescription());
|
||||
|
||||
@ -87,7 +87,7 @@ public class SparkPlugUI extends JPanel {
|
||||
add(installButton, new GridBagConstraints(4, 0, 1, 2, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
|
||||
|
||||
|
||||
if (plugin.isChangeLogAvailable() && plugin.isReadMeAvailable()) {
|
||||
if (_plugin.getChangeLog()!=null && _plugin.getReadMeURL() != null) {
|
||||
RolloverButton changeLogButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.CHANGELOG_IMAGE));
|
||||
RolloverButton readMeButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.README_IMAGE));
|
||||
|
||||
@ -95,7 +95,7 @@ public class SparkPlugUI extends JPanel {
|
||||
changeLogButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
BrowserLauncher.openURL("http://www.igniterealtime.org/updater/retrieve.jsp?filename=" + getFilename() + "&changeLog=true");
|
||||
BrowserLauncher.openURL(_plugin.getChangeLog());
|
||||
}
|
||||
catch (Exception e1) {
|
||||
Log.error(e1);
|
||||
@ -106,7 +106,7 @@ public class SparkPlugUI extends JPanel {
|
||||
readMeButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
BrowserLauncher.openURL("http://www.igniterealtime.org/updater/retrieve.jsp?filename=" + getFilename() + "&readme=true");
|
||||
BrowserLauncher.openURL(_plugin.getReadMeURL());
|
||||
}
|
||||
catch (Exception e1) {
|
||||
Log.error(e1);
|
||||
@ -134,7 +134,7 @@ public class SparkPlugUI extends JPanel {
|
||||
|
||||
public void showOperationButton() {
|
||||
final PluginManager pluginManager = PluginManager.getInstance();
|
||||
if (!pluginManager.isInstalled(plugin)) {
|
||||
if (!pluginManager.isInstalled(_plugin)) {
|
||||
installButton.setIcon(SparkRes.getImageIcon(SparkRes.SMALL_ADD_IMAGE));
|
||||
}
|
||||
else {
|
||||
@ -165,7 +165,7 @@ public class SparkPlugUI extends JPanel {
|
||||
|
||||
|
||||
public PublicPlugin getPlugin() {
|
||||
return plugin;
|
||||
return _plugin;
|
||||
}
|
||||
|
||||
public JButton getInstallButton() {
|
||||
@ -173,7 +173,7 @@ public class SparkPlugUI extends JPanel {
|
||||
}
|
||||
|
||||
public void useLocalIcon() {
|
||||
File pluginDIR = plugin.getPluginDir();
|
||||
File pluginDIR = _plugin.getPluginDir();
|
||||
try {
|
||||
File smallIcon = new File(pluginDIR, "logo_small.gif");
|
||||
File largeIcon = new File(pluginDIR, "logo_large.gif");
|
||||
@ -190,10 +190,14 @@ public class SparkPlugUI extends JPanel {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Filename of provided Download URL
|
||||
* @return
|
||||
*/
|
||||
public String getFilename() {
|
||||
String filename = null;
|
||||
try {
|
||||
URL downloadURL = new URL(plugin.getDownloadURL());
|
||||
URL downloadURL = new URL(_plugin.getDownloadURL());
|
||||
filename = URLFileSystem.getFileName(downloadURL);
|
||||
}
|
||||
catch (MalformedURLException e) {
|
||||
|
||||
Reference in New Issue
Block a user