speedscheduler
Class SpeedSchedulerPlugin

java.lang.Object
  extended by speedscheduler.SpeedSchedulerPlugin
All Implemented Interfaces:
org.gudy.azureus2.plugins.Plugin

public class SpeedSchedulerPlugin
extends java.lang.Object
implements org.gudy.azureus2.plugins.Plugin

The main plugin class for this plugin. Azureus instantiates and initializes this class, so this class must do all the plugin bootstrapping, including loading the saved user schedules and starting the SpeedSchedulerThread. The file plugin.properties references this class.


Field Summary
private static java.lang.String AUTO_SPEED_ENABLED_CONFIG_VAR
           
private static java.lang.String AUTO_SPEED_MAX_UPLOAD_CONFIG_VAR
           
private static java.lang.String AUTO_SPEED_PLUGIN_NAME
           
private static java.lang.String AUTO_SPEED_WARNED_PARAM
           
private static java.lang.String ENABLED_PARAM
          The name of the parameter in the Azureus config that tells us if we are enabled or not.
private static java.lang.String MAX_DOWNLOAD_SPEED_PARAM
           
private static java.lang.String MAX_UPLOAD_SPEED_PARAM
           
private  org.gudy.azureus2.plugins.PluginConfig pluginConfig
          A reference to the Azureus PluginConfig implementation
private  org.gudy.azureus2.plugins.PluginInterface pluginInterface
          A reference to the Azureus PluginConfig implementation
private static SpeedSchedulerPlugin speedSchedulerPlugin
          A reference to this singleton
private  SpeedSchedulerThread speedSchedulerThread
          A reference to the thread that powers this whole shindig
 
Constructor Summary
SpeedSchedulerPlugin()
           
 
Method Summary
 int getAutoSpeedMaxUploadSpeed()
          Gets auto speed's maximum upload setting.
private  org.gudy.azureus2.plugins.PluginInterface getAutoSpeedPluginInterface()
          Fetches the AutoSpeed plugin interface.
 int getAzureusGlobalDownloadSpeed()
          Sets Azureus' maximum global download speed.
 int getAzureusGlobalUploadSpeed()
          Gets Azureus' maximum global upload speed.
 org.gudy.azureus2.plugins.PluginInterface getAzureusPluginInterface()
          Gets a reference to the Azureus plugin interface.
 int getConfigParameter(java.lang.String name, int defaultValue)
           
 java.lang.String getConfigParameter(java.lang.String name, java.lang.String defaultValue)
           
static SpeedSchedulerPlugin getInstance()
          Get the singleton instance of the SpeedSchedulerPlugin.
 java.lang.String getPluginDirectoryName()
          Gets the directory where we are installed.
 boolean hasUserBeenWarnedAboutAutoSpeed()
          Returns true if the user has already been warned about AutoSpeed/SpeedScheduler behavior.
 void initialize(org.gudy.azureus2.plugins.PluginInterface pluginInterface)
          This method is called when the plugin is loaded / initialized In our case, it'll simply store the pluginInterface reference and register our PluginView.
 boolean isAutoSpeedEnabled()
          Figures out if the Auto Speed plugin is installed and enabled.
 boolean isEnabled()
          If the user has checked the "Enable SpeedSCheduler" in the view, this will return true.
 boolean isSwtAvailable()
          Checks if SWT is available on the host system.
 void setAutoSpeedMaxUploadSpeed(int speed)
          Sets auto speed's maximum upload setting.
 void setAzureusGlobalDownloadSpeed(int newSpeed)
          Sets Azureus' maximum global download speed.
 void setAzureusGlobalUploadSpeed(int newSpeed)
          Sets Azureus' maximum global upload speed.
 void setEnabled(boolean enabled)
          Turns on/off the SpeedScheduler.
 void setUserHasBeenWarnedAboutAutoSpeed(boolean hasBeenWarned)
          Stores whether the user has already been warned about AutoSpeed/SpeedScheduler behavior.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pluginInterface

private org.gudy.azureus2.plugins.PluginInterface pluginInterface
A reference to the Azureus PluginConfig implementation


pluginConfig

private org.gudy.azureus2.plugins.PluginConfig pluginConfig
A reference to the Azureus PluginConfig implementation


speedSchedulerPlugin

private static SpeedSchedulerPlugin speedSchedulerPlugin
A reference to this singleton


ENABLED_PARAM

private static final java.lang.String ENABLED_PARAM
The name of the parameter in the Azureus config that tells us if we are enabled or not.

See Also:
Constant Field Values

speedSchedulerThread

private SpeedSchedulerThread speedSchedulerThread
A reference to the thread that powers this whole shindig


MAX_UPLOAD_SPEED_PARAM

private static final java.lang.String MAX_UPLOAD_SPEED_PARAM
See Also:
Constant Field Values

MAX_DOWNLOAD_SPEED_PARAM

private static final java.lang.String MAX_DOWNLOAD_SPEED_PARAM
See Also:
Constant Field Values

AUTO_SPEED_ENABLED_CONFIG_VAR

private static final java.lang.String AUTO_SPEED_ENABLED_CONFIG_VAR
See Also:
Constant Field Values

AUTO_SPEED_MAX_UPLOAD_CONFIG_VAR

private static final java.lang.String AUTO_SPEED_MAX_UPLOAD_CONFIG_VAR
See Also:
Constant Field Values

AUTO_SPEED_PLUGIN_NAME

private static final java.lang.String AUTO_SPEED_PLUGIN_NAME
See Also:
Constant Field Values

AUTO_SPEED_WARNED_PARAM

private static final java.lang.String AUTO_SPEED_WARNED_PARAM
See Also:
Constant Field Values
Constructor Detail

SpeedSchedulerPlugin

public SpeedSchedulerPlugin()
Method Detail

initialize

public void initialize(org.gudy.azureus2.plugins.PluginInterface pluginInterface)
This method is called when the plugin is loaded / initialized In our case, it'll simply store the pluginInterface reference and register our PluginView.

Specified by:
initialize in interface org.gudy.azureus2.plugins.Plugin

isSwtAvailable

public boolean isSwtAvailable()
Checks if SWT is available on the host system.

Returns:
True is SWT is available, false otherwise.

getAzureusPluginInterface

public org.gudy.azureus2.plugins.PluginInterface getAzureusPluginInterface()
Gets a reference to the Azureus plugin interface.

Returns:
the plugin interface

isEnabled

public boolean isEnabled()
If the user has checked the "Enable SpeedSCheduler" in the view, this will return true. Returns false if not. This setting is persistent in the Azureus PluginConfig.

Returns:
True if the SpeedScheduler is enabled, false otherwise.

setEnabled

public void setEnabled(boolean enabled)
Turns on/off the SpeedScheduler. The setting is persisted in the Azureus PluginConfig.

Parameters:
enabled - True to turn it on, false to turn it off.
See Also:
this.isEnabled

getInstance

public static SpeedSchedulerPlugin getInstance()
Get the singleton instance of the SpeedSchedulerPlugin.

Returns:
The singleton instance of the SpeedSchedulerPlugin object.

setAzureusGlobalUploadSpeed

public void setAzureusGlobalUploadSpeed(int newSpeed)
Sets Azureus' maximum global upload speed.

Parameters:
newSpeed - The new max upload speed.
See Also:
PluginInterface, PluginConfig

setAzureusGlobalDownloadSpeed

public void setAzureusGlobalDownloadSpeed(int newSpeed)
Sets Azureus' maximum global download speed.

Parameters:
newSpeed - The new max download speed.
See Also:
PluginInterface, PluginConfig

getAzureusGlobalDownloadSpeed

public int getAzureusGlobalDownloadSpeed()
Sets Azureus' maximum global download speed.

See Also:
PluginInterface, PluginConfig

getAzureusGlobalUploadSpeed

public int getAzureusGlobalUploadSpeed()
Gets Azureus' maximum global upload speed.

See Also:
PluginInterface, PluginConfig

getConfigParameter

public int getConfigParameter(java.lang.String name,
                              int defaultValue)
Parameters:
name - The config entry name whose value to fetch.
defaultValue - The value to return if the property does not exist.
Returns:
The value of the key.

getConfigParameter

public java.lang.String getConfigParameter(java.lang.String name,
                                           java.lang.String defaultValue)

getPluginDirectoryName

public java.lang.String getPluginDirectoryName()
Gets the directory where we are installed.

Returns:
The name of the directory.

isAutoSpeedEnabled

public boolean isAutoSpeedEnabled()
Figures out if the Auto Speed plugin is installed and enabled.

Returns:
true if it is both installed *and* enabled.

getAutoSpeedPluginInterface

private org.gudy.azureus2.plugins.PluginInterface getAutoSpeedPluginInterface()
Fetches the AutoSpeed plugin interface.

Returns:
A reference to the auto speed plugin interface object.

setAutoSpeedMaxUploadSpeed

public void setAutoSpeedMaxUploadSpeed(int speed)
Sets auto speed's maximum upload setting.

Parameters:
speed - The speed in Kb/sec.

getAutoSpeedMaxUploadSpeed

public int getAutoSpeedMaxUploadSpeed()
Gets auto speed's maximum upload setting.

Returns:
The speed in Kb/sec.

hasUserBeenWarnedAboutAutoSpeed

public boolean hasUserBeenWarnedAboutAutoSpeed()
Returns true if the user has already been warned about AutoSpeed/SpeedScheduler behavior.


setUserHasBeenWarnedAboutAutoSpeed

public void setUserHasBeenWarnedAboutAutoSpeed(boolean hasBeenWarned)
Stores whether the user has already been warned about AutoSpeed/SpeedScheduler behavior. This is persistent between application shutdown/startup.