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 Stringprivate final HashSetprivate Class<?> protected static AEMonitorprivate Stringprivate booleanprivate Coreprivate static final String[]private static Stringprivate static final LogIDsprivate static final String[]private Processprivate booleanprivate booleanprivate static final String[]protected static PlatformManagerImplFields inherited from interface PlatformManager
LOC_DOCUMENTS, LOC_DOWNLOADS, LOC_MUSIC, LOC_USER_DATA, LOC_VIDEOFields inherited from interface 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 TypeMethodDescriptionvoidaddListener(PlatformManagerListener listener) private Fileprivate voidcheckCapability(PlatformManagerCapabilities capability) protected static booleancompileOSAScript(CharSequence[] cmds, File destination) Compiles a new AppleScript instance to the specified locationprotected static booleancompileOSAScript(CharSequence cmd, File destination) Compiles a new AppleScript instance to the specified locationprivate booleancontainsTag(String line, String tag) private voidconvertToXML(File file) voidcopyFilePermissions(String from_file_name, String to_file_name) voidcreateProcess(String cmd, boolean inheritsHandles) voiddispose()Disposes system resources.private StringfindCommand(String name) voidgenerate(IndentWriter writer) private FileBundle Path is the .app file that launched vuze, usually /Applications/Vuze.appcommand to launch Vuzeprivate StringBundle Path is the .app file that launched vuze, usually /Applications/Vuze.appString[]private static StringGets the preferred file browser nameprivate Class<?> private File[]private StringgetLocation(long location_id) Get a well-known location, if defined for the platformprivate FileintThis max-open-files concept here is from linux/osx where network connections are treated as 'files'intbooleanbooleanintstatic PlatformManagerImplGets the platform manager singleton, which was already initializedbooleanhasCapability(PlatformManagerCapabilities capability) Gets whether the platform manager supports a capabilityprivate booleanprivate static voidInstantiates the singletonbooleanisAdditionalFileTypeRegistered(String name, String type) Checks to see if the supplied file type is registered with this applicationbooleanprivate booleanprivate booleanisOurMimeType(String mimetype) private booleanisOurScheme(String scheme) Class<?> loadClass(ClassLoader loader, String class_name) Gives a particular platform the ability to alter the class-loading methodstatic voidprotected static StringperformOSAScript(File script) Compiles a new AppleScript instance and runs itprotected static StringCompiles a new AppleScript instance and runs itprotected static StringperformOSAScript(CharSequence[] cmds) Compiles a new AppleScript instance and runs itvoidprotected static ProcessperformRuntimeExec(String[] cmdargs) voidping(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) voidPlays the system alert (the jingle is specified by the user in System Preferences)voidregisterAdditionalFileType(String name, String description, String type, String content_type) Registers a file type with this applicationvoidvoidremoveListener(PlatformManagerListener listener) voidrequestUserAttention(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.voidsetExplicitVMOptions(String[] options) voidsetPreventComputerSleep(boolean prevent_it) voidsetRunAtLogin(boolean run) voidsetTCPTOSEnabled(boolean enabled) enable or disable the platforms support for TCP TOSbooleansetUseSystemTheme(boolean use_it) voidReveals the file or directory with the platform's default browservoidshowInFinder(File path) Shows the given file or directory in FindervoidshowInTerminal(File path) Shows the given file or directory in Terminal by executing cd /absolute/path/tovoidshowInTerminal(String path) Shows the given file or directory in Terminal by executing cd /absolute/path/tovoidshutdown(int type) voidbooleantestNativeAvailability(String name) voidtraceRoute(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) voidunregisterAdditionalFileType(String name, String type) Removes a file-type registrationMethods inherited from class 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:
getPlatformTypein interfacePlatformManager
-
getVersion
- Specified by:
getVersionin interfacePlatformManager- Throws:
PlatformManagerException
-
setUseSystemTheme
- Specified by:
setUseSystemThemein interfacePlatformManager- Parameters:
use_it-- Returns:
- if changes were made then true is returned, otherwise false
- Throws:
PlatformManagerException
-
getVMOptionFile
- Specified by:
getVMOptionFilein interfacePlatformManager- Throws:
PlatformManagerException
-
checkCapability
private void checkCapability(PlatformManagerCapabilities capability) throws PlatformManagerException - Throws:
PlatformManagerException
-
getExplicitVMOptions
- Specified by:
getExplicitVMOptionsin interfacePlatformManager- Throws:
PlatformManagerException
-
setExplicitVMOptions
- Specified by:
setExplicitVMOptionsin interfacePlatformManager- Throws:
PlatformManagerException
-
checkAndGetLocalVMOptionFile
- Throws:
PlatformManagerException
-
getJVMOptionRedirect
-
hasVMOptions
private boolean hasVMOptions() -
getJVMOptionFiles
-
startup
- Specified by:
startupin interfacePlatformManager- Throws:
PlatformManagerException
-
getShutdownTypes
public int getShutdownTypes()- Specified by:
getShutdownTypesin interfacePlatformManager
-
shutdown
- Specified by:
shutdownin interfacePlatformManager- Throws:
PlatformManagerException
-
setPreventComputerSleep
- Specified by:
setPreventComputerSleepin interfacePlatformManager- Throws:
PlatformManagerException
-
getPreventComputerSleep
public boolean getPreventComputerSleep()- Specified by:
getPreventComputerSleepin interfacePlatformManager
-
getRunAtLogin
- Specified by:
getRunAtLoginin interfacePlatformManager- Throws:
PlatformManagerException
-
setRunAtLogin
- Specified by:
setRunAtLoginin interfacePlatformManager- Throws:
PlatformManagerException
-
convertToXML
- Throws:
PlatformManagerException
-
findCommand
-
containsTag
-
getLoginPList
- Throws:
PlatformManagerException
-
getUserDataDirectory
- Specified by:
getUserDataDirectoryin interfacePlatformManager- Throws:
PlatformManagerException- See Also:
-
getComputerName
- Specified by:
getComputerNamein interfacePlatformManager- Returns:
- null if can't be found
-
getLocation
Description copied from interface:PlatformManagerGet a well-known location, if defined for the platform- Specified by:
getLocationin interfacePlatformManager- Parameters:
location_id- from above LOC_constants- Returns:
- Throws:
PlatformManagerException
-
isApplicationRegistered
- Specified by:
isApplicationRegisteredin 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:
getApplicationCommandLinein interfacePlatformManager- Throws:
PlatformManagerException
-
isAdditionalFileTypeRegistered
public boolean isAdditionalFileTypeRegistered(String name, String type) throws PlatformManagerException Description copied from interface:PlatformManagerChecks to see if the supplied file type is registered with this application- Specified by:
isAdditionalFileTypeRegisteredin interfacePlatformManager- Parameters:
name-type-- Returns:
- Throws:
PlatformManagerException
-
unregisterAdditionalFileType
Description copied from interface:PlatformManagerRemoves a file-type registration- Specified by:
unregisterAdditionalFileTypein 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:PlatformManagerRegisters a file type with this application- Specified by:
registerAdditionalFileTypein interfacePlatformManager- Parameters:
name-description-type-content_type-- Throws:
PlatformManagerException
-
registerApplication
- Specified by:
registerApplicationin interfacePlatformManager- Throws:
PlatformManagerException
-
createProcess
- Specified by:
createProcessin interfacePlatformManager- Throws:
PlatformManagerException
-
getFileManagerClass
-
performRecoverableFileDelete
- Specified by:
performRecoverableFileDeletein 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:
hasCapabilityin 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:
disposein interfacePlatformManager
-
setTCPTOSEnabled
enable or disable the platforms support for TCP TOS- Specified by:
setTCPTOSEnabledin interfacePlatformManager- Parameters:
enabled-- Throws:
PlatformManagerException
-
copyFilePermissions
public void copyFilePermissions(String from_file_name, String to_file_name) throws PlatformManagerException - Specified by:
copyFilePermissionsin interfacePlatformManager- Throws:
PlatformManagerException
-
showFile
Reveals the file or directory with the platform's default browser- Specified by:
showFilein 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:
testNativeAvailabilityin interfacePlatformManager- Throws:
PlatformManagerException
-
traceRoute
public void traceRoute(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) throws PlatformManagerException - Specified by:
traceRoutein interfacePlatformManager- Throws:
PlatformManagerException
-
ping
public void ping(InetAddress interface_address, InetAddress target, PlatformManagerPingCallback callback) throws PlatformManagerException - Specified by:
pingin interfacePlatformManager- Throws:
PlatformManagerException
-
getMaxOpenFiles
Description copied from interface:PlatformManagerThis max-open-files concept here is from linux/osx where network connections are treated as 'files'- Specified by:
getMaxOpenFilesin interfacePlatformManager- Returns:
- Throws:
PlatformManagerException
-
addListener
- Specified by:
addListenerin interfacePlatformManager
-
removeListener
- Specified by:
removeListenerin interfacePlatformManager
-
generate
- Specified by:
generatein 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:
requestUserAttentionin interfacePlatformManager- Parameters:
type- one of USER_REQUEST_INFO, USER_REQUEST_WARNINGdata-- Throws:
PlatformManagerException
-
loadClass
Description copied from interface:PlatformManagerGives a particular platform the ability to alter the class-loading method- Specified by:
loadClassin interfacePlatformManager- Parameters:
loader-class_name-- Returns:
- Throws:
PlatformManagerException
-
main
-