Package com.biglybt.platform.win32
Class PlatformManagerImpl
- java.lang.Object
-
- com.biglybt.platform.win32.PlatformManagerImpl
-
- All Implemented Interfaces:
AEDiagnosticsEvidenceGenerator
,PlatformManager
,PlatformManager
,AEWin32AccessListener
public class PlatformManagerImpl extends java.lang.Object implements PlatformManager, AEWin32AccessListener, AEDiagnosticsEvidenceGenerator
-
-
Field Summary
Fields Modifier and Type Field Description private AEWin32Access
access
private java.lang.String
app_exe_name
private java.lang.String
app_name
private java.io.File
az_exe
private boolean
az_exe_checked
static java.lang.String
BIGLYBY_ASSOC
private java.util.Set<PlatformManagerCapabilities>
capabilitySet
private static AEMonitor
class_mon
static java.lang.String
DLL_NAME
private static boolean
init_tried
private static boolean
initialising
private java.util.List
listeners
static java.lang.String
OLD_MAIN_ASS0C
private boolean
prevent_computer_sleep
private AEThread2
prevent_sleep_thread
static int
RT_AZ
static int
RT_NONE
static int
RT_OTHER
private static PlatformManagerImpl
singleton
-
Fields inherited from interface com.biglybt.platform.win32.access.AEWin32AccessListener
ET_RESUME, ET_SHUTDOWN, ET_SUSPEND, RT_SUSPEND_DENY
-
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
Constructors Modifier Constructor Description protected
PlatformManagerImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(PlatformManagerListener listener)
protected void
applyPatches()
private boolean
canHibernate()
private java.io.File
checkAndGetLocalVMOptionFile()
private void
checkCapability(PlatformManagerCapabilities capability)
protected void
checkExeKey(int hkey, java.io.File exe)
protected void
checkExeKey(java.io.File exe)
void
copyFilePermissions(java.lang.String from_file_name, java.lang.String to_file_name)
protected boolean
createKey(int type, java.lang.String key)
void
createProcess(java.lang.String command_line, boolean inherit_handles)
void
dispose()
Does nothingint
eventOccurred(int type)
protected void
fixPermissions(java.io.File parent, java.io.File dir)
void
generate(IndentWriter writer)
int
getAdditionalFileTypeRegistrationDetails(java.lang.String name, java.lang.String type)
java.lang.String
getApplicationCommandLine()
protected java.io.File
getApplicationEXELocation()
java.lang.String
getComputerName()
java.lang.String[]
getExplicitVMOptions()
protected int
getIconIndex()
private UpdateInstaller
getInstaller(Core core)
private java.io.File[]
getJVMOptionFiles()
private java.lang.String
getJVMOptionRedirect()
java.io.File
getLocation(long location_id)
Get a well-known location, if defined for the platformint
getMaxOpenFiles()
This max-open-files concept here is from linux/osx where network connections are treated as 'files'int
getPlatformType()
boolean
getPreventComputerSleep()
boolean
getRunAtLogin()
int
getShutdownTypes()
static PlatformManagerImpl
getSingleton()
java.lang.String
getUserDataDirectory()
java.lang.String
getVersion()
java.io.File
getVMOptionFile()
boolean
hasCapability(PlatformManagerCapabilities capability)
Gets whether the platform manager supports a capabilityprivate boolean
informUpdateRequired()
private void
initializeCapabilities()
boolean
isAdditionalFileTypeRegistered(java.lang.String name, java.lang.String type)
Checks to see if the supplied file type is registered with this applicationboolean
isApplicationRegistered()
java.lang.Class<?>
loadClass(java.lang.ClassLoader loader, java.lang.String class_name)
Gives a particular platform the ability to alter the class-loading methodvoid
performRecoverableFileDelete(java.lang.String file_name)
void
ping(java.net.InetAddress interface_address, java.net.InetAddress target, PlatformManagerPingCallback callback)
void
registerAdditionalFileType(java.lang.String name, java.lang.String description, java.lang.String type, java.lang.String content_type)
Registers a file type with this applicationvoid
registerAdditionalFileType(java.lang.String name, java.lang.String description, java.lang.String type, java.lang.String content_type, boolean url_protocol)
void
registerApplication()
protected void
registerBC()
protected void
registerDHT()
protected void
registerMagnet(boolean force)
void
removeListener(PlatformManagerListener listener)
void
requestUserAttention(int type, java.lang.Object data)
Requests the user's attention such as bouncing the application icon on OSXvoid
setExplicitVMOptions(java.lang.String[] options)
void
setPreventComputerSleep(boolean prevent_it)
void
setRunAtLogin(boolean run)
void
setTCPTOSEnabled(boolean enabled)
enable or disable the platforms support for TCP TOSint
shellExecute(java.lang.String operation, java.lang.String file, java.lang.String parameters, java.lang.String directory, int SW_const)
void
showFile(java.lang.String file_name)
Reveals the file or directory with the platform's default browservoid
shutdown(int type)
void
startup(Core core)
boolean
testNativeAvailability(java.lang.String name)
void
traceRoute(java.net.InetAddress interface_address, java.net.InetAddress target, PlatformManagerPingCallback callback)
void
unregisterAdditionalFileType(java.lang.String name, java.lang.String type)
Removes a file-type registrationprivate void
writeStringToHKCRandHKCU(java.lang.String subkey, java.lang.String name, java.lang.String value)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.platform.PlatformManager
setUseSystemTheme
-
-
-
-
Field Detail
-
RT_NONE
public static final int RT_NONE
- See Also:
- Constant Field Values
-
RT_AZ
public static final int RT_AZ
- See Also:
- Constant Field Values
-
RT_OTHER
public static final int RT_OTHER
- See Also:
- Constant Field Values
-
DLL_NAME
public static java.lang.String DLL_NAME
-
BIGLYBY_ASSOC
public static final java.lang.String BIGLYBY_ASSOC
- See Also:
- Constant Field Values
-
OLD_MAIN_ASS0C
public static final java.lang.String OLD_MAIN_ASS0C
- See Also:
- Constant Field Values
-
initialising
private static boolean initialising
-
init_tried
private static boolean init_tried
-
singleton
private static PlatformManagerImpl singleton
-
class_mon
private static AEMonitor class_mon
-
capabilitySet
private final java.util.Set<PlatformManagerCapabilities> capabilitySet
-
listeners
private java.util.List listeners
-
access
private final AEWin32Access access
-
app_name
private final java.lang.String app_name
-
app_exe_name
private final java.lang.String app_exe_name
-
az_exe
private java.io.File az_exe
-
az_exe_checked
private boolean az_exe_checked
-
prevent_computer_sleep
private boolean prevent_computer_sleep
-
prevent_sleep_thread
private AEThread2 prevent_sleep_thread
-
-
Constructor Detail
-
PlatformManagerImpl
protected PlatformManagerImpl() throws PlatformManagerException
- Throws:
PlatformManagerException
-
-
Method Detail
-
getSingleton
public static PlatformManagerImpl getSingleton() throws PlatformManagerException
- Throws:
PlatformManagerException
-
initializeCapabilities
private void initializeCapabilities()
-
applyPatches
protected void applyPatches()
-
fixPermissions
protected void fixPermissions(java.io.File parent, java.io.File dir) throws PlatformManagerException
- Throws:
PlatformManagerException
-
getIconIndex
protected int getIconIndex() throws PlatformManagerException
- Throws:
PlatformManagerException
-
getVersion
public java.lang.String getVersion()
- Specified by:
getVersion
in interfacePlatformManager
-
getApplicationEXELocation
protected java.io.File getApplicationEXELocation() throws PlatformManagerException
- Throws:
PlatformManagerException
-
getPlatformType
public int getPlatformType()
- Specified by:
getPlatformType
in interfacePlatformManager
-
getUserDataDirectory
public java.lang.String getUserDataDirectory() throws PlatformManagerException
- Specified by:
getUserDataDirectory
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getComputerName
public java.lang.String getComputerName()
- Specified by:
getComputerName
in interfacePlatformManager
- Returns:
- null if can't be found
-
getLocation
public java.io.File getLocation(long location_id) throws PlatformManagerException
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
-
getJVMOptionRedirect
private java.lang.String getJVMOptionRedirect()
-
getJVMOptionFiles
private java.io.File[] getJVMOptionFiles()
-
checkAndGetLocalVMOptionFile
private java.io.File checkAndGetLocalVMOptionFile() throws PlatformManagerException
- Throws:
PlatformManagerException
-
getVMOptionFile
public java.io.File getVMOptionFile() throws PlatformManagerException
- Specified by:
getVMOptionFile
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getExplicitVMOptions
public java.lang.String[] getExplicitVMOptions() throws PlatformManagerException
- Specified by:
getExplicitVMOptions
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setExplicitVMOptions
public void setExplicitVMOptions(java.lang.String[] options) throws PlatformManagerException
- Specified by:
setExplicitVMOptions
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getRunAtLogin
public boolean getRunAtLogin() throws PlatformManagerException
- Specified by:
getRunAtLogin
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setRunAtLogin
public void setRunAtLogin(boolean run) throws PlatformManagerException
- Specified by:
setRunAtLogin
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getShutdownTypes
public int getShutdownTypes()
- Specified by:
getShutdownTypes
in interfacePlatformManager
-
getPreventComputerSleep
public boolean getPreventComputerSleep()
- Specified by:
getPreventComputerSleep
in interfacePlatformManager
-
setPreventComputerSleep
public void setPreventComputerSleep(boolean prevent_it)
- Specified by:
setPreventComputerSleep
in interfacePlatformManager
-
canHibernate
private boolean canHibernate()
-
startup
public void startup(Core core) throws PlatformManagerException
- Specified by:
startup
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getInstaller
private UpdateInstaller getInstaller(Core core) throws java.lang.Exception
- Throws:
java.lang.Exception
-
informUpdateRequired
private boolean informUpdateRequired()
-
shutdown
public void shutdown(int type) throws PlatformManagerException
- Specified by:
shutdown
in interfacePlatformManager
- Throws:
PlatformManagerException
-
getApplicationCommandLine
public java.lang.String getApplicationCommandLine()
- Specified by:
getApplicationCommandLine
in interfacePlatformManager
-
isApplicationRegistered
public boolean isApplicationRegistered() throws PlatformManagerException
- Specified by:
isApplicationRegistered
in interfacePlatformManager
- Throws:
PlatformManagerException
-
checkExeKey
protected void checkExeKey(java.io.File exe)
-
checkExeKey
protected void checkExeKey(int hkey, java.io.File exe)
-
isAdditionalFileTypeRegistered
public boolean isAdditionalFileTypeRegistered(java.lang.String name, java.lang.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
- Returns:
- Throws:
PlatformManagerException
-
getAdditionalFileTypeRegistrationDetails
public int getAdditionalFileTypeRegistrationDetails(java.lang.String name, java.lang.String type) throws PlatformManagerException
- Throws:
PlatformManagerException
-
registerApplication
public void registerApplication() throws PlatformManagerException
- Specified by:
registerApplication
in interfacePlatformManager
- Throws:
PlatformManagerException
-
registerMagnet
protected void registerMagnet(boolean force)
-
createKey
protected boolean createKey(int type, java.lang.String key)
-
registerDHT
protected void registerDHT()
-
registerBC
protected void registerBC()
-
registerAdditionalFileType
public void registerAdditionalFileType(java.lang.String name, java.lang.String description, java.lang.String type, java.lang.String content_type) throws PlatformManagerException
Description copied from interface:PlatformManager
Registers a file type with this application- Specified by:
registerAdditionalFileType
in interfacePlatformManager
- Throws:
PlatformManagerException
-
registerAdditionalFileType
public void registerAdditionalFileType(java.lang.String name, java.lang.String description, java.lang.String type, java.lang.String content_type, boolean url_protocol) throws PlatformManagerException
- Throws:
PlatformManagerException
-
writeStringToHKCRandHKCU
private void writeStringToHKCRandHKCU(java.lang.String subkey, java.lang.String name, java.lang.String value)
-
unregisterAdditionalFileType
public void unregisterAdditionalFileType(java.lang.String name, java.lang.String type) throws PlatformManagerException
Description copied from interface:PlatformManager
Removes a file-type registration- Specified by:
unregisterAdditionalFileType
in interfacePlatformManager
- Throws:
PlatformManagerException
-
createProcess
public void createProcess(java.lang.String command_line, boolean inherit_handles) throws PlatformManagerException
- Specified by:
createProcess
in interfacePlatformManager
- Throws:
PlatformManagerException
-
performRecoverableFileDelete
public void performRecoverableFileDelete(java.lang.String file_name) throws PlatformManagerException
- Specified by:
performRecoverableFileDelete
in interfacePlatformManager
- Throws:
PlatformManagerException
-
setTCPTOSEnabled
public void setTCPTOSEnabled(boolean enabled) throws PlatformManagerException
Description copied from interface:PlatformManager
enable or disable the platforms support for TCP TOS- Specified by:
setTCPTOSEnabled
in interfacePlatformManager
- Throws:
PlatformManagerException
-
copyFilePermissions
public void copyFilePermissions(java.lang.String from_file_name, java.lang.String to_file_name) throws PlatformManagerException
- Specified by:
copyFilePermissions
in interfacePlatformManager
- Throws:
PlatformManagerException
-
showFile
public void showFile(java.lang.String file_name) throws PlatformManagerException
Reveals the file or directory with the platform's default browser- Specified by:
showFile
in interfacePlatformManager
- Parameters:
file_name
- The full path to a file or directory- Throws:
PlatformManagerException
- If this operation fails
-
testNativeAvailability
public boolean testNativeAvailability(java.lang.String name) throws PlatformManagerException
- Specified by:
testNativeAvailability
in interfacePlatformManager
- Throws:
PlatformManagerException
-
traceRoute
public void traceRoute(java.net.InetAddress interface_address, java.net.InetAddress target, PlatformManagerPingCallback callback) throws PlatformManagerException
- Specified by:
traceRoute
in interfacePlatformManager
- Throws:
PlatformManagerException
-
ping
public void ping(java.net.InetAddress interface_address, java.net.InetAddress target, PlatformManagerPingCallback callback) throws PlatformManagerException
- Specified by:
ping
in interfacePlatformManager
- Throws:
PlatformManagerException
-
shellExecute
public int shellExecute(java.lang.String operation, java.lang.String file, java.lang.String parameters, java.lang.String directory, int SW_const) throws PlatformManagerException
- Throws:
PlatformManagerException
-
getMaxOpenFiles
public int getMaxOpenFiles() throws PlatformManagerException
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
-
hasCapability
public boolean hasCapability(PlatformManagerCapabilities capability)
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
-
checkCapability
private void checkCapability(PlatformManagerCapabilities capability) throws PlatformManagerException
- Throws:
PlatformManagerException
-
dispose
public void dispose()
Does nothing- Specified by:
dispose
in interfacePlatformManager
-
eventOccurred
public int eventOccurred(int type)
- Specified by:
eventOccurred
in interfaceAEWin32AccessListener
-
addListener
public void addListener(PlatformManagerListener listener)
- Specified by:
addListener
in interfacePlatformManager
-
removeListener
public void removeListener(PlatformManagerListener listener)
- Specified by:
removeListener
in interfacePlatformManager
-
requestUserAttention
public void requestUserAttention(int type, java.lang.Object data) throws PlatformManagerException
Description copied from interface:PlatformManager
Requests the user's attention such as bouncing the application icon on OSX- Specified by:
requestUserAttention
in interfacePlatformManager
- Throws:
PlatformManagerException
-
loadClass
public java.lang.Class<?> loadClass(java.lang.ClassLoader loader, java.lang.String class_name) throws PlatformManagerException
Description copied from interface:PlatformManager
Gives a particular platform the ability to alter the class-loading method- Specified by:
loadClass
in interfacePlatformManager
- Returns:
- Throws:
PlatformManagerException
-
generate
public void generate(IndentWriter writer)
- Specified by:
generate
in interfaceAEDiagnosticsEvidenceGenerator
-
-