[icedtea-web] RFC: Integrate desktop shortcut creation with configuration
Deepak Bhole
dbhole at redhat.com
Tue Nov 9 10:53:28 PST 2010
* Omair Majid <omajid at redhat.com> [2010-11-05 12:13]:
> Hi,
>
> The attached patch allows using the new configuration to select
> whether the user should be prompted for desktop shortcut/launcher
> creation.
>
Looks fine to me. Okay for HEAD.
Deepak
> ChangeLog:
> 2010-11-05 Omair Majid <omajid at redhat.com>
>
> * netx/net/sourceforge/jnlp/ShortcutDesc.java: Change prefixes from
> SHORTCUT_ to CREATE_.
> * netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
> (addMenuAndDesktopEntries): Call shouldCreateShortcut to find out
> if shortcut should be created. Remove call to checkAccess which
> does nothing as the entire stack contains trusted classes.
> (shouldCreateShortcut): New method. Use the configuration to find
> out if a shorcut should be created, and possibly prompt the user.
> * netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java:
> Add KEY_CREATE_DESKTOP_SHORTCUT.
> (loadDefaultProperties): Use KEY_CREATE_DESKTOP_SHORTCUT.
>
> Any thoughts or comments?
>
> Thanks,
> Omair
> diff -r 8e66d9386273 netx/net/sourceforge/jnlp/ShortcutDesc.java
> --- a/netx/net/sourceforge/jnlp/ShortcutDesc.java Thu Nov 04 16:44:27 2010 -0700
> +++ b/netx/net/sourceforge/jnlp/ShortcutDesc.java Fri Nov 05 10:17:49 2010 -0400
> @@ -19,16 +19,15 @@
> public final class ShortcutDesc {
>
> /** Never create a shortcut */
> - public static final String SHORTCUT_NEVER = "NEVER";
> + public static final String CREATE_NEVER = "NEVER";
> /** Always create a shortcut */
> - public static final String SHORTCUT_ALWAYS = "ALWAYS";
> + public static final String CREATE_ALWAYS = "ALWAYS";
> /** Always ask user whether to create a shortcut */
> - public static final String SHORTCUT_ASK_USER = "ASK_USER";
> + public static final String CREATE_ASK_USER = "ASK_USER";
> /** Ask user whether to create a shortcut but only if jnlp file asks for it */
> - public static final String SHORTCUT_ASK_USER_IF_HINTED = "ASK_IF_HINTED";
> + public static final String CREATE_ASK_USER_IF_HINTED = "ASK_IF_HINTED";
> /** Create a desktop shortcut without prompting if the jnlp asks for it */
> - public static final String SHORTCUT_ALWAYS_IF_HINTED = "ALWAYS_IF_HINTED";
> - public static final String SHORTCUT_DEFAULT = SHORTCUT_ASK_USER_IF_HINTED;
> + public static final String CREATE_ALWAYS_IF_HINTED = "ALWAYS_IF_HINTED";
>
> /** the application wants to be placed on the desktop */
> private boolean onDesktop = false;
> diff -r 8e66d9386273 netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
> --- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java Thu Nov 04 16:44:27 2010 -0700
> +++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java Fri Nov 05 10:17:49 2010 -0400
> @@ -35,6 +35,7 @@
> import net.sourceforge.jnlp.ShortcutDesc;
> import net.sourceforge.jnlp.event.ApplicationEvent;
> import net.sourceforge.jnlp.event.ApplicationListener;
> +import net.sourceforge.jnlp.security.SecurityWarning;
> import net.sourceforge.jnlp.security.SecurityWarning.AccessType;
> import net.sourceforge.jnlp.services.ServiceUtil;
> import net.sourceforge.jnlp.util.WeakList;
> @@ -148,10 +149,8 @@
> XDesktopEntry entry = new XDesktopEntry(file);
> ShortcutDesc sd = file.getInformation().getShortcut();
>
> - if (sd != null && sd.onDesktop()) {
> - if (ServiceUtil.checkAccess(this, AccessType.CREATE_DESTKOP_SHORTCUT)) {
> - entry.createDesktopShortcut();
> - }
> + if (shouldCreateShortcut(sd)) {
> + entry.createDesktopShortcut();
> }
>
> if (sd != null && sd.getMenu() != null) {
> @@ -167,6 +166,45 @@
> }
>
> /**
> + * Indicates whether a desktop launcher/shortcut should be created for this
> + * application instance
> + *
> + * @param sd the ShortcutDesc element from the JNLP file
> + * @return true if a desktop shortcut should be created
> + */
> + private boolean shouldCreateShortcut(ShortcutDesc sd) {
> + String currentSetting = JNLPRuntime.getConfiguration()
> + .getProperty(DeploymentConfiguration.KEY_CREATE_DESKTOP_SHORTCUT);
> + boolean createShortcut = false;
> +
> + /*
> + * check configuration and possibly prompt user to find out if a
> + * shortcut should be created or not
> + */
> + if (currentSetting.equals(ShortcutDesc.CREATE_NEVER)) {
> + createShortcut = false;
> + } else if (currentSetting.equals(ShortcutDesc.CREATE_ALWAYS)) {
> + createShortcut = true;
> + } else if (currentSetting.equals(ShortcutDesc.CREATE_ASK_USER)) {
> + if (SecurityWarning.showAccessWarningDialog(AccessType.CREATE_DESTKOP_SHORTCUT, file)) {
> + createShortcut = true;
> + }
> + } else if (currentSetting.equals(ShortcutDesc.CREATE_ASK_USER_IF_HINTED)) {
> + if (sd != null && sd.onDesktop()) {
> + if (SecurityWarning.showAccessWarningDialog(AccessType.CREATE_DESTKOP_SHORTCUT, file)) {
> + createShortcut = true;
> + }
> + }
> + } else if (currentSetting.equals(ShortcutDesc.CREATE_ALWAYS_IF_HINTED)) {
> + if (sd != null && sd.onDesktop()) {
> + createShortcut = true;
> + }
> + }
> +
> + return createShortcut;
> + }
> +
> + /**
> * Releases the application's resources before it is collected.
> * Only collectable if classloader and thread group are
> * also collectable so basically is almost never called (an
> diff -r 8e66d9386273 netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
> --- a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java Thu Nov 04 16:44:27 2010 -0700
> +++ b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java Fri Nov 05 10:17:49 2010 -0400
> @@ -142,6 +142,8 @@
> */
> public static final String KEY_USER_NETX_RUNNING_FILE = "deployment.user.runningfile";
>
> + public static final String KEY_CREATE_DESKTOP_SHORTCUT = "deployment.javaws.shortcut";
> +
> public enum ConfigType {
> System, User
> }
> @@ -363,7 +365,7 @@
> /* JNLP association */
> { "deployment.javaws.associations", String.valueOf(JNLP_ASSOCIATION_ASK_USER) },
> /* desktop integration */
> - { "deployment.javaws.shortcut", ShortcutDesc.SHORTCUT_ASK_USER_IF_HINTED},
> + { KEY_CREATE_DESKTOP_SHORTCUT, ShortcutDesc.CREATE_ASK_USER_IF_HINTED},
> /* jre selection */
> { "deployment.javaws.installURL", null },
> /* jre management */
More information about the distro-pkg-dev
mailing list