Package com.biglybt.platform.macosx
Class PlatformManagerImpl
java.lang.Object
com.biglybt.platform.PlatformManagerBase
com.biglybt.platform.macosx.PlatformManagerImpl
- All Implemented Interfaces:
AEDiagnosticsEvidenceGenerator
,PlatformManager
,PlatformManager
public class PlatformManagerImpl
extends PlatformManagerBase
implements PlatformManager, AEDiagnosticsEvidenceGenerator
Performs platform-specific operations with Mac OS X
- Version:
- 1.0 Initial Version
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private final HashSet
private Class
<?> protected static AEMonitor
private String
private boolean
private Core
private static final String[]
private static String
private static final LogIDs
private static final String[]
private Process
private boolean
private boolean
private static final String[]
protected static PlatformManagerImpl
Fields inherited from interface com.biglybt.pif.platform.PlatformManager
LOC_DOCUMENTS, LOC_DOWNLOADS, LOC_MUSIC, LOC_USER_DATA, LOC_VIDEO
Fields inherited from interface com.biglybt.platform.PlatformManager
ERR_UNSUPPORTED, PT_MACOSX, PT_OTHER, PT_UNIX, PT_WINDOWS, SD_ALL, SD_HIBERNATE, SD_SHUTDOWN, SD_SLEEP, USER_REQUEST_INFO, USER_REQUEST_QUESTION, USER_REQUEST_WARNING
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new PlatformManager and initializes its capabilities -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(PlatformManagerListener listener) private File
private void
checkCapability
(PlatformManagerCapabilities capability) protected static boolean
compileOSAScript
(CharSequence[] cmds, File destination) Compiles a new AppleScript instance to the specified locationprotected static boolean
compileOSAScript
(CharSequence cmd, File destination) Compiles a new AppleScript instance to the specified locationprivate boolean
containsTag
(String line, String tag) private void
convertToXML
(File file) void
copyFilePermissions
(String from_file_name, String to_file_name) void
createProcess
(String cmd, boolean inheritsHandles) void
dispose()
Disposes system resources.private String
findCommand
(String name) void
generate
(IndentWriter writer) private File
Bundle Path is the .app file that launched vuze, usually /Applications/Vuze.appcommand to launch Vuzeprivate String
Bundle Path is the .app file that launched vuze, usually /Applications/Vuze.appString[]
private static String
Gets the preferred file browser nameprivate Class
<?> private File[]
private String
getLocation
(long location_id) Get a well-known location, if defined for the platformprivate File
int
This max-open-files concept here is from linux/osx where network connections are treated as 'files'int
boolean
boolean
int
static PlatformManagerImpl
Gets the platform manager singleton, which was already initializedboolean
hasCapability
(PlatformManagerCapabilities capability) Gets whether the platform manager supports a capabilityprivate boolean
private static void
Instantiates the singletonboolean
isAdditionalFileTypeRegistered
(String name, String type) Checks to see if the supplied file type is registered with this applicationboolean
private boolean
private boolean
isOurMimeType
(String mimetype) private boolean
isOurScheme
(String scheme) Class
<?> loadClass
(ClassLoader loader, String class_name) Gives a particular platform the ability to alter the class-loading methodstatic void
protected static String
performOSAScript
(File script) Compiles a new AppleScript instance and runs itprotected static String
Compiles a new AppleScript instance and runs itprotected static String
performOSAScript
(CharSequence[] cmds) Compiles a new AppleScript instance and runs itvoid
protected static Process
performRuntimeExec
(String[] cmdargs) void
ping
(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) void
Plays the system alert (the jingle is specified by the user in System Preferences)void
registerAdditionalFileType
(String name, String description, String type, String content_type) Registers a file type with this applicationvoid
void
removeListener
(PlatformManagerListener listener) void
requestUserAttention
(int type, Object data) If the application is not active causes the application icon at the bottom to bounce until the application becomes active If the application is already active then this method does nothing.void
setExplicitVMOptions
(String[] options) void
setPreventComputerSleep
(boolean prevent_it) void
setRunAtLogin
(boolean run) void
setTCPTOSEnabled
(boolean enabled) enable or disable the platforms support for TCP TOSboolean
setUseSystemTheme
(boolean use_it) void
Reveals the file or directory with the platform's default browservoid
showInFinder
(File path) Shows the given file or directory in Findervoid
showInTerminal
(File path) Shows the given file or directory in Terminal by executing cd /absolute/path/tovoid
showInTerminal
(String path) Shows the given file or directory in Terminal by executing cd /absolute/path/tovoid
shutdown
(int type) void
boolean
testNativeAvailability
(String name) void
traceRoute
(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) void
unregisterAdditionalFileType
(String name, String type) Removes a file-type registrationMethods inherited from class com.biglybt.platform.PlatformManagerBase
checkCanUseJVMOptions
-
Field Details
-
LOGID
-
BUNDLE_ID
- See Also:
-
SCHEMES
-
MIMETYPES
-
EXTENSIONS
-
singleton
-
class_mon
-
fileBrowserName
-
capabilitySet
-
computer_name
-
computer_name_tried
private volatile boolean computer_name_tried -
claFileManager
-
core
-
prevent_computer_sleep_pending
private boolean prevent_computer_sleep_pending -
prevent_computer_sleep
private boolean prevent_computer_sleep -
prevent_computer_proc
-
-
Constructor Details
-
PlatformManagerImpl
public PlatformManagerImpl()Creates a new PlatformManager and initializes its capabilities
-
-
Method Details
-
getSingleton
Gets the platform manager singleton, which was already initialized -
initializeSingleton
private static void initializeSingleton()Instantiates the singleton -
getPlatformType
public int getPlatformType()- Specified by:
getPlatformType
in interfacePlatformManager
-
getVersion
- Specified by:
getVersion
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setUseSystemTheme
- Specified by:
setUseSystemTheme
in interfacePlatformManager
- Parameters:
use_it
-- Returns:
- if changes were made then true is returned, otherwise false
- Throws:
PlatformManagerException
-
getVMOptionFile
- Specified by:
getVMOptionFile
in interfacePlatformManager
- Throws:
PlatformManagerException
-
checkCapability
private void checkCapability(PlatformManagerCapabilities capability) throws PlatformManagerException - Throws:
PlatformManagerException
-
getExplicitVMOptions
- Specified by:
getExplicitVMOptions
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setExplicitVMOptions
- Specified by:
setExplicitVMOptions
in interfacePlatformManager
- Throws:
PlatformManagerException
-
checkAndGetLocalVMOptionFile
- Throws:
PlatformManagerException
-
getJVMOptionRedirect
-
hasVMOptions
private boolean hasVMOptions() -
getJVMOptionFiles
-
startup
- Specified by:
startup
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getShutdownTypes
public int getShutdownTypes()- Specified by:
getShutdownTypes
in interfacePlatformManager
-
shutdown
- Specified by:
shutdown
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setPreventComputerSleep
- Specified by:
setPreventComputerSleep
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getPreventComputerSleep
public boolean getPreventComputerSleep()- Specified by:
getPreventComputerSleep
in interfacePlatformManager
-
getRunAtLogin
- Specified by:
getRunAtLogin
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setRunAtLogin
- Specified by:
setRunAtLogin
in interfacePlatformManager
- Throws:
PlatformManagerException
-
convertToXML
- Throws:
PlatformManagerException
-
findCommand
-
containsTag
-
getLoginPList
- Throws:
PlatformManagerException
-
getUserDataDirectory
- Specified by:
getUserDataDirectory
in interfacePlatformManager
- Throws:
PlatformManagerException
- See Also:
-
getComputerName
- Specified by:
getComputerName
in interfacePlatformManager
- Returns:
- null if can't be found
-
getLocation
Description copied from interface:PlatformManager
Get a well-known location, if defined for the platform- Specified by:
getLocation
in interfacePlatformManager
- Parameters:
location_id
- from above LOC_constants- Returns:
- Throws:
PlatformManagerException
-
isApplicationRegistered
- Specified by:
isApplicationRegistered
in interfacePlatformManager
- Throws:
PlatformManagerException
-
isOurExt
-
isOurScheme
-
isOurMimeType
-
getBundlePath
Bundle Path is the .app file that launched vuze, usually /Applications/Vuze.app -
getAbsoluteBundleFile
Bundle Path is the .app file that launched vuze, usually /Applications/Vuze.app -
getApplicationCommandLine
command to launch Vuze- Specified by:
getApplicationCommandLine
in interfacePlatformManager
- Throws:
PlatformManagerException
-
isAdditionalFileTypeRegistered
public boolean isAdditionalFileTypeRegistered(String name, String type) throws PlatformManagerException Description copied from interface:PlatformManager
Checks to see if the supplied file type is registered with this application- Specified by:
isAdditionalFileTypeRegistered
in interfacePlatformManager
- Parameters:
name
-type
-- Returns:
- Throws:
PlatformManagerException
-
unregisterAdditionalFileType
Description copied from interface:PlatformManager
Removes a file-type registration- Specified by:
unregisterAdditionalFileType
in interfacePlatformManager
- Parameters:
name
-type
-- Throws:
PlatformManagerException
-
registerAdditionalFileType
public void registerAdditionalFileType(String name, String description, String type, String content_type) throws PlatformManagerException Description copied from interface:PlatformManager
Registers a file type with this application- Specified by:
registerAdditionalFileType
in interfacePlatformManager
- Parameters:
name
-description
-type
-content_type
-- Throws:
PlatformManagerException
-
registerApplication
- Specified by:
registerApplication
in interfacePlatformManager
- Throws:
PlatformManagerException
-
createProcess
- Specified by:
createProcess
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getFileManagerClass
-
performRecoverableFileDelete
- Specified by:
performRecoverableFileDelete
in interfacePlatformManager
- Throws:
PlatformManagerException
-
hasCapability
Gets whether the platform manager supports a capability
Users of PlatformManager should check for supported capabilities before calling the corresponding methods
Note that support for a particular capability may change arbitrarily in the duration of the application session, but the manager will cache where necessary.
- Specified by:
hasCapability
in interfacePlatformManager
- Parameters:
capability
- A platform manager capability- Returns:
- True if the manager supports the capability
-
dispose
public void dispose()Disposes system resources. This method is optional.- Specified by:
dispose
in interfacePlatformManager
-
setTCPTOSEnabled
enable or disable the platforms support for TCP TOS- Specified by:
setTCPTOSEnabled
in interfacePlatformManager
- Parameters:
enabled
-- Throws:
PlatformManagerException
-
copyFilePermissions
public void copyFilePermissions(String from_file_name, String to_file_name) throws PlatformManagerException - Specified by:
copyFilePermissions
in interfacePlatformManager
- Throws:
PlatformManagerException
-
showFile
Reveals the file or directory with the platform's default browser- Specified by:
showFile
in interfacePlatformManager
- Parameters:
path
- The full path to a file or directory- Throws:
PlatformManagerException
- If this operation fails
-
playSystemAlert
public void playSystemAlert()Plays the system alert (the jingle is specified by the user in System Preferences) -
showInFinder
Shows the given file or directory in Finder
- Parameters:
path
- Absolute path to the file or directory
-
showInTerminal
Shows the given file or directory in Terminal by executing cd /absolute/path/to
- Parameters:
path
- Absolute path to the file or directory
-
showInTerminal
Shows the given file or directory in Terminal by executing cd /absolute/path/to
- Parameters:
path
- Absolute path to the file or directory
-
performOSAScript
Compiles a new AppleScript instance and runs it- Parameters:
cmd
- AppleScript command to execute; do not surround command with extra quotation marks- Returns:
- Output of the script
- Throws:
IOException
- If the script failed to execute
-
performOSAScript
Compiles a new AppleScript instance and runs it- Parameters:
cmds
- AppleScript Sequence of commands to execute; do not surround command with extra quotation marks- Returns:
- Output of the script
- Throws:
IOException
- If the script failed to execute
-
performOSAScript
Compiles a new AppleScript instance and runs it- Parameters:
script
- AppleScript file (.scpt) to execute- Returns:
- Output of the script
- Throws:
IOException
- If the script failed to execute
-
compileOSAScript
Compiles a new AppleScript instance to the specified location- Parameters:
cmd
- Command to compile; do not surround command with extra quotation marksdestination
- Destination location of the AppleScript file- Returns:
- True if compiled successfully
-
compileOSAScript
Compiles a new AppleScript instance to the specified location- Parameters:
cmds
- Sequence of commands to compile; do not surround command with extra quotation marksdestination
- Destination location of the AppleScript file- Returns:
- True if compiled successfully
-
performRuntimeExec
- Throws:
IOException
- See Also:
-
getFileBrowserName
Gets the preferred file browser name
Currently supported browsers are Path Finder and Finder. If Path Finder is currently running (not just installed), then "Path Finder is returned; else, "Finder" is returned.
- Returns:
- "Path Finder" if it is currently running; else "Finder"
-
testNativeAvailability
- Specified by:
testNativeAvailability
in interfacePlatformManager
- Throws:
PlatformManagerException
-
traceRoute
public void traceRoute(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) throws PlatformManagerException - Specified by:
traceRoute
in interfacePlatformManager
- Throws:
PlatformManagerException
-
ping
public void ping(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) throws PlatformManagerException - Specified by:
ping
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getMaxOpenFiles
Description copied from interface:PlatformManager
This max-open-files concept here is from linux/osx where network connections are treated as 'files'- Specified by:
getMaxOpenFiles
in interfacePlatformManager
- Returns:
- Throws:
PlatformManagerException
-
addListener
- Specified by:
addListener
in interfacePlatformManager
-
removeListener
- Specified by:
removeListener
in interfacePlatformManager
-
generate
- Specified by:
generate
in interfaceAEDiagnosticsEvidenceGenerator
-
getAzComputerID
- Throws:
PlatformManagerException
-
requestUserAttention
If the application is not active causes the application icon at the bottom to bounce until the application becomes active If the application is already active then this method does nothing. Note: This is an undocumented feature from Apple so it's behavior may change without warning- Specified by:
requestUserAttention
in interfacePlatformManager
- Parameters:
type
- one of USER_REQUEST_INFO, USER_REQUEST_WARNINGdata
-- Throws:
PlatformManagerException
-
loadClass
Description copied from interface:PlatformManager
Gives a particular platform the ability to alter the class-loading method- Specified by:
loadClass
in interfacePlatformManager
- Parameters:
loader
-class_name
-- Returns:
- Throws:
PlatformManagerException
-
main
-