jwrapper.jwutils
Class JWLinuxOS

java.lang.Object
  extended by jwrapper.jwutils.JWGenericOS
      extended by jwrapper.jwutils.JWLinuxOS

public class JWLinuxOS
extends JWGenericOS

Utility APIs for Linux


Field Summary
static java.lang.String SHORTCUT_CATEGORY_AUDIOVIDEO
           
static java.lang.String SHORTCUT_CATEGORY_DEVELOPMENT
           
static java.lang.String SHORTCUT_CATEGORY_EDUCATION
           
static java.lang.String SHORTCUT_CATEGORY_GAME
           
static java.lang.String SHORTCUT_CATEGORY_GRAPHICS
           
static java.lang.String SHORTCUT_CATEGORY_NETWORK
           
static java.lang.String SHORTCUT_CATEGORY_OFFICE
           
static java.lang.String SHORTCUT_CATEGORY_SCIENCE
           
static java.lang.String SHORTCUT_CATEGORY_SETTINGS
           
static java.lang.String SHORTCUT_CATEGORY_SYSTEM
           
static java.lang.String SHORTCUT_CATEGORY_UTILITY
           
 
Constructor Summary
JWLinuxOS()
           
 
Method Summary
static void createApplicationDesktopShortcut(java.lang.String name, java.lang.String targetCommand)
           
static void createApplicationDesktopShortcut(java.lang.String name, java.lang.String targetCommand, java.io.File icon)
           
static void createApplicationStartShortcut(java.lang.String linkFilename, java.lang.String name, java.lang.String targetCommand, boolean allUsers)
           
static void createApplicationStartShortcut(java.lang.String linkFilename, java.lang.String name, java.lang.String targetCommand, boolean allUsers, java.io.File icon)
           
static void createWebpageDesktopShortcut(java.lang.String name, java.lang.String url)
           
static void createWebpageDesktopShortcut(java.lang.String name, java.lang.String url, java.io.File icon)
           
static void createWebpageStartShortcut(java.lang.String linkFilename, java.lang.String name, java.lang.String url, boolean allUsers)
           
static void createWebpageStartShortcut(java.lang.String linkFilename, java.lang.String name, java.lang.String url, boolean allUsers, java.io.File icon)
           
static void deleteApplicationStartShortcut(java.lang.String linkFilename, boolean allUsers)
           
static void deleteWebpageStartShortcut(java.lang.String linkFilename, boolean allUsers)
           
 java.lang.String[] getAllConsoleUsers()
          Get a list of all users logged in to the console (logged in to a graphical session)
static int getBeesuElevationFailedReturnCode()
          Get the return code that Beesu will return if an attempted elevated launch fails (1)
static int getGkSudoElevationCancelledReturnCode()
          Get the return code that GkSudo will return if an attempted elevated launch is cancelled (255)
static int getGkSudoElevationFailedReturnCode()
          Get the return code that GkSudo will return if an attempted elevated launch fails (1)
static int getGnomeSUElevationFailedReturnCode()
          Get the return code that gnomesu will return if an attempted elevated launch fails (1)
 java.lang.String getHostname()
           
static JWLinuxOS getLinuxInstance()
           
static int getPkExecElevationCancelledReturnCode()
          Get the return code that PkExec will return if an attempted elevated launch is cancelled (126)
static int getPkExecElevationFailedReturnCode()
          Get the return code that PkExec will return if an attempted elevated launch fails (127)
static boolean isBeeSuAvailable()
           
static boolean isCommandAvailable(java.lang.String command)
          Checks whether a particular command (e.g.
static boolean isGkSudoAvailable()
          On some linux distros the pre-command 'gksudo ' is used to elevate, this tests whether it is available on this distro.
static boolean isGnomeSuAvailable()
           
static boolean isKdeSudoAvailable()
           
static boolean isPkExecAvailable()
          On some linux distros the pre-command 'pkexec ' is used to elevate, this tests whether it is available on this distro.
 boolean killProcess(int pid)
          Kill the process with the given PID
 
Methods inherited from class jwrapper.jwutils.JWGenericOS
getCurrentProcessID, getInstance, getOSName, getOSNameWithBitness, getOSVersion, setCurrentDirectory, setReadableForAllUsers, setReadableForAllUsersAndWait, setWritableForAllUsers, setWritableForAllUsersAndWait, terminateProcess
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORTCUT_CATEGORY_AUDIOVIDEO

public static final java.lang.String SHORTCUT_CATEGORY_AUDIOVIDEO
See Also:
Constant Field Values

SHORTCUT_CATEGORY_DEVELOPMENT

public static final java.lang.String SHORTCUT_CATEGORY_DEVELOPMENT
See Also:
Constant Field Values

SHORTCUT_CATEGORY_EDUCATION

public static final java.lang.String SHORTCUT_CATEGORY_EDUCATION
See Also:
Constant Field Values

SHORTCUT_CATEGORY_GAME

public static final java.lang.String SHORTCUT_CATEGORY_GAME
See Also:
Constant Field Values

SHORTCUT_CATEGORY_GRAPHICS

public static final java.lang.String SHORTCUT_CATEGORY_GRAPHICS
See Also:
Constant Field Values

SHORTCUT_CATEGORY_NETWORK

public static final java.lang.String SHORTCUT_CATEGORY_NETWORK
See Also:
Constant Field Values

SHORTCUT_CATEGORY_OFFICE

public static final java.lang.String SHORTCUT_CATEGORY_OFFICE
See Also:
Constant Field Values

SHORTCUT_CATEGORY_SCIENCE

public static final java.lang.String SHORTCUT_CATEGORY_SCIENCE
See Also:
Constant Field Values

SHORTCUT_CATEGORY_SETTINGS

public static final java.lang.String SHORTCUT_CATEGORY_SETTINGS
See Also:
Constant Field Values

SHORTCUT_CATEGORY_SYSTEM

public static final java.lang.String SHORTCUT_CATEGORY_SYSTEM
See Also:
Constant Field Values

SHORTCUT_CATEGORY_UTILITY

public static final java.lang.String SHORTCUT_CATEGORY_UTILITY
See Also:
Constant Field Values
Constructor Detail

JWLinuxOS

public JWLinuxOS()
Method Detail

createApplicationDesktopShortcut

public static void createApplicationDesktopShortcut(java.lang.String name,
                                                    java.lang.String targetCommand)
                                             throws java.io.IOException
Throws:
java.io.IOException

createApplicationDesktopShortcut

public static void createApplicationDesktopShortcut(java.lang.String name,
                                                    java.lang.String targetCommand,
                                                    java.io.File icon)
                                             throws java.io.IOException
Throws:
java.io.IOException

createApplicationStartShortcut

public static void createApplicationStartShortcut(java.lang.String linkFilename,
                                                  java.lang.String name,
                                                  java.lang.String targetCommand,
                                                  boolean allUsers)
                                           throws java.io.IOException
Throws:
java.io.IOException

createApplicationStartShortcut

public static void createApplicationStartShortcut(java.lang.String linkFilename,
                                                  java.lang.String name,
                                                  java.lang.String targetCommand,
                                                  boolean allUsers,
                                                  java.io.File icon)
                                           throws java.io.IOException
Throws:
java.io.IOException

createWebpageDesktopShortcut

public static void createWebpageDesktopShortcut(java.lang.String name,
                                                java.lang.String url)
                                         throws java.io.IOException
Throws:
java.io.IOException

createWebpageDesktopShortcut

public static void createWebpageDesktopShortcut(java.lang.String name,
                                                java.lang.String url,
                                                java.io.File icon)
                                         throws java.io.IOException
Throws:
java.io.IOException

createWebpageStartShortcut

public static void createWebpageStartShortcut(java.lang.String linkFilename,
                                              java.lang.String name,
                                              java.lang.String url,
                                              boolean allUsers)
                                       throws java.io.IOException
Throws:
java.io.IOException

createWebpageStartShortcut

public static void createWebpageStartShortcut(java.lang.String linkFilename,
                                              java.lang.String name,
                                              java.lang.String url,
                                              boolean allUsers,
                                              java.io.File icon)
                                       throws java.io.IOException
Throws:
java.io.IOException

deleteApplicationStartShortcut

public static void deleteApplicationStartShortcut(java.lang.String linkFilename,
                                                  boolean allUsers)
                                           throws java.io.IOException
Throws:
java.io.IOException

deleteWebpageStartShortcut

public static void deleteWebpageStartShortcut(java.lang.String linkFilename,
                                              boolean allUsers)
                                       throws java.io.IOException
Throws:
java.io.IOException

getAllConsoleUsers

public java.lang.String[] getAllConsoleUsers()
Get a list of all users logged in to the console (logged in to a graphical session)

Specified by:
getAllConsoleUsers in class JWGenericOS
Returns:

getBeesuElevationFailedReturnCode

public static int getBeesuElevationFailedReturnCode()
Get the return code that Beesu will return if an attempted elevated launch fails (1)

Returns:

getGkSudoElevationCancelledReturnCode

public static int getGkSudoElevationCancelledReturnCode()
Get the return code that GkSudo will return if an attempted elevated launch is cancelled (255)

Returns:

getGkSudoElevationFailedReturnCode

public static int getGkSudoElevationFailedReturnCode()
Get the return code that GkSudo will return if an attempted elevated launch fails (1)

Returns:

getGnomeSUElevationFailedReturnCode

public static int getGnomeSUElevationFailedReturnCode()
Get the return code that gnomesu will return if an attempted elevated launch fails (1)

Returns:

getHostname

public java.lang.String getHostname()
Overrides:
getHostname in class JWGenericOS

getLinuxInstance

public static JWLinuxOS getLinuxInstance()

getPkExecElevationCancelledReturnCode

public static int getPkExecElevationCancelledReturnCode()
Get the return code that PkExec will return if an attempted elevated launch is cancelled (126)

Returns:

getPkExecElevationFailedReturnCode

public static int getPkExecElevationFailedReturnCode()
Get the return code that PkExec will return if an attempted elevated launch fails (127)

Returns:

isBeeSuAvailable

public static boolean isBeeSuAvailable()

isCommandAvailable

public static boolean isCommandAvailable(java.lang.String command)
Checks whether a particular command (e.g. 'ls', 'gksudo', 'wget', 'curl') is available on this Linux distro.

Parameters:
command - the command to check for, this should contain no arguments and just be individual command
Returns:
whether the command is available

isGkSudoAvailable

public static boolean isGkSudoAvailable()
On some linux distros the pre-command 'gksudo ' is used to elevate, this tests whether it is available on this distro.

Returns:
true if gksudo is available

isGnomeSuAvailable

public static boolean isGnomeSuAvailable()

isKdeSudoAvailable

public static boolean isKdeSudoAvailable()

isPkExecAvailable

public static boolean isPkExecAvailable()
On some linux distros the pre-command 'pkexec ' is used to elevate, this tests whether it is available on this distro.

Returns:
true if psexec is available

killProcess

public boolean killProcess(int pid)
Kill the process with the given PID