FileDocCategorySizeDatePackage
AEWin32AccessImpl.javaAPI DocAzureus 3.0.3.410971Mon Jul 30 20:38:58 BST 2007org.gudy.azureus2.platform.win32.access.impl

AEWin32AccessImpl

public class AEWin32AccessImpl extends Object implements AEWin32AccessCallback, AEWin32Access
author
parg

Fields Summary
protected static AEWin32AccessImpl
singleton
private boolean
fully_initialise
private int
trace_id_next
private List
listeners
Constructors Summary
protected AEWin32AccessImpl(boolean _fully_initialise)

	
	
	
				 
	
		fully_initialise	= _fully_initialise;
		
		if ( isEnabled()){
			
			AEWin32AccessInterface.load( this, fully_initialise );
		}
	
Methods Summary
public voidaddListener(AEWin32AccessListener listener)

    	listeners.add( listener );
    
private intaddressToInt(java.net.InetAddress address)

		byte[]	bytes = address.getAddress();
		
		int	resp = (bytes[0]<<24)&0xff000000 | (bytes[1] << 16)&0x00ff0000 | (bytes[2] << 8)&0x0000ff00 | bytes[3]&0x000000ff;
			
		return( resp );
	
public voidcopyFilePermissions(java.lang.String from_file_name, java.lang.String to_file_name)

		AEWin32AccessInterface.copyPermission( from_file_name, to_file_name ); 
	
public voidcreateProcess(java.lang.String command_line, boolean inherit_handles)

		AEWin32AccessInterface.createProcess( command_line, inherit_handles );
	
public voiddeleteKey(int type, java.lang.String subkey)

		deleteKey( type, subkey, false );
	
public voiddeleteKey(int type, java.lang.String subkey, boolean recursive)

		AEWin32AccessInterface.deleteKey( type, subkey, recursive );
	
public voiddeleteValue(int type, java.lang.String subkey, java.lang.String value_name)

		AEWin32AccessInterface.deleteValue( type, subkey, value_name );	
	
public longgeneralMessage(java.lang.String str)

	
		return( 0 );
	
public java.lang.StringgetApplicationInstallDir(java.lang.String app_name)

		String	res = "";
		
		try{
			res = readStringValue(
					HKEY_CURRENT_USER,
					"software\\" + app_name,
					null );
			
		}catch( AEWin32AccessException e ){
			
			res = readStringValue(
					HKEY_LOCAL_MACHINE,
					"software\\" + app_name,
					null );
						
		}
		
		return( res );
	
public java.lang.StringgetCommonAppData()

		String	app_data_key	= "software\\microsoft\\windows\\currentversion\\explorer\\shell folders";
		String	app_data_name 	= "Common AppData";
		
		return(	readStringValue(
					HKEY_LOCAL_MACHINE,
					app_data_key,
					app_data_name ));

	
public java.lang.StringgetProgramFilesDir()

		String	app_data_key	= "software\\microsoft\\windows\\currentversion";
		String	app_data_name 	= "ProgramFilesDir";
		
		return(	readStringValue(
					HKEY_LOCAL_MACHINE,
					app_data_key,
					app_data_name ));
	
public static synchronized AEWin32AccessgetSingleton(boolean fully_initialise)

		if ( singleton == null ){
			
			singleton = new AEWin32AccessImpl(fully_initialise);
		}
		
		return( singleton );		
	
public java.lang.StringgetUserAppData()

		String	app_data_key	= "software\\microsoft\\windows\\currentversion\\explorer\\shell folders";
		String	app_data_name 	= "appdata";
		
		return(	readStringValue(
					HKEY_CURRENT_USER,
					app_data_key,
					app_data_name ));

	
public java.lang.StringgetUserDocumentsDir()

		String	app_data_key	= "software\\microsoft\\windows\\currentversion\\explorer\\shell folders";
		String	app_data_name 	= "personal";
		
		return(	readStringValue(
					HKEY_CURRENT_USER,
					app_data_key,
					app_data_name ));

	
public java.lang.StringgetUserMusicDir()

		String	app_data_key	= "software\\microsoft\\windows\\currentversion\\explorer\\shell folders";
		String	app_data_name 	= "my music";
		
		try {
  		return(	readStringValue(
  					HKEY_CURRENT_USER,
  					app_data_key,
  					app_data_name ));
		} catch (AEWin32AccessException e) {
			// Win98 doesn't have it
  		String s = getUserDocumentsDir();
  		if (s != null) {
  			s += "\\My Music";
  		}
  		return s;
		}

	
public java.lang.StringgetUserVideoDir()

		String	app_data_key	= "software\\microsoft\\windows\\currentversion\\explorer\\shell folders";
		String	app_data_name 	= "my video";
		
		try {
  		return(	readStringValue(
  					HKEY_CURRENT_USER,
  					app_data_key,
  					app_data_name ));
		} catch (AEWin32AccessException e) {
			// Win98 doesn't have it
  		String s = getUserDocumentsDir();
  		if (s != null) {
  			s += "\\My Video";
  		}
  		return s;
		}

	
public java.lang.StringgetVersion()

		return( AEWin32AccessInterface.getVersion());		
	
private java.net.InetAddressintToAddress(int address)

		byte[]	bytes = { (byte)(address>>24), (byte)(address>>16),(byte)(address>>8),(byte)address };
		
		try{
			InetAddress	res = InetAddress.getByAddress(bytes);
						
			return( res );
			
		}catch( UnknownHostException e ){
				
			return( null );
		}
	
public booleanisEnabled()

		return( AEWin32AccessInterface.isEnabled( fully_initialise ));
	
public voidmoveToRecycleBin(java.lang.String file_name)

		AEWin32AccessInterface.moveToRecycleBin( file_name );
	
public voidping(java.net.InetAddress source_address, java.net.InetAddress target_address, org.gudy.azureus2.platform.PlatformManagerPingCallback callback)

		traceRoute( source_address, target_address, true, callback );
	
public java.lang.StringreadStringValue(int type, java.lang.String subkey, java.lang.String value_name)

		return( AEWin32AccessInterface.readStringValue( type, subkey, value_name ));
	
public intreadWordValue(int type, java.lang.String subkey, java.lang.String value_name)

		return( AEWin32AccessInterface.readWordValue( type, subkey, value_name ));
	
public voidremoveListener(AEWin32AccessListener listener)

    	listeners.remove( listener );
    
public intshellExecute(java.lang.String operation, java.lang.String file, java.lang.String parameters, java.lang.String directory, int SW_const)

		return AEWin32AccessInterface.shellExecute(operation, file, parameters, 
				directory, SW_const);
	
public booleantestNativeAvailability(java.lang.String name)

		return( AEWin32AccessInterface.testNativeAvailability( name ));
	
public voidtraceRoute(java.net.InetAddress source_address, java.net.InetAddress target_address, org.gudy.azureus2.platform.PlatformManagerPingCallback callback)

		traceRoute( source_address, target_address, false, callback );
	
protected voidtraceRoute(java.net.InetAddress source_address, java.net.InetAddress target_address, boolean ping_mode, org.gudy.azureus2.platform.PlatformManagerPingCallback callback)

		int	trace_id;
		
		synchronized( this ){
			
			trace_id = trace_id_next++;
		}
		
		AEWin32AccessCallback	cb = new traceRouteCallback( ping_mode, callback );
	
		AEWin32AccessInterface.traceRoute(
				trace_id,
				addressToInt( source_address ),
				addressToInt( target_address ),
				ping_mode?1:0,
				cb );
	
public longwindowsMessage(int msg, int param1, long param2)

		int	type	= -1;
		
		if ( msg == AEWin32AccessInterface.WM_ENDSESSION ){
		
			type = AEWin32AccessListener.ET_SHUTDOWN;
			
		}else if ( msg == AEWin32AccessInterface.WM_POWERBROADCAST ){

			if ( param1 == AEWin32AccessInterface.PBT_APMQUERYSUSPEND ){

				type = AEWin32AccessListener.ET_SUSPEND;
			
			}else if ( param1 == AEWin32AccessInterface.PBT_APMRESUMESUSPEND ){
				
				type = AEWin32AccessListener.ET_RESUME;
			}
		}
		
		if ( type != -1 ){
					
			for (int i=0;i<listeners.size();i++){
				
				try{
					((AEWin32AccessListener)listeners.get(i)).eventOccurred( type );
					
				}catch( Throwable e ){
					
					e.printStackTrace();
				}
			}
		}
		
		return( -1 );
	
public voidwriteStringValue(int type, java.lang.String subkey, java.lang.String value_name, java.lang.String value_value)

		AEWin32AccessInterface.writeStringValue( type, subkey, value_name, value_value );
	
public voidwriteWordValue(int type, java.lang.String subkey, java.lang.String value_name, int value_value)

		AEWin32AccessInterface.writeWordValue( type, subkey, value_name, value_value );