aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2010-11-10 16:07:06 -0500
committerOmair Majid <[email protected]>2010-11-10 16:07:06 -0500
commit6a451aa7ebf76df590247b90065a4cac6bb7cf3e (patch)
tree5344944bc2d197ce4d116fe5a263b45c9cb421ba /netx/net/sourceforge/jnlp
parentada535b6a8453dca218b72743894c04b70c605be (diff)
integrate desktop shortcut creation with configuration
2010-11-05 Omair Majid <[email protected]> * 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.
Diffstat (limited to 'netx/net/sourceforge/jnlp')
-rw-r--r--netx/net/sourceforge/jnlp/ShortcutDesc.java11
-rw-r--r--netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java46
-rw-r--r--netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java4
3 files changed, 50 insertions, 11 deletions
diff --git a/netx/net/sourceforge/jnlp/ShortcutDesc.java b/netx/net/sourceforge/jnlp/ShortcutDesc.java
index 66367bb..c64fbee 100644
--- a/netx/net/sourceforge/jnlp/ShortcutDesc.java
+++ b/netx/net/sourceforge/jnlp/ShortcutDesc.java
@@ -19,16 +19,15 @@ package net.sourceforge.jnlp;
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 --git a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
index 536f6be..a8c7638 100644
--- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
+++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
@@ -35,6 +35,7 @@ import net.sourceforge.jnlp.SecurityDesc;
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 @@ public class ApplicationInstance {
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 @@ public class ApplicationInstance {
}
/**
+ * 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 --git a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
index f2217ee..ac171ef 100644
--- a/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
+++ b/netx/net/sourceforge/jnlp/runtime/DeploymentConfiguration.java
@@ -154,6 +154,8 @@ public final class DeploymentConfiguration {
public static final String KEY_SYSTEM_TRUSTED_JSSE_CERTS = "deployment.system.security.trusted.jssecerts";
public static final String KEY_SYSTEM_TRUSTED_CLIENT_CERTS = "deployment.system.security.trusted.clientautcerts";
+ public static final String KEY_CREATE_DESKTOP_SHORTCUT = "deployment.javaws.shortcut";
+
public enum ConfigType {
System, User
}
@@ -375,7 +377,7 @@ public final class DeploymentConfiguration {
/* 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 */