[rfc][icedtea-web] fixinf of desktop icon behaviour

Jiri Vanek jvanek at redhat.com
Fri Dec 21 08:58:02 PST 2012


On 12/21/2012 05:38 PM, Adam Domurad wrote:
> On 12/21/2012 11:05 AM, Jiri Vanek wrote:
>> Hi! This is fix for http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=725 - JNLP applications will prompt for creating desktop shortcuts every time they are run
>>
>> When I have seen Omairs original patch it was too much complicated, So I want at least to try this one.
>
> Do you know why Omair used explicit locking? I couldn't quite figure it out
nope ;(
>
>> It is pretty simple. The disadvantage however is:
>> +    public File getFinalLinuxDesktopIconFile() {
>> +        return new File(System.getProperty("user.home")+"/Desktop/"+getDesktopIconFinalName()+".desktop");
>> +    }
>>
>> to be dependent on System.getProperty("user.home")+"/Desktop/" and .desktop suffix.
>>
>> However .. can it be enough?
>>
>> The second patch is for testing purposes of this case which I would like to push forward as soon as possible.
>>
>> J.
>
>> doNotAskToDesktopIconCreationWithXtrustAll.patch
>>
>>
>> diff -r a24c48429ff1 netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
>> --- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java	Fri Dec 21 13:19:14 2012 +0100
>> +++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java	Fri Dec 21 16:58:29 2012 +0100
>> @@ -171,6 +177,9 @@
>>        * @return true if a desktop shortcut should be created
>>        */
>>       private boolean shouldCreateShortcut(ShortcutDesc sd) {
>> +        if (JNLPRuntime.isTrustAll()) {
>> +            return true;
>> +        }
>>           String currentSetting = JNLPRuntime.getConfiguration()
>>                   .getProperty(DeploymentConfiguration.KEY_CREATE_DESKTOP_SHORTCUT);
>>           boolean createShortcut = false;
>
> This is OK for head.

thank you.
>
>>
>> fixedRecreationOfDesktopIcon.patch
>>
>>
>> diff -r a24c48429ff1 netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java
>> --- a/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java	Fri Dec 21 13:19:14 2012 +0100
>> +++ b/netx/net/sourceforge/jnlp/runtime/ApplicationInstance.java	Fri Dec 21 16:58:29 2012 +0100
>> @@ -146,7 +146,13 @@
>>       private void addMenuAndDesktopEntries() {
>>           XDesktopEntry entry = new XDesktopEntry(file);
>>           ShortcutDesc sd = file.getInformation().getShortcut();
>> -
>> +        if (entry.getFinalLinuxDesktopIconFile().exists()) {
>
> How would this behave if it was ever run on a non-Linux system ?

It will create file which will probably not exists. So it will return false and so do the next lines -  so it do correct.
>
>> +            if (JNLPRuntime.isDebug()) {
>> +                System.out.println("ApplicationInstance.addMenuAndDesktopEntries(): file - "
>> +                        + entry.getFinalLinuxDesktopIconFile().getAbsolutePath() + " already exists. Not proceeding with desktop additions");
>> +            }
>> +            return;
>> +        }
>>           if (shouldCreateShortcut(sd)) {
>>               entry.createDesktopShortcut();
>>           }
>> diff -r a24c48429ff1 netx/net/sourceforge/jnlp/util/XDesktopEntry.java
>> --- a/netx/net/sourceforge/jnlp/util/XDesktopEntry.java	Fri Dec 21 13:19:14 2012 +0100
>> +++ b/netx/net/sourceforge/jnlp/util/XDesktopEntry.java	Fri Dec 21 16:58:29 2012 +0100
>> @@ -78,7 +78,7 @@
>>
>>           String fileContents = "[Desktop Entry]\n";
>>           fileContents += "Version=1.0\n";
>> -        fileContents += "Name=" + sanitize(file.getTitle()) + "\n";
>> +        fileContents += "Name=" + getDesktopIconFinalName() + "\n";
>>           fileContents += "GenericName=Java Web Start Application\n";
>>           fileContents += "Comment=" + sanitize(file.getInformation().getDescription()) + "\n";
>>           fileContents += "Type=Application\n";
>> @@ -122,6 +122,11 @@
>>           return iconSize;
>>       }
>>
>> +    public File getShortcutTmpFile() {
>> +        File shortcutFile = new File(JNLPRuntime.getConfiguration().getProperty(DeploymentConfiguration.KEY_USER_TMP_DIR) + File.separator + FileUtils.sanitizeFileName(file.getTitle()) + ".desktop");
>> +        return shortcutFile;
>> +    }
>> +
>>       /**
>>        * Set the icon size to use for the desktop shortcut
>>        *
>> @@ -148,9 +153,7 @@
>>        * Install this XDesktopEntry into the user's desktop as a launcher
>>        */
>>       private void installDesktopLauncher() {
>> -        File shortcutFile = new File(JNLPRuntime.getConfiguration()
>> -                .getProperty(DeploymentConfiguration.KEY_USER_TMP_DIR)
>> -                + File.separator + FileUtils.sanitizeFileName(file.getTitle()) + ".desktop");
>> +        File shortcutFile = getShortcutTmpFile();
>>           try {
>>
>>               if (!shortcutFile.getParentFile().isDirectory()&&  !shortcutFile.getParentFile().mkdirs()) {
>> @@ -234,4 +237,12 @@
>>           }
>>       }
>>
>> +    public String getDesktopIconFinalName() {
>> +        return sanitize(file.getTitle());
>> +    }
>> +
>> +    public File getFinalLinuxDesktopIconFile() {
>> +        return new File(System.getProperty("user.home")+"/Desktop/"+getDesktopIconFinalName()+".desktop");
>
> A deployment property could still be good. This seems a little hardcoded.

Yah hardcoded but nice and doing as expected.  How does deployment property behave when desktop icon is removed manually (what is what we actually all do:) ?

Is there some system independent way how to get usr's desktop? It will solve this, but I think there is not.

So when (System.getProperty("user.home")+"/Desktop/" will become invalid we can elaborate here by array of locations?

I still don't like the cannon (to kill a chicken) which deployment property was....
>
>> +    }
>> +
>>   }
>
> happy hackerdays,
> -Adam




More information about the distro-pkg-dev mailing list