FileDocCategorySizeDatePackage
ClientIDPlugin.javaAPI DocAzureus 3.0.3.43363Mon Jul 16 10:35:48 BST 2007com.aelitis.azureus.plugins.clientid

ClientIDPlugin

public class ClientIDPlugin extends Object implements Plugin
author
parg

Fields Summary
private PluginInterface
plugin_interface
private static boolean
send_os
Constructors Summary
Methods Summary
protected static voiddoHTTPProperties(PluginInterface plugin_interface, java.util.Properties properties)

		String	version = Constants.AZUREUS_VERSION;
		
			// trim of any _Bnn or _CVS suffix as unfortunately some trackers can't cope with this
			// (well, apparently can't cope with B10)
			// its not a big deal anyway
		
		int	pos = version.indexOf('_");
		
		if ( pos != -1 ){
			
			version = version.substring(0,pos);
		}
		
		String	agent = Constants.AZUREUS_NAME + " " + version;
				
		if ( send_os ){
							
			agent += ";" + Constants.OSName;
		
			agent += ";Java " + Constants.JAVA_VERSION;
		}
		
		properties.put( ClientIDGenerator.PR_USER_AGENT, agent );
	
public voidinitialize(PluginInterface _plugin_interface)

		plugin_interface	= _plugin_interface;
		
		plugin_interface.getPluginProperties().setProperty( "plugin.version", 	"1.0" );
		plugin_interface.getPluginProperties().setProperty( "plugin.name", 		"Client ID" );
	
public static voidload(PluginInterface plugin_interface)

		final String	param = "Tracker Client Send OS and Java Version";
		
		send_os = plugin_interface.getPluginconfig().getBooleanParameter( param );

		plugin_interface.getPluginconfig().addListener(
			new PluginConfigListener()
			{
				public void 
				configSaved() 
				{
					send_os = plugin_interface.getPluginconfig().getBooleanParameter( param );				
				}
			});
		
		plugin_interface.getClientIDManager().setGenerator( 
			new ClientIDGenerator()
			{
				public byte[]
				generatePeerID(
					Torrent		torrent,
					boolean		for_tracker )
				{
					return( PeerUtils.createPeerID());
				}
							
				public void
				generateHTTPProperties(
					Properties	properties )
				{
					doHTTPProperties( plugin_interface, properties );
				}
				
				public String[]
				filterHTTP(
					String[]	lines_in )
				{
					return( lines_in );
				}
			},
			false );