Class XDesktopEntry

  • All Implemented Interfaces:
    GenericDesktopEntry

    public class XDesktopEntry
    extends java.lang.Object
    implements GenericDesktopEntry
    This class builds a (freedesktop.org) desktop entry out of a JNLPFile . This entry can be used to install desktop shortcuts. See xdg-desktop-icon (1) and http://standards.freedesktop.org/desktop-entry-spec/latest/ for more information
    • Constructor Detail

      • XDesktopEntry

        public XDesktopEntry​(JNLPFile file)
        Create a XDesktopEntry for the given JNLP file
        Parameters:
        file - a JNLPFile that indicates the application to launch
    • Method Detail

      • getContent

        java.lang.String getContent​(boolean menu,
                                    AccessWarningPaneComplexReturn.ShortcutResult info)
        Returns the contents of the XDesktopEntry as a String.
        Parameters:
        menu - whether to create this icon to menu
        info - result of user's interference
        Returns:
        string with desktop shortcut specification
      • getBrowserBin

        public static java.lang.String getBrowserBin()
      • sanitize

        private static java.lang.String sanitize​(java.lang.String input)
        Sanitizes a string so that it can be used safely in a key=value pair in a desktop entry file.
        Parameters:
        input - a String to sanitize
        Returns:
        a string safe to use as either the key or the value in the key=value pair in a desktop entry file
      • getShortcutTmpFile

        java.io.File getShortcutTmpFile()
      • getUniqueIconName

        private java.lang.String getUniqueIconName​(java.lang.String iconName)
      • convertToIco

        private java.io.File convertToIco​(java.io.File source,
                                          java.lang.String targetName)
      • cacheAndGetIconLocation

        java.lang.String cacheAndGetIconLocation()
      • possibleFavIconLocations

        static java.util.List<java.lang.String> possibleFavIconLocations​(java.lang.String path)
      • favUrl

        private static java.net.URL favUrl​(java.lang.String delimiter,
                                           java.lang.String path,
                                           JNLPFile file)
                                    throws java.net.MalformedURLException
        Throws:
        java.net.MalformedURLException
      • downloadFavIcon

        private static java.io.File downloadFavIcon​(JNLPFile file)
      • getShortcutName

        private java.lang.String getShortcutName()
      • getDesktop

        static java.io.File getDesktop()
      • getShortcutFileName

        private java.lang.String getShortcutFileName()
      • findAndVerifyGeneratedJnlpDir

        private static java.lang.String findAndVerifyGeneratedJnlpDir()
      • findAndVerifyJavawsMenuDir

        private static java.lang.String findAndVerifyJavawsMenuDir()
      • findAndVerifyBasicDir

        private static java.lang.String findAndVerifyBasicDir​(java.io.File f,
                                                              java.lang.String message)
      • findFreedesktopOrgDesktopPathCatch

        public static java.lang.String findFreedesktopOrgDesktopPathCatch()
      • findFreedesktopOrgDesktopPath

        private static java.lang.String findFreedesktopOrgDesktopPath()
                                                               throws java.io.IOException
        Instead of having all this parsing of user-dirs.dirs and replacing variables we can execute `echo $(xdg-user-dir DESKTOP)` and it will do all the job in case approaches below become failing
        Returns:
        variables (if declared) and quotation marks (unless escaped) free path
        Throws:
        java.io.IOException - if no file do not exists or key with desktop do not exists
      • getFreedesktopOrgDesktopPathFrom

        private static java.lang.String getFreedesktopOrgDesktopPathFrom​(java.io.File userDirs)
                                                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • getFreedesktopOrgDesktopPathFrom

        static java.lang.String getFreedesktopOrgDesktopPathFrom​(java.io.BufferedReader r)
                                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • filterQuotes

        private static java.lang.String filterQuotes​(java.lang.String string)
      • evaluateLinuxVariables

        private static java.lang.String evaluateLinuxVariables​(java.lang.String orig)
      • evaluateLinuxVariables

        private static java.lang.String evaluateLinuxVariables​(java.lang.String orig,
                                                               java.util.Map<java.lang.String,​java.lang.String> variables)