GUAC-1260 Allow extensions to override guacamole icons.

This commit is contained in:
James Muehlner
2015-07-22 21:37:09 -07:00
parent df0d6710a6
commit 1a837b9fee
9 changed files with 115 additions and 5 deletions

View File

@@ -108,6 +108,18 @@ public class Extension {
*/
private final Collection<Class<AuthenticationProvider>> authenticationProviderClasses;
/**
* The resource for the small favicon for the extension. If provided, this
* will replace the default guacamole icon.
*/
private final Resource smallIcon;
/**
* The resource foe the large favicon for the extension. If provided, this
* will replace the default guacamole icon.
*/
private final Resource largeIcon;
/**
* Returns a new map of all resources corresponding to the collection of
* paths provided. Each resource will be associated with the given
@@ -346,6 +358,17 @@ public class Extension {
// Define authentication providers
authenticationProviderClasses = getAuthenticationProviderClasses(manifest.getAuthProviders());
// Get small icon resource if provided
if (manifest.getSmallIcon() != null)
smallIcon = new ClassPathResource(classLoader, "image/png", manifest.getSmallIcon());
else
smallIcon = null;
// Get large icon resource if provided
if (manifest.getLargeIcon() != null)
largeIcon = new ClassPathResource(classLoader, "image/png", manifest.getLargeIcon());
else
largeIcon = null;
}
/**
@@ -447,4 +470,26 @@ public class Extension {
return authenticationProviderClasses;
}
/**
* Returns the resource for the small favicon for the extension. If
* provided, this will replace the default guacamole icon.
*
* @return
* The resource for the large favicon.
*/
public Resource getSmallIcon() {
return smallIcon;
}
/**
* Returns the resource for the large favicon for the extension. If
* provided, this will replace the default guacamole icon.
*
* @return
* The resource for the large favicon.
*/
public Resource getLargeIcon() {
return largeIcon;
}
}

View File

@@ -86,6 +86,18 @@ public class ExtensionManifest {
*/
private Collection<String> authProviders;
/**
* The path to the small favicon. If provided, this will replace the default
* guacamole icon.
*/
private String smallIcon;
/**
* The path to the large favicon. If provided, this will replace the default
* guacamole icon.
*/
private String largeIcon;
/**
* Returns the version of the Guacamole web application for which the
* extension was built, such as "0.9.7".
@@ -312,4 +324,46 @@ public class ExtensionManifest {
this.authProviders = authProviders;
}
/**
* Returns the path to the small favicon, relative to the root of the
* extension.
*
* @return The path to the small favicon.
*/
public String getSmallIcon() {
return smallIcon;
}
/**
* Sets the path to the small favicon. This will replace the default
* guacamole icon.
*
* @param smallIcon The path to the small favicon.
*/
public void setSmallIcon(String smallIcon) {
this.smallIcon = smallIcon;
}
/**
* Returns the path to the large favicon, relative to the root of the
* extension.
*
* @return
* The path to the large favicon.
*/
public String getLargeIcon() {
return largeIcon;
}
/**
* Sets the path to the large favicon. This will replace the default
* guacamole icon.
*
* @param largeIcon
* The path to the large favicon.
*/
public void setLargeIcon(String largeIcon) {
this.largeIcon = largeIcon;
}
}

View File

@@ -369,6 +369,14 @@ public class ExtensionModule extends ServletModule {
String staticResourcePrefix = "/app/ext/" + extension.getNamespace() + "/";
serveStaticResources(staticResourcePrefix, extension.getStaticResources());
// Serve up the small favicon if provided
if(extension.getSmallIcon() != null)
serve("/images/logo-64.png").with(new ResourceServlet(extension.getSmallIcon()));
// Serve up the large favicon if provided
if(extension.getLargeIcon()!= null)
serve("/images/logo-144.png").with(new ResourceServlet(extension.getLargeIcon()));
// Log successful loading of extension by name
logger.info("Extension \"{}\" loaded.", extension.getName());