diff --git a/vendor/JXInput/0.3.4/c/JXInputManager.cpp b/vendor/JXInput/0.3.4/c/JXInputManager.cpp new file mode 100644 index 0000000..3718a7f --- /dev/null +++ b/vendor/JXInput/0.3.4/c/JXInputManager.cpp @@ -0,0 +1,175 @@ + +#include "stdafx.h" +#include "JXInputManager.h" +#include "JXInput.h" + +// +// Globals +// +extern HINSTANCE g_hInst; + + +JXInputManager::JXInputManager( HWND hWnd ) : +mhWnd( hWnd ), +mDeviceCounter( 0 ) +{ + + for ( int i = 0; i < MAX_JXINPUTS; ++i ) + { + mDevices[ i ] = NULL; + } + + + if ( FAILED( InitDirectInput( hWnd ) ) ) + { + FreeDirectInput(); + } + +} + +JXInputManager::~JXInputManager() +{ + for ( int i = 0; i < getNumberOfJXInputs(); ++i ) + { + delete mDevices[ i ]; + mDevices[ i ] = NULL; + } + + FreeDirectInput(); +} + +int JXInputManager::getNumberOfJXInputs() const +{ + return mDeviceCounter; +} + +JXInput& JXInputManager::getJXInput( int idx ) const +{ + assert( idx < mDeviceCounter ); + return * mDevices[ idx ]; +} + + +int JXInputManager::getMaxNumberOfAxes() const +{ + return JXINPUT_MAX_AXES; +} + +int JXInputManager::getMaxNumberOfButtons() const +{ + return JXINPUT_MAX_BUTTONS; +} + +int JXInputManager::getMaxNumberOfDirectionals() const +{ + return JXINPUT_MAX_DIRECTIONALS; +} + + + +//----------------------------------------------------------------------------- +// Name: InitDirectInput() +// Desc: Initialize the DirectInput variables. +//----------------------------------------------------------------------------- +HRESULT JXInputManager::InitDirectInput( HWND hWnd ) +{ + HRESULT hr; + + // Register with the DirectInput subsystem and get a pointer + // to a IDirectInput interface we can use. + // Create a DInput object + if( FAILED( hr = DirectInput8Create( g_hInst, DIRECTINPUT_VERSION, + IID_IDirectInput8, (VOID**)&mpDI, NULL ) ) ) + return hr; + + // Look for a simple joystick we can use for this sample program. + if( FAILED( hr = mpDI->EnumDevices( DI8DEVCLASS_GAMECTRL, + EnumJoysticksCallback, + (VOID*)this, DIEDFL_ALLDEVICES /*| DIEDFL_INCLUDEPHANTOMS*/ ) ) ) + return hr; + + // Look for a other devices + if( FAILED( hr = mpDI->EnumDevices( DI8DEVCLASS_DEVICE, + EnumJoysticksCallback, + (VOID*)this, DIEDFL_ALLDEVICES /*| DIEDFL_INCLUDEPHANTOMS*/ ) ) ) + return hr; + + return S_OK; +} + + +//----------------------------------------------------------------------------- +// Name: FreeDirectInput() +// Desc: Initialize the DirectInput variables. +//----------------------------------------------------------------------------- +HRESULT JXInputManager::FreeDirectInput() +{ + + if ( NULL != mpDI ) + mpDI->Release(); + mpDI = NULL; + return S_OK; +} + + +//----------------------------------------------------------------------------- +// Name: EnumJoysticksCallback() +// Desc: Called once for each enumerated joystick. If we find one, create a +// device interface on it so we can play with it. +//----------------------------------------------------------------------------- +BOOL CALLBACK JXInputManager::EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, + VOID* pContext ) +{ + HRESULT hr; + LPDIRECTINPUTDEVICE8 pJoystick; + + JXInputManager* pThis = (JXInputManager*)pContext; + + // + // if the maximum number of devices is already registered, + // issue a warning and stop enumeration. + // + if( MAX_JXINPUTS == pThis->mDeviceCounter ) + { + OutputDebugString( "Max. number of devices exceeded!" ); + return DIENUM_STOP; + } + + + + // Obtain an interface to the enumerated joystick. + hr = pThis->mpDI->CreateDevice( pdidInstance->guidInstance, &pJoystick, NULL ); + + // If it failed, then we can't use this joystick. (Maybe the user unplugged + // it while we were in the middle of enumerating it.) + if( FAILED(hr) ) + return DIENUM_CONTINUE; + + JXInput* pJ = new JXInput( pJoystick, pThis->mhWnd ); + + // + // only register useful devices + // + if( pJ->getNumberOfAxes() + pJ->getNumberOfButtons() + pJ->getNumberOfDirectionals() > 0 ) + { + pThis->addJXInput( pJ ); + } + else + { + delete pJ; + } + + return DIENUM_CONTINUE; +} + + +/** + * Register a JXInput device. + */ +void JXInputManager::addJXInput( JXInput* pJ ) +{ + assert( mDeviceCounter < MAX_JXINPUTS ); + + if( mDeviceCounter < MAX_JXINPUTS ) + mDevices[ mDeviceCounter++ ] = pJ; +} diff --git a/vendor/JXInput/0.3.4/c/JXInputManager.h b/vendor/JXInput/0.3.4/c/JXInputManager.h new file mode 100644 index 0000000..41b9da4 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/JXInputManager.h @@ -0,0 +1,47 @@ +// JXInputManager.h: Schnittstelle für die Klasse JXInputManager. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_JXINPUTMANAGER_H__24862402_14C9_407D_8532_A16A6E3A7D64__INCLUDED_) +#define AFX_JXINPUTMANAGER_H__24862402_14C9_407D_8532_A16A6E3A7D64__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +#define MAX_JXINPUTS 10 + +class JXInput; + +class JXINPUT_API JXInputManager +{ +public: + JXInputManager( HWND hWnd ); + virtual ~JXInputManager(); + + int getNumberOfJXInputs() const; + JXInput& getJXInput( int idx ) const; + + // + // Numbering methods + // + int getMaxNumberOfAxes() const; + int getMaxNumberOfButtons() const; + int getMaxNumberOfDirectionals() const; + +private: + LPDIRECTINPUT8 mpDI; + HWND mhWnd; + JXInput* mDevices[ MAX_JXINPUTS ]; + int mDeviceCounter; + + HRESULT InitDirectInput( HWND hWnd = NULL ); + HRESULT FreeDirectInput(); + + static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, + VOID* pContext ); + void addJXInput( JXInput* pJ ); +}; + +#endif // !defined(AFX_JXINPUTMANAGER_H__24862402_14C9_407D_8532_A16A6E3A7D64__INCLUDED_) diff --git a/vendor/JXInput/0.3.4/c/ReadMe.txt b/vendor/JXInput/0.3.4/c/ReadMe.txt new file mode 100644 index 0000000..755cd4c --- /dev/null +++ b/vendor/JXInput/0.3.4/c/ReadMe.txt @@ -0,0 +1,37 @@ +======================================================================== + DYNAMIC LINK LIBRARY : jxinput +======================================================================== + + +Diese jxinput-DLL hat der Anwendungs-Assistent für Sie erstellt. + +Diese Datei enthält eine Zusammenfassung dessen, was Sie in jeder der Dateien +finden, die Ihre jxinput-Anwendung bilden. + +jxinput.dsp + Diese Datei (Projektdatei) enthält Informationen auf Projektebene und wird zur + Erstellung eines einzelnen Projekts oder Teilprojekts verwendet. Andere Benutzer können + die Projektdatei (.dsp) gemeinsam nutzen, sollten aber die Makefiles lokal exportieren. + +jxinput.cpp + Dies ist die Hauptquellcodedatei für die DLL. + +jxinput.h + Diese Datei enthält Ihre DLL-Exporte. + +///////////////////////////////////////////////////////////////////////////// +Weitere Standarddateien: + +StdAfx.h, StdAfx.cpp + Diese Dateien werden zum Erstellen einer vorkompilierten Header-Datei (PCH) namens + jxinput.pch und einer vorkompilierten Typdatei namens StdAfx.obj verwendet. + + +///////////////////////////////////////////////////////////////////////////// +Weitere Hinweise: + +Der Anwendungs-Assistent verwendet "ZU ERLEDIGEN:", um Bereiche des Quellcodes zu +kennzeichnen, die Sie hinzufügen oder anpassen sollten. + + +///////////////////////////////////////////////////////////////////////////// diff --git a/vendor/JXInput/0.3.4/c/StdAfx.cpp b/vendor/JXInput/0.3.4/c/StdAfx.cpp new file mode 100644 index 0000000..a144a09 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/StdAfx.cpp @@ -0,0 +1,9 @@ +// stdafx.cpp : Quelltextdatei, die nur die Standard-Includes einbindet +// jxinput.pch ist die vorkompilierte Header-Datei +// stdafx.obj enthält die vorkompilierte Typinformation + +#include "stdafx.h" + +// ZU ERLEDIGEN: Verweis auf alle zusätzlichen Header-Dateien, die Sie in STDAFX.H +// und nicht in dieser Datei benötigen + diff --git a/vendor/JXInput/0.3.4/c/StdAfx.h b/vendor/JXInput/0.3.4/c/StdAfx.h new file mode 100644 index 0000000..e139c4c --- /dev/null +++ b/vendor/JXInput/0.3.4/c/StdAfx.h @@ -0,0 +1,32 @@ +// stdafx.h : Include-Datei für Standard-System-Include-Dateien, +// oder projektspezifische Include-Dateien, die häufig benutzt, aber +// in unregelmäßigen Abständen geändert werden. +// + +#if !defined(AFX_STDAFX_H__68E14C76_098F_47ED_932B_4C01E8E9EFFB__INCLUDED_) +#define AFX_STDAFX_H__68E14C76_098F_47ED_932B_4C01E8E9EFFB__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Fügen Sie hier Ihre Header-Dateien ein +#define WIN32_LEAN_AND_MEAN // Selten benutzte Teile der Windows-Header nicht einbinden +#define STRICT +#include + +// ZU ERLEDIGEN: Verweisen Sie hier auf zusätzliche Header-Dateien, die Ihr Programm benötigt +#ifdef JXINPUT_EXPORTS +#define JXINPUT_API __declspec(dllexport) +#else +#define JXINPUT_API __declspec(dllimport) +#endif + +#include +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ fügt zusätzliche Deklarationen unmittelbar vor der vorherigen Zeile ein. + +#endif // !defined(AFX_STDAFX_H__68E14C76_098F_47ED_932B_4C01E8E9EFFB__INCLUDED_) diff --git a/vendor/JXInput/0.3.4/c/de_hardcode_jxinput_directinput_DirectInputDriver.cpp b/vendor/JXInput/0.3.4/c/de_hardcode_jxinput_directinput_DirectInputDriver.cpp new file mode 100644 index 0000000..077afe8 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/de_hardcode_jxinput_directinput_DirectInputDriver.cpp @@ -0,0 +1,279 @@ +#include "stdafx.h" + +#include "de_hardcode_jxinput_directinput_DirectInputDriver.h" +#include "jxinput.h" +#include "JXInputManager.h" + + +// +// Globals +// +extern HINSTANCE g_hInst; + +static JXInputManager* pJXInputManager = NULL; +static JXInput* apJXInput[ MAX_JXINPUTS ]; +static HWND hWndJava; + +// +// IDs of the static Java arrays. +// +static jfieldID sAxesFieldID; +static jfieldID sButtonsFieldID; +static jfieldID sDirectionsFieldID; + + + +/** + * Remove all resources allocated by the Java binding. + */ +void shutdownJavaResources() +{ + if ( NULL != pJXInputManager ) + delete pJXInputManager; + + if ( NULL != hWndJava ) + DestroyWindow( hWndJava ); + + pJXInputManager = NULL; + + for( int i = 0; i < MAX_JXINPUTS; ++i ) + apJXInput[ i ] = NULL; + + hWndJava = NULL; +} + + + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) +{ + return JNI_VERSION_1_2; +} + + +JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) +{ + shutdownJavaResources(); +} + + +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeinit + (JNIEnv * penv, jclass pClazz ) +{ + + // + // Create a non-visible window as 'owner' of the DI device. + // + hWndJava = CreateWindowEx( + 0/*WS_EX_APPWINDOW*/, // DWORD dwExStyle, // extended window style + "STATIC", // LPCTSTR lpClassName, // pointer to registered class name + NULL, // LPCTSTR lpWindowName, // pointer to window name + 0/*WS_CAPTION*/, // DWORD dwStyle, // window style + 0, // int x, // horizontal position of window + 0, // int y, // vertical position of window + 0, // int nWidth, // window width + 0, // int nHeight, // window height + NULL, // HWND hWndParent, // handle to parent or owner window + NULL, // HMENU hMenu, // handle to menu, or child-window identifier + g_hInst, // HINSTANCE hInstance, // handle to application instance + NULL // LPVOID lpParam // pointer to window-creation data + ); + + + if ( NULL == pJXInputManager ) + { + pJXInputManager = new JXInputManager( hWndJava ); + + for( int i = 0; i < MAX_JXINPUTS; ++i ) + apJXInput[ i ] = NULL; + + for ( int i = 0; i < pJXInputManager->getNumberOfJXInputs(); ++i ) + { + apJXInput[ i ] = & pJXInputManager->getJXInput( i ); + } + } + + return true; +} + + + +JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeexit + (JNIEnv *, jclass ) +{ + shutdownJavaResources(); +} + + +/** + * Bind my field IDs to the Java variables. + */ +JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_bind + (JNIEnv * penv, jclass pClazz) +{ + // + // All fields are static. + // + sAxesFieldID = penv->GetStaticFieldID( pClazz, "sAxisValues", "[[D" ); + sButtonsFieldID = penv->GetStaticFieldID( pClazz, "sButtonStates", "[[Z" ); + sDirectionsFieldID = penv->GetStaticFieldID( pClazz, "sDirectionalValues", "[[I" ); +} + + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDevices + (JNIEnv *penv, jclass) +{ + return pJXInputManager->getNumberOfJXInputs(); +} + + +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getName + (JNIEnv *penv, jclass, jint dev) +{ + return penv->NewStringUTF( apJXInput[ dev ]->getName() ); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfAxes + (JNIEnv *, jclass, jint dev) +{ + return apJXInput[ dev ]->getNumberOfAxes(); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfButtons + (JNIEnv *, jclass, jint dev) +{ + return apJXInput[ dev ]->getNumberOfButtons(); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDirectionals + (JNIEnv *, jclass, jint dev) +{ + return apJXInput[ dev ]->getNumberOfDirectionals(); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfAxes + (JNIEnv *, jclass) +{ + return pJXInputManager->getMaxNumberOfAxes(); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfButtons + (JNIEnv *, jclass) +{ + return pJXInputManager->getMaxNumberOfButtons(); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfDirectionals + (JNIEnv *, jclass) +{ + return pJXInputManager->getMaxNumberOfDirectionals(); +} + +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isAxisAvailable + (JNIEnv *, jclass, jint dev, jint idx ) +{ + return apJXInput[ dev ]->isAxisAvailable( idx ); +} + +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisName + (JNIEnv *penv, jclass, jint dev, jint idx ) +{ + return penv->NewStringUTF( apJXInput[ dev ]->getAxisName( idx ) ); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisType + (JNIEnv *, jclass, jint dev, jint idx ) +{ + return apJXInput[ dev ]->getAxisType( idx ); +} + + +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isButtonAvailable + (JNIEnv *, jclass, jint dev, jint idx ) +{ + return apJXInput[ dev ]->isButtonAvailable( idx ); +} + +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonName + (JNIEnv *penv, jclass, jint dev, jint idx ) +{ + return penv->NewStringUTF( apJXInput[ dev ]->getButtonName( idx ) ); +} + +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonType + (JNIEnv *, jclass, jint dev, jint idx ) +{ + return apJXInput[ dev ]->getButtonType( idx ); +} + +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isDirectionalAvailable + (JNIEnv *, jclass, jint dev, jint idx ) +{ + return apJXInput[ dev ]->isDirectionalAvailable( idx ); +} + +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getDirectionalName + (JNIEnv *penv, jclass, jint dev, jint idx ) +{ + return penv->NewStringUTF( apJXInput[ dev ]->getDirectionalName( idx ) ); +} + + + +/** + * The main update method. + * Here, the actual work is done. + */ +JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeupdate + (JNIEnv * penv, jclass pClazz ) +{ + + static jdouble axes [ MAX_JXINPUTS ][ JXINPUT_MAX_AXES ]; + static jboolean buttons [ MAX_JXINPUTS ][ JXINPUT_MAX_BUTTONS ]; + static jint directions [ MAX_JXINPUTS ][ JXINPUT_MAX_DIRECTIONALS ]; + + static jobjectArray axisarrayarray; + static jobjectArray buttonarrayarray; + static jobjectArray directionarrayarray; + + static jdoubleArray axisarray; + static jbooleanArray buttonarray; + static jintArray directionarray; + + axisarrayarray = (jobjectArray)penv->GetStaticObjectField( pClazz, sAxesFieldID ); + buttonarrayarray = (jobjectArray)penv->GetStaticObjectField( pClazz, sButtonsFieldID ); + directionarrayarray = (jobjectArray)penv->GetStaticObjectField( pClazz, sDirectionsFieldID ); + + // + // For each device.... + // + for ( int dev = 0; dev < pJXInputManager->getNumberOfJXInputs(); ++dev ) + { + // Do the update of the device. + apJXInput[ dev ]->update(); + + // + // Copy all values into my arrays. + // + for ( int i = 0; i < JXINPUT_MAX_AXES; ++i ) + axes[ dev ][ i ] = apJXInput[ dev ]->getAxisValue( i ); + for ( int i = 0; i < JXINPUT_MAX_BUTTONS; ++i ) + buttons[ dev ][ i ] = apJXInput[ dev ]->isButtonDown( i ); + for ( int i = 0; i < JXINPUT_MAX_DIRECTIONALS; ++i ) + directions[ dev ][ i ] = apJXInput[ dev ]->getDirection( i ); + + + // + // Move my arrays to the Java arrays. + // + axisarray = (jdoubleArray)penv->GetObjectArrayElement( axisarrayarray, dev ); + penv->SetDoubleArrayRegion( axisarray, 0, JXINPUT_MAX_AXES, axes[ dev ] ); + + buttonarray = (jbooleanArray)penv->GetObjectArrayElement( buttonarrayarray, dev ); + penv->SetBooleanArrayRegion( buttonarray, 0, JXINPUT_MAX_BUTTONS, buttons[ dev ] ); + + directionarray = (jintArray)penv->GetObjectArrayElement( directionarrayarray, dev ); + penv->SetIntArrayRegion( directionarray, 0, JXINPUT_MAX_DIRECTIONALS, directions[ dev ] ); + } + +} + diff --git a/vendor/JXInput/0.3.4/c/de_hardcode_jxinput_directinput_DirectInputDriver.h b/vendor/JXInput/0.3.4/c/de_hardcode_jxinput_directinput_DirectInputDriver.h new file mode 100644 index 0000000..bb93548 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/de_hardcode_jxinput_directinput_DirectInputDriver.h @@ -0,0 +1,183 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include + +/* Header for class de_hardcode_jxinput_directinput_DirectInputDriver */ + +#ifndef _Included_de_hardcode_jxinput_directinput_DirectInputDriver +#define _Included_de_hardcode_jxinput_directinput_DirectInputDriver + +#ifdef __cplusplus +extern "C" { +#endif + +/* Inaccessible static: sIsOperational */ +/* Inaccessible static: sAxisValues */ +/* Inaccessible static: sButtonStates */ +/* Inaccessible static: sDirectionalValues */ +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: nativeinit + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeinit + (JNIEnv *, jclass); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: nativeexit + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeexit + (JNIEnv *, jclass); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: bind + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_bind + (JNIEnv *, jclass); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getNumberOfDevices + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDevices + (JNIEnv *, jclass); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getName + * Signature: (I)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getName + (JNIEnv *, jclass, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getNumberOfAxes + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfAxes + + (JNIEnv *, jclass, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getNumberOfButtons + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfButtons + (JNIEnv *, jclass, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getNumberOfDirectionals + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getNumberOfDirectionals + (JNIEnv *, jclass, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getMaxNumberOfAxes + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfAxes + (JNIEnv *, jclass); + + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getMaxNumberOfButtons + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfButtons + (JNIEnv *, jclass); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getMaxNumberOfDirectionals + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getMaxNumberOfDirectionals + (JNIEnv *, jclass); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: isAxisAvailable + * Signature: (II)Z + */ +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isAxisAvailable + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getAxisName + * Signature: (II)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisName + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getAxisType + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getAxisType + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: isButtonAvailable + * Signature: (II)Z + */ +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isButtonAvailable + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getButtonName + * Signature: (II)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonName + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getButtonType + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getButtonType + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: isDirectionalAvailable + * Signature: (II)Z + */ +JNIEXPORT jboolean JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_isDirectionalAvailable + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: getDirectionalName + * Signature: (II)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_getDirectionalName + (JNIEnv *, jclass, jint, jint); + +/* + * Class: de_hardcode_jxinput_directinput_DirectInputDriver + * Method: nativeupdate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_de_hardcode_jxinput_directinput_DirectInputDriver_nativeupdate + (JNIEnv *, jclass); + +#ifdef __cplusplus +} +#endif +#endif + diff --git a/vendor/JXInput/0.3.4/c/dllmain.cpp b/vendor/JXInput/0.3.4/c/dllmain.cpp new file mode 100644 index 0000000..567e8d4 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/dllmain.cpp @@ -0,0 +1,24 @@ +#include "stdafx.h" + +HINSTANCE g_hInst; + + +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + g_hInst = (HINSTANCE)hModule; + break; + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + g_hInst = NULL; + break; + } + return TRUE; +} diff --git a/vendor/JXInput/0.3.4/c/jxinput.cpp b/vendor/JXInput/0.3.4/c/jxinput.cpp new file mode 100644 index 0000000..890805b --- /dev/null +++ b/vendor/JXInput/0.3.4/c/jxinput.cpp @@ -0,0 +1,600 @@ +// +// jxinput.cpp +// +#include "stdafx.h" +#include "jxinput.h" + + +// +// Globals +// +extern HINSTANCE g_hInst; + + +/** + * Ctor: Connect with DI + */ +JXInput::JXInput( LPDIRECTINPUTDEVICE8 pJoystick, HWND hWnd ) : + mpJoystick( pJoystick ), + mSliderCount( 0 ), + mPOVCount( 0 ), + mButtonCount( 0 ) +{ + initAxisConfig(); + initButtonsConfig(); + initDirectionalsConfig(); + + if ( FAILED( InitDirectInput( hWnd ) ) ) + { + FreeDirectInput(); + } +} + + + +/** + * Destructor: + * Free DirectInput. + */ +JXInput::~JXInput() +{ + FreeDirectInput(); +} + + +void JXInput::update() +{ + UpdateInputState(); +} + + +TCHAR * const JXInput::getName() const +{ + return (TCHAR*)mdiDevInfo.tszInstanceName; +} + + + +int JXInput::getNumberOfAxes() const +{ + return mdiDevCaps.dwAxes; +} + +int JXInput::getNumberOfButtons() const +{ + return mButtonCount; +} + +int JXInput::getNumberOfDirectionals() const +{ + return mPOVCount; +} + + +double JXInput::getAxisValueHelper( LONG val, int idx ) const +{ + const AxisConfig& cfg = mAxisConfig[ idx ]; + + double span = (double)( cfg.mMaxValue - cfg.mMinValue ); + double ret = (double)(val - cfg.mMinValue) / span; + + if ( TYPE_SLIDER != cfg.mType ) + return ret*2.0 - 1.0; + return ret; +} + +double JXInput::getX() const +{ + return getAxisValueHelper( mJS.lX, ID_X ); +} +double JXInput::getY() const +{ + return getAxisValueHelper( mJS.lY, ID_Y ); +} +double JXInput::getZ() const +{ + return getAxisValueHelper( mJS.lZ, ID_Z ); +} +double JXInput::getRotX() const +{ + return getAxisValueHelper( mJS.lRx, ID_ROTX ); +} +double JXInput::getRotY() const +{ + return getAxisValueHelper( mJS.lRy, ID_ROTY ); +} +double JXInput::getRotZ() const +{ + return getAxisValueHelper( mJS.lRz, ID_ROTZ ); +} +double JXInput::getSlider0() const +{ + return getAxisValueHelper( mJS.rglSlider[ 0 ], ID_SLIDER0 ); +} +double JXInput::getSlider1() const +{ + return getAxisValueHelper( mJS.rglSlider[ 1 ], ID_SLIDER1 ); +} + + + +bool JXInput::isAxisAvailable( int idx ) const +{ + assert( idx < JXINPUT_MAX_AXES ); + return mAxisConfig[ idx ].mIsAvailable; +} + +TCHAR * const JXInput::getAxisName( int idx ) const +{ + assert( idx < JXINPUT_MAX_AXES ); + return (char*const)mAxisConfig[ idx ].mName; +} + +int JXInput::getAxisType( int idx ) const +{ + assert( idx < JXINPUT_MAX_AXES ); + return mAxisConfig[ idx ].mType; +} + +double JXInput::getAxisValue( int idx ) const +{ + assert( idx < JXINPUT_MAX_AXES ); + + // Failsafe if called accidentally + if ( ! mAxisConfig[ idx ].mIsAvailable ) + return 0.0; + + return (this->*mAxisConfig[ idx ].mGetValueMethod)(); +} + + + + + +bool JXInput::isButtonAvailable( int idx ) const +{ + assert( idx < JXINPUT_MAX_BUTTONS ); + return mButtonConfig[ idx ].mIsAvailable; +} + +TCHAR * const JXInput::getButtonName( int idx ) const +{ + assert( idx < JXINPUT_MAX_BUTTONS ); + return (char*const)mButtonConfig[ idx ].mName; +} + +int JXInput::getButtonType( int idx ) const +{ + assert( idx < JXINPUT_MAX_BUTTONS ); + return mButtonConfig[ idx ].mType; +} + +bool JXInput::isButtonDown( int idx ) const +{ + assert( idx < JXINPUT_MAX_BUTTONS ); + return 0 != mJS.rgbButtons[ idx ] ; +} + + +bool JXInput::isDirectionalAvailable( int idx ) const +{ + assert( idx < JXINPUT_MAX_DIRECTIONALS ); + return mDirectionalConfig[ idx ].mIsAvailable; +} + +TCHAR * const JXInput::getDirectionalName( int idx ) const +{ + assert( idx < JXINPUT_MAX_DIRECTIONALS ); + return (char*const)mDirectionalConfig[ idx ].mName; +} + +int JXInput::getDirection( int idx ) const +{ + assert( idx < JXINPUT_MAX_DIRECTIONALS ); + return mJS.rgdwPOV[ idx ] ; +} + + +/** + * Initialize axis configuration array. + */ +void JXInput::initAxisConfig() +{ + mAxisConfig[ ID_X ].mIsAvailable = false; + mAxisConfig[ ID_X ].mType = TYPE_TRANSLATION; + mAxisConfig[ ID_X ].mGetValueMethod = &JXInput::getX; + + mAxisConfig[ ID_Y ].mIsAvailable = false; + mAxisConfig[ ID_Y ].mType = TYPE_TRANSLATION; + mAxisConfig[ ID_Y ].mGetValueMethod = &JXInput::getY; + + mAxisConfig[ ID_Z ].mIsAvailable = false; + mAxisConfig[ ID_Z ].mType = TYPE_TRANSLATION; + mAxisConfig[ ID_Z ].mGetValueMethod = &JXInput::getZ; + + mAxisConfig[ ID_ROTX ].mIsAvailable = false; + mAxisConfig[ ID_ROTX ].mType = TYPE_ROTATION; + mAxisConfig[ ID_ROTX ].mGetValueMethod = &JXInput::getRotX; + + mAxisConfig[ ID_ROTY ].mIsAvailable = false; + mAxisConfig[ ID_ROTY ].mType = TYPE_ROTATION; + mAxisConfig[ ID_ROTY ].mGetValueMethod = &JXInput::getRotY; + + mAxisConfig[ ID_ROTZ ].mIsAvailable = false; + mAxisConfig[ ID_ROTZ ].mType = TYPE_ROTATION; + mAxisConfig[ ID_ROTZ ].mGetValueMethod = &JXInput::getRotZ; + + mAxisConfig[ ID_SLIDER0 ].mIsAvailable = false; + mAxisConfig[ ID_SLIDER0 ].mType = TYPE_SLIDER; + mAxisConfig[ ID_SLIDER0 ].mGetValueMethod = &JXInput::getSlider0; + + mAxisConfig[ ID_SLIDER1 ].mIsAvailable = false; + mAxisConfig[ ID_SLIDER1 ].mType = TYPE_SLIDER; + mAxisConfig[ ID_SLIDER1 ].mGetValueMethod = &JXInput::getSlider1; +} + + +/** + * Initialize buttons configuration array. + */ +void JXInput::initButtonsConfig() +{ + for ( int i = 0; i < JXINPUT_MAX_BUTTONS; ++i ) + { + mButtonConfig[ i ].mIsAvailable = false; + mButtonConfig[ i ].mName[ 0 ] = '\0'; + mButtonConfig[ i ].mType = TYPE_PUSHBUTTON; + } + +} + + +/** + * Initialize directionals configuration array. + */ +void JXInput::initDirectionalsConfig() +{ + for ( int i = 0; i < JXINPUT_MAX_DIRECTIONALS; ++i ) + { + mDirectionalConfig[ i ].mIsAvailable = false; + mDirectionalConfig[ i ].mName[ 0 ] = '\0'; + } + +} + + + +//----------------------------------------------------------------------------- +// Name: EnumAxesCallback() +// Desc: Callback function for enumerating the axes on a joystick +//----------------------------------------------------------------------------- +BOOL CALLBACK JXInput::EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext ) +{ + JXInput* pThis = (JXInput*)pContext; + + AxisConfig* pAxCfg = NULL; + + // Set the UI to reflect what objects the joystick supports + // Code derived from M$ samples, really sucks, eh? + if (pdidoi->guidType == GUID_XAxis) + { + pAxCfg = & pThis->mAxisConfig[ ID_X ]; + } + if (pdidoi->guidType == GUID_YAxis) + { + pAxCfg = & pThis->mAxisConfig[ ID_Y ]; + } + if (pdidoi->guidType == GUID_ZAxis) + { + pAxCfg = & pThis->mAxisConfig[ ID_Z ]; + } + if (pdidoi->guidType == GUID_RxAxis) + { + pAxCfg = & pThis->mAxisConfig[ ID_ROTX ]; + } + if (pdidoi->guidType == GUID_RyAxis) + { + pAxCfg = & pThis->mAxisConfig[ ID_ROTY ]; + } + if (pdidoi->guidType == GUID_RzAxis) + { + pAxCfg = & pThis->mAxisConfig[ ID_ROTZ ]; + } + if (pdidoi->guidType == GUID_Slider) + { + switch( pThis->mSliderCount++ ) + { + case 0 : + pAxCfg = & pThis->mAxisConfig[ ID_SLIDER0 ]; + break; + + case 1 : + pAxCfg = & pThis->mAxisConfig[ ID_SLIDER1 ]; + break; + } + } + + // fail-safe + if( NULL == pAxCfg ) // e.g. GUID_Unknown + return DIENUM_CONTINUE; + + + // + // Perform config. + // + + DIPROPRANGE diprg; + diprg.diph.dwSize = sizeof(DIPROPRANGE); + diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); + diprg.diph.dwHow = DIPH_BYID; + diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis + + // Get the range for the axis + if( FAILED( pThis->mpJoystick->GetProperty( DIPROP_RANGE, &diprg.diph ) ) ) + return DIENUM_CONTINUE; + + pAxCfg->mMinValue = diprg.lMin; + pAxCfg->mMaxValue = diprg.lMax; + + strcpy( (char*)pAxCfg->mName, (char*)pdidoi->tszName ); + pAxCfg->mIsAvailable = true; + + return DIENUM_CONTINUE; +} + + + +//----------------------------------------------------------------------------- +// Name: EnumButtonsCallback() +// Desc: Callback function for enumerating the axes on a joystick +//----------------------------------------------------------------------------- +BOOL CALLBACK JXInput::EnumButtonsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext ) +{ + JXInput* pThis = (JXInput*)pContext; + + // + // if the maximum number of buttons is already registered, + // issue a warning and stop enumeration. + // + if( JXINPUT_MAX_BUTTONS == pThis->mButtonCount ) + { + OutputDebugString( "Max. number of buttons exceeded!" ); + return DIENUM_STOP; + } + + + ButtonConfig* pBtCfg = NULL; + + if ( pdidoi->guidType == GUID_Button ) + { + assert( JXINPUT_MAX_BUTTONS > pThis->mButtonCount ); + pBtCfg = & pThis->mButtonConfig[ pThis->mButtonCount++ ]; + } + + + // fail-safe + if( NULL == pBtCfg ) // e.g. unknown stuff + return DIENUM_CONTINUE; + assert( NULL != pBtCfg ); + + // + // Perform config. + // + + strcpy( (char*)pBtCfg->mName, (char*)pdidoi->tszName ); + pBtCfg->mIsAvailable = true; + + return DIENUM_CONTINUE; +} + + +//----------------------------------------------------------------------------- +// Name: EnumPOVsCallback() +// Desc: Callback function for enumerating the axes on a joystick +//----------------------------------------------------------------------------- +BOOL CALLBACK JXInput::EnumPOVsCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext ) +{ + JXInput* pThis = (JXInput*)pContext; + + // + // if the maximum number of buttons is already registered, + // issue a warning and stop enumeration. + // + if( JXINPUT_MAX_DIRECTIONALS == pThis->mPOVCount ) + { + OutputDebugString( "Max. number of POVs exceeded!" ); + return DIENUM_STOP; + } + + DirectionalConfig* pDirCfg = NULL; + + + if (pdidoi->guidType == GUID_POV) + { + assert( JXINPUT_MAX_DIRECTIONALS > pThis->mPOVCount ); + pDirCfg = & pThis->mDirectionalConfig[ pThis->mPOVCount++ ]; + } + + // fail-safe + if( NULL == pDirCfg ) // e.g. unknown stuff + return DIENUM_CONTINUE; + assert( NULL != pDirCfg ); + + // + // Perform config. + // + + strcpy( (char*)pDirCfg->mName, (char*)pdidoi->tszName ); + pDirCfg->mIsAvailable = true; + + return DIENUM_CONTINUE; +} + + + +//----------------------------------------------------------------------------- +// Name: EnumEffectsCallback() +// Desc: Callback function for enumerating the effects of a joystick +//----------------------------------------------------------------------------- +BOOL CALLBACK JXInput::EnumEffectsCallback( const DIEFFECTINFO* pdidoi, + VOID* pContext ) +{ + JXInput* pThis = (JXInput*)pContext; + + // + // Work on that!! + // + + return DIENUM_CONTINUE; +} + + + +//----------------------------------------------------------------------------- +// Name: InitDirectInput() +// Desc: Initialize the DirectInput variables. +//----------------------------------------------------------------------------- +HRESULT JXInput::InitDirectInput( HWND hWnd ) +{ + HRESULT hr; + + // Make sure we got a joystick + if( NULL == mpJoystick ) + { + return E_FAIL; + } + + + // + // Ask the device for some useful information. + // + mdiDevInfo.dwSize = sizeof( DIDEVICEINSTANCE ); + hr = mpJoystick->GetDeviceInfo( &mdiDevInfo ); + if( FAILED(hr) ) + return hr; + + // Set the data format to "simple joystick" - a predefined data format + // + // A data format specifies which controls on a device we are interested in, + // and how they should be reported. This tells DInput that we will be + // passing a DIJOYSTATE structure to IDirectInputDevice::GetDeviceState(). + hr = mpJoystick->SetDataFormat( &c_dfDIJoystick2 ); + if( FAILED(hr) ) + return hr; + + // Set the cooperative level to let DInput know how this device should + // interact with the system and with other DInput applications. +// hr = g_pJoystick->SetCooperativeLevel( hDlg, DISCL_EXCLUSIVE|DISCL_FOREGROUND ); + DWORD mode = ( NULL == hWnd ? DISCL_NONEXCLUSIVE|DISCL_BACKGROUND : DISCL_EXCLUSIVE|DISCL_BACKGROUND ); + hr = mpJoystick->SetCooperativeLevel( hWnd, mode ); + if( FAILED(hr) ) + return hr; + + // Determine how many axis the joystick has (so we don't error out setting + // properties for unavailable axis) + mdiDevCaps.dwSize = sizeof(DIDEVCAPS); + hr = mpJoystick->GetCapabilities(&mdiDevCaps); + if ( FAILED(hr) ) + return hr; + + + // Enumerate the axes of the joyctick and set the range of each axis. Note: + // we could just use the defaults, but we're just trying to show an example + // of enumerating device objects (axes, buttons, etc.). + mpJoystick->EnumObjects( EnumAxesCallback, (VOID*)this, DIDFT_AXIS ); + mpJoystick->EnumObjects( EnumButtonsCallback, (VOID*)this, DIDFT_BUTTON ); + mpJoystick->EnumObjects( EnumPOVsCallback, (VOID*)this, DIDFT_POV ); + + mpJoystick->EnumEffects( EnumEffectsCallback, (VOID*)this, DIEFT_ALL ); + + // For FF sticks, switch on autocenter as long as we do not use real FF + SwitchAutoCenter( true ); + + return S_OK; +} + + + + + +//----------------------------------------------------------------------------- +// Name: UpdateInputState() +// Desc: Get the input device's state and display it. +//----------------------------------------------------------------------------- +HRESULT JXInput::UpdateInputState() +{ + HRESULT hr; + + if( mpJoystick ) + { + + // Poll the device to read the current state + hr = mpJoystick->Poll(); + if( FAILED(hr) ) + { + // DInput is telling us that the input stream has been + // interrupted. We aren't tracking any state between polls, so + // we don't have any special reset that needs to be done. We + // just re-acquire and try again. + hr = mpJoystick->Acquire(); + while( hr == DIERR_INPUTLOST ) + hr = mpJoystick->Acquire(); + + // hr may be DIERR_OTHERAPPHASPRIO or other errors. This + // may occur when the app is minimized or in the process of + // switching, so just try again later + return S_OK; + } + + // Get the input's device state + if( FAILED( hr = mpJoystick->GetDeviceState( sizeof(DIJOYSTATE2), &mJS ) ) ) + return hr; // The device should have been acquired during the Poll() + + } + + return S_OK; +} + + + + +//----------------------------------------------------------------------------- +// Name: FreeDirectInput() +// Desc: Initialize the DirectInput variables. +//----------------------------------------------------------------------------- +HRESULT JXInput::FreeDirectInput() +{ + // Unacquire and release any DirectInputDevice objects. + if( NULL != mpJoystick ) + { + // Unacquire the device one last time just in case + // the app tried to exit while the device is still acquired. + mpJoystick->Unacquire(); + + mpJoystick->Release(); + mpJoystick = NULL; + } + + return S_OK; +} + + + +HRESULT JXInput::SwitchAutoCenter( bool onoff ) +{ + HRESULT hr; + + DIPROPDWORD DIPropAutoCenter; + + DIPropAutoCenter.diph.dwSize = sizeof(DIPropAutoCenter); + DIPropAutoCenter.diph.dwHeaderSize = sizeof(DIPROPHEADER); + DIPropAutoCenter.diph.dwObj = 0; + DIPropAutoCenter.diph.dwHow = DIPH_DEVICE; + DIPropAutoCenter.dwData = ( onoff ? DIPROPAUTOCENTER_ON : DIPROPAUTOCENTER_OFF ); + + hr = mpJoystick->SetProperty( DIPROP_AUTOCENTER, &DIPropAutoCenter.diph ); + return hr; +} diff --git a/vendor/JXInput/0.3.4/c/jxinput.dsp b/vendor/JXInput/0.3.4/c/jxinput.dsp new file mode 100644 index 0000000..aac15c1 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/jxinput.dsp @@ -0,0 +1,175 @@ +# Microsoft Developer Studio Project File - Name="jxinput" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=jxinput - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "jxinput.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "jxinput.mak" CFG="jxinput - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "jxinput - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "jxinput - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "jxinput - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\j2sdk1.4.2\include" /I "C:\j2sdk1.4.2\include\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /FR /Yu"stdafx.h" /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 dxguid.lib dinput8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\build\jxinput.dll" + +!ELSEIF "$(CFG)" == "jxinput - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\j2sdk1.4.2\include" /I "C:\j2sdk1.4.2\include\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "JXINPUT_EXPORTS" /FR /Yu"stdafx.h" /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 dxguid.lib dinput8.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\Classes\jxinput.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "jxinput - Win32 Release" +# Name "jxinput - Win32 Debug" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\de_hardcode_jxinput_directinput_DirectInputDriver.cpp +# End Source File +# Begin Source File + +SOURCE=.\dllmain.cpp +# End Source File +# Begin Source File + +SOURCE=.\jxinput.cpp +# End Source File +# Begin Source File + +SOURCE=.\JXInputManager.cpp +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.cpp +# ADD CPP /Yc"stdafx.h" +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\de_hardcode_jxinput_directinput_DirectInputDriver.h + +!IF "$(CFG)" == "jxinput - Win32 Release" + +# PROP Ignore_Default_Tool 1 +USERDEP__DE_HA="..\classes\de\hardcode\jxinput\directinput\DirectInputDriver.class" +# Begin Custom Build +InputPath=.\de_hardcode_jxinput_directinput_DirectInputDriver.h + +"de_hardcode_jxinput_directinput_DirectInputDriver.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + cd ..\Classes + C:\j2sdk1.4.2\bin\javah -classpath . -d ..\win32 de.hardcode.jxinput.directinput.DirectInputDriver + cd ..\win32 + +# End Custom Build + +!ELSEIF "$(CFG)" == "jxinput - Win32 Debug" + +# PROP Ignore_Default_Tool 1 +USERDEP__DE_HA="..\classes\de\hardcode\jxinput\directinput\DirectInputDriver.class" +# Begin Custom Build +InputPath=.\de_hardcode_jxinput_directinput_DirectInputDriver.h + +"de_hardcode_jxinput_directinput_DirectInputDriver.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" + cd ..\Classes + C:\j2sdk1.4.2\bin\javah -classpath . -d ..\win32 de.hardcode.jxinput.directinput.DirectInputDriver + cd ..\win32 + +# End Custom Build + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\jxinput.h +# End Source File +# Begin Source File + +SOURCE=.\JXInputManager.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/vendor/JXInput/0.3.4/c/jxinput.dsw b/vendor/JXInput/0.3.4/c/jxinput.dsw new file mode 100644 index 0000000..deb2877 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/jxinput.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "jxinput"=".\jxinput.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/vendor/JXInput/0.3.4/c/jxinput.h b/vendor/JXInput/0.3.4/c/jxinput.h new file mode 100644 index 0000000..6d47a31 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/jxinput.h @@ -0,0 +1,183 @@ + +#define JXINPUT_MAX_AXES 8 +#define JXINPUT_MAX_BUTTONS 256 +#define JXINPUT_MAX_DIRECTIONALS 4 + + +/** + * This class will be exported by jxinput.dll. + */ +class JXINPUT_API JXInput +{ + +public: + + typedef enum AXISTYPE + { + TYPE_TRANSLATION, + TYPE_ROTATION, + TYPE_SLIDER + }; + + typedef enum BUTTONTYPE + { + TYPE_PUSHBUTTON, + TYPE_TOGGLEBUTTON + }; + + typedef enum AXISID + { + ID_X, ID_Y, ID_Z, + ID_ROTX, ID_ROTY, ID_ROTZ, + ID_SLIDER0, ID_SLIDER1 + }; + + + // + // Ctor + // + JXInput( LPDIRECTINPUTDEVICE8 pJoystick, HWND hWnd = NULL ); + + // + // Dtor + // + virtual ~JXInput(); + + // + // Operational methods + // + void update(); + + // Ask for the name + TCHAR * const getName() const; + + // + // Numbering methods + // + int getNumberOfAxes() const; + int getNumberOfButtons() const; + int getNumberOfDirectionals() const; + + + // + // Access axes + // + double getX() const; /** -1.0 .... 1.0 */ + double getY() const; /** -1.0 .... 1.0 */ + double getZ() const; /** -1.0 .... 1.0 */ + double getRotX() const; /** -1.0 .... 1.0 */ + double getRotY() const; /** -1.0 .... 1.0 */ + double getRotZ() const; /** -1.0 .... 1.0 */ + double getSlider0() const; /** 0.0 .... 1.0 */ + double getSlider1() const; /** 0.0 .... 1.0 */ + + + // + // Axis methods + // + bool isAxisAvailable( int idx ) const; + TCHAR* const getAxisName( int idx ) const; + int getAxisType( int idx ) const; + double getAxisValue( int idx ) const; + + // + // Button methods + // + bool isButtonAvailable( int idx ) const; + TCHAR* const getButtonName( int idx ) const; + int getButtonType( int idx ) const; + bool isButtonDown( int idx ) const; + + // + // Directional methods + // + bool isDirectionalAvailable( int idx ) const; + TCHAR* const getDirectionalName( int idx ) const; + int getDirection( int idx ) const; + +private://----------------------------------------------------------------------------------------- + LPDIRECTINPUTDEVICE8 mpJoystick; + + DIDEVICEINSTANCE mdiDevInfo; + DIDEVCAPS mdiDevCaps; + DIJOYSTATE2 mJS; // DInput joystick state + + int mSliderCount; + int mPOVCount; + int mButtonCount; + + double getAxisValueHelper( LONG val, int idx ) const; + + HRESULT SwitchAutoCenter( bool onoff = true ); + + HRESULT InitDirectInput( HWND hWnd = NULL ); + HRESULT FreeDirectInput(); + HRESULT UpdateInputState(); + + + static BOOL CALLBACK EnumAxesCallback + ( + const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext + ); + + static BOOL CALLBACK EnumButtonsCallback + ( + const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext + ); + + static BOOL CALLBACK EnumPOVsCallback + ( + const DIDEVICEOBJECTINSTANCE* pdidoi, + VOID* pContext + ); + + static BOOL CALLBACK EnumEffectsCallback + ( + const DIEFFECTINFO* pdidoi, + VOID* pContext + ); + + + class JXINPUT_API AxisConfig + { + + public: + bool mIsAvailable; + CHAR mName[MAX_PATH]; + AXISTYPE mType; + LONG mMinValue; + LONG mMaxValue; + double (JXInput::*mGetValueMethod)() const; + + } mAxisConfig [ JXINPUT_MAX_AXES ]; + + void initAxisConfig(); + + + class JXINPUT_API ButtonConfig + { + + public: + bool mIsAvailable; + CHAR mName[MAX_PATH]; + BUTTONTYPE mType; + + } mButtonConfig[ JXINPUT_MAX_BUTTONS ]; + + void initButtonsConfig(); + + + class JXINPUT_API DirectionalConfig + { + + public: + bool mIsAvailable; + CHAR mName[MAX_PATH]; + + } mDirectionalConfig[ JXINPUT_MAX_DIRECTIONALS ]; + + void initDirectionalsConfig(); +}; + diff --git a/vendor/JXInput/0.3.4/c/jxinput.sln b/vendor/JXInput/0.3.4/c/jxinput.sln new file mode 100644 index 0000000..714fdc7 --- /dev/null +++ b/vendor/JXInput/0.3.4/c/jxinput.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C++ Express 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jxinput", "jxinput.vcproj", "{8AEA84DC-D8F0-4425-BEBF-A84E91115F76}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Debug|Win32.ActiveCfg = Debug|Win32 + {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Debug|Win32.Build.0 = Debug|Win32 + {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Release|Win32.ActiveCfg = Release|Win32 + {8AEA84DC-D8F0-4425-BEBF-A84E91115F76}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vendor/JXInput/0.3.4/c/jxinput.vcproj b/vendor/JXInput/0.3.4/c/jxinput.vcproj new file mode 100644 index 0000000..c87fc0f --- /dev/null +++ b/vendor/JXInput/0.3.4/c/jxinput.vcproj @@ -0,0 +1,367 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Axis.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Axis.java new file mode 100644 index 0000000..9f1d710 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Axis.java @@ -0,0 +1,72 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 19. Dezember 2001, 21:58 +//********************************************************************************************** +package de.hardcode.jxinput; + +/** + * The Axis interface describes the most common feature of a joystick or other input devices. + * + * @author Herkules + */ +public interface Axis extends Feature +{ + // Enumeration of axes. + final static int ID_X = 0; + final static int ID_Y = 1; + final static int ID_Z = 2; + final static int ID_ROTX = 3; + final static int ID_ROTY = 4; + final static int ID_ROTZ = 5; + final static int ID_SLIDER0 = 6; + final static int ID_SLIDER1 = 7; + final static int NUMBER_OF_ID = 8; + + // Enumeration of axis types + final static int TRANSLATION = 0; + final static int ROTATION = 1; + final static int SLIDER = 2; + + /** + * Retrieve the type of the axis. + * The type is describes the meaning and the range of values of the axis. + *

+ * TRANSLATION typed axes denote a translational deviation from a center + * position. This can be e.g. the common, basic joystick axes. + * The range of getValue() is [-1.0,1.0]. + *

+ * ROTATION typed axes denote a rotational deviation from a center + * position. Something on the stick is turned or twisted. + * The range of getValue() is [-1.0,1.0]. + *

+ * SLIDER typed axes denote a shifting device without a center position. + * A good sample is a throttle control. + * The range of getValue() is [0.0,1.0]. + * + * @return [ TRANSLATION | ROTATION | SLIDER ] + */ + int getType(); + + /** + * Returns the current value of the axis. + * The range of the result depends on the axis type. + * + * @return value [-1.0,1.0] or [0.0,1.0] + */ + double getValue(); + + + /** + * Inform about the resolution of the axis. + * + * @return resolution, e.g. 2^-16 + */ + double getResolution(); + +} + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Button.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Button.java new file mode 100644 index 0000000..418e2b6 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Button.java @@ -0,0 +1,35 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 19. Dezember 2001, 21:58 +//********************************************************************************************** +package de.hardcode.jxinput; + +/** + * + * @author Herkules + */ +public interface Button extends Feature +{ + // Enumeration of button types + final static int PUSHBUTTON = 0; + final static int TOGGLEBUTTON = 1; + + /** + * Retrieve the type of the button. + * Pushbutton will deliver true==getState() as long as they are pressed down. + * Togglebuttons will change their state once they are pressed and keep that state + * until they are pressed again. + * @return [ PUSHBUTTON | TOGGLEBUTTON ] + */ + int getType(); + + /** + * Tells the state of the button at last update. + */ + boolean getState(); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Directional.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Directional.java new file mode 100644 index 0000000..ccd27c1 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Directional.java @@ -0,0 +1,45 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 27. Dezember 2001, 23:33 +//********************************************************************************************** +package de.hardcode.jxinput; + +/** + * + * @author Herkules + */ +public interface Directional extends Feature +{ + /** + * If the Directional has a center position where it points to no direction, this + * flag is true when this position is reached. + */ + boolean isCentered(); + + /** + * Retrieve the direction pointed to. + * Value is given in 1/100 degree, [0,36000] + */ + int getDirection(); + + /** + * Retrieve the analog value pointing to the angle described by + * getDirection(). + * For coolie hats this will be either 1,0 for any direction or 0.0 + * when isCentered()==true. + */ + double getValue(); + + /** + * Inform about the resolution of the value returned by getValue(). + * + * @return resolution, e.g. 1.0 for coolie hats + */ + double getResolution(); + +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Feature.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Feature.java new file mode 100644 index 0000000..20c396f --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/Feature.java @@ -0,0 +1,38 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 27. Dezember 2001, 00:19 +//********************************************************************************************** +package de.hardcode.jxinput; + +/** + * An input device offers a set of features (otherwise it would be pretty useless). + * Features in this sense can be axes, buttons and a feature callede directional here. + * Coolie hats are typical directionals because they control a direction (to look at e.g.). + *

+ * There are no concrete classes directly derived from Feature - it only + * provides a basis for other interfaces. + * + * @see Axis + * @see Button + * @see Directional + * + * @author Herkules + */ +public abstract interface Feature +{ + /** + * Features may have a name provided e.g. by the driver. + */ + String getName(); + + /** + * Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + boolean hasChanged(); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/JXInputDevice.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/JXInputDevice.java new file mode 100644 index 0000000..d8a8bc8 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/JXInputDevice.java @@ -0,0 +1,71 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 19. Dezember 2001, 21:47 +//********************************************************************************************** +package de.hardcode.jxinput; + +/** + * The JXInputDevise is the main entrypoint to the jxinput package. + *

+ * A JXInputDevice represents one physical device like a joystick, a gamepad or + * even some emulation (e.g. using keyboard) that implements the interface. + *

+ * The basis task of a JXInputDevise is to maintain a consistent state of all its features. + *
+ * It is save to distribute the Feature objects into application without worrying + * about someone else performing an update method and thereby destructing the consistent state. + *

+ * An additional task is to provide basic device features information like number of axes, buttons + * and directional features. + * + * @see Feature + * @see JXInputManager + * + * @author Herkules + * @version 0.2beta + */ +public interface JXInputDevice +{ + /** + * @directed + */ + /*#Features lnkFeatures;*/ + + /** + *@link aggregationByValue + */ + /*#Feature lnkFeature;*/ + + /** + * Devices may have a name. + * This name might be provided by a system dependant driver. + */ + String getName(); + + /** Actual number of available axes. */ + int getNumberOfAxes(); + + /** Actual number of available buttons. */ + int getNumberOfButtons(); + + /** Actual number of available directional features. */ + int getNumberOfDirectionals(); + + /** Maximum number of axes as an upper bound for index values. */ + int getMaxNumberOfAxes(); + + /** Maximum number of buttons as an upper bound for index values. */ + int getMaxNumberOfButtons(); + + /** Maximum number of directional features as an upper bound for index values. */ + int getMaxNumberOfDirectionals(); + + Axis getAxis( int idx ); + Button getButton( int idx ); + Directional getDirectional( int idx ); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/JXInputManager.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/JXInputManager.java new file mode 100644 index 0000000..8c3e050 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/JXInputManager.java @@ -0,0 +1,233 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 29. Dezember 2001, 02:17 +//********************************************************************************************** +package de.hardcode.jxinput; + +// +// Import driver stuff +// +import de.hardcode.jxinput.directinput.DirectInputDevice; +import de.hardcode.jxinput.event.JXInputEventManager; +import de.hardcode.jxinput.keyboard.JXKeyboardInputDevice; +import de.hardcode.jxinput.virtual.JXVirtualInputDevice; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.awt.Component; + + +/** + * Manages the available instances of JXInputDevice. + * It holds the one central update method which synchronizes with the physical device. + * @author Herkules + */ +public class JXInputManager +{ + + /** Remember when the last update took place. */ + private static long mTimeOfLastUpdate; + + /** Maintain a list of devices. */ + private final static ArrayList mDevices = new ArrayList(); + + /** Maintain a list of direct input devices. */ + private final static ArrayList mDIDevices = new ArrayList(); + + /** Maintain a list of virtual devices. */ + private final static ArrayList mVirtualDevices = new ArrayList(); + + /** Maintain a list of keyboard devices. */ + private final static ArrayList mKBDevices = new ArrayList(); + + /** + * Statically retrieve all DirectInputDevices available. + */ + static + { + reset(); + } + + + /** + * @directed + */ + /*#JXInputDevice lnkJXInputDevice;*/ + + /** + * Creates a new instance of JXInputManager. + * This is prohibited - it only has static members. + */ + private JXInputManager() + { + } + + + /** + * Retrieve the number of available input devices. + */ + public static int getNumberOfDevices() + { + return mDevices.size(); + } + + /** + * Delivers the JXInputDevice with the desired index. + *

+ * Take care that idx < getNumberOfDevices()! + */ + public static JXInputDevice getJXInputDevice( int idx ) + { + // + // Be well-behaved even if idx is out of range. + // + if ( idx >= mDevices.size() ) + return null; + return (JXInputDevice)mDevices.get( idx ); + } + + + /** + * Master reset for all devices and events. + * After calling reset(), better forget all devices created or retrieved. + * They are no longer valid. + * Event listeners will no longer be called and should be discarded. + */ + synchronized public static void reset() + { + JXInputEventManager.reset(); + + mDevices.clear(); + + mVirtualDevices.clear(); + mDIDevices.clear(); + + DirectInputDevice.reset(); + + for ( int i = 0; i < DirectInputDevice.getNumberOfDevices(); ++i ) + { + DirectInputDevice dev = new DirectInputDevice( i ); + mDevices.add( dev ); + mDIDevices.add( dev ); + } + + // I have to call updateFeatures one time here during initialization + // bc. I experienced difficulties otherwise while running with the + // J3D sensoring stuff! +// updateFeatures(); + DirectInputDevice.update(); + + int n = mKBDevices.size(); + for ( int i = 0; i < n; ++i ) + ((JXKeyboardInputDevice)mKBDevices.get( i )).shutdown(); + mKBDevices.clear(); + } + + + /** + * Update the (shared) state of all features in one step. + * This method asks the actual device for a consistant state. + * After calling this method, all features may have new values. + * updateFeatures() is meant to be called e.g. once per frame in a gaming environment. + */ + public static void updateFeatures() + { + // Get timing + long now = System.currentTimeMillis(); + long deltaT = now - mTimeOfLastUpdate; + + // Update available driver + DirectInputDevice.update(); + + // + // Update the virtual devices. + // + Iterator vdevices = mVirtualDevices.iterator(); + while ( vdevices.hasNext() ) + { + ((JXVirtualInputDevice)vdevices.next()).update( deltaT ); + } + + // Remember time + mTimeOfLastUpdate = now; + + // Fire all events. + JXInputEventManager.trigger(); + } + + + + /** + * Get time when last update occurred. + * @return tickervalue in milliseconds + */ + public static long getLastUpdateTime() + { + return mTimeOfLastUpdate; + } + + + /** + * Create a new pseudo-device. + */ + public static JXKeyboardInputDevice createKeyboardDevice() + { + JXKeyboardInputDevice d = new JXKeyboardInputDevice(); + mDevices.add( d ); + mKBDevices.add( d ); + return d; + } + + + /** + * Create a new pseudo-device listening to a Swing component. + * Make sure that the component also has the keyboard focus!! + */ + public static JXKeyboardInputDevice createKeyboardDevice( Component comp ) + { + JXKeyboardInputDevice d = new JXKeyboardInputDevice( comp ); + mDevices.add( d ); + mKBDevices.add( d ); + return d; + } + + + /** + * Delete a keyboard device again e.g. when the corresponding + * JComponent gets deleted. + */ + public static void deleteKeyboardDevice( JXKeyboardInputDevice dev ) + { + mDevices.remove( dev ); + mKBDevices.remove( dev ); + ((JXKeyboardInputDevice)dev).shutdown(); + } + + + /** + * Create a new pseudo-device. + */ + public static JXVirtualInputDevice createVirtualDevice() + { + JXVirtualInputDevice d = new JXVirtualInputDevice(); + mDevices.add( d ); + mVirtualDevices.add( d ); + return d; + } + + + /** + * Delete a virtual device again. + */ + public static void deleteVirtualDevice( JXVirtualInputDevice dev ) + { + mDevices.remove( dev ); + mVirtualDevices.remove( dev ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIAxis.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIAxis.java new file mode 100644 index 0000000..a6d0eac --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIAxis.java @@ -0,0 +1,70 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 27. Dezember 2001, 00:14 +//********************************************************************************************** +package de.hardcode.jxinput.directinput; + +import de.hardcode.jxinput.Axis; + +/** + * + * @author Herkules + */ +class DIAxis implements Axis +{ + private final int mDeviceIdx; + private final int mIdx; + + /** + * Creates a new instance of DIAxis. + */ + DIAxis( int devidx, int idx ) + { + mDeviceIdx = devidx; + mIdx = idx; + } + + public String getName() + { + return DirectInputDriver.getAxisName( mDeviceIdx, mIdx ); + } + + + /** + * Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + public boolean hasChanged() + { + return true; + } + + public double getValue() + { + return DirectInputDriver.getAxisValue( mDeviceIdx, mIdx ); + } + + public int getType() + { + return DirectInputDriver.getAxisType( mDeviceIdx, mIdx ); + } + + /** + * Inform about the resolution of the axis. + * + * @return resolution, e.g. 2^-16 + */ + public double getResolution() + { + // extend the driver here!! + // Here I assume typical 16 bit resolution + return ( getType() == Axis.SLIDER ? 1.0/65536.0 : 2.0/65536.0 ) ; + } + +} + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIButton.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIButton.java new file mode 100644 index 0000000..5419550 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIButton.java @@ -0,0 +1,55 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 27. Dezember 2001, 00:14 +//********************************************************************************************** +package de.hardcode.jxinput.directinput; + +import de.hardcode.jxinput.Button; + + +/** + * + * @author Herkules + */ +class DIButton implements Button +{ + private final int mDeviceIdx; + private final int mIdx; + + /** + * Creates a new instance of DIButton. + */ + DIButton( int devidx, int idx ) + { + mDeviceIdx = devidx; + mIdx = idx; + } + + public String getName() + { + return DirectInputDriver.getButtonName( mDeviceIdx, mIdx ); + } + + /** + * Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + public boolean hasChanged() + { + return true; + } + + public int getType() + { + return DirectInputDriver.getButtonType( mDeviceIdx, mIdx ); + } + + public boolean getState() + { + return DirectInputDriver.getButtonState( mDeviceIdx, mIdx ); + } +} \ No newline at end of file diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIDirectional.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIDirectional.java new file mode 100644 index 0000000..9da2d3d --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DIDirectional.java @@ -0,0 +1,78 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 27. Dezember 2001, 23:40 +//********************************************************************************************** +package de.hardcode.jxinput.directinput; + +import de.hardcode.jxinput.Directional; + +/** + * + * @author Herkules + */ +class DIDirectional implements Directional +{ + private final int mDeviceIdx; + private final int mIdx; + + /** + * Creates a new instance of DIDirectional. + */ + DIDirectional( int devidx, int idx ) + { + mDeviceIdx = devidx; + mIdx = idx; + } + + /** Features may have a name provided e.g. by the driver. */ + public String getName() + { + return DirectInputDriver.getDirectionalName( mDeviceIdx, mIdx ); + } + + /** + * Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + public boolean hasChanged() + { + return true; + } + + + public boolean isCentered() + { + return ( 0xffff == (DirectInputDriver.getDirection( mDeviceIdx, mIdx ) & 0xffff) ); + } + + public int getDirection() + { + return isCentered() ? 0 : DirectInputDriver.getDirection( mDeviceIdx, mIdx ); + } + + public double getValue() + { + if ( isCentered() ) + return 0.0; + return 1.0; + } + + /** + * Inform about the resolution of the value returned by getValue(). + * + * @return resolution, e.g. 1.0 for coolie hats + */ + public double getResolution() + { + // DI POV always return 0.0 or 1.0, so the resolution is 1.0. + return 1.0; + } + + +} + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DirectInputDevice.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DirectInputDevice.java new file mode 100644 index 0000000..a20eab3 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DirectInputDevice.java @@ -0,0 +1,170 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 26. Dezember 2001, 00:40 +//********************************************************************************************** +package de.hardcode.jxinput.directinput; + +import de.hardcode.jxinput.JXInputDevice; +import de.hardcode.jxinput.Axis; +import de.hardcode.jxinput.Directional; +import de.hardcode.jxinput.Button; + +/** + * + * @author Herkules + */ +public class DirectInputDevice implements JXInputDevice +{ + int mDeviceIdx; + + private DIAxis[] mAxes; + private DIButton[] mButtons; + private DIDirectional[] mDirectionals; + + /** + * The number of DirectInput devices available with the driver. + */ + public static int getNumberOfDevices() + { + if ( DirectInputDriver.isAvailable() ) + return DirectInputDriver.getNumberOfDevices(); + return 0; + } + + + /** + * Update the state of all devices. + */ + public static void update() + { + if ( DirectInputDriver.isAvailable() ) + DirectInputDriver.nativeupdate(); + } + + + + + /** + * Creates a new instance of DirectInputDevice. + */ + public DirectInputDevice( int devidx ) + { + mDeviceIdx = devidx; + + init(); + } + + /** + * Reset the DirectInput connection. + */ + public static void reset() + { + if ( DirectInputDriver.isAvailable() ) + DirectInputDriver.reset(); + } + + + /** + * Initialisation of fields. + */ + private final void init() + { + // + // Allocate arrays for max. number of features + // + mAxes = new DIAxis [ getMaxNumberOfAxes() ]; + mButtons = new DIButton [ getMaxNumberOfButtons() ]; + mDirectionals = new DIDirectional [ getMaxNumberOfDirectionals() ]; + + // + // Fill arrays due to the state of the driver. + // + for ( int i = 0; i < mAxes.length; ++i ) + { + if ( DirectInputDriver.isAxisAvailable( mDeviceIdx, i ) ) + mAxes[ i ] = new DIAxis( mDeviceIdx, i ); + } + + for ( int i = 0; i < mButtons.length; ++i ) + { + if ( DirectInputDriver.isButtonAvailable( mDeviceIdx, i ) ) + mButtons[ i ] = new DIButton( mDeviceIdx, i ); + } + + for ( int i = 0; i < mDirectionals.length; ++i ) + { + if ( DirectInputDriver.isDirectionalAvailable( mDeviceIdx, i ) ) + mDirectionals[ i ] = new DIDirectional( mDeviceIdx, i ); + } + } + + /** Devices may have a name. */ + public String getName() + { + String name = DirectInputDriver.getName( mDeviceIdx ); + if ( null == name ) + return "Win32 DirectInput Joystick"; + return name; + } + + + /** Actual number of available buttons. */ + public int getNumberOfButtons() + { + return DirectInputDriver.getNumberOfButtons( mDeviceIdx ); + } + + /** Actual number of available axes. */ + public int getNumberOfAxes() + { + return DirectInputDriver.getNumberOfAxes( mDeviceIdx ); + } + + /** Actual number of available directional features. */ + public int getNumberOfDirectionals() + { + return DirectInputDriver.getNumberOfDirectionals( mDeviceIdx ); + } + + /** Maximum number of buttons as an upper bound for index values. */ + public int getMaxNumberOfButtons() + { + return DirectInputDriver.getMaxNumberOfButtons(); + } + + /** Maximum number of axes as an upper bound for index values. */ + public int getMaxNumberOfAxes() + { + return DirectInputDriver.getMaxNumberOfAxes(); + } + + /** Maximum number of available directional features. */ + public int getMaxNumberOfDirectionals() + { + return DirectInputDriver.getMaxNumberOfDirectionals(); + } + + + public Axis getAxis(int idx) + { + return mAxes[ idx ]; + } + + public Button getButton(int idx) + { + return mButtons[ idx ]; + } + + public Directional getDirectional(int idx) + { + return mDirectionals[ idx ]; + } + +} + + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DirectInputDriver.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DirectInputDriver.java new file mode 100644 index 0000000..558f7d8 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/DirectInputDriver.java @@ -0,0 +1,184 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 19. Dezember 2001, 22:44 +//********************************************************************************************** +package de.hardcode.jxinput.directinput; + +import java.lang.reflect.Array; + +/** + * DirectInputDriver: the connection to the Win32 joystick. + * There is only one allowed, so the layout of this class is merely static. + * + * History: + * + * Changes since 0.1beta: + * - support of multiple devices addressed by the dev index + * + * + * @author Herkules + * @version 0.2beta + */ +class DirectInputDriver +{ + private final static String NATIVE_LIB_NAME = "jxinput"; + + /** Remember wether nativeinit() succeeded. */ + static boolean sIsOperational = false; + + // + // Static arrays to hold the values. + // + private static double [][] sAxisValues; + private static boolean [][] sButtonStates; + private static int [][] sDirectionalValues; + + /** + * Perform the static initialization. + */ + static + { + try + { + // Load the native lib. + System.loadLibrary( NATIVE_LIB_NAME ); + + init(); + } + catch( SecurityException e ) + { + Log.logger.warning("Native library jxinput not loaded due to a SecurityException."); + } + catch( UnsatisfiedLinkError e ) + { + Log.logger.info("Native library jxinput not loaded due to an UnsatisfiedLinkError."); + } + } + + + private final static void init() + { + sIsOperational = false; + // + // Initialize it. + // + if ( nativeinit() ) + { + int devs = getNumberOfDevices(); + sAxisValues = new double [ devs ][ DirectInputDriver.getMaxNumberOfAxes() ]; + sButtonStates = new boolean [ devs ][ DirectInputDriver.getMaxNumberOfButtons() ]; + sDirectionalValues = new int [ devs ][ DirectInputDriver.getMaxNumberOfDirectionals() ]; + + // Bind the native lib to my variables. + bind(); + + // Remember I am fine. + sIsOperational = true; + } + + } + + + /** + * Static ctor of DirectInputDriver. + * No object will be created due to the static layout. + */ + private DirectInputDriver() + { + } + + // Administration + private static native boolean nativeinit(); + private static native void nativeexit(); + private static native void bind(); + + static native int getNumberOfDevices(); + + // Configuration + static native String getName( int dev ); + static native int getNumberOfAxes( int dev ); + static native int getNumberOfButtons( int dev ); + static native int getNumberOfDirectionals( int dev ); + static native int getMaxNumberOfAxes(); + static native int getMaxNumberOfButtons(); + static native int getMaxNumberOfDirectionals(); + + static native boolean isAxisAvailable( int dev, int idx ); + static native String getAxisName( int dev, int idx ); + static native int getAxisType( int dev, int idx ); + + static native boolean isButtonAvailable( int dev, int idx ); + static native String getButtonName( int dev, int idx ); + static native int getButtonType( int dev, int idx ); + + static native boolean isDirectionalAvailable( int dev, int idx ); + static native String getDirectionalName( int dev, int idx ); + + // Operation + static native void nativeupdate(); + + + public static boolean isAvailable() + { + return sIsOperational; + } + + + /** + * Shutdown the device and free all Win32 resources. + * It is not a good idea to access any joystick features after + * shutdown(). + */ + static void shutdown() + { + nativeexit(); + sAxisValues = null; + sButtonStates = null; + sDirectionalValues = null; + } + + + /** + * Reset the device and free all Win32 resources. + */ + static void reset() + { + shutdown(); + init(); + } + + static double getAxisValue( int dev, int idx ) + { + return sAxisValues[ dev ][ idx ]; + } + + static boolean getButtonState( int dev, int idx ) + { + return sButtonStates[ dev ][ idx ]; + } + + static int getDirection( int dev, int idx ) + { + return sDirectionalValues[ dev ][ idx ]; + } + + /** + * @param args the command line arguments + */ + public static void main (String args[]) + { + + if ( ! sIsOperational ) + return; + + for( int i = 0; i < 5000; ++i ) + nativeupdate(); + + shutdown(); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/Log.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/Log.java new file mode 100644 index 0000000..95e586c --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/directinput/Log.java @@ -0,0 +1,34 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 29. Oktober 2002, 22:57 +//********************************************************************************************** +package de.hardcode.jxinput.directinput; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author Herkules + */ +public class Log +{ + public final static Logger logger = Logger.getLogger( Log.class.getPackage().getName() ); + +// static +// { +// logger.setLevel( Level.ALL ); +// } + + /** + * Creates a new instance of Log. + */ + private Log() + { + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputAxisEvent.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputAxisEvent.java new file mode 100644 index 0000000..c353b5e --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputAxisEvent.java @@ -0,0 +1,48 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:33 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +import de.hardcode.jxinput.JXInputDevice; +import de.hardcode.jxinput.Axis; + +/** + * Represents an event coming from an axis. + * @author Joerg Plewe + */ +public class JXInputAxisEvent +{ + private final Axis mAxis; + double mDelta; + + /** + * Creates a new instance of JXInputEvent. + */ + JXInputAxisEvent( Axis axis ) + { + mAxis = axis; + } + + /** + * The feature that caused the event. + */ + public final Axis getAxis() + { + return mAxis; + } + + + /** + * Return the change in value that caused the event. + */ + public double getDelta() + { + return mDelta; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputAxisEventListener.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputAxisEventListener.java new file mode 100644 index 0000000..d8adf46 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputAxisEventListener.java @@ -0,0 +1,19 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:54 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +/** + * + * @author Herkules + */ +public interface JXInputAxisEventListener +{ + void changed( JXInputAxisEvent ev ); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputButtonEvent.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputButtonEvent.java new file mode 100644 index 0000000..d82d0b9 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputButtonEvent.java @@ -0,0 +1,38 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:33 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +import de.hardcode.jxinput.JXInputDevice; +import de.hardcode.jxinput.Button; + +/** + * Represents event coming from a button. + * @author Joerg Plewe + */ +public class JXInputButtonEvent +{ + final Button mButton; + + /** + * Creates a new instance of JXInputEvent. + */ + JXInputButtonEvent( Button button ) + { + mButton = button; + } + + /** + * The feature that caused the event. + */ + public final Button getButton() + { + return mButton; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputButtonEventListener.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputButtonEventListener.java new file mode 100644 index 0000000..afdc323 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputButtonEventListener.java @@ -0,0 +1,19 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:54 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +/** + * + * @author Herkules + */ +public interface JXInputButtonEventListener +{ + void changed( JXInputButtonEvent ev ); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputDirectionalEvent.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputDirectionalEvent.java new file mode 100644 index 0000000..70e6bcd --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputDirectionalEvent.java @@ -0,0 +1,56 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:33 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +import de.hardcode.jxinput.JXInputDevice; +import de.hardcode.jxinput.Directional; + +/** + * Represents an event coming from an axis. + * @author Joerg Plewe + */ +public class JXInputDirectionalEvent +{ + private final Directional mDirectional; + double mValueDelta; + int mDirectionDelta; + + /** + * Creates a new instance of JXInputEvent. + */ + JXInputDirectionalEvent( Directional directional ) + { + mDirectional = directional; + } + + /** + * The feature that caused the event. + */ + public final Directional getDirectional() + { + return mDirectional; + } + + /** + * Return the change in value that caused the event. + */ + public double getValueDelta() + { + return mValueDelta; + } + + /** + * Return the change in direction that caused the event. + */ + public int getDirectionDelta() + { + return mDirectionDelta; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputDirectionalEventListener.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputDirectionalEventListener.java new file mode 100644 index 0000000..65c7efa --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputDirectionalEventListener.java @@ -0,0 +1,19 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:54 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +/** + * + * @author Herkules + */ +public interface JXInputDirectionalEventListener +{ + void changed( JXInputDirectionalEvent ev ); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputEventManager.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputEventManager.java new file mode 100644 index 0000000..aa196d7 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/event/JXInputEventManager.java @@ -0,0 +1,284 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 31. Januar 2002, 23:42 +//********************************************************************************************** +package de.hardcode.jxinput.event; + +import de.hardcode.jxinput.JXInputManager; +import de.hardcode.jxinput.JXInputDevice; + +import java.util.ArrayList; +import de.hardcode.jxinput.Axis; +import java.util.Iterator; +import de.hardcode.jxinput.Button; +import de.hardcode.jxinput.Directional; + +/** + * Handles all events and listeners. + * JXInputEventManager is layed out a static singleton. + * @author Herkules + */ +public class JXInputEventManager +{ + + private final static ArrayList mAxisEventListeners = new ArrayList(); + private final static ArrayList mButtonEventListeners = new ArrayList(); + private final static ArrayList mDirectionalEventListeners = new ArrayList(); + + private static autotrigger mAutoTrigger = null; + + /** + * Inner class combining a listener with its scheduling parameters. + */ + private static class axislistener + { + final JXInputAxisEventListener mListener; + final double mTreshold; + final JXInputAxisEvent mEvent; + double mLastValueFired = 0.0; + + axislistener( JXInputAxisEventListener l, Axis axis, double treshold ) + { + mListener = l; + mTreshold = treshold; + mEvent = new JXInputAxisEvent( axis ); + } + + final void checkTrigger() + { + double curval = mEvent.getAxis().getValue(); + double delta = curval - mLastValueFired; + + if ( Math.abs( delta ) >= mTreshold ) + { + mLastValueFired = curval; + mEvent.mDelta = delta; + mListener.changed( mEvent ); + } + } + } + + /** + * Inner class combining a listener with its scheduling parameters. + */ + private static class buttonlistener + { + final JXInputButtonEventListener mListener; + final JXInputButtonEvent mEvent; + boolean mLastValueFired = false; + + buttonlistener( JXInputButtonEventListener l, Button button ) + { + mListener = l; + mEvent = new JXInputButtonEvent( button ); + } + + final void checkTrigger() + { + boolean curstate = mEvent.getButton().getState(); + if ( curstate != mLastValueFired ) + { + mLastValueFired = curstate; + mListener.changed( mEvent ); + } + } + } + + + private static class directionallistener + { + final JXInputDirectionalEventListener mListener; + final double mValueTreshold; + final JXInputDirectionalEvent mEvent; + double mLastValueFired = 0.0; + boolean mLastCenteredFired = true; + int mLastDirectionFired = 0; + + directionallistener( JXInputDirectionalEventListener l, Directional directional, double valuetreshold ) + { + mListener = l; + mValueTreshold = valuetreshold; + mEvent = new JXInputDirectionalEvent( directional ); + } + + final void checkTrigger() + { + double curval = mEvent.getDirectional().getValue(); + int curdir = mEvent.getDirectional().getDirection(); + boolean curctr = mEvent.getDirectional().isCentered(); + + double delta = curval - mLastValueFired; + int dirdelta = curdir - mLastDirectionFired; + boolean centeredchanged = mLastCenteredFired != curctr; + + if ( Math.abs( delta ) >= mValueTreshold + || Math.abs( dirdelta ) > 0 + || centeredchanged ) + { + mLastValueFired = curval; + mLastDirectionFired = curdir; + mLastCenteredFired = curctr; + + mEvent.mValueDelta = delta; + mEvent.mDirectionDelta = dirdelta; + mListener.changed( mEvent ); + } + } + } + + /** + * Creates a new instance of JXInputEventManager. + */ + private JXInputEventManager() + { + } + + + /** + * Remove all listeners at once. + */ + public static void reset() + { + mAxisEventListeners.clear(); + mButtonEventListeners.clear(); + mDirectionalEventListeners.clear(); + } + + + /** + * Query devices and fire all occuring events. + * trigger() is thought to be called by JXInputManager#updateFeatures(). + */ + public static void trigger() + { + int n = mAxisEventListeners.size(); + for ( int i = 0; i < n; i++ ) + { + axislistener l = (axislistener)mAxisEventListeners.get( i ); + l.checkTrigger(); + } + + n = mButtonEventListeners.size(); + for ( int i = 0; i < n; i++ ) + { + buttonlistener l = (buttonlistener)mButtonEventListeners.get( i ); + l.checkTrigger(); + } + + n = mDirectionalEventListeners.size(); + for ( int i = 0; i < n; i++ ) + { + directionallistener l = (directionallistener)mDirectionalEventListeners.get( i ); + l.checkTrigger(); + } + } + + + private final static class autotrigger extends Thread + { + boolean mFinish = false; + final int mDelay; + + autotrigger( int delay ) + { + mDelay = delay; + } + + public void run() + { + while ( ! mFinish ) + { + try + { + Thread.sleep( mDelay ); + JXInputManager.updateFeatures(); + } + catch ( InterruptedException ex ) + { + } + } + } + } + + + /** + * Set the intervall in ms that is used to check for new values of the features. + * Set it to <= 0 to prohibit automatic triggering. Events will then only be fired + * when somebody invokes JXInputManager#updateFeatures(). + */ + public static void setTriggerIntervall( int ms ) + { + // + // Kill current thread, if any + // + if ( null != mAutoTrigger ) + { + mAutoTrigger.mFinish = true; + try + { + mAutoTrigger.join(); + } + catch ( InterruptedException ex ) + { + } + } + + mAutoTrigger = null; + + if ( ms > 0 ) + { + mAutoTrigger = new autotrigger( ms ); + mAutoTrigger.start(); + } + + } + + + + + public static void addListener( JXInputAxisEventListener l, Axis axis, double treshold ) + { + mAxisEventListeners.add( new JXInputEventManager.axislistener( l, axis, treshold ) ); + } + + public static void addListener( JXInputAxisEventListener l, Axis axis ) + { + mAxisEventListeners.add( new JXInputEventManager.axislistener( l, axis, axis.getResolution() ) ); + } + + public static void removeListener( JXInputAxisEventListener l ) + { + mAxisEventListeners.remove( l ); + } + + + public static void addListener( JXInputButtonEventListener l, Button button ) + { + mButtonEventListeners.add( new JXInputEventManager.buttonlistener( l, button ) ); + } + + public static void removeListener( JXInputButtonEventListener l ) + { + mButtonEventListeners.remove( l ); + } + + public static void addListener( JXInputDirectionalEventListener l, Directional directional, double valuetreshold ) + { + mDirectionalEventListeners.add( new JXInputEventManager.directionallistener( l, directional, valuetreshold ) ); + } + + public static void addListener( JXInputDirectionalEventListener l, Directional directional ) + { + mDirectionalEventListeners.add( new JXInputEventManager.directionallistener( l, directional, directional.getResolution() ) ); + } + + public static void removeListener( JXInputDirectionalEventListener l ) + { + mDirectionalEventListeners.remove( l ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/DeviceConfiguration.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/DeviceConfiguration.java new file mode 100644 index 0000000..8c1288a --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/DeviceConfiguration.java @@ -0,0 +1,95 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 23. Februar 2002, 14:05 +//********************************************************************************************** +package de.hardcode.jxinput.j3d; + +import de.hardcode.jxinput.Axis; + + +/** + * Connects JXInput with J3DInputDevice. + * + * @author Herkules + */ +public class DeviceConfiguration +{ + public final static int AXIS_X = 0; + public final static int AXIS_Y = 1; + public final static int AXIS_Z = 2; + + private final static class axisvalue + { + private final Axis mAxis; + private final IsActiveCondition mIsActive; + private final IsActiveCondition mIsIncremental; + private final double mScale; + private final double mOffset; + private double mValue; + + axisvalue( Axis axis, IsActiveCondition active, IsActiveCondition incremental, double offset, double scale ) + { + mAxis = axis; + mIsActive = active; + mIsIncremental = incremental; + mValue = mOffset = offset; + mScale = scale; + } + + double value() + { + if ( mIsActive.isActive() ) + { + double newval = mAxis.getValue() * mScale; + + if ( mIsIncremental.isActive() ) + mValue += newval; + else + mValue = newval + mOffset; + } + return mValue; + } + } + + DeviceConfiguration.axisvalue [] mAxisTrans = new DeviceConfiguration.axisvalue[ 3 ]; + DeviceConfiguration.axisvalue [] mAxisRot = new DeviceConfiguration.axisvalue[ 3 ]; + + /** + * Creates a new instance of DeviceConfiguration. + */ + public DeviceConfiguration() + { + } + + + double getTranslational( int axisid ) + { + DeviceConfiguration.axisvalue val = mAxisTrans[ axisid ]; + return null == val ? 0.0 : val.value(); + } + + double getRotational( int axisid ) + { + DeviceConfiguration.axisvalue val = mAxisRot[ axisid ]; + return null == val ? 0.0 : val.value(); + } + + public void setTranslational( int axisid, Axis axis, IsActiveCondition active, IsActiveCondition incremental, double offset, double scale ) + { + if ( axisid < 0 || axisid > AXIS_Z ) + throw new IllegalArgumentException(); + mAxisTrans[ axisid ] = new DeviceConfiguration.axisvalue( axis, active, incremental, offset, scale ); + } + + public void setRotational( int axisid, Axis axis, IsActiveCondition active, IsActiveCondition incremental, double offset, double scale ) + { + if ( axisid < 0 || axisid > AXIS_Z ) + throw new IllegalArgumentException(); + mAxisRot[ axisid ] = new DeviceConfiguration.axisvalue( axis, active, incremental, offset, scale ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsActiveCondition.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsActiveCondition.java new file mode 100644 index 0000000..af6ca08 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsActiveCondition.java @@ -0,0 +1,25 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 25. Februar 2002, 22:41 +//********************************************************************************************** +package de.hardcode.jxinput.j3d; + +/** + * + * @author Herkules + */ +public interface IsActiveCondition +{ + public final static IsActiveCondition ALWAYS = IsAlwaysActiveCondition.ALWAYS; + public final static IsActiveCondition NEVER = IsAlwaysActiveCondition.NEVER; + + /** + * Tell wether a certain thing is active. + */ + boolean isActive(); +} + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsActiveOnButtonCondition.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsActiveOnButtonCondition.java new file mode 100644 index 0000000..98da7bb --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsActiveOnButtonCondition.java @@ -0,0 +1,39 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 25. Februar 2002, 22:43 +//********************************************************************************************** +package de.hardcode.jxinput.j3d; + +import de.hardcode.jxinput.Button; + +/** + * + * @author Herkules + */ +public class IsActiveOnButtonCondition implements IsActiveCondition +{ + private final boolean mActiveState; + private final Button mButton; + + /** + * Creates a new instance of IsAlwayActiveCondition. + */ + public IsActiveOnButtonCondition( Button button, boolean activestate ) + { + mActiveState = activestate; + mButton = button; + } + + /** + * Tell wether a certain thing is active. + */ + public boolean isActive() + { + return mButton.getState() == mActiveState; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsAlwaysActiveCondition.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsAlwaysActiveCondition.java new file mode 100644 index 0000000..cd8b1fe --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/IsAlwaysActiveCondition.java @@ -0,0 +1,38 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 25. Februar 2002, 22:43 +//********************************************************************************************** +package de.hardcode.jxinput.j3d; + +/** + * + * @author Herkules + */ +final class IsAlwaysActiveCondition implements IsActiveCondition +{ + private final boolean mIsActive; + + public final static IsActiveCondition ALWAYS = new IsAlwaysActiveCondition( true ); + public final static IsActiveCondition NEVER = new IsAlwaysActiveCondition( false ); + + /** + * Creates a new instance of IsAlwayActiveCondition. + */ + private IsAlwaysActiveCondition(boolean isactive) + { + mIsActive = isactive; + } + + /** + * Tell wether a certain thing is active. + */ + public boolean isActive() + { + return mIsActive; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/J3DInputDevice.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/J3DInputDevice.java new file mode 100644 index 0000000..f5b08f2 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/J3DInputDevice.java @@ -0,0 +1,171 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 22. Februar 2002, 13:21 +//********************************************************************************************** +package de.hardcode.jxinput.j3d; + +import javax.media.j3d.InputDevice; +import javax.media.j3d.Sensor; +import javax.media.j3d.SensorRead; +import javax.vecmath.Vector3d; +import javax.media.j3d.Transform3D; +import de.hardcode.jxinput.JXInputManager; + + +/** + * Implementation of Java3D's InputDevice + * + * @author Herkules + */ +public class J3DInputDevice + implements InputDevice +{ + private Vector3d mPosition = new Vector3d(); + private Transform3D mNewTransform = new Transform3D(); + + private Transform3D mRotTransX = new Transform3D(); + private Transform3D mRotTransY = new Transform3D(); + private Transform3D mRotTransZ = new Transform3D(); + + private Vector3d mInitPos = new Vector3d( 0.0, 0.0, 0.0 ); + + private Sensor mSensor = new Sensor( this ); + private SensorRead mSensorRead = new SensorRead(); + + private DeviceConfiguration mConfig; + + /** + * Creates a new instance of J3DInputDevice. + */ + public J3DInputDevice( DeviceConfiguration config ) + { + mConfig = config; + setNominalPositionAndOrientation(); + } + + + public void close() + { + // Intentionally empty + } + + + /** + * Retrieve processing mode. + * For this device, it always is NON_BLOCKING. + */ + public int getProcessingMode() + { + return InputDevice.NON_BLOCKING; + } + + + /** + * Don't care for the index, I only support one sensor. + * And I deliver that. + */ + public Sensor getSensor( int param ) + { + return mSensor; + } + + + /** + * Tell the world about the only one sensor I support. + */ + public int getSensorCount() + { + return 1; + } + + + /** + * Well - initialize! + * Nothing to do here. + */ + public boolean initialize() + { + return true; + } + + + /** + * The main update method. + */ + public void pollAndProcessInput() + { + JXInputManager.updateFeatures(); + + mSensorRead.setTime( JXInputManager.getLastUpdateTime() ); + + mRotTransX.rotX( mConfig.getRotational( DeviceConfiguration.AXIS_X ) ); + mRotTransY.rotY( mConfig.getRotational( DeviceConfiguration.AXIS_Y ) ); + mRotTransZ.rotZ( mConfig.getRotational( DeviceConfiguration.AXIS_Z ) ); + + mPosition.set( + mConfig.getTranslational( DeviceConfiguration.AXIS_X ), + mConfig.getTranslational( DeviceConfiguration.AXIS_Y ), + mConfig.getTranslational( DeviceConfiguration.AXIS_Z ) + ); + + mNewTransform.set( mPosition ); + + mNewTransform.mul( mRotTransX ); + mNewTransform.mul( mRotTransY ); + mNewTransform.mul( mRotTransZ ); + + mSensorRead.set( mNewTransform ); + mSensor.setNextSensorRead( mSensorRead ); + } + + + /** + * Not called by current j3d implementation. + */ + public void processStreamInput() + { + // Intentionally empty + } + + + /** + * Reset state. + */ + public void setNominalPositionAndOrientation() + { + mSensorRead.setTime( JXInputManager.getLastUpdateTime() ); + + mRotTransX.rotX( 0.0 ); + mRotTransY.rotY( 0.0 ); + mRotTransZ.rotZ( 0.0 ); + + mPosition.set( mInitPos ); + + mNewTransform.set( mPosition ); + + mNewTransform.mul( mRotTransX ); + mNewTransform.mul( mRotTransY ); + mNewTransform.mul( mRotTransZ ); + + mSensorRead.set( mNewTransform ); + mSensor.setNextSensorRead( mSensorRead ); + + } + + + /** + * Set the processing mode. + * Only NON_BLOCKING is allowed! + */ + public void setProcessingMode(int param) + { + if ( param != InputDevice.NON_BLOCKING ) + throw new IllegalArgumentException("Processing mode must be NON_BLOCKING"); + + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/package.html b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/package.html new file mode 100644 index 0000000..9b92964 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/package.html @@ -0,0 +1,11 @@ + + + + + + + +Connecting JXInput to Java3D by implementing the interface +javax.media.j3d.InputDevice. + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/test/HelloUniverse.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/test/HelloUniverse.java new file mode 100644 index 0000000..fde34bc --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/test/HelloUniverse.java @@ -0,0 +1,205 @@ + +/* + * @(#)HelloUniverse.java 1.15 02/02/07 14:48:36 + * + * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES + * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN + * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR + * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that Software is not designed,licensed or intended + * for use in the design, construction, operation or maintenance of + * any nuclear facility. + */ + +package de.hardcode.jxinput.j3d.test; + + +import java.applet.Applet; +import java.awt.*; +import java.awt.event.*; +import com.sun.j3d.utils.applet.MainFrame; +import com.sun.j3d.utils.geometry.ColorCube; +import com.sun.j3d.utils.universe.*; +import javax.media.j3d.*; +import javax.vecmath.*; +import de.hardcode.jxinput.j3d.DeviceConfiguration; +import de.hardcode.jxinput.Axis; +import de.hardcode.jxinput.JXInputManager; +import de.hardcode.jxinput.j3d.IsActiveCondition; +import de.hardcode.jxinput.j3d.J3DInputDevice; +import de.hardcode.jxinput.j3d.IsActiveOnButtonCondition; + + +public class HelloUniverse extends Applet +{ + + private SimpleUniverse u = null; + TransformGroup objTrans; + + public BranchGroup createSceneGraph() + { + BranchGroup objRoot = new BranchGroup(); + objTrans = new TransformGroup(); + objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + objTrans.addChild(new ColorCube(0.4)); + +// Transform3D yAxis = new Transform3D(); +// Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, +// 0, 0, +// 4000, 0, 0, +// 0, 0, 0); +// RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, +// 0.0f, (float) Math.PI*2.0f); +// BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); +// rotator.setSchedulingBounds(bounds); +// objTrans.addChild(rotator); + return objRoot; + } + + + public HelloUniverse() + { + + } + + public void init() + { + // These are the string arguments given to the VirtualInputDevice + // constructor. These are settable parameters. Look in the + // VirtualInputDevice constructor for a complete list. + String[] args = new String[10]; + args[0] = "printvalues"; + args[1] = "true"; + args[2] = "yscreeninitloc"; + args[3] = "50"; + args[4] = null; + + + // now create the HelloUniverse Canvas + setLayout(new BorderLayout()); + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + add("Center", c); + + // Create a simple scene and attach it to the virtual universe + BranchGroup scene = createSceneGraph(); + u = new SimpleUniverse(c); + + // + // Use the inputdevice + // + InputDevice device = createInputDevice(); + + // Register the VirtualInputDevice with Java 3D + u.getViewer().getPhysicalEnvironment().addInputDevice( device ); + +// TransformGroup viewTrans = u.getViewingPlatform().getViewPlatformTransform(); + + // Put the behavoir to teh object + SensorBehavior s = new SensorBehavior( objTrans, device.getSensor(0) ); + s.setSchedulingBounds( new BoundingSphere( new Point3d(0.0,0.0,0.0), Float.MAX_VALUE ) ); + objTrans.addChild( s ); + + u.getViewingPlatform().setNominalViewingTransform(); + u.addBranchGraph(scene); + } + + public void destroy() + { + u.removeAllLocales(); + } + + + /** + * Setup an input device. + */ + private InputDevice createInputDevice() + { + IsActiveCondition button1down = new IsActiveOnButtonCondition(JXInputManager.getJXInputDevice( 0 ).getButton( 0 ), true ); + IsActiveCondition button1up = new IsActiveOnButtonCondition(JXInputManager.getJXInputDevice( 0 ).getButton( 0 ), false ); + + Axis xaxis = JXInputManager.getJXInputDevice( 0 ).getAxis( Axis.ID_X ); + Axis yaxis = JXInputManager.getJXInputDevice( 0 ).getAxis( Axis.ID_Y ); + + DeviceConfiguration cnf = new DeviceConfiguration(); + + // + // Setup the configuration to use joysticks x/y for rotation is not button is pressed + // and for translation if button1 is pressed. + // + cnf.setRotational( + DeviceConfiguration.AXIS_Y, + xaxis, + button1up, + IsActiveCondition.NEVER, + 0.0, Math.PI + ); + + cnf.setRotational( + DeviceConfiguration.AXIS_X, + yaxis, + button1up, + IsActiveCondition.NEVER, + 0.0, Math.PI + ); + + cnf.setTranslational( + DeviceConfiguration.AXIS_Z, + yaxis, + button1down, + IsActiveCondition.NEVER, + -5.0, 4.0 + ); + cnf.setTranslational( + DeviceConfiguration.AXIS_X, + xaxis, + button1down, + IsActiveCondition.NEVER, + 0.0, 4.0 + ); + + // We have the config, create the device... + J3DInputDevice d = new J3DInputDevice( cnf ); + + // The InputDevice must be initialized before registering it + // with the PhysicalEnvironment object. + d.initialize(); + + return d; + } + + + public static void main(String[] args) + { + new MainFrame(new HelloUniverse(), 350, 350); + } +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/test/SensorBehavior.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/test/SensorBehavior.java new file mode 100644 index 0000000..6836ebb --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/j3d/test/SensorBehavior.java @@ -0,0 +1,70 @@ +package de.hardcode.jxinput.j3d.test; + +/* + * @(#)SensorBehavior.java 1.8 02/02/07 14:48:34 + * + * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES + * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR + * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN + * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR + * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR + * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF + * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, + * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that Software is not designed,licensed or intended + * for use in the design, construction, operation or maintenance of + * any nuclear facility. + */ + +import javax.media.j3d.*; +import java.util.*; + +public class SensorBehavior extends Behavior +{ + private WakeupOnElapsedFrames conditions = new WakeupOnElapsedFrames(0); + private TransformGroup transformGroup; + private Sensor sensor; + private Transform3D transform = new Transform3D(); + + public SensorBehavior( TransformGroup tg, Sensor sensor ) + { + transformGroup = tg; + this.sensor = sensor; + } + + public void initialize() + { + wakeupOn( conditions ); + } + + public void processStimulus( Enumeration criteria ) + { + sensor.getRead( transform ); + transformGroup.setTransform( transform ); + wakeupOn( conditions ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/InvalidKeyCodeException.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/InvalidKeyCodeException.java new file mode 100644 index 0000000..f44ee6b --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/InvalidKeyCodeException.java @@ -0,0 +1,35 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 16. April 2002, 23:31 +//********************************************************************************************** +package de.hardcode.jxinput.keyboard; + +/** + * Exeception to be thrown if keycode is not in then range [0,255]. + * + * @author Herkules + */ +public class InvalidKeyCodeException + extends IllegalArgumentException +{ + + /** + * Creates a new instance of InvalidKeyCodeException. + */ + public InvalidKeyCodeException() + { + } + + + /** + * Creates a new instance of InvalidKeyCodeException. + */ + public InvalidKeyCodeException( String s ) + { + super( s ); + } +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/JXKeyboardInputDevice.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/JXKeyboardInputDevice.java new file mode 100644 index 0000000..858bdb7 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/JXKeyboardInputDevice.java @@ -0,0 +1,175 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 9. April 2002, 22:40 +//********************************************************************************************** +package de.hardcode.jxinput.keyboard; + + +import de.hardcode.jxinput.*; +import java.awt.Component; + + +/** + * Virtual input device treating a AWT keyboard as a source for Buttons. + * + * @author Herkules + */ +public class JXKeyboardInputDevice + implements JXInputDevice +{ + private static final String DEVICENAME = "Swing Keyboard"; + + /** The driver doing all the real work. */ + private final KeyboardDriver mDriver = new KeyboardDriver(); + + /** The Component I am listening to. */ + private Component mComponent = null; + + /** Hold the biggest keycode for which a button has been created. */ + private int mMaxIdxCreated = 0; + + + /** + * Creates a new instance of JXKeyboardInputDevice. + */ + public JXKeyboardInputDevice() + { + } + + + /** + * Creates a new instance of JXKeyboardInputDevice + * immediately listening to a JComponent. + */ + public JXKeyboardInputDevice( Component comp ) + { + listenTo( comp ); + } + + /** + * Makes this device listen to a certain JComponent. + */ + public final void listenTo( Component comp ) + { + shutdown(); + mComponent = comp; + mComponent.addKeyListener( mDriver ); + } + + /** + * Shut down. No longer listen to my JComponent. + */ + public final void shutdown() + { + if ( null != mComponent ) + mComponent.removeKeyListener( mDriver ); + } + + + /** + * Create a button object for a certain keycode. + */ + public Button createButton( int keycode ) + { + if ( 0 > keycode || 0x100 < keycode ) + throw new InvalidKeyCodeException(); + + KeyButton b; + if ( null == (b = mDriver.getButton( keycode ) ) ) + { + b = new KeyButton( keycode ); + mDriver.registerKeyButton( b ); + if ( keycode > mMaxIdxCreated ) + mMaxIdxCreated = keycode; + } + return b; + } + + + public void removeButton( Button b ) + { + mDriver.unregisterKeyButton( (KeyButton) b ); + } + + + + //********************************************************************************************* + // + // Implement JXInputDevice + // + //********************************************************************************************* + + public Axis getAxis(int idx) + { + // No axes on keyboard. + return null; + } + + + public Button getButton(int idx) + { + // idx is interpreted as the keycode + return mDriver.getButton( idx ); + } + + public Directional getDirectional(int idx) + { + // No directionals on keyboard. + return null; + } + + /** Maximum number of axes as an upper bound for index values. */ + public int getMaxNumberOfAxes() + { + // No axes on keyboard. + return 0; + } + + /** Maximum number of buttons as an upper bound for index values. */ + public int getMaxNumberOfButtons() + { + // Return biggest keycode (inclusive). + return mMaxIdxCreated + 1; + } + + /** Maximum number of directional features as an upper bound for index values. */ + public int getMaxNumberOfDirectionals() + { + // No directionals on keyboard. + return 0; + } + + /** + * Devices may have a name. + * This name might be provided by a system dependant driver. + */ + public String getName() + { + return DEVICENAME; + } + + /** Actual number of available axes. */ + public int getNumberOfAxes() + { + // No axes on keyboard. + return 0; + } + + /** Actual number of available buttons. */ + public int getNumberOfButtons() + { + return mDriver.getNumberOfButtons(); + } + + /** Actual number of available directional features. */ + public int getNumberOfDirectionals() + { + // No directionals on keyboard. + return 0; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/KeyButton.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/KeyButton.java new file mode 100644 index 0000000..3fd7130 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/KeyButton.java @@ -0,0 +1,94 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 9. April 2002, 22:51 +//********************************************************************************************** +package de.hardcode.jxinput.keyboard; + +import de.hardcode.jxinput.Button; +import java.awt.event.KeyEvent; + + +/** + * Associates a keycode with a Button and handles the current state of that button. + * + * @author Herkules + */ +class KeyButton + implements Button +{ + private final int mKeyCode; + private boolean mIsPressed; + private boolean mHasChanged; + + /** + * Creates a new instance of KeyButton. + */ + public KeyButton( int keycode ) + { + mKeyCode = keycode; + } + + + /** + * Return the keycode assigned with this button. + */ + public final int getKeyCode() + { + return mKeyCode; + } + + final void setIsPressed( boolean flag ) + { + mIsPressed = flag; + } + + //********************************************************************************************* + // + // Implement Button + // + //********************************************************************************************* + + + /** + * Features may have a name provided e.g. by the driver. + */ + public String getName() + { + return KeyEvent.getKeyText( mKeyCode ); + } + + /** + * Tells the state of the button at last update. + */ + public boolean getState() + { + return mIsPressed; + } + + /** + * Retrieve the type of the button. + * Pushbutton will deliver true==getState() as long as they are pressed down. + * Togglebuttons will change their state once they are pressed and keep that state + * until they are pressed again. + * @return [ PUSHBUTTON | TOGGLEBUTTON ] + */ + public int getType() + { + return Button.PUSHBUTTON; + } + + + /** + * Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + public boolean hasChanged() + { + return true; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/KeyboardDriver.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/KeyboardDriver.java new file mode 100644 index 0000000..7eb6232 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/KeyboardDriver.java @@ -0,0 +1,141 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 9. April 2002, 22:43 +//********************************************************************************************** +package de.hardcode.jxinput.keyboard; + +import java.awt.event.KeyListener; +import java.awt.event.KeyEvent; +import java.util.HashMap; +import java.security.InvalidParameterException; + + + +/** + * Listen to a JComponent handle handle all associated button objects. + * This is the main worker class for JXKeyboardInputDevice. + * + * @author Herkules + */ +class KeyboardDriver implements KeyListener +{ +// HashMap mKeysToObserveMap = new HashMap(); + + int mNumberOfKeysObserved = 0; + KeyButton [] mKeysObserved = new KeyButton [ 0x100 ]; + + + /** + * Creates a new instance of KeyboardDriver. + */ + public KeyboardDriver() + { + } + + + /** + * How many buttons are registered? + */ + final int getNumberOfButtons() + { + return mNumberOfKeysObserved; +// return mKeysToObserveMap.size(); + } + + + /** + * Place a new button under my observation. + */ + final boolean registerKeyButton( KeyButton b ) + { + final int keycode = b.getKeyCode(); + + if ( 0 > keycode || 0x100 < keycode ) + throw new InvalidKeyCodeException(); + + if ( null == mKeysObserved[ keycode ] ) + { + mKeysObserved[ keycode ] = b; + mNumberOfKeysObserved++; + return true; + } + else + { + return false; + } + +// Integer code = new Integer( b.getKeyCode() ); +// if ( ! mKeysToObserveMap.containsKey( code ) ) +// { +// mKeysToObserveMap.put( code, b ); +// return true; +// } +// else +// { +// return false; +// } + } + + final void unregisterKeyButton( KeyButton b ) + { + final int keycode = b.getKeyCode(); + + if ( 0 > keycode || 0x100 < keycode ) + throw new InvalidKeyCodeException(); + + if ( null != mKeysObserved[ b.getKeyCode() ] ) + { + mKeysObserved[ keycode ] = null; + mNumberOfKeysObserved--; + } + +// Integer code = new Integer( b.getKeyCode() ); +// mKeysToObserveMap.remove( code ); + } + + + /** + * Retrieve the button from its keycode. + */ + final KeyButton getButton( int keycode ) + { + if ( 0 > keycode || 0x100 < keycode ) + throw new InvalidKeyCodeException(); + + return mKeysObserved[ keycode ]; + +// Integer code = new Integer( keycode ); +// return (KeyButton)mKeysToObserveMap.get( code ); + } + + + //********************************************************************************************* + // + // Implement KeyListener + // + //********************************************************************************************* + + public void keyPressed( KeyEvent keyEvent ) + { + KeyButton b = getButton( keyEvent.getKeyCode() ); + if ( null != b ) + b.setIsPressed( true ); + } + + public void keyReleased( KeyEvent keyEvent ) + { + KeyButton b = getButton( keyEvent.getKeyCode() ); + if ( null != b ) + b.setIsPressed( false ); + } + + public void keyTyped( KeyEvent keyEvent ) + { + // Intentionally empty. + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/package.html b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/package.html new file mode 100644 index 0000000..e1021d1 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/keyboard/package.html @@ -0,0 +1,10 @@ + + + + + de.hardcode.jxinput.keyboard + + +Connects Swing keyboard handling to the JXInput infrastructure. + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/AxisListener.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/AxisListener.java new file mode 100644 index 0000000..7d2b138 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/AxisListener.java @@ -0,0 +1,39 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 20. Februar 2002, 22:19 +//********************************************************************************************** +package de.hardcode.jxinput.test; + +import de.hardcode.jxinput.event.JXInputEventManager; +import de.hardcode.jxinput.event.JXInputAxisEventListener; +import de.hardcode.jxinput.event.JXInputAxisEvent; +import de.hardcode.jxinput.Axis; + +/** + * Example listener to an axis. + * + * @author Herkules + */ +public class AxisListener + implements JXInputAxisEventListener +{ + + /** + * Creates a new instance of AxisListener. + */ + public AxisListener( Axis axis ) + { + JXInputEventManager.addListener( this, axis, 0.1 ); + } + + + public void changed( JXInputAxisEvent ev ) + { + System.out.println( "Axis " + ev.getAxis().getName() + " changed : value=" + ev.getAxis().getValue() + ", event causing delta=" + ev.getDelta() ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/ButtonListener.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/ButtonListener.java new file mode 100644 index 0000000..604002d --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/ButtonListener.java @@ -0,0 +1,38 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 20. Februar 2002, 22:19 +//********************************************************************************************** +package de.hardcode.jxinput.test; + +import de.hardcode.jxinput.event.JXInputEventManager; +import de.hardcode.jxinput.event.JXInputButtonEventListener; +import de.hardcode.jxinput.event.JXInputButtonEvent; +import de.hardcode.jxinput.Button; + +/** + * Sample button listener. + * + * @author Herkules + */ +public class ButtonListener implements JXInputButtonEventListener +{ + + /** + * Creates a new instance of AxisListener. + */ + public ButtonListener( Button button ) + { + JXInputEventManager.addListener( this, button ); + } + + + public void changed( JXInputButtonEvent ev ) + { + System.out.println( "Button " + ev.getButton().getName() + " changed : state=" + ev.getButton().getState() ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/DirectionalListener.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/DirectionalListener.java new file mode 100644 index 0000000..9f79796 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/DirectionalListener.java @@ -0,0 +1,37 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 20. Februar 2002, 22:19 +//********************************************************************************************** +package de.hardcode.jxinput.test; + +import de.hardcode.jxinput.event.JXInputEventManager; +import de.hardcode.jxinput.event.JXInputDirectionalEventListener; +import de.hardcode.jxinput.event.JXInputDirectionalEvent; +import de.hardcode.jxinput.Directional; + +/** + * Sample directional listener. + * + * @author Herkules + */ +public class DirectionalListener implements JXInputDirectionalEventListener +{ + /** + * Creates a new instance of AxisListener. + */ + public DirectionalListener( Directional directional ) + { + JXInputEventManager.addListener( this, directional, 1.0 ); + } + + + public void changed( JXInputDirectionalEvent ev ) + { + System.out.println( "Directional " + ev.getDirectional().getName() + " changed : direction=" + ev.getDirectional().getDirection() + ", value=" + ev.getDirectional().getValue() + ", event causing delta=" + ev.getDirectionDelta() ); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputDevicePanel.form b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputDevicePanel.form new file mode 100644 index 0000000..fe9f69e --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputDevicePanel.form @@ -0,0 +1,97 @@ + + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputDevicePanel.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputDevicePanel.java new file mode 100644 index 0000000..81fbef3 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputDevicePanel.java @@ -0,0 +1,296 @@ +/* + * JXInputDevicePanel.java + * + * Created on 23. Januar 2002, 22:19 + */ +package de.hardcode.jxinput.test; + +import de.hardcode.jxinput.JXInputManager; +import de.hardcode.jxinput.JXInputDevice; +import de.hardcode.jxinput.Axis; +import de.hardcode.jxinput.Directional; +import de.hardcode.jxinput.Button; + +import javax.swing.*; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.Iterator; +import java.awt.BorderLayout; +import java.awt.Font; +import java.util.Dictionary; +import java.util.Enumeration; + +/** + * + * @author Herkules + */ +public class JXInputDevicePanel extends javax.swing.JPanel +{ + private static final Font AXIS_SLIDER_FONT = new Font( "Verdana", Font.PLAIN, 9 ); + + private final JXInputDevice mDev; + private final ArrayList mAxisSliders = new ArrayList(); + private final ArrayList mButtonCheckboxes = new ArrayList(); + private final ArrayList mDirectionalLabels = new ArrayList(); + + + /** Creates new form JXInputDevicePanel */ + public JXInputDevicePanel( JXInputDevice dev ) + { + mDev = dev; + initComponents(); + initFromDevice(); + } + + /** + * Helper class connecting a JSlider with an Axis. + */ + private class AxisSlider extends JSlider + { + Axis mAxis; + AxisSlider( Axis axis ) + { + super( ( Axis.SLIDER == axis.getType() ? 0 : -100 ), 100 ); + this.setMajorTickSpacing( Axis.SLIDER == axis.getType() ? 25 : 50 ); + this.setMinorTickSpacing( 5 ); + this.setPaintTicks( true ); + this.setPaintLabels( true ); + this.setEnabled( false ); + + Dictionary labeldict = this.getLabelTable(); + Enumeration labels = labeldict.elements(); + while ( labels.hasMoreElements() ) + { + JLabel label = (JLabel)labels.nextElement(); + label.setFont( AXIS_SLIDER_FONT ); + label.setSize( 32, 12 ); + label.setHorizontalAlignment( SwingConstants.LEFT ); + } + + mAxis = axis; + } + + void update() + { + int ax = (int)(mAxis.getValue() * 100.0); + + // + // Only if value really changes + // + if ( ax != this.getValue() ) + { + this.setValue( ax ); + this.setToolTipText( mAxis.getName() + ": " + Double.toString( mAxis.getValue() ) ); + } + } + + } + + + private class ButtonCheckbox extends JCheckBox + { + Button mButton; + ButtonCheckbox( Button button ) + { + super( button.getName() ); + this.setEnabled( false ); + mButton = button; + } + + void update() + { + boolean state = mButton.getState(); + + // + // Only if value really changes + // + if ( state != this.isSelected() ) + { + this.setSelected( state ); + } + } + } + + + private class DirectionalLabel extends JLabel + { + Directional mDirectional; + int mCurrent = 0; + + DirectionalLabel( Directional directional ) + { + super( directional.getName() ); + mDirectional = directional; + } + + void update() + { + int dir = mDirectional.getDirection(); + + // + // Only if value really changes + // + if ( dir != mCurrent ) + { + this.setText( mDirectional.getName() + ": " + ( mDirectional.isCentered() ? "-" : Integer.toString( dir ) ) ); + mCurrent = dir; + } + } + } + + + /** + * Setup the dialogs content from the JXInputDevice. + */ + void initFromDevice() + { + if ( null != mDev ) + { + ((GridLayout)mAxesPanel.getLayout()).setRows( mDev.getNumberOfAxes() ); + + for ( int i = 0; i < mDev.getMaxNumberOfAxes(); ++i ) + { + if ( null != mDev.getAxis( i ) ) + { + AxisSlider slider = new AxisSlider( mDev.getAxis( i ) ); + + JLabel name = new JLabel( mDev.getAxis( i ).getName() ); + name.setVerticalAlignment( SwingConstants.TOP ); + name.setHorizontalAlignment( SwingConstants.CENTER ); + name.setPreferredSize( new java.awt.Dimension( 90, 0 ) ); + + JPanel p = new JPanel(); + p.setLayout( new BorderLayout() ); + + p.add( name, BorderLayout.WEST ); + p.add( slider, BorderLayout.CENTER ); + + mAxesPanel.add( p ); + + // Add to list of all AxisSlider controls + mAxisSliders.add( slider ); + + // Add an event listener: + new AxisListener( mDev.getAxis( i ) ); + } + } + + + ((GridLayout)mButtonsPanel.getLayout()).setRows( mDev.getNumberOfButtons() ); + for ( int i = 0; i < mDev.getMaxNumberOfButtons(); ++i ) + { + if ( null != mDev.getButton( i ) ) + { + ButtonCheckbox chk = new ButtonCheckbox( mDev.getButton( i ) ); + mButtonCheckboxes.add( chk ); + mButtonsPanel.add( chk ); + + // Add an event listener: + new ButtonListener( mDev.getButton( i ) ); + } + } + + ((GridLayout)mDirectionalPanel.getLayout()).setRows( mDev.getNumberOfDirectionals() / 2 ); + for ( int i = 0; i < mDev.getMaxNumberOfDirectionals(); ++i ) + { + if ( null != mDev.getDirectional( i ) ) + { + DirectionalLabel lbl = new DirectionalLabel( mDev.getDirectional( i ) ); + mDirectionalLabels.add( lbl ); + mDirectionalPanel.add( lbl ); + + // Add an event listener: + new DirectionalListener( mDev.getDirectional( i ) ); + } + } + } + } + + + public void update() + { + Iterator it = mAxisSliders.iterator(); + while ( it.hasNext() ) + { + ((AxisSlider)it.next()).update(); + } + + it = mButtonCheckboxes.iterator(); + while ( it.hasNext() ) + { + ((ButtonCheckbox)it.next()).update(); + } + + it = mDirectionalLabels.iterator(); + while ( it.hasNext() ) + { + ((DirectionalLabel)it.next()).update(); + } + } + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + mAxesPanelContainer = new javax.swing.JPanel(); + mAxesPanel = new javax.swing.JPanel(); + mDirectionalPanel = new javax.swing.JPanel(); + mButtonScrollPane = new javax.swing.JScrollPane(); + mButtonsPanel = new javax.swing.JPanel(); + + setLayout(new java.awt.BorderLayout(2, 2)); + + addComponentListener(new java.awt.event.ComponentAdapter() + { + public void componentShown(java.awt.event.ComponentEvent evt) + { + OnShow(evt); + } + }); + + mAxesPanelContainer.setLayout(new java.awt.BorderLayout()); + + mAxesPanelContainer.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); + mAxesPanel.setLayout(new java.awt.GridLayout(1, 1, 0, 20)); + + mAxesPanelContainer.add(mAxesPanel, java.awt.BorderLayout.NORTH); + + add(mAxesPanelContainer, java.awt.BorderLayout.CENTER); + + mDirectionalPanel.setLayout(new java.awt.GridLayout(1, 1)); + + mDirectionalPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); + add(mDirectionalPanel, java.awt.BorderLayout.SOUTH); + + mButtonsPanel.setLayout(new java.awt.GridLayout(1, 1)); + + mButtonsPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); + mButtonScrollPane.setViewportView(mButtonsPanel); + + add(mButtonScrollPane, java.awt.BorderLayout.EAST); + + }// //GEN-END:initComponents + + private void OnShow(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_OnShow + {//GEN-HEADEREND:event_OnShow + // Commented: the focus is held by a parent component +// System.out.println("OnShow"); +// this.requestFocus(); + }//GEN-LAST:event_OnShow + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel mAxesPanel; + private javax.swing.JPanel mAxesPanelContainer; + private javax.swing.JScrollPane mButtonScrollPane; + private javax.swing.JPanel mButtonsPanel; + private javax.swing.JPanel mDirectionalPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputTestDialog.form b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputTestDialog.form new file mode 100644 index 0000000..1abc589 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputTestDialog.form @@ -0,0 +1,79 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputTestDialog.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputTestDialog.java new file mode 100644 index 0000000..3829aa2 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/test/JXInputTestDialog.java @@ -0,0 +1,286 @@ +//********************************************************************************************** +// Dipl. Phys. Joerg Plewe, HARDCODE Development +// Created on 27. Dezember 2001, 01:15 +//********************************************************************************************** + +package de.hardcode.jxinput.test; + +import de.hardcode.jxinput.*; +import de.hardcode.jxinput.event.*; +import de.hardcode.jxinput.keyboard.JXKeyboardInputDevice; +import de.hardcode.jxinput.virtual.JXVirtualInputDevice; +import de.hardcode.jxinput.virtual.VirtualAxis; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; + + +/** + * Test dialog showing some features of JXInput. + * @author Herkules + */ +public class JXInputTestDialog extends javax.swing.JDialog + implements ActionListener +{ + + private JXKeyboardInputDevice mKeyboardDevice = null; + private JXVirtualInputDevice mVirtualDevice = null; + + Button mButtonUp; + Button mButtonDown; + Button mButtonLeft; + Button mButtonRight; + Button mButtonFire; + Button mButtonSpace; + + /** Creates new form JXInputTestDialog */ + public JXInputTestDialog(java.awt.Frame parent, boolean modal) + { + super(parent, modal); + initComponents(); + configureKeyboardInputDevice(); + configureVirtualInputDevice(); + initDevicePanels(); + pack(); + + // Request the focus so that the keyboarddevice can work + mMainPanel.requestFocus(); + + new Timer( 50, this ).start(); + + // Uncomment this line as an alternative to the Timer above. + // Don't use both!! + //JXInputEventManager.setTriggerIntervall( 50 ); + } + + + /** + * Implement ActionListener#actionPerformed(). + * This is called by the Timer. + */ + public void actionPerformed( ActionEvent e ) + { + JXInputManager.updateFeatures(); + SwingUtilities.invokeLater( + new Runnable() + { + public void run() + { + for ( int i = 0; i < mDevicesTabbedPane.getComponentCount(); ++i ) + { + ((JXInputDevicePanel)mDevicesTabbedPane.getComponent( i )).update(); + } + } + } + ); + } + + + /** + * Configure a test JXKeyboardInputdevice. + */ + void configureKeyboardInputDevice() + { + mKeyboardDevice = JXInputManager.createKeyboardDevice(); + + mKeyboardDevice.createButton( KeyEvent.VK_ESCAPE ); + + mKeyboardDevice.createButton( KeyEvent.VK_F1 ); + mKeyboardDevice.createButton( KeyEvent.VK_F2 ); + mKeyboardDevice.createButton( KeyEvent.VK_F3 ); + mKeyboardDevice.createButton( KeyEvent.VK_F4 ); + + mKeyboardDevice.createButton( KeyEvent.VK_LEFT ); + mKeyboardDevice.createButton( KeyEvent.VK_RIGHT ); + mKeyboardDevice.createButton( KeyEvent.VK_UP ); + mKeyboardDevice.createButton( KeyEvent.VK_DOWN ); + + mKeyboardDevice.createButton( KeyEvent.VK_PAGE_UP ); + mKeyboardDevice.createButton( KeyEvent.VK_PAGE_DOWN ); + + mButtonSpace = mKeyboardDevice.createButton( KeyEvent.VK_SPACE ); + mButtonLeft = mKeyboardDevice.createButton( KeyEvent.VK_A ); + mButtonRight = mKeyboardDevice.createButton( KeyEvent.VK_D ); + mButtonDown = mKeyboardDevice.createButton( KeyEvent.VK_S ); + mButtonUp = mKeyboardDevice.createButton( KeyEvent.VK_W ); + + // Configure it to make it listen to the main panel. + // I try to keep the kbd focus on it. + mKeyboardDevice.listenTo( mMainPanel ); + } + + + /** + * Configure a test JXVirtualInputdevice. + */ + void configureVirtualInputDevice() + { + mVirtualDevice = JXInputManager.createVirtualDevice(); + + Button firebutton; + // + // Remember 'fire' button of first device for use + // in the virtual device. + // For we ran configureKeyboardInputDevice() before, + // getJXInputDevice( 0 ) should not return null + // + firebutton = JXInputManager.getJXInputDevice( 0 ).getButton( 0 ); + + VirtualAxis x = mVirtualDevice.createAxis( Axis.ID_X ); + x.setButtons( mButtonRight, mButtonLeft ); + x.setName( "x: A-D" ); + + VirtualAxis y = mVirtualDevice.createAxis( Axis.ID_Y ); + y.setButtons( mButtonUp, mButtonDown ); + y.setSpringSpeed( 0.0 ); + y.setName( "y: S|W" ); + + VirtualAxis slider = mVirtualDevice.createAxis( Axis.ID_SLIDER0 ); + slider.setIncreaseButton( mButtonSpace ); + slider.setTimeFor0To1( 2000 ); + slider.setName( "" ); + slider.setType( Axis.SLIDER ); + + if ( null != firebutton ) + { + slider = mVirtualDevice.createAxis( Axis.ID_SLIDER1 ); + slider.setIncreaseButton( firebutton ); + slider.setTimeFor0To1( 2000 ); + slider.setName( "JoyButton 0" ); + } + + + } + + + /** + * Initialize one panel for each device available. + */ + void initDevicePanels() + { + int cnt = JXInputManager.getNumberOfDevices(); + + mLabelNoDevice.setVisible( cnt == 0 ); + mDevicesTabbedPane.setVisible( cnt != 0 ); + + for ( int i = 0; i < cnt; ++i ) + { + JXInputDevice dev = JXInputManager.getJXInputDevice( i ); + if ( null != dev ) + { + // + // Setup an own panel for each device. + // + JPanel panel = new JXInputDevicePanel( dev ); + mDevicesTabbedPane.addTab( dev.getName(), panel ); + } + } + } + + + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + mMainPanel = new javax.swing.JPanel(); + mLabelNoDevice = new javax.swing.JLabel(); + mDevicesTabbedPane = new javax.swing.JTabbedPane(); + mButtonReset = new javax.swing.JButton(); + + setTitle("JXInput (C) 2001-2006 HARDCODE Dev."); + addWindowListener(new java.awt.event.WindowAdapter() + { + public void windowClosing(java.awt.event.WindowEvent evt) + { + closeDialog(evt); + } + }); + + mMainPanel.setLayout(new java.awt.BorderLayout(10, 0)); + + mLabelNoDevice.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + mLabelNoDevice.setText("No JXInputDevice available!"); + mLabelNoDevice.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + mMainPanel.add(mLabelNoDevice, java.awt.BorderLayout.NORTH); + + mDevicesTabbedPane.addFocusListener(new java.awt.event.FocusAdapter() + { + public void focusGained(java.awt.event.FocusEvent evt) + { + mDevicesTabbedPaneFocusGained(evt); + } + }); + + mMainPanel.add(mDevicesTabbedPane, java.awt.BorderLayout.CENTER); + + mButtonReset.setText("Reset "); + mButtonReset.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + mButtonResetActionPerformed(evt); + } + }); + + mMainPanel.add(mButtonReset, java.awt.BorderLayout.SOUTH); + + getContentPane().add(mMainPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// //GEN-END:initComponents + + private void mButtonResetActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_mButtonResetActionPerformed + {//GEN-HEADEREND:event_mButtonResetActionPerformed + + while ( this.mDevicesTabbedPane.getTabCount() > 0 ) + this.mDevicesTabbedPane.removeTabAt( 0 ); + + JXInputManager.reset(); + configureKeyboardInputDevice(); + configureVirtualInputDevice(); + initDevicePanels(); + pack(); + + // Request the focus so that the keyboarddevice can work + mMainPanel.requestFocus(); + + }//GEN-LAST:event_mButtonResetActionPerformed + + private void mDevicesTabbedPaneFocusGained(java.awt.event.FocusEvent evt)//GEN-FIRST:event_mDevicesTabbedPaneFocusGained + {//GEN-HEADEREND:event_mDevicesTabbedPaneFocusGained + // Switch focus back to main panel! + this.mMainPanel.requestFocus(); + }//GEN-LAST:event_mDevicesTabbedPaneFocusGained + + /** Closes the dialog */ + private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog + setVisible(false); + dispose(); + System.exit( 0 ); + }//GEN-LAST:event_closeDialog + + /** + * Allow the dialog to run standalone. + * @param args the command line arguments + */ + public static void main(String args[]) + { + new JXInputTestDialog(new javax.swing.JFrame(), true).setVisible(true); + } + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton mButtonReset; + private javax.swing.JTabbedPane mDevicesTabbedPane; + private javax.swing.JLabel mLabelNoDevice; + private javax.swing.JPanel mMainPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/util/LatestChangedValueAxis.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/util/LatestChangedValueAxis.java new file mode 100644 index 0000000..f4f2c35 --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/util/LatestChangedValueAxis.java @@ -0,0 +1,98 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 17. April 2002, 23:24 +//********************************************************************************************** +package de.hardcode.jxinput.util; + +import de.hardcode.jxinput.Axis; + +/** + * + * @author Herkules + */ +public class LatestChangedValueAxis implements Axis +{ + private final Axis mAxis1; + private final Axis mAxis2; + private Axis mAxisInUse; + + private double mSaved1; + private double mSaved2; + + /** + * Creates a new instance of MeanValueAxis. + */ + public LatestChangedValueAxis(Axis a1, Axis a2) + { + mAxis1 = a1; + mAxis2 = a2; + mAxisInUse = a1; + + mSaved1 = a1.getValue(); + mSaved2 = a2.getValue(); + } + + /** + * Features may have a name provided e.g. by the driver. + */ + public String getName() + { + return mAxis1.getName(); + } + + /** Inform about the resolution of the axis. + * + * @return resolution, e.g. 2^-16 + */ + public double getResolution() + { + return mAxis1.getResolution(); + } + + /** + * Retrieve the type of the axis. + * + * @return [ TRANSLATION | ROTATION | SLIDER ] + */ + public int getType() + { + return mAxis1.getType(); + } + + /** Returns the current value of the axis. + * The range of the result depends on the axis type. + *s + * @return value [-1.0,1.0] or [0.0,1.0] + */ + public double getValue() + { + double v1 = mAxis1.getValue(); + double v2 = mAxis2.getValue(); + + if ( Math.abs( v2 - mSaved2 ) > 0.2 ) + { + mAxisInUse = mAxis2; + mSaved2 = v2; + } + if ( Math.abs( v1 - mSaved1 ) > 0.2 ) + { + mAxisInUse = mAxis1; + mSaved1 = v1; + } + + return mAxisInUse.getValue(); + } + + /** Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + public boolean hasChanged() + { + return true; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/util/OrButton.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/util/OrButton.java new file mode 100644 index 0000000..338538c --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/util/OrButton.java @@ -0,0 +1,52 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 23. Dezember 2002, 19:21 +//********************************************************************************************** +package de.hardcode.jxinput.util; + +import de.hardcode.jxinput.Button; + +/** + * + * @author Herkules + */ +public class OrButton implements Button +{ + private final Button mButton1; + private final Button mButton2; + + + /** + * Creates a new instance of OrButton. + */ + public OrButton( Button b1, Button b2 ) + { + mButton1 = b1; + mButton2 = b2; + } + + public String getName() + { + return mButton1.getName(); + } + + public boolean getState() + { + return mButton1.getState() || mButton2.getState(); + } + + public int getType() + { + return mButton1.getType(); + } + + public boolean hasChanged() + { + return mButton1.hasChanged() || mButton2.hasChanged(); + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/JXVirtualInputDevice.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/JXVirtualInputDevice.java new file mode 100644 index 0000000..aa125af --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/JXVirtualInputDevice.java @@ -0,0 +1,140 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 9. April 2002, 22:40 +//********************************************************************************************** +package de.hardcode.jxinput.virtual; + + +import de.hardcode.jxinput.*; + + +/** + * Virtual input device. + * + * @author Herkules + */ +public class JXVirtualInputDevice implements JXInputDevice +{ + private static final String DEVICENAME = "Virtual Device"; + + /** The driver doing all the real work. */ + private final VirtualDriver mDriver = new VirtualDriver(); + + + /** + * Creates a new instance of JXKeyboardInputDevice. + */ + public JXVirtualInputDevice() + { + } + + + /** + * The virtual input device needs to be updated regularly. + */ + public final void update( long deltaT ) + { + // + // Delegate the update call to the driver. + // + mDriver.update( deltaT ); + } + + /** + * Create a virtual axis object with a certain ID, e.g. Axis.ID_X. + */ + public VirtualAxis createAxis( int id ) + { + VirtualAxis a; + a = new VirtualAxis( id ); + mDriver.registerVirtualAxis( id, a ); + return a; + } + + + public void removeAxis( VirtualAxis a ) + { + mDriver.unregisterVirtualAxis( a ); + } + + + + //********************************************************************************************* + // + // Implement JXInputDevice + // + //********************************************************************************************* + + public Axis getAxis(int idx) + { + return mDriver.getAxis( idx ); + } + + + public Button getButton(int idx) + { + // No virtual buttons. + return null; + } + + + public Directional getDirectional(int idx) + { + // No virtual directionals. + return null; + } + + /** Maximum number of axes as an upper bound for index values. */ + public int getMaxNumberOfAxes() + { + return Axis.NUMBER_OF_ID; + } + + /** Maximum number of buttons as an upper bound for index values. */ + public int getMaxNumberOfButtons() + { + // No virtual buttons. + return 0; + } + + /** Maximum number of directional features as an upper bound for index values. */ + public int getMaxNumberOfDirectionals() + { + // No virtual directionals. + return 0; + } + + /** + * Devices may have a name. + * This name might be provided by a system dependant driver. + */ + public String getName() + { + return DEVICENAME; + } + + /** Actual number of available axes. */ + public int getNumberOfAxes() + { + // No axes on keyboard. + return mDriver.getNumberOfAxes(); + } + + /** Actual number of available buttons. */ + public int getNumberOfButtons() + { + return 0; + } + + /** Actual number of available directional features. */ + public int getNumberOfDirectionals() + { + // No directionals on keyboard. + return 0; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/VirtualAxis.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/VirtualAxis.java new file mode 100644 index 0000000..b272c6e --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/VirtualAxis.java @@ -0,0 +1,207 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 11. April 2002, 23:40 +//********************************************************************************************** +package de.hardcode.jxinput.virtual; + +import de.hardcode.jxinput.Axis; +import de.hardcode.jxinput.Button; +import java.security.InvalidParameterException; + +/** + * + * @author Jörg Plewe + */ +public class VirtualAxis + implements Axis +{ + + private int mType = Axis.TRANSLATION; + private final int mID; + private String mName = "VirtualAxis"; + private double mCurrentValue = 0; + + private Button mButtonIncrease = null; + private Button mButtonDecrease = null; + private double mSpeed = 1.0 / 500.0; + private double mSpringSpeed = 1.0 / 500.0; + + /** + * Creates a new instance of VirtualAxis. + */ + public VirtualAxis( int id ) + { + mID = id; + } + + + /** + * Set the type of this axis to be either Axis.ROTATION, + * Axis.TRANSLATION or Axis.SLIDER. + */ + public void setType( int type ) + { + if ( Axis.ROTATION != type + && Axis.TRANSLATION != type + && Axis.SLIDER != type + ) + throw new InvalidParameterException( "Invalid type for axis!" ); + + mType = type; + } + + /** + * Update features under my control. + */ + final void update( long deltaT ) + { + double change = mSpeed * deltaT; + double springchange = mSpringSpeed * deltaT; + boolean doincrease = ( null != mButtonIncrease && mButtonIncrease.getState() ); + boolean dodecrease = ( null != mButtonDecrease && mButtonDecrease.getState() ); + boolean iscontrolled = doincrease || dodecrease; + + double controlledchange = 0.0; + if ( doincrease ) + controlledchange += change; + if ( dodecrease ) + controlledchange -= change; + + mCurrentValue += controlledchange; + + if ( mCurrentValue > 0.0 && ! doincrease ) + { + springchange = Math.min( mCurrentValue, springchange ); + mCurrentValue -= springchange; + } + if ( mCurrentValue < 0.0 && ! dodecrease ) + { + springchange = Math.min( -mCurrentValue, springchange ); + mCurrentValue += springchange; + } + + // + // Hold value within range + // + if ( mCurrentValue > 1.0 ) + mCurrentValue = 1.0; + double lowerlimit = Axis.SLIDER == mType ? 0.0 : -1.0; + if ( mCurrentValue < lowerlimit ) + mCurrentValue = lowerlimit; + } + + + /** + * Set the button to increase the axis for a single button axis. + */ + public final void setIncreaseButton( Button b ) + { + if ( null == b ) + throw new InvalidParameterException( "Button may not be null!" ); + + mButtonIncrease = b; + } + + + /** + * Set the buttons to increase and descrease the axis. + */ + public final void setButtons( Button increase, Button decrease ) + { + if ( null == increase || null == decrease ) + throw new InvalidParameterException( "Buttons may not be null!" ); + + mButtonIncrease = increase; + mButtonDecrease = decrease; + } + + + public final void setSpeed( double speed ) + { + mSpeed = speed; + } + + public final void setSpringSpeed( double springspeed ) + { + mSpringSpeed = springspeed; + } + + + public final void setTimeFor0To1( int ms ) + { + if ( 0 >= ms ) + mSpeed = 0.0; + else + mSpeed = 1.0/ ms; + } + public final void setTimeFor1To0( int ms ) + { + if ( 0 >= ms ) + mSpringSpeed = 0.0; + else + mSpringSpeed = 1.0/ ms; + } + + + public final void setName( String name ) + { + mName = name; + } + + //********************************************************************************************* + // + // Implement Axis + // + //********************************************************************************************* + + /** + * Features may have a name provided e.g. by the driver. + */ + public String getName() + { + return mName; + } + + /** + * Inform about the resolution of the axis. + * + * @return resolution, e.g. 2^-16 + */ + public double getResolution() + { + return 1.0/65536.0; + } + + + /** + * Retrieve the type of the axis. + * @return [ TRANSLATION | ROTATION | SLIDER ] + */ + public int getType() + { + return mType; + } + + /** Returns the current value of the axis. + * The range of the result depends on the axis type. + * + * @return value [-1.0,1.0] or [0.0,1.0] + */ + public double getValue() + { + return mCurrentValue; + } + + /** Denote wether this feature has changed beyond it's resolution since it got last + * updated. + */ + public boolean hasChanged() + { + return true; + } + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/VirtualDriver.java b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/VirtualDriver.java new file mode 100644 index 0000000..5952eff --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/VirtualDriver.java @@ -0,0 +1,95 @@ +//********************************************************************************************** +// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development +// All rights reserved. Copying, modification, +// distribution or publication without the prior written +// consent of the author is prohibited. +// +// Created on 9. April 2002, 22:43 +//********************************************************************************************** +package de.hardcode.jxinput.virtual; + +import java.util.ArrayList; +import de.hardcode.jxinput.Axis; + + + +/** + * This is the main worker class for JXVirtualInputDevice. + * + * @author Herkules + */ +class VirtualDriver +{ + + private final VirtualAxis[] mVAxes = new VirtualAxis[ Axis.NUMBER_OF_ID ]; + + /** + * Creates a new instance of KeyboardDriver. + */ + VirtualDriver() + { + } + + + /** + * Update features under my control. + */ + final void update( long deltaT ) + { + // + // Delegate the update call to the axes in use. + // + for ( int i = 0; i < mVAxes.length; i++ ) + { + if ( null != mVAxes[ i ] ) + mVAxes[ i ].update( deltaT ); + } + } + + + /** + * How many axes are registered? + */ + final int getNumberOfAxes() + { + int ctr = 0; + for ( int i = 0; i < mVAxes.length; i++ ) + { + if ( null != mVAxes[ i ] ) + ctr++; + } + return ctr; + } + + Axis getAxis(int idx) + { + return mVAxes[ idx ]; + } + + + /** + * Place a new axis under my observation. + */ + final void registerVirtualAxis( int id, VirtualAxis a ) + { + mVAxes[ id ] = a; + } + + + /** + * Remove an axis from my control. + */ + final void unregisterVirtualAxis( VirtualAxis a ) + { + for ( int i = 0; i < mVAxes.length; ++i ) + { + if ( mVAxes[ i ] == a ) + { + mVAxes[ i ] = null; + break; + } + } + } + + +} diff --git a/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/package.html b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/package.html new file mode 100644 index 0000000..d8e1d6a --- /dev/null +++ b/vendor/JXInput/0.3.4/java/de/hardcode/jxinput/virtual/package.html @@ -0,0 +1,11 @@ + + + + + de.hardcode.jxinput.virtual + + +Allows to define virtual axes that are not derived from any device +but from other JXInput feature objects. + + diff --git a/vendor/JXInput/0.3.4/jxinput.dll b/vendor/JXInput/0.3.4/jxinput.dll new file mode 100644 index 0000000..720b9bb Binary files /dev/null and b/vendor/JXInput/0.3.4/jxinput.dll differ diff --git a/vendor/JXInput/0.3.4/jxinput.jar b/vendor/JXInput/0.3.4/jxinput.jar new file mode 100644 index 0000000..dbb035a Binary files /dev/null and b/vendor/JXInput/0.3.4/jxinput.jar differ diff --git a/vendor/JavaWinampApi/1.1/cpp/Makefile.win b/vendor/JavaWinampApi/1.1/cpp/Makefile.win new file mode 100644 index 0000000..206b141 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/Makefile.win @@ -0,0 +1,34 @@ +# Project: wpcom +# Makefile created by Dev-C++ 4.9.9.2 + +CPP = g++.exe +CC = gcc.exe +WINDRES = windres.exe +RES = +OBJ = WinampController.o $(RES) +LINKOBJ = WinampController.o $(RES) +LIBS = -L"E:/java/Dev-Cpp/lib" --no-export-all-symbols --add-stdcall-alias +INCS = -I"E:/java/Dev-Cpp/include" -I"E:/Program Files/Java/jdk1.6.0_11/include" -I"E:/Program Files/Java/jdk1.6.0_11/include/win32" +CXXINCS = -I"E:/java/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"E:/java/Dev-Cpp/include/c++/3.4.2/backward" -I"E:/java/Dev-Cpp/include/c++/3.4.2/mingw32" -I"E:/java/Dev-Cpp/include/c++/3.4.2" -I"E:/java/Dev-Cpp/include" -I"E:/Program Files/Java/jdk1.6.0_11/include" -I"E:/Program Files/Java/jdk1.6.0_11/include/win32" +BIN = ../../wpcom.dll +CXXFLAGS = $(CXXINCS) -DBUILDING_DLL=1 +CFLAGS = $(INCS) -DBUILDING_DLL=1 +RM = rm -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before ../../wpcom.dll all-after + + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +DLLWRAP=dllwrap.exe +DEFFILE=../../libwpcom.def +STATICLIB=../../libwpcom.a + +$(BIN): $(LINKOBJ) + $(DLLWRAP) --output-def $(DEFFILE) --implib $(STATICLIB) $(LINKOBJ) $(LIBS) -o $(BIN) + +WinampController.o: WinampController.c + $(CC) -c WinampController.c -o WinampController.o $(CFLAGS) diff --git a/vendor/JavaWinampApi/1.1/cpp/WINAMPCMD.H b/vendor/JavaWinampApi/1.1/cpp/WINAMPCMD.H new file mode 100644 index 0000000..068b55c --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/WINAMPCMD.H @@ -0,0 +1,62 @@ +#define WINAMP_FILE_QUIT 40001 +#define WINAMP_OPTIONS_PREFS 40012 +#define WINAMP_OPTIONS_AOT 40019 +#define WINAMP_FILE_REPEAT 40022 +#define WINAMP_FILE_SHUFFLE 40023 +#define WINAMP_HIGH_PRIORITY 40025 +#define WINAMP_FILE_PLAY 40029 +#define WINAMP_OPTIONS_EQ 40036 +#define WINAMP_OPTIONS_ELAPSED 40037 +#define WINAMP_OPTIONS_REMAINING 40038 +#define WINAMP_OPTIONS_PLEDIT 40040 +#define WINAMP_HELP_ABOUT 40041 +#define WINAMP_MAINMENU 40043 +#define WINAMP_BUTTON1 40044 +#define WINAMP_BUTTON2 40045 +#define WINAMP_BUTTON3 40046 +#define WINAMP_BUTTON4 40047 +#define WINAMP_BUTTON5 40048 +#define WINAMP_VOLUMEUP 40058 +#define WINAMP_VOLUMEDOWN 40059 +#define WINAMP_FFWD5S 40060 +#define WINAMP_REW5S 40061 +#define WINAMP_NEXT_WINDOW 40063 +#define WINAMP_OPTIONS_WINDOWSHADE 40064 +#define WINAMP_BUTTON1_SHIFT 40144 +#define WINAMP_BUTTON2_SHIFT 40145 +#define WINAMP_BUTTON3_SHIFT 40146 +#define WINAMP_BUTTON4_SHIFT 40147 +#define WINAMP_BUTTON5_SHIFT 40148 +#define WINAMP_BUTTON1_CTRL 40154 +#define WINAMP_BUTTON2_CTRL 40155 +#define WINAMP_BUTTON3_CTRL 40156 +#define WINAMP_BUTTON4_CTRL 40157 +#define WINAMP_BUTTON5_CTRL 40158 +#define WINAMP_OPTIONS_DSIZE 40165 +#define IDC_SORT_FILENAME 40166 +#define IDC_SORT_FILETITLE 40167 +#define IDC_SORT_ENTIREFILENAME 40168 +#define IDC_SELECTALL 40169 +#define IDC_SELECTNONE 40170 +#define IDC_SELECTINV 40171 +#define IDM_EQ_LOADPRE 40172 +#define IDM_EQ_LOADMP3 40173 +#define IDM_EQ_LOADDEFAULT 40174 +#define IDM_EQ_SAVEPRE 40175 +#define IDM_EQ_SAVEMP3 40176 +#define IDM_EQ_SAVEDEFAULT 40177 +#define IDM_EQ_DELPRE 40178 +#define IDM_EQ_DELMP3 40180 +#define IDC_PLAYLIST_PLAY 40184 +#define WINAMP_FILE_LOC 40185 +#define WINAMP_OPTIONS_EASYMOVE 40186 +#define WINAMP_FILE_DIR 40187 +#define WINAMP_EDIT_ID3 40188 +#define WINAMP_TOGGLE_AUTOSCROLL 40189 +#define WINAMP_VISSETUP 40190 +#define WINAMP_PLGSETUP 40191 +#define WINAMP_VISPLUGIN 40192 +#define WINAMP_JUMP 40193 +#define WINAMP_JUMPFILE 40194 +#define WINAMP_JUMP10FWD 40195 +#define WINAMP_JUMP10BACK 40197 diff --git a/vendor/JavaWinampApi/1.1/cpp/WinampController.c b/vendor/JavaWinampApi/1.1/cpp/WinampController.c new file mode 100644 index 0000000..1b6f46e --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/WinampController.c @@ -0,0 +1,587 @@ +/* meu .h */ +#include "WinampController.h" + +/* mingw */ +#include +#include +#include + +/* winamp sdk */ +#include "wa_ipc.h" +#include "WINAMPCMD.H" + +const int WA_CLOSE = 40001 ; +const int WA_PLAY = WINAMP_BUTTON2; +const int WA_STOP = WINAMP_BUTTON4; +const int WA_PAUSE = WINAMP_BUTTON3; +const int WA_PREVTRACK = WINAMP_BUTTON1; +const int WA_NEXTTRACK = WINAMP_BUTTON5; +const int WA_FWD5SECS = WINAMP_FFWD5S; +const int WA_REW5SECS = WINAMP_REW5S; + +const int WA_PLAYLISTLEN = IPC_GETLISTLENGTH; +const int WA_SETVOLUME = IPC_SETVOLUME; +const int WA_SETPLAYLISTPOS = IPC_SETPLAYLISTPOS; +const int WA_WRITEPLAYLIST = IPC_WRITEPLAYLIST; +const int WA_ENQUEUEFILE = IPC_ENQUEUEFILE; + +const int WA_VOLUMEUP = WINAMP_VOLUMEUP; +const int WA_VOLUMEDOWN = WINAMP_VOLUMEDOWN; + +const int WA_CLEARPLAYLIST = IPC_DELETE; +const int WA_NOTHING = 0; +const int WA_TRACK_LENGTH = 1; + +const int WA_RESTART = IPC_RESTARTWINAMP; +const int WA_REFRESHPLCACHE = IPC_REFRESHPLCACHE; +const int WA_GETSHUFFLESTATUS = IPC_GET_SHUFFLE; +const int WA_GETREPEATSTATUS = IPC_GET_REPEAT; +const int WA_SETSHUFFLESTATUS = IPC_SET_SHUFFLE; +const int WA_SETREPEATSTATUS = IPC_SET_REPEAT; + +const int WA_GETSTATUS = IPC_ISPLAYING; + +const int WA_GETLISTPOS = IPC_GETLISTPOS; +const int WA_GETTITLE = IPC_GETPLAYLISTTITLE; + +const int WA_VERSION = IPC_GETVERSION; +const int WA_FILENAMEINLIST = IPC_GETPLAYLISTFILE; +const int WA_GETFILEINFO = IPC_GET_EXTENDED_FILE_INFO; + +HWND hwnd_winamp = NULL; +INT position = 0; +STARTUPINFO si; +PROCESS_INFORMATION pi; +char messageReturn[255]; +wchar_t* wMessageReturn; + +LPDWORD temp; + +void initWinampHandle() { + hwnd_winamp = NULL; + if (hwnd_winamp == NULL) { + hwnd_winamp = FindWindow("Winamp v1.x", NULL); + } + if (hwnd_winamp == NULL) { + hwnd_winamp = FindWindow("Winamp v2.x", NULL); + } + if (hwnd_winamp == NULL) { + hwnd_winamp = FindWindow("Winamp v3.x", NULL); + } +} + +jboolean runWinamp(unsigned char* pathWinamp) { + + /* STARTUPINFO si; + PROCESS_INFORMATION pi;*/ + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + + // Start the child process. + if(!CreateProcess(pathWinamp, + NULL, + 0, + 0, + FALSE, + CREATE_NEW_CONSOLE, + 0, + 0, + &si, + &pi)) + { + return FALSE; + } + + DWORD dwResult = WaitForInputIdle(pi.hProcess,INFINITE); + if (dwResult != 0) return FALSE; + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + return TRUE; + + +} + +int getListPos() { + + initWinampHandle(); + if (hwnd_winamp != NULL) { + + return SendMessage(hwnd_winamp,WM_USER,WA_NOTHING,WA_GETLISTPOS); + + } + return -1; + +} + +void getPluginMessage(int param, int sendMessage) +{ + + LPCVOID message = (LPCVOID)SendMessageW(hwnd_winamp, WM_USER, param, sendMessage); + ZeroMemory( &pi, sizeof(pi)); + GetWindowThreadProcessId(hwnd_winamp, &pi.dwThreadId); + pi.hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,pi.dwThreadId); + ReadProcessMemory(pi.hProcess, message, messageReturn,2056,temp); + free(temp); + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_run + (JNIEnv *env, jobject obj) { + + initWinampHandle(); + + if ( hwnd_winamp == NULL ) { + + unsigned char path[MAX_PATH]=""; + DWORD size = MAX_PATH; + + HKEY key; + DWORD tipo; + + if (!RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\Clients\\Media\\Winamp\\shell\\open\\command",&key)==ERROR_SUCCESS) + { + + printf("0"); + return FALSE; + + } + + if (!(RegQueryValueEx(key,"",NULL,&tipo,path,&size))==ERROR_SUCCESS) + { + + RegCloseKey(key); + return FALSE; + + } + + if (!runWinamp(path)) + { + + RegCloseKey(key); + return FALSE; + + } + return TRUE; + + } + + int version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION); + return TRUE; + +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_exit + (JNIEnv *env, jobject obj) { + + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_CLOSE, WA_NOTHING); + return TRUE; + } + + return FALSE; + + +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_play + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + + SendMessageA(hwnd_winamp, WM_COMMAND, WA_PLAY, WA_NOTHING); + return TRUE; + + } + + return FALSE; +} + + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_stop + (JNIEnv *env, jobject obj) +{ + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_STOP, WA_NOTHING); + return TRUE; + } + + return FALSE; +} + + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_resume + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_PAUSE, WA_NOTHING); + return TRUE; + } + + return FALSE; +} + + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_pause + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_PAUSE, WA_NOTHING); + return TRUE; + } + + return FALSE; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_previousTrack + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_PREVTRACK, WA_NOTHING); + return TRUE; + } + + return FALSE; + +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_nextTrack + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_NEXTTRACK, WA_NOTHING); + return TRUE; + } + + return FALSE; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_fwd5Secs + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_FWD5SECS, WA_NOTHING); + return TRUE; + } + + return FALSE; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_rew5Secs + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_REW5SECS, WA_NOTHING); + return TRUE; + } + + return FALSE; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolume + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_VOLUMEUP, WA_NOTHING); + return TRUE; + } + + return FALSE; + +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_decreaseVolume + (JNIEnv *env, jobject obj) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_COMMAND, WA_VOLUMEDOWN, WA_NOTHING); + return TRUE; + } + + return FALSE; + +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolumePercent + (JNIEnv *env, jobject obj, jint percent) { + initWinampHandle(); + int i = 0; + if (hwnd_winamp != NULL) { + for(i=0;i0?1:0; +} + +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_isRepeatStatusOn + (JNIEnv *env, jobject obj) { + jint status = 0; + initWinampHandle(); + if (hwnd_winamp != NULL) { + status = (jint)SendMessageA(hwnd_winamp, WM_USER, WA_NOTHING, WA_GETREPEATSTATUS); + } else + return -1; + + return status>0?1:0; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setRepeatStatusOn + (JNIEnv *env, jobject obj, jboolean status) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_USER, status, WA_SETREPEATSTATUS); + return TRUE; + } + + return FALSE; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setShuffleStatusOn + (JNIEnv *env, jobject obj, jboolean status) { + initWinampHandle(); + if (hwnd_winamp != NULL) { + SendMessageA(hwnd_winamp, WM_USER, status, WA_SETSHUFFLESTATUS); + return TRUE; + } + + return FALSE; +} + +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_appendToPlayList + (JNIEnv *env, jobject obj, jstring mp3filename) { + initWinampHandle(); + jboolean iscopy; + if (hwnd_winamp != NULL) { + wMessageReturn = (wchar_t*)(*env)->GetStringChars(env, mp3filename, &iscopy); + int length = wcslen(wMessageReturn); + COPYDATASTRUCT cds; + cds.dwData = IPC_PLAYFILEW; + cds.lpData = (void*)wMessageReturn; + cds.cbData = length * 2 + 2 ; // it sums white space + + SendMessageW(hwnd_winamp, WM_COPYDATA, WA_NOTHING, (LPARAM)&cds); + return TRUE; + } + + return FALSE; + +} + +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getStatus + (JNIEnv *env, jobject obj) { + jint status = -1; + initWinampHandle(); + if (hwnd_winamp != NULL) { + status = SendMessageA(hwnd_winamp, WM_USER, WA_NOTHING, WA_GETSTATUS); + } + + return status; + + +} + +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getListPos + (JNIEnv *env, jobject obj) { + + return getListPos(); + +} + +JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTitle + (JNIEnv *env, jobject obj) { + + initWinampHandle(); + if (hwnd_winamp != NULL) { + + char title[500] = ""; + GetWindowText(hwnd_winamp,title,500); + return (*env)->NewStringUTF(env,title); + + + } + + return NULL; + +} + +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTime + (JNIEnv *env, jobject obj, jint mode) { + + initWinampHandle(); + if (hwnd_winamp != NULL) { + + return SendMessage(hwnd_winamp,WM_USER,mode,IPC_GETOUTPUTTIME); + + } + + return -2; + +} + +JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNameInList + (JNIEnv *env, jobject obj, jint index) +{ + + initWinampHandle(); + + if (hwnd_winamp != NULL) { + + getPluginMessage(index, WA_FILENAMEINLIST); + char* filePath = messageReturn; + jstring strReturn = (*env)->NewStringUTF(env,filePath); + return strReturn; + + } + + return NULL; + +} + +JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNamePlaying + (JNIEnv *env, jobject obj) +{ + + initWinampHandle(); + + if (hwnd_winamp != NULL) { + + getPluginMessage(WA_NOTHING, IPC_GET_PLAYING_FILENAME); + wchar_t* fileName = (wchar_t*)messageReturn; + int length = wcslen(fileName); + jstring strReturn = (*env)->NewString(env,fileName,length); + return strReturn; + + } + + return NULL; + +} diff --git a/vendor/JavaWinampApi/1.1/cpp/WinampController.h b/vendor/JavaWinampApi/1.1/cpp/WinampController.h new file mode 100644 index 0000000..7f2ace1 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/WinampController.h @@ -0,0 +1,285 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class WinampController */ + + +#ifndef _Included_WinampController +#define _Included_WinampController +#ifdef __cplusplus +extern "C" { +#endif + +void initWinampHandle(); + +jboolean runWinamp(unsigned char* pathWinamp); + +int getListPos(); + +void getPluginMessage(int param, int sendMessage); + +/* + * Class: WinampController + * Method: run + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_run + (JNIEnv *, jclass); +/* + * Class: WinampController + * Method: exit + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_exit + (JNIEnv *, jclass); +/* + * Class: WinampController + * Method: play + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_play + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: stop + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_stop + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: resume + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_resume + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: pause + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_pause + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: previousTrack + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_previousTrack + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: nextTrack + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_nextTrack + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: fwd5Secs + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_fwd5Secs + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: fwd5Secs + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_rew5Secs + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: increaseVolume + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolume + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: decreaseVolume + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_decreaseVolume + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: increaseVolumePercent + * Signature: (I)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_increaseVolumePercent + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: decreaseVolumePercent + * Signature: (I)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_decreaseVolumePercent + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: setVolume + * Signature: (I)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setVolume + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: setVolume + * Signature: (I)V + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getVolume + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: restart + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_restart + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: setPlaylistPosition + * Signature: (I)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setPlaylistPosition + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: clearPlayList + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_clearPlayList + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: refreshPlayListCache + * Signature: ()V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_refreshPlayListCache + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: getPlayListLength + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getPlayListLength + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: writePlayListToFile + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_writePlayListToFile + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: isShuffleStatusOn + * Signature: ()Z + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_isShuffleStatusOn + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: isRepeatStatusOn + * Signature: ()Z + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_isRepeatStatusOn + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: setRepeatStatusOn + * Signature: (Z)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setRepeatStatusOn + (JNIEnv *, jclass, jboolean); + +/* + * Class: WinampController + * Method: setShuffleStatusOn + * Signature: (Z)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_setShuffleStatusOn + (JNIEnv *, jclass, jboolean); + +/* + * Class: WinampController + * Method: appendToPlayList + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT jboolean JNICALL Java_com_qotsa_jni_controller_JNIWinamp_appendToPlayList + (JNIEnv *, jclass, jstring); + +/* + * Class: WinampController + * Method: getStatus + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getStatus + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: getListPos + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getListPos + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: getTitle + * Signature: ()I + */ +JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTitle + (JNIEnv *, jclass); + +/* + * Class: WinampController + * Method: getTime + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getTime + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: getFileNameInList + * Signature: ()I + */ +JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNameInList + (JNIEnv *, jclass, jint); + +/* + * Class: WinampController + * Method: getFileNamePlaying + * Signature: ()I + */ +JNIEXPORT jstring JNICALL Java_com_qotsa_jni_controller_JNIWinamp_getFileNamePlaying + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/JavaWinampApi/1.1/cpp/cpy.bat b/vendor/JavaWinampApi/1.1/cpp/cpy.bat new file mode 100644 index 0000000..2abdf4a --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/cpy.bat @@ -0,0 +1 @@ +copy /y wpcom.dll c:\winnt\system32\ \ No newline at end of file diff --git a/vendor/JavaWinampApi/1.1/cpp/libwpcom.def b/vendor/JavaWinampApi/1.1/cpp/libwpcom.def new file mode 100644 index 0000000..e17c91c --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/libwpcom.def @@ -0,0 +1,58 @@ +; dlltool --base-file C:\DOCUME~1\FRANCI~1\CONFIG~1\Temp/cca03628.base --output-exp wpcom.exp --dllname wpcom.dll --output-def libwpcom.def --no-export-all-symbols --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def C:\DOCUME~1\FRANCI~1\CONFIG~1\Temp/cca03628.def --output-lib libwpcom.a +EXPORTS + Java_controller_JNIWinampController_appendToPlayList = Java_controller_JNIWinampController_appendToPlayList@12 @ 1 + Java_controller_JNIWinampController_appendToPlayList@12 @ 2 + Java_controller_JNIWinampController_clearPlayList = Java_controller_JNIWinampController_clearPlayList@8 @ 3 + Java_controller_JNIWinampController_clearPlayList@8 @ 4 + Java_controller_JNIWinampController_clearPlayListCache = Java_controller_JNIWinampController_clearPlayListCache@8 @ 5 + Java_controller_JNIWinampController_clearPlayListCache@8 @ 6 + Java_controller_JNIWinampController_decreaseVolume = Java_controller_JNIWinampController_decreaseVolume@8 @ 7 + Java_controller_JNIWinampController_decreaseVolume@8 @ 8 + Java_controller_JNIWinampController_decreaseVolumePercent = Java_controller_JNIWinampController_decreaseVolumePercent@12 @ 9 + Java_controller_JNIWinampController_decreaseVolumePercent@12 @ 10 + Java_controller_JNIWinampController_exit = Java_controller_JNIWinampController_exit@8 @ 11 + Java_controller_JNIWinampController_exit@8 @ 12 + Java_controller_JNIWinampController_getListPos = Java_controller_JNIWinampController_getListPos@8 @ 13 + Java_controller_JNIWinampController_getListPos@8 @ 14 + Java_controller_JNIWinampController_getPlayListLength = Java_controller_JNIWinampController_getPlayListLength@8 @ 15 + Java_controller_JNIWinampController_getPlayListLength@8 @ 16 + Java_controller_JNIWinampController_getSeconds = Java_controller_JNIWinampController_getSeconds@8 @ 17 + Java_controller_JNIWinampController_getSeconds@8 @ 18 + Java_controller_JNIWinampController_getStatus = Java_controller_JNIWinampController_getStatus@8 @ 19 + Java_controller_JNIWinampController_getStatus@8 @ 20 + Java_controller_JNIWinampController_getTitle = Java_controller_JNIWinampController_getTitle@8 @ 21 + Java_controller_JNIWinampController_getTitle@8 @ 22 + Java_controller_JNIWinampController_increaseVolume = Java_controller_JNIWinampController_increaseVolume@8 @ 23 + Java_controller_JNIWinampController_increaseVolume@8 @ 24 + Java_controller_JNIWinampController_increaseVolumePercent = Java_controller_JNIWinampController_increaseVolumePercent@12 @ 25 + Java_controller_JNIWinampController_increaseVolumePercent@12 @ 26 + Java_controller_JNIWinampController_isRepeatStatusOn = Java_controller_JNIWinampController_isRepeatStatusOn@8 @ 27 + Java_controller_JNIWinampController_isRepeatStatusOn@8 @ 28 + Java_controller_JNIWinampController_isShuffleStatusOn = Java_controller_JNIWinampController_isShuffleStatusOn@8 @ 29 + Java_controller_JNIWinampController_isShuffleStatusOn@8 @ 30 + Java_controller_JNIWinampController_nextTrack = Java_controller_JNIWinampController_nextTrack@8 @ 31 + Java_controller_JNIWinampController_nextTrack@8 @ 32 + Java_controller_JNIWinampController_pause = Java_controller_JNIWinampController_pause@8 @ 33 + Java_controller_JNIWinampController_pause@8 @ 34 + Java_controller_JNIWinampController_play = Java_controller_JNIWinampController_play@8 @ 35 + Java_controller_JNIWinampController_play@8 @ 36 + Java_controller_JNIWinampController_previousTrack = Java_controller_JNIWinampController_previousTrack@8 @ 37 + Java_controller_JNIWinampController_previousTrack@8 @ 38 + Java_controller_JNIWinampController_restart = Java_controller_JNIWinampController_restart@8 @ 39 + Java_controller_JNIWinampController_restart@8 @ 40 + Java_controller_JNIWinampController_resume = Java_controller_JNIWinampController_resume@8 @ 41 + Java_controller_JNIWinampController_resume@8 @ 42 + Java_controller_JNIWinampController_run = Java_controller_JNIWinampController_run@8 @ 43 + Java_controller_JNIWinampController_run@8 @ 44 + Java_controller_JNIWinampController_setPlaylistPosition = Java_controller_JNIWinampController_setPlaylistPosition@12 @ 45 + Java_controller_JNIWinampController_setPlaylistPosition@12 @ 46 + Java_controller_JNIWinampController_setRepeatStatusOn = Java_controller_JNIWinampController_setRepeatStatusOn@12 @ 47 + Java_controller_JNIWinampController_setRepeatStatusOn@12 @ 48 + Java_controller_JNIWinampController_setShuffleStatusOn = Java_controller_JNIWinampController_setShuffleStatusOn@12 @ 49 + Java_controller_JNIWinampController_setShuffleStatusOn@12 @ 50 + Java_controller_JNIWinampController_setVolume = Java_controller_JNIWinampController_setVolume@12 @ 51 + Java_controller_JNIWinampController_setVolume@12 @ 52 + Java_controller_JNIWinampController_stop = Java_controller_JNIWinampController_stop@8 @ 53 + Java_controller_JNIWinampController_stop@8 @ 54 + Java_controller_JNIWinampController_writePlayListToFile = Java_controller_JNIWinampController_writePlayListToFile@8 @ 55 + Java_controller_JNIWinampController_writePlayListToFile@8 @ 56 diff --git a/vendor/JavaWinampApi/1.1/cpp/wa_ipc.h b/vendor/JavaWinampApi/1.1/cpp/wa_ipc.h new file mode 100644 index 0000000..8bc8402 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/wa_ipc.h @@ -0,0 +1,1620 @@ +/* +** Copyright (C) 2006 Nullsoft, Inc. +** +** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held +** liable for any damages arising from the use of this software. +** +** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to +** alter it and redistribute it freely, subject to the following restrictions: +** +** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. +** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. +** +** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +** +** 3. This notice may not be removed or altered from any source distribution. +** +*/ + +#ifndef _WA_IPC_H_ +#define _WA_IPC_H_ + +#include +#include +#if (_MSC_VER <= 1200) +typedef int intptr_t; +#endif +/* +** This is the modern replacement for the classic 'frontend.h'. Most of these +** updates are designed for in-process use, i.e. from a plugin. +** +*/ + +/* message used to sent many messages to winamp's main window. +** most all of the IPC_* messages involve sending the message in the form of: +** result = SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*); +** +** When you use SendMessage(hwnd_winamp,WM_WA_IPC,(parameter),IPC_*) and specify a IPC_* +** which is not currently implemented/supported by the Winamp version being used then it +** will return 1 for 'result'. This is a good way of helping to check if an api being +** used which returns a function pointer, etc is even going to be valid. +*/ +#define WM_WA_IPC WM_USER +/* but some of them use WM_COPYDATA. be afraid. +*/ + +#define WINAMP_VERSION_MAJOR(winampVersion) ((winampVersion & 0x0000FF00) >> 12) +#define WINAMP_VERSION_MINOR(winampVersion) (winampVersion & 0x000000FF) // returns, i.e. 0x12 for 5.12 and 0x10 for 5.1... + +#define IPC_GETVERSION 0 +/* int version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION); +** +** The version returned will be 0x20yx for Winamp 2.yx. +** Versions previous to Winamp 2.0 typically (but not always) use 0x1zyx for 1.zx. +** Just a bit weird but that's the way it goes. +** +** For Winamp 5.x it uses the format 0x50yx for Winamp 5.yx +** e.g. 5.01 -> 0x5001 +** 5.09 -> 0x5009 +** 5.1 -> 0x5010 +** +** Notes: For 5.02 this api will return the same value as for a 5.01 build. +** For 5.07 this api will return the same value as for a 5.06 build. +*/ +#define IPC_GETVERSIONSTRING 1 + +#define IPC_GETREGISTEREDVERSION 770 + + +typedef struct { + const char *filename; + const char *title; + int length; +} enqueueFileWithMetaStruct; // send this to a IPC_PLAYFILE in a non WM_COPYDATA, +// and you get the nice desired result. if title is NULL, it is treated as a "thing", +// otherwise it's assumed to be a file (for speed) + +typedef struct { + const wchar_t *filename; + const wchar_t *title; + int length; +} enqueueFileWithMetaStructW; + +#define IPC_PLAYFILE 100 // dont be fooled, this is really the same as enqueufile +#define IPC_ENQUEUEFILE 100 +#define IPC_PLAYFILEW 1100 +/* This is sent as a WM_COPYDATA with IPC_PLAYFILE as the dwData member and the string +** of the file / playlist to be enqueued into the playlist editor as the lpData member. +** This will just enqueue the file or files since you can use this to enqueue a playlist. +** It will not clear the current playlist or change the playback state. +** +** COPYDATASTRUCT cds = {0}; +** cds.dwData = IPC_ENQUEUEFILE; +** cds.lpData = (void*)"c:\\test\\folder\\test.mp3"; +** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char +** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); +** +** +** With 2.9+ and all of the 5.x versions you can send this as a normal WM_WA_IPC +** (non WM_COPYDATA) with an enqueueFileWithMetaStruct as the param. +** If the title member is null then it is treated as a "thing" otherwise it will be +** assumed to be a file (for speed). +** +** enqueueFileWithMetaStruct eFWMS = {0}; +** eFWMS.filename = "c:\\test\\folder\\test.mp3"; +** eFWMS.title = "Whipping Good"; +** eFWMS.length = 300; // this is the number of seconds for the track +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)&eFWMS,IPC_ENQUEUEFILE); +*/ + + +#define IPC_DELETE 101 +#define IPC_DELETE_INT 1101 +/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_DELETE); +** Use this api to clear Winamp's internal playlist. +** You should not need to use IPC_DELETE_INT since it is used internally by Winamp when +** it is dealing with some lame Windows Explorer issues (hard to believe that!). +*/ + + +#define IPC_STARTPLAY 102 +#define IPC_STARTPLAY_INT 1102 +/* SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_STARTPLAY); +** Sending this will start playback and is almost the same as hitting the play button. +** The IPC_STARTPLAY_INT version is used internally and you should not need to use it +** since it won't be any fun. +*/ + +#define IPC_CHDIR 103 +/* This is sent as a WM_COPYDATA type message with IPC_CHDIR as the dwData value and the +** directory you want to change to as the lpData member. +** +** COPYDATASTRUCT cds = {0}; +** cds.dwData = IPC_CHDIR; +** cds.lpData = (void*)"c:\\download"; +** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char +** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); +** +** The above example will make Winamp change to the directory 'C:\download'. +*/ + + +#define IPC_ISPLAYING 104 +/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING); +** This is sent to retrieve the current playback state of Winamp. +** If it returns 1, Winamp is playing. +** If it returns 3, Winamp is paused. +** If it returns 0, Winamp is not playing. +*/ + + +#define IPC_GETOUTPUTTIME 105 +/* int res = SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETOUTPUTTIME); +** This api can return two different sets of information about current playback status. +** +** If mode = 0 then it will return the position (in ms) of the currently playing track. +** Will return -1 if Winamp is not playing. +** +** If mode = 1 then it will return the current track length (in seconds). +** Will return -1 if there are no tracks (or possibly if Winamp cannot get the length). +*/ + + + +#define IPC_JUMPTOTIME 106 +/* (requires Winamp 1.60+) +** SendMessage(hwnd_winamp,WM_WA_IPC,ms,IPC_JUMPTOTIME); +** This api sets the current position (in milliseconds) for the currently playing song. +** The resulting playback position may only be an approximate time since some playback +** formats do not provide exact seeking e.g. mp3 +** This returns -1 if Winamp is not playing, 1 on end of file, or 0 if it was successful. +*/ + +#define IPC_GETMODULENAME 109 +#define IPC_EX_ISRIGHTEXE 666 +/* usually shouldnt bother using these, but here goes: +** send a WM_COPYDATA with IPC_GETMODULENAME, and an internal +** flag gets set, which if you send a normal WM_WA_IPC message with +** IPC_EX_ISRIGHTEXE, it returns whether or not that filename +** matches. lame, I know. +*/ + +#define IPC_WRITEPLAYLIST 120 +/* (requires Winamp 1.666+) +** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_WRITEPLAYLIST); +** +** IPC_WRITEPLAYLIST will write the current playlist to '\\Winamp.m3u' and +** will also return the current playlist position (see IPC_GETLISTPOS). +** +** This is kinda obsoleted by some of the newer 2.x api items but it still is good for +** use with a front-end program (instead of a plug-in) and you want to see what is in the +** current playlist. +** +** This api will only save out extended file information in the #EXTINF entry if Winamp +** has already read the data such as if the file was played of scrolled into view. If +** Winamp has not read the data then you will only find the file with its filepath entry +** (as is the base requirements for a m3u playlist). +*/ + + +#define IPC_SETPLAYLISTPOS 121 +/* (requires Winamp 2.0+) +** SendMessage(hwnd_winamp,WM_WA_IPC,position,IPC_SETPLAYLISTPOS) +** IPC_SETPLAYLISTPOS sets the playlist position to the specified 'position'. +** It will not change playback status or anything else. It will just set the current +** position in the playlist and will update the playlist view if necessary. +** +** If you use SendMessage(hwnd_winamp,WM_COMMAND,MAKEWPARAM(WINAMP_BUTTON2,0),0); +** after using IPC_SETPLAYLISTPOS then Winamp will start playing the file at 'position'. +*/ + + +#define IPC_SETVOLUME 122 +/* (requires Winamp 2.0+) +** SendMessage(hwnd_winamp,WM_WA_IPC,volume,IPC_SETVOLUME); +** IPC_SETVOLUME sets the volume of Winamp (between the range of 0 to 255). +** +** If you pass 'volume' as -666 then the message will return the current volume. +** int curvol = SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETVOLUME); +*/ + + +#define IPC_SETPANNING 123 +/* (requires Winamp 2.0+) +** SendMessage(hwnd_winamp,WM_WA_IPC,panning,IPC_SETPANNING); +** IPC_SETPANNING sets the panning of Winamp from 0 (left) to 255 (right). +** +** At least in 5.x+ this works from -127 (left) to 127 (right). +** +** If you pass 'panning' as -666 to this api then it will return the current panning. +** int curpan = SendMessage(hwnd_winamp,WM_WA_IPC,-666,IPC_SETPANNING); +*/ + + +#define IPC_GETLISTLENGTH 124 +/* (requires Winamp 2.0+) +** int length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH); +** IPC_GETLISTLENGTH returns the length of the current playlist as the number of tracks. +*/ + + +#define IPC_GETLISTPOS 125 +/* (requires Winamp 2.05+) +** int pos=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS); +** IPC_GETLISTPOS returns the current playlist position (which is shown in the playlist +** editor as a differently coloured text entry e.g is yellow for the classic skin). +** +** This api is a lot like IPC_WRITEPLAYLIST but a lot faster since it does not have to +** write out the whole of the current playlist first. +*/ + + +#define IPC_GETINFO 126 +/* (requires Winamp 2.05+) +** int inf=SendMessage(hwnd_winamp,WM_WA_IPC,mode,IPC_GETINFO); +** IPC_GETINFO returns info about the current playing song. The value +** it returns depends on the value of 'mode'. +** Mode Meaning +** ------------------ +** 0 Samplerate, in kilohertz (i.e. 44) +** 1 Bitrate (i.e. 128) +** 2 Channels (i.e. 2) +** 3 (5+) Video LOWORD=w HIWORD=h +** 4 (5+) > 65536, string (video description) +** 5 (5.25+) Samplerate, in hertz (i.e. 44100) +*/ + + +#define IPC_GETEQDATA 127 +/* (requires Winamp 2.05+) +** int data=SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); +** IPC_GETEQDATA queries the status of the EQ. +** The value returned depends on what 'pos' is set to: +** Value Meaning +** ------------------ +** 0-9 The 10 bands of EQ data. 0-63 (+20db - -20db) +** 10 The preamp value. 0-63 (+20db - -20db) +** 11 Enabled. zero if disabled, nonzero if enabled. +** 12 Autoload. zero if disabled, nonzero if enabled. +*/ + + +#define IPC_SETEQDATA 128 +/* (requires Winamp 2.05+) +** SendMessage(hwnd_winamp,WM_WA_IPC,pos,IPC_GETEQDATA); +** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SETEQDATA); +** IPC_SETEQDATA sets the value of the last position retrieved +** by IPC_GETEQDATA. This is pretty lame, and we should provide +** an extended version that lets you do a MAKELPARAM(pos,value). +** someday... + + new (2.92+): + if the high byte is set to 0xDB, then the third byte specifies + which band, and the bottom word specifies the value. +*/ + +#define IPC_ADDBOOKMARK 129 +#define IPC_ADDBOOKMARKW 131 +/* (requires Winamp 2.4+) +** This is sent as a WM_COPYDATA using IPC_ADDBOOKMARK as the dwData value and the +** directory you want to change to as the lpData member. This will add the specified +** file / url to the Winamp bookmark list. +** +** COPYDATASTRUCT cds = {0}; +** cds.dwData = IPC_ADDBOOKMARK; +** cds.lpData = (void*)"http://www.blah.com/listen.pls"; +** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char +** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); +** +** +** In Winamp 5.0+ we use this as a normal WM_WA_IPC and the string is null separated as +** the filename and then the title of the entry. +** +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(char*)"filename\0title\0",IPC_ADDBOOKMARK); +** +** This will notify the library / bookmark editor that a bookmark was added. +** Note that using this message in this context does not actually add the bookmark. +** Do not use, it is essentially just a notification type message :) +*/ + + +#define IPC_INSTALLPLUGIN 130 +/* This is not implemented (and is very unlikely to be done due to safety concerns). +** If it was then you could do a WM_COPYDATA with a path to a .wpz and it would then +** install the plugin for you. +** +** COPYDATASTRUCT cds = {0}; +** cds.dwData = IPC_INSTALLPLUGIN; +** cds.lpData = (void*)"c:\\path\\to\\file.wpz"; +** cds.cbData = lstrlen((char*)cds.lpData)+1; // include space for null char +** SendMessage(hwnd_winamp,WM_COPYDATA,0,(LPARAM)&cds); +*/ + + +#define IPC_RESTARTWINAMP 135 +/* (requires Winamp 2.2+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_RESTARTWINAMP); +** IPC_RESTARTWINAMP will restart Winamp (isn't that obvious ? :) ) +** If this fails to make Winamp start after closing then there is a good chance one (or +** more) of the currently installed plugins caused Winamp to crash on exit (either as a +** silent crash or a full crash log report before it could call itself start again. +*/ + + +#define IPC_ISFULLSTOP 400 +/* (requires winamp 2.7+ I think) +** int ret=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISFULLSTOP); +** This is useful for when you're an output plugin and you want to see if the stop/close +** happening is a full stop or if you are just between tracks. This returns non zero if +** it is a full stop or zero if it is just a new track. +*/ + + +#define IPC_INETAVAILABLE 242 +/* (requires Winamp 2.05+) +** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_INETAVAILABLE); +** IPC_INETAVAILABLE will return 1 if an Internet connection is available for Winamp and +** relates to the internet connection type setting on the main general preferences page +** in the Winamp preferences. +*/ + + +#define IPC_UPDTITLE 243 +/* (requires Winamp 2.2+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_UPDTITLE); +** IPC_UPDTITLE will ask Winamp to update the information about the current title and +** causes GetFileInfo(..) in the input plugin associated with the current playlist entry +** to be called. This can be called such as when an input plugin is buffering a file so +** that it can cause the buffer percentage to appear in the playlist. +*/ + + +#define IPC_REFRESHPLCACHE 247 +/* (requires Winamp 2.2+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REFRESHPLCACHE); +** IPC_REFRESHPLCACHE will flush the playlist cache buffer and you send this if you want +** Winamp to go refetch the titles for all of the entries in the current playlist. + +5.3+: pass a wchar_t * string in wParam, and it'll do a strnicmp() before clearing the cache +*/ + + +#define IPC_GET_SHUFFLE 250 +/* (requires Winamp 2.4+) +** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_SHUFFLE); +** IPC_GET_SHUFFLE returns the status of the shuffle option. +** If set then it will return 1 and if not set then it will return 0. +*/ + + +#define IPC_GET_REPEAT 251 +/* (requires Winamp 2.4+) +** int val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_REPEAT); +** IPC_GET_REPEAT returns the status of the repeat option. +** If set then it will return 1 and if not set then it will return 0. +*/ + + +#define IPC_SET_SHUFFLE 252 +/* (requires Winamp 2.4+) +** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_SHUFFLE); +** IPC_SET_SHUFFLE sets the status of the shuffle option. +** If 'value' is 1 then shuffle is turned on. +** If 'value' is 0 then shuffle is turned off. +*/ + + +#define IPC_SET_REPEAT 253 +/* (requires Winamp 2.4+) +** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_REPEAT); +** IPC_SET_REPEAT sets the status of the repeat option. +** If 'value' is 1 then shuffle is turned on. +** If 'value' is 0 then shuffle is turned off. +*/ + + +#define IPC_ENABLEDISABLE_ALL_WINDOWS 259 // 0xdeadbeef to disable +/* (requires Winamp 2.9+) +** SendMessage(hwnd_winamp,WM_WA_IPC,(enable?0:0xdeadbeef),IPC_ENABLEDISABLE_ALL_WINDOWS); +** Sending this message with 0xdeadbeef as the param will disable all winamp windows and +** any other values will enable all of the Winamp windows again. When disabled you won't +** get any response on clicking or trying to do anything to the Winamp windows. If the +** taskbar icon is shown then you may still have control ;) +*/ + + +#define IPC_GETWND 260 +/* (requires Winamp 2.9+) +** HWND h=SendMessage(hwnd_winamp,WM_WA_IPC,IPC_GETWND_xxx,IPC_GETWND); +** returns the HWND of the window specified. +*/ + #define IPC_GETWND_EQ 0 // use one of these for the param + #define IPC_GETWND_PE 1 + #define IPC_GETWND_MB 2 + #define IPC_GETWND_VIDEO 3 +#define IPC_ISWNDVISIBLE 261 // same param as IPC_GETWND + + + + +/************************************************************************ +***************** in-process only (WE LOVE PLUGINS) +************************************************************************/ + +#define IPC_SETSKINW 199 +#define IPC_SETSKIN 200 +/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"skinname",IPC_SETSKIN); +** IPC_SETSKIN sets the current skin to "skinname". Note that skinname +** can be the name of a skin, a skin .zip file, with or without path. +** If path isn't specified, the default search path is the winamp skins +** directory. +*/ + + +#define IPC_GETSKIN 201 +/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)skinname_buffer,IPC_GETSKIN); +** IPC_GETSKIN puts the directory where skin bitmaps can be found +** into skinname_buffer. +** skinname_buffer must be MAX_PATH characters in length. +** When using a .zip'd skin file, it'll return a temporary directory +** where the ZIP was decompressed. +*/ + + +#define IPC_EXECPLUG 202 +/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)"vis_file.dll",IPC_EXECPLUG); +** IPC_EXECPLUG executes a visualization plug-in pointed to by WPARAM. +** the format of this string can be: +** "vis_whatever.dll" +** "vis_whatever.dll,0" // (first mod, file in winamp plug-in dir) +** "C:\\dir\\vis_whatever.dll,1" +*/ + + +#define IPC_GETPLAYLISTFILE 211 +#define IPC_GETPLAYLISTFILEW 214 +/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) +** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTFILE); +** IPC_GETPLAYLISTFILE gets the filename of the playlist entry [index]. +** returns a pointer to it. returns NULL on error. +*/ + + +#define IPC_GETPLAYLISTTITLE 212 +#define IPC_GETPLAYLISTTITLEW 213 +/* (requires Winamp 2.04+, only usable from plug-ins (not external apps)) +** char *name=SendMessage(hwnd_winamp,WM_WA_IPC,index,IPC_GETPLAYLISTTITLE); +** +** IPC_GETPLAYLISTTITLE gets the title of the playlist entry [index]. +** returns a pointer to it. returns NULL on error. +*/ + + +#define IPC_GETHTTPGETTER 240 +/* retrieves a function pointer to a HTTP retrieval function. +** if this is unsupported, returns 1 or 0. +** the function should be: +** int (*httpRetrieveFile)(HWND hwnd, char *url, char *file, char *dlgtitle); +** if you call this function, with a parent window, a URL, an output file, and a dialog title, +** it will return 0 on successful download, 1 on error. +*/ + + +#define IPC_MBOPEN 241 +/* (requires Winamp 2.05+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_MBOPEN); +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPEN); +** IPC_MBOPEN will open a new URL in the minibrowser. if url is NULL, it will open the Minibrowser window. +*/ + + + +#define IPC_CHANGECURRENTFILE 245 +/* (requires Winamp 2.05+) +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILE); +** IPC_CHANGECURRENTFILE will set the current playlist item. +*/ + +#define IPC_CHANGECURRENTFILEW 1245 +/* (requires Winamp 2.05+) +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)file,IPC_CHANGECURRENTFILEW); +** IPC_CHANGECURRENTFILEW will set the current playlist item. +*/ + + +#define IPC_GETMBURL 246 +/* (requires Winamp 2.2+) +** char buffer[4096]; // Urls can be VERY long +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)buffer,IPC_GETMBURL); +** IPC_GETMBURL will retrieve the current Minibrowser URL into buffer. +** buffer must be at least 4096 bytes long. +*/ + + +#define IPC_MBBLOCK 248 +/* (requires Winamp 2.4+) +** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_MBBLOCK); +** +** IPC_MBBLOCK will block the Minibrowser from updates if value is set to 1 +*/ + +#define IPC_MBOPENREAL 249 +/* (requires Winamp 2.4+) +** SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)url,IPC_MBOPENREAL); +** +** IPC_MBOPENREAL works the same as IPC_MBOPEN except that it will works even if +** IPC_MBBLOCK has been set to 1 +*/ + +#define IPC_ADJUST_OPTIONSMENUPOS 280 +/* (requires Winamp 2.9+) +** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_OPTIONSMENUPOS); +** moves where winamp expects the Options menu in the main menu. Useful if you wish to insert a +** menu item above the options/skins/vis menus. +*/ + +#define IPC_GET_HMENU 281 +/* (requires Winamp 2.9+) +** HMENU hMenu=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)0,IPC_GET_HMENU); +** values for data: +** 0 : main popup menu +** 1 : main menubar file menu +** 2 : main menubar options menu +** 3 : main menubar windows menu +** 4 : main menubar help menu +** other values will return NULL. +*/ + +#define IPC_GET_EXTENDED_FILE_INFO 290 //pass a pointer to the following struct in wParam +#define IPC_GET_EXTENDED_FILE_INFO_HOOKABLE 296 +/* (requires Winamp 2.9+) +** to use, create an extendedFileInfoStruct, point the values filename and metadata to the +** filename and metadata field you wish to query, and ret to a buffer, with retlen to the +** length of that buffer, and then SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_GET_EXTENDED_FILE_INFO); +** the results should be in the buffer pointed to by ret. +** returns 1 if the decoder supports a getExtendedFileInfo method +*/ +typedef struct { + const char *filename; + const char *metadata; + char *ret; + size_t retlen; +} extendedFileInfoStruct; + + +#define IPC_GET_BASIC_FILE_INFO 291 //pass a pointer to the following struct in wParam +typedef struct { + const char *filename; + + int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) + + // filled in by winamp + int length; + char *title; + int titlelen; +} basicFileInfoStruct; + +#define IPC_GET_BASIC_FILE_INFOW 1291 //pass a pointer to the following struct in wParam +typedef struct { + const wchar_t *filename; + + int quickCheck; // set to 0 to always get, 1 for quick, 2 for default (if 2, quickCheck will be set to 0 if quick wasnot used) + + // filled in by winamp + int length; + wchar_t *title; + int titlelen; +} basicFileInfoStructW; + + +#define IPC_GET_EXTLIST 292 //returns doublenull delimited. GlobalFree() it when done. if data is 0, returns raw extlist, if 1, returns something suitable for getopenfilename +#define IPC_GET_EXTLISTW 1292 // wide char version of above + +#define IPC_INFOBOX 293 +typedef struct { + HWND parent; + char *filename; +} infoBoxParam; + +#define IPC_INFOBOXW 1293 +typedef struct { + HWND parent; + const wchar_t *filename; +} infoBoxParamW; + +#define IPC_SET_EXTENDED_FILE_INFO 294 //pass a pointer to the a extendedFileInfoStruct in wParam +/* (requires Winamp 2.9+) +** to use, create an extendedFileInfoStruct, point the values filename and metadata to the +** filename and metadata field you wish to write in ret. (retlen is not used). and then +** SendMessage(hwnd_winamp,WM_WA_IPC,&struct,IPC_SET_EXTENDED_FILE_INFO); +** returns 1 if the metadata is supported +** Call IPC_WRITE_EXTENDED_FILE_INFO once you're done setting all the metadata you want to update +*/ + +#define IPC_WRITE_EXTENDED_FILE_INFO 295 +/* (requires Winamp 2.9+) +** writes all the metadata set thru IPC_SET_EXTENDED_FILE_INFO to the file +** returns 1 if the file has been successfully updated, 0 if error +*/ + +#define IPC_FORMAT_TITLE 297 +typedef struct +{ + char *spec; // NULL=default winamp spec + void *p; + + char *out; + int out_len; + + char * (*TAGFUNC)(const char * tag, void * p); //return 0 if not found + void (*TAGFREEFUNC)(char * tag,void * p); +} waFormatTitle; + +#define IPC_FORMAT_TITLE_EXTENDED 298 // similiar to IPC_FORMAT_TITLE, but falls back to Winamp's %tags% if your passed tag function doesn't handle it +typedef struct +{ + const wchar_t *filename; + int useExtendedInfo; // set to 1 if you want the Title Formatter to query the input plugins for any tags that your tag function fails on + const wchar_t *spec; // NULL=default winamp spec + void *p; + + wchar_t *out; + int out_len; + + wchar_t * (*TAGFUNC)(const wchar_t * tag, void * p); //return 0 if not found, -1 for empty tag + void (*TAGFREEFUNC)(wchar_t *tag, void *p); +} waFormatTitleExtended; + +#define IPC_COPY_EXTENDED_FILE_INFO 299 +typedef struct +{ + const char *source; + const char *dest; +} copyFileInfoStruct; + +#define IPC_COPY_EXTENDED_FILE_INFOW 1299 +typedef struct +{ + const wchar_t *source; + const wchar_t *dest; +} copyFileInfoStructW; + + +#define IPC_GETUNCOMPRESSINTERFACE 331 +/* returns a function pointer to uncompress(). +** int (*uncompress)(unsigned char *dest, unsigned long *destLen, const unsigned char *source, unsigned long sourceLen); +** right out of zlib, useful for decompressing zlibbed data. +** if you pass the parm of 0x10100000, it will return a wa_inflate_struct * to an inflate API. +*/ + +typedef struct { + int (*inflateReset)(void *strm); + int (*inflateInit_)(void *strm,const char *version, int stream_size); + int (*inflate)(void *strm, int flush); + int (*inflateEnd)(void *strm); + unsigned long (*crc32)(unsigned long crc, const unsigned char *buf, unsigned int len); +} wa_inflate_struct; + + +#define IPC_ADD_PREFS_DLG 332 +#define IPC_REMOVE_PREFS_DLG 333 +/* (requires Winamp 2.9+) +** to use, allocate a prefsDlgRec structure (either on the heap or some global +** data, but NOT on the stack), initialze the members: +** hInst to the DLL instance where the resource is located +** dlgID to the ID of the dialog, +** proc to the window procedure for the dialog +** name to the name of the prefs page in the prefs. +** where to 0 (eventually we may add more options) +** then, SendMessage(hwnd_winamp,WM_WA_IPC,&prefsRec,IPC_ADD_PREFS_DLG); +** +** you can also IPC_REMOVE_PREFS_DLG with the address of the same prefsRec, +** but you shouldn't really ever have to. +** +*/ +#define IPC_OPENPREFSTOPAGE 380 // pass an id of a builtin page, or a &prefsDlgRec of prefs page to open + +typedef struct _prefsDlgRec { + HINSTANCE hInst; + int dlgID; + void *proc; + + char *name; + intptr_t where; // 0 for options, 1 for plugins, 2 for skins, 3 for bookmarks, 4 for prefs + + intptr_t _id; + struct _prefsDlgRec *next; +} prefsDlgRec; + + +#define IPC_GETINIFILE 334 // returns a pointer to winamp.ini +#define IPC_GETINIDIRECTORY 335 // returns a pointer to the directory to put config files in (if you dont want to use winamp.ini) +#define IPC_GETPLUGINDIRECTORY 336 +#define IPC_GETM3UDIRECTORY 337 // returns a char pointer to the directory where winamp.m3u is stored in. +#define IPC_GETM3UDIRECTORYW 338 // returns a wchar_t pointer to the directory where winamp.m3u is stored in. + +#define IPC_SPAWNBUTTONPOPUP 361 // param = +// 0 = eject +// 1 = previous +// 2 = next +// 3 = pause +// 4 = play +// 5 = stop + +#define IPC_OPENURLBOX 360 // pass a HWND to a parent, returns a HGLOBAL that needs to be freed with GlobalFree(), if successful +#define IPC_OPENFILEBOX 362 // pass a HWND to a parent +#define IPC_OPENDIRBOX 363 // pass a HWND to a parent + +// pass an HWND to a parent. call this if you take over the whole UI so that the dialogs are not appearing on the +// bottom right of the screen since the main winamp window is at 3000x3000, call again with NULL to reset +#define IPC_SETDIALOGBOXPARENT 364 + + + +#define IPC_DRO_MIN 401 // reserved for DrO +#define IPC_SET_JTF_COMPARATOR 409 +/* pass me an int (__cdecl *)(const char *, const char *) in wParam */ +#define IPC_SET_JTF_COMPARATOR_W 410 +/* pass me an int (__cdecl *)(const wchar_t *, const wchar_t *) in wParam ... maybe someday :) */ +#define IPC_SET_JTF_DRAWTEXT 416 + +#define IPC_DRO_MAX 499 + + +// pass 0 for a copy of the skin HBITMAP +// pass 1 for name of font to use for playlist editor likeness +// pass 2 for font charset +// pass 3 for font size +#define IPC_GET_GENSKINBITMAP 503 + + +#define IPC_GET_EMBEDIF 505 // pass an embedWindowState +// returns an HWND embedWindow(embedWindowState *); if the data is NULL, otherwise returns the HWND directly +typedef struct +{ + HWND me; //hwnd of the window + + int flags; + + RECT r; + + void *user_ptr; // for application use + + intptr_t extra_data[64]; // for internal winamp use +} embedWindowState; + +#define EMBED_FLAGS_NORESIZE 0x1 // set this bit in embedWindowState.flags to keep window from being resizable +#define EMBED_FLAGS_NOTRANSPARENCY 0x2 // set this bit in embedWindowState.flags to make gen_ff turn transparency off for this wnd +#define EMBED_FLAGS_NOWINDOWMENU 0x4 // set this bit to prevent gen_ff from automatically adding your window to the right-click menu +#define EMBED_FLAGS_GUID 0x8 // call SET_EMBED_GUID(yourEmbedWindowStateStruct, GUID) to define a GUID for this window + +#define SET_EMBED_GUID(windowState, windowGUID) { windowState->flags |= EMBED_FLAGS_GUID; *((GUID *)&windowState->extra_data[4])=windowGUID; } +#define GET_EMBED_GUID(windowState) (*((GUID *)&windowState->extra_data[4])) + +#define IPC_EMBED_ENUM 532 +typedef struct embedEnumStruct +{ + int (*enumProc)(embedWindowState *ws, struct embedEnumStruct *param); // return 1 to abort + int user_data; // or more :) +} embedEnumStruct; + // pass + +#define IPC_EMBED_ISVALID 533 + +#define IPC_CONVERTFILE 506 +/* (requires Winamp 2.92+) +** Converts a given file to a different format (PCM, MP3, etc...) +** To use, pass a pointer to a waFileConvertStruct struct +** This struct can be either on the heap or some global +** data, but NOT on the stack. At least, until the conversion is done. +** +** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE); +** +** Return value: +** 0: Can't start the conversion. Look at myConvertStruct->error for details. +** 1: Conversion started. Status messages will be sent to the specified callbackhwnd. +** Be sure to call IPC_CONVERTFILE_END when your callback window receives the +** IPC_CB_CONVERT_DONE message. +*/ +typedef struct +{ + char *sourcefile; // "c:\\source.mp3" + char *destfile; // "c:\\dest.pcm" + int destformat[8]; // like 'PCM ',srate,nch,bps. + //hack alert! you can set destformat[6]=mmioFOURCC('I','N','I',' '); and destformat[7]=(int)my_ini_file; (where my_ini_file is a char*) + HWND callbackhwnd; // window that will receive the IPC_CB_CONVERT notification messages + + //filled in by winamp.exe + char *error; //if IPC_CONVERTFILE returns 0, the reason will be here + + int bytes_done; //you can look at both of these values for speed statistics + int bytes_total; + int bytes_out; + + int killswitch; // don't set it manually, use IPC_CONVERTFILE_END + intptr_t extra_data[64]; // for internal winamp use +} convertFileStruct; + +#define IPC_CONVERTFILE_END 507 +/* (requires Winamp 2.92+) +** Stop/ends a convert process started from IPC_CONVERTFILE +** You need to call this when you receive the IPC_CB_CONVERTDONE message or when you +** want to abort a conversion process +** +** eg: SendMessage(hwnd_winamp,WM_WA_IPC,&myConvertStruct,IPC_CONVERTFILE_END); +** +** No return value +*/ + +typedef struct { + HWND hwndParent; + int format; + + //filled in by winamp.exe + HWND hwndConfig; + int extra_data[8]; + //hack alert! you can set extra_data[6]=mmioFOURCC('I','N','I',' '); and extra_data[7]=(int)my_ini_file; (where my_ini_file is a char*) +} convertConfigStruct; +#define IPC_CONVERT_CONFIG 508 +#define IPC_CONVERT_CONFIG_END 509 + +typedef struct +{ + void (*enumProc)(intptr_t user_data, const char *desc, int fourcc); + intptr_t user_data; +} converterEnumFmtStruct; +#define IPC_CONVERT_CONFIG_ENUMFMTS 510 +/* (requires Winamp 2.92+) +*/ + +typedef struct +{ + char cdletter; + char *playlist_file; + HWND callback_hwnd; + + //filled in by winamp.exe + char *error; +} burnCDStruct; +#define IPC_BURN_CD 511 +/* (requires Winamp 5.0+) +*/ + +typedef struct +{ + convertFileStruct *cfs; + int priority; +} convertSetPriority; +#define IPC_CONVERT_SET_PRIORITY 512 + +typedef struct +{ + unsigned int format; //fourcc value + char *item; // config item, eg "bitrate" + char *data; // buffer to recieve, or buffer that contains the data + int len; // length of the data buffer (only used when getting a config item) + char *configfile; // config file to read from +} convertConfigItem; + +#define IPC_CONVERT_CONFIG_SET_ITEM 513 // returns TRUE if successful +#define IPC_CONVERT_CONFIG_GET_ITEM 514 // returns TRUE if successful + +typedef struct +{ + const char *filename; + char *title; // 2048 bytes + int length; + int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit +} waHookTitleStruct; +// return TRUE if you hook this +#define IPC_HOOK_TITLES 850 + +typedef struct +{ + const wchar_t *filename; + wchar_t *title; // 2048 bytes + int length; + int force_useformatting; // can set this to 1 if you want to force a url to use title formatting shit +} waHookTitleStructW; +// return TRUE if you hook this +#define IPC_HOOK_TITLESW 851 + +#define IPC_GETSADATAFUNC 800 +// 0: returns a char *export_sa_get() that returns 150 bytes of data +// 1: returns a export_sa_setreq(int want); + +#define IPC_GETVUDATAFUNC 801 +// 0: returns a int export_vu_get(int channel) that returns 0-255 (or -1 for bad channel) + +#define IPC_ISMAINWNDVISIBLE 900 + + +#define IPC_SETPLEDITCOLORS 920 +typedef struct +{ + int numElems; + int *elems; + HBITMAP bm; // set if you want to override +} waSetPlColorsStruct; + + +// the following IPC use waSpawnMenuParms as parameter +#define IPC_SPAWNEQPRESETMENU 933 +#define IPC_SPAWNFILEMENU 934 //menubar +#define IPC_SPAWNOPTIONSMENU 935 //menubar +#define IPC_SPAWNWINDOWSMENU 936 //menubar +#define IPC_SPAWNHELPMENU 937 //menubar +#define IPC_SPAWNPLAYMENU 938 //menubar +#define IPC_SPAWNPEFILEMENU 939 //menubar +#define IPC_SPAWNPEPLAYLISTMENU 940 //menubar +#define IPC_SPAWNPESORTMENU 941 //menubar +#define IPC_SPAWNPEHELPMENU 942 //menubar +#define IPC_SPAWNMLFILEMENU 943 //menubar +#define IPC_SPAWNMLVIEWMENU 944 //menubar +#define IPC_SPAWNMLHELPMENU 945 //menubar +#define IPC_SPAWNPELISTOFPLAYLISTS 946 + +typedef struct +{ + HWND wnd; + int xpos; // in screen coordinates + int ypos; +} waSpawnMenuParms; + +// waSpawnMenuParms2 is used by the menubar submenus +typedef struct +{ + HWND wnd; + int xpos; // in screen coordinates + int ypos; + int width; + int height; +} waSpawnMenuParms2; + + +// system tray sends this (you might want to simulate it) +#define WM_WA_SYSTRAY WM_USER+1 + +// input plugins send this when they are done playing back +#define WM_WA_MPEG_EOF WM_USER+2 + + + +//// video stuff + +#define IPC_IS_PLAYING_VIDEO 501 // returns >1 if playing, 0 if not, 1 if old version (so who knows):) +#define IPC_GET_IVIDEOOUTPUT 500 // see below for IVideoOutput interface +#define VIDEO_MAKETYPE(A,B,C,D) ((A) | ((B)<<8) | ((C)<<16) | ((D)<<24)) +#define VIDUSER_SET_INFOSTRING 0x1000 +#define VIDUSER_GET_VIDEOHWND 0x1001 +#define VIDUSER_SET_VFLIP 0x1002 +#define VIDUSER_SET_TRACKSELINTERFACE 0x1003 // give your ITrackSelector interface as param2 +#define VIDUSER_OPENVIDEORENDERER 0x1004 +#define VIDUSER_CLOSEVIDEORENDERER 0x1005 +#define VIDUSER_GETPOPUPMENU 0x1006 + +typedef struct +{ + int w; + int h; + int vflip; + double aspectratio; + unsigned int fmt; +} VideoOpenStruct; + +#ifndef NO_IVIDEO_DECLARE +#ifdef __cplusplus + +class VideoOutput; +class SubsItem; + +#ifndef _NSV_DEC_IF_H_ +typedef struct { + unsigned char* baseAddr; + long rowBytes; +} YV12_PLANE; + +typedef struct { + YV12_PLANE y; + YV12_PLANE u; + YV12_PLANE v; +} YV12_PLANES; +#endif + +class IVideoOutput +{ + public: + virtual ~IVideoOutput() { } + virtual int open(int w, int h, int vflip, double aspectratio, unsigned int fmt)=0; + virtual void setcallback(LRESULT (*msgcallback)(void *token, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam), void *token) { (void)token; (void)msgcallback; /* to eliminate warning C4100 */ } + virtual void close()=0; + virtual void draw(void *frame)=0; + virtual void drawSubtitle(SubsItem *item) { } + virtual void showStatusMsg(const char *text) { } + virtual int get_latency() { return 0; } + virtual void notifyBufferState(int bufferstate) { } /* 0-255*/ + + virtual INT_PTR extended(INT_PTR param1, INT_PTR param2, INT_PTR param3) { return 0; } // Dispatchable, eat this! +}; + +class ITrackSelector +{ + public: + virtual int getNumAudioTracks()=0; + virtual void enumAudioTrackName(int n, const char *buf, int size)=0; + virtual int getCurAudioTrack()=0; + virtual int getNumVideoTracks()=0; + virtual void enumVideoTrackName(int n, const char *buf, int size)=0; + virtual int getCurVideoTrack()=0; + + virtual void setAudioTrack(int n)=0; + virtual void setVideoTrack(int n)=0; +}; + +#endif //cplusplus +#endif//NO_IVIDEO_DECLARE + +// these messages are callbacks that you can grab by subclassing the winamp window + +// wParam = +#define IPC_CB_WND_EQ 0 // use one of these for the param +#define IPC_CB_WND_PE 1 +#define IPC_CB_WND_MB 2 +#define IPC_CB_WND_VIDEO 3 +#define IPC_CB_WND_MAIN 4 + +#define IPC_CB_ONSHOWWND 600 +#define IPC_CB_ONHIDEWND 601 + +#define IPC_CB_GETTOOLTIP 602 + +#define IPC_CB_MISC 603 + #define IPC_CB_MISC_TITLE 0 + #define IPC_CB_MISC_VOLUME 1 // volume/pan + #define IPC_CB_MISC_STATUS 2 + #define IPC_CB_MISC_EQ 3 + #define IPC_CB_MISC_INFO 4 + #define IPC_CB_MISC_VIDEOINFO 5 + +#define IPC_CB_CONVERT_STATUS 604 // param value goes from 0 to 100 (percent) +#define IPC_CB_CONVERT_DONE 605 + +#define IPC_ADJUST_FFWINDOWSMENUPOS 606 +/* (requires Winamp 2.9+) +** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFWINDOWSMENUPOS); +** moves where winamp expects the freeform windows in the menubar windows main menu. Useful if you wish to insert a +** menu item above extra freeform windows. +*/ + +#define IPC_ISDOUBLESIZE 608 + +#define IPC_ADJUST_FFOPTIONSMENUPOS 609 +/* (requires Winamp 2.9+) +** int newpos=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)adjust_offset,IPC_ADJUST_FFOPTIONSMENUPOS); +** moves where winamp expects the freeform preferences item in the menubar windows main menu. Useful if you wish to insert a +** menu item above preferences item. +*/ + +#define IPC_GETTIMEDISPLAYMODE 610 // returns 0 if displaying elapsed time or 1 if displaying remaining time + +#define IPC_SETVISWND 611 // param is hwnd, setting this allows you to receive ID_VIS_NEXT/PREVOUS/RANDOM/FS wm_commands +#define ID_VIS_NEXT 40382 +#define ID_VIS_PREV 40383 +#define ID_VIS_RANDOM 40384 +#define ID_VIS_FS 40389 +#define ID_VIS_CFG 40390 +#define ID_VIS_MENU 40391 + +#define IPC_GETVISWND 612 // returns the vis cmd handler hwnd +#define IPC_ISVISRUNNING 613 +#define IPC_CB_VISRANDOM 628 // param is status of random + +#define IPC_SETIDEALVIDEOSIZE 614 // sent by winamp to winamp, trap it if you need it. width=HIWORD(param), height=LOWORD(param) + +#define IPC_GETSTOPONVIDEOCLOSE 615 +#define IPC_SETSTOPONVIDEOCLOSE 616 + +typedef struct { + HWND hwnd; + int uMsg; + WPARAM wParam; + LPARAM lParam; +} transAccelStruct; + +#define IPC_TRANSLATEACCELERATOR 617 + +typedef struct { + int cmd; + int x; + int y; + int align; +} windowCommand; // send this as param to an IPC_PLCMD, IPC_MBCMD, IPC_VIDCMD + +#define IPC_CB_ONTOGGLEAOT 618 + +#define IPC_GETPREFSWND 619 + +#define IPC_SET_PE_WIDTHHEIGHT 620 // data is a pointer to a POINT structure that holds width & height + +#define IPC_GETLANGUAGEPACKINSTANCE 621 + +#define IPC_CB_PEINFOTEXT 622 // data is a string, ie: "04:21/45:02" + +#define IPC_CB_OUTPUTCHANGED 623 // output plugin was changed in config + +#define IPC_GETOUTPUTPLUGIN 625 + +#define IPC_SETDRAWBORDERS 626 +#define IPC_DISABLESKINCURSORS 627 +#define IPC_CB_RESETFONT 629 + +#define IPC_IS_FULLSCREEN 630 // returns 1 if video or vis is in fullscreen mode +#define IPC_SET_VIS_FS_FLAG 631 // a vis should send this message with 1/as param to notify winamp that it has gone to or has come back from fullscreen mode + +#define IPC_SHOW_NOTIFICATION 632 + +#define IPC_GETSKININFO 633 + +#define IPC_GET_MANUALPLADVANCE 634 +/* (requires Winamp 5.03+) +** val=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_MANUALPLADVANCE); +** +** IPC_GET_MANUALPLADVANCE returns the status of the Manual Playlist Advance (1 if set) +*/ + +#define IPC_SET_MANUALPLADVANCE 635 +/* (requires Winamp 5.03+) +** SendMessage(hwnd_winamp,WM_WA_IPC,value,IPC_SET_MANUALPLADVANCE); +** +** IPC_SET_MANUALPLADVANCE sets the status of the Manual Playlist Advance option (1 to turn it on) +*/ + +#define IPC_GET_NEXT_PLITEM 636 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_EOF_GET_NEXT_PLITEM); +** +** Sent to Winamp's main window when an item has just finished playback or the next button has been pressed and +** requesting the new playlist item number to go to. +** Mainly used by gen_jumpex. Subclass this message in your application to return the new item number. +** -1 for normal winamp operation (default) or the new item number in the playlist to play. +*/ + +#define IPC_GET_PREVIOUS_PLITEM 637 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_EOF_GET_PREVIOUS_PLITEM); +** +** Sent to Winamp's main window when the previous button has been pressed and Winamp is requesting the new playlist item number to go to. +** Mainly used by gen_jumpex. Subclass this message in your application to return the new item number. +** -1 for normal winamp operation (default) or the new item number in the playlist to play. +*/ + +#define IPC_IS_WNDSHADE 638 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,wnd,IPC_IS_WNDSHADE); +** +** 'wnd' is window id as defined for IPC_GETWND, or -1 for main window +** Returns 1 if wnd is set to winshade mode, or 0 if it is not +*/ + +#define IPC_SETRATING 639 +/* (requires Winamp 5.04+ with ML) +** SendMessage(hwnd_winamp,WM_WA_IPC,rating,IPC_SETRATING); +** 'rating' is an int value from 0 (no rating) to 5 +*/ + +#define IPC_GETRATING 640 +/* (requires Winamp 5.04+ with ML) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETRATING); +** returns the current item's rating +*/ + +#define IPC_GETNUMAUDIOTRACKS 641 +/* (requires Winamp 5.04+) +** int n = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETNUMAUDIOTRACKS); +** returns the number of audio tracks for the currently playing item +*/ + +#define IPC_GETNUMVIDEOTRACKS 642 +/* (requires Winamp 5.04+) +** int n = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETNUMVIDEOTRACKS); +** returns the number of video tracks for the currently playing item +*/ + +#define IPC_GETAUDIOTRACK 643 +/* (requires Winamp 5.04+) +** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETAUDIOTRACK); +** returns the id of the current audio track for the currently playing item +*/ + +#define IPC_GETVIDEOTRACK 644 +/* (requires Winamp 5.04+) +** int cur = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVIDEOTRACK); +** returns the id of the current video track for the currently playing item +*/ + +#define IPC_SETAUDIOTRACK 645 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,track,IPC_SETAUDIOTRACK); +** switch the currently playing item to a new audio track +*/ + +#define IPC_SETVIDEOTRACK 646 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,track,IPC_SETVIDEOTRACK); +** switch the currently playing item to a new video track +*/ + +#define IPC_PUSH_DISABLE_EXIT 647 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_PUSH_DISABLE_EXIT ); +** lets you disable or re-enable the UI exit functions (close button, +** context menu, alt-f4). +** call IPC_POP_DISABLE_EXIT when you are done doing whatever required +** preventing exit +*/ + +#define IPC_POP_DISABLE_EXIT 648 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_POP_DISABLE_EXIT ); +** see IPC_PUSH_DISABLE_EXIT +*/ + +#define IPC_IS_EXIT_ENABLED 649 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_EXIT_ENABLED); +** returns 0 if exit is disabled, 1 otherwise +*/ + +#define IPC_IS_AOT 650 +/* (requires Winamp 5.04+) +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_IS_AOT); +** returns status of always on top flag. note: this may not match the actual +** TOPMOST window flag while another fullscreen application is focused +*/ + +#define IPC_USES_RECYCLEBIN 651 +/* +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USES_RECYCLEBIN); +** returns 1 if deleted files should be sent to the recycle bin. +** returns 0 if deleted files should be deleted permanently. +** +** You should check for this option if your plugin deletes files +** so that your setting matches the winamp setting +*/ + +#define IPC_FLUSHAUDITS 652 +/* +** SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_FLUSHAUDITS); +** +** Will flush any pending audits in the global audits que +** +*/ + +#define IPC_GETPLAYITEM_START 653 +#define IPC_GETPLAYITEM_END 654 + + +#define IPC_GETVIDEORESIZE 655 +#define IPC_SETVIDEORESIZE 656 + +// >>>>>>>>>>> Next is 657 + +#define IPC_PLCMD 1000 + +#define PLCMD_ADD 0 +#define PLCMD_REM 1 +#define PLCMD_SEL 2 +#define PLCMD_MISC 3 +#define PLCMD_LIST 4 + +//#define IPC_MBCMD 1001 + +#define MBCMD_BACK 0 +#define MBCMD_FORWARD 1 +#define MBCMD_STOP 2 +#define MBCMD_RELOAD 3 +#define MBCMD_MISC 4 + +#define IPC_VIDCMD 1002 + +#define VIDCMD_FULLSCREEN 0 +#define VIDCMD_1X 1 +#define VIDCMD_2X 2 +#define VIDCMD_LIB 3 +#define VIDPOPUP_MISC 4 + +//#define IPC_MBURL 1003 //sets the URL +//#define IPC_MBGETCURURL 1004 //copies the current URL into wParam (have a 4096 buffer ready) +//#define IPC_MBGETDESC 1005 //copies the current URL description into wParam (have a 4096 buffer ready) +//#define IPC_MBCHECKLOCFILE 1006 //checks that the link file is up to date (otherwise updates it). wParam=parent HWND +//#define IPC_MBREFRESH 1007 //refreshes the "now playing" view in the library +//#define IPC_MBGETDEFURL 1008 //copies the default URL into wParam (have a 4096 buffer ready) + +#define IPC_STATS_LIBRARY_ITEMCNT 1300 // updates library count status + +// IPC 2000-3000 reserved for freeform messages, see gen_ff/ff_ipc.h +#define IPC_FF_FIRST 2000 +#define IPC_FF_LAST 3000 + + +/* +** General IPC messages in Winamp +** +** All notification messages appear in the lParam of the main window message proceedure. +*/ + + +#define IPC_GETDROPTARGET 3001 +/* (requires Winamp 5.0+) +** IDropTarget* IDrop = (IDropTarget*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETDROPTARGET); +** +** You call this to retrieve a copy of the IDropTarget interface which Winamp created for +** handling external drag and drop operations on to it's Windows. This is only really +** useful if you're providing an alternate interface and want your Windows to provide the +** same drag and drop support as Winamp normally provides the user. Check out MSDN or +** your prefered search facility for more information about the IDropTarget interface and +** what's needed to handle it in your own instance. +*/ + +#define IPC_PLAYLIST_MODIFIED 3002 +/* (requires Winamp 5.0+) +** This is a notification message sent to the main Winamp window whenever the playlist is +** modified in any way e.g. the addition/removal of a playlist entry. +** +** It is not a good idea to do large amounts of processing in this notification since it +** will slow down Winamp as playlist entries are modified (especially when you're adding +** in a large playlist). +** +** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYLIST_MODIFIED){ +** // do what you need to do here +** } +*/ + +#define IPC_PLAYING_FILE 3003 +/* (requires Winamp 5.0+) +** This is a notification message sent to the main Winamp window when playback begins for +** a file. This passes the full filepath in the wParam of the message received. +** +** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYING_FILE){ +** // do what you need to do here, e.g. +** process_file((char*)wParam); +** } +*/ + +#define IPC_PLAYING_FILEW 13003 +/* (requires Winamp 5.0+) +** This is a notification message sent to the main Winamp window when playback begins for +** a file. This passes the full filepath in the wParam of the message received. +** +** if(uMsg == WM_WA_IPC && lParam == IPC_PLAYING_FILEW){ +** // do what you need to do here, e.g. +** process_file((wchar_t*)wParam); +** } +*/ + +#define IPC_FILE_TAG_MAY_HAVE_UPDATED 3004 // sent to main wnd with the file as parm (char *) whenever a file tag might be updated +#define IPC_FILE_TAG_MAY_HAVE_UPDATEDW 3005 // sent to main wnd with the file as parm (wchar_t *) whenever a file tag might be updated +/* (requires Winamp 5.0+) +** This is a notification message sent to the main Winamp window when a file's tag +** (e.g. id3) may have been updated. This appears to be sent when the InfoBox(..) function +** of the associated input plugin returns a 1 (which is the file information dialog/editor +** call normally). +** +** if(uMsg == WM_WA_IPC && lParam == IPC_FILE_TAG_MAY_HAVE_UPDATED){ +** // do what you need to do here, e.g. +** update_info_on_file_update((char*)wParam); +** } +*/ + +#define IPC_ALLOW_PLAYTRACKING 3007 +/* (requires Winamp 5.0+) +** SendMessage(hwnd_winamp,WM_WA_IPC,allow,IPC_ALLOW_PLAYTRACKING); +** Send allow as nonzero to allow play tracking and zero to disable the mode. +*/ + +#define IPC_HOOK_OKTOQUIT 3010 +/* (requires Winamp 5.0+) +** This is a notification message sent to the main Winamp window asking if it's okay to +** close or not. Return zero to prevent Winamp from closing or return anything non-zero +** to allow Winamp to close. +** +** The best implementation of this option is to let the message pass through to the +** original window proceedure since another plugin may want to have a say in the matter +** with regards to Winamp closing. +** +** if(uMsg == WM_WA_IPC && lParam == IPC_HOOK_OKTOQUIT){ +** // do what you need to do here, e.g. +** if(no_shut_down()){ +** return 1; +** } +** } +*/ + +#define IPC_WRITECONFIG 3011 +/* (requires Winamp 5.0+) +** SendMessage(hwnd_winamp,WM_WA_IPC,write_type,IPC_WRITECONFIG); +** +** Send write_type as 2 to write all config settings and the current playlist. +** +** Send write_type as 1 to write the playlist and common settings. +** This won't save the following ini settings:: +** +** defext, titlefmt, proxy, visplugin_name, dspplugin_name, check_ft_startup, +** visplugin_num, pe_fontsize, visplugin_priority, visplugin_autoexec, dspplugin_num, +** sticon, splash, taskbar, dropaotfs, ascb_new, ttips, riol, minst, whichicon, +** whichicon2, addtolist, snap, snaplen, parent, hilite, disvis, rofiob, shownumsinpl, +** keeponscreen, eqdsize, usecursors, fixtitles, priority, shuffle_morph_rate, +** useexttitles, bifont, inet_mode, ospb, embedwnd_freesize, no_visseh +** (the above was valid for 5.1) +** +** Send write_type as 0 to write the common and less common settings and no playlist. +*/ + +#define IPC_UPDATE_URL 3012 // pass the URL (char *) in lparam, will be free()'d on done. + +// pass a string to be the name to register, and returns a value > 65536, which is a unique value you can use +// for custom WM_WA_IPC messages. + +#define IPC_GET_RANDFUNC 3015 // returns a function to get a random number +/* (requires Winamp 5.1+) +** int (*randfunc)(void) = (int(*)(void))SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_GET_RANDFUNC); +** if(randfunc && randfunc != 1){ +** randfunc(); +** } +** +** This will return a positive 32-bit number (essentially 31-bit). +** The check for a returned value of 1 is because that's the default return value from +** SendMessage(..) when it is not handled so is good to check for it in this situation. +*/ + +#define IPC_METADATA_CHANGED 3017 +/* (requires Winamp 5.1+) +** int changed=SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)(char*)field,IPC_METADATA_CHANGED); +** a plugin can SendMessage this to winamp if internal metadata has changes. +** wParam should be a char * of what field changed +** +** Currently used for internal actions (and very few at that) the intent of this api is +** to allow a plugin to call it when metadata has changed in the current playlist entry +** e.g.a new id3v2 tag was found in a stream +** +** The wparam value can either be NULL or a pointer to an ansi string for the metadata +** which has changed. This can be thought of as an advanced version of IPC_UPDTITLE and +** could be used to allow for update of the current title when a specific tag changed. +** +** Not recommended to be used since there is not the complete handling implemented in +** Winamp for it at the moment. +*/ + +#define IPC_SKIN_CHANGED 3018 +/* (requires Winamp 5.1+) +** This is a notification message sent to the main Winamp window by itself whenever +** the skin in use is changed. There is no information sent by the wParam for this. +** +** if(message == WM_WA_IPC && lparam == IPC_SKIN_CHANGED){ +** // do what you need to do to handle skin changes, e.g. call WADlg_init(hwnd_winamp); +** } +*/ + +#define IPC_REGISTER_LOWORD_COMMAND 3019 +/* (requires Winamp 5.1+) +** WORD id = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_REGISTER_LOWORD_COMMAND); +** This will assign you a unique id for making your own commands such as for extra menu +** entries. The starting value returned by this message will potentially change as and +** when the main resource file of Winamp is updated with extra data so assumptions cannot +** be made on what will be returned and plugin loading order will affect things as well. + +** 5.33+ +** If you want to reserve more than one id, you can pass the number of ids required in wParam +*/ + +#define IPC_GET_DISPATCH_OBJECT 3020 // gets winamp main IDispatch * (for embedded webpages) +#define IPC_GET_UNIQUE_DISPATCH_ID 3021 // gives you a unique dispatch ID that won't conflict with anything in winamp's IDispatch * + +#define IPC_ADD_DISPATCH_OBJECT 3022 // add your own dispatch object into winamp's. This lets embedded webpages access your functions +// pass a pointer to DispatchInfo (see below). Winamp makes a copy of all this data so you can safely delete it later +typedef struct +{ + wchar_t *name; // filled in by plugin, make sure it's a unicode string!! (i.e. L"myObject" instead of "myObject). + struct IDispatch *dispatch; // filled in by plugin + DWORD id; // filled in by winamp on return +} DispatchInfo; + +#define IPC_GET_PROXY_STRING 3023 +/* (requires Winamp 5.11+) +** char* proxy_string=(char*)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_PROXY_STRING); +** This will return the same string as is shown on the General Preferences page. +*/ + +#define IPC_USE_REGISTRY 3024 +/* (requires Winamp 5.11+) +** int reg_enabled=SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_USE_REGISTRY); +** This will return 0 if you should leave your grubby hands off the registry (i.e. for +** lockdown mode). This is useful if Winamp is run from a USB drive and you can't alter +** system settings, etc. +*/ + +#define IPC_GET_API_SERVICE 3025 +/* (requires Winamp 5.12+) +** api_service* api_service = (api_service)SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_API_SERVICE); +** This api will return Winamp's api_service pointer (which is what Winamp3 used, heh). +** If this api is not supported in the Winamp version that is being used at the time then +** the returned value from this api will be 1 which is a good version check. +** +** As of 5.12 there is support for .w5s plugins which reside in %WinampDir%\System and +** are intended for common code that can be shared amongst other plugins e.g. jnetlib.w5s +** which contains jnetlib in one instance instead of being duplicated multiple times in +** all of the plugins which need internet access. +** +** Details on the .w5s specifications will come at some stage (possibly). +*/ + + + +typedef struct { + const wchar_t *filename; + const wchar_t *metadata; + wchar_t *ret; + size_t retlen; +} extendedFileInfoStructW; + +#define IPC_GET_EXTENDED_FILE_INFOW 3026 +/* (requires Winamp 5.13+) +** Pass a pointer to the above struct in wParam +*/ +#define IPC_GET_EXTENDED_FILE_INFOW_HOOKABLE 3027 +#define IPC_SET_EXTENDED_FILE_INFOW 3028 +/* (requires Winamp 5.13+) +** Pass a pointer to the above struct in wParam +*/ + +#define IPC_PLAYLIST_GET_NEXT_SELECTED 3029 +/* (requires 5.2+) +** int pl_item = SendMessage(hwnd_winamp,WM_WA_IPC,start,IPC_PLAYLIST_GET_NEXT_SELECTED); +** +** This works just like the ListView_GetNextItem(..) macro for ListView controls. +** 'start' is the index of the playlist item that you want to begin the search after or +** set this as -1 for the search to begin with the first item of the current playlist. +** +** This will return the index of the selected playlist according to the 'start' value or +** it returns -1 if there is no selection or no more selected items according to 'start'. +** +** Quick example: +** +** int sel = -1; +** // keep incrementing the start of the search so we get all of the selected entries +** while((sel = SendMessage(hwnd_winamp,WM_WA_IPC,sel,IPC_PLAYLIST_GET_NEXT_SELECTED))!=-1){ +** // show the playlist file entry of the selected item(s) if there were any +** MessageBox(hwnd_winamp,(char*)SendMessage(hwnd_winamp,WM_WA_IPC,sel,IPC_GETPLAYLISTFILE),0,0); +** } +*/ + +#define IPC_PLAYLIST_GET_SELECTED_COUNT 3030 +/* (requires 5.2+) +** int selcnt = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_PLAYLIST_GET_SELECTED_COUNT); +** This will return the number of selected playlist entries. +*/ + +#define IPC_GET_PLAYING_FILENAME 3031 // returns wchar_t * of the currently playing filename + +#define IPC_OPEN_URL 3032 // send either ANSI or Unicode string (it'll figure it out, but it MUST start with "h"!, so don't send ftp:// or anything funny) + +#define IPC_REGISTER_WINAMP_IPCMESSAGE 65536 +/* (requires Winamp 5.0+) +** DWORD id = SendMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)name,IPC_REGISTER_WINAMP_IPCMESSAGE); +** The value 'id' returned is > 65536 and is incremented on subsequent calls for unique +** 'name' values passed to it. By using the same 'name' in different plugins will allow a +** common runtime api to be provided for the currently running instance of Winamp +** e.g. +** PostMessage(hwnd_winamp,WM_WA_IPC,(WPARAM)my_param,registered_ipc); +** Have a look at wa_hotkeys.h for an example on how this api is used in practice for a +** custom WM_WA_IPC message. +** +** if(uMsg == WM_WA_IPC && lParam == id_from_register_winamp_ipcmessage){ +** // do things +** } +*/ + +#endif//_WA_IPC_H_ diff --git a/vendor/JavaWinampApi/1.1/cpp/wpcom.dev b/vendor/JavaWinampApi/1.1/cpp/wpcom.dev new file mode 100644 index 0000000..2c226a4 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/wpcom.dev @@ -0,0 +1,69 @@ +[Project] +FileName=wpcom.dev +Name=wpcom +UnitCount=2 +Type=3 +Ver=1 +ObjFiles= +Includes="E:\Program Files\Java\jdk1.6.0_11\include";"E:\Program Files\Java\jdk1.6.0_11\include\win32" +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler=-DBUILDING_DLL=1_@@_ +CppCompiler=-DBUILDING_DLL=1_@@_ +Linker=--no-export-all-symbols --add-stdcall-alias_@@_ +IsCpp=0 +Icon= +ExeOutput=..\..\..\JavaWinampAPI +ObjectOutput= +OverrideOutput=1 +OverrideOutputName=wpcom.dll +HostApplication= +Folders= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000000 + +[Unit1] +FileName=WinampController.c +CompileCpp=0 +Folder=wacon +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd=$(CC) -c WinampController.c -o WinampController.o $(CFLAGS) + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Developed using the Dev-C++ IDE +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + +[Unit2] +FileName=WinampController.h +CompileCpp=0 +Folder=wacon +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/vendor/JavaWinampApi/1.1/cpp/wpcom.layout b/vendor/JavaWinampApi/1.1/cpp/wpcom.layout new file mode 100644 index 0000000..fc89c00 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/cpp/wpcom.layout @@ -0,0 +1,17 @@ +[Editor_0] +CursorCol=32 +CursorRow=359 +TopLine=338 +LeftChar=1 +Open=1 +Top=1 +[Editors] +Focused=0 +Order=1,0 +[Editor_1] +Open=1 +Top=0 +CursorCol=73 +CursorRow=143 +TopLine=127 +LeftChar=1 diff --git a/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/InvalidHandle.java b/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/InvalidHandle.java new file mode 100644 index 0000000..4785982 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/InvalidHandle.java @@ -0,0 +1,40 @@ +/* + * InvalidHandle.java + * + * Created on 9 de Outubro de 2007, 14:18 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.qotsa.exception; + +/** + * Exception to throw when Winamp Handle Fails. + * + * @author Francisco + */ +public class InvalidHandle extends Exception{ + + private static final String defaultMessage = "Invalid Handle. Please Verify if Winamp is running."; + + /** + * Creates a new instance of InvalidHandle + * @param message Message to print in the stack. + */ + public InvalidHandle(String message) { + + super(message); + + } + + /** + * Creates a new instance of InvalidHandle with the default message + */ + public InvalidHandle() { + + super(defaultMessage); + + } + +} diff --git a/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/InvalidParameter.java b/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/InvalidParameter.java new file mode 100644 index 0000000..3499308 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/InvalidParameter.java @@ -0,0 +1,40 @@ +/* + * InvalidParameter.java + * + * Created on 11 de Outubro de 2007, 10:53 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.qotsa.exception; + +/** + * Exception to throw when any parameter is invalid. + * + * @author Francisco + */ +public class InvalidParameter extends Exception { + + private static final String defaultMessage = "Invalid Parameter"; + + /** + * Creates a new instance of NegativeValueException + * @param message Message to print in the stack. + */ + public InvalidParameter(String message) { + + super(message); + + } + + /** + * Creates a new instance of NegativeValueException with the default message + */ + public InvalidParameter() { + + super(defaultMessage); + + } + +} diff --git a/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/package.html b/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/package.html new file mode 100644 index 0000000..b2aafb7 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/java/com/qotsa/exception/package.html @@ -0,0 +1,20 @@ + + + + + + + +Package containing the Exception Class used in the WinampController Class. + + +

Package Specification

+ + + + + diff --git a/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/JNIWinamp.java b/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/JNIWinamp.java new file mode 100644 index 0000000..8da725e --- /dev/null +++ b/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/JNIWinamp.java @@ -0,0 +1,227 @@ +/* + * JNIWinamp.java + * + * Created on 23 de Abril de 2007, 20:41 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package com.qotsa.jni.controller; + +import java.io.IOException; + +/** + * + * @author Francisco Guimarães + */ +final class JNIWinamp { + + static { + System.loadLibrary("wpcom"); + } + + /** + * Verify if Winamp is started + * and if not started, starts it + * @return True - if successful run Winamp + * False - if not successful run Winamp + */ + + protected static native boolean run() throws UnsatisfiedLinkError; + + /* + * Exit Winamp + * @return True - if successful exit + * False - if not successful exit + */ + protected static native boolean exit() throws UnsatisfiedLinkError; + + /** + * Play Winamp. + * + */ + protected static native boolean play() throws UnsatisfiedLinkError; + + /** + * Stop Winamp. + * + */ + protected static native boolean stop() throws UnsatisfiedLinkError; + + /** + * Resume Winamp. + * + */ + protected static native boolean resume() throws UnsatisfiedLinkError; + + /** + * Pause Winamp. + * + */ + protected static native boolean pause() throws UnsatisfiedLinkError; + + /** + * Go to Previous Track. + * + */ + protected static native boolean previousTrack() throws UnsatisfiedLinkError; + + /** + * Go to Next Track. + * + */ + protected static native boolean nextTrack() throws UnsatisfiedLinkError; + + /** + * Fowards 5 seconds on the current song. + * + */ + protected static native boolean fwd5Secs() throws UnsatisfiedLinkError; + + /** + * Rewinds 5 seconds on the current song. + * + */ + protected static native boolean rew5Secs() throws UnsatisfiedLinkError; + + /** + * Increase Volume. + * + */ + protected static native boolean increaseVolume() throws UnsatisfiedLinkError; + + /** + * Decrease Volume. + * + */ + protected static native boolean decreaseVolume() throws UnsatisfiedLinkError; + + /** + * Increase Volume. + * @param percent Percent to Increase. + */ + protected static native boolean increaseVolumePercent(int percent) throws UnsatisfiedLinkError; + + /** + * Decrease Volume. + * @param percent Percent to Decrease. + */ + protected static native boolean decreaseVolumePercent(int percent) throws UnsatisfiedLinkError; + + /** + * Adjust Volume + * @param pos Position to Set Volume between 0 and 99. + */ + protected static native boolean setVolume(int pos) throws UnsatisfiedLinkError; + + /** + * Get Volume. + * @return volume. + */ + protected static native int getVolume() throws UnsatisfiedLinkError; + + /** + * Go to a Specified Position in the List. + * @param pos Position. + */ + protected static native boolean setPlaylistPosition(int pos) throws UnsatisfiedLinkError; + + /** + * Clear List. + * + */ + protected static native boolean clearPlayList() throws UnsatisfiedLinkError; + + /** + * Refresh List´s Cache. + * + */ + protected static native boolean refreshPlayListCache() throws UnsatisfiedLinkError; + + /** + * Return the PlayListLength. + * @return List Length. + */ + protected static native int getPlayListLength() throws UnsatisfiedLinkError; + + /** + * Write a Playlist in \\Winamp.m3u. + * @return List Position. + */ + protected static native int writePlayListToFile() throws UnsatisfiedLinkError; + + /** + * Verify if Shuffle is On. + * @return True - On throws UnsatisfiedLinkError; False - Off. + */ + protected static native int isShuffleStatusOn() throws UnsatisfiedLinkError; + + /** + * Verify if Repeat is On. + * @return True - On throws UnsatisfiedLinkError; False - Off. + */ + protected static native int isRepeatStatusOn() throws UnsatisfiedLinkError; + + /** + * Turn on Repeat. + * @param True - Turn on Repeat throws UnsatisfiedLinkError; False - Turn off Repeat. + */ + protected static native boolean setRepeatStatusOn(boolean mode) throws UnsatisfiedLinkError; + + /** + * Turn on Shuffle. + * @param True - Turn on Shuffle throws UnsatisfiedLinkError; False - Turn off Shuffle. + */ + protected static native boolean setShuffleStatusOn(boolean mode) throws UnsatisfiedLinkError; + + /** + * Append a File in the List + * @param filename FileName to Append. + */ + protected static native boolean appendToPlayList(String filename) throws UnsatisfiedLinkError; + + /** + * Get Winamp Status. + * @return STOPPED - Stop + * PLAYING - play + * PAUSED - Paused + */ + protected static native int getStatus() throws UnsatisfiedLinkError; + + /** + * Get Current List Pos. + * @return Current List Position. + */ + protected static native int getListPos() throws UnsatisfiedLinkError; + + /** + * Get Current Track Title + * @return Current Track Title + */ + protected static native String getTitle() throws UnsatisfiedLinkError; + + /** + * Get Track FileName in List´s index. + * @param index Track Index in the Current PlayList + * @return Current Track FileName + */ + protected static native String getFileNameInList(int index) throws UnsatisfiedLinkError; + + /** + * Get Song Time + * @param mode CURRENTTIME - Currently Time in Milliseconds + * TIMELENGHT - Song Time Length in seconds + * @return Song Time in Seconds + */ + protected static native int getTime(int mode) throws UnsatisfiedLinkError; + + /** + * Get File Name Playing In Winamp. + * + * @return Current File Name. + */ + protected static native String getFileNamePlaying() throws UnsatisfiedLinkError; + +} + diff --git a/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/WinampController.java b/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/WinampController.java new file mode 100644 index 0000000..159fd9c --- /dev/null +++ b/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/WinampController.java @@ -0,0 +1,592 @@ +/* + * WinampController.java + * + * Created on 9 de Outubro de 2007, 14:06 + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +/** + * Package containing the Controller Class to communicate with Winamp. + * + * @author Francisco Guimarães + */ +package com.qotsa.jni.controller; + +import com.qotsa.exception.InvalidHandle; +import com.qotsa.exception.InvalidParameter; +import java.io.File; + +/** + * This class is a wrapper to call JNI functions + * to send Message to Winamp Window. + * + * @author Francisco Guimarães + * + * + */ +public class WinampController { + + /** + * Constant used as return in getTime() + * Value = -1 + */ + public static final int ISNOTPLAYING = -1; + + /** + * Constant used as parameter in getTime() method + * Value = 0 + */ + public static final int CURRENTTIME = 0; + + /** + * Constant used as parameter in getTime() method + * Value = 1 + */ + public static final int TIMELENGTH = 1; + + /** + * Constant used as return in getStatus() method + * Value = 0 + */ + public static final int STOPPED = 0; + + /** + * Constant used as return in getStatus() method + * Value = 1 + */ + public static final int PLAYING = 1; + + /** + * Constant used as return in getStatus() method + * Value = 3 + */ + public static final int PAUSED = 3; + + + /** + * Verify if Winamp is started + * and if not started, starts it. + * + * @throws java.lang.Exception When the key HKEY_LOCAL_MACHINE\Software\Clients\Media\Winamp\shell\open\command + * is not found in the register. This key is used to find Winamp Directory installation to execute it. + */ + + public static void run() throws Exception{ + + if (!JNIWinamp.run()) + throw new Exception("Unable to run Winamp. Verify if it is properly installed"); + + } + + /** + * Exit Winamp. + * + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void exit() throws InvalidHandle { + + if (!JNIWinamp.exit()) + throw new InvalidHandle(); + + + } + + /** + * Play current file in Winamp. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void play() throws InvalidHandle { + + if (!JNIWinamp.play()) + throw new InvalidHandle(); + + } + + /** + * Stop current file in Winamp. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void stop() throws InvalidHandle { + + if (!JNIWinamp.stop()) + throw new InvalidHandle(); + + } + + /** + * Resume current file in Winamp. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void resume() throws InvalidHandle { + + if (!JNIWinamp.resume()) + throw new InvalidHandle(); + + } + + /** + * Pause Winamp. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void pause() throws InvalidHandle { + + if (!JNIWinamp.pause()) + throw new InvalidHandle(); + + } + + /** + * + * Go to Previous Track in the play list. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void previousTrack() throws InvalidHandle { + + if (!JNIWinamp.previousTrack()) + throw new InvalidHandle(); + + } + + /** + * Go to Next Track in the play list. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void nextTrack() throws InvalidHandle { + + if (!JNIWinamp.nextTrack()) + throw new InvalidHandle(); + + } + + /** + * Fowards 5 seconds on the current song. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void fwd5Secs() throws InvalidHandle { + + if (!JNIWinamp.fwd5Secs()) + throw new InvalidHandle(); + + } + + /** + * Rewinds 5 seconds on the current song. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void rew5Secs() throws InvalidHandle { + + if (!JNIWinamp.rew5Secs()) + throw new InvalidHandle(); + + } + + /** + * Increase Volume a little bit. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void increaseVolume() throws InvalidHandle { + + if (!JNIWinamp.increaseVolume()) + throw new InvalidHandle(); + + } + + /** + * Decrease Volume a little bit. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void decreaseVolume() throws InvalidHandle { + + if (!JNIWinamp.decreaseVolume()) + throw new InvalidHandle(); + + } + + /** + * Increase Volume. + * + * @param percent Percent to Increase Volume. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter If percent not between 0 and 100 + */ + public static void increaseVolumePercent (int percent) throws InvalidHandle, InvalidParameter { + + if ( (percent < 0) || (percent > 100) ) + throw new InvalidParameter("percent´s value must be between 0 and 100"); + + if (!JNIWinamp.increaseVolumePercent(percent)) + throw new InvalidHandle(); + + } + + /** + * Decrease Volume. + * + * @param percent Percent to Decrease Volume. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter If percent not between 0 and 100 + */ + public static void decreaseVolumePercent(int percent) throws InvalidHandle, InvalidParameter { + + if ( (percent < 0) || (percent > 100) ) + throw new InvalidParameter("percent´s value must be between 0 and 100"); + if (!JNIWinamp.decreaseVolumePercent(percent)) + throw new InvalidHandle(); + + } + + /** + * Adjust Volume. + * Note that the pos must be between 0(0%) and 255 (100%). + * + * @param pos Position to Set Volume. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter If pos not between 0 and 255 + */ + public static void setVolume(int pos) throws InvalidHandle, InvalidParameter { + + if ( (pos < 0) || (pos > 255) ) + throw new InvalidParameter("pos value must be between 0 and 255"); + if (!JNIWinamp.setVolume(pos)) + throw new InvalidHandle(); + + } + + /** + * Get Volume. + * @return The volume which is a number between 0 (0%) and 255(100%) + * @throws com.qotsa.exception.InvalidHandle + */ + public static int getVolume() throws InvalidHandle { + int volume = JNIWinamp.getVolume(); + if (volume == -1) + throw new InvalidHandle(); + return volume; + } + + /** + * Get Volume Percent. + * @return Volume percent. + * @throws com.qotsa.exception.InvalidHandle + */ + public static int getVolumePercent() throws InvalidHandle { + + int volume = getVolume(); + int percent = (volume * 100) / 255; + return percent; + } + + /** + * Restarts Winamp. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws java.lang.Exception When failed to restart Winamp. + */ + public static void restart() throws InvalidHandle, Exception { + + exit(); + run(); + + } + + /** + * Go to a Specified Position in the List. This method doesn´t play. + * Just set list position. If you wanna play call play() after set position. + * Parameter pos is Zero-based index. + * @param pos Position. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter If pos is negative or greater than List Length. + */ + public static void setPlaylistPosition(int pos) throws InvalidHandle, InvalidParameter { + + int listLength = getPlayListLength(); + if ( (pos < 0) || ( (pos + 1) > listLength) ) + throw new InvalidParameter("Position is invalid in the list."); + if (!JNIWinamp.setPlaylistPosition(pos)) + throw new InvalidHandle(); + + } + + /** + * Clear Winamp's internal playlist. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void clearPlayList() throws InvalidHandle { + + if (!JNIWinamp.clearPlayList()) + throw new InvalidHandle(); + + } + + /** + * Flush the playlist cache buffer. + * Call this if you want it to go refetch titles for tracks in the list. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void refreshPlayListCache() throws InvalidHandle{ + + if (!JNIWinamp.refreshPlayListCache()) + throw new InvalidHandle(); + + } + + /** + * Return the PlayListLength. + * + * @return List Length. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static int getPlayListLength() throws InvalidHandle { + + int length = JNIWinamp.getPlayListLength(); + if (length == -1) + throw new InvalidHandle(); + return length; + + } + + /** + * Write a Playlist in winampDirInstallation\\Winamp.m3u. + * This is default Winamp IPC Default. If you wanna change this, + * just rename the file you´ve created. + * + * @return Current List Position. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static int writePlayListToFile() throws InvalidHandle { + + int playListPos = JNIWinamp.writePlayListToFile(); + if (playListPos == -1) + throw new InvalidHandle(); + return playListPos; + + } + + /** + * Verify if Shuffle is On. + * + * @return True - On ; False - Off. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static boolean isShuffleStatusOn() throws InvalidHandle { + + int status = JNIWinamp.isShuffleStatusOn(); + if (status == -1) + throw new InvalidHandle(); + return (status == 1 ? true : false); + + } + + /** + * Verify if Repeat is On. + * + * @return True - On ; False - Off. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static boolean isRepeatStatusOn() throws InvalidHandle { + + int status = JNIWinamp.isRepeatStatusOn(); + if (status == -1) + throw new InvalidHandle(); + return (status == 1 ? true : false); + + } + + /** + * Turn on Repeat. + * + * @param mode True - Turn on Repeat ; False - Turn off Repeat. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void setRepeatStatusOn(boolean mode) throws InvalidHandle { + + if (!JNIWinamp.setRepeatStatusOn(mode)) + throw new InvalidHandle(); + + } + + /** + * Turn on Shuffle. + * + * @param mode True - Turn on Shuffle ; False - Turn off Shuffle. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static void setShuffleStatusOn(boolean mode) throws InvalidHandle { + + if (!JNIWinamp.setShuffleStatusOn(mode)) + throw new InvalidHandle(); + + } + + /** + * Append a File into the List. + * + * @param filename FileName to Append in the list. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter If the filename is an invalid path. + */ + public static void appendToPlayList(String filename) throws InvalidHandle, InvalidParameter { + + File file = new File(filename); + if (!file.exists()) + throw new InvalidParameter("File doesn´t exists."); + if (!JNIWinamp.appendToPlayList(filename)) + throw new InvalidHandle(); + + } + + /** + * Get Winamp Status. + * + * @return STOPPED - Stop + * PLAYING - play + * PAUSED - Paused + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static int getStatus() throws InvalidHandle { + + int status = JNIWinamp.getStatus(); + if (status == -1) + throw new InvalidHandle(); + return status; + + } + + /** + * Get Current List Pos. + * + * @return Current List Position. + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static int getListPos() throws InvalidHandle { + + int pos = JNIWinamp.getListPos(); + if (pos == -1) + throw new InvalidHandle(); + return pos; + + } + + /** + * Get Current Track Title. + * + * @return Current Track Title + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + */ + public static String getTitle() throws InvalidHandle { + + String title = JNIWinamp.getTitle(); + if (title == null) + throw new InvalidHandle(); + return title; + + } + + /** + * Get Current Track FileName. + * Parameter pos is Zero-based index. + * + * @return Current Track FileName + * @param pos Track Position in the Current PlayList + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter If pos is negative or greater than List Length + */ + public static String getFileNameInList(int pos) throws InvalidHandle, InvalidParameter { + + int listLength = getPlayListLength(); + if ( (pos < 0) || (pos > listLength) ) + throw new InvalidParameter("Position is invalid in the list."); + String filename = JNIWinamp.getFileNameInList(pos); + if (filename == null) + throw new InvalidHandle(); + return filename; + + } + + /** + * Get Song Time. + * + * @return Time Song (depends on Param mode) or + * ISNOTPLAYING if there is no info about time because it not starts to play. + * @param mode CURRENTTIME - Currently Time in Milliseconds + * TIMELENGHT - Song Time Length in seconds + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter if parameter is not CURRENTTIME or TIMELENGTH. + */ + public static int getTime(int mode) throws InvalidHandle, InvalidParameter { + + if (mode != CURRENTTIME && mode != TIMELENGTH) + throw new InvalidParameter(); + int time = JNIWinamp.getTime(mode); + if (time == -2) + throw new InvalidHandle(); + return time; + + } + + /** + * Fowards n Tracks in Play List. + * + * @param n Number of Tracks to Foward + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter if n is negative or Zero. + */ + public static void fwdTracks(int n) throws InvalidParameter, InvalidHandle { + + if (n <= 0) + throw new InvalidParameter("Value must be Positive"); + int pos = getListPos(); + int lengthList = getPlayListLength(); + int newPos = pos + n; + if (newPos > lengthList ) { + setPlaylistPosition(lengthList); + play(); + } + else { + setPlaylistPosition(newPos); + play(); + } + + } + + /** + * Rewinds n Tracks in Play List. + * + * @param n Number of Tracks to Rewind + * @throws com.qotsa.exception.InvalidHandle When the Winamp Windows is not handle(in most case, it means that winamp is not running) + * @throws com.qotsa.exception.InvalidParameter if n is negative or Zero. + */ + public static void rewTracks(int n) throws InvalidParameter, InvalidHandle { + + if (n <= 0) + throw new InvalidParameter("Value must be Positive"); + int pos = getListPos(); + int lengthList = getPlayListLength(); + int newPos = pos - n; + if (newPos < 0 ) { + setPlaylistPosition(0); + play(); + } + else { + setPlaylistPosition(newPos); + play(); + } + + } + + /** + * Get File Name Playing In Winamp. + * + * @return Current File Name. + */ + public static String getFileNamePlaying() throws InvalidHandle { + + String fileName = JNIWinamp.getFileNamePlaying(); + if (fileName == null) + throw new InvalidHandle(); + return fileName; + + } + +} diff --git a/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/package.html b/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/package.html new file mode 100644 index 0000000..c78cf04 --- /dev/null +++ b/vendor/JavaWinampApi/1.1/java/com/qotsa/jni/controller/package.html @@ -0,0 +1,20 @@ + + + + + + + +Package containing the Controller Class to communicate with Winamp. + + +

Package Specification

+ + + + + diff --git a/vendor/commons-logging/1.1.1/commons-logging-1.1.1.jar b/vendor/commons-logging/1.1.1/commons-logging-1.1.1.jar new file mode 100644 index 0000000..8758a96 Binary files /dev/null and b/vendor/commons-logging/1.1.1/commons-logging-1.1.1.jar differ diff --git a/vendor/commons-logging/1.1.1/commons-logging-adapters-1.1.1.jar b/vendor/commons-logging/1.1.1/commons-logging-adapters-1.1.1.jar new file mode 100644 index 0000000..2f23c35 Binary files /dev/null and b/vendor/commons-logging/1.1.1/commons-logging-adapters-1.1.1.jar differ diff --git a/vendor/commons-logging/1.1.1/commons-logging-api-1.1.1.jar b/vendor/commons-logging/1.1.1/commons-logging-api-1.1.1.jar new file mode 100644 index 0000000..bd45116 Binary files /dev/null and b/vendor/commons-logging/1.1.1/commons-logging-api-1.1.1.jar differ diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/Log.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/Log.java new file mode 100644 index 0000000..1fef2f0 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/Log.java @@ -0,0 +1,246 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging; + +/** + *

A simple logging interface abstracting logging APIs. In order to be + * instantiated successfully by {@link LogFactory}, classes that implement + * this interface must have a constructor that takes a single String + * parameter representing the "name" of this Log.

+ * + *

The six logging levels used by Log are (in order): + *

    + *
  1. trace (the least serious)
  2. + *
  3. debug
  4. + *
  5. info
  6. + *
  7. warn
  8. + *
  9. error
  10. + *
  11. fatal (the most serious)
  12. + *
+ * The mapping of these log levels to the concepts used by the underlying + * logging system is implementation dependent. + * The implemention should ensure, though, that this ordering behaves + * as expected.

+ * + *

Performance is often a logging concern. + * By examining the appropriate property, + * a component can avoid expensive operations (producing information + * to be logged).

+ * + *

For example, + *

+ *    if (log.isDebugEnabled()) {
+ *        ... do something expensive ...
+ *        log.debug(theResult);
+ *    }
+ * 
+ *

+ * + *

Configuration of the underlying logging system will generally be done + * external to the Logging APIs, through whatever mechanism is supported by + * that system.

+ * + * @author Scott Sanders + * @author Rod Waldhoff + * @version $Id: Log.java 424107 2006-07-20 23:15:42Z skitching $ + */ +public interface Log { + + + // ----------------------------------------------------- Logging Properties + + + /** + *

Is debug logging currently enabled?

+ * + *

Call this method to prevent having to perform expensive operations + * (for example, String concatenation) + * when the log level is more than debug.

+ * + * @return true if debug is enabled in the underlying logger. + */ + public boolean isDebugEnabled(); + + + /** + *

Is error logging currently enabled?

+ * + *

Call this method to prevent having to perform expensive operations + * (for example, String concatenation) + * when the log level is more than error.

+ * + * @return true if error is enabled in the underlying logger. + */ + public boolean isErrorEnabled(); + + + /** + *

Is fatal logging currently enabled?

+ * + *

Call this method to prevent having to perform expensive operations + * (for example, String concatenation) + * when the log level is more than fatal.

+ * + * @return true if fatal is enabled in the underlying logger. + */ + public boolean isFatalEnabled(); + + + /** + *

Is info logging currently enabled?

+ * + *

Call this method to prevent having to perform expensive operations + * (for example, String concatenation) + * when the log level is more than info.

+ * + * @return true if info is enabled in the underlying logger. + */ + public boolean isInfoEnabled(); + + + /** + *

Is trace logging currently enabled?

+ * + *

Call this method to prevent having to perform expensive operations + * (for example, String concatenation) + * when the log level is more than trace.

+ * + * @return true if trace is enabled in the underlying logger. + */ + public boolean isTraceEnabled(); + + + /** + *

Is warn logging currently enabled?

+ * + *

Call this method to prevent having to perform expensive operations + * (for example, String concatenation) + * when the log level is more than warn.

+ * + * @return true if warn is enabled in the underlying logger. + */ + public boolean isWarnEnabled(); + + + // -------------------------------------------------------- Logging Methods + + + /** + *

Log a message with trace log level.

+ * + * @param message log this message + */ + public void trace(Object message); + + + /** + *

Log an error with trace log level.

+ * + * @param message log this message + * @param t log this cause + */ + public void trace(Object message, Throwable t); + + + /** + *

Log a message with debug log level.

+ * + * @param message log this message + */ + public void debug(Object message); + + + /** + *

Log an error with debug log level.

+ * + * @param message log this message + * @param t log this cause + */ + public void debug(Object message, Throwable t); + + + /** + *

Log a message with info log level.

+ * + * @param message log this message + */ + public void info(Object message); + + + /** + *

Log an error with info log level.

+ * + * @param message log this message + * @param t log this cause + */ + public void info(Object message, Throwable t); + + + /** + *

Log a message with warn log level.

+ * + * @param message log this message + */ + public void warn(Object message); + + + /** + *

Log an error with warn log level.

+ * + * @param message log this message + * @param t log this cause + */ + public void warn(Object message, Throwable t); + + + /** + *

Log a message with error log level.

+ * + * @param message log this message + */ + public void error(Object message); + + + /** + *

Log an error with error log level.

+ * + * @param message log this message + * @param t log this cause + */ + public void error(Object message, Throwable t); + + + /** + *

Log a message with fatal log level.

+ * + * @param message log this message + */ + public void fatal(Object message); + + + /** + *

Log an error with fatal log level.

+ * + * @param message log this message + * @param t log this cause + */ + public void fatal(Object message, Throwable t); + + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogConfigurationException.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogConfigurationException.java new file mode 100644 index 0000000..419725d --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogConfigurationException.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.logging; + + +/** + *

An exception that is thrown only if a suitable LogFactory + * or Log instance cannot be created by the corresponding + * factory methods.

+ * + * @author Craig R. McClanahan + * @version $Revision: 424107 $ $Date: 2006-07-21 01:15:42 +0200 (fr, 21 jul 2006) $ + */ + +public class LogConfigurationException extends RuntimeException { + + + /** + * Construct a new exception with null as its detail message. + */ + public LogConfigurationException() { + + super(); + + } + + + /** + * Construct a new exception with the specified detail message. + * + * @param message The detail message + */ + public LogConfigurationException(String message) { + + super(message); + + } + + + /** + * Construct a new exception with the specified cause and a derived + * detail message. + * + * @param cause The underlying cause + */ + public LogConfigurationException(Throwable cause) { + + this((cause == null) ? null : cause.toString(), cause); + + } + + + /** + * Construct a new exception with the specified detail message and cause. + * + * @param message The detail message + * @param cause The underlying cause + */ + public LogConfigurationException(String message, Throwable cause) { + + super(message + " (Caused by " + cause + ")"); + this.cause = cause; // Two-argument version requires JDK 1.4 or later + + } + + + /** + * The underlying cause of this exception. + */ + protected Throwable cause = null; + + + /** + * Return the underlying cause of this exception (if any). + */ + public Throwable getCause() { + + return (this.cause); + + } + + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogFactory.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogFactory.java new file mode 100644 index 0000000..60522af --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogFactory.java @@ -0,0 +1,1824 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.logging; + + +import java.io.BufferedReader; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Properties; + + +/** + *

Factory for creating {@link Log} instances, with discovery and + * configuration features similar to that employed by standard Java APIs + * such as JAXP.

+ * + *

IMPLEMENTATION NOTE - This implementation is heavily + * based on the SAXParserFactory and DocumentBuilderFactory implementations + * (corresponding to the JAXP pluggability APIs) found in Apache Xerces.

+ * + * @author Craig R. McClanahan + * @author Costin Manolache + * @author Richard A. Sitze + * @version $Revision: 593798 $ $Date: 2007-11-10 18:40:43 +0100 $ + */ + +public abstract class LogFactory { + // Implementation note re AccessController usage + // + // It is important to keep code invoked via an AccessController to small + // auditable blocks. Such code must carefully evaluate all user input + // (parameters, system properties, config file contents, etc). As an + // example, a Log implementation should not write to its logfile + // with an AccessController anywhere in the call stack, otherwise an + // insecure application could configure the log implementation to write + // to a protected file using the privileges granted to JCL rather than + // to the calling application. + // + // Under no circumstance should a non-private method return data that is + // retrieved via an AccessController. That would allow an insecure app + // to invoke that method and obtain data that it is not permitted to have. + // + // Invoking user-supplied code with an AccessController set is not a major + // issue (eg invoking the constructor of the class specified by + // HASHTABLE_IMPLEMENTATION_PROPERTY). That class will be in a different + // trust domain, and therefore must have permissions to do whatever it + // is trying to do regardless of the permissions granted to JCL. There is + // a slight issue in that untrusted code may point that environment var + // to another trusted library, in which case the code runs if both that + // lib and JCL have the necessary permissions even when the untrusted + // caller does not. That's a pretty hard route to exploit though. + + + // ----------------------------------------------------- Manifest Constants + + /** + * The name (priority) of the key in the config file used to + * specify the priority of that particular config file. The associated value + * is a floating-point number; higher values take priority over lower values. + */ + public static final String PRIORITY_KEY = "priority"; + + /** + * The name (use_tccl) of the key in the config file used + * to specify whether logging classes should be loaded via the thread + * context class loader (TCCL), or not. By default, the TCCL is used. + */ + public static final String TCCL_KEY = "use_tccl"; + + /** + * The name (org.apache.commons.logging.LogFactory) of the property + * used to identify the LogFactory implementation + * class name. This can be used as a system property, or as an entry in a + * configuration properties file. + */ + public static final String FACTORY_PROPERTY = + "org.apache.commons.logging.LogFactory"; + + /** + * The fully qualified class name of the fallback LogFactory + * implementation class to use, if no other can be found. + */ + public static final String FACTORY_DEFAULT = + "org.apache.commons.logging.impl.LogFactoryImpl"; + + /** + * The name (commons-logging.properties) of the properties file to search for. + */ + public static final String FACTORY_PROPERTIES = + "commons-logging.properties"; + + /** + * JDK1.3+ + * 'Service Provider' specification. + * + */ + protected static final String SERVICE_ID = + "META-INF/services/org.apache.commons.logging.LogFactory"; + + /** + * The name (org.apache.commons.logging.diagnostics.dest) + * of the property used to enable internal commons-logging + * diagnostic output, in order to get information on what logging + * implementations are being discovered, what classloaders they + * are loaded through, etc. + *

+ * If a system property of this name is set then the value is + * assumed to be the name of a file. The special strings + * STDOUT or STDERR (case-sensitive) indicate output to + * System.out and System.err respectively. + *

+ * Diagnostic logging should be used only to debug problematic + * configurations and should not be set in normal production use. + */ + public static final String DIAGNOSTICS_DEST_PROPERTY = + "org.apache.commons.logging.diagnostics.dest"; + + /** + * When null (the usual case), no diagnostic output will be + * generated by LogFactory or LogFactoryImpl. When non-null, + * interesting events will be written to the specified object. + */ + private static PrintStream diagnosticsStream = null; + + /** + * A string that gets prefixed to every message output by the + * logDiagnostic method, so that users can clearly see which + * LogFactory class is generating the output. + */ + private static String diagnosticPrefix; + + /** + *

Setting this system property + * (org.apache.commons.logging.LogFactory.HashtableImpl) + * value allows the Hashtable used to store + * classloaders to be substituted by an alternative implementation. + *

+ *

+ * Note: LogFactory will print: + *

+     * [ERROR] LogFactory: Load of custom hashtable failed
+     * 
+ * to system error and then continue using a standard Hashtable. + *

+ *

+ * Usage: Set this property when Java is invoked + * and LogFactory will attempt to load a new instance + * of the given implementation class. + * For example, running the following ant scriplet: + *

+     *  <java classname="${test.runner}" fork="yes" failonerror="${test.failonerror}">
+     *     ...
+     *     <sysproperty 
+     *        key="org.apache.commons.logging.LogFactory.HashtableImpl"
+     *        value="org.apache.commons.logging.AltHashtable"/>
+     *  </java>
+     * 
+ * will mean that LogFactory will load an instance of + * org.apache.commons.logging.AltHashtable. + *

+ *

+ * A typical use case is to allow a custom + * Hashtable implementation using weak references to be substituted. + * This will allow classloaders to be garbage collected without + * the need to release them (on 1.3+ JVMs only, of course ;) + *

+ */ + public static final String HASHTABLE_IMPLEMENTATION_PROPERTY = + "org.apache.commons.logging.LogFactory.HashtableImpl"; + /** Name used to load the weak hashtable implementation by names */ + private static final String WEAK_HASHTABLE_CLASSNAME = + "org.apache.commons.logging.impl.WeakHashtable"; + + /** + * A reference to the classloader that loaded this class. This is the + * same as LogFactory.class.getClassLoader(). However computing this + * value isn't quite as simple as that, as we potentially need to use + * AccessControllers etc. It's more efficient to compute it once and + * cache it here. + */ + private static ClassLoader thisClassLoader; + + // ----------------------------------------------------------- Constructors + + + /** + * Protected constructor that is not available for public use. + */ + protected LogFactory() { + } + + // --------------------------------------------------------- Public Methods + + + /** + * Return the configuration attribute with the specified name (if any), + * or null if there is no such attribute. + * + * @param name Name of the attribute to return + */ + public abstract Object getAttribute(String name); + + + /** + * Return an array containing the names of all currently defined + * configuration attributes. If there are no such attributes, a zero + * length array is returned. + */ + public abstract String[] getAttributeNames(); + + + /** + * Convenience method to derive a name from the specified class and + * call getInstance(String) with it. + * + * @param clazz Class for which a suitable Log name will be derived + * + * @exception LogConfigurationException if a suitable Log + * instance cannot be returned + */ + public abstract Log getInstance(Class clazz) + throws LogConfigurationException; + + + /** + *

Construct (if necessary) and return a Log instance, + * using the factory's current set of configuration attributes.

+ * + *

NOTE - Depending upon the implementation of + * the LogFactory you are using, the Log + * instance you are returned may or may not be local to the current + * application, and may or may not be returned again on a subsequent + * call with the same name argument.

+ * + * @param name Logical name of the Log instance to be + * returned (the meaning of this name is only known to the underlying + * logging implementation that is being wrapped) + * + * @exception LogConfigurationException if a suitable Log + * instance cannot be returned + */ + public abstract Log getInstance(String name) + throws LogConfigurationException; + + + /** + * Release any internal references to previously created {@link Log} + * instances returned by this factory. This is useful in environments + * like servlet containers, which implement application reloading by + * throwing away a ClassLoader. Dangling references to objects in that + * class loader would prevent garbage collection. + */ + public abstract void release(); + + + /** + * Remove any configuration attribute associated with the specified name. + * If there is no such attribute, no action is taken. + * + * @param name Name of the attribute to remove + */ + public abstract void removeAttribute(String name); + + + /** + * Set the configuration attribute with the specified name. Calling + * this with a null value is equivalent to calling + * removeAttribute(name). + * + * @param name Name of the attribute to set + * @param value Value of the attribute to set, or null + * to remove any setting for this attribute + */ + public abstract void setAttribute(String name, Object value); + + + // ------------------------------------------------------- Static Variables + + + /** + * The previously constructed LogFactory instances, keyed by + * the ClassLoader with which it was created. + */ + protected static Hashtable factories = null; + + /** + * Prevously constructed LogFactory instance as in the + * factories map, but for the case where + * getClassLoader returns null. + * This can happen when: + *
    + *
  • using JDK1.1 and the calling code is loaded via the system + * classloader (very common)
  • + *
  • using JDK1.2+ and the calling code is loaded via the boot + * classloader (only likely for embedded systems work).
  • + *
+ * Note that factories is a Hashtable (not a HashMap), + * and hashtables don't allow null as a key. + */ + protected static LogFactory nullClassLoaderFactory = null; + + /** + * Create the hashtable which will be used to store a map of + * (context-classloader -> logfactory-object). Version 1.2+ of Java + * supports "weak references", allowing a custom Hashtable class + * to be used which uses only weak references to its keys. Using weak + * references can fix memory leaks on webapp unload in some cases (though + * not all). Version 1.1 of Java does not support weak references, so we + * must dynamically determine which we are using. And just for fun, this + * code also supports the ability for a system property to specify an + * arbitrary Hashtable implementation name. + *

+ * Note that the correct way to ensure no memory leaks occur is to ensure + * that LogFactory.release(contextClassLoader) is called whenever a + * webapp is undeployed. + */ + private static final Hashtable createFactoryStore() { + Hashtable result = null; + String storeImplementationClass; + try { + storeImplementationClass = getSystemProperty(HASHTABLE_IMPLEMENTATION_PROPERTY, null); + } catch(SecurityException ex) { + // Permissions don't allow this to be accessed. Default to the "modern" + // weak hashtable implementation if it is available. + storeImplementationClass = null; + } + + if (storeImplementationClass == null) { + storeImplementationClass = WEAK_HASHTABLE_CLASSNAME; + } + try { + Class implementationClass = Class.forName(storeImplementationClass); + result = (Hashtable) implementationClass.newInstance(); + + } catch (Throwable t) { + // ignore + if (!WEAK_HASHTABLE_CLASSNAME.equals(storeImplementationClass)) { + // if the user's trying to set up a custom implementation, give a clue + if (isDiagnosticsEnabled()) { + // use internal logging to issue the warning + logDiagnostic("[ERROR] LogFactory: Load of custom hashtable failed"); + } else { + // we *really* want this output, even if diagnostics weren't + // explicitly enabled by the user. + System.err.println("[ERROR] LogFactory: Load of custom hashtable failed"); + } + } + } + if (result == null) { + result = new Hashtable(); + } + return result; + } + + + // --------------------------------------------------------- Static Methods + + /** Utility method to safely trim a string. */ + private static String trim(String src) { + if (src == null) { + return null; + } + return src.trim(); + } + + /** + *

Construct (if necessary) and return a LogFactory + * instance, using the following ordered lookup procedure to determine + * the name of the implementation class to be loaded.

+ *
    + *
  • The org.apache.commons.logging.LogFactory system + * property.
  • + *
  • The JDK 1.3 Service Discovery mechanism
  • + *
  • Use the properties file commons-logging.properties + * file, if found in the class path of this class. The configuration + * file is in standard java.util.Properties format and + * contains the fully qualified name of the implementation class + * with the key being the system property defined above.
  • + *
  • Fall back to a default implementation class + * (org.apache.commons.logging.impl.LogFactoryImpl).
  • + *
+ * + *

NOTE - If the properties file method of identifying the + * LogFactory implementation class is utilized, all of the + * properties defined in this file will be set as configuration attributes + * on the corresponding LogFactory instance.

+ * + *

NOTE - In a multithreaded environment it is possible + * that two different instances will be returned for the same + * classloader environment. + *

+ * + * @exception LogConfigurationException if the implementation class is not + * available or cannot be instantiated. + */ + public static LogFactory getFactory() throws LogConfigurationException { + // Identify the class loader we will be using + ClassLoader contextClassLoader = getContextClassLoaderInternal(); + + if (contextClassLoader == null) { + // This is an odd enough situation to report about. This + // output will be a nuisance on JDK1.1, as the system + // classloader is null in that environment. + if (isDiagnosticsEnabled()) { + logDiagnostic("Context classloader is null."); + } + } + + // Return any previously registered factory for this class loader + LogFactory factory = getCachedFactory(contextClassLoader); + if (factory != null) { + return factory; + } + + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] LogFactory implementation requested for the first time for context classloader " + + objectId(contextClassLoader)); + logHierarchy("[LOOKUP] ", contextClassLoader); + } + + // Load properties file. + // + // If the properties file exists, then its contents are used as + // "attributes" on the LogFactory implementation class. One particular + // property may also control which LogFactory concrete subclass is + // used, but only if other discovery mechanisms fail.. + // + // As the properties file (if it exists) will be used one way or + // another in the end we may as well look for it first. + + Properties props = getConfigurationFile(contextClassLoader, FACTORY_PROPERTIES); + + // Determine whether we will be using the thread context class loader to + // load logging classes or not by checking the loaded properties file (if any). + ClassLoader baseClassLoader = contextClassLoader; + if (props != null) { + String useTCCLStr = props.getProperty(TCCL_KEY); + if (useTCCLStr != null) { + // The Boolean.valueOf(useTCCLStr).booleanValue() formulation + // is required for Java 1.2 compatability. + if (Boolean.valueOf(useTCCLStr).booleanValue() == false) { + // Don't use current context classloader when locating any + // LogFactory or Log classes, just use the class that loaded + // this abstract class. When this class is deployed in a shared + // classpath of a container, it means webapps cannot deploy their + // own logging implementations. It also means that it is up to the + // implementation whether to load library-specific config files + // from the TCCL or not. + baseClassLoader = thisClassLoader; + } + } + } + + // Determine which concrete LogFactory subclass to use. + // First, try a global system property + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Looking for system property [" + FACTORY_PROPERTY + + "] to define the LogFactory subclass to use..."); + } + + try { + String factoryClass = getSystemProperty(FACTORY_PROPERTY, null); + if (factoryClass != null) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Creating an instance of LogFactory class '" + factoryClass + + "' as specified by system property " + FACTORY_PROPERTY); + } + + factory = newFactory(factoryClass, baseClassLoader, contextClassLoader); + } else { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] No system property [" + FACTORY_PROPERTY + + "] defined."); + } + } + } catch (SecurityException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] A security exception occurred while trying to create an" + + " instance of the custom factory class" + + ": [" + trim(e.getMessage()) + + "]. Trying alternative implementations..."); + } + ; // ignore + } catch(RuntimeException e) { + // This is not consistent with the behaviour when a bad LogFactory class is + // specified in a services file. + // + // One possible exception that can occur here is a ClassCastException when + // the specified class wasn't castable to this LogFactory type. + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] An exception occurred while trying to create an" + + " instance of the custom factory class" + + ": [" + trim(e.getMessage()) + + "] as specified by a system property."); + } + throw e; + } + + + // Second, try to find a service by using the JDK1.3 class + // discovery mechanism, which involves putting a file with the name + // of an interface class in the META-INF/services directory, where the + // contents of the file is a single line specifying a concrete class + // that implements the desired interface. + + if (factory == null) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Looking for a resource file of name [" + SERVICE_ID + + "] to define the LogFactory subclass to use..."); + } + try { + InputStream is = getResourceAsStream(contextClassLoader, + SERVICE_ID); + + if( is != null ) { + // This code is needed by EBCDIC and other strange systems. + // It's a fix for bugs reported in xerces + BufferedReader rd; + try { + rd = new BufferedReader(new InputStreamReader(is, "UTF-8")); + } catch (java.io.UnsupportedEncodingException e) { + rd = new BufferedReader(new InputStreamReader(is)); + } + + String factoryClassName = rd.readLine(); + rd.close(); + + if (factoryClassName != null && + ! "".equals(factoryClassName)) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Creating an instance of LogFactory class " + factoryClassName + + " as specified by file '" + SERVICE_ID + + "' which was present in the path of the context" + + " classloader."); + } + factory = newFactory(factoryClassName, baseClassLoader, contextClassLoader ); + } + } else { + // is == null + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] No resource file with name '" + SERVICE_ID + + "' found."); + } + } + } catch( Exception ex ) { + // note: if the specified LogFactory class wasn't compatible with LogFactory + // for some reason, a ClassCastException will be caught here, and attempts will + // continue to find a compatible class. + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] A security exception occurred while trying to create an" + + " instance of the custom factory class" + + ": [" + trim(ex.getMessage()) + + "]. Trying alternative implementations..."); + } + ; // ignore + } + } + + + // Third try looking into the properties file read earlier (if found) + + if (factory == null) { + if (props != null) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Looking in properties file for entry with key '" + + FACTORY_PROPERTY + + "' to define the LogFactory subclass to use..."); + } + String factoryClass = props.getProperty(FACTORY_PROPERTY); + if (factoryClass != null) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Properties file specifies LogFactory subclass '" + + factoryClass + "'"); + } + factory = newFactory(factoryClass, baseClassLoader, contextClassLoader); + + // TODO: think about whether we need to handle exceptions from newFactory + } else { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Properties file has no entry specifying LogFactory subclass."); + } + } + } else { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] No properties file available to determine" + + " LogFactory subclass from.."); + } + } + } + + + // Fourth, try the fallback implementation class + + if (factory == null) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Loading the default LogFactory implementation '" + FACTORY_DEFAULT + + "' via the same classloader that loaded this LogFactory" + + " class (ie not looking in the context classloader)."); + } + + // Note: unlike the above code which can try to load custom LogFactory + // implementations via the TCCL, we don't try to load the default LogFactory + // implementation via the context classloader because: + // * that can cause problems (see comments in newFactory method) + // * no-one should be customising the code of the default class + // Yes, we do give up the ability for the child to ship a newer + // version of the LogFactoryImpl class and have it used dynamically + // by an old LogFactory class in the parent, but that isn't + // necessarily a good idea anyway. + factory = newFactory(FACTORY_DEFAULT, thisClassLoader, contextClassLoader); + } + + if (factory != null) { + /** + * Always cache using context class loader. + */ + cacheFactory(contextClassLoader, factory); + + if( props!=null ) { + Enumeration names = props.propertyNames(); + while (names.hasMoreElements()) { + String name = (String) names.nextElement(); + String value = props.getProperty(name); + factory.setAttribute(name, value); + } + } + } + + return factory; + } + + + /** + * Convenience method to return a named logger, without the application + * having to care about factories. + * + * @param clazz Class from which a log name will be derived + * + * @exception LogConfigurationException if a suitable Log + * instance cannot be returned + */ + public static Log getLog(Class clazz) + throws LogConfigurationException { + + return (getFactory().getInstance(clazz)); + + } + + + /** + * Convenience method to return a named logger, without the application + * having to care about factories. + * + * @param name Logical name of the Log instance to be + * returned (the meaning of this name is only known to the underlying + * logging implementation that is being wrapped) + * + * @exception LogConfigurationException if a suitable Log + * instance cannot be returned + */ + public static Log getLog(String name) + throws LogConfigurationException { + + return (getFactory().getInstance(name)); + + } + + + /** + * Release any internal references to previously created {@link LogFactory} + * instances that have been associated with the specified class loader + * (if any), after calling the instance method release() on + * each of them. + * + * @param classLoader ClassLoader for which to release the LogFactory + */ + public static void release(ClassLoader classLoader) { + + if (isDiagnosticsEnabled()) { + logDiagnostic("Releasing factory for classloader " + objectId(classLoader)); + } + synchronized (factories) { + if (classLoader == null) { + if (nullClassLoaderFactory != null) { + nullClassLoaderFactory.release(); + nullClassLoaderFactory = null; + } + } else { + LogFactory factory = (LogFactory) factories.get(classLoader); + if (factory != null) { + factory.release(); + factories.remove(classLoader); + } + } + } + + } + + + /** + * Release any internal references to previously created {@link LogFactory} + * instances, after calling the instance method release() on + * each of them. This is useful in environments like servlet containers, + * which implement application reloading by throwing away a ClassLoader. + * Dangling references to objects in that class loader would prevent + * garbage collection. + */ + public static void releaseAll() { + + if (isDiagnosticsEnabled()) { + logDiagnostic("Releasing factory for all classloaders."); + } + synchronized (factories) { + Enumeration elements = factories.elements(); + while (elements.hasMoreElements()) { + LogFactory element = (LogFactory) elements.nextElement(); + element.release(); + } + factories.clear(); + + if (nullClassLoaderFactory != null) { + nullClassLoaderFactory.release(); + nullClassLoaderFactory = null; + } + } + + } + + + // ------------------------------------------------------ Protected Methods + + /** + * Safely get access to the classloader for the specified class. + *

+ * Theoretically, calling getClassLoader can throw a security exception, + * and so should be done under an AccessController in order to provide + * maximum flexibility. However in practice people don't appear to use + * security policies that forbid getClassLoader calls. So for the moment + * all code is written to call this method rather than Class.getClassLoader, + * so that we could put AccessController stuff in this method without any + * disruption later if we need to. + *

+ * Even when using an AccessController, however, this method can still + * throw SecurityException. Commons-logging basically relies on the + * ability to access classloaders, ie a policy that forbids all + * classloader access will also prevent commons-logging from working: + * currently this method will throw an exception preventing the entire app + * from starting up. Maybe it would be good to detect this situation and + * just disable all commons-logging? Not high priority though - as stated + * above, security policies that prevent classloader access aren't common. + *

+ * Note that returning an object fetched via an AccessController would + * technically be a security flaw anyway; untrusted code that has access + * to a trusted JCL library could use it to fetch the classloader for + * a class even when forbidden to do so directly. + * + * @since 1.1 + */ + protected static ClassLoader getClassLoader(Class clazz) { + try { + return clazz.getClassLoader(); + } catch(SecurityException ex) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Unable to get classloader for class '" + clazz + + "' due to security restrictions - " + ex.getMessage()); + } + throw ex; + } + } + + /** + * Returns the current context classloader. + *

+ * In versions prior to 1.1, this method did not use an AccessController. + * In version 1.1, an AccessController wrapper was incorrectly added to + * this method, causing a minor security flaw. + *

+ * In version 1.1.1 this change was reverted; this method no longer uses + * an AccessController. User code wishing to obtain the context classloader + * must invoke this method via AccessController.doPrivileged if it needs + * support for that. + * + * @return the context classloader associated with the current thread, + * or null if security doesn't allow it. + * + * @throws LogConfigurationException if there was some weird error while + * attempting to get the context classloader. + * + * @throws SecurityException if the current java security policy doesn't + * allow this class to access the context classloader. + */ + protected static ClassLoader getContextClassLoader() + throws LogConfigurationException { + + return directGetContextClassLoader(); + } + + /** + * Calls LogFactory.directGetContextClassLoader under the control of an + * AccessController class. This means that java code running under a + * security manager that forbids access to ClassLoaders will still work + * if this class is given appropriate privileges, even when the caller + * doesn't have such privileges. Without using an AccessController, the + * the entire call stack must have the privilege before the call is + * allowed. + * + * @return the context classloader associated with the current thread, + * or null if security doesn't allow it. + * + * @throws LogConfigurationException if there was some weird error while + * attempting to get the context classloader. + * + * @throws SecurityException if the current java security policy doesn't + * allow this class to access the context classloader. + */ + private static ClassLoader getContextClassLoaderInternal() + throws LogConfigurationException { + return (ClassLoader)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return directGetContextClassLoader(); + } + }); + } + + /** + * Return the thread context class loader if available; otherwise return + * null. + *

+ * Most/all code should call getContextClassLoaderInternal rather than + * calling this method directly. + *

+ * The thread context class loader is available for JDK 1.2 + * or later, if certain security conditions are met. + *

+ * Note that no internal logging is done within this method because + * this method is called every time LogFactory.getLogger() is called, + * and we don't want too much output generated here. + * + * @exception LogConfigurationException if a suitable class loader + * cannot be identified. + * + * @exception SecurityException if the java security policy forbids + * access to the context classloader from one of the classes in the + * current call stack. + * @since 1.1 + */ + protected static ClassLoader directGetContextClassLoader() + throws LogConfigurationException + { + ClassLoader classLoader = null; + + try { + // Are we running on a JDK 1.2 or later system? + Method method = Thread.class.getMethod("getContextClassLoader", + (Class[]) null); + + // Get the thread context class loader (if there is one) + try { + classLoader = (ClassLoader)method.invoke(Thread.currentThread(), + (Object[]) null); + } catch (IllegalAccessException e) { + throw new LogConfigurationException + ("Unexpected IllegalAccessException", e); + } catch (InvocationTargetException e) { + /** + * InvocationTargetException is thrown by 'invoke' when + * the method being invoked (getContextClassLoader) throws + * an exception. + * + * getContextClassLoader() throws SecurityException when + * the context class loader isn't an ancestor of the + * calling class's class loader, or if security + * permissions are restricted. + * + * In the first case (not related), we want to ignore and + * keep going. We cannot help but also ignore the second + * with the logic below, but other calls elsewhere (to + * obtain a class loader) will trigger this exception where + * we can make a distinction. + */ + if (e.getTargetException() instanceof SecurityException) { + ; // ignore + } else { + // Capture 'e.getTargetException()' exception for details + // alternate: log 'e.getTargetException()', and pass back 'e'. + throw new LogConfigurationException + ("Unexpected InvocationTargetException", e.getTargetException()); + } + } + } catch (NoSuchMethodException e) { + // Assume we are running on JDK 1.1 + classLoader = getClassLoader(LogFactory.class); + + // We deliberately don't log a message here to outputStream; + // this message would be output for every call to LogFactory.getLog() + // when running on JDK1.1 + // + // if (outputStream != null) { + // outputStream.println( + // "Method Thread.getContextClassLoader does not exist;" + // + " assuming this is JDK 1.1, and that the context" + // + " classloader is the same as the class that loaded" + // + " the concrete LogFactory class."); + // } + + } + + // Return the selected class loader + return classLoader; + } + + /** + * Check cached factories (keyed by contextClassLoader) + * + * @param contextClassLoader is the context classloader associated + * with the current thread. This allows separate LogFactory objects + * per component within a container, provided each component has + * a distinct context classloader set. This parameter may be null + * in JDK1.1, and in embedded systems where jcl-using code is + * placed in the bootclasspath. + * + * @return the factory associated with the specified classloader if + * one has previously been created, or null if this is the first time + * we have seen this particular classloader. + */ + private static LogFactory getCachedFactory(ClassLoader contextClassLoader) + { + LogFactory factory = null; + + if (contextClassLoader == null) { + // We have to handle this specially, as factories is a Hashtable + // and those don't accept null as a key value. + // + // nb: nullClassLoaderFactory might be null. That's ok. + factory = nullClassLoaderFactory; + } else { + factory = (LogFactory) factories.get(contextClassLoader); + } + + return factory; + } + + /** + * Remember this factory, so later calls to LogFactory.getCachedFactory + * can return the previously created object (together with all its + * cached Log objects). + * + * @param classLoader should be the current context classloader. Note that + * this can be null under some circumstances; this is ok. + * + * @param factory should be the factory to cache. This should never be null. + */ + private static void cacheFactory(ClassLoader classLoader, LogFactory factory) + { + // Ideally we would assert(factory != null) here. However reporting + // errors from within a logging implementation is a little tricky! + + if (factory != null) { + if (classLoader == null) { + nullClassLoaderFactory = factory; + } else { + factories.put(classLoader, factory); + } + } + } + + /** + * Return a new instance of the specified LogFactory + * implementation class, loaded by the specified class loader. + * If that fails, try the class loader used to load this + * (abstract) LogFactory. + *

+ *

ClassLoader conflicts

+ * Note that there can be problems if the specified ClassLoader is not the + * same as the classloader that loaded this class, ie when loading a + * concrete LogFactory subclass via a context classloader. + *

+ * The problem is the same one that can occur when loading a concrete Log + * subclass via a context classloader. + *

+ * The problem occurs when code running in the context classloader calls + * class X which was loaded via a parent classloader, and class X then calls + * LogFactory.getFactory (either directly or via LogFactory.getLog). Because + * class X was loaded via the parent, it binds to LogFactory loaded via + * the parent. When the code in this method finds some LogFactoryYYYY + * class in the child (context) classloader, and there also happens to be a + * LogFactory class defined in the child classloader, then LogFactoryYYYY + * will be bound to LogFactory@childloader. It cannot be cast to + * LogFactory@parentloader, ie this method cannot return the object as + * the desired type. Note that it doesn't matter if the LogFactory class + * in the child classloader is identical to the LogFactory class in the + * parent classloader, they are not compatible. + *

+ * The solution taken here is to simply print out an error message when + * this occurs then throw an exception. The deployer of the application + * must ensure they remove all occurrences of the LogFactory class from + * the child classloader in order to resolve the issue. Note that they + * do not have to move the custom LogFactory subclass; that is ok as + * long as the only LogFactory class it can find to bind to is in the + * parent classloader. + *

+ * @param factoryClass Fully qualified name of the LogFactory + * implementation class + * @param classLoader ClassLoader from which to load this class + * @param contextClassLoader is the context that this new factory will + * manage logging for. + * + * @exception LogConfigurationException if a suitable instance + * cannot be created + * @since 1.1 + */ + protected static LogFactory newFactory(final String factoryClass, + final ClassLoader classLoader, + final ClassLoader contextClassLoader) + throws LogConfigurationException + { + // Note that any unchecked exceptions thrown by the createFactory + // method will propagate out of this method; in particular a + // ClassCastException can be thrown. + Object result = AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return createFactory(factoryClass, classLoader); + } + }); + + if (result instanceof LogConfigurationException) { + LogConfigurationException ex = (LogConfigurationException) result; + if (isDiagnosticsEnabled()) { + logDiagnostic( + "An error occurred while loading the factory class:" + + ex.getMessage()); + } + throw ex; + } + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Created object " + objectId(result) + + " to manage classloader " + objectId(contextClassLoader)); + } + return (LogFactory)result; + } + + /** + * Method provided for backwards compatibility; see newFactory version that + * takes 3 parameters. + *

+ * This method would only ever be called in some rather odd situation. + * Note that this method is static, so overriding in a subclass doesn't + * have any effect unless this method is called from a method in that + * subclass. However this method only makes sense to use from the + * getFactory method, and as that is almost always invoked via + * LogFactory.getFactory, any custom definition in a subclass would be + * pointless. Only a class with a custom getFactory method, then invoked + * directly via CustomFactoryImpl.getFactory or similar would ever call + * this. Anyway, it's here just in case, though the "managed class loader" + * value output to the diagnostics will not report the correct value. + */ + protected static LogFactory newFactory(final String factoryClass, + final ClassLoader classLoader) { + return newFactory(factoryClass, classLoader, null); + } + + /** + * Implements the operations described in the javadoc for newFactory. + * + * @param factoryClass + * + * @param classLoader used to load the specified factory class. This is + * expected to be either the TCCL or the classloader which loaded this + * class. Note that the classloader which loaded this class might be + * "null" (ie the bootloader) for embedded systems. + * + * @return either a LogFactory object or a LogConfigurationException object. + * @since 1.1 + */ + protected static Object createFactory(String factoryClass, ClassLoader classLoader) { + + // This will be used to diagnose bad configurations + // and allow a useful message to be sent to the user + Class logFactoryClass = null; + try { + if (classLoader != null) { + try { + // First the given class loader param (thread class loader) + + // Warning: must typecast here & allow exception + // to be generated/caught & recast properly. + logFactoryClass = classLoader.loadClass(factoryClass); + if (LogFactory.class.isAssignableFrom(logFactoryClass)) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Loaded class " + logFactoryClass.getName() + + " from classloader " + objectId(classLoader)); + } + } else { + // + // This indicates a problem with the ClassLoader tree. + // An incompatible ClassLoader was used to load the + // implementation. + // As the same classes + // must be available in multiple class loaders, + // it is very likely that multiple JCL jars are present. + // The most likely fix for this + // problem is to remove the extra JCL jars from the + // ClassLoader hierarchy. + // + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Factory class " + logFactoryClass.getName() + + " loaded from classloader " + objectId(logFactoryClass.getClassLoader()) + + " does not extend '" + LogFactory.class.getName() + + "' as loaded by this classloader."); + logHierarchy("[BAD CL TREE] ", classLoader); + } + } + + return (LogFactory) logFactoryClass.newInstance(); + + } catch (ClassNotFoundException ex) { + if (classLoader == thisClassLoader) { + // Nothing more to try, onwards. + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Unable to locate any class called '" + factoryClass + + "' via classloader " + objectId(classLoader)); + } + throw ex; + } + // ignore exception, continue + } catch (NoClassDefFoundError e) { + if (classLoader == thisClassLoader) { + // Nothing more to try, onwards. + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Class '" + factoryClass + "' cannot be loaded" + + " via classloader " + objectId(classLoader) + + " - it depends on some other class that cannot" + + " be found."); + } + throw e; + } + // ignore exception, continue + } catch(ClassCastException e) { + if (classLoader == thisClassLoader) { + // There's no point in falling through to the code below that + // tries again with thisClassLoader, because we've just tried + // loading with that loader (not the TCCL). Just throw an + // appropriate exception here. + + final boolean implementsLogFactory = implementsLogFactory(logFactoryClass); + + // + // Construct a good message: users may not actual expect that a custom implementation + // has been specified. Several well known containers use this mechanism to adapt JCL + // to their native logging system. + // + String msg = + "The application has specified that a custom LogFactory implementation should be used but " + + "Class '" + factoryClass + "' cannot be converted to '" + + LogFactory.class.getName() + "'. "; + if (implementsLogFactory) { + msg = msg + "The conflict is caused by the presence of multiple LogFactory classes in incompatible classloaders. " + + "Background can be found in http://commons.apache.org/logging/tech.html. " + + "If you have not explicitly specified a custom LogFactory then it is likely that " + + "the container has set one without your knowledge. " + + "In this case, consider using the commons-logging-adapters.jar file or " + + "specifying the standard LogFactory from the command line. "; + } else { + msg = msg + "Please check the custom implementation. "; + } + msg = msg + "Help can be found @http://commons.apache.org/logging/troubleshooting.html."; + + if (isDiagnosticsEnabled()) { + logDiagnostic(msg); + } + + ClassCastException ex = new ClassCastException(msg); + throw ex; + } + + // Ignore exception, continue. Presumably the classloader was the + // TCCL; the code below will try to load the class via thisClassLoader. + // This will handle the case where the original calling class is in + // a shared classpath but the TCCL has a copy of LogFactory and the + // specified LogFactory implementation; we will fall back to using the + // LogFactory implementation from the same classloader as this class. + // + // Issue: this doesn't handle the reverse case, where this LogFactory + // is in the webapp, and the specified LogFactory implementation is + // in a shared classpath. In that case: + // (a) the class really does implement LogFactory (bad log msg above) + // (b) the fallback code will result in exactly the same problem. + } + } + + /* At this point, either classLoader == null, OR + * classLoader was unable to load factoryClass. + * + * In either case, we call Class.forName, which is equivalent + * to LogFactory.class.getClassLoader().load(name), ie we ignore + * the classloader parameter the caller passed, and fall back + * to trying the classloader associated with this class. See the + * javadoc for the newFactory method for more info on the + * consequences of this. + * + * Notes: + * * LogFactory.class.getClassLoader() may return 'null' + * if LogFactory is loaded by the bootstrap classloader. + */ + // Warning: must typecast here & allow exception + // to be generated/caught & recast properly. + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Unable to load factory class via classloader " + + objectId(classLoader) + + " - trying the classloader associated with this LogFactory."); + } + logFactoryClass = Class.forName(factoryClass); + return (LogFactory) logFactoryClass.newInstance(); + } catch (Exception e) { + // Check to see if we've got a bad configuration + if (isDiagnosticsEnabled()) { + logDiagnostic("Unable to create LogFactory instance."); + } + if (logFactoryClass != null + && !LogFactory.class.isAssignableFrom(logFactoryClass)) { + + return new LogConfigurationException( + "The chosen LogFactory implementation does not extend LogFactory." + + " Please check your configuration.", + e); + } + return new LogConfigurationException(e); + } + } + + /** + * Determines whether the given class actually implements LogFactory. + * Diagnostic information is also logged. + *

+ * Usage: to diagnose whether a classloader conflict is the cause + * of incompatibility. The test used is whether the class is assignable from + * the LogFactory class loaded by the class's classloader. + * @param logFactoryClass Class which may implement LogFactory + * @return true if the logFactoryClass does extend + * LogFactory when that class is loaded via the same + * classloader that loaded the logFactoryClass. + */ + private static boolean implementsLogFactory(Class logFactoryClass) { + boolean implementsLogFactory = false; + if (logFactoryClass != null) { + try { + ClassLoader logFactoryClassLoader = logFactoryClass.getClassLoader(); + if (logFactoryClassLoader == null) { + logDiagnostic("[CUSTOM LOG FACTORY] was loaded by the boot classloader"); + } else { + logHierarchy("[CUSTOM LOG FACTORY] ", logFactoryClassLoader); + Class factoryFromCustomLoader + = Class.forName("org.apache.commons.logging.LogFactory", false, logFactoryClassLoader); + implementsLogFactory = factoryFromCustomLoader.isAssignableFrom(logFactoryClass); + if (implementsLogFactory) { + logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + + " implements LogFactory but was loaded by an incompatible classloader."); + } else { + logDiagnostic("[CUSTOM LOG FACTORY] " + logFactoryClass.getName() + + " does not implement LogFactory."); + } + } + } catch (SecurityException e) { + // + // The application is running within a hostile security environment. + // This will make it very hard to diagnose issues with JCL. + // Consider running less securely whilst debugging this issue. + // + logDiagnostic("[CUSTOM LOG FACTORY] SecurityException thrown whilst trying to determine whether " + + "the compatibility was caused by a classloader conflict: " + + e.getMessage()); + } catch (LinkageError e) { + // + // This should be an unusual circumstance. + // LinkageError's usually indicate that a dependent class has incompatibly changed. + // Another possibility may be an exception thrown by an initializer. + // Time for a clean rebuild? + // + logDiagnostic("[CUSTOM LOG FACTORY] LinkageError thrown whilst trying to determine whether " + + "the compatibility was caused by a classloader conflict: " + + e.getMessage()); + } catch (ClassNotFoundException e) { + // + // LogFactory cannot be loaded by the classloader which loaded the custom factory implementation. + // The custom implementation is not viable until this is corrected. + // Ensure that the JCL jar and the custom class are available from the same classloader. + // Running with diagnostics on should give information about the classloaders used + // to load the custom factory. + // + logDiagnostic("[CUSTOM LOG FACTORY] LogFactory class cannot be loaded by classloader which loaded the " + + "custom LogFactory implementation. Is the custom factory in the right classloader?"); + } + } + return implementsLogFactory; + } + + /** + * Applets may run in an environment where accessing resources of a loader is + * a secure operation, but where the commons-logging library has explicitly + * been granted permission for that operation. In this case, we need to + * run the operation using an AccessController. + */ + private static InputStream getResourceAsStream(final ClassLoader loader, + final String name) + { + return (InputStream)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + if (loader != null) { + return loader.getResourceAsStream(name); + } else { + return ClassLoader.getSystemResourceAsStream(name); + } + } + }); + } + + /** + * Given a filename, return an enumeration of URLs pointing to + * all the occurrences of that filename in the classpath. + *

+ * This is just like ClassLoader.getResources except that the + * operation is done under an AccessController so that this method will + * succeed when this jarfile is privileged but the caller is not. + * This method must therefore remain private to avoid security issues. + *

+ * If no instances are found, an Enumeration is returned whose + * hasMoreElements method returns false (ie an "empty" enumeration). + * If resources could not be listed for some reason, null is returned. + */ + private static Enumeration getResources(final ClassLoader loader, + final String name) + { + PrivilegedAction action = + new PrivilegedAction() { + public Object run() { + try { + if (loader != null) { + return loader.getResources(name); + } else { + return ClassLoader.getSystemResources(name); + } + } catch(IOException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Exception while trying to find configuration file " + + name + ":" + e.getMessage()); + } + return null; + } catch(NoSuchMethodError e) { + // we must be running on a 1.1 JVM which doesn't support + // ClassLoader.getSystemResources; just return null in + // this case. + return null; + } + } + }; + Object result = AccessController.doPrivileged(action); + return (Enumeration) result; + } + + /** + * Given a URL that refers to a .properties file, load that file. + * This is done under an AccessController so that this method will + * succeed when this jarfile is privileged but the caller is not. + * This method must therefore remain private to avoid security issues. + *

+ * Null is returned if the URL cannot be opened. + */ + private static Properties getProperties(final URL url) { + PrivilegedAction action = + new PrivilegedAction() { + public Object run() { + try { + InputStream stream = url.openStream(); + if (stream != null) { + Properties props = new Properties(); + props.load(stream); + stream.close(); + return props; + } + } catch(IOException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic("Unable to read URL " + url); + } + } + + return null; + } + }; + return (Properties) AccessController.doPrivileged(action); + } + + /** + * Locate a user-provided configuration file. + *

+ * The classpath of the specified classLoader (usually the context classloader) + * is searched for properties files of the specified name. If none is found, + * null is returned. If more than one is found, then the file with the greatest + * value for its PRIORITY property is returned. If multiple files have the + * same PRIORITY value then the first in the classpath is returned. + *

+ * This differs from the 1.0.x releases; those always use the first one found. + * However as the priority is a new field, this change is backwards compatible. + *

+ * The purpose of the priority field is to allow a webserver administrator to + * override logging settings in all webapps by placing a commons-logging.properties + * file in a shared classpath location with a priority > 0; this overrides any + * commons-logging.properties files without priorities which are in the + * webapps. Webapps can also use explicit priorities to override a configuration + * file in the shared classpath if needed. + */ + private static final Properties getConfigurationFile( + ClassLoader classLoader, String fileName) { + + Properties props = null; + double priority = 0.0; + URL propsUrl = null; + try { + Enumeration urls = getResources(classLoader, fileName); + + if (urls == null) { + return null; + } + + while (urls.hasMoreElements()) { + URL url = (URL) urls.nextElement(); + + Properties newProps = getProperties(url); + if (newProps != null) { + if (props == null) { + propsUrl = url; + props = newProps; + String priorityStr = props.getProperty(PRIORITY_KEY); + priority = 0.0; + if (priorityStr != null) { + priority = Double.parseDouble(priorityStr); + } + + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Properties file found at '" + url + "'" + + " with priority " + priority); + } + } else { + String newPriorityStr = newProps.getProperty(PRIORITY_KEY); + double newPriority = 0.0; + if (newPriorityStr != null) { + newPriority = Double.parseDouble(newPriorityStr); + } + + if (newPriority > priority) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Properties file at '" + url + "'" + + " with priority " + newPriority + + " overrides file at '" + propsUrl + "'" + + " with priority " + priority); + } + + propsUrl = url; + props = newProps; + priority = newPriority; + } else { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[LOOKUP] Properties file at '" + url + "'" + + " with priority " + newPriority + + " does not override file at '" + propsUrl + "'" + + " with priority " + priority); + } + } + } + + } + } + } catch (SecurityException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic("SecurityException thrown while trying to find/read config files."); + } + } + + if (isDiagnosticsEnabled()) { + if (props == null) { + logDiagnostic( + "[LOOKUP] No properties file of name '" + fileName + + "' found."); + } else { + logDiagnostic( + "[LOOKUP] Properties file of name '" + fileName + + "' found at '" + propsUrl + '"'); + } + } + + return props; + } + + /** + * Read the specified system property, using an AccessController so that + * the property can be read if JCL has been granted the appropriate + * security rights even if the calling code has not. + *

+ * Take care not to expose the value returned by this method to the + * calling application in any way; otherwise the calling app can use that + * info to access data that should not be available to it. + */ + private static String getSystemProperty(final String key, final String def) + throws SecurityException { + return (String) AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return System.getProperty(key, def); + } + }); + } + + /** + * Determines whether the user wants internal diagnostic output. If so, + * returns an appropriate writer object. Users can enable diagnostic + * output by setting the system property named {@link #DIAGNOSTICS_DEST_PROPERTY} to + * a filename, or the special values STDOUT or STDERR. + */ + private static void initDiagnostics() { + String dest; + try { + dest = getSystemProperty(DIAGNOSTICS_DEST_PROPERTY, null); + if (dest == null) { + return; + } + } catch(SecurityException ex) { + // We must be running in some very secure environment. + // We just have to assume output is not wanted.. + return; + } + + if (dest.equals("STDOUT")) { + diagnosticsStream = System.out; + } else if (dest.equals("STDERR")) { + diagnosticsStream = System.err; + } else { + try { + // open the file in append mode + FileOutputStream fos = new FileOutputStream(dest, true); + diagnosticsStream = new PrintStream(fos); + } catch(IOException ex) { + // We should report this to the user - but how? + return; + } + } + + // In order to avoid confusion where multiple instances of JCL are + // being used via different classloaders within the same app, we + // ensure each logged message has a prefix of form + // [LogFactory from classloader OID] + // + // Note that this prefix should be kept consistent with that + // in LogFactoryImpl. However here we don't need to output info + // about the actual *instance* of LogFactory, as all methods that + // output diagnostics from this class are static. + String classLoaderName; + try { + ClassLoader classLoader = thisClassLoader; + if (thisClassLoader == null) { + classLoaderName = "BOOTLOADER"; + } else { + classLoaderName = objectId(classLoader); + } + } catch(SecurityException e) { + classLoaderName = "UNKNOWN"; + } + diagnosticPrefix = "[LogFactory from " + classLoaderName + "] "; + } + + /** + * Indicates true if the user has enabled internal logging. + *

+ * By the way, sorry for the incorrect grammar, but calling this method + * areDiagnosticsEnabled just isn't java beans style. + * + * @return true if calls to logDiagnostic will have any effect. + * @since 1.1 + */ + protected static boolean isDiagnosticsEnabled() { + return diagnosticsStream != null; + } + + /** + * Write the specified message to the internal logging destination. + *

+ * Note that this method is private; concrete subclasses of this class + * should not call it because the diagnosticPrefix string this + * method puts in front of all its messages is LogFactory@...., + * while subclasses should put SomeSubClass@... + *

+ * Subclasses should instead compute their own prefix, then call + * logRawDiagnostic. Note that calling isDiagnosticsEnabled is + * fine for subclasses. + *

+ * Note that it is safe to call this method before initDiagnostics + * is called; any output will just be ignored (as isDiagnosticsEnabled + * will return false). + * + * @param msg is the diagnostic message to be output. + */ + private static final void logDiagnostic(String msg) { + if (diagnosticsStream != null) { + diagnosticsStream.print(diagnosticPrefix); + diagnosticsStream.println(msg); + diagnosticsStream.flush(); + } + } + + /** + * Write the specified message to the internal logging destination. + * + * @param msg is the diagnostic message to be output. + * @since 1.1 + */ + protected static final void logRawDiagnostic(String msg) { + if (diagnosticsStream != null) { + diagnosticsStream.println(msg); + diagnosticsStream.flush(); + } + } + + /** + * Generate useful diagnostics regarding the classloader tree for + * the specified class. + *

+ * As an example, if the specified class was loaded via a webapp's + * classloader, then you may get the following output: + *

+     * Class com.acme.Foo was loaded via classloader 11111
+     * ClassLoader tree: 11111 -> 22222 (SYSTEM) -> 33333 -> BOOT 
+     * 
+ *

+ * This method returns immediately if isDiagnosticsEnabled() + * returns false. + * + * @param clazz is the class whose classloader + tree are to be + * output. + */ + private static void logClassLoaderEnvironment(Class clazz) { + if (!isDiagnosticsEnabled()) { + return; + } + + try { + // Deliberately use System.getProperty here instead of getSystemProperty; if + // the overall security policy for the calling application forbids access to + // these variables then we do not want to output them to the diagnostic stream. + logDiagnostic("[ENV] Extension directories (java.ext.dir): " + System.getProperty("java.ext.dir")); + logDiagnostic("[ENV] Application classpath (java.class.path): " + System.getProperty("java.class.path")); + } catch(SecurityException ex) { + logDiagnostic("[ENV] Security setting prevent interrogation of system classpaths."); + } + + String className = clazz.getName(); + ClassLoader classLoader; + + try { + classLoader = getClassLoader(clazz); + } catch(SecurityException ex) { + // not much useful diagnostics we can print here! + logDiagnostic( + "[ENV] Security forbids determining the classloader for " + className); + return; + } + + logDiagnostic( + "[ENV] Class " + className + " was loaded via classloader " + + objectId(classLoader)); + logHierarchy("[ENV] Ancestry of classloader which loaded " + className + " is ", classLoader); + } + + /** + * Logs diagnostic messages about the given classloader + * and it's hierarchy. The prefix is prepended to the message + * and is intended to make it easier to understand the logs. + * @param prefix + * @param classLoader + */ + private static void logHierarchy(String prefix, ClassLoader classLoader) { + if (!isDiagnosticsEnabled()) { + return; + } + ClassLoader systemClassLoader; + if (classLoader != null) { + final String classLoaderString = classLoader.toString(); + logDiagnostic(prefix + objectId(classLoader) + " == '" + classLoaderString + "'"); + } + + try { + systemClassLoader = ClassLoader.getSystemClassLoader(); + } catch(SecurityException ex) { + logDiagnostic( + prefix + "Security forbids determining the system classloader."); + return; + } + if (classLoader != null) { + StringBuffer buf = new StringBuffer(prefix + "ClassLoader tree:"); + for(;;) { + buf.append(objectId(classLoader)); + if (classLoader == systemClassLoader) { + buf.append(" (SYSTEM) "); + } + + try { + classLoader = classLoader.getParent(); + } catch(SecurityException ex) { + buf.append(" --> SECRET"); + break; + } + + buf.append(" --> "); + if (classLoader == null) { + buf.append("BOOT"); + break; + } + } + logDiagnostic(buf.toString()); + } + } + + /** + * Returns a string that uniquely identifies the specified object, including + * its class. + *

+ * The returned string is of form "classname@hashcode", ie is the same as + * the return value of the Object.toString() method, but works even when + * the specified object's class has overidden the toString method. + * + * @param o may be null. + * @return a string of form classname@hashcode, or "null" if param o is null. + * @since 1.1 + */ + public static String objectId(Object o) { + if (o == null) { + return "null"; + } else { + return o.getClass().getName() + "@" + System.identityHashCode(o); + } + } + + // ---------------------------------------------------------------------- + // Static initialiser block to perform initialisation at class load time. + // + // We can't do this in the class constructor, as there are many + // static methods on this class that can be called before any + // LogFactory instances are created, and they depend upon this + // stuff having been set up. + // + // Note that this block must come after any variable declarations used + // by any methods called from this block, as we want any static initialiser + // associated with the variable to run first. If static initialisers for + // variables run after this code, then (a) their value might be needed + // by methods called from here, and (b) they might *override* any value + // computed here! + // + // So the wisest thing to do is just to place this code at the very end + // of the class file. + // ---------------------------------------------------------------------- + + static { + // note: it's safe to call methods before initDiagnostics (though + // diagnostic output gets discarded). + thisClassLoader = getClassLoader(LogFactory.class); + initDiagnostics(); + logClassLoaderEnvironment(LogFactory.class); + factories = createFactoryStore(); + if (isDiagnosticsEnabled()) { + logDiagnostic("BOOTSTRAP COMPLETED"); + } + } +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogSource.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogSource.java new file mode 100644 index 0000000..50b3e4b --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogSource.java @@ -0,0 +1,262 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.logging; + + +import java.lang.reflect.Constructor; +import java.util.Hashtable; + +import org.apache.commons.logging.impl.NoOpLog; + + +/** + *

Factory for creating {@link Log} instances. Applications should call + * the makeNewLogInstance() method to instantiate new instances + * of the configured {@link Log} implementation class.

+ * + *

By default, calling getInstance() will use the following + * algorithm:

+ *
    + *
  • If Log4J is available, return an instance of + * org.apache.commons.logging.impl.Log4JLogger.
  • + *
  • If JDK 1.4 or later is available, return an instance of + * org.apache.commons.logging.impl.Jdk14Logger.
  • + *
  • Otherwise, return an instance of + * org.apache.commons.logging.impl.NoOpLog.
  • + *
+ * + *

You can change the default behavior in one of two ways:

+ *
    + *
  • On the startup command line, set the system property + * org.apache.commons.logging.log to the name of the + * org.apache.commons.logging.Log implementation class + * you want to use.
  • + *
  • At runtime, call LogSource.setLogImplementation().
  • + *
+ * + * @deprecated Use {@link LogFactory} instead - The default factory + * implementation performs exactly the same algorithm as this class did + * + * @author Rod Waldhoff + * @version $Id: LogSource.java 424107 2006-07-20 23:15:42Z skitching $ + */ +public class LogSource { + + // ------------------------------------------------------- Class Attributes + + static protected Hashtable logs = new Hashtable(); + + /** Is log4j available (in the current classpath) */ + static protected boolean log4jIsAvailable = false; + + /** Is JDK 1.4 logging available */ + static protected boolean jdk14IsAvailable = false; + + /** Constructor for current log class */ + static protected Constructor logImplctor = null; + + + // ----------------------------------------------------- Class Initializers + + static { + + // Is Log4J Available? + try { + if (null != Class.forName("org.apache.log4j.Logger")) { + log4jIsAvailable = true; + } else { + log4jIsAvailable = false; + } + } catch (Throwable t) { + log4jIsAvailable = false; + } + + // Is JDK 1.4 Logging Available? + try { + if ((null != Class.forName("java.util.logging.Logger")) && + (null != Class.forName("org.apache.commons.logging.impl.Jdk14Logger"))) { + jdk14IsAvailable = true; + } else { + jdk14IsAvailable = false; + } + } catch (Throwable t) { + jdk14IsAvailable = false; + } + + // Set the default Log implementation + String name = null; + try { + name = System.getProperty("org.apache.commons.logging.log"); + if (name == null) { + name = System.getProperty("org.apache.commons.logging.Log"); + } + } catch (Throwable t) { + } + if (name != null) { + try { + setLogImplementation(name); + } catch (Throwable t) { + try { + setLogImplementation + ("org.apache.commons.logging.impl.NoOpLog"); + } catch (Throwable u) { + ; + } + } + } else { + try { + if (log4jIsAvailable) { + setLogImplementation + ("org.apache.commons.logging.impl.Log4JLogger"); + } else if (jdk14IsAvailable) { + setLogImplementation + ("org.apache.commons.logging.impl.Jdk14Logger"); + } else { + setLogImplementation + ("org.apache.commons.logging.impl.NoOpLog"); + } + } catch (Throwable t) { + try { + setLogImplementation + ("org.apache.commons.logging.impl.NoOpLog"); + } catch (Throwable u) { + ; + } + } + } + + } + + + // ------------------------------------------------------------ Constructor + + + /** Don't allow others to create instances */ + private LogSource() { + } + + + // ---------------------------------------------------------- Class Methods + + + /** + * Set the log implementation/log implementation factory + * by the name of the class. The given class + * must implement {@link Log}, and provide a constructor that + * takes a single {@link String} argument (containing the name + * of the log). + */ + static public void setLogImplementation(String classname) throws + LinkageError, ExceptionInInitializerError, + NoSuchMethodException, SecurityException, + ClassNotFoundException { + try { + Class logclass = Class.forName(classname); + Class[] argtypes = new Class[1]; + argtypes[0] = "".getClass(); + logImplctor = logclass.getConstructor(argtypes); + } catch (Throwable t) { + logImplctor = null; + } + } + + + /** + * Set the log implementation/log implementation factory + * by class. The given class must implement {@link Log}, + * and provide a constructor that takes a single {@link String} + * argument (containing the name of the log). + */ + static public void setLogImplementation(Class logclass) throws + LinkageError, ExceptionInInitializerError, + NoSuchMethodException, SecurityException { + Class[] argtypes = new Class[1]; + argtypes[0] = "".getClass(); + logImplctor = logclass.getConstructor(argtypes); + } + + + /** Get a Log instance by class name */ + static public Log getInstance(String name) { + Log log = (Log) (logs.get(name)); + if (null == log) { + log = makeNewLogInstance(name); + logs.put(name, log); + } + return log; + } + + + /** Get a Log instance by class */ + static public Log getInstance(Class clazz) { + return getInstance(clazz.getName()); + } + + + /** + * Create a new {@link Log} implementation, based + * on the given name. + *

+ * The specific {@link Log} implementation returned + * is determined by the value of the + * org.apache.commons.logging.log property. + * The value of org.apache.commons.logging.log may be set to + * the fully specified name of a class that implements + * the {@link Log} interface. This class must also + * have a public constructor that takes a single + * {@link String} argument (containing the name + * of the {@link Log} to be constructed. + *

+ * When org.apache.commons.logging.log is not set, + * or when no corresponding class can be found, + * this method will return a Log4JLogger + * if the log4j Logger class is + * available in the {@link LogSource}'s classpath, or a + * Jdk14Logger if we are on a JDK 1.4 or later system, or + * NoOpLog if neither of the above conditions is true. + * + * @param name the log name (or category) + */ + static public Log makeNewLogInstance(String name) { + + Log log = null; + try { + Object[] args = new Object[1]; + args[0] = name; + log = (Log) (logImplctor.newInstance(args)); + } catch (Throwable t) { + log = null; + } + if (null == log) { + log = new NoOpLog(name); + } + return log; + + } + + + /** + * Returns a {@link String} array containing the names of + * all logs known to me. + */ + static public String[] getLogNames() { + return (String[]) (logs.keySet().toArray(new String[logs.size()])); + } + + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/AvalonLogger.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/AvalonLogger.java new file mode 100644 index 0000000..2500172 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/AvalonLogger.java @@ -0,0 +1,292 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.logging.impl; + +import org.apache.avalon.framework.logger.Logger; +import org.apache.commons.logging.Log; + +/** + *

Implementation of commons-logging Log interface that delegates all + * logging calls to the Avalon logging abstraction: the Logger interface. + *

+ *

+ * There are two ways in which this class can be used: + *

+ *
    + *
  • the instance can be constructed with an Avalon logger + * (by calling {@link #AvalonLogger(Logger)}). In this case, it acts + * as a simple thin wrapping implementation over the logger. This is + * particularly useful when using a property setter. + *
  • + *
  • the {@link #setDefaultLogger} class property can be called which + * sets the ancesteral Avalon logger for this class. Any AvalonLogger + * instances created through the LogFactory mechanisms will output + * to child loggers of this Logger. + *
  • + *
+ *

+ * Note: AvalonLogger does not implement Serializable + * because the constructors available for it make this impossible to achieve in all + * circumstances; there is no way to "reconnect" to an underlying Logger object on + * deserialization if one was just passed in to the constructor of the original + * object. This class was marked Serializable in the 1.0.4 release of + * commons-logging, but this never actually worked (a NullPointerException would + * be thrown as soon as the deserialized object was used), so removing this marker + * is not considered to be an incompatible change. + *

+ * @author Neeme Praks + * @version $Revision: 424107 $ $Date: 2006-07-21 01:15:42 +0200 (fr, 21 jul 2006) $ + */ +public class AvalonLogger implements Log { + + /** Ancesteral avalon logger */ + private static Logger defaultLogger = null; + /** Avalon logger used to perform log */ + private transient Logger logger = null; + + /** + * Constructs an AvalonLogger that outputs to the given + * Logger instance. + * @param logger the avalon logger implementation to delegate to + */ + public AvalonLogger(Logger logger) { + this.logger = logger; + } + + /** + * Constructs an AvalonLogger that will log to a child + * of the Logger set by calling {@link #setDefaultLogger}. + * @param name the name of the avalon logger implementation to delegate to + */ + public AvalonLogger(String name) { + if (defaultLogger == null) + throw new NullPointerException("default logger has to be specified if this constructor is used!"); + this.logger = defaultLogger.getChildLogger(name); + } + + /** + * Gets the Avalon logger implementation used to perform logging. + * @return avalon logger implementation + */ + public Logger getLogger() { + return logger; + } + + /** + * Sets the ancesteral Avalon logger from which the delegating loggers + * will descend. + * @param logger the default avalon logger, + * in case there is no logger instance supplied in constructor + */ + public static void setDefaultLogger(Logger logger) { + defaultLogger = logger; + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.debug. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#debug(Object, Throwable) + */ + public void debug(Object message, Throwable t) { + if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message), t); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.debug. + * + * @param message to log. + * @see org.apache.commons.logging.Log#debug(Object) + */ + public void debug(Object message) { + if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message)); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.error. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#error(Object, Throwable) + */ + public void error(Object message, Throwable t) { + if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(message), t); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.error. + * + * @param message to log + * @see org.apache.commons.logging.Log#error(Object) + */ + public void error(Object message) { + if (getLogger().isErrorEnabled()) getLogger().error(String.valueOf(message)); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.fatalError. + * + * @param message to log. + * @param t log this cause. + * @see org.apache.commons.logging.Log#fatal(Object, Throwable) + */ + public void fatal(Object message, Throwable t) { + if (getLogger().isFatalErrorEnabled()) getLogger().fatalError(String.valueOf(message), t); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.fatalError. + * + * @param message to log + * @see org.apache.commons.logging.Log#fatal(Object) + */ + public void fatal(Object message) { + if (getLogger().isFatalErrorEnabled()) getLogger().fatalError(String.valueOf(message)); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.info. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#info(Object, Throwable) + */ + public void info(Object message, Throwable t) { + if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(message), t); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.info. + * + * @param message to log + * @see org.apache.commons.logging.Log#info(Object) + */ + public void info(Object message) { + if (getLogger().isInfoEnabled()) getLogger().info(String.valueOf(message)); + } + + /** + * Is logging to + * org.apache.avalon.framework.logger.Logger.debug enabled? + * @see org.apache.commons.logging.Log#isDebugEnabled() + */ + public boolean isDebugEnabled() { + return getLogger().isDebugEnabled(); + } + + /** + * Is logging to + * org.apache.avalon.framework.logger.Logger.error enabled? + * @see org.apache.commons.logging.Log#isErrorEnabled() + */ + public boolean isErrorEnabled() { + return getLogger().isErrorEnabled(); + } + + /** + * Is logging to + * org.apache.avalon.framework.logger.Logger.fatalError enabled? + * @see org.apache.commons.logging.Log#isFatalEnabled() + */ + public boolean isFatalEnabled() { + return getLogger().isFatalErrorEnabled(); + } + + /** + * Is logging to + * org.apache.avalon.framework.logger.Logger.info enabled? + * @see org.apache.commons.logging.Log#isInfoEnabled() + */ + public boolean isInfoEnabled() { + return getLogger().isInfoEnabled(); + } + + /** + * Is logging to + * org.apache.avalon.framework.logger.Logger.debug enabled? + * @see org.apache.commons.logging.Log#isTraceEnabled() + */ + public boolean isTraceEnabled() { + return getLogger().isDebugEnabled(); + } + + /** + * Is logging to + * org.apache.avalon.framework.logger.Logger.warn enabled? + * @see org.apache.commons.logging.Log#isWarnEnabled() + */ + public boolean isWarnEnabled() { + return getLogger().isWarnEnabled(); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.debug. + * + * @param message to log. + * @param t log this cause. + * @see org.apache.commons.logging.Log#trace(Object, Throwable) + */ + public void trace(Object message, Throwable t) { + if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message), t); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.debug. + * + * @param message to log + * @see org.apache.commons.logging.Log#trace(Object) + */ + public void trace(Object message) { + if (getLogger().isDebugEnabled()) getLogger().debug(String.valueOf(message)); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.warn. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#warn(Object, Throwable) + */ + public void warn(Object message, Throwable t) { + if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(message), t); + } + + /** + * Logs a message with + * org.apache.avalon.framework.logger.Logger.warn. + * + * @param message to log + * @see org.apache.commons.logging.Log#warn(Object) + */ + public void warn(Object message) { + if (getLogger().isWarnEnabled()) getLogger().warn(String.valueOf(message)); + } + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java new file mode 100644 index 0000000..fb17d26 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java @@ -0,0 +1,335 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + + +import java.io.Serializable; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.logging.LogRecord; +import java.util.StringTokenizer; +import java.io.PrintWriter; +import java.io.StringWriter; + +import org.apache.commons.logging.Log; + + +/** + *

Implementation of the org.apache.commons.logging.Log + * interface that wraps the standard JDK logging mechanisms that are + * available in SourceForge's Lumberjack for JDKs prior to 1.4.

+ * + * @author Scott Sanders + * @author Berin Loritsch + * @author Peter Donald + * @author Vince Eagen + * @version $Revision: 424107 $ $Date: 2006-07-21 01:15:42 +0200 (fr, 21 jul 2006) $ + * @since 1.1 + */ + +public class Jdk13LumberjackLogger implements Log, Serializable { + + + // ----------------------------------------------------- Instance Variables + + + /** + * The underlying Logger implementation we are using. + */ + protected transient Logger logger = null; + protected String name = null; + private String sourceClassName = "unknown"; + private String sourceMethodName = "unknown"; + private boolean classAndMethodFound = false; + + + /** + * This member variable simply ensures that any attempt to initialise + * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError. + * It must not be private, as an optimising compiler could detect that it + * is not used and optimise it away. + */ + protected static final Level dummyLevel = Level.FINE; + + // ----------------------------------------------------------- Constructors + + + /** + * Construct a named instance of this Logger. + * + * @param name Name of the logger to be constructed + */ + public Jdk13LumberjackLogger(String name) { + + this.name = name; + logger = getLogger(); + + } + + + // --------------------------------------------------------- Public Methods + + + private void log( Level level, String msg, Throwable ex ) { + if( getLogger().isLoggable(level) ) { + LogRecord record = new LogRecord(level, msg); + if( !classAndMethodFound ) { + getClassAndMethod(); + } + record.setSourceClassName(sourceClassName); + record.setSourceMethodName(sourceMethodName); + if( ex != null ) { + record.setThrown(ex); + } + getLogger().log(record); + } + } + + /** + *

Gets the class and method by looking at the stack trace for the + * first entry that is not this class.

+ */ + private void getClassAndMethod() { + try { + Throwable throwable = new Throwable(); + throwable.fillInStackTrace(); + StringWriter stringWriter = new StringWriter(); + PrintWriter printWriter = new PrintWriter( stringWriter ); + throwable.printStackTrace( printWriter ); + String traceString = stringWriter.getBuffer().toString(); + StringTokenizer tokenizer = + new StringTokenizer( traceString, "\n" ); + tokenizer.nextToken(); + String line = tokenizer.nextToken(); + while ( line.indexOf( this.getClass().getName() ) == -1 ) { + line = tokenizer.nextToken(); + } + while ( line.indexOf( this.getClass().getName() ) >= 0 ) { + line = tokenizer.nextToken(); + } + int start = line.indexOf( "at " ) + 3; + int end = line.indexOf( '(' ); + String temp = line.substring( start, end ); + int lastPeriod = temp.lastIndexOf( '.' ); + sourceClassName = temp.substring( 0, lastPeriod ); + sourceMethodName = temp.substring( lastPeriod + 1 ); + } catch ( Exception ex ) { + // ignore - leave class and methodname unknown + } + classAndMethodFound = true; + } + + /** + * Logs a message with java.util.logging.Level.FINE. + * + * @param message to log + * @see org.apache.commons.logging.Log#debug(Object) + */ + public void debug(Object message) { + log(Level.FINE, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.FINE. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#debug(Object, Throwable) + */ + public void debug(Object message, Throwable exception) { + log(Level.FINE, String.valueOf(message), exception); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @see org.apache.commons.logging.Log#error(Object) + */ + public void error(Object message) { + log(Level.SEVERE, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#error(Object, Throwable) + */ + public void error(Object message, Throwable exception) { + log(Level.SEVERE, String.valueOf(message), exception); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @see org.apache.commons.logging.Log#fatal(Object) + */ + public void fatal(Object message) { + log(Level.SEVERE, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#fatal(Object, Throwable) + */ + public void fatal(Object message, Throwable exception) { + log(Level.SEVERE, String.valueOf(message), exception); + } + + + /** + * Return the native Logger instance we are using. + */ + public Logger getLogger() { + if (logger == null) { + logger = Logger.getLogger(name); + } + return (logger); + } + + + /** + * Logs a message with java.util.logging.Level.INFO. + * + * @param message to log + * @see org.apache.commons.logging.Log#info(Object) + */ + public void info(Object message) { + log(Level.INFO, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.INFO. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#info(Object, Throwable) + */ + public void info(Object message, Throwable exception) { + log(Level.INFO, String.valueOf(message), exception); + } + + + /** + * Is debug logging currently enabled? + */ + public boolean isDebugEnabled() { + return (getLogger().isLoggable(Level.FINE)); + } + + + /** + * Is error logging currently enabled? + */ + public boolean isErrorEnabled() { + return (getLogger().isLoggable(Level.SEVERE)); + } + + + /** + * Is fatal logging currently enabled? + */ + public boolean isFatalEnabled() { + return (getLogger().isLoggable(Level.SEVERE)); + } + + + /** + * Is info logging currently enabled? + */ + public boolean isInfoEnabled() { + return (getLogger().isLoggable(Level.INFO)); + } + + + /** + * Is trace logging currently enabled? + */ + public boolean isTraceEnabled() { + return (getLogger().isLoggable(Level.FINEST)); + } + + + /** + * Is warn logging currently enabled? + */ + public boolean isWarnEnabled() { + return (getLogger().isLoggable(Level.WARNING)); + } + + + /** + * Logs a message with java.util.logging.Level.FINEST. + * + * @param message to log + * @see org.apache.commons.logging.Log#trace(Object) + */ + public void trace(Object message) { + log(Level.FINEST, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.FINEST. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#trace(Object, Throwable) + */ + public void trace(Object message, Throwable exception) { + log(Level.FINEST, String.valueOf(message), exception); + } + + + /** + * Logs a message with java.util.logging.Level.WARNING. + * + * @param message to log + * @see org.apache.commons.logging.Log#warn(Object) + */ + public void warn(Object message) { + log(Level.WARNING, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.WARNING. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#warn(Object, Throwable) + */ + public void warn(Object message, Throwable exception) { + log(Level.WARNING, String.valueOf(message), exception); + } + + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk14Logger.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk14Logger.java new file mode 100644 index 0000000..9fafefd --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk14Logger.java @@ -0,0 +1,304 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + + +import java.io.Serializable; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.commons.logging.Log; + + +/** + *

Implementation of the org.apache.commons.logging.Log + * interface that wraps the standard JDK logging mechanisms that were + * introduced in the Merlin release (JDK 1.4).

+ * + * @author Scott Sanders + * @author Berin Loritsch + * @author Peter Donald + * @version $Revision: 424107 $ $Date: 2006-07-21 01:15:42 +0200 (fr, 21 jul 2006) $ + */ + +public class Jdk14Logger implements Log, Serializable { + + /** + * This member variable simply ensures that any attempt to initialise + * this class in a pre-1.4 JVM will result in an ExceptionInInitializerError. + * It must not be private, as an optimising compiler could detect that it + * is not used and optimise it away. + */ + protected static final Level dummyLevel = Level.FINE; + + // ----------------------------------------------------------- Constructors + + + /** + * Construct a named instance of this Logger. + * + * @param name Name of the logger to be constructed + */ + public Jdk14Logger(String name) { + + this.name = name; + logger = getLogger(); + + } + + + // ----------------------------------------------------- Instance Variables + + + /** + * The underlying Logger implementation we are using. + */ + protected transient Logger logger = null; + + + /** + * The name of the logger we are wrapping. + */ + protected String name = null; + + + // --------------------------------------------------------- Public Methods + + private void log( Level level, String msg, Throwable ex ) { + + Logger logger = getLogger(); + if (logger.isLoggable(level)) { + // Hack (?) to get the stack trace. + Throwable dummyException=new Throwable(); + StackTraceElement locations[]=dummyException.getStackTrace(); + // Caller will be the third element + String cname="unknown"; + String method="unknown"; + if( locations!=null && locations.length >2 ) { + StackTraceElement caller=locations[2]; + cname=caller.getClassName(); + method=caller.getMethodName(); + } + if( ex==null ) { + logger.logp( level, cname, method, msg ); + } else { + logger.logp( level, cname, method, msg, ex ); + } + } + + } + + /** + * Logs a message with java.util.logging.Level.FINE. + * + * @param message to log + * @see org.apache.commons.logging.Log#debug(Object) + */ + public void debug(Object message) { + log(Level.FINE, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.FINE. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#debug(Object, Throwable) + */ + public void debug(Object message, Throwable exception) { + log(Level.FINE, String.valueOf(message), exception); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @see org.apache.commons.logging.Log#error(Object) + */ + public void error(Object message) { + log(Level.SEVERE, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#error(Object, Throwable) + */ + public void error(Object message, Throwable exception) { + log(Level.SEVERE, String.valueOf(message), exception); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @see org.apache.commons.logging.Log#fatal(Object) + */ + public void fatal(Object message) { + log(Level.SEVERE, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.SEVERE. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#fatal(Object, Throwable) + */ + public void fatal(Object message, Throwable exception) { + log(Level.SEVERE, String.valueOf(message), exception); + } + + + /** + * Return the native Logger instance we are using. + */ + public Logger getLogger() { + if (logger == null) { + logger = Logger.getLogger(name); + } + return (logger); + } + + + /** + * Logs a message with java.util.logging.Level.INFO. + * + * @param message to log + * @see org.apache.commons.logging.Log#info(Object) + */ + public void info(Object message) { + log(Level.INFO, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.INFO. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#info(Object, Throwable) + */ + public void info(Object message, Throwable exception) { + log(Level.INFO, String.valueOf(message), exception); + } + + + /** + * Is debug logging currently enabled? + */ + public boolean isDebugEnabled() { + return (getLogger().isLoggable(Level.FINE)); + } + + + /** + * Is error logging currently enabled? + */ + public boolean isErrorEnabled() { + return (getLogger().isLoggable(Level.SEVERE)); + } + + + /** + * Is fatal logging currently enabled? + */ + public boolean isFatalEnabled() { + return (getLogger().isLoggable(Level.SEVERE)); + } + + + /** + * Is info logging currently enabled? + */ + public boolean isInfoEnabled() { + return (getLogger().isLoggable(Level.INFO)); + } + + + /** + * Is trace logging currently enabled? + */ + public boolean isTraceEnabled() { + return (getLogger().isLoggable(Level.FINEST)); + } + + + /** + * Is warn logging currently enabled? + */ + public boolean isWarnEnabled() { + return (getLogger().isLoggable(Level.WARNING)); + } + + + /** + * Logs a message with java.util.logging.Level.FINEST. + * + * @param message to log + * @see org.apache.commons.logging.Log#trace(Object) + */ + public void trace(Object message) { + log(Level.FINEST, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.FINEST. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#trace(Object, Throwable) + */ + public void trace(Object message, Throwable exception) { + log(Level.FINEST, String.valueOf(message), exception); + } + + + /** + * Logs a message with java.util.logging.Level.WARNING. + * + * @param message to log + * @see org.apache.commons.logging.Log#warn(Object) + */ + public void warn(Object message) { + log(Level.WARNING, String.valueOf(message), null); + } + + + /** + * Logs a message with java.util.logging.Level.WARNING. + * + * @param message to log + * @param exception log this cause + * @see org.apache.commons.logging.Log#warn(Object, Throwable) + */ + public void warn(Object message, Throwable exception) { + log(Level.WARNING, String.valueOf(message), exception); + } + + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Log4JLogger.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Log4JLogger.java new file mode 100644 index 0000000..68877b9 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Log4JLogger.java @@ -0,0 +1,342 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + +import java.io.Serializable; +import org.apache.commons.logging.Log; +import org.apache.log4j.Logger; +import org.apache.log4j.Priority; +import org.apache.log4j.Level; + +/** + * Implementation of {@link Log} that maps directly to a + * Logger for log4J version 1.2. + *

+ * Initial configuration of the corresponding Logger instances should be done + * in the usual manner, as outlined in the Log4J documentation. + *

+ * The reason this logger is distinct from the 1.3 logger is that in version 1.2 + * of Log4J: + *

    + *
  • class Logger takes Priority parameters not Level parameters. + *
  • class Level extends Priority + *
+ * Log4J1.3 is expected to change Level so it no longer extends Priority, which is + * a non-binary-compatible change. The class generated by compiling this code against + * log4j 1.2 will therefore not run against log4j 1.3. + * + * @author Scott Sanders + * @author Rod Waldhoff + * @author Robert Burrell Donkin + * @version $Id: Log4JLogger.java 479747 2006-11-27 20:15:01Z dennisl $ + */ + +public class Log4JLogger implements Log, Serializable { + + // ------------------------------------------------------------- Attributes + + /** The fully qualified name of the Log4JLogger class. */ + private static final String FQCN = Log4JLogger.class.getName(); + + /** Log to this logger */ + private transient Logger logger = null; + + /** Logger name */ + private String name = null; + + private static Priority traceLevel; + + // ------------------------------------------------------------ + // Static Initializer. + // + // Note that this must come after the static variable declarations + // otherwise initialiser expressions associated with those variables + // will override any settings done here. + // + // Verify that log4j is available, and that it is version 1.2. + // If an ExceptionInInitializerError is generated, then LogFactoryImpl + // will treat that as meaning that the appropriate underlying logging + // library is just not present - if discovery is in progress then + // discovery will continue. + // ------------------------------------------------------------ + + static { + if (!Priority.class.isAssignableFrom(Level.class)) { + // nope, this is log4j 1.3, so force an ExceptionInInitializerError + throw new InstantiationError("Log4J 1.2 not available"); + } + + // Releases of log4j1.2 >= 1.2.12 have Priority.TRACE available, earlier + // versions do not. If TRACE is not available, then we have to map + // calls to Log.trace(...) onto the DEBUG level. + + try { + traceLevel = (Priority) Level.class.getDeclaredField("TRACE").get(null); + } catch(Exception ex) { + // ok, trace not available + traceLevel = Priority.DEBUG; + } + } + + + // ------------------------------------------------------------ Constructor + + public Log4JLogger() { + } + + + /** + * Base constructor. + */ + public Log4JLogger(String name) { + this.name = name; + this.logger = getLogger(); + } + + /** + * For use with a log4j factory. + */ + public Log4JLogger(Logger logger ) { + if (logger == null) { + throw new IllegalArgumentException( + "Warning - null logger in constructor; possible log4j misconfiguration."); + } + this.name = logger.getName(); + this.logger=logger; + } + + + // --------------------------------------------------------- + // Implementation + // + // Note that in the methods below the Priority class is used to define + // levels even though the Level class is supported in 1.2. This is done + // so that at compile time the call definitely resolves to a call to + // a method that takes a Priority rather than one that takes a Level. + // + // The Category class (and hence its subclass Logger) in version 1.2 only + // has methods that take Priority objects. The Category class (and hence + // Logger class) in version 1.3 has methods that take both Priority and + // Level objects. This means that if we use Level here, and compile + // against log4j 1.3 then calls would be bound to the versions of + // methods taking Level objects and then would fail to run against + // version 1.2 of log4j. + // --------------------------------------------------------- + + + /** + * Logs a message with org.apache.log4j.Priority.TRACE. + * When using a log4j version that does not support the TRACE + * level, the message will be logged at the DEBUG level. + * + * @param message to log + * @see org.apache.commons.logging.Log#trace(Object) + */ + public void trace(Object message) { + getLogger().log(FQCN, traceLevel, message, null ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.TRACE. + * When using a log4j version that does not support the TRACE + * level, the message will be logged at the DEBUG level. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#trace(Object, Throwable) + */ + public void trace(Object message, Throwable t) { + getLogger().log(FQCN, traceLevel, message, t ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.DEBUG. + * + * @param message to log + * @see org.apache.commons.logging.Log#debug(Object) + */ + public void debug(Object message) { + getLogger().log(FQCN, Priority.DEBUG, message, null ); + } + + /** + * Logs a message with org.apache.log4j.Priority.DEBUG. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#debug(Object, Throwable) + */ + public void debug(Object message, Throwable t) { + getLogger().log(FQCN, Priority.DEBUG, message, t ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.INFO. + * + * @param message to log + * @see org.apache.commons.logging.Log#info(Object) + */ + public void info(Object message) { + getLogger().log(FQCN, Priority.INFO, message, null ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.INFO. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#info(Object, Throwable) + */ + public void info(Object message, Throwable t) { + getLogger().log(FQCN, Priority.INFO, message, t ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.WARN. + * + * @param message to log + * @see org.apache.commons.logging.Log#warn(Object) + */ + public void warn(Object message) { + getLogger().log(FQCN, Priority.WARN, message, null ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.WARN. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#warn(Object, Throwable) + */ + public void warn(Object message, Throwable t) { + getLogger().log(FQCN, Priority.WARN, message, t ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.ERROR. + * + * @param message to log + * @see org.apache.commons.logging.Log#error(Object) + */ + public void error(Object message) { + getLogger().log(FQCN, Priority.ERROR, message, null ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.ERROR. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#error(Object, Throwable) + */ + public void error(Object message, Throwable t) { + getLogger().log(FQCN, Priority.ERROR, message, t ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.FATAL. + * + * @param message to log + * @see org.apache.commons.logging.Log#fatal(Object) + */ + public void fatal(Object message) { + getLogger().log(FQCN, Priority.FATAL, message, null ); + } + + + /** + * Logs a message with org.apache.log4j.Priority.FATAL. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#fatal(Object, Throwable) + */ + public void fatal(Object message, Throwable t) { + getLogger().log(FQCN, Priority.FATAL, message, t ); + } + + + /** + * Return the native Logger instance we are using. + */ + public Logger getLogger() { + if (logger == null) { + logger = Logger.getLogger(name); + } + return (this.logger); + } + + + /** + * Check whether the Log4j Logger used is enabled for DEBUG priority. + */ + public boolean isDebugEnabled() { + return getLogger().isDebugEnabled(); + } + + + /** + * Check whether the Log4j Logger used is enabled for ERROR priority. + */ + public boolean isErrorEnabled() { + return getLogger().isEnabledFor(Priority.ERROR); + } + + + /** + * Check whether the Log4j Logger used is enabled for FATAL priority. + */ + public boolean isFatalEnabled() { + return getLogger().isEnabledFor(Priority.FATAL); + } + + + /** + * Check whether the Log4j Logger used is enabled for INFO priority. + */ + public boolean isInfoEnabled() { + return getLogger().isInfoEnabled(); + } + + + /** + * Check whether the Log4j Logger used is enabled for TRACE priority. + * When using a log4j version that does not support the TRACE level, this call + * will report whether DEBUG is enabled or not. + */ + public boolean isTraceEnabled() { + return getLogger().isEnabledFor(traceLevel); + } + + /** + * Check whether the Log4j Logger used is enabled for WARN priority. + */ + public boolean isWarnEnabled() { + return getLogger().isEnabledFor(Priority.WARN); + } +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogFactoryImpl.java new file mode 100644 index 0000000..97a9ac0 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -0,0 +1,1500 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.commons.logging.impl; + + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Vector; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogConfigurationException; +import org.apache.commons.logging.LogFactory; + + +/** + *

Concrete subclass of {@link LogFactory} that implements the + * following algorithm to dynamically select a logging implementation + * class to instantiate a wrapper for.

+ *
    + *
  • Use a factory configuration attribute named + * org.apache.commons.logging.Log to identify the + * requested implementation class.
  • + *
  • Use the org.apache.commons.logging.Log system property + * to identify the requested implementation class.
  • + *
  • If Log4J is available, return an instance of + * org.apache.commons.logging.impl.Log4JLogger.
  • + *
  • If JDK 1.4 or later is available, return an instance of + * org.apache.commons.logging.impl.Jdk14Logger.
  • + *
  • Otherwise, return an instance of + * org.apache.commons.logging.impl.SimpleLog.
  • + *
+ * + *

If the selected {@link Log} implementation class has a + * setLogFactory() method that accepts a {@link LogFactory} + * parameter, this method will be called on each newly created instance + * to identify the associated factory. This makes factory configuration + * attributes available to the Log instance, if it so desires.

+ * + *

This factory will remember previously created Log instances + * for the same name, and will return them on repeated requests to the + * getInstance() method.

+ * + * @author Rod Waldhoff + * @author Craig R. McClanahan + * @author Richard A. Sitze + * @author Brian Stansberry + * @version $Revision: 581090 $ $Date: 2007-10-02 00:01:06 +0200 (ti, 02 okt 2007) $ + */ + +public class LogFactoryImpl extends LogFactory { + + + /** Log4JLogger class name */ + private static final String LOGGING_IMPL_LOG4J_LOGGER = "org.apache.commons.logging.impl.Log4JLogger"; + /** Jdk14Logger class name */ + private static final String LOGGING_IMPL_JDK14_LOGGER = "org.apache.commons.logging.impl.Jdk14Logger"; + /** Jdk13LumberjackLogger class name */ + private static final String LOGGING_IMPL_LUMBERJACK_LOGGER = "org.apache.commons.logging.impl.Jdk13LumberjackLogger"; + /** SimpleLog class name */ + private static final String LOGGING_IMPL_SIMPLE_LOGGER = "org.apache.commons.logging.impl.SimpleLog"; + + private static final String PKG_IMPL="org.apache.commons.logging.impl."; + private static final int PKG_LEN = PKG_IMPL.length(); + + // ----------------------------------------------------------- Constructors + + + + /** + * Public no-arguments constructor required by the lookup mechanism. + */ + public LogFactoryImpl() { + super(); + initDiagnostics(); // method on this object + if (isDiagnosticsEnabled()) { + logDiagnostic("Instance created."); + } + } + + + // ----------------------------------------------------- Manifest Constants + + + /** + * The name (org.apache.commons.logging.Log) of the system + * property identifying our {@link Log} implementation class. + */ + public static final String LOG_PROPERTY = + "org.apache.commons.logging.Log"; + + + /** + * The deprecated system property used for backwards compatibility with + * old versions of JCL. + */ + protected static final String LOG_PROPERTY_OLD = + "org.apache.commons.logging.log"; + + /** + * The name (org.apache.commons.logging.Log.allowFlawedContext) + * of the system property which can be set true/false to + * determine system behaviour when a bad context-classloader is encountered. + * When set to false, a LogConfigurationException is thrown if + * LogFactoryImpl is loaded via a child classloader of the TCCL (this + * should never happen in sane systems). + * + * Default behaviour: true (tolerates bad context classloaders) + * + * See also method setAttribute. + */ + public static final String ALLOW_FLAWED_CONTEXT_PROPERTY = + "org.apache.commons.logging.Log.allowFlawedContext"; + + /** + * The name (org.apache.commons.logging.Log.allowFlawedDiscovery) + * of the system property which can be set true/false to + * determine system behaviour when a bad logging adapter class is + * encountered during logging discovery. When set to false, an + * exception will be thrown and the app will fail to start. When set + * to true, discovery will continue (though the user might end up + * with a different logging implementation than they expected). + * + * Default behaviour: true (tolerates bad logging adapters) + * + * See also method setAttribute. + */ + public static final String ALLOW_FLAWED_DISCOVERY_PROPERTY = + "org.apache.commons.logging.Log.allowFlawedDiscovery"; + + /** + * The name (org.apache.commons.logging.Log.allowFlawedHierarchy) + * of the system property which can be set true/false to + * determine system behaviour when a logging adapter class is + * encountered which has bound to the wrong Log class implementation. + * When set to false, an exception will be thrown and the app will fail + * to start. When set to true, discovery will continue (though the user + * might end up with a different logging implementation than they expected). + * + * Default behaviour: true (tolerates bad Log class hierarchy) + * + * See also method setAttribute. + */ + public static final String ALLOW_FLAWED_HIERARCHY_PROPERTY = + "org.apache.commons.logging.Log.allowFlawedHierarchy"; + + + /** + * The names of classes that will be tried (in order) as logging + * adapters. Each class is expected to implement the Log interface, + * and to throw NoClassDefFound or ExceptionInInitializerError when + * loaded if the underlying logging library is not available. Any + * other error indicates that the underlying logging library is available + * but broken/unusable for some reason. + */ + private static final String[] classesToDiscover = { + LOGGING_IMPL_LOG4J_LOGGER, + "org.apache.commons.logging.impl.Jdk14Logger", + "org.apache.commons.logging.impl.Jdk13LumberjackLogger", + "org.apache.commons.logging.impl.SimpleLog" + }; + + + // ----------------------------------------------------- Instance Variables + + /** + * Determines whether logging classes should be loaded using the thread-context + * classloader, or via the classloader that loaded this LogFactoryImpl class. + */ + private boolean useTCCL = true; + + /** + * The string prefixed to every message output by the logDiagnostic method. + */ + private String diagnosticPrefix; + + + /** + * Configuration attributes. + */ + protected Hashtable attributes = new Hashtable(); + + + /** + * The {@link org.apache.commons.logging.Log} instances that have + * already been created, keyed by logger name. + */ + protected Hashtable instances = new Hashtable(); + + + /** + * Name of the class implementing the Log interface. + */ + private String logClassName; + + + /** + * The one-argument constructor of the + * {@link org.apache.commons.logging.Log} + * implementation class that will be used to create new instances. + * This value is initialized by getLogConstructor(), + * and then returned repeatedly. + */ + protected Constructor logConstructor = null; + + + /** + * The signature of the Constructor to be used. + */ + protected Class logConstructorSignature[] = + { java.lang.String.class }; + + + /** + * The one-argument setLogFactory method of the selected + * {@link org.apache.commons.logging.Log} method, if it exists. + */ + protected Method logMethod = null; + + + /** + * The signature of the setLogFactory method to be used. + */ + protected Class logMethodSignature[] = + { LogFactory.class }; + + /** + * See getBaseClassLoader and initConfiguration. + */ + private boolean allowFlawedContext; + + /** + * See handleFlawedDiscovery and initConfiguration. + */ + private boolean allowFlawedDiscovery; + + /** + * See handleFlawedHierarchy and initConfiguration. + */ + private boolean allowFlawedHierarchy; + + // --------------------------------------------------------- Public Methods + + + /** + * Return the configuration attribute with the specified name (if any), + * or null if there is no such attribute. + * + * @param name Name of the attribute to return + */ + public Object getAttribute(String name) { + + return (attributes.get(name)); + + } + + + /** + * Return an array containing the names of all currently defined + * configuration attributes. If there are no such attributes, a zero + * length array is returned. + */ + public String[] getAttributeNames() { + + Vector names = new Vector(); + Enumeration keys = attributes.keys(); + while (keys.hasMoreElements()) { + names.addElement((String) keys.nextElement()); + } + String results[] = new String[names.size()]; + for (int i = 0; i < results.length; i++) { + results[i] = (String) names.elementAt(i); + } + return (results); + + } + + + /** + * Convenience method to derive a name from the specified class and + * call getInstance(String) with it. + * + * @param clazz Class for which a suitable Log name will be derived + * + * @exception LogConfigurationException if a suitable Log + * instance cannot be returned + */ + public Log getInstance(Class clazz) throws LogConfigurationException { + + return (getInstance(clazz.getName())); + + } + + + /** + *

Construct (if necessary) and return a Log instance, + * using the factory's current set of configuration attributes.

+ * + *

NOTE - Depending upon the implementation of + * the LogFactory you are using, the Log + * instance you are returned may or may not be local to the current + * application, and may or may not be returned again on a subsequent + * call with the same name argument.

+ * + * @param name Logical name of the Log instance to be + * returned (the meaning of this name is only known to the underlying + * logging implementation that is being wrapped) + * + * @exception LogConfigurationException if a suitable Log + * instance cannot be returned + */ + public Log getInstance(String name) throws LogConfigurationException { + + Log instance = (Log) instances.get(name); + if (instance == null) { + instance = newInstance(name); + instances.put(name, instance); + } + return (instance); + + } + + + /** + * Release any internal references to previously created + * {@link org.apache.commons.logging.Log} + * instances returned by this factory. This is useful in environments + * like servlet containers, which implement application reloading by + * throwing away a ClassLoader. Dangling references to objects in that + * class loader would prevent garbage collection. + */ + public void release() { + + logDiagnostic("Releasing all known loggers"); + instances.clear(); + } + + + /** + * Remove any configuration attribute associated with the specified name. + * If there is no such attribute, no action is taken. + * + * @param name Name of the attribute to remove + */ + public void removeAttribute(String name) { + + attributes.remove(name); + + } + + + /** + * Set the configuration attribute with the specified name. Calling + * this with a null value is equivalent to calling + * removeAttribute(name). + *

+ * This method can be used to set logging configuration programmatically + * rather than via system properties. It can also be used in code running + * within a container (such as a webapp) to configure behaviour on a + * per-component level instead of globally as system properties would do. + * To use this method instead of a system property, call + *

+     * LogFactory.getFactory().setAttribute(...)
+     * 
+ * This must be done before the first Log object is created; configuration + * changes after that point will be ignored. + *

+ * This method is also called automatically if LogFactory detects a + * commons-logging.properties file; every entry in that file is set + * automatically as an attribute here. + * + * @param name Name of the attribute to set + * @param value Value of the attribute to set, or null + * to remove any setting for this attribute + */ + public void setAttribute(String name, Object value) { + + if (logConstructor != null) { + logDiagnostic("setAttribute: call too late; configuration already performed."); + } + + if (value == null) { + attributes.remove(name); + } else { + attributes.put(name, value); + } + + if (name.equals(TCCL_KEY)) { + useTCCL = Boolean.valueOf(value.toString()).booleanValue(); + } + + } + + + // ------------------------------------------------------ + // Static Methods + // + // These methods only defined as workarounds for a java 1.2 bug; + // theoretically none of these are needed. + // ------------------------------------------------------ + + /** + * Gets the context classloader. + * This method is a workaround for a java 1.2 compiler bug. + * @since 1.1 + */ + protected static ClassLoader getContextClassLoader() throws LogConfigurationException { + return LogFactory.getContextClassLoader(); + } + + + /** + * Workaround for bug in Java1.2; in theory this method is not needed. + * See LogFactory.isDiagnosticsEnabled. + */ + protected static boolean isDiagnosticsEnabled() { + return LogFactory.isDiagnosticsEnabled(); + } + + + /** + * Workaround for bug in Java1.2; in theory this method is not needed. + * See LogFactory.getClassLoader. + * @since 1.1 + */ + protected static ClassLoader getClassLoader(Class clazz) { + return LogFactory.getClassLoader(clazz); + } + + + // ------------------------------------------------------ Protected Methods + + /** + * Calculate and cache a string that uniquely identifies this instance, + * including which classloader the object was loaded from. + *

+ * This string will later be prefixed to each "internal logging" message + * emitted, so that users can clearly see any unexpected behaviour. + *

+ * Note that this method does not detect whether internal logging is + * enabled or not, nor where to output stuff if it is; that is all + * handled by the parent LogFactory class. This method just computes + * its own unique prefix for log messages. + */ + private void initDiagnostics() { + // It would be nice to include an identifier of the context classloader + // that this LogFactoryImpl object is responsible for. However that + // isn't possible as that information isn't available. It is possible + // to figure this out by looking at the logging from LogFactory to + // see the context & impl ids from when this object was instantiated, + // in order to link the impl id output as this object's prefix back to + // the context it is intended to manage. + // Note that this prefix should be kept consistent with that + // in LogFactory. + Class clazz = this.getClass(); + ClassLoader classLoader = getClassLoader(clazz); + String classLoaderName; + try { + if (classLoader == null) { + classLoaderName = "BOOTLOADER"; + } else { + classLoaderName = objectId(classLoader); + } + } catch(SecurityException e) { + classLoaderName = "UNKNOWN"; + } + diagnosticPrefix = "[LogFactoryImpl@" + System.identityHashCode(this) + " from " + classLoaderName + "] "; + } + + + /** + * Output a diagnostic message to a user-specified destination (if the + * user has enabled diagnostic logging). + * + * @param msg diagnostic message + * @since 1.1 + */ + protected void logDiagnostic(String msg) { + if (isDiagnosticsEnabled()) { + logRawDiagnostic(diagnosticPrefix + msg); + } + } + + /** + * Return the fully qualified Java classname of the {@link Log} + * implementation we will be using. + * + * @deprecated Never invoked by this class; subclasses should not assume + * it will be. + */ + protected String getLogClassName() { + + if (logClassName == null) { + discoverLogImplementation(getClass().getName()); + } + + return logClassName; + } + + + /** + *

Return the Constructor that can be called to instantiate + * new {@link org.apache.commons.logging.Log} instances.

+ * + *

IMPLEMENTATION NOTE - Race conditions caused by + * calling this method from more than one thread are ignored, because + * the same Constructor instance will ultimately be derived + * in all circumstances.

+ * + * @exception LogConfigurationException if a suitable constructor + * cannot be returned + * + * @deprecated Never invoked by this class; subclasses should not assume + * it will be. + */ + protected Constructor getLogConstructor() + throws LogConfigurationException { + + // Return the previously identified Constructor (if any) + if (logConstructor == null) { + discoverLogImplementation(getClass().getName()); + } + + return logConstructor; + } + + + /** + * Is JDK 1.3 with Lumberjack logging available? + * + * @deprecated Never invoked by this class; subclasses should not assume + * it will be. + */ + protected boolean isJdk13LumberjackAvailable() { + return isLogLibraryAvailable( + "Jdk13Lumberjack", + "org.apache.commons.logging.impl.Jdk13LumberjackLogger"); + } + + + /** + *

Return true if JDK 1.4 or later logging + * is available. Also checks that the Throwable class + * supports getStackTrace(), which is required by + * Jdk14Logger.

+ * + * @deprecated Never invoked by this class; subclasses should not assume + * it will be. + */ + protected boolean isJdk14Available() { + return isLogLibraryAvailable( + "Jdk14", + "org.apache.commons.logging.impl.Jdk14Logger"); + } + + + /** + * Is a Log4J implementation available? + * + * @deprecated Never invoked by this class; subclasses should not assume + * it will be. + */ + protected boolean isLog4JAvailable() { + return isLogLibraryAvailable( + "Log4J", + LOGGING_IMPL_LOG4J_LOGGER); + } + + + /** + * Create and return a new {@link org.apache.commons.logging.Log} + * instance for the specified name. + * + * @param name Name of the new logger + * + * @exception LogConfigurationException if a new instance cannot + * be created + */ + protected Log newInstance(String name) throws LogConfigurationException { + + Log instance = null; + try { + if (logConstructor == null) { + instance = discoverLogImplementation(name); + } + else { + Object params[] = { name }; + instance = (Log) logConstructor.newInstance(params); + } + + if (logMethod != null) { + Object params[] = { this }; + logMethod.invoke(instance, params); + } + + return (instance); + + } catch (LogConfigurationException lce) { + + // this type of exception means there was a problem in discovery + // and we've already output diagnostics about the issue, etc.; + // just pass it on + throw (LogConfigurationException) lce; + + } catch (InvocationTargetException e) { + // A problem occurred invoking the Constructor or Method + // previously discovered + Throwable c = e.getTargetException(); + if (c != null) { + throw new LogConfigurationException(c); + } else { + throw new LogConfigurationException(e); + } + } catch (Throwable t) { + // A problem occurred invoking the Constructor or Method + // previously discovered + throw new LogConfigurationException(t); + } + } + + + // ------------------------------------------------------ Private Methods + + /** + * Calls LogFactory.directGetContextClassLoader under the control of an + * AccessController class. This means that java code running under a + * security manager that forbids access to ClassLoaders will still work + * if this class is given appropriate privileges, even when the caller + * doesn't have such privileges. Without using an AccessController, the + * the entire call stack must have the privilege before the call is + * allowed. + * + * @return the context classloader associated with the current thread, + * or null if security doesn't allow it. + * + * @throws LogConfigurationException if there was some weird error while + * attempting to get the context classloader. + * + * @throws SecurityException if the current java security policy doesn't + * allow this class to access the context classloader. + */ + private static ClassLoader getContextClassLoaderInternal() + throws LogConfigurationException { + return (ClassLoader)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return LogFactory.directGetContextClassLoader(); + } + }); + } + + /** + * Read the specified system property, using an AccessController so that + * the property can be read if JCL has been granted the appropriate + * security rights even if the calling code has not. + *

+ * Take care not to expose the value returned by this method to the + * calling application in any way; otherwise the calling app can use that + * info to access data that should not be available to it. + */ + private static String getSystemProperty(final String key, final String def) + throws SecurityException { + return (String) AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return System.getProperty(key, def); + } + }); + } + + /** + * Fetch the parent classloader of a specified classloader. + *

+ * If a SecurityException occurs, null is returned. + *

+ * Note that this method is non-static merely so logDiagnostic is available. + */ + private ClassLoader getParentClassLoader(final ClassLoader cl) { + try { + return (ClassLoader)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return cl.getParent(); + } + }); + } catch(SecurityException ex) { + logDiagnostic("[SECURITY] Unable to obtain parent classloader"); + return null; + } + + } + + /** + * Utility method to check whether a particular logging library is + * present and available for use. Note that this does not + * affect the future behaviour of this class. + */ + private boolean isLogLibraryAvailable(String name, String classname) { + if (isDiagnosticsEnabled()) { + logDiagnostic("Checking for '" + name + "'."); + } + try { + Log log = createLogFromClass( + classname, + this.getClass().getName(), // dummy category + false); + + if (log == null) { + if (isDiagnosticsEnabled()) { + logDiagnostic("Did not find '" + name + "'."); + } + return false; + } else { + if (isDiagnosticsEnabled()) { + logDiagnostic("Found '" + name + "'."); + } + return true; + } + } catch(LogConfigurationException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic("Logging system '" + name + "' is available but not useable."); + } + return false; + } + } + + /** + * Attempt to find an attribute (see method setAttribute) or a + * system property with the provided name and return its value. + *

+ * The attributes associated with this object are checked before + * system properties in case someone has explicitly called setAttribute, + * or a configuration property has been set in a commons-logging.properties + * file. + * + * @return the value associated with the property, or null. + */ + private String getConfigurationValue(String property) { + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] Trying to get configuration for item " + property); + } + + Object valueObj = getAttribute(property); + if (valueObj != null) { + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] Found LogFactory attribute [" + valueObj + "] for " + property); + } + return valueObj.toString(); + } + + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] No LogFactory attribute found for " + property); + } + + try { + // warning: minor security hole here, in that we potentially read a system + // property that the caller cannot, then output it in readable form as a + // diagnostic message. However it's only ever JCL-specific properties + // involved here, so the harm is truly trivial. + String value = getSystemProperty(property, null); + if (value != null) { + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] Found system property [" + value + "] for " + property); + } + return value; + } + + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] No system property found for property " + property); + } + } catch (SecurityException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] Security prevented reading system property " + property); + } + } + + if (isDiagnosticsEnabled()) { + logDiagnostic("[ENV] No configuration defined for item " + property); + } + + return null; + } + + /** + * Get the setting for the user-configurable behaviour specified by key. + * If nothing has explicitly been set, then return dflt. + */ + private boolean getBooleanConfiguration(String key, boolean dflt) { + String val = getConfigurationValue(key); + if (val == null) + return dflt; + return Boolean.valueOf(val).booleanValue(); + } + + /** + * Initialize a number of variables that control the behaviour of this + * class and that can be tweaked by the user. This is done when the first + * logger is created, not in the constructor of this class, because we + * need to give the user a chance to call method setAttribute in order to + * configure this object. + */ + private void initConfiguration() { + allowFlawedContext = getBooleanConfiguration(ALLOW_FLAWED_CONTEXT_PROPERTY, true); + allowFlawedDiscovery = getBooleanConfiguration(ALLOW_FLAWED_DISCOVERY_PROPERTY, true); + allowFlawedHierarchy = getBooleanConfiguration(ALLOW_FLAWED_HIERARCHY_PROPERTY, true); + } + + + /** + * Attempts to create a Log instance for the given category name. + * Follows the discovery process described in the class javadoc. + * + * @param logCategory the name of the log category + * + * @throws LogConfigurationException if an error in discovery occurs, + * or if no adapter at all can be instantiated + */ + private Log discoverLogImplementation(String logCategory) + throws LogConfigurationException + { + if (isDiagnosticsEnabled()) { + logDiagnostic("Discovering a Log implementation..."); + } + + initConfiguration(); + + Log result = null; + + // See if the user specified the Log implementation to use + String specifiedLogClassName = findUserSpecifiedLogClassName(); + + if (specifiedLogClassName != null) { + if (isDiagnosticsEnabled()) { + logDiagnostic("Attempting to load user-specified log class '" + + specifiedLogClassName + "'..."); + } + + result = createLogFromClass(specifiedLogClassName, + logCategory, + true); + if (result == null) { + StringBuffer messageBuffer = new StringBuffer("User-specified log class '"); + messageBuffer.append(specifiedLogClassName); + messageBuffer.append("' cannot be found or is not useable."); + + // Mistyping or misspelling names is a common fault. + // Construct a good error message, if we can + if (specifiedLogClassName != null) { + informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LOG4J_LOGGER); + informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_JDK14_LOGGER); + informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_LUMBERJACK_LOGGER); + informUponSimilarName(messageBuffer, specifiedLogClassName, LOGGING_IMPL_SIMPLE_LOGGER); + } + throw new LogConfigurationException(messageBuffer.toString()); + } + + return result; + } + + // No user specified log; try to discover what's on the classpath + // + // Note that we deliberately loop here over classesToDiscover and + // expect method createLogFromClass to loop over the possible source + // classloaders. The effect is: + // for each discoverable log adapter + // for each possible classloader + // see if it works + // + // It appears reasonable at first glance to do the opposite: + // for each possible classloader + // for each discoverable log adapter + // see if it works + // + // The latter certainly has advantages for user-installable logging + // libraries such as log4j; in a webapp for example this code should + // first check whether the user has provided any of the possible + // logging libraries before looking in the parent classloader. + // Unfortunately, however, Jdk14Logger will always work in jvm>=1.4, + // and SimpleLog will always work in any JVM. So the loop would never + // ever look for logging libraries in the parent classpath. Yet many + // users would expect that putting log4j there would cause it to be + // detected (and this is the historical JCL behaviour). So we go with + // the first approach. A user that has bundled a specific logging lib + // in a webapp should use a commons-logging.properties file or a + // service file in META-INF to force use of that logging lib anyway, + // rather than relying on discovery. + + if (isDiagnosticsEnabled()) { + logDiagnostic( + "No user-specified Log implementation; performing discovery" + + " using the standard supported logging implementations..."); + } + for(int i=0; (iStringBuffer the message should be appended to, + * not null + * @param name the (trimmed) name to be test against the candidate, not null + * @param candidate the candidate name (not null) + */ + private void informUponSimilarName(final StringBuffer messageBuffer, final String name, + final String candidate) { + if (name.equals(candidate)) { + // Don't suggest a name that is exactly the same as the one the + // user tried... + return; + } + + // If the user provides a name that is in the right package, and gets + // the first 5 characters of the adapter class right (ignoring case), + // then suggest the candidate adapter class name. + if (name.regionMatches(true, 0, candidate, 0, PKG_LEN + 5)) { + messageBuffer.append(" Did you mean '"); + messageBuffer.append(candidate); + messageBuffer.append("'?"); + } + } + + + /** + * Checks system properties and the attribute map for + * a Log implementation specified by the user under the + * property names {@link #LOG_PROPERTY} or {@link #LOG_PROPERTY_OLD}. + * + * @return classname specified by the user, or null + */ + private String findUserSpecifiedLogClassName() + { + if (isDiagnosticsEnabled()) { + logDiagnostic("Trying to get log class from attribute '" + LOG_PROPERTY + "'"); + } + String specifiedClass = (String) getAttribute(LOG_PROPERTY); + + if (specifiedClass == null) { // @deprecated + if (isDiagnosticsEnabled()) { + logDiagnostic("Trying to get log class from attribute '" + + LOG_PROPERTY_OLD + "'"); + } + specifiedClass = (String) getAttribute(LOG_PROPERTY_OLD); + } + + if (specifiedClass == null) { + if (isDiagnosticsEnabled()) { + logDiagnostic("Trying to get log class from system property '" + + LOG_PROPERTY + "'"); + } + try { + specifiedClass = getSystemProperty(LOG_PROPERTY, null); + } catch (SecurityException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic("No access allowed to system property '" + + LOG_PROPERTY + "' - " + e.getMessage()); + } + } + } + + if (specifiedClass == null) { // @deprecated + if (isDiagnosticsEnabled()) { + logDiagnostic("Trying to get log class from system property '" + + LOG_PROPERTY_OLD + "'"); + } + try { + specifiedClass = getSystemProperty(LOG_PROPERTY_OLD, null); + } catch (SecurityException e) { + if (isDiagnosticsEnabled()) { + logDiagnostic("No access allowed to system property '" + + LOG_PROPERTY_OLD + "' - " + e.getMessage()); + } + } + } + + // Remove any whitespace; it's never valid in a classname so its + // presence just means a user mistake. As we know what they meant, + // we may as well strip the spaces. + if (specifiedClass != null) { + specifiedClass = specifiedClass.trim(); + } + + return specifiedClass; + } + + + /** + * Attempts to load the given class, find a suitable constructor, + * and instantiate an instance of Log. + * + * @param logAdapterClassName classname of the Log implementation + * + * @param logCategory argument to pass to the Log implementation's + * constructor + * + * @param affectState true if this object's state should + * be affected by this method call, false otherwise. + * + * @return an instance of the given class, or null if the logging + * library associated with the specified adapter is not available. + * + * @throws LogConfigurationException if there was a serious error with + * configuration and the handleFlawedDiscovery method decided this + * problem was fatal. + */ + private Log createLogFromClass(String logAdapterClassName, + String logCategory, + boolean affectState) + throws LogConfigurationException { + + if (isDiagnosticsEnabled()) { + logDiagnostic("Attempting to instantiate '" + logAdapterClassName + "'"); + } + + Object[] params = { logCategory }; + Log logAdapter = null; + Constructor constructor = null; + + Class logAdapterClass = null; + ClassLoader currentCL = getBaseClassLoader(); + + for(;;) { + // Loop through the classloader hierarchy trying to find + // a viable classloader. + logDiagnostic( + "Trying to load '" + + logAdapterClassName + + "' from classloader " + + objectId(currentCL)); + try { + if (isDiagnosticsEnabled()) { + // Show the location of the first occurrence of the .class file + // in the classpath. This is the location that ClassLoader.loadClass + // will load the class from -- unless the classloader is doing + // something weird. + URL url; + String resourceName = logAdapterClassName.replace('.', '/') + ".class"; + if (currentCL != null) { + url = currentCL.getResource(resourceName ); + } else { + url = ClassLoader.getSystemResource(resourceName + ".class"); + } + + if (url == null) { + logDiagnostic("Class '" + logAdapterClassName + "' [" + resourceName + "] cannot be found."); + } else { + logDiagnostic("Class '" + logAdapterClassName + "' was found at '" + url + "'"); + } + } + + Class c = null; + try { + c = Class.forName(logAdapterClassName, true, currentCL); + } catch (ClassNotFoundException originalClassNotFoundException) { + // The current classloader was unable to find the log adapter + // in this or any ancestor classloader. There's no point in + // trying higher up in the hierarchy in this case.. + String msg = "" + originalClassNotFoundException.getMessage(); + logDiagnostic( + "The log adapter '" + + logAdapterClassName + + "' is not available via classloader " + + objectId(currentCL) + + ": " + + msg.trim()); + try { + // Try the class classloader. + // This may work in cases where the TCCL + // does not contain the code executed or JCL. + // This behaviour indicates that the application + // classloading strategy is not consistent with the + // Java 1.2 classloading guidelines but JCL can + // and so should handle this case. + c = Class.forName(logAdapterClassName); + } catch (ClassNotFoundException secondaryClassNotFoundException) { + // no point continuing: this adapter isn't available + msg = "" + secondaryClassNotFoundException.getMessage(); + logDiagnostic( + "The log adapter '" + + logAdapterClassName + + "' is not available via the LogFactoryImpl class classloader: " + + msg.trim()); + break; + } + } + + constructor = c.getConstructor(logConstructorSignature); + Object o = constructor.newInstance(params); + + // Note that we do this test after trying to create an instance + // [rather than testing Log.class.isAssignableFrom(c)] so that + // we don't complain about Log hierarchy problems when the + // adapter couldn't be instantiated anyway. + if (o instanceof Log) { + logAdapterClass = c; + logAdapter = (Log) o; + break; + } + + // Oops, we have a potential problem here. An adapter class + // has been found and its underlying lib is present too, but + // there are multiple Log interface classes available making it + // impossible to cast to the type the caller wanted. We + // certainly can't use this logger, but we need to know whether + // to keep on discovering or terminate now. + // + // The handleFlawedHierarchy method will throw + // LogConfigurationException if it regards this problem as + // fatal, and just return if not. + handleFlawedHierarchy(currentCL, c); + } catch (NoClassDefFoundError e) { + // We were able to load the adapter but it had references to + // other classes that could not be found. This simply means that + // the underlying logger library is not present in this or any + // ancestor classloader. There's no point in trying higher up + // in the hierarchy in this case.. + String msg = "" + e.getMessage(); + logDiagnostic( + "The log adapter '" + + logAdapterClassName + + "' is missing dependencies when loaded via classloader " + + objectId(currentCL) + + ": " + + msg.trim()); + break; + } catch (ExceptionInInitializerError e) { + // A static initializer block or the initializer code associated + // with a static variable on the log adapter class has thrown + // an exception. + // + // We treat this as meaning the adapter's underlying logging + // library could not be found. + String msg = "" + e.getMessage(); + logDiagnostic( + "The log adapter '" + + logAdapterClassName + + "' is unable to initialize itself when loaded via classloader " + + objectId(currentCL) + + ": " + + msg.trim()); + break; + } catch(LogConfigurationException e) { + // call to handleFlawedHierarchy above must have thrown + // a LogConfigurationException, so just throw it on + throw e; + } catch(Throwable t) { + // handleFlawedDiscovery will determine whether this is a fatal + // problem or not. If it is fatal, then a LogConfigurationException + // will be thrown. + handleFlawedDiscovery(logAdapterClassName, currentCL, t); + } + + if (currentCL == null) { + break; + } + + // try the parent classloader + // currentCL = currentCL.getParent(); + currentCL = getParentClassLoader(currentCL); + } + + if ((logAdapter != null) && affectState) { + // We've succeeded, so set instance fields + this.logClassName = logAdapterClassName; + this.logConstructor = constructor; + + // Identify the setLogFactory method (if there is one) + try { + this.logMethod = logAdapterClass.getMethod("setLogFactory", + logMethodSignature); + logDiagnostic("Found method setLogFactory(LogFactory) in '" + + logAdapterClassName + "'"); + } catch (Throwable t) { + this.logMethod = null; + logDiagnostic( + "[INFO] '" + logAdapterClassName + + "' from classloader " + objectId(currentCL) + + " does not declare optional method " + + "setLogFactory(LogFactory)"); + } + + logDiagnostic( + "Log adapter '" + logAdapterClassName + + "' from classloader " + objectId(logAdapterClass.getClassLoader()) + + " has been selected for use."); + } + + return logAdapter; + } + + + /** + * Return the classloader from which we should try to load the logging + * adapter classes. + *

+ * This method usually returns the context classloader. However if it + * is discovered that the classloader which loaded this class is a child + * of the context classloader and the allowFlawedContext option + * has been set then the classloader which loaded this class is returned + * instead. + *

+ * The only time when the classloader which loaded this class is a + * descendant (rather than the same as or an ancestor of the context + * classloader) is when an app has created custom classloaders but + * failed to correctly set the context classloader. This is a bug in + * the calling application; however we provide the option for JCL to + * simply generate a warning rather than fail outright. + * + */ + private ClassLoader getBaseClassLoader() throws LogConfigurationException { + ClassLoader thisClassLoader = getClassLoader(LogFactoryImpl.class); + + if (useTCCL == false) { + return thisClassLoader; + } + + ClassLoader contextClassLoader = getContextClassLoaderInternal(); + + ClassLoader baseClassLoader = getLowestClassLoader( + contextClassLoader, thisClassLoader); + + if (baseClassLoader == null) { + // The two classloaders are not part of a parent child relationship. + // In some classloading setups (e.g. JBoss with its + // UnifiedLoaderRepository) this can still work, so if user hasn't + // forbidden it, just return the contextClassLoader. + if (allowFlawedContext) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "[WARNING] the context classloader is not part of a" + + " parent-child relationship with the classloader that" + + " loaded LogFactoryImpl."); + } + // If contextClassLoader were null, getLowestClassLoader() would + // have returned thisClassLoader. The fact we are here means + // contextClassLoader is not null, so we can just return it. + return contextClassLoader; + } + else { + throw new LogConfigurationException( + "Bad classloader hierarchy; LogFactoryImpl was loaded via" + + " a classloader that is not related to the current context" + + " classloader."); + } + } + + if (baseClassLoader != contextClassLoader) { + // We really should just use the contextClassLoader as the starting + // point for scanning for log adapter classes. However it is expected + // that there are a number of broken systems out there which create + // custom classloaders but fail to set the context classloader so + // we handle those flawed systems anyway. + if (allowFlawedContext) { + if (isDiagnosticsEnabled()) { + logDiagnostic( + "Warning: the context classloader is an ancestor of the" + + " classloader that loaded LogFactoryImpl; it should be" + + " the same or a descendant. The application using" + + " commons-logging should ensure the context classloader" + + " is used correctly."); + } + } else { + throw new LogConfigurationException( + "Bad classloader hierarchy; LogFactoryImpl was loaded via" + + " a classloader that is not related to the current context" + + " classloader."); + } + } + + return baseClassLoader; + } + + /** + * Given two related classloaders, return the one which is a child of + * the other. + *

+ * @param c1 is a classloader (including the null classloader) + * @param c2 is a classloader (including the null classloader) + * + * @return c1 if it has c2 as an ancestor, c2 if it has c1 as an ancestor, + * and null if neither is an ancestor of the other. + */ + private ClassLoader getLowestClassLoader(ClassLoader c1, ClassLoader c2) { + // TODO: use AccessController when dealing with classloaders here + + if (c1 == null) + return c2; + + if (c2 == null) + return c1; + + ClassLoader current; + + // scan c1's ancestors to find c2 + current = c1; + while (current != null) { + if (current == c2) + return c1; + current = current.getParent(); + } + + // scan c2's ancestors to find c1 + current = c2; + while (current != null) { + if (current == c1) + return c2; + current = current.getParent(); + } + + return null; + } + + /** + * Generates an internal diagnostic logging of the discovery failure and + * then throws a LogConfigurationException that wraps + * the passed Throwable. + * + * @param logAdapterClassName is the class name of the Log implementation + * that could not be instantiated. Cannot be null. + * + * @param classLoader is the classloader that we were trying to load the + * logAdapterClassName from when the exception occurred. + * + * @param discoveryFlaw is the Throwable created by the classloader + * + * @throws LogConfigurationException ALWAYS + */ + private void handleFlawedDiscovery(String logAdapterClassName, + ClassLoader classLoader, + Throwable discoveryFlaw) { + + if (isDiagnosticsEnabled()) { + logDiagnostic("Could not instantiate Log '" + + logAdapterClassName + "' -- " + + discoveryFlaw.getClass().getName() + ": " + + discoveryFlaw.getLocalizedMessage()); + + if (discoveryFlaw instanceof InvocationTargetException ) { + // Ok, the lib is there but while trying to create a real underlying + // logger something failed in the underlying lib; display info about + // that if possible. + InvocationTargetException ite = (InvocationTargetException)discoveryFlaw; + Throwable cause = ite.getTargetException(); + if (cause != null) { + logDiagnostic("... InvocationTargetException: " + + cause.getClass().getName() + ": " + + cause.getLocalizedMessage()); + + if (cause instanceof ExceptionInInitializerError) { + ExceptionInInitializerError eiie = (ExceptionInInitializerError)cause; + Throwable cause2 = eiie.getException(); + if (cause2 != null) { + logDiagnostic("... ExceptionInInitializerError: " + + cause2.getClass().getName() + ": " + + cause2.getLocalizedMessage()); + } + } + } + } + } + + if (!allowFlawedDiscovery) { + throw new LogConfigurationException(discoveryFlaw); + } + } + + + /** + * Report a problem loading the log adapter, then either return + * (if the situation is considered recoverable) or throw a + * LogConfigurationException. + *

+ * There are two possible reasons why we successfully loaded the + * specified log adapter class then failed to cast it to a Log object: + *

    + *
  1. the specific class just doesn't implement the Log interface + * (user screwed up), or + *
  2. the specified class has bound to a Log class loaded by some other + * classloader; Log@classloaderX cannot be cast to Log@classloaderY. + *
+ *

+ * Here we try to figure out which case has occurred so we can give the + * user some reasonable feedback. + * + * @param badClassLoader is the classloader we loaded the problem class from, + * ie it is equivalent to badClass.getClassLoader(). + * + * @param badClass is a Class object with the desired name, but which + * does not implement Log correctly. + * + * @throws LogConfigurationException when the situation + * should not be recovered from. + */ + private void handleFlawedHierarchy(ClassLoader badClassLoader, Class badClass) + throws LogConfigurationException { + + boolean implementsLog = false; + String logInterfaceName = Log.class.getName(); + Class interfaces[] = badClass.getInterfaces(); + for (int i = 0; i < interfaces.length; i++) { + if (logInterfaceName.equals(interfaces[i].getName())) { + implementsLog = true; + break; + } + } + + if (implementsLog) { + // the class does implement an interface called Log, but + // it is in the wrong classloader + if (isDiagnosticsEnabled()) { + try { + ClassLoader logInterfaceClassLoader = getClassLoader(Log.class); + logDiagnostic( + "Class '" + badClass.getName() + + "' was found in classloader " + + objectId(badClassLoader) + + ". It is bound to a Log interface which is not" + + " the one loaded from classloader " + + objectId(logInterfaceClassLoader)); + } catch (Throwable t) { + logDiagnostic( + "Error while trying to output diagnostics about" + + " bad class '" + badClass + "'"); + } + } + + if (!allowFlawedHierarchy) { + StringBuffer msg = new StringBuffer(); + msg.append("Terminating logging for this context "); + msg.append("due to bad log hierarchy. "); + msg.append("You have more than one version of '"); + msg.append(Log.class.getName()); + msg.append("' visible."); + if (isDiagnosticsEnabled()) { + logDiagnostic(msg.toString()); + } + throw new LogConfigurationException(msg.toString()); + } + + if (isDiagnosticsEnabled()) { + StringBuffer msg = new StringBuffer(); + msg.append("Warning: bad log hierarchy. "); + msg.append("You have more than one version of '"); + msg.append(Log.class.getName()); + msg.append("' visible."); + logDiagnostic(msg.toString()); + } + } else { + // this is just a bad adapter class + if (!allowFlawedDiscovery) { + StringBuffer msg = new StringBuffer(); + msg.append("Terminating logging for this context. "); + msg.append("Log class '"); + msg.append(badClass.getName()); + msg.append("' does not implement the Log interface."); + if (isDiagnosticsEnabled()) { + logDiagnostic(msg.toString()); + } + + throw new LogConfigurationException(msg.toString()); + } + + if (isDiagnosticsEnabled()) { + StringBuffer msg = new StringBuffer(); + msg.append("[WARNING] Log class '"); + msg.append(badClass.getName()); + msg.append("' does not implement the Log interface."); + logDiagnostic(msg.toString()); + } + } + } +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogKitLogger.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogKitLogger.java new file mode 100644 index 0000000..2587e81 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogKitLogger.java @@ -0,0 +1,294 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + +import java.io.Serializable; +import org.apache.log.Logger; +import org.apache.log.Hierarchy; +import org.apache.commons.logging.Log; + +/** + *

Implementation of org.apache.commons.logging.Log + * that wraps the avalon-logkit + * logging system. Configuration of LogKit is left to the user. + *

+ * + *

LogKit accepts only String messages. + * Therefore, this implementation converts object messages into strings + * by called their toString() method before logging them.

+ * + * @author Scott Sanders + * @author Robert Burrell Donkin + * @version $Id: LogKitLogger.java 424107 2006-07-20 23:15:42Z skitching $ + */ + +public class LogKitLogger implements Log, Serializable { + + + // ------------------------------------------------------------- Attributes + + + /** Logging goes to this LogKit logger */ + protected transient Logger logger = null; + + /** Name of this logger */ + protected String name = null; + + + // ------------------------------------------------------------ Constructor + + + /** + * Construct LogKitLogger which wraps the LogKit + * logger with given name. + * + * @param name log name + */ + public LogKitLogger(String name) { + this.name = name; + this.logger = getLogger(); + } + + + // --------------------------------------------------------- Public Methods + + + /** + *

Return the underlying Logger we are using.

+ */ + public Logger getLogger() { + + if (logger == null) { + logger = Hierarchy.getDefaultHierarchy().getLoggerFor(name); + } + return (logger); + + } + + + // ----------------------------------------------------- Log Implementation + + + /** + * Logs a message with org.apache.log.Priority.DEBUG. + * + * @param message to log + * @see org.apache.commons.logging.Log#trace(Object) + */ + public void trace(Object message) { + debug(message); + } + + + /** + * Logs a message with org.apache.log.Priority.DEBUG. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#trace(Object, Throwable) + */ + public void trace(Object message, Throwable t) { + debug(message, t); + } + + + /** + * Logs a message with org.apache.log.Priority.DEBUG. + * + * @param message to log + * @see org.apache.commons.logging.Log#debug(Object) + */ + public void debug(Object message) { + if (message != null) { + getLogger().debug(String.valueOf(message)); + } + } + + + /** + * Logs a message with org.apache.log.Priority.DEBUG. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#debug(Object, Throwable) + */ + public void debug(Object message, Throwable t) { + if (message != null) { + getLogger().debug(String.valueOf(message), t); + } + } + + + /** + * Logs a message with org.apache.log.Priority.INFO. + * + * @param message to log + * @see org.apache.commons.logging.Log#info(Object) + */ + public void info(Object message) { + if (message != null) { + getLogger().info(String.valueOf(message)); + } + } + + + /** + * Logs a message with org.apache.log.Priority.INFO. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#info(Object, Throwable) + */ + public void info(Object message, Throwable t) { + if (message != null) { + getLogger().info(String.valueOf(message), t); + } + } + + + /** + * Logs a message with org.apache.log.Priority.WARN. + * + * @param message to log + * @see org.apache.commons.logging.Log#warn(Object) + */ + public void warn(Object message) { + if (message != null) { + getLogger().warn(String.valueOf(message)); + } + } + + + /** + * Logs a message with org.apache.log.Priority.WARN. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#warn(Object, Throwable) + */ + public void warn(Object message, Throwable t) { + if (message != null) { + getLogger().warn(String.valueOf(message), t); + } + } + + + /** + * Logs a message with org.apache.log.Priority.ERROR. + * + * @param message to log + * @see org.apache.commons.logging.Log#error(Object) + */ + public void error(Object message) { + if (message != null) { + getLogger().error(String.valueOf(message)); + } + } + + + /** + * Logs a message with org.apache.log.Priority.ERROR. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#error(Object, Throwable) + */ + public void error(Object message, Throwable t) { + if (message != null) { + getLogger().error(String.valueOf(message), t); + } + } + + + /** + * Logs a message with org.apache.log.Priority.FATAL_ERROR. + * + * @param message to log + * @see org.apache.commons.logging.Log#fatal(Object) + */ + public void fatal(Object message) { + if (message != null) { + getLogger().fatalError(String.valueOf(message)); + } + } + + + /** + * Logs a message with org.apache.log.Priority.FATAL_ERROR. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#fatal(Object, Throwable) + */ + public void fatal(Object message, Throwable t) { + if (message != null) { + getLogger().fatalError(String.valueOf(message), t); + } + } + + + /** + * Checks whether the LogKit logger will log messages of priority DEBUG. + */ + public boolean isDebugEnabled() { + return getLogger().isDebugEnabled(); + } + + + /** + * Checks whether the LogKit logger will log messages of priority ERROR. + */ + public boolean isErrorEnabled() { + return getLogger().isErrorEnabled(); + } + + + /** + * Checks whether the LogKit logger will log messages of priority FATAL_ERROR. + */ + public boolean isFatalEnabled() { + return getLogger().isFatalErrorEnabled(); + } + + + /** + * Checks whether the LogKit logger will log messages of priority INFO. + */ + public boolean isInfoEnabled() { + return getLogger().isInfoEnabled(); + } + + + /** + * Checks whether the LogKit logger will log messages of priority DEBUG. + */ + public boolean isTraceEnabled() { + return getLogger().isDebugEnabled(); + } + + + /** + * Checks whether the LogKit logger will log messages of priority WARN. + */ + public boolean isWarnEnabled() { + return getLogger().isWarnEnabled(); + } + + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/NoOpLog.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/NoOpLog.java new file mode 100644 index 0000000..229cdff --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/NoOpLog.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + + +import java.io.Serializable; +import org.apache.commons.logging.Log; + + +/** + *

Trivial implementation of Log that throws away all messages. No + * configurable system properties are supported.

+ * + * @author Scott Sanders + * @author Rod Waldhoff + * @version $Id: NoOpLog.java 424107 2006-07-20 23:15:42Z skitching $ + */ +public class NoOpLog implements Log, Serializable { + + /** Convenience constructor */ + public NoOpLog() { } + /** Base constructor */ + public NoOpLog(String name) { } + /** Do nothing */ + public void trace(Object message) { } + /** Do nothing */ + public void trace(Object message, Throwable t) { } + /** Do nothing */ + public void debug(Object message) { } + /** Do nothing */ + public void debug(Object message, Throwable t) { } + /** Do nothing */ + public void info(Object message) { } + /** Do nothing */ + public void info(Object message, Throwable t) { } + /** Do nothing */ + public void warn(Object message) { } + /** Do nothing */ + public void warn(Object message, Throwable t) { } + /** Do nothing */ + public void error(Object message) { } + /** Do nothing */ + public void error(Object message, Throwable t) { } + /** Do nothing */ + public void fatal(Object message) { } + /** Do nothing */ + public void fatal(Object message, Throwable t) { } + + /** + * Debug is never enabled. + * + * @return false + */ + public final boolean isDebugEnabled() { return false; } + + /** + * Error is never enabled. + * + * @return false + */ + public final boolean isErrorEnabled() { return false; } + + /** + * Fatal is never enabled. + * + * @return false + */ + public final boolean isFatalEnabled() { return false; } + + /** + * Info is never enabled. + * + * @return false + */ + public final boolean isInfoEnabled() { return false; } + + /** + * Trace is never enabled. + * + * @return false + */ + public final boolean isTraceEnabled() { return false; } + + /** + * Warn is never enabled. + * + * @return false + */ + public final boolean isWarnEnabled() { return false; } + +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/ServletContextCleaner.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/ServletContextCleaner.java new file mode 100644 index 0000000..6061171 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/ServletContextCleaner.java @@ -0,0 +1,138 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; + +import org.apache.commons.logging.LogFactory; + + +/** + * This class is capable of receiving notifications about the undeployment of + * a webapp, and responds by ensuring that commons-logging releases all + * memory associated with the undeployed webapp. + *

+ * In general, the WeakHashtable support added in commons-logging release 1.1 + * ensures that logging classes do not hold references that prevent an + * undeployed webapp's memory from being garbage-collected even when multiple + * copies of commons-logging are deployed via multiple classloaders (a + * situation that earlier versions had problems with). However there are + * some rare cases where the WeakHashtable approach does not work; in these + * situations specifying this class as a listener for the web application will + * ensure that all references held by commons-logging are fully released. + *

+ * To use this class, configure the webapp deployment descriptor to call + * this class on webapp undeploy; the contextDestroyed method will tell + * every accessable LogFactory class that the entry in its map for the + * current webapp's context classloader should be cleared. + * + * @since 1.1 + */ + +public class ServletContextCleaner implements ServletContextListener { + + private Class[] RELEASE_SIGNATURE = {ClassLoader.class}; + + /** + * Invoked when a webapp is undeployed, this tells the LogFactory + * class to release any logging information related to the current + * contextClassloader. + */ + public void contextDestroyed(ServletContextEvent sce) { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + + Object[] params = new Object[1]; + params[0] = tccl; + + // Walk up the tree of classloaders, finding all the available + // LogFactory classes and releasing any objects associated with + // the tccl (ie the webapp). + // + // When there is only one LogFactory in the classpath, and it + // is within the webapp being undeployed then there is no problem; + // garbage collection works fine. + // + // When there are multiple LogFactory classes in the classpath but + // parent-first classloading is used everywhere, this loop is really + // short. The first instance of LogFactory found will + // be the highest in the classpath, and then no more will be found. + // This is ok, as with this setup this will be the only LogFactory + // holding any data associated with the tccl being released. + // + // When there are multiple LogFactory classes in the classpath and + // child-first classloading is used in any classloader, then multiple + // LogFactory instances may hold info about this TCCL; whenever the + // webapp makes a call into a class loaded via an ancestor classloader + // and that class calls LogFactory the tccl gets registered in + // the LogFactory instance that is visible from the ancestor + // classloader. However the concrete logging library it points + // to is expected to have been loaded via the TCCL, so the + // underlying logging lib is only initialised/configured once. + // These references from ancestor LogFactory classes down to + // TCCL classloaders are held via weak references and so should + // be released but there are circumstances where they may not. + // Walking up the classloader ancestry ladder releasing + // the current tccl at each level tree, though, will definitely + // clear any problem references. + ClassLoader loader = tccl; + while (loader != null) { + // Load via the current loader. Note that if the class is not accessable + // via this loader, but is accessable via some ancestor then that class + // will be returned. + try { + Class logFactoryClass = loader.loadClass("org.apache.commons.logging.LogFactory"); + Method releaseMethod = logFactoryClass.getMethod("release", RELEASE_SIGNATURE); + releaseMethod.invoke(null, params); + loader = logFactoryClass.getClassLoader().getParent(); + } catch(ClassNotFoundException ex) { + // Neither the current classloader nor any of its ancestors could find + // the LogFactory class, so we can stop now. + loader = null; + } catch(NoSuchMethodException ex) { + // This is not expected; every version of JCL has this method + System.err.println("LogFactory instance found which does not support release method!"); + loader = null; + } catch(IllegalAccessException ex) { + // This is not expected; every ancestor class should be accessable + System.err.println("LogFactory instance found which is not accessable!"); + loader = null; + } catch(InvocationTargetException ex) { + // This is not expected + System.err.println("LogFactory instance release method failed!"); + loader = null; + } + } + + // Just to be sure, invoke release on the LogFactory that is visible from + // this ServletContextCleaner class too. This should already have been caught + // by the above loop but just in case... + LogFactory.release(tccl); + } + + /** + * Invoked when a webapp is deployed. Nothing needs to be done here. + */ + public void contextInitialized(ServletContextEvent sce) { + // do nothing + } +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/SimpleLog.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/SimpleLog.java new file mode 100644 index 0000000..d966722 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/SimpleLog.java @@ -0,0 +1,721 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + +import java.io.InputStream; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogConfigurationException; + +/** + *

Simple implementation of Log that sends all enabled log messages, + * for all defined loggers, to System.err. The following system properties + * are supported to configure the behavior of this logger:

+ *
    + *
  • org.apache.commons.logging.simplelog.defaultlog - + * Default logging detail level for all instances of SimpleLog. + * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal"). + * If not specified, defaults to "info".
  • + *
  • org.apache.commons.logging.simplelog.log.xxxxx - + * Logging detail level for a SimpleLog instance named "xxxxx". + * Must be one of ("trace", "debug", "info", "warn", "error", or "fatal"). + * If not specified, the default logging detail level is used.
  • + *
  • org.apache.commons.logging.simplelog.showlogname - + * Set to true if you want the Log instance name to be + * included in output messages. Defaults to false.
  • + *
  • org.apache.commons.logging.simplelog.showShortLogname - + * Set to true if you want the last component of the name to be + * included in output messages. Defaults to true.
  • + *
  • org.apache.commons.logging.simplelog.showdatetime - + * Set to true if you want the current date and time + * to be included in output messages. Default is false.
  • + *
  • org.apache.commons.logging.simplelog.dateTimeFormat - + * The date and time format to be used in the output messages. + * The pattern describing the date and time format is the same that is + * used in java.text.SimpleDateFormat. If the format is not + * specified or is invalid, the default format is used. + * The default format is yyyy/MM/dd HH:mm:ss:SSS zzz.
  • + *
+ * + *

In addition to looking for system properties with the names specified + * above, this implementation also checks for a class loader resource named + * "simplelog.properties", and includes any matching definitions + * from this resource (if it exists).

+ * + * @author Scott Sanders + * @author Rod Waldhoff + * @author Robert Burrell Donkin + * + * @version $Id: SimpleLog.java 581090 2007-10-01 22:01:06Z dennisl $ + */ +public class SimpleLog implements Log, Serializable { + + + // ------------------------------------------------------- Class Attributes + + /** All system properties used by SimpleLog start with this */ + static protected final String systemPrefix = + "org.apache.commons.logging.simplelog."; + + /** Properties loaded from simplelog.properties */ + static protected final Properties simpleLogProps = new Properties(); + + /** The default format to use when formating dates */ + static protected final String DEFAULT_DATE_TIME_FORMAT = + "yyyy/MM/dd HH:mm:ss:SSS zzz"; + + /** Include the instance name in the log message? */ + static protected boolean showLogName = false; + /** Include the short name ( last component ) of the logger in the log + * message. Defaults to true - otherwise we'll be lost in a flood of + * messages without knowing who sends them. + */ + static protected boolean showShortName = true; + /** Include the current time in the log message */ + static protected boolean showDateTime = false; + /** The date and time format to use in the log message */ + static protected String dateTimeFormat = DEFAULT_DATE_TIME_FORMAT; + + /** + * Used to format times. + *

+ * Any code that accesses this object should first obtain a lock on it, + * ie use synchronized(dateFormatter); this requirement was introduced + * in 1.1.1 to fix an existing thread safety bug (SimpleDateFormat.format + * is not thread-safe). + */ + static protected DateFormat dateFormatter = null; + + // ---------------------------------------------------- Log Level Constants + + + /** "Trace" level logging. */ + public static final int LOG_LEVEL_TRACE = 1; + /** "Debug" level logging. */ + public static final int LOG_LEVEL_DEBUG = 2; + /** "Info" level logging. */ + public static final int LOG_LEVEL_INFO = 3; + /** "Warn" level logging. */ + public static final int LOG_LEVEL_WARN = 4; + /** "Error" level logging. */ + public static final int LOG_LEVEL_ERROR = 5; + /** "Fatal" level logging. */ + public static final int LOG_LEVEL_FATAL = 6; + + /** Enable all logging levels */ + public static final int LOG_LEVEL_ALL = (LOG_LEVEL_TRACE - 1); + + /** Enable no logging levels */ + public static final int LOG_LEVEL_OFF = (LOG_LEVEL_FATAL + 1); + + // ------------------------------------------------------------ Initializer + + private static String getStringProperty(String name) { + String prop = null; + try { + prop = System.getProperty(name); + } catch (SecurityException e) { + ; // Ignore + } + return (prop == null) ? simpleLogProps.getProperty(name) : prop; + } + + private static String getStringProperty(String name, String dephault) { + String prop = getStringProperty(name); + return (prop == null) ? dephault : prop; + } + + private static boolean getBooleanProperty(String name, boolean dephault) { + String prop = getStringProperty(name); + return (prop == null) ? dephault : "true".equalsIgnoreCase(prop); + } + + // Initialize class attributes. + // Load properties file, if found. + // Override with system properties. + static { + // Add props from the resource simplelog.properties + InputStream in = getResourceAsStream("simplelog.properties"); + if(null != in) { + try { + simpleLogProps.load(in); + in.close(); + } catch(java.io.IOException e) { + // ignored + } + } + + showLogName = getBooleanProperty( systemPrefix + "showlogname", showLogName); + showShortName = getBooleanProperty( systemPrefix + "showShortLogname", showShortName); + showDateTime = getBooleanProperty( systemPrefix + "showdatetime", showDateTime); + + if(showDateTime) { + dateTimeFormat = getStringProperty(systemPrefix + "dateTimeFormat", + dateTimeFormat); + try { + dateFormatter = new SimpleDateFormat(dateTimeFormat); + } catch(IllegalArgumentException e) { + // If the format pattern is invalid - use the default format + dateTimeFormat = DEFAULT_DATE_TIME_FORMAT; + dateFormatter = new SimpleDateFormat(dateTimeFormat); + } + } + } + + // ------------------------------------------------------------- Attributes + + /** The name of this simple log instance */ + protected String logName = null; + /** The current log level */ + protected int currentLogLevel; + /** The short name of this simple log instance */ + private String shortLogName = null; + + + // ------------------------------------------------------------ Constructor + + /** + * Construct a simple log with given name. + * + * @param name log name + */ + public SimpleLog(String name) { + + logName = name; + + // Set initial log level + // Used to be: set default log level to ERROR + // IMHO it should be lower, but at least info ( costin ). + setLevel(SimpleLog.LOG_LEVEL_INFO); + + // Set log level from properties + String lvl = getStringProperty(systemPrefix + "log." + logName); + int i = String.valueOf(name).lastIndexOf("."); + while(null == lvl && i > -1) { + name = name.substring(0,i); + lvl = getStringProperty(systemPrefix + "log." + name); + i = String.valueOf(name).lastIndexOf("."); + } + + if(null == lvl) { + lvl = getStringProperty(systemPrefix + "defaultlog"); + } + + if("all".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_ALL); + } else if("trace".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_TRACE); + } else if("debug".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_DEBUG); + } else if("info".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_INFO); + } else if("warn".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_WARN); + } else if("error".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_ERROR); + } else if("fatal".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_FATAL); + } else if("off".equalsIgnoreCase(lvl)) { + setLevel(SimpleLog.LOG_LEVEL_OFF); + } + + } + + + // -------------------------------------------------------- Properties + + /** + *

Set logging level.

+ * + * @param currentLogLevel new logging level + */ + public void setLevel(int currentLogLevel) { + + this.currentLogLevel = currentLogLevel; + + } + + + /** + *

Get logging level.

+ */ + public int getLevel() { + + return currentLogLevel; + } + + + // -------------------------------------------------------- Logging Methods + + + /** + *

Do the actual logging. + * This method assembles the message + * and then calls write() to cause it to be written.

+ * + * @param type One of the LOG_LEVEL_XXX constants defining the log level + * @param message The message itself (typically a String) + * @param t The exception whose stack trace should be logged + */ + protected void log(int type, Object message, Throwable t) { + // Use a string buffer for better performance + StringBuffer buf = new StringBuffer(); + + // Append date-time if so configured + if(showDateTime) { + Date now = new Date(); + String dateText; + synchronized(dateFormatter) { + dateText = dateFormatter.format(now); + } + buf.append(dateText); + buf.append(" "); + } + + // Append a readable representation of the log level + switch(type) { + case SimpleLog.LOG_LEVEL_TRACE: buf.append("[TRACE] "); break; + case SimpleLog.LOG_LEVEL_DEBUG: buf.append("[DEBUG] "); break; + case SimpleLog.LOG_LEVEL_INFO: buf.append("[INFO] "); break; + case SimpleLog.LOG_LEVEL_WARN: buf.append("[WARN] "); break; + case SimpleLog.LOG_LEVEL_ERROR: buf.append("[ERROR] "); break; + case SimpleLog.LOG_LEVEL_FATAL: buf.append("[FATAL] "); break; + } + + // Append the name of the log instance if so configured + if( showShortName) { + if( shortLogName==null ) { + // Cut all but the last component of the name for both styles + shortLogName = logName.substring(logName.lastIndexOf(".") + 1); + shortLogName = + shortLogName.substring(shortLogName.lastIndexOf("/") + 1); + } + buf.append(String.valueOf(shortLogName)).append(" - "); + } else if(showLogName) { + buf.append(String.valueOf(logName)).append(" - "); + } + + // Append the message + buf.append(String.valueOf(message)); + + // Append stack trace if not null + if(t != null) { + buf.append(" <"); + buf.append(t.toString()); + buf.append(">"); + + java.io.StringWriter sw= new java.io.StringWriter(1024); + java.io.PrintWriter pw= new java.io.PrintWriter(sw); + t.printStackTrace(pw); + pw.close(); + buf.append(sw.toString()); + } + + // Print to the appropriate destination + write(buf); + + } + + + /** + *

Write the content of the message accumulated in the specified + * StringBuffer to the appropriate output destination. The + * default implementation writes to System.err.

+ * + * @param buffer A StringBuffer containing the accumulated + * text to be logged + */ + protected void write(StringBuffer buffer) { + + System.err.println(buffer.toString()); + + } + + + /** + * Is the given log level currently enabled? + * + * @param logLevel is this level enabled? + */ + protected boolean isLevelEnabled(int logLevel) { + // log level are numerically ordered so can use simple numeric + // comparison + return (logLevel >= currentLogLevel); + } + + + // -------------------------------------------------------- Log Implementation + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG. + * + * @param message to log + * @see org.apache.commons.logging.Log#debug(Object) + */ + public final void debug(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { + log(SimpleLog.LOG_LEVEL_DEBUG, message, null); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_DEBUG. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#debug(Object, Throwable) + */ + public final void debug(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG)) { + log(SimpleLog.LOG_LEVEL_DEBUG, message, t); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE. + * + * @param message to log + * @see org.apache.commons.logging.Log#trace(Object) + */ + public final void trace(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) { + log(SimpleLog.LOG_LEVEL_TRACE, message, null); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_TRACE. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#trace(Object, Throwable) + */ + public final void trace(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE)) { + log(SimpleLog.LOG_LEVEL_TRACE, message, t); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO. + * + * @param message to log + * @see org.apache.commons.logging.Log#info(Object) + */ + public final void info(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { + log(SimpleLog.LOG_LEVEL_INFO,message,null); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_INFO. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#info(Object, Throwable) + */ + public final void info(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_INFO)) { + log(SimpleLog.LOG_LEVEL_INFO, message, t); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN. + * + * @param message to log + * @see org.apache.commons.logging.Log#warn(Object) + */ + public final void warn(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { + log(SimpleLog.LOG_LEVEL_WARN, message, null); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_WARN. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#warn(Object, Throwable) + */ + public final void warn(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_WARN)) { + log(SimpleLog.LOG_LEVEL_WARN, message, t); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR. + * + * @param message to log + * @see org.apache.commons.logging.Log#error(Object) + */ + public final void error(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { + log(SimpleLog.LOG_LEVEL_ERROR, message, null); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_ERROR. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#error(Object, Throwable) + */ + public final void error(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR)) { + log(SimpleLog.LOG_LEVEL_ERROR, message, t); + } + } + + + /** + * Log a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL. + * + * @param message to log + * @see org.apache.commons.logging.Log#fatal(Object) + */ + public final void fatal(Object message) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { + log(SimpleLog.LOG_LEVEL_FATAL, message, null); + } + } + + + /** + * Logs a message with + * org.apache.commons.logging.impl.SimpleLog.LOG_LEVEL_FATAL. + * + * @param message to log + * @param t log this cause + * @see org.apache.commons.logging.Log#fatal(Object, Throwable) + */ + public final void fatal(Object message, Throwable t) { + + if (isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL)) { + log(SimpleLog.LOG_LEVEL_FATAL, message, t); + } + } + + + /** + *

Are debug messages currently enabled?

+ * + *

This allows expensive operations such as String + * concatenation to be avoided when the message will be ignored by the + * logger.

+ */ + public final boolean isDebugEnabled() { + + return isLevelEnabled(SimpleLog.LOG_LEVEL_DEBUG); + } + + + /** + *

Are error messages currently enabled?

+ * + *

This allows expensive operations such as String + * concatenation to be avoided when the message will be ignored by the + * logger.

+ */ + public final boolean isErrorEnabled() { + + return isLevelEnabled(SimpleLog.LOG_LEVEL_ERROR); + } + + + /** + *

Are fatal messages currently enabled?

+ * + *

This allows expensive operations such as String + * concatenation to be avoided when the message will be ignored by the + * logger.

+ */ + public final boolean isFatalEnabled() { + + return isLevelEnabled(SimpleLog.LOG_LEVEL_FATAL); + } + + + /** + *

Are info messages currently enabled?

+ * + *

This allows expensive operations such as String + * concatenation to be avoided when the message will be ignored by the + * logger.

+ */ + public final boolean isInfoEnabled() { + + return isLevelEnabled(SimpleLog.LOG_LEVEL_INFO); + } + + + /** + *

Are trace messages currently enabled?

+ * + *

This allows expensive operations such as String + * concatenation to be avoided when the message will be ignored by the + * logger.

+ */ + public final boolean isTraceEnabled() { + + return isLevelEnabled(SimpleLog.LOG_LEVEL_TRACE); + } + + + /** + *

Are warn messages currently enabled?

+ * + *

This allows expensive operations such as String + * concatenation to be avoided when the message will be ignored by the + * logger.

+ */ + public final boolean isWarnEnabled() { + + return isLevelEnabled(SimpleLog.LOG_LEVEL_WARN); + } + + + /** + * Return the thread context class loader if available. + * Otherwise return null. + * + * The thread context class loader is available for JDK 1.2 + * or later, if certain security conditions are met. + * + * @exception LogConfigurationException if a suitable class loader + * cannot be identified. + */ + private static ClassLoader getContextClassLoader() + { + ClassLoader classLoader = null; + + if (classLoader == null) { + try { + // Are we running on a JDK 1.2 or later system? + Method method = Thread.class.getMethod("getContextClassLoader", + (Class[]) null); + + // Get the thread context class loader (if there is one) + try { + classLoader = (ClassLoader)method.invoke(Thread.currentThread(), + (Class[]) null); + } catch (IllegalAccessException e) { + ; // ignore + } catch (InvocationTargetException e) { + /** + * InvocationTargetException is thrown by 'invoke' when + * the method being invoked (getContextClassLoader) throws + * an exception. + * + * getContextClassLoader() throws SecurityException when + * the context class loader isn't an ancestor of the + * calling class's class loader, or if security + * permissions are restricted. + * + * In the first case (not related), we want to ignore and + * keep going. We cannot help but also ignore the second + * with the logic below, but other calls elsewhere (to + * obtain a class loader) will trigger this exception where + * we can make a distinction. + */ + if (e.getTargetException() instanceof SecurityException) { + ; // ignore + } else { + // Capture 'e.getTargetException()' exception for details + // alternate: log 'e.getTargetException()', and pass back 'e'. + throw new LogConfigurationException + ("Unexpected InvocationTargetException", e.getTargetException()); + } + } + } catch (NoSuchMethodException e) { + // Assume we are running on JDK 1.1 + ; // ignore + } + } + + if (classLoader == null) { + classLoader = SimpleLog.class.getClassLoader(); + } + + // Return the selected class loader + return classLoader; + } + + private static InputStream getResourceAsStream(final String name) + { + return (InputStream)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + ClassLoader threadCL = getContextClassLoader(); + + if (threadCL != null) { + return threadCL.getResourceAsStream(name); + } else { + return ClassLoader.getSystemResourceAsStream(name); + } + } + }); + } +} + diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/WeakHashtable.java b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/WeakHashtable.java new file mode 100644 index 0000000..e2d4100 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/WeakHashtable.java @@ -0,0 +1,478 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.commons.logging.impl; + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.*; + +/** + *

Implementation of Hashtable that uses WeakReference's + * to hold its keys thus allowing them to be reclaimed by the garbage collector. + * The associated values are retained using strong references.

+ * + *

This class follows the symantics of Hashtable as closely as + * possible. It therefore does not accept null values or keys.

+ * + *

Note: + * This is not intended to be a general purpose hash table replacement. + * This implementation is also tuned towards a particular purpose: for use as a replacement + * for Hashtable in LogFactory. This application requires + * good liveliness for get and put. Various tradeoffs + * have been made with this in mind. + *

+ *

+ * Usage: typical use case is as a drop-in replacement + * for the Hashtable used in LogFactory for J2EE enviroments + * running 1.3+ JVMs. Use of this class in most cases (see below) will + * allow classloaders to be collected by the garbage collector without the need + * to call {@link org.apache.commons.logging.LogFactory#release(ClassLoader) LogFactory.release(ClassLoader)}. + *

+ * + *

org.apache.commons.logging.LogFactory checks whether this class + * can be supported by the current JVM, and if so then uses it to store + * references to the LogFactory implementationd it loads + * (rather than using a standard Hashtable instance). + * Having this class used instead of Hashtable solves + * certain issues related to dynamic reloading of applications in J2EE-style + * environments. However this class requires java 1.3 or later (due to its use + * of java.lang.ref.WeakReference and associates). + * And by the way, this extends Hashtable rather than HashMap + * for backwards compatibility reasons. See the documentation + * for method LogFactory.createFactoryStore for more details.

+ * + *

The reason all this is necessary is due to a issue which + * arises during hot deploy in a J2EE-like containers. + * Each component running in the container owns one or more classloaders; when + * the component loads a LogFactory instance via the component classloader + * a reference to it gets stored in the static LogFactory.factories member, + * keyed by the component's classloader so different components don't + * stomp on each other. When the component is later unloaded, the container + * sets the component's classloader to null with the intent that all the + * component's classes get garbage-collected. However there's still a + * reference to the component's classloader from a key in the "global" + * LogFactory's factories member! If LogFactory.release() + * is called whenever component is unloaded, the classloaders will be correctly + * garbage collected; this should be done by any container that + * bundles commons-logging by default. However, holding the classloader + * references weakly ensures that the classloader will be garbage collected + * without the container performing this step.

+ * + *

+ * Limitations: + * There is still one (unusual) scenario in which a component will not + * be correctly unloaded without an explicit release. Though weak references + * are used for its keys, it is necessary to use strong references for its values. + *

+ * + *

If the abstract class LogFactory is + * loaded by the container classloader but a subclass of + * LogFactory [LogFactory1] is loaded by the component's + * classloader and an instance stored in the static map associated with the + * base LogFactory class, then there is a strong reference from the LogFactory + * class to the LogFactory1 instance (as normal) and a strong reference from + * the LogFactory1 instance to the component classloader via + * getClass().getClassLoader(). This chain of references will prevent + * collection of the child classloader.

+ * + *

+ * Such a situation occurs when the commons-logging.jar is + * loaded by a parent classloader (e.g. a server level classloader in a + * servlet container) and a custom LogFactory implementation is + * loaded by a child classloader (e.g. a web app classloader).

+ * + *

To avoid this scenario, ensure + * that any custom LogFactory subclass is loaded by the same classloader as + * the base LogFactory. Creating custom LogFactory subclasses is, + * however, rare. The standard LogFactoryImpl class should be sufficient + * for most or all users.

+ * + * + * @author Brian Stansberry + * + * @since 1.1 + */ +public final class WeakHashtable extends Hashtable { + + /** + * The maximum number of times put() or remove() can be called before + * the map will be purged of all cleared entries. + */ + private static final int MAX_CHANGES_BEFORE_PURGE = 100; + + /** + * The maximum number of times put() or remove() can be called before + * the map will be purged of one cleared entry. + */ + private static final int PARTIAL_PURGE_COUNT = 10; + + /* ReferenceQueue we check for gc'd keys */ + private ReferenceQueue queue = new ReferenceQueue(); + /* Counter used to control how often we purge gc'd entries */ + private int changeCount = 0; + + /** + * Constructs a WeakHashtable with the Hashtable default + * capacity and load factor. + */ + public WeakHashtable() {} + + + /** + *@see Hashtable + */ + public boolean containsKey(Object key) { + // purge should not be required + Referenced referenced = new Referenced(key); + return super.containsKey(referenced); + } + + /** + *@see Hashtable + */ + public Enumeration elements() { + purge(); + return super.elements(); + } + + /** + *@see Hashtable + */ + public Set entrySet() { + purge(); + Set referencedEntries = super.entrySet(); + Set unreferencedEntries = new HashSet(); + for (Iterator it=referencedEntries.iterator(); it.hasNext();) { + Map.Entry entry = (Map.Entry) it.next(); + Referenced referencedKey = (Referenced) entry.getKey(); + Object key = referencedKey.getValue(); + Object value = entry.getValue(); + if (key != null) { + Entry dereferencedEntry = new Entry(key, value); + unreferencedEntries.add(dereferencedEntry); + } + } + return unreferencedEntries; + } + + /** + *@see Hashtable + */ + public Object get(Object key) { + // for performance reasons, no purge + Referenced referenceKey = new Referenced(key); + return super.get(referenceKey); + } + + /** + *@see Hashtable + */ + public Enumeration keys() { + purge(); + final Enumeration enumer = super.keys(); + return new Enumeration() { + public boolean hasMoreElements() { + return enumer.hasMoreElements(); + } + public Object nextElement() { + Referenced nextReference = (Referenced) enumer.nextElement(); + return nextReference.getValue(); + } + }; + } + + + /** + *@see Hashtable + */ + public Set keySet() { + purge(); + Set referencedKeys = super.keySet(); + Set unreferencedKeys = new HashSet(); + for (Iterator it=referencedKeys.iterator(); it.hasNext();) { + Referenced referenceKey = (Referenced) it.next(); + Object keyValue = referenceKey.getValue(); + if (keyValue != null) { + unreferencedKeys.add(keyValue); + } + } + return unreferencedKeys; + } + + /** + *@see Hashtable + */ + public Object put(Object key, Object value) { + // check for nulls, ensuring symantics match superclass + if (key == null) { + throw new NullPointerException("Null keys are not allowed"); + } + if (value == null) { + throw new NullPointerException("Null values are not allowed"); + } + + // for performance reasons, only purge every + // MAX_CHANGES_BEFORE_PURGE times + if (changeCount++ > MAX_CHANGES_BEFORE_PURGE) { + purge(); + changeCount = 0; + } + // do a partial purge more often + else if ((changeCount % PARTIAL_PURGE_COUNT) == 0) { + purgeOne(); + } + + Referenced keyRef = new Referenced(key, queue); + return super.put(keyRef, value); + } + + /** + *@see Hashtable + */ + public void putAll(Map t) { + if (t != null) { + Set entrySet = t.entrySet(); + for (Iterator it=entrySet.iterator(); it.hasNext();) { + Map.Entry entry = (Map.Entry) it.next(); + put(entry.getKey(), entry.getValue()); + } + } + } + + /** + *@see Hashtable + */ + public Collection values() { + purge(); + return super.values(); + } + + /** + *@see Hashtable + */ + public Object remove(Object key) { + // for performance reasons, only purge every + // MAX_CHANGES_BEFORE_PURGE times + if (changeCount++ > MAX_CHANGES_BEFORE_PURGE) { + purge(); + changeCount = 0; + } + // do a partial purge more often + else if ((changeCount % PARTIAL_PURGE_COUNT) == 0) { + purgeOne(); + } + return super.remove(new Referenced(key)); + } + + /** + *@see Hashtable + */ + public boolean isEmpty() { + purge(); + return super.isEmpty(); + } + + /** + *@see Hashtable + */ + public int size() { + purge(); + return super.size(); + } + + /** + *@see Hashtable + */ + public String toString() { + purge(); + return super.toString(); + } + + /** + * @see Hashtable + */ + protected void rehash() { + // purge here to save the effort of rehashing dead entries + purge(); + super.rehash(); + } + + /** + * Purges all entries whose wrapped keys + * have been garbage collected. + */ + private void purge() { + synchronized (queue) { + WeakKey key; + while ((key = (WeakKey) queue.poll()) != null) { + super.remove(key.getReferenced()); + } + } + } + + /** + * Purges one entry whose wrapped key + * has been garbage collected. + */ + private void purgeOne() { + + synchronized (queue) { + WeakKey key = (WeakKey) queue.poll(); + if (key != null) { + super.remove(key.getReferenced()); + } + } + } + + /** Entry implementation */ + private final static class Entry implements Map.Entry { + + private final Object key; + private final Object value; + + private Entry(Object key, Object value) { + this.key = key; + this.value = value; + } + + public boolean equals(Object o) { + boolean result = false; + if (o != null && o instanceof Map.Entry) { + Map.Entry entry = (Map.Entry) o; + result = (getKey()==null ? + entry.getKey() == null : + getKey().equals(entry.getKey())) + && + (getValue()==null ? + entry.getValue() == null : + getValue().equals(entry.getValue())); + } + return result; + } + + public int hashCode() { + + return (getKey()==null ? 0 : getKey().hashCode()) ^ + (getValue()==null ? 0 : getValue().hashCode()); + } + + public Object setValue(Object value) { + throw new UnsupportedOperationException("Entry.setValue is not supported."); + } + + public Object getValue() { + return value; + } + + public Object getKey() { + return key; + } + } + + + /** Wrapper giving correct symantics for equals and hashcode */ + private final static class Referenced { + + private final WeakReference reference; + private final int hashCode; + + /** + * + * @throws NullPointerException if referant is null + */ + private Referenced(Object referant) { + reference = new WeakReference(referant); + // Calc a permanent hashCode so calls to Hashtable.remove() + // work if the WeakReference has been cleared + hashCode = referant.hashCode(); + } + + /** + * + * @throws NullPointerException if key is null + */ + private Referenced(Object key, ReferenceQueue queue) { + reference = new WeakKey(key, queue, this); + // Calc a permanent hashCode so calls to Hashtable.remove() + // work if the WeakReference has been cleared + hashCode = key.hashCode(); + + } + + public int hashCode() { + return hashCode; + } + + private Object getValue() { + return reference.get(); + } + + public boolean equals(Object o) { + boolean result = false; + if (o instanceof Referenced) { + Referenced otherKey = (Referenced) o; + Object thisKeyValue = getValue(); + Object otherKeyValue = otherKey.getValue(); + if (thisKeyValue == null) { + result = (otherKeyValue == null); + + // Since our hashcode was calculated from the original + // non-null referant, the above check breaks the + // hashcode/equals contract, as two cleared Referenced + // objects could test equal but have different hashcodes. + // We can reduce (not eliminate) the chance of this + // happening by comparing hashcodes. + if (result == true) { + result = (this.hashCode() == otherKey.hashCode()); + } + // In any case, as our c'tor does not allow null referants + // and Hashtable does not do equality checks between + // existing keys, normal hashtable operations should never + // result in an equals comparison between null referants + } + else + { + result = thisKeyValue.equals(otherKeyValue); + } + } + return result; + } + } + + /** + * WeakReference subclass that holds a hard reference to an + * associated value and also makes accessible + * the Referenced object holding it. + */ + private final static class WeakKey extends WeakReference { + + private final Referenced referenced; + + private WeakKey(Object key, + ReferenceQueue queue, + Referenced referenced) { + super(key, queue); + this.referenced = referenced; + } + + private Referenced getReferenced() { + return referenced; + } + } +} diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/package.html b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/package.html new file mode 100644 index 0000000..5344784 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/package.html @@ -0,0 +1,22 @@ + + + +

Concrete implementations of commons-logging wrapper APIs.

+ diff --git a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/package.html b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/package.html new file mode 100644 index 0000000..e9b32a5 --- /dev/null +++ b/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/package.html @@ -0,0 +1,255 @@ + + + +

Simple wrapper API around multiple logging APIs.

+ + +

Overview

+ +

This package provides an API for logging in server-based applications that +can be used around a variety of different logging implementations, including +prebuilt support for the following:

+
    +
  • Log4J (version 1.2 or later) + from Apache's Logging project. Each named Log + instance is connected to a corresponding Log4J Logger.
  • +
  • + JDK Logging API, included in JDK 1.4 or later systems. Each named + Log instance is connected to a corresponding + java.util.logging.Logger instance.
  • +
  • LogKit from Apache's + Avalon project. Each named Log instance is + connected to a corresponding LogKit Logger.
  • +
  • NoOpLog implementation that simply swallows + all log output, for all named Log instances.
  • +
  • SimpleLog implementation that writes all + log output, for all named Log instances, to + System.err.
  • +
+ + +

Quick Start Guide

+ +

For those impatient to just get on with it, the following example +illustrates the typical declaration and use of a logger that is named (by +convention) after the calling class: + +

+    import org.apache.commons.logging.Log;
+    import org.apache.commons.logging.LogFactory;
+
+    public class Foo {
+
+        private Log log = LogFactory.getLog(Foo.class);
+
+        public void foo() {
+            ...
+            try {
+                if (log.isDebugEnabled()) {
+                    log.debug("About to do something to object " + name);
+                }
+                name.bar();
+            } catch (IllegalStateException e) {
+                log.error("Something bad happened to " + name, e);
+            }
+            ...
+        }
+
+ +

Unless you configure things differently, all log output will be written +to System.err. Therefore, you really will want to review the remainder of +this page in order to understand how to configure logging for your +application.

+ + +

Configuring the Commons Logging Package

+ + +

Choosing a LogFactory Implementation

+ +

From an application perspective, the first requirement is to retrieve an +object reference to the LogFactory instance that will be used +to create Log instances for this +application. This is normally accomplished by calling the static +getFactory() method. This method implements the following +discovery algorithm to select the name of the LogFactory +implementation class this application wants to use:

+
    +
  • Check for a system property named + org.apache.commons.logging.LogFactory.
  • +
  • Use the JDK 1.3 JAR Services Discovery mechanism (see + + http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html for + more information) to look for a resource named + META-INF/services/org.apache.commons.logging.LogFactory + whose first line is assumed to contain the desired class name.
  • +
  • Look for a properties file named commons-logging.properties + visible in the application class path, with a property named + org.apache.commons.logging.LogFactory defining the + desired implementation class name.
  • +
  • Fall back to a default implementation, which is described + further below.
  • +
+ +

If a commons-logging.properties file is found, all of the +properties defined there are also used to set configuration attributes on +the instantiated LogFactory instance.

+ +

Once an implementation class name is selected, the corresponding class is +loaded from the current Thread context class loader (if there is one), or +from the class loader that loaded the LogFactory class itself +otherwise. This allows a copy of commons-logging.jar to be +shared in a multiple class loader environment (such as a servlet container), +but still allow each web application to provide its own LogFactory +implementation, if it so desires. An instance of this class will then be +created, and cached per class loader. + + +

The Default LogFactory Implementation

+ +

The Logging Package APIs include a default LogFactory +implementation class ( +org.apache.commons.logging.impl.LogFactoryImpl) that is selected if no +other implementation class name can be discovered. Its primary purpose is +to create (as necessary) and return Log instances +in response to calls to the getInstance() method. The default +implementation uses the following rules:

+
    +
  • At most one Log instance of the same name will be created. + Subsequent getInstance() calls to the same + LogFactory instance, with the same name or Class + parameter, will return the same Log instance.
  • +
  • When a new Log instance must be created, the default + LogFactory implementation uses the following discovery + process: +
      +
    • Look for a configuration attribute of this factory named + org.apache.commons.logging.Log (for backwards + compatibility to pre-1.0 versions of this API, an attribute + org.apache.commons.logging.log is also consulted).
    • +
    • Look for a system property named + org.apache.commons.logging.Log (for backwards + compatibility to pre-1.0 versions of this API, a system property + org.apache.commons.logging.log is also consulted).
    • +
    • If the Log4J logging system is available in the application + class path, use the corresponding wrapper class + (Log4JLogger).
    • +
    • If the application is executing on a JDK 1.4 system, use + the corresponding wrapper class + (Jdk14Logger).
    • +
    • Fall back to the default simple logging implementation + (SimpleLog).
    • +
  • +
  • Load the class of the specified name from the thread context class + loader (if any), or from the class loader that loaded the + LogFactory class otherwise.
  • +
  • Instantiate an instance of the selected Log + implementation class, passing the specified name as the single + argument to its constructor.
  • +
+ +

See the SimpleLog JavaDocs for detailed +configuration information for this default implementation.

+ + +

Configuring the Underlying Logging System

+ +

The basic principle is that the user is totally responsible for the +configuration of the underlying logging system. +Commons-logging should not change the existing configuration.

+ +

Each individual Log implementation may +support its own configuration properties. These will be documented in the +class descriptions for the corresponding implementation class.

+ +

Finally, some Log implementations (such as the one for Log4J) +require an external configuration file for the entire logging environment. +This file should be prepared in a manner that is specific to the actual logging +technology being used.

+ + +

Using the Logging Package APIs

+ +

Use of the Logging Package APIs, from the perspective of an application +component, consists of the following steps:

+
    +
  1. Acquire a reference to an instance of + org.apache.commons.logging.Log, by calling the + factory method + + LogFactory.getInstance(String name). Your application can contain + references to multiple loggers that are used for different + purposes. A typical scenario for a server application is to have each + major component of the server use its own Log instance.
  2. +
  3. Cause messages to be logged (if the corresponding detail level is enabled) + by calling appropriate methods (trace(), debug(), + info(), warn(), error, and + fatal()).
  4. +
+ +

For convenience, LogFactory also offers a static method +getLog() that combines the typical two-step pattern:

+
+  Log log = LogFactory.getFactory().getInstance(Foo.class);
+
+

into a single method call:

+
+  Log log = LogFactory.getLog(Foo.class);
+
+ +

For example, you might use the following technique to initialize and +use a Log instance in an application component:

+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class MyComponent {
+
+  protected Log log =
+    LogFactory.getLog(MyComponent.class);
+
+  // Called once at startup time
+  public void start() {
+    ...
+    log.info("MyComponent started");
+    ...
+  }
+
+  // Called once at shutdown time
+  public void stop() {
+    ...
+    log.info("MyComponent stopped");
+    ...
+  }
+
+  // Called repeatedly to process a particular argument value
+  // which you want logged if debugging is enabled
+  public void process(String value) {
+    ...
+    // Do the string concatenation only if logging is enabled
+    if (log.isDebugEnabled())
+      log.debug("MyComponent processing " + value);
+    ...
+  }
+
+}
+
+ + diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtwork.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtwork.java new file mode 100644 index 0000000..53846c9 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtwork.java @@ -0,0 +1,55 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a artwork. + * + * Defines a single piece of artwork. + * + * Artwork is always associated with an individual track. + * To add a piece of artwork to a track, use IITTrack::AddArtworkFromFile(). + * The IITTrack::Artwork property + * + * To get a collection of artwork associated with a track call + * ITTrack.getArtwork(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITArtwork extends ITObject { + + public ITArtwork (Dispatch d) { + super(d); + } + + /** + * Delete this object. + */ + public void delete() { + Dispatch.call(object, "Delete"); + } + + /** + * Returns the kind of the object. + * @return Returns the kind of the object. + */ + public ITArtworkFormat getFormat() { + return ITArtworkFormat.values()[Dispatch.get(object, "Format").getInt()]; + } + + // TODO: Comments + + public boolean getIsDownloadedArtwork() { + return Dispatch.get(object, "IsDownloadedArtwork").getBoolean(); + } + + public String getDescription() { + return Dispatch.get(object, "Description").getString(); + + } + + public void SaveArtworkToFile(String filePath) { + Dispatch.call(object, "SaveArtworkToFile",filePath); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkCollection.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkCollection.java new file mode 100644 index 0000000..c1d8afa --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkCollection.java @@ -0,0 +1,55 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a collection of Artwork objects. + * + * Note that collection indices are always 1-based. + * + * You can retrieve all the Artworks defined for a source using + * ITSource.getArtwork(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITArtworkCollection { + + protected Dispatch object; + + public ITArtworkCollection(Dispatch d) { + object = d; + } + + /** + * Returns the number of playlists in the collection. + * @return Returns the number of playlists in the collection. + */ + public int getCount() { + return Dispatch.get(object, "Count").getInt(); + } + + /** + * Returns an ITArtwork object corresponding to the given index (1-based). + * @param index Index of the playlist to retrieve, must be less than or + * equal to ITArtworkCollection.getCount(). + * @return Returns an ITArtwork object corresponding to the given index. + * Will be set to NULL if no playlist could be retrieved. + */ + public ITArtwork getItem (int index) { + Dispatch item = Dispatch.call(object, "Item", index).toDispatch(); + return new ITArtwork(item); + } + + /** + * Returns an ITArtwork object with the specified persistent ID. See the + * documentation on ITObject for more information on persistent IDs. + * @param highID The high 32 bits of the 64-bit persistent ID. + * @param lowID The low 32 bits of the 64-bit persistent ID. + * @return Returns an ITArtwork object with the specified persistent ID. + * Will be set to NULL if no playlist could be retrieved. + */ + public ITArtwork getItemByPersistentID (int highID, int lowID) { + Dispatch item = Dispatch.call(object, "ItemByPersistentID", highID, lowID).toDispatch(); + return new ITArtwork(item); + } +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkFormat.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkFormat.java new file mode 100644 index 0000000..ed4b61e --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkFormat.java @@ -0,0 +1,13 @@ +package com.dt.iTunesController; + +/** + * Specifies the Artwork kind. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITArtworkFormat { + ITArtworkFormatUnknown, + ITArtworkFormatJPEG, + ITArtworkFormatPNG, + ITArtworkFormatBMP; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITAudioCDPlaylist.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITAudioCDPlaylist.java new file mode 100644 index 0000000..bc12943 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITAudioCDPlaylist.java @@ -0,0 +1,76 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents an audio CD playlist. + * + * An audio CD playlist is always associated with an IITSource of kind + * ITSourceKindAudioCD. + * + * You can retrieve all the playlists defined for a source using + * ITSource.getPlaylists(). + * @author Steve Eyre + * @version 0.2 + */ +public class ITAudioCDPlaylist extends ITPlaylist { + + public ITAudioCDPlaylist(Dispatch d) { + super(d); + } + + /** + * Returns the audio CD's artist. + * @return Returns the audio CD's artist. + */ + public String getArtist() { + return Dispatch.get(object, "Artist").getString(); + } + + /** + * Returns true if this audio CD is a compilation album. + * @return Returns true if this audio CD is a compilation album. + */ + public boolean isCompilation() { + return Dispatch.get(object, "Compilation").getBoolean(); + } + + /** + * Returns the audio CD's composer. + * @return Returns the audio CD's composer. + */ + public String getComposer() { + return Dispatch.get(object, "Composer").getString(); + } + + /** + * Returns the total number of discs in this CD's album. + * @return Returns the total number of discs in this CD's album. + */ + public long getDiscCount() { + return Dispatch.get(object, "DiscCount").getLong(); + } + + /** + * Returns the index of the CD disc in the source album. + * @return Returns the index of the CD disc in the source album. + */ + public long getDiscNumber() { + return Dispatch.get(object, "DiscNumber").getLong(); + } + + /** + * Returns the audio CD's genre. + * @return Returns the audio CD's genre. + */ + public String getGenre() { + return Dispatch.get(object, "Genre").getString(); + } + + /** + * Reveals the CD playlist in the main browser window. + */ + public void reveal() { + Dispatch.call(object, "Reveal"); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITBrowserWindow.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITBrowserWindow.java new file mode 100644 index 0000000..16dc6cf --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITBrowserWindow.java @@ -0,0 +1,45 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents the main browser window. + * + * You can retrieve the main browser window using + * iTunes.BrowserWindow(). + * + * @author Steve Eyre + * @version 0.2 + */ + +public class ITBrowserWindow extends ITWindow { + + public ITBrowserWindow (Dispatch d) { + super(d); + } + + /** + * Returns the kind of the object. + * @return Returns the kind of the object. + */ + public boolean getMiniPlayer() { + return Dispatch.get(object, "MiniPlayer").getBoolean(); + } + + // TODO: Comments + + public ITTrackCollection getSelectedTracks() { + Dispatch collection = Dispatch.call(object, "SelectedTracks").getDispatch(); + return new ITTrackCollection(collection); + } + + public ITPlaylist getSelectedPlaylist() { + Dispatch playlist = Dispatch.get(object, "SelectedPlaylist").toDispatch(); + return new ITPlaylist(playlist); + } + + public void setSelectedPlaylist(ITPlaylist playlist) { + Dispatch dispatchRef = playlist.fetchDispatch(); + Dispatch.put(object, "SelectedPlaylist", dispatchRef); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITCOMDisabledReason.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITCOMDisabledReason.java new file mode 100644 index 0000000..500280c --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITCOMDisabledReason.java @@ -0,0 +1,12 @@ +package com.dt.iTunesController; + +/** + * Specifies the reason the COM interface is being disabled. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITCOMDisabledReason { + ITCOMDisabledReasonOther, + ITCOMDisabledReasonDialog, + ITCOMDisabledReasonQuitting; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITEQPreset.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITEQPreset.java new file mode 100644 index 0000000..1d00cfb --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITEQPreset.java @@ -0,0 +1,236 @@ +package com.dt.iTunesController; + +import com.jacob.com.Dispatch; + +/** + * Represents an equalizer preset. + * You can retrieve or set the currently selected EQ preset using the + * iTunes.getCurrentEQPreset() method. + * @author Steve Eyre + * @version 0.2 + */ +public class ITEQPreset { + + protected Dispatch object; + + public ITEQPreset(Dispatch d) { + object = d; + } + + /** + * Returns the name of the EQ Preset (e.g. "Acoustic"). + * @return Returns the name of the EQ Preset (e.g. "Acoustic"). + */ + public String getName() { + return Dispatch.get(object, "Name").getString(); + } + + /** + * Returns true if the EQ preset can be modified. + * @return True if the EQ preset can be modified. + */ + public boolean getModifiable() { + return Dispatch.get(object, "Modifiable").getBoolean(); + } + + /** + * Set the equalizer preamp level (-12.0 db to +12.0 db). + * @param level The new equalizer preamp level (-12.0 db to +12.0 db). + */ + public void setPreamp(double level) { + Dispatch.put(object, "Preamp", level); + } + + /** + * Returns the equalizer preamp level (-12.0db to +12.0db). + * @return Returns the equalizer preamp level (-12.0db to +12.0db). + */ + public double getPreamp() { + return Dispatch.get(object, "Preamp").getDouble(); + } + + /** + * Set the equalizer 32Hz level (-12.0 db to +12.0 db). + * @param level The new equalizer 32Hz level (-12.0 db to +12.0db). + */ + public void setBand1(double level) { + Dispatch.put(object, "Band1", level); + } + + /** + * Returns the equalizer 32Hz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 32Hz level (-12.0 db to +12.0 db). + */ + public double getBand1() { + return Dispatch.get(object, "Band1").getDouble(); + } + + /** + * Set the equalizer 64Hz level (-12.0 db to +12.0 db). + * @param level The new equalizer 64Hz level (-12.0 db to +12.0db). + */ + public void setBand2(double level) { + Dispatch.put(object, "Band2", level); + } + + /** + * Returns the equalizer 64Hz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 64Hz level (-12.0 db to +12.0 db). + */ + public double getBand2() { + return Dispatch.get(object, "Band2").getDouble(); + } + + /** + * Set the equalizer 125Hz level (-12.0 db to +12.0 db). + * @param level The new equalizer 125Hz level (-12.0 db to +12.0db). + */ + public void setBand3(double level) { + Dispatch.put(object, "Band3", level); + } + + /** + * Returns the equalizer 125Hz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 125Hz level (-12.0 db to +12.0 db). + */ + public double getBand3() { + return Dispatch.get(object, "Band3").getDouble(); + } + + /** + * Set the equalizer 250Hz level (-12.0 db to +12.0 db). + * @param level The new equalizer 250Hz level (-12.0 db to +12.0db). + */ + public void setBand4(double level) { + Dispatch.put(object, "Band4", level); + } + + /** + * Returns the equalizer 250Hz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 250Hz level (-12.0 db to +12.0 db). + */ + public double getBand4() { + return Dispatch.get(object, "Band4").getDouble(); + } + + /** + * Set the equalizer 500Hz level (-12.0 db to +12.0 db). + * @param level The new equalizer 500Hz level (-12.0 db to +12.0db). + */ + public void setBand5(double level) { + Dispatch.put(object, "Band5", level); + } + + /** + * Returns the equalizer 500Hz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 500Hz level (-12.0 db to +12.0 db). + */ + public double getBand5() { + return Dispatch.get(object, "Band5").getDouble(); + } + + /** + * Set the equalizer 1KHz level (-12.0 db to +12.0 db). + * @param level The new equalizer 1KHz level (-12.0 db to +12.0db). + */ + public void setBand6(double level) { + Dispatch.put(object, "Band6", level); + } + + /** + * Returns the equalizer 1KHz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 1KHz level (-12.0 db to +12.0 db). + */ + public double getBand6() { + return Dispatch.get(object, "Band6").getDouble(); + } + + /** + * Set the equalizer 2KHz level (-12.0 db to +12.0 db). + * @param level The new equalizer 2KHz level (-12.0 db to +12.0db). + */ + public void setBand7(double level) { + Dispatch.put(object, "Band7", level); + } + + /** + * Returns the equalizer 2KHz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 2KHz level (-12.0 db to +12.0 db). + */ + public double getBand7() { + return Dispatch.get(object, "Band7").getDouble(); + } + + /** + * Set the equalizer 4KHz level (-12.0 db to +12.0 db). + * @param level The new equalizer 4KHz level (-12.0 db to +12.0db). + */ + public void setBand8(double level) { + Dispatch.put(object, "Band8", level); + } + + /** + * Returns the equalizer 4KHz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 4KHz level (-12.0 db to +12.0 db). + */ + public double getBand8() { + return Dispatch.get(object, "Band8").getDouble(); + } + + /** + * Set the equalizer 8KHz level (-12.0 db to +12.0 db). + * @param level The new equalizer 8KHz level (-12.0 db to +12.0db). + */ + public void setBand9(double level) { + Dispatch.put(object, "Band9", level); + } + + /** + * Returns the equalizer 8KHz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 8KHz level (-12.0 db to +12.0 db). + */ + public double getBand9() { + return Dispatch.get(object, "Band9").getDouble(); + } + + /** + * Set the equalizer 16KHz level (-12.0 db to +12.0 db). + * @param level The new equalizer 16KHz level (-12.0 db to +12.0db). + */ + public void setBand10(double level) { + Dispatch.put(object, "Band10", level); + } + + /** + * Returns the equalizer 16KHz level (-12.0 db to +12.0 db). + * @return Returns the equalizer 16KHz level (-12.0 db to +12.0 db). + */ + public double getBand10() { + return Dispatch.get(object, "Band10").getDouble(); + } + + /** + * Delete this EQ Preset. + * Any EQ preset can be deleted, including built-in presets, except for the + * Manual preset. + * @param updateAllTracks If true, any tracks that use this EQ preet will be + * set to have no assigned EQ preset. + */ + public void delete(boolean updateAllTracks) { + Dispatch.call(object, "Delete", updateAllTracks); + } + + /** + * Rename this EQ Preset. + * The name of any EQ preset can be changed, including built-in presets, + * except for the Manual preset. + * EQ preset names cannot start with leading spaces. If you specify a name + * that starts with leading spaces they will be stripped out. + * @param updateAllTracks If true, any tracks that use this EQ preet will be + * updated with the new preset name. + */ + public void rename(String newName, boolean updateAllTracks) { + Dispatch.call(object, "Rename", newName, updateAllTracks); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITFileOrCDTrack.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITFileOrCDTrack.java new file mode 100644 index 0000000..570896c --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITFileOrCDTrack.java @@ -0,0 +1,39 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a file or CD track. + * @author Steve Eyre + * @version 0.2 + */ +public class ITFileOrCDTrack extends ITTrack { + + public ITFileOrCDTrack (Dispatch d) { + super(d); + } + + /** + * Reveals the track in the main browser window. + */ + public void reveal() { + Dispatch.call(object, "Reveal"); + } + + public ITVideoKind getVideoKind() { + return ITVideoKind.values()[Dispatch.get(object, "VideoKind").getInt()]; + } + + public ITRatingKind getRatingKind() { + return ITRatingKind.values()[Dispatch.get(object, "RatingKind").getInt()]; + } + + public String getLocation() { + return Dispatch.get(object, "Location").getString(); + } + + public ITArtworkCollection getArtworks() { + Dispatch artworks = Dispatch.get(object, "Artwork").toDispatch(); + return new ITArtworkCollection(artworks); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITLibraryPlaylist.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITLibraryPlaylist.java new file mode 100644 index 0000000..c19cba8 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITLibraryPlaylist.java @@ -0,0 +1,20 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a library playlist. + * + * A library playlist consists of all the tracks in a user's library. + * + * For convenience, you can retrieve the main library playlist using + * iTunes.getLibraryPlaylist(). + * @author Steve Eyre + * @version 0.2 + */ +public class ITLibraryPlaylist extends ITPlaylist { + + public ITLibraryPlaylist(Dispatch d) { + super(d); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITObject.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITObject.java new file mode 100644 index 0000000..27475fd --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITObject.java @@ -0,0 +1,112 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Defines a source, playlist or track. + * + * An ITObject uniquely identifies a source, playlist, or track in iTunes using + * four separate IDs. These are runtime IDs, they are only valid while the + * current instance of iTunes is running. + * + * As of iTunes 7.7, you can also identify an ITObject using a 64-bit persistent + * ID, which is valid across multiple invocations of iTunes. + * + * The main use of the ITObject interface is to allow clients to track iTunes + * database changes using + * iTunesEventsInterface.onDatabaseChangedEvent(). + * + * You can retrieve an ITObject with a specified runtime ID using + * iTunes.getITObjectByID(). + * + * An ITObject will always have a valid, non-zero source ID. + * + * An ITObject corresponding to a playlist or track will always have a valid + * playlist ID. The playlist ID will be zero for a source. + * + * An ITObject corresponding to a track will always have a valid track and + * track database ID. These IDs will be zero for a source or playlist. + * + * A track ID is unique within the track's playlist. A track database ID is + * unique across all playlists. For example, if the same music file is in two + * different playlists, each of the tracks could have different track IDs, but + * they will have the same track database ID. + * + * An ITObject also has a 64-bit persistent ID which can be used to identify + * the ITObject across multiple invocations of iTunes. + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITObject { + + protected Dispatch object; + + public ITObject(Dispatch d) { + object = d; + } + + /** + * Returns the JACOB Dispatch object for this object. + * @return Returns the JACOB Dispatch object for this object. + */ + public Dispatch fetchDispatch() { + return object; + } + + /** + * Set the name of the object. + * @param name The new name of the object. + */ + public void setName (String name) { + Dispatch.put(object, "Name", name); + } + + /** + * Returns the name of the object. + * @return Returns the name of the object. + */ + public String getName() { + return Dispatch.get(object, "Name").getString(); + } + + /** + * Returns the index of the object in internal application order. + * @return The index of the object in internal application order. + */ + public int getIndex() { + return Dispatch.get(object, "Index").getInt(); + } + + /** + * Returns the ID that identifies the source. + * @return Returns the ID that identifies the source. + */ + public int getSourceID() { + return Dispatch.get(object, "SourceID").getInt(); + } + + /** + * Returns the ID that identifies the playlist. + * @return Returns the ID that identifies the playlist. + */ + public int getPlaylistID() { + return Dispatch.get(object, "PlaylistID").getInt(); + } + + /** + * Returns the ID that identifies the track within the playlist. + * @return Returns the ID that identifies the track within the playlist. + */ + public int getTrackID() { + return Dispatch.get(object, "TrackID").getInt(); + } + + /** + * Returns the ID that identifies the track, independent of its playlist. + * @return Returns the ID that identifies the track, independent of its playlist. + */ + public int getTrackDatabaseID() { + return Dispatch.get(object, "TrackDatabaseID").getInt(); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITObjectPersistentID.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITObjectPersistentID.java new file mode 100644 index 0000000..e5c674b --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITObjectPersistentID.java @@ -0,0 +1,53 @@ +package com.dt.iTunesController; + +/** + * Simple utility wrapper class to represent the persistent object identity + * ID numbers. Use the getHigh() and getLow() methods individually to get + * each ID, or the combined hex string through toString(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITObjectPersistentID { + + private long High; + private long Low; + private String hexString; + + /** + * Create the ITObjectPersistentID. This class is not intended to be created + * manually, and this function should only be used by classes implementing + * this utility. + * @param high The High Persistent ID + * @param low The Low Persistent ID + */ + public ITObjectPersistentID(long high, long low) { + this.High=high; + this.Low=low; + this.hexString = String.format("%8s%8s",Long.toHexString(this.High),Long.toHexString(this.Low)).toUpperCase().replace(' ','0'); + } + + /** + * Returns the high persistent ID. + * @return The high persistent ID. + */ + public long getHigh() { + return this.High; + } + + /** + * Returns the low persistent ID. + * @return The low persistent ID. + */ + public long getLow() { + return this.Low; + } + + /** + * Return a string representation (in hex) of the persistent IDs. + * @return String representation of the persistent IDs. + */ + public String toString() { + return this.hexString; + } +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITOperationStatus.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITOperationStatus.java new file mode 100644 index 0000000..cf764aa --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITOperationStatus.java @@ -0,0 +1,62 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents the status of an asynchronous add or convert operation. + * + * When a track is added using TLibraryPlaylist.addFile(), + * ITLibraryPlaylist.AddFiles(), IITUserPlaylist.addFile(), or + * ITUserPlaylist.addFiles(), the add may not complete immediately if iTunes + * needs to make a copy of the file. + * + * Similarly, when converting or importing a file or track using + * iTunes.convertFile(), iTunes.convertFiles(), + * iTunes.convertTrack() or iTunes.convertTracks(), + * the conversion will never complete immediately. + * + * These methods return an ITOperationStatus object, which can be + * polled todetermine when the operation is done. This object will also return + * the collection of newly added or converted tracks. + * + * As of version 1.1 of the iTunes type library, you should use + * iTunes.convertFile2(), iTunes.convertFiles2(), + * iTunes.convertTrack2() or iTunes.convertTracks2() + * instead of the original convert methods. These new methods return an + * ITConvertOperationStatus object to allow clients to retrieve + * additional conversion progress information. + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITOperationStatus { + + protected Dispatch object; + + public ITOperationStatus(Dispatch d) { + object = d; + } + + /** + * Returns true if the operation is still in progress. + * You cannot retrieve the ITOperationStatus.getTracks() + * property until the operation completes. + * @return Returns true if the operation is still in progress. + */ + public boolean getInProgress() { + return Dispatch.get(object, "InProgress").getBoolean(); + } + + /** + * Returns a collection containing the tracks that were generated by the + * operation. + * You cannot retrieve this property until + * ITOperationStatus.getInProgress() returns false + * @return Returns a collection containing the tracks that were generated by + * the operation. + */ + public ITTrackCollection getTracks() { + Dispatch tracks = Dispatch.get(object, "Tracks").toDispatch(); + return new ITTrackCollection(tracks); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlayerState.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlayerState.java new file mode 100644 index 0000000..4be2a70 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlayerState.java @@ -0,0 +1,13 @@ +package com.dt.iTunesController; + +/** + * Specifies the state of the player. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITPlayerState { + ITPlayerStateStopped, + ITPlayerStatePlaying, + ITPlayerStateFastForward, + ITPlayerStateRewind; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylist.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylist.java new file mode 100644 index 0000000..23bf2b9 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylist.java @@ -0,0 +1,154 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a playlist. + * + * A playlist is always associated with an ITSource. + * + * You can retrieve all the playlists defined for a source using + * ITSource.getPlaylists(). + * + * For convenience, you can retrieve the main library playlist using + * iTunes.getLibraryPlaylist(). + * + * You can create a new playlist using iTunes.createPlaylist(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITPlaylist extends ITObject { + + public ITPlaylist (Dispatch d) { + super(d); + } + + /** + * Delete this object. + */ + public void delete() { + Dispatch.call(object, "Delete"); + } + + /** + * Start playing the first track in this object. + */ + public void playFirstTrack() { + Dispatch.call(object, "PlayFirstTrack"); + } + + /** + * Print this object. + * @param showPrintDialog If true, display the print dialog. + * @param printKind The printout kind. + * @param theme The name of the theme to use. This corresponds to the name + * of a Theme combo box item in the print dialog for the specified printKind + * (e.g. "Track length"). This string cannot be longer than 255 characters, + * but it may be empty. + */ + public void print(boolean showPrintDialog, ITPlaylistPrintKind printKind, String theme) { + Dispatch.call(object, "Print", showPrintDialog, printKind.ordinal(), theme); + } + + /** + * Returns a collection containing the tracks with the specified text. + * @param searchText The text to search for. This string cannot be longer + * than 255 chracters. + * @param searchFields Specifies which fields of each track should be + * searched for searchText. + * @return Collection of IITTrack objects. This will be NULL if no tracks + * meet the search criteria. + */ + public ITTrackCollection search (String searchText, ITPlaylistSearchField searchFields) { + Dispatch collection = Dispatch.call(object, "Search", searchText, searchFields.ordinal()).getDispatch(); + return new ITTrackCollection(collection); + } + + /** + * Returns the kind of the object. + * @return Returns the kind of the object. + */ + public ITPlaylistKind getKind() { + return ITPlaylistKind.values()[Dispatch.get(object, "Kind").getInt()]; + } + + /** + * Returns an ITSource object corresponding to the source that contains the + * object. + * @return Returns an ITSource object corresponding to the source that + * contains the object. + */ + public ITSource getSource() { + Dispatch source = Dispatch.get(object, "Source").toDispatch(); + return new ITSource(source); + } + + /** + * Returns the total length of all songs in the object (in seconds). + * @return Returns the total length of all songs in the object (in + * seconds). + */ + public int getDuration() { + return Dispatch.get(object, "Duration").getInt(); + } + + /** + * Set whether songs in the object should be played in random order. + * @param shouldShuffle True if songs in the object should be played in + * random order. + */ + public void setShuffle(boolean shouldShuffle) { + Dispatch.put(object, "Shuffle", shouldShuffle); + } + + /** + * Returns the total size of all songs in the object (in bytes). + * @return Returns the total size of all songs in the object (in bytes). + */ + public double getSize() { + return Dispatch.get(object, "Size").getDouble(); + } + + /** + * Sets the playback repeat mode. + * @param repeatMode The new playback repeat mode. + */ + public void setSongRepeat(ITPlaylistRepeatMode repeatMode) { + Dispatch.put(object, "SongRepeat", repeatMode.ordinal()); + } + + /** + * Returns the playback repeat mode. + * @return Returns the playback repeat mode. + */ + public ITPlaylistRepeatMode getSongRepeat() { + return ITPlaylistRepeatMode.values()[Dispatch.get(object, "SongRepeat").getInt()]; + } + + /** + * Returns the total length of all songs in the object (in MM:SS format). + * @return Returns the total length of all songs in the object (in + * MM:SS format). + */ + public String getTime() { + return Dispatch.get(object, "Time").getString(); + } + + /** + * Returns true if the object is visible in the sources list. + * @return True if the object is visible in the sources list. + */ + public boolean getVisible() { + return Dispatch.get(object, "Visible").getBoolean(); + } + + /** + * Returns a collection containing the tracks in this object. + * @return Collection of ITTrack objects. + */ + public ITTrackCollection getTracks() { + Dispatch tracks = Dispatch.get(object, "Tracks").toDispatch(); + return new ITTrackCollection(tracks); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistCollection.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistCollection.java new file mode 100644 index 0000000..3717735 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistCollection.java @@ -0,0 +1,67 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a collection of playlist objects. + * + * Note that collection indices are always 1-based. + * + * You can retrieve all the playlists defined for a source using + * ITSource.getPlaylists(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITPlaylistCollection { + + protected Dispatch object; + + public ITPlaylistCollection(Dispatch d) { + object = d; + } + + /** + * Returns the number of playlists in the collection. + * @return Returns the number of playlists in the collection. + */ + public int getCount() { + return Dispatch.get(object, "Count").getInt(); + } + + /** + * Returns an ITPlaylist object corresponding to the given index (1-based). + * @param index Index of the playlist to retrieve, must be less than or + * equal to ITPlaylistCollection.getCount(). + * @return Returns an ITPlaylist object corresponding to the given index. + * Will be set to NULL if no playlist could be retrieved. + */ + public ITPlaylist getItem (int index) { + Dispatch item = Dispatch.call(object, "Item", index).toDispatch(); + return new ITPlaylist(item); + } + + /** + * Returns an ITPlaylist object withthe specified name. + * @param name The name of the playlist to retrieve. + * @return Returns an ITPlaylist object corresponding to the given index. + * Will be set to NULL if no playlist could be retrieved. + */ + public ITPlaylist ItemByName (String name) { + Dispatch item = Dispatch.call(object, "ItemByName", name).toDispatch(); + return new ITPlaylist(item); + } + + /** + * Returns an ITPlaylist object with the specified persistent ID. See the + * documentation on ITObject for more information on persistent IDs. + * @param highID The high 32 bits of the 64-bit persistent ID. + * @param lowID The low 32 bits of the 64-bit persistent ID. + * @return Returns an ITPlaylist object with the specified persistent ID. + * Will be set to NULL if no playlist could be retrieved. + */ + public ITPlaylist getItemByPersistentID (int highID, int lowID) { + Dispatch item = Dispatch.call(object, "ItemByPersistentID", highID, lowID).toDispatch(); + return new ITPlaylist(item); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistKind.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistKind.java new file mode 100644 index 0000000..e6f685f --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistKind.java @@ -0,0 +1,15 @@ +package com.dt.iTunesController; + +/** + * Specifies the playlist kind. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITPlaylistKind { + ITPlaylistKindUnknown, + ITPlaylistKindLibrary, + ITPlaylistKindUser, + ITPlaylistKindCD, + ITPlaylistKindDevice, + ITPlaylistKindRadioTuner; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistPrintKind.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistPrintKind.java new file mode 100644 index 0000000..6fc8ef8 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistPrintKind.java @@ -0,0 +1,14 @@ +package com.dt.iTunesController; + +/** + * Specifies the kind of playlist printout. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITPlaylistPrintKind { + + ITPlaylistPrintKindPlaylist, + ITPlaylistPrintKindAlbumlist, + ITPlaylistPrintKindInsert; + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistRepeatMode.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistRepeatMode.java new file mode 100644 index 0000000..4b6fc16 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistRepeatMode.java @@ -0,0 +1,14 @@ +package com.dt.iTunesController; + +/** + * Specifies the playlist playback repeat mode. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITPlaylistRepeatMode { + + ITPlaylistRepeatModeOff, + ITPlaylistRepeatModeOne, + ITPlaylistRepeatModeAll; + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistSearchField.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistSearchField.java new file mode 100644 index 0000000..420b305 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistSearchField.java @@ -0,0 +1,16 @@ +package com.dt.iTunesController; + +/** + * Specifies the fields in each track that will be searched by + * ITPlaylist.search(). + * @author Steve Eyre + * @version 0.2 + */ +public enum ITPlaylistSearchField { + ITPlaylistSearchFieldAll, + ITPlaylistSearchFieldVisible, + ITPlaylistSearchFieldArtists, + ITPlaylistSearchFieldAlbums, + ITPlaylistSearchFieldComposers, + ITPlaylistSearchFieldSongNames; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITRatingKind.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITRatingKind.java new file mode 100644 index 0000000..7d1cb22 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITRatingKind.java @@ -0,0 +1,11 @@ +package com.dt.iTunesController; + +/** + * Specifies the rating kind. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITRatingKind { + ITRatingKindUser, + ITRatingKindComputed; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITSource.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITSource.java new file mode 100644 index 0000000..b0d93fc --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITSource.java @@ -0,0 +1,51 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents an entry in the Source list (music library, CD, device, etc.). + * You can retrieve all the sources using iTunes.getSources(). + * @author Steve Eyre + * @version 0.2 + */ +public class ITSource extends ITObject { + + public ITSource(Dispatch d) { + super(d); + } + + /** + * Returns the kind of the source. + * @return Returns the kind of the source. + */ + public ITSourceKind getKind() { + return ITSourceKind.values()[Dispatch.get(object, "Kind").getInt()]; + } + + /** + * Returns the total size of the source, if it has a fixed size. + * @return Returns the total size of the source, if it has a fixed size. + */ + public double getCapacity() { + return Dispatch.get(object, "Capacity").getDouble(); + } + + /** + * Returns the free space on the source, if it has a fixed size. + * @return Returns the free space on the source, if it has a fixed size. + */ + public double getFreespace() { + return Dispatch.get(object, "Freespace").getDouble(); + } + + /** + * Returns a collection containing the playlists in this source. + * The source's primary playlist is always the first playlist in the + * collection. + * @return Collection of IITPlaylist objects. + */ + public ITPlaylistCollection getPlaylists() { + Dispatch playlists = Dispatch.get(object, "Playlists").toDispatch(); + return new ITPlaylistCollection(playlists); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceCollection.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceCollection.java new file mode 100644 index 0000000..357bdec --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceCollection.java @@ -0,0 +1,66 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a collection of source objects. + * + * Note that collection indices are always 1-based. + * + * You can retrieve all the sources using ITSource.getSources(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITSourceCollection { + + protected Dispatch object; + + public ITSourceCollection(Dispatch d) { + object = d; + } + + /** + * Returns the number of sources in the collection. + * @return Returns the number of sources in the collection. + */ + public int getCount() { + return Dispatch.get(object, "Count").getInt(); + } + + /** + * Returns an ITSource object corresponding to the given index (1-based). + * @param index Index of the source to retrieve, must be less than or + * equal to ITSourceCollection.getCount(). + * @return Returns an ITSource object corresponding to the given index. + * Will be set to NULL if no source could be retrieved. + */ + public ITSource getItem (int index) { + Dispatch item = Dispatch.call(object, "Item", index).toDispatch(); + return new ITSource(item); + } + + /** + * Returns an ITSource object withthe specified name. + * @param name The name of the source to retrieve. + * @return Returns an ITSource object corresponding to the given index. + * Will be set to NULL if no source could be retrieved. + */ + public ITSource getItemByName (String name) { + Dispatch item = Dispatch.call(object, "ItemByName", name).toDispatch(); + return new ITSource(item); + } + + /** + * Returns an ITSource object with the specified persistent ID. See the + * documentation on ITObject for more information on persistent IDs. + * @param highID The high 32 bits of the 64-bit persistent ID. + * @param lowID The low 32 bits of the 64-bit persistent ID. + * @return Returns an ITSource object with the specified persistent ID. + * Will be set to NULL if no source could be retrieved. + */ + public ITSource getItemByPersistentID (int highID, int lowID) { + Dispatch item = Dispatch.call(object, "ItemByPersistentID", highID, lowID).toDispatch(); + return new ITSource(item); + } + +} \ No newline at end of file diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceKind.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceKind.java new file mode 100644 index 0000000..f332249 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceKind.java @@ -0,0 +1,17 @@ +package com.dt.iTunesController; + +/** + * Specifies the source kind. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITSourceKind { + ITSourceKindUnknown, + ITSourceKindLibrary, + ITSourceKindIPod, + ITSourceKindAudioCD, + ITSourceKindMP3CD, + ITSourceKindDevice, + ITSourceKindRadioTuner, + ITSourceKindSharedLibrary; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrack.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrack.java new file mode 100644 index 0000000..0046c7e --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrack.java @@ -0,0 +1,492 @@ +package com.dt.iTunesController; +import com.jacob.com.*; +import java.util.Date; + +/** + * Represents a track. + * + * A track represents a song in a single playlist. A song may be in more than + * one playlist, in which case it would be represented by multiple tracks. + * + * You can retrieve the currently targeted (playing) track using + * iTunes.getCurrentTrack(). + * + * Typically, an ITrack is accessed through an ITTrackCollection. + * + * You can retrieve all the tracks defined for a playlist using + * ITPlaylist.getTracks(). + * + * You can retrieve the currently selected track or tracks using + * iTunes.getSelectedTracks(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITTrack extends ITObject { + + public ITTrack (Dispatch d) { + super(d); + } + + /** + * Delete this object. + */ + public void delete() { + Dispatch.call(object, "Delete"); + } + + /** + * Start playing this object. + */ + public void play() { + Dispatch.call(object, "Play"); + } + + /** + * Set the name of the album containing the object.; + * @param album The new name of the album containing the object. + */ + public void setAlbum(String album) { + Dispatch.put(object, "Album", album); + } + + /** + * Returns the name of the album containing the object. + * @return Returns the name of the album containing the object. + */ + public String getAlbum() { + return Dispatch.get(object, "Album").getString(); + } + + /** + * Set the name of the artist/source of the object. + * @param artist The new artist/source of the object. + */ + public void setArtist(String artist) { + Dispatch.put(object, "Artist", artist); + } + + /** + * Returns the name of the artist/source of the object. + * @return Returns the name of the artist/source of the object. + */ + public String getArtist() { + return Dispatch.get(object, "Artist").getString(); + } + + /** + * Returns the bit rate of the object (in kbps). + * @return Returns the bit rate of the object (in kbps). + */ + public int getBitRate() { + return Dispatch.get(object, "BitRate").getInt(); + } + + /** + * Set the tempo of the object (in beats per minute). + * @param beatsPerMinute The new tempo of the object (in beats per minute). + */ + public void setBPM(int beatsPerMinute) { + Dispatch.put(object, "BPM", beatsPerMinute); + } + + /** + * Returns the tempo of the object (in beats per minute). + * @return Returns the tempo of the object (in beats per minute). + */ + public int getBPM() { + return Dispatch.get(object, "BPM").getInt(); + } + + /** + * Set freeform notes about the object. + * @param comment The new freeform notes about the object. + */ + public void setComment(String comment) { + Dispatch.put(object, "Comment", comment); + } + + /** + * Returns freeform notes about the object. + * @return Returns freeform notes about the object. + */ + public String getComment() { + return Dispatch.get(object, "Comment").getString(); + } + + /** + * Set whether this object is from a compilation album. + * @param isCompilation True if this object should be from a compilation album. + */ + public void setCompilation(boolean isCompilation) { + Dispatch.put(object, "Compilation", isCompilation); + } + + /** + * Returns true if this object is from a compilation album. + * @return Returns true if this object is from a compilation album. + */ + public boolean getCompilation() { + return Dispatch.get(object, "Compilation").getBoolean(); + } + + /** + * Set the composer of the object. + * @param composer The new composer of the object. + */ + public void setComposer (String composer) { + Dispatch.put(object, "Composer", composer); + } + + /** + * Returns the composer of the object. + * @return Returns the composer of the object. + */ + public String getComposer() { + return Dispatch.get(object, "Composer").getString(); + } + + /** + * Returns the date the object was added to the playlist. + * @return Returns the date the object was added to the playlist. + */ + public Date getDateAdded() { + return Dispatch.get(object, "DateAdded").getJavaDate(); + } + + /** + * Set the total number of discs in the source album. + * @param discCount The new total number of discs in the source album. + */ + public void setDiscCount (int discCount) { + Dispatch.put(object, "DiscCount", discCount); + } + + /** + * Returns the total number of discs in the source album. + * @return Returns the total number of discs in the source album. + */ + public int getDiscCount() { + return Dispatch.get(object, "DiscCount").getInt(); + } + + /** + * Set the index of the disc containing the object on the source album. + * @param discNumber The new index of the disc containing the object on the + * source album. + */ + public void setDiscNumber (int discNumber) { + Dispatch.put(object, "DiscNumber", discNumber); + } + + /** + * Returns the index of the disc containing the object on the source album. + * @return Returns the index of the disc containing the object on the source + * album. + */ + public int getDiscNumber() { + return Dispatch.get(object, "DiscNumber").getInt(); + } + + /** + * Returns the length of the object (in seconds). + * @return Returns the length of the object (in seconds). + */ + public int getDuration() { + return Dispatch.get(object, "Duration").getInt(); + } + + /** + * Set whether this object is checked for playback. + * @param shouldBeEnabled True if the object should be checked for playback. + */ + public void setEnabled (boolean shouldBeEnabled) { + Dispatch.put(object, "Enabled", shouldBeEnabled); + } + + /** + * Returns true if the object is checked for playback. + * @return Returns true if the object is checked for playback. + */ + public boolean getEnabled() { + return Dispatch.get(object, "Enabled").getBoolean(); + } + + /** + * Set the name of the EQ preset of the object. + * @param eq The new name of the EQ preset of the object. + */ + public void setEQ (String eq) { + Dispatch.put(object, "EQ", eq); + } + + /** + * Returns the name of the EQ preset of the object. + * @return Returns the name of the EQ preset of the object. + */ + public String getEQ() { + return Dispatch.get(object, "EQ").getString(); + } + + /** + * Set the stop time of the object (in seconds). + * @param finish The new stop time of the object (in seconds). + */ + public void setFinish(int finish) { + Dispatch.put(object, "Finish", finish); + } + + /** + * Returns the stop time of the object (in seconds). + * @return Returns the stop time of the object (in seconds). + */ + public int getFinish() { + return Dispatch.get(object, "Finish").getInt(); + } + + /** + * Returns the music/audio genre (category) of the object. + * @param genre Returns the music/audio genre (category) of the object. + */ + public void setGenre(String genre) { + Dispatch.put(object, "Genre", genre); + } + + /** + * Set the music/audio genre (category) of the object. + * @return The new music/audio genre (category) of the object. + */ + public String getGenre() { + return Dispatch.get(object, "Genre").getString(); + } + + /** + * Set the grouping (piece) of the object. + * Generally used to denote movements within classical work. + * @param grouping The new grouping (piece) of the object. + */ + public void setGrouping (String grouping) { + Dispatch.put(object, "Grouping", grouping); + } + + /** + * Returns the grouping (piece) of the object. + * Generally used to denote movements within classical work. + * @return Returns the grouping (piece) of the object. + */ + public String getGrouping() { + return Dispatch.get(object, "Grouping").getString(); + } + + public ITTrackKind getKind() { + return ITTrackKind.values()[Dispatch.get(object, "Kind").getInt()]; + } + + /** + * Returns the text description of the object (e.g. "AAC audio file"). + * @return Returns the text description of the object (e.g. "AAC audio file"). + */ + public String getKindAsString() { + return Dispatch.get(object, "KindAsString").getString(); + } + + /** + * Returns the modification date of the content of the object. + * @return Returns the modification date of the content of the object. + */ + public Date getModificationDate() { + return Dispatch.get(object, "ModificationDate").getJavaDate(); + } + + /** + * Set the number of times the object has been played. This property cannot + * be set if the object is not playable (e.g. a PDF file). + * @param playedCount The new number of times the object has been played. + */ + public void setPlayedCount (int playedCount) { + Dispatch.put(object, "PlayedCount", playedCount); + } + + /** + * Returns the number of times the object has been played. + * @return Returns the number of times the object has been played. + */ + public int getPlayedCount() { + return Dispatch.get(object, "PlayedCount").getInt(); + } + + /** + * Set the date and time the object was last played. This property cannot be + * set if the object is not playable (e.g. a PDF file). + * A value of zero means no played date. + * @param playedDate The new date and time the object was last played. + */ + public void setPlayedDate (Date playedDate) { + Dispatch.put(object, "PlayedDate", playedDate); + } + + /** + * Returns the date and time the object was last played. + * A value of zero means no played date. + * @return Returns the date and time the object was last played. + */ + public Date getPlayedDate() { + return Dispatch.get(object, "PlayedDate").getJavaDate(); + } + + /** + * Returns an ITPlaylist object corresponding to the playlist that contains + * the object. Use ITFileOrCDTrack::Playlists() or IITURLTrack::Playlists() + * to get the collection of all playlists that contain the song this object + * represents. + * @return Returns an ITPlaylist object corresponding to the playlist that + * contains the object. + */ + public ITPlaylist getPlaylist() { + Dispatch playlist = Dispatch.get(object, "Playlist").toDispatch(); + return new ITPlaylist(playlist); + } + + /** + * Returns the play order index of the object in the owner playlist + * (1-based). + * You can pass this index to IITTrackCollection::ItemByPlayOrder() for the + * collection returned by ITPlaylist::Tracks() to retrieve an ITTrack + * object corresponding to this object. + * @return Returns the play order index of the object in the owner playlist. + */ + public int getPlayOrderIndex() { + return Dispatch.get(object, "PlayOrderIndex").getInt(); + } + + /** + * Set the rating of the object (0 to 100). If the object rating is set to 0, + * it will be computed based on the album rating. + * @param rating The new rating of the object (0 to 100). + */ + public void setRating (int rating) { + Dispatch.put(object, "Rating", rating); + } + + /** + * Returns the rating of the object (0 to 100). If the object rating has never + * been set, or has been set to 0, it will be computed based on the album + * rating. + * @return Returns the rating of the object (0 to 100). + */ + public int getRating() { + return Dispatch.get(object, "Rating").getInt(); + } + + /** + * Returns the sample rate of the object (in Hz). + * @return Returns the sample rate of the object (in Hz). + */ + public int getSampleRate() { + return Dispatch.get(object, "SampleRate").getInt(); + } + + /** + * Returns the size of the object (in bytes). + * @return Returns the size of the object (in bytes). + */ + public int getSize() { + return Dispatch.get(object, "Size").getInt(); + } + + /** + * Set the start time of the object (in seconds). + * @param start The new start time of the object (in seconds). + */ + public void setStart (int start) { + Dispatch.put(object, "Start", start); + } + + /** + * Returns the start time of the object (in seconds). + * @return Returns the start time of the object (in seconds). + */ + public int getStart() { + return Dispatch.get(object, "Start").getInt(); + } + + /** + * Returns the length of the object (in MM:SS format). + * @return Returns the length of the object (in MM:SS format). + */ + public String getTime() { + return Dispatch.get(object, "Time").getString(); + } + + /** + * Set the total number of tracks on the source album. + * @param trackCount The new total number of tracks on the source album. + */ + public void setTrackCount (int trackCount) { + Dispatch.put(object, "TrackCount", trackCount); + } + + /** + * Returns the total number of tracks on the source album. + * @return Returns the total number of tracks on the source album. + */ + public int getTrackCount() { + return Dispatch.get(object, "TrackCount").getInt(); + } + + /** + * Set the index of the object on the source album. + * @param trackNumber The new index of the object on the source album. + */ + public void setTrackNumber (int trackNumber) { + Dispatch.put(object, "TrackNumber", trackNumber); + } + + /** + * Returns the index of the object on the source album. + * @return Returns the index of the object on the source album. + */ + public int getTrackNumber() { + return Dispatch.get(object, "TrackNumebr").getInt(); + } + + /** + * Set the relative volume adjustment of the object (-100% to 100%). + * @param volumeAdjustment Set the relative volume adjustment of the object + * (-100% to 100%). + */ + public void setVolumeAdjustment (int volumeAdjustment) { + Dispatch.put(object, "VolumeAdjustment", volumeAdjustment); + } + + /** + * Returns the relative volume adjustment of the object (-100% to 100%). + * @return Returns the relative volume adjustment of the object (-100% to 100%). + */ + public int getVolumeAdjustment() { + return Dispatch.get(object, "VolumeAdjustment").getInt(); + } + + /** + * Set the year the object was recorded/released. + * @param year The new year the object was recorded/released. + */ + public void setYear (int year) { + Dispatch.put(object, "Year", year); + } + + /** + * Returns the year the object was recorded/released. + * @return Returns the year the object was recorded/released. + */ + public int getYear() { + return Dispatch.get(object, "Year").getInt(); + } + + public ITArtworkCollection getArtwork() { + Dispatch art = Dispatch.get(object, "Artwork").toDispatch(); + return new ITArtworkCollection(art); + + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackCollection.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackCollection.java new file mode 100644 index 0000000..b87208f --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackCollection.java @@ -0,0 +1,91 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a collection of track objects. + * + * Note that collection indices are always 1-based. + * + * You can retrieve all the tracks defined for a playlist using + * ITPlaylist.getTracks(). + * + * You can retrieve the currently selected track or tracks using + * iTunes.getSelectedTracks(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITTrackCollection { + + protected Dispatch object; + + public ITTrackCollection(Dispatch d) { + object = d; + } + + /** + * Returns the number of tracks in the collection. + * @return Returns the number of tracks in the collection. + */ + public int getCount() { + return Dispatch.get(object, "Count").getInt(); + } + + /** + * Returns an ITTrack object corresponding to the given index (1-based). + * @param index Index of the track to retrieve, must be less than or + * equal to ITTrackCollection.getCount(). + * @return Returns an ITTrack object corresponding to the given index. + * Will be set to NULL if no track could be retrieved. + */ + public ITTrack getItem (int index) { + Dispatch item = Dispatch.call(object, "Item", index).toDispatch(); + ITTrack track = new ITTrack(item); + if (track.getKind()==ITTrackKind.ITTrackKindFile) { + return new ITFileOrCDTrack(item); + } else if (track.getKind()==ITTrackKind.ITTrackKindCD) { + return new ITFileOrCDTrack(item); + } else if (track.getKind()==ITTrackKind.ITTrackKindURL ) { + return new ITURLTrack(item); + } else { + return track; + } + } + + /** + * Returns an ITTrack object corresponding to the given index (1-based). + * @param index Index of the track to retrieve, must be less than or + * equal to ITTrackCollection.getCount(). + * @return Returns an ITTrack object corresponding to the given index. + * Will be set to NULL if no track could be retrieved. + */ + public ITTrack getItemByPlayOrder(int index) { + Dispatch item = Dispatch.call(object, "ItemByPlayOrder", index).toDispatch(); + return new ITTrack(item); + } + + /** + * Returns an ITTrack object withthe specified name. + * @param name The name of the track to retrieve. + * @return Returns an ITTrack object corresponding to the given index. + * Will be set to NULL if no track could be retrieved. + */ + public ITTrack ItemByName (String name) { + Dispatch item = Dispatch.call(object, "ItemByName", name).toDispatch(); + return new ITTrack(item); + } + + /** + * Returns an ITTrack object with the specified persistent ID. See the + * documentation on ITObject for more information on persistent IDs. + * @param highID The high 32 bits of the 64-bit persistent ID. + * @param lowID The low 32 bits of the 64-bit persistent ID. + * @return Returns an ITTrack object with the specified persistent ID. + * Will be set to NULL if no track could be retrieved. + */ + public ITTrack getItemByPersistentID (int highID, int lowID) { + Dispatch item = Dispatch.call(object, "ItemByPersistentID", highID, lowID).toDispatch(); + return new ITTrack(item); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackKind.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackKind.java new file mode 100644 index 0000000..ec233a1 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackKind.java @@ -0,0 +1,15 @@ +package com.dt.iTunesController; + +/** + * Specifies the track kind. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITTrackKind { + ITTrackKindUnknown, + ITTrackKindFile, + ITTrackKindCD, + ITTrackKindURL, + ITTrackKindDevice, + ITTrackKindSharedLibrary; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITURLTrack.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITURLTrack.java new file mode 100644 index 0000000..9829190 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITURLTrack.java @@ -0,0 +1,175 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a URL track. + * + * A URL track references a network audio stream. + * @author Steve Eyre + * @version 0.2 + */ +public class ITURLTrack extends ITTrack { + + public ITURLTrack (Dispatch d) { + super(d); + } + + /** + * Returns the URL of the stream represented by this track. + * @return The URL of the stream represented by this track. + */ + public String getURL () { + return Dispatch.get(object, "URL").getString(); + } + + /** + * Set the URL of the stream represented by this track. + * @param url The URL of the stream represented by this track. + */ + public void setURL (String url) { + Dispatch.call(object, "URL", url); + } + + /** + * Returns true if this track is a podcast track. If a podcast track is an + * IITURLTrack, the podcast episode has not been downloaded. + * @return Returns true if this track is a podcast track. + */ + public boolean isPodcast () { + return Dispatch.get(object, "Podcast").getBoolean(); + } + + /** + * Returns the category for the track. + * @return Returns the category for the track. + */ + public String getCategory () { + return Dispatch.get(object, "Category").getString(); + } + + /** + * Sets the category for the track. + * @param category Sets the category for the track. + */ + public void setCategory (String category) { + Dispatch.call(object, "Category", category); + } + + /** + * Returns the description for the track. + * @return Returns the description for the track. + */ + public String getDescription () { + return Dispatch.get(object, "Description").getString(); + } + + /** + * Sets the description for the track. + * @param description The new description for the track. + */ + public void setDescription (String description) { + Dispatch.call(object, "Description", description); + } + + /** + * Returns the long description for the track. + * @return Returns the description for the track. + */ + public String getLongDescription () { + return Dispatch.get(object, "LongDescription").getString(); + } + + /** + * Sets the long description for the track. + * @param longDescription The new long description for the track. + */ + public void setLongDescription (String longDescription) { + Dispatch.call(object, "LongDescription", longDescription); + } + + /** + * Returns the user or computed rating of the album that this track belongs + * to (0 to 100). If the album rating has never been set, or has been set to + * 0, it will be computed based on the ratings of tracks in the album. + * @return Returns the album rating of the album that this track belongs to (0 to 100). + */ + public long getAlbumRating () { + return Dispatch.get(object, "AlbumRating").getLong(); + } + + /** + * Set the album rating of the album that this track belongs to (0 to 100). + * If the album rating is set to 0, it will be computed based on the ratings + * of tracks in the album. + * @param albumRating The new album rating of the album that this track + * belongs to (0 to 100). If rating is outside this range, it will be + * pinned. + */ + public void setAlbumRating (long albumRating) { + Dispatch.call(object, "AlbumRating", albumRating); + } + + /** + * Returns the album rating kind. If the album rating has never been set, or + * has been set to 0, the kind is ITRatingKindComputed. Otherwise, the kind + * is ITRatingKindUser. + * @return Returns the album rating kind. + */ + public ITRatingKind getAlbumRatingKind () { + return ITRatingKind.values()[Dispatch.get(object, "AlbumRatingKind").getInt()]; + } + + /** + * Returns the track rating kind. If the track rating has never been set, or + * has been set to 0, the kind is ITRatingKindComputed. Otherwise, the kind + * is ITRatingKindUser. + * @return Returns the track rating kind. + */ + public ITRatingKind getRatingKind () { + return ITRatingKind.values()[Dispatch.get(object, "RatingKind").getInt()]; + } + + /** + * Returns a collection of playlists that contain the song that this track + * represents. + * + * This is the same collection of playlists that are shown in the "Show in + * Playlist" contextual menu for a track, plus the specific playlist that + * contains this track. + * + * A track represents a song in a single playlist, use + * ITTrack.getPlaylist() to get the specific playlist that + * contains this track. + * @return Collection of ITPlaylist objects. + */ + public ITPlaylistCollection getPlaylists () { + Dispatch playlists = Dispatch.get(object, "Playlists").toDispatch(); + return new ITPlaylistCollection(playlists); + } + + /** + * Update the podcast feed for this track. This is equivalent to the user + * choosing Update Podcast from the contextual menu for the podcast feed + * that contains this track. + */ + public void updatePodcastFeed () { + Dispatch.call(object, "UpdatePodcastFeed"); + } + + /** + * Start downloading the podcast episode that corresponds to this track. + * This is equivalent to the user clicking the Get button next to this + * track. + */ + public void downloadPodcastEpisode () { + Dispatch.call(object, "DownloadPodcastEpisode"); + } + + /** + * Reveals the track in the main browser window. + */ + public void reveal() { + Dispatch.call(object, "Reveal"); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITUserPlaylist.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITUserPlaylist.java new file mode 100644 index 0000000..b4025cf --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITUserPlaylist.java @@ -0,0 +1,60 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a user-defined playlist. + * + * A user playlist includes both smart and manual user-defined playlists. + * @author Steve Eyre + * @version 0.2 + */ +public class ITUserPlaylist extends ITPlaylist { + + public ITUserPlaylist(Dispatch d) { + super(d); + } + + /** + * Add a file or files inside a folder to the playlist. + * You cannot use this method to add a file that requires conversion to be + * added (e.g. a CD track), use iTunes.convertFile() or + * iTunes.convertFile2() instead. If you add a folder that + * contains files that require conversion, they will be skipped. + * @param filePath The full path to the file or folder to add. + * @return Returns an ITOperationStatus object corresponding to the + * asynchronous operation. If an error occurs, or no files were added, this + * will be set to NULL. + */ + public ITOperationStatus addFile (String filePath) { + Dispatch status = Dispatch.call(object, "AddFile", filePath).toDispatch(); + return new ITOperationStatus(status); + } + + /** + * Add a streaming audio URL to the playlist. + * @param url The URL to add. The length of the URL can be 255 characters or + * less. + * @return Returns an ITURLTrack object corresponding to the new track. + */ + public ITURLTrack addURL (String url) { + Dispatch URLTrack = Dispatch.call(object, "AddURL", url).toDispatch(); + return new ITURLTrack(URLTrack); + } + + /** + * Add an existing track to the playlist. + * You cannot use this method to add a CD track (ITTrackKindCD) to another + * playlist, use iTunes.convertTrack() or + * iTunes.convertTrack2() instead. + * You cannot add a shared library track (ITTrackKindSharedLibrary) to + * another playlist. + * @param track The track to add. + * @return Returns an IITTrack object corresponding to the new track. + */ + public ITTrack addTrack (ITTrack track) { + Dispatch trackToAdd = track.fetchDispatch(); + Dispatch addedTrack = Dispatch.call(object, "AddTrack", trackToAdd).toDispatch(); + return new ITTrack(addedTrack); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITVideoKind.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITVideoKind.java new file mode 100644 index 0000000..d318724 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITVideoKind.java @@ -0,0 +1,13 @@ +package com.dt.iTunesController; + +/** + * Specifies the Video kind. + * @author Steve Eyre + * @version 0.2 + */ +public enum ITVideoKind { + ITVideoKindNone, + ITVideoKindMovie, + ITVideoKindMusicVideo, + ITVideoKindTVShow; +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindow.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindow.java new file mode 100644 index 0000000..4af825f --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindow.java @@ -0,0 +1,32 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents an iTunes window. + */ + +public class ITWindow { + + protected Dispatch object; + + public ITWindow(Dispatch d) { + object = d; + } + + /** + * Returns the JACOB Dispatch object for this object. + * @return Returns the JACOB Dispatch object for this object. + */ + public Dispatch fetchDispatch() { + return object; + } + + /** + * Returns the name of the object. + * @return Returns the name of the object. + */ + public String getName() { + return Dispatch.get(object, "Name").getString(); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindowCollection.java b/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindowCollection.java new file mode 100644 index 0000000..df1f3cf --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindowCollection.java @@ -0,0 +1,55 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; + +/** + * Represents a collection of window objects. + * + * Note that collection indices are always 1-based. + * + * You can retrieve all the windows using + * iTunes.getWindows(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class ITWindowCollection { + + protected Dispatch object; + + public ITWindowCollection(Dispatch d) { + object = d; + } + + // TODO: iTunes.getWindows() + + /** + * Returns the number of playlists in the collection. + * @return Returns the number of playlists in the collection. + */ + public int getCount() { + return Dispatch.get(object, "Count").getInt(); + } + + /** + * Returns an ITWindow object corresponding to the given index (1-based). + * @param index Index of the playlist to retrieve, must be less than or + * equal to ITWindowCollection.getCount(). + * @return Returns an ITWindow object corresponding to the given index. + * Will be set to NULL if no playlist could be retrieved. + */ + public ITWindow getItem (int index) { + Dispatch item = Dispatch.call(object, "Item", index).toDispatch(); + return new ITWindow(item); + } + /** + * Returns an ITWindow object with the specified name. + * @param name The name of the window to retrieve. + * @return Returns an ITWindow object corresponding to the given index. + * Will be set to NULL if no ITWindow could be retrieved. + */ + public ITWindow ItemByName (String name) { + Dispatch item = Dispatch.call(object, "ItemByName", name).toDispatch(); + return new ITWindow(item); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/iTunes.java b/vendor/iTunesController/0.2/com/dt/iTunesController/iTunes.java new file mode 100644 index 0000000..150ae7a --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/iTunes.java @@ -0,0 +1,488 @@ +package com.dt.iTunesController; +import com.jacob.activeX.*; +import com.jacob.com.Dispatch; +import com.jacob.com.DispatchEvents; +import com.jacob.com.Variant; + +/** + * Defines the top-level iTunes application object. + * + * This interface defines the top-level iTunes application object. All other + * iTunes interfaces are accessed through this object. + * + * @author Steve Eyre + * @version 0.2 + */ +public class iTunes { + + ActiveXComponent iTunes; + iTunesEvents iTunesEvents; + DispatchEvents dispatchEvents; + + /** + * Initiate iTunes Controller. + */ + public iTunes() { + iTunes = new ActiveXComponent("iTunes.Application"); + } + + /** + * Add an event handler to the iTunes controller. + * @param itef The class that will handle the iTunes events. + */ + public void addEventHandler(iTunesEventsInterface itef) { + iTunesEvents = new iTunesEvents(itef); + dispatchEvents = new DispatchEvents(iTunes, iTunesEvents); + System.out.println("New event handler added."); + } + + /** + * Reposition to the beginning of the current track or go to the previous + * track if already at start of current track. + */ + public void backTrack() { + iTunes.invoke("BackTrack"); + } + + /** + * Skip forward in a playing track. + */ + public void fastForward() { + iTunes.invoke("FastForward"); + } + + /** + * Advance to the next track in the current playlist. + */ + public void nextTrack() { + iTunes.invoke("NextTrack"); + } + + /** + * Pause playback. + */ + public void pause() { + iTunes.invoke("Pause"); + } + + /** + * Play the currently targeted track. + */ + public void play() { + Variant s = iTunes.invoke("ASDSDPlay"); + } + + /** + * Play the specified file path, adding it to the library if not already + * present. + */ + public void playFile(String filePath) { + iTunes.invoke("PlayFile", filePath); + } + + /** + * Toggle the playing/paused state of the current track. + */ + public void playPause() { + iTunes.invoke("PlayPause"); + } + + /** + * Return to the previous track in the current playlist. + */ + public void previousTrack() { + iTunes.invoke("PreviousTrack"); + } + + /** + * Disable fast forward/rewind and resume playback, if playing. + */ + public void resume() { + iTunes.invoke("Resume"); + } + + /** + * Skip backwards in a playing track. + */ + public void rewind() { + iTunes.invoke("Rewind"); + } + + /** + * Stop playback. + */ + public void stop() { + iTunes.invoke("Stop"); + } + + /** + * Retrieves the current state of the player buttons in the window + * containing the currently targeted track. If there is no currently + * targeted track, returns the current state of the player buttons + * in the main browser window. + */ + public void getPlayerButtonsState(boolean previousEnabled, + String playPause, boolean nextEnabled) { + + } + + /** + * Returns true if this version of the iTunes type library is compatible + * with the specified version. + * @param majorVersion Major version of iTunes interface. + * @param minorVersion Minor version of iTunes interface. + * @return Returns true if this version is compatible with the indicated + * interface version. + */ + public boolean getCheckVersion (int majorVersion, int minorVersion) { + return iTunes.invoke("CheckVersion", majorVersion, minorVersion).getBoolean(); + } + + /** + * Returns an IITObject corresponding to the specified IDs. + * The object may be a source, playlist, or track. + * @param sourceID The ID that identifies the source. Valid for a source, + * playlist, or track. + * @param playlistID The ID that identifies the playlist. Valid for a + * playlist or track. Must be zero for a source. + * @param trackID The ID that identifies the track within the playlist. + * Valid for a track. Must be zero for a source or playlist. + * @param databaseID The ID that identifies the track, independent of its + * playlist. Valid for a track. Must be zero for a source or playlist. + * @return Returns an IITObject object corresponding to the specified IDs. + * Will be set to NULL if no object could be retrieved. + */ + public ITObject getITObjectByID(int sourceID, int playlistID, int trackID, int databaseID) { + Dispatch object = Dispatch.call(iTunes, "GetITObjectByID", sourceID, playlistID, trackID, databaseID).toDispatch(); + return new ITObject(object); + } + + /** + * Creates a new playlist in the main library. + * @param playlistName The name of the new playlist (may be empty). + * @return Returns an ITPlaylist object corresponding to the new playlist. + */ + public ITPlaylist createPlaylist(String playlistName) { + Dispatch cplaylist = Dispatch.call(iTunes, "CreatePlaylist", playlistName).toDispatch(); + ITPlaylist playlist = new ITPlaylist(cplaylist); + ITPlaylistKind playlistKind = playlist.getKind(); + if (playlistKind == ITPlaylistKind.ITPlaylistKindCD) + return new ITAudioCDPlaylist(cplaylist); + else if (playlist.getKind() == ITPlaylistKind.ITPlaylistKindLibrary) + return new ITLibraryPlaylist(cplaylist); + else if (playlist.getKind() == ITPlaylistKind.ITPlaylistKindUser) + return new ITUserPlaylist(cplaylist); + else + return playlist; + } + + /** + * Open the specified iTunes Store or streaming audio URL. + * @param url The URL to open. The length of the URL cannot exceed 512 + * characters. iTunes Store URLs start with itms:// or itmss://. Streaming + * audio URLs start with http://. + */ + public void openURL (String url) { + iTunes.invoke("OpenURL", url); + } + + /** + * Go to the iTunes Store home page. + */ + public void gotoMusicStoreHomePage() { + iTunes.invoke("GoToMusicStoreHomePage"); + } + + /** + * Update the contents of the iPod. + */ + public void updateIPod() { + iTunes.invoke("UpdateIPod"); + } + + /** + * Exits the iTunes application. + */ + public void quit() { + iTunes.invoke("Quit"); + } + + /** + * Creates a new EQ preset. + * The EQ preset will be created "flat", i.e. the preamp and all band levels + * will be set to 0. + * EQ preset names cannot start with leading spaces. If you specify a name + * that starts with leading spaces they will be stripped out. + * If eqPresetName is empty, the EQ preset will be created with + * a default name. + * @param eqPresetName The name of the new EQ Preset (may be empty) + * @return Returns an ITEQPreset object corresponding to the new EQ Preset. + */ + public ITEQPreset createEQPreset(String eqPresetName) { + Dispatch eqPreset = Dispatch.call(iTunes, "CreateEQPreset", eqPresetName).toDispatch(); + return new ITEQPreset(eqPreset); + } + + /** + * Creates a new playlist in an existing source. + * You may not be able to create a playlist in every source. For example, + * you cannot create a playlist in an audio CD source, or in an iPod source + * if it is in auto update mode. + * If playlistName is empty, the playlist will be created with + * a default name. + * @param playlistName The name of the new playlist (may be empty). + * @param source The source that will contain the new playlist. + * @return Returns an ITPlaylist object corresponding to the new playlist. + */ + public ITPlaylist createPlaylistInSource(String playlistName, ITSource source) { + Dispatch cplaylist = Dispatch.call(iTunes, "CreatePlaylistInSource", playlistName, source.fetchDispatch()).toDispatch(); + ITPlaylist playlist = new ITPlaylist(cplaylist); + ITPlaylistKind playlistKind = playlist.getKind(); + if (playlistKind == ITPlaylistKind.ITPlaylistKindCD) + return new ITAudioCDPlaylist(cplaylist); + else if (playlist.getKind() == ITPlaylistKind.ITPlaylistKindLibrary) + return new ITLibraryPlaylist(cplaylist); + else if (playlist.getKind() == ITPlaylistKind.ITPlaylistKindUser) + return new ITUserPlaylist(cplaylist); + else + return playlist; + } + + /** + * Subscribes to the specified podcast feed URL. Any "unsafe" characters in + * the URL should already be converted into their corresponding escape + * sequences, iTunes will not do this. + * @param url The URL to subscribe to. + */ + public void subscribeToPodcast(String url) { + iTunes.invoke("SubscribeToPodcast", url); + } + + /** + * Updates all podcast feeds. This is equivalent to the user pressing the + * Update button when Podcasts is selected in the Source list. + */ + public void updatePodcastFeeds() { + iTunes.invoke("UpdatePodcastFeeds"); + } + + /** + * Creates a new folder in the main library. + * If folderName is empty, the folder will be created with a + * default name. + * @param folderName The name of the new folder (may be empty). + * @return Returns an ITPlaylist object corresponding to the new folder. + */ + public ITUserPlaylist createFolder(String folderName) { + Dispatch folder = Dispatch.call(iTunes, "CreateFolder", folderName).toDispatch(); + return new ITUserPlaylist(folder); + } + + /** + * Creates a new folder in an existing source. + * You may not be able to create a folder in every source. For example, you + * cannot create a folder in an audio CD source, or in an iPod source if it + * is in auto update mode. + * If folderName is empty, the folder will be created with a + * default name. + * @param folderName The name of the new folder (may be empty) + * @param iSource The source that will contain the new folder. + * @return Returns an ITPlaylist object corresponding to the new folder. + */ + public ITUserPlaylist createFolderInSource(String folderName, ITSource iSource) { + Dispatch folder = Dispatch.call(iTunes, "CreateFolderInSource", folderName, iSource.fetchDispatch()).toDispatch(); + return new ITUserPlaylist(folder); + } + + /** + * Returns a collection of music sources (music library, CD, device, etc.). + * @return Collection of ITSource objects. + */ + public ITSourceCollection getSources() { + Dispatch sources = Dispatch.call(iTunes, "Sources").toDispatch(); + return new ITSourceCollection(sources); + } + + /** + * Sets the sound output volume (0=minimum, 100=maximum). + * @param volume New sound output volume + */ + public void setSoundVolume(int volume) { + iTunes.setProperty("SoundVolume", volume); + } + + /** + * Returns the sound output volume (0=minimum, 100=maximum). + * @return Current sound output volume + */ + public int getSoundVolume() { + return iTunes.getPropertyAsInt("SoundVolume"); + } + + /** + * Sets sound output mute state. + * @param shouldMute If true, sound output will be muted. + */ + public void setMute(boolean shouldMute) { + iTunes.setProperty("Mute", shouldMute); + } + + /** + * Returns true if the sound output is muted. + * @return True if sound output is muted. + */ + public boolean getMute() { + return iTunes.getPropertyAsBoolean("Mute"); + } + + /** + * Returns the current player state. + * @return Returns the current player state. + */ + public ITPlayerState getPlayerState() { + return ITPlayerState.values()[Dispatch.get(iTunes, "PlayerState").getInt()]; + } + + /** + * Sets the player's position within the currently playing track in + * seconds. + * If playerPos specifies a position before the beginning of the track, + * the position will be set to the beginning. If playerPos specifies a + * position after the end of the track, the position will be set to the + * end. + * @param playerPos The player's position within the currently playing + * track in seconds. + */ + public void setPlayerPosition(int playerPos) { + iTunes.setProperty("playerPosition", playerPos); + } + + /** + * Returns the player's position within the currently playing track in + * seconds. + * @return The player's position within the currently playing track in + * seconds. + */ + public int getPlayerPosition() { + return iTunes.getPropertyAsInt("playerPosition"); + } + + /** + * Returns the source that represents the main library. + * You can also find the main library source by iterating over + * iTunes.getSources() and looking for an ITSource + * of kind ITSourceKindLibrary. + * @return Returns the source that represents the main library. + */ + public ITSource getLibrarySource() { + Dispatch lsource = iTunes.getProperty("LibrarySource").toDispatch(); + return new ITSource(lsource); + } + + /** + * Returns the main library playlist in the main library source. + * @return An IITLibraryPlaylist object corresponding to the main library + * playlist. + */ + public ITLibraryPlaylist getLibraryPlaylist() { + Dispatch lplaylist = iTunes.getProperty("LibraryPlaylist").toDispatch(); + return new ITLibraryPlaylist(lplaylist); + } + + /** + * Returns the currently targetd track. + * @return An ITTrack object corresponding to the currently targeted track. + * Will be set to NULL if there is no currently targeted track. + */ + public ITTrack getCurrentTrack() { + Dispatch item = iTunes.getProperty("CurrentTrack").toDispatch(); + ITTrack track = new ITTrack(item); + if (track.getKind()==ITTrackKind.ITTrackKindFile) { + return new ITFileOrCDTrack(item); + } else if (track.getKind()==ITTrackKind.ITTrackKindCD) { + return new ITFileOrCDTrack(item); + } else if (track.getKind()==ITTrackKind.ITTrackKindURL ) { + return new ITURLTrack(item); + } else { + return track; + } + } + + /** + * Returns the playlist containing the currently targeted track. + * @return An ITPlaylist object corresponding to the playlist containing the + * currently targeted track. + * Will be set to NULL if there is no currently targeted playlist. + */ + public ITPlaylist getCurrentPlaylist() { + Dispatch cplaylist = iTunes.getProperty("CurrentPlaylist").toDispatch(); + ITPlaylist playlist = new ITPlaylist(cplaylist); + ITPlaylistKind playlistKind = playlist.getKind(); + if (playlistKind == ITPlaylistKind.ITPlaylistKindCD) + return new ITAudioCDPlaylist(cplaylist); + else if (playlist.getKind() == ITPlaylistKind.ITPlaylistKindLibrary) + return new ITLibraryPlaylist(cplaylist); + else if (playlist.getKind() == ITPlaylistKind.ITPlaylistKindUser) + return new ITUserPlaylist(cplaylist); + else + return playlist; + } + + /** + * Returns a collection containing the currently selected track or tracks. + * The frontmost visible window in iTunes must be a browser or playlist + * window. If there is no frontmost visible window (e.g. iTunes is minimized + * to the system tray), the main browser window is used. + * @return Collection of ITrack objects. + * Will be set to NULL if there is no current selection. + */ + public ITTrackCollection getSelectedTracks() { + Dispatch stracks = iTunes.getProperty("SelectedTracks").toDispatch(); + return new ITTrackCollection(stracks); + } + + /** + * Returns the version of the iTunes application. + * @return + */ + public String getVersion() { + return iTunes.getPropertyAsString("Version"); + } + + /** + * Returns the high 32 bits of the persistent ID of the specified IITObject. + * See the documentation on IITObject for more information on persistent + * IDs. + * + * The object may be a source, playlist, or track. + * @param iObject The object to fetch the High Persistent ID. + * @return The high 32 bits of the 64-bit persistent ID. + */ + public long getITObjectPersistentIDHigh (ITObject iObject) { + Dispatch object = iObject.fetchDispatch(); + return Dispatch.call(object, "GetObjectPersistentIDHigh", object).getLong(); + } + + /** + * Returns the low 32 bits of the persistent ID of the specified IITObject. + * See the documentation on IITObject for more information on persistent + * IDs. + * + * The object may be a source, playlist, or track. + * @param iObject The object to fetch the Low Persistent ID. + * @return The low 32 bits of the 64-bit persistent ID. + */ + public long getITObjectPersistentIDLow (ITObject iObject) { + Dispatch object = iObject.fetchDispatch(); + return Dispatch.call(object, "GetObjectPersistentIDLow", object).getLong(); + } + + public ITObjectPersistentID getObjectPersistentIDs(ITObject iObject){ + return new ITObjectPersistentID(getITObjectPersistentIDHigh(iObject),getITObjectPersistentIDLow(iObject)); + } + + public ITBrowserWindow getBrowserWindow(){ + Dispatch window = iTunes.getProperty("BrowserWindow").toDispatch(); + return new ITBrowserWindow(window); + } +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEvents.java b/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEvents.java new file mode 100644 index 0000000..ddbee23 --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEvents.java @@ -0,0 +1,62 @@ +package com.dt.iTunesController; +import com.jacob.com.Dispatch; +import com.jacob.com.Variant; + +/** + * This class is used to forward all iTunes COM Events to a class that + * implements iTunesEventsInterface. To receive events, create + * a class that implements the interface, and then use + * iTunes.addEventHandler(). + * + * @author Steve Eyre + * @version 0.2 + */ +public class iTunesEvents { + + private iTunesEventsInterface eventHandler; + + public iTunesEvents (iTunesEventsInterface itef) { + eventHandler = itef; + } + + public void OnDatabaseChangedEvent(Variant[] args) { + // Not currently implemented + } + + public void OnPlayerPlayEvent(Variant[] args) { + ITTrack itt = new ITTrack((Dispatch)args[0].getDispatch()); + eventHandler.onPlayerPlayEvent(itt); + } + + public void OnPlayerStopEvent(Variant[] args) { + ITTrack itt = new ITTrack((Dispatch)args[0].getDispatch()); + eventHandler.onPlayerStopEvent(itt); + } + + public void OnPlayerPlayingTrackChangedEvent(Variant[] args) { + ITTrack itt = new ITTrack((Dispatch)args[0].getDispatch()); + eventHandler.onPlayerPlayingTrackChangedEvent(itt); + } + + public void OnCOMCallsDisabledEvent(Variant[] args) { + ITCOMDisabledReason reason = ITCOMDisabledReason.values()[args[0].getInt()]; + eventHandler.onCOMCallsDisabledEvent(reason); + } + + public void OnCOMCallsEnabledEvent(Variant[] args) { + eventHandler.onCOMCallsEnabledEvent(); + } + + public void OnQuittingEvent(Variant[] args) { + eventHandler.onQuittingEvent(); + } + + public void OnAboutToPromptUserToQuitEvent(Variant[] args) { + eventHandler.onAboutToPromptUserToQuitEvent(); + } + + public void OnSoundVolumeChangedEvent(Variant[] args) { + eventHandler.onSoundVolumeChangedEvent(args[0].getInt()); + } + +} diff --git a/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEventsInterface.java b/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEventsInterface.java new file mode 100644 index 0000000..3d8f17e --- /dev/null +++ b/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEventsInterface.java @@ -0,0 +1,115 @@ +package com.dt.iTunesController; + +/** + * Interface for receiving iTunes events. + * @author Steve Eyre + * @version 0.2 + */ +public interface iTunesEventsInterface { + + /** + * Not currently implemented. + * + * The ITEventDatabaseChanged event is fired when the iTunes database is + * changed. + * + * Each parameter is a two-dimensional array of integers. The first + * dimension is the number of objects. The second dimension is always 4 and + * specifies each of the 4 ITObject IDs, where index 0 is the source ID, + * index 1 is the playlist ID, index 2 is the track ID, and index 3 is the + * track database ID. For more information on object IDs, see + * ITObject. + * + * Note that you can use iTunes.getITObjectByID() to retrieve + * changed ITObject, but not for deleted objects (since they no longer + * exist). + * + * @param deletedObjectIDs + * @param changedObjectIDs + */ + public void onDatabaseChangedEvent(int[][] deletedObjectIDs, int[][] changedObjectIDs); + + /** + * The ITEventPlayerPlay event is fired when a track begins playing. + * @param iTrack An ITTrack object corresponding to the track that has + * started playing. + */ + public void onPlayerPlayEvent (ITTrack iTrack); + + /** + * The ITEventPlayerStop event is fired when a track stops playing. + * @param iTrack An ITTrack object corresponding to the track that has + * stopped playing. + */ + public void onPlayerStopEvent (ITTrack iTrack); + + /** + * The ITEventPlayerPlayingTrackChanged event is fired when information + * about the currently playing track has changed. + * This event is fired when the user changes information about the currently + * playing track (e.g. the name of the track). + * This event is also fired when iTunes plays the next joined CD track in a + * CD playlist, since joined CD tracks are treated as a single track. + * @param iTrack An ITTrack object corresponding to the track that is now + * playing. + */ + public void onPlayerPlayingTrackChangedEvent(ITTrack iTrack); + + /** + * The ITEventCOMCallsDisabled event is fired when calls to the iTunes COM + * interface will be deferred. + * Typically, iTunes will defer COM calls when any modal dialog is being + * displayed. When the user dismisses the last modal dialog, COM calls will + * be enabled again, and any deferred COM calls will be executed. You can + * use this event to avoid making a COM call which will be deferred. + * @param reason The reason the COM interface is being disabled. This is + * typically ITCOMDisabledReasonDialog. + */ + public void onCOMCallsDisabledEvent(ITCOMDisabledReason reason); + + /** + * The ITEventCOMCallsEnabled event is fired when calls to the iTunes COM + * interface will no longer be deferred. + * Typically, iTunes will defer COM calls when any modal dialog is being + * displayed. When the user dismisses the last modal dialog, COM calls will + * be enabled again, and any deferred COM calls will be executed. + */ + public void onCOMCallsEnabledEvent(); + + /** + * The ITEventQuitting event is fired when iTunes is about to quit. + * If the user attempts to quit iTunes while a client still has outstanding + * iTunes COM objects instantiated, iTunes will display a warning dialog. + * The user can still choose to quit iTunes anyway, in which case this event + * will be fired. After this event is fired, any existing iTunes COM objects + * will no longer be valid. + * This event is only used to notify clients that iTunes is quitting, + * clients cannot prevent this from happening. + */ + public void onQuittingEvent(); + + /** + * The ITEventAboutToPromptUserToQuit event is fired when iTunes is about + * prompt the user to quit. + * This event gives clients the opportunity to prevent the warning dialog + * prompt from occurring. + * If the user attempts to quit iTunes while a client still has outstanding + * iTunes COM objects instantiated, iTunes will display a warning dialog. + * This event is fired just before the warning dialog is shown. iTunes will + * then wait up to 5 seconds for clients to release any outstanding iTunes + * COM objects. If all objects are released during this time, the warning + * dialog will not be shown and iTunes will quit immediately. + * Otherwise, the warning dialog will be shown. If the user chooses to quit + * iTunes anyway, the ITEventQuitting event is fired. See + * iTunesEventsInterface.onQuittingEvent() for more details. + */ + public void onAboutToPromptUserToQuitEvent(); + + /** + * The ITEventSoundVolumeChanged event is fired when the sound output volume + * has changed. + * @param newVolume The new sound output volume (0 = minimum, 100 = maximum). + */ + public void onSoundVolumeChangedEvent(int newVolume); + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXComponent.java b/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXComponent.java new file mode 100644 index 0000000..4d0096b --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXComponent.java @@ -0,0 +1,479 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.activeX; + +import com.jacob.com.Dispatch; +import com.jacob.com.JacobObject; +import com.jacob.com.Variant; + +/** + * This class provides a higher level, more object like, wrapper for top of the + * Dispatch object. The Dispatch class's method essentially directly map to + * Microsoft C API including the first parameter that is almost always the + * target of the message. ActiveXComponent assumes the target of every message + * is the MS COM object behind the ActiveXComponent. This removes the need to + * pass the Dispatch object into every method. + *

+ * It is really up to the developer as to whether they want to use the Dispatch + * interface or the ActiveXComponent interface. + *

+ * This class simulates com.ms.activeX.ActiveXComponent only in the sense that + * it is used for creating Dispatch objects + */ +public class ActiveXComponent extends Dispatch { + + /** + * Normally used to create a new connection to a microsoft application. The + * passed in parameter is the name of the program as registered in the + * registry. It can also be the object name. + *

+ * This constructor causes a new Windows object of the requested type to be + * created. The windows CoCreate() function gets called to create the + * underlying windows object. + * + *

+	 * new ActiveXComponent("ScriptControl");
+	 * 
+ * + * @param programId + */ + public ActiveXComponent(String programId) { + super(programId); + } + + /** + * Creates an active X component that is built on top of the COM pointers + * held in the passed in dispatch. This widens the Dispatch object to pick + * up the ActiveXComponent API + * + * @param dispatchToBeWrapped + */ + public ActiveXComponent(Dispatch dispatchToBeWrapped) { + super(dispatchToBeWrapped); + } + + /** + * only used by the factories + * + */ + private ActiveXComponent() { + super(); + } + + /** + * Probably was a cover for something else in the past. Should be + * deprecated. + * + * @return Now it actually returns this exact same object. + */ + public Dispatch getObject() { + return this; + } + + /** + * Most code should use the standard ActiveXComponent(String) contructor and + * not this factory method. This method exists for applications that need + * special behavior. Experimental in release 1.9.2. + *

+ * Factory that returns a Dispatch object wrapped around the result of a + * CoCreate() call. This differs from the standard constructor in that it + * throws no exceptions and returns null on failure. + *

+ * This will fail for any prog id with a ":" in it. + * + * @param pRequestedProgramId + * @return Dispatch pointer to the COM object or null if couldn't create + */ + public static ActiveXComponent createNewInstance(String pRequestedProgramId) { + ActiveXComponent mCreatedDispatch = null; + try { + mCreatedDispatch = new ActiveXComponent(); + mCreatedDispatch.coCreateInstance(pRequestedProgramId); + } catch (Exception e) { + mCreatedDispatch = null; + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("Unable to co-create instance of " + + pRequestedProgramId); + } + } + return mCreatedDispatch; + } + + /** + * Most code should use the standard ActiveXComponent(String) constructor + * and not this factory method. This method exists for applications that + * need special behavior. Experimental in release 1.9.2. + *

+ * Factory that returns a Dispatch wrapped around the result of a + * getActiveObject() call. This differs from the standard constructor in + * that it throws no exceptions and returns null on failure. + *

+ * This will fail for any prog id with a ":" in it + * + * @param pRequestedProgramId + * @return Dispatch pointer to a COM object or null if wasn't already + * running + */ + public static ActiveXComponent connectToActiveInstance( + String pRequestedProgramId) { + ActiveXComponent mCreatedDispatch = null; + try { + mCreatedDispatch = new ActiveXComponent(); + mCreatedDispatch.getActiveInstance(pRequestedProgramId); + } catch (Exception e) { + mCreatedDispatch = null; + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("Unable to attach to running instance of " + + pRequestedProgramId); + } + } + return mCreatedDispatch; + } + + /** + * @see com.jacob.com.Dispatch#finalize() + */ + @Override + protected void finalize() { + super.finalize(); + } + + /* + * ============================================================ + * + * start of instance based calls to the COM layer + * =========================================================== + */ + + /** + * retrieves a property and returns it as a Variant + * + * @param propertyName + * @return variant value of property + */ + public Variant getProperty(String propertyName) { + return Dispatch.get(this, propertyName); + } + + /** + * retrieves a property and returns it as an ActiveX component + * + * @param propertyName + * @return Dispatch representing the object under the property name + */ + public ActiveXComponent getPropertyAsComponent(String propertyName) { + return new ActiveXComponent(Dispatch.get(this, propertyName) + .toDispatch()); + + } + + /** + * retrieves a property and returns it as a Boolean + * + * @param propertyName + * property we are looking up + * @return boolean value of property + */ + public boolean getPropertyAsBoolean(String propertyName) { + return Dispatch.get(this, propertyName).getBoolean(); + } + + /** + * retrieves a property and returns it as a byte + * + * @param propertyName + * property we are looking up + * @return byte value of property + */ + public byte getPropertyAsByte(String propertyName) { + return Dispatch.get(this, propertyName).getByte(); + } + + /** + * retrieves a property and returns it as a String + * + * @param propertyName + * @return String value of property + */ + public String getPropertyAsString(String propertyName) { + return Dispatch.get(this, propertyName).getString(); + + } + + /** + * retrieves a property and returns it as a int + * + * @param propertyName + * @return the property value as an int + */ + public int getPropertyAsInt(String propertyName) { + return Dispatch.get(this, propertyName).getInt(); + } + + /** + * sets a property on this object + * + * @param propertyName + * property name + * @param arg + * variant value to be set + */ + public void setProperty(String propertyName, Variant arg) { + Dispatch.put(this, propertyName, arg); + } + + /** + * sets a property on this object + * + * @param propertyName + * property name + * @param arg + * variant value to be set + */ + public void setProperty(String propertyName, Dispatch arg) { + Dispatch.put(this, propertyName, arg); + } + + /** + * sets a property to be the value of the string + * + * @param propertyName + * @param propertyValue + */ + public void setProperty(String propertyName, String propertyValue) { + this.setProperty(propertyName, new Variant(propertyValue)); + } + + /** + * sets a property as a boolean value + * + * @param propertyName + * @param propValue + * the boolean value we want the prop set to + */ + public void setProperty(String propertyName, boolean propValue) { + this.setProperty(propertyName, new Variant(propValue)); + } + + /** + * sets a property as a boolean value + * + * @param propertyName + * @param propValue + * the boolean value we want the prop set to + */ + public void setProperty(String propertyName, byte propValue) { + this.setProperty(propertyName, new Variant(propValue)); + } + + /** + * sets the property as an int value + * + * @param propertyName + * @param propValue + * the int value we want the prop to be set to. + */ + public void setProperty(String propertyName, int propValue) { + this.setProperty(propertyName, new Variant(propValue)); + } + + /*------------------------------------------------------- + * Listener logging helpers + *------------------------------------------------------- + */ + + /** + * This boolean determines if callback events should be logged + */ + public static boolean shouldLogEvents = false; + + /** + * used by the doc and application listeners to get intelligent logging + * + * @param description + * event description + * @param args + * args passed in (variants) + * + */ + public void logCallbackEvent(String description, Variant[] args) { + String argString = ""; + if (args != null && ActiveXComponent.shouldLogEvents) { + if (args.length > 0) { + argString += " args: "; + } + for (int i = 0; i < args.length; i++) { + short argType = args[i].getvt(); + argString += ",[" + i + "]"; + // break out the byref bits if they are on this + if ((argType & Variant.VariantByref) == Variant.VariantByref) { + // show the type and the fact that its byref + argString += "(" + + (args[i].getvt() & ~Variant.VariantByref) + "/" + + Variant.VariantByref + ")"; + } else { + // show the type + argString += "(" + argType + ")"; + } + argString += "="; + if (argType == Variant.VariantDispatch) { + Dispatch foo = (args[i].getDispatch()); + argString += foo; + } else if ((argType & Variant.VariantBoolean) == Variant.VariantBoolean) { + // do the boolean thing + if ((argType & Variant.VariantByref) == Variant.VariantByref) { + // boolean by ref + argString += args[i].getBooleanRef(); + } else { + // boolean by value + argString += args[i].getBoolean(); + } + } else if ((argType & Variant.VariantString) == Variant.VariantString) { + // do the string thing + if ((argType & Variant.VariantByref) == Variant.VariantByref) { + // string by ref + argString += args[i].getStringRef(); + } else { + // string by value + argString += args[i].getString(); + } + } else { + argString += args[i].toString(); + } + } + System.out.println(description + argString); + } + } + + /* + * ============================================================== + * + * covers for dispatch call methods + * ============================================================= + */ + + /** + * makes a dispatch call for the passed in action and no parameter + * + * @param callAction + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction) { + return new ActiveXComponent(invoke(callAction).toDispatch()); + } + + /** + * makes a dispatch call for the passed in action and single parameter + * + * @param callAction + * @param parameters + * @return ActiveXComponent representing the results of the call + */ + public ActiveXComponent invokeGetComponent(String callAction, + Variant... parameters) { + return new ActiveXComponent(invoke(callAction, parameters).toDispatch()); + } + + /** + * invokes a single parameter call on this dispatch that returns no value + * + * @param actionCommand + * @param parameter + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String actionCommand, String parameter) { + return Dispatch.call(this, actionCommand, parameter); + } + + /** + * makes a dispatch call to the passed in action with a single boolean + * parameter + * + * @param actionCommand + * @param parameter + * @return Variant result + */ + public Variant invoke(String actionCommand, boolean parameter) { + return Dispatch.call(this, actionCommand, new Variant(parameter)); + } + + /** + * makes a dispatch call to the passed in action with a single int parameter + * + * @param actionCommand + * @param parameter + * @return Variant result of the invoke (Dispatch.call) + */ + public Variant invoke(String actionCommand, int parameter) { + return Dispatch.call(this, actionCommand, new Variant(parameter)); + } + + /** + * makes a dispatch call to the passed in action with a string and integer + * parameter (this was put in for some application) + * + * @param actionCommand + * @param parameter1 + * @param parameter2 + * @return Variant result + */ + public Variant invoke(String actionCommand, String parameter1, + int parameter2) { + return Dispatch.call(this, actionCommand, parameter1, new Variant( + parameter2)); + } + + /** + * makes a dispatch call to the passed in action with two integer parameters + * (this was put in for some application) + * + * @param actionCommand + * @param parameter1 + * @param parameter2 + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String actionCommand, int parameter1, int parameter2) { + return Dispatch.call(this, actionCommand, new Variant(parameter1), + new Variant(parameter2)); + } + + /** + * makes a dispatch call for the passed in action and no parameter + * + * @param callAction + * @return a Variant but that may be null for some calls + */ + public Variant invoke(String callAction) { + return Dispatch.call(this, callAction); + } + + /** + * This is really a cover for call(String,Variant[]) that should be + * eliminated call with a variable number of args mainly used for quit. + * + * @param name + * @param args + * @return Variant returned by the invoke (Dispatch.callN) + */ + public Variant invoke(String name, Variant... args) { + return Dispatch.callN(this, name, args); + } + +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXDispatchEvents.java b/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXDispatchEvents.java new file mode 100644 index 0000000..16bb649 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXDispatchEvents.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.activeX; + +import com.jacob.com.Dispatch; +import com.jacob.com.DispatchEvents; +import com.jacob.com.InvocationProxy; + +/** + * RELEASE 1.12 EXPERIMENTAL. + *

+ * Use this exactly like the DispatchEvents class. This class plugs in an + * ActiveXInvocationProxy instead of an InvocationProxy. It is the + * ActiveXInvocationProxy that implements the reflection calls and invoke the + * found java event callbacks. See ActiveXInvocationProxy for details. + * + * + */ +public class ActiveXDispatchEvents extends DispatchEvents { + + /** + * This is the most commonly used constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + */ + public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink) { + super(sourceOfEvent, eventSink, null); + } + + /** + * None of the samples use this constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + * @param progId + * ??? + */ + public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink, + String progId) { + super(sourceOfEvent, eventSink, progId, null); + } + + /** + * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + * + *

+	 * >ActiveXDispatchEvents de = 
+	 * 			new ActiveXDispatchEvents(someDispatch,someEventHAndler,
+	 * 				"Excel.Application",
+	 * 				"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
+	 * 
+	 * @param sourceOfEvent Dispatch object who's MS app will generate callbacks
+	 * @param eventSink Java object that wants to receive the events
+	 * @param progId , mandatory if the typelib is specified
+	 * @param typeLib The location of the typelib to use
+	 * 
+	 */
+	public ActiveXDispatchEvents(Dispatch sourceOfEvent, Object eventSink,
+			String progId, String typeLib) {
+		super(sourceOfEvent, eventSink, progId, typeLib);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see com.jacob.com.DispatchEvents#getInvocationProxy(java.lang.Object)
+	 */
+	protected InvocationProxy getInvocationProxy(Object pTargetObject) {
+		InvocationProxy newProxy = new ActiveXInvocationProxy();
+		newProxy.setTarget(pTargetObject);
+		return newProxy;
+	}
+
+}
diff --git a/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXInvocationProxy.java b/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXInvocationProxy.java
new file mode 100644
index 0000000..94c4f31
--- /dev/null
+++ b/vendor/jacob/1.15-M4/java/com/jacob/activeX/ActiveXInvocationProxy.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright (c) 1999-2004 Sourceforge JACOB Project.
+ * All rights reserved. Originator: Dan Adler (http://danadler.com).
+ * Get more information about JACOB at http://sourceforge.net/projects/jacob-project
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+package com.jacob.activeX;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import com.jacob.com.InvocationProxy;
+import com.jacob.com.NotImplementedException;
+import com.jacob.com.Variant;
+
+/**
+ * RELEASE 1.12 EXPERIMENTAL.
+ * 

+ * This class that lets event handlers receive events with all java objects as + * parameters. The standard Jacob event methods all accept an array of Variant + * objects. When using this class, you can set up your event methods as regular + * java methods with the correct number of parameters of the correct java type. + * This does NOT work for any event that wishes to accept a call back and modify + * the calling parameters to tell windows what to do. An example is when an + * event lets the receiver cancel the action by setting a boolean flag to false. + * The java objects cannot be modified and their values will not be passed back + * into the originating Variants even if they could be modified. + *

+ * This class acts as a proxy between the windows event callback mechanism and + * the Java classes that are looking for events. It assumes that all of the Java + * classes that are looking for events implement methods with the same names as + * the windows events and that the implemented methods native java objects of + * the type and order that match the windows documentation. The methods can + * return void or a Variant that will be returned to the calling layer. All + * Event methods that will be recognized by InvocationProxyAllEvents have the + * signature + * + * void eventMethodName(Object,Object...) or + * Object eventMethodName(Object,Object...) + */ +public class ActiveXInvocationProxy extends InvocationProxy { + + /* + * (non-Javadoc) + * + * @see com.jacob.com.InvocationProxy#invoke(java.lang.String, + * com.jacob.com.Variant[]) + */ + @SuppressWarnings("unchecked") + public Variant invoke(String methodName, Variant targetParameters[]) { + Variant mVariantToBeReturned = null; + if (mTargetObject == null) { + // structured programming guidlines say this return should not be up + // here + return null; + } + Class targetClass = mTargetObject.getClass(); + if (methodName == null) { + throw new IllegalArgumentException( + "InvocationProxy: missing method name"); + } + if (targetParameters == null) { + throw new IllegalArgumentException( + "InvocationProxy: missing Variant parameters"); + } + try { + Method targetMethod; + Object parametersAsJavaObjects[] = getParametersAsJavaObjects(targetParameters); + Class parametersAsJavaClasses[] = getParametersAsJavaClasses(parametersAsJavaObjects); + targetMethod = targetClass.getMethod(methodName, + parametersAsJavaClasses); + if (targetMethod != null) { + // protected classes can't be invoked against even if they + // let you grab the method. you could do + // targetMethod.setAccessible(true); + // but that should be stopped by the security manager + Object mReturnedByInvocation = null; + mReturnedByInvocation = targetMethod.invoke(mTargetObject, + parametersAsJavaObjects); + if (mReturnedByInvocation == null) { + mVariantToBeReturned = null; + } else if (!(mReturnedByInvocation instanceof Variant)) { + mVariantToBeReturned = new Variant(mReturnedByInvocation); + } else { + mVariantToBeReturned = (Variant) mReturnedByInvocation; + } + } + } catch (SecurityException e) { + // what causes this exception? + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // this happens whenever the listener doesn't implement all the + // methods + } catch (IllegalArgumentException e) { + // we can throw these inside the catch block so need to re-throw it + Exception oneWeShouldToss = new IllegalArgumentException( + "Unable to map parameters for method " + methodName + ": " + + e.toString()); + oneWeShouldToss.printStackTrace(); + } catch (IllegalAccessException e) { + // can't access the method on the target instance for some reason + e.printStackTrace(); + } catch (InvocationTargetException e) { + // invocation of target method failed + e.printStackTrace(); + } + return mVariantToBeReturned; + + } + + /** + * creates a method signature compatible array of classes from an array of + * parameters + * + * @param parametersAsJavaObjects + * @return + */ + @SuppressWarnings("unchecked") + private Class[] getParametersAsJavaClasses(Object[] parametersAsJavaObjects) { + if (parametersAsJavaObjects == null) { + throw new IllegalArgumentException( + "This only works with an array of parameters"); + } + int numParameters = parametersAsJavaObjects.length; + Class parametersAsJavaClasses[] = new Class[numParameters]; + for (int parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) { + Object oneParameterObject = parametersAsJavaObjects[parameterIndex]; + if (oneParameterObject == null) { + parametersAsJavaClasses[parameterIndex] = null; + } else { + Class oneParameterClass = oneParameterObject.getClass(); + parametersAsJavaClasses[parameterIndex] = oneParameterClass; + } + } + return parametersAsJavaClasses; + } + + /** + * converts an array of Variants to their associated Java types + * + * @param targetParameters + * @return + */ + private Object[] getParametersAsJavaObjects(Variant[] targetParameters) { + if (targetParameters == null) { + throw new IllegalArgumentException( + "This only works with an array of parameters"); + } + int numParameters = targetParameters.length; + Object parametersAsJavaObjects[] = new Object[numParameters]; + for (int parameterIndex = 0; parameterIndex < numParameters; parameterIndex++) { + Variant oneParameterObject = targetParameters[parameterIndex]; + if (oneParameterObject == null) { + parametersAsJavaObjects[parameterIndex] = null; + } else { + try { + parametersAsJavaObjects[parameterIndex] = oneParameterObject + .toJavaObject(); + } catch (NotImplementedException nie) { + throw new IllegalArgumentException( + "Can't convert parameter " + parameterIndex + + " type " + oneParameterObject.getvt() + + " to java object: " + nie.getMessage()); + } + } + } + return parametersAsJavaObjects; + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/ComException.java b/vendor/jacob/1.15-M4/java/com/jacob/com/ComException.java new file mode 100644 index 0000000..8632577 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/ComException.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * Standard exception thrown by com jni code when there is a problem + */ +public abstract class ComException extends JacobException { + + /** + * COM code initializes this filed with an appropriate return code that was + * returned by the underlying com code + */ + protected int hr; + /** + * No documentation is available at this time. Someone should document this + * field + */ + protected int m_helpContext; + /** + * No documentation is available at this time. Someone should document this + * field + */ + protected String m_helpFile; + /** + * No documentation is available at this time. Someone should document this + * field + */ + protected String m_source; + + /** + * constructor + * + */ + public ComException() { + super(); + } + + /** + * constructor with error code? + * + * @param newHr ?? + */ + public ComException(int newHr) { + super(); + this.hr = newHr; + } + + /** + * @param newHr + * @param description + */ + public ComException(int newHr, String description) { + super(description); + this.hr = newHr; + } + + /** + * @param newHr + * @param source + * @param helpFile + * @param helpContext + */ + public ComException(int newHr, String source, String helpFile, + int helpContext) { + super(); + this.hr = newHr; + m_source = source; + m_helpFile = helpFile; + m_helpContext = helpContext; + } + + /** + * @param newHr + * @param description + * @param source + * @param helpFile + * @param helpContext + */ + public ComException(int newHr, String description, String source, + String helpFile, int helpContext) { + super(description); + this.hr = newHr; + m_source = source; + m_helpFile = helpFile; + m_helpContext = helpContext; + } + + /** + * @param description + */ + public ComException(String description) { + super(description); + } + + /** + * @return int representation of the help context + */ + // Methods + public int getHelpContext() { + return m_helpContext; + } + + /** + * @return String ??? help file + */ + public String getHelpFile() { + return m_helpFile; + } + + /** + * @return int hr result ?? + */ + public int getHResult() { + return hr; + } + + /** + * @return String source ?? + */ + public String getSource() { + return m_source; + } +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/ComFailException.java b/vendor/jacob/1.15-M4/java/com/jacob/com/ComFailException.java new file mode 100644 index 0000000..20ce1a8 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/ComFailException.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * COM Fail Exception class raised when there is a problem + */ +public class ComFailException extends ComException { + /** + * eclipse generated to get rid of a wanring + */ + private static final long serialVersionUID = -266047261992987700L; + + /** + * Constructor + * + * @param hrNew + */ + public ComFailException(int hrNew) { + super(hrNew); + } + + /** + * Constructor + * + * @param hrNew + * @param message + */ + public ComFailException(int hrNew, String message) { + super(hrNew, message); + } + + /** + * @param hrNew + * @param source + * @param helpFile + * @param helpContext + */ + public ComFailException(int hrNew, String source, String helpFile, + int helpContext) { + super(hrNew, source, helpFile, helpContext); + } + + /** + * Constructor + * + * @param hrNew + * @param description + * @param source + * @param helpFile + * @param helpContext + */ + public ComFailException(int hrNew, String description, String source, + String helpFile, int helpContext) { + super(hrNew, description, source, helpFile, helpContext); + } + + /** + * No argument Constructor + */ + public ComFailException() { + super(); + } + + /** + * @param message + */ + public ComFailException(String message) { + super(message); + } +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/ComThread.java b/vendor/jacob/1.15-M4/java/com/jacob/com/ComThread.java new file mode 100644 index 0000000..aeee598 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/ComThread.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * Represents a COM level thread This is an abstract class because all the + * methods are static and no instances are ever created. + */ +public abstract class ComThread { + private static final int MTA = 0x0; + + private static final int STA = 0x2; + + /** + * Comment for haveSTA + */ + public static boolean haveSTA = false; + + /** + * Comment for mainSTA + */ + public static MainSTA mainSTA = null; + + /** + * Initialize the current java thread to be part of the Multi-threaded COM + * Apartment + */ + public static synchronized void InitMTA() { + InitMTA(false); + } + + /** + * Initialize the current java thread to be an STA + */ + public static synchronized void InitSTA() { + InitSTA(false); + } + + /** + * Initialize the current java thread to be part of the Multi-threaded COM + * Apartment, if createMainSTA is true, create a separate MainSTA thread + * that will house all Apartment Threaded components + * + * @param createMainSTA + */ + public static synchronized void InitMTA(boolean createMainSTA) { + Init(createMainSTA, MTA); + } + + /** + * Initialize the current java thread to be an STA COM Apartment, if + * createMainSTA is true, create a separate MainSTA thread that will house + * all Apartment Threaded components + * + * @param createMainSTA + */ + public static synchronized void InitSTA(boolean createMainSTA) { + Init(createMainSTA, STA); + } + + /** + * + */ + public static synchronized void startMainSTA() { + mainSTA = new MainSTA(); + haveSTA = true; + } + + /** + * + */ + public static synchronized void quitMainSTA() { + if (mainSTA != null) + mainSTA.quit(); + } + + /** + * Initialize the current java thread to be part of the MTA/STA COM + * Apartment + * + * @param createMainSTA + * @param mode + */ + public static synchronized void Init(boolean createMainSTA, int mode) { + if (createMainSTA && !haveSTA) { + // if the current thread is going to be in the MTA and there + // is no STA thread yet, then create a main STA thread + // to avoid COM creating its own + startMainSTA(); + } + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ComThread: before Init: " + mode); + } + doCoInitialize(mode); + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ComThread: after Init: " + mode); + } + ROT.addThread(); + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ComThread: after ROT.addThread: " + mode); + } + } + + /** + * Call CoUninitialize to release this java thread from COM + */ + public static synchronized void Release() { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ComThread: before clearObjects"); + } + ROT.clearObjects(); + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ComThread: before UnInit"); + } + doCoUninitialize(); + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ComThread: after UnInit"); + } + } + + /** + * @deprecated the java model leave the responsibility of clearing up + * objects to the Garbage Collector. Our programming model + * should not require that the user specifically remove object + * from the thread. + * + * This will remove an object from the ROT + * @param o + */ + @Deprecated + public static synchronized void RemoveObject(JacobObject o) { + ROT.removeObject(o); + } + + /** + * @param threadModel + */ + public static native void doCoInitialize(int threadModel); + + /** + * + */ + public static native void doCoUninitialize(); + + /** + * load the Jacob DLL. We do this in case COMThread is called before any + * other reference to one of the JacboObject subclasses is made. + */ + static { + LibraryLoader.loadJacobLibrary(); + } +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/Currency.java b/vendor/jacob/1.15-M4/java/com/jacob/com/Currency.java new file mode 100644 index 0000000..749506c --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/Currency.java @@ -0,0 +1,91 @@ +package com.jacob.com; + +/** + * Most COM bridges use java.lang.Long as their Java data type for COM Currency + * data. This is because COM currency is a 64 bit number where the last 4 digits + * represent the milli-cents. We wanted to support 64 bit Long values for x64 + * platforms so that meant we wanted to map Java.LONG to COM.LONG even though it + * only works for 64 bit platforms. The end result was we needed a new + * representation for Money so we have this. + *

+ * In the future, this should convert to and from BigDecimal or Double + */ +public class Currency { + Long embeddedValue = null; + + /** + * constructor that takes a long already in COM representation + * + * @param newValue + */ + public Currency(long newValue) { + embeddedValue = new Long(newValue); + } + + /** + * constructor that takes a String already in COM representation + * + * @param newValue + */ + public Currency(String newValue) { + embeddedValue = new Long(newValue); + } + + /** + * + * @return the currency as a primitive long + */ + public long longValue() { + return embeddedValue.longValue(); + } + + /** + * getter to the inner storage so that cmpareTo can work + * + * @return the embedded long value + */ + protected Long getLongValue() { + return embeddedValue; + } + + /** + * compares the values of two currencies + * + * @param anotherCurrency + * @return the usual compareTo results + */ + public int compareTo(Currency anotherCurrency) { + return embeddedValue.compareTo(anotherCurrency.getLongValue()); + } + + /** + * standard comparison + * + * @param o + * must be Currency or Long + * @return the usual compareTo results + */ + public int compareTo(Object o) { + if (o instanceof Currency) { + return compareTo((Currency) o); + } else if (o instanceof Long) { + return embeddedValue.compareTo((Long) o); + } else + throw new IllegalArgumentException( + "Can only compare to Long and Currency not " + + o.getClass().getName()); + } + + /** + * {@inheritDoc} + */ + public boolean equals(Object o) { + if (o == null) { + return false; + } else if (compareTo(o) == 0) { + return true; + } else { + return false; + } + } +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/DateUtilities.java b/vendor/jacob/1.15-M4/java/com/jacob/com/DateUtilities.java new file mode 100644 index 0000000..195ba33 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/DateUtilities.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +import java.util.Calendar; +import java.util.Date; + +/** + * java / windows date conversion utilities + * + * @author joe + * + */ +public class DateUtilities { + + /** + * converts a windows time to a Java Date Object + * + * @param comTime + * @return Date object representing the windows time as specified in comTime + */ + static public Date convertWindowsTimeToDate(double comTime) { + return new Date(convertWindowsTimeToMilliseconds(comTime)); + } + + /** + * Convert a COM time from functions Date(), Time(), Now() to a Java time + * (milliseconds). Visual Basic time values are based to 30.12.1899, Java + * time values are based to 1.1.1970 (= 0 milliseconds). The difference is + * added to the Visual Basic value to get the corresponding Java value. The + * Visual Basic double value reads: .<1 + * day percentage fraction>, e.g. "38100.6453" means: 38100 days since + * 30.12.1899 plus (24 hours * 0.6453). Example usage: + * Date javaDate = new Date(toMilliseconds (vbDate));. + * + * @param comTime + * COM time. + * @return Java time. + */ + static public long convertWindowsTimeToMilliseconds(double comTime) { + long result = 0; + + // code from jacobgen: + comTime = comTime - 25569D; + Calendar cal = Calendar.getInstance(); + result = Math.round(86400000L * comTime) + - cal.get(Calendar.ZONE_OFFSET); + cal.setTime(new Date(result)); + result -= cal.get(Calendar.DST_OFFSET); + + return result; + }// convertWindowsTimeToMilliseconds() + + /** + * converts a java date to a windows time object (is this timezone safe?) + * + * @param javaDate + * the java date to be converted to windows time + * @return the double representing the date in a form windows understands + */ + static public double convertDateToWindowsTime(Date javaDate) { + if (javaDate == null) { + throw new IllegalArgumentException( + "cannot convert null to windows time"); + } + return convertMillisecondsToWindowsTime(javaDate.getTime()); + } + + /** + * Convert a Java time to a COM time. + * + * @param milliseconds + * Java time. + * @return COM time. + */ + static public double convertMillisecondsToWindowsTime(long milliseconds) { + double result = 0.0; + + // code from jacobgen: + Calendar cal = Calendar.getInstance(); + cal.setTimeInMillis(milliseconds); + milliseconds += (cal.get(Calendar.ZONE_OFFSET) + cal + .get(Calendar.DST_OFFSET)); // add GMT offset + result = (milliseconds / 86400000D) + 25569D; + + return result; + }// convertMillisecondsToWindowsTime() +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/Dispatch.java b/vendor/jacob/1.15-M4/java/com/jacob/com/Dispatch.java new file mode 100644 index 0000000..4902c46 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/Dispatch.java @@ -0,0 +1,872 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. All rights reserved. Originator: Dan Adler + * (http://danadler.com). Get more information about JACOB at + * http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or modify it under the terms of the + * GNU Lesser General Public License as published by the Free Software Foundation; either version + * 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with this library; + * if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +package com.jacob.com; + +/** + * Object represents MS level dispatch object. Each instance of this points at + * some data structure on the MS windows side. + * + * + *

+ * You're going to live here a lot + */ +public class Dispatch extends JacobObject { + + /** + * Used to set the locale in a call. The user locale is another option + */ + public static final int LOCALE_SYSTEM_DEFAULT = 2048; + /** used by callN() and callSubN() */ + public static final int Method = 1; + /** used by callN() and callSubN() */ + public static final int Get = 2; + /** used by put() */ + public static final int Put = 4; + /** not used, probably intended for putRef() */ + public static final int PutRef = 8; + /** + * One of legal values for GetDispId. Not used in this layer and probably + * not needed. + */ + public static final int fdexNameCaseSensitive = 1; + + /** + * This is public because Dispatch.cpp knows its name and accesses it + * directly to get the dispatch id. You really can't rename it or make it + * private + */ + public int m_pDispatch; + + /** program Id passed in by ActiveX components in their constructor */ + private String programId = null; + + private static int NOT_ATTACHED = 0; + + /** + * Dummy empty array used one doesn't have to be created on every invocation + */ + private final static Object[] NO_OBJECT_ARGS = new Object[0]; + /** + * Dummy empty array used one doesn't have to be created on every invocation + */ + private final static Variant[] NO_VARIANT_ARGS = new Variant[0]; + /** + * Dummy empty array used one doesn't have to be created on every invocation + */ + private final static int[] NO_INT_ARGS = new int[0]; + + /** + * zero argument constructor that sets the dispatch pointer to 0 This is the + * only way to create a Dispatch without a value in the pointer field. + */ + public Dispatch() { + m_pDispatch = NOT_ATTACHED; + } + + /** + * This constructor calls createInstance with progid. This is the + * constructor used by the ActiveXComponent or by programs that don't like + * the activeX interface but wish to create new connections to windows + * programs. + *

+ * This constructor always creates a new windows/program object because it + * is based on the CoCreate() windows function. + *

+ * + * @param requestedProgramId + * @throws IllegalArgumentException + * if null is passed in as the program id + *

+ */ + public Dispatch(String requestedProgramId) { + programId = requestedProgramId; + if (programId != null && !"".equals(programId)) { + createInstanceNative(requestedProgramId); + } else { + throw new IllegalArgumentException( + "Dispatch(String) does not accept null or an empty string as a parameter"); + } + } + + /** + * native call createInstance only used by the constructor with the same + * parm type. This probably should be private. It is the wrapper for the + * Windows CoCreate() call + *

+ * This ends up calling CoCreate down in the JNI layer + *

+ * The behavior is different if a ":" character exists in the progId. In + * that case CoGetObject and CreateInstance (someone needs to describe this + * better) + * + * @param progid + */ + private native void createInstanceNative(String progid); + + /** + * native call getActiveInstance only used by the constructor with the same + * parm type. This probably should be private. It is the wrapper for the + * Windows GetActiveObject() call + *

+ * This ends up calling GetActiveObject down in the JNI layer + *

+ * This does not have the special behavior for program ids with ":" in them + * that createInstance has. + * + * @param progid + */ + private native void getActiveInstanceNative(String progid); + + /** + * Wrapper around the native method + * + * @param pProgramIdentifier + * name of the program you wish to connect to + */ + protected void getActiveInstance(String pProgramIdentifier) { + if (pProgramIdentifier == null || "".equals(pProgramIdentifier)) { + throw new IllegalArgumentException("program id is required"); + } + this.programId = pProgramIdentifier; + getActiveInstanceNative(pProgramIdentifier); + } + + /** + * native call coCreateInstance only used by the constructor with the same + * parm type. This probably should be private. It is the wrapper for the + * Windows CoCreate() call + *

+ * This ends up calling CoCreate down in the JNI layer + *

+ * This does not have the special behavior for program ids with ":" in them + * that createInstance has. + * + * @param progid + */ + private native void coCreateInstanceNative(String progid); + + /** + * Wrapper around the native method + * + * @param pProgramIdentifier + */ + protected void coCreateInstance(String pProgramIdentifier) { + if (pProgramIdentifier == null || "".equals(pProgramIdentifier)) { + throw new IllegalArgumentException("program id is required"); + } + this.programId = pProgramIdentifier; + coCreateInstanceNative(pProgramIdentifier); + } + + /** + * Return a different interface by IID string. + *

+ * Once you have a Dispatch object, you can navigate to the other interfaces + * of a COM object by calling QueryInterafce. The argument is an IID string + * in the format: "{9BF24410-B2E0-11D4-A695-00104BFF3241}". You typically + * get this string from the idl file (it's called uuid in there). Any + * interface you try to use must be derived from IDispatch. T The atl + * example uses this. + *

+ * The Dispatch instance resulting from this query is instanciated in the + * JNI code. + * + * @param iid + * @return Dispatch a disptach that matches ?? + */ + public native Dispatch QueryInterface(String iid); + + /** + * Constructor that only gets called from JNI QueryInterface calls JNI code + * that looks up the object for the key passed in. The JNI CODE then creates + * a new dispatch object using this constructor + * + * @param pDisp + */ + protected Dispatch(int pDisp) { + m_pDispatch = pDisp; + } + + /** + * Constructor to be used by subclass that want to swap themselves in for + * the default Dispatch class. Usually you will have a class like + * WordDocument that is a subclass of Dispatch and it will have a + * constructor public WordDocument(Dispatch). That constructor should just + * call this constructor as super(Dispatch) + * + * @param dispatchToBeDisplaced + */ + public Dispatch(Dispatch dispatchToBeDisplaced) { + // TAKE OVER THE IDispatch POINTER + this.m_pDispatch = dispatchToBeDisplaced.m_pDispatch; + // NULL OUT THE INPUT POINTER + dispatchToBeDisplaced.m_pDispatch = NOT_ATTACHED; + } + + /** + * returns the program id if an activeX component created this otherwise it + * returns null. This was added to aid in debugging + * + * @return the program id an activeX component was created against + */ + public String getProgramId() { + return programId; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + @Override + protected void finalize() { + safeRelease(); + } + + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + @Override + public void safeRelease() { + super.safeRelease(); + if (isAttached()) { + release(); + m_pDispatch = NOT_ATTACHED; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } + + /** + * + * @return true if there is an underlying windows dispatch object + */ + protected boolean isAttached() { + if (m_pDispatch == NOT_ATTACHED) { + return false; + } else { + return true; + } + } + + /** + * @param theOneInQuestion + * dispatch being tested + * @throws IllegalStateException + * if this dispatch isn't hooked up + * @throws IllegalArgumentException + * if null the dispatch under test is null + */ + private static void throwIfUnattachedDispatch(Dispatch theOneInQuestion) { + if (theOneInQuestion == null) { + throw new IllegalArgumentException( + "Can't pass in null Dispatch object"); + } else if (theOneInQuestion.isAttached()) { + return; + } else { + throw new IllegalStateException( + "Dispatch not hooked to windows memory"); + } + } + + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /** + * not implemented yet + * + * @param dispatchTarget + * @param name + * @param val + * @throws com.jacob.com.NotImplementedException + */ + public static void put_Casesensitive(Dispatch dispatchTarget, String name, + Object val) { + throw new NotImplementedException("not implemented yet"); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + // eliminate _Guid arg + /** + * @param dispatchTarget + * @param name + * @param dispID + * @param lcid + * @param wFlags + * @param vArg + * @param uArgErr + */ + public static void invokeSubv(Dispatch dispatchTarget, String name, + int dispID, int lcid, int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokev(dispatchTarget, name, dispID, lcid, wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param vArg + * @param uArgErr + */ + public static void invokeSubv(Dispatch dispatchTarget, String name, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param dispID + * @param wFlags + * @param vArg + * @param uArgErr + */ + public static void invokeSubv(Dispatch dispatchTarget, int dispID, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokev(dispatchTarget, null, dispID, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * not implemented yet + * + * @param dispatchTarget + * @param name + * @param values + * @return never returns anything because + * @throws com.jacob.com.NotImplementedException + */ + public static Variant callN_CaseSensitive(Dispatch dispatchTarget, + String name, Object[] values) { + throw new NotImplementedException("not implemented yet"); + } + + /** + * @param dispatchTarget + * @param name + * @param args + * an array of argument objects + */ + public static void callSubN(Dispatch dispatchTarget, String name, + Object... args) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSubv(dispatchTarget, name, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), new int[args.length]); + } + + /** + * @param dispatchTarget + * @param dispID + * @param args + * an array of argument objects + */ + public static void callSubN(Dispatch dispatchTarget, int dispID, + Object... args) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSubv(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), new int[args.length]); + } + + /* + * ============================================================ start of the + * getIdsOfNames section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @return int id for the passed in name + */ + public static int getIDOfName(Dispatch dispatchTarget, String name) { + int ids[] = getIDsOfNames(dispatchTarget, + Dispatch.LOCALE_SYSTEM_DEFAULT, new String[] { name }); + return ids[0]; + } + + /** + * @param dispatchTarget + * @param lcid + * @param names + * @return int[] in id array for passed in names + */ + // eliminated _Guid argument + public static native int[] getIDsOfNames(Dispatch dispatchTarget, int lcid, + String[] names); + + /** + * @param dispatchTarget + * @param names + * @return int[] int id array for passed in names + */ + // eliminated _Guid argument + public static int[] getIDsOfNames(Dispatch dispatchTarget, String[] names) { + return getIDsOfNames(dispatchTarget, Dispatch.LOCALE_SYSTEM_DEFAULT, + names); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @param args + * @return Variant returned by call + */ + public static Variant callN(Dispatch dispatchTarget, String name, + Object... args) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), new int[args.length]); + } + + /** + * @param dispatchTarget + * @param dispID + * @param args + * @return Variant returned by call + */ + public static Variant callN(Dispatch dispatchTarget, int dispID, + Object... args) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, dispID, Dispatch.Method | Dispatch.Get, + VariantUtilities.objectsToVariants(args), new int[args.length]); + } + + /** + * @param dispatchTarget + * @param name + * @param dispID + * @param lcid + * @param wFlags + * @param oArg + * @param uArgErr + * @return Variant returned by invoke + */ + public static Variant invoke(Dispatch dispatchTarget, String name, + int dispID, int lcid, int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, dispID, lcid, wFlags, + VariantUtilities.objectsToVariants(oArg), uArgErr); + } + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param oArg + * @param uArgErr + * @return Variant returned by invoke + */ + public static Variant invoke(Dispatch dispatchTarget, String name, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, wFlags, VariantUtilities + .objectsToVariants(oArg), uArgErr); + } + + /** + * @param dispatchTarget + * @param dispID + * @param wFlags + * @param oArg + * @param uArgErr + * @return Variant returned by invoke + */ + public static Variant invoke(Dispatch dispatchTarget, int dispID, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, dispID, wFlags, VariantUtilities + .objectsToVariants(oArg), uArgErr); + } + + /* + * ============================================================ start of the + * callN section =========================================================== + */ + + /** + * @param dispatchTarget + * @param name + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, NO_VARIANT_ARGS); + } + + /** + * @param dispatchTarget + * @param name + * @param attributes + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, String name, + Object... attributes) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, name, attributes); + } + + /** + * @param dispatchTarget + * @param dispid + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, NO_VARIANT_ARGS); + } + + /** + * @param dispatchTarget + * @param dispid + * @param attributes + * var arg list of attributes that will be passed to the + * underlying function + * @return Variant returned by underlying callN + */ + public static Variant call(Dispatch dispatchTarget, int dispid, + Object... attributes) { + throwIfUnattachedDispatch(dispatchTarget); + return callN(dispatchTarget, dispid, attributes); + } + + /* + * ============================================================ start of the + * invoke section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @param val + */ + public static void put(Dispatch dispatchTarget, String name, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, name, Dispatch.Put, new Object[] { val }, + new int[1]); + } + + /** + * @param dispatchTarget + * @param dispid + * @param val + */ + public static void put(Dispatch dispatchTarget, int dispid, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, dispid, Dispatch.Put, new Object[] { val }, + new int[1]); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + // removed _Guid argument + /** + * @param dispatchTarget + * @param name + * @param dispID + * @param lcid + * @param wFlags + * @param vArg + * @param uArgErr + * @return Variant returned by underlying invokev + */ + public static native Variant invokev(Dispatch dispatchTarget, String name, + int dispID, int lcid, int wFlags, Variant[] vArg, int[] uArgErr); + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param vArg + * @param uArgErr + * @return Variant returned by underlying invokev + */ + public static Variant invokev(Dispatch dispatchTarget, String name, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param vArg + * @param uArgErr + * @param wFlagsEx + * @return Variant returned by underlying invokev + */ + public static Variant invokev(Dispatch dispatchTarget, String name, + int wFlags, Variant[] vArg, int[] uArgErr, int wFlagsEx) { + throwIfUnattachedDispatch(dispatchTarget); + // do not implement IDispatchEx for now + return invokev(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, vArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param dispID + * @param wFlags + * @param vArg + * @param uArgErr + * @return Variant returned by underlying invokev + */ + public static Variant invokev(Dispatch dispatchTarget, int dispID, + int wFlags, Variant[] vArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, null, dispID, + Dispatch.LOCALE_SYSTEM_DEFAULT, wFlags, vArg, uArgErr); + } + + /* + * ============================================================ start of the + * invokeSubv section + * =========================================================== + */ + + // removed _Guid argument + /** + * @param dispatchTarget + * @param name + * @param dispid + * @param lcid + * @param wFlags + * @param oArg + * @param uArgErr + */ + public static void invokeSub(Dispatch dispatchTarget, String name, + int dispid, int lcid, int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSubv(dispatchTarget, name, dispid, lcid, wFlags, VariantUtilities + .objectsToVariants(oArg), uArgErr); + } + + /* + * ============================================================ start of the + * invokeSub section + * =========================================================== + */ + /** + * @param dispatchTarget + * @param name + * @param wFlags + * @param oArg + * @param uArgErr + */ + public static void invokeSub(Dispatch dispatchTarget, String name, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSub(dispatchTarget, name, 0, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, oArg, uArgErr); + } + + /** + * @param dispatchTarget + * @param dispid + * @param wFlags + * @param oArg + * @param uArgErr + */ + public static void invokeSub(Dispatch dispatchTarget, int dispid, + int wFlags, Object[] oArg, int[] uArgErr) { + throwIfUnattachedDispatch(dispatchTarget); + invokeSub(dispatchTarget, null, dispid, Dispatch.LOCALE_SYSTEM_DEFAULT, + wFlags, oArg, uArgErr); + } + + /* + * ============================================================ start of the + * callSubN section + * =========================================================== + */ + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + */ + public static void callSub(Dispatch dispatchTarget, String name) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, NO_OBJECT_ARGS); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param name + * @param attributes + * var args list of attributes to be passed to underlying + * functions + */ + public static void callSub(Dispatch dispatchTarget, String name, + Object... attributes) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, name, attributes); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + */ + public static void callSub(Dispatch dispatchTarget, int dispid) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, NO_OBJECT_ARGS); + } + + /** + * makes call to native callSubN + * + * @param dispatchTarget + * @param dispid + * @param attributes + * var args list of attributes to be passed to underlying + * function + */ + public static void callSub(Dispatch dispatchTarget, int dispid, + Object... attributes) { + throwIfUnattachedDispatch(dispatchTarget); + callSubN(dispatchTarget, dispid, attributes); + } + + /* + * ============================================================ start of the + * invokev section + * =========================================================== + */ + /** + * Cover for call to underlying invokev() + * + * @param dispatchTarget + * @param name + * @return Variant returned by the request for retrieval of parameter + */ + public static Variant get(Dispatch dispatchTarget, String name) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, name, Dispatch.Get, NO_VARIANT_ARGS, + NO_INT_ARGS); + } + + /** + * Cover for call to underlying invokev() + * + * @param dispatchTarget + * @param dispid + * @return Variant returned by the request for retrieval of parameter + */ + public static Variant get(Dispatch dispatchTarget, int dispid) { + throwIfUnattachedDispatch(dispatchTarget); + return invokev(dispatchTarget, dispid, Dispatch.Get, NO_VARIANT_ARGS, + NO_INT_ARGS); + } + + /* + * ============================================================ start of the + * invoke section + * =========================================================== + */ + /** + * cover for underlying call to invoke + * + * @param dispatchTarget + * @param name + * @param val + */ + public static void putRef(Dispatch dispatchTarget, String name, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, name, Dispatch.PutRef, new Object[] { val }, + new int[1]); + } + + /** + * cover for underlying call to invoke + * + * @param dispatchTarget + * @param dispid + * @param val + */ + public static void putRef(Dispatch dispatchTarget, int dispid, Object val) { + throwIfUnattachedDispatch(dispatchTarget); + invoke(dispatchTarget, dispid, Dispatch.PutRef, new Object[] { val }, + new int[1]); + } + + /** + * not implemented yet + * + * @param dispatchTarget + * @param name + * @return Variant never returned + * @throws com.jacob.com.NotImplementedException + */ + public static Variant get_CaseSensitive(Dispatch dispatchTarget, String name) { + throw new NotImplementedException("not implemented yet"); + } + + /** + * Cover for native method + * + * @param disp + * @param dispid + * @param lcid + * @return 0 if the dispatch is still active and 1 if it has exited + */ + public static native int hasExited(Dispatch disp, int dispid, int lcid); + + /** + * The method is used to poll until it returns 1, indicating that the COM + * server in gone. + *

+ * Sourceforge feature request 2927058 + * + * @param dispatchTarget + * @return 0 if the dispatch is still active and 1 if it has exited + */ + public static int hasExited(Dispatch dispatchTarget) { + throwIfUnattachedDispatch(dispatchTarget); + return hasExited(dispatchTarget, 0, LOCALE_SYSTEM_DEFAULT); + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchEvents.java b/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchEvents.java new file mode 100644 index 0000000..a9ca0a1 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchEvents.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * This class creates the scaffolding for event callbacks. Every instance of tis + * acts as a wrapper around some java object that wants callbacks from the + * microsoft side. It represents the connection between Java and COM for + * callbacks. + *

+ * The callback mechanism will take any event that it receives and try and find + * a java method with the same name that accepts the Variant... as a parameter. + * It will then wrap the call back data in the Variant array and call the java + * method of the object that this DispatchEvents object was initialized with. + *

+ * Instances of this class are created with "sink object" that will receive the + * event messages. The sink object is wrapped in an Invocation handler that + * actually receives the messages and then forwards them on to the "sink + * object". The constructors recognize when an instance of InvocationProxy is + * passed in and do not create a new InvocationProxy as a wrapper. They instead + * use the passed in InvocationProxy. + * + */ +public class DispatchEvents extends JacobObject { + + /** + * pointer to an MS data struct. The COM layer knows the name of this + * variable and puts the windows memory pointer here. + */ + int m_pConnPtProxy = 0; + + /** + * the wrapper for the event sink. This object is the one that will be sent + * a message when an event occurs in the MS layer. Normally, the + * InvocationProxy will forward the messages to a wrapped object that it + * contains. + */ + InvocationProxy mInvocationProxy = null; + + /** + * This is the most commonly used constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + *

+ * Can be used on any object that implements IProvideClassInfo. + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + */ + public DispatchEvents(Dispatch sourceOfEvent, Object eventSink) { + this(sourceOfEvent, eventSink, null); + } + + /** + * None of the samples use this constructor. + *

+ * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + *

+ * Used when the program doesn't implement IProvideClassInfo. It provides a + * way to find the TypeLib in the registry based on the programId. The + * TypeLib is looked up in the registry on the path + * HKEY_LOCAL_MACHINE/SOFTWARE/Classes/CLSID/(CLID drived from + * progid)/ProgID/Typelib + * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + * @param progId + * program id in the registry that has a TypeLib subkey. The + * progrId is mapped to a CLSID that is they used to look up the + * key to the Typelib + */ + public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, + String progId) { + this(sourceOfEvent, eventSink, progId, null); + } + + /** + * Creates the event callback linkage between the the MS program represented + * by the Dispatch object and the Java object that will receive the + * callback. + *

+ * This method was added because Excel doesn't implement IProvideClassInfo + * and the registry entry for Excel.Application doesn't include a typelib + * key. + * + *

+	 * DispatchEvents de = new DispatchEvents(someDispatch, someEventHAndler,
+	 * 		"Excel.Application",
+	 * 		"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE");
+	 * 
+ * + * @param sourceOfEvent + * Dispatch object who's MS app will generate callbacks + * @param eventSink + * Java object that wants to receive the events + * @param progId , + * mandatory if the typelib is specified + * @param typeLib + * The location of the typelib to use + */ + public DispatchEvents(Dispatch sourceOfEvent, Object eventSink, + String progId, String typeLib) { + if (JacobObject.isDebugEnabled()) { + System.out.println("DispatchEvents: Registering " + eventSink + + "for events "); + } + if (eventSink instanceof InvocationProxy) { + mInvocationProxy = (InvocationProxy) eventSink; + } else { + mInvocationProxy = getInvocationProxy(eventSink); + } + if (mInvocationProxy != null) { + init3(sourceOfEvent, mInvocationProxy, progId, typeLib); + } else { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("Cannot register null event sink for events"); + } + throw new IllegalArgumentException( + "Cannot register null event sink for events"); + } + } + + /** + * Returns an instance of the proxy configured with pTargetObject as its + * target + * + * @param pTargetObject + * @return InvocationProxy an instance of the proxy this DispatchEvents will + * send to the COM layer + */ + protected InvocationProxy getInvocationProxy(Object pTargetObject) { + InvocationProxy newProxy = new InvocationProxyAllVariants(); + newProxy.setTarget(pTargetObject); + return newProxy; + } + + /** + * hooks up a connection point proxy by progId event methods on the sink + * object will be called by name with a signature of (Variant[] args) + * + * You must specify the location of the typeLib. + * + * @param src + * dispatch that is the source of the messages + * @param sink + * the object that will receive the messages + * @param progId + * optional program id. most folks don't need this either + * @param typeLib + * optional parameter for those programs that don't register + * their type libs (like Excel) + */ + private native void init3(Dispatch src, Object sink, String progId, + String typeLib); + + /** + * now private so only this object can asccess was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() { + safeRelease(); + } + + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + if (mInvocationProxy != null) { + mInvocationProxy.setTarget(null); + } + mInvocationProxy = null; + super.safeRelease(); + if (m_pConnPtProxy != 0) { + release(); + m_pConnPtProxy = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug("DispatchEvents:" + this.hashCode() + " double release"); + } + } + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchIdentifier.java b/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchIdentifier.java new file mode 100644 index 0000000..cebd9f8 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchIdentifier.java @@ -0,0 +1,82 @@ +/** + * + */ +package com.jacob.com; + +/** + * A bunch of DispatchIds that were pulled out of the Dispatch class for version + * 1.14. + */ +public class DispatchIdentifier { + + private DispatchIdentifier() { + // This is utility class so there is no constructor. + } + + public static final int DISPID_UNKNOWN = -1; + public static final int DISPID_VALUE = 0; + public static final int DISPID_PROPERTYPUT = -3; + public static final int DISPID_NEWENUM = -4; + public static final int DISPID_EVALUATE = -5; + public static final int DISPID_CONSTRUCTOR = -6; + public static final int DISPID_DESTRUCTOR = -7; + public static final int DISPID_COLLECT = -8; + public static final int DISPID_AUTOSIZE = -500; + public static final int DISPID_BACKCOLOR = -501; + public static final int DISPID_BACKSTYLE = -502; + public static final int DISPID_BORDERCOLOR = -503; + public static final int DISPID_BORDERSTYLE = -504; + public static final int DISPID_BORDERWIDTH = -505; + public static final int DISPID_DRAWMODE = -507; + public static final int DISPID_DRAWSTYLE = -508; + public static final int DISPID_DRAWWIDTH = -509; + public static final int DISPID_FILLCOLOR = -510; + public static final int DISPID_FILLSTYLE = -511; + public static final int DISPID_FONT = -512; + public static final int DISPID_FORECOLOR = -513; + public static final int DISPID_ENABLED = -514; + public static final int DISPID_HWND = -515; + public static final int DISPID_TABSTOP = -516; + public static final int DISPID_TEXT = -517; + public static final int DISPID_CAPTION = -518; + public static final int DISPID_BORDERVISIBLE = -519; + public static final int DISPID_APPEARANCE = -520; + public static final int DISPID_MOUSEPOINTER = -521; + public static final int DISPID_MOUSEICON = -522; + public static final int DISPID_PICTURE = -523; + public static final int DISPID_VALID = -524; + public static final int DISPID_READYSTATE = -525; + public static final int DISPID_REFRESH = -550; + public static final int DISPID_DOCLICK = -551; + public static final int DISPID_ABOUTBOX = -552; + public static final int DISPID_CLICK = -600; + public static final int DISPID_DBLCLICK = -601; + public static final int DISPID_KEYDOWN = -602; + public static final int DISPID_KEYPRESS = -603; + public static final int DISPID_KEYUP = -604; + public static final int DISPID_MOUSEDOWN = -605; + public static final int DISPID_MOUSEMOVE = -606; + public static final int DISPID_MOUSEUP = -607; + public static final int DISPID_ERROREVENT = -608; + public static final int DISPID_READYSTATECHANGE = -609; + public static final int DISPID_AMBIENT_BACKCOLOR = -701; + public static final int DISPID_AMBIENT_DISPLAYNAME = -702; + public static final int DISPID_AMBIENT_FONT = -703; + public static final int DISPID_AMBIENT_FORECOLOR = -704; + public static final int DISPID_AMBIENT_LOCALEID = -705; + public static final int DISPID_AMBIENT_MESSAGEREFLECT = -706; + public static final int DISPID_AMBIENT_SCALEUNITS = -707; + public static final int DISPID_AMBIENT_TEXTALIGN = -708; + public static final int DISPID_AMBIENT_USERMODE = -709; + public static final int DISPID_AMBIENT_UIDEAD = -710; + public static final int DISPID_AMBIENT_SHOWGRABHANDLES = -711; + public static final int DISPID_AMBIENT_SHOWHATCHING = -712; + public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = -713; + public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714; + public static final int DISPID_AMBIENT_AUTOCLIP = -715; + public static final int DISPID_AMBIENT_APPEARANCE = -716; + public static final int DISPID_AMBIENT_CODEPAGE = -725; + public static final int DISPID_AMBIENT_PALETTE = -726; + public static final int DISPID_AMBIENT_CHARSET = -727; + public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728; +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchProxy.java b/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchProxy.java new file mode 100644 index 0000000..c8f08cf --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/DispatchProxy.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * If you need to pass a COM Dispatch object between STA threads, you have to + * marshall the interface. This class is used as follows: the STA that creates + * the Dispatch object must construct an instance of this class. Another thread + * can then call toDispatch() on that instance and get a Dispatch pointer which + * has been marshalled. WARNING: You can only call toDispatch() once! If you + * need to call it multiple times (or from multiple threads) you need to + * construct a separate DispatchProxy instance for each such case! + */ +public class DispatchProxy extends JacobObject { + /** + * Comment for m_pStream + */ + public int m_pStream; + + /** + * Marshals the passed in dispatch into the stream + * + * @param localDispatch + */ + public DispatchProxy(Dispatch localDispatch) { + MarshalIntoStream(localDispatch); + } + + /** + * + * @return Dispatch the dispatch retrieved from the stream + */ + public Dispatch toDispatch() { + return MarshalFromStream(); + } + + private native void MarshalIntoStream(Dispatch d); + + private native Dispatch MarshalFromStream(); + + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + public void finalize() { + safeRelease(); + } + + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + super.safeRelease(); + if (m_pStream != 0) { + release(); + m_pStream = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/EnumVariant.java b/vendor/jacob/1.15-M4/java/com/jacob/com/EnumVariant.java new file mode 100644 index 0000000..8ff298f --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/EnumVariant.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * An implementation of IEnumVariant based on code submitted by Thomas Hallgren + * (mailto:Thomas.Hallgren@eoncompany.com) + */ +public class EnumVariant extends JacobObject implements + java.util.Enumeration { + private int m_pIEnumVARIANT; + + private final Variant[] m_recBuf = new Variant[1]; + + // this only gets called from JNI + // + protected EnumVariant(int pIEnumVARIANT) { + m_pIEnumVARIANT = pIEnumVARIANT; + } + + /** + * @param disp + */ + public EnumVariant(Dispatch disp) { + int[] hres = new int[1]; + Variant evv = Dispatch.invokev(disp, DispatchIdentifier.DISPID_NEWENUM, + Dispatch.Get, new Variant[0], hres); + if (evv.getvt() != Variant.VariantObject) + // + // The DISPID_NEWENUM did not result in a valid object + // + throw new ComFailException("Can't obtain EnumVARIANT"); + + EnumVariant tmp = evv.toEnumVariant(); + m_pIEnumVARIANT = tmp.m_pIEnumVARIANT; + tmp.m_pIEnumVARIANT = 0; + } + + /** + * Implements java.util.Enumeration + * + * @return boolean true if there are more elements in this enumeration + */ + public boolean hasMoreElements() { + { + if (m_recBuf[0] == null) { + if (this.Next(m_recBuf) <= 0) + return false; + } + return true; + } + } + + /** + * Implements java.util.Enumeration + * + * @return next element in the enumeration + */ + public Variant nextElement() { + Variant last = m_recBuf[0]; + if (last == null) { + if (this.Next(m_recBuf) <= 0) + throw new java.util.NoSuchElementException(); + last = m_recBuf[0]; + } + m_recBuf[0] = null; + return last; + } + + /** + * Get next element in collection or null if at end + * + * @return Variant that is next in the collection + * @deprecated use nextElement() instead + */ + @Deprecated + public Variant Next() { + if (hasMoreElements()) + return nextElement(); + return null; + } + + /** + * This should be private and wrapped to protect JNI layer. + * + * @param receiverArray + * @return Returns the next variant object pointer as an int from windows + * layer + */ + public native int Next(Variant[] receiverArray); + + /** + * This should be private and wrapped to protect JNI layer. + * + * @param count + * number to skip + */ + public native void Skip(int count); + + /** + * This should be private and wrapped to protect JNI layer + */ + public native void Reset(); + + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + protected void finalize() { + safeRelease(); + } + + /* + * (non-Javadoc) + * + * @see com.jacob.com.JacobObject#safeRelease() + */ + public void safeRelease() { + super.safeRelease(); + if (m_pIEnumVARIANT != 0) { + this.release(); + m_pIEnumVARIANT = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/InvocationProxy.java b/vendor/jacob/1.15-M4/java/com/jacob/com/InvocationProxy.java new file mode 100644 index 0000000..7687d84 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/InvocationProxy.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * @version $Id$ + * @author joe + * + * DispatchEvents wraps this class around any event handlers before making the + * JNI call that sets up the link with EventProxy. This means that + * EventProxy.cpp just calls invoke(String,Variant[]) against the instance of + * this class. Then this class does reflection against the event listener to + * call the actual event methods. The event methods can return void or return a + * Variant. Any value returned will be passed back to the calling windows module + * by the Jacob JNI layer. + *

+ * + * The void returning signature is the standard legacy signature. The Variant + * returning signature was added in 1.10 to support event handlers returning + * values. + * + */ +public abstract class InvocationProxy { + + /** + * the object we will try and forward to. + */ + protected Object mTargetObject = null; + + /** + * dummy constructor for subclasses that don't actually wrap anything and + * just want to override the invoke() method + */ + protected InvocationProxy() { + super(); + } + + /** + * The method actually invoked by EventProxy.cpp. The method name is + * calculated by the underlying JNI code from the MS windows Callback + * function name. The method is assumed to take an array of Variant objects. + * The method may return a Variant or be a void. Those are the only two + * options that will not blow up. + *

+ * Subclasses that override this should make sure mTargetObject is not null + * before processing. + * + * @param methodName + * name of method in mTargetObject we will invoke + * @param targetParameters + * Variant[] that is the single parameter to the method + * @return an object that will be returned to the com event caller + */ + public abstract Variant invoke(String methodName, + Variant targetParameters[]); + + /** + * used by EventProxy.cpp to create variant objects in the right thread + * + * @return Variant object that will be used by the COM layer + */ + public Variant getVariant() { + return new VariantViaEvent(); + } + + /** + * Sets the target for this InvocationProxy. + * + * @param pTargetObject + * @throws IllegalArgumentException + * if target is not publicly accessible + */ + public void setTarget(Object pTargetObject) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: setting target " + + pTargetObject); + } + if (pTargetObject != null) { + // JNI code apparently bypasses this check and could operate against + // protected classes. This seems like a security issue... + // maybe it was because JNI code isn't in a package? + if (!java.lang.reflect.Modifier.isPublic(pTargetObject.getClass() + .getModifiers())) { + throw new IllegalArgumentException( + "InvocationProxy only public classes can receive event notifications"); + } + } + mTargetObject = pTargetObject; + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/InvocationProxyAllVariants.java b/vendor/jacob/1.15-M4/java/com/jacob/com/InvocationProxyAllVariants.java new file mode 100644 index 0000000..3a5d846 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/InvocationProxyAllVariants.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +/** + * This class acts as a proxy between the windows event callback mechanism and + * the Java classes that are looking for events. It assumes that all of the Java + * classes that are looking for events implement methods with the same names as + * the windows events and that the implemented methods accept an array of + * variant objects. The methods can return void or a Variant that will be + * returned to the calling layer. All Event methods that will be recognized by + * InvocationProxyAllEvents have the signature + * + * void eventMethodName(Variant[]) or + * Variant eventMethodName(Variant[]) + */ +public class InvocationProxyAllVariants extends InvocationProxy { + + /* + * (non-Javadoc) + * + * @see com.jacob.com.InvocationProxy#invoke(java.lang.String, + * com.jacob.com.Variant[]) + */ + @SuppressWarnings("unchecked") + public Variant invoke(String methodName, Variant targetParameters[]) { + Variant mVariantToBeReturned = null; + if (mTargetObject == null) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: received notification (" + + methodName + ") with no target set"); + } + // structured programming guidlines say this return should not be up + // here + return null; + } + Class targetClass = mTargetObject.getClass(); + if (methodName == null) { + throw new IllegalArgumentException( + "InvocationProxy: missing method name"); + } + if (targetParameters == null) { + throw new IllegalArgumentException( + "InvocationProxy: missing Variant parameters"); + } + try { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: trying to invoke " + + methodName + " on " + mTargetObject); + } + Method targetMethod; + targetMethod = targetClass.getMethod(methodName, + new Class[] { Variant[].class }); + if (targetMethod != null) { + // protected classes can't be invoked against even if they + // let you grab the method. you could do + // targetMethod.setAccessible(true); + // but that should be stopped by the security manager + Object mReturnedByInvocation = null; + mReturnedByInvocation = targetMethod.invoke(mTargetObject, + new Object[] { targetParameters }); + if (mReturnedByInvocation == null) { + mVariantToBeReturned = null; + } else if (!(mReturnedByInvocation instanceof Variant)) { + // could try and convert to Variant here. + throw new IllegalArgumentException( + "InvocationProxy: invokation of target method returned " + + "non-null non-variant object: " + + mReturnedByInvocation); + } else { + mVariantToBeReturned = (Variant) mReturnedByInvocation; + } + } + } catch (SecurityException e) { + // what causes this exception? + e.printStackTrace(); + } catch (NoSuchMethodException e) { + // this happens whenever the listener doesn't implement all the + // methods + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("InvocationProxy: listener (" + mTargetObject + + ") doesn't implement " + methodName); + } + } catch (IllegalArgumentException e) { + e.printStackTrace(); + // we can throw these inside the catch block so need to re-throw it + throw e; + } catch (IllegalAccessException e) { + // can't access the method on the target instance for some reason + if (JacobObject.isDebugEnabled()) { + JacobObject + .debug("InvocationProxy: probably tried to access public method on non public class" + + methodName); + } + e.printStackTrace(); + } catch (InvocationTargetException e) { + // invocation of target method failed + e.printStackTrace(); + } + return mVariantToBeReturned; + + } +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/JacobException.java b/vendor/jacob/1.15-M4/java/com/jacob/com/JacobException.java new file mode 100644 index 0000000..6e2e926 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/JacobException.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * The parent class of all Jacob exceptions. They all used to be based off of + * RuntimeException or ComException but it was decided to base them all off of + * one owned by this project. + */ +public class JacobException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -1637125318746002715L; + + /** + * Default constructor. Calls super with a "No Message Provided" string + */ + public JacobException() { + super("No Message Provided"); + } + + /** + * standard constructor + * + * @param message + */ + public JacobException(String message) { + super(message); + } +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/JacobObject.java b/vendor/jacob/1.15-M4/java/com/jacob/com/JacobObject.java new file mode 100644 index 0000000..acd346c --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/JacobObject.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * The superclass of all Jacob objects. It is used to create a standard API + * framework and to facilitate memory management for Java and COM memory + * elements. + *

+ * All instances of this class and subclasses are automatically managed by the + * ROT. This means the ROT cannot be a subclass of JacobObject. + *

+ * All COM object created by JACOB extend this class so that we can + * automatically release them when the thread is detached from COM - if we leave + * it to the finalizer it will call the release from another thread, which may + * result in a segmentation violation. + */ +public class JacobObject { + + /** + * Standard constructor that adds this JacobObject to the memory management + * pool. + */ + public JacobObject() { + ROT.addObject(this); + } + + /** + * Finalizers call this method. This method should release any COM data + * structures in a way that it can be called multiple times. This can happen + * if someone manually calls this and then a finalizer calls it. + */ + public void safeRelease() { + // currently does nothing - subclasses may do something + if (isDebugEnabled()) { + // this used to do a toString() but that is bad for SafeArray + debug("SafeRelease: " + this.getClass().getName()); + } + } + + /** + * When things go wrong, it is useful to be able to debug the ROT. + */ + private static final boolean DEBUG = + // true; + "true".equalsIgnoreCase(System.getProperty("com.jacob.debug")); + + protected static boolean isDebugEnabled() { + return DEBUG; + } + + /** + * Loads JacobVersion.Properties and returns the value of version in it + * + * @deprecated use JacobReleaseInfo.getBuildDate() instead. + * @return String value of version in JacobVersion.Properties or "" if none + */ + @Deprecated + public static String getBuildDate() { + return JacobReleaseInfo.getBuildDate(); + } + + /** + * Loads JacobVersion.Properties and returns the value of version in it + * + * @deprecated use JacobReleaseInfo.getBuildVersion() instead. + * @return String value of version in JacobVersion.Properties or "" if none + */ + @Deprecated + public static String getBuildVersion() { + return JacobReleaseInfo.getBuildVersion(); + } + + /** + * Very basic debugging function. + * + * @param istrMessage + */ + protected static void debug(String istrMessage) { + if (isDebugEnabled()) { + System.out.println(Thread.currentThread().getName() + ": " + + istrMessage); + } + } + + /** + * force the jacob DLL to be loaded whenever this class is referenced + */ + static { + LibraryLoader.loadJacobLibrary(); + } + +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/JacobReleaseInfo.java b/vendor/jacob/1.15-M4/java/com/jacob/com/JacobReleaseInfo.java new file mode 100644 index 0000000..a41b239 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/JacobReleaseInfo.java @@ -0,0 +1,96 @@ +package com.jacob.com; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +/** + * An interface to the version properties file. This code was removed from + * JacobObject because it doesn't belong there. + * + */ +public class JacobReleaseInfo { + + /** + * holds the build version as retrieved from the version properties file + * that exists in the JAR. This can be retrieved by calling the static + * method getBuildVersion() + * + * @see #getBuildVersion() + */ + private static String buildVersion = ""; + /** + * holds the build date as retrieved from the version properties file that + * exists in the JAR This can be retrieved by calling the static method + * getBuildDate() + * + * @see #getBuildDate() + */ + private static String buildDate = ""; + /** the name of the jacob version properties file */ + private static final String PROPERTY_FILE_NAME = "META-INF/JacobVersion.properties"; + + /** + * Loads version information from PROPERTY_FILE_NAME that was built as part + * of this release. + * + * @throws IllegalStateException + * when it can't find the version properties file + */ + private static void loadVersionProperties() { + Properties versionProps = new Properties(); + // can't use system class loader cause won't work in JavaWebStart + InputStream stream = JacobReleaseInfo.class.getClassLoader() + .getResourceAsStream(PROPERTY_FILE_NAME); + // This should never happen. This is an attempt to make something work + // for WebSphere. They may be using some kind of Servlet loader that + // needs an absolute path based search + if (stream == null) { + stream = JacobReleaseInfo.class.getClassLoader() + .getResourceAsStream("/" + PROPERTY_FILE_NAME); + } + // A report came in that WebSphere had trouble finding the file + // so lets trap it. Plus, it's a good idea anyway. + if (stream == null) { + throw new IllegalStateException( + "Can't find " + + PROPERTY_FILE_NAME + + " using JacobReleaseInfo.class.getClassLoader().getResourceAsStream()"); + } else { + try { + versionProps.load(stream); + stream.close(); + buildVersion = (String) versionProps.get("version"); + buildDate = (String) versionProps.get("build.date"); + } catch (IOException ioe) { + ioe.printStackTrace(); + System.err.println("Warning! Couldn't load props " + ioe); + } + } + } + + /** + * loads PROPERT_FILE_NAME and returns the value of version in it + * + * @return String value of version in PROPERT_FILE_NAME or "" if none + */ + public static String getBuildDate() { + if (buildDate.equals("")) { + loadVersionProperties(); + } + return buildDate; + } + + /** + * loads PROPERT_FILE_NAME and returns the value of version in it + * + * @return String value of version in PROPERT_FILE_NAME or "" if none + */ + public static String getBuildVersion() { + if (buildVersion.equals("")) { + loadVersionProperties(); + } + return buildVersion; + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/LibraryLoader.java b/vendor/jacob/1.15-M4/java/com/jacob/com/LibraryLoader.java new file mode 100644 index 0000000..4fd2740 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/LibraryLoader.java @@ -0,0 +1,230 @@ +/* + * Copyright (c) 1999-2007 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import java.util.Set; + +/** + * Utility class to centralize the way in which the jacob JNI library is loaded. + *

+ * + * This supports defining the path or library name using system properties or a + * custom resource file. If desired, jacob can auto-detect the correct version + * of the DLL for 32 or 64 bit windows, as long as you have named them + * differently. + * + *

    + *
  1. If system property {@link #JACOB_DLL_PATH} is defined, the file located + * there will be loaded as the jacob dll using System.load().
  2. + * + *
  3. If system property {@link #JACOB_DLL_NAME} is defined, the file located + * there will be loaded as the jacob dll.
  4. + *
  5. If system property {@link #JACOB_DLL_NAME_X86} and + * {@link #JACOB_DLL_NAME_X64} are defined, the file located there will be + * loaded as the jacob dll, depending on the version of Windows.
  6. + * + *
  7. If {@link #JACOB_DLL_NAME} is defined in the + * {@code com.jacob.com.JacobLibraryLoader} resource file, the specified dll + * will be loaded from the {@code java.library.path}.
  8. + *
  9. If {@link #JACOB_DLL_NAME_X86} and {@link #JACOB_DLL_NAME_X64} are + * defined in the {@code com.jacob.com.JacobLibraryLoader} resource file, the + * specified dll will be loaded from the {@code java.library.path}, depending + * on the version of Windows.
  10. + * + *
  11. If none of the above are true, the default is to load the library named + * "jacob-<version>-<arch>" (or + * "jacob-<version>-<arch&rt;.dll") from the {@code java.library.path}. + *
  12. + *
+ * + * The standard behavior for most applications is that {@code LoadLibrary()} + * will be called to load the dll. {@code LoadLibary()} searches directories + * specified in the variable {@code java.library.path}. This is why most test + * cases specify -Djava.library.path in their command line arguments. + *

+ * JACOB_DLL_PATH submitted sourceforge ticket 1493647 Added 1.11
+ * JACOB_DLL_NAME, JACOB_DLL_NAME_32, JACOB_DLL_NAME_64 submitted sourceforge + * ticket 1845039 Added 1.14M7 + * + * @author Scott Dickerson (sjd78) + * @author Jason Smith + */ +public final class LibraryLoader { + /** + * Name of system property (currently jacob.dll.path) that may + * contain an absolute path to the JNI library. + */ + public static final String JACOB_DLL_PATH = "jacob.dll.path"; + + /** + * Name of system property (currently jacob.dll.name) that may + * contain an alternate name for the JNI library (default is 'jacob'). + */ + public static final String JACOB_DLL_NAME = "jacob.dll.name"; + + /** + * Name of system property (currently jacob.dll.name) that may + * contain an alternate name for the JNI library (default is 'jacob'), 32 + * bit windows. + */ + public static final String JACOB_DLL_NAME_X86 = "jacob.dll.name.x86"; + + /** + * Name of system property (currently jacob.dll.name) that may + * contain an alternate name for the JNI library (default is 'jacob'), 64 + * bit windows. + */ + public static final String JACOB_DLL_NAME_X64 = "jacob.dll.name.x64"; + + /** + * Appended to "jacob" when building DLL name This string must EXACTLY match + * the string in the build.xml file + */ + public static final String DLL_NAME_MODIFIER_32_BIT = "x86"; + /** + * Appended to "jacob" when building DLL name This string must EXACTLY match + * the string in the build.xml file + */ + public static final String DLL_NAME_MODIFIER_64_BIT = "x64"; + + /** + * Load the jacob dll either from an absolute path or by a library name, + * both of which may be defined in various ways. + * + * @throws UnsatisfiedLinkError + * if the library does not exist. + */ + public static void loadJacobLibrary() { + // In some cases, a library that uses Jacob won't be able to set system + // properties + // prior to Jacob being loaded. The resource bundle provides an + // alternate way to + // override DLL name or path that will be loaded with Jacob regardless + // of other + // initialization order. + ResourceBundle resources = null; + Set keys = new HashSet(); + try { + resources = ResourceBundle.getBundle(LibraryLoader.class.getName(), + Locale.getDefault(), LibraryLoader.class.getClassLoader()); + for (Enumeration i = resources.getKeys(); i + .hasMoreElements();) { + String key = i.nextElement(); + keys.add(key); + } + } catch (MissingResourceException e) { + // Do nothing. Expected. + } + + // First, check for a defined PATH. System property overrides resource + // bundle. + String path = System.getProperty(JACOB_DLL_PATH); + if (path == null && resources != null && keys.contains(JACOB_DLL_PATH)) { + path = (String) resources.getObject(JACOB_DLL_PATH); + } + + if (path != null) { + JacobObject.debug("Loading library " + path + + " using System.loadLibrary "); + System.load(path); + } else { + // Path was not defined, so use the OS mechanism for loading + // libraries. + // Check for a defined NAME. System property overrides resource + // bundle. + String name = null; + + if (System.getProperty(JACOB_DLL_NAME) != null) { + name = System.getProperty(JACOB_DLL_NAME); + } else if (System.getProperty(JACOB_DLL_NAME_X86) != null + && shouldLoad32Bit()) { + name = System.getProperty(JACOB_DLL_NAME_X86); + } else if (System.getProperty(JACOB_DLL_NAME_X64) != null + && !shouldLoad32Bit()) { + name = System.getProperty(JACOB_DLL_NAME_X64); + } else if (resources != null && keys.contains(JACOB_DLL_NAME)) { + name = resources.getString(JACOB_DLL_NAME); + } else if (resources != null && keys.contains(JACOB_DLL_NAME_X86) + && shouldLoad32Bit()) { + name = resources.getString(JACOB_DLL_NAME_X86); + } else if (resources != null && keys.contains(JACOB_DLL_NAME_X64) + && !shouldLoad32Bit()) { + name = resources.getString(JACOB_DLL_NAME_X64); + } else { + // No alternate NAME or PATH was defined, so use the default. + // We will almost always end up here. + name = getPreferredDLLName(); + } + + JacobObject.debug("Loading library " + name + + " using System.loadLibrary "); + // System.out.println("Loading " + name); + System.loadLibrary(name); + } + } + + /** + * Developer note: This method MUST be synchronized with the DLL names + * created as part of the build process in build.xml + *

+ * The DLL name is "jacob\.release" + * + * @return the preferred name of the DLL adjusted for this platform and + * version without the ".dll" extension + */ + public static String getPreferredDLLName() { + if (shouldLoad32Bit()) { + return "jacob" + "-" + JacobReleaseInfo.getBuildVersion() + "-" + + DLL_NAME_MODIFIER_32_BIT; + } else { + return "jacob" + "-" + JacobReleaseInfo.getBuildVersion() + "-" + + DLL_NAME_MODIFIER_64_BIT; + } + } + + /** + * Detects whether this is a 32-bit JVM. + * + * @return {@code true} if this is a 32-bit JVM. + */ + protected static boolean shouldLoad32Bit() { + // This guesses whether we are running 32 or 64 bit Java. + // This works for Sun and IBM JVMs version 5.0 or later. + // May need to be adjusted for non-Sun JVMs. + + String bits = System.getProperty("sun.arch.data.model", "?"); + if (bits.equals("32")) + return true; + else if (bits.equals("64")) + return false; + + // this works for jRocket + String arch = System.getProperty("java.vm.name", "?"); + if (arch.toLowerCase().indexOf("64-bit") >= 0) + return false; + + return true; + } +} // LibraryLoader diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/MainSTA.java b/vendor/jacob/1.15-M4/java/com/jacob/com/MainSTA.java new file mode 100644 index 0000000..a87e3c4 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/MainSTA.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * We provide our own main sta thread to avoid COM tagging a random thread as + * the main STA - this is the thread in which all Apartment threaded components + * will be created if the client chooses an MTA threading model for the java + * side of the app. + */ +public class MainSTA extends STA { +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/NotImplementedException.java b/vendor/jacob/1.15-M4/java/com/jacob/com/NotImplementedException.java new file mode 100644 index 0000000..c5773b5 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/NotImplementedException.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * Thrown by java APIs that are not implemented either because they were never + * implemented or because they are being deprecated This is a subclass of + * ComException so callers can still just catch ComException. + */ +public class NotImplementedException extends JacobException { + + /** + * + */ + private static final long serialVersionUID = -9169900832852356445L; + + /** + * @param description + */ + public NotImplementedException(String description) { + super(description); + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/ROT.java b/vendor/jacob/1.15-M4/java/com/jacob/com/ROT.java new file mode 100644 index 0000000..7b50fd3 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/ROT.java @@ -0,0 +1,279 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.WeakHashMap; + +/** + * The Running Object Table (ROT) maps each thread to a collection of all the + * JacobObjects that were created in that thread. It always operates on the + * current thread so all the methods are static and they implicitly get the + * current thread. + *

+ * The clearObjects method is used to release all the COM objects created by + * Jacob in the current thread prior to uninitializing COM for that thread. + *

+ * Prior to 1.9, manual garbage collection was the only option in Jacob, but + * from 1.9 onward, setting the com.jacob.autogc system property allows the + * objects referenced by the ROT to be automatically GCed. Automatic GC may be + * preferable in systems with heavy event callbacks. + *

+ * Is [ 1116101 ] jacob-msg 0284 relevant??? + */ +public abstract class ROT { + /** + * Manual garbage collection was the only option pre 1.9 Can staticly cache + * the results because only one value and we don't let it change during a + * run + */ + protected static final boolean USE_AUTOMATIC_GARBAGE_COLLECTION = "true" + .equalsIgnoreCase(System.getProperty("com.jacob.autogc")); + + /** + * If the code is ran from an applet that is called from javascript the Java + * Plugin does not give full permissions to the code and thus System + * properties cannot be accessed. They can be accessed at class + * initialization time. + * + * The default behavior is to include all classes in the ROT, setting a + * boolean here to indicate this prevents a call to System.getProperty as + * part of the general call flow. + */ + protected static final Boolean INCLUDE_ALL_CLASSES_IN_ROT = Boolean + .valueOf(System.getProperty("com.jacob.includeAllClassesInROT", + "true")); + + /** + * Suffix added to class name to make up property name that determines if + * this object should be stored in the ROT. This 1.13 "feature" makes it + * possible to cause VariantViaEvent objects to not be added to the ROT in + * event callbacks. + *

+ * We don't have a static for the actual property because there is a + * different property for each class that may make use of this feature. + */ + protected static String PUT_IN_ROT_SUFFIX = ".PutInROT"; + + /** + * A hash table where each element is another HashMap that represents a + * thread. Each thread HashMap contains the com objects created in that + * thread + */ + private static HashMap> rot = new HashMap>(); + + /** + * adds a new thread storage area to rot + * + * @return Map corresponding to the thread that this call was made in + */ + protected synchronized static Map addThread() { + // should use the id here instead of the name because the name can be + // changed + String t_name = Thread.currentThread().getName(); + if (rot.containsKey(t_name)) { + // nothing to do + } else { + Map tab = null; + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: Automatic GC flag == " + + USE_AUTOMATIC_GARBAGE_COLLECTION); + } + if (!USE_AUTOMATIC_GARBAGE_COLLECTION) { + tab = new HashMap(); + } else { + tab = new WeakHashMap(); + } + rot.put(t_name, tab); + } + return getThreadObjects(false); + } + + /** + * Returns the pool for this thread if it exists. can create a new one if + * you wish by passing in TRUE + * + * @param createIfDoesNotExist + * @return Map the collection that holds the objects created in the current + * thread + */ + protected synchronized static Map getThreadObjects( + boolean createIfDoesNotExist) { + String t_name = Thread.currentThread().getName(); + if (!rot.containsKey(t_name) && createIfDoesNotExist) { + addThread(); + } + return rot.get(t_name); + } + + /** + * Iterates across all of the entries in the Hashmap in the rot that + * corresponds to this thread. This calls safeRelease() on each entry and + * then clears the map when done and removes it from the rot. All traces of + * this thread's objects will disappear. This is called by COMThread in the + * tear down and provides a synchronous way of releasing memory + */ + protected static void clearObjects() { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: " + rot.keySet().size() + + " thread tables exist"); + } + + Map tab = getThreadObjects(false); + if (tab != null) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: " + tab.keySet().size() + + " objects to clear in this thread's ROT "); + } + // walk the values + Iterator it = tab.keySet().iterator(); + while (it.hasNext()) { + JacobObject o = it.next(); + if (o != null + // can't use this cause creates a Variant if calling SafeAray + // and we get an exception modifying the collection while + // iterating + // && o.toString() != null + ) { + if (JacobObject.isDebugEnabled()) { + if (o instanceof SafeArray) { + // SafeArray create more objects when calling + // toString() + // which causes a concurrent modification exception + // in HashMap + JacobObject.debug("ROT: removing " + + o.getClass().getName()); + } else { + // Variant toString() is probably always bad in here + JacobObject.debug("ROT: removing " + o.hashCode() + + "->" + o.getClass().getName()); + } + } + o.safeRelease(); + } + } + // empty the collection + tab.clear(); + // remove the collection from rot + ROT.removeThread(); + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: thread table cleared and removed"); + } + } else { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: nothing to clear!"); + } + } + } + + /** + * Removes the map from the rot that is associated with the current thread. + */ + private synchronized static void removeThread() { + // should this see if it exists first? + rot.remove(Thread.currentThread().getName()); + } + + /** + * @deprecated the java model leave the responsibility of clearing up + * objects to the Garbage Collector. Our programming model + * should not require that the user specifically remove object + * from the thread.
+ * This will remove an object from the ROT
+ * This does not need to be synchronized because only the rot + * modification related methods need to synchronized. Each + * individual map is only modified in a single thread. + * @param o + */ + @Deprecated + protected static void removeObject(JacobObject o) { + Map tab = ROT.getThreadObjects(false); + if (tab != null) { + tab.remove(o); + } + o.safeRelease(); + } + + /** + * Adds an object to the HashMap for the current thread.
+ *

+ * This method does not need to be threaded because the only concurrent + * modification risk is on the hash map that contains all of the thread + * related hash maps. The individual thread related maps are only used on a + * per thread basis so there isn't a locking issue. + *

+ * In addition, this method cannot be threaded because it calls + * ComThread.InitMTA. The ComThread object has some methods that call ROT so + * we could end up deadlocked. This method should be safe without the + * synchronization because the ROT works on per thread basis and the methods + * that add threads and remove thread related entries are all synchronized + * + * + * @param o + */ + protected static void addObject(JacobObject o) { + String shouldIncludeClassInROT = "true"; + // only call System.getProperty if we are not including all classes in + // the ROT. This lets us run with standard Jacob behavior in Applets + // without the security exception raised by System.getProperty in the + // flow + if (!ROT.INCLUDE_ALL_CLASSES_IN_ROT) { + shouldIncludeClassInROT = System.getProperty(o.getClass().getName() + + PUT_IN_ROT_SUFFIX, "true"); + } + if (shouldIncludeClassInROT.equalsIgnoreCase("false")) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("JacobObject: New instance of " + + o.getClass().getName() + " not added to ROT"); + } + } else { + // first see if we have a table for this thread + Map tab = getThreadObjects(false); + if (tab == null) { + // this thread has not been initialized as a COM thread + // so make it part of MTA for backwards compatibility + ComThread.InitMTA(false); + // don't really need the "true" because the InitMTA will have + // called back to the ROT to create a table for this thread + tab = getThreadObjects(true); + } + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("ROT: adding " + o + "->" + + o.getClass().getName() + + " table size prior to addition:" + tab.size()); + } + // add the object to the table that is specific to this thread + if (tab != null) { + tab.put(o, null); + } + } + } + + /** + * ROT can't be a subclass of JacobObject because of the way ROT pools are + * managed so we force a DLL load here by referencing JacobObject + */ + static { + LibraryLoader.loadJacobLibrary(); + } + +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/STA.java b/vendor/jacob/1.15-M4/java/com/jacob/com/STA.java new file mode 100644 index 0000000..837e2d3 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/STA.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * A class that implements a Single Threaded Apartment. Users will subclass this + * and override OnInit() and OnQuit() where they will create and destroy a COM + * component that wants to run in an STA other than the main STA. + */ +public class STA extends Thread { + /** + * referenced by STA.cpp + */ + public int threadID; + + /** + * constructor for STA + */ + public STA() { + start(); // start the thread + } + + /* + * (non-Javadoc) + * + * @see java.lang.Thread#run() + */ + public void run() { + // init COM + ComThread.InitSTA(); + if (OnInit()) { + // this call blocks in the win32 message loop + // until quitMessagePump is called + doMessagePump(); + } + OnQuit(); + // uninit COM + ComThread.Release(); + } + + /** + * Override this method to create and initialize any COM component that you + * want to run in this thread. If anything fails, return false to terminate + * the thread. + * + * @return always returns true + */ + public boolean OnInit() { + return true; + } + + /** + * Override this method to destroy any resource before the thread exits and + * COM in uninitialized + */ + public void OnQuit() { + // there is nothing to see here + } + + /** + * calls quitMessagePump + */ + public void quit() { + quitMessagePump(); + } + + /** + * run a message pump for the main STA + */ + public native void doMessagePump(); + + /** + * quit message pump for the main STA + */ + public native void quitMessagePump(); + + /** + * STA isn't a subclass of JacobObject so a reference to it doesn't load the + * DLL without this + */ + static { + LibraryLoader.loadJacobLibrary(); + } +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/SafeArray.java b/vendor/jacob/1.15-M4/java/com/jacob/com/SafeArray.java new file mode 100644 index 0000000..f250d81 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/SafeArray.java @@ -0,0 +1,1172 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * This creates an array wrapper around Variant objects(?). This supports 1, 2 + * and n-dimensional arrays. It exists in this form because n-dimensional arrays + * were a later addition. + */ +public class SafeArray extends JacobObject { + /** The super secret int that is actually the pointer to windows memory */ + int m_pV = 0; + + /** + * Constructor. Why does this exist? Yeah, someone will post on sourceforge + * about this comment. + * + */ + public SafeArray() { + } + + /** + * Constructor. + * + * @param vt + * type of array + */ + public SafeArray(int vt) { + init(vt, new int[] { 0 }, new int[] { -1 }); + } + + /** + * Constructor for a single dimensional array whose lower bounds is 0 and + * whose upper bound is specified as a parameter + * + * @param vt + * type of the array + * @param celems + * length of the array + */ + public SafeArray(int vt, int celems) { + init(vt, new int[] { 0 }, new int[] { celems }); + } + + /** + * Creates a two dimensional SafeArray whose base indexes are 0. + * + * @param vt + * Type of the array + * @param celems1 + * length of the array in first dimension + * @param celems2 + * length of the array in second dimension + */ + public SafeArray(int vt, int celems1, int celems2) { + init(vt, new int[] { 0, 0 }, new int[] { celems1, celems2 }); + } + + /** + * Constructor with support for N-dimensional array support + *

+ * You create an N-D SafeArray by: SafeArray sa = new + * SafeArray(Variant.VariantVariant, new int[] {0,0,0,0}, new int[] + * {4,4,4,4}); Where the 1st array is lower bounds and 2nd has the lengths + * of each dimension * + * + * @param vt + * @param lbounds + * @param celems + */ + public SafeArray(int vt, int lbounds[], int celems[]) { + init(vt, lbounds, celems); + } + + /** + * convert a string to a VT_UI1 array + * + * @param s + * source string + */ + public SafeArray(String s) { + char[] ca = s.toCharArray(); + init(Variant.VariantByte, new int[] { 0 }, new int[] { ca.length }); + fromCharArray(ca); + } + + /** + * convert a VT_UI1 array to string + * + * @return variant byte as a string + */ + public String asString() { + if (getvt() != Variant.VariantByte) { + return null; + } + char ja[] = toCharArray(); + return new String(ja); + } + + public native Object clone(); + + /** + * now private so only this object can access. Was: call this to explicitly + * release the com object before gc + * + */ + private native void destroy(); + + /** + * {@inheritDoc} + */ + protected void finalize() { + safeRelease(); + } + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromBooleanArray(boolean ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromByteArray(byte ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromCharArray(char ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromDoubleArray(double ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromFloatArray(float ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromIntArray(int ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromLongArray(long ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromShortArray(short ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromStringArray(String ja[]); + + /** + * populate the safe array from the passed in array of data + * + * @param ja + */ + public native void fromVariantArray(Variant ja[]); + + /** + * boolean access + * + * @param sa_idx + * @return boolean representation + */ + public native boolean getBoolean(int sa_idx); + + /** + * get boolean value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native boolean getBoolean(int indices[]); + + /** + * boolean access + * + * @param sa_idx1 + * @param sa_idx2 + * @return boolean representation + */ + public native boolean getBoolean(int sa_idx1, int sa_idx2); + + /** + * boolean access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getBooleans(int sa_idx, int nelems, boolean ja[], + int ja_start); + + /** + * byte access + * + * @param sa_idx + * @return byte representaton + */ + public native byte getByte(int sa_idx); + + /** + * get byte value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native byte getByte(int indices[]); + + /** + * byte access + * + * @param sa_idx1 + * @param sa_idx2 + * @return byte representation + */ + public native byte getByte(int sa_idx1, int sa_idx2); + + /** + * Fills byte array from contents of this array + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getBytes(int sa_idx, int nelems, byte ja[], int ja_start); + + /** + * char access + * + * @param sa_idx + * @return single character rpeesentation + */ + public native char getChar(int sa_idx); + + /** + * get char value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native char getChar(int indices[]); + + /** + * char access + * + * @param sa_idx1 + * @param sa_idx2 + * @return single character representation + */ + public native char getChar(int sa_idx1, int sa_idx2); + + /** + * char access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getChars(int sa_idx, int nelems, char ja[], int ja_start); + + /** + * double access + * + * @param sa_idx + * @return double stored in array + */ + public native double getDouble(int sa_idx); + + /** + * get double value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native double getDouble(int indices[]); + + /** + * double access + * + * @param sa_idx1 + * @param sa_idx2 + * @return double stored in array + */ + public native double getDouble(int sa_idx1, int sa_idx2); + + /** + * double access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getDoubles(int sa_idx, int nelems, double ja[], + int ja_start); + + /** + * @return the size of each element? + */ + public native int getElemSize(); + + /** + * @return The ??features of the array? + */ + public native int getFeatures(); + + /** + * float access + * + * @param sa_idx + * @return float held in array at location + */ + public native float getFloat(int sa_idx); + + /** + * get float value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native float getFloat(int indices[]); + + /** + * float access + * + * @param sa_idx1 + * @param sa_idx2 + * @return float held in array at location + */ + public native float getFloat(int sa_idx1, int sa_idx2); + + /** + * float access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getFloats(int sa_idx, int nelems, float ja[], + int ja_start); + + /** + * get int from an single dimensional array + * + * @param sa_idx + * array index + * @return int stored in array + */ + public native int getInt(int sa_idx); + + /** + * get int value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native int getInt(int indices[]); + + /** + * get int from 2 dimensional array + * + * @param sa_idx1 + * array index first dimension + * @param sa_idx2 + * array index of second dimension + * @return int stored in array + */ + public native int getInt(int sa_idx1, int sa_idx2); + + /** + * retrieves a group of ints from a single dimensional array + * + * @param sa_idx + * the index in the array to start the get + * @param nelems + * number of elements to retrieve + * @param ja + * the structure to be filled with the ints + * @param ja_start + * the start point in the java int array to start filling + */ + public native void getInts(int sa_idx, int nelems, int ja[], int ja_start); + + /** + * get int from an single dimensional array + * + * @param sa_idx + * array index + * @return long stored in array + */ + public native long getLong(int sa_idx); + + /** + * get long value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native long getLong(int indices[]); + + /** + * get long from 2 dimensional array + * + * @param sa_idx1 + * array index first dimension + * @param sa_idx2 + * array index of second dimension + * @return long stored in array + */ + public native long getLong(int sa_idx1, int sa_idx2); + + /** + * retrieves a group of longs from a single dimensional array + * + * @param sa_idx + * the index in the array to start the get + * @param nelems + * number of elements to retrieve + * @param ja + * the structure to be filled with the longs + * @param ja_start + * the start point in the java longs array to start filling + */ + public native void getLongs(int sa_idx, int nelems, long ja[], int ja_start); + + /** + * @return The lower bounds of the array? + */ + public native int getLBound(); + + /** + * @param dim + * the dimension we are checking in a multidimensional array + * @return The lower bounds of the array? + */ + public native int getLBound(int dim); + + /** + * @return The number of dimensions in this array + */ + public native int getNumDim(); + + /** + * not implemented. + * + * @return 0 + */ + public int getNumLocks() { + return 0; + } + + /** + * short access + * + * @param sa_idx + * @return short stored in array + */ + public native short getShort(int sa_idx); + + /** + * get short value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native short getShort(int indices[]); + + /** + * short access + * + * @param sa_idx1 + * @param sa_idx2 + * @return short stored in array + */ + public native short getShort(int sa_idx1, int sa_idx2); + + /** + * short access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getShorts(int sa_idx, int nelems, short ja[], + int ja_start); + + /** + * string access + * + * @param sa_idx + * @return String stored in array + * + */ + public native String getString(int sa_idx); + + /** + * get String value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native String getString(int indices[]); + + /** + * string access + * + * @param sa_idx1 + * @param sa_idx2 + * @return String stored in array + */ + public native String getString(int sa_idx1, int sa_idx2); + + /** + * string access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getStrings(int sa_idx, int nelems, String ja[], + int ja_start); + + /** + * @return The upper bounds of the array? + */ + public native int getUBound(); + + /** + * @param dim + * the dimension we are checking in a multidimensional array + * @return The upper bounds of the array? + */ + public native int getUBound(int dim); + + /** + * variant access + * + * @param sa_idx + * @return Variant held in location in the array? + */ + public native Variant getVariant(int sa_idx); + + /** + * get Variant value from N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @return the value at the specified location + */ + public native Variant getVariant(int indices[]); + + /** + * variant access + * + * @param sa_idx1 + * @param sa_idx2 + * @return Variant held in a location in the array? + */ + public native Variant getVariant(int sa_idx1, int sa_idx2); + + /** + * variant access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void getVariants(int sa_idx, int nelems, Variant ja[], + int ja_start); + + /** + * @return the Variant type + */ + public native int getvt(); + + protected native void init(int vt, int lbounds[], int celems[]); + + /** + * Does anyone want to document this? + * + * @param sa + */ + public native void reinit(SafeArray sa); + + /** + * Does anyone want to document this? + * + * @param vt + * the variant type? + */ + public native void reinterpretType(int vt); + + /** + * {@inheritDoc} + */ + public void safeRelease() { + super.safeRelease(); + if (m_pV != 0) { + destroy(); + m_pV = 0; + } else { + // looks like a double release + if (isDebugEnabled()) { + debug(this.getClass().getName() + ":" + this.hashCode() + + " double release"); + } + } + } + + /** + * boolean access + * + * @param sa_idx + * @param c + */ + public native void setBoolean(int sa_idx, boolean c); + + /** + * set boolean value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setBoolean(int indices[], boolean c); + + /** + * boolean access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setBoolean(int sa_idx1, int sa_idx2, boolean c); + + /** + * boolean access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setBooleans(int sa_idx, int nelems, boolean ja[], + int ja_start); + + /** + * byte access + * + * @param sa_idx + * @param c + */ + public native void setByte(int sa_idx, byte c); + + /** + * set byte value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setByte(int indices[], byte c); + + /** + * byte access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setByte(int sa_idx1, int sa_idx2, byte c); + + /** + * fills array with passed in bytes + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setBytes(int sa_idx, int nelems, byte ja[], int ja_start); + + /** + * char access + * + * @param sa_idx + * @param c + */ + public native void setChar(int sa_idx, char c); + + /** + * set char value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setChar(int indices[], char c); + + /** + * char access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setChar(int sa_idx1, int sa_idx2, char c); + + /** + * char access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setChars(int sa_idx, int nelems, char ja[], int ja_start); + + /** + * double access + * + * @param sa_idx + * @param c + */ + public native void setDouble(int sa_idx, double c); + + /** + * set double value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setDouble(int indices[], double c); + + /** + * double access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setDouble(int sa_idx1, int sa_idx2, double c); + + /** + * double access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setDoubles(int sa_idx, int nelems, double ja[], + int ja_start); + + /** + * float access + * + * @param sa_idx + * @param c + */ + public native void setFloat(int sa_idx, float c); + + /** + * set float value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setFloat(int indices[], float c); + + /** + * float access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setFloat(int sa_idx1, int sa_idx2, float c); + + /** + * float access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setFloats(int sa_idx, int nelems, float ja[], + int ja_start); + + /** + * sets the int value of an element in a single dimensional array + * + * @param sa_idx + * index into the array + * @param c + * the value to be set + */ + public native void setInt(int sa_idx, int c); + + /** + * set int value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setInt(int indices[], int c); + + /** + * sets the int value of a 2 dimensional array + * + * @param sa_idx1 + * index on the first dimension + * @param sa_idx2 + * index on the second dimension + * @param c + * the value to be set + */ + public native void setInt(int sa_idx1, int sa_idx2, int c); + + /** + * sets a group of ints into a single dimensional array + * + * @param sa_idx + * the index of the start of the array to put into + * @param nelems + * number of elements to be copied + * @param ja + * the new int values to be put into the array + * @param ja_start + * the start index in the array that we are copying into + * SafeArray + */ + public native void setInts(int sa_idx, int nelems, int ja[], int ja_start); + + /** + * sets the long value of an element in a single dimensional array + * + * @param sa_idx + * index into the array + * @param c + * the value to be set + */ + public native void setLong(int sa_idx, long c); + + /** + * set long value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setLong(int indices[], long c); + + /** + * sets the long value of a 2 dimensional array + * + * @param sa_idx1 + * index on the first dimension + * @param sa_idx2 + * index on the second dimension + * @param c + * the value to be set + */ + public native void setLong(int sa_idx1, int sa_idx2, long c); + + /** + * sets a group of longs into a single dimensional array + * + * @param sa_idx + * the index of the start of the array to put into + * @param nelems + * number of elements to be copied + * @param ja + * the new long values to be put into the array + * @param ja_start + * the start index in the array that we are copying into + * SafeArray + */ + public native void setLongs(int sa_idx, int nelems, long ja[], int ja_start); + + /** + * short access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setShort(int sa_idx1, int sa_idx2, short c); + + /** + * short access + * + * @param sa_idx + * @param c + */ + public native void setShort(int sa_idx, short c); + + /** + * set short value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setShort(int indices[], short c); + + /** + * short access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setShorts(int sa_idx, int nelems, short ja[], + int ja_start); + + /** + * puts a string into an element in a two dimensional array. + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setString(int sa_idx1, int sa_idx2, String c); + + /* + * ================================================================ The + * beginning of N-dimensional array support + * ================================================================ + */ + + /** + * puts a string into an element in a single dimensional safe array + * + * @param sa_idx + * @param c + */ + public native void setString(int sa_idx, String c); + + /** + * set Stringvalue in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param c + */ + public native void setString(int indices[], String c); + + /** + * string access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setStrings(int sa_idx, int nelems, String ja[], + int ja_start); + + /** + * variant access + * + * @param sa_idx1 + * @param sa_idx2 + * @param c + */ + public native void setVariant(int sa_idx1, int sa_idx2, Variant c); + + /** + * variant access + * + * @param sa_idx + * @param c + */ + public native void setVariant(int sa_idx, Variant c); + + /** + * set Variant value in N-dimensional array + * + * @param indices - + * length must equal Dimension of SafeArray + * @param v + */ + public native void setVariant(int indices[], Variant v); + + /** + * variant access + * + * @param sa_idx + * @param nelems + * @param ja + * @param ja_start + */ + public native void setVariants(int sa_idx, int nelems, Variant ja[], + int ja_start); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return boolean[] array of booleans contained in this collection + */ + public native boolean[] toBooleanArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return byte[] byte array contained in this collection + */ + public native byte[] toByteArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return char[] character array contained in this collection + */ + public native char[] toCharArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return double[] double array contained in this collection + */ + public native double[] toDoubleArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return float[] array of float contained in this collection + */ + public native float[] toFloatArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return int[] int array contained in this collection + */ + public native int[] toIntArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return long[] long array contained in this collection + */ + public native long[] toLongArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return short[] short array contained in this collection + */ + public native short[] toShortArray(); + + /** + * Standard toString() Warning, this creates new Variant objects! + * + * @return String contents of variant + */ + public String toString() { + String s = ""; + int ndim = getNumDim(); + if (ndim == 1) { + int ldim = getLBound(); + int udim = getUBound(); + for (int i = ldim; i <= udim; i++) { + Variant v = getVariant(i); + + if (((v.getvt() & Variant.VariantTypeMask) | Variant.VariantArray) == v + .getvt()) { + return s + "[" + v.toSafeArray().toString() + "]"; + } else { + s += " " + v.toString(); + } + } + } else if (ndim == 2) { + int ldim1 = getLBound(1); + int udim1 = getUBound(1); + + int ldim2 = getLBound(2); + int udim2 = getUBound(2); + + for (int i = ldim1; i <= udim1; i++) { + for (int j = ldim2; j <= udim2; j++) { + Variant v = getVariant(i, j); + s += " " + v.toString(); + } + s += "\n"; + } + } + return s; + } + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return String[] String array contained in this collection + */ + public native String[] toStringArray(); + + /** + * Retrieves the data from the array cast to a Java data type + * + * @return Variant[] array of variants contained in this collection + */ + public native Variant[] toVariantArray(); + +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/Variant.java b/vendor/jacob/1.15-M4/java/com/jacob/com/Variant.java new file mode 100644 index 0000000..91ae210 --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/Variant.java @@ -0,0 +1,2235 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; + +/** + * The multi-format data type used for all call backs and most communications + * between Java and COM. It provides a single class that can handle all data + * types. + *

+ * Just loading this class creates 3 variants that get added to the ROT + *

+ * PROPVARIANT introduces new types so eventually Variant will need to be + * upgraded to support PropVariant types. + * http://blogs.msdn.com/benkaras/archive/2006/09/13/749962.aspx + *

+ * This object no longer implements Serializable because serialization is broken + * (and has been since 2000/xp). The underlying marshalling/unmarshalling code + * is broken in the JNI layer. + */ +public class Variant extends JacobObject { + + /** + * Use this constant for optional parameters + */ + public final static com.jacob.com.Variant DEFAULT; + + /** + * Same than {@link #DEFAULT} + */ + public final static com.jacob.com.Variant VT_MISSING; + + /** + * Use for true/false variant parameters + */ + public final static com.jacob.com.Variant VT_TRUE = new com.jacob.com.Variant( + true); + + /** + * Use for true/false variant parameters + */ + public final static com.jacob.com.Variant VT_FALSE = new com.jacob.com.Variant( + false); + + /** variant's type is empty : equivalent to VB Nothing and VT_EMPTY */ + public static final short VariantEmpty = 0; + + /** variant's type is null : equivalent to VB Null and VT_NULL */ + public static final short VariantNull = 1; + + /** variant's type is short VT_I2 */ + public static final short VariantShort = 2; + + /** variant's type is int VT_I4, a Long in VC */ + public static final short VariantInt = 3; + + /** variant's type is float VT_R4 */ + public static final short VariantFloat = 4; + + /** variant's type is double VT_R8 */ + public static final short VariantDouble = 5; + + /** variant's type is currency VT_CY */ + public static final short VariantCurrency = 6; + + /** variant's type is date VT_DATE */ + public static final short VariantDate = 7; + + /** variant's type is string also known as VT_BSTR */ + public static final short VariantString = 8; + + /** variant's type is dispatch VT_DISPATCH */ + public static final short VariantDispatch = 9; + + /** variant's type is error VT_ERROR */ + public static final short VariantError = 10; + + /** variant's type is boolean VT_BOOL */ + public static final short VariantBoolean = 11; + + /** variant's type is variant it encapsulate another variant VT_VARIANT */ + public static final short VariantVariant = 12; + + /** variant's type is object VT_UNKNOWN */ + public static final short VariantObject = 13; + + /** variant's type is object VT_DECIMAL */ + public static final short VariantDecimal = 14; + + // VT_I1 = 16 + + /** variant's type is byte VT_UI1 */ + public static final short VariantByte = 17; + + // VT_UI2 = 18 + // VT_UI4 = 19 + + /** + * variant's type is 64 bit long integer VT_I8 - not yet implemented in + * Jacob because we have to decide what to do with Currency and because its + * only supported on XP and later. No win2k, NT or 2003 server. + */ + public static final short VariantLongInt = 20; + + // VT_UI8 = 21 + // VT_INT = 22 + // VT_UNIT = 23 + // VT_VOID = 24 + // VT_HRESULT = 25 + + /** + * This value is for reference only and is not to be used by any callers + */ + public static final short VariantPointer = 26; + + // VT_SAFEARRAY = 27 + // VT_CARRARY = 28 + // VT_USERDEFINED = 29 + + /** what is this? VT_TYPEMASK && VT_BSTR_BLOB 0xfff */ + public static final short VariantTypeMask = 4095; + + /** variant's type is array VT_ARRAY 0x2000 */ + public static final short VariantArray = 8192; + + /** variant's type is a reference (to IDispatch?) VT_BYREF 0x4000 */ + public static final short VariantByref = 16384; + + /* + * Do the run time definition of DEFAULT and MISSING. Have to use static + * block because of the way the initialization is done via two calls instead + * of just a constructor for this type. + */ + static { + com.jacob.com.Variant vtMissing = new com.jacob.com.Variant(); + vtMissing.putVariantNoParam(); + DEFAULT = vtMissing; + VT_MISSING = vtMissing; + } + + /** + * Pointer to MS struct. + */ + int m_pVariant = 0; + + /** + * public constructor, initializes and sets type to VariantEmpty + */ + public Variant() { + this(null, false); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(boolean in) { + this(new Boolean(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(byte in) { + this(new Byte(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(double in) { + this(new Double(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(float in) { + this(new Float(in)); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(int in) { + this(new Integer(in)); + }; + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(long in) { + this(new Long(in)); + } + + /** + * Convenience constructor that calls the main one with a byRef value of + * false + * + * @param in + * object to be made into variant + */ + public Variant(Object in) { + this(in, false); + } + + /** + * Constructor that accepts the data object and information about whether + * this is by reference or not. It calls the JavaVariantConverter to + * actually push the data into the newly created Variant. + * + * @param pValueObject + * The value object that will pushed down into windows memory. A + * null object sets this to "empty" + * @param fByRef + */ + public Variant(Object pValueObject, boolean fByRef) { + init(); + VariantUtilities.populateVariant(this, pValueObject, fByRef); + } + + /** + * Constructor that accepts a primitive rather than an object + * + * @param in + */ + public Variant(short in) { + this(new Short(in)); + } + + /** + * Cover for native method so we can cover it. + *

+ * This cannot convert an object to a byRef. It can convert from byref to + * not byref + * + * @param in + * type to convert this variant too + * @return Variant returns this same object so folks can change when + * replacing calls toXXX() with changeType().getXXX() + */ + public Variant changeType(short in) { + changeVariantType(in); + return this; + } + + /** + * Converts variant to the passed in type by converting the underlying + * windows variant structure. private so folks use public java method + * + * @param in + * the desired resulting type + */ + private native void changeVariantType(short in); + + /** + * this returns null + * + * @return ?? comment says null? + */ + @Override + public native Object clone(); + + /** + * @deprecated No longer used + * @return null ! + */ + @Deprecated + public native Variant cloneIndirect(); + + /* + * (non-Javadoc) + * + * @see java.lang.Object#finalize() + */ + @Override + protected void finalize() { + safeRelease(); + } + + /** + * + * @return returns the value as a boolean, throws an exception if its not. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public boolean getBoolean() { + if (this.getvt() == VariantBoolean) { + return getVariantBoolean(); + } else { + throw new IllegalStateException( + "getBoolean() only legal on Variants of type VariantBoolean, not " + + this.getvt()); + } + } + + /** + * public cover for native method + * + * @return the boolean from a booleanRef + * @throws IllegalStateException + * if variant is not of the requested type + */ + public boolean getBooleanRef() { + if ((this.getvt() & VariantTypeMask) == VariantBoolean + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantBooleanRef(); + } else { + throw new IllegalStateException( + "getBooleanRef() only legal on byRef Variants of type VariantBoolean, not " + + this.getvt()); + } + } + + /** + * + * @return returns the value as a boolean, throws an exception if its not. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public byte getByte() { + if (this.getvt() == VariantByte) { + return getVariantByte(); + } else { + throw new IllegalStateException( + "getByte() only legal on Variants of type VariantByte, not " + + this.getvt()); + } + } + + /** + * public cover for native method + * + * @return the byte from a booleanRef + * @throws IllegalStateException + * if variant is not of the requested type + */ + public byte getByteRef() { + if ((this.getvt() & VariantTypeMask) == VariantByte + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantByteRef(); + } else { + throw new IllegalStateException( + "getByteRef() only legal on byRef Variants of type VariantByte, not " + + this.getvt()); + } + } + + /** + * MS Currency objects are 64 bit fixed point numbers with 15 digits to the + * left and 4 to the right of the decimal place. + * + * @return returns the currency value as a long, throws exception if not a + * currency type.. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Currency getCurrency() { + if (this.getvt() == VariantCurrency) { + return new Currency(getVariantCurrency()); + } else { + throw new IllegalStateException( + "getCurrency() only legal on Variants of type VariantCurrency, not " + + this.getvt()); + } + } + + /** + * MS Currency objects are 64 bit fixed point numbers with 15 digits to the + * left and 4 to the right of the decimal place. + * + * @return returns the currency value as a long, throws exception if not a + * currency type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Currency getCurrencyRef() { + if ((this.getvt() & VariantTypeMask) == VariantCurrency + && (this.getvt() & VariantByref) == VariantByref) { + return new Currency(getVariantCurrencyRef()); + } else { + throw new IllegalStateException( + "getCurrencyRef() only legal on byRef Variants of type VariantCurrency, not " + + this.getvt()); + } + } + + /** + * @return double return the date (as a double) value held in this variant + * (fails on other types?) + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDate() { + if (this.getvt() == VariantDate) { + return getVariantDate(); + } else { + throw new IllegalStateException( + "getDate() only legal on Variants of type VariantDate, not " + + this.getvt()); + } + } + + /** + * + * @return returns the date value as a double, throws exception if not a + * date type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDateRef() { + if ((this.getvt() & VariantTypeMask) == VariantDate + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantDateRef(); + } else { + throw new IllegalStateException( + "getDateRef() only legal on byRef Variants of type VariantDate, not " + + this.getvt()); + } + } + + /** + * return the BigDecimal value held in this variant (fails on other types) + * + * @return BigDecimal + * @throws IllegalStateException + * if variant is not of the requested type + */ + public BigDecimal getDecimal() { + if (this.getvt() == VariantDecimal) { + return (BigDecimal) (getVariantDec()); + } else { + throw new IllegalStateException( + "getDecimal() only legal on Variants of type VariantDecimal, not " + + this.getvt()); + } + } + + /** + * return the BigDecimal value held in this variant (fails on other types) + * + * @return BigDecimal + * @throws IllegalStateException + * if variant is not of the requested type + */ + public BigDecimal getDecimalRef() { + if ((this.getvt() & VariantTypeMask) == VariantDecimal + && (this.getvt() & VariantByref) == VariantByref) { + return (BigDecimal) (getVariantDecRef()); + } else { + throw new IllegalStateException( + "getDecimalRef() only legal on byRef Variants of type VariantDecimal, not " + + this.getvt()); + } + } + + /** + * cover for {@link #toDispatch()} This method now matches other getXXX() + * methods. It throws an IllegalStateException if the object is not of type + * VariantDispatch + * + * @return this object as a dispatch + * @throws IllegalStateException + * if wrong variant type + */ + public Dispatch getDispatch() { + if (this.getvt() == VariantDispatch) { + return toDispatch(); + } else { + throw new IllegalStateException( + "getDispatch() only legal on Variants of type VariantDispatch, not " + + this.getvt()); + } + } + + /** + * Dispatch and dispatchRef are treated the same This is just a cover for + * toDispatch() with a flag check + * + * @return the results of toDispatch() + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Dispatch getDispatchRef() { + if ((this.getvt() & VariantTypeMask) == VariantDispatch + && (this.getvt() & VariantByref) == VariantByref) { + return toDispatch(); + } else { + throw new IllegalStateException( + "getDispatchRef() only legal on byRef Variants of type VariantDispatch, not " + + this.getvt()); + } + } + + /** + * @return double return the double value held in this variant (fails on + * other types?) + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDouble() { + if (this.getvt() == VariantDouble) { + return getVariantDouble(); + } else { + throw new IllegalStateException( + "getDouble() only legal on Variants of type VariantDouble, not " + + this.getvt()); + } + } + + /** + * + * @return returns the double value, throws exception if not a Double type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public double getDoubleRef() { + if ((this.getvt() & VariantTypeMask) == VariantDouble + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantDoubleRef(); + } else { + throw new IllegalStateException( + "getDoubleRef() only legal on byRef Variants of type VariantDouble, not " + + this.getvt()); + } + } + + /** + * Pointless method that was put here so that putEmpty() has a get method. + * This would have returned null if the value was VT_EMPTY or if it wasn't + * so it would have always returned the same value. + * + * @deprecated method never did anything + */ + @Deprecated + public void getEmpty() { + } + + /** + * @return double return the error value held in this variant (fails on + * other types?) + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getError() { + if (this.getvt() == VariantError) { + return getVariantError(); + } else { + throw new IllegalStateException( + "getError() only legal on Variants of type VariantError, not " + + this.getvt()); + } + } + + /** + * + * @return returns the error value as an int, throws exception if not a + * Error type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getErrorRef() { + if ((this.getvt() & VariantTypeMask) == VariantError + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantErrorRef(); + } else { + throw new IllegalStateException( + "getErrorRef() only legal on byRef Variants of type VariantError, not " + + this.getvt()); + } + } + + /** + * @return returns the value as a float if the type is of type float + * @throws IllegalStateException + * if variant is not of the requested type + */ + public float getFloat() { + if (this.getvt() == VariantFloat) { + return getVariantFloat(); + } else { + throw new IllegalStateException( + "getFloat() only legal on Variants of type VariantFloat, not " + + this.getvt()); + } + } + + /** + * + * @return returns the float value, throws exception if not a Float type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public float getFloatRef() { + if ((this.getvt() & VariantTypeMask) == VariantFloat + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantFloatRef(); + } else { + throw new IllegalStateException( + "getFloatRef() only legal on byRef Variants of type VariantFloat, not " + + this.getvt()); + } + } + + /** + * return the int value held in this variant if it is an int or a short. + * Throws for other types. + * + * @return int contents of the windows memory + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getInt() { + if (this.getvt() == VariantInt) { + return getVariantInt(); + } else if (this.getvt() == VariantShort) { + return getVariantShort(); + } else { + throw new IllegalStateException( + "getInt() only legal on Variants of type VariantInt, not " + + this.getvt()); + } + } + + /** + * get the content of this variant as an int + * + * @return int + * @throws IllegalStateException + * if variant is not of the requested type + */ + public int getIntRef() { + if ((this.getvt() & VariantTypeMask) == VariantInt + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantIntRef(); + } else { + throw new IllegalStateException( + "getIntRef() only legal on byRef Variants of type VariantInt, not " + + this.getvt()); + } + } + + /** + * returns the windows time contained in this Variant to a Java Date. should + * return null if this is not a date Variant SF 959382 + * + * @return java.util.Date returns the date if this is a VariantDate != 0, + * null if it is a VariantDate == 0 and throws an + * IllegalStateException if this isn't a date. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public Date getJavaDate() { + Date returnDate = null; + if (getvt() == VariantDate) { + double windowsDate = getDate(); + if (windowsDate != 0) { + returnDate = DateUtilities.convertWindowsTimeToDate(getDate()); + } + } else { + throw new IllegalStateException( + "getJavaDate() only legal on Variants of type VariantDate, not " + + this.getvt()); + } + return returnDate; + } + + /** + * returns the windows time contained in this Variant to a Java Date should + * return null if this is not a date reference Variant SF 959382 + * + * @return java.util.Date + */ + public Date getJavaDateRef() { + double windowsDate = getDateRef(); + if (windowsDate == 0) { + return null; + } else { + return DateUtilities.convertWindowsTimeToDate(windowsDate); + } + } + + /** + * 64 bit Longs only available on x64. 64 bit long support added 1.14 + * + * @return returns the value as a long, throws exception if not a Long + * type.. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public long getLong() { + if (this.getvt() == VariantLongInt) { + return getVariantLong(); + } else { + throw new IllegalStateException( + "getLong() only legal on Variants of type VariantLongInt, not " + + this.getvt()); + } + } + + /** + * 64 bit Longs only available on x64. 64 bit long support added 1.14 + * + * @return returns the value as a long, throws exception if not a long type + * @throws IllegalStateException + * if variant is not of the requested type + */ + public long getLongRef() { + if ((this.getvt() & VariantTypeMask) == VariantLongInt + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantLongRef(); + } else { + throw new IllegalStateException( + "getLongRef() only legal on byRef Variants of type VariantLongInt, not " + + this.getvt()); + } + } + + /** + * This method would have returned null if the type was VT_NULL. But because + * we return null if the data is not of the right type, this method should + * have always returned null + * + * @deprecated method never did anything + */ + @Deprecated + public void getNull() { + } + + /** + * return the int value held in this variant (fails on other types?) + * + * @return int + * @throws IllegalStateException + * if variant is not of the requested type + */ + public short getShort() { + if (this.getvt() == VariantShort) { + return getVariantShort(); + } else { + throw new IllegalStateException( + "getShort() only legal on Variants of type VariantShort, not " + + this.getvt()); + } + } + + /** + * get the content of this variant as an int + * + * @return int + * @throws IllegalStateException + * if variant is not of the requested type + */ + public short getShortRef() { + if ((this.getvt() & VariantTypeMask) == VariantShort + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantShortRef(); + } else { + throw new IllegalStateException( + "getShortRef() only legal on byRef Variants of type VariantShort, not " + + this.getvt()); + } + } + + /** + * + * @return string contents of the variant. + * @throws IllegalStateException + * if this variant is not of type String + */ + public String getString() { + if (getvt() == Variant.VariantString) { + return getVariantString(); + } else { + throw new IllegalStateException( + "getString() only legal on Variants of type VariantString, not " + + this.getvt()); + } + } + + /** + * gets the content of the variant as a string ref + * + * @return String retrieved from the COM area. + * @throws IllegalStateException + * if variant is not of the requested type + */ + public String getStringRef() { + if ((this.getvt() & VariantTypeMask) == VariantString + && (this.getvt() & VariantByref) == VariantByref) { + return getVariantStringRef(); + } else { + throw new IllegalStateException( + "getStringRef() only legal on byRef Variants of type VariantString, not " + + this.getvt()); + } + } + + /** + * Used to get the value from a windows type of VT_VARIANT or a jacob + * Variant type of VariantVariant. Added 1.12 pre 6 - VT_VARIANT support is + * at an alpha level + * + * @return Object a java Object that represents the content of the enclosed + * Variant + */ + public Object getVariant() { + if ((this.getvt() & VariantTypeMask) == VariantVariant + && (this.getvt() & VariantByref) == VariantByref) { + if (JacobObject.isDebugEnabled()) { + JacobObject.debug("About to call getVariantVariant()"); + } + Variant enclosedVariant = new Variant(); + int enclosedVariantMemory = getVariantVariant(); + enclosedVariant.m_pVariant = enclosedVariantMemory; + Object enclosedVariantAsJava = enclosedVariant.toJavaObject(); + // zero out the reference to the underlying windows memory so that + // it is still only owned in one place by one java object + // (this object of type VariantVariant) + // enclosedVariant.putEmpty(); // don't know if this would have had + // side effects + if (JacobObject.isDebugEnabled()) { + JacobObject + .debug("Zeroing out enclosed Variant's ref to windows memory"); + } + enclosedVariant.m_pVariant = 0; + return enclosedVariantAsJava; + } else { + throw new IllegalStateException( + "getVariant() only legal on Variants of type VariantVariant, not " + + this.getvt()); + } + } + + /** + * @deprecated superseded by SafeArray + * @return never returns anything + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Variant[] getVariantArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * @return the Variant Array that represents the data in the Variant + * @deprecated superseded by SafeArray + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Variant[] getVariantArrayRef() { + throw new NotImplementedException("Not implemented"); + } + + /** + * + * @return the value in this Variant as a boolean, null if not a boolean + */ + private native boolean getVariantBoolean(); + + private native boolean getVariantBooleanRef(); + + /** + * @return the value in this Variant as a byte, null if not a byte + */ + private native byte getVariantByte(); + + /** + * @return the value in this Variant as a byte, null if not a byte + */ + private native byte getVariantByteRef(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantCurrency(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantCurrencyRef(); + + /** + * @return double return the date (as a double) value held in this variant + * (fails on other types?) + */ + private native double getVariantDate(); + + /** + * get the content of this variant as a double representing a date + * + * @return double + */ + private native double getVariantDateRef(); + + /** + * @return the value in this Variant as a decimal, null if not a decimal + */ + private native Object getVariantDec(); + + /** + * @return the value in this Variant (byref) as a decimal, null if not a + * decimal + */ + private native Object getVariantDecRef(); + + /** + * @return double get the content of this variant as a double + */ + private native double getVariantDouble(); + + /** + * @return double get the content of this variant as a double + */ + private native double getVariantDoubleRef(); + + private native int getVariantError(); + + private native int getVariantErrorRef(); + + /** + * @return returns the value as a float if the type is of type float + */ + private native float getVariantFloat(); + + /** + * @return returns the value as a float if the type is of type float + */ + private native float getVariantFloatRef(); + + /** + * @return the int value held in this variant (fails on other types?) + */ + private native int getVariantInt(); + + /** + * @return the int value held in this variant (fails on other types?) + */ + private native int getVariantIntRef(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantLong(); + + /** + * @return the value in this Variant as a long, null if not a long + */ + private native long getVariantLongRef(); + + /** + * get the content of this variant as a short + * + * @return short + */ + private native short getVariantShort(); + + /** + * @return short the content of this variant as a short + */ + private native short getVariantShortRef(); + + /** + * Native method that actually extracts a string value from the variant + * + * @return + */ + private native String getVariantString(); + + /** + * @return String the content of this variant as a string + */ + private native String getVariantStringRef(); + + /** + * Returns the variant type via a native method call + * + * @return short one of the VT_xx types + */ + private native short getVariantType(); + + /** + * Returns the variant type via a native method call. Added 1.12 pre 6 - + * VT_VARIANT support is at an alpha level + * + * @return Variant one of the VT_Variant types + */ + private native int getVariantVariant(); + + /** + * Reports the type of the underlying Variant object + * + * @return returns the variant type as a short, one of the Variantxxx values + * defined as statics in this class. returns VariantNull if not + * initialized + * @throws IllegalStateException + * if there is no underlying windows data structure + */ + public short getvt() { + if (m_pVariant != 0) { + return getVariantType(); + } else { + throw new IllegalStateException("uninitialized Variant"); + } + } + + /** + * initializes the COM Variant and puts its reference in this instance + */ + protected native void init(); + + /** + * + * @return returns true if the variant is considered null + * @throws IllegalStateException + * if there is no underlying windows memory + */ + public boolean isNull() { + getvt(); + return isVariantConsideredNull(); + } + + /** + * is the variant null or empty or error or null dispatch + * + * @return true if it is null or false if not + */ + private native boolean isVariantConsideredNull(); + + /** + * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND + * + * @deprecated replaced by putNoParam() + */ + @Deprecated + public void noParam() { + putNoParam(); + } + + /** + * returns true if the passed in Variant is a constant that should not be + * freed + * + * @param pVariant + * @return boolean that is true if Variant is a type of constant, VT_FALSE, + * VT_TRUE, VT_MISSING, DEFAULT + */ + protected boolean objectIsAConstant(Variant pVariant) { + if (pVariant == VT_FALSE || pVariant == VT_TRUE + || pVariant == VT_MISSING || pVariant == DEFAULT) { + return true; + } else { + return false; + } + + } + + /** + * puts a boolean into the variant and sets it's type + * + * @param in + * the new value + */ + public void putBoolean(boolean in) { + // verify we aren't released yet + getvt(); + putVariantBoolean(in); + } + + /** + * pushes a boolean into the variant by ref and sets the type of the variant + * to boolean + * + * @param in + */ + public void putBooleanRef(boolean in) { + // verify we aren't released yet + getvt(); + putVariantBooleanRef(in); + } + + /** + * pushes a byte into the varaint and sets the type + * + * @param in + */ + public void putByte(byte in) { + // verify we aren't released yet + getvt(); + putVariantByte(in); + }; + + /** + * @deprecated superseded by SafeArray + * @param in + * doesn't matter because this method does nothing + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putByteArray(Object in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * pushes a byte into the variant by ref and sets the type + * + * @param in + */ + public void putByteRef(byte in) { + // verify we aren't released yet + getvt(); + putVariantByteRef(in); + } + + /** + * @param in + * the object that would be wrapped by the Variant if this method + * was implemented + * @deprecated superseded by SafeArray + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putCharArray(Object in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * Puts a value in as a currency and sets the variant type. MS Currency + * objects are 64 bit fixed point numbers with 15 digits to the left and 4 + * to the right of the decimal place. + * + * @param in + * the long that will be put into the 64 bit currency object. + */ + public void putCurrency(Currency in) { + // verify we aren't released yet + getvt(); + putVariantCurrency(in.longValue()); + } + + /** + * Pushes a long into the variant as currency and sets the type. MS Currency + * objects are 64 bit fixed point numbers with 15 digits to the left and 4 + * to the right of the decimal place. + * + * @param in + * the long that will be put into the 64 bit currency object + */ + public void putCurrencyRef(Currency in) { + // verify we aren't released yet + getvt(); + putVariantCurrencyRef(in.longValue()); + } + + /** + * converts a java date to a windows time and calls putDate(double) SF + * 959382 + * + * @param inDate + * a Java date to be converted + * @throws IllegalArgumentException + * if inDate = null + */ + public void putDate(Date inDate) { + if (inDate == null) { + throw new IllegalArgumentException( + "Cannot put null in as windows date"); + // do nothing + } else { + putDate(DateUtilities.convertDateToWindowsTime(inDate)); + } + } + + /** + * puts a windows date double into the variant and sets the type + * + * @param in + */ + public void putDate(double in) { + // verify we aren't released yet + getvt(); + putVariantDate(in); + } + + /** + * converts a java date to a windows time and calls putDateRef(double) SF + * 959382 + * + * @param inDate + * a Java date to be converted + * @throws IllegalArgumentException + * if inDate = null + */ + public void putDateRef(Date inDate) { + if (inDate == null) { + throw new IllegalArgumentException( + "Cannot put null in as windows date"); + // do nothing + } else { + putDateRef(DateUtilities.convertDateToWindowsTime(inDate)); + } + } + + /** + * set the content of this variant to a date (VT_DATE|VT_BYREF) + * + * @param in + */ + public void putDateRef(double in) { + // verify we aren't released + getvt(); + putVariantDateRef(in); + } + + /** + * This actual does all the validating and massaging of the BigDecimalValues + * when converting them to MS Decimal types + * + * @param in + * number to be made into VT_DECIMAL + * @param byRef + * store by reference or not + * @param roundingBehavior + * one of the BigDecimal ROUND_xxx methods. Any method other than + * ROUND_UNECESSARY means that the value will be rounded to fit + */ + private void putDecimal(BigDecimal in, boolean byRef) { + // verify we aren't released + getvt(); + // first validate the min and max + VariantUtilities.validateDecimalMinMax(in); + BigInteger allWordBigInt; + allWordBigInt = in.unscaledValue(); + // Assume any required rounding has been done. + VariantUtilities.validateDecimalScaleAndBits(in); + // finally we can do what we actually came here to do + int sign = in.signum(); + // VT_DECIMAL always has positive value with just the sign + // flipped + if (in.signum() < 0) { + in = in.negate(); + } + // ugh, reusing allWordBigInt but now should always be positive + // and any round is applied + allWordBigInt = in.unscaledValue(); + byte scale = (byte) in.scale(); + int lowWord = allWordBigInt.intValue(); + BigInteger middleWordBigInt = allWordBigInt.shiftRight(32); + int middleWord = middleWordBigInt.intValue(); + BigInteger highWordBigInt = allWordBigInt.shiftRight(64); + int highWord = highWordBigInt.intValue(); + if (byRef) { + putVariantDecRef(sign, scale, lowWord, middleWord, highWord); + } else { + putVariantDec(sign, scale, lowWord, middleWord, highWord); + } + } + + /** + * EXPERIMENTAL 1.14 feature to support rounded decimals. + *

+ * Set the value of this variant and set the type. This may throw exceptions + * more often than the caller expects because most callers don't manage the + * scale of their BigDecimal objects. + *

+ * This default set method throws exceptions if precision or size is out of + * bounds + *

+ * There are 12 bytes available for the integer number. + *

+ * There is 1 byte for the scale. + * + * @param in + * the BigDecimal that will be converted to VT_DECIMAL + * @throws IllegalArgumentException + * if the scale is > 28, the maximum for VT_DECIMAL or if there + * are more than 12 bytes worth the digits + */ + public void putDecimal(BigDecimal in) { + putDecimal(in, false); + } + + /** + * Set the value of this variant and set the type. This may throw exceptions + * more often than the caller expects because most callers don't manage the + * scale of their BigDecimal objects. + *

+ * This default set method throws exceptions if precision or size is out of + * bounds + *

+ * There are 12 bytes available for the integer number. + *

+ * There is 1 byte for the scale. + * + * @param in + * the BigDecimal that will be converted to VT_DECIMAL + * @throws IllegalArgumentException + * if the scale is > 28, the maximum for VT_DECIMAL or if there + * are more than 12 bytes worth the digits + */ + public void putDecimalRef(BigDecimal in) { + putDecimal(in, true); + } + + /** + * This acts a cover for putVariant Dispatch. + * + * @param in + * the Dispatch we're putting down in the COM variant space. + */ + public void putDispatch(Dispatch in) { + putVariantDispatch(in); + } + + /** + * Dispatch and dispatchRef are treated the same This is a cover for + * putVariantDispatch(). putDispatch and putDispatchRef are treated the same + * because no one has written the COM code for putDispatchRef. + * + * @param in + * the Dispatch we're putting down in the COM variant space. + */ + public void putDispatchRef(Dispatch in) { + putVariantDispatch(in); + } + + /** + * wraps this Variant around the passed in double. + * + * @param in + */ + public void putDouble(double in) { + // verify we aren't released yet + getvt(); + putVariantDouble(in); + } + + /** + * set the content of this variant to a double (VT_R8|VT_BYREF) + * + * @param in + */ + public void putDoubleRef(double in) { + // verify we aren't released + getvt(); + putVariantDoubleRef(in); + } + + /** + * sets the type to VariantEmpty + * + */ + public void putEmpty() { + // verify we aren't released yet + getvt(); + putVariantEmpty(); + } + + /** + * puts an error code (I think) into the variant and sets the type + * + * @param in + */ + public void putError(int in) { + // verify we aren't released yet + getvt(); + putVariantError(in); + } + + /** + * pushes an error code into the variant by ref and sets the type + * + * @param in + */ + public void putErrorRef(int in) { + // verify we aren't released yet + getvt(); + putVariantErrorRef(in); + } + + /** + * fills the Variant with a float and sets the type to float + * + * @param in + */ + public void putFloat(float in) { + // verify we haven't been released yet + getvt(); + putVariantFloat(in); + } + + /** + * pushes a float into the variant and sets the type + * + * @param in + */ + public void putFloatRef(float in) { + // verify we aren't released yet + getvt(); + putVariantFloatRef(in); + } + + /** + * set the value of this variant and set the type + * + * @param in + */ + public void putInt(int in) { + // verify we aren't released yet + getvt(); + putVariantInt(in); + } + + /** + * set the content of this variant to an int (VT_I4|VT_BYREF) + * + * @param in + */ + public void putIntRef(int in) { + // verify we aren't released + getvt(); + putVariantIntRef(in); + } + + /** + * Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64 + * systems otherwise throws an error. 64 bit long support added 1.14 + * + * @param in + * the long that will be put into the 64 bit Long object. + */ + public void putLong(long in) { + // verify we aren't released yet + getvt(); + putVariantLong(in); + } + + /** + * Puts a 64 bit Java Long into a 64 bit Variant Long. Only works on x64 + * systems otherwise throws an error. 64 bit long support added 1.14 + * + * @param in + * the long that will be put into the 64 bit Long object. + */ + public void putLongRef(long in) { + // verify we aren't released yet + getvt(); + putVariantLongRef(in); + } + + /** + * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND + */ + public void putNoParam() { + // verify we aren't released yet + getvt(); + putVariantNoParam(); + } + + /** + * Sets the type to VariantDispatch and sets the value to null Equivalent to + * VB's nothing + */ + public void putNothing() { + // verify we aren't released yet + getvt(); + putVariantNothing(); + } + + /** + * Set this Variant's type to VT_NULL (the VB equivalent of NULL) + */ + public void putNull() { + // verify we aren't released yet + getvt(); + putVariantNull(); + } + + /** + * Puts an object into the Variant -- converts to Dispatch. Acts as a cover + * for putVariantDispatch(); This primarily exists to support jacobgen. This + * should be deprecated. + * + * @param in + * the object we are putting into the Variant, assumes a + * @see Variant#putDispatch(Dispatch) + * @deprecated should use putDispatch() + */ + @Deprecated + public void putObject(Object in) { + // this should verify in instanceof Dispatch + putVariantDispatch(in); + } + + /** + * Just a cover for putObject(). We shouldn't accept any old random object. + * This has been left in to support jacobgen. This should be deprecated. + * + * @param in + * @deprecated + */ + @Deprecated + public void putObjectRef(Object in) { + putObject(in); + } + + /** + * have no idea... + * + * @param in + */ + public void putSafeArray(SafeArray in) { + // verify we haven't been released yet + getvt(); + putVariantSafeArray(in); + } + + /** + * have no idea... + * + * @param in + */ + public void putSafeArrayRef(SafeArray in) { + // verify we haven't been released yet + getvt(); + putVariantSafeArrayRef(in); + } + + /** + * set the content of this variant to a short (VT_I2) + * + * @param in + */ + public void putShort(short in) { + // verify we aren't released + getvt(); + putVariantShort(in); + } + + /** + * set the content of this variant to a short (VT_I2|VT_BYREF) + * + * @param in + */ + public void putShortRef(short in) { + // verify we aren't released + getvt(); + putVariantShortRef(in); + } + + /** + * put a string into the variant and set its type + * + * @param in + */ + public void putString(String in) { + // verify we aren't released yet + getvt(); + putVariantString(in); + } + + /** + * set the content of this variant to a string (VT_BSTR|VT_BYREF) + * + * @param in + */ + public void putStringRef(String in) { + // verify we aren't released + getvt(); + putVariantStringRef(in); + } + + /** + * Puts a variant into this variant making it type VT_VARIANT. Added 1.12 + * pre 6 + * + * @param objectToBeWrapped + * A object that is to be referenced by this variant. If + * objectToBeWrapped is already of type Variant, then it is used. + * If objectToBeWrapped is not Variant then + * new Variant(objectToBeWrapped) is called and the + * result is passed into the com layer + * @throws IllegalArgumentException + * if inVariant = null or if inVariant is a Varint + */ + public void putVariant(Object objectToBeWrapped) { + if (objectToBeWrapped == null) { + throw new IllegalArgumentException( + "Cannot put null in as a variant"); + } else if (objectToBeWrapped instanceof Variant) { + throw new IllegalArgumentException( + "Cannot putVariant() only accepts non jacob objects."); + } else { + Variant inVariant = new Variant(objectToBeWrapped); + putVariantVariant(inVariant); + // This could be done in Variant.cpp + if (JacobObject.isDebugEnabled()) { + JacobObject + .debug("Zeroing out enclosed Variant's ref to windows memory"); + } + inVariant.m_pVariant = 0; + } + } + + /** + * @deprecated superseded by SafeArray + * @param in + * doesn't matter because this method does nothing + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putVariantArray(Variant[] in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * @param in + * the thing that would be come an array if this method was + * implemented + * @deprecated superseded by SafeArray + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public void putVariantArrayRef(Variant[] in) { + throw new NotImplementedException("Not implemented"); + } + + /** + * puts a boolean into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantBoolean(boolean in); + + /** + * puts a boolean into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantBooleanRef(boolean in); + + /** + * puts a byte into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantByte(byte in); + + /** + * puts a byte into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantByteRef(byte in); + + /** + * puts a Currency into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantCurrency(long in); + + /** + * puts a Currency into the variant and sets it's type + * + * @param in + * the new value + */ + private native void putVariantCurrencyRef(long in); + + /** + * set the value of this variant + * + * @param in + */ + private native void putVariantDate(double in); + + /** + * set the content of this variant to a date (VT_DATE|VT_BYREF) + * + * @param in + */ + private native void putVariantDateRef(double in); + + /** + * private JNI method called by putDecimal + * + * @param signum + * sign + * @param scale + * BigDecimal's scale + * @param lo + * low 32 bits + * @param mid + * middle 32 bits + * @param hi + * high 32 bits + */ + private native void putVariantDec(int signum, byte scale, int lo, int mid, + int hi); + + /** + * private JNI method called by putDecimalRef + * + * @param signum + * sign + * @param scale + * BigDecimal's scale + * @param lo + * low 32 bits + * @param mid + * middle 32 bits + * @param hi + * high 32 bits + */ + private native void putVariantDecRef(int signum, byte scale, int lo, + int mid, int hi); + + /** + * the JNI implementation for putDispatch() so that we can screen the + * incoming dispatches in putDispatch() before this is invoked + * + * @param in + * should be a dispatch object + */ + private native void putVariantDispatch(Object in); + + private native void putVariantDouble(double in); + + /** + * set the content of this variant to a double (VT_R8|VT_BYREF) + * + * @param in + */ + private native void putVariantDoubleRef(double in); + + /** + * Sets the type to VariantEmpty. No values needed + */ + private native void putVariantEmpty(); + + private native void putVariantError(int in); + + private native void putVariantErrorRef(int in); + + /** + * fills the Variant with a float and sets the type to float + * + * @param in + */ + private native void putVariantFloat(float in); + + private native void putVariantFloatRef(float in); + + /** + * set the value of this variant and set the type + * + * @param in + */ + private native void putVariantInt(int in); + + /** + * set the content of this variant to an int (VT_I4|VT_BYREF) + * + * @param in + */ + private native void putVariantIntRef(int in); + + private native void putVariantLong(long in); + + private native void putVariantLongRef(long in); + + /** + * sets the type to VT_ERROR and the error message to DISP_E_PARAMNOTFOIUND + */ + private native void putVariantNoParam(); + + /** + * Sets the type to VariantDispatch and sets the value to null Equivalent to + * VB's nothing + */ + private native void putVariantNothing(); + + /** + * Set this Variant's type to VT_NULL (the VB equivalent of NULL) + */ + private native void putVariantNull(); + + private native void putVariantSafeArray(SafeArray in); + + private native void putVariantSafeArrayRef(SafeArray in); + + /** + * set the content of this variant to a short (VT_I2) + * + * @param in + */ + private native void putVariantShort(short in); + + /** + * set the content of this variant to a short (VT_I2|VT_BYREF) + * + * @param in + */ + private native void putVariantShortRef(short in); + + private native void putVariantString(String in); + + /** + * set the content of this variant to a string (VT_BSTR|VT_BYREF) + * + * @param in + */ + private native void putVariantStringRef(String in); + + /** + * All VariantVariant type variants are BYREF. + * + * Set the content of this variant to a string (VT_VARIANT|VT_BYREF). + * + * Added 1.12 pre 6 - VT_VARIANT support is at an alpha level + * + * @param in + * variant to be wrapped + * + */ + private native void putVariantVariant(Variant in); + + /** + * now private so only this object can access was: call this to explicitly + * release the com object before gc + * + */ + private native void release(); + + /** + * This will release the "C" memory for the Variant unless this Variant is + * one of the constants in which case we don't want to release the memory. + *

+ * + * @see com.jacob.com.JacobObject#safeRelease() + */ + @Override + public void safeRelease() { + // The well known constants should not be released. + // Unfortunately this doesn't fix any other classes that are + // keeping constants around in their static ivars. + // those will still be busted. + // + // The only inconsistency here is that we leak + // when this class is unloaded because we won't + // free the memory even if the constants are being + // finalized. this is not a big deal at all. + // another way around this would be to create the constants + // in their own thread so that they would never be released + if (!objectIsAConstant(this)) { + super.safeRelease(); + if (m_pVariant != 0) { + release(); + m_pVariant = 0; + } else { + // looks like a double release + // this should almost always happen due to gc + // after someone has called ComThread.Release + if (isDebugEnabled()) { + debug("Variant: " + this.hashCode() + " double release"); + // Throwable x = new Throwable(); + // x.printStackTrace(); + } + } + } else { + if (isDebugEnabled()) { + debug("Variant: " + this.hashCode() + + " don't want to release a constant"); + } + } + } + + /** + * this is supposed to cause the underlying variant object struct to be + * rebuilt from a previously serialized byte array. + * + * @param ba + */ + protected native void SerializationReadFromBytes(byte[] ba); + + /** + * this is supposed to create a byte array that represents the underlying + * variant object structure + */ + protected native byte[] SerializationWriteToBytes(); + + /** + * @deprecated should be replaced by changeType() followed by getBoolean() + * @return the value of this variant as boolean (after possible conversion) + */ + @Deprecated + public boolean toBoolean() { + changeType(Variant.VariantBoolean); + return getBoolean(); + } + + /** + * attempts to return the content of this variant as a double (after + * possible conversion) + * + * @deprecated should be replaced by changeType() followed by getByte() + * @return byte + */ + @Deprecated + public byte toByte() { + changeType(Variant.VariantByte); + return getByte(); + } + + /** + * @deprecated superseded by SafeArray + * @return nothing because this method is not implemented + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Object toByteArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * @deprecated superseded by SafeArray + * @return never returns anything + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Object toCharArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * @deprecated should be replaced by changeType() followed by getCurrency + * @return the content of this variant as a long representing a monetary + * amount + */ + @Deprecated + public Currency toCurrency() { + changeType(Variant.VariantCurrency); + return getCurrency(); + } + + /** + * @deprecated should use changeType() followed by getDate() + * @return the value of this variant as a date (after possible conversion) + */ + @Deprecated + public double toDate() { + changeType(VariantDate); + return getDate(); + } + + /** + * @return the content of this variant as a Dispatch object (after possible + * conversion) + */ + public Dispatch toDispatch() { + // now make the native call + return toVariantDispatch(); + } + + /** + * @deprecated should call changeType() then getDouble() + * @return the content of this variant as a double (after possible + * conversion) + */ + @Deprecated + public double toDouble() { + changeType(Variant.VariantDouble); + return getDouble(); + } + + /** @return the value of this variant as an enumeration (java style) */ + public native EnumVariant toEnumVariant(); + + /** + * converts to an error type and returns the error + * + * @deprecated should use changeType() followed by getError() + * @return the error as an int (after conversion) + */ + @Deprecated + public int toError() { + changeType(Variant.VariantError); + return getError(); + } + + /** + * attempts to return the contents of this variant as a float (after + * possible conversion) + * + * @deprecated should use changeType() and getFloat() instead + * @return float + */ + @Deprecated + public float toFloat() { + changeType(Variant.VariantFloat); + return getFloat(); + } + + /** + * @deprecated should use changeType() followed by getInt() + * @return the value of this variant as an int (after possible conversion) + */ + @Deprecated + public int toInt() { + changeType(VariantInt); + return getInt(); + } + + /** + * Returns the windows time contained in this Variant as a Java Date + * converts to a date like many of the other toXXX() methods SF 959382. + *

+ * This method added 12/2005 for possible use by jacobgen instead of its + * conversion code + *

+ * This does not convert the data + * + * @deprecated callers should use getDate() + * @return java.util.Date version of this variant if it is a date, otherwise + * null + * + */ + @Deprecated + public Date toJavaDate() { + changeType(Variant.VariantDate); + return getJavaDate(); + } + + /** + * Convert a JACOB Variant value to a Java object (type conversions). + * provided in Sourceforge feature request 959381. See + * JavaVariantConverter..convertVariantTJavaObject(Variant) for more + * information. + * + * @return Corresponding Java object of the type matching the Variant type. + * @throws IllegalStateException + * if no underlying windows data structure + * @throws NotImplementedException + * if unsupported conversion is requested + * @throws JacobException + * if the calculated result was a JacobObject usually as a + * result of error + */ + public Object toJavaObject() throws JacobException { + return VariantUtilities.variantToObject(this); + } + + /** + * Acts a a cover for toDispatch. This primarily exists to support jacobgen. + * + * @deprecated this is a cover for toDispatch(); + * @return Object returned by toDispatch() + * @see Variant#toDispatch() instead + */ + @Deprecated + public Object toObject() { + return toDispatch(); + } + + /** + * By default toSafeArray makes a deep copy due to the fact that this + * Variant owns the embedded SafeArray and will destroy it when it gc's + * calls toSafeArray(true). + * + * @return the object converted to a SafeArray + */ + public SafeArray toSafeArray() { + // verify we haven't been released yet + getvt(); + return toSafeArray(true); + } + + /** + * This lets folk turn into a safe array without a deep copy. Should this + * API be public? + * + * @param deepCopy + * @return SafeArray constructed + */ + public SafeArray toSafeArray(boolean deepCopy) { + // verify we haven't been released yet + getvt(); + return toVariantSafeArray(deepCopy); + } + + /** + * I don't know what this is. Is it some legacy (pre 1.8) thing? + * + * @deprecated + * @return this object as a dispatch object by calling toDispatch() + */ + @Deprecated + public Object toScriptObject() { + return toDispatch(); + } + + /** + * attempts to return the contents of this Variant as a short (after + * possible conversion) + * + * @deprecated callers should use changeType() followed by getShort() + * @return short + */ + @Deprecated + public short toShort() { + this.changeType(Variant.VariantShort); + return getShort(); + } + + /** + * This method now correctly implements java toString() semantics Attempts + * to return the content of this variant as a string + *

    + *
  • "not initialized" if not initialized + *
  • "null" if VariantEmpty, + *
  • "null" if VariantError + *
  • "null" if VariantNull + *
  • the value if we know how to describe one of that type + *
  • three question marks if can't convert + * + * @return String value conversion, + * @throws IllegalStateException + * if there is no underlying windows data structure + */ + @Override + public String toString() { + try { + // see if we are in a legal state + getvt(); + } catch (IllegalStateException ise) { + return ""; + } + if (getvt() == VariantEmpty || getvt() == VariantError + || getvt() == VariantNull) { + return "null"; + } + if (getvt() == VariantString) { + return getString(); + } + try { + Object foo = toJavaObject(); + // rely on java objects to do the right thing + return foo.toString(); + } catch (NotImplementedException nie) { + // some types do not generate a good description yet + return "Description not available for type: " + getvt(); + } + } + + /** + * Exists to support jacobgen. This would be deprecated if it weren't for + * jacobgen + * + * @deprecated superseded by "this" + * @return this same object + */ + @Deprecated + public Variant toVariant() { + return this; + } + + /** + * @deprecated superseded by SafeArray + * @return nothing because this method is not implemented + * @throws com.jacob.com.NotImplementedException + */ + @Deprecated + public Variant[] toVariantArray() { + throw new NotImplementedException("Not implemented"); + } + + /** + * native method used by toDispatch() + * + * @return + */ + private native Dispatch toVariantDispatch(); + + private native SafeArray toVariantSafeArray(boolean deepCopy); + + /* + * ===================================================================== + * + * + * ===================================================================== + */ + + /** + * Clear the content of this variant + */ + public native void VariantClear(); + +} \ No newline at end of file diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/VariantUtilities.java b/vendor/jacob/1.15-M4/java/com/jacob/com/VariantUtilities.java new file mode 100644 index 0000000..1ac652a --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/VariantUtilities.java @@ -0,0 +1,502 @@ +/** + * + */ +package com.jacob.com; + +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.math.MathContext; +import java.util.Date; + +/** + * A utility class used to convert between Java objects and Variants + */ +public final class VariantUtilities { + private VariantUtilities() { + // utility class with only static methods don't need constructors + } + + /** + * Populates a variant object from a java object. This method attempts to + * figure out the appropriate Variant type + * + * @param targetVariant + * @param pValueObject + * @param fByRef + */ + protected static void populateVariant(Variant targetVariant, + Object pValueObject, boolean fByRef) { + if (pValueObject == null) { + targetVariant.putEmpty(); + } else if (pValueObject instanceof Integer) { + if (fByRef) { + targetVariant.putIntRef(((Integer) pValueObject).intValue()); + } else { + targetVariant.putInt(((Integer) pValueObject).intValue()); + } + } else if (pValueObject instanceof Short) { + if (fByRef) { + targetVariant.putShortRef(((Short) pValueObject).shortValue()); + } else { + targetVariant.putShort(((Short) pValueObject).shortValue()); + } + } else if (pValueObject instanceof String) { + if (fByRef) { + targetVariant.putStringRef((String) pValueObject); + } else { + targetVariant.putString((String) pValueObject); + } + } else if (pValueObject instanceof Boolean) { + if (fByRef) { + targetVariant.putBooleanRef(((Boolean) pValueObject) + .booleanValue()); + } else { + targetVariant.putBoolean(((Boolean) pValueObject) + .booleanValue()); + } + } else if (pValueObject instanceof Double) { + if (fByRef) { + targetVariant.putDoubleRef(((Double) pValueObject) + .doubleValue()); + } else { + targetVariant.putDouble(((Double) pValueObject).doubleValue()); + } + } else if (pValueObject instanceof Float) { + if (fByRef) { + targetVariant.putFloatRef(((Float) pValueObject).floatValue()); + } else { + targetVariant.putFloat(((Float) pValueObject).floatValue()); + } + } else if (pValueObject instanceof BigDecimal) { + if (fByRef) { + targetVariant.putDecimalRef(((BigDecimal) pValueObject)); + } else { + targetVariant.putDecimal(((BigDecimal) pValueObject)); + } + } else if (pValueObject instanceof Byte) { + if (fByRef) { + targetVariant.putByteRef(((Byte) pValueObject).byteValue()); + } else { + targetVariant.putByte(((Byte) pValueObject).byteValue()); + } + } else if (pValueObject instanceof Date) { + if (fByRef) { + targetVariant.putDateRef((Date) pValueObject); + } else { + targetVariant.putDate((Date) pValueObject); + } + } else if (pValueObject instanceof Long) { + if (fByRef) { + targetVariant.putLongRef(((Long) pValueObject).longValue()); + } else { + targetVariant.putLong(((Long) pValueObject).longValue()); + } + } else if (pValueObject instanceof Currency) { + if (fByRef) { + targetVariant.putCurrencyRef(((Currency) pValueObject)); + } else { + targetVariant.putCurrency(((Currency) pValueObject)); + } + } else if (pValueObject instanceof SafeArray) { + if (fByRef) { + targetVariant.putSafeArrayRef((SafeArray) pValueObject); + } else { + targetVariant.putSafeArray((SafeArray) pValueObject); + } + } else if (pValueObject instanceof Dispatch) { + if (fByRef) { + targetVariant.putDispatchRef((Dispatch) pValueObject); + } else { + targetVariant.putDispatch((Dispatch) pValueObject); + } + } else if (pValueObject instanceof Variant) { + // newly added 1.12-pre6 to support VT_VARIANT + targetVariant.putVariant(pValueObject); + } else { + // sourceforge patch 2171967 + // used to rely on coercion but sometimes crashed VM + throw new NotImplementedException( + "populateVariant() not implemented for " + + pValueObject.getClass()); + } + } + + /** + * Map arguments based on msdn documentation. This method relies on the + * variant constructor except for arrays. + * + * @param objectToBeMadeIntoVariant + * @return Variant that represents the object + */ + protected static Variant objectToVariant(Object objectToBeMadeIntoVariant) { + if (objectToBeMadeIntoVariant == null) { + return new Variant(); + } else if (objectToBeMadeIntoVariant instanceof Variant) { + // if a variant was passed in then be a slacker and just return it + return (Variant) objectToBeMadeIntoVariant; + } else if (objectToBeMadeIntoVariant.getClass().isArray()) { + // automatically convert arrays using reflection + // handle it differently based on the type of array + // added primitive support sourceforge 2762275 + SafeArray sa = null; + int len1 = Array.getLength(objectToBeMadeIntoVariant); + Class componentType = objectToBeMadeIntoVariant.getClass() + .getComponentType(); + + if (componentType.isArray()) { // array of arrays + int max = 0; + for (int i = 0; i < len1; i++) { + Object e1 = Array.get(objectToBeMadeIntoVariant, i); + int len2 = Array.getLength(e1); + if (max < len2) { + max = len2; + } + } + sa = new SafeArray(Variant.VariantVariant, len1, max); + for (int i = 0; i < len1; i++) { + Object e1 = Array.get(objectToBeMadeIntoVariant, i); + for (int j = 0; j < Array.getLength(e1); j++) { + sa.setVariant(i, j, objectToVariant(Array.get(e1, j))); + } + } + } else if (byte.class.equals(componentType)) { + byte[] arr = (byte[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantByte, len1); + for (int i = 0; i < len1; i++) { + sa.setByte(i, arr[i]); + } + } else if (int.class.equals(componentType)) { + int[] arr = (int[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantInt, len1); + for (int i = 0; i < len1; i++) { + sa.setInt(i, arr[i]); + } + } else if (double.class.equals(componentType)) { + double[] arr = (double[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantDouble, len1); + for (int i = 0; i < len1; i++) { + sa.setDouble(i, arr[i]); + } + } else if (long.class.equals(componentType)) { + long[] arr = (long[]) objectToBeMadeIntoVariant; + sa = new SafeArray(Variant.VariantLongInt, len1); + for (int i = 0; i < len1; i++) { + sa.setLong(i, arr[i]); + } + } else { + // array of object + sa = new SafeArray(Variant.VariantVariant, len1); + for (int i = 0; i < len1; i++) { + sa.setVariant(i, objectToVariant(Array.get( + objectToBeMadeIntoVariant, i))); + } + } + Variant returnVariant = new Variant(); + populateVariant(returnVariant, sa, false); + return returnVariant; + } else { + // rely on populateVariant to throw an exception if its an + // invalid type + Variant returnVariant = new Variant(); + populateVariant(returnVariant, objectToBeMadeIntoVariant, false); + return returnVariant; + } + } + + /** + * converts an array of objects into an array of Variants by repeatedly + * calling obj2Variant(Object) + * + * @param arrayOfObjectsToBeConverted + * @return Variant[] + */ + protected static Variant[] objectsToVariants( + Object[] arrayOfObjectsToBeConverted) { + if (arrayOfObjectsToBeConverted instanceof Variant[]) { + // just return the passed in array if it is a Variant array + return (Variant[]) arrayOfObjectsToBeConverted; + } else { + Variant vArg[] = new Variant[arrayOfObjectsToBeConverted.length]; + for (int i = 0; i < arrayOfObjectsToBeConverted.length; i++) { + vArg[i] = objectToVariant(arrayOfObjectsToBeConverted[i]); + } + return vArg; + } + } + + /** + * Convert a JACOB Variant value to a Java object (type conversions). + * provided in Sourceforge feature request 959381. A fix was done to handle + * byRef bug report 1607878. + *

    + * Unlike other toXXX() methods, it does not do a type conversion except for + * special data types (it shouldn't do any!) + *

    + * Converts Variant.VariantArray types to SafeArrays + * + * @return Corresponding Java object of the type matching the Variant type. + * @throws IllegalStateException + * if no underlying windows data structure + * @throws NotImplementedException + * if unsupported conversion is requested + * @throws JacobException + * if the calculated result was a JacobObject usually as a + * result of error + */ + protected static Object variantToObject(Variant sourceData) { + Object result = null; + + short type = sourceData.getvt(); // variant type + + if ((type & Variant.VariantArray) == Variant.VariantArray) { // array + // returned? + SafeArray array = null; + type = (short) (type - Variant.VariantArray); + // From SF Bug 1840487 + // This did call toSafeArray(false) but that meant + // this was the only variantToObject() that didn't have its own + // copy of the data so you would end up with weird run time + // errors after some GC. So now we just get stupid about it and + // always make a copy just like toSafeArray() does. + array = sourceData.toSafeArray(); + result = array; + } else { // non-array object returned + switch (type) { + case Variant.VariantEmpty: // 0 + case Variant.VariantNull: // 1 + break; + case Variant.VariantShort: // 2 + result = new Short(sourceData.getShort()); + break; + case Variant.VariantShort | Variant.VariantByref: // 2 + result = new Short(sourceData.getShortRef()); + break; + case Variant.VariantInt: // 3 + result = new Integer(sourceData.getInt()); + break; + case Variant.VariantInt | Variant.VariantByref: // 3 + result = new Integer(sourceData.getIntRef()); + break; + case Variant.VariantFloat: // 4 + result = new Float(sourceData.getFloat()); + break; + case Variant.VariantFloat | Variant.VariantByref: // 4 + result = new Float(sourceData.getFloatRef()); + break; + case Variant.VariantDouble: // 5 + result = new Double(sourceData.getDouble()); + break; + case Variant.VariantDouble | Variant.VariantByref: // 5 + result = new Double(sourceData.getDoubleRef()); + break; + case Variant.VariantCurrency: // 6 + result = sourceData.getCurrency(); + break; + case Variant.VariantCurrency | Variant.VariantByref: // 6 + result = sourceData.getCurrencyRef(); + break; + case Variant.VariantDate: // 7 + result = sourceData.getJavaDate(); + break; + case Variant.VariantDate | Variant.VariantByref: // 7 + result = sourceData.getJavaDateRef(); + break; + case Variant.VariantString: // 8 + result = sourceData.getString(); + break; + case Variant.VariantString | Variant.VariantByref: // 8 + result = sourceData.getStringRef(); + break; + case Variant.VariantDispatch: // 9 + result = sourceData.getDispatch(); + break; + case Variant.VariantDispatch | Variant.VariantByref: // 9 + result = sourceData.getDispatchRef(); // Can dispatches even + // be byRef? + break; + case Variant.VariantError: // 10 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantError"); + break; + case Variant.VariantBoolean: // 11 + result = new Boolean(sourceData.getBoolean()); + break; + case Variant.VariantBoolean | Variant.VariantByref: // 11 + result = new Boolean(sourceData.getBooleanRef()); + break; + case Variant.VariantVariant: // 12 they are always by ref + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantVariant without ByRef"); + break; + case Variant.VariantVariant | Variant.VariantByref: // 12 + result = sourceData.getVariant(); + break; + case Variant.VariantObject: // 13 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantObject"); + break; + case Variant.VariantDecimal: // 14 + result = sourceData.getDecimal(); + break; + case Variant.VariantDecimal | Variant.VariantByref: // 14 + result = sourceData.getDecimalRef(); + break; + case Variant.VariantByte: // 17 + result = new Byte(sourceData.getByte()); + break; + case Variant.VariantByte | Variant.VariantByref: // 17 + result = new Byte(sourceData.getByteRef()); + break; + case Variant.VariantLongInt: // 20 + result = new Long(sourceData.getLong()); + break; + case Variant.VariantLongInt | Variant.VariantByref: // 20 + result = new Long(sourceData.getLongRef()); + break; + case Variant.VariantTypeMask: // 4095 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantBstrBlob/VariantTypeMask"); + break; + case Variant.VariantArray: // 8192 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantArray"); + break; + case Variant.VariantByref: // 16384 + result = new NotImplementedException( + "toJavaObject() Not implemented for VariantByref"); + break; + default: + result = new NotImplementedException("Unknown return type: " + + type); + // there was a "return result" here that caused defect 1602118 + // so it was removed + break; + }// switch (type) + + if (result instanceof JacobException) { + throw (JacobException) result; + } + } + + return result; + }// toJava() + + /** + * Verifies that we have a scale 0 <= x <= 28 and now more than 96 bits of + * data. The roundToMSDecimal method will attempt to adjust a BigDecimal to + * pass this set of tests + * + * @param in + * @throws IllegalArgumentException + * if out of bounds + */ + protected static void validateDecimalScaleAndBits(BigDecimal in) { + BigInteger allWordBigInt = in.unscaledValue(); + if (in.scale() > 28) { + // should this cast to a string and call putStringRef()? + throw new IllegalArgumentException( + "VT_DECIMAL only supports a maximum scale of 28 and the passed" + + " in value has a scale of " + in.scale()); + } else if (in.scale() < 0) { + // should this cast to a string and call putStringRef()? + throw new IllegalArgumentException( + "VT_DECIMAL only supports a minimum scale of 0 and the passed" + + " in value has a scale of " + in.scale()); + } else if (allWordBigInt.bitLength() > 12 * 8) { + throw new IllegalArgumentException( + "VT_DECIMAL supports a maximum of " + + 12 + * 8 + + " bits not counting scale and the number passed in has " + + allWordBigInt.bitLength()); + + } else { + // no bounds problem to be handled + } + + } + + /** + * Largest possible number with scale set to 0 + */ + private static final BigDecimal LARGEST_DECIMAL = new BigDecimal( + new BigInteger("ffffffffffffffffffffffff", 16)); + /** + * Smallest possible number with scale set to 0. MS doesn't support negative + * scales like BigDecimal. + */ + private static final BigDecimal SMALLEST_DECIMAL = new BigDecimal( + new BigInteger("ffffffffffffffffffffffff", 16).negate()); + + /** + * Does any validation that couldn't have been fixed by rounding or scale + * modification. + * + * @param in + * The BigDecimal to be validated + * @throws IllegalArgumentException + * if the number is too large or too small or null + */ + protected static void validateDecimalMinMax(BigDecimal in) { + if (in == null) { + throw new IllegalArgumentException( + "null is not a supported Decimal value."); + } else if (LARGEST_DECIMAL.compareTo(in) < 0) { + throw new IllegalArgumentException( + "Value too large for VT_DECIMAL data type:" + in.toString() + + " integer: " + in.toBigInteger().toString(16) + + " scale: " + in.scale()); + } else if (SMALLEST_DECIMAL.compareTo(in) > 0) { + throw new IllegalArgumentException( + "Value too small for VT_DECIMAL data type:" + in.toString() + + " integer: " + in.toBigInteger().toString(16) + + " scale: " + in.scale()); + } + + } + + /** + * Rounds the scale and bit length so that it will pass + * validateDecimalScaleBits(). Developers should call this method if they + * really want MS Decimal and don't want to lose precision. + *

    + * Changing the scale on a number that can fit in an MS Decimal can change + * the number's representation enough that it will round to a number too + * large to be represented by an MS VT_DECIMAL + * + * @param sourceDecimal + * @return BigDecimal a new big decimal that was rounded to fit in an MS + * VT_DECIMAL + */ + public static BigDecimal roundToMSDecimal(BigDecimal sourceDecimal) { + BigInteger sourceDecimalIntComponent = sourceDecimal.unscaledValue(); + BigDecimal destinationDecimal = new BigDecimal( + sourceDecimalIntComponent, sourceDecimal.scale()); + int roundingModel = BigDecimal.ROUND_HALF_UP; + validateDecimalMinMax(destinationDecimal); + // First limit the number of digits and then the precision. + // Try and round to 29 digits because we can sometimes do that + BigInteger allWordBigInt; + allWordBigInt = destinationDecimal.unscaledValue(); + if (allWordBigInt.bitLength() > 96) { + destinationDecimal = destinationDecimal.round(new MathContext(29)); + // see if 29 digits uses more than 96 bits + if (allWordBigInt.bitLength() > 96) { + // Dang. It was over 97 bits so shorten it one more digit to + // stay <= 96 bits + destinationDecimal = destinationDecimal.round(new MathContext( + 28)); + } + } + // the bit manipulations above may change the scale so do it afterwards + // round the scale to the max MS can support + if (destinationDecimal.scale() > 28) { + destinationDecimal = destinationDecimal.setScale(28, roundingModel); + } + if (destinationDecimal.scale() < 0) { + destinationDecimal = destinationDecimal.setScale(0, roundingModel); + } + return destinationDecimal; + } +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/VariantViaEvent.java b/vendor/jacob/1.15-M4/java/com/jacob/com/VariantViaEvent.java new file mode 100644 index 0000000..649d2bc --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/VariantViaEvent.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * a public class to variant that is used to track which variant objects are + * created by event callbacks This is solely used for that purpose. + */ +public class VariantViaEvent extends Variant { + + /** + * Standard constructor used by JNI event handling layer + */ + public VariantViaEvent() { + super(); + } +} diff --git a/vendor/jacob/1.15-M4/java/com/jacob/com/WrongThreadException.java b/vendor/jacob/1.15-M4/java/com/jacob/com/WrongThreadException.java new file mode 100644 index 0000000..938e40c --- /dev/null +++ b/vendor/jacob/1.15-M4/java/com/jacob/com/WrongThreadException.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 1999-2004 Sourceforge JACOB Project. + * All rights reserved. Originator: Dan Adler (http://danadler.com). + * Get more information about JACOB at http://sourceforge.net/projects/jacob-project + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +package com.jacob.com; + +/** + * thrown in util.cpp + */ +public class WrongThreadException extends JacobException { + /** + * identifier generated by Eclipse + */ + private static final long serialVersionUID = 6308780364980228692L; + + /** + * standard 0 arg constructor with no message + * + */ + public WrongThreadException() { + super("No Message Provided."); + } + + /** + * standard constructor with a string message + * + * @param s + */ + public WrongThreadException(String s) { + super(s); + } +} \ No newline at end of file diff --git a/vendor/jdk/1.6.0_23/include/classfile_constants.h b/vendor/jdk/1.6.0_23/include/classfile_constants.h new file mode 100644 index 0000000..30e839e --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/classfile_constants.h @@ -0,0 +1,523 @@ +/* + * %W% %E% + * + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + * + */ + +#ifndef CLASSFILE_CONSTANTS_H +#define CLASSFILE_CONSTANTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Flags */ + +enum { + JVM_ACC_PUBLIC = 0x0001, + JVM_ACC_PRIVATE = 0x0002, + JVM_ACC_PROTECTED = 0x0004, + JVM_ACC_STATIC = 0x0008, + JVM_ACC_FINAL = 0x0010, + JVM_ACC_SYNCHRONIZED = 0x0020, + JVM_ACC_SUPER = 0x0020, + JVM_ACC_VOLATILE = 0x0040, + JVM_ACC_BRIDGE = 0x0040, + JVM_ACC_TRANSIENT = 0x0080, + JVM_ACC_VARARGS = 0x0080, + JVM_ACC_NATIVE = 0x0100, + JVM_ACC_INTERFACE = 0x0200, + JVM_ACC_ABSTRACT = 0x0400, + JVM_ACC_STRICT = 0x0800, + JVM_ACC_SYNTHETIC = 0x1000, + JVM_ACC_ANNOTATION = 0x2000, + JVM_ACC_ENUM = 0x4000 +}; + +/* Used in newarray instruction. */ + +enum { + JVM_T_BOOLEAN = 4, + JVM_T_CHAR = 5, + JVM_T_FLOAT = 6, + JVM_T_DOUBLE = 7, + JVM_T_BYTE = 8, + JVM_T_SHORT = 9, + JVM_T_INT = 10, + JVM_T_LONG = 11 +}; + +/* Constant Pool Entries */ + +enum { + JVM_CONSTANT_Utf8 = 1, + JVM_CONSTANT_Unicode = 2, /* unused */ + JVM_CONSTANT_Integer = 3, + JVM_CONSTANT_Float = 4, + JVM_CONSTANT_Long = 5, + JVM_CONSTANT_Double = 6, + JVM_CONSTANT_Class = 7, + JVM_CONSTANT_String = 8, + JVM_CONSTANT_Fieldref = 9, + JVM_CONSTANT_Methodref = 10, + JVM_CONSTANT_InterfaceMethodref = 11, + JVM_CONSTANT_NameAndType = 12 +}; + +/* StackMapTable type item numbers */ + +enum { + JVM_ITEM_Top = 0, + JVM_ITEM_Integer = 1, + JVM_ITEM_Float = 2, + JVM_ITEM_Double = 3, + JVM_ITEM_Long = 4, + JVM_ITEM_Null = 5, + JVM_ITEM_UninitializedThis = 6, + JVM_ITEM_Object = 7, + JVM_ITEM_Uninitialized = 8 +}; + +/* Type signatures */ + +enum { + JVM_SIGNATURE_ARRAY = '[', + JVM_SIGNATURE_BYTE = 'B', + JVM_SIGNATURE_CHAR = 'C', + JVM_SIGNATURE_CLASS = 'L', + JVM_SIGNATURE_ENDCLASS = ';', + JVM_SIGNATURE_ENUM = 'E', + JVM_SIGNATURE_FLOAT = 'F', + JVM_SIGNATURE_DOUBLE = 'D', + JVM_SIGNATURE_FUNC = '(', + JVM_SIGNATURE_ENDFUNC = ')', + JVM_SIGNATURE_INT = 'I', + JVM_SIGNATURE_LONG = 'J', + JVM_SIGNATURE_SHORT = 'S', + JVM_SIGNATURE_VOID = 'V', + JVM_SIGNATURE_BOOLEAN = 'Z' +}; + +/* Opcodes */ + +enum { + JVM_OPC_nop = 0, + JVM_OPC_aconst_null = 1, + JVM_OPC_iconst_m1 = 2, + JVM_OPC_iconst_0 = 3, + JVM_OPC_iconst_1 = 4, + JVM_OPC_iconst_2 = 5, + JVM_OPC_iconst_3 = 6, + JVM_OPC_iconst_4 = 7, + JVM_OPC_iconst_5 = 8, + JVM_OPC_lconst_0 = 9, + JVM_OPC_lconst_1 = 10, + JVM_OPC_fconst_0 = 11, + JVM_OPC_fconst_1 = 12, + JVM_OPC_fconst_2 = 13, + JVM_OPC_dconst_0 = 14, + JVM_OPC_dconst_1 = 15, + JVM_OPC_bipush = 16, + JVM_OPC_sipush = 17, + JVM_OPC_ldc = 18, + JVM_OPC_ldc_w = 19, + JVM_OPC_ldc2_w = 20, + JVM_OPC_iload = 21, + JVM_OPC_lload = 22, + JVM_OPC_fload = 23, + JVM_OPC_dload = 24, + JVM_OPC_aload = 25, + JVM_OPC_iload_0 = 26, + JVM_OPC_iload_1 = 27, + JVM_OPC_iload_2 = 28, + JVM_OPC_iload_3 = 29, + JVM_OPC_lload_0 = 30, + JVM_OPC_lload_1 = 31, + JVM_OPC_lload_2 = 32, + JVM_OPC_lload_3 = 33, + JVM_OPC_fload_0 = 34, + JVM_OPC_fload_1 = 35, + JVM_OPC_fload_2 = 36, + JVM_OPC_fload_3 = 37, + JVM_OPC_dload_0 = 38, + JVM_OPC_dload_1 = 39, + JVM_OPC_dload_2 = 40, + JVM_OPC_dload_3 = 41, + JVM_OPC_aload_0 = 42, + JVM_OPC_aload_1 = 43, + JVM_OPC_aload_2 = 44, + JVM_OPC_aload_3 = 45, + JVM_OPC_iaload = 46, + JVM_OPC_laload = 47, + JVM_OPC_faload = 48, + JVM_OPC_daload = 49, + JVM_OPC_aaload = 50, + JVM_OPC_baload = 51, + JVM_OPC_caload = 52, + JVM_OPC_saload = 53, + JVM_OPC_istore = 54, + JVM_OPC_lstore = 55, + JVM_OPC_fstore = 56, + JVM_OPC_dstore = 57, + JVM_OPC_astore = 58, + JVM_OPC_istore_0 = 59, + JVM_OPC_istore_1 = 60, + JVM_OPC_istore_2 = 61, + JVM_OPC_istore_3 = 62, + JVM_OPC_lstore_0 = 63, + JVM_OPC_lstore_1 = 64, + JVM_OPC_lstore_2 = 65, + JVM_OPC_lstore_3 = 66, + JVM_OPC_fstore_0 = 67, + JVM_OPC_fstore_1 = 68, + JVM_OPC_fstore_2 = 69, + JVM_OPC_fstore_3 = 70, + JVM_OPC_dstore_0 = 71, + JVM_OPC_dstore_1 = 72, + JVM_OPC_dstore_2 = 73, + JVM_OPC_dstore_3 = 74, + JVM_OPC_astore_0 = 75, + JVM_OPC_astore_1 = 76, + JVM_OPC_astore_2 = 77, + JVM_OPC_astore_3 = 78, + JVM_OPC_iastore = 79, + JVM_OPC_lastore = 80, + JVM_OPC_fastore = 81, + JVM_OPC_dastore = 82, + JVM_OPC_aastore = 83, + JVM_OPC_bastore = 84, + JVM_OPC_castore = 85, + JVM_OPC_sastore = 86, + JVM_OPC_pop = 87, + JVM_OPC_pop2 = 88, + JVM_OPC_dup = 89, + JVM_OPC_dup_x1 = 90, + JVM_OPC_dup_x2 = 91, + JVM_OPC_dup2 = 92, + JVM_OPC_dup2_x1 = 93, + JVM_OPC_dup2_x2 = 94, + JVM_OPC_swap = 95, + JVM_OPC_iadd = 96, + JVM_OPC_ladd = 97, + JVM_OPC_fadd = 98, + JVM_OPC_dadd = 99, + JVM_OPC_isub = 100, + JVM_OPC_lsub = 101, + JVM_OPC_fsub = 102, + JVM_OPC_dsub = 103, + JVM_OPC_imul = 104, + JVM_OPC_lmul = 105, + JVM_OPC_fmul = 106, + JVM_OPC_dmul = 107, + JVM_OPC_idiv = 108, + JVM_OPC_ldiv = 109, + JVM_OPC_fdiv = 110, + JVM_OPC_ddiv = 111, + JVM_OPC_irem = 112, + JVM_OPC_lrem = 113, + JVM_OPC_frem = 114, + JVM_OPC_drem = 115, + JVM_OPC_ineg = 116, + JVM_OPC_lneg = 117, + JVM_OPC_fneg = 118, + JVM_OPC_dneg = 119, + JVM_OPC_ishl = 120, + JVM_OPC_lshl = 121, + JVM_OPC_ishr = 122, + JVM_OPC_lshr = 123, + JVM_OPC_iushr = 124, + JVM_OPC_lushr = 125, + JVM_OPC_iand = 126, + JVM_OPC_land = 127, + JVM_OPC_ior = 128, + JVM_OPC_lor = 129, + JVM_OPC_ixor = 130, + JVM_OPC_lxor = 131, + JVM_OPC_iinc = 132, + JVM_OPC_i2l = 133, + JVM_OPC_i2f = 134, + JVM_OPC_i2d = 135, + JVM_OPC_l2i = 136, + JVM_OPC_l2f = 137, + JVM_OPC_l2d = 138, + JVM_OPC_f2i = 139, + JVM_OPC_f2l = 140, + JVM_OPC_f2d = 141, + JVM_OPC_d2i = 142, + JVM_OPC_d2l = 143, + JVM_OPC_d2f = 144, + JVM_OPC_i2b = 145, + JVM_OPC_i2c = 146, + JVM_OPC_i2s = 147, + JVM_OPC_lcmp = 148, + JVM_OPC_fcmpl = 149, + JVM_OPC_fcmpg = 150, + JVM_OPC_dcmpl = 151, + JVM_OPC_dcmpg = 152, + JVM_OPC_ifeq = 153, + JVM_OPC_ifne = 154, + JVM_OPC_iflt = 155, + JVM_OPC_ifge = 156, + JVM_OPC_ifgt = 157, + JVM_OPC_ifle = 158, + JVM_OPC_if_icmpeq = 159, + JVM_OPC_if_icmpne = 160, + JVM_OPC_if_icmplt = 161, + JVM_OPC_if_icmpge = 162, + JVM_OPC_if_icmpgt = 163, + JVM_OPC_if_icmple = 164, + JVM_OPC_if_acmpeq = 165, + JVM_OPC_if_acmpne = 166, + JVM_OPC_goto = 167, + JVM_OPC_jsr = 168, + JVM_OPC_ret = 169, + JVM_OPC_tableswitch = 170, + JVM_OPC_lookupswitch = 171, + JVM_OPC_ireturn = 172, + JVM_OPC_lreturn = 173, + JVM_OPC_freturn = 174, + JVM_OPC_dreturn = 175, + JVM_OPC_areturn = 176, + JVM_OPC_return = 177, + JVM_OPC_getstatic = 178, + JVM_OPC_putstatic = 179, + JVM_OPC_getfield = 180, + JVM_OPC_putfield = 181, + JVM_OPC_invokevirtual = 182, + JVM_OPC_invokespecial = 183, + JVM_OPC_invokestatic = 184, + JVM_OPC_invokeinterface = 185, + JVM_OPC_xxxunusedxxx = 186, + JVM_OPC_new = 187, + JVM_OPC_newarray = 188, + JVM_OPC_anewarray = 189, + JVM_OPC_arraylength = 190, + JVM_OPC_athrow = 191, + JVM_OPC_checkcast = 192, + JVM_OPC_instanceof = 193, + JVM_OPC_monitorenter = 194, + JVM_OPC_monitorexit = 195, + JVM_OPC_wide = 196, + JVM_OPC_multianewarray = 197, + JVM_OPC_ifnull = 198, + JVM_OPC_ifnonnull = 199, + JVM_OPC_goto_w = 200, + JVM_OPC_jsr_w = 201, + JVM_OPC_MAX = 201 +}; + +/* Opcode length initializer, use with something like: + * unsigned char opcode_length[JVM_OPC_MAX+1] = JVM_OPCODE_LENGTH_INITIALIZER; + */ +#define JVM_OPCODE_LENGTH_INITIALIZER { \ + 1, /* nop */ \ + 1, /* aconst_null */ \ + 1, /* iconst_m1 */ \ + 1, /* iconst_0 */ \ + 1, /* iconst_1 */ \ + 1, /* iconst_2 */ \ + 1, /* iconst_3 */ \ + 1, /* iconst_4 */ \ + 1, /* iconst_5 */ \ + 1, /* lconst_0 */ \ + 1, /* lconst_1 */ \ + 1, /* fconst_0 */ \ + 1, /* fconst_1 */ \ + 1, /* fconst_2 */ \ + 1, /* dconst_0 */ \ + 1, /* dconst_1 */ \ + 2, /* bipush */ \ + 3, /* sipush */ \ + 2, /* ldc */ \ + 3, /* ldc_w */ \ + 3, /* ldc2_w */ \ + 2, /* iload */ \ + 2, /* lload */ \ + 2, /* fload */ \ + 2, /* dload */ \ + 2, /* aload */ \ + 1, /* iload_0 */ \ + 1, /* iload_1 */ \ + 1, /* iload_2 */ \ + 1, /* iload_3 */ \ + 1, /* lload_0 */ \ + 1, /* lload_1 */ \ + 1, /* lload_2 */ \ + 1, /* lload_3 */ \ + 1, /* fload_0 */ \ + 1, /* fload_1 */ \ + 1, /* fload_2 */ \ + 1, /* fload_3 */ \ + 1, /* dload_0 */ \ + 1, /* dload_1 */ \ + 1, /* dload_2 */ \ + 1, /* dload_3 */ \ + 1, /* aload_0 */ \ + 1, /* aload_1 */ \ + 1, /* aload_2 */ \ + 1, /* aload_3 */ \ + 1, /* iaload */ \ + 1, /* laload */ \ + 1, /* faload */ \ + 1, /* daload */ \ + 1, /* aaload */ \ + 1, /* baload */ \ + 1, /* caload */ \ + 1, /* saload */ \ + 2, /* istore */ \ + 2, /* lstore */ \ + 2, /* fstore */ \ + 2, /* dstore */ \ + 2, /* astore */ \ + 1, /* istore_0 */ \ + 1, /* istore_1 */ \ + 1, /* istore_2 */ \ + 1, /* istore_3 */ \ + 1, /* lstore_0 */ \ + 1, /* lstore_1 */ \ + 1, /* lstore_2 */ \ + 1, /* lstore_3 */ \ + 1, /* fstore_0 */ \ + 1, /* fstore_1 */ \ + 1, /* fstore_2 */ \ + 1, /* fstore_3 */ \ + 1, /* dstore_0 */ \ + 1, /* dstore_1 */ \ + 1, /* dstore_2 */ \ + 1, /* dstore_3 */ \ + 1, /* astore_0 */ \ + 1, /* astore_1 */ \ + 1, /* astore_2 */ \ + 1, /* astore_3 */ \ + 1, /* iastore */ \ + 1, /* lastore */ \ + 1, /* fastore */ \ + 1, /* dastore */ \ + 1, /* aastore */ \ + 1, /* bastore */ \ + 1, /* castore */ \ + 1, /* sastore */ \ + 1, /* pop */ \ + 1, /* pop2 */ \ + 1, /* dup */ \ + 1, /* dup_x1 */ \ + 1, /* dup_x2 */ \ + 1, /* dup2 */ \ + 1, /* dup2_x1 */ \ + 1, /* dup2_x2 */ \ + 1, /* swap */ \ + 1, /* iadd */ \ + 1, /* ladd */ \ + 1, /* fadd */ \ + 1, /* dadd */ \ + 1, /* isub */ \ + 1, /* lsub */ \ + 1, /* fsub */ \ + 1, /* dsub */ \ + 1, /* imul */ \ + 1, /* lmul */ \ + 1, /* fmul */ \ + 1, /* dmul */ \ + 1, /* idiv */ \ + 1, /* ldiv */ \ + 1, /* fdiv */ \ + 1, /* ddiv */ \ + 1, /* irem */ \ + 1, /* lrem */ \ + 1, /* frem */ \ + 1, /* drem */ \ + 1, /* ineg */ \ + 1, /* lneg */ \ + 1, /* fneg */ \ + 1, /* dneg */ \ + 1, /* ishl */ \ + 1, /* lshl */ \ + 1, /* ishr */ \ + 1, /* lshr */ \ + 1, /* iushr */ \ + 1, /* lushr */ \ + 1, /* iand */ \ + 1, /* land */ \ + 1, /* ior */ \ + 1, /* lor */ \ + 1, /* ixor */ \ + 1, /* lxor */ \ + 3, /* iinc */ \ + 1, /* i2l */ \ + 1, /* i2f */ \ + 1, /* i2d */ \ + 1, /* l2i */ \ + 1, /* l2f */ \ + 1, /* l2d */ \ + 1, /* f2i */ \ + 1, /* f2l */ \ + 1, /* f2d */ \ + 1, /* d2i */ \ + 1, /* d2l */ \ + 1, /* d2f */ \ + 1, /* i2b */ \ + 1, /* i2c */ \ + 1, /* i2s */ \ + 1, /* lcmp */ \ + 1, /* fcmpl */ \ + 1, /* fcmpg */ \ + 1, /* dcmpl */ \ + 1, /* dcmpg */ \ + 3, /* ifeq */ \ + 3, /* ifne */ \ + 3, /* iflt */ \ + 3, /* ifge */ \ + 3, /* ifgt */ \ + 3, /* ifle */ \ + 3, /* if_icmpeq */ \ + 3, /* if_icmpne */ \ + 3, /* if_icmplt */ \ + 3, /* if_icmpge */ \ + 3, /* if_icmpgt */ \ + 3, /* if_icmple */ \ + 3, /* if_acmpeq */ \ + 3, /* if_acmpne */ \ + 3, /* goto */ \ + 3, /* jsr */ \ + 2, /* ret */ \ + 99, /* tableswitch */ \ + 99, /* lookupswitch */ \ + 1, /* ireturn */ \ + 1, /* lreturn */ \ + 1, /* freturn */ \ + 1, /* dreturn */ \ + 1, /* areturn */ \ + 1, /* return */ \ + 3, /* getstatic */ \ + 3, /* putstatic */ \ + 3, /* getfield */ \ + 3, /* putfield */ \ + 3, /* invokevirtual */ \ + 3, /* invokespecial */ \ + 3, /* invokestatic */ \ + 5, /* invokeinterface */ \ + 0, /* xxxunusedxxx */ \ + 3, /* new */ \ + 2, /* newarray */ \ + 3, /* anewarray */ \ + 1, /* arraylength */ \ + 1, /* athrow */ \ + 3, /* checkcast */ \ + 3, /* instanceof */ \ + 1, /* monitorenter */ \ + 1, /* monitorexit */ \ + 0, /* wide */ \ + 4, /* multianewarray */ \ + 3, /* ifnull */ \ + 3, /* ifnonnull */ \ + 5, /* goto_w */ \ + 5 /* jsr_w */ \ +} + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* CLASSFILE_CONSTANTS */ diff --git a/vendor/jdk/1.6.0_23/include/jawt.h b/vendor/jdk/1.6.0_23/include/jawt.h new file mode 100644 index 0000000..87e0b18 --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/jawt.h @@ -0,0 +1,278 @@ +/* + * %W% %E% + * + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#ifndef _JAVASOFT_JAWT_H_ +#define _JAVASOFT_JAWT_H_ + +#include "jni.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * AWT native interface (new in JDK 1.3) + * + * The AWT native interface allows a native C or C++ application a means + * by which to access native structures in AWT. This is to facilitate moving + * legacy C and C++ applications to Java and to target the needs of the + * community who, at present, wish to do their own native rendering to canvases + * for performance reasons. Standard extensions such as Java3D also require a + * means to access the underlying native data structures of AWT. + * + * There may be future extensions to this API depending on demand. + * + * A VM does not have to implement this API in order to pass the JCK. + * It is recommended, however, that this API is implemented on VMs that support + * standard extensions, such as Java3D. + * + * Since this is a native API, any program which uses it cannot be considered + * 100% pure java. + */ + +/* + * AWT Native Drawing Surface (JAWT_DrawingSurface). + * + * For each platform, there is a native drawing surface structure. This + * platform-specific structure can be found in jawt_md.h. It is recommended + * that additional platforms follow the same model. It is also recommended + * that VMs on Win32 and Solaris support the existing structures in jawt_md.h. + * + ******************* + * EXAMPLE OF USAGE: + ******************* + * + * In Win32, a programmer wishes to access the HWND of a canvas to perform + * native rendering into it. The programmer has declared the paint() method + * for their canvas subclass to be native: + * + * + * MyCanvas.java: + * + * import java.awt.*; + * + * public class MyCanvas extends Canvas { + * + * static { + * System.loadLibrary("mylib"); + * } + * + * public native void paint(Graphics g); + * } + * + * + * myfile.c: + * + * #include "jawt_md.h" + * #include + * + * JNIEXPORT void JNICALL + * Java_MyCanvas_paint(JNIEnv* env, jobject canvas, jobject graphics) + * { + * JAWT awt; + * JAWT_DrawingSurface* ds; + * JAWT_DrawingSurfaceInfo* dsi; + * JAWT_Win32DrawingSurfaceInfo* dsi_win; + * jboolean result; + * jint lock; + * + * // Get the AWT + * awt.version = JAWT_VERSION_1_3; + * result = JAWT_GetAWT(env, &awt); + * assert(result != JNI_FALSE); + * + * // Get the drawing surface + * ds = awt.GetDrawingSurface(env, canvas); + * assert(ds != NULL); + * + * // Lock the drawing surface + * lock = ds->Lock(ds); + * assert((lock & JAWT_LOCK_ERROR) == 0); + * + * // Get the drawing surface info + * dsi = ds->GetDrawingSurfaceInfo(ds); + * + * // Get the platform-specific drawing info + * dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo; + * + * ////////////////////////////// + * // !!! DO PAINTING HERE !!! // + * ////////////////////////////// + * + * // Free the drawing surface info + * ds->FreeDrawingSurfaceInfo(dsi); + * + * // Unlock the drawing surface + * ds->Unlock(ds); + * + * // Free the drawing surface + * awt.FreeDrawingSurface(ds); + * } + * + */ + +/* + * JAWT_Rectangle + * Structure for a native rectangle. + */ +typedef struct jawt_Rectangle { + jint x; + jint y; + jint width; + jint height; +} JAWT_Rectangle; + +struct jawt_DrawingSurface; + +/* + * JAWT_DrawingSurfaceInfo + * Structure for containing the underlying drawing information of a component. + */ +typedef struct jawt_DrawingSurfaceInfo { + /* + * Pointer to the platform-specific information. This can be safely + * cast to a JAWT_Win32DrawingSurfaceInfo on Windows or a + * JAWT_X11DrawingSurfaceInfo on Solaris. See jawt_md.h for details. + */ + void* platformInfo; + /* Cached pointer to the underlying drawing surface */ + struct jawt_DrawingSurface* ds; + /* Bounding rectangle of the drawing surface */ + JAWT_Rectangle bounds; + /* Number of rectangles in the clip */ + jint clipSize; + /* Clip rectangle array */ + JAWT_Rectangle* clip; +} JAWT_DrawingSurfaceInfo; + +#define JAWT_LOCK_ERROR 0x00000001 +#define JAWT_LOCK_CLIP_CHANGED 0x00000002 +#define JAWT_LOCK_BOUNDS_CHANGED 0x00000004 +#define JAWT_LOCK_SURFACE_CHANGED 0x00000008 + +/* + * JAWT_DrawingSurface + * Structure for containing the underlying drawing information of a component. + * All operations on a JAWT_DrawingSurface MUST be performed from the same + * thread as the call to GetDrawingSurface. + */ +typedef struct jawt_DrawingSurface { + /* + * Cached reference to the Java environment of the calling thread. + * If Lock(), Unlock(), GetDrawingSurfaceInfo() or + * FreeDrawingSurfaceInfo() are called from a different thread, + * this data member should be set before calling those functions. + */ + JNIEnv* env; + /* Cached reference to the target object */ + jobject target; + /* + * Lock the surface of the target component for native rendering. + * When finished drawing, the surface must be unlocked with + * Unlock(). This function returns a bitmask with one or more of the + * following values: + * + * JAWT_LOCK_ERROR - When an error has occurred and the surface could not + * be locked. + * + * JAWT_LOCK_CLIP_CHANGED - When the clip region has changed. + * + * JAWT_LOCK_BOUNDS_CHANGED - When the bounds of the surface have changed. + * + * JAWT_LOCK_SURFACE_CHANGED - When the surface itself has changed + */ + jint (JNICALL *Lock) + (struct jawt_DrawingSurface* ds); + /* + * Get the drawing surface info. + * The value returned may be cached, but the values may change if + * additional calls to Lock() or Unlock() are made. + * Lock() must be called before this can return a valid value. + * Returns NULL if an error has occurred. + * When finished with the returned value, FreeDrawingSurfaceInfo must be + * called. + */ + JAWT_DrawingSurfaceInfo* (JNICALL *GetDrawingSurfaceInfo) + (struct jawt_DrawingSurface* ds); + /* + * Free the drawing surface info. + */ + void (JNICALL *FreeDrawingSurfaceInfo) + (JAWT_DrawingSurfaceInfo* dsi); + /* + * Unlock the drawing surface of the target component for native rendering. + */ + void (JNICALL *Unlock) + (struct jawt_DrawingSurface* ds); +} JAWT_DrawingSurface; + +/* + * JAWT + * Structure for containing native AWT functions. + */ +typedef struct jawt { + /* + * Version of this structure. This must always be set before + * calling JAWT_GetAWT() + */ + jint version; + /* + * Return a drawing surface from a target jobject. This value + * may be cached. + * Returns NULL if an error has occurred. + * Target must be a java.awt.Component (should be a Canvas + * or Window for native rendering). + * FreeDrawingSurface() must be called when finished with the + * returned JAWT_DrawingSurface. + */ + JAWT_DrawingSurface* (JNICALL *GetDrawingSurface) + (JNIEnv* env, jobject target); + /* + * Free the drawing surface allocated in GetDrawingSurface. + */ + void (JNICALL *FreeDrawingSurface) + (JAWT_DrawingSurface* ds); + /* + * Since 1.4 + * Locks the entire AWT for synchronization purposes + */ + void (JNICALL *Lock)(JNIEnv* env); + /* + * Since 1.4 + * Unlocks the entire AWT for synchronization purposes + */ + void (JNICALL *Unlock)(JNIEnv* env); + /* + * Since 1.4 + * Returns a reference to a java.awt.Component from a native + * platform handle. On Windows, this corresponds to an HWND; + * on Solaris and Linux, this is a Drawable. For other platforms, + * see the appropriate machine-dependent header file for a description. + * The reference returned by this function is a local + * reference that is only valid in this environment. + * This function returns a NULL reference if no component could be + * found with matching platform information. + */ + jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); + +} JAWT; + +/* + * Get the AWT native structure. This function returns JNI_FALSE if + * an error occurs. + */ +_JNI_IMPORT_OR_EXPORT_ +jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); + +#define JAWT_VERSION_1_3 0x00010003 +#define JAWT_VERSION_1_4 0x00010004 + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* !_JAVASOFT_JAWT_H_ */ diff --git a/vendor/jdk/1.6.0_23/include/jdwpTransport.h b/vendor/jdk/1.6.0_23/include/jdwpTransport.h new file mode 100644 index 0000000..eae435a --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/jdwpTransport.h @@ -0,0 +1,237 @@ +/* + * %W% %E% + * + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/* + * Java Debug Wire Protocol Transport Service Provider Interface. + */ + +#ifndef JDWPTRANSPORT_H +#define JDWPTRANSPORT_H + +#include "jni.h" + +enum { + JDWPTRANSPORT_VERSION_1_0 = 0x00010000 +}; + +#ifdef __cplusplus +extern "C" { +#endif + +struct jdwpTransportNativeInterface_; + +struct _jdwpTransportEnv; + +#ifdef __cplusplus +typedef _jdwpTransportEnv jdwpTransportEnv; +#else +typedef const struct jdwpTransportNativeInterface_ *jdwpTransportEnv; +#endif /* __cplusplus */ + +/* + * Errors. Universal errors with JVMTI/JVMDI equivalents keep the + * values the same. + */ +typedef enum { + JDWPTRANSPORT_ERROR_NONE = 0, + JDWPTRANSPORT_ERROR_ILLEGAL_ARGUMENT = 103, + JDWPTRANSPORT_ERROR_OUT_OF_MEMORY = 110, + JDWPTRANSPORT_ERROR_INTERNAL = 113, + JDWPTRANSPORT_ERROR_ILLEGAL_STATE = 201, + JDWPTRANSPORT_ERROR_IO_ERROR = 202, + JDWPTRANSPORT_ERROR_TIMEOUT = 203, + JDWPTRANSPORT_ERROR_MSG_NOT_AVAILABLE = 204 +} jdwpTransportError; + + +/* + * Structure to define capabilities + */ +typedef struct { + unsigned int can_timeout_attach :1; + unsigned int can_timeout_accept :1; + unsigned int can_timeout_handshake :1; + unsigned int reserved3 :1; + unsigned int reserved4 :1; + unsigned int reserved5 :1; + unsigned int reserved6 :1; + unsigned int reserved7 :1; + unsigned int reserved8 :1; + unsigned int reserved9 :1; + unsigned int reserved10 :1; + unsigned int reserved11 :1; + unsigned int reserved12 :1; + unsigned int reserved13 :1; + unsigned int reserved14 :1; + unsigned int reserved15 :1; +} JDWPTransportCapabilities; + + +/* + * Structures to define packet layout. + * + * See: http://java.sun.com/j2se/1.5/docs/guide/jpda/jdwp-spec.html + */ + +enum { + JDWPTRANSPORT_FLAGS_NONE = 0x0, + JDWPTRANSPORT_FLAGS_REPLY = 0x80 +}; + +typedef struct { + jint len; + jint id; + jbyte flags; + jbyte cmdSet; + jbyte cmd; + jbyte *data; +} jdwpCmdPacket; + +typedef struct { + jint len; + jint id; + jbyte flags; + jshort errorCode; + jbyte *data; +} jdwpReplyPacket; + +typedef struct { + union { + jdwpCmdPacket cmd; + jdwpReplyPacket reply; + } type; +} jdwpPacket; + +/* + * JDWP functions called by the transport. + */ +typedef struct jdwpTransportCallback { + void *(*alloc)(jint numBytes); /* Call this for all allocations */ + void (*free)(void *buffer); /* Call this for all deallocations */ +} jdwpTransportCallback; + +typedef jint (JNICALL *jdwpTransport_OnLoad_t)(JavaVM *jvm, + jdwpTransportCallback *callback, + jint version, + jdwpTransportEnv** env); + + + +/* Function Interface */ + +struct jdwpTransportNativeInterface_ { + /* 1 : RESERVED */ + void *reserved1; + + /* 2 : Get Capabilities */ + jdwpTransportError (JNICALL *GetCapabilities)(jdwpTransportEnv* env, + JDWPTransportCapabilities *capabilities_ptr); + + /* 3 : Attach */ + jdwpTransportError (JNICALL *Attach)(jdwpTransportEnv* env, + const char* address, + jlong attach_timeout, + jlong handshake_timeout); + + /* 4: StartListening */ + jdwpTransportError (JNICALL *StartListening)(jdwpTransportEnv* env, + const char* address, + char** actual_address); + + /* 5: StopListening */ + jdwpTransportError (JNICALL *StopListening)(jdwpTransportEnv* env); + + /* 6: Accept */ + jdwpTransportError (JNICALL *Accept)(jdwpTransportEnv* env, + jlong accept_timeout, + jlong handshake_timeout); + + /* 7: IsOpen */ + jboolean (JNICALL *IsOpen)(jdwpTransportEnv* env); + + /* 8: Close */ + jdwpTransportError (JNICALL *Close)(jdwpTransportEnv* env); + + /* 9: ReadPacket */ + jdwpTransportError (JNICALL *ReadPacket)(jdwpTransportEnv* env, + jdwpPacket *pkt); + + /* 10: Write Packet */ + jdwpTransportError (JNICALL *WritePacket)(jdwpTransportEnv* env, + const jdwpPacket* pkt); + + /* 11: GetLastError */ + jdwpTransportError (JNICALL *GetLastError)(jdwpTransportEnv* env, + char** error); + +}; + + +/* + * Use inlined functions so that C++ code can use syntax such as + * env->Attach("mymachine:5000", 10*1000, 0); + * + * rather than using C's :- + * + * (*env)->Attach(env, "mymachine:5000", 10*1000, 0); + */ +struct _jdwpTransportEnv { + const struct jdwpTransportNativeInterface_ *functions; +#ifdef __cplusplus + + jdwpTransportError GetCapabilities(JDWPTransportCapabilities *capabilities_ptr) { + return functions->GetCapabilities(this, capabilities_ptr); + } + + jdwpTransportError Attach(const char* address, jlong attach_timeout, + jlong handshake_timeout) { + return functions->Attach(this, address, attach_timeout, handshake_timeout); + } + + jdwpTransportError StartListening(const char* address, + char** actual_address) { + return functions->StartListening(this, address, actual_address); + } + + jdwpTransportError StopListening(void) { + return functions->StopListening(this); + } + + jdwpTransportError Accept(jlong accept_timeout, jlong handshake_timeout) { + return functions->Accept(this, accept_timeout, handshake_timeout); + } + + jboolean IsOpen(void) { + return functions->IsOpen(this); + } + + jdwpTransportError Close(void) { + return functions->Close(this); + } + + jdwpTransportError ReadPacket(jdwpPacket *pkt) { + return functions->ReadPacket(this, pkt); + } + + jdwpTransportError WritePacket(const jdwpPacket* pkt) { + return functions->WritePacket(this, pkt); + } + + jdwpTransportError GetLastError(char** error) { + return functions->GetLastError(this, error); + } + + +#endif /* __cplusplus */ +}; + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* JDWPTRANSPORT_H */ + diff --git a/vendor/jdk/1.6.0_23/include/jni.h b/vendor/jdk/1.6.0_23/include/jni.h new file mode 100644 index 0000000..8ed7366 --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/jni.h @@ -0,0 +1,1944 @@ +/* + * %W% %E% + * + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/* + * We used part of Netscape's Java Runtime Interface (JRI) as the starting + * point of our design and implementation. + */ + +/****************************************************************************** + * Java Runtime Interface + * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved. + *****************************************************************************/ + +#ifndef _JAVASOFT_JNI_H_ +#define _JAVASOFT_JNI_H_ + +#include +#include + +/* jni_md.h contains the machine-dependent typedefs for jbyte, jint + and jlong */ + +#include "jni_md.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * JNI Types + */ + +#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H + +typedef unsigned char jboolean; +typedef unsigned short jchar; +typedef short jshort; +typedef float jfloat; +typedef double jdouble; + +typedef jint jsize; + +#ifdef __cplusplus + +class _jobject {}; +class _jclass : public _jobject {}; +class _jthrowable : public _jobject {}; +class _jstring : public _jobject {}; +class _jarray : public _jobject {}; +class _jbooleanArray : public _jarray {}; +class _jbyteArray : public _jarray {}; +class _jcharArray : public _jarray {}; +class _jshortArray : public _jarray {}; +class _jintArray : public _jarray {}; +class _jlongArray : public _jarray {}; +class _jfloatArray : public _jarray {}; +class _jdoubleArray : public _jarray {}; +class _jobjectArray : public _jarray {}; + +typedef _jobject *jobject; +typedef _jclass *jclass; +typedef _jthrowable *jthrowable; +typedef _jstring *jstring; +typedef _jarray *jarray; +typedef _jbooleanArray *jbooleanArray; +typedef _jbyteArray *jbyteArray; +typedef _jcharArray *jcharArray; +typedef _jshortArray *jshortArray; +typedef _jintArray *jintArray; +typedef _jlongArray *jlongArray; +typedef _jfloatArray *jfloatArray; +typedef _jdoubleArray *jdoubleArray; +typedef _jobjectArray *jobjectArray; + +#else + +struct _jobject; + +typedef struct _jobject *jobject; +typedef jobject jclass; +typedef jobject jthrowable; +typedef jobject jstring; +typedef jobject jarray; +typedef jarray jbooleanArray; +typedef jarray jbyteArray; +typedef jarray jcharArray; +typedef jarray jshortArray; +typedef jarray jintArray; +typedef jarray jlongArray; +typedef jarray jfloatArray; +typedef jarray jdoubleArray; +typedef jarray jobjectArray; + +#endif + +typedef jobject jweak; + +typedef union jvalue { + jboolean z; + jbyte b; + jchar c; + jshort s; + jint i; + jlong j; + jfloat f; + jdouble d; + jobject l; +} jvalue; + +struct _jfieldID; +typedef struct _jfieldID *jfieldID; + +struct _jmethodID; +typedef struct _jmethodID *jmethodID; + +/* Return values from jobjectRefType */ +typedef enum _jobjectType { + JNIInvalidRefType = 0, + JNILocalRefType = 1, + JNIGlobalRefType = 2, + JNIWeakGlobalRefType = 3 +} jobjectRefType; + + +#endif /* JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H */ + +/* + * jboolean constants + */ + +#define JNI_FALSE 0 +#define JNI_TRUE 1 + +/* + * possible return values for JNI functions. + */ + +#define JNI_OK 0 /* success */ +#define JNI_ERR (-1) /* unknown error */ +#define JNI_EDETACHED (-2) /* thread detached from the VM */ +#define JNI_EVERSION (-3) /* JNI version error */ +#define JNI_ENOMEM (-4) /* not enough memory */ +#define JNI_EEXIST (-5) /* VM already created */ +#define JNI_EINVAL (-6) /* invalid arguments */ + +/* + * used in ReleaseScalarArrayElements + */ + +#define JNI_COMMIT 1 +#define JNI_ABORT 2 + +/* + * used in RegisterNatives to describe native method name, signature, + * and function pointer. + */ + +typedef struct { + char *name; + char *signature; + void *fnPtr; +} JNINativeMethod; + +/* + * JNI Native Method Interface. + */ + +struct JNINativeInterface_; + +struct JNIEnv_; + +#ifdef __cplusplus +typedef JNIEnv_ JNIEnv; +#else +typedef const struct JNINativeInterface_ *JNIEnv; +#endif + +/* + * JNI Invocation Interface. + */ + +struct JNIInvokeInterface_; + +struct JavaVM_; + +#ifdef __cplusplus +typedef JavaVM_ JavaVM; +#else +typedef const struct JNIInvokeInterface_ *JavaVM; +#endif + +struct JNINativeInterface_ { + void *reserved0; + void *reserved1; + void *reserved2; + + void *reserved3; + jint (JNICALL *GetVersion)(JNIEnv *env); + + jclass (JNICALL *DefineClass) + (JNIEnv *env, const char *name, jobject loader, const jbyte *buf, + jsize len); + jclass (JNICALL *FindClass) + (JNIEnv *env, const char *name); + + jmethodID (JNICALL *FromReflectedMethod) + (JNIEnv *env, jobject method); + jfieldID (JNICALL *FromReflectedField) + (JNIEnv *env, jobject field); + + jobject (JNICALL *ToReflectedMethod) + (JNIEnv *env, jclass cls, jmethodID methodID, jboolean isStatic); + + jclass (JNICALL *GetSuperclass) + (JNIEnv *env, jclass sub); + jboolean (JNICALL *IsAssignableFrom) + (JNIEnv *env, jclass sub, jclass sup); + + jobject (JNICALL *ToReflectedField) + (JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic); + + jint (JNICALL *Throw) + (JNIEnv *env, jthrowable obj); + jint (JNICALL *ThrowNew) + (JNIEnv *env, jclass clazz, const char *msg); + jthrowable (JNICALL *ExceptionOccurred) + (JNIEnv *env); + void (JNICALL *ExceptionDescribe) + (JNIEnv *env); + void (JNICALL *ExceptionClear) + (JNIEnv *env); + void (JNICALL *FatalError) + (JNIEnv *env, const char *msg); + + jint (JNICALL *PushLocalFrame) + (JNIEnv *env, jint capacity); + jobject (JNICALL *PopLocalFrame) + (JNIEnv *env, jobject result); + + jobject (JNICALL *NewGlobalRef) + (JNIEnv *env, jobject lobj); + void (JNICALL *DeleteGlobalRef) + (JNIEnv *env, jobject gref); + void (JNICALL *DeleteLocalRef) + (JNIEnv *env, jobject obj); + jboolean (JNICALL *IsSameObject) + (JNIEnv *env, jobject obj1, jobject obj2); + jobject (JNICALL *NewLocalRef) + (JNIEnv *env, jobject ref); + jint (JNICALL *EnsureLocalCapacity) + (JNIEnv *env, jint capacity); + + jobject (JNICALL *AllocObject) + (JNIEnv *env, jclass clazz); + jobject (JNICALL *NewObject) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jobject (JNICALL *NewObjectV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jobject (JNICALL *NewObjectA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jclass (JNICALL *GetObjectClass) + (JNIEnv *env, jobject obj); + jboolean (JNICALL *IsInstanceOf) + (JNIEnv *env, jobject obj, jclass clazz); + + jmethodID (JNICALL *GetMethodID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (JNICALL *CallObjectMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jobject (JNICALL *CallObjectMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jobject (JNICALL *CallObjectMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); + + jboolean (JNICALL *CallBooleanMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jboolean (JNICALL *CallBooleanMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jboolean (JNICALL *CallBooleanMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); + + jbyte (JNICALL *CallByteMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jbyte (JNICALL *CallByteMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jbyte (JNICALL *CallByteMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jchar (JNICALL *CallCharMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jchar (JNICALL *CallCharMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jchar (JNICALL *CallCharMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jshort (JNICALL *CallShortMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jshort (JNICALL *CallShortMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jshort (JNICALL *CallShortMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jint (JNICALL *CallIntMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jint (JNICALL *CallIntMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jint (JNICALL *CallIntMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jlong (JNICALL *CallLongMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jlong (JNICALL *CallLongMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jlong (JNICALL *CallLongMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jfloat (JNICALL *CallFloatMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jfloat (JNICALL *CallFloatMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jfloat (JNICALL *CallFloatMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + jdouble (JNICALL *CallDoubleMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + jdouble (JNICALL *CallDoubleMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + jdouble (JNICALL *CallDoubleMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args); + + void (JNICALL *CallVoidMethod) + (JNIEnv *env, jobject obj, jmethodID methodID, ...); + void (JNICALL *CallVoidMethodV) + (JNIEnv *env, jobject obj, jmethodID methodID, va_list args); + void (JNICALL *CallVoidMethodA) + (JNIEnv *env, jobject obj, jmethodID methodID, const jvalue * args); + + jobject (JNICALL *CallNonvirtualObjectMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jobject (JNICALL *CallNonvirtualObjectMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jobject (JNICALL *CallNonvirtualObjectMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue * args); + + jboolean (JNICALL *CallNonvirtualBooleanMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jboolean (JNICALL *CallNonvirtualBooleanMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jboolean (JNICALL *CallNonvirtualBooleanMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue * args); + + jbyte (JNICALL *CallNonvirtualByteMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jbyte (JNICALL *CallNonvirtualByteMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jbyte (JNICALL *CallNonvirtualByteMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + jchar (JNICALL *CallNonvirtualCharMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jchar (JNICALL *CallNonvirtualCharMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jchar (JNICALL *CallNonvirtualCharMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + jshort (JNICALL *CallNonvirtualShortMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jshort (JNICALL *CallNonvirtualShortMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jshort (JNICALL *CallNonvirtualShortMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + jint (JNICALL *CallNonvirtualIntMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jint (JNICALL *CallNonvirtualIntMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jint (JNICALL *CallNonvirtualIntMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + jlong (JNICALL *CallNonvirtualLongMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jlong (JNICALL *CallNonvirtualLongMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jlong (JNICALL *CallNonvirtualLongMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + jfloat (JNICALL *CallNonvirtualFloatMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jfloat (JNICALL *CallNonvirtualFloatMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jfloat (JNICALL *CallNonvirtualFloatMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + jdouble (JNICALL *CallNonvirtualDoubleMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + jdouble (JNICALL *CallNonvirtualDoubleMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + jdouble (JNICALL *CallNonvirtualDoubleMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue *args); + + void (JNICALL *CallNonvirtualVoidMethod) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, ...); + void (JNICALL *CallNonvirtualVoidMethodV) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + va_list args); + void (JNICALL *CallNonvirtualVoidMethodA) + (JNIEnv *env, jobject obj, jclass clazz, jmethodID methodID, + const jvalue * args); + + jfieldID (JNICALL *GetFieldID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (JNICALL *GetObjectField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jboolean (JNICALL *GetBooleanField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jbyte (JNICALL *GetByteField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jchar (JNICALL *GetCharField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jshort (JNICALL *GetShortField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jint (JNICALL *GetIntField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jlong (JNICALL *GetLongField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jfloat (JNICALL *GetFloatField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + jdouble (JNICALL *GetDoubleField) + (JNIEnv *env, jobject obj, jfieldID fieldID); + + void (JNICALL *SetObjectField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jobject val); + void (JNICALL *SetBooleanField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jboolean val); + void (JNICALL *SetByteField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jbyte val); + void (JNICALL *SetCharField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jchar val); + void (JNICALL *SetShortField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jshort val); + void (JNICALL *SetIntField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jint val); + void (JNICALL *SetLongField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jlong val); + void (JNICALL *SetFloatField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jfloat val); + void (JNICALL *SetDoubleField) + (JNIEnv *env, jobject obj, jfieldID fieldID, jdouble val); + + jmethodID (JNICALL *GetStaticMethodID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + + jobject (JNICALL *CallStaticObjectMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jobject (JNICALL *CallStaticObjectMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jobject (JNICALL *CallStaticObjectMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jboolean (JNICALL *CallStaticBooleanMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jboolean (JNICALL *CallStaticBooleanMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jboolean (JNICALL *CallStaticBooleanMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jbyte (JNICALL *CallStaticByteMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jbyte (JNICALL *CallStaticByteMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jbyte (JNICALL *CallStaticByteMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jchar (JNICALL *CallStaticCharMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jchar (JNICALL *CallStaticCharMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jchar (JNICALL *CallStaticCharMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jshort (JNICALL *CallStaticShortMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jshort (JNICALL *CallStaticShortMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jshort (JNICALL *CallStaticShortMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jint (JNICALL *CallStaticIntMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jint (JNICALL *CallStaticIntMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jint (JNICALL *CallStaticIntMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jlong (JNICALL *CallStaticLongMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jlong (JNICALL *CallStaticLongMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jlong (JNICALL *CallStaticLongMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jfloat (JNICALL *CallStaticFloatMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jfloat (JNICALL *CallStaticFloatMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jfloat (JNICALL *CallStaticFloatMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + jdouble (JNICALL *CallStaticDoubleMethod) + (JNIEnv *env, jclass clazz, jmethodID methodID, ...); + jdouble (JNICALL *CallStaticDoubleMethodV) + (JNIEnv *env, jclass clazz, jmethodID methodID, va_list args); + jdouble (JNICALL *CallStaticDoubleMethodA) + (JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args); + + void (JNICALL *CallStaticVoidMethod) + (JNIEnv *env, jclass cls, jmethodID methodID, ...); + void (JNICALL *CallStaticVoidMethodV) + (JNIEnv *env, jclass cls, jmethodID methodID, va_list args); + void (JNICALL *CallStaticVoidMethodA) + (JNIEnv *env, jclass cls, jmethodID methodID, const jvalue * args); + + jfieldID (JNICALL *GetStaticFieldID) + (JNIEnv *env, jclass clazz, const char *name, const char *sig); + jobject (JNICALL *GetStaticObjectField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jboolean (JNICALL *GetStaticBooleanField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jbyte (JNICALL *GetStaticByteField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jchar (JNICALL *GetStaticCharField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jshort (JNICALL *GetStaticShortField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jint (JNICALL *GetStaticIntField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jlong (JNICALL *GetStaticLongField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jfloat (JNICALL *GetStaticFloatField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + jdouble (JNICALL *GetStaticDoubleField) + (JNIEnv *env, jclass clazz, jfieldID fieldID); + + void (JNICALL *SetStaticObjectField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value); + void (JNICALL *SetStaticBooleanField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jboolean value); + void (JNICALL *SetStaticByteField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jbyte value); + void (JNICALL *SetStaticCharField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jchar value); + void (JNICALL *SetStaticShortField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jshort value); + void (JNICALL *SetStaticIntField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jint value); + void (JNICALL *SetStaticLongField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jlong value); + void (JNICALL *SetStaticFloatField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jfloat value); + void (JNICALL *SetStaticDoubleField) + (JNIEnv *env, jclass clazz, jfieldID fieldID, jdouble value); + + jstring (JNICALL *NewString) + (JNIEnv *env, const jchar *unicode, jsize len); + jsize (JNICALL *GetStringLength) + (JNIEnv *env, jstring str); + const jchar *(JNICALL *GetStringChars) + (JNIEnv *env, jstring str, jboolean *isCopy); + void (JNICALL *ReleaseStringChars) + (JNIEnv *env, jstring str, const jchar *chars); + + jstring (JNICALL *NewStringUTF) + (JNIEnv *env, const char *utf); + jsize (JNICALL *GetStringUTFLength) + (JNIEnv *env, jstring str); + const char* (JNICALL *GetStringUTFChars) + (JNIEnv *env, jstring str, jboolean *isCopy); + void (JNICALL *ReleaseStringUTFChars) + (JNIEnv *env, jstring str, const char* chars); + + + jsize (JNICALL *GetArrayLength) + (JNIEnv *env, jarray array); + + jobjectArray (JNICALL *NewObjectArray) + (JNIEnv *env, jsize len, jclass clazz, jobject init); + jobject (JNICALL *GetObjectArrayElement) + (JNIEnv *env, jobjectArray array, jsize index); + void (JNICALL *SetObjectArrayElement) + (JNIEnv *env, jobjectArray array, jsize index, jobject val); + + jbooleanArray (JNICALL *NewBooleanArray) + (JNIEnv *env, jsize len); + jbyteArray (JNICALL *NewByteArray) + (JNIEnv *env, jsize len); + jcharArray (JNICALL *NewCharArray) + (JNIEnv *env, jsize len); + jshortArray (JNICALL *NewShortArray) + (JNIEnv *env, jsize len); + jintArray (JNICALL *NewIntArray) + (JNIEnv *env, jsize len); + jlongArray (JNICALL *NewLongArray) + (JNIEnv *env, jsize len); + jfloatArray (JNICALL *NewFloatArray) + (JNIEnv *env, jsize len); + jdoubleArray (JNICALL *NewDoubleArray) + (JNIEnv *env, jsize len); + + jboolean * (JNICALL *GetBooleanArrayElements) + (JNIEnv *env, jbooleanArray array, jboolean *isCopy); + jbyte * (JNICALL *GetByteArrayElements) + (JNIEnv *env, jbyteArray array, jboolean *isCopy); + jchar * (JNICALL *GetCharArrayElements) + (JNIEnv *env, jcharArray array, jboolean *isCopy); + jshort * (JNICALL *GetShortArrayElements) + (JNIEnv *env, jshortArray array, jboolean *isCopy); + jint * (JNICALL *GetIntArrayElements) + (JNIEnv *env, jintArray array, jboolean *isCopy); + jlong * (JNICALL *GetLongArrayElements) + (JNIEnv *env, jlongArray array, jboolean *isCopy); + jfloat * (JNICALL *GetFloatArrayElements) + (JNIEnv *env, jfloatArray array, jboolean *isCopy); + jdouble * (JNICALL *GetDoubleArrayElements) + (JNIEnv *env, jdoubleArray array, jboolean *isCopy); + + void (JNICALL *ReleaseBooleanArrayElements) + (JNIEnv *env, jbooleanArray array, jboolean *elems, jint mode); + void (JNICALL *ReleaseByteArrayElements) + (JNIEnv *env, jbyteArray array, jbyte *elems, jint mode); + void (JNICALL *ReleaseCharArrayElements) + (JNIEnv *env, jcharArray array, jchar *elems, jint mode); + void (JNICALL *ReleaseShortArrayElements) + (JNIEnv *env, jshortArray array, jshort *elems, jint mode); + void (JNICALL *ReleaseIntArrayElements) + (JNIEnv *env, jintArray array, jint *elems, jint mode); + void (JNICALL *ReleaseLongArrayElements) + (JNIEnv *env, jlongArray array, jlong *elems, jint mode); + void (JNICALL *ReleaseFloatArrayElements) + (JNIEnv *env, jfloatArray array, jfloat *elems, jint mode); + void (JNICALL *ReleaseDoubleArrayElements) + (JNIEnv *env, jdoubleArray array, jdouble *elems, jint mode); + + void (JNICALL *GetBooleanArrayRegion) + (JNIEnv *env, jbooleanArray array, jsize start, jsize l, jboolean *buf); + void (JNICALL *GetByteArrayRegion) + (JNIEnv *env, jbyteArray array, jsize start, jsize len, jbyte *buf); + void (JNICALL *GetCharArrayRegion) + (JNIEnv *env, jcharArray array, jsize start, jsize len, jchar *buf); + void (JNICALL *GetShortArrayRegion) + (JNIEnv *env, jshortArray array, jsize start, jsize len, jshort *buf); + void (JNICALL *GetIntArrayRegion) + (JNIEnv *env, jintArray array, jsize start, jsize len, jint *buf); + void (JNICALL *GetLongArrayRegion) + (JNIEnv *env, jlongArray array, jsize start, jsize len, jlong *buf); + void (JNICALL *GetFloatArrayRegion) + (JNIEnv *env, jfloatArray array, jsize start, jsize len, jfloat *buf); + void (JNICALL *GetDoubleArrayRegion) + (JNIEnv *env, jdoubleArray array, jsize start, jsize len, jdouble *buf); + + void (JNICALL *SetBooleanArrayRegion) + (JNIEnv *env, jbooleanArray array, jsize start, jsize l, const jboolean *buf); + void (JNICALL *SetByteArrayRegion) + (JNIEnv *env, jbyteArray array, jsize start, jsize len, const jbyte *buf); + void (JNICALL *SetCharArrayRegion) + (JNIEnv *env, jcharArray array, jsize start, jsize len, const jchar *buf); + void (JNICALL *SetShortArrayRegion) + (JNIEnv *env, jshortArray array, jsize start, jsize len, const jshort *buf); + void (JNICALL *SetIntArrayRegion) + (JNIEnv *env, jintArray array, jsize start, jsize len, const jint *buf); + void (JNICALL *SetLongArrayRegion) + (JNIEnv *env, jlongArray array, jsize start, jsize len, const jlong *buf); + void (JNICALL *SetFloatArrayRegion) + (JNIEnv *env, jfloatArray array, jsize start, jsize len, const jfloat *buf); + void (JNICALL *SetDoubleArrayRegion) + (JNIEnv *env, jdoubleArray array, jsize start, jsize len, const jdouble *buf); + + jint (JNICALL *RegisterNatives) + (JNIEnv *env, jclass clazz, const JNINativeMethod *methods, + jint nMethods); + jint (JNICALL *UnregisterNatives) + (JNIEnv *env, jclass clazz); + + jint (JNICALL *MonitorEnter) + (JNIEnv *env, jobject obj); + jint (JNICALL *MonitorExit) + (JNIEnv *env, jobject obj); + + jint (JNICALL *GetJavaVM) + (JNIEnv *env, JavaVM **vm); + + void (JNICALL *GetStringRegion) + (JNIEnv *env, jstring str, jsize start, jsize len, jchar *buf); + void (JNICALL *GetStringUTFRegion) + (JNIEnv *env, jstring str, jsize start, jsize len, char *buf); + + void * (JNICALL *GetPrimitiveArrayCritical) + (JNIEnv *env, jarray array, jboolean *isCopy); + void (JNICALL *ReleasePrimitiveArrayCritical) + (JNIEnv *env, jarray array, void *carray, jint mode); + + const jchar * (JNICALL *GetStringCritical) + (JNIEnv *env, jstring string, jboolean *isCopy); + void (JNICALL *ReleaseStringCritical) + (JNIEnv *env, jstring string, const jchar *cstring); + + jweak (JNICALL *NewWeakGlobalRef) + (JNIEnv *env, jobject obj); + void (JNICALL *DeleteWeakGlobalRef) + (JNIEnv *env, jweak ref); + + jboolean (JNICALL *ExceptionCheck) + (JNIEnv *env); + + jobject (JNICALL *NewDirectByteBuffer) + (JNIEnv* env, void* address, jlong capacity); + void* (JNICALL *GetDirectBufferAddress) + (JNIEnv* env, jobject buf); + jlong (JNICALL *GetDirectBufferCapacity) + (JNIEnv* env, jobject buf); + + /* New JNI 1.6 Features */ + + jobjectRefType (JNICALL *GetObjectRefType) + (JNIEnv* env, jobject obj); +}; + +/* + * We use inlined functions for C++ so that programmers can write: + * + * env->FindClass("java/lang/String") + * + * in C++ rather than: + * + * (*env)->FindClass(env, "java/lang/String") + * + * in C. + */ + +struct JNIEnv_ { + const struct JNINativeInterface_ *functions; +#ifdef __cplusplus + + jint GetVersion() { + return functions->GetVersion(this); + } + jclass DefineClass(const char *name, jobject loader, const jbyte *buf, + jsize len) { + return functions->DefineClass(this, name, loader, buf, len); + } + jclass FindClass(const char *name) { + return functions->FindClass(this, name); + } + jmethodID FromReflectedMethod(jobject method) { + return functions->FromReflectedMethod(this,method); + } + jfieldID FromReflectedField(jobject field) { + return functions->FromReflectedField(this,field); + } + + jobject ToReflectedMethod(jclass cls, jmethodID methodID, jboolean isStatic) { + return functions->ToReflectedMethod(this, cls, methodID, isStatic); + } + + jclass GetSuperclass(jclass sub) { + return functions->GetSuperclass(this, sub); + } + jboolean IsAssignableFrom(jclass sub, jclass sup) { + return functions->IsAssignableFrom(this, sub, sup); + } + + jobject ToReflectedField(jclass cls, jfieldID fieldID, jboolean isStatic) { + return functions->ToReflectedField(this,cls,fieldID,isStatic); + } + + jint Throw(jthrowable obj) { + return functions->Throw(this, obj); + } + jint ThrowNew(jclass clazz, const char *msg) { + return functions->ThrowNew(this, clazz, msg); + } + jthrowable ExceptionOccurred() { + return functions->ExceptionOccurred(this); + } + void ExceptionDescribe() { + functions->ExceptionDescribe(this); + } + void ExceptionClear() { + functions->ExceptionClear(this); + } + void FatalError(const char *msg) { + functions->FatalError(this, msg); + } + + jint PushLocalFrame(jint capacity) { + return functions->PushLocalFrame(this,capacity); + } + jobject PopLocalFrame(jobject result) { + return functions->PopLocalFrame(this,result); + } + + jobject NewGlobalRef(jobject lobj) { + return functions->NewGlobalRef(this,lobj); + } + void DeleteGlobalRef(jobject gref) { + functions->DeleteGlobalRef(this,gref); + } + void DeleteLocalRef(jobject obj) { + functions->DeleteLocalRef(this, obj); + } + + jboolean IsSameObject(jobject obj1, jobject obj2) { + return functions->IsSameObject(this,obj1,obj2); + } + + jobject NewLocalRef(jobject ref) { + return functions->NewLocalRef(this,ref); + } + jint EnsureLocalCapacity(jint capacity) { + return functions->EnsureLocalCapacity(this,capacity); + } + + jobject AllocObject(jclass clazz) { + return functions->AllocObject(this,clazz); + } + jobject NewObject(jclass clazz, jmethodID methodID, ...) { + va_list args; + jobject result; + va_start(args, methodID); + result = functions->NewObjectV(this,clazz,methodID,args); + va_end(args); + return result; + } + jobject NewObjectV(jclass clazz, jmethodID methodID, + va_list args) { + return functions->NewObjectV(this,clazz,methodID,args); + } + jobject NewObjectA(jclass clazz, jmethodID methodID, + const jvalue *args) { + return functions->NewObjectA(this,clazz,methodID,args); + } + + jclass GetObjectClass(jobject obj) { + return functions->GetObjectClass(this,obj); + } + jboolean IsInstanceOf(jobject obj, jclass clazz) { + return functions->IsInstanceOf(this,obj,clazz); + } + + jmethodID GetMethodID(jclass clazz, const char *name, + const char *sig) { + return functions->GetMethodID(this,clazz,name,sig); + } + + jobject CallObjectMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jobject result; + va_start(args,methodID); + result = functions->CallObjectMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jobject CallObjectMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallObjectMethodV(this,obj,methodID,args); + } + jobject CallObjectMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallObjectMethodA(this,obj,methodID,args); + } + + jboolean CallBooleanMethod(jobject obj, + jmethodID methodID, ...) { + va_list args; + jboolean result; + va_start(args,methodID); + result = functions->CallBooleanMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jboolean CallBooleanMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallBooleanMethodV(this,obj,methodID,args); + } + jboolean CallBooleanMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallBooleanMethodA(this,obj,methodID, args); + } + + jbyte CallByteMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jbyte result; + va_start(args,methodID); + result = functions->CallByteMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jbyte CallByteMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallByteMethodV(this,obj,methodID,args); + } + jbyte CallByteMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallByteMethodA(this,obj,methodID,args); + } + + jchar CallCharMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jchar result; + va_start(args,methodID); + result = functions->CallCharMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jchar CallCharMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallCharMethodV(this,obj,methodID,args); + } + jchar CallCharMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallCharMethodA(this,obj,methodID,args); + } + + jshort CallShortMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jshort result; + va_start(args,methodID); + result = functions->CallShortMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jshort CallShortMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallShortMethodV(this,obj,methodID,args); + } + jshort CallShortMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallShortMethodA(this,obj,methodID,args); + } + + jint CallIntMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jint result; + va_start(args,methodID); + result = functions->CallIntMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jint CallIntMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallIntMethodV(this,obj,methodID,args); + } + jint CallIntMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallIntMethodA(this,obj,methodID,args); + } + + jlong CallLongMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jlong result; + va_start(args,methodID); + result = functions->CallLongMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jlong CallLongMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallLongMethodV(this,obj,methodID,args); + } + jlong CallLongMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallLongMethodA(this,obj,methodID,args); + } + + jfloat CallFloatMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jfloat result; + va_start(args,methodID); + result = functions->CallFloatMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jfloat CallFloatMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallFloatMethodV(this,obj,methodID,args); + } + jfloat CallFloatMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallFloatMethodA(this,obj,methodID,args); + } + + jdouble CallDoubleMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + jdouble result; + va_start(args,methodID); + result = functions->CallDoubleMethodV(this,obj,methodID,args); + va_end(args); + return result; + } + jdouble CallDoubleMethodV(jobject obj, jmethodID methodID, + va_list args) { + return functions->CallDoubleMethodV(this,obj,methodID,args); + } + jdouble CallDoubleMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + return functions->CallDoubleMethodA(this,obj,methodID,args); + } + + void CallVoidMethod(jobject obj, jmethodID methodID, ...) { + va_list args; + va_start(args,methodID); + functions->CallVoidMethodV(this,obj,methodID,args); + va_end(args); + } + void CallVoidMethodV(jobject obj, jmethodID methodID, + va_list args) { + functions->CallVoidMethodV(this,obj,methodID,args); + } + void CallVoidMethodA(jobject obj, jmethodID methodID, + const jvalue * args) { + functions->CallVoidMethodA(this,obj,methodID,args); + } + + jobject CallNonvirtualObjectMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jobject result; + va_start(args,methodID); + result = functions->CallNonvirtualObjectMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jobject CallNonvirtualObjectMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualObjectMethodV(this,obj,clazz, + methodID,args); + } + jobject CallNonvirtualObjectMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualObjectMethodA(this,obj,clazz, + methodID,args); + } + + jboolean CallNonvirtualBooleanMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jboolean result; + va_start(args,methodID); + result = functions->CallNonvirtualBooleanMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jboolean CallNonvirtualBooleanMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualBooleanMethodV(this,obj,clazz, + methodID,args); + } + jboolean CallNonvirtualBooleanMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualBooleanMethodA(this,obj,clazz, + methodID, args); + } + + jbyte CallNonvirtualByteMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jbyte result; + va_start(args,methodID); + result = functions->CallNonvirtualByteMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jbyte CallNonvirtualByteMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualByteMethodV(this,obj,clazz, + methodID,args); + } + jbyte CallNonvirtualByteMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualByteMethodA(this,obj,clazz, + methodID,args); + } + + jchar CallNonvirtualCharMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jchar result; + va_start(args,methodID); + result = functions->CallNonvirtualCharMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jchar CallNonvirtualCharMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualCharMethodV(this,obj,clazz, + methodID,args); + } + jchar CallNonvirtualCharMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualCharMethodA(this,obj,clazz, + methodID,args); + } + + jshort CallNonvirtualShortMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jshort result; + va_start(args,methodID); + result = functions->CallNonvirtualShortMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jshort CallNonvirtualShortMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualShortMethodV(this,obj,clazz, + methodID,args); + } + jshort CallNonvirtualShortMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualShortMethodA(this,obj,clazz, + methodID,args); + } + + jint CallNonvirtualIntMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jint result; + va_start(args,methodID); + result = functions->CallNonvirtualIntMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jint CallNonvirtualIntMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualIntMethodV(this,obj,clazz, + methodID,args); + } + jint CallNonvirtualIntMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualIntMethodA(this,obj,clazz, + methodID,args); + } + + jlong CallNonvirtualLongMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jlong result; + va_start(args,methodID); + result = functions->CallNonvirtualLongMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jlong CallNonvirtualLongMethodV(jobject obj, jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallNonvirtualLongMethodV(this,obj,clazz, + methodID,args); + } + jlong CallNonvirtualLongMethodA(jobject obj, jclass clazz, + jmethodID methodID, const jvalue * args) { + return functions->CallNonvirtualLongMethodA(this,obj,clazz, + methodID,args); + } + + jfloat CallNonvirtualFloatMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jfloat result; + va_start(args,methodID); + result = functions->CallNonvirtualFloatMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jfloat CallNonvirtualFloatMethodV(jobject obj, jclass clazz, + jmethodID methodID, + va_list args) { + return functions->CallNonvirtualFloatMethodV(this,obj,clazz, + methodID,args); + } + jfloat CallNonvirtualFloatMethodA(jobject obj, jclass clazz, + jmethodID methodID, + const jvalue * args) { + return functions->CallNonvirtualFloatMethodA(this,obj,clazz, + methodID,args); + } + + jdouble CallNonvirtualDoubleMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + jdouble result; + va_start(args,methodID); + result = functions->CallNonvirtualDoubleMethodV(this,obj,clazz, + methodID,args); + va_end(args); + return result; + } + jdouble CallNonvirtualDoubleMethodV(jobject obj, jclass clazz, + jmethodID methodID, + va_list args) { + return functions->CallNonvirtualDoubleMethodV(this,obj,clazz, + methodID,args); + } + jdouble CallNonvirtualDoubleMethodA(jobject obj, jclass clazz, + jmethodID methodID, + const jvalue * args) { + return functions->CallNonvirtualDoubleMethodA(this,obj,clazz, + methodID,args); + } + + void CallNonvirtualVoidMethod(jobject obj, jclass clazz, + jmethodID methodID, ...) { + va_list args; + va_start(args,methodID); + functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); + va_end(args); + } + void CallNonvirtualVoidMethodV(jobject obj, jclass clazz, + jmethodID methodID, + va_list args) { + functions->CallNonvirtualVoidMethodV(this,obj,clazz,methodID,args); + } + void CallNonvirtualVoidMethodA(jobject obj, jclass clazz, + jmethodID methodID, + const jvalue * args) { + functions->CallNonvirtualVoidMethodA(this,obj,clazz,methodID,args); + } + + jfieldID GetFieldID(jclass clazz, const char *name, + const char *sig) { + return functions->GetFieldID(this,clazz,name,sig); + } + + jobject GetObjectField(jobject obj, jfieldID fieldID) { + return functions->GetObjectField(this,obj,fieldID); + } + jboolean GetBooleanField(jobject obj, jfieldID fieldID) { + return functions->GetBooleanField(this,obj,fieldID); + } + jbyte GetByteField(jobject obj, jfieldID fieldID) { + return functions->GetByteField(this,obj,fieldID); + } + jchar GetCharField(jobject obj, jfieldID fieldID) { + return functions->GetCharField(this,obj,fieldID); + } + jshort GetShortField(jobject obj, jfieldID fieldID) { + return functions->GetShortField(this,obj,fieldID); + } + jint GetIntField(jobject obj, jfieldID fieldID) { + return functions->GetIntField(this,obj,fieldID); + } + jlong GetLongField(jobject obj, jfieldID fieldID) { + return functions->GetLongField(this,obj,fieldID); + } + jfloat GetFloatField(jobject obj, jfieldID fieldID) { + return functions->GetFloatField(this,obj,fieldID); + } + jdouble GetDoubleField(jobject obj, jfieldID fieldID) { + return functions->GetDoubleField(this,obj,fieldID); + } + + void SetObjectField(jobject obj, jfieldID fieldID, jobject val) { + functions->SetObjectField(this,obj,fieldID,val); + } + void SetBooleanField(jobject obj, jfieldID fieldID, + jboolean val) { + functions->SetBooleanField(this,obj,fieldID,val); + } + void SetByteField(jobject obj, jfieldID fieldID, + jbyte val) { + functions->SetByteField(this,obj,fieldID,val); + } + void SetCharField(jobject obj, jfieldID fieldID, + jchar val) { + functions->SetCharField(this,obj,fieldID,val); + } + void SetShortField(jobject obj, jfieldID fieldID, + jshort val) { + functions->SetShortField(this,obj,fieldID,val); + } + void SetIntField(jobject obj, jfieldID fieldID, + jint val) { + functions->SetIntField(this,obj,fieldID,val); + } + void SetLongField(jobject obj, jfieldID fieldID, + jlong val) { + functions->SetLongField(this,obj,fieldID,val); + } + void SetFloatField(jobject obj, jfieldID fieldID, + jfloat val) { + functions->SetFloatField(this,obj,fieldID,val); + } + void SetDoubleField(jobject obj, jfieldID fieldID, + jdouble val) { + functions->SetDoubleField(this,obj,fieldID,val); + } + + jmethodID GetStaticMethodID(jclass clazz, const char *name, + const char *sig) { + return functions->GetStaticMethodID(this,clazz,name,sig); + } + + jobject CallStaticObjectMethod(jclass clazz, jmethodID methodID, + ...) { + va_list args; + jobject result; + va_start(args,methodID); + result = functions->CallStaticObjectMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jobject CallStaticObjectMethodV(jclass clazz, jmethodID methodID, + va_list args) { + return functions->CallStaticObjectMethodV(this,clazz,methodID,args); + } + jobject CallStaticObjectMethodA(jclass clazz, jmethodID methodID, + const jvalue *args) { + return functions->CallStaticObjectMethodA(this,clazz,methodID,args); + } + + jboolean CallStaticBooleanMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jboolean result; + va_start(args,methodID); + result = functions->CallStaticBooleanMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jboolean CallStaticBooleanMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticBooleanMethodV(this,clazz,methodID,args); + } + jboolean CallStaticBooleanMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticBooleanMethodA(this,clazz,methodID,args); + } + + jbyte CallStaticByteMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jbyte result; + va_start(args,methodID); + result = functions->CallStaticByteMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jbyte CallStaticByteMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticByteMethodV(this,clazz,methodID,args); + } + jbyte CallStaticByteMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticByteMethodA(this,clazz,methodID,args); + } + + jchar CallStaticCharMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jchar result; + va_start(args,methodID); + result = functions->CallStaticCharMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jchar CallStaticCharMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticCharMethodV(this,clazz,methodID,args); + } + jchar CallStaticCharMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticCharMethodA(this,clazz,methodID,args); + } + + jshort CallStaticShortMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jshort result; + va_start(args,methodID); + result = functions->CallStaticShortMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jshort CallStaticShortMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticShortMethodV(this,clazz,methodID,args); + } + jshort CallStaticShortMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticShortMethodA(this,clazz,methodID,args); + } + + jint CallStaticIntMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jint result; + va_start(args,methodID); + result = functions->CallStaticIntMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jint CallStaticIntMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticIntMethodV(this,clazz,methodID,args); + } + jint CallStaticIntMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticIntMethodA(this,clazz,methodID,args); + } + + jlong CallStaticLongMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jlong result; + va_start(args,methodID); + result = functions->CallStaticLongMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jlong CallStaticLongMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticLongMethodV(this,clazz,methodID,args); + } + jlong CallStaticLongMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticLongMethodA(this,clazz,methodID,args); + } + + jfloat CallStaticFloatMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jfloat result; + va_start(args,methodID); + result = functions->CallStaticFloatMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jfloat CallStaticFloatMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticFloatMethodV(this,clazz,methodID,args); + } + jfloat CallStaticFloatMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticFloatMethodA(this,clazz,methodID,args); + } + + jdouble CallStaticDoubleMethod(jclass clazz, + jmethodID methodID, ...) { + va_list args; + jdouble result; + va_start(args,methodID); + result = functions->CallStaticDoubleMethodV(this,clazz,methodID,args); + va_end(args); + return result; + } + jdouble CallStaticDoubleMethodV(jclass clazz, + jmethodID methodID, va_list args) { + return functions->CallStaticDoubleMethodV(this,clazz,methodID,args); + } + jdouble CallStaticDoubleMethodA(jclass clazz, + jmethodID methodID, const jvalue *args) { + return functions->CallStaticDoubleMethodA(this,clazz,methodID,args); + } + + void CallStaticVoidMethod(jclass cls, jmethodID methodID, ...) { + va_list args; + va_start(args,methodID); + functions->CallStaticVoidMethodV(this,cls,methodID,args); + va_end(args); + } + void CallStaticVoidMethodV(jclass cls, jmethodID methodID, + va_list args) { + functions->CallStaticVoidMethodV(this,cls,methodID,args); + } + void CallStaticVoidMethodA(jclass cls, jmethodID methodID, + const jvalue * args) { + functions->CallStaticVoidMethodA(this,cls,methodID,args); + } + + jfieldID GetStaticFieldID(jclass clazz, const char *name, + const char *sig) { + return functions->GetStaticFieldID(this,clazz,name,sig); + } + jobject GetStaticObjectField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticObjectField(this,clazz,fieldID); + } + jboolean GetStaticBooleanField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticBooleanField(this,clazz,fieldID); + } + jbyte GetStaticByteField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticByteField(this,clazz,fieldID); + } + jchar GetStaticCharField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticCharField(this,clazz,fieldID); + } + jshort GetStaticShortField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticShortField(this,clazz,fieldID); + } + jint GetStaticIntField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticIntField(this,clazz,fieldID); + } + jlong GetStaticLongField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticLongField(this,clazz,fieldID); + } + jfloat GetStaticFloatField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticFloatField(this,clazz,fieldID); + } + jdouble GetStaticDoubleField(jclass clazz, jfieldID fieldID) { + return functions->GetStaticDoubleField(this,clazz,fieldID); + } + + void SetStaticObjectField(jclass clazz, jfieldID fieldID, + jobject value) { + functions->SetStaticObjectField(this,clazz,fieldID,value); + } + void SetStaticBooleanField(jclass clazz, jfieldID fieldID, + jboolean value) { + functions->SetStaticBooleanField(this,clazz,fieldID,value); + } + void SetStaticByteField(jclass clazz, jfieldID fieldID, + jbyte value) { + functions->SetStaticByteField(this,clazz,fieldID,value); + } + void SetStaticCharField(jclass clazz, jfieldID fieldID, + jchar value) { + functions->SetStaticCharField(this,clazz,fieldID,value); + } + void SetStaticShortField(jclass clazz, jfieldID fieldID, + jshort value) { + functions->SetStaticShortField(this,clazz,fieldID,value); + } + void SetStaticIntField(jclass clazz, jfieldID fieldID, + jint value) { + functions->SetStaticIntField(this,clazz,fieldID,value); + } + void SetStaticLongField(jclass clazz, jfieldID fieldID, + jlong value) { + functions->SetStaticLongField(this,clazz,fieldID,value); + } + void SetStaticFloatField(jclass clazz, jfieldID fieldID, + jfloat value) { + functions->SetStaticFloatField(this,clazz,fieldID,value); + } + void SetStaticDoubleField(jclass clazz, jfieldID fieldID, + jdouble value) { + functions->SetStaticDoubleField(this,clazz,fieldID,value); + } + + jstring NewString(const jchar *unicode, jsize len) { + return functions->NewString(this,unicode,len); + } + jsize GetStringLength(jstring str) { + return functions->GetStringLength(this,str); + } + const jchar *GetStringChars(jstring str, jboolean *isCopy) { + return functions->GetStringChars(this,str,isCopy); + } + void ReleaseStringChars(jstring str, const jchar *chars) { + functions->ReleaseStringChars(this,str,chars); + } + + jstring NewStringUTF(const char *utf) { + return functions->NewStringUTF(this,utf); + } + jsize GetStringUTFLength(jstring str) { + return functions->GetStringUTFLength(this,str); + } + const char* GetStringUTFChars(jstring str, jboolean *isCopy) { + return functions->GetStringUTFChars(this,str,isCopy); + } + void ReleaseStringUTFChars(jstring str, const char* chars) { + functions->ReleaseStringUTFChars(this,str,chars); + } + + jsize GetArrayLength(jarray array) { + return functions->GetArrayLength(this,array); + } + + jobjectArray NewObjectArray(jsize len, jclass clazz, + jobject init) { + return functions->NewObjectArray(this,len,clazz,init); + } + jobject GetObjectArrayElement(jobjectArray array, jsize index) { + return functions->GetObjectArrayElement(this,array,index); + } + void SetObjectArrayElement(jobjectArray array, jsize index, + jobject val) { + functions->SetObjectArrayElement(this,array,index,val); + } + + jbooleanArray NewBooleanArray(jsize len) { + return functions->NewBooleanArray(this,len); + } + jbyteArray NewByteArray(jsize len) { + return functions->NewByteArray(this,len); + } + jcharArray NewCharArray(jsize len) { + return functions->NewCharArray(this,len); + } + jshortArray NewShortArray(jsize len) { + return functions->NewShortArray(this,len); + } + jintArray NewIntArray(jsize len) { + return functions->NewIntArray(this,len); + } + jlongArray NewLongArray(jsize len) { + return functions->NewLongArray(this,len); + } + jfloatArray NewFloatArray(jsize len) { + return functions->NewFloatArray(this,len); + } + jdoubleArray NewDoubleArray(jsize len) { + return functions->NewDoubleArray(this,len); + } + + jboolean * GetBooleanArrayElements(jbooleanArray array, jboolean *isCopy) { + return functions->GetBooleanArrayElements(this,array,isCopy); + } + jbyte * GetByteArrayElements(jbyteArray array, jboolean *isCopy) { + return functions->GetByteArrayElements(this,array,isCopy); + } + jchar * GetCharArrayElements(jcharArray array, jboolean *isCopy) { + return functions->GetCharArrayElements(this,array,isCopy); + } + jshort * GetShortArrayElements(jshortArray array, jboolean *isCopy) { + return functions->GetShortArrayElements(this,array,isCopy); + } + jint * GetIntArrayElements(jintArray array, jboolean *isCopy) { + return functions->GetIntArrayElements(this,array,isCopy); + } + jlong * GetLongArrayElements(jlongArray array, jboolean *isCopy) { + return functions->GetLongArrayElements(this,array,isCopy); + } + jfloat * GetFloatArrayElements(jfloatArray array, jboolean *isCopy) { + return functions->GetFloatArrayElements(this,array,isCopy); + } + jdouble * GetDoubleArrayElements(jdoubleArray array, jboolean *isCopy) { + return functions->GetDoubleArrayElements(this,array,isCopy); + } + + void ReleaseBooleanArrayElements(jbooleanArray array, + jboolean *elems, + jint mode) { + functions->ReleaseBooleanArrayElements(this,array,elems,mode); + } + void ReleaseByteArrayElements(jbyteArray array, + jbyte *elems, + jint mode) { + functions->ReleaseByteArrayElements(this,array,elems,mode); + } + void ReleaseCharArrayElements(jcharArray array, + jchar *elems, + jint mode) { + functions->ReleaseCharArrayElements(this,array,elems,mode); + } + void ReleaseShortArrayElements(jshortArray array, + jshort *elems, + jint mode) { + functions->ReleaseShortArrayElements(this,array,elems,mode); + } + void ReleaseIntArrayElements(jintArray array, + jint *elems, + jint mode) { + functions->ReleaseIntArrayElements(this,array,elems,mode); + } + void ReleaseLongArrayElements(jlongArray array, + jlong *elems, + jint mode) { + functions->ReleaseLongArrayElements(this,array,elems,mode); + } + void ReleaseFloatArrayElements(jfloatArray array, + jfloat *elems, + jint mode) { + functions->ReleaseFloatArrayElements(this,array,elems,mode); + } + void ReleaseDoubleArrayElements(jdoubleArray array, + jdouble *elems, + jint mode) { + functions->ReleaseDoubleArrayElements(this,array,elems,mode); + } + + void GetBooleanArrayRegion(jbooleanArray array, + jsize start, jsize len, jboolean *buf) { + functions->GetBooleanArrayRegion(this,array,start,len,buf); + } + void GetByteArrayRegion(jbyteArray array, + jsize start, jsize len, jbyte *buf) { + functions->GetByteArrayRegion(this,array,start,len,buf); + } + void GetCharArrayRegion(jcharArray array, + jsize start, jsize len, jchar *buf) { + functions->GetCharArrayRegion(this,array,start,len,buf); + } + void GetShortArrayRegion(jshortArray array, + jsize start, jsize len, jshort *buf) { + functions->GetShortArrayRegion(this,array,start,len,buf); + } + void GetIntArrayRegion(jintArray array, + jsize start, jsize len, jint *buf) { + functions->GetIntArrayRegion(this,array,start,len,buf); + } + void GetLongArrayRegion(jlongArray array, + jsize start, jsize len, jlong *buf) { + functions->GetLongArrayRegion(this,array,start,len,buf); + } + void GetFloatArrayRegion(jfloatArray array, + jsize start, jsize len, jfloat *buf) { + functions->GetFloatArrayRegion(this,array,start,len,buf); + } + void GetDoubleArrayRegion(jdoubleArray array, + jsize start, jsize len, jdouble *buf) { + functions->GetDoubleArrayRegion(this,array,start,len,buf); + } + + void SetBooleanArrayRegion(jbooleanArray array, jsize start, jsize len, + const jboolean *buf) { + functions->SetBooleanArrayRegion(this,array,start,len,buf); + } + void SetByteArrayRegion(jbyteArray array, jsize start, jsize len, + const jbyte *buf) { + functions->SetByteArrayRegion(this,array,start,len,buf); + } + void SetCharArrayRegion(jcharArray array, jsize start, jsize len, + const jchar *buf) { + functions->SetCharArrayRegion(this,array,start,len,buf); + } + void SetShortArrayRegion(jshortArray array, jsize start, jsize len, + const jshort *buf) { + functions->SetShortArrayRegion(this,array,start,len,buf); + } + void SetIntArrayRegion(jintArray array, jsize start, jsize len, + const jint *buf) { + functions->SetIntArrayRegion(this,array,start,len,buf); + } + void SetLongArrayRegion(jlongArray array, jsize start, jsize len, + const jlong *buf) { + functions->SetLongArrayRegion(this,array,start,len,buf); + } + void SetFloatArrayRegion(jfloatArray array, jsize start, jsize len, + const jfloat *buf) { + functions->SetFloatArrayRegion(this,array,start,len,buf); + } + void SetDoubleArrayRegion(jdoubleArray array, jsize start, jsize len, + const jdouble *buf) { + functions->SetDoubleArrayRegion(this,array,start,len,buf); + } + + jint RegisterNatives(jclass clazz, const JNINativeMethod *methods, + jint nMethods) { + return functions->RegisterNatives(this,clazz,methods,nMethods); + } + jint UnregisterNatives(jclass clazz) { + return functions->UnregisterNatives(this,clazz); + } + + jint MonitorEnter(jobject obj) { + return functions->MonitorEnter(this,obj); + } + jint MonitorExit(jobject obj) { + return functions->MonitorExit(this,obj); + } + + jint GetJavaVM(JavaVM **vm) { + return functions->GetJavaVM(this,vm); + } + + void GetStringRegion(jstring str, jsize start, jsize len, jchar *buf) { + functions->GetStringRegion(this,str,start,len,buf); + } + void GetStringUTFRegion(jstring str, jsize start, jsize len, char *buf) { + functions->GetStringUTFRegion(this,str,start,len,buf); + } + + void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) { + return functions->GetPrimitiveArrayCritical(this,array,isCopy); + } + void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) { + functions->ReleasePrimitiveArrayCritical(this,array,carray,mode); + } + + const jchar * GetStringCritical(jstring string, jboolean *isCopy) { + return functions->GetStringCritical(this,string,isCopy); + } + void ReleaseStringCritical(jstring string, const jchar *cstring) { + functions->ReleaseStringCritical(this,string,cstring); + } + + jweak NewWeakGlobalRef(jobject obj) { + return functions->NewWeakGlobalRef(this,obj); + } + void DeleteWeakGlobalRef(jweak ref) { + functions->DeleteWeakGlobalRef(this,ref); + } + + jboolean ExceptionCheck() { + return functions->ExceptionCheck(this); + } + + jobject NewDirectByteBuffer(void* address, jlong capacity) { + return functions->NewDirectByteBuffer(this, address, capacity); + } + void* GetDirectBufferAddress(jobject buf) { + return functions->GetDirectBufferAddress(this, buf); + } + jlong GetDirectBufferCapacity(jobject buf) { + return functions->GetDirectBufferCapacity(this, buf); + } + jobjectRefType GetObjectRefType(jobject obj) { + return functions->GetObjectRefType(this, obj); + } + +#endif /* __cplusplus */ +}; + +typedef struct JavaVMOption { + char *optionString; + void *extraInfo; +} JavaVMOption; + +typedef struct JavaVMInitArgs { + jint version; + + jint nOptions; + JavaVMOption *options; + jboolean ignoreUnrecognized; +} JavaVMInitArgs; + +typedef struct JavaVMAttachArgs { + jint version; + + char *name; + jobject group; +} JavaVMAttachArgs; + +/* These will be VM-specific. */ + +#define JDK1_2 +#define JDK1_4 + +/* End VM-specific. */ + +struct JNIInvokeInterface_ { + void *reserved0; + void *reserved1; + void *reserved2; + + jint (JNICALL *DestroyJavaVM)(JavaVM *vm); + + jint (JNICALL *AttachCurrentThread)(JavaVM *vm, void **penv, void *args); + + jint (JNICALL *DetachCurrentThread)(JavaVM *vm); + + jint (JNICALL *GetEnv)(JavaVM *vm, void **penv, jint version); + + jint (JNICALL *AttachCurrentThreadAsDaemon)(JavaVM *vm, void **penv, void *args); +}; + +struct JavaVM_ { + const struct JNIInvokeInterface_ *functions; +#ifdef __cplusplus + + jint DestroyJavaVM() { + return functions->DestroyJavaVM(this); + } + jint AttachCurrentThread(void **penv, void *args) { + return functions->AttachCurrentThread(this, penv, args); + } + jint DetachCurrentThread() { + return functions->DetachCurrentThread(this); + } + + jint GetEnv(void **penv, jint version) { + return functions->GetEnv(this, penv, version); + } + jint AttachCurrentThreadAsDaemon(void **penv, void *args) { + return functions->AttachCurrentThreadAsDaemon(this, penv, args); + } +#endif +}; + +#ifdef _JNI_IMPLEMENTATION_ +#define _JNI_IMPORT_OR_EXPORT_ JNIEXPORT +#else +#define _JNI_IMPORT_OR_EXPORT_ JNIIMPORT +#endif +_JNI_IMPORT_OR_EXPORT_ jint JNICALL +JNI_GetDefaultJavaVMInitArgs(void *args); + +_JNI_IMPORT_OR_EXPORT_ jint JNICALL +JNI_CreateJavaVM(JavaVM **pvm, void **penv, void *args); + +_JNI_IMPORT_OR_EXPORT_ jint JNICALL +JNI_GetCreatedJavaVMs(JavaVM **, jsize, jsize *); + +/* Defined by native libraries. */ +JNIEXPORT jint JNICALL +JNI_OnLoad(JavaVM *vm, void *reserved); + +JNIEXPORT void JNICALL +JNI_OnUnload(JavaVM *vm, void *reserved); + +#define JNI_VERSION_1_1 0x00010001 +#define JNI_VERSION_1_2 0x00010002 +#define JNI_VERSION_1_4 0x00010004 +#define JNI_VERSION_1_6 0x00010006 + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !_JAVASOFT_JNI_H_ */ + + + diff --git a/vendor/jdk/1.6.0_23/include/jvmti.h b/vendor/jdk/1.6.0_23/include/jvmti.h new file mode 100644 index 0000000..865f21e --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/jvmti.h @@ -0,0 +1,2504 @@ +#ifdef USE_PRAGMA_IDENT_HDR +#pragma ident "@(#)jvmtiLib.xsl 1.38 06/08/02 23:22:31 JVM" +#endif +/* + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + + /* AUTOMATICALLY GENERATED FILE - DO NOT EDIT */ + + + /* Include file for the Java(tm) Virtual Machine Tool Interface */ + +#ifndef _JAVA_JVMTI_H_ +#define _JAVA_JVMTI_H_ + +#include "jni.h" + +#ifdef __cplusplus +extern "C" { +#endif + +enum { + JVMTI_VERSION_1 = 0x30010000, + JVMTI_VERSION_1_0 = 0x30010000, + JVMTI_VERSION_1_1 = 0x30010100, + + JVMTI_VERSION = 0x30000000 + (1 * 0x10000) + (1 * 0x100) + 102 /* version: 1.1.102 */ +}; + +JNIEXPORT jint JNICALL +Agent_OnLoad(JavaVM *vm, char *options, void *reserved); + +JNIEXPORT jint JNICALL +Agent_OnAttach(JavaVM* vm, char* options, void* reserved); + +JNIEXPORT void JNICALL +Agent_OnUnload(JavaVM *vm); + + /* Forward declaration of the environment */ + +struct _jvmtiEnv; + +struct jvmtiInterface_1_; + +#ifdef __cplusplus +typedef _jvmtiEnv jvmtiEnv; +#else +typedef const struct jvmtiInterface_1_ *jvmtiEnv; +#endif /* __cplusplus */ + +/* Derived Base Types */ + +typedef jobject jthread; +typedef jobject jthreadGroup; +typedef jlong jlocation; +struct _jrawMonitorID; +typedef struct _jrawMonitorID *jrawMonitorID; +typedef struct JNINativeInterface_ jniNativeInterface; + + /* Constants */ + + + /* Thread State Flags */ + +enum { + JVMTI_THREAD_STATE_ALIVE = 0x0001, + JVMTI_THREAD_STATE_TERMINATED = 0x0002, + JVMTI_THREAD_STATE_RUNNABLE = 0x0004, + JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER = 0x0400, + JVMTI_THREAD_STATE_WAITING = 0x0080, + JVMTI_THREAD_STATE_WAITING_INDEFINITELY = 0x0010, + JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT = 0x0020, + JVMTI_THREAD_STATE_SLEEPING = 0x0040, + JVMTI_THREAD_STATE_IN_OBJECT_WAIT = 0x0100, + JVMTI_THREAD_STATE_PARKED = 0x0200, + JVMTI_THREAD_STATE_SUSPENDED = 0x100000, + JVMTI_THREAD_STATE_INTERRUPTED = 0x200000, + JVMTI_THREAD_STATE_IN_NATIVE = 0x400000, + JVMTI_THREAD_STATE_VENDOR_1 = 0x10000000, + JVMTI_THREAD_STATE_VENDOR_2 = 0x20000000, + JVMTI_THREAD_STATE_VENDOR_3 = 0x40000000 +}; + + /* java.lang.Thread.State Conversion Masks */ + +enum { + JVMTI_JAVA_LANG_THREAD_STATE_MASK = JVMTI_THREAD_STATE_TERMINATED | JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT, + JVMTI_JAVA_LANG_THREAD_STATE_NEW = 0, + JVMTI_JAVA_LANG_THREAD_STATE_TERMINATED = JVMTI_THREAD_STATE_TERMINATED, + JVMTI_JAVA_LANG_THREAD_STATE_RUNNABLE = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_RUNNABLE, + JVMTI_JAVA_LANG_THREAD_STATE_BLOCKED = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER, + JVMTI_JAVA_LANG_THREAD_STATE_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_INDEFINITELY, + JVMTI_JAVA_LANG_THREAD_STATE_TIMED_WAITING = JVMTI_THREAD_STATE_ALIVE | JVMTI_THREAD_STATE_WAITING | JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT +}; + + /* Thread Priority Constants */ + +enum { + JVMTI_THREAD_MIN_PRIORITY = 1, + JVMTI_THREAD_NORM_PRIORITY = 5, + JVMTI_THREAD_MAX_PRIORITY = 10 +}; + + /* Heap Filter Flags */ + +enum { + JVMTI_HEAP_FILTER_TAGGED = 0x4, + JVMTI_HEAP_FILTER_UNTAGGED = 0x8, + JVMTI_HEAP_FILTER_CLASS_TAGGED = 0x10, + JVMTI_HEAP_FILTER_CLASS_UNTAGGED = 0x20 +}; + + /* Heap Visit Control Flags */ + +enum { + JVMTI_VISIT_OBJECTS = 0x100, + JVMTI_VISIT_ABORT = 0x8000 +}; + + /* Heap Reference Enumeration */ + +typedef enum { + JVMTI_HEAP_REFERENCE_CLASS = 1, + JVMTI_HEAP_REFERENCE_FIELD = 2, + JVMTI_HEAP_REFERENCE_ARRAY_ELEMENT = 3, + JVMTI_HEAP_REFERENCE_CLASS_LOADER = 4, + JVMTI_HEAP_REFERENCE_SIGNERS = 5, + JVMTI_HEAP_REFERENCE_PROTECTION_DOMAIN = 6, + JVMTI_HEAP_REFERENCE_INTERFACE = 7, + JVMTI_HEAP_REFERENCE_STATIC_FIELD = 8, + JVMTI_HEAP_REFERENCE_CONSTANT_POOL = 9, + JVMTI_HEAP_REFERENCE_SUPERCLASS = 10, + JVMTI_HEAP_REFERENCE_JNI_GLOBAL = 21, + JVMTI_HEAP_REFERENCE_SYSTEM_CLASS = 22, + JVMTI_HEAP_REFERENCE_MONITOR = 23, + JVMTI_HEAP_REFERENCE_STACK_LOCAL = 24, + JVMTI_HEAP_REFERENCE_JNI_LOCAL = 25, + JVMTI_HEAP_REFERENCE_THREAD = 26, + JVMTI_HEAP_REFERENCE_OTHER = 27 +} jvmtiHeapReferenceKind; + + /* Primitive Type Enumeration */ + +typedef enum { + JVMTI_PRIMITIVE_TYPE_BOOLEAN = 90, + JVMTI_PRIMITIVE_TYPE_BYTE = 66, + JVMTI_PRIMITIVE_TYPE_CHAR = 67, + JVMTI_PRIMITIVE_TYPE_SHORT = 83, + JVMTI_PRIMITIVE_TYPE_INT = 73, + JVMTI_PRIMITIVE_TYPE_LONG = 74, + JVMTI_PRIMITIVE_TYPE_FLOAT = 70, + JVMTI_PRIMITIVE_TYPE_DOUBLE = 68 +} jvmtiPrimitiveType; + + /* Heap Object Filter Enumeration */ + +typedef enum { + JVMTI_HEAP_OBJECT_TAGGED = 1, + JVMTI_HEAP_OBJECT_UNTAGGED = 2, + JVMTI_HEAP_OBJECT_EITHER = 3 +} jvmtiHeapObjectFilter; + + /* Heap Root Kind Enumeration */ + +typedef enum { + JVMTI_HEAP_ROOT_JNI_GLOBAL = 1, + JVMTI_HEAP_ROOT_SYSTEM_CLASS = 2, + JVMTI_HEAP_ROOT_MONITOR = 3, + JVMTI_HEAP_ROOT_STACK_LOCAL = 4, + JVMTI_HEAP_ROOT_JNI_LOCAL = 5, + JVMTI_HEAP_ROOT_THREAD = 6, + JVMTI_HEAP_ROOT_OTHER = 7 +} jvmtiHeapRootKind; + + /* Object Reference Enumeration */ + +typedef enum { + JVMTI_REFERENCE_CLASS = 1, + JVMTI_REFERENCE_FIELD = 2, + JVMTI_REFERENCE_ARRAY_ELEMENT = 3, + JVMTI_REFERENCE_CLASS_LOADER = 4, + JVMTI_REFERENCE_SIGNERS = 5, + JVMTI_REFERENCE_PROTECTION_DOMAIN = 6, + JVMTI_REFERENCE_INTERFACE = 7, + JVMTI_REFERENCE_STATIC_FIELD = 8, + JVMTI_REFERENCE_CONSTANT_POOL = 9 +} jvmtiObjectReferenceKind; + + /* Iteration Control Enumeration */ + +typedef enum { + JVMTI_ITERATION_CONTINUE = 1, + JVMTI_ITERATION_IGNORE = 2, + JVMTI_ITERATION_ABORT = 0 +} jvmtiIterationControl; + + /* Class Status Flags */ + +enum { + JVMTI_CLASS_STATUS_VERIFIED = 1, + JVMTI_CLASS_STATUS_PREPARED = 2, + JVMTI_CLASS_STATUS_INITIALIZED = 4, + JVMTI_CLASS_STATUS_ERROR = 8, + JVMTI_CLASS_STATUS_ARRAY = 16, + JVMTI_CLASS_STATUS_PRIMITIVE = 32 +}; + + /* Event Enable/Disable */ + +typedef enum { + JVMTI_ENABLE = 1, + JVMTI_DISABLE = 0 +} jvmtiEventMode; + + /* Extension Function/Event Parameter Types */ + +typedef enum { + JVMTI_TYPE_JBYTE = 101, + JVMTI_TYPE_JCHAR = 102, + JVMTI_TYPE_JSHORT = 103, + JVMTI_TYPE_JINT = 104, + JVMTI_TYPE_JLONG = 105, + JVMTI_TYPE_JFLOAT = 106, + JVMTI_TYPE_JDOUBLE = 107, + JVMTI_TYPE_JBOOLEAN = 108, + JVMTI_TYPE_JOBJECT = 109, + JVMTI_TYPE_JTHREAD = 110, + JVMTI_TYPE_JCLASS = 111, + JVMTI_TYPE_JVALUE = 112, + JVMTI_TYPE_JFIELDID = 113, + JVMTI_TYPE_JMETHODID = 114, + JVMTI_TYPE_CCHAR = 115, + JVMTI_TYPE_CVOID = 116, + JVMTI_TYPE_JNIENV = 117 +} jvmtiParamTypes; + + /* Extension Function/Event Parameter Kinds */ + +typedef enum { + JVMTI_KIND_IN = 91, + JVMTI_KIND_IN_PTR = 92, + JVMTI_KIND_IN_BUF = 93, + JVMTI_KIND_ALLOC_BUF = 94, + JVMTI_KIND_ALLOC_ALLOC_BUF = 95, + JVMTI_KIND_OUT = 96, + JVMTI_KIND_OUT_BUF = 97 +} jvmtiParamKind; + + /* Timer Kinds */ + +typedef enum { + JVMTI_TIMER_USER_CPU = 30, + JVMTI_TIMER_TOTAL_CPU = 31, + JVMTI_TIMER_ELAPSED = 32 +} jvmtiTimerKind; + + /* Phases of execution */ + +typedef enum { + JVMTI_PHASE_ONLOAD = 1, + JVMTI_PHASE_PRIMORDIAL = 2, + JVMTI_PHASE_START = 6, + JVMTI_PHASE_LIVE = 4, + JVMTI_PHASE_DEAD = 8 +} jvmtiPhase; + + /* Version Interface Types */ + +enum { + JVMTI_VERSION_INTERFACE_JNI = 0x00000000, + JVMTI_VERSION_INTERFACE_JVMTI = 0x30000000 +}; + + /* Version Masks */ + +enum { + JVMTI_VERSION_MASK_INTERFACE_TYPE = 0x70000000, + JVMTI_VERSION_MASK_MAJOR = 0x0FFF0000, + JVMTI_VERSION_MASK_MINOR = 0x0000FF00, + JVMTI_VERSION_MASK_MICRO = 0x000000FF +}; + + /* Version Shifts */ + +enum { + JVMTI_VERSION_SHIFT_MAJOR = 16, + JVMTI_VERSION_SHIFT_MINOR = 8, + JVMTI_VERSION_SHIFT_MICRO = 0 +}; + + /* Verbose Flag Enumeration */ + +typedef enum { + JVMTI_VERBOSE_OTHER = 0, + JVMTI_VERBOSE_GC = 1, + JVMTI_VERBOSE_CLASS = 2, + JVMTI_VERBOSE_JNI = 4 +} jvmtiVerboseFlag; + + /* JLocation Format Enumeration */ + +typedef enum { + JVMTI_JLOCATION_JVMBCI = 1, + JVMTI_JLOCATION_MACHINEPC = 2, + JVMTI_JLOCATION_OTHER = 0 +} jvmtiJlocationFormat; + + /* Resource Exhaustion Flags */ + +enum { + JVMTI_RESOURCE_EXHAUSTED_OOM_ERROR = 0x0001, + JVMTI_RESOURCE_EXHAUSTED_JAVA_HEAP = 0x0002, + JVMTI_RESOURCE_EXHAUSTED_THREADS = 0x0004 +}; + + /* Errors */ + +typedef enum { + JVMTI_ERROR_NONE = 0, + JVMTI_ERROR_INVALID_THREAD = 10, + JVMTI_ERROR_INVALID_THREAD_GROUP = 11, + JVMTI_ERROR_INVALID_PRIORITY = 12, + JVMTI_ERROR_THREAD_NOT_SUSPENDED = 13, + JVMTI_ERROR_THREAD_SUSPENDED = 14, + JVMTI_ERROR_THREAD_NOT_ALIVE = 15, + JVMTI_ERROR_INVALID_OBJECT = 20, + JVMTI_ERROR_INVALID_CLASS = 21, + JVMTI_ERROR_CLASS_NOT_PREPARED = 22, + JVMTI_ERROR_INVALID_METHODID = 23, + JVMTI_ERROR_INVALID_LOCATION = 24, + JVMTI_ERROR_INVALID_FIELDID = 25, + JVMTI_ERROR_NO_MORE_FRAMES = 31, + JVMTI_ERROR_OPAQUE_FRAME = 32, + JVMTI_ERROR_TYPE_MISMATCH = 34, + JVMTI_ERROR_INVALID_SLOT = 35, + JVMTI_ERROR_DUPLICATE = 40, + JVMTI_ERROR_NOT_FOUND = 41, + JVMTI_ERROR_INVALID_MONITOR = 50, + JVMTI_ERROR_NOT_MONITOR_OWNER = 51, + JVMTI_ERROR_INTERRUPT = 52, + JVMTI_ERROR_INVALID_CLASS_FORMAT = 60, + JVMTI_ERROR_CIRCULAR_CLASS_DEFINITION = 61, + JVMTI_ERROR_FAILS_VERIFICATION = 62, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_ADDED = 63, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_SCHEMA_CHANGED = 64, + JVMTI_ERROR_INVALID_TYPESTATE = 65, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_HIERARCHY_CHANGED = 66, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED = 67, + JVMTI_ERROR_UNSUPPORTED_VERSION = 68, + JVMTI_ERROR_NAMES_DONT_MATCH = 69, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_CLASS_MODIFIERS_CHANGED = 70, + JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_MODIFIERS_CHANGED = 71, + JVMTI_ERROR_UNMODIFIABLE_CLASS = 79, + JVMTI_ERROR_NOT_AVAILABLE = 98, + JVMTI_ERROR_MUST_POSSESS_CAPABILITY = 99, + JVMTI_ERROR_NULL_POINTER = 100, + JVMTI_ERROR_ABSENT_INFORMATION = 101, + JVMTI_ERROR_INVALID_EVENT_TYPE = 102, + JVMTI_ERROR_ILLEGAL_ARGUMENT = 103, + JVMTI_ERROR_NATIVE_METHOD = 104, + JVMTI_ERROR_CLASS_LOADER_UNSUPPORTED = 106, + JVMTI_ERROR_OUT_OF_MEMORY = 110, + JVMTI_ERROR_ACCESS_DENIED = 111, + JVMTI_ERROR_WRONG_PHASE = 112, + JVMTI_ERROR_INTERNAL = 113, + JVMTI_ERROR_UNATTACHED_THREAD = 115, + JVMTI_ERROR_INVALID_ENVIRONMENT = 116, + JVMTI_ERROR_MAX = 116 +} jvmtiError; + + /* Event IDs */ + +typedef enum { + JVMTI_MIN_EVENT_TYPE_VAL = 50, + JVMTI_EVENT_VM_INIT = 50, + JVMTI_EVENT_VM_DEATH = 51, + JVMTI_EVENT_THREAD_START = 52, + JVMTI_EVENT_THREAD_END = 53, + JVMTI_EVENT_CLASS_FILE_LOAD_HOOK = 54, + JVMTI_EVENT_CLASS_LOAD = 55, + JVMTI_EVENT_CLASS_PREPARE = 56, + JVMTI_EVENT_VM_START = 57, + JVMTI_EVENT_EXCEPTION = 58, + JVMTI_EVENT_EXCEPTION_CATCH = 59, + JVMTI_EVENT_SINGLE_STEP = 60, + JVMTI_EVENT_FRAME_POP = 61, + JVMTI_EVENT_BREAKPOINT = 62, + JVMTI_EVENT_FIELD_ACCESS = 63, + JVMTI_EVENT_FIELD_MODIFICATION = 64, + JVMTI_EVENT_METHOD_ENTRY = 65, + JVMTI_EVENT_METHOD_EXIT = 66, + JVMTI_EVENT_NATIVE_METHOD_BIND = 67, + JVMTI_EVENT_COMPILED_METHOD_LOAD = 68, + JVMTI_EVENT_COMPILED_METHOD_UNLOAD = 69, + JVMTI_EVENT_DYNAMIC_CODE_GENERATED = 70, + JVMTI_EVENT_DATA_DUMP_REQUEST = 71, + JVMTI_EVENT_MONITOR_WAIT = 73, + JVMTI_EVENT_MONITOR_WAITED = 74, + JVMTI_EVENT_MONITOR_CONTENDED_ENTER = 75, + JVMTI_EVENT_MONITOR_CONTENDED_ENTERED = 76, + JVMTI_EVENT_RESOURCE_EXHAUSTED = 80, + JVMTI_EVENT_GARBAGE_COLLECTION_START = 81, + JVMTI_EVENT_GARBAGE_COLLECTION_FINISH = 82, + JVMTI_EVENT_OBJECT_FREE = 83, + JVMTI_EVENT_VM_OBJECT_ALLOC = 84, + JVMTI_MAX_EVENT_TYPE_VAL = 84 +} jvmtiEvent; + + + /* Pre-Declarations */ +struct _jvmtiThreadInfo; +typedef struct _jvmtiThreadInfo jvmtiThreadInfo; +struct _jvmtiMonitorStackDepthInfo; +typedef struct _jvmtiMonitorStackDepthInfo jvmtiMonitorStackDepthInfo; +struct _jvmtiThreadGroupInfo; +typedef struct _jvmtiThreadGroupInfo jvmtiThreadGroupInfo; +struct _jvmtiFrameInfo; +typedef struct _jvmtiFrameInfo jvmtiFrameInfo; +struct _jvmtiStackInfo; +typedef struct _jvmtiStackInfo jvmtiStackInfo; +struct _jvmtiHeapReferenceInfoField; +typedef struct _jvmtiHeapReferenceInfoField jvmtiHeapReferenceInfoField; +struct _jvmtiHeapReferenceInfoArray; +typedef struct _jvmtiHeapReferenceInfoArray jvmtiHeapReferenceInfoArray; +struct _jvmtiHeapReferenceInfoConstantPool; +typedef struct _jvmtiHeapReferenceInfoConstantPool jvmtiHeapReferenceInfoConstantPool; +struct _jvmtiHeapReferenceInfoStackLocal; +typedef struct _jvmtiHeapReferenceInfoStackLocal jvmtiHeapReferenceInfoStackLocal; +struct _jvmtiHeapReferenceInfoJniLocal; +typedef struct _jvmtiHeapReferenceInfoJniLocal jvmtiHeapReferenceInfoJniLocal; +struct _jvmtiHeapReferenceInfoReserved; +typedef struct _jvmtiHeapReferenceInfoReserved jvmtiHeapReferenceInfoReserved; +union _jvmtiHeapReferenceInfo; +typedef union _jvmtiHeapReferenceInfo jvmtiHeapReferenceInfo; +struct _jvmtiHeapCallbacks; +typedef struct _jvmtiHeapCallbacks jvmtiHeapCallbacks; +struct _jvmtiClassDefinition; +typedef struct _jvmtiClassDefinition jvmtiClassDefinition; +struct _jvmtiMonitorUsage; +typedef struct _jvmtiMonitorUsage jvmtiMonitorUsage; +struct _jvmtiLineNumberEntry; +typedef struct _jvmtiLineNumberEntry jvmtiLineNumberEntry; +struct _jvmtiLocalVariableEntry; +typedef struct _jvmtiLocalVariableEntry jvmtiLocalVariableEntry; +struct _jvmtiParamInfo; +typedef struct _jvmtiParamInfo jvmtiParamInfo; +struct _jvmtiExtensionFunctionInfo; +typedef struct _jvmtiExtensionFunctionInfo jvmtiExtensionFunctionInfo; +struct _jvmtiExtensionEventInfo; +typedef struct _jvmtiExtensionEventInfo jvmtiExtensionEventInfo; +struct _jvmtiTimerInfo; +typedef struct _jvmtiTimerInfo jvmtiTimerInfo; +struct _jvmtiAddrLocationMap; +typedef struct _jvmtiAddrLocationMap jvmtiAddrLocationMap; + + /* Function Types */ + +typedef void (JNICALL *jvmtiStartFunction) + (jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg); + +typedef jint (JNICALL *jvmtiHeapIterationCallback) + (jlong class_tag, jlong size, jlong* tag_ptr, jint length, void* user_data); + +typedef jint (JNICALL *jvmtiHeapReferenceCallback) + (jvmtiHeapReferenceKind reference_kind, const jvmtiHeapReferenceInfo* reference_info, jlong class_tag, jlong referrer_class_tag, jlong size, jlong* tag_ptr, jlong* referrer_tag_ptr, jint length, void* user_data); + +typedef jint (JNICALL *jvmtiPrimitiveFieldCallback) + (jvmtiHeapReferenceKind kind, const jvmtiHeapReferenceInfo* info, jlong object_class_tag, jlong* object_tag_ptr, jvalue value, jvmtiPrimitiveType value_type, void* user_data); + +typedef jint (JNICALL *jvmtiArrayPrimitiveValueCallback) + (jlong class_tag, jlong size, jlong* tag_ptr, jint element_count, jvmtiPrimitiveType element_type, const void* elements, void* user_data); + +typedef jint (JNICALL *jvmtiStringPrimitiveValueCallback) + (jlong class_tag, jlong size, jlong* tag_ptr, const jchar* value, jint value_length, void* user_data); + +typedef jint (JNICALL *jvmtiReservedCallback) + (); + +typedef jvmtiIterationControl (JNICALL *jvmtiHeapObjectCallback) + (jlong class_tag, jlong size, jlong* tag_ptr, void* user_data); + +typedef jvmtiIterationControl (JNICALL *jvmtiHeapRootCallback) + (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, void* user_data); + +typedef jvmtiIterationControl (JNICALL *jvmtiStackReferenceCallback) + (jvmtiHeapRootKind root_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong thread_tag, jint depth, jmethodID method, jint slot, void* user_data); + +typedef jvmtiIterationControl (JNICALL *jvmtiObjectReferenceCallback) + (jvmtiObjectReferenceKind reference_kind, jlong class_tag, jlong size, jlong* tag_ptr, jlong referrer_tag, jint referrer_index, void* user_data); + +typedef jvmtiError (JNICALL *jvmtiExtensionFunction) + (jvmtiEnv* jvmti_env, ...); + +typedef void (JNICALL *jvmtiExtensionEvent) + (jvmtiEnv* jvmti_env, ...); + + + /* Structure Types */ +struct _jvmtiThreadInfo { + char* name; + jint priority; + jboolean is_daemon; + jthreadGroup thread_group; + jobject context_class_loader; +}; +struct _jvmtiMonitorStackDepthInfo { + jobject monitor; + jint stack_depth; +}; +struct _jvmtiThreadGroupInfo { + jthreadGroup parent; + char* name; + jint max_priority; + jboolean is_daemon; +}; +struct _jvmtiFrameInfo { + jmethodID method; + jlocation location; +}; +struct _jvmtiStackInfo { + jthread thread; + jint state; + jvmtiFrameInfo* frame_buffer; + jint frame_count; +}; +struct _jvmtiHeapReferenceInfoField { + jint index; +}; +struct _jvmtiHeapReferenceInfoArray { + jint index; +}; +struct _jvmtiHeapReferenceInfoConstantPool { + jint index; +}; +struct _jvmtiHeapReferenceInfoStackLocal { + jlong thread_tag; + jlong thread_id; + jint depth; + jmethodID method; + jlocation location; + jint slot; +}; +struct _jvmtiHeapReferenceInfoJniLocal { + jlong thread_tag; + jlong thread_id; + jint depth; + jmethodID method; +}; +struct _jvmtiHeapReferenceInfoReserved { + jlong reserved1; + jlong reserved2; + jlong reserved3; + jlong reserved4; + jlong reserved5; + jlong reserved6; + jlong reserved7; + jlong reserved8; +}; +union _jvmtiHeapReferenceInfo { + jvmtiHeapReferenceInfoField field; + jvmtiHeapReferenceInfoArray array; + jvmtiHeapReferenceInfoConstantPool constant_pool; + jvmtiHeapReferenceInfoStackLocal stack_local; + jvmtiHeapReferenceInfoJniLocal jni_local; + jvmtiHeapReferenceInfoReserved other; +}; +struct _jvmtiHeapCallbacks { + jvmtiHeapIterationCallback heap_iteration_callback; + jvmtiHeapReferenceCallback heap_reference_callback; + jvmtiPrimitiveFieldCallback primitive_field_callback; + jvmtiArrayPrimitiveValueCallback array_primitive_value_callback; + jvmtiStringPrimitiveValueCallback string_primitive_value_callback; + jvmtiReservedCallback reserved5; + jvmtiReservedCallback reserved6; + jvmtiReservedCallback reserved7; + jvmtiReservedCallback reserved8; + jvmtiReservedCallback reserved9; + jvmtiReservedCallback reserved10; + jvmtiReservedCallback reserved11; + jvmtiReservedCallback reserved12; + jvmtiReservedCallback reserved13; + jvmtiReservedCallback reserved14; + jvmtiReservedCallback reserved15; +}; +struct _jvmtiClassDefinition { + jclass klass; + jint class_byte_count; + const unsigned char* class_bytes; +}; +struct _jvmtiMonitorUsage { + jthread owner; + jint entry_count; + jint waiter_count; + jthread* waiters; + jint notify_waiter_count; + jthread* notify_waiters; +}; +struct _jvmtiLineNumberEntry { + jlocation start_location; + jint line_number; +}; +struct _jvmtiLocalVariableEntry { + jlocation start_location; + jint length; + char* name; + char* signature; + char* generic_signature; + jint slot; +}; +struct _jvmtiParamInfo { + char* name; + jvmtiParamKind kind; + jvmtiParamTypes base_type; + jboolean null_ok; +}; +struct _jvmtiExtensionFunctionInfo { + jvmtiExtensionFunction func; + char* id; + char* short_description; + jint param_count; + jvmtiParamInfo* params; + jint error_count; + jvmtiError* errors; +}; +struct _jvmtiExtensionEventInfo { + jint extension_event_index; + char* id; + char* short_description; + jint param_count; + jvmtiParamInfo* params; +}; +struct _jvmtiTimerInfo { + jlong max_value; + jboolean may_skip_forward; + jboolean may_skip_backward; + jvmtiTimerKind kind; + jlong reserved1; + jlong reserved2; +}; +struct _jvmtiAddrLocationMap { + const void* start_address; + jlocation location; +}; + +typedef struct { + unsigned int can_tag_objects : 1; + unsigned int can_generate_field_modification_events : 1; + unsigned int can_generate_field_access_events : 1; + unsigned int can_get_bytecodes : 1; + unsigned int can_get_synthetic_attribute : 1; + unsigned int can_get_owned_monitor_info : 1; + unsigned int can_get_current_contended_monitor : 1; + unsigned int can_get_monitor_info : 1; + unsigned int can_pop_frame : 1; + unsigned int can_redefine_classes : 1; + unsigned int can_signal_thread : 1; + unsigned int can_get_source_file_name : 1; + unsigned int can_get_line_numbers : 1; + unsigned int can_get_source_debug_extension : 1; + unsigned int can_access_local_variables : 1; + unsigned int can_maintain_original_method_order : 1; + unsigned int can_generate_single_step_events : 1; + unsigned int can_generate_exception_events : 1; + unsigned int can_generate_frame_pop_events : 1; + unsigned int can_generate_breakpoint_events : 1; + unsigned int can_suspend : 1; + unsigned int can_redefine_any_class : 1; + unsigned int can_get_current_thread_cpu_time : 1; + unsigned int can_get_thread_cpu_time : 1; + unsigned int can_generate_method_entry_events : 1; + unsigned int can_generate_method_exit_events : 1; + unsigned int can_generate_all_class_hook_events : 1; + unsigned int can_generate_compiled_method_load_events : 1; + unsigned int can_generate_monitor_events : 1; + unsigned int can_generate_vm_object_alloc_events : 1; + unsigned int can_generate_native_method_bind_events : 1; + unsigned int can_generate_garbage_collection_events : 1; + unsigned int can_generate_object_free_events : 1; + unsigned int can_force_early_return : 1; + unsigned int can_get_owned_monitor_stack_depth_info : 1; + unsigned int can_get_constant_pool : 1; + unsigned int can_set_native_method_prefix : 1; + unsigned int can_retransform_classes : 1; + unsigned int can_retransform_any_class : 1; + unsigned int can_generate_resource_exhaustion_heap_events : 1; + unsigned int can_generate_resource_exhaustion_threads_events : 1; + unsigned int : 7; + unsigned int : 16; + unsigned int : 16; + unsigned int : 16; + unsigned int : 16; + unsigned int : 16; +} jvmtiCapabilities; + + + /* Event Definitions */ + +typedef void (JNICALL *jvmtiEventReserved)(void); + + +typedef void (JNICALL *jvmtiEventBreakpoint) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jlocation location); + +typedef void (JNICALL *jvmtiEventClassFileLoadHook) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jclass class_being_redefined, + jobject loader, + const char* name, + jobject protection_domain, + jint class_data_len, + const unsigned char* class_data, + jint* new_class_data_len, + unsigned char** new_class_data); + +typedef void (JNICALL *jvmtiEventClassLoad) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jclass klass); + +typedef void (JNICALL *jvmtiEventClassPrepare) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jclass klass); + +typedef void (JNICALL *jvmtiEventCompiledMethodLoad) + (jvmtiEnv *jvmti_env, + jmethodID method, + jint code_size, + const void* code_addr, + jint map_length, + const jvmtiAddrLocationMap* map, + const void* compile_info); + +typedef void (JNICALL *jvmtiEventCompiledMethodUnload) + (jvmtiEnv *jvmti_env, + jmethodID method, + const void* code_addr); + +typedef void (JNICALL *jvmtiEventDataDumpRequest) + (jvmtiEnv *jvmti_env); + +typedef void (JNICALL *jvmtiEventDynamicCodeGenerated) + (jvmtiEnv *jvmti_env, + const char* name, + const void* address, + jint length); + +typedef void (JNICALL *jvmtiEventException) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jlocation location, + jobject exception, + jmethodID catch_method, + jlocation catch_location); + +typedef void (JNICALL *jvmtiEventExceptionCatch) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jlocation location, + jobject exception); + +typedef void (JNICALL *jvmtiEventFieldAccess) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jlocation location, + jclass field_klass, + jobject object, + jfieldID field); + +typedef void (JNICALL *jvmtiEventFieldModification) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jlocation location, + jclass field_klass, + jobject object, + jfieldID field, + char signature_type, + jvalue new_value); + +typedef void (JNICALL *jvmtiEventFramePop) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jboolean was_popped_by_exception); + +typedef void (JNICALL *jvmtiEventGarbageCollectionFinish) + (jvmtiEnv *jvmti_env); + +typedef void (JNICALL *jvmtiEventGarbageCollectionStart) + (jvmtiEnv *jvmti_env); + +typedef void (JNICALL *jvmtiEventMethodEntry) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method); + +typedef void (JNICALL *jvmtiEventMethodExit) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jboolean was_popped_by_exception, + jvalue return_value); + +typedef void (JNICALL *jvmtiEventMonitorContendedEnter) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jobject object); + +typedef void (JNICALL *jvmtiEventMonitorContendedEntered) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jobject object); + +typedef void (JNICALL *jvmtiEventMonitorWait) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jobject object, + jlong timeout); + +typedef void (JNICALL *jvmtiEventMonitorWaited) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jobject object, + jboolean timed_out); + +typedef void (JNICALL *jvmtiEventNativeMethodBind) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + void* address, + void** new_address_ptr); + +typedef void (JNICALL *jvmtiEventObjectFree) + (jvmtiEnv *jvmti_env, + jlong tag); + +typedef void (JNICALL *jvmtiEventResourceExhausted) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jint flags, + const void* reserved, + const char* description); + +typedef void (JNICALL *jvmtiEventSingleStep) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jmethodID method, + jlocation location); + +typedef void (JNICALL *jvmtiEventThreadEnd) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread); + +typedef void (JNICALL *jvmtiEventThreadStart) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread); + +typedef void (JNICALL *jvmtiEventVMDeath) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env); + +typedef void (JNICALL *jvmtiEventVMInit) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread); + +typedef void (JNICALL *jvmtiEventVMObjectAlloc) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env, + jthread thread, + jobject object, + jclass object_klass, + jlong size); + +typedef void (JNICALL *jvmtiEventVMStart) + (jvmtiEnv *jvmti_env, + JNIEnv* jni_env); + + /* Event Callback Structure */ + +typedef struct { + /* 50 : VM Initialization Event */ + jvmtiEventVMInit VMInit; + /* 51 : VM Death Event */ + jvmtiEventVMDeath VMDeath; + /* 52 : Thread Start */ + jvmtiEventThreadStart ThreadStart; + /* 53 : Thread End */ + jvmtiEventThreadEnd ThreadEnd; + /* 54 : Class File Load Hook */ + jvmtiEventClassFileLoadHook ClassFileLoadHook; + /* 55 : Class Load */ + jvmtiEventClassLoad ClassLoad; + /* 56 : Class Prepare */ + jvmtiEventClassPrepare ClassPrepare; + /* 57 : VM Start Event */ + jvmtiEventVMStart VMStart; + /* 58 : Exception */ + jvmtiEventException Exception; + /* 59 : Exception Catch */ + jvmtiEventExceptionCatch ExceptionCatch; + /* 60 : Single Step */ + jvmtiEventSingleStep SingleStep; + /* 61 : Frame Pop */ + jvmtiEventFramePop FramePop; + /* 62 : Breakpoint */ + jvmtiEventBreakpoint Breakpoint; + /* 63 : Field Access */ + jvmtiEventFieldAccess FieldAccess; + /* 64 : Field Modification */ + jvmtiEventFieldModification FieldModification; + /* 65 : Method Entry */ + jvmtiEventMethodEntry MethodEntry; + /* 66 : Method Exit */ + jvmtiEventMethodExit MethodExit; + /* 67 : Native Method Bind */ + jvmtiEventNativeMethodBind NativeMethodBind; + /* 68 : Compiled Method Load */ + jvmtiEventCompiledMethodLoad CompiledMethodLoad; + /* 69 : Compiled Method Unload */ + jvmtiEventCompiledMethodUnload CompiledMethodUnload; + /* 70 : Dynamic Code Generated */ + jvmtiEventDynamicCodeGenerated DynamicCodeGenerated; + /* 71 : Data Dump Request */ + jvmtiEventDataDumpRequest DataDumpRequest; + /* 72 */ + jvmtiEventReserved reserved72; + /* 73 : Monitor Wait */ + jvmtiEventMonitorWait MonitorWait; + /* 74 : Monitor Waited */ + jvmtiEventMonitorWaited MonitorWaited; + /* 75 : Monitor Contended Enter */ + jvmtiEventMonitorContendedEnter MonitorContendedEnter; + /* 76 : Monitor Contended Entered */ + jvmtiEventMonitorContendedEntered MonitorContendedEntered; + /* 77 */ + jvmtiEventReserved reserved77; + /* 78 */ + jvmtiEventReserved reserved78; + /* 79 */ + jvmtiEventReserved reserved79; + /* 80 : Resource Exhausted */ + jvmtiEventResourceExhausted ResourceExhausted; + /* 81 : Garbage Collection Start */ + jvmtiEventGarbageCollectionStart GarbageCollectionStart; + /* 82 : Garbage Collection Finish */ + jvmtiEventGarbageCollectionFinish GarbageCollectionFinish; + /* 83 : Object Free */ + jvmtiEventObjectFree ObjectFree; + /* 84 : VM Object Allocation */ + jvmtiEventVMObjectAlloc VMObjectAlloc; +} jvmtiEventCallbacks; + + + /* Function Interface */ + +typedef struct jvmtiInterface_1_ { + + /* 1 : RESERVED */ + void *reserved1; + + /* 2 : Set Event Notification Mode */ + jvmtiError (JNICALL *SetEventNotificationMode) (jvmtiEnv* env, + jvmtiEventMode mode, + jvmtiEvent event_type, + jthread event_thread, + ...); + + /* 3 : RESERVED */ + void *reserved3; + + /* 4 : Get All Threads */ + jvmtiError (JNICALL *GetAllThreads) (jvmtiEnv* env, + jint* threads_count_ptr, + jthread** threads_ptr); + + /* 5 : Suspend Thread */ + jvmtiError (JNICALL *SuspendThread) (jvmtiEnv* env, + jthread thread); + + /* 6 : Resume Thread */ + jvmtiError (JNICALL *ResumeThread) (jvmtiEnv* env, + jthread thread); + + /* 7 : Stop Thread */ + jvmtiError (JNICALL *StopThread) (jvmtiEnv* env, + jthread thread, + jobject exception); + + /* 8 : Interrupt Thread */ + jvmtiError (JNICALL *InterruptThread) (jvmtiEnv* env, + jthread thread); + + /* 9 : Get Thread Info */ + jvmtiError (JNICALL *GetThreadInfo) (jvmtiEnv* env, + jthread thread, + jvmtiThreadInfo* info_ptr); + + /* 10 : Get Owned Monitor Info */ + jvmtiError (JNICALL *GetOwnedMonitorInfo) (jvmtiEnv* env, + jthread thread, + jint* owned_monitor_count_ptr, + jobject** owned_monitors_ptr); + + /* 11 : Get Current Contended Monitor */ + jvmtiError (JNICALL *GetCurrentContendedMonitor) (jvmtiEnv* env, + jthread thread, + jobject* monitor_ptr); + + /* 12 : Run Agent Thread */ + jvmtiError (JNICALL *RunAgentThread) (jvmtiEnv* env, + jthread thread, + jvmtiStartFunction proc, + const void* arg, + jint priority); + + /* 13 : Get Top Thread Groups */ + jvmtiError (JNICALL *GetTopThreadGroups) (jvmtiEnv* env, + jint* group_count_ptr, + jthreadGroup** groups_ptr); + + /* 14 : Get Thread Group Info */ + jvmtiError (JNICALL *GetThreadGroupInfo) (jvmtiEnv* env, + jthreadGroup group, + jvmtiThreadGroupInfo* info_ptr); + + /* 15 : Get Thread Group Children */ + jvmtiError (JNICALL *GetThreadGroupChildren) (jvmtiEnv* env, + jthreadGroup group, + jint* thread_count_ptr, + jthread** threads_ptr, + jint* group_count_ptr, + jthreadGroup** groups_ptr); + + /* 16 : Get Frame Count */ + jvmtiError (JNICALL *GetFrameCount) (jvmtiEnv* env, + jthread thread, + jint* count_ptr); + + /* 17 : Get Thread State */ + jvmtiError (JNICALL *GetThreadState) (jvmtiEnv* env, + jthread thread, + jint* thread_state_ptr); + + /* 18 : Get Current Thread */ + jvmtiError (JNICALL *GetCurrentThread) (jvmtiEnv* env, + jthread* thread_ptr); + + /* 19 : Get Frame Location */ + jvmtiError (JNICALL *GetFrameLocation) (jvmtiEnv* env, + jthread thread, + jint depth, + jmethodID* method_ptr, + jlocation* location_ptr); + + /* 20 : Notify Frame Pop */ + jvmtiError (JNICALL *NotifyFramePop) (jvmtiEnv* env, + jthread thread, + jint depth); + + /* 21 : Get Local Variable - Object */ + jvmtiError (JNICALL *GetLocalObject) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jobject* value_ptr); + + /* 22 : Get Local Variable - Int */ + jvmtiError (JNICALL *GetLocalInt) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jint* value_ptr); + + /* 23 : Get Local Variable - Long */ + jvmtiError (JNICALL *GetLocalLong) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jlong* value_ptr); + + /* 24 : Get Local Variable - Float */ + jvmtiError (JNICALL *GetLocalFloat) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jfloat* value_ptr); + + /* 25 : Get Local Variable - Double */ + jvmtiError (JNICALL *GetLocalDouble) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jdouble* value_ptr); + + /* 26 : Set Local Variable - Object */ + jvmtiError (JNICALL *SetLocalObject) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jobject value); + + /* 27 : Set Local Variable - Int */ + jvmtiError (JNICALL *SetLocalInt) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jint value); + + /* 28 : Set Local Variable - Long */ + jvmtiError (JNICALL *SetLocalLong) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jlong value); + + /* 29 : Set Local Variable - Float */ + jvmtiError (JNICALL *SetLocalFloat) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jfloat value); + + /* 30 : Set Local Variable - Double */ + jvmtiError (JNICALL *SetLocalDouble) (jvmtiEnv* env, + jthread thread, + jint depth, + jint slot, + jdouble value); + + /* 31 : Create Raw Monitor */ + jvmtiError (JNICALL *CreateRawMonitor) (jvmtiEnv* env, + const char* name, + jrawMonitorID* monitor_ptr); + + /* 32 : Destroy Raw Monitor */ + jvmtiError (JNICALL *DestroyRawMonitor) (jvmtiEnv* env, + jrawMonitorID monitor); + + /* 33 : Raw Monitor Enter */ + jvmtiError (JNICALL *RawMonitorEnter) (jvmtiEnv* env, + jrawMonitorID monitor); + + /* 34 : Raw Monitor Exit */ + jvmtiError (JNICALL *RawMonitorExit) (jvmtiEnv* env, + jrawMonitorID monitor); + + /* 35 : Raw Monitor Wait */ + jvmtiError (JNICALL *RawMonitorWait) (jvmtiEnv* env, + jrawMonitorID monitor, + jlong millis); + + /* 36 : Raw Monitor Notify */ + jvmtiError (JNICALL *RawMonitorNotify) (jvmtiEnv* env, + jrawMonitorID monitor); + + /* 37 : Raw Monitor Notify All */ + jvmtiError (JNICALL *RawMonitorNotifyAll) (jvmtiEnv* env, + jrawMonitorID monitor); + + /* 38 : Set Breakpoint */ + jvmtiError (JNICALL *SetBreakpoint) (jvmtiEnv* env, + jmethodID method, + jlocation location); + + /* 39 : Clear Breakpoint */ + jvmtiError (JNICALL *ClearBreakpoint) (jvmtiEnv* env, + jmethodID method, + jlocation location); + + /* 40 : RESERVED */ + void *reserved40; + + /* 41 : Set Field Access Watch */ + jvmtiError (JNICALL *SetFieldAccessWatch) (jvmtiEnv* env, + jclass klass, + jfieldID field); + + /* 42 : Clear Field Access Watch */ + jvmtiError (JNICALL *ClearFieldAccessWatch) (jvmtiEnv* env, + jclass klass, + jfieldID field); + + /* 43 : Set Field Modification Watch */ + jvmtiError (JNICALL *SetFieldModificationWatch) (jvmtiEnv* env, + jclass klass, + jfieldID field); + + /* 44 : Clear Field Modification Watch */ + jvmtiError (JNICALL *ClearFieldModificationWatch) (jvmtiEnv* env, + jclass klass, + jfieldID field); + + /* 45 : Is Modifiable Class */ + jvmtiError (JNICALL *IsModifiableClass) (jvmtiEnv* env, + jclass klass, + jboolean* is_modifiable_class_ptr); + + /* 46 : Allocate */ + jvmtiError (JNICALL *Allocate) (jvmtiEnv* env, + jlong size, + unsigned char** mem_ptr); + + /* 47 : Deallocate */ + jvmtiError (JNICALL *Deallocate) (jvmtiEnv* env, + unsigned char* mem); + + /* 48 : Get Class Signature */ + jvmtiError (JNICALL *GetClassSignature) (jvmtiEnv* env, + jclass klass, + char** signature_ptr, + char** generic_ptr); + + /* 49 : Get Class Status */ + jvmtiError (JNICALL *GetClassStatus) (jvmtiEnv* env, + jclass klass, + jint* status_ptr); + + /* 50 : Get Source File Name */ + jvmtiError (JNICALL *GetSourceFileName) (jvmtiEnv* env, + jclass klass, + char** source_name_ptr); + + /* 51 : Get Class Modifiers */ + jvmtiError (JNICALL *GetClassModifiers) (jvmtiEnv* env, + jclass klass, + jint* modifiers_ptr); + + /* 52 : Get Class Methods */ + jvmtiError (JNICALL *GetClassMethods) (jvmtiEnv* env, + jclass klass, + jint* method_count_ptr, + jmethodID** methods_ptr); + + /* 53 : Get Class Fields */ + jvmtiError (JNICALL *GetClassFields) (jvmtiEnv* env, + jclass klass, + jint* field_count_ptr, + jfieldID** fields_ptr); + + /* 54 : Get Implemented Interfaces */ + jvmtiError (JNICALL *GetImplementedInterfaces) (jvmtiEnv* env, + jclass klass, + jint* interface_count_ptr, + jclass** interfaces_ptr); + + /* 55 : Is Interface */ + jvmtiError (JNICALL *IsInterface) (jvmtiEnv* env, + jclass klass, + jboolean* is_interface_ptr); + + /* 56 : Is Array Class */ + jvmtiError (JNICALL *IsArrayClass) (jvmtiEnv* env, + jclass klass, + jboolean* is_array_class_ptr); + + /* 57 : Get Class Loader */ + jvmtiError (JNICALL *GetClassLoader) (jvmtiEnv* env, + jclass klass, + jobject* classloader_ptr); + + /* 58 : Get Object Hash Code */ + jvmtiError (JNICALL *GetObjectHashCode) (jvmtiEnv* env, + jobject object, + jint* hash_code_ptr); + + /* 59 : Get Object Monitor Usage */ + jvmtiError (JNICALL *GetObjectMonitorUsage) (jvmtiEnv* env, + jobject object, + jvmtiMonitorUsage* info_ptr); + + /* 60 : Get Field Name (and Signature) */ + jvmtiError (JNICALL *GetFieldName) (jvmtiEnv* env, + jclass klass, + jfieldID field, + char** name_ptr, + char** signature_ptr, + char** generic_ptr); + + /* 61 : Get Field Declaring Class */ + jvmtiError (JNICALL *GetFieldDeclaringClass) (jvmtiEnv* env, + jclass klass, + jfieldID field, + jclass* declaring_class_ptr); + + /* 62 : Get Field Modifiers */ + jvmtiError (JNICALL *GetFieldModifiers) (jvmtiEnv* env, + jclass klass, + jfieldID field, + jint* modifiers_ptr); + + /* 63 : Is Field Synthetic */ + jvmtiError (JNICALL *IsFieldSynthetic) (jvmtiEnv* env, + jclass klass, + jfieldID field, + jboolean* is_synthetic_ptr); + + /* 64 : Get Method Name (and Signature) */ + jvmtiError (JNICALL *GetMethodName) (jvmtiEnv* env, + jmethodID method, + char** name_ptr, + char** signature_ptr, + char** generic_ptr); + + /* 65 : Get Method Declaring Class */ + jvmtiError (JNICALL *GetMethodDeclaringClass) (jvmtiEnv* env, + jmethodID method, + jclass* declaring_class_ptr); + + /* 66 : Get Method Modifiers */ + jvmtiError (JNICALL *GetMethodModifiers) (jvmtiEnv* env, + jmethodID method, + jint* modifiers_ptr); + + /* 67 : RESERVED */ + void *reserved67; + + /* 68 : Get Max Locals */ + jvmtiError (JNICALL *GetMaxLocals) (jvmtiEnv* env, + jmethodID method, + jint* max_ptr); + + /* 69 : Get Arguments Size */ + jvmtiError (JNICALL *GetArgumentsSize) (jvmtiEnv* env, + jmethodID method, + jint* size_ptr); + + /* 70 : Get Line Number Table */ + jvmtiError (JNICALL *GetLineNumberTable) (jvmtiEnv* env, + jmethodID method, + jint* entry_count_ptr, + jvmtiLineNumberEntry** table_ptr); + + /* 71 : Get Method Location */ + jvmtiError (JNICALL *GetMethodLocation) (jvmtiEnv* env, + jmethodID method, + jlocation* start_location_ptr, + jlocation* end_location_ptr); + + /* 72 : Get Local Variable Table */ + jvmtiError (JNICALL *GetLocalVariableTable) (jvmtiEnv* env, + jmethodID method, + jint* entry_count_ptr, + jvmtiLocalVariableEntry** table_ptr); + + /* 73 : Set Native Method Prefix */ + jvmtiError (JNICALL *SetNativeMethodPrefix) (jvmtiEnv* env, + const char* prefix); + + /* 74 : Set Native Method Prefixes */ + jvmtiError (JNICALL *SetNativeMethodPrefixes) (jvmtiEnv* env, + jint prefix_count, + char** prefixes); + + /* 75 : Get Bytecodes */ + jvmtiError (JNICALL *GetBytecodes) (jvmtiEnv* env, + jmethodID method, + jint* bytecode_count_ptr, + unsigned char** bytecodes_ptr); + + /* 76 : Is Method Native */ + jvmtiError (JNICALL *IsMethodNative) (jvmtiEnv* env, + jmethodID method, + jboolean* is_native_ptr); + + /* 77 : Is Method Synthetic */ + jvmtiError (JNICALL *IsMethodSynthetic) (jvmtiEnv* env, + jmethodID method, + jboolean* is_synthetic_ptr); + + /* 78 : Get Loaded Classes */ + jvmtiError (JNICALL *GetLoadedClasses) (jvmtiEnv* env, + jint* class_count_ptr, + jclass** classes_ptr); + + /* 79 : Get Classloader Classes */ + jvmtiError (JNICALL *GetClassLoaderClasses) (jvmtiEnv* env, + jobject initiating_loader, + jint* class_count_ptr, + jclass** classes_ptr); + + /* 80 : Pop Frame */ + jvmtiError (JNICALL *PopFrame) (jvmtiEnv* env, + jthread thread); + + /* 81 : Force Early Return - Object */ + jvmtiError (JNICALL *ForceEarlyReturnObject) (jvmtiEnv* env, + jthread thread, + jobject value); + + /* 82 : Force Early Return - Int */ + jvmtiError (JNICALL *ForceEarlyReturnInt) (jvmtiEnv* env, + jthread thread, + jint value); + + /* 83 : Force Early Return - Long */ + jvmtiError (JNICALL *ForceEarlyReturnLong) (jvmtiEnv* env, + jthread thread, + jlong value); + + /* 84 : Force Early Return - Float */ + jvmtiError (JNICALL *ForceEarlyReturnFloat) (jvmtiEnv* env, + jthread thread, + jfloat value); + + /* 85 : Force Early Return - Double */ + jvmtiError (JNICALL *ForceEarlyReturnDouble) (jvmtiEnv* env, + jthread thread, + jdouble value); + + /* 86 : Force Early Return - Void */ + jvmtiError (JNICALL *ForceEarlyReturnVoid) (jvmtiEnv* env, + jthread thread); + + /* 87 : Redefine Classes */ + jvmtiError (JNICALL *RedefineClasses) (jvmtiEnv* env, + jint class_count, + const jvmtiClassDefinition* class_definitions); + + /* 88 : Get Version Number */ + jvmtiError (JNICALL *GetVersionNumber) (jvmtiEnv* env, + jint* version_ptr); + + /* 89 : Get Capabilities */ + jvmtiError (JNICALL *GetCapabilities) (jvmtiEnv* env, + jvmtiCapabilities* capabilities_ptr); + + /* 90 : Get Source Debug Extension */ + jvmtiError (JNICALL *GetSourceDebugExtension) (jvmtiEnv* env, + jclass klass, + char** source_debug_extension_ptr); + + /* 91 : Is Method Obsolete */ + jvmtiError (JNICALL *IsMethodObsolete) (jvmtiEnv* env, + jmethodID method, + jboolean* is_obsolete_ptr); + + /* 92 : Suspend Thread List */ + jvmtiError (JNICALL *SuspendThreadList) (jvmtiEnv* env, + jint request_count, + const jthread* request_list, + jvmtiError* results); + + /* 93 : Resume Thread List */ + jvmtiError (JNICALL *ResumeThreadList) (jvmtiEnv* env, + jint request_count, + const jthread* request_list, + jvmtiError* results); + + /* 94 : RESERVED */ + void *reserved94; + + /* 95 : RESERVED */ + void *reserved95; + + /* 96 : RESERVED */ + void *reserved96; + + /* 97 : RESERVED */ + void *reserved97; + + /* 98 : RESERVED */ + void *reserved98; + + /* 99 : RESERVED */ + void *reserved99; + + /* 100 : Get All Stack Traces */ + jvmtiError (JNICALL *GetAllStackTraces) (jvmtiEnv* env, + jint max_frame_count, + jvmtiStackInfo** stack_info_ptr, + jint* thread_count_ptr); + + /* 101 : Get Thread List Stack Traces */ + jvmtiError (JNICALL *GetThreadListStackTraces) (jvmtiEnv* env, + jint thread_count, + const jthread* thread_list, + jint max_frame_count, + jvmtiStackInfo** stack_info_ptr); + + /* 102 : Get Thread Local Storage */ + jvmtiError (JNICALL *GetThreadLocalStorage) (jvmtiEnv* env, + jthread thread, + void** data_ptr); + + /* 103 : Set Thread Local Storage */ + jvmtiError (JNICALL *SetThreadLocalStorage) (jvmtiEnv* env, + jthread thread, + const void* data); + + /* 104 : Get Stack Trace */ + jvmtiError (JNICALL *GetStackTrace) (jvmtiEnv* env, + jthread thread, + jint start_depth, + jint max_frame_count, + jvmtiFrameInfo* frame_buffer, + jint* count_ptr); + + /* 105 : RESERVED */ + void *reserved105; + + /* 106 : Get Tag */ + jvmtiError (JNICALL *GetTag) (jvmtiEnv* env, + jobject object, + jlong* tag_ptr); + + /* 107 : Set Tag */ + jvmtiError (JNICALL *SetTag) (jvmtiEnv* env, + jobject object, + jlong tag); + + /* 108 : Force Garbage Collection */ + jvmtiError (JNICALL *ForceGarbageCollection) (jvmtiEnv* env); + + /* 109 : Iterate Over Objects Reachable From Object */ + jvmtiError (JNICALL *IterateOverObjectsReachableFromObject) (jvmtiEnv* env, + jobject object, + jvmtiObjectReferenceCallback object_reference_callback, + const void* user_data); + + /* 110 : Iterate Over Reachable Objects */ + jvmtiError (JNICALL *IterateOverReachableObjects) (jvmtiEnv* env, + jvmtiHeapRootCallback heap_root_callback, + jvmtiStackReferenceCallback stack_ref_callback, + jvmtiObjectReferenceCallback object_ref_callback, + const void* user_data); + + /* 111 : Iterate Over Heap */ + jvmtiError (JNICALL *IterateOverHeap) (jvmtiEnv* env, + jvmtiHeapObjectFilter object_filter, + jvmtiHeapObjectCallback heap_object_callback, + const void* user_data); + + /* 112 : Iterate Over Instances Of Class */ + jvmtiError (JNICALL *IterateOverInstancesOfClass) (jvmtiEnv* env, + jclass klass, + jvmtiHeapObjectFilter object_filter, + jvmtiHeapObjectCallback heap_object_callback, + const void* user_data); + + /* 113 : RESERVED */ + void *reserved113; + + /* 114 : Get Objects With Tags */ + jvmtiError (JNICALL *GetObjectsWithTags) (jvmtiEnv* env, + jint tag_count, + const jlong* tags, + jint* count_ptr, + jobject** object_result_ptr, + jlong** tag_result_ptr); + + /* 115 : Follow References */ + jvmtiError (JNICALL *FollowReferences) (jvmtiEnv* env, + jint heap_filter, + jclass klass, + jobject initial_object, + const jvmtiHeapCallbacks* callbacks, + const void* user_data); + + /* 116 : Iterate Through Heap */ + jvmtiError (JNICALL *IterateThroughHeap) (jvmtiEnv* env, + jint heap_filter, + jclass klass, + const jvmtiHeapCallbacks* callbacks, + const void* user_data); + + /* 117 : RESERVED */ + void *reserved117; + + /* 118 : RESERVED */ + void *reserved118; + + /* 119 : RESERVED */ + void *reserved119; + + /* 120 : Set JNI Function Table */ + jvmtiError (JNICALL *SetJNIFunctionTable) (jvmtiEnv* env, + const jniNativeInterface* function_table); + + /* 121 : Get JNI Function Table */ + jvmtiError (JNICALL *GetJNIFunctionTable) (jvmtiEnv* env, + jniNativeInterface** function_table); + + /* 122 : Set Event Callbacks */ + jvmtiError (JNICALL *SetEventCallbacks) (jvmtiEnv* env, + const jvmtiEventCallbacks* callbacks, + jint size_of_callbacks); + + /* 123 : Generate Events */ + jvmtiError (JNICALL *GenerateEvents) (jvmtiEnv* env, + jvmtiEvent event_type); + + /* 124 : Get Extension Functions */ + jvmtiError (JNICALL *GetExtensionFunctions) (jvmtiEnv* env, + jint* extension_count_ptr, + jvmtiExtensionFunctionInfo** extensions); + + /* 125 : Get Extension Events */ + jvmtiError (JNICALL *GetExtensionEvents) (jvmtiEnv* env, + jint* extension_count_ptr, + jvmtiExtensionEventInfo** extensions); + + /* 126 : Set Extension Event Callback */ + jvmtiError (JNICALL *SetExtensionEventCallback) (jvmtiEnv* env, + jint extension_event_index, + jvmtiExtensionEvent callback); + + /* 127 : Dispose Environment */ + jvmtiError (JNICALL *DisposeEnvironment) (jvmtiEnv* env); + + /* 128 : Get Error Name */ + jvmtiError (JNICALL *GetErrorName) (jvmtiEnv* env, + jvmtiError error, + char** name_ptr); + + /* 129 : Get JLocation Format */ + jvmtiError (JNICALL *GetJLocationFormat) (jvmtiEnv* env, + jvmtiJlocationFormat* format_ptr); + + /* 130 : Get System Properties */ + jvmtiError (JNICALL *GetSystemProperties) (jvmtiEnv* env, + jint* count_ptr, + char*** property_ptr); + + /* 131 : Get System Property */ + jvmtiError (JNICALL *GetSystemProperty) (jvmtiEnv* env, + const char* property, + char** value_ptr); + + /* 132 : Set System Property */ + jvmtiError (JNICALL *SetSystemProperty) (jvmtiEnv* env, + const char* property, + const char* value); + + /* 133 : Get Phase */ + jvmtiError (JNICALL *GetPhase) (jvmtiEnv* env, + jvmtiPhase* phase_ptr); + + /* 134 : Get Current Thread CPU Timer Information */ + jvmtiError (JNICALL *GetCurrentThreadCpuTimerInfo) (jvmtiEnv* env, + jvmtiTimerInfo* info_ptr); + + /* 135 : Get Current Thread CPU Time */ + jvmtiError (JNICALL *GetCurrentThreadCpuTime) (jvmtiEnv* env, + jlong* nanos_ptr); + + /* 136 : Get Thread CPU Timer Information */ + jvmtiError (JNICALL *GetThreadCpuTimerInfo) (jvmtiEnv* env, + jvmtiTimerInfo* info_ptr); + + /* 137 : Get Thread CPU Time */ + jvmtiError (JNICALL *GetThreadCpuTime) (jvmtiEnv* env, + jthread thread, + jlong* nanos_ptr); + + /* 138 : Get Timer Information */ + jvmtiError (JNICALL *GetTimerInfo) (jvmtiEnv* env, + jvmtiTimerInfo* info_ptr); + + /* 139 : Get Time */ + jvmtiError (JNICALL *GetTime) (jvmtiEnv* env, + jlong* nanos_ptr); + + /* 140 : Get Potential Capabilities */ + jvmtiError (JNICALL *GetPotentialCapabilities) (jvmtiEnv* env, + jvmtiCapabilities* capabilities_ptr); + + /* 141 : RESERVED */ + void *reserved141; + + /* 142 : Add Capabilities */ + jvmtiError (JNICALL *AddCapabilities) (jvmtiEnv* env, + const jvmtiCapabilities* capabilities_ptr); + + /* 143 : Relinquish Capabilities */ + jvmtiError (JNICALL *RelinquishCapabilities) (jvmtiEnv* env, + const jvmtiCapabilities* capabilities_ptr); + + /* 144 : Get Available Processors */ + jvmtiError (JNICALL *GetAvailableProcessors) (jvmtiEnv* env, + jint* processor_count_ptr); + + /* 145 : Get Class Version Numbers */ + jvmtiError (JNICALL *GetClassVersionNumbers) (jvmtiEnv* env, + jclass klass, + jint* minor_version_ptr, + jint* major_version_ptr); + + /* 146 : Get Constant Pool */ + jvmtiError (JNICALL *GetConstantPool) (jvmtiEnv* env, + jclass klass, + jint* constant_pool_count_ptr, + jint* constant_pool_byte_count_ptr, + unsigned char** constant_pool_bytes_ptr); + + /* 147 : Get Environment Local Storage */ + jvmtiError (JNICALL *GetEnvironmentLocalStorage) (jvmtiEnv* env, + void** data_ptr); + + /* 148 : Set Environment Local Storage */ + jvmtiError (JNICALL *SetEnvironmentLocalStorage) (jvmtiEnv* env, + const void* data); + + /* 149 : Add To Bootstrap Class Loader Search */ + jvmtiError (JNICALL *AddToBootstrapClassLoaderSearch) (jvmtiEnv* env, + const char* segment); + + /* 150 : Set Verbose Flag */ + jvmtiError (JNICALL *SetVerboseFlag) (jvmtiEnv* env, + jvmtiVerboseFlag flag, + jboolean value); + + /* 151 : Add To System Class Loader Search */ + jvmtiError (JNICALL *AddToSystemClassLoaderSearch) (jvmtiEnv* env, + const char* segment); + + /* 152 : Retransform Classes */ + jvmtiError (JNICALL *RetransformClasses) (jvmtiEnv* env, + jint class_count, + const jclass* classes); + + /* 153 : Get Owned Monitor Stack Depth Info */ + jvmtiError (JNICALL *GetOwnedMonitorStackDepthInfo) (jvmtiEnv* env, + jthread thread, + jint* monitor_info_count_ptr, + jvmtiMonitorStackDepthInfo** monitor_info_ptr); + + /* 154 : Get Object Size */ + jvmtiError (JNICALL *GetObjectSize) (jvmtiEnv* env, + jobject object, + jlong* size_ptr); + +} jvmtiInterface_1; + +struct _jvmtiEnv { + const struct jvmtiInterface_1_ *functions; +#ifdef __cplusplus + + + jvmtiError Allocate(jlong size, + unsigned char** mem_ptr) { + return functions->Allocate(this, size, mem_ptr); + } + + jvmtiError Deallocate(unsigned char* mem) { + return functions->Deallocate(this, mem); + } + + jvmtiError GetThreadState(jthread thread, + jint* thread_state_ptr) { + return functions->GetThreadState(this, thread, thread_state_ptr); + } + + jvmtiError GetCurrentThread(jthread* thread_ptr) { + return functions->GetCurrentThread(this, thread_ptr); + } + + jvmtiError GetAllThreads(jint* threads_count_ptr, + jthread** threads_ptr) { + return functions->GetAllThreads(this, threads_count_ptr, threads_ptr); + } + + jvmtiError SuspendThread(jthread thread) { + return functions->SuspendThread(this, thread); + } + + jvmtiError SuspendThreadList(jint request_count, + const jthread* request_list, + jvmtiError* results) { + return functions->SuspendThreadList(this, request_count, request_list, results); + } + + jvmtiError ResumeThread(jthread thread) { + return functions->ResumeThread(this, thread); + } + + jvmtiError ResumeThreadList(jint request_count, + const jthread* request_list, + jvmtiError* results) { + return functions->ResumeThreadList(this, request_count, request_list, results); + } + + jvmtiError StopThread(jthread thread, + jobject exception) { + return functions->StopThread(this, thread, exception); + } + + jvmtiError InterruptThread(jthread thread) { + return functions->InterruptThread(this, thread); + } + + jvmtiError GetThreadInfo(jthread thread, + jvmtiThreadInfo* info_ptr) { + return functions->GetThreadInfo(this, thread, info_ptr); + } + + jvmtiError GetOwnedMonitorInfo(jthread thread, + jint* owned_monitor_count_ptr, + jobject** owned_monitors_ptr) { + return functions->GetOwnedMonitorInfo(this, thread, owned_monitor_count_ptr, owned_monitors_ptr); + } + + jvmtiError GetOwnedMonitorStackDepthInfo(jthread thread, + jint* monitor_info_count_ptr, + jvmtiMonitorStackDepthInfo** monitor_info_ptr) { + return functions->GetOwnedMonitorStackDepthInfo(this, thread, monitor_info_count_ptr, monitor_info_ptr); + } + + jvmtiError GetCurrentContendedMonitor(jthread thread, + jobject* monitor_ptr) { + return functions->GetCurrentContendedMonitor(this, thread, monitor_ptr); + } + + jvmtiError RunAgentThread(jthread thread, + jvmtiStartFunction proc, + const void* arg, + jint priority) { + return functions->RunAgentThread(this, thread, proc, arg, priority); + } + + jvmtiError SetThreadLocalStorage(jthread thread, + const void* data) { + return functions->SetThreadLocalStorage(this, thread, data); + } + + jvmtiError GetThreadLocalStorage(jthread thread, + void** data_ptr) { + return functions->GetThreadLocalStorage(this, thread, data_ptr); + } + + jvmtiError GetTopThreadGroups(jint* group_count_ptr, + jthreadGroup** groups_ptr) { + return functions->GetTopThreadGroups(this, group_count_ptr, groups_ptr); + } + + jvmtiError GetThreadGroupInfo(jthreadGroup group, + jvmtiThreadGroupInfo* info_ptr) { + return functions->GetThreadGroupInfo(this, group, info_ptr); + } + + jvmtiError GetThreadGroupChildren(jthreadGroup group, + jint* thread_count_ptr, + jthread** threads_ptr, + jint* group_count_ptr, + jthreadGroup** groups_ptr) { + return functions->GetThreadGroupChildren(this, group, thread_count_ptr, threads_ptr, group_count_ptr, groups_ptr); + } + + jvmtiError GetStackTrace(jthread thread, + jint start_depth, + jint max_frame_count, + jvmtiFrameInfo* frame_buffer, + jint* count_ptr) { + return functions->GetStackTrace(this, thread, start_depth, max_frame_count, frame_buffer, count_ptr); + } + + jvmtiError GetAllStackTraces(jint max_frame_count, + jvmtiStackInfo** stack_info_ptr, + jint* thread_count_ptr) { + return functions->GetAllStackTraces(this, max_frame_count, stack_info_ptr, thread_count_ptr); + } + + jvmtiError GetThreadListStackTraces(jint thread_count, + const jthread* thread_list, + jint max_frame_count, + jvmtiStackInfo** stack_info_ptr) { + return functions->GetThreadListStackTraces(this, thread_count, thread_list, max_frame_count, stack_info_ptr); + } + + jvmtiError GetFrameCount(jthread thread, + jint* count_ptr) { + return functions->GetFrameCount(this, thread, count_ptr); + } + + jvmtiError PopFrame(jthread thread) { + return functions->PopFrame(this, thread); + } + + jvmtiError GetFrameLocation(jthread thread, + jint depth, + jmethodID* method_ptr, + jlocation* location_ptr) { + return functions->GetFrameLocation(this, thread, depth, method_ptr, location_ptr); + } + + jvmtiError NotifyFramePop(jthread thread, + jint depth) { + return functions->NotifyFramePop(this, thread, depth); + } + + jvmtiError ForceEarlyReturnObject(jthread thread, + jobject value) { + return functions->ForceEarlyReturnObject(this, thread, value); + } + + jvmtiError ForceEarlyReturnInt(jthread thread, + jint value) { + return functions->ForceEarlyReturnInt(this, thread, value); + } + + jvmtiError ForceEarlyReturnLong(jthread thread, + jlong value) { + return functions->ForceEarlyReturnLong(this, thread, value); + } + + jvmtiError ForceEarlyReturnFloat(jthread thread, + jfloat value) { + return functions->ForceEarlyReturnFloat(this, thread, value); + } + + jvmtiError ForceEarlyReturnDouble(jthread thread, + jdouble value) { + return functions->ForceEarlyReturnDouble(this, thread, value); + } + + jvmtiError ForceEarlyReturnVoid(jthread thread) { + return functions->ForceEarlyReturnVoid(this, thread); + } + + jvmtiError FollowReferences(jint heap_filter, + jclass klass, + jobject initial_object, + const jvmtiHeapCallbacks* callbacks, + const void* user_data) { + return functions->FollowReferences(this, heap_filter, klass, initial_object, callbacks, user_data); + } + + jvmtiError IterateThroughHeap(jint heap_filter, + jclass klass, + const jvmtiHeapCallbacks* callbacks, + const void* user_data) { + return functions->IterateThroughHeap(this, heap_filter, klass, callbacks, user_data); + } + + jvmtiError GetTag(jobject object, + jlong* tag_ptr) { + return functions->GetTag(this, object, tag_ptr); + } + + jvmtiError SetTag(jobject object, + jlong tag) { + return functions->SetTag(this, object, tag); + } + + jvmtiError GetObjectsWithTags(jint tag_count, + const jlong* tags, + jint* count_ptr, + jobject** object_result_ptr, + jlong** tag_result_ptr) { + return functions->GetObjectsWithTags(this, tag_count, tags, count_ptr, object_result_ptr, tag_result_ptr); + } + + jvmtiError ForceGarbageCollection() { + return functions->ForceGarbageCollection(this); + } + + jvmtiError IterateOverObjectsReachableFromObject(jobject object, + jvmtiObjectReferenceCallback object_reference_callback, + const void* user_data) { + return functions->IterateOverObjectsReachableFromObject(this, object, object_reference_callback, user_data); + } + + jvmtiError IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, + jvmtiStackReferenceCallback stack_ref_callback, + jvmtiObjectReferenceCallback object_ref_callback, + const void* user_data) { + return functions->IterateOverReachableObjects(this, heap_root_callback, stack_ref_callback, object_ref_callback, user_data); + } + + jvmtiError IterateOverHeap(jvmtiHeapObjectFilter object_filter, + jvmtiHeapObjectCallback heap_object_callback, + const void* user_data) { + return functions->IterateOverHeap(this, object_filter, heap_object_callback, user_data); + } + + jvmtiError IterateOverInstancesOfClass(jclass klass, + jvmtiHeapObjectFilter object_filter, + jvmtiHeapObjectCallback heap_object_callback, + const void* user_data) { + return functions->IterateOverInstancesOfClass(this, klass, object_filter, heap_object_callback, user_data); + } + + jvmtiError GetLocalObject(jthread thread, + jint depth, + jint slot, + jobject* value_ptr) { + return functions->GetLocalObject(this, thread, depth, slot, value_ptr); + } + + jvmtiError GetLocalInt(jthread thread, + jint depth, + jint slot, + jint* value_ptr) { + return functions->GetLocalInt(this, thread, depth, slot, value_ptr); + } + + jvmtiError GetLocalLong(jthread thread, + jint depth, + jint slot, + jlong* value_ptr) { + return functions->GetLocalLong(this, thread, depth, slot, value_ptr); + } + + jvmtiError GetLocalFloat(jthread thread, + jint depth, + jint slot, + jfloat* value_ptr) { + return functions->GetLocalFloat(this, thread, depth, slot, value_ptr); + } + + jvmtiError GetLocalDouble(jthread thread, + jint depth, + jint slot, + jdouble* value_ptr) { + return functions->GetLocalDouble(this, thread, depth, slot, value_ptr); + } + + jvmtiError SetLocalObject(jthread thread, + jint depth, + jint slot, + jobject value) { + return functions->SetLocalObject(this, thread, depth, slot, value); + } + + jvmtiError SetLocalInt(jthread thread, + jint depth, + jint slot, + jint value) { + return functions->SetLocalInt(this, thread, depth, slot, value); + } + + jvmtiError SetLocalLong(jthread thread, + jint depth, + jint slot, + jlong value) { + return functions->SetLocalLong(this, thread, depth, slot, value); + } + + jvmtiError SetLocalFloat(jthread thread, + jint depth, + jint slot, + jfloat value) { + return functions->SetLocalFloat(this, thread, depth, slot, value); + } + + jvmtiError SetLocalDouble(jthread thread, + jint depth, + jint slot, + jdouble value) { + return functions->SetLocalDouble(this, thread, depth, slot, value); + } + + jvmtiError SetBreakpoint(jmethodID method, + jlocation location) { + return functions->SetBreakpoint(this, method, location); + } + + jvmtiError ClearBreakpoint(jmethodID method, + jlocation location) { + return functions->ClearBreakpoint(this, method, location); + } + + jvmtiError SetFieldAccessWatch(jclass klass, + jfieldID field) { + return functions->SetFieldAccessWatch(this, klass, field); + } + + jvmtiError ClearFieldAccessWatch(jclass klass, + jfieldID field) { + return functions->ClearFieldAccessWatch(this, klass, field); + } + + jvmtiError SetFieldModificationWatch(jclass klass, + jfieldID field) { + return functions->SetFieldModificationWatch(this, klass, field); + } + + jvmtiError ClearFieldModificationWatch(jclass klass, + jfieldID field) { + return functions->ClearFieldModificationWatch(this, klass, field); + } + + jvmtiError GetLoadedClasses(jint* class_count_ptr, + jclass** classes_ptr) { + return functions->GetLoadedClasses(this, class_count_ptr, classes_ptr); + } + + jvmtiError GetClassLoaderClasses(jobject initiating_loader, + jint* class_count_ptr, + jclass** classes_ptr) { + return functions->GetClassLoaderClasses(this, initiating_loader, class_count_ptr, classes_ptr); + } + + jvmtiError GetClassSignature(jclass klass, + char** signature_ptr, + char** generic_ptr) { + return functions->GetClassSignature(this, klass, signature_ptr, generic_ptr); + } + + jvmtiError GetClassStatus(jclass klass, + jint* status_ptr) { + return functions->GetClassStatus(this, klass, status_ptr); + } + + jvmtiError GetSourceFileName(jclass klass, + char** source_name_ptr) { + return functions->GetSourceFileName(this, klass, source_name_ptr); + } + + jvmtiError GetClassModifiers(jclass klass, + jint* modifiers_ptr) { + return functions->GetClassModifiers(this, klass, modifiers_ptr); + } + + jvmtiError GetClassMethods(jclass klass, + jint* method_count_ptr, + jmethodID** methods_ptr) { + return functions->GetClassMethods(this, klass, method_count_ptr, methods_ptr); + } + + jvmtiError GetClassFields(jclass klass, + jint* field_count_ptr, + jfieldID** fields_ptr) { + return functions->GetClassFields(this, klass, field_count_ptr, fields_ptr); + } + + jvmtiError GetImplementedInterfaces(jclass klass, + jint* interface_count_ptr, + jclass** interfaces_ptr) { + return functions->GetImplementedInterfaces(this, klass, interface_count_ptr, interfaces_ptr); + } + + jvmtiError GetClassVersionNumbers(jclass klass, + jint* minor_version_ptr, + jint* major_version_ptr) { + return functions->GetClassVersionNumbers(this, klass, minor_version_ptr, major_version_ptr); + } + + jvmtiError GetConstantPool(jclass klass, + jint* constant_pool_count_ptr, + jint* constant_pool_byte_count_ptr, + unsigned char** constant_pool_bytes_ptr) { + return functions->GetConstantPool(this, klass, constant_pool_count_ptr, constant_pool_byte_count_ptr, constant_pool_bytes_ptr); + } + + jvmtiError IsInterface(jclass klass, + jboolean* is_interface_ptr) { + return functions->IsInterface(this, klass, is_interface_ptr); + } + + jvmtiError IsArrayClass(jclass klass, + jboolean* is_array_class_ptr) { + return functions->IsArrayClass(this, klass, is_array_class_ptr); + } + + jvmtiError IsModifiableClass(jclass klass, + jboolean* is_modifiable_class_ptr) { + return functions->IsModifiableClass(this, klass, is_modifiable_class_ptr); + } + + jvmtiError GetClassLoader(jclass klass, + jobject* classloader_ptr) { + return functions->GetClassLoader(this, klass, classloader_ptr); + } + + jvmtiError GetSourceDebugExtension(jclass klass, + char** source_debug_extension_ptr) { + return functions->GetSourceDebugExtension(this, klass, source_debug_extension_ptr); + } + + jvmtiError RetransformClasses(jint class_count, + const jclass* classes) { + return functions->RetransformClasses(this, class_count, classes); + } + + jvmtiError RedefineClasses(jint class_count, + const jvmtiClassDefinition* class_definitions) { + return functions->RedefineClasses(this, class_count, class_definitions); + } + + jvmtiError GetObjectSize(jobject object, + jlong* size_ptr) { + return functions->GetObjectSize(this, object, size_ptr); + } + + jvmtiError GetObjectHashCode(jobject object, + jint* hash_code_ptr) { + return functions->GetObjectHashCode(this, object, hash_code_ptr); + } + + jvmtiError GetObjectMonitorUsage(jobject object, + jvmtiMonitorUsage* info_ptr) { + return functions->GetObjectMonitorUsage(this, object, info_ptr); + } + + jvmtiError GetFieldName(jclass klass, + jfieldID field, + char** name_ptr, + char** signature_ptr, + char** generic_ptr) { + return functions->GetFieldName(this, klass, field, name_ptr, signature_ptr, generic_ptr); + } + + jvmtiError GetFieldDeclaringClass(jclass klass, + jfieldID field, + jclass* declaring_class_ptr) { + return functions->GetFieldDeclaringClass(this, klass, field, declaring_class_ptr); + } + + jvmtiError GetFieldModifiers(jclass klass, + jfieldID field, + jint* modifiers_ptr) { + return functions->GetFieldModifiers(this, klass, field, modifiers_ptr); + } + + jvmtiError IsFieldSynthetic(jclass klass, + jfieldID field, + jboolean* is_synthetic_ptr) { + return functions->IsFieldSynthetic(this, klass, field, is_synthetic_ptr); + } + + jvmtiError GetMethodName(jmethodID method, + char** name_ptr, + char** signature_ptr, + char** generic_ptr) { + return functions->GetMethodName(this, method, name_ptr, signature_ptr, generic_ptr); + } + + jvmtiError GetMethodDeclaringClass(jmethodID method, + jclass* declaring_class_ptr) { + return functions->GetMethodDeclaringClass(this, method, declaring_class_ptr); + } + + jvmtiError GetMethodModifiers(jmethodID method, + jint* modifiers_ptr) { + return functions->GetMethodModifiers(this, method, modifiers_ptr); + } + + jvmtiError GetMaxLocals(jmethodID method, + jint* max_ptr) { + return functions->GetMaxLocals(this, method, max_ptr); + } + + jvmtiError GetArgumentsSize(jmethodID method, + jint* size_ptr) { + return functions->GetArgumentsSize(this, method, size_ptr); + } + + jvmtiError GetLineNumberTable(jmethodID method, + jint* entry_count_ptr, + jvmtiLineNumberEntry** table_ptr) { + return functions->GetLineNumberTable(this, method, entry_count_ptr, table_ptr); + } + + jvmtiError GetMethodLocation(jmethodID method, + jlocation* start_location_ptr, + jlocation* end_location_ptr) { + return functions->GetMethodLocation(this, method, start_location_ptr, end_location_ptr); + } + + jvmtiError GetLocalVariableTable(jmethodID method, + jint* entry_count_ptr, + jvmtiLocalVariableEntry** table_ptr) { + return functions->GetLocalVariableTable(this, method, entry_count_ptr, table_ptr); + } + + jvmtiError GetBytecodes(jmethodID method, + jint* bytecode_count_ptr, + unsigned char** bytecodes_ptr) { + return functions->GetBytecodes(this, method, bytecode_count_ptr, bytecodes_ptr); + } + + jvmtiError IsMethodNative(jmethodID method, + jboolean* is_native_ptr) { + return functions->IsMethodNative(this, method, is_native_ptr); + } + + jvmtiError IsMethodSynthetic(jmethodID method, + jboolean* is_synthetic_ptr) { + return functions->IsMethodSynthetic(this, method, is_synthetic_ptr); + } + + jvmtiError IsMethodObsolete(jmethodID method, + jboolean* is_obsolete_ptr) { + return functions->IsMethodObsolete(this, method, is_obsolete_ptr); + } + + jvmtiError SetNativeMethodPrefix(const char* prefix) { + return functions->SetNativeMethodPrefix(this, prefix); + } + + jvmtiError SetNativeMethodPrefixes(jint prefix_count, + char** prefixes) { + return functions->SetNativeMethodPrefixes(this, prefix_count, prefixes); + } + + jvmtiError CreateRawMonitor(const char* name, + jrawMonitorID* monitor_ptr) { + return functions->CreateRawMonitor(this, name, monitor_ptr); + } + + jvmtiError DestroyRawMonitor(jrawMonitorID monitor) { + return functions->DestroyRawMonitor(this, monitor); + } + + jvmtiError RawMonitorEnter(jrawMonitorID monitor) { + return functions->RawMonitorEnter(this, monitor); + } + + jvmtiError RawMonitorExit(jrawMonitorID monitor) { + return functions->RawMonitorExit(this, monitor); + } + + jvmtiError RawMonitorWait(jrawMonitorID monitor, + jlong millis) { + return functions->RawMonitorWait(this, monitor, millis); + } + + jvmtiError RawMonitorNotify(jrawMonitorID monitor) { + return functions->RawMonitorNotify(this, monitor); + } + + jvmtiError RawMonitorNotifyAll(jrawMonitorID monitor) { + return functions->RawMonitorNotifyAll(this, monitor); + } + + jvmtiError SetJNIFunctionTable(const jniNativeInterface* function_table) { + return functions->SetJNIFunctionTable(this, function_table); + } + + jvmtiError GetJNIFunctionTable(jniNativeInterface** function_table) { + return functions->GetJNIFunctionTable(this, function_table); + } + + jvmtiError SetEventCallbacks(const jvmtiEventCallbacks* callbacks, + jint size_of_callbacks) { + return functions->SetEventCallbacks(this, callbacks, size_of_callbacks); + } + + jvmtiError SetEventNotificationMode(jvmtiEventMode mode, + jvmtiEvent event_type, + jthread event_thread, + ...) { + return functions->SetEventNotificationMode(this, mode, event_type, event_thread); + } + + jvmtiError GenerateEvents(jvmtiEvent event_type) { + return functions->GenerateEvents(this, event_type); + } + + jvmtiError GetExtensionFunctions(jint* extension_count_ptr, + jvmtiExtensionFunctionInfo** extensions) { + return functions->GetExtensionFunctions(this, extension_count_ptr, extensions); + } + + jvmtiError GetExtensionEvents(jint* extension_count_ptr, + jvmtiExtensionEventInfo** extensions) { + return functions->GetExtensionEvents(this, extension_count_ptr, extensions); + } + + jvmtiError SetExtensionEventCallback(jint extension_event_index, + jvmtiExtensionEvent callback) { + return functions->SetExtensionEventCallback(this, extension_event_index, callback); + } + + jvmtiError GetPotentialCapabilities(jvmtiCapabilities* capabilities_ptr) { + return functions->GetPotentialCapabilities(this, capabilities_ptr); + } + + jvmtiError AddCapabilities(const jvmtiCapabilities* capabilities_ptr) { + return functions->AddCapabilities(this, capabilities_ptr); + } + + jvmtiError RelinquishCapabilities(const jvmtiCapabilities* capabilities_ptr) { + return functions->RelinquishCapabilities(this, capabilities_ptr); + } + + jvmtiError GetCapabilities(jvmtiCapabilities* capabilities_ptr) { + return functions->GetCapabilities(this, capabilities_ptr); + } + + jvmtiError GetCurrentThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { + return functions->GetCurrentThreadCpuTimerInfo(this, info_ptr); + } + + jvmtiError GetCurrentThreadCpuTime(jlong* nanos_ptr) { + return functions->GetCurrentThreadCpuTime(this, nanos_ptr); + } + + jvmtiError GetThreadCpuTimerInfo(jvmtiTimerInfo* info_ptr) { + return functions->GetThreadCpuTimerInfo(this, info_ptr); + } + + jvmtiError GetThreadCpuTime(jthread thread, + jlong* nanos_ptr) { + return functions->GetThreadCpuTime(this, thread, nanos_ptr); + } + + jvmtiError GetTimerInfo(jvmtiTimerInfo* info_ptr) { + return functions->GetTimerInfo(this, info_ptr); + } + + jvmtiError GetTime(jlong* nanos_ptr) { + return functions->GetTime(this, nanos_ptr); + } + + jvmtiError GetAvailableProcessors(jint* processor_count_ptr) { + return functions->GetAvailableProcessors(this, processor_count_ptr); + } + + jvmtiError AddToBootstrapClassLoaderSearch(const char* segment) { + return functions->AddToBootstrapClassLoaderSearch(this, segment); + } + + jvmtiError AddToSystemClassLoaderSearch(const char* segment) { + return functions->AddToSystemClassLoaderSearch(this, segment); + } + + jvmtiError GetSystemProperties(jint* count_ptr, + char*** property_ptr) { + return functions->GetSystemProperties(this, count_ptr, property_ptr); + } + + jvmtiError GetSystemProperty(const char* property, + char** value_ptr) { + return functions->GetSystemProperty(this, property, value_ptr); + } + + jvmtiError SetSystemProperty(const char* property, + const char* value) { + return functions->SetSystemProperty(this, property, value); + } + + jvmtiError GetPhase(jvmtiPhase* phase_ptr) { + return functions->GetPhase(this, phase_ptr); + } + + jvmtiError DisposeEnvironment() { + return functions->DisposeEnvironment(this); + } + + jvmtiError SetEnvironmentLocalStorage(const void* data) { + return functions->SetEnvironmentLocalStorage(this, data); + } + + jvmtiError GetEnvironmentLocalStorage(void** data_ptr) { + return functions->GetEnvironmentLocalStorage(this, data_ptr); + } + + jvmtiError GetVersionNumber(jint* version_ptr) { + return functions->GetVersionNumber(this, version_ptr); + } + + jvmtiError GetErrorName(jvmtiError error, + char** name_ptr) { + return functions->GetErrorName(this, error, name_ptr); + } + + jvmtiError SetVerboseFlag(jvmtiVerboseFlag flag, + jboolean value) { + return functions->SetVerboseFlag(this, flag, value); + } + + jvmtiError GetJLocationFormat(jvmtiJlocationFormat* format_ptr) { + return functions->GetJLocationFormat(this, format_ptr); + } + +#endif /* __cplusplus */ +}; + + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* !_JAVA_JVMTI_H_ */ + diff --git a/vendor/jdk/1.6.0_23/include/win32/jawt_md.h b/vendor/jdk/1.6.0_23/include/win32/jawt_md.h new file mode 100644 index 0000000..82ba034 --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/win32/jawt_md.h @@ -0,0 +1,41 @@ +/* + * %W% %E% + * + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#ifndef _JAVASOFT_JAWT_MD_H_ +#define _JAVASOFT_JAWT_MD_H_ + +#include +#include "jawt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Win32-specific declarations for AWT native interface. + * See notes in jawt.h for an example of use. + */ +typedef struct jawt_Win32DrawingSurfaceInfo { + /* Native window, DDB, or DIB handle */ + union { + HWND hwnd; + HBITMAP hbitmap; + void* pbits; + }; + /* + * This HDC should always be used instead of the HDC returned from + * BeginPaint() or any calls to GetDC(). + */ + HDC hdc; + HPALETTE hpalette; +} JAWT_Win32DrawingSurfaceInfo; + +#ifdef __cplusplus +} +#endif + +#endif /* !_JAVASOFT_JAWT_MD_H_ */ diff --git a/vendor/jdk/1.6.0_23/include/win32/jni_md.h b/vendor/jdk/1.6.0_23/include/win32/jni_md.h new file mode 100644 index 0000000..9ac4718 --- /dev/null +++ b/vendor/jdk/1.6.0_23/include/win32/jni_md.h @@ -0,0 +1,19 @@ +/* + * %W% %E% + * + * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +#ifndef _JAVASOFT_JNI_MD_H_ +#define _JAVASOFT_JNI_MD_H_ + +#define JNIEXPORT __declspec(dllexport) +#define JNIIMPORT __declspec(dllimport) +#define JNICALL __stdcall + +typedef long jint; +typedef __int64 jlong; +typedef signed char jbyte; + +#endif /* !_JAVASOFT_JNI_MD_H_ */ diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitype.cpp b/vendor/jintellitype/1.3.6/cpp/JIntellitype.cpp new file mode 100644 index 0000000..9de9b61 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitype.cpp @@ -0,0 +1,157 @@ +/* + JIntellitype (http://www.melloware.com/) + Java JNI API for Windows Intellitype commands and global keystrokes. + + Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Compiled with Mingw port of GCC, + Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) +*/ +#include "stdafx.h" +#include "com_melloware_jintellitype_JIntellitype.h" +#include "JIntellitypeHandler.h" + +HINSTANCE g_instance = NULL; + + +BOOL WINAPI DllMain +( + HINSTANCE hinstDLL, // handle to DLL module + DWORD fdwReason, // reason for calling function + LPVOID lpvReserved // reserved +) +{ + switch( fdwReason ) + { + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + + case DLL_PROCESS_ATTACH: + g_instance = hinstDLL; + + break; + } + return TRUE; +} + + +extern "C" +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: initializeLibrary + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_initializeLibrary + (JNIEnv *env, jobject object) +{ + // Get handler + JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); + + // Create our handler + l_handler = new JIntellitypeHandler( env, object ); + + // Enable it + if( l_handler ) + l_handler->initialize(env, g_instance); +} + +extern "C" +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: regHotKey + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_regHotKey + (JNIEnv *env, jobject object, jint identifier, jint modifier, jint keycode) +{ + // Get handler + JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); + + if( l_handler ) + { + l_handler->regHotKey(identifier, modifier, keycode); + } + else + { + // throw exception + jclass JIntellitypeException = env->FindClass("com/melloware/jintellitype/JIntellitypeException"); + env->ThrowNew(JIntellitypeException,"JIntellitype was not initialized properly."); + } +} + +extern "C" +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: unregHotKey + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_unregHotKey + (JNIEnv *env, jobject object, jint identifier) +{ + // Get handler + JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); + + if( l_handler ) + { + l_handler->unregHotKey(identifier); + } + else + { + // throw exception + jclass JIntellitypeException = env->FindClass("com/melloware/jintellitype/JIntellitypeException"); + env->ThrowNew(JIntellitypeException,"JIntellitype was not initialized properly."); + } + +} + +extern "C" +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: terminate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_terminate + (JNIEnv *env, jobject object) +{ + // Get handler + JIntellitypeHandler *l_handler = JIntellitypeHandler::extract( env, object ); + + // Clean up all resources allocated by this API + if( l_handler ) + l_handler->terminate(); + +} + +extern "C" +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: isRunning + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_com_melloware_jintellitype_JIntellitype_isRunning + (JNIEnv *env, jclass, jstring wndName) +{ + // App name for the hidden window's registered class + CHAR szAppName[] = "SunAwtFrame"; + const char *cWndName = env->GetStringUTFChars(wndName, 0); + // Find out if there's a hidden window with the given title + HWND mHwnd = FindWindow(szAppName, cWndName); + env->ReleaseStringUTFChars(wndName, cWndName); + // If there is, another instance of our app is already running + return mHwnd != NULL; +} + diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitype.dev b/vendor/jintellitype/1.3.6/cpp/JIntellitype.dev new file mode 100644 index 0000000..7de6bd8 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitype.dev @@ -0,0 +1,149 @@ +[Project] +FileName=JIntellitype.dev +Name=JIntellitype +Ver=1 +IsCpp=1 +Type=3 +Compiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DBUILDING_DLL=1_@@_ +CppCompiler=-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL_@@_ +Includes=c:\java\jdk1.2.2\include;c:\java\jdk1.2.2\include\win32 +Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 --no-export-all-symbols --add-stdcall-alias_@@_ +Libs= +UnitCount=8 +Folders="Header Files","Resource Files","Source Files" +ObjFiles= +PrivateResource=JIntellitype_private.rc +ResourceIncludes= +MakeIncludes= +Icon= +ExeOutput=..\..\..\..\jintellitype +ObjectOutput=..\..\..\target +OverrideOutput=0 +OverrideOutputName=JIntellitype.dll +HostApplication= +CommandLine= +UseCustomMakefile=0 +CustomMakefile= +IncludeVersionInfo=1 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000001001000000100 + +[Unit1] +FileName=JIntellitypeThread.cpp +Folder="Source Files" +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit2] +FileName=JIntellitype.cpp +Folder="Source Files" +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit3] +FileName=JIntellitypeHandler.cpp +Folder="Source Files" +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit5] +FileName=JIntellitypeHandler.h +Folder="Header Files" +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit7] +FileName=StdAfx.h +Folder="Header Files" +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit8] +FileName=com_melloware_jintellitype_JIntellitype.h +Folder=Header Files +Compile=1 +CompileCpp=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=1 +Minor=0 +Release=0 +Build=465 +LanguageID=1033 +CharsetID=1252 +CompanyName=Melloware Inc (www.melloware.com) +FileVersion=1.0 +FileDescription=Java JNI bridge to MS Intellitype commands +InternalName= +LegalCopyright=Copyright 2006 Melloware Inc +LegalTrademarks=Copyright 2006 Melloware Inc +OriginalFilename= +ProductName=JIntellitype +ProductVersion=1.0 +AutoIncBuildNr=1 + +[Unit11] +FileName=com_melloware_jintellitype_JIntellitype.h +CompileCpp=1 +Folder=Header Files +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit10] +FileName=com_melloware_jintellitype_JIntellitype.h +CompileCpp=1 +Folder=Header Files +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit4] +FileName=StdAfx.cpp +CompileCpp=1 +Folder="Source Files" +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[Unit6] +FileName=JIntellitypeThread.h +CompileCpp=1 +Folder="Header Files" +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitype.layout b/vendor/jintellitype/1.3.6/cpp/JIntellitype.layout new file mode 100644 index 0000000..e77247b --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitype.layout @@ -0,0 +1,76 @@ +[Editor_9] +CursorCol=1 +CursorRow=20 +TopLine=1 +LeftChar=1 +Open=0 +Top=0 +[Editors] +Focused=2 +Order=1,2,0,7,4 +[Editor_0] +Open=1 +Top=0 +CursorCol=5 +CursorRow=118 +TopLine=71 +LeftChar=1 +[Editor_1] +Open=1 +Top=0 +CursorCol=36 +CursorRow=149 +TopLine=75 +LeftChar=1 +[Editor_2] +Open=1 +Top=1 +CursorCol=14 +CursorRow=209 +TopLine=162 +LeftChar=1 +[Editor_3] +Open=0 +Top=0 +CursorCol=23 +CursorRow=3 +TopLine=1 +LeftChar=1 +[Editor_4] +Open=1 +Top=0 +CursorCol=1 +CursorRow=27 +TopLine=1 +LeftChar=1 +[Editor_5] +Open=0 +Top=0 +CursorCol=3 +CursorRow=24 +TopLine=11 +LeftChar=1 +[Editor_6] +Open=0 +Top=0 +CursorCol=1 +CursorRow=16 +TopLine=1 +LeftChar=1 +[Editor_7] +Open=1 +Top=0 +CursorCol=54 +CursorRow=35 +TopLine=3 +LeftChar=1 +[Editor_8] +Open=0 +Top=0 +CursorCol=1 +CursorRow=3 +TopLine=1 +LeftChar=1 +[Editor_10] +Open=0 +Top=0 diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.cpp b/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.cpp new file mode 100644 index 0000000..10fe844 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.cpp @@ -0,0 +1,279 @@ +/* + JIntellitype (http://www.melloware.com/) + Java JNI API for Windows Intellitype commands and global keystrokes. + + Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Compiled with Mingw port of GCC, + Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) +*/ +#include "stdafx.h" +#include "JIntellitypeHandler.h" +#include "JIntellitypeThread.h" +#include + + +UINT WM_SHELLHOOK = 0; + +/* + * Extract the unique handlerID from the java object + */ +JIntellitypeHandler *JIntellitypeHandler::extract( JNIEnv *env, jobject object ) +{ + // Get field ID + jfieldID l_handlerId = env->GetFieldID( env->GetObjectClass( object ), "handler", "I" ); + + // Get field + JIntellitypeHandler *l_handler = (JIntellitypeHandler *) env->GetIntField( object, l_handlerId ); + + return l_handler; +} + +/* + * Constructor + */ +JIntellitypeHandler::JIntellitypeHandler( JNIEnv *env, jobject object ) +{ + m_window = NULL; + + // Reference object + m_object = env->NewGlobalRef(object ); + + // Get method IDs + m_fireHotKey = env->GetMethodID( env->GetObjectClass( m_object ) , "onHotKey", "(I)V" ); + m_fireIntellitype = env->GetMethodID( env->GetObjectClass( m_object ) , "onIntellitype", "(I)V" ); + + // Get field ID + jfieldID l_handlerId = env->GetFieldID( env->GetObjectClass( m_object ) , "handler", "I" ); + + // Set field + env->SetIntField( m_object, l_handlerId, (jint) this ); +} + +/* + * Destructor + */ +JIntellitypeHandler::~JIntellitypeHandler() +{ + // Get field ID + jfieldID l_handlerId = g_JIntellitypeThread.m_env->GetFieldID( g_JIntellitypeThread.m_env->GetObjectClass( m_object ), "handler", "I" ); + + // Set field + g_JIntellitypeThread.m_env->SetIntField( m_object, l_handlerId, 0 ); + + // Release our reference + g_JIntellitypeThread.m_env->DeleteGlobalRef( m_object ); + + // unregister the shell hook + DeregisterShellHookWindow( m_window ); + + // Destroy window + DestroyWindow( m_window ); +} + + +/* + * Perform initialization of the object and thread. + */ +void JIntellitypeHandler::initialize( JNIEnv *env, HINSTANCE instance ) +{ + m_instance = instance; + g_JIntellitypeThread.MakeSureThreadIsUp( env ); + while( !PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, INITIALIZE_CODE, (LPARAM) this ) ) + Sleep( 0 ); +} + +/* + * Callback method that creates the hidden window on initialization to receive + * any WM_HOTKEY messages and process them. + */ +void JIntellitypeHandler::doInitialize() +{ + // Register window class + WNDCLASSEX l_Class; + l_Class.cbSize = sizeof( l_Class ); + l_Class.style = CS_HREDRAW | CS_VREDRAW; + l_Class.lpszClassName = TEXT( "JIntellitypeHandlerClass" ); + l_Class.lpfnWndProc = WndProc; + l_Class.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); + l_Class.hCursor = NULL; + l_Class.hIcon = NULL; + l_Class.hIconSm = NULL; + l_Class.lpszMenuName = NULL; + l_Class.cbClsExtra = 0; + l_Class.cbWndExtra = 0; + l_Class.hInstance = m_instance; + + if( !RegisterClassEx( &l_Class ) ) + return; + + // Create window + m_window = CreateWindow + ( + TEXT( "JIntellitypeHandlerClass" ), + TEXT( "JIntellitypeHandler" ), + WS_OVERLAPPEDWINDOW, + 0, 0, 0, 0, + NULL, + NULL, + m_instance, + NULL + ); + + if( !m_window ) + return; + + //Set pointer to this object inside the Window's USERDATA section + SetWindowLong( m_window, GWL_USERDATA, (LONG) this ); + + // hide the window + ShowWindow(m_window, SW_HIDE); + UpdateWindow(m_window); + + //register this window as a shell hook to intercept WM_APPCOMMAND messages + WM_SHELLHOOK = RegisterWindowMessage(TEXT("SHELLHOOK")); + BOOL (__stdcall *RegisterShellHookWindow)(HWND) = NULL; + RegisterShellHookWindow = (BOOL (__stdcall *)(HWND))GetProcAddress(GetModuleHandle("USER32.DLL"), "RegisterShellHookWindow"); + + //make sure it worked + if (!RegisterShellHookWindow(m_window)) { + // throw exception + jclass JIntellitypeException = g_JIntellitypeThread.m_env->FindClass("com/melloware/jintellitype/JIntellitypeException"); + g_JIntellitypeThread.m_env->ThrowNew(JIntellitypeException,"Could not register window as a shell hook window."); + } +} + +/* + * Registers a hotkey. + * identifier - unique identifier assigned to this key comination + * modifier - ALT, SHIFT, CTRL, WIN or combination of + * keycode- Ascii keycode, 65 for A, 66 for B etc + */ +void JIntellitypeHandler::regHotKey( jint identifier, jint modifier, jint keycode ) +{ + JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) malloc(sizeof(JIntellitypeHandlerCallback)); + callback->identifier = identifier; + callback->modifier = modifier; + callback->keycode = keycode; + callback->handler = this; + PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, REGISTER_HOTKEY_CODE, (LPARAM) callback ); +} + +/* + * Actually registers the hotkey using the Win32API RegisterHotKey call. + */ +void JIntellitypeHandler::doRegHotKey(LPARAM callback_) +{ + JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) callback_; + RegisterHotKey(m_window, callback->identifier, callback->modifier, callback->keycode); + free(callback); +} + +/* + * Unregisters a previously assigned hotkey. + * identifier - unique identifier assigned to this key comination + */ +void JIntellitypeHandler::unregHotKey( jint identifier ) +{ + JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) malloc(sizeof(JIntellitypeHandlerCallback)); + callback->identifier = identifier; + callback->handler = this; + PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, UNREGISTER_HOTKEY_CODE, (LPARAM) callback ); +} + +/* + * Actually unregisters the hotkey using the Win32API UnregisterHotKey call. + */ +void JIntellitypeHandler::doUnregisterHotKey(LPARAM callback_) +{ + JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) callback_; + UnregisterHotKey(m_window, callback->identifier); + free(callback); +} + +/* + * When an intellitype command is recieved by the JFrame this method is called + * to perform a callback to the Intellitype java listeners. + * commandId - the unique command Id from the WM_APPCOMMAND listings + */ +void JIntellitypeHandler::intellitype( jint commandId ) +{ + JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) malloc(sizeof(JIntellitypeHandlerCallback)); + callback->command = commandId; + callback->handler = this; + PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, INTELLITYPE_CODE, (LPARAM) callback ); +} + +/* + * Call the correct JVM with the intellitype command for the listeners listening. + */ +void JIntellitypeHandler::doIntellitype(LPARAM callback_) +{ + JIntellitypeHandlerCallback *callback = (JIntellitypeHandlerCallback*) callback_; + g_JIntellitypeThread.m_env->CallVoidMethod(m_object, m_fireIntellitype, callback->command); + free(callback); +} + +/* + * Cleans up resources allocated by JIntellitype. + */ +void JIntellitypeHandler::terminate() +{ + PostThreadMessage( g_JIntellitypeThread, WM_JINTELLITYPE, TERMINATE_CODE, (LPARAM) this ); +} + +/* + * Callback method to send hotkey to the Java HotKeyListeners registered. + */ +void JIntellitypeHandler::fireHotKey(jint hotkeyId) +{ + g_JIntellitypeThread.m_env->CallVoidMethod(m_object, m_fireHotKey, hotkeyId); +} + + +/* + * WndProc method registered to the hidden window to listen for WM_HOTKEY + * messages and send them back to the Java listeners. + */ +LRESULT CALLBACK JIntellitypeHandler::WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam ) +{ + + // check for Intellitype messages and if found send them to Intellitype listeners + if (uMessage == WM_SHELLHOOK) { + if (wParam == HSHELL_APPCOMMAND) { + jint cmd = GET_APPCOMMAND_LPARAM(lParam); + JIntellitypeHandler *l_this = (JIntellitypeHandler *) GetWindowLong( hWnd, GWL_USERDATA ); + l_this->intellitype(cmd); + } + return TRUE; + } + + // check for registered hotkey messages and send them to HotKeyListeners + switch( uMessage ) { + case WM_HOTKEY: { + JIntellitypeHandler *l_this = (JIntellitypeHandler *) GetWindowLong( hWnd, GWL_USERDATA ); + l_this->fireHotKey(wParam); + return TRUE; + break; + } + default: + return DefWindowProc( hWnd, uMessage, wParam, lParam ); + } + +} + + + diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.h b/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.h new file mode 100644 index 0000000..4806ef7 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.h @@ -0,0 +1,93 @@ +/* + JIntellitype (http://www.melloware.com/) + Java JNI API for Windows Intellitype commands and global keystrokes. + + Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Compiled with Mingw port of GCC, + Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) +*/ +#ifndef __JIntellitypeHandler_h__ +#define __JIntellitypeHandler_h__ + +#include "JIntellitypeThread.h" + +class JIntellitypeHandler +{ + friend DWORD WINAPI JIntellitypeThread::ThreadProc( LPVOID lpParameter ); + +public: + + static JIntellitypeHandler *extract( JNIEnv *env, jobject object ); + + JIntellitypeHandler( JNIEnv *env, jobject object ); + + void initialize( JNIEnv *env, HINSTANCE instance ); + void regHotKey( jint identifier, jint modifier, jint keycode ); + void unregHotKey( jint identifier ); + void intellitype( jint commandId ); + void terminate(); + +private: + + enum + { + INITIALIZE_CODE = 1, + REGISTER_HOTKEY_CODE = 2, + UNREGISTER_HOTKEY_CODE = 3, + TERMINATE_CODE = 4, + INTELLITYPE_CODE = 5 + }; + + ~JIntellitypeHandler(); + + void createHiddenWindow(); + void doInitialize(); + void doRegHotKey(LPARAM callback); + void doUnregisterHotKey(LPARAM callback); + void doIntellitype(LPARAM callback); + void fireHotKey(jint hotkeyId); + void fireIntellitype(jint commandId); + + HINSTANCE m_instance; + HWND m_window; + jobject m_object; + jmethodID m_fireHotKey; + jmethodID m_fireIntellitype; + + static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam ); + static DWORD WINAPI ThreadProc( LPVOID lpParameter ); +}; + +typedef struct { + JIntellitypeHandler *handler; + jint identifier; + jint modifier; + jint keycode; + jint command; +} JIntellitypeHandlerCallback; + + +#ifndef WM_APPCOMMAND +#define WM_APPCOMMAND 0x319 +#define FAPPCOMMAND_MASK 0x8000 +#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK)) +#define HSHELL_APPCOMMAND 12 + +#endif + + +#endif diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.cpp b/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.cpp new file mode 100644 index 0000000..10ff4da --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.cpp @@ -0,0 +1,133 @@ +/* + JIntellitype (http://www.melloware.com/) + Java JNI API for Windows Intellitype commands and global keystrokes. + + Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Compiled with Mingw port of GCC, + Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) +*/ +#include "stdafx.h" +#include "JIntellitypeThread.h" +#include "JIntellitypeHandler.h" + +JIntellitypeThread g_JIntellitypeThread; + + +JIntellitypeThread::JIntellitypeThread() +{ + m_env = NULL; + m_thread = 0; + m_vm = NULL; + m_handlerCount = 0; +} + + +void JIntellitypeThread::MakeSureThreadIsUp( JNIEnv *env ) +{ + if( !m_thread ) + { + // Get VM + env->GetJavaVM( &m_vm ); + + // Start "native" thread + CreateThread + ( + NULL, + 0, + ThreadProc, + this, + 0, + &m_thread + ); + } +} + + +JIntellitypeThread::operator DWORD () +{ + return m_thread; +} + + +DWORD WINAPI JIntellitypeThread::ThreadProc( LPVOID lpParameter ) +{ + JIntellitypeThread *l_this = (JIntellitypeThread *) lpParameter; + + // Attach the thread to the VM + l_this->m_vm->AttachCurrentThread( (void**) &l_this->m_env, NULL ); + + MSG msg; + while( GetMessage( &msg, NULL, 0, 0 ) ) + { + if( msg.message == WM_JINTELLITYPE ) + { + // Extract handler + JIntellitypeHandler *l_handler; + + switch( msg.wParam ) + { + case JIntellitypeHandler::INITIALIZE_CODE: + l_handler = (JIntellitypeHandler*) msg.lParam; + l_this->m_handlerCount++; + l_handler->doInitialize(); + break; + case JIntellitypeHandler::REGISTER_HOTKEY_CODE: + l_handler = ((JIntellitypeHandlerCallback*) msg.lParam)->handler; + l_handler->doRegHotKey(msg.lParam); + break; + + case JIntellitypeHandler::UNREGISTER_HOTKEY_CODE: + l_handler = ((JIntellitypeHandlerCallback*) msg.lParam)->handler; + l_handler->doUnregisterHotKey(msg.lParam); + break; + case JIntellitypeHandler::INTELLITYPE_CODE: + l_handler = ((JIntellitypeHandlerCallback*) msg.lParam)->handler; + l_handler->doIntellitype(msg.lParam); + break; + + case JIntellitypeHandler::TERMINATE_CODE: + l_handler = (JIntellitypeHandler*) msg.lParam; + + // Destroy it! + delete l_handler; + + // No more handlers? + if( !--l_this->m_handlerCount ) + { + l_this->m_thread = 0; + + // Detach thread from VM + l_this->m_vm->DetachCurrentThread(); + + // Time to die + ExitThread( 0 ); + } + break; + } + } + else + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + } + + // Detach thread from VM + l_this->m_vm->DetachCurrentThread(); + + return 0; +} diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.h b/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.h new file mode 100644 index 0000000..e4a0048 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.h @@ -0,0 +1,55 @@ +/* + JIntellitype (http://www.melloware.com/) + Java JNI API for Windows Intellitype commands and global keystrokes. + + Copyright (C) 1999, 2008 Emil A. Lefkof III, info@melloware.com + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + Compiled with Mingw port of GCC, + Bloodshed Dev-C++ IDE (http://www.bloodshed.net/devcpp.html) +*/ +#ifndef __JIntellitypeThread_h__ +#define __JIntellitypeThread_h__ + + +class JIntellitypeThread +{ +public: + + JIntellitypeThread(); + + void MakeSureThreadIsUp( JNIEnv *env ); + + JNIEnv *m_env; + static DWORD WINAPI ThreadProc( LPVOID lpParameter ); + + operator DWORD (); + +private: + + DWORD m_thread; + JavaVM *m_vm; + int m_handlerCount; + + +}; + +extern JIntellitypeThread g_JIntellitypeThread; + + +#define WM_JINTELLITYPE (WM_USER+1) + + +#endif diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.h b/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.h new file mode 100644 index 0000000..688740c --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.h @@ -0,0 +1,23 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT ! */ + +#ifndef JINTELLITYPE_PRIVATE_H +#define JINTELLITYPE_PRIVATE_H + +/* VERSION DEFINITIONS */ +#define VER_STRING "1.0.0.465" +#define VER_MAJOR 1 +#define VER_MINOR 0 +#define VER_RELEASE 0 +#define VER_BUILD 465 +#define COMPANY_NAME "Melloware Inc (www.melloware.com)" +#define FILE_VERSION "1.0" +#define FILE_DESCRIPTION "Java JNI bridge to MS Intellitype commands" +#define INTERNAL_NAME "" +#define LEGAL_COPYRIGHT "Copyright 2006 Melloware Inc" +#define LEGAL_TRADEMARKS "Copyright 2006 Melloware Inc" +#define ORIGINAL_FILENAME "" +#define PRODUCT_NAME "JIntellitype" +#define PRODUCT_VERSION "1.0" + +#endif /*JINTELLITYPE_PRIVATE_H*/ diff --git a/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.rc b/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.rc new file mode 100644 index 0000000..804ed7d --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.rc @@ -0,0 +1,35 @@ +/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */ +/* DO NOT EDIT! */ + +#include // include for version info constants + + +// +// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS... +// +1 VERSIONINFO +FILEVERSION 1,0,0,465 +PRODUCTVERSION 1,0,0,465 +FILETYPE VFT_DLL +{ + BLOCK "StringFileInfo" + { + BLOCK "040904E4" + { + VALUE "CompanyName", "Melloware Inc (www.melloware.com)" + VALUE "FileVersion", "1.0" + VALUE "FileDescription", "Java JNI bridge to MS Intellitype commands" + VALUE "InternalName", "" + VALUE "LegalCopyright", "Copyright 2006 Melloware Inc" + VALUE "LegalTrademarks", "Copyright 2006 Melloware Inc" + VALUE "OriginalFilename", "" + VALUE "ProductName", "JIntellitype" + VALUE "ProductVersion", "1.0" + } + } + BLOCK "VarFileInfo" + { + VALUE "Translation", 0x0409, 1252 + } +} + diff --git a/vendor/jintellitype/1.3.6/cpp/Makefile.win b/vendor/jintellitype/1.3.6/cpp/Makefile.win new file mode 100644 index 0000000..3891470 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/Makefile.win @@ -0,0 +1,46 @@ +# Project: JIntellitype +# Makefile created by Dev-C++ 4.9.9.2 + +CPP = g++.exe +CC = gcc.exe +WINDRES = windres.exe +RES = ../../../target/JIntellitype_private.res +OBJ = ../../../target/JIntellitypeThread.o ../../../target/JIntellitype.o ../../../target/JIntellitypeHandler.o ../../../target/StdAfx.o $(RES) +LINKOBJ = ../../../target/JIntellitypeThread.o ../../../target/JIntellitype.o ../../../target/JIntellitypeHandler.o ../../../target/StdAfx.o $(RES) +LIBS = -L"C:/Dev-Cpp/lib" -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 --no-export-all-symbols --add-stdcall-alias -s +INCS = -I"C:/Dev-Cpp/include" +CXXINCS = -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include" +BIN = ../../../../jintellitype/JIntellitype.dll +CXXFLAGS = $(CXXINCS) -D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -fexpensive-optimizations -O3 +CFLAGS = $(INCS) -D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DBUILDING_DLL=1 -fexpensive-optimizations -O3 +RM = rm -f + +.PHONY: all all-before all-after clean clean-custom + +all: all-before ../../../../jintellitype/JIntellitype.dll all-after + + +clean: clean-custom + ${RM} $(OBJ) $(BIN) + +DLLWRAP=dllwrap.exe +DEFFILE=../../../../jintellitype/libJIntellitype.def +STATICLIB=../../../../jintellitype/libJIntellitype.a + +$(BIN): $(LINKOBJ) + $(DLLWRAP) --output-def $(DEFFILE) --driver-name c++ --implib $(STATICLIB) $(LINKOBJ) $(LIBS) -o $(BIN) + +../../../target/JIntellitypeThread.o: JIntellitypeThread.cpp + $(CPP) -c JIntellitypeThread.cpp -o ../../../target/JIntellitypeThread.o $(CXXFLAGS) + +../../../target/JIntellitype.o: JIntellitype.cpp + $(CPP) -c JIntellitype.cpp -o ../../../target/JIntellitype.o $(CXXFLAGS) + +../../../target/JIntellitypeHandler.o: JIntellitypeHandler.cpp + $(CPP) -c JIntellitypeHandler.cpp -o ../../../target/JIntellitypeHandler.o $(CXXFLAGS) + +../../../target/StdAfx.o: StdAfx.cpp + $(CPP) -c StdAfx.cpp -o ../../../target/StdAfx.o $(CXXFLAGS) + +../../../target/JIntellitype_private.res: JIntellitype_private.rc + $(WINDRES) -i JIntellitype_private.rc --input-format=rc -o ../../../target/JIntellitype_private.res -O coff diff --git a/vendor/jintellitype/1.3.6/cpp/StdAfx.cpp b/vendor/jintellitype/1.3.6/cpp/StdAfx.cpp new file mode 100644 index 0000000..04dfff1 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/StdAfx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// win32.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/vendor/jintellitype/1.3.6/cpp/StdAfx.h b/vendor/jintellitype/1.3.6/cpp/StdAfx.h new file mode 100644 index 0000000..5a1e4d6 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/StdAfx.h @@ -0,0 +1,24 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__1F571525_24C2_11D3_B0CF_0000E85D9A83__INCLUDED_) +#define AFX_STDAFX_H__1F571525_24C2_11D3_B0CF_0000E85D9A83__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +// Insert your headers here +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include +#include + +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__1F571525_24C2_11D3_B0CF_0000E85D9A83__INCLUDED_) diff --git a/vendor/jintellitype/1.3.6/cpp/com_melloware_jintellitype_JIntellitype.h b/vendor/jintellitype/1.3.6/cpp/com_melloware_jintellitype_JIntellitype.h new file mode 100644 index 0000000..602d053 --- /dev/null +++ b/vendor/jintellitype/1.3.6/cpp/com_melloware_jintellitype_JIntellitype.h @@ -0,0 +1,53 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_melloware_jintellitype_JIntellitype */ + +#ifndef _Included_com_melloware_jintellitype_JIntellitype +#define _Included_com_melloware_jintellitype_JIntellitype +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: initializeLibrary + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_initializeLibrary + (JNIEnv *, jobject); + +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: regHotKey + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_regHotKey + (JNIEnv *, jobject, jint, jint, jint); + +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: terminate + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_terminate + (JNIEnv *, jobject); + +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: unregHotKey + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_melloware_jintellitype_JIntellitype_unregHotKey + (JNIEnv *, jobject, jint); + +/* + * Class: com_melloware_jintellitype_JIntellitype + * Method: isRunning + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_com_melloware_jintellitype_JIntellitype_isRunning + (JNIEnv *, jclass, jstring); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/HotkeyListener.java b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/HotkeyListener.java new file mode 100644 index 0000000..4c44a72 --- /dev/null +++ b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/HotkeyListener.java @@ -0,0 +1,46 @@ +/** + * JIntellitype + * ----------------- + * Copyright 2005-2008 Emil A. Lefkof III, Melloware Inc. + * + * I always give it my best shot to make a program useful and solid, but + * remeber that there is absolutely no warranty for using this program as + * stated in the following terms: + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.melloware.jintellitype; + + +/** + * Listener interface for Windows Hotkey events registered using the + * Windows API call RegisterHotKey to globally listen for a key combination + * regardless if your application has focus or not. + *

    + * Copyright (c) 1999-2008 + * Melloware, Inc. + * @author Emil A. Lefkof III + * @version 1.3.1 + * + * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/registerhotkey.asp + */ +public interface HotkeyListener +{ + /** + * Event fired when a WM_HOTKEY message is received that was initiated + * by this application. + *

    + * @param identifier the unique Identifer the Hotkey was assigned + */ + void onHotKey( int identifier ); +} \ No newline at end of file diff --git a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/IntellitypeListener.java b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/IntellitypeListener.java new file mode 100644 index 0000000..a9d5aa8 --- /dev/null +++ b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/IntellitypeListener.java @@ -0,0 +1,51 @@ +/** + * JIntellitype + * ----------------- + * Copyright 2005-2008 Emil A. Lefkof III, Melloware Inc. + * + * I always give it my best shot to make a program useful and solid, but + * remeber that there is absolutely no warranty for using this program as + * stated in the following terms: + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.melloware.jintellitype; + + +/** + * Listener interface for Windows Intellitype events. Intellitype are Windows + * App Commands that are specialand were introduced with Microsoft Keyboards + * that had special keys for Play, Pause, Stop, Next etc for controlling + * Media applications like Windows Media Player, Itunes, and Winamp. + *

    + * If you have ever wanted your Swing/SWT application to respond to these global + * events you now can with JIntellitype. Just implement this interface and + * you can now take action when those special Media keys are pressed. + *

    + * Copyright (c) 1999-2008 + * Melloware, Inc. + * @author Emil A. Lefkof III + * @version 1.3.1 + * + * @see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_appcommand.asp + */ +public interface IntellitypeListener +{ + /** + * Event fired when a WM_APPCOMMAND message is received that was initiated + * by this application. + *

    + * @param command the WM_APPCOMMAND that was pressed + */ + void onIntellitype( int command ); +} \ No newline at end of file diff --git a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitype.java b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitype.java new file mode 100644 index 0000000..7f734d6 --- /dev/null +++ b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitype.java @@ -0,0 +1,665 @@ +/** + * JIntellitype ----------------- Copyright 2005-2008 Emil A. Lefkof III, + * Melloware Inc. I always give it my best shot to make a program useful and + * solid, but remeber that there is absolutely no warranty for using this + * program as stated in the following terms: Licensed under the Apache License, + * Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law + * or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package com.melloware.jintellitype; + +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +import javax.swing.SwingUtilities; + +/** + * JIntellitype A Java Implementation for using the Windows API Intellitype + * commands and the RegisterHotKey and UnRegisterHotkey API calls for globally + * responding to key events. Intellitype are commands that are using for Play, + * Stop, Next on Media keyboards or some laptops that have those special keys. + *

    + * JIntellitype class that is used to call Windows API calls using the + * JIntellitype.dll. + *

    + * This file comes with native code in JINTELLITYPE.DLL The DLL should go in + * C:/WINDOWS/SYSTEM or in your current directory + *

    + *

    + * Copyright (c) 1999-2008 Melloware, Inc. + * @author Emil A. Lefkof III + * @version 1.3.1 + */ +public final class JIntellitype implements JIntellitypeConstants { + + /** + * Static variable to hold singleton. + */ + private static JIntellitype jintellitype = null; + + /** + * Static variable for double checked thread safety. + */ + private static boolean isInitialized = false; + + /** + * Static variable to hold the libary location if set + */ + private static String libraryLocation = null; + + /** + * Listeners collection for Hotkey events + */ + private final List hotkeyListeners = Collections + .synchronizedList(new CopyOnWriteArrayList()); + + /** + * Listeners collection for Hotkey events + */ + private final List intellitypeListeners = Collections + .synchronizedList(new CopyOnWriteArrayList()); + + /** + * Handler is used by JNI code to keep different JVM instances separate + */ + @SuppressWarnings("unused") + private final int handler = 0; + + /** + * Map containing key->keycode mapping + * @see #registerHotKey(int, String) + * @see #getKey2KeycodeMapping() + */ + private final HashMap keycodeMap; + + /** + * Private Constructor to prevent instantiation. Initialize the library for + * calling. + */ + private JIntellitype() { + try { + // Load JNI library + System.loadLibrary("JIntellitype"); + } catch (Throwable ex) { + try { + if (getLibraryLocation() != null) { + System.load(getLibraryLocation()); + } else { + String jarPath = "com/melloware/jintellitype/"; + String tmpDir = System.getProperty("java.io.tmpdir"); + try { + String dll = "JIntellitype.dll"; + fromJarToFs(jarPath + dll, tmpDir + dll); + System.load(tmpDir + dll); + } catch (UnsatisfiedLinkError e) { + String dll = "JIntellitype64.dll"; + fromJarToFs(jarPath + dll, tmpDir + dll); + System.load(tmpDir + dll); + } + } + } catch (Throwable ex2) { + throw new JIntellitypeException( + "Could not load JIntellitype.dll from local file system or from inside JAR", ex2); + } + } + + initializeLibrary(); + this.keycodeMap = getKey2KeycodeMapping(); + } + + /** + * Pulls a file out of the JAR and puts it on the File Path. + *

    + * @param jarPath the path to the JAR + * @param filePath the file path to extract to + * @throws IOException if any IO error occurs + */ + private void fromJarToFs(String jarPath, String filePath) throws IOException { + File file = new File(filePath); + if (file.exists()) { + boolean success = file.delete(); + if (!success) { + throw new IOException("couldn't delete " + filePath); + } + } + InputStream is = null; + OutputStream os = null; + try { + is = ClassLoader.getSystemClassLoader().getResourceAsStream(jarPath); + os = new FileOutputStream(filePath); + byte[] buffer = new byte[8192]; + int bytesRead; + while ((bytesRead = is.read(buffer)) != -1) { + os.write(buffer, 0, bytesRead); + } + } finally { + if (is != null) { + is.close(); + } + if (os != null) { + os.close(); + } + } + } + + /** + * Gets the singleton instance of the JIntellitype object. + *

    + * But the possibility of creation of more instance is only before the + * instance is created. Since all code defined inside getInstance method is + * in the synchronized block, even the subsequent requests will also come and + * wait in the synchronized block. This is a performance issue. The same can + * be solved using double-checked lock. Following is the implementation of + * Singleton with lazy initialization and double-checked lock. + *

    + * @return an instance of JIntellitype class + */ + public static JIntellitype getInstance() { + if (!isInitialized) { + synchronized (JIntellitype.class) { + if (!isInitialized) { + jintellitype = new JIntellitype(); + isInitialized = true; + } + } + } + return jintellitype; + } + + /** + * Adds a listener for hotkeys. + *

    + * @param listener the HotKeyListener to be added + */ + public void addHotKeyListener(HotkeyListener listener) { + hotkeyListeners.add(listener); + } + + /** + * Adds a listener for intellitype commands. + *

    + * @param listener the IntellitypeListener to be added + */ + public void addIntellitypeListener(IntellitypeListener listener) { + intellitypeListeners.add(listener); + } + + /** + * Cleans up all resources used by JIntellitype. + */ + public void cleanUp() { + try { + terminate(); + } catch (UnsatisfiedLinkError ex) { + throw new JIntellitypeException(ERROR_MESSAGE, ex); + } catch (RuntimeException ex) { + throw new JIntellitypeException(ex); + } + } + + /** + * Registers a Hotkey with windows. This combination will be responded to by + * all registered HotKeyListeners. Uses the JIntellitypeConstants for MOD, + * ALT, CTRL, and WINDOWS keys. + *

    + * @param identifier a unique identifier for this key combination + * @param modifier MOD_SHIFT, MOD_ALT, MOD_CONTROL, MOD_WIN from + * JIntellitypeConstants, or 0 if no modifier needed + * @param keycode the key to respond to in Ascii integer, 65 for A + */ + public void registerHotKey(int identifier, int modifier, int keycode) { + try { + int modifiers = swingToIntelliType(modifier); + if (modifiers == 0) { + modifiers = modifier; + } + regHotKey(identifier, modifier, keycode); + } catch (UnsatisfiedLinkError ex) { + throw new JIntellitypeException(ERROR_MESSAGE, ex); + } catch (RuntimeException ex) { + throw new JIntellitypeException(ex); + } + } + + /** + * Registers a Hotkey with windows. This combination will be responded to by + * all registered HotKeyListeners. Use the Swing InputEvent constants from + * java.awt.InputEvent. + *

    + * @param identifier a unique identifier for this key combination + * @param modifier InputEvent.SHIFT_MASK, InputEvent.ALT_MASK, + * InputEvent.CTRL_MASK, or 0 if no modifier needed + * @param keycode the key to respond to in Ascii integer, 65 for A + */ + public void registerSwingHotKey(int identifier, int modifier, int keycode) { + try { + regHotKey(identifier, swingToIntelliType(modifier), keycode); + } catch (UnsatisfiedLinkError ex) { + throw new JIntellitypeException(ERROR_MESSAGE, ex); + } catch (RuntimeException ex) { + throw new JIntellitypeException(ex); + } + } + + /** + * Registers a Hotkey with windows. This combination will be responded to by + * all registered HotKeyListeners. Use the identifiers CTRL, SHIFT, ALT + * and/or WIN. + *

    + * @param identifier a unique identifier for this key combination + * @param modifierAndKeyCode String with modifiers separated by + and keycode + * (e.g. CTRL+SHIFT+A) + * @see #registerHotKey(int, int, int) + * @see #registerSwingHotKey(int, int, int) + */ + public void registerHotKey(int identifier, String modifierAndKeyCode) { + String[] split = modifierAndKeyCode.split("\\+"); + int mask = 0; + int keycode = 0; + + for (int i = 0; i < split.length; i++) { + if ("ALT".equalsIgnoreCase(split[i])) { + mask += JIntellitype.MOD_ALT; + } else if ("CTRL".equalsIgnoreCase(split[i]) || "CONTROL".equalsIgnoreCase(split[i])) { + mask += JIntellitype.MOD_CONTROL; + } else if ("SHIFT".equalsIgnoreCase(split[i])) { + mask += JIntellitype.MOD_SHIFT; + } else if ("WIN".equalsIgnoreCase(split[i])) { + mask += JIntellitype.MOD_WIN; + } else if (keycodeMap.containsKey(split[i].toLowerCase())) { + keycode = keycodeMap.get(split[i].toLowerCase()); + } + } + registerHotKey(identifier, mask, keycode); + } + + /** + * Removes a listener for hotkeys. + */ + public void removeHotKeyListener(HotkeyListener listener) { + hotkeyListeners.remove(listener); + } + + /** + * Removes a listener for intellitype commands. + */ + public void removeIntellitypeListener(IntellitypeListener listener) { + intellitypeListeners.remove(listener); + } + + /** + * Unregisters a previously registered Hotkey identified by its unique + * identifier. + *

    + * @param identifier the unique identifer of this Hotkey + */ + public void unregisterHotKey(int identifier) { + try { + unregHotKey(identifier); + } catch (UnsatisfiedLinkError ex) { + throw new JIntellitypeException(ERROR_MESSAGE, ex); + } catch (RuntimeException ex) { + throw new JIntellitypeException(ex); + } + } + + /** + * Checks to see if this application is already running. + *

    + * @param appTitle the name of the application to check for + * @return true if running, false if not running + */ + public static boolean checkInstanceAlreadyRunning(String appTitle) { + return getInstance().isRunning(appTitle); + } + + /** + * Checks to make sure the OS is a Windows flavor and that the JIntellitype + * DLL is found in the path and the JDK is 32 bit not 64 bit. The DLL + * currently only supports 32 bit JDK. + *

    + * @return true if Jintellitype may be used, false if not + */ + public static boolean isJIntellitypeSupported() { + boolean result = false; + String os = "none"; + + try { + os = System.getProperty("os.name").toLowerCase(); + } catch (SecurityException ex) { + // we are not allowed to look at this property + System.err.println("Caught a SecurityException reading the system property " + + "'os.name'; the SystemUtils property value will default to null."); + } + + // only works on Windows OS currently + if (os.startsWith("windows")) { + // try an get the instance and if it succeeds then return true + try { + getInstance(); + result = true; + } catch (Exception e) { + result = false; + } + } + + return result; + } + + /** + * Gets the libraryLocation. + *

    + * @return Returns the libraryLocation. + */ + public static String getLibraryLocation() { + return libraryLocation; + } + + /** + * Sets the libraryLocation. + *

    + * @param libraryLocation The libraryLocation to set. + */ + public static void setLibraryLocation(String libraryLocation) { + final File dll = new File(libraryLocation); + if (!dll.isAbsolute()) { + JIntellitype.libraryLocation = dll.getAbsolutePath(); + } else { + // absolute path, no further calculation needed + JIntellitype.libraryLocation = libraryLocation; + } + } + + /** + * Notifies all listeners that Hotkey was pressed. + *

    + * @param identifier the unique identifier received + */ + protected void onHotKey(final int identifier) { + for (final HotkeyListener hotkeyListener : hotkeyListeners) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + hotkeyListener.onHotKey(identifier); + } + }); + } + } + + /** + * Notifies all listeners that Intellitype command was received. + *

    + * @param command the unique WM_APPCOMMAND received + */ + protected void onIntellitype(final int command) { + for (final IntellitypeListener intellitypeListener : intellitypeListeners) { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + intellitypeListener.onIntellitype(command); + } + }); + } + } + + /** + * Swing modifier value to Jintellipad conversion. If no conversion needed + * just return the original value. This lets users pass either the original + * JIntellitype constants or Swing InputEvent constants. + *

    + * @param swingKeystrokeModifier the Swing KeystrokeModifier to check + * @return Jintellitype the JIntellitype modifier value + */ + protected static int swingToIntelliType(int swingKeystrokeModifier) { + int mask = 0; + if ((swingKeystrokeModifier & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { + mask += JIntellitype.MOD_SHIFT; + } + if ((swingKeystrokeModifier & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) { + mask += JIntellitype.MOD_ALT; + } + if ((swingKeystrokeModifier & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) { + mask += JIntellitype.MOD_CONTROL; + } + if ((swingKeystrokeModifier & InputEvent.SHIFT_DOWN_MASK) == InputEvent.SHIFT_DOWN_MASK) { + mask += JIntellitype.MOD_SHIFT; + } + if ((swingKeystrokeModifier & InputEvent.ALT_DOWN_MASK) == InputEvent.ALT_DOWN_MASK) { + mask += JIntellitype.MOD_ALT; + } + if ((swingKeystrokeModifier & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) { + mask += JIntellitype.MOD_CONTROL; + } + return mask; + } + + /** + * Puts all constants from {@link java.awt.event.KeyEvent} in a keycodeMap. + * The key is the lower case form of it. + * @return Map containing key->keycode mapping DOCU Now enables the user to + * use all keys specified here instead of just [A-Z],[0-9] as before + */ + private HashMap getKey2KeycodeMapping() { + HashMap map = new HashMap(); + + map.put("first", KeyEvent.KEY_FIRST); + map.put("last", KeyEvent.KEY_LAST); + map.put("typed", KeyEvent.KEY_TYPED); + map.put("pressed", KeyEvent.KEY_PRESSED); + map.put("released", KeyEvent.KEY_RELEASED); + map.put("enter", 13); + map.put("back_space", KeyEvent.VK_BACK_SPACE); + map.put("tab", KeyEvent.VK_TAB); + map.put("cancel", KeyEvent.VK_CANCEL); + map.put("clear", KeyEvent.VK_CLEAR); + map.put("pause", KeyEvent.VK_PAUSE); + map.put("caps_lock", KeyEvent.VK_CAPS_LOCK); + map.put("escape", KeyEvent.VK_ESCAPE); + map.put("space", KeyEvent.VK_SPACE); + map.put("page_up", KeyEvent.VK_PAGE_UP); + map.put("page_down", KeyEvent.VK_PAGE_DOWN); + map.put("end", KeyEvent.VK_END); + map.put("home", KeyEvent.VK_HOME); + map.put("left", KeyEvent.VK_LEFT); + map.put("up", KeyEvent.VK_UP); + map.put("right", KeyEvent.VK_RIGHT); + map.put("down", KeyEvent.VK_DOWN); + map.put("comma", 188); + map.put("minus", 109); + map.put("period", 110); + map.put("slash", 191); + map.put("0", KeyEvent.VK_0); + map.put("1", KeyEvent.VK_1); + map.put("2", KeyEvent.VK_2); + map.put("3", KeyEvent.VK_3); + map.put("4", KeyEvent.VK_4); + map.put("5", KeyEvent.VK_5); + map.put("6", KeyEvent.VK_6); + map.put("7", KeyEvent.VK_7); + map.put("8", KeyEvent.VK_8); + map.put("9", KeyEvent.VK_9); + map.put("semicolon", 186); + map.put("equals", 187); + map.put("a", KeyEvent.VK_A); + map.put("b", KeyEvent.VK_B); + map.put("c", KeyEvent.VK_C); + map.put("d", KeyEvent.VK_D); + map.put("e", KeyEvent.VK_E); + map.put("f", KeyEvent.VK_F); + map.put("g", KeyEvent.VK_G); + map.put("h", KeyEvent.VK_H); + map.put("i", KeyEvent.VK_I); + map.put("j", KeyEvent.VK_J); + map.put("k", KeyEvent.VK_K); + map.put("l", KeyEvent.VK_L); + map.put("m", KeyEvent.VK_M); + map.put("n", KeyEvent.VK_N); + map.put("o", KeyEvent.VK_O); + map.put("p", KeyEvent.VK_P); + map.put("q", KeyEvent.VK_Q); + map.put("r", KeyEvent.VK_R); + map.put("s", KeyEvent.VK_S); + map.put("t", KeyEvent.VK_T); + map.put("u", KeyEvent.VK_U); + map.put("v", KeyEvent.VK_V); + map.put("w", KeyEvent.VK_W); + map.put("x", KeyEvent.VK_X); + map.put("y", KeyEvent.VK_Y); + map.put("z", KeyEvent.VK_Z); + map.put("open_bracket", 219); + map.put("back_slash", 220); + map.put("close_bracket", 221); + map.put("numpad0", KeyEvent.VK_NUMPAD0); + map.put("numpad1", KeyEvent.VK_NUMPAD1); + map.put("numpad2", KeyEvent.VK_NUMPAD2); + map.put("numpad3", KeyEvent.VK_NUMPAD3); + map.put("numpad4", KeyEvent.VK_NUMPAD4); + map.put("numpad5", KeyEvent.VK_NUMPAD5); + map.put("numpad6", KeyEvent.VK_NUMPAD6); + map.put("numpad7", KeyEvent.VK_NUMPAD7); + map.put("numpad8", KeyEvent.VK_NUMPAD8); + map.put("numpad9", KeyEvent.VK_NUMPAD9); + map.put("multiply", KeyEvent.VK_MULTIPLY); + map.put("add", KeyEvent.VK_ADD); + map.put("separator", KeyEvent.VK_SEPARATOR); + map.put("subtract", KeyEvent.VK_SUBTRACT); + map.put("decimal", KeyEvent.VK_DECIMAL); + map.put("divide", KeyEvent.VK_DIVIDE); + map.put("delete", 46); + map.put("num_lock", KeyEvent.VK_NUM_LOCK); + map.put("scroll_lock", KeyEvent.VK_SCROLL_LOCK); + map.put("f1", KeyEvent.VK_F1); + map.put("f2", KeyEvent.VK_F2); + map.put("f3", KeyEvent.VK_F3); + map.put("f4", KeyEvent.VK_F4); + map.put("f5", KeyEvent.VK_F5); + map.put("f6", KeyEvent.VK_F6); + map.put("f7", KeyEvent.VK_F7); + map.put("f8", KeyEvent.VK_F8); + map.put("f9", KeyEvent.VK_F9); + map.put("f10", KeyEvent.VK_F10); + map.put("f11", KeyEvent.VK_F11); + map.put("f12", KeyEvent.VK_F12); + map.put("f13", KeyEvent.VK_F13); + map.put("f14", KeyEvent.VK_F14); + map.put("f15", KeyEvent.VK_F15); + map.put("f16", KeyEvent.VK_F16); + map.put("f17", KeyEvent.VK_F17); + map.put("f18", KeyEvent.VK_F18); + map.put("f19", KeyEvent.VK_F19); + map.put("f20", KeyEvent.VK_F20); + map.put("f21", KeyEvent.VK_F21); + map.put("f22", KeyEvent.VK_F22); + map.put("f23", KeyEvent.VK_F23); + map.put("f24", KeyEvent.VK_F24); + map.put("printscreen", 44); + map.put("insert", 45); + map.put("help", 47); + map.put("meta", KeyEvent.VK_META); + map.put("back_quote", KeyEvent.VK_BACK_QUOTE); + map.put("quote", KeyEvent.VK_QUOTE); + map.put("kp_up", KeyEvent.VK_KP_UP); + map.put("kp_down", KeyEvent.VK_KP_DOWN); + map.put("kp_left", KeyEvent.VK_KP_LEFT); + map.put("kp_right", KeyEvent.VK_KP_RIGHT); + map.put("dead_grave", KeyEvent.VK_DEAD_GRAVE); + map.put("dead_acute", KeyEvent.VK_DEAD_ACUTE); + map.put("dead_circumflex", KeyEvent.VK_DEAD_CIRCUMFLEX); + map.put("dead_tilde", KeyEvent.VK_DEAD_TILDE); + map.put("dead_macron", KeyEvent.VK_DEAD_MACRON); + map.put("dead_breve", KeyEvent.VK_DEAD_BREVE); + map.put("dead_abovedot", KeyEvent.VK_DEAD_ABOVEDOT); + map.put("dead_diaeresis", KeyEvent.VK_DEAD_DIAERESIS); + map.put("dead_abovering", KeyEvent.VK_DEAD_ABOVERING); + map.put("dead_doubleacute", KeyEvent.VK_DEAD_DOUBLEACUTE); + map.put("dead_caron", KeyEvent.VK_DEAD_CARON); + map.put("dead_cedilla", KeyEvent.VK_DEAD_CEDILLA); + map.put("dead_ogonek", KeyEvent.VK_DEAD_OGONEK); + map.put("dead_iota", KeyEvent.VK_DEAD_IOTA); + map.put("dead_voiced_sound", KeyEvent.VK_DEAD_VOICED_SOUND); + map.put("dead_semivoiced_sound", KeyEvent.VK_DEAD_SEMIVOICED_SOUND); + map.put("ampersand", KeyEvent.VK_AMPERSAND); + map.put("asterisk", KeyEvent.VK_ASTERISK); + map.put("quotedbl", KeyEvent.VK_QUOTEDBL); + map.put("less", KeyEvent.VK_LESS); + map.put("greater", KeyEvent.VK_GREATER); + map.put("braceleft", KeyEvent.VK_BRACELEFT); + map.put("braceright", KeyEvent.VK_BRACERIGHT); + map.put("at", KeyEvent.VK_AT); + map.put("colon", KeyEvent.VK_COLON); + map.put("circumflex", KeyEvent.VK_CIRCUMFLEX); + map.put("dollar", KeyEvent.VK_DOLLAR); + map.put("euro_sign", KeyEvent.VK_EURO_SIGN); + map.put("exclamation_mark", KeyEvent.VK_EXCLAMATION_MARK); + map.put("inverted_exclamation_mark", KeyEvent.VK_INVERTED_EXCLAMATION_MARK); + map.put("left_parenthesis", KeyEvent.VK_LEFT_PARENTHESIS); + map.put("number_sign", KeyEvent.VK_NUMBER_SIGN); + map.put("plus", KeyEvent.VK_PLUS); + map.put("right_parenthesis", KeyEvent.VK_RIGHT_PARENTHESIS); + map.put("underscore", KeyEvent.VK_UNDERSCORE); + map.put("context_menu", KeyEvent.VK_CONTEXT_MENU); + map.put("final", KeyEvent.VK_FINAL); + map.put("convert", KeyEvent.VK_CONVERT); + map.put("nonconvert", KeyEvent.VK_NONCONVERT); + map.put("accept", KeyEvent.VK_ACCEPT); + map.put("modechange", KeyEvent.VK_MODECHANGE); + map.put("kana", KeyEvent.VK_KANA); + map.put("kanji", KeyEvent.VK_KANJI); + map.put("alphanumeric", KeyEvent.VK_ALPHANUMERIC); + map.put("katakana", KeyEvent.VK_KATAKANA); + map.put("hiragana", KeyEvent.VK_HIRAGANA); + map.put("full_width", KeyEvent.VK_FULL_WIDTH); + map.put("half_width", KeyEvent.VK_HALF_WIDTH); + map.put("roman_characters", KeyEvent.VK_ROMAN_CHARACTERS); + map.put("all_candidates", KeyEvent.VK_ALL_CANDIDATES); + map.put("previous_candidate", KeyEvent.VK_PREVIOUS_CANDIDATE); + map.put("code_input", KeyEvent.VK_CODE_INPUT); + map.put("japanese_katakana", KeyEvent.VK_JAPANESE_KATAKANA); + map.put("japanese_hiragana", KeyEvent.VK_JAPANESE_HIRAGANA); + map.put("japanese_roman", KeyEvent.VK_JAPANESE_ROMAN); + map.put("kana_lock", KeyEvent.VK_KANA_LOCK); + map.put("input_method_on_off", KeyEvent.VK_INPUT_METHOD_ON_OFF); + map.put("cut", KeyEvent.VK_CUT); + map.put("copy", KeyEvent.VK_COPY); + map.put("paste", KeyEvent.VK_PASTE); + map.put("undo", KeyEvent.VK_UNDO); + map.put("again", KeyEvent.VK_AGAIN); + map.put("find", KeyEvent.VK_FIND); + map.put("props", KeyEvent.VK_PROPS); + map.put("stop", KeyEvent.VK_STOP); + map.put("compose", KeyEvent.VK_COMPOSE); + map.put("alt_graph", KeyEvent.VK_ALT_GRAPH); + map.put("begin", KeyEvent.VK_BEGIN); + + return map; + } + + private synchronized native void initializeLibrary() throws UnsatisfiedLinkError; + + private synchronized native void regHotKey(int identifier, int modifier, int keycode) throws UnsatisfiedLinkError; + + private synchronized native void terminate() throws UnsatisfiedLinkError; + + private synchronized native void unregHotKey(int identifier) throws UnsatisfiedLinkError; + + /** + * Checks if there's an instance with hidden window title = appName running + * Can be used to detect that another instance of your app is already running + * (so exit..) + *

    + * @param appName = the title of the hidden window to search for + */ + private synchronized native boolean isRunning(String appName); +} \ No newline at end of file diff --git a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeConstants.java b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeConstants.java new file mode 100644 index 0000000..dfa2af5 --- /dev/null +++ b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeConstants.java @@ -0,0 +1,182 @@ +/** + * JIntellitype + * ----------------- + * Copyright 2005-2008 Emil A. Lefkof III, Melloware Inc. + * + * I always give it my best shot to make a program useful and solid, but + * remeber that there is absolutely no warranty for using this program as + * stated in the following terms: + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.melloware.jintellitype; + +/** + * Constants from the Windows API used in JIntellitype. + *

    + * Message information can be found on MSDN here: + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputmessages/wm_appcommand.asp + *

    + * Copyright (c) 1999-2008 + * Melloware, Inc. + * @author Emil A. Lefkof III + * @version 1.3.1 + */ +public interface JIntellitypeConstants { + + public static final String ERROR_MESSAGE = "JIntellitype DLL Error"; + + // Modifier keys, can be added together + + /** + * ALT key for registering Hotkeys. + */ + public static final int MOD_ALT = 1; + + /** + * CONTROL key for registering Hotkeys. + */ + public static final int MOD_CONTROL = 2; + + /** + * SHIFT key for registering Hotkeys. + */ + public static final int MOD_SHIFT = 4; + + /** + * WINDOWS key for registering Hotkeys. + */ + public static final int MOD_WIN = 8; + + + // Intellitype Virtual Key Constants from MSDN + + /** + * Browser Navigate backward + */ + public static final int APPCOMMAND_BROWSER_BACKWARD = 1; + + /** + * Browser Navigate forward + */ + public static final int APPCOMMAND_BROWSER_FORWARD = 2; + + /** + * Browser Refresh page + */ + public static final int APPCOMMAND_BROWSER_REFRESH = 3; + + /** + * Browser Stop download + */ + public static final int APPCOMMAND_BROWSER_STOP = 4; + + /** + * Browser Open search + */ + public static final int APPCOMMAND_BROWSER_SEARCH = 5; + + /** + * Browser Open favorites + */ + public static final int APPCOMMAND_BROWSER_FAVOURITES = 6; + + /** + * Browser Navigate home + */ + public static final int APPCOMMAND_BROWSER_HOME = 7; + + /** + * Mute the volume + */ + public static final int APPCOMMAND_VOLUME_MUTE = 8; + + /** + * Lower the volume + */ + public static final int APPCOMMAND_VOLUME_DOWN = 9; + + /** + * Raise the volume + */ + public static final int APPCOMMAND_VOLUME_UP = 10; + + /** + * Media application go to next track. + */ + public static final int APPCOMMAND_MEDIA_NEXTTRACK = 11; + + /** + * Media application Go to previous track. + */ + public static final int APPCOMMAND_MEDIA_PREVIOUSTRACK = 12; + + /** + * Media application Stop playback. + */ + public static final int APPCOMMAND_MEDIA_STOP = 13; + + /** + * Media application Play or pause playback. + */ + public static final int APPCOMMAND_MEDIA_PLAY_PAUSE = 14; + + /** + * Open mail application + */ + public static final int APPCOMMAND_LAUNCH_MAIL = 15; + + /** + * Go to Media Select mode. + */ + public static final int APPCOMMAND_LAUNCH_MEDIA_SELECT = 16; + + /** + * Start App1. + */ + public static final int APPCOMMAND_LAUNCH_APP1 = 17; + + /** + * Start App2. + */ + public static final int APPCOMMAND_LAUNCH_APP2 = 18; + + public static final int APPCOMMAND_BASS_DOWN = 19; + public static final int APPCOMMAND_BASS_BOOST = 20; + public static final int APPCOMMAND_BASS_UP = 21; + public static final int APPCOMMAND_TREBLE_DOWN = 22; + public static final int APPCOMMAND_TREBLE_UP = 23; + public static final int APPCOMMAND_MICROPHONE_VOLUME_MUTE = 24; + public static final int APPCOMMAND_MICROPHONE_VOLUME_DOWN = 25; + public static final int APPCOMMAND_MICROPHONE_VOLUME_UP = 26; + public static final int APPCOMMAND_HELP = 27; + public static final int APPCOMMAND_FIND = 28; + public static final int APPCOMMAND_NEW = 29; + public static final int APPCOMMAND_OPEN = 30; + public static final int APPCOMMAND_CLOSE = 31; + public static final int APPCOMMAND_SAVE = 32; + public static final int APPCOMMAND_PRINT = 33; + public static final int APPCOMMAND_UNDO = 34; + public static final int APPCOMMAND_REDO = 35; + public static final int APPCOMMAND_COPY = 36; + public static final int APPCOMMAND_CUT = 37; + public static final int APPCOMMAND_PASTE = 38; + public static final int APPCOMMAND_REPLY_TO_MAIL = 39; + public static final int APPCOMMAND_FORWARD_MAIL = 40; + public static final int APPCOMMAND_SEND_MAIL = 41; + public static final int APPCOMMAND_SPELL_CHECK = 42; + public static final int APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE = 43; + public static final int APPCOMMAND_MIC_ON_OFF_TOGGLE = 44; + public static final int APPCOMMAND_CORRECTION_LIST = 45; + +} diff --git a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeException.java b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeException.java new file mode 100644 index 0000000..f0bd0f2 --- /dev/null +++ b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeException.java @@ -0,0 +1,55 @@ +/** + * JIntellitype + * ----------------- + * Copyright 2005-2008 Emil A. Lefkof III, Melloware Inc. + * + * I always give it my best shot to make a program useful and solid, but + * remeber that there is absolutely no warranty for using this program as + * stated in the following terms: + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.melloware.jintellitype; + + +/** + * Exception class for all JIntellitype Exceptions. + *

    + * Copyright (c) 1999-2008 + * Melloware, Inc. + * @author Emil A. Lefkof III + * @version 1.3.1 + */ +public class JIntellitypeException extends RuntimeException { + + + public JIntellitypeException() { + super(); + } + + + public JIntellitypeException(String aMessage, Throwable aCause) { + super(aMessage, aCause); + } + + + public JIntellitypeException(String aMessage) { + super(aMessage); + } + + + public JIntellitypeException(Throwable aCause) { + super(aCause); + } + +} diff --git a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/Main.java b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/Main.java new file mode 100644 index 0000000..b579745 --- /dev/null +++ b/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/Main.java @@ -0,0 +1,80 @@ +/** + * JIntellitype + * ----------------- + * Copyright 2005-2008 Emil A. Lefkof III, Melloware Inc. + * + * I always give it my best shot to make a program useful and solid, but + * remeber that there is absolutely no warranty for using this program as + * stated in the following terms: + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.melloware.jintellitype; + +import java.util.Properties; + +/** + * Simple executable class that is used as the Main-Class in the JIntellitype + * jar. Outputs version information and other information about the environment + * on which the jar is being executed. + *

    + * Copyright (c) 1999-2008 + * Melloware, Inc. + * @author Emil A. Lefkof III + * @version 1.3.1 + */ +@SuppressWarnings("") +public final class Main { + + /** + * Private constructor to make sure this class is never instantiated. + * + */ + private Main() { + // private constructor to make singleton. + } + + /** Main method that does what the class level javadoc states. */ + public static void main(String[] argv) { + System.out.println("JIntellitype version \"" + getProjectVersion() + "\""); + System.out.println(" "); + + System.out.println("Running on java version \"" + System.getProperty("java.version") + "\"" + + " (build " + System.getProperty("java.runtime.version") + ")" + + " from " + System.getProperty("java.vendor")); + + System.out.println("Operating environment \"" + System.getProperty("os.name") + "\"" + + " version " + System.getProperty("os.version") + " on " + System.getProperty("os.arch")); + + System.out.println("For more information on JIntellitype please visit http://www.melloware.com"); + } + + /** + * Attempts to read the version number out of the pom.properties. If not found + * then RUNNING.IN.IDE.FULL is returned as the version. + *

    + * @return the full version number of this application + */ + private static String getProjectVersion() { + String version; + + try { + final Properties pomProperties = new Properties(); + pomProperties.load(Main.class.getResourceAsStream("/META-INF/maven/com.melloware/jintellitype/pom.properties")); + version = pomProperties.getProperty("version"); + } catch (Exception e) { + version = "RUNNING.IN.IDE.FULL"; + } + return version; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/lib/basicplayer3.0.jar b/vendor/jlgui/3.0/lib/basicplayer3.0.jar new file mode 100644 index 0000000..a45e1fc Binary files /dev/null and b/vendor/jlgui/3.0/lib/basicplayer3.0.jar differ diff --git a/vendor/jlgui/3.0/lib/commons-logging-api.jar b/vendor/jlgui/3.0/lib/commons-logging-api.jar new file mode 100644 index 0000000..ade9a13 Binary files /dev/null and b/vendor/jlgui/3.0/lib/commons-logging-api.jar differ diff --git a/vendor/jlgui/3.0/lib/jflac-1.2.jar b/vendor/jlgui/3.0/lib/jflac-1.2.jar new file mode 100644 index 0000000..0de540f Binary files /dev/null and b/vendor/jlgui/3.0/lib/jflac-1.2.jar differ diff --git a/vendor/jlgui/3.0/lib/jl1.0.jar b/vendor/jlgui/3.0/lib/jl1.0.jar new file mode 100644 index 0000000..17f7c0a Binary files /dev/null and b/vendor/jlgui/3.0/lib/jl1.0.jar differ diff --git a/vendor/jlgui/3.0/lib/jmactritonusspi1.74.jar b/vendor/jlgui/3.0/lib/jmactritonusspi1.74.jar new file mode 100644 index 0000000..a5073e2 Binary files /dev/null and b/vendor/jlgui/3.0/lib/jmactritonusspi1.74.jar differ diff --git a/vendor/jlgui/3.0/lib/jogg-0.0.7.jar b/vendor/jlgui/3.0/lib/jogg-0.0.7.jar new file mode 100644 index 0000000..1cbd1ad Binary files /dev/null and b/vendor/jlgui/3.0/lib/jogg-0.0.7.jar differ diff --git a/vendor/jlgui/3.0/lib/jorbis-0.0.15.jar b/vendor/jlgui/3.0/lib/jorbis-0.0.15.jar new file mode 100644 index 0000000..4cf51f9 Binary files /dev/null and b/vendor/jlgui/3.0/lib/jorbis-0.0.15.jar differ diff --git a/vendor/jlgui/3.0/lib/jspeex0.9.7.jar b/vendor/jlgui/3.0/lib/jspeex0.9.7.jar new file mode 100644 index 0000000..f7a1861 Binary files /dev/null and b/vendor/jlgui/3.0/lib/jspeex0.9.7.jar differ diff --git a/vendor/jlgui/3.0/lib/kj_dsp1.1.jar b/vendor/jlgui/3.0/lib/kj_dsp1.1.jar new file mode 100644 index 0000000..2cb3479 Binary files /dev/null and b/vendor/jlgui/3.0/lib/kj_dsp1.1.jar differ diff --git a/vendor/jlgui/3.0/lib/mp3spi1.9.4.jar b/vendor/jlgui/3.0/lib/mp3spi1.9.4.jar new file mode 100644 index 0000000..019b86c Binary files /dev/null and b/vendor/jlgui/3.0/lib/mp3spi1.9.4.jar differ diff --git a/vendor/jlgui/3.0/lib/tritonus_share.jar b/vendor/jlgui/3.0/lib/tritonus_share.jar new file mode 100644 index 0000000..d21ba89 Binary files /dev/null and b/vendor/jlgui/3.0/lib/tritonus_share.jar differ diff --git a/vendor/jlgui/3.0/lib/vorbisspi1.0.2.jar b/vendor/jlgui/3.0/lib/vorbisspi1.0.2.jar new file mode 100644 index 0000000..1a924af Binary files /dev/null and b/vendor/jlgui/3.0/lib/vorbisspi1.0.2.jar differ diff --git a/vendor/jlgui/3.0/src/META-INF/services/org.apache.commons.logging.LogFactory b/vendor/jlgui/3.0/src/META-INF/services/org.apache.commons.logging.LogFactory new file mode 100644 index 0000000..8693527 --- /dev/null +++ b/vendor/jlgui/3.0/src/META-INF/services/org.apache.commons.logging.LogFactory @@ -0,0 +1 @@ +org.apache.commons.logging.impl.LogFactoryImpl diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicController.java b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicController.java new file mode 100644 index 0000000..93944fd --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicController.java @@ -0,0 +1,102 @@ +/* + * BasicController. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.basicplayer; + +import java.io.File; +import java.io.InputStream; +import java.net.URL; + +/** + * This interface defines player controls available. + */ +public interface BasicController +{ + /** + * Open inputstream to play. + * @param in + * @throws BasicPlayerException + */ + public void open(InputStream in) throws BasicPlayerException; + + /** + * Open file to play. + * @param file + * @throws BasicPlayerException + */ + public void open(File file) throws BasicPlayerException; + + /** + * Open URL to play. + * @param url + * @throws BasicPlayerException + */ + public void open(URL url) throws BasicPlayerException; + + /** + * Skip bytes. + * @param bytes + * @return bytes skipped according to audio frames constraint. + * @throws BasicPlayerException + */ + public long seek(long bytes) throws BasicPlayerException; + + /** + * Start playback. + * @throws BasicPlayerException + */ + public void play() throws BasicPlayerException; + + /** + * Stop playback. + * @throws BasicPlayerException + */ + public void stop() throws BasicPlayerException; + + /** + * Pause playback. + * @throws BasicPlayerException + */ + public void pause() throws BasicPlayerException; + + /** + * Resume playback. + * @throws BasicPlayerException + */ + public void resume() throws BasicPlayerException; + + /** + * Sets Pan (Balance) value. + * Linear scale : -1.0 <--> +1.0 + * @param pan value from -1.0 to +1.0 + * @throws BasicPlayerException + */ + public void setPan(double pan) throws BasicPlayerException; + + /** + * Sets Gain value. + * Linear scale 0.0 <--> 1.0 + * @param gain value from 0.0 to 1.0 + * @throws BasicPlayerException + */ + public void setGain(double gain) throws BasicPlayerException; +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayer.java b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayer.java new file mode 100644 index 0000000..a69dd8f --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayer.java @@ -0,0 +1,1038 @@ +/* + * BasicPlayer. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.basicplayer; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Control; +import javax.sound.sampled.DataLine; +import javax.sound.sampled.FloatControl; +import javax.sound.sampled.Line; +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.Mixer; +import javax.sound.sampled.SourceDataLine; +import javax.sound.sampled.UnsupportedAudioFileException; +import javazoom.spi.PropertiesContainer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.tritonus.share.sampled.TAudioFormat; +import org.tritonus.share.sampled.file.TAudioFileFormat; + +/** + * BasicPlayer is a threaded simple player class based on JavaSound API. + * It has been successfully tested under J2SE 1.3.x, 1.4.x and 1.5.x. + */ +public class BasicPlayer implements BasicController, Runnable +{ + public static int EXTERNAL_BUFFER_SIZE = 4000 * 4; + public static int SKIP_INACCURACY_SIZE = 1200; + protected Thread m_thread = null; + protected Object m_dataSource; + protected AudioInputStream m_encodedaudioInputStream; + protected int encodedLength = -1; + protected AudioInputStream m_audioInputStream; + protected AudioFileFormat m_audioFileFormat; + protected SourceDataLine m_line; + protected FloatControl m_gainControl; + protected FloatControl m_panControl; + protected String m_mixerName = null; + private int m_lineCurrentBufferSize = -1; + private int lineBufferSize = -1; + private long threadSleep = -1; + private static Log log = LogFactory.getLog(BasicPlayer.class); + /** + * These variables are used to distinguish stopped, paused, playing states. + * We need them to control Thread. + */ + public static final int UNKNOWN = -1; + public static final int PLAYING = 0; + public static final int PAUSED = 1; + public static final int STOPPED = 2; + public static final int OPENED = 3; + public static final int SEEKING = 4; + private int m_status = UNKNOWN; + // Listeners to be notified. + private Collection m_listeners = null; + private Map empty_map = new HashMap(); + + /** + * Constructs a Basic Player. + */ + public BasicPlayer() + { + m_dataSource = null; + m_listeners = new ArrayList(); + reset(); + } + + protected void reset() + { + m_status = UNKNOWN; + if (m_audioInputStream != null) + { + synchronized (m_audioInputStream) + { + closeStream(); + } + } + m_audioInputStream = null; + m_audioFileFormat = null; + m_encodedaudioInputStream = null; + encodedLength = -1; + if (m_line != null) + { + m_line.stop(); + m_line.close(); + m_line = null; + } + m_gainControl = null; + m_panControl = null; + } + + /** + * Add listener to be notified. + * @param bpl + */ + public void addBasicPlayerListener(BasicPlayerListener bpl) + { + m_listeners.add(bpl); + } + + /** + * Return registered listeners. + * @return + */ + public Collection getListeners() + { + return m_listeners; + } + + /** + * Remove registered listener. + * @param bpl + */ + public void removeBasicPlayerListener(BasicPlayerListener bpl) + { + if (m_listeners != null) + { + m_listeners.remove(bpl); + } + } + + /** + * Set SourceDataLine buffer size. It affects audio latency. + * (the delay between line.write(data) and real sound). + * Minimum value should be over 10000 bytes. + * @param size -1 means maximum buffer size available. + */ + public void setLineBufferSize(int size) + { + lineBufferSize = size; + } + + /** + * Return SourceDataLine buffer size. + * @return -1 maximum buffer size. + */ + public int getLineBufferSize() + { + return lineBufferSize; + } + + /** + * Return SourceDataLine current buffer size. + * @return + */ + public int getLineCurrentBufferSize() + { + return m_lineCurrentBufferSize; + } + + /** + * Set thread sleep time. + * Default is -1 (no sleep time). + * @param time in milliseconds. + */ + public void setSleepTime(long time) + { + threadSleep = time; + } + + /** + * Return thread sleep time in milliseconds. + * @return -1 means no sleep time. + */ + public long getSleepTime() + { + return threadSleep; + } + + /** + * Returns BasicPlayer status. + * @return status + */ + public int getStatus() + { + return m_status; + } + + /** + * Open file to play. + */ + public void open(File file) throws BasicPlayerException + { + log.info("open(" + file + ")"); + if (file != null) + { + m_dataSource = file; + initAudioInputStream(); + } + } + + /** + * Open URL to play. + */ + public void open(URL url) throws BasicPlayerException + { + log.info("open(" + url + ")"); + if (url != null) + { + m_dataSource = url; + initAudioInputStream(); + } + } + + /** + * Open inputstream to play. + */ + public void open(InputStream inputStream) throws BasicPlayerException + { + log.info("open(" + inputStream + ")"); + if (inputStream != null) + { + m_dataSource = inputStream; + initAudioInputStream(); + } + } + + /** + * Inits AudioInputStream and AudioFileFormat from the data source. + * @throws BasicPlayerException + */ + protected void initAudioInputStream() throws BasicPlayerException + { + try + { + reset(); + notifyEvent(BasicPlayerEvent.OPENING, getEncodedStreamPosition(), -1, m_dataSource); + if (m_dataSource instanceof URL) + { + initAudioInputStream((URL) m_dataSource); + } + else if (m_dataSource instanceof File) + { + initAudioInputStream((File) m_dataSource); + } + else if (m_dataSource instanceof InputStream) + { + initAudioInputStream((InputStream) m_dataSource); + } + createLine(); + // Notify listeners with AudioFileFormat properties. + Map properties = null; + if (m_audioFileFormat instanceof TAudioFileFormat) + { + // Tritonus SPI compliant audio file format. + properties = ((TAudioFileFormat) m_audioFileFormat).properties(); + // Clone the Map because it is not mutable. + properties = deepCopy(properties); + } + else properties = new HashMap(); + // Add JavaSound properties. + if (m_audioFileFormat.getByteLength() > 0) properties.put("audio.length.bytes", new Integer(m_audioFileFormat.getByteLength())); + if (m_audioFileFormat.getFrameLength() > 0) properties.put("audio.length.frames", new Integer(m_audioFileFormat.getFrameLength())); + if (m_audioFileFormat.getType() != null) properties.put("audio.type", (m_audioFileFormat.getType().toString())); + // Audio format. + AudioFormat audioFormat = m_audioFileFormat.getFormat(); + if (audioFormat.getFrameRate() > 0) properties.put("audio.framerate.fps", new Float(audioFormat.getFrameRate())); + if (audioFormat.getFrameSize() > 0) properties.put("audio.framesize.bytes", new Integer(audioFormat.getFrameSize())); + if (audioFormat.getSampleRate() > 0) properties.put("audio.samplerate.hz", new Float(audioFormat.getSampleRate())); + if (audioFormat.getSampleSizeInBits() > 0) properties.put("audio.samplesize.bits", new Integer(audioFormat.getSampleSizeInBits())); + if (audioFormat.getChannels() > 0) properties.put("audio.channels", new Integer(audioFormat.getChannels())); + if (audioFormat instanceof TAudioFormat) + { + // Tritonus SPI compliant audio format. + Map addproperties = ((TAudioFormat) audioFormat).properties(); + properties.putAll(addproperties); + } + // Add SourceDataLine + properties.put("basicplayer.sourcedataline", m_line); + Iterator it = m_listeners.iterator(); + while (it.hasNext()) + { + BasicPlayerListener bpl = (BasicPlayerListener) it.next(); + bpl.opened(m_dataSource, properties); + } + m_status = OPENED; + notifyEvent(BasicPlayerEvent.OPENED, getEncodedStreamPosition(), -1, null); + } + catch (LineUnavailableException e) + { + throw new BasicPlayerException(e); + } + catch (UnsupportedAudioFileException e) + { + throw new BasicPlayerException(e); + } + catch (IOException e) + { + throw new BasicPlayerException(e); + } + } + + /** + * Inits Audio ressources from file. + */ + protected void initAudioInputStream(File file) throws UnsupportedAudioFileException, IOException + { + m_audioInputStream = AudioSystem.getAudioInputStream(file); + m_audioFileFormat = AudioSystem.getAudioFileFormat(file); + } + + /** + * Inits Audio ressources from URL. + */ + protected void initAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException + { + m_audioInputStream = AudioSystem.getAudioInputStream(url); + m_audioFileFormat = AudioSystem.getAudioFileFormat(url); + } + + /** + * Inits Audio ressources from InputStream. + */ + protected void initAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException + { + m_audioInputStream = AudioSystem.getAudioInputStream(inputStream); + m_audioFileFormat = AudioSystem.getAudioFileFormat(inputStream); + } + + /** + * Inits Audio ressources from AudioSystem.
    + */ + protected void initLine() throws LineUnavailableException + { + log.info("initLine()"); + if (m_line == null) createLine(); + if (!m_line.isOpen()) + { + openLine(); + } + else + { + AudioFormat lineAudioFormat = m_line.getFormat(); + AudioFormat audioInputStreamFormat = m_audioInputStream == null ? null : m_audioInputStream.getFormat(); + if (!lineAudioFormat.equals(audioInputStreamFormat)) + { + m_line.close(); + openLine(); + } + } + } + + /** + * Inits a DateLine.
    + * + * We check if the line supports Gain and Pan controls. + * + * From the AudioInputStream, i.e. from the sound file, we + * fetch information about the format of the audio data. These + * information include the sampling frequency, the number of + * channels and the size of the samples. There information + * are needed to ask JavaSound for a suitable output line + * for this audio file. + * Furthermore, we have to give JavaSound a hint about how + * big the internal buffer for the line should be. Here, + * we say AudioSystem.NOT_SPECIFIED, signaling that we don't + * care about the exact size. JavaSound will use some default + * value for the buffer size. + */ + protected void createLine() throws LineUnavailableException + { + log.info("Create Line"); + if (m_line == null) + { + AudioFormat sourceFormat = m_audioInputStream.getFormat(); + log.info("Create Line : Source format : " + sourceFormat.toString()); + int nSampleSizeInBits = sourceFormat.getSampleSizeInBits(); + if (nSampleSizeInBits <= 0) nSampleSizeInBits = 16; + if ((sourceFormat.getEncoding() == AudioFormat.Encoding.ULAW) || (sourceFormat.getEncoding() == AudioFormat.Encoding.ALAW)) nSampleSizeInBits = 16; + if (nSampleSizeInBits != 8) nSampleSizeInBits = 16; + AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, sourceFormat.getSampleRate(), nSampleSizeInBits, sourceFormat.getChannels(), sourceFormat.getChannels() * (nSampleSizeInBits / 8), sourceFormat.getSampleRate(), false); + log.info("Create Line : Target format: " + targetFormat); + // Keep a reference on encoded stream to progress notification. + m_encodedaudioInputStream = m_audioInputStream; + try + { + // Get total length in bytes of the encoded stream. + encodedLength = m_encodedaudioInputStream.available(); + } + catch (IOException e) + { + log.error("Cannot get m_encodedaudioInputStream.available()", e); + } + // Create decoded stream. + m_audioInputStream = AudioSystem.getAudioInputStream(targetFormat, m_audioInputStream); + AudioFormat audioFormat = m_audioInputStream.getFormat(); + DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat, AudioSystem.NOT_SPECIFIED); + Mixer mixer = getMixer(m_mixerName); + if (mixer != null) + { + log.info("Mixer : "+mixer.getMixerInfo().toString()); + m_line = (SourceDataLine) mixer.getLine(info); + } + else + { + m_line = (SourceDataLine) AudioSystem.getLine(info); + m_mixerName = null; + } + log.info("Line : " + m_line.toString()); + log.debug("Line Info : " + m_line.getLineInfo().toString()); + log.debug("Line AudioFormat: " + m_line.getFormat().toString()); + } + } + + /** + * Opens the line. + */ + protected void openLine() throws LineUnavailableException + { + if (m_line != null) + { + AudioFormat audioFormat = m_audioInputStream.getFormat(); + int buffersize = lineBufferSize; + if (buffersize <= 0) buffersize = m_line.getBufferSize(); + m_lineCurrentBufferSize = buffersize; + m_line.open(audioFormat, buffersize); + log.info("Open Line : BufferSize=" + buffersize); + /*-- Display supported controls --*/ + Control[] c = m_line.getControls(); + for (int p = 0; p < c.length; p++) + { + log.debug("Controls : " + c[p].toString()); + } + /*-- Is Gain Control supported ? --*/ + if (m_line.isControlSupported(FloatControl.Type.MASTER_GAIN)) + { + m_gainControl = (FloatControl) m_line.getControl(FloatControl.Type.MASTER_GAIN); + log.info("Master Gain Control : [" + m_gainControl.getMinimum() + "," + m_gainControl.getMaximum() + "] " + m_gainControl.getPrecision()); + } + /*-- Is Pan control supported ? --*/ + if (m_line.isControlSupported(FloatControl.Type.PAN)) + { + m_panControl = (FloatControl) m_line.getControl(FloatControl.Type.PAN); + log.info("Pan Control : [" + m_panControl.getMinimum() + "," + m_panControl.getMaximum() + "] " + m_panControl.getPrecision()); + } + } + } + + /** + * Stops the playback.
    + * + * Player Status = STOPPED.
    + * Thread should free Audio ressources. + */ + protected void stopPlayback() + { + if ((m_status == PLAYING) || (m_status == PAUSED)) + { + if (m_line != null) + { + m_line.flush(); + m_line.stop(); + } + m_status = STOPPED; + notifyEvent(BasicPlayerEvent.STOPPED, getEncodedStreamPosition(), -1, null); + synchronized (m_audioInputStream) + { + closeStream(); + } + log.info("stopPlayback() completed"); + } + } + + /** + * Pauses the playback.
    + * + * Player Status = PAUSED. + */ + protected void pausePlayback() + { + if (m_line != null) + { + if (m_status == PLAYING) + { + m_line.flush(); + m_line.stop(); + m_status = PAUSED; + log.info("pausePlayback() completed"); + notifyEvent(BasicPlayerEvent.PAUSED, getEncodedStreamPosition(), -1, null); + } + } + } + + /** + * Resumes the playback.
    + * + * Player Status = PLAYING. + */ + protected void resumePlayback() + { + if (m_line != null) + { + if (m_status == PAUSED) + { + m_line.start(); + m_status = PLAYING; + log.info("resumePlayback() completed"); + notifyEvent(BasicPlayerEvent.RESUMED, getEncodedStreamPosition(), -1, null); + } + } + } + + /** + * Starts playback. + */ + protected void startPlayback() throws BasicPlayerException + { + if (m_status == STOPPED) initAudioInputStream(); + if (m_status == OPENED) + { + log.info("startPlayback called"); + if (!(m_thread == null || !m_thread.isAlive())) + { + log.info("WARNING: old thread still running!!"); + int cnt = 0; + while (m_status != OPENED) + { + try + { + if (m_thread != null) + { + log.info("Waiting ... " + cnt); + cnt++; + Thread.sleep(1000); + if (cnt > 2) + { + m_thread.interrupt(); + } + } + } + catch (InterruptedException e) + { + throw new BasicPlayerException(BasicPlayerException.WAITERROR, e); + } + } + } + // Open SourceDataLine. + try + { + initLine(); + } + catch (LineUnavailableException e) + { + throw new BasicPlayerException(BasicPlayerException.CANNOTINITLINE, e); + } + log.info("Creating new thread"); + m_thread = new Thread(this, "BasicPlayer"); + m_thread.start(); + if (m_line != null) + { + m_line.start(); + m_status = PLAYING; + notifyEvent(BasicPlayerEvent.PLAYING, getEncodedStreamPosition(), -1, null); + } + } + } + + /** + * Main loop. + * + * Player Status == STOPPED || SEEKING => End of Thread + Freeing Audio Ressources.
    + * Player Status == PLAYING => Audio stream data sent to Audio line.
    + * Player Status == PAUSED => Waiting for another status. + */ + public void run() + { + log.info("Thread Running"); + int nBytesRead = 1; + byte[] abData = new byte[EXTERNAL_BUFFER_SIZE]; + // Lock stream while playing. + synchronized (m_audioInputStream) + { + // Main play/pause loop. + while ((nBytesRead != -1) && (m_status != STOPPED) && (m_status != SEEKING) && (m_status != UNKNOWN)) + { + if (m_status == PLAYING) + { + // Play. + try + { + nBytesRead = m_audioInputStream.read(abData, 0, abData.length); + if (nBytesRead >= 0) + { + byte[] pcm = new byte[nBytesRead]; + System.arraycopy(abData, 0, pcm, 0, nBytesRead); + if (m_line.available() >= m_line.getBufferSize()) log.debug("Underrun : "+m_line.available()+"/"+m_line.getBufferSize()); + int nBytesWritten = m_line.write(abData, 0, nBytesRead); + // Compute position in bytes in encoded stream. + int nEncodedBytes = getEncodedStreamPosition(); + // Notify listeners + Iterator it = m_listeners.iterator(); + while (it.hasNext()) + { + BasicPlayerListener bpl = (BasicPlayerListener) it.next(); + if (m_audioInputStream instanceof PropertiesContainer) + { + // Pass audio parameters such as instant bitrate, ... + Map properties = ((PropertiesContainer) m_audioInputStream).properties(); + bpl.progress(nEncodedBytes, m_line.getMicrosecondPosition(), pcm, properties); + } + else bpl.progress(nEncodedBytes, m_line.getMicrosecondPosition(), pcm, empty_map); + } + } + } + catch (IOException e) + { + log.error("Thread cannot run()", e); + m_status = STOPPED; + notifyEvent(BasicPlayerEvent.STOPPED, getEncodedStreamPosition(), -1, null); + } + // Nice CPU usage. + if (threadSleep > 0) + { + try + { + Thread.sleep(threadSleep); + } + catch (InterruptedException e) + { + log.error("Thread cannot sleep(" + threadSleep + ")", e); + } + } + } + else + { + // Pause + try + { + Thread.sleep(1000); + } + catch (InterruptedException e) + { + log.error("Thread cannot sleep(1000)", e); + } + } + } + // Free audio resources. + if (m_line != null) + { + m_line.drain(); + m_line.stop(); + m_line.close(); + m_line = null; + } + // Notification of "End Of Media" + if (nBytesRead == -1) + { + notifyEvent(BasicPlayerEvent.EOM, getEncodedStreamPosition(), -1, null); + } + // Close stream. + closeStream(); + } + m_status = STOPPED; + notifyEvent(BasicPlayerEvent.STOPPED, getEncodedStreamPosition(), -1, null); + log.info("Thread completed"); + } + + /** + * Skip bytes in the File inputstream. + * It will skip N frames matching to bytes, so it will never skip given bytes length exactly. + * @param bytes + * @return value>0 for File and value=0 for URL and InputStream + * @throws BasicPlayerException + */ + protected long skipBytes(long bytes) throws BasicPlayerException + { + long totalSkipped = 0; + if (m_dataSource instanceof File) + { + log.info("Bytes to skip : " + bytes); + int previousStatus = m_status; + m_status = SEEKING; + long skipped = 0; + try + { + synchronized (m_audioInputStream) + { + notifyEvent(BasicPlayerEvent.SEEKING, getEncodedStreamPosition(), -1, null); + initAudioInputStream(); + if (m_audioInputStream != null) + { + // Loop until bytes are really skipped. + while (totalSkipped < (bytes - SKIP_INACCURACY_SIZE)) + { + skipped = m_audioInputStream.skip(bytes - totalSkipped); + if (skipped == 0) break; + totalSkipped = totalSkipped + skipped; + log.info("Skipped : " + totalSkipped + "/" + bytes); + if (totalSkipped == -1) throw new BasicPlayerException(BasicPlayerException.SKIPNOTSUPPORTED); + } + } + } + notifyEvent(BasicPlayerEvent.SEEKED, getEncodedStreamPosition(), -1, null); + m_status = OPENED; + if (previousStatus == PLAYING) startPlayback(); + else if (previousStatus == PAUSED) + { + startPlayback(); + pausePlayback(); + } + } + catch (IOException e) + { + throw new BasicPlayerException(e); + } + } + return totalSkipped; + } + + /** + * Notify listeners about a BasicPlayerEvent. + * @param code event code. + * @param position in the stream when the event occurs. + */ + protected void notifyEvent(int code, int position, double value, Object description) + { + BasicPlayerEventLauncher trigger = new BasicPlayerEventLauncher(code, position, value, description, new ArrayList(m_listeners), this); + trigger.start(); + } + + protected int getEncodedStreamPosition() + { + int nEncodedBytes = -1; + if (m_dataSource instanceof File) + { + try + { + if (m_encodedaudioInputStream != null) + { + nEncodedBytes = encodedLength - m_encodedaudioInputStream.available(); + } + } + catch (IOException e) + { + //log.debug("Cannot get m_encodedaudioInputStream.available()",e); + } + } + return nEncodedBytes; + } + + protected void closeStream() + { + // Close stream. + try + { + if (m_audioInputStream != null) + { + m_audioInputStream.close(); + log.info("Stream closed"); + } + } + catch (IOException e) + { + log.info("Cannot close stream", e); + } + } + + /** + * Returns true if Gain control is supported. + */ + public boolean hasGainControl() + { + if (m_gainControl == null) + { + // Try to get Gain control again (to support J2SE 1.5) + if ( (m_line != null) && (m_line.isControlSupported(FloatControl.Type.MASTER_GAIN))) m_gainControl = (FloatControl) m_line.getControl(FloatControl.Type.MASTER_GAIN); + } + return m_gainControl != null; + } + + /** + * Returns Gain value. + */ + public float getGainValue() + { + if (hasGainControl()) + { + return m_gainControl.getValue(); + } + else + { + return 0.0F; + } + } + + /** + * Gets max Gain value. + */ + public float getMaximumGain() + { + if (hasGainControl()) + { + return m_gainControl.getMaximum(); + } + else + { + return 0.0F; + } + } + + /** + * Gets min Gain value. + */ + public float getMinimumGain() + { + if (hasGainControl()) + { + return m_gainControl.getMinimum(); + } + else + { + return 0.0F; + } + } + + /** + * Returns true if Pan control is supported. + */ + public boolean hasPanControl() + { + if (m_panControl == null) + { + // Try to get Pan control again (to support J2SE 1.5) + if ((m_line != null)&& (m_line.isControlSupported(FloatControl.Type.PAN))) m_panControl = (FloatControl) m_line.getControl(FloatControl.Type.PAN); + } + return m_panControl != null; + } + + /** + * Returns Pan precision. + */ + public float getPrecision() + { + if (hasPanControl()) + { + return m_panControl.getPrecision(); + } + else + { + return 0.0F; + } + } + + /** + * Returns Pan value. + */ + public float getPan() + { + if (hasPanControl()) + { + return m_panControl.getValue(); + } + else + { + return 0.0F; + } + } + + /** + * Deep copy of a Map. + * @param src + * @return + */ + protected Map deepCopy(Map src) + { + HashMap map = new HashMap(); + if (src != null) + { + Iterator it = src.keySet().iterator(); + while (it.hasNext()) + { + Object key = it.next(); + Object value = src.get(key); + map.put(key, value); + } + } + return map; + } + + /** + * @see javazoom.jlgui.basicplayer.BasicController#seek(long) + */ + public long seek(long bytes) throws BasicPlayerException + { + return skipBytes(bytes); + } + + /** + * @see javazoom.jlgui.basicplayer.BasicController#play() + */ + public void play() throws BasicPlayerException + { + startPlayback(); + } + + /** + * @see javazoom.jlgui.basicplayer.BasicController#stop() + */ + public void stop() throws BasicPlayerException + { + stopPlayback(); + } + + /** + * @see javazoom.jlgui.basicplayer.BasicController#pause() + */ + public void pause() throws BasicPlayerException + { + pausePlayback(); + } + + /** + * @see javazoom.jlgui.basicplayer.BasicController#resume() + */ + public void resume() throws BasicPlayerException + { + resumePlayback(); + } + + /** + * Sets Pan value. + * Line should be opened before calling this method. + * Linear scale : -1.0 <--> +1.0 + */ + public void setPan(double fPan) throws BasicPlayerException + { + if (hasPanControl()) + { + log.debug("Pan : " + fPan); + m_panControl.setValue((float) fPan); + notifyEvent(BasicPlayerEvent.PAN, getEncodedStreamPosition(), fPan, null); + } + else throw new BasicPlayerException(BasicPlayerException.PANCONTROLNOTSUPPORTED); + } + + /** + * Sets Gain value. + * Line should be opened before calling this method. + * Linear scale 0.0 <--> 1.0 + * Threshold Coef. : 1/2 to avoid saturation. + */ + public void setGain(double fGain) throws BasicPlayerException + { + if (hasGainControl()) + { + double minGainDB = getMinimumGain(); + double ampGainDB = ((10.0f / 20.0f) * getMaximumGain()) - getMinimumGain(); + double cste = Math.log(10.0) / 20; + double valueDB = minGainDB + (1 / cste) * Math.log(1 + (Math.exp(cste * ampGainDB) - 1) * fGain); + log.debug("Gain : " + valueDB); + m_gainControl.setValue((float) valueDB); + notifyEvent(BasicPlayerEvent.GAIN, getEncodedStreamPosition(), fGain, null); + } + else throw new BasicPlayerException(BasicPlayerException.GAINCONTROLNOTSUPPORTED); + } + + public List getMixers() + { + ArrayList mixers = new ArrayList(); + Mixer.Info[] mInfos = AudioSystem.getMixerInfo(); + if (mInfos != null) + { + for (int i = 0; i < mInfos.length; i++) + { + Line.Info lineInfo = new Line.Info(SourceDataLine.class); + Mixer mixer = AudioSystem.getMixer(mInfos[i]); + if (mixer.isLineSupported(lineInfo)) + { + mixers.add(mInfos[i].getName()); + } + } + } + return mixers; + } + + public Mixer getMixer(String name) + { + Mixer mixer = null; + if (name != null) + { + Mixer.Info[] mInfos = AudioSystem.getMixerInfo(); + if (mInfos != null) + { + for (int i = 0; i < mInfos.length; i++) + { + if (mInfos[i].getName().equals(name)) + { + mixer = AudioSystem.getMixer(mInfos[i]); + break; + } + } + } + } + return mixer; + } + + public String getMixerName() + { + return m_mixerName; + } + + public void setMixerName(String name) + { + m_mixerName = name; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEvent.java b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEvent.java new file mode 100644 index 0000000..c2c93bd --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEvent.java @@ -0,0 +1,121 @@ +/* + * BasicPlayerEvent. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.basicplayer; + +/** + * This class implements player events. + */ +public class BasicPlayerEvent +{ + public static final int UNKNOWN = -1; + public static final int OPENING = 0; + public static final int OPENED = 1; + public static final int PLAYING = 2; + public static final int STOPPED = 3; + public static final int PAUSED = 4; + public static final int RESUMED = 5; + public static final int SEEKING = 6; + public static final int SEEKED = 7; + public static final int EOM = 8; + public static final int PAN = 9; + public static final int GAIN = 10; + private int code = UNKNOWN; + private int position = -1; + private double value = -1.0; + private Object source = null; + private Object description = null; + + /** + * Constructor + * @param source of the event + * @param code of the envent + * @param position optional stream position + * @param value opitional control value + * @param desc optional description + */ + public BasicPlayerEvent(Object source, int code, int position, double value, Object desc) + { + this.value = value; + this.position = position; + this.source = source; + this.code = code; + this.description = desc; + } + + /** + * Return code of the event triggered. + * @return + */ + public int getCode() + { + return code; + } + + /** + * Return position in the stream when event occured. + * @return + */ + public int getPosition() + { + return position; + } + + /** + * Return value related to event triggered. + * @return + */ + public double getValue() + { + return value; + } + + /** + * Return description. + * @return + */ + public Object getDescription() + { + return description; + } + + public Object getSource() + { + return source; + } + + public String toString() + { + if (code == OPENED) return "OPENED:" + position; + else if (code == OPENING) return "OPENING:" + position + ":" + description; + else if (code == PLAYING) return "PLAYING:" + position; + else if (code == STOPPED) return "STOPPED:" + position; + else if (code == PAUSED) return "PAUSED:" + position; + else if (code == RESUMED) return "RESUMED:" + position; + else if (code == SEEKING) return "SEEKING:" + position; + else if (code == SEEKED) return "SEEKED:" + position; + else if (code == EOM) return "EOM:" + position; + else if (code == PAN) return "PAN:" + value; + else if (code == GAIN) return "GAIN:" + value; + else return "UNKNOWN:" + position; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEventLauncher.java b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEventLauncher.java new file mode 100644 index 0000000..5c3a136 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEventLauncher.java @@ -0,0 +1,73 @@ +/* + * BasicPlayerEventLauncher. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.basicplayer; + +import java.util.Collection; +import java.util.Iterator; + +/** + * This class implements a threaded events launcher. + */ +public class BasicPlayerEventLauncher extends Thread +{ + private int code = -1; + private int position = -1; + private double value = 0.0; + private Object description = null; + private Collection listeners = null; + private Object source = null; + + /** + * Contructor. + * @param code + * @param position + * @param value + * @param description + * @param listeners + * @param source + */ + public BasicPlayerEventLauncher(int code, int position, double value, Object description, Collection listeners, Object source) + { + super(); + this.code = code; + this.position = position; + this.value = value; + this.description = description; + this.listeners = listeners; + this.source = source; + } + + public void run() + { + if (listeners != null) + { + Iterator it = listeners.iterator(); + while (it.hasNext()) + { + BasicPlayerListener bpl = (BasicPlayerListener) it.next(); + BasicPlayerEvent event = new BasicPlayerEvent(source, code, position, value, description); + bpl.stateUpdated(event); + } + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerException.java b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerException.java new file mode 100644 index 0000000..df6e4b4 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerException.java @@ -0,0 +1,107 @@ +/* + * BasicPlayerException. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.basicplayer; + +import java.io.PrintStream; +import java.io.PrintWriter; + +/** + * This class implements custom exception for basicplayer. + */ +public class BasicPlayerException extends Exception +{ + public static final String GAINCONTROLNOTSUPPORTED = "Gain control not supported"; + public static final String PANCONTROLNOTSUPPORTED = "Pan control not supported"; + public static final String WAITERROR = "Wait error"; + public static final String CANNOTINITLINE = "Cannot init line"; + public static final String SKIPNOTSUPPORTED = "Skip not supported"; + private Throwable cause = null; + + public BasicPlayerException() + { + super(); + } + + public BasicPlayerException(String msg) + { + super(msg); + } + + public BasicPlayerException(Throwable cause) + { + super(); + this.cause = cause; + } + + public BasicPlayerException(String msg, Throwable cause) + { + super(msg); + this.cause = cause; + } + + public Throwable getCause() + { + return cause; + } + + /** + * Returns the detail message string of this throwable. If it was + * created with a null message, returns the following: + * (cause==null ? null : cause.toString()). + */ + public String getMessage() + { + if (super.getMessage() != null) + { + return super.getMessage(); + } + else if (cause != null) + { + return cause.toString(); + } + else + { + return null; + } + } + + public void printStackTrace() + { + printStackTrace(System.err); + } + + public void printStackTrace(PrintStream out) + { + synchronized (out) + { + PrintWriter pw = new PrintWriter(out, false); + printStackTrace(pw); + pw.flush(); + } + } + + public void printStackTrace(PrintWriter out) + { + if (cause != null) cause.printStackTrace(out); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerListener.java b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerListener.java new file mode 100644 index 0000000..1157ab2 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerListener.java @@ -0,0 +1,72 @@ +/* + * BasicPlayerListener. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.basicplayer; + +import java.util.Map; + +/** + * This interface defines callbacks methods that will be notified + * for all registered BasicPlayerListener of BasicPlayer. + */ +public interface BasicPlayerListener +{ + /** + * Open callback, stream is ready to play. + * + * properties map includes audio format dependant features such as + * bitrate, duration, frequency, channels, number of frames, vbr flag, + * id3v2/id3v1 (for MP3 only), comments (for Ogg Vorbis), ... + * + * @param stream could be File, URL or InputStream + * @param properties audio stream properties. + */ + public void opened(Object stream, Map properties); + + /** + * Progress callback while playing. + * + * This method is called severals time per seconds while playing. + * properties map includes audio format features such as + * instant bitrate, microseconds position, current frame number, ... + * + * @param bytesread from encoded stream. + * @param microseconds elapsed (reseted after a seek !). + * @param pcmdata PCM samples. + * @param properties audio stream parameters. + */ + public void progress(int bytesread, long microseconds, byte[] pcmdata, Map properties); + + /** + * Notification callback for basicplayer events such as opened, eom ... + * + * @param event + */ + public void stateUpdated(BasicPlayerEvent event); + + /** + * A handle to the BasicPlayer, plugins may control the player through + * the controller (play, stop, ...) + * @param controller : a handle to the player + */ + public void setController(BasicController controller); +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/Loader.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/Loader.java new file mode 100644 index 0000000..52b5b07 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/Loader.java @@ -0,0 +1,40 @@ +/* + * Loader. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp; + +import java.awt.Point; + +public interface Loader +{ + public void loaded(); + + public void close(); + + public void minimize(); + + public Point getLocation(); + + public void togglePlaylist(boolean enabled); + + public void toggleEqualizer(boolean enabled); +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerActionEvent.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerActionEvent.java new file mode 100644 index 0000000..8c9da95 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerActionEvent.java @@ -0,0 +1,99 @@ +/* + * PlayerActionEvent. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp; + +import java.awt.event.ActionEvent; + +public class PlayerActionEvent extends ActionEvent +{ + public static final String ACPREVIOUS = "Previous"; + public static final String ACPLAY = "Play"; + public static final String ACPAUSE = "Pause"; + public static final String ACSTOP = "Stop"; + public static final String ACNEXT = "Next"; + public static final String ACEJECT = "Eject"; + public static final String ACEQUALIZER = "EqualizerUI"; + public static final String ACPLAYLIST = "Playlist"; + public static final String ACSHUFFLE = "Shuffle"; + public static final String ACREPEAT = "Repeat"; + public static final String ACVOLUME = "Volume"; + public static final String ACBALANCE = "Balance"; + public static final String ACTITLEBAR = "TitleBar"; + public static final String ACEXIT = "Exit"; + public static final String ACMINIMIZE = "Minimize"; + public static final String ACPOSBAR = "Seek"; + public static final String MIPLAYFILE = "PlayFileMI"; + public static final String MIPLAYLOCATION = "PlayLocationMI"; + public static final String MIPLAYLIST = "PlaylistMI"; + public static final String MIEQUALIZER = "EqualizerMI"; + public static final String MIPREFERENCES = "PreferencesMI"; + public static final String MISKINBROWSER = "SkinBrowserMI"; + public static final String MILOADSKIN = "LoadSkinMI"; + public static final String MIJUMPFILE = "JumpFileMI"; + public static final String MISTOP = "StopMI"; + public static final String EQSLIDER = "SliderEQ"; + public static final String ACEQPRESETS = "PresetsEQ"; + public static final String ACEQONOFF = "OnOffEQ"; + public static final String ACEQAUTO = "AutoEQ"; + public static final String ACPLUP = "ScrollUpPL"; + public static final String ACPLDOWN = "ScrollDownPL"; + public static final String ACPLINFO = "InfoPL"; + public static final String ACPLPLAY = "PlayPL"; + public static final String ACPLREMOVE = "RemovePL"; + public static final String ACPLADDPOPUP = "AddPopupPL"; + public static final String ACPLADDFILE = "AddFilePL"; + public static final String ACPLADDDIR = "AddDirPL"; + public static final String ACPLADDURL = "AddURLPL"; + public static final String ACPLREMOVEPOPUP = "RemovePopupPL"; + public static final String ACPLREMOVEMISC = "RemoveMiscPL"; + public static final String ACPLREMOVESEL = "RemoveSelPL"; + public static final String ACPLREMOVEALL = "RemoveAllPL"; + public static final String ACPLREMOVECROP = "RemoveCropPL"; + public static final String ACPLSELPOPUP = "SelectPopupPL"; + public static final String ACPLSELALL = "SelectAllPL"; + public static final String ACPLSELZERO = "SelectZeroPL"; + public static final String ACPLSELINV = "SelectInvPL"; + public static final String ACPLMISCPOPUP = "MiscPopupPL"; + public static final String ACPLMISCOPTS = "MiscOptsPL"; + public static final String ACPLMISCFILE = "MiscFilePL"; + public static final String ACPLMISCSORT = "MiscSortPL"; + public static final String ACPLLISTPOPUP = "ListPopupPL"; + public static final String ACPLLISTLOAD = "ListLoadPL"; + public static final String ACPLLISTSAVE = "ListSavePL"; + public static final String ACPLLISTNEW = "ListNewPL"; + + public PlayerActionEvent(Object source, int id, String command) + { + super(source, id, command); + } + + public PlayerActionEvent(Object source, int id, String command, int modifiers) + { + super(source, id, command, modifiers); + } + + public PlayerActionEvent(Object source, int id, String command, long when, int modifiers) + { + super(source, id, command, when, modifiers); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerUI.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerUI.java new file mode 100644 index 0000000..47abd20 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerUI.java @@ -0,0 +1,1827 @@ +/* + * PlayerUI. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp; + +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.StringTokenizer; +import javax.sound.sampled.SourceDataLine; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javazoom.jlgui.basicplayer.BasicController; +import javazoom.jlgui.basicplayer.BasicPlayer; +import javazoom.jlgui.basicplayer.BasicPlayerEvent; +import javazoom.jlgui.basicplayer.BasicPlayerException; +import javazoom.jlgui.basicplayer.BasicPlayerListener; +import javazoom.jlgui.player.amp.equalizer.ui.EqualizerUI; +import javazoom.jlgui.player.amp.playlist.Playlist; +import javazoom.jlgui.player.amp.playlist.PlaylistFactory; +import javazoom.jlgui.player.amp.playlist.PlaylistItem; +import javazoom.jlgui.player.amp.playlist.ui.PlaylistUI; +import javazoom.jlgui.player.amp.skin.AbsoluteLayout; +import javazoom.jlgui.player.amp.skin.DropTargetAdapter; +import javazoom.jlgui.player.amp.skin.ImageBorder; +import javazoom.jlgui.player.amp.skin.PopupAdapter; +import javazoom.jlgui.player.amp.skin.Skin; +import javazoom.jlgui.player.amp.skin.UrlDialog; +import javazoom.jlgui.player.amp.tag.ui.TagSearch; +import javazoom.jlgui.player.amp.util.Config; +import javazoom.jlgui.player.amp.util.FileSelector; +import javazoom.jlgui.player.amp.util.ui.Preferences; +import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class PlayerUI extends JPanel implements ActionListener, ChangeListener, BasicPlayerListener +{ + private static Log log = LogFactory.getLog(PlayerUI.class); + public static final int INIT = 0; + public static final int OPEN = 1; + public static final int PLAY = 2; + public static final int PAUSE = 3; + public static final int STOP = 4; + public static final int TEXT_LENGTH_MAX = 30; + public static final long SCROLL_PERIOD = 250; + private Skin ui = null; + private Loader loader = null; + private Config config = null; + /*-- Pop up menus --*/ + private JPopupMenu mainpopup = null; + private JPopupMenu ejectpopup = null; + private JCheckBoxMenuItem miPlaylist = null; + private JCheckBoxMenuItem miEqualizer = null; + private JMenuItem miPlayFile = null; + private JMenuItem miPlayLocation = null; + private PopupAdapter popupAdapter = null; + private PopupAdapter ejectpopupAdapter = null; + /*-- Sound player --*/ + private BasicController theSoundPlayer = null; + private Map audioInfo = null; + private int playerState = INIT; + /*-- Title text --*/ + private String titleText = Skin.TITLETEXT.toUpperCase(); + private String currentTitle = Skin.TITLETEXT.toUpperCase(); + private String[] titleScrollLabel = null; + private int scrollIndex = 0; + private long lastScrollTime = 0L; + private boolean scrollRight = true; + private long secondsAmount = 0; + /*-- Playlist --*/ + private Playlist playlist = null; + private PlaylistUI playlistUI = null; + private String currentFileOrURL = null; + private String currentSongName = null; + private PlaylistItem currentPlaylistItem = null; + private boolean currentIsFile; + /*-- PosBar members --*/ + private boolean posValueJump = false; + private boolean posDragging = false; + private double posValue = 0.0; + /*-- EqualizerUI --*/ + private EqualizerUI equalizerUI = null; + + public PlayerUI() + { + super(); + setDoubleBuffered(true); + ui = new Skin(); + } + + public void setEqualizerUI(EqualizerUI eq) + { + equalizerUI = eq; + } + + public EqualizerUI getEqualizerUI() + { + return equalizerUI; + } + + public PlaylistUI getPlaylistUI() + { + return playlistUI; + } + + public void setPlaylistUI(PlaylistUI playlistUI) + { + this.playlistUI = playlistUI; + } + + public Playlist getPlaylist() + { + return playlist; + } + + /** + * Return config. + * @return + */ + public Config getConfig() + { + return config; + } + + /** + * Return skin. + * @return + */ + public Skin getSkin() + { + return ui; + } + + /** + * Return parent loader. + * @return + */ + public Loader getLoader() + { + return loader; + } + + /** + * A handle to the BasicPlayer, plugins may control the player through + * the controller (play, stop, ...) + * @param controller + */ + public void setController(BasicController controller) + { + theSoundPlayer = controller; + } + + /** + * Return player controller. + * @return + */ + public BasicController getController() + { + return theSoundPlayer; + } + + /** + * Load main player. + * @param loader + */ + public void loadUI(Loader loader) + { + this.loader = loader; + setLayout(new AbsoluteLayout()); + config = Config.getInstance(); + ui.setConfig(config); + playlistUI = new PlaylistUI(); + playlistUI.setSkin(ui); + playlistUI.setPlayer(this); + equalizerUI = new EqualizerUI(); + equalizerUI.setSkin(ui); + loadSkin(); + // DnD support. + DropTargetAdapter dnd = new DropTargetAdapter() + { + public void processDrop(Object data) + { + processDnD(data); + } + }; + DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true); + } + + public void loadSkin() + { + log.info("Load PlayerUI (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + removeAll(); + // Load skin specified in args + if (ui.getPath() != null) + { + log.info("Load default skin from " + ui.getPath()); + ui.loadSkin(ui.getPath()); + config.setDefaultSkin(ui.getPath()); + } + // Load skin specified in jlgui.ini + else if ((config.getDefaultSkin() != null) && (!config.getDefaultSkin().trim().equals(""))) + { + log.info("Load default skin from " + config.getDefaultSkin()); + ui.loadSkin(config.getDefaultSkin()); + } + // Default included skin + else + { + ClassLoader cl = getClass().getClassLoader(); + InputStream sis = cl.getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz"); + log.info("Load default skin for JAR"); + ui.loadSkin(sis); + } + // Background + ImageBorder border = new ImageBorder(); + border.setImage(ui.getMainImage()); + setBorder(border); + // Buttons + add(ui.getAcPrevious(), ui.getAcPrevious().getConstraints()); + ui.getAcPrevious().removeActionListener(this); + ui.getAcPrevious().addActionListener(this); + add(ui.getAcPlay(), ui.getAcPlay().getConstraints()); + ui.getAcPlay().removeActionListener(this); + ui.getAcPlay().addActionListener(this); + add(ui.getAcPause(), ui.getAcPause().getConstraints()); + ui.getAcPause().removeActionListener(this); + ui.getAcPause().addActionListener(this); + add(ui.getAcStop(), ui.getAcStop().getConstraints()); + ui.getAcStop().removeActionListener(this); + ui.getAcStop().addActionListener(this); + add(ui.getAcNext(), ui.getAcNext().getConstraints()); + ui.getAcNext().removeActionListener(this); + ui.getAcNext().addActionListener(this); + add(ui.getAcEject(), ui.getAcEject().getConstraints()); + ui.getAcEject().removeActionListener(this); + ui.getAcEject().addActionListener(this); + // EqualizerUI toggle + add(ui.getAcEqualizer(), ui.getAcEqualizer().getConstraints()); + ui.getAcEqualizer().removeActionListener(this); + ui.getAcEqualizer().addActionListener(this); + // Playlist toggle + add(ui.getAcPlaylist(), ui.getAcPlaylist().getConstraints()); + ui.getAcPlaylist().removeActionListener(this); + ui.getAcPlaylist().addActionListener(this); + // Shuffle toggle + add(ui.getAcShuffle(), ui.getAcShuffle().getConstraints()); + ui.getAcShuffle().removeActionListener(this); + ui.getAcShuffle().addActionListener(this); + // Repeat toggle + add(ui.getAcRepeat(), ui.getAcRepeat().getConstraints()); + ui.getAcRepeat().removeActionListener(this); + ui.getAcRepeat().addActionListener(this); + // Volume + add(ui.getAcVolume(), ui.getAcVolume().getConstraints()); + ui.getAcVolume().removeChangeListener(this); + ui.getAcVolume().addChangeListener(this); + // Balance + add(ui.getAcBalance(), ui.getAcBalance().getConstraints()); + ui.getAcBalance().removeChangeListener(this); + ui.getAcBalance().addChangeListener(this); + // Seek bar + add(ui.getAcPosBar(), ui.getAcPosBar().getConstraints()); + ui.getAcPosBar().removeChangeListener(this); + ui.getAcPosBar().addChangeListener(this); + // Mono + add(ui.getAcMonoIcon(), ui.getAcMonoIcon().getConstraints()); + // Stereo + add(ui.getAcStereoIcon(), ui.getAcStereoIcon().getConstraints()); + // Title label + add(ui.getAcTitleLabel(), ui.getAcTitleLabel().getConstraints()); + // Sample rate label + add(ui.getAcSampleRateLabel(), ui.getAcSampleRateLabel().getConstraints()); + // Bit rate label + add(ui.getAcBitRateLabel(), ui.getAcBitRateLabel().getConstraints()); + // Play icon + add(ui.getAcPlayIcon(), ui.getAcPlayIcon().getConstraints()); + // Time icon + add(ui.getAcTimeIcon(), ui.getAcTimeIcon().getConstraints()); + // MinuteH number + add(ui.getAcMinuteH(), ui.getAcMinuteH().getConstraints()); + // MinuteL number + add(ui.getAcMinuteL(), ui.getAcMinuteL().getConstraints()); + // SecondH number + add(ui.getAcSecondH(), ui.getAcSecondH().getConstraints()); + // SecondL number + add(ui.getAcSecondL(), ui.getAcSecondL().getConstraints()); + // TitleBar + add(ui.getAcTitleBar(), ui.getAcTitleBar().getConstraints()); + add(ui.getAcMinimize(), ui.getAcMinimize().getConstraints()); + ui.getAcMinimize().removeActionListener(this); + ui.getAcMinimize().addActionListener(this); + add(ui.getAcExit(), ui.getAcExit().getConstraints()); + ui.getAcExit().removeActionListener(this); + ui.getAcExit().addActionListener(this); + // DSP + if (ui.getAcAnalyzer() != null) + { + add(ui.getAcAnalyzer(), ui.getAcAnalyzer().getConstraints()); + } + // Popup menu + mainpopup = new JPopupMenu(ui.getResource("popup.title")); + JMenuItem mi = new JMenuItem(Skin.TITLETEXT + "- JavaZOOM"); + //mi.removeActionListener(this); + //mi.addActionListener(this); + mainpopup.add(mi); + mainpopup.addSeparator(); + JMenu playSubMenu = new JMenu(ui.getResource("popup.play")); + miPlayFile = new JMenuItem(ui.getResource("popup.play.file")); + miPlayFile.setActionCommand(PlayerActionEvent.MIPLAYFILE); + miPlayFile.removeActionListener(this); + miPlayFile.addActionListener(this); + miPlayLocation = new JMenuItem(ui.getResource("popup.play.location")); + miPlayLocation.setActionCommand(PlayerActionEvent.MIPLAYLOCATION); + miPlayLocation.removeActionListener(this); + miPlayLocation.addActionListener(this); + playSubMenu.add(miPlayFile); + playSubMenu.add(miPlayLocation); + mainpopup.add(playSubMenu); + mainpopup.addSeparator(); + miPlaylist = new JCheckBoxMenuItem(ui.getResource("popup.playlist")); + miPlaylist.setActionCommand(PlayerActionEvent.MIPLAYLIST); + if (config.isPlaylistEnabled()) miPlaylist.setState(true); + miPlaylist.removeActionListener(this); + miPlaylist.addActionListener(this); + mainpopup.add(miPlaylist); + miEqualizer = new JCheckBoxMenuItem(ui.getResource("popup.equalizer")); + miEqualizer.setActionCommand(PlayerActionEvent.MIEQUALIZER); + if (config.isEqualizerEnabled()) miEqualizer.setState(true); + miEqualizer.removeActionListener(this); + miEqualizer.addActionListener(this); + mainpopup.add(miEqualizer); + mainpopup.addSeparator(); + mi = new JMenuItem(ui.getResource("popup.preferences")); + mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.CTRL_MASK, false)); + mi.setActionCommand(PlayerActionEvent.MIPREFERENCES); + mi.removeActionListener(this); + mi.addActionListener(this); + mainpopup.add(mi); + JMenu skinsSubMenu = new JMenu(ui.getResource("popup.skins")); + mi = new JMenuItem(ui.getResource("popup.skins.browser")); + mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, ActionEvent.ALT_MASK, false)); + mi.setActionCommand(PlayerActionEvent.MISKINBROWSER); + mi.removeActionListener(this); + mi.addActionListener(this); + skinsSubMenu.add(mi); + mi = new JMenuItem(ui.getResource("popup.skins.load")); + mi.setActionCommand(PlayerActionEvent.MILOADSKIN); + mi.removeActionListener(this); + mi.addActionListener(this); + skinsSubMenu.add(mi); + mainpopup.add(skinsSubMenu); + JMenu playbackSubMenu = new JMenu(ui.getResource("popup.playback")); + mi = new JMenuItem(ui.getResource("popup.playback.jump")); + mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false)); + mi.setActionCommand(PlayerActionEvent.MIJUMPFILE); + mi.removeActionListener(this); + mi.addActionListener(this); + playbackSubMenu.add(mi); + mi = new JMenuItem(ui.getResource("popup.playback.stop")); + mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false)); + mi.setActionCommand(PlayerActionEvent.MISTOP); + mi.removeActionListener(this); + mi.addActionListener(this); + playbackSubMenu.add(mi); + mainpopup.add(playbackSubMenu); + mainpopup.addSeparator(); + mi = new JMenuItem(ui.getResource("popup.exit")); + mi.setActionCommand(PlayerActionEvent.ACEXIT); + mi.removeActionListener(this); + mi.addActionListener(this); + mainpopup.add(mi); + // Popup menu on TitleBar + ui.getAcTitleBar().removeMouseListener(popupAdapter); + popupAdapter = new PopupAdapter(mainpopup); + ui.getAcTitleBar().addMouseListener(popupAdapter); + // Popup menu on Eject button + ejectpopup = new JPopupMenu(); + mi = new JMenuItem(ui.getResource("popup.eject.openfile")); + mi.setActionCommand(PlayerActionEvent.MIPLAYFILE); + mi.removeActionListener(this); + mi.addActionListener(this); + ejectpopup.add(mi); + mi = new JMenuItem(ui.getResource("popup.eject.openlocation")); + mi.setActionCommand(PlayerActionEvent.MIPLAYLOCATION); + mi.removeActionListener(this); + mi.addActionListener(this); + ejectpopup.add(mi); + ui.getAcEject().removeMouseListener(ejectpopupAdapter); + ejectpopupAdapter = new PopupAdapter(ejectpopup); + ui.getAcEject().addMouseListener(ejectpopupAdapter); + // EqualizerUI + if (equalizerUI != null) equalizerUI.loadUI(); + if (playlistUI != null) playlistUI.loadUI(); + validate(); + loader.loaded(); + } + + /** + * Load playlist. + * @param playlistName + * @return + */ + public boolean loadPlaylist(String playlistName) + { + boolean loaded = false; + PlaylistFactory plf = PlaylistFactory.getInstance(); + playlist = plf.getPlaylist(); + if (playlist == null) + { + config.setPlaylistClassName("javazoom.jlgui.player.amp.playlist.BasePlaylist"); + playlist = plf.getPlaylist(); + } + playlistUI.setPlaylist(playlist); + if ((playlistName != null) && (!playlistName.equals(""))) + { + // M3U file or URL. + if ((playlistName.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) || (playlistName.toLowerCase().endsWith(ui.getResource("playlist.extension.pls")))) loaded = playlist.load(playlistName); + // Simple song. + else + { + String name = playlistName; + if (!Config.startWithProtocol(playlistName)) + { + int indn = playlistName.lastIndexOf(java.io.File.separatorChar); + if (indn != -1) name = playlistName.substring(indn + 1); + PlaylistItem pli = new PlaylistItem(name, playlistName, -1, true); + playlist.appendItem(pli); + loaded = true; + } + else + { + PlaylistItem pli = new PlaylistItem(name, playlistName, -1, false); + playlist.appendItem(pli); + loaded = true; + } + } + } + return loaded; + } + + /* (non-Javadoc) + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent e) + { + Object src = e.getSource(); + //log.debug("State (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + // Volume + if (src == ui.getAcVolume()) + { + Object[] args = { String.valueOf(ui.getAcVolume().getValue()) }; + String volumeText = MessageFormat.format(ui.getResource("slider.volume.text"), args); + ui.getAcTitleLabel().setAcText(volumeText); + try + { + int gainValue = ui.getAcVolume().getValue(); + int maxGain = ui.getAcVolume().getMaximum(); + if (gainValue == 0) theSoundPlayer.setGain(0); + else theSoundPlayer.setGain(((double) gainValue / (double) maxGain)); + config.setVolume(gainValue); + } + catch (BasicPlayerException ex) + { + log.debug("Cannot set gain", ex); + } + } + // Balance + else if (src == ui.getAcBalance()) + { + Object[] args = { String.valueOf(Math.abs(ui.getAcBalance().getValue() * 100 / Skin.BALANCEMAX)) }; + String balanceText = null; + if (ui.getAcBalance().getValue() > 0) + { + balanceText = MessageFormat.format(ui.getResource("slider.balance.text.right"), args); + } + else if (ui.getAcBalance().getValue() < 0) + { + balanceText = MessageFormat.format(ui.getResource("slider.balance.text.left"), args); + } + else + { + balanceText = MessageFormat.format(ui.getResource("slider.balance.text.center"), args); + } + ui.getAcTitleLabel().setAcText(balanceText); + try + { + float balanceValue = ui.getAcBalance().getValue() * 1.0f / Skin.BALANCEMAX; + theSoundPlayer.setPan(balanceValue); + } + catch (BasicPlayerException ex) + { + log.debug("Cannot set pan", ex); + } + } + else if (src == ui.getAcPosBar()) + { + if (ui.getAcPosBar().getValueIsAdjusting() == false) + { + if (posDragging == true) + { + posDragging = false; + posValue = ui.getAcPosBar().getValue() * 1.0 / Skin.POSBARMAX; + processSeek(posValue); + } + } + else + { + posDragging = true; + posValueJump = true; + } + } + } + + /* (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) + { + final ActionEvent evt = e; + if (e.getActionCommand().equals(PlayerActionEvent.ACPAUSE)) + { + processActionEvent(e); + } + else if ((e.getActionCommand().equals(PlayerActionEvent.ACPLAY)) && (playerState == PAUSE)) + { + processActionEvent(e); + } + else + { + new Thread("PlayerUIActionEvent") + { + public void run() + { + processActionEvent(evt); + } + }.start(); + } + } + + /** + * Process action event. + * @param e + */ + public void processActionEvent(ActionEvent e) + { + String cmd = e.getActionCommand(); + log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + // Preferences. + if (cmd.equalsIgnoreCase(PlayerActionEvent.MIPREFERENCES)) + { + processPreferences(e.getModifiers()); + } + // Skin browser + else if (cmd.equals(PlayerActionEvent.MISKINBROWSER)) + { + processSkinBrowser(e.getModifiers()); + } + // Jump to file + else if (cmd.equals(PlayerActionEvent.MIJUMPFILE)) + { + processJumpToFile(e.getModifiers()); + } + // Stop + else if (cmd.equals(PlayerActionEvent.MISTOP)) + { + processStop(MouseEvent.BUTTON1_MASK); + } + // Load skin + else if (e.getActionCommand().equals(PlayerActionEvent.MILOADSKIN)) + { + File[] file = FileSelector.selectFile(loader, FileSelector.OPEN, false, ui.getResource("skin.extension"), ui.getResource("loadskin.dialog.filtername"), new File(config.getLastDir())); + if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath()); + if (file != null) + { + String fsFile = file[0].getName(); + ui.setPath(config.getLastDir() + fsFile); + loadSkin(); + config.setDefaultSkin(ui.getPath()); + } + } + // Shuffle + else if (cmd.equals(PlayerActionEvent.ACSHUFFLE)) + { + if (ui.getAcShuffle().isSelected()) + { + config.setShuffleEnabled(true); + if (playlist != null) + { + playlist.shuffle(); + playlistUI.initPlayList(); + // Play from the top + PlaylistItem pli = playlist.getCursor(); + setCurrentSong(pli); + } + } + else + { + config.setShuffleEnabled(false); + } + } + // Repeat + else if (cmd.equals(PlayerActionEvent.ACREPEAT)) + { + if (ui.getAcRepeat().isSelected()) + { + config.setRepeatEnabled(true); + } + else + { + config.setRepeatEnabled(false); + } + } + // Play file + else if (cmd.equals(PlayerActionEvent.MIPLAYFILE)) + { + processEject(MouseEvent.BUTTON1_MASK); + } + // Play URL + else if (cmd.equals(PlayerActionEvent.MIPLAYLOCATION)) + { + processEject(MouseEvent.BUTTON3_MASK); + } + // Playlist menu item + else if (cmd.equals(PlayerActionEvent.MIPLAYLIST)) + { + ui.getAcPlaylist().setSelected(miPlaylist.getState()); + togglePlaylist(); + } + // Playlist toggle button + else if (cmd.equals(PlayerActionEvent.ACPLAYLIST)) + { + togglePlaylist(); + } + // EqualizerUI menu item + else if (cmd.equals(PlayerActionEvent.MIEQUALIZER)) + { + ui.getAcEqualizer().setSelected(miEqualizer.getState()); + toggleEqualizer(); + } + // EqualizerUI + else if (cmd.equals(PlayerActionEvent.ACEQUALIZER)) + { + toggleEqualizer(); + } + // Exit player + else if (cmd.equals(PlayerActionEvent.ACEXIT)) + { + closePlayer(); + } + // Minimize + else if (cmd.equals(PlayerActionEvent.ACMINIMIZE)) + { + loader.minimize(); + } + // Eject + else if (cmd.equals(PlayerActionEvent.ACEJECT)) + { + processEject(e.getModifiers()); + } + // Play + else if (cmd.equals(PlayerActionEvent.ACPLAY)) + { + processPlay(e.getModifiers()); + } + // Pause + else if (cmd.equals(PlayerActionEvent.ACPAUSE)) + { + processPause(e.getModifiers()); + } + // Stop + else if (cmd.equals(PlayerActionEvent.ACSTOP)) + { + processStop(e.getModifiers()); + } + // Next + else if (cmd.equals(PlayerActionEvent.ACNEXT)) + { + processNext(e.getModifiers()); + } + // Previous + else if (cmd.equals(PlayerActionEvent.ACPREVIOUS)) + { + processPrevious(e.getModifiers()); + } + } + + /* (non-Javadoc) + * @see javazoom.jlgui.basicplayer.BasicPlayerListener#opened(java.lang.Object, java.util.Map) + */ + public void opened(Object stream, Map properties) + { + // Not in EDT. + audioInfo = properties; + log.debug(properties.toString()); + } + + /* (non-Javadoc) + * @see javazoom.jlgui.basicplayer.BasicPlayerListener#stateUpdated(javazoom.jlgui.basicplayer.BasicPlayerEvent) + */ + public void stateUpdated(final BasicPlayerEvent event) + { + // Not in EDT. + processStateUpdated(event); + } + + /* (non-Javadoc) + * @see javazoom.jlgui.basicplayer.BasicPlayerListener#progress(int, long, byte[], java.util.Map) + */ + public void progress(int bytesread, long microseconds, byte[] pcmdata, Map properties) + { + // Not in EDT. + processProgress(bytesread, microseconds, pcmdata, properties); + } + + /** + * Process PREFERENCES event. + * @param modifiers + */ + protected void processPreferences(int modifiers) + { + Preferences preferences = Preferences.getInstance(this); + preferences.setLocation(loader.getLocation().x, loader.getLocation().y); + preferences.setSize(512, 350); + preferences.setVisible(true); + } + + /** + * Process SKINS BROWSER event. + * @param modifiers + */ + protected void processSkinBrowser(int modifiers) + { + Preferences preferences = Preferences.getInstance(this); + preferences.selectSkinBrowserPane(); + preferences.setLocation(loader.getLocation().x, loader.getLocation().y); + preferences.setSize(512, 350); + preferences.setVisible(true); + } + + /** + * Process JUMP FILE event. + * @param modifiers + */ + protected void processJumpToFile(int modifiers) + { + TagSearch ts = new TagSearch(this); + ts.setIconImage(config.getIconParent().getImage()); + ts.setSize(400, 300); + ts.setLocation(loader.getLocation()); + ts.display(); + } + + /** + * Process EJECT event. + * @param modifiers + */ + protected void processEject(int modifiers) + { + if ((playerState == PLAY) || (playerState == PAUSE)) + { + try + { + if (theSoundPlayer != null) + { + theSoundPlayer.stop(); + } + } + catch (BasicPlayerException e) + { + log.info("Cannot stop", e); + } + playerState = STOP; + } + if ((playerState == INIT) || (playerState == STOP) || (playerState == OPEN)) + { + PlaylistItem pli = null; + // Local File. + if (modifiers == MouseEvent.BUTTON1_MASK) + { + File[] file = FileSelector.selectFile(loader, FileSelector.OPEN, false, config.getExtensions(), ui.getResource("button.eject.filedialog.filtername"), new File(config.getLastDir())); + if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath()); + if (file != null) + { + String fsFile = file[0].getName(); + if (fsFile != null) + { + // Loads a new playlist. + if ((fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) || (fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls")))) + { + if (loadPlaylist(config.getLastDir() + fsFile)) + { + config.setPlaylistFilename(config.getLastDir() + fsFile); + playlist.begin(); + playlistUI.initPlayList(); + setCurrentSong(playlist.getCursor()); + playlistUI.repaint(); + } + } + else if (fsFile.toLowerCase().endsWith(ui.getResource("skin.extension"))) + { + ui.setPath(config.getLastDir() + fsFile); + loadSkin(); + config.setDefaultSkin(ui.getPath()); + } + else pli = new PlaylistItem(fsFile, config.getLastDir() + fsFile, -1, true); + } + } + } + // Remote File. + else if (modifiers == MouseEvent.BUTTON3_MASK) + { + UrlDialog UD = new UrlDialog(config.getTopParent(), ui.getResource("button.eject.urldialog.title"), loader.getLocation().x, loader.getLocation().y + 10, config.getLastURL()); + UD.show(); + if (UD.getFile() != null) + { + showTitle(ui.getResource("title.loading")); + // Remote playlist ? + if ((UD.getURL().toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) || (UD.getURL().toLowerCase().endsWith(ui.getResource("playlist.extension.pls")))) + { + if (loadPlaylist(UD.getURL())) + { + config.setPlaylistFilename(UD.getURL()); + playlist.begin(); + playlistUI.initPlayList(); + setCurrentSong(playlist.getCursor()); + playlistUI.repaint(); + } + } + // Remote file or stream. + else + { + pli = new PlaylistItem(UD.getFile(), UD.getURL(), -1, false); + } + config.setLastURL(UD.getURL()); + } + } + if ((pli != null) && (playlist != null)) + { + playlist.removeAllItems(); + playlist.appendItem(pli); + playlist.nextCursor(); + playlistUI.initPlayList(); + setCurrentSong(pli); + playlistUI.repaint(); + } + } + // Display play/time icons. + ui.getAcPlayIcon().setIcon(2); + ui.getAcTimeIcon().setIcon(1); + } + + /** + * Process PLAY event. + * @param modifiers + */ + protected void processPlay(int modifiers) + { + if (playlist.isModified()) // playlist has been modified since we were last there, must update our cursor pos etc. + { + PlaylistItem pli = playlist.getCursor(); + if (pli == null) + { + playlist.begin(); + pli = playlist.getCursor(); + } + setCurrentSong(pli); + playlist.setModified(false); + playlistUI.repaint(); + } + // Resume is paused. + if (playerState == PAUSE) + { + try + { + theSoundPlayer.resume(); + } + catch (BasicPlayerException e) + { + log.error("Cannot resume", e); + } + playerState = PLAY; + ui.getAcPlayIcon().setIcon(0); + ui.getAcTimeIcon().setIcon(0); + } + // Stop if playing. + else if (playerState == PLAY) + { + try + { + theSoundPlayer.stop(); + } + catch (BasicPlayerException e) + { + log.error("Cannot stop", e); + } + playerState = PLAY; + secondsAmount = 0; + ui.getAcMinuteH().setAcText("0"); + ui.getAcMinuteL().setAcText("0"); + ui.getAcSecondH().setAcText("0"); + ui.getAcSecondL().setAcText("0"); + if (currentFileOrURL != null) + { + try + { + if (currentIsFile == true) theSoundPlayer.open(openFile(currentFileOrURL)); + else + { + theSoundPlayer.open(new URL(currentFileOrURL)); + } + theSoundPlayer.play(); + } + catch (Exception ex) + { + log.error("Cannot read file : " + currentFileOrURL, ex); + showMessage(ui.getResource("title.invalidfile")); + } + } + } + else if ((playerState == STOP) || (playerState == OPEN)) + { + try + { + theSoundPlayer.stop(); + } + catch (BasicPlayerException e) + { + log.error("Stop failed", e); + } + if (currentFileOrURL != null) + { + try + { + if (currentIsFile == true) theSoundPlayer.open(openFile(currentFileOrURL)); + else theSoundPlayer.open(new URL(currentFileOrURL)); + theSoundPlayer.play(); + titleText = currentSongName.toUpperCase(); + // Get bitrate, samplingrate, channels, time in the following order : + // PlaylistItem, BasicPlayer (JavaSound SPI), Manual computation. + int bitRate = -1; + if (currentPlaylistItem != null) bitRate = currentPlaylistItem.getBitrate(); + if ((bitRate <= 0) && (audioInfo.containsKey("bitrate"))) bitRate = ((Integer) audioInfo.get("bitrate")).intValue(); + if ((bitRate <= 0) && (audioInfo.containsKey("audio.framerate.fps")) && (audioInfo.containsKey("audio.framesize.bytes"))) + { + float FR = ((Float) audioInfo.get("audio.framerate.fps")).floatValue(); + int FS = ((Integer) audioInfo.get("audio.framesize.bytes")).intValue(); + bitRate = Math.round(FS * FR * 8); + } + int channels = -1; + if (currentPlaylistItem != null) channels = currentPlaylistItem.getChannels(); + if ((channels <= 0) && (audioInfo.containsKey("audio.channels"))) channels = ((Integer) audioInfo.get("audio.channels")).intValue(); + float sampleRate = -1.0f; + if (currentPlaylistItem != null) sampleRate = currentPlaylistItem.getSamplerate(); + if ((sampleRate <= 0) && (audioInfo.containsKey("audio.samplerate.hz"))) sampleRate = ((Float) audioInfo.get("audio.samplerate.hz")).floatValue(); + long lenghtInSecond = -1L; + if (currentPlaylistItem != null) lenghtInSecond = currentPlaylistItem.getLength(); + if ((lenghtInSecond <= 0) && (audioInfo.containsKey("duration"))) lenghtInSecond = ((Long) audioInfo.get("duration")).longValue() / 1000000; + if ((lenghtInSecond <= 0) && (audioInfo.containsKey("audio.length.bytes"))) + { + // Try to compute time length. + lenghtInSecond = (long) Math.round(getTimeLengthEstimation(audioInfo) / 1000); + if (lenghtInSecond > 0) + { + int minutes = (int) Math.floor(lenghtInSecond / 60); + int hours = (int) Math.floor(minutes / 60); + minutes = minutes - hours * 60; + int seconds = (int) (lenghtInSecond - minutes * 60 - hours * 3600); + if (seconds >= 10) titleText = "(" + minutes + ":" + seconds + ") " + titleText; + else titleText = "(" + minutes + ":0" + seconds + ") " + titleText; + } + } + bitRate = Math.round((bitRate / 1000)); + ui.getAcSampleRateLabel().setAcText(String.valueOf(Math.round((sampleRate / 1000)))); + if (bitRate > 999) + { + bitRate = (int) (bitRate / 100); + ui.getAcBitRateLabel().setAcText(bitRate + "H"); + } + else + { + ui.getAcBitRateLabel().setAcText(String.valueOf(bitRate)); + } + if (channels == 2) + { + ui.getAcStereoIcon().setIcon(1); + ui.getAcMonoIcon().setIcon(0); + } + else if (channels == 1) + { + ui.getAcStereoIcon().setIcon(0); + ui.getAcMonoIcon().setIcon(1); + } + showTitle(titleText); + ui.getAcMinuteH().setAcText("0"); + ui.getAcMinuteL().setAcText("0"); + ui.getAcSecondH().setAcText("0"); + ui.getAcSecondL().setAcText("0"); + ui.getAcPlayIcon().setIcon(0); + ui.getAcTimeIcon().setIcon(0); + } + catch (BasicPlayerException bpe) + { + log.info("Stream error :" + currentFileOrURL, bpe); + showMessage(ui.getResource("title.invalidfile")); + } + catch (MalformedURLException mue) + { + log.info("Stream error :" + currentFileOrURL, mue); + showMessage(ui.getResource("title.invalidfile")); + } + // Set pan/gain. + try + { + theSoundPlayer.setGain(((double) ui.getAcVolume().getValue() / (double) ui.getAcVolume().getMaximum())); + theSoundPlayer.setPan((float) ui.getAcBalance().getValue() / 10.0f); + } + catch (BasicPlayerException e) + { + log.info("Cannot set control", e); + } + playerState = PLAY; + log.info(titleText); + } + } + } + + /** + * Process PAUSE event. + * @param modifiers + */ + public void processPause(int modifiers) + { + if (playerState == PLAY) + { + try + { + theSoundPlayer.pause(); + } + catch (BasicPlayerException e) + { + log.error("Cannot pause", e); + } + playerState = PAUSE; + ui.getAcPlayIcon().setIcon(1); + ui.getAcTimeIcon().setIcon(1); + } + else if (playerState == PAUSE) + { + try + { + theSoundPlayer.resume(); + } + catch (BasicPlayerException e) + { + log.info("Cannot resume", e); + } + playerState = PLAY; + ui.getAcPlayIcon().setIcon(0); + ui.getAcTimeIcon().setIcon(0); + } + } + + /** + * Process STOP event. + * @param modifiers + */ + public void processStop(int modifiers) + { + if ((playerState == PAUSE) || (playerState == PLAY)) + { + try + { + theSoundPlayer.stop(); + } + catch (BasicPlayerException e) + { + log.info("Cannot stop", e); + } + playerState = STOP; + secondsAmount = 0; + ui.getAcPosBar().setValue(0); + ui.getAcPlayIcon().setIcon(2); + ui.getAcTimeIcon().setIcon(1); + } + } + + /** + * Process NEXT event. + * @param modifiers + */ + public void processNext(int modifiers) + { + // Try to get next song from the playlist + playlist.nextCursor(); + playlistUI.nextCursor(); + PlaylistItem pli = playlist.getCursor(); + setCurrentSong(pli); + } + + /** + * Process PREVIOUS event. + * @param modifiers + */ + public void processPrevious(int modifiers) + { + // Try to get previous song from the playlist + playlist.previousCursor(); + playlistUI.nextCursor(); + PlaylistItem pli = playlist.getCursor(); + setCurrentSong(pli); + } + + /** + * Process STATEUPDATED event. + * @param event + */ + public void processStateUpdated(BasicPlayerEvent event) + { + log.debug("Player:" + event + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + /*-- End Of Media reached --*/ + int state = event.getCode(); + Object obj = event.getDescription(); + if (state == BasicPlayerEvent.EOM) + { + if ((playerState == PAUSE) || (playerState == PLAY)) + { + playlist.nextCursor(); + playlistUI.nextCursor(); + PlaylistItem pli = playlist.getCursor(); + setCurrentSong(pli); + } + } + else if (state == BasicPlayerEvent.PLAYING) + { + lastScrollTime = System.currentTimeMillis(); + posValueJump = false; + if (audioInfo.containsKey("basicplayer.sourcedataline")) + { + if (ui.getAcAnalyzer() != null) + { + ui.getAcAnalyzer().setupDSP((SourceDataLine) audioInfo.get("basicplayer.sourcedataline")); + ui.getAcAnalyzer().startDSP((SourceDataLine) audioInfo.get("basicplayer.sourcedataline")); + } + } + } + else if (state == BasicPlayerEvent.SEEKING) + { + posValueJump = true; + } + else if (state == BasicPlayerEvent.SEEKED) + { + try + { + theSoundPlayer.setGain(((double) ui.getAcVolume().getValue() / (double) ui.getAcVolume().getMaximum())); + theSoundPlayer.setPan((float) ui.getAcBalance().getValue() / 10.0f); + } + catch (BasicPlayerException e) + { + log.debug(e); + } + } + else if (state == BasicPlayerEvent.OPENING) + { + if ((obj instanceof URL) || (obj instanceof InputStream)) + { + showTitle(ui.getResource("title.buffering")); + } + } + else if (state == BasicPlayerEvent.STOPPED) + { + if (ui.getAcAnalyzer() != null) + { + ui.getAcAnalyzer().stopDSP(); + ui.getAcAnalyzer().repaint(); + } + } + } + + /** + * Process PROGRESS event. + * @param bytesread + * @param microseconds + * @param pcmdata + * @param properties + */ + public void processProgress(int bytesread, long microseconds, byte[] pcmdata, Map properties) + { + //log.debug("Player: Progress (EDT="+SwingUtilities.isEventDispatchThread()+")"); + int byteslength = -1; + long total = -1; + // Try to get time from playlist item. + if (currentPlaylistItem != null) total = currentPlaylistItem.getLength(); + // If it fails then try again with JavaSound SPI. + if (total <= 0) total = (long) Math.round(getTimeLengthEstimation(audioInfo) / 1000); + // If it fails again then it might be stream => Total = -1 + if (total <= 0) total = -1; + if (audioInfo.containsKey("basicplayer.sourcedataline")) + { + // Spectrum/time analyzer + if (ui.getAcAnalyzer() != null) ui.getAcAnalyzer().writeDSP(pcmdata); + } + if (audioInfo.containsKey("audio.length.bytes")) + { + byteslength = ((Integer) audioInfo.get("audio.length.bytes")).intValue(); + } + float progress = -1.0f; + if ((bytesread > 0) && ((byteslength > 0))) progress = bytesread * 1.0f / byteslength * 1.0f; + if (audioInfo.containsKey("audio.type")) + { + String audioformat = (String) audioInfo.get("audio.type"); + if (audioformat.equalsIgnoreCase("mp3")) + { + //if (properties.containsKey("mp3.position.microseconds")) secondsAmount = (long) Math.round(((Long) properties.get("mp3.position.microseconds")).longValue()/1000000); + // Shoutcast stream title. + if (properties.containsKey("mp3.shoutcast.metadata.StreamTitle")) + { + String shoutTitle = ((String) properties.get("mp3.shoutcast.metadata.StreamTitle")).trim(); + if (shoutTitle.length() > 0) + { + if (currentPlaylistItem != null) + { + String sTitle = " (" + currentPlaylistItem.getFormattedDisplayName() + ")"; + if (!currentPlaylistItem.getFormattedName().equals(shoutTitle + sTitle)) + { + currentPlaylistItem.setFormattedDisplayName(shoutTitle + sTitle); + showTitle((shoutTitle + sTitle).toUpperCase()); + playlistUI.paintList(); + } + } + } + } + // EqualizerUI + if (properties.containsKey("mp3.equalizer")) equalizerUI.setBands((float[]) properties.get("mp3.equalizer")); + if (total > 0) secondsAmount = (long) (total * progress); + else secondsAmount = -1; + } + else if (audioformat.equalsIgnoreCase("wave")) + { + secondsAmount = (long) (total * progress); + } + else + { + secondsAmount = (long) Math.round(microseconds / 1000000); + equalizerUI.setBands(null); + } + } + else + { + secondsAmount = (long) Math.round(microseconds / 1000000); + equalizerUI.setBands(null); + } + if (secondsAmount < 0) secondsAmount = (long) Math.round(microseconds / 1000000); + /*-- Display elapsed time --*/ + int secondD = 0, second = 0, minuteD = 0, minute = 0; + int seconds = (int) secondsAmount; + int minutes = (int) Math.floor(seconds / 60); + int hours = (int) Math.floor(minutes / 60); + minutes = minutes - hours * 60; + seconds = seconds - minutes * 60 - hours * 3600; + if (seconds < 10) + { + secondD = 0; + second = seconds; + } + else + { + secondD = ((int) seconds / 10); + second = ((int) (seconds - (((int) seconds / 10)) * 10)); + } + if (minutes < 10) + { + minuteD = 0; + minute = minutes; + } + else + { + minuteD = ((int) minutes / 10); + minute = ((int) (minutes - (((int) minutes / 10)) * 10)); + } + ui.getAcMinuteH().setAcText(String.valueOf(minuteD)); + ui.getAcMinuteL().setAcText(String.valueOf(minute)); + ui.getAcSecondH().setAcText(String.valueOf(secondD)); + ui.getAcSecondL().setAcText(String.valueOf(second)); + // Update PosBar location. + if (total != 0) + { + if (posValueJump == false) + { + int posValue = ((int) Math.round(secondsAmount * Skin.POSBARMAX / total)); + ui.getAcPosBar().setValue(posValue); + } + } + else ui.getAcPosBar().setValue(0); + long ctime = System.currentTimeMillis(); + long lctime = lastScrollTime; + // Scroll title ? + if ((titleScrollLabel != null) && (titleScrollLabel.length > 0)) + { + if (ctime - lctime > SCROLL_PERIOD) + { + lastScrollTime = ctime; + if (scrollRight == true) + { + scrollIndex++; + if (scrollIndex >= titleScrollLabel.length) + { + scrollIndex--; + scrollRight = false; + } + } + else + { + scrollIndex--; + if (scrollIndex <= 0) + { + scrollRight = true; + } + } + // TODO : Improve + ui.getAcTitleLabel().setAcText(titleScrollLabel[scrollIndex]); + } + } + } + + /** + * Process seek feature. + * @param rate + */ + protected void processSeek(double rate) + { + try + { + if ((audioInfo != null) && (audioInfo.containsKey("audio.type"))) + { + String type = (String) audioInfo.get("audio.type"); + // Seek support for MP3. + if ((type.equalsIgnoreCase("mp3")) && (audioInfo.containsKey("audio.length.bytes"))) + { + long skipBytes = (long) Math.round(((Integer) audioInfo.get("audio.length.bytes")).intValue() * rate); + log.debug("Seek value (MP3) : " + skipBytes); + theSoundPlayer.seek(skipBytes); + } + // Seek support for WAV. + else if ((type.equalsIgnoreCase("wave")) && (audioInfo.containsKey("audio.length.bytes"))) + { + long skipBytes = (long) Math.round(((Integer) audioInfo.get("audio.length.bytes")).intValue() * rate); + log.debug("Seek value (WAVE) : " + skipBytes); + theSoundPlayer.seek(skipBytes); + } + else posValueJump = false; + } + else posValueJump = false; + } + catch (BasicPlayerException ioe) + { + log.error("Cannot skip", ioe); + posValueJump = false; + } + } + + /** + * Process Drag&Drop + * @param data + */ + public void processDnD(Object data) + { + log.debug("Player DnD"); + // Looking for files to drop. + if (data instanceof List) + { + List al = (List) data; + if ((al != null) && (al.size() > 0)) + { + ArrayList fileList = new ArrayList(); + ArrayList folderList = new ArrayList(); + ListIterator li = al.listIterator(); + while (li.hasNext()) + { + File f = (File) li.next(); + if ((f.exists()) && (f.canRead())) + { + if (f.isFile()) fileList.add(f); + else if (f.isDirectory()) folderList.add(f); + } + } + playFiles(fileList); + // TODO : Add dir support + } + } + else if (data instanceof String) + { + String files = (String) data; + if ((files.length() > 0)) + { + ArrayList fileList = new ArrayList(); + ArrayList folderList = new ArrayList(); + StringTokenizer st = new StringTokenizer(files, System.getProperty("line.separator")); + // Transfer files dropped. + while (st.hasMoreTokens()) + { + String path = st.nextToken(); + if (path.startsWith("file://")) + { + path = path.substring(7, path.length()); + if (path.endsWith("\r")) path = path.substring(0, (path.length() - 1)); + } + File f = new File(path); + if ((f.exists()) && (f.canRead())) + { + if (f.isFile()) fileList.add(f); + else if (f.isDirectory()) folderList.add(f); + } + } + playFiles(fileList); + // TODO : Add dir support + } + } + else + { + log.info("Unknown dropped objects"); + } + } + + /** + * Play files from a list. + * @param files + */ + protected void playFiles(List files) + { + if (files.size() > 0) + { + // Clean the playlist. + playlist.removeAllItems(); + // Add all dropped files to playlist. + ListIterator li = files.listIterator(); + while (li.hasNext()) + { + File file = (File) li.next(); + PlaylistItem pli = null; + if (file != null) + { + pli = new PlaylistItem(file.getName(), file.getAbsolutePath(), -1, true); + if (pli != null) playlist.appendItem(pli); + } + } + // Start the playlist from the top. + playlist.nextCursor(); + playlistUI.initPlayList(); + setCurrentSong(playlist.getCursor()); + } + } + + /** + * Sets the current song to play and start playing if needed. + * @param pli + */ + public void setCurrentSong(PlaylistItem pli) + { + int playerStateMem = playerState; + if ((playerState == PAUSE) || (playerState == PLAY)) + { + try + { + theSoundPlayer.stop(); + } + catch (BasicPlayerException e) + { + log.error("Cannot stop", e); + } + playerState = STOP; + secondsAmount = 0; + // Display play/time icons. + ui.getAcPlayIcon().setIcon(2); + ui.getAcTimeIcon().setIcon(0); + } + playerState = OPEN; + if (pli != null) + { + // Read tag info. + pli.getTagInfo(); + currentSongName = pli.getFormattedName(); + currentFileOrURL = pli.getLocation(); + currentIsFile = pli.isFile(); + currentPlaylistItem = pli; + } + // Playlist ended. + else + { + // Try to repeat ? + if (config.isRepeatEnabled()) + { + if (playlist != null) + { + // PlaylistItems available ? + if (playlist.getPlaylistSize() > 0) + { + playlist.begin(); + PlaylistItem rpli = playlist.getCursor(); + if (rpli != null) + { + // OK, Repeat the playlist. + rpli.getTagInfo(); + currentSongName = rpli.getFormattedName(); + currentFileOrURL = rpli.getLocation(); + currentIsFile = rpli.isFile(); + currentPlaylistItem = rpli; + } + } + // No, so display Title. + else + { + currentSongName = Skin.TITLETEXT; + currentFileOrURL = null; + currentIsFile = false; + currentPlaylistItem = null; + } + } + } + // No, so display Title. + else + { + currentSongName = Skin.TITLETEXT; + currentFileOrURL = null; + currentIsFile = false; + currentPlaylistItem = null; + } + } + if (currentIsFile == true) + { + ui.getAcPosBar().setEnabled(true); + ui.getAcPosBar().setHideThumb(false); + } + else + { + config.setLastURL(currentFileOrURL); + ui.getAcPosBar().setEnabled(false); + ui.getAcPosBar().setHideThumb(true); + } + titleText = currentSongName.toUpperCase(); + showMessage(titleText); + // Start playing if needed. + if ((playerStateMem == PLAY) || (playerStateMem == PAUSE)) + { + processPlay(MouseEvent.BUTTON1_MASK); + } + } + + /** + * Display text in title area. + * @param str + */ + public void showTitle(String str) + { + if (str != null) + { + currentTitle = str; + titleScrollLabel = null; + scrollIndex = 0; + scrollRight = true; + if (str.length() > TEXT_LENGTH_MAX) + { + int a = ((str.length()) - (TEXT_LENGTH_MAX)) + 1; + titleScrollLabel = new String[a]; + for (int k = 0; k < a; k++) + { + String sText = str.substring(k, TEXT_LENGTH_MAX + k); + titleScrollLabel[k] = sText; + } + str = str.substring(0, TEXT_LENGTH_MAX); + } + ui.getAcTitleLabel().setAcText(str); + } + } + + /** + * Shows message in title an updates bitRate,sampleRate, Mono/Stereo,time features. + * @param txt + */ + public void showMessage(String txt) + { + showTitle(txt); + ui.getAcSampleRateLabel().setAcText(" "); + ui.getAcBitRateLabel().setAcText(" "); + ui.getAcStereoIcon().setIcon(0); + ui.getAcMonoIcon().setIcon(0); + ui.getAcMinuteH().setAcText("0"); + ui.getAcMinuteL().setAcText("0"); + ui.getAcSecondH().setAcText("0"); + ui.getAcSecondL().setAcText("0"); + } + + /** + * Toggle playlistUI. + */ + protected void togglePlaylist() + { + if (ui.getAcPlaylist().isSelected()) + { + miPlaylist.setState(true); + config.setPlaylistEnabled(true); + loader.togglePlaylist(true); + } + else + { + miPlaylist.setState(false); + config.setPlaylistEnabled(false); + loader.togglePlaylist(false); + } + } + + /** + * Toggle equalizerUI. + */ + protected void toggleEqualizer() + { + if (ui.getAcEqualizer().isSelected()) + { + miEqualizer.setState(true); + config.setEqualizerEnabled(true); + loader.toggleEqualizer(true); + } + else + { + miEqualizer.setState(false); + config.setEqualizerEnabled(false); + loader.toggleEqualizer(false); + } + } + + /** + * Returns a File from a filename. + * @param file + * @return + */ + protected File openFile(String file) + { + return new File(file); + } + + /** + * Free resources and close the player. + */ + protected void closePlayer() + { + if ((playerState == PAUSE) || (playerState == PLAY)) + { + try + { + if (theSoundPlayer != null) + { + theSoundPlayer.stop(); + } + } + catch (BasicPlayerException e) + { + log.error("Cannot stop", e); + } + } + if (theSoundPlayer != null) + { + config.setAudioDevice(((BasicPlayer) theSoundPlayer).getMixerName()); + } + if (ui.getAcAnalyzer() != null) + { + if (ui.getAcAnalyzer().getDisplayMode() == SpectrumTimeAnalyzer.DISPLAY_MODE_OFF) config.setVisualMode("off"); + else if (ui.getAcAnalyzer().getDisplayMode() == SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE) config.setVisualMode("oscillo"); + else config.setVisualMode("spectrum"); + } + if (playlist != null) + { + playlist.save("default.m3u"); + config.setPlaylistFilename("default.m3u"); + } + loader.close(); + } + + /** + * Return current title in player. + * @return + */ + public String getCurrentTitle() + { + return currentTitle; + } + + /** + * Try to compute time length in milliseconds. + * @param properties + * @return + */ + public long getTimeLengthEstimation(Map properties) + { + long milliseconds = -1; + int byteslength = -1; + if (properties != null) + { + if (properties.containsKey("audio.length.bytes")) + { + byteslength = ((Integer) properties.get("audio.length.bytes")).intValue(); + } + if (properties.containsKey("duration")) + { + milliseconds = (int) (((Long) properties.get("duration")).longValue()) / 1000; + } + else + { + // Try to compute duration + int bitspersample = -1; + int channels = -1; + float samplerate = -1.0f; + int framesize = -1; + if (properties.containsKey("audio.samplesize.bits")) + { + bitspersample = ((Integer) properties.get("audio.samplesize.bits")).intValue(); + } + if (properties.containsKey("audio.channels")) + { + channels = ((Integer) properties.get("audio.channels")).intValue(); + } + if (properties.containsKey("audio.samplerate.hz")) + { + samplerate = ((Float) properties.get("audio.samplerate.hz")).floatValue(); + } + if (properties.containsKey("audio.framesize.bytes")) + { + framesize = ((Integer) properties.get("audio.framesize.bytes")).intValue(); + } + if (bitspersample > 0) + { + milliseconds = (int) (1000.0f * byteslength / (samplerate * channels * (bitspersample / 8))); + } + else + { + milliseconds = (int) (1000.0f * byteslength / (samplerate * framesize)); + } + } + } + return milliseconds; + } + + /** + * Simulates "Play" selection. + */ + public void pressStart() + { + ui.getAcPlay().doClick(); + } + + /** + * Simulates "Pause" selection. + */ + public void pressPause() + { + ui.getAcPause().doClick(); + } + + /** + * Simulates "Stop" selection. + */ + public void pressStop() + { + ui.getAcStop().doClick(); + } + + /** + * Simulates "Next" selection. + */ + public void pressNext() + { + ui.getAcNext().doClick(); + } + + /** + * Simulates "Previous" selection. + */ + public void pressPrevious() + { + ui.getAcPrevious().doClick(); + } + + /** + * Simulates "Eject" selection. + */ + public void pressEject() + { + ui.getAcEject().doClick(); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/StandalonePlayer.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/StandalonePlayer.java new file mode 100644 index 0000000..ec249d2 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/StandalonePlayer.java @@ -0,0 +1,500 @@ +/* + * StandalonePlayer. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.net.URL; +import java.util.Iterator; +import java.util.List; +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ImageIcon; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JWindow; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javazoom.jlgui.basicplayer.BasicPlayer; +import javazoom.jlgui.player.amp.skin.DragAdapter; +import javazoom.jlgui.player.amp.skin.Skin; +import javazoom.jlgui.player.amp.util.Config; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class StandalonePlayer extends JFrame implements Loader +{ + private static Log log = LogFactory.getLog(StandalonePlayer.class); + /*-- Run parameters --*/ + private String initConfig = "jlgui.ini"; + private String initSong = null; + private String showPlaylist = null; + private String showEqualizer = null; + private String showDsp = null; + private String skinPath = null; + private String skinVersion = "1"; // 1, 2, for different Volume.bmp + private boolean autoRun = false; + /*-- Front-end --*/ + private PlayerUI mp = null; + private JWindow eqWin = null; + private JWindow plWin = null; + private int eqFactor = 2; + private Config config = null; + private boolean playlistfound = false; + + public StandalonePlayer() + { + super(); + } + + /** + * @param args + */ + public static void main(String[] args) + { + final StandalonePlayer player = new StandalonePlayer(); + player.parseParameters(args); + SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + player.loadUI(); + player.loadJS(); + player.loadPlaylist(); + player.boot(); + } + }); + } + + /** + * Initialize the player front-end. + * @param args + */ + private void parseParameters(String[] args) + { + String currentArg = null; + String currentValue = null; + for (int i = 0; i < args.length; i++) + { + currentArg = args[i]; + if (currentArg.startsWith("-")) + { + if (currentArg.toLowerCase().equals("-init")) + { + i++; + if (i >= args.length) usage("init value missing"); + currentValue = args[i]; + if (Config.startWithProtocol(currentValue)) initConfig = currentValue; + else initConfig = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar); + } + else if (currentArg.toLowerCase().equals("-song")) + { + i++; + if (i >= args.length) usage("song value missing"); + currentValue = args[i]; + if (Config.startWithProtocol(currentValue)) initSong = currentValue; + else initSong = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar); + } + else if (currentArg.toLowerCase().equals("-start")) + { + autoRun = true; + } + else if (currentArg.toLowerCase().equals("-showplaylist")) + { + showPlaylist = "true"; + } + else if (currentArg.toLowerCase().equals("-showequalizer")) + { + showEqualizer = "true"; + } + else if (currentArg.toLowerCase().equals("-disabledsp")) + { + showDsp = "false"; + } + else if (currentArg.toLowerCase().equals("-skin")) + { + i++; + if (i >= args.length) usage("skin value missing"); + currentValue = args[i]; + if (Config.startWithProtocol(currentValue)) skinPath = currentValue; + else skinPath = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar); + } + else if (currentArg.toLowerCase().equals("-v")) + { + i++; + if (i >= args.length) usage("skin version value missing"); + skinVersion = args[i]; + } + else usage("Unknown parameter : " + currentArg); + } + else + { + usage("Invalid parameter :" + currentArg); + } + } + } + + private void boot() + { + // Go to playlist begining if needed. + /*if ((playlist != null) && (playlistfound == true)) + { + if (playlist.getPlaylistSize() > 0) mp.pressNext(); + } */ + // Start playing if needed. + if (autoRun == true) + { + mp.pressStart(); + } + } + + /** + * Instantiate low-level player. + */ + public void loadJS() + { + BasicPlayer bplayer = new BasicPlayer(); + List mixers = bplayer.getMixers(); + if (mixers != null) + { + Iterator it = mixers.iterator(); + String mixer = config.getAudioDevice(); + boolean mixerFound = false; + if ((mixer != null) && (mixer.length() > 0)) + { + // Check if mixer is valid. + while (it.hasNext()) + { + if (((String) it.next()).equals(mixer)) + { + bplayer.setMixerName(mixer); + mixerFound = true; + break; + } + } + } + if (mixerFound == false) + { + // Use first mixer available. + it = mixers.iterator(); + if (it.hasNext()) + { + mixer = (String) it.next(); + bplayer.setMixerName(mixer); + } + } + } + // Register the front-end to low-level player events. + bplayer.addBasicPlayerListener(mp); + // Adds controls for front-end to low-level player. + mp.setController(bplayer); + } + + /** + * Load playlist. + */ + public void loadPlaylist() + { + if ((initSong != null) && (!initSong.equals(""))) playlistfound = mp.loadPlaylist(initSong); + else playlistfound = mp.loadPlaylist(config.getPlaylistFilename()); + } + + /** + * Load player front-end. + */ + public void loadUI() + { + try + { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } + catch (Exception ex) + { + log.debug(ex); + } + config = Config.getInstance(); + config.load(initConfig); + config.setTopParent(this); + if (showPlaylist != null) + { + if (showPlaylist.equalsIgnoreCase("true")) + { + config.setPlaylistEnabled(true); + } + else + { + config.setPlaylistEnabled(false); + } + } + if (showEqualizer != null) + { + if (showEqualizer.equalsIgnoreCase("true")) + { + config.setEqualizerEnabled(true); + } + else + { + config.setEqualizerEnabled(false); + } + } + if (config.isPlaylistEnabled()) eqFactor = 2; + else eqFactor = 1; + setTitle(Skin.TITLETEXT); + ClassLoader cl = this.getClass().getClassLoader(); + URL iconURL = cl.getResource("javazoom/jlgui/player/amp/jlguiicon.gif"); + if (iconURL != null) + { + ImageIcon jlguiIcon = new ImageIcon(iconURL); + setIconImage(jlguiIcon.getImage()); + config.setIconParent(jlguiIcon); + } + setUndecorated(true); + mp = new PlayerUI(); + if ((showDsp != null) && (showDsp.equalsIgnoreCase("false"))) + { + mp.getSkin().setDspEnabled(false); + } + if (skinPath != null) + { + mp.getSkin().setPath(skinPath); + } + mp.getSkin().setSkinVersion(skinVersion); + mp.loadUI(this); + setContentPane(mp); + setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight())); + eqWin = new JWindow(this); + eqWin.setContentPane(mp.getEqualizerUI()); + eqWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight())); + eqWin.setVisible(false); + plWin = new JWindow(this); + plWin.setContentPane(mp.getPlaylistUI()); + plWin.setSize(new Dimension(mp.getSkin().getMainWidth(), mp.getSkin().getMainHeight())); + plWin.setVisible(false); + // Window listener + addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + // Closing window (Alt+F4 under Win32) + close(); + } + }); + // Keyboard shortcut + setKeyBoardShortcut(); + // Display front-end + setLocation(config.getXLocation(), config.getYLocation()); + setVisible(true); + if (config.isPlaylistEnabled()) plWin.setVisible(true); + if (config.isEqualizerEnabled()) eqWin.setVisible(true); + } + + /** + * Install keyboard shortcuts. + */ + public void setKeyBoardShortcut() + { + KeyStroke jKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_J, 0, false); + KeyStroke ctrlPKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_MASK, false); + KeyStroke altSKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.ALT_MASK, false); + KeyStroke vKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_V, 0, false); + String searchID = "TAGSEARCH"; + String preferenceID = "PREFERENCES"; + String skinbrowserID = "SKINBROWSER"; + String stopplayerID = "STOPPLAYER"; + Action searchAction = new AbstractAction() + { + public void actionPerformed(ActionEvent e) + { + if (mp != null) mp.processJumpToFile(e.getModifiers()); + } + }; + Action preferencesAction = new AbstractAction() + { + public void actionPerformed(ActionEvent e) + { + if (mp != null) mp.processPreferences(e.getModifiers()); + } + }; + Action skinbrowserAction = new AbstractAction() + { + public void actionPerformed(ActionEvent e) + { + if (mp != null) mp.processSkinBrowser(e.getModifiers()); + } + }; + Action stopplayerAction = new AbstractAction() + { + public void actionPerformed(ActionEvent e) + { + if (mp != null) mp.processStop(MouseEvent.BUTTON1_MASK); + } + }; + setKeyboardAction(searchID, jKeyStroke, searchAction); + setKeyboardAction(preferenceID, ctrlPKeyStroke, preferencesAction); + setKeyboardAction(skinbrowserID, altSKeyStroke, skinbrowserAction); + setKeyboardAction(stopplayerID, vKeyStroke, stopplayerAction); + } + + /** + * Set keyboard key shortcut for the whole player. + * @param id + * @param key + * @param action + */ + public void setKeyboardAction(String id, KeyStroke key, Action action) + { + mp.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(key, id); + mp.getActionMap().put(id, action); + mp.getPlaylistUI().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, id); + mp.getPlaylistUI().getActionMap().put(id, action); + mp.getEqualizerUI().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(key, id); + mp.getEqualizerUI().getActionMap().put(id, action); + } + + public void loaded() + { + DragAdapter dragAdapter = new DragAdapter(this); + mp.getSkin().getAcTitleBar().addMouseListener(dragAdapter); + mp.getSkin().getAcTitleBar().addMouseMotionListener(dragAdapter); + } + + public void close() + { + log.info("Close player"); + config.setLocation(getLocation().x, getLocation().y); + config.save(); + dispose(); + exit(0); + } + + /* (non-Javadoc) + * @see javazoom.jlgui.player.amp.skin.Loader#togglePlaylist(boolean) + */ + public void togglePlaylist(boolean enabled) + { + if (plWin != null) + { + if (enabled) + { + if (config.isEqualizerEnabled()) + { + eqFactor = 2; + eqWin.setLocation(getLocation().x, getLocation().y + mp.getSkin().getMainHeight() * eqFactor); + } + plWin.setVisible(true); + } + else + { + plWin.setVisible(false); + if (config.isEqualizerEnabled()) + { + eqFactor = 1; + eqWin.setLocation(getLocation().x, getLocation().y + mp.getSkin().getMainHeight() * eqFactor); + } + } + } + } + + public void toggleEqualizer(boolean enabled) + { + if (eqWin != null) + { + if (enabled) + { + if (config.isPlaylistEnabled()) eqFactor = 2; + else eqFactor = 1; + eqWin.setLocation(getLocation().x, getLocation().y + mp.getSkin().getMainHeight() * eqFactor); + eqWin.setVisible(true); + } + else + { + eqWin.setVisible(false); + } + } + } + + public void minimize() + { + setState(JFrame.ICONIFIED); + } + + public void setLocation(int x, int y) + { + super.setLocation(x, y); + if (plWin != null) + { + plWin.setLocation(getLocation().x, getLocation().y + getHeight()); + } + if (eqWin != null) + { + eqWin.setLocation(getLocation().x, getLocation().y + eqFactor * getHeight()); + } + } + + public Point getLocation() + { + return super.getLocation(); + } + + /** + * Kills the player. + * @param status + */ + public void exit(int status) + { + System.exit(status); + } + + /** + * Displays usage. + * @param msg + */ + protected static void usage(String msg) + { + System.out.println(Skin.TITLETEXT + " : " + msg); + System.out.println(""); + System.out.println(Skin.TITLETEXT + " : Usage"); + System.out.println(" java javazoom.jlgui.player.amp.Player [-skin skinFilename] [-song audioFilename] [-start] [-showplaylist] [-showequalizer] [-disabledsp] [-init configFilename] [-v skinversion]"); + System.out.println(""); + System.out.println(" skinFilename : Filename or URL to a Winamp Skin2.x"); + System.out.println(" audioFilename : Filename or URL to initial song or playlist"); + System.out.println(" start : Starts playing song (from the playlist)"); + System.out.println(" showplaylist : Show playlist"); + System.out.println(" showequalizer : Show equalizer"); + System.out.println(" disabledsp : Disable spectrum/time visual"); + System.out.println(""); + System.out.println(" Advanced parameters :"); + System.out.println(" skinversion : 1 or 2 (default 1)"); + System.out.println(" configFilename : Filename or URL to jlGui initial configuration (playlist,skin,parameters ...)"); + System.out.println(" Initial configuration won't be overriden by -skin and -song arguments"); + System.out.println(""); + System.out.println("Homepage : http://www.javazoom.net"); + System.exit(0); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/ControlCurve.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/ControlCurve.java new file mode 100644 index 0000000..43b768e --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/ControlCurve.java @@ -0,0 +1,139 @@ +/* + * ControlCurve. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.equalizer.ui; + +import java.awt.Polygon; + +public abstract class ControlCurve +{ + static final int EPSILON = 36; /* square of distance for picking */ + protected Polygon pts; + protected int selection = -1; + int maxHeight = -1; + int minHeight = -1; + + public ControlCurve() + { + pts = new Polygon(); + } + + public int boundY(int y) + { + int ny = y; + if ((minHeight >= 0) && (y < minHeight)) + { + ny = 0; + } + if ((maxHeight >= 0) && (y >= maxHeight)) + { + ny = maxHeight - 1; + } + return ny; + } + + public void setMaxHeight(int h) + { + maxHeight = h; + } + + public void setMinHeight(int h) + { + minHeight = h; + } + + /** + * Return index of control point near to (x,y) or -1 if nothing near. + * @param x + * @param y + * @return + */ + public int selectPoint(int x, int y) + { + int mind = Integer.MAX_VALUE; + selection = -1; + for (int i = 0; i < pts.npoints; i++) + { + int d = sqr(pts.xpoints[i] - x) + sqr(pts.ypoints[i] - y); + if (d < mind && d < EPSILON) + { + mind = d; + selection = i; + } + } + return selection; + } + + /** + * Square of an int. + * @param x + * @return + */ + static int sqr(int x) + { + return x * x; + } + + /** + * Add a control point, return index of new control point. + * @param x + * @param y + * @return + */ + public int addPoint(int x, int y) + { + pts.addPoint(x, y); + return selection = pts.npoints - 1; + } + + /** + * Set selected control point. + * @param x + * @param y + */ + public void setPoint(int x, int y) + { + if (selection >= 0) + { + pts.xpoints[selection] = x; + pts.ypoints[selection] = y; + } + } + + /** + * Remove selected control point. + */ + public void removePoint() + { + if (selection >= 0) + { + pts.npoints--; + for (int i = selection; i < pts.npoints; i++) + { + pts.xpoints[i] = pts.xpoints[i + 1]; + pts.ypoints[i] = pts.ypoints[i + 1]; + } + } + } + + public abstract Polygon getPolyline(); +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/Cubic.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/Cubic.java new file mode 100644 index 0000000..a1c91ea --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/Cubic.java @@ -0,0 +1,46 @@ +/* + * Cubic. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.equalizer.ui; + +public class Cubic +{ + float a, b, c, d; /* a + b*u + c*u^2 +d*u^3 */ + + public Cubic(float a, float b, float c, float d) + { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + } + + /** + * Evaluate cubic. + * @param u + * @return + */ + public float eval(float u) + { + return (((d * u) + c) * u + b) * u + a; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/EqualizerUI.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/EqualizerUI.java new file mode 100644 index 0000000..e63e631 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/EqualizerUI.java @@ -0,0 +1,441 @@ +/* + * EqualizerUI. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.equalizer.ui; + +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javazoom.jlgui.player.amp.PlayerActionEvent; +import javazoom.jlgui.player.amp.PlayerUI; +import javazoom.jlgui.player.amp.skin.AbsoluteLayout; +import javazoom.jlgui.player.amp.skin.DropTargetAdapter; +import javazoom.jlgui.player.amp.skin.ImageBorder; +import javazoom.jlgui.player.amp.skin.Skin; +import javazoom.jlgui.player.amp.util.Config; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class implements an equalizer UI. + *

    + * The equalizer consists of 32 band-pass filters. + * Each band of the equalizer can take on a fractional value between + * -1.0 and +1.0. + * At -1.0, the input signal is attenuated by 6dB, at +1.0 the signal is + * amplified by 6dB. + */ +public class EqualizerUI extends JPanel implements ActionListener, ChangeListener +{ + private static Log log = LogFactory.getLog(EqualizerUI.class); + private int minGain = 0; + private int maxGain = 100; + private int[] gainValue = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 }; + private int[] PRESET_NORMAL = { 50, 50, 50, 50, 50, 50, 50, 50, 50, 50 }; + private int[] PRESET_CLASSICAL = { 50, 50, 50, 50, 50, 50, 70, 70, 70, 76 }; + private int[] PRESET_CLUB = { 50, 50, 42, 34, 34, 34, 42, 50, 50, 50 }; + private int[] PRESET_DANCE = { 26, 34, 46, 50, 50, 66, 70, 70, 50, 50 }; + private int[] PRESET_FULLBASS = { 26, 26, 26, 36, 46, 62, 76, 78, 78, 78 }; + private int[] PRESET_FULLBASSTREBLE = { 34, 34, 50, 68, 62, 46, 28, 22, 18, 18 }; + private int[] PRESET_FULLTREBLE = { 78, 78, 78, 62, 42, 24, 8, 8, 8, 8 }; + private int[] PRESET_LAPTOP = { 38, 22, 36, 60, 58, 46, 38, 24, 16, 14 }; + private int[] PRESET_LIVE = { 66, 50, 40, 36, 34, 34, 40, 42, 42, 42 }; + private int[] PRESET_PARTY = { 32, 32, 50, 50, 50, 50, 50, 50, 32, 32 }; + private int[] PRESET_POP = { 56, 38, 32, 30, 38, 54, 56, 56, 54, 54 }; + private int[] PRESET_REGGAE = { 48, 48, 50, 66, 48, 34, 34, 48, 48, 48 }; + private int[] PRESET_ROCK = { 32, 38, 64, 72, 56, 40, 28, 24, 24, 24 }; + private int[] PRESET_TECHNO = { 30, 34, 48, 66, 64, 48, 30, 24, 24, 28 }; + private Config config = null; + private PlayerUI player = null; + private Skin ui = null; + private JPopupMenu mainpopup = null; + public static final int LINEARDIST = 1; + public static final int OVERDIST = 2; + private float[] bands = null; + private int[] eqgains = null; + private int eqdist = OVERDIST; + + public EqualizerUI() + { + super(); + setDoubleBuffered(true); + config = Config.getInstance(); + eqgains = new int[10]; + setLayout(new AbsoluteLayout()); + int[] vals = config.getLastEqualizer(); + if (vals != null) + { + for (int h = 0; h < vals.length; h++) + { + gainValue[h] = vals[h]; + } + } + // DnD support disabled. + DropTargetAdapter dnd = new DropTargetAdapter() + { + public void processDrop(Object data) + { + return; + } + }; + DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, false); + } + + /** + * Return skin. + * @return + */ + public Skin getSkin() + { + return ui; + } + + /** + * Set skin. + * @param ui + */ + public void setSkin(Skin ui) + { + this.ui = ui; + } + + /** + * Set parent player. + * @param mp + */ + public void setPlayer(PlayerUI mp) + { + player = mp; + } + + public void loadUI() + { + log.info("Load EqualizerUI (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + removeAll(); + // Background + ImageBorder border = new ImageBorder(); + border.setImage(ui.getEqualizerImage()); + setBorder(border); + // On/Off + add(ui.getAcEqOnOff(), ui.getAcEqOnOff().getConstraints()); + ui.getAcEqOnOff().removeActionListener(this); + ui.getAcEqOnOff().addActionListener(this); + // Auto + add(ui.getAcEqAuto(), ui.getAcEqAuto().getConstraints()); + ui.getAcEqAuto().removeActionListener(this); + ui.getAcEqAuto().addActionListener(this); + // Sliders + add(ui.getAcEqPresets(), ui.getAcEqPresets().getConstraints()); + for (int i = 0; i < ui.getAcEqSliders().length; i++) + { + add(ui.getAcEqSliders()[i], ui.getAcEqSliders()[i].getConstraints()); + ui.getAcEqSliders()[i].setValue(maxGain - gainValue[i]); + ui.getAcEqSliders()[i].removeChangeListener(this); + ui.getAcEqSliders()[i].addChangeListener(this); + } + if (ui.getSpline() != null) + { + ui.getSpline().setValues(gainValue); + add(ui.getSpline(), ui.getSpline().getConstraints()); + } + // Popup menu on TitleBar + mainpopup = new JPopupMenu(); + String[] presets = { "Normal", "Classical", "Club", "Dance", "Full Bass", "Full Bass & Treble", "Full Treble", "Laptop", "Live", "Party", "Pop", "Reggae", "Rock", "Techno" }; + JMenuItem mi; + for (int p = 0; p < presets.length; p++) + { + mi = new JMenuItem(presets[p]); + mi.removeActionListener(this); + mi.addActionListener(this); + mainpopup.add(mi); + } + ui.getAcEqPresets().removeActionListener(this); + ui.getAcEqPresets().addActionListener(this); + validate(); + } + + /* (non-Javadoc) + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent e) + { + for (int i = 0; i < ui.getAcEqSliders().length; i++) + { + gainValue[i] = maxGain - ui.getAcEqSliders()[i].getValue(); + } + if (ui.getSpline() != null) ui.getSpline().repaint(); + // Apply equalizer values. + synchronizeEqualizer(); + } + + /** + * Set bands array for equalizer. + * + * @param bands + */ + public void setBands(float[] bands) + { + this.bands = bands; + } + + /** + * Apply equalizer function. + * + * @param gains + * @param min + * @param max + */ + public void updateBands(int[] gains, int min, int max) + { + if ((gains != null) && (bands != null)) + { + int j = 0; + float gvalj = (gains[j] * 2.0f / (max - min) * 1.0f) - 1.0f; + float gvalj1 = (gains[j + 1] * 2.0f / (max - min) * 1.0f) - 1.0f; + // Linear distribution : 10 values => 32 values. + if (eqdist == LINEARDIST) + { + float a = (gvalj1 - gvalj) * 1.0f; + float b = gvalj * 1.0f - (gvalj1 - gvalj) * j; + // x=s*x' + float s = (gains.length - 1) * 1.0f / (bands.length - 1) * 1.0f; + for (int i = 0; i < bands.length; i++) + { + float ind = s * i; + if (ind > (j + 1)) + { + j++; + gvalj = (gains[j] * 2.0f / (max - min) * 1.0f) - 1.0f; + gvalj1 = (gains[j + 1] * 2.0f / (max - min) * 1.0f) - 1.0f; + a = (gvalj1 - gvalj) * 1.0f; + b = gvalj * 1.0f - (gvalj1 - gvalj) * j; + } + // a*x+b + bands[i] = a * i * 1.0f * s + b; + } + } + // Over distribution : 10 values => 10 first value of 32 values. + else if (eqdist == OVERDIST) + { + for (int i = 0; i < gains.length; i++) + { + bands[i] = (gains[i] * 2.0f / (max - min) * 1.0f) - 1.0f; + } + } + } + } + + /* (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) + { + String cmd = e.getActionCommand(); + log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + // On/Off + if (cmd.equals(PlayerActionEvent.ACEQONOFF)) + { + if (ui.getAcEqOnOff().isSelected()) + { + config.setEqualizerOn(true); + } + else + { + config.setEqualizerOn(false); + } + synchronizeEqualizer(); + } + // Auto + else if (cmd.equals(PlayerActionEvent.ACEQAUTO)) + { + if (ui.getAcEqAuto().isSelected()) + { + config.setEqualizerAuto(true); + } + else + { + config.setEqualizerAuto(false); + } + } + // Presets + else if (cmd.equals(PlayerActionEvent.ACEQPRESETS)) + { + if (e.getModifiers() == MouseEvent.BUTTON1_MASK) + { + mainpopup.show(this, ui.getAcEqPresets().getLocation().x, ui.getAcEqPresets().getLocation().y); + } + } + else if (cmd.equals("Normal")) + { + updateSliders(PRESET_NORMAL); + synchronizeEqualizer(); + } + else if (cmd.equals("Classical")) + { + updateSliders(PRESET_CLASSICAL); + synchronizeEqualizer(); + } + else if (cmd.equals("Club")) + { + updateSliders(PRESET_CLUB); + synchronizeEqualizer(); + } + else if (cmd.equals("Dance")) + { + updateSliders(PRESET_DANCE); + synchronizeEqualizer(); + } + else if (cmd.equals("Full Bass")) + { + updateSliders(PRESET_FULLBASS); + synchronizeEqualizer(); + } + else if (cmd.equals("Full Bass & Treble")) + { + updateSliders(PRESET_FULLBASSTREBLE); + synchronizeEqualizer(); + } + else if (cmd.equals("Full Treble")) + { + updateSliders(PRESET_FULLTREBLE); + synchronizeEqualizer(); + } + else if (cmd.equals("Laptop")) + { + updateSliders(PRESET_LAPTOP); + synchronizeEqualizer(); + } + else if (cmd.equals("Live")) + { + updateSliders(PRESET_LIVE); + synchronizeEqualizer(); + } + else if (cmd.equals("Party")) + { + updateSliders(PRESET_PARTY); + synchronizeEqualizer(); + } + else if (cmd.equals("Pop")) + { + updateSliders(PRESET_POP); + synchronizeEqualizer(); + } + else if (cmd.equals("Reggae")) + { + updateSliders(PRESET_REGGAE); + synchronizeEqualizer(); + } + else if (cmd.equals("Rock")) + { + updateSliders(PRESET_ROCK); + synchronizeEqualizer(); + } + else if (cmd.equals("Techno")) + { + updateSliders(PRESET_TECHNO); + synchronizeEqualizer(); + } + } + + /** + * Update sliders from gains array. + * + * @param gains + */ + public void updateSliders(int[] gains) + { + if (gains != null) + { + for (int i = 0; i < gains.length; i++) + { + gainValue[i + 1] = gains[i]; + ui.getAcEqSliders()[i + 1].setValue(maxGain - gainValue[i + 1]); + } + } + } + + /** + * Apply equalizer values. + */ + public void synchronizeEqualizer() + { + config.setLastEqualizer(gainValue); + if (config.isEqualizerOn()) + { + for (int j = 0; j < eqgains.length; j++) + { + eqgains[j] = -gainValue[j + 1] + maxGain; + } + updateBands(eqgains, minGain, maxGain); + } + else + { + for (int j = 0; j < eqgains.length; j++) + { + eqgains[j] = (maxGain - minGain) / 2; + } + updateBands(eqgains, minGain, maxGain); + } + } + + /** + * Return equalizer bands distribution. + * @return + */ + public int getEqdist() + { + return eqdist; + } + + /** + * Set equalizer bands distribution. + * @param i + */ + public void setEqdist(int i) + { + eqdist = i; + } + + /** + * Simulates "On/Off" selection. + */ + public void pressOnOff() + { + ui.getAcEqOnOff().doClick(); + } + + /** + * Simulates "Auto" selection. + */ + public void pressAuto() + { + ui.getAcEqAuto().doClick(); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/NaturalSpline.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/NaturalSpline.java new file mode 100644 index 0000000..2ed8b94 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/NaturalSpline.java @@ -0,0 +1,108 @@ +/* + * NaturalSpline. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.equalizer.ui; + +import java.awt.Polygon; + +public class NaturalSpline extends ControlCurve +{ + public final int STEPS = 12; + + public NaturalSpline() + { + super(); + } + + /* + * calculates the natural cubic spline that interpolates y[0], y[1], ... + * y[n] The first segment is returned as C[0].a + C[0].b*u + C[0].c*u^2 + + * C[0].d*u^3 0<=u <1 the other segments are in C[1], C[2], ... C[n-1] + */ + Cubic[] calcNaturalCubic(int n, int[] x) + { + float[] gamma = new float[n + 1]; + float[] delta = new float[n + 1]; + float[] D = new float[n + 1]; + int i; + /* + * We solve the equation [2 1 ] [D[0]] [3(x[1] - x[0]) ] |1 4 1 | |D[1]| + * |3(x[2] - x[0]) | | 1 4 1 | | . | = | . | | ..... | | . | | . | | 1 4 + * 1| | . | |3(x[n] - x[n-2])| [ 1 2] [D[n]] [3(x[n] - x[n-1])] + * + * by using row operations to convert the matrix to upper triangular and + * then back sustitution. The D[i] are the derivatives at the knots. + */ + gamma[0] = 1.0f / 2.0f; + for (i = 1; i < n; i++) + { + gamma[i] = 1 / (4 - gamma[i - 1]); + } + gamma[n] = 1 / (2 - gamma[n - 1]); + delta[0] = 3 * (x[1] - x[0]) * gamma[0]; + for (i = 1; i < n; i++) + { + delta[i] = (3 * (x[i + 1] - x[i - 1]) - delta[i - 1]) * gamma[i]; + } + delta[n] = (3 * (x[n] - x[n - 1]) - delta[n - 1]) * gamma[n]; + D[n] = delta[n]; + for (i = n - 1; i >= 0; i--) + { + D[i] = delta[i] - gamma[i] * D[i + 1]; + } + /* now compute the coefficients of the cubics */ + Cubic[] C = new Cubic[n]; + for (i = 0; i < n; i++) + { + C[i] = new Cubic((float) x[i], D[i], 3 * (x[i + 1] - x[i]) - 2 * D[i] - D[i + 1], 2 * (x[i] - x[i + 1]) + D[i] + D[i + 1]); + } + return C; + } + + /** + * Return a cubic spline. + */ + public Polygon getPolyline() + { + Polygon p = new Polygon(); + if (pts.npoints >= 2) + { + Cubic[] X = calcNaturalCubic(pts.npoints - 1, pts.xpoints); + Cubic[] Y = calcNaturalCubic(pts.npoints - 1, pts.ypoints); + // very crude technique - just break each segment up into steps lines + int x = (int) Math.round(X[0].eval(0)); + int y = (int) Math.round(Y[0].eval(0)); + p.addPoint(x, boundY(y)); + for (int i = 0; i < X.length; i++) + { + for (int j = 1; j <= STEPS; j++) + { + float u = j / (float) STEPS; + x = Math.round(X[i].eval(u)); + y = Math.round(Y[i].eval(u)); + p.addPoint(x, boundY(y)); + } + } + } + return p; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/SplinePanel.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/SplinePanel.java new file mode 100644 index 0000000..d604afe --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/SplinePanel.java @@ -0,0 +1,133 @@ +/* + * SplinePanel. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.equalizer.ui; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Polygon; +import javax.swing.JPanel; +import javazoom.jlgui.player.amp.skin.AbsoluteConstraints; + +public class SplinePanel extends JPanel +{ + private AbsoluteConstraints constraints = null; + private Image backgroundImage = null; + private Image barImage = null; + private int[] values = null; + private Color[] gradient = null; + + public SplinePanel() + { + super(); + setDoubleBuffered(true); + setLayout(null); + } + + public Color[] getGradient() + { + return gradient; + } + + public void setGradient(Color[] gradient) + { + this.gradient = gradient; + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } + + public Image getBarImage() + { + return barImage; + } + + public void setBarImage(Image barImage) + { + this.barImage = barImage; + } + + public Image getBackgroundImage() + { + return backgroundImage; + } + + public void setBackgroundImage(Image backgroundImage) + { + this.backgroundImage = backgroundImage; + } + + public int[] getValues() + { + return values; + } + + public void setValues(int[] values) + { + this.values = values; + } + + /* (non-Javadoc) + * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) + */ + public void paintComponent(Graphics g) + { + if (backgroundImage != null) g.drawImage(backgroundImage, 0, 0, null); + if (barImage != null) g.drawImage(barImage, 0, getHeight()/2, null); + if ((values != null) && (values.length > 0)) + { + NaturalSpline curve = new NaturalSpline(); + float dx = 1.0f * getWidth() / (values.length - 2); + int h = getHeight(); + curve.setMaxHeight(h); + curve.setMinHeight(0); + for (int i = 1; i < values.length; i++) + { + int x1 = (int) Math.round(dx * (i - 1)); + int y1 = ((int) Math.round((h * values[i] / 100))); + y1 = curve.boundY(y1); + curve.addPoint(x1, y1); + } + Polygon spline = curve.getPolyline(); + if (gradient != null) + { + for (int i=0;i<(spline.npoints-1);i++) + { + g.setColor(gradient[spline.ypoints[i]]); + g.drawLine(spline.xpoints[i], spline.ypoints[i],spline.xpoints[i+1], spline.ypoints[i+1]); + } + } + else + { + g.drawPolyline(spline.xpoints, spline.ypoints, spline.npoints); + } + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/jlguiicon.gif b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/jlguiicon.gif new file mode 100644 index 0000000..d44ea31 Binary files /dev/null and b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/jlguiicon.gif differ diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/metrix.wsz b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/metrix.wsz new file mode 100644 index 0000000..58fd9ad Binary files /dev/null and b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/metrix.wsz differ diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/BasePlaylist.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/BasePlaylist.java new file mode 100644 index 0000000..7149b5e --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/BasePlaylist.java @@ -0,0 +1,586 @@ +/* + * BasePlaylist. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.playlist; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.Collection; +import java.util.Iterator; +import java.util.StringTokenizer; +import java.util.Vector; +import javazoom.jlgui.player.amp.util.Config; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * BasePlaylist implementation. + * This class implements Playlist interface using a Vector. + * It support .m3u and .pls playlist format. + */ +public class BasePlaylist implements Playlist +{ + protected Vector _playlist = null; + protected int _cursorPos = -1; + protected boolean isModified; + protected String M3UHome = null; + protected String PLSHome = null; + private static Log log = LogFactory.getLog(BasePlaylist.class); + + /** + * Constructor. + */ + public BasePlaylist() + { + _playlist = new Vector(); + } + + public boolean isModified() + { + return isModified; + } + + /** + * Loads playlist as M3U format. + */ + public boolean load(String filename) + { + setModified(true); + boolean loaded = false; + if ((filename != null) && (filename.toLowerCase().endsWith(".m3u"))) + { + loaded = loadM3U(filename); + } + else if ((filename != null) && (filename.toLowerCase().endsWith(".pls"))) + { + loaded = loadPLS(filename); + } + return loaded; + } + + /** + * Load playlist from M3U format. + * + * @param filename + * @return + */ + protected boolean loadM3U(String filename) + { + Config config = Config.getInstance(); + _playlist = new Vector(); + boolean loaded = false; + BufferedReader br = null; + try + { + // Playlist from URL ? (http:, ftp:, file: ....) + if (Config.startWithProtocol(filename)) + { + br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream())); + } + else + { + br = new BufferedReader(new FileReader(filename)); + } + String line = null; + String songName = null; + String songFile = null; + String songLength = null; + while ((line = br.readLine()) != null) + { + if (line.trim().length() == 0) continue; + if (line.startsWith("#")) + { + if (line.toUpperCase().startsWith("#EXTINF")) + { + int indA = line.indexOf(",", 0); + if (indA != -1) + { + songName = line.substring(indA + 1, line.length()); + } + int indB = line.indexOf(":", 0); + if (indB != -1) + { + if (indB < indA) songLength = (line.substring(indB + 1, indA)).trim(); + } + } + } + else + { + songFile = line; + if (songName == null) songName = songFile; + if (songLength == null) songLength = "-1"; + PlaylistItem pli = null; + if (Config.startWithProtocol(songFile)) + { + // URL. + pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), false); + } + else + { + // File. + File f = new File(songFile); + if (f.exists()) + { + pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), true); + } + else + { + // Try relative path. + f = new File(config.getLastDir() + songFile); + if (f.exists()) + { + pli = new PlaylistItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true); + } + else + { + // Try optional M3U home. + if (M3UHome != null) + { + if (Config.startWithProtocol(M3UHome)) + { + pli = new PlaylistItem(songName, M3UHome + songFile, Long.parseLong(songLength), false); + } + else + { + pli = new PlaylistItem(songName, M3UHome + songFile, Long.parseLong(songLength), true); + } + } + } + } + } + if (pli != null) this.appendItem(pli); + songFile = null; + songName = null; + songLength = null; + } + } + loaded = true; + } + catch (Exception e) + { + log.debug("Can't load .m3u playlist", e); + } + finally + { + try + { + if (br != null) + { + br.close(); + } + } + catch (Exception ioe) + { + log.info("Can't close .m3u playlist", ioe); + } + } + return loaded; + } + + /** + * Load playlist in PLS format. + * + * @param filename + * @return + */ + protected boolean loadPLS(String filename) + { + Config config = Config.getInstance(); + _playlist = new Vector(); + boolean loaded = false; + BufferedReader br = null; + try + { + // Playlist from URL ? (http:, ftp:, file: ....) + if (Config.startWithProtocol(filename)) + { + br = new BufferedReader(new InputStreamReader((new URL(filename)).openStream())); + } + else + { + br = new BufferedReader(new FileReader(filename)); + } + String line = null; + String songName = null; + String songFile = null; + String songLength = null; + while ((line = br.readLine()) != null) + { + if (line.trim().length() == 0) continue; + if ((line.toLowerCase().startsWith("file"))) + { + StringTokenizer st = new StringTokenizer(line, "="); + st.nextToken(); + songFile = st.nextToken().trim(); + } + else if ((line.toLowerCase().startsWith("title"))) + { + StringTokenizer st = new StringTokenizer(line, "="); + st.nextToken(); + songName = st.nextToken().trim(); + } + else if ((line.toLowerCase().startsWith("length"))) + { + StringTokenizer st = new StringTokenizer(line, "="); + st.nextToken(); + songLength = st.nextToken().trim(); + } + // New entry ? + if (songFile != null) + { + PlaylistItem pli = null; + if (songName == null) songName = songFile; + if (songLength == null) songLength = "-1"; + if (Config.startWithProtocol(songFile)) + { + // URL. + pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), false); + } + else + { + // File. + File f = new File(songFile); + if (f.exists()) + { + pli = new PlaylistItem(songName, songFile, Long.parseLong(songLength), true); + } + else + { + // Try relative path. + f = new File(config.getLastDir() + songFile); + if (f.exists()) + { + pli = new PlaylistItem(songName, config.getLastDir() + songFile, Long.parseLong(songLength), true); + } + else + { + // Try optional PLS home. + if (PLSHome != null) + { + if (Config.startWithProtocol(PLSHome)) + { + pli = new PlaylistItem(songName, PLSHome + songFile, Long.parseLong(songLength), false); + } + else + { + pli = new PlaylistItem(songName, PLSHome + songFile, Long.parseLong(songLength), true); + } + } + } + } + } + if (pli != null) this.appendItem(pli); + songName = null; + songFile = null; + songLength = null; + } + } + loaded = true; + } + catch (Exception e) + { + log.debug("Can't load .pls playlist", e); + } + finally + { + try + { + if (br != null) + { + br.close(); + } + } + catch (Exception ioe) + { + log.info("Can't close .pls playlist", ioe); + } + } + return loaded; + } + + /** + * Saves playlist in M3U format. + */ + public boolean save(String filename) + { + // Implemented by C.K + if (_playlist != null) + { + BufferedWriter bw = null; + try + { + bw = new BufferedWriter(new FileWriter(filename)); + bw.write("#EXTM3U"); + bw.newLine(); + Iterator it = _playlist.iterator(); + while (it.hasNext()) + { + PlaylistItem pli = (PlaylistItem) it.next(); + bw.write("#EXTINF:" + pli.getM3UExtInf()); + bw.newLine(); + bw.write(pli.getLocation()); + bw.newLine(); + } + return true; + } + catch (IOException e) + { + log.info("Can't save playlist", e); + } + finally + { + try + { + if (bw != null) + { + bw.close(); + } + } + catch (IOException ioe) + { + log.info("Can't close playlist", ioe); + } + } + } + return false; + } + + /** + * Adds item at a given position in the playlist. + */ + public void addItemAt(PlaylistItem pli, int pos) + { + _playlist.insertElementAt(pli, pos); + setModified(true); + } + + /** + * Searchs and removes item from the playlist. + */ + public void removeItem(PlaylistItem pli) + { + _playlist.remove(pli); + setModified(true); + } + + /** + * Removes item at a given position from the playlist. + */ + public void removeItemAt(int pos) + { + _playlist.removeElementAt(pos); + setModified(true); + } + + /** + * Removes all items from the playlist. + */ + public void removeAllItems() + { + _playlist.removeAllElements(); + _cursorPos = -1; + setModified(true); + } + + /** + * Append item at the end of the playlist. + */ + public void appendItem(PlaylistItem pli) + { + _playlist.addElement(pli); + setModified(true); + } + + /** + * Sorts items of the playlist. + */ + public void sortItems(int sortmode) + { + // TODO + } + + /** + * Shuffles items in the playlist randomly + */ + public void shuffle() + { + int size = _playlist.size(); + if (size < 2) { return; } + Vector v = _playlist; + _playlist = new Vector(size); + while ((size = v.size()) > 0) + { + _playlist.addElement(v.remove((int) (Math.random() * size))); + } + begin(); + } + + /** + * Moves the cursor at the top of the playlist. + */ + public void begin() + { + _cursorPos = -1; + if (getPlaylistSize() > 0) + { + _cursorPos = 0; + } + setModified(true); + } + + /** + * Returns item at a given position from the playlist. + */ + public PlaylistItem getItemAt(int pos) + { + PlaylistItem pli = null; + pli = (PlaylistItem) _playlist.elementAt(pos); + return pli; + } + + /** + * Returns a collection of playlist items. + */ + public Collection getAllItems() + { + // TODO + return null; + } + + /** + * Returns then number of items in the playlist. + */ + public int getPlaylistSize() + { + return _playlist.size(); + } + + // Next methods will be used by the Player + /** + * Returns item matching to the cursor. + */ + public PlaylistItem getCursor() + { + if ((_cursorPos < 0) || (_cursorPos >= _playlist.size())) { return null; } + return getItemAt(_cursorPos); + } + + /** + * Computes cursor position (next). + */ + public void nextCursor() + { + _cursorPos++; + } + + /** + * Computes cursor position (previous). + */ + public void previousCursor() + { + _cursorPos--; + if (_cursorPos < 0) + { + _cursorPos = 0; + } + } + + public boolean setModified(boolean set) + { + isModified = set; + return isModified; + } + + public void setCursor(int index) + { + _cursorPos = index; + } + + /** + * Returns selected index. + */ + public int getSelectedIndex() + { + return _cursorPos; + } + + /** + * Returns index of playlist item. + */ + public int getIndex(PlaylistItem pli) + { + int pos = -1; + for (int i = 0; i < _playlist.size(); i++) + { + pos = i; + PlaylistItem p = (PlaylistItem) _playlist.elementAt(i); + if (p.equals(pli)) break; + } + return pos; + } + + /** + * Get M3U home for relative playlist. + * + * @return + */ + public String getM3UHome() + { + return M3UHome; + } + + /** + * Set optional M3U home for relative playlist. + * + * @param string + */ + public void setM3UHome(String string) + { + M3UHome = string; + } + + /** + * Get PLS home for relative playlist. + * + * @return + */ + public String getPLSHome() + { + return PLSHome; + } + + /** + * Set optional PLS home for relative playlist. + * + * @param string + */ + public void setPLSHome(String string) + { + PLSHome = string; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/Playlist.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/Playlist.java new file mode 100644 index 0000000..0eb3dd6 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/Playlist.java @@ -0,0 +1,138 @@ +/* + * Playlist. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.playlist; + +import java.util.Collection; + +/** + * Playlist. + * This interface defines method that a playlist should implement.
    + * A playlist provides a collection of item to play and a cursor to know + * which item is playing. + */ +public interface Playlist +{ + // Next methods will be called by the Playlist UI. + /** + * Loads playlist. + */ + public boolean load(String filename); + + /** + * Saves playlist. + */ + public boolean save(String filename); + + /** + * Adds item at a given position in the playlist. + */ + public void addItemAt(PlaylistItem pli, int pos); + + /** + * Searchs and removes item from the playlist. + */ + public void removeItem(PlaylistItem pli); + + /** + * Removes item at a given position from the playlist. + */ + public void removeItemAt(int pos); + + /** + * Removes all items in the playlist. + */ + public void removeAllItems(); + + /** + * Append item at the end of the playlist. + */ + public void appendItem(PlaylistItem pli); + + /** + * Sorts items of the playlist. + */ + public void sortItems(int sortmode); + + /** + * Returns item at a given position from the playlist. + */ + public PlaylistItem getItemAt(int pos); + + /** + * Returns a collection of playlist items. + */ + public Collection getAllItems(); + + /** + * Returns then number of items in the playlist. + */ + public int getPlaylistSize(); + + // Next methods will be used by the Player + /** + * Randomly re-arranges the playlist. + */ + public void shuffle(); + + /** + * Returns item matching to the cursor. + */ + public PlaylistItem getCursor(); + + /** + * Moves the cursor at the begining of the Playlist. + */ + public void begin(); + + /** + * Returns item matching to the cursor. + */ + public int getSelectedIndex(); + + /** + * Returns index of playlist item. + */ + public int getIndex(PlaylistItem pli); + + /** + * Computes cursor position (next). + */ + public void nextCursor(); + + /** + * Computes cursor position (previous). + */ + public void previousCursor(); + + /** + * Set the modification flag for the playlist + */ + boolean setModified(boolean set); + + /** + * Checks the modification flag + */ + public boolean isModified(); + + void setCursor(int index); +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistFactory.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistFactory.java new file mode 100644 index 0000000..a854f7c --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistFactory.java @@ -0,0 +1,107 @@ +/* + * PlaylistFactory. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.playlist; + +import java.lang.reflect.Constructor; +import javazoom.jlgui.player.amp.util.Config; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * PlaylistFactory. + */ +public class PlaylistFactory +{ + private static PlaylistFactory _instance = null; + private Playlist _playlistInstance = null; + private Config _config = null; + private static Log log = LogFactory.getLog(PlaylistFactory.class); + + /** + * Constructor. + */ + private PlaylistFactory() + { + _config = Config.getInstance(); + } + + /** + * Returns instance of PlaylistFactory. + */ + public synchronized static PlaylistFactory getInstance() + { + if (_instance == null) + { + _instance = new PlaylistFactory(); + } + return _instance; + } + + /** + * Returns Playlist instantied from full qualified class name. + */ + public Playlist getPlaylist() + { + if (_playlistInstance == null) + { + String classname = _config.getPlaylistClassName(); + boolean interfaceFound = false; + try + { + Class aClass = Class.forName(classname); + Class superClass = aClass; + // Looking for Playlist interface implementation. + while (superClass != null) + { + Class[] interfaces = superClass.getInterfaces(); + for (int i = 0; i < interfaces.length; i++) + { + if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.playlist.Playlist")) + { + interfaceFound = true; + break; + } + } + if (interfaceFound == true) break; + superClass = superClass.getSuperclass(); + } + if (interfaceFound == false) + { + log.error("Error : Playlist implementation not found in " + classname + " hierarchy"); + } + else + { + Class[] argsClass = new Class[] {}; + Constructor c = aClass.getConstructor(argsClass); + _playlistInstance = (Playlist) (c.newInstance(null)); + log.info(classname + " loaded"); + } + } + catch (Exception e) + { + log.error("Error : " + classname + " : " + e.getMessage()); + } + } + return _playlistInstance; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistItem.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistItem.java new file mode 100644 index 0000000..2ff3b6c --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistItem.java @@ -0,0 +1,302 @@ +/* + * PlaylistItem. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + * + */ +package javazoom.jlgui.player.amp.playlist; + +import javazoom.jlgui.player.amp.tag.TagInfo; +import javazoom.jlgui.player.amp.tag.TagInfoFactory; +import javazoom.jlgui.player.amp.util.Config; +import javazoom.jlgui.player.amp.util.FileUtil; + +/** + * This class implements item for playlist. + */ +public class PlaylistItem +{ + protected String _name = null; + protected String _displayName = null; + protected String _location = null; + protected boolean _isFile = true; + protected long _seconds = -1; + protected boolean _isSelected = false; // add by JOHN YANG + protected TagInfo _taginfo = null; + + protected PlaylistItem() + { + } + + /** + * Contructor for playlist item. + * + * @param name Song name to be displayed + * @param location File or URL + * @param seconds Time length + * @param isFile true for File instance + */ + public PlaylistItem(String name, String location, long seconds, boolean isFile) + { + _name = name; + _seconds = seconds; + _isFile = isFile; + Config config = Config.getInstance(); + if (config.getTaginfoPolicy().equals(Config.TAGINFO_POLICY_ALL)) + { + // Read tag info for any File or URL. It could take time. + setLocation(location, true); + } + else if (config.getTaginfoPolicy().equals(Config.TAGINFO_POLICY_FILE)) + { + // Read tag info for any File only not for URL. + if (_isFile) setLocation(location, true); + else setLocation(location, false); + } + else + { + // Do not read tag info. + setLocation(location, false); + } + } + + /** + * Returns item name such as (hh:mm:ss) Title - Artist if available. + * + * @return + */ + public String getFormattedName() + { + if (_displayName == null) + { + if (_seconds > 0) + { + String length = getFormattedLength(); + return "(" + length + ") " + _name; + } + else return _name; + } + // Name extracted from TagInfo or stream title. + else return _displayName; + } + + public String getName() + { + return _name; + } + + public String getLocation() + { + return _location; + } + + /** + * Returns true if item to play is coming for a file. + * + * @return + */ + public boolean isFile() + { + return _isFile; + } + + /** + * Set File flag for playslit item. + * + * @param b + */ + public void setFile(boolean b) + { + _isFile = b; + } + + /** + * Returns playtime in seconds. If tag info is available then its playtime will be returned. + * + * @return playtime + */ + public long getLength() + { + if ((_taginfo != null) && (_taginfo.getPlayTime() > 0)) return _taginfo.getPlayTime(); + else return _seconds; + } + + public int getBitrate() + { + if (_taginfo != null) return _taginfo.getBitRate(); + else return -1; + } + + public int getSamplerate() + { + if (_taginfo != null) return _taginfo.getSamplingRate(); + else return -1; + } + + public int getChannels() + { + if (_taginfo != null) return _taginfo.getChannels(); + else return -1; + } + + public void setSelected(boolean mode) + { + _isSelected = mode; + } + + public boolean isSelected() + { + return _isSelected; + } + + /** + * Reads file comments/tags. + * + * @param l + */ + public void setLocation(String l) + { + setLocation(l, false); + } + + /** + * Reads (or not) file comments/tags. + * + * @param l input location + * @param readInfo + */ + public void setLocation(String l, boolean readInfo) + { + _location = l; + if (readInfo == true) + { + // Read Audio Format and read tags/comments. + if ((_location != null) && (!_location.equals(""))) + { + TagInfoFactory factory = TagInfoFactory.getInstance(); + _taginfo = factory.getTagInfo(l); + } + } + _displayName = getFormattedDisplayName(); + } + + /** + * Returns item lenght such as hh:mm:ss + * + * @return formatted String. + */ + public String getFormattedLength() + { + long time = getLength(); + String length = ""; + if (time > -1) + { + int minutes = (int) Math.floor(time / 60); + int hours = (int) Math.floor(minutes / 60); + minutes = minutes - hours * 60; + int seconds = (int) (time - minutes * 60 - hours * 3600); + // Hours. + if (hours > 0) + { + length = length + FileUtil.rightPadString(hours + "", '0', 2) + ":"; + } + length = length + FileUtil.rightPadString(minutes + "", '0', 2) + ":" + FileUtil.rightPadString(seconds + "", '0', 2); + } + else length = "" + time; + return length; + } + + /** + * Returns item name such as (hh:mm:ss) Title - Artist + * + * @return formatted String. + */ + public String getFormattedDisplayName() + { + if (_taginfo == null) return null; + else + { + String length = getFormattedLength(); + if ((_taginfo.getTitle() != null) && (!_taginfo.getTitle().equals("")) && (_taginfo.getArtist() != null) && (!_taginfo.getArtist().equals(""))) + { + if (getLength() > 0) return ("(" + length + ") " + _taginfo.getTitle() + " - " + _taginfo.getArtist()); + else return (_taginfo.getTitle() + " - " + _taginfo.getArtist()); + } + else if ((_taginfo.getTitle() != null) && (!_taginfo.getTitle().equals(""))) + { + if (getLength() > 0) return ("(" + length + ") " + _taginfo.getTitle()); + else return (_taginfo.getTitle()); + } + else + { + if (getLength() > 0) return ("(" + length + ") " + _name); + else return (_name); + } + } + } + + public void setFormattedDisplayName(String fname) + { + _displayName = fname; + } + + /** + * Return item name such as hh:mm:ss,Title,Artist + * + * @return formatted String. + */ + public String getM3UExtInf() + { + if (_taginfo == null) + { + return (_seconds + "," + _name); + } + else + { + if ((_taginfo.getTitle() != null) && (_taginfo.getArtist() != null)) + { + return (getLength() + "," + _taginfo.getTitle() + " - " + _taginfo.getArtist()); + } + else if (_taginfo.getTitle() != null) + { + return (getLength() + "," + _taginfo.getTitle()); + } + else + { + return (_seconds + "," + _name); + } + } + } + + /** + * Return TagInfo. + * + * @return + */ + public TagInfo getTagInfo() + { + if (_taginfo == null) + { + // Inspect location + setLocation(_location, true); + } + return _taginfo; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/ui/PlaylistUI.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/ui/PlaylistUI.java new file mode 100644 index 0000000..f460ee3 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/ui/PlaylistUI.java @@ -0,0 +1,882 @@ +/* + * PlaylistUI. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.playlist.ui; + +import java.awt.Graphics; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; +import java.util.StringTokenizer; +import java.util.Vector; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javazoom.jlgui.player.amp.PlayerActionEvent; +import javazoom.jlgui.player.amp.PlayerUI; +import javazoom.jlgui.player.amp.playlist.Playlist; +import javazoom.jlgui.player.amp.playlist.PlaylistItem; +import javazoom.jlgui.player.amp.skin.AbsoluteLayout; +import javazoom.jlgui.player.amp.skin.ActiveJButton; +import javazoom.jlgui.player.amp.skin.DropTargetAdapter; +import javazoom.jlgui.player.amp.skin.Skin; +import javazoom.jlgui.player.amp.skin.UrlDialog; +import javazoom.jlgui.player.amp.tag.TagInfo; +import javazoom.jlgui.player.amp.tag.TagInfoFactory; +import javazoom.jlgui.player.amp.tag.ui.TagInfoDialog; +import javazoom.jlgui.player.amp.util.Config; +import javazoom.jlgui.player.amp.util.FileSelector; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class PlaylistUI extends JPanel implements ActionListener, ChangeListener +{ + private static Log log = LogFactory.getLog(PlaylistUI.class); + public static int MAXDEPTH = 4; + private Config config = null; + private Skin ui = null; + private Playlist playlist = null; + private PlayerUI player = null; + private int topIndex = 0; + private int currentSelection = -1; + private Vector exts = null; + private boolean isSearching = false; + private JPopupMenu fipopup = null; + + public PlaylistUI() + { + super(); + setDoubleBuffered(true); + setLayout(new AbsoluteLayout()); + config = Config.getInstance(); + addMouseListener(new MouseAdapter() + { + public void mousePressed(MouseEvent e) + { + handleMouseClick(e); + } + }); + // DnD support. + DropTargetAdapter dnd = new DropTargetAdapter() + { + public void processDrop(Object data) + { + processDnD(data); + } + }; + DropTarget dt = new DropTarget(this, DnDConstants.ACTION_COPY, dnd, true); + } + + public void setPlayer(PlayerUI mp) + { + player = mp; + } + + public void setSkin(Skin skin) + { + ui = skin; + } + + public Skin getSkin() + { + return ui; + } + + public Playlist getPlaylist() + { + return playlist; + } + + public void setPlaylist(Playlist playlist) + { + this.playlist = playlist; + } + + public int getTopIndex() + { + return topIndex; + } + + public void loadUI() + { + removeAll(); + ui.getPlaylistPanel().setParent(this); + add(ui.getAcPlSlider(), ui.getAcPlSlider().getConstraints()); + ui.getAcPlSlider().setValue(100); + ui.getAcPlSlider().removeChangeListener(this); + ui.getAcPlSlider().addChangeListener(this); + add(ui.getAcPlUp(), ui.getAcPlUp().getConstraints()); + ui.getAcPlUp().removeActionListener(this); + ui.getAcPlUp().addActionListener(this); + add(ui.getAcPlDown(), ui.getAcPlDown().getConstraints()); + ui.getAcPlDown().removeActionListener(this); + ui.getAcPlDown().addActionListener(this); + // Add menu + add(ui.getAcPlAdd(), ui.getAcPlAdd().getConstraints()); + ui.getAcPlAdd().removeActionListener(this); + ui.getAcPlAdd().addActionListener(this); + add(ui.getAcPlAddPopup(), ui.getAcPlAddPopup().getConstraints()); + ui.getAcPlAddPopup().setVisible(false); + ActiveJButton[] items = ui.getAcPlAddPopup().getItems(); + for (int i = 0; i < items.length; i++) + { + items[i].addActionListener(this); + } + // Remove menu + add(ui.getAcPlRemove(), ui.getAcPlRemove().getConstraints()); + ui.getAcPlRemove().removeActionListener(this); + ui.getAcPlRemove().addActionListener(this); + add(ui.getAcPlRemovePopup(), ui.getAcPlRemovePopup().getConstraints()); + ui.getAcPlRemovePopup().setVisible(false); + items = ui.getAcPlRemovePopup().getItems(); + for (int i = 0; i < items.length; i++) + { + items[i].removeActionListener(this); + items[i].addActionListener(this); + } + // Select menu + add(ui.getAcPlSelect(), ui.getAcPlSelect().getConstraints()); + ui.getAcPlSelect().removeActionListener(this); + ui.getAcPlSelect().addActionListener(this); + add(ui.getAcPlSelectPopup(), ui.getAcPlSelectPopup().getConstraints()); + ui.getAcPlSelectPopup().setVisible(false); + items = ui.getAcPlSelectPopup().getItems(); + for (int i = 0; i < items.length; i++) + { + items[i].removeActionListener(this); + items[i].addActionListener(this); + } + // Misc menu + add(ui.getAcPlMisc(), ui.getAcPlMisc().getConstraints()); + ui.getAcPlMisc().removeActionListener(this); + ui.getAcPlMisc().addActionListener(this); + add(ui.getAcPlMiscPopup(), ui.getAcPlMiscPopup().getConstraints()); + ui.getAcPlMiscPopup().setVisible(false); + items = ui.getAcPlMiscPopup().getItems(); + for (int i = 0; i < items.length; i++) + { + items[i].removeActionListener(this); + items[i].addActionListener(this); + } + // List menu + add(ui.getAcPlList(), ui.getAcPlList().getConstraints()); + ui.getAcPlList().removeActionListener(this); + ui.getAcPlList().addActionListener(this); + add(ui.getAcPlListPopup(), ui.getAcPlListPopup().getConstraints()); + ui.getAcPlListPopup().setVisible(false); + items = ui.getAcPlListPopup().getItems(); + for (int i = 0; i < items.length; i++) + { + items[i].removeActionListener(this); + items[i].addActionListener(this); + } + // Popup menu + fipopup = new JPopupMenu(); + JMenuItem mi = new JMenuItem(ui.getResource("playlist.popup.info")); + mi.setActionCommand(PlayerActionEvent.ACPLINFO); + mi.removeActionListener(this); + mi.addActionListener(this); + fipopup.add(mi); + fipopup.addSeparator(); + mi = new JMenuItem(ui.getResource("playlist.popup.play")); + mi.setActionCommand(PlayerActionEvent.ACPLPLAY); + mi.removeActionListener(this); + mi.addActionListener(this); + fipopup.add(mi); + fipopup.addSeparator(); + mi = new JMenuItem(ui.getResource("playlist.popup.remove")); + mi.setActionCommand(PlayerActionEvent.ACPLREMOVE); + mi.removeActionListener(this); + mi.addActionListener(this); + fipopup.add(mi); + validate(); + repaint(); + } + + /** + * Initialize playlist. + */ + public void initPlayList() + { + topIndex = 0; + nextCursor(); + } + + /** + * Repaint the file list area and scroll it if necessary + */ + public void nextCursor() + { + currentSelection = playlist.getSelectedIndex(); + int n = playlist.getPlaylistSize(); + int nlines = ui.getPlaylistPanel().getLines(); + while (currentSelection - topIndex > nlines - 1) + topIndex += 2; + if (topIndex >= n) topIndex = n - 1; + while (currentSelection < topIndex) + topIndex -= 2; + if (topIndex < 0) topIndex = 0; + resetScrollBar(); + repaint(); + } + + /** + * Get the item index according to the mouse y position + * @param y + * @return + */ + protected int getIndex(int y) + { + int n0 = playlist.getPlaylistSize(); + if (n0 == 0) return -1; + for (int n = 0; n < 100; n++) + { + if (ui.getPlaylistPanel().isIndexArea(y, n)) + { + if (topIndex + n > n0 - 1) return -1; + return topIndex + n; + } + } + return -1; + } + + /* (non-Javadoc) + * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent) + */ + public void stateChanged(ChangeEvent e) + { + Object src = e.getSource(); + //log.debug("State (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + if (src == ui.getAcPlSlider()) + { + int n = playlist.getPlaylistSize(); + float dx = (100 - ui.getAcPlSlider().getValue()) / 100.0f; + int index = (int) (dx * (n - 1)); + if (index != topIndex) + { + topIndex = index; + paintList(); + } + } + } + + /* (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) + { + final ActionEvent evt = e; + new Thread("PlaylistUIActionEvent") + { + public void run() + { + processActionEvent(evt); + } + }.start(); + } + + /** + * Process action event. + * @param e + */ + public void processActionEvent(ActionEvent e) + { + String cmd = e.getActionCommand(); + log.debug("Action=" + cmd + " (EDT=" + SwingUtilities.isEventDispatchThread() + ")"); + int n = playlist.getPlaylistSize(); + if (cmd.equals(PlayerActionEvent.ACPLUP)) + { + topIndex--; + if (topIndex < 0) topIndex = 0; + resetScrollBar(); + paintList(); + } + else if (cmd.equals(PlayerActionEvent.ACPLDOWN)) + { + topIndex++; + if (topIndex > n - 1) topIndex = n - 1; + resetScrollBar(); + paintList(); + } + else if (cmd.equals(PlayerActionEvent.ACPLADDPOPUP)) + { + ui.getAcPlAdd().setVisible(false); + ui.getAcPlAddPopup().setVisible(true); + } + else if (cmd.equals(PlayerActionEvent.ACPLREMOVEPOPUP)) + { + ui.getAcPlRemove().setVisible(false); + ui.getAcPlRemovePopup().setVisible(true); + } + else if (cmd.equals(PlayerActionEvent.ACPLSELPOPUP)) + { + ui.getAcPlSelect().setVisible(false); + ui.getAcPlSelectPopup().setVisible(true); + } + else if (cmd.equals(PlayerActionEvent.ACPLMISCPOPUP)) + { + ui.getAcPlMisc().setVisible(false); + ui.getAcPlMiscPopup().setVisible(true); + } + else if (cmd.equals(PlayerActionEvent.ACPLLISTPOPUP)) + { + ui.getAcPlList().setVisible(false); + ui.getAcPlListPopup().setVisible(true); + } + else if (cmd.equals(PlayerActionEvent.ACPLINFO)) + { + popupFileInfo(); + } + else if (cmd.equals(PlayerActionEvent.ACPLPLAY)) + { + int n0 = playlist.getPlaylistSize(); + PlaylistItem pli = null; + for (int i = n0 - 1; i >= 0; i--) + { + pli = playlist.getItemAt(i); + if (pli.isSelected()) break; + } + // Play. + if ((pli != null) && (pli.getTagInfo() != null)) + { + player.pressStop(); + player.setCurrentSong(pli); + playlist.setCursor(playlist.getIndex(pli)); + player.pressStart(); + } + } + else if (cmd.equals(PlayerActionEvent.ACPLREMOVE)) + { + delSelectedItems(); + } + else if (cmd.equals(PlayerActionEvent.ACPLADDFILE)) + { + ui.getAcPlAddPopup().setVisible(false); + ui.getAcPlAdd().setVisible(true); + File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true, config.getExtensions(), ui.getResource("playlist.popup.add.file"), new File(config.getLastDir())); + if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath()); + addFiles(file); + } + else if (cmd.equals(PlayerActionEvent.ACPLADDURL)) + { + ui.getAcPlAddPopup().setVisible(false); + ui.getAcPlAdd().setVisible(true); + UrlDialog UD = new UrlDialog(config.getTopParent(), ui.getResource("playlist.popup.add.url"), player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight(), null); + UD.show(); + if (UD.getFile() != null) + { + PlaylistItem pli = new PlaylistItem(UD.getFile(), UD.getURL(), -1, false); + playlist.appendItem(pli); + resetScrollBar(); + repaint(); + } + } + else if (cmd.equals(PlayerActionEvent.ACPLADDDIR)) + { + ui.getAcPlAddPopup().setVisible(false); + ui.getAcPlAdd().setVisible(true); + File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "", ui.getResource("playlist.popup.add.dir"), new File(config.getLastDir())); + if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath()); + if (file == null || !file[0].isDirectory()) return; + // TODO - add message box for wrong filename + addDir(file[0]); + } + else if (cmd.equals(PlayerActionEvent.ACPLREMOVEALL)) + { + ui.getAcPlRemovePopup().setVisible(false); + ui.getAcPlRemove().setVisible(true); + delAllItems(); + } + else if (cmd.equals(PlayerActionEvent.ACPLREMOVESEL)) + { + ui.getAcPlRemovePopup().setVisible(false); + ui.getAcPlRemove().setVisible(true); + delSelectedItems(); + } + else if (cmd.equals(PlayerActionEvent.ACPLREMOVEMISC)) + { + ui.getAcPlRemovePopup().setVisible(false); + ui.getAcPlRemove().setVisible(true); + // TODO + } + else if (cmd.equals(PlayerActionEvent.ACPLREMOVECROP)) + { + ui.getAcPlRemovePopup().setVisible(false); + ui.getAcPlRemove().setVisible(true); + // TODO + } + else if (cmd.equals(PlayerActionEvent.ACPLSELALL)) + { + ui.getAcPlSelectPopup().setVisible(false); + ui.getAcPlSelect().setVisible(true); + selFunctions(1); + } + else if (cmd.equals(PlayerActionEvent.ACPLSELINV)) + { + ui.getAcPlSelectPopup().setVisible(false); + ui.getAcPlSelect().setVisible(true); + selFunctions(-1); + } + else if (cmd.equals(PlayerActionEvent.ACPLSELZERO)) + { + ui.getAcPlSelectPopup().setVisible(false); + ui.getAcPlSelect().setVisible(true); + selFunctions(0); + } + else if (cmd.equals(PlayerActionEvent.ACPLMISCOPTS)) + { + ui.getAcPlMiscPopup().setVisible(false); + ui.getAcPlMisc().setVisible(true); + // TODO + } + else if (cmd.equals(PlayerActionEvent.ACPLMISCFILE)) + { + ui.getAcPlMiscPopup().setVisible(false); + ui.getAcPlMisc().setVisible(true); + popupFileInfo(); + } + else if (cmd.equals(PlayerActionEvent.ACPLMISCSORT)) + { + ui.getAcPlMiscPopup().setVisible(false); + ui.getAcPlMisc().setVisible(true); + // TODO + } + else if (cmd.equals(PlayerActionEvent.ACPLLISTLOAD)) + { + ui.getAcPlListPopup().setVisible(false); + ui.getAcPlList().setVisible(true); + File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.OPEN, true, config.getExtensions(), ui.getResource("playlist.popup.list.load"), new File(config.getLastDir())); + if (FileSelector.getInstance().getDirectory() != null) config.setLastDir(FileSelector.getInstance().getDirectory().getPath()); + if ((file != null) && (file[0] != null)) + { + String fsFile = file[0].getName(); + if ((fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) || (fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls")))) + { + if (player.loadPlaylist(config.getLastDir() + fsFile)) + { + config.setPlaylistFilename(config.getLastDir() + fsFile); + playlist.begin(); + playlist.setCursor(-1); + // TODO + topIndex = 0; + } + resetScrollBar(); + repaint(); + } + } + } + else if (cmd.equals(PlayerActionEvent.ACPLLISTSAVE)) + { + ui.getAcPlListPopup().setVisible(false); + ui.getAcPlList().setVisible(true); + // TODO + } + else if (cmd.equals(PlayerActionEvent.ACPLLISTNEW)) + { + ui.getAcPlListPopup().setVisible(false); + ui.getAcPlList().setVisible(true); + // TODO + } + } + + /** + * Display file info. + */ + public void popupFileInfo() + { + int n0 = playlist.getPlaylistSize(); + PlaylistItem pli = null; + for (int i = n0 - 1; i >= 0; i--) + { + pli = playlist.getItemAt(i); + if (pli.isSelected()) break; + } + // Display Tag Info. + if (pli != null) + { + TagInfo taginfo = pli.getTagInfo(); + TagInfoFactory factory = TagInfoFactory.getInstance(); + TagInfoDialog dialog = factory.getTagInfoDialog(taginfo); + dialog.setLocation(player.getLoader().getLocation().x, player.getLoader().getLocation().y + player.getHeight()); + dialog.show(); + } + } + + /** + * Selection operation in pledit window + * @param mode -1 : inverse selected items, 0 : select none, 1 : select all + */ + private void selFunctions(int mode) + { + int n0 = playlist.getPlaylistSize(); + if (n0 == 0) return; + for (int i = 0; i < n0; i++) + { + PlaylistItem pli = playlist.getItemAt(i); + if (pli == null) break; + if (mode == -1) + { // inverse selection + pli.setSelected(!pli.isSelected()); + } + else if (mode == 0) + { // select none + pli.setSelected(false); + } + else if (mode == 1) + { // select all + pli.setSelected(true); + } + } + repaint(); + } + + /** + * Remove all items in playlist. + */ + private void delAllItems() + { + int n0 = playlist.getPlaylistSize(); + if (n0 == 0) return; + playlist.removeAllItems(); + topIndex = 0; + ui.getAcPlSlider().setValue(100); + repaint(); + } + + /** + * Remove selected items in playlist. + */ + private void delSelectedItems() + { + int n0 = playlist.getPlaylistSize(); + boolean brepaint = false; + for (int i = n0 - 1; i >= 0; i--) + { + if (playlist.getItemAt(i).isSelected()) + { + playlist.removeItemAt(i); + brepaint = true; + } + } + if (brepaint) + { + int n = playlist.getPlaylistSize(); + if (topIndex >= n) topIndex = n - 1; + if (topIndex < 0) topIndex = 0; + resetScrollBar(); + repaint(); + } + } + + /** + * Add file(s) to playlist. + * @param file + */ + public void addFiles(File[] file) + { + if (file != null) + { + for (int i = 0; i < file.length; i++) + { + String fsFile = file[i].getName(); + if ((!fsFile.toLowerCase().endsWith(ui.getResource("skin.extension"))) && (!fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.m3u"))) && (!fsFile.toLowerCase().endsWith(ui.getResource("playlist.extension.pls")))) + { + PlaylistItem pli = new PlaylistItem(fsFile, file[i].getAbsolutePath(), -1, true); + playlist.appendItem(pli); + resetScrollBar(); + repaint(); + } + } + } + } + + /** + * Handle mouse clicks on playlist. + * @param evt + */ + protected void handleMouseClick(MouseEvent evt) + { + int x = evt.getX(); + int y = evt.getY(); + ui.getAcPlAddPopup().setVisible(false); + ui.getAcPlAdd().setVisible(true); + ui.getAcPlRemovePopup().setVisible(false); + ui.getAcPlRemove().setVisible(true); + ui.getAcPlSelectPopup().setVisible(false); + ui.getAcPlSelect().setVisible(true); + ui.getAcPlMiscPopup().setVisible(false); + ui.getAcPlMisc().setVisible(true); + ui.getAcPlListPopup().setVisible(false); + ui.getAcPlList().setVisible(true); + // Check select action + if (ui.getPlaylistPanel().isInSelectArea(x, y)) + { + int index = getIndex(y); + if (index != -1) + { + // PopUp + if (javax.swing.SwingUtilities.isRightMouseButton(evt)) + { + if (fipopup != null) fipopup.show(this, x, y); + } + else + { + PlaylistItem pli = playlist.getItemAt(index); + if (pli != null) + { + pli.setSelected(!pli.isSelected()); + if ((evt.getClickCount() == 2) && (evt.getModifiers() == MouseEvent.BUTTON1_MASK)) + { + player.pressStop(); + player.setCurrentSong(pli); + playlist.setCursor(index); + player.pressStart(); + } + } + } + repaint(); + } + } + } + + /** + * Process Drag&Drop + * @param data + */ + public void processDnD(Object data) + { + log.debug("Playlist DnD"); + // Looking for files to drop. + if (data instanceof List) + { + List al = (List) data; + if ((al != null) && (al.size() > 0)) + { + ArrayList fileList = new ArrayList(); + ArrayList folderList = new ArrayList(); + ListIterator li = al.listIterator(); + while (li.hasNext()) + { + File f = (File) li.next(); + if ((f.exists()) && (f.canRead())) + { + if (f.isFile()) fileList.add(f); + else if (f.isDirectory()) folderList.add(f); + } + } + addFiles(fileList); + addDirs(folderList); + } + } + else if (data instanceof String) + { + String files = (String) data; + if ((files.length() > 0)) + { + ArrayList fileList = new ArrayList(); + ArrayList folderList = new ArrayList(); + StringTokenizer st = new StringTokenizer(files, System.getProperty("line.separator")); + // Transfer files dropped. + while (st.hasMoreTokens()) + { + String path = st.nextToken(); + if (path.startsWith("file://")) + { + path = path.substring(7, path.length()); + if (path.endsWith("\r")) path = path.substring(0, (path.length() - 1)); + } + File f = new File(path); + if ((f.exists()) && (f.canRead())) + { + if (f.isFile()) fileList.add(f); + else if (f.isDirectory()) folderList.add(f); + } + } + addFiles(fileList); + addDirs(folderList); + } + } + else + { + log.info("Unknown dropped objects"); + } + } + + /** + * Add files to playlistUI. + * @param fileList + */ + public void addFiles(List fileList) + { + if (fileList.size() > 0) + { + File[] file = (File[]) fileList.toArray(new File[fileList.size()]); + addFiles(file); + } + } + + /** + * Add directories to playlistUI. + * @param folderList + */ + public void addDirs(List folderList) + { + if (folderList.size() > 0) + { + ListIterator it = folderList.listIterator(); + while (it.hasNext()) + { + addDir((File) it.next()); + } + } + } + + /** + * Compute slider value. + */ + private void resetScrollBar() + { + int n = playlist.getPlaylistSize(); + float dx = (n < 1) ? 0 : ((float) topIndex / (n - 1)) * (100); + ui.getAcPlSlider().setValue(100 - (int) dx); + } + + public void paintList() + { + if (!isVisible()) return; + else repaint(); + } + + /* (non-Javadoc) + * @see javax.swing.JComponent#paintComponent(java.awt.Graphics) + */ + public void paintComponent(Graphics g) + { + ui.getPlaylistPanel().paintBackground(g); + ui.getPlaylistPanel().paintList(g); + } + + /** + * Add all files under this directory to play list. + * @param fsFile + */ + private void addDir(File fsFile) + { + // Put all music file extension in a Vector + String ext = config.getExtensions(); + StringTokenizer st = new StringTokenizer(ext, ", "); + if (exts == null) + { + exts = new Vector(); + while (st.hasMoreTokens()) + { + exts.add("." + st.nextElement()); + } + } + // recursive + Thread addThread = new AddThread(fsFile); + addThread.start(); + // Refresh thread + Thread refresh = new Thread("Refresh") + { + public void run() + { + while (isSearching) + { + resetScrollBar(); + repaint(); + try + { + Thread.sleep(4000); + } + catch (Exception ex) + { + } + } + } + }; + refresh.start(); + } + class AddThread extends Thread + { + private File fsFile; + + public AddThread(File fsFile) + { + super("Add"); + this.fsFile = fsFile; + } + + public void run() + { + isSearching = true; + addMusicRecursive(fsFile, 0); + isSearching = false; + resetScrollBar(); + repaint(); + } + } + + private void addMusicRecursive(File rootDir, int depth) + { + // We do not want waste time + if (rootDir == null || depth > MAXDEPTH) return; + String[] list = rootDir.list(); + if (list == null) return; + for (int i = 0; i < list.length; i++) + { + File ff = new File(rootDir, list[i]); + if (ff.isDirectory()) addMusicRecursive(ff, depth + 1); + else + { + if (isMusicFile(list[i])) + { + PlaylistItem pli = new PlaylistItem(list[i], rootDir + File.separator + list[i], -1, true); + playlist.appendItem(pli); + } + } + } + } + + private boolean isMusicFile(String ff) + { + int sz = exts.size(); + for (int i = 0; i < sz; i++) + { + String ext = exts.elementAt(i).toString().toLowerCase(); + // TODO : Improve + if (ext.equalsIgnoreCase(".wsz") || ext.equalsIgnoreCase(".m3u") || ext.equalsIgnoreCase(".pls")) continue; + if (ff.toLowerCase().endsWith(exts.elementAt(i).toString().toLowerCase())) return true; + } + return false; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteConstraints.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteConstraints.java new file mode 100644 index 0000000..44149dc --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteConstraints.java @@ -0,0 +1,151 @@ +/* + * AbsoluteConstraints. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Dimension; +import java.awt.Point; + +/** + * An object that encapsulates position and (optionally) size for + * Absolute positioning of components. + */ +public class AbsoluteConstraints implements java.io.Serializable +{ + /** + * generated Serialized Version UID + */ + static final long serialVersionUID = 5261460716622152494L; + /** + * The X position of the component + */ + public int x; + /** + * The Y position of the component + */ + public int y; + /** + * The width of the component or -1 if the component's preferred width should be used + */ + public int width = -1; + /** + * The height of the component or -1 if the component's preferred height should be used + */ + public int height = -1; + + /** + * Creates a new AbsoluteConstraints for specified position. + * + * @param pos The position to be represented by this AbsoluteConstraints + */ + public AbsoluteConstraints(Point pos) + { + this(pos.x, pos.y); + } + + /** + * Creates a new AbsoluteConstraints for specified position. + * + * @param x The X position to be represented by this AbsoluteConstraints + * @param y The Y position to be represented by this AbsoluteConstraints + */ + public AbsoluteConstraints(int x, int y) + { + this.x = x; + this.y = y; + } + + /** + * Creates a new AbsoluteConstraints for specified position and size. + * + * @param pos The position to be represented by this AbsoluteConstraints + * @param size The size to be represented by this AbsoluteConstraints or null + * if the component's preferred size should be used + */ + public AbsoluteConstraints(Point pos, Dimension size) + { + this.x = pos.x; + this.y = pos.y; + if (size != null) + { + this.width = size.width; + this.height = size.height; + } + } + + /** + * Creates a new AbsoluteConstraints for specified position and size. + * + * @param x The X position to be represented by this AbsoluteConstraints + * @param y The Y position to be represented by this AbsoluteConstraints + * @param width The width to be represented by this AbsoluteConstraints or -1 if the + * component's preferred width should be used + * @param height The height to be represented by this AbsoluteConstraints or -1 if the + * component's preferred height should be used + */ + public AbsoluteConstraints(int x, int y, int width, int height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + /** + * @return The X position represented by this AbsoluteConstraints + */ + public int getX() + { + return x; + } + + /** + * @return The Y position represented by this AbsoluteConstraints + */ + public int getY() + { + return y; + } + + /** + * @return The width represented by this AbsoluteConstraints or -1 if the + * component's preferred width should be used + */ + public int getWidth() + { + return width; + } + + /** + * @return The height represented by this AbsoluteConstraints or -1 if the + * component's preferred height should be used + */ + public int getHeight() + { + return height; + } + + public String toString() + { + return super.toString() + " [x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + "]"; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteLayout.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteLayout.java new file mode 100644 index 0000000..03a21bf --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteLayout.java @@ -0,0 +1,196 @@ +/* + * AbsoluteLayout. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.LayoutManager; +import java.awt.LayoutManager2; + +/** + * AbsoluteLayout is a LayoutManager that works as a replacement for "null" layout to + * allow placement of components in absolute positions. + */ +public class AbsoluteLayout implements LayoutManager2, java.io.Serializable +{ + /** + * generated Serialized Version UID + */ + static final long serialVersionUID = -1919857869177070440L; + + /** + * Adds the specified component with the specified name to + * the layout. + * + * @param name the component name + * @param comp the component to be added + */ + public void addLayoutComponent(String name, Component comp) + { + throw new IllegalArgumentException(); + } + + /** + * Removes the specified component from the layout. + * + * @param comp the component to be removed + */ + public void removeLayoutComponent(Component comp) + { + constraints.remove(comp); + } + + /** + * Calculates the preferred dimension for the specified + * panel given the components in the specified parent container. + * + * @param parent the component to be laid out + * @see #minimumLayoutSize + */ + public Dimension preferredLayoutSize(Container parent) + { + int maxWidth = 0; + int maxHeight = 0; + for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();) + { + Component comp = (Component) e.nextElement(); + AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp); + Dimension size = comp.getPreferredSize(); + int width = ac.getWidth(); + if (width == -1) width = size.width; + int height = ac.getHeight(); + if (height == -1) height = size.height; + if (ac.x + width > maxWidth) maxWidth = ac.x + width; + if (ac.y + height > maxHeight) maxHeight = ac.y + height; + } + return new Dimension(maxWidth, maxHeight); + } + + /** + * Calculates the minimum dimension for the specified + * panel given the components in the specified parent container. + * + * @param parent the component to be laid out + * @see #preferredLayoutSize + */ + public Dimension minimumLayoutSize(Container parent) + { + int maxWidth = 0; + int maxHeight = 0; + for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();) + { + Component comp = (Component) e.nextElement(); + AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp); + Dimension size = comp.getMinimumSize(); + int width = ac.getWidth(); + if (width == -1) width = size.width; + int height = ac.getHeight(); + if (height == -1) height = size.height; + if (ac.x + width > maxWidth) maxWidth = ac.x + width; + if (ac.y + height > maxHeight) maxHeight = ac.y + height; + } + return new Dimension(maxWidth, maxHeight); + } + + /** + * Lays out the container in the specified panel. + * + * @param parent the component which needs to be laid out + */ + public void layoutContainer(Container parent) + { + for (java.util.Enumeration e = constraints.keys(); e.hasMoreElements();) + { + Component comp = (Component) e.nextElement(); + AbsoluteConstraints ac = (AbsoluteConstraints) constraints.get(comp); + Dimension size = comp.getPreferredSize(); + int width = ac.getWidth(); + if (width == -1) width = size.width; + int height = ac.getHeight(); + if (height == -1) height = size.height; + comp.setBounds(ac.x, ac.y, width, height); + } + } + + /** + * Adds the specified component to the layout, using the specified + * constraint object. + * + * @param comp the component to be added + * @param constr where/how the component is added to the layout. + */ + public void addLayoutComponent(Component comp, Object constr) + { + if (!(constr instanceof AbsoluteConstraints)) throw new IllegalArgumentException(); + constraints.put(comp, constr); + } + + /** + * Returns the maximum size of this component. + * + * @see java.awt.Component#getMinimumSize() + * @see java.awt.Component#getPreferredSize() + * @see LayoutManager + */ + public Dimension maximumLayoutSize(Container target) + { + return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE); + } + + /** + * Returns the alignment along the x axis. This specifies how + * the component would like to be aligned relative to other + * components. The value should be a number between 0 and 1 + * where 0 represents alignment along the origin, 1 is aligned + * the furthest away from the origin, 0.5 is centered, etc. + */ + public float getLayoutAlignmentX(Container target) + { + return 0; + } + + /** + * Returns the alignment along the y axis. This specifies how + * the component would like to be aligned relative to other + * components. The value should be a number between 0 and 1 + * where 0 represents alignment along the origin, 1 is aligned + * the furthest away from the origin, 0.5 is centered, etc. + */ + public float getLayoutAlignmentY(Container target) + { + return 0; + } + + /** + * Invalidates the layout, indicating that if the layout manager + * has cached information it should be discarded. + */ + public void invalidateLayout(Container target) + { + } + /** + * A mapping + */ + protected java.util.Hashtable constraints = new java.util.Hashtable(); +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveFont.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveFont.java new file mode 100644 index 0000000..05feaec --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveFont.java @@ -0,0 +1,88 @@ +/* + * ActiveFont. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Image; + +public class ActiveFont +{ + private Image image = null; + private String index = null; + private int width = -1; + private int height = -1; + + public ActiveFont() + { + super(); + } + + public ActiveFont(Image image, String index, int width, int height) + { + super(); + this.image=image; + this.index=index; + this.width=width; + this.height=height; + } + + public int getHeight() + { + return height; + } + + public void setHeight(int height) + { + this.height = height; + } + + public Image getImage() + { + return image; + } + + public void setImage(Image image) + { + this.image = image; + } + + public String getIndex() + { + return index; + } + + public void setIndex(String index) + { + this.index = index; + } + + public int getWidth() + { + return width; + } + + public void setWidth(int width) + { + this.width = width; + } + +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJBar.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJBar.java new file mode 100644 index 0000000..5b069e0 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJBar.java @@ -0,0 +1,45 @@ +/* + * ActiveJBar. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import javax.swing.JPanel; + +public class ActiveJBar extends JPanel +{ + private AbsoluteConstraints constraints = null; + + public ActiveJBar() + { + super(); + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJButton.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJButton.java new file mode 100644 index 0000000..792943e --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJButton.java @@ -0,0 +1,48 @@ +/* + * ActiveJButton. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import javax.swing.JButton; + +public class ActiveJButton extends JButton +{ + private AbsoluteConstraints constraints = null; + + public ActiveJButton() + { + super(); + setBorder(null); + setDoubleBuffered(true); + setFocusPainted(false); + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJIcon.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJIcon.java new file mode 100644 index 0000000..331dc53 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJIcon.java @@ -0,0 +1,62 @@ +/* + * ActiveJIcon. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; + +public class ActiveJIcon extends JLabel +{ + private AbsoluteConstraints constraints = null; + private ImageIcon[] icons = null; + + public ActiveJIcon() + { + super(); + this.setBorder(null); + this.setDoubleBuffered(true); + } + + public void setIcons(ImageIcon[] icons) + { + this.icons = icons; + } + + public void setIcon(int id) + { + if ((id >= 0) && (id < icons.length)) + { + setIcon(icons[id]); + } + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJLabel.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJLabel.java new file mode 100644 index 0000000..0520193 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJLabel.java @@ -0,0 +1,104 @@ +/* + * ActiveJLabel. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Rectangle; +import javax.swing.ImageIcon; +import javax.swing.JLabel; + +public class ActiveJLabel extends JLabel +{ + private AbsoluteConstraints constraints = null; + private ActiveFont acFont = null; + private Rectangle cropRectangle = null; + private String acText = null; + + public ActiveJLabel() + { + super(); + setBorder(null); + setDoubleBuffered(true); + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } + + public ActiveFont getAcFont() + { + return acFont; + } + + public void setAcFont(ActiveFont acFont) + { + this.acFont = acFont; + } + + public Rectangle getCropRectangle() + { + return cropRectangle; + } + + public void setCropRectangle(Rectangle cropRectangle) + { + this.cropRectangle = cropRectangle; + } + + public String getAcText() + { + return acText; + } + + public void setAcText(String txt) + { + acText = txt; + + acText = acText.replace('È','E'); + acText = acText.replace('É','E'); + acText = acText.replace('Ê','E'); + acText = acText.replace('À','A'); + acText = acText.replace('Ä','A'); + acText = acText.replace('Ç','C'); + acText = acText.replace('Ù','U'); + acText = acText.replace('Ü','U'); + acText = acText.replace('Ï','I'); + if (acFont != null) + { + Taftb parser = new Taftb(acFont.getIndex(), acFont.getImage(), acFont.getWidth(), acFont.getHeight(), 0, acText); + if (cropRectangle != null) + { + setIcon(new ImageIcon(parser.getBanner(cropRectangle.x, cropRectangle.y, cropRectangle.width, cropRectangle.height))); + } + else + { + setIcon(new ImageIcon(parser.getBanner())); + } + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJNumberLabel.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJNumberLabel.java new file mode 100644 index 0000000..c3ad335 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJNumberLabel.java @@ -0,0 +1,61 @@ +/* + * ActiveJNumberLabel. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import javax.swing.ImageIcon; + +public class ActiveJNumberLabel extends ActiveJLabel +{ + private ImageIcon[] numbers = null; + + public ActiveJNumberLabel() + { + super(); + } + + public ImageIcon[] getNumbers() + { + return numbers; + } + + public void setNumbers(ImageIcon[] numbers) + { + this.numbers = numbers; + } + + public void setAcText(String numberStr) + { + int number = 10; + try + { + number = Integer.parseInt(numberStr); + } + catch (NumberFormatException e) + { + } + if ((number >= 0) && (number < numbers.length)) + { + setIcon(numbers[number]); + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJPopup.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJPopup.java new file mode 100644 index 0000000..2bd9e75 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJPopup.java @@ -0,0 +1,70 @@ +/* + * ActiveJPopup. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.GridLayout; +import javax.swing.JPanel; + +public class ActiveJPopup extends JPanel +{ + private AbsoluteConstraints constraints = null; + private ActiveJButton[] items = null; + + public ActiveJPopup() + { + super(); + setBorder(null); + setDoubleBuffered(true); + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } + + public ActiveJButton[] getItems() + { + return items; + } + + public void setItems(ActiveJButton[] items) + { + this.items = items; + if (items != null) + { + setLayout(new GridLayout(items.length, 1, 0, 0)); + for (int i=0;i= 0) + { + if (parentSlider.getOrientation() == JSlider.HORIZONTAL) + { + g.drawImage(img, thumbRect.x + thumbXOffset, thumbYOffset, img.getWidth(null), newThumbHeight, null); + } + else + { + g.drawImage(img, thumbXOffset, thumbRect.y + thumbYOffset, img.getWidth(null), newThumbHeight, null); + } + } + else + { + if (parentSlider.getOrientation() == JSlider.HORIZONTAL) + { + g.drawImage(img, thumbRect.x + thumbXOffset, thumbYOffset, img.getWidth(null), img.getHeight(null), null); + } + else + { + g.drawImage(img, thumbXOffset, thumbRect.y + thumbYOffset, img.getWidth(null), img.getHeight(null), null); + } + } + } + } + + public void paintTrack(Graphics g) + { + if (backgroundImages != null) + { + int id = (int) Math.round(((double) Math.abs(parentSlider.getValue()) / (double) parentSlider.getMaximum()) * (backgroundImages.length - 1)); + g.drawImage(backgroundImages[id], 0, 0, backgroundImages[id].getWidth(null), backgroundImages[id].getHeight(null), null); + } + } + + public void setThumbLocation(int x, int y) + { + super.setThumbLocation(x, y); + parentSlider.repaint(); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DragAdapter.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DragAdapter.java new file mode 100644 index 0000000..59f1901 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DragAdapter.java @@ -0,0 +1,68 @@ +/* + * DragAdapter. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Component; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseMotionListener; + +public class DragAdapter extends MouseAdapter implements MouseMotionListener +{ + private int mousePrevX = 0; + private int mousePrevY = 0; + private Component component = null; + + public DragAdapter(Component component) + { + super(); + this.component = component; + } + + public void mousePressed(MouseEvent me) + { + super.mousePressed(me); + mousePrevX = me.getX(); + mousePrevY = me.getY(); + } + + public void mouseDragged(MouseEvent me) + { + int mX = me.getX(); + int mY = me.getY(); + int cX = component.getX(); + int cY = component.getY(); + int moveX = mX - mousePrevX; // Negative if move left + int moveY = mY - mousePrevY; // Negative if move down + if (moveX == 0 && moveY == 0) return; + mousePrevX = mX - moveX; + mousePrevY = mY - moveY; + int newX = cX + moveX; + int newY = cY + moveY; + component.setLocation(newX, newY); + } + + public void mouseMoved(MouseEvent e) + { + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DropTargetAdapter.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DropTargetAdapter.java new file mode 100644 index 0000000..774a125 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DropTargetAdapter.java @@ -0,0 +1,163 @@ +/* + * DropTargetAdapter. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.io.IOException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class DropTargetAdapter implements DropTargetListener +{ + private static Log log = LogFactory.getLog(DropTargetAdapter.class); + + public DropTargetAdapter() + { + super(); + } + + public void dragEnter(DropTargetDragEvent e) + { + if (isDragOk(e) == false) + { + e.rejectDrag(); + } + } + + public void dragOver(DropTargetDragEvent e) + { + if (isDragOk(e) == false) + { + e.rejectDrag(); + } + } + + public void dropActionChanged(DropTargetDragEvent e) + { + if (isDragOk(e) == false) + { + e.rejectDrag(); + } + } + + public void dragExit(DropTargetEvent dte) + { + } + + protected boolean isDragOk(DropTargetDragEvent e) + { + // Check DataFlavor + DataFlavor[] dfs = e.getCurrentDataFlavors(); + DataFlavor tdf = null; + for (int i = 0; i < dfs.length; i++) + { + if (DataFlavor.javaFileListFlavor.equals(dfs[i])) + { + tdf = dfs[i]; + break; + } + else if (DataFlavor.stringFlavor.equals(dfs[i])) + { + tdf = dfs[i]; + break; + } + } + // Only file list allowed. + if (tdf != null) + { + // Only DnD COPY allowed. + if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0) + { + return true; + } + else return false; + } + else return false; + } + + public void drop(DropTargetDropEvent e) + { + // Check DataFlavor + DataFlavor[] dfs = e.getCurrentDataFlavors(); + DataFlavor tdf = null; + for (int i = 0; i < dfs.length; i++) + { + if (DataFlavor.javaFileListFlavor.equals(dfs[i])) + { + tdf = dfs[i]; + break; + } + else if (DataFlavor.stringFlavor.equals(dfs[i])) + { + tdf = dfs[i]; + break; + } + } + // Data Flavor available ? + if (tdf != null) + { + // Accept COPY DnD only. + if ((e.getSourceActions() & DnDConstants.ACTION_COPY) != 0) + { + e.acceptDrop(DnDConstants.ACTION_COPY); + } + else return; + try + { + Transferable t = e.getTransferable(); + Object data = t.getTransferData(tdf); + processDrop(data); + } + catch (IOException ioe) + { + log.info("Drop error", ioe); + e.dropComplete(false); + return; + } + catch (UnsupportedFlavorException ufe) + { + log.info("Drop error", ufe); + e.dropComplete(false); + return; + } + catch (Exception ex) + { + log.info("Drop error", ex); + e.dropComplete(false); + return; + } + e.dropComplete(true); + } + } + + public void processDrop(Object data) + { + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ImageBorder.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ImageBorder.java new file mode 100644 index 0000000..040c37a --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ImageBorder.java @@ -0,0 +1,65 @@ +/* + * ImageBorder. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Insets; +import javax.swing.border.Border; + +public class ImageBorder implements Border +{ + private Insets insets = new Insets(0, 0, 0, 0); + private Image image = null; + + public ImageBorder() + { + super(); + } + + public void setImage(Image image) + { + this.image = image; + } + + public boolean isBorderOpaque() + { + return true; + } + + public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) + { + if (image != null) + { + int x0 = x + (width - image.getWidth(null)) / 2; + int y0 = y + (height - image.getHeight(null)) / 2; + g.drawImage(image, x0, y0, null); + } + } + + public Insets getBorderInsets(Component c) + { + return insets; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PlaylistUIDelegate.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PlaylistUIDelegate.java new file mode 100644 index 0000000..5c68592 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PlaylistUIDelegate.java @@ -0,0 +1,276 @@ +/* + * PlaylistUIDelegate. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Image; +import javazoom.jlgui.player.amp.playlist.PlaylistItem; +import javazoom.jlgui.player.amp.playlist.ui.PlaylistUI; + +public class PlaylistUIDelegate +{ + private AbsoluteConstraints constraints = null; + private Image titleLeftImage = null; + private Image titleRightImage = null; + private Image titleCenterImage = null; + private Image titleStretchImage = null; + private Image leftImage = null; + private Image rightImage = null; + private Image bottomLeftImage = null; + private Image bottomRightImage = null; + private Image bottomStretchImage = null; + private Color backgroundColor = null; + private Color selectedBackgroundColor = null; + private Color normalColor = null; + private Color currentColor = null; + private Font font = null; + private int listarea[] = { 12, 24 - 4, 256, 78 }; + private PlaylistUI parent = null; + + public PlaylistUIDelegate() + { + super(); + currentColor = new Color(102, 204, 255); + normalColor = new Color(0xb2, 0xe4, 0xf6); + selectedBackgroundColor = Color.black; + backgroundColor = Color.black; + font = new Font("Dialog", Font.PLAIN, 10); + } + + public void setParent(PlaylistUI playlist) + { + parent = playlist; + } + + public Color getBackgroundColor() + { + return backgroundColor; + } + + public void setBackgroundColor(Color backgroundColor) + { + this.backgroundColor = backgroundColor; + } + + public Color getSelectedBackgroundColor() + { + return selectedBackgroundColor; + } + + public Color getCurrentColor() + { + return currentColor; + } + + public void setCurrentColor(Color currentColor) + { + this.currentColor = currentColor; + } + + public Color getNormalColor() + { + return normalColor; + } + + public void setNormalColor(Color normalColor) + { + this.normalColor = normalColor; + } + + public void setSelectedBackgroundColor(Color selectedColor) + { + this.selectedBackgroundColor = selectedColor; + } + + public Image getBottomLeftImage() + { + return bottomLeftImage; + } + + public void setBottomLeftImage(Image bottomLeftImage) + { + this.bottomLeftImage = bottomLeftImage; + } + + public Image getBottomRightImage() + { + return bottomRightImage; + } + + public void setBottomRightImage(Image bottomRightImage) + { + this.bottomRightImage = bottomRightImage; + } + + public Image getBottomStretchImage() + { + return bottomStretchImage; + } + + public void setBottomStretchImage(Image bottomStretchImage) + { + this.bottomStretchImage = bottomStretchImage; + } + + public Image getLeftImage() + { + return leftImage; + } + + public void setLeftImage(Image leftImage) + { + this.leftImage = leftImage; + } + + public Image getRightImage() + { + return rightImage; + } + + public void setRightImage(Image rightImage) + { + this.rightImage = rightImage; + } + + public Image getTitleCenterImage() + { + return titleCenterImage; + } + + public void setTitleCenterImage(Image titleCenterImage) + { + this.titleCenterImage = titleCenterImage; + } + + public Image getTitleLeftImage() + { + return titleLeftImage; + } + + public void setTitleLeftImage(Image titleLeftImage) + { + this.titleLeftImage = titleLeftImage; + } + + public Image getTitleRightImage() + { + return titleRightImage; + } + + public void setTitleRightImage(Image titleRightImage) + { + this.titleRightImage = titleRightImage; + } + + public Image getTitleStretchImage() + { + return titleStretchImage; + } + + public void setTitleStretchImage(Image titleStretchImage) + { + this.titleStretchImage = titleStretchImage; + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } + + public int getLines() + { + return ((listarea[3] - listarea[1]) / 12); + } + + public boolean isInSelectArea(int x, int y) + { + return (x >= listarea[0] && x <= listarea[2] && y >= listarea[1] && y <= listarea[3]); + } + + public boolean isIndexArea(int y, int n) + { + return (y >= listarea[1] + 12 - 10 + n * 12 && y < listarea[1] + 12 - 10 + n * 12 + 14); + } + + public void paintBackground(Graphics g) + { + g.drawImage(titleLeftImage, 0, 0, null); + g.drawImage(titleStretchImage, 25, 0, null); + g.drawImage(titleStretchImage, 50, 0, null); + g.drawImage(titleStretchImage, 62, 0, null); + g.drawImage(titleCenterImage, 87, 0, null); + g.drawImage(titleStretchImage, 187, 0, null); + g.drawImage(titleStretchImage, 200, 0, null); + g.drawImage(titleStretchImage, 225, 0, null); + g.drawImage(titleRightImage, 250, 0, null); + g.drawImage(leftImage, 0, 20, null); + g.drawImage(leftImage, 0, 48, null); + g.drawImage(leftImage, 0, 50, null); + //g.drawImage(rightImage, parent.getWidth() - 20, 20, null); + //g.drawImage(rightImage, parent.getWidth() - 20, 48, null); + //g.drawImage(rightImage, parent.getWidth() - 20, 50, null); + g.drawImage(bottomLeftImage, 0, parent.getHeight() - 38, null); + g.drawImage(bottomRightImage, 125, parent.getHeight() - 38, null); + } + + public void paintList(Graphics g) + { + g.setColor(backgroundColor); + g.fillRect(listarea[0], listarea[1], listarea[2] - listarea[0], listarea[3] - listarea[1]); + if (font != null) g.setFont(font); + if (parent.getPlaylist() != null) + { + int currentSelection = parent.getPlaylist().getSelectedIndex(); + g.setColor(normalColor); + int n = parent.getPlaylist().getPlaylistSize(); + for (int i = 0; i < n; i++) + { + if (i < parent.getTopIndex()) continue; + int k = i - parent.getTopIndex(); + if (listarea[1] + 12 + k * 12 > listarea[3]) break; + PlaylistItem pli = parent.getPlaylist().getItemAt(i); + String name = pli.getFormattedName(); + if (pli.isSelected()) + { + g.setColor(selectedBackgroundColor); + g.fillRect(listarea[0] + 4, listarea[1] + 12 - 10 + k * 12, listarea[2] - listarea[0] - 4, 14); + } + if (i == currentSelection) g.setColor(currentColor); + else g.setColor(normalColor); + if (i + 1 >= 10) g.drawString((i + 1) + ". " + name, listarea[0] + 12, listarea[1] + 12 + k * 12); + else g.drawString("0" + (i + 1) + ". " + name, listarea[0] + 12, listarea[1] + 12 + k * 12); + if (i == currentSelection) g.setColor(normalColor); + } + //g.drawImage(rightImage, parent.getWidth() - 20, 20, null); + //g.drawImage(rightImage, parent.getWidth() - 20, 48, null); + //g.drawImage(rightImage, parent.getWidth() - 20, 50, null); + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PopupAdapter.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PopupAdapter.java new file mode 100644 index 0000000..fc961ee --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PopupAdapter.java @@ -0,0 +1,61 @@ +/* + * PopupAdapter. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.JPopupMenu; + +public class PopupAdapter extends MouseAdapter +{ + private JPopupMenu popup = null; + + public PopupAdapter(JPopupMenu popup) + { + super(); + this.popup=popup; + } + + public void mousePressed(MouseEvent e) + { + checkPopup(e); + } + + public void mouseClicked(MouseEvent e) + { + checkPopup(e); + } + + public void mouseReleased(MouseEvent e) + { + checkPopup(e); + } + + private void checkPopup(MouseEvent e) + { + if (e.isPopupTrigger()) + { + popup.show(e.getComponent(), e.getX(), e.getY()); + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Skin.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Skin.java new file mode 100644 index 0000000..32a03e3 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Skin.java @@ -0,0 +1,1493 @@ +/* + * Skin. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import java.awt.image.PixelGrabber; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import javax.swing.ImageIcon; +import javax.swing.JSlider; +import javazoom.jlgui.player.amp.PlayerActionEvent; +import javazoom.jlgui.player.amp.equalizer.ui.SplinePanel; +import javazoom.jlgui.player.amp.util.Config; +import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class allows to load all skin (2.0 compliant) features. + */ +public class Skin +{ + private static Log log = LogFactory.getLog(Skin.class); + public static final String TITLETEXT = "jlGui 3.0 "; + private Config config = null; + private String skinVersion = "1"; // 1, 2, for different Volume.bmp + private String path = null; + private boolean dspEnabled = true; + /*-- Window Parameters --*/ + private int WinWidth, WinHeight; + private String theMain = "main.bmp"; + private Image imMain = null; + /*-- Text Members --*/ + private int fontWidth = 5; + private int fontHeight = 6; + private String theText = "text.bmp"; + private Image imText; + private String fontIndex = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\"@a " + "0123456789 :()-'!_+ /[]^&%.=$#" + " ?*"; + private ActiveFont acFont = null; + private ActiveJLabel acTitleLabel = null; + private ActiveJLabel acSampleRateLabel = null; + private ActiveJLabel acBitRateLabel = null; + private String sampleRateClearText = " "; + private int[] sampleRateLocation = { 156, 43 }; + private String bitsRateClearText = " "; + private int[] bitsRateLocation = { 110, 43 }; + private int[] titleLocation = { 111, 27 }; + /*-- Numbers Members --*/ + private int numberWidth = 9; + private int numberHeight = 13; + private String theNumbers = "numbers.bmp"; + private String theNumEx = "nums_ex.bmp"; + private Image imNumbers; + private String numberIndex = "0123456789 "; + private int[] minuteHLocation = { 48, 26 }; + private int[] minuteLLocation = { 60, 26 }; + private int[] secondHLocation = { 78, 26 }; + private int[] secondLLocation = { 90, 26 }; + private ActiveJNumberLabel acMinuteH = null; + private ActiveJNumberLabel acMinuteL = null; + private ActiveJNumberLabel acSecondH = null; + private ActiveJNumberLabel acSecondL = null; + /*-- Buttons Panel members --*/ + private String theButtons = "cbuttons.bmp"; + private Image imButtons; + private ActiveJButton acPrevious, acPlay, acPause, acStop, acNext, acEject; + private Image imPrevious, imPlay, imPause, imStop, imNext, imEject; + private Image[] releasedImage = { imPrevious, imPlay, imPause, imStop, imNext, imEject }; + private Image[] pressedImage = { imPrevious, imPlay, imPause, imStop, imNext, imEject }; + private int[] releasedPanel = { 0, 0, 23, 18, 23, 0, 23, 18, 46, 0, 23, 18, 69, 0, 23, 18, 92, 0, 22, 18, 114, 0, 22, 16 }; + private int[] pressedPanel = { 0, 18, 23, 18, 23, 18, 23, 18, 46, 18, 23, 18, 69, 18, 23, 18, 92, 18, 22, 18, 114, 16, 22, 16 }; + private int[] panelLocation = { 16, 88, 39, 88, 62, 88, 85, 88, 108, 88, 136, 89 }; + /*-- EqualizerUI/Playlist/Shuffle/Repeat --*/ + private String theEPSRButtons = "shufrep.bmp"; + private Image imEPSRButtons; + private ActiveJToggleButton acEqualizer, acPlaylist, acShuffle, acRepeat; + private Image[] releasedEPSRImage = { null, null, null, null }; + private Image[] pressedEPSRImage = { null, null, null, null }; + private int[] releasedEPSRPanel = { 0, 61, 23, 12, 23, 61, 23, 12, 28, 0, 47, 15, 0, 0, 28, 15 }; + private int[] pressedEPSRPanel = { 0, 73, 23, 12, 23, 73, 23, 12, 28, 30, 47, 15, 0, 30, 28, 15 }; + private int[] panelEPSRLocation = { 219, 58, 242, 58, 164, 89, 212, 89 }; + /*-- Volume Panel members --*/ + public static final int VOLUMEMAX = 100; + private String theVolume = "volume.bmp"; + private Image imVolume; + private ActiveJSlider acVolume = null;; + private Image[] volumeImage = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; + private String fakeIndex = "abcdefghijklmnopqrstuvwxyz01"; + private int[] volumeBarLocation = { 107, 57 }; + private Image[] releasedVolumeImage = { null }; + private Image[] pressedVolumeImage = { null }; + private int[] releasedVolumePanel0 = { 15, 422, 14, 11 }; + private int[] pressedVolumePanel0 = { 0, 422, 14, 11 }; + private int[] releasedVolumePanel1 = { 75, 376, 14, 11 }; + private int[] pressedVolumePanel1 = { 90, 376, 14, 11 }; + /*-- Balance Panel members --*/ + public static final int BALANCEMAX = 5; + private String theBalance = "balance.bmp"; + private ActiveJSlider acBalance = null; + private Image imBalance; + private Image[] balanceImage = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; + private Image[] releasedBalanceImage = { null }; + private Image[] pressedBalanceImage = { null }; + private int[] releasedBalancePanel0 = { 15, 422, 14, 11 }; + private int[] pressedBalancePanel0 = { 0, 422, 14, 11 }; + private int[] releasedBalancePanel1 = { 75, 376, 14, 11 }; + private int[] pressedBalancePanel1 = { 90, 376, 14, 11 }; + private int[] balanceBarLocation = { 177, 57 }; + /*-- Title members --*/ + private String theTitleBar = "titlebar.bmp"; + private Image imTitleBar; + private ActiveJBar acTitleBar = null; + private Image imTitleB; + private Image[] releasedTitleIm = { imTitleB }; + private Image[] pressedTitleIm = { imTitleB }; + private int[] releasedTitlePanel = { 27, 0, 264 - 20, 14 }; // -20 for the two button add by me + private int[] pressedTitlePanel = { 27, 15, 264 - 20, 14 };// -20 for the two button add by me + private int[] titleBarLocation = { 0, 0 }; + /*-- Exit member --*/ + private ActiveJButton acExit = null; + private int[] releasedExitPanel = { 18, 0, 9, 9 }; + private int[] pressedExitPanel = { 18, 9, 9, 9 }; + private Image[] releasedExitIm = { null }; + private Image[] pressedExitIm = { null }; + private int[] exitLocation = { 264, 3 }; + /*-- Minimize member --*/ + private ActiveJButton acMinimize = null; + private int[] releasedMinimizePanel = { 9, 0, 9, 9 }; + private int[] pressedMinimizePanel = { 9, 9, 9, 9 }; + private Image[] releasedMinimizeIm = { null }; + private Image[] pressedMinimizeIm = { null }; + private int[] minimizeLocation = { 244, 3 }; + /*-- Mono/Stereo Members --*/ + private String theMode = "monoster.bmp"; + private Image imMode; + private int[] activeModePanel = { 0, 0, 28, 12, 29, 0, 27, 12 }; + private int[] passiveModePanel = { 0, 12, 28, 12, 29, 12, 27, 12 }; + private Image[] activeModeImage = { null, null }; + private Image[] passiveModeImage = { null, null }; + private int[] monoLocation = { 212, 41 }; + private int[] stereoLocation = { 239, 41 }; + private ActiveJIcon acMonoIcon = null; + private ActiveJIcon acStereoIcon = null; + /*-- PosBar members --*/ + public static final int POSBARMAX = 1000; + private String thePosBar = "posbar.bmp"; + private Image imPosBar; + private ActiveJSlider acPosBar = null; + private Image[] releasedPosIm = { null }; + private Image[] pressedPosIm = { null }; + private int[] releasedPosPanel = { 248, 0, 28, 10 }; + private int[] pressedPosPanel = { 278, 0, 28, 10 }; + private int[] posBarLocation = { 16, 72 }; + /*-- Play/Pause Icons --*/ + private String theIcons = "playpaus.bmp"; + private Image imIcons; + private Image[] iconsImage = { null, null, null, null, null }; + private int[] iconsPanel = { 0, 0, 9, 9, 9, 0, 9, 9, 18, 0, 9, 9, 36, 0, 3, 9, 27, 0, 2, 9 }; + private int[] iconsLocation = { 26, 28, 24, 28 }; + private ActiveJIcon acPlayIcon = null; + private ActiveJIcon acTimeIcon = null; + /*-- Readme --*/ + private String theReadme = "readme.txt"; + private String readme = null; + /*-- DSP and viscolor --*/ + private String theViscolor = "viscolor.txt"; + private String viscolor = null; + private int[] visualLocation = { 24, 44 }; + private int[] visualSize = { 76, 15 }; + private SpectrumTimeAnalyzer analyzer = null; + /*-- EqualizerUI --*/ + private Image imFullEqualizer = null; + private Image imEqualizer = null; + private Image imSliders = null; + private ActiveJSlider[] acSlider = { null, null, null, null, null, null, null, null, null, null, null }; + private Image[] sliderImage = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; + private int[][] sliderBarLocation = { { 21, 38 }, { 78, 38 }, { 96, 38 }, { 114, 38 }, { 132, 38 }, { 150, 38 }, { 168, 38 }, { 186, 38 }, { 204, 38 }, { 222, 38 }, { 240, 38 } }; + private Image[] releasedSliderImage = { null }; + private Image[] pressedSliderImage = { null }; + private int[][] sliderLocation = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } }; + private Image[] releasedPresetsImage = { null }; + private Image[] pressedPresetsImage = { null }; + private int[] panelPresetsLocation = { 217, 18 }; + private ActiveJButton acPresets = null; + private ActiveJToggleButton acOnOff, acAuto; + private Image[] releasedOAImage = { null, null }; + private Image[] pressedOAImage = { null, null }; + private int[] panelOALocation = { 15, 18, 39, 18 }; + private SplinePanel spline = null; + private int[] panelSplineLocation = { 88, 17, 113, 19 }; + private Image splineImage = null; + private Image splineBarImage = null; + private ResourceBundle bundle = null; + /*-- Playlist --*/ + private PlaylistUIDelegate playlist = null; + private Image imPlaylist = null; + private String plEdit = null; + private ActiveJSlider acPlSlider = null; + private int[] plSliderLocation = { 255, 20 }; + private ActiveJButton acPlUp, acPlDown; + private ActiveJButton acPlAdd, acPlRemove, acPlSelect, acPlMisc, acPlList; + private int[] plAddLocation = { 14, 86 }; + private int[] plRemoveLocation = { 14 + 30, 86 }; + private int[] plSelectLocation = { 14 + 60, 86 }; + private int[] plMiscLocation = { 14 + 89, 86 }; + private int[] plListLocation = { 14 + 214, 86 }; + private ActiveJPopup acPlAddPopup, acPlRemovePopup, acPlSelectPopup, acPlMiscPopup, acPlListPopup; + private int[] plAddPopupArea = { 14, 50, 22, 18 * 3 }; + private int[] plRemovePopupArea = { 14 + 29, 32, 22, 18 * 4 }; + private int[] plSelectPopupArea = { 14 + 58, 50, 22, 18 * 3 }; + private int[] plMiscPopupArea = { 14 + 87, 50, 22, 18 * 3 }; + private int[] plListPopupArea = { 14 + 217, 50, 22, 18 * 3 }; + + public Skin() + { + super(); + String i18n = "javazoom/jlgui/player/amp/skin/skin"; + bundle = ResourceBundle.getBundle(i18n); + } + + /** + * Return I18N value of a given key. + * @param key + * @return + */ + public String getResource(String key) + { + String value = null; + try + { + value = bundle.getString(key); + } + catch (MissingResourceException e) + { + log.debug(e); + } + return value; + } + + /** + * Return skin path. + * @return + */ + public String getPath() + { + return path; + } + + public void setPath(String path) + { + this.path = path; + } + + public boolean isDspEnabled() + { + return dspEnabled; + } + + public void setDspEnabled(boolean dspEnabled) + { + this.dspEnabled = dspEnabled; + } + + /** + * Loads a new skin from local file system. + * @param skinName + */ + public void loadSkin(String skinName) + { + SkinLoader skl = new SkinLoader(skinName); + try + { + loadSkin(skl); + path = skinName; + } + catch (Exception e) + { + log.info("Can't load skin : ", e); + InputStream sis = this.getClass().getClassLoader().getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz"); + log.info("Load default skin for JAR"); + loadSkin(sis); + } + } + + /** + * Loads a new skin from any input stream. + * @param skinStream + */ + public void loadSkin(InputStream skinStream) + { + SkinLoader skl = new SkinLoader(skinStream); + try + { + loadSkin(skl); + } + catch (Exception e) + { + log.info("Can't load skin : ", e); + InputStream sis = this.getClass().getClassLoader().getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz"); + log.info("Load default skin for JAR"); + loadSkin(sis); + } + } + + /** + * Loads a skin from a SkinLoader. + * @param skl + * @throws Exception + */ + public void loadSkin(SkinLoader skl) throws Exception + { + skl.loadImages(); + imMain = skl.getImage(theMain); + imButtons = skl.getImage(theButtons); + imTitleBar = skl.getImage(theTitleBar); + imText = skl.getImage(theText); + imMode = skl.getImage(theMode); + imNumbers = skl.getImage(theNumbers); + // add by John Yang + if (imNumbers == null) + { + log.debug("Try load nums_ex.bmp !"); + imNumbers = skl.getImage(theNumEx); + } + imVolume = skl.getImage(theVolume); + imBalance = skl.getImage(theBalance); + imIcons = skl.getImage(theIcons); + imPosBar = skl.getImage(thePosBar); + imEPSRButtons = skl.getImage(theEPSRButtons); + viscolor = (String) skl.getContent(theViscolor); + String readmeStr = theReadme; + readme = (String) skl.getContent(readmeStr); + if (readme == null) + { + readmeStr = readmeStr.toUpperCase(); + readme = (String) skl.getContent(readmeStr); + } + if (readme == null) + { + readmeStr = readmeStr.substring(0, 1) + theReadme.substring(1, theReadme.length()); + readme = (String) skl.getContent(readmeStr); + } + // Computes volume slider height : + int vh = (imVolume.getHeight(null) - 422); + if (vh > 0) + { + releasedVolumePanel0[3] = vh; + pressedVolumePanel0[3] = vh; + releasedVolumePanel1[3] = vh; + pressedVolumePanel1[3] = vh; + } + // Computes balance slider height : + if (imBalance == null) imBalance = imVolume; + int bh = (imBalance.getHeight(null) - 422); + if (bh > 0) + { + releasedBalancePanel0[3] = bh; + pressedBalancePanel0[3] = bh; + releasedBalancePanel1[3] = bh; + pressedBalancePanel1[3] = bh; + } + // Compute posbar height. + int ph = imPosBar.getHeight(null); + if (ph > 0) + { + releasedPosPanel[3] = ph; + pressedPosPanel[3] = ph; + } + WinHeight = imMain.getHeight(null); // 116 + WinWidth = imMain.getWidth(null); // 275 + /*-- Text --*/ + acFont = new ActiveFont(imText, fontIndex, fontWidth, fontHeight); + acTitleLabel = new ActiveJLabel(); + acTitleLabel.setAcFont(acFont); + acTitleLabel.setCropRectangle(new Rectangle(0, 0, 155, 6)); + acTitleLabel.setConstraints(new AbsoluteConstraints(titleLocation[0], titleLocation[1], 155, 6)); + acTitleLabel.setAcText(TITLETEXT.toUpperCase()); + acSampleRateLabel = new ActiveJLabel(); + acSampleRateLabel.setAcFont(acFont); + acSampleRateLabel.setConstraints(new AbsoluteConstraints(sampleRateLocation[0], sampleRateLocation[1])); + acSampleRateLabel.setAcText(sampleRateClearText); + acBitRateLabel = new ActiveJLabel(); + acBitRateLabel.setAcFont(acFont); + acBitRateLabel.setConstraints(new AbsoluteConstraints(bitsRateLocation[0], bitsRateLocation[1])); + acBitRateLabel.setAcText(bitsRateClearText); + /*-- Buttons --*/ + readPanel(releasedImage, releasedPanel, pressedImage, pressedPanel, imButtons); + setButtonsPanel(); + /*-- Volume/Balance --*/ + if (skinVersion.equals("1")) + { + readPanel(releasedVolumeImage, releasedVolumePanel0, pressedVolumeImage, pressedVolumePanel0, imVolume); + readPanel(releasedBalanceImage, releasedBalancePanel0, pressedBalanceImage, pressedBalancePanel0, imBalance); + } + else + { + readPanel(releasedVolumeImage, releasedVolumePanel1, pressedVolumeImage, pressedVolumePanel1, imVolume); + readPanel(releasedBalanceImage, releasedBalancePanel1, pressedBalanceImage, pressedBalancePanel1, imBalance); + } + setVolumeBalancePanel(vh, bh); + /*-- Title Bar --*/ + readPanel(releasedTitleIm, releasedTitlePanel, pressedTitleIm, pressedTitlePanel, imTitleBar); + setTitleBarPanel(); + /*-- Exit --*/ + readPanel(releasedExitIm, releasedExitPanel, pressedExitIm, pressedExitPanel, imTitleBar); + setExitPanel(); + /*-- Minimize --*/ + readPanel(releasedMinimizeIm, releasedMinimizePanel, pressedMinimizeIm, pressedMinimizePanel, imTitleBar); + setMinimizePanel(); + /*-- Mode --*/ + readPanel(activeModeImage, activeModePanel, passiveModeImage, passiveModePanel, imMode); + setMonoStereoPanel(); + /*-- Numbers --*/ + ImageIcon[] numbers = new ImageIcon[numberIndex.length()]; + for (int h = 0; h < numberIndex.length(); h++) + { + numbers[h] = new ImageIcon((new Taftb(numberIndex, imNumbers, numberWidth, numberHeight, 0, "" + numberIndex.charAt(h))).getBanner()); + } + acMinuteH = new ActiveJNumberLabel(); + acMinuteH.setNumbers(numbers); + acMinuteH.setConstraints(new AbsoluteConstraints(minuteHLocation[0], minuteHLocation[1])); + acMinuteH.setAcText(" "); + acMinuteL = new ActiveJNumberLabel(); + acMinuteL.setNumbers(numbers); + acMinuteL.setConstraints(new AbsoluteConstraints(minuteLLocation[0], minuteLLocation[1])); + acMinuteL.setAcText(" "); + acSecondH = new ActiveJNumberLabel(); + acSecondH.setNumbers(numbers); + acSecondH.setConstraints(new AbsoluteConstraints(secondHLocation[0], secondHLocation[1])); + acSecondH.setAcText(" "); + acSecondL = new ActiveJNumberLabel(); + acSecondL.setNumbers(numbers); + acSecondL.setConstraints(new AbsoluteConstraints(secondLLocation[0], secondLLocation[1])); + acSecondL.setAcText(" "); + /*-- Icons --*/ + readPanel(iconsImage, iconsPanel, null, null, imIcons); + acPlayIcon = new ActiveJIcon(); + ImageIcon[] playIcons = { new ImageIcon(iconsImage[0]), new ImageIcon(iconsImage[1]), new ImageIcon(iconsImage[2]) }; + acPlayIcon.setIcons(playIcons); + acPlayIcon.setConstraints(new AbsoluteConstraints(iconsLocation[0], iconsLocation[1])); + acPlayIcon.setIcon(2); + acTimeIcon = new ActiveJIcon(); + ImageIcon[] timeIcons = { new ImageIcon(iconsImage[3]), new ImageIcon(iconsImage[4]) }; + acTimeIcon.setIcons(timeIcons); + acTimeIcon.setConstraints(new AbsoluteConstraints(iconsLocation[2], iconsLocation[3])); + /*-- DSP --*/ + setAnalyzerPanel(); + /*-- Pos Bar --*/ + readPanel(releasedPosIm, releasedPosPanel, pressedPosIm, pressedPosPanel, imPosBar); + setPosBarPanel(); + /*-- EqualizerUI/Playlist/Shuffle/Repeat --*/ + readPanel(releasedEPSRImage, releasedEPSRPanel, pressedEPSRImage, pressedEPSRPanel, imEPSRButtons); + setEPSRButtonsPanel(); + /*-- EqualizerUI --*/ + imFullEqualizer = skl.getImage("eqmain.bmp"); + imEqualizer = new BufferedImage(WinWidth, WinHeight, BufferedImage.TYPE_INT_RGB); + imEqualizer.getGraphics().drawImage(imFullEqualizer, 0, 0, null); + imSliders = new BufferedImage(208, 128, BufferedImage.TYPE_INT_RGB); + imSliders.getGraphics().drawImage(imFullEqualizer, 0, 0, 208, 128, 13, 164, 13 + 208, 164 + 128, null); + setSliderPanel(); + setOnOffAutoPanel(); + setPresetsPanel(); + setSplinePanel(); + /*-- Playlist --*/ + imPlaylist = skl.getImage("pledit.bmp"); + plEdit = (String) skl.getContent("pledit.txt"); + setPlaylistPanel(); + } + + /** + * Instantiate Buttons Panel with ActiveComponent. + */ + private void setButtonsPanel() + { + int l = 0; + acPrevious = new ActiveJButton(); + acPrevious.setIcon(new ImageIcon(releasedImage[0])); + acPrevious.setPressedIcon(new ImageIcon(pressedImage[0])); + acPrevious.setConstraints(new AbsoluteConstraints(panelLocation[l++], panelLocation[l++], releasedImage[0].getWidth(null), releasedImage[0].getHeight(null))); + acPrevious.setToolTipText(getResource("button.previous")); + acPrevious.setActionCommand(PlayerActionEvent.ACPREVIOUS); + acPlay = new ActiveJButton(); + acPlay.setIcon(new ImageIcon(releasedImage[1])); + acPlay.setPressedIcon(new ImageIcon(pressedImage[1])); + acPlay.setConstraints(new AbsoluteConstraints(panelLocation[l++], panelLocation[l++], releasedImage[1].getWidth(null), releasedImage[1].getHeight(null))); + acPlay.setToolTipText(getResource("button.play")); + acPlay.setActionCommand(PlayerActionEvent.ACPLAY); + acPause = new ActiveJButton(); + acPause.setIcon(new ImageIcon(releasedImage[2])); + acPause.setPressedIcon(new ImageIcon(pressedImage[2])); + acPause.setConstraints(new AbsoluteConstraints(panelLocation[l++], panelLocation[l++], releasedImage[2].getWidth(null), releasedImage[2].getHeight(null))); + acPause.setToolTipText(getResource("button.pause")); + acPause.setActionCommand(PlayerActionEvent.ACPAUSE); + acStop = new ActiveJButton(); + acStop.setIcon(new ImageIcon(releasedImage[3])); + acStop.setPressedIcon(new ImageIcon(pressedImage[3])); + acStop.setConstraints(new AbsoluteConstraints(panelLocation[l++], panelLocation[l++], releasedImage[3].getWidth(null), releasedImage[3].getHeight(null))); + acStop.setToolTipText(getResource("button.stop")); + acStop.setActionCommand(PlayerActionEvent.ACSTOP); + acNext = new ActiveJButton(); + acNext.setIcon(new ImageIcon(releasedImage[4])); + acNext.setPressedIcon(new ImageIcon(pressedImage[4])); + acNext.setConstraints(new AbsoluteConstraints(panelLocation[l++], panelLocation[l++], releasedImage[4].getWidth(null), releasedImage[4].getHeight(null))); + acNext.setToolTipText(getResource("button.next")); + acNext.setActionCommand(PlayerActionEvent.ACNEXT); + acEject = new ActiveJButton(); + acEject.setIcon(new ImageIcon(releasedImage[5])); + acEject.setPressedIcon(new ImageIcon(pressedImage[5])); + acEject.setConstraints(new AbsoluteConstraints(panelLocation[l++], panelLocation[l++], releasedImage[5].getWidth(null), releasedImage[5].getHeight(null))); + acEject.setToolTipText(getResource("button.eject")); + acEject.setActionCommand(PlayerActionEvent.ACEJECT); + } + + /** + * Instantiate EPSR Buttons Panel with ActiveComponent. + * imEqualizer, imPlaylist, imShuffle, imRepeat + */ + private void setEPSRButtonsPanel() + { + int l = 0; + acEqualizer = new ActiveJToggleButton(); + acEqualizer.setIcon(new ImageIcon(releasedEPSRImage[0])); + acEqualizer.setSelectedIcon(new ImageIcon(pressedEPSRImage[0])); + acEqualizer.setPressedIcon(new ImageIcon(pressedEPSRImage[0])); + acEqualizer.setConstraints(new AbsoluteConstraints(panelEPSRLocation[l++], panelEPSRLocation[l++], releasedEPSRImage[0].getWidth(null), releasedEPSRImage[0].getHeight(null))); + acEqualizer.setToolTipText(getResource("toggle.equalizer")); + acEqualizer.setActionCommand(PlayerActionEvent.ACEQUALIZER); + acEqualizer.setSelected(config.isEqualizerEnabled()); + acPlaylist = new ActiveJToggleButton(); + acPlaylist.setIcon(new ImageIcon(releasedEPSRImage[1])); + acPlaylist.setSelectedIcon(new ImageIcon(pressedEPSRImage[1])); + acPlaylist.setPressedIcon(new ImageIcon(pressedEPSRImage[1])); + acPlaylist.setConstraints(new AbsoluteConstraints(panelEPSRLocation[l++], panelEPSRLocation[l++], releasedEPSRImage[1].getWidth(null), releasedEPSRImage[1].getHeight(null))); + acPlaylist.setToolTipText(getResource("toggle.playlist")); + acPlaylist.setActionCommand(PlayerActionEvent.ACPLAYLIST); + acPlaylist.setSelected(config.isPlaylistEnabled()); + acShuffle = new ActiveJToggleButton(); + acShuffle.setIcon(new ImageIcon(releasedEPSRImage[2])); + acShuffle.setSelectedIcon(new ImageIcon(pressedEPSRImage[2])); + acShuffle.setPressedIcon(new ImageIcon(pressedEPSRImage[2])); + acShuffle.setConstraints(new AbsoluteConstraints(panelEPSRLocation[l++], panelEPSRLocation[l++], releasedEPSRImage[2].getWidth(null), releasedEPSRImage[2].getHeight(null))); + acShuffle.setToolTipText(getResource("toggle.shuffle")); + acShuffle.setActionCommand(PlayerActionEvent.ACSHUFFLE); + acShuffle.setSelected(config.isShuffleEnabled()); + acRepeat = new ActiveJToggleButton(); + acRepeat.setIcon(new ImageIcon(releasedEPSRImage[3])); + acRepeat.setSelectedIcon(new ImageIcon(pressedEPSRImage[3])); + acRepeat.setPressedIcon(new ImageIcon(pressedEPSRImage[3])); + acRepeat.setConstraints(new AbsoluteConstraints(panelEPSRLocation[l++], panelEPSRLocation[l++], releasedEPSRImage[3].getWidth(null), releasedEPSRImage[3].getHeight(null))); + acRepeat.setToolTipText(getResource("toggle.repeat")); + acRepeat.setActionCommand(PlayerActionEvent.ACREPEAT); + acRepeat.setSelected(config.isRepeatEnabled()); + } + + /** + * Instantiate Volume/Balance Panel with ActiveComponent. + * @param vheight + * @param bheight + */ + private void setVolumeBalancePanel(int vheight, int bheight) + { + // Volume. + acVolume = new ActiveJSlider(); + acVolume.setMinimum(0); + acVolume.setMaximum(VOLUMEMAX); + int volumeValue = config.getVolume(); + if (volumeValue < 0) volumeValue = (int) VOLUMEMAX / 2; + acVolume.setValue(volumeValue); + acVolume.setToolTipText(getResource("slider.volume")); + int l = 0; + for (int k = 0; k < volumeImage.length; k++) + { + //volumeImage[k] = (new Taftb(fakeIndex, imVolume, 68, 13, 2, "" + fakeIndex.charAt(k))).getBanner(); + volumeImage[k] = (new Taftb(fakeIndex, imVolume, imVolume.getWidth(null), 13, 2, "" + fakeIndex.charAt(k))).getBanner(); + } + if (volumeImage[0].getHeight(null) > releasedVolumeImage[0].getHeight(null)) + { + acVolume.setConstraints(new AbsoluteConstraints(volumeBarLocation[l++], volumeBarLocation[l++], volumeImage[0].getWidth(null), volumeImage[0].getHeight(null))); + } + else + { + acVolume.setConstraints(new AbsoluteConstraints(volumeBarLocation[l++], volumeBarLocation[l++], volumeImage[0].getWidth(null), releasedVolumeImage[0].getHeight(null))); + } + ActiveSliderUI sUI = new ActiveSliderUI(acVolume); + sUI.setThumbImage(releasedVolumeImage[0]); + sUI.setThumbPressedImage(pressedVolumeImage[0]); + sUI.setBackgroundImages(volumeImage); + if (vheight < 0) vheight = 0; + sUI.forceThumbHeight(vheight); + sUI.setThumbXOffset(0); + sUI.setThumbYOffset(1); + acVolume.setUI(sUI); + // Balance + acBalance = new ActiveJSlider(); + acBalance.setMinimum(-BALANCEMAX); + acBalance.setMaximum(BALANCEMAX); + acBalance.setValue(0); + acBalance.setToolTipText(getResource("slider.balance")); + Image cropBalance = new BufferedImage(38, 418, BufferedImage.TYPE_INT_RGB); + Graphics g = cropBalance.getGraphics(); + g.drawImage(imBalance, 0, 0, 38, 418, 9, 0, 9 + 38, 0 + 418, null); + for (int k = 0; k < balanceImage.length; k++) + { + balanceImage[k] = (new Taftb(fakeIndex, cropBalance, 38, 13, 2, "" + fakeIndex.charAt(k))).getBanner(); + } + l = 0; + if (balanceImage[0].getHeight(null) > releasedBalanceImage[0].getHeight(null)) + { + acBalance.setConstraints(new AbsoluteConstraints(balanceBarLocation[l++], balanceBarLocation[l++], balanceImage[0].getWidth(null), balanceImage[0].getHeight(null))); + } + else + { + acBalance.setConstraints(new AbsoluteConstraints(balanceBarLocation[l++], balanceBarLocation[l++], balanceImage[0].getWidth(null), releasedBalanceImage[0].getHeight(null))); + } + sUI = new ActiveSliderUI(acBalance); + sUI.setThumbImage(releasedBalanceImage[0]); + sUI.setThumbPressedImage(pressedBalanceImage[0]); + sUI.setBackgroundImages(balanceImage); + if (bheight < 0) bheight = 0; + sUI.forceThumbHeight(bheight); + sUI.setThumbXOffset(1); + sUI.setThumbYOffset(1); + acBalance.setUI(sUI); + } + + /** + * Instantiate Title Panel with ActiveComponent. + */ + protected void setTitleBarPanel() + { + int l = 0; + acTitleBar = new ActiveJBar(); + ImageBorder border = new ImageBorder(); + border.setImage(releasedTitleIm[0]); + acTitleBar.setBorder(border); + acTitleBar.setConstraints(new AbsoluteConstraints(titleBarLocation[l++], titleBarLocation[l++], releasedTitleIm[0].getWidth(null), releasedTitleIm[0].getHeight(null))); + } + + /** + * Instantiate Exit Panel with ActiveComponent. + */ + protected void setExitPanel() + { + int l = 0; + acExit = new ActiveJButton(); + acExit.setIcon(new ImageIcon(releasedExitIm[0])); + acExit.setPressedIcon(new ImageIcon(pressedExitIm[0])); + acExit.setConstraints(new AbsoluteConstraints(exitLocation[l++], exitLocation[l++], releasedExitIm[0].getWidth(null), releasedExitIm[0].getHeight(null))); + acExit.setToolTipText(getResource("button.exit")); + acExit.setActionCommand(PlayerActionEvent.ACEXIT); + } + + /** + * Instantiate Minimize Panel with ActiveComponent. + */ + protected void setMinimizePanel() + { + int l = 0; + acMinimize = new ActiveJButton(); + acMinimize.setIcon(new ImageIcon(releasedMinimizeIm[0])); + acMinimize.setPressedIcon(new ImageIcon(pressedMinimizeIm[0])); + acMinimize.setConstraints(new AbsoluteConstraints(minimizeLocation[l++], minimizeLocation[l++], releasedMinimizeIm[0].getWidth(null), releasedMinimizeIm[0].getHeight(null))); + acMinimize.setToolTipText(getResource("button.minimize")); + acMinimize.setActionCommand(PlayerActionEvent.ACMINIMIZE); + } + + /** + * Instantiate Mono/Stereo panel. + */ + private void setMonoStereoPanel() + { + acMonoIcon = new ActiveJIcon(); + ImageIcon[] mono = { new ImageIcon(passiveModeImage[1]), new ImageIcon(activeModeImage[1]) }; + acMonoIcon.setIcons(mono); + acMonoIcon.setIcon(0); + acMonoIcon.setConstraints(new AbsoluteConstraints(monoLocation[0], monoLocation[1], passiveModeImage[1].getWidth(null), passiveModeImage[1].getHeight(null))); + acStereoIcon = new ActiveJIcon(); + ImageIcon[] stereo = { new ImageIcon(passiveModeImage[0]), new ImageIcon(activeModeImage[0]) }; + acStereoIcon.setIcons(stereo); + acStereoIcon.setIcon(0); + acStereoIcon.setConstraints(new AbsoluteConstraints(stereoLocation[0], stereoLocation[1], passiveModeImage[0].getWidth(null), passiveModeImage[0].getHeight(null))); + } + + /** + * Initialize Spectrum/Time analyzer. + */ + private void setAnalyzerPanel() + { + String javaVersion = System.getProperty("java.version"); + if ((javaVersion != null) && ((javaVersion.startsWith("1.3"))) || (javaVersion.startsWith("1.4"))) + { + log.info("DSP disabled for JRE " + javaVersion); + } + else if (!dspEnabled) + { + log.info("DSP disabled"); + } + else + { + if (analyzer == null) analyzer = new SpectrumTimeAnalyzer(); + String visualMode = config.getVisualMode(); + if ((visualMode != null) && (visualMode.length() > 0)) + { + if (visualMode.equalsIgnoreCase("off")) analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_OFF); + else if (visualMode.equalsIgnoreCase("oscillo")) analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE); + else analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER); + } + else analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER); + analyzer.setSpectrumAnalyserBandCount(19); + analyzer.setVisColor(viscolor); + analyzer.setLocation(visualLocation[0], visualLocation[1]); + analyzer.setSize(visualSize[0], visualSize[1]); + analyzer.setSpectrumAnalyserDecay(0.05f); + int fps = SpectrumTimeAnalyzer.DEFAULT_FPS; + analyzer.setFps(fps); + analyzer.setPeakDelay((int) (fps * SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO)); + analyzer.setConstraints(new AbsoluteConstraints(visualLocation[0], visualLocation[1], visualSize[0], visualSize[1])); + analyzer.setToolTipText(getResource("panel.analyzer")); + } + } + + /** + * Instantiate PosBar Panel with ActiveComponent. + */ + protected void setPosBarPanel() + { + int l = 0; + Image posBackground = new BufferedImage(248, 10, BufferedImage.TYPE_INT_RGB); + posBackground.getGraphics().drawImage(imPosBar, 0, 0, 248, 10, 0, 0, 248, 10, null); + acPosBar = new ActiveJSlider(); + acPosBar.setMinimum(0); + acPosBar.setMaximum(POSBARMAX); + acPosBar.setValue(0); + acPosBar.setOrientation(JSlider.HORIZONTAL); + acPosBar.setConstraints(new AbsoluteConstraints(posBarLocation[l++], posBarLocation[l++], 248, releasedPosIm[0].getHeight(null))); + ActiveSliderUI sUI = new ActiveSliderUI(acPosBar); + Image[] back = { posBackground }; + sUI.setBackgroundImages(back); + sUI.setThumbXOffset(0); + sUI.setThumbYOffset(0); + sUI.setThumbImage(releasedPosIm[0]); + sUI.setThumbPressedImage(pressedPosIm[0]); + acPosBar.setUI(sUI); + acPosBar.setToolTipText(getResource("slider.seek")); + } + + /** + * Set sliders for equalizer. + */ + private void setSliderPanel() + { + releasedSliderImage[0] = new BufferedImage(12, 11, BufferedImage.TYPE_INT_RGB); + Graphics g = releasedSliderImage[0].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, 12, 11, 0, 164, 0 + 12, 164 + 11, null); + pressedSliderImage[0] = new BufferedImage(10, 11, BufferedImage.TYPE_INT_RGB); + g = pressedSliderImage[0].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, 11, 11, 0, 176, 0 + 11, 176 + 11, null); + for (int k = 0; k < sliderImage.length / 2; k++) + { + sliderImage[k] = new BufferedImage(13, 63, BufferedImage.TYPE_INT_RGB); + g = sliderImage[k].getGraphics(); + g.drawImage(imSliders, 0, 0, 13, 63, k * 15, 0, k * 15 + 13, 0 + 63, null); + } + for (int k = 0; k < sliderImage.length / 2; k++) + { + sliderImage[k + (sliderImage.length / 2)] = new BufferedImage(13, 63, BufferedImage.TYPE_INT_RGB); + g = sliderImage[k + (sliderImage.length / 2)].getGraphics(); + g.drawImage(imSliders, 0, 0, 13, 63, k * 15, 65, k * 15 + 13, 65 + 63, null); + } + // Setup sliders + for (int i = 0; i < acSlider.length; i++) + { + sliderLocation[i][0] = sliderBarLocation[i][0] + 1; + sliderLocation[i][1] = sliderBarLocation[i][1] + 1;// + deltaSlider * gainEqValue[i] / maxEqGain; + acSlider[i] = new ActiveJSlider(); + acSlider[i].setMinimum(0); + acSlider[i].setMaximum(100); + acSlider[i].setValue(50); + acSlider[i].setOrientation(JSlider.VERTICAL); + ActiveSliderUI sUI = new ActiveSliderUI(acSlider[i]); + sUI.setThumbImage(releasedSliderImage[0]); + sUI.setThumbPressedImage(pressedSliderImage[0]); + sUI.setBackgroundImages(sliderImage); + sUI.setThumbXOffset(1); + sUI.setThumbYOffset(-1); + acSlider[i].setUI(sUI); + acSlider[i].setConstraints(new AbsoluteConstraints(sliderLocation[i][0], sliderLocation[i][1], releasedSliderImage[0].getWidth(null), sliderImage[0].getHeight(null))); + } + acSlider[0].setEnabled(false); + } + + /** + * Set On/Off and Auto checkbox. + */ + public void setOnOffAutoPanel() + { + // On/Off + int w = 24, h = 12; + releasedOAImage[0] = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics g = releasedOAImage[0].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, w, h, 10, 119, 10 + w, 119 + h, null); + pressedOAImage[0] = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + g = pressedOAImage[0].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, w, h, 69, 119, 69 + w, 119 + h, null); + acOnOff = new ActiveJToggleButton(); + acOnOff.setIcon(new ImageIcon(releasedOAImage[0])); + acOnOff.setSelectedIcon(new ImageIcon(pressedOAImage[0])); + acOnOff.setPressedIcon(new ImageIcon(pressedOAImage[0])); + acOnOff.setSelected(config.isEqualizerOn()); + acOnOff.setConstraints(new AbsoluteConstraints(panelOALocation[0], panelOALocation[1], releasedOAImage[0].getWidth(null), releasedOAImage[0].getHeight(null))); + acOnOff.setToolTipText(getResource("equalizer.toggle.onoff")); + acOnOff.setActionCommand(PlayerActionEvent.ACEQONOFF); + // Auto + w = 34; + h = 12; + releasedOAImage[1] = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + g = releasedOAImage[1].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, w, h, 34, 119, 34 + w, 119 + h, null); + pressedOAImage[1] = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + g = pressedOAImage[1].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, w, h, 93, 119, 93 + w, 119 + h, null); + acAuto = new ActiveJToggleButton(); + acAuto.setIcon(new ImageIcon(releasedOAImage[1])); + acAuto.setPressedIcon(new ImageIcon(pressedOAImage[1])); + acAuto.setSelectedIcon(new ImageIcon(pressedOAImage[1])); + acAuto.setConstraints(new AbsoluteConstraints(panelOALocation[2], panelOALocation[3], releasedOAImage[1].getWidth(null), releasedOAImage[1].getHeight(null))); + acAuto.setToolTipText(getResource("equalizer.toggle.auto")); + acAuto.setActionCommand(PlayerActionEvent.ACEQAUTO); + } + + /** + * Set presets button. + */ + public void setPresetsPanel() + { + int w = 44, h = 12; + releasedPresetsImage[0] = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics g = releasedPresetsImage[0].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, w, h, 224, 164, 224 + w, 164 + h, null); + pressedPresetsImage[0] = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + g = pressedPresetsImage[0].getGraphics(); + g.drawImage(imFullEqualizer, 0, 0, w, h, 224, 176, 224 + w, 176 + h, null); + acPresets = new ActiveJButton(); + acPresets.setIcon(new ImageIcon(releasedPresetsImage[0])); + acPresets.setPressedIcon(new ImageIcon(pressedPresetsImage[0])); + acPresets.setConstraints(new AbsoluteConstraints(panelPresetsLocation[0], panelPresetsLocation[1], releasedPresetsImage[0].getWidth(null), releasedPresetsImage[0].getHeight(null))); + acPresets.setToolTipText(getResource("equalizer.button.presets")); + acPresets.setActionCommand(PlayerActionEvent.ACEQPRESETS); + } + + /** + * Instantiate equalizer spline panel. + */ + public void setSplinePanel() + { + int w = panelSplineLocation[2]; + int h = panelSplineLocation[3]; + splineImage = null; + splineBarImage = null; + spline = null; + if (imFullEqualizer.getHeight(null) > 294) + { + splineImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + splineBarImage = new BufferedImage(w, 1, BufferedImage.TYPE_INT_RGB); + splineImage.getGraphics().drawImage(imFullEqualizer, 0, 0, w, h, 0, 294, 0 + w, 294 + h, null); + splineBarImage.getGraphics().drawImage(imFullEqualizer, 0, 0, w, 1, 0, 294 + h + 1, 0 + w, 294 + h + 1 + 1, null); + spline = new SplinePanel(); + spline.setBackgroundImage(splineImage); + spline.setBarImage(splineBarImage); + int[] pixels = new int[1 * h]; + PixelGrabber pg = new PixelGrabber(imFullEqualizer, 115, 294, 1, h, pixels, 0, 1); + try + { + pg.grabPixels(); + } + catch (InterruptedException e) + { + log.debug(e); + } + Color[] colors = new Color[h]; + for (int i = 0; i < h; i++) + { + int c = pixels[i]; + int red = (c & 0x00ff0000) >> 16; + int green = (c & 0x0000ff00) >> 8; + int blue = c & 0x000000ff; + colors[i] = new Color(red, green, blue); + } + spline.setGradient(colors); + spline.setConstraints(new AbsoluteConstraints(panelSplineLocation[0], panelSplineLocation[1], panelSplineLocation[2], panelSplineLocation[3])); + } + } + + /** + * Instantiate playlist panel. + */ + public void setPlaylistPanel() + { + playlist = new PlaylistUIDelegate(); + Image titleCenter = new BufferedImage(100, 20, BufferedImage.TYPE_INT_RGB); + titleCenter.getGraphics().drawImage(imPlaylist, 0, 0, 100, 20, 26, 0, 126, 20, null); + playlist.setTitleCenterImage(titleCenter); + Image titleLeft = new BufferedImage(25, 20, BufferedImage.TYPE_INT_RGB); + titleLeft.getGraphics().drawImage(imPlaylist, 0, 0, 25, 20, 0, 0, 25, 20, null); + playlist.setTitleLeftImage(titleLeft); + Image titleStretch = new BufferedImage(25, 20, BufferedImage.TYPE_INT_RGB); + titleStretch.getGraphics().drawImage(imPlaylist, 0, 0, 25, 20, 127, 0, 152, 20, null); + playlist.setTitleStretchImage(titleStretch); + Image titleRight = new BufferedImage(25, 20, BufferedImage.TYPE_INT_RGB); + titleRight.getGraphics().drawImage(imPlaylist, 0, 0, 25, 20, 153, 0, 178, 20, null); + playlist.setTitleRightImage(titleRight); + Image btmLeft = new BufferedImage(125, 38, BufferedImage.TYPE_INT_RGB); + btmLeft.getGraphics().drawImage(imPlaylist, 0, 0, 125, 38, 0, 72, 125, 110, null); + playlist.setBottomLeftImage(btmLeft); + Image btmRight = new BufferedImage(150, 38, BufferedImage.TYPE_INT_RGB); + btmRight.getGraphics().drawImage(imPlaylist, 0, 0, 150, 38, 126, 72, 276, 110, null); + playlist.setBottomRightImage(btmRight); + Image bodyLeft = new BufferedImage(12, 28, BufferedImage.TYPE_INT_RGB); + bodyLeft.getGraphics().drawImage(imPlaylist, 0, 0, 12, 28, 0, 42, 12, 70, null); + playlist.setLeftImage(bodyLeft); + Image bodyRight = new BufferedImage(20, 28, BufferedImage.TYPE_INT_RGB); + bodyRight.getGraphics().drawImage(imPlaylist, 0, 0, 20, 28, 31, 42, 51, 70, null); + playlist.setRightImage(bodyRight); + // Parse color + plEdit = plEdit.toLowerCase(); + ByteArrayInputStream in = new ByteArrayInputStream(plEdit.getBytes()); + BufferedReader lin = new BufferedReader(new InputStreamReader(in)); + try + { + for (;;) + { + String line = lin.readLine(); + if (line == null) break; + if ((line.toLowerCase()).startsWith("normalbg")) playlist.setBackgroundColor(parsePlEditColor(line)); + else if ((line.toLowerCase()).startsWith("normal")) playlist.setNormalColor(parsePlEditColor(line)); + else if ((line.toLowerCase()).startsWith("current")) playlist.setCurrentColor(parsePlEditColor(line)); + else if ((line.toLowerCase()).startsWith("selectedbg")) playlist.setSelectedBackgroundColor(parsePlEditColor(line)); + } + } + catch (Exception e) + { + log.debug(e); + } + finally + { + try + { + if (in != null) in.close(); + } + catch (IOException e) + { + } + } + // Playlist slider. + acPlSlider = new ActiveJSlider(); + acPlSlider.setOrientation(JSlider.VERTICAL); + acPlSlider.setMinimum(0); + acPlSlider.setMaximum(100); + acPlSlider.setValue(100); + ActiveSliderUI sUI = new ActiveSliderUI(acPlSlider); + Image scrollBarReleased = new BufferedImage(8, 18, BufferedImage.TYPE_INT_RGB); + scrollBarReleased.getGraphics().drawImage(imPlaylist, 0, 0, 8, 18, 52, 53, 52 + 8, 53 + 18, null); + sUI.setThumbImage(scrollBarReleased); + Image scrollBarClicked = new BufferedImage(8, 18, BufferedImage.TYPE_INT_RGB); + scrollBarClicked.getGraphics().drawImage(imPlaylist, 0, 0, 8, 18, 61, 53, 61 + 8, 53 + 18, null); + sUI.setThumbPressedImage(scrollBarClicked); + Image sliderBackground = new BufferedImage(20, 58, BufferedImage.TYPE_INT_RGB); + sliderBackground.getGraphics().drawImage(bodyRight, 0, 0, null); + sliderBackground.getGraphics().drawImage(bodyRight, 0, 28, null); + sliderBackground.getGraphics().drawImage(bodyRight, 0, 30, null); + Image[] background = { sliderBackground }; + sUI.setBackgroundImages(background); + sUI.setThumbXOffset(5); + acPlSlider.setUI(sUI); + acPlSlider.setConstraints(new AbsoluteConstraints(plSliderLocation[0], plSliderLocation[1], 20, 58)); + // Up/Down scroll buttons + acPlUp = new ActiveJButton(); + Image upScrollButton = new BufferedImage(8, 4, BufferedImage.TYPE_INT_RGB); + upScrollButton.getGraphics().drawImage(imPlaylist, 0, 0, 8, 4, 261, 75, 269, 79, null); + acPlUp.setIcon(new ImageIcon(upScrollButton)); + acPlUp.setPressedIcon(new ImageIcon(upScrollButton)); + acPlUp.setConstraints(new AbsoluteConstraints(WinWidth - 15, WinHeight - 35, 8, 4)); + acPlUp.setActionCommand(PlayerActionEvent.ACPLUP); + acPlDown = new ActiveJButton(); + Image downScrollButton = new BufferedImage(8, 4, BufferedImage.TYPE_INT_RGB); + downScrollButton.getGraphics().drawImage(imPlaylist, 0, 0, 8, 4, 261, 80, 269, 84, null); + acPlDown.setIcon(new ImageIcon(downScrollButton)); + acPlDown.setPressedIcon(new ImageIcon(downScrollButton)); + acPlDown.setConstraints(new AbsoluteConstraints(WinWidth - 15, WinHeight - 30, 8, 4)); + acPlDown.setActionCommand(PlayerActionEvent.ACPLDOWN); + // Playlist AddFile/AddDir/AddURL buttons + int w = 22; + int h = 18; + Image addButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + addButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14, 80, 14 + w, 80 + h, null); + acPlAdd = new ActiveJButton(); + acPlAdd.setIcon(new ImageIcon(addButtonImage)); + acPlAdd.setPressedIcon(new ImageIcon(addButtonImage)); + acPlAdd.setActionCommand(PlayerActionEvent.ACPLADDPOPUP); + acPlAdd.setConstraints(new AbsoluteConstraints(plAddLocation[0], plAddLocation[1], w, h)); + ActiveJButton acPlAddFile = createPLButton(0, 149); + acPlAddFile.setActionCommand(PlayerActionEvent.ACPLADDFILE); + ActiveJButton acPlAddDir = createPLButton(0, 130); + acPlAddDir.setActionCommand(PlayerActionEvent.ACPLADDDIR); + ActiveJButton acPlAddURL = createPLButton(0, 111); + acPlAddURL.setActionCommand(PlayerActionEvent.ACPLADDURL); + acPlAddPopup = new ActiveJPopup(); + ActiveJButton[] addbuttons = { acPlAddURL, acPlAddDir, acPlAddFile }; + acPlAddPopup.setItems(addbuttons); + acPlAddPopup.setConstraints(new AbsoluteConstraints(plAddPopupArea[0], plAddPopupArea[1], plAddPopupArea[2], plAddPopupArea[3])); + // Playlist RemoveMisc/RemoveSelection/Crop/RemoveAll buttons + Image removeButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + removeButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 30, 80, 14 + 30 + w, 80 + h, null); + acPlRemove = new ActiveJButton(); + acPlRemove.setIcon(new ImageIcon(removeButtonImage)); + acPlRemove.setPressedIcon(new ImageIcon(removeButtonImage)); + acPlRemove.setActionCommand(PlayerActionEvent.ACPLREMOVEPOPUP); + acPlRemove.setConstraints(new AbsoluteConstraints(plRemoveLocation[0], plRemoveLocation[1], w, h)); + ActiveJButton acPlRemoveMisc = createPLButton(54, 168); + acPlRemoveMisc.setActionCommand(PlayerActionEvent.ACPLREMOVEMISC); + ActiveJButton acPlRemoveSel = createPLButton(54, 149); + acPlRemoveSel.setActionCommand(PlayerActionEvent.ACPLREMOVESEL); + ActiveJButton acPlRemoveCrop = createPLButton(54, 130); + acPlRemoveCrop.setActionCommand(PlayerActionEvent.ACPLREMOVECROP); + ActiveJButton acPlRemoveAll = createPLButton(54, 111); + acPlRemoveAll.setActionCommand(PlayerActionEvent.ACPLREMOVEALL); + acPlRemovePopup = new ActiveJPopup(); + ActiveJButton[] rembuttons = { acPlRemoveMisc, acPlRemoveAll, acPlRemoveCrop, acPlRemoveSel }; + acPlRemovePopup.setItems(rembuttons); + acPlRemovePopup.setConstraints(new AbsoluteConstraints(plRemovePopupArea[0], plRemovePopupArea[1], plRemovePopupArea[2], plRemovePopupArea[3])); + // Playlist SelAll/SelZero/SelInv buttons + Image selButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + selButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 60, 80, 14 + 60 + w, 80 + h, null); + acPlSelect = new ActiveJButton(); + acPlSelect.setIcon(new ImageIcon(selButtonImage)); + acPlSelect.setPressedIcon(new ImageIcon(selButtonImage)); + acPlSelect.setActionCommand(PlayerActionEvent.ACPLSELPOPUP); + acPlSelect.setConstraints(new AbsoluteConstraints(plSelectLocation[0], plSelectLocation[1], w, h)); + ActiveJButton acPlSelectAll = createPLButton(104, 149); + acPlSelectAll.setActionCommand(PlayerActionEvent.ACPLSELALL); + ActiveJButton acPlSelectZero = createPLButton(104, 130); + acPlSelectZero.setActionCommand(PlayerActionEvent.ACPLSELZERO); + ActiveJButton acPlSelectInv = createPLButton(104, 111); + acPlSelectInv.setActionCommand(PlayerActionEvent.ACPLSELINV); + acPlSelectPopup = new ActiveJPopup(); + ActiveJButton[] selbuttons = { acPlSelectInv, acPlSelectZero, acPlSelectAll }; + acPlSelectPopup.setItems(selbuttons); + acPlSelectPopup.setConstraints(new AbsoluteConstraints(plSelectPopupArea[0], plSelectPopupArea[1], plSelectPopupArea[2], plSelectPopupArea[3])); + // Playlist MiscOpts/MiscFile/MiscSort buttons + Image miscButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + miscButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 89, 80, 14 + 89 + w, 80 + h, null); + acPlMisc = new ActiveJButton(); + acPlMisc.setIcon(new ImageIcon(miscButtonImage)); + acPlMisc.setPressedIcon(new ImageIcon(miscButtonImage)); + acPlMisc.setActionCommand(PlayerActionEvent.ACPLMISCPOPUP); + acPlMisc.setConstraints(new AbsoluteConstraints(plMiscLocation[0], plMiscLocation[1], w, h)); + ActiveJButton acPlMiscOpts = createPLButton(154, 149); + acPlMiscOpts.setActionCommand(PlayerActionEvent.ACPLMISCOPTS); + ActiveJButton acPlMiscFile = createPLButton(154, 130); + acPlMiscFile.setActionCommand(PlayerActionEvent.ACPLMISCFILE); + ActiveJButton acPlMiscSort = createPLButton(154, 111); + acPlMiscSort.setActionCommand(PlayerActionEvent.ACPLMISCSORT); + acPlMiscPopup = new ActiveJPopup(); + ActiveJButton[] miscbuttons = { acPlMiscSort, acPlMiscFile, acPlMiscOpts }; + acPlMiscPopup.setItems(miscbuttons); + acPlMiscPopup.setConstraints(new AbsoluteConstraints(plMiscPopupArea[0], plMiscPopupArea[1], plMiscPopupArea[2], plMiscPopupArea[3])); + // Playlist ListLoad/ListSave/ListNew buttons + Image listButtonImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + listButtonImage.getGraphics().drawImage(imPlaylist, 0, 0, w, h, 14 + 215, 80, 14 + 215 + w, 80 + h, null); + acPlList = new ActiveJButton(); + acPlList.setIcon(new ImageIcon(listButtonImage)); + acPlList.setPressedIcon(new ImageIcon(listButtonImage)); + acPlList.setActionCommand(PlayerActionEvent.ACPLLISTPOPUP); + acPlList.setConstraints(new AbsoluteConstraints(plListLocation[0], plListLocation[1], w, h)); + ActiveJButton acPlListLoad = createPLButton(204, 149); + acPlListLoad.setActionCommand(PlayerActionEvent.ACPLLISTLOAD); + ActiveJButton acPlListSave = createPLButton(204, 130); + acPlListSave.setActionCommand(PlayerActionEvent.ACPLLISTSAVE); + ActiveJButton acPlListNew = createPLButton(204, 111); + acPlListNew.setActionCommand(PlayerActionEvent.ACPLLISTNEW); + acPlListPopup = new ActiveJPopup(); + ActiveJButton[] listbuttons = { acPlListNew, acPlListSave, acPlListLoad }; + acPlListPopup.setItems(listbuttons); + acPlListPopup.setConstraints(new AbsoluteConstraints(plListPopupArea[0], plListPopupArea[1], plListPopupArea[2], plListPopupArea[3])); + } + + /** + * Create Playlist buttons. + * @param sx + * @param sy + * @return + */ + private ActiveJButton createPLButton(int sx, int sy) + { + Image normal = new BufferedImage(22, 18, BufferedImage.TYPE_INT_RGB); + Image clicked = new BufferedImage(22, 18, BufferedImage.TYPE_INT_RGB); + Graphics g = normal.getGraphics(); + g.drawImage(imPlaylist, 0, 0, 22, 18, sx, sy, sx + 22, sy + 18, null); + sx += 23; + g = clicked.getGraphics(); + g.drawImage(imPlaylist, 0, 0, 22, 18, sx, sy, sx + 22, sy + 18, null); + ActiveJButton comp = new ActiveJButton(); + comp.setIcon(new ImageIcon(normal)); + comp.setPressedIcon(new ImageIcon(clicked)); + comp.setRolloverIcon(new ImageIcon(clicked)); + comp.setRolloverEnabled(true); + return comp; + } + + /** + * Parse playlist colors. + * @param line + * @return + * @throws Exception + */ + private Color parsePlEditColor(String line) throws Exception + { + int pos = line.indexOf("#"); + if (pos == -1) + { + pos = line.indexOf("="); + if (pos == -1) throw new Exception("Can not parse color!"); + } + line = line.substring(pos + 1); + int r = Integer.parseInt(line.substring(0, 2), 16); + int g = Integer.parseInt(line.substring(2, 4), 16); + int b = Integer.parseInt(line.substring(4), 16); + return new Color(r, g, b); + } + + /** + * Crop Panel Features from image file. + * @param releasedImage + * @param releasedPanel + * @param pressedImage + * @param pressedPanel + * @param imPanel + */ + public void readPanel(Image[] releasedImage, int[] releasedPanel, Image[] pressedImage, int[] pressedPanel, Image imPanel) + { + int xul, yul, xld, yld; + int j = 0; + if (releasedImage != null) + { + for (int i = 0; i < releasedImage.length; i++) + { + releasedImage[i] = new BufferedImage(releasedPanel[j + 2], releasedPanel[j + 3], BufferedImage.TYPE_INT_RGB); + xul = releasedPanel[j]; + yul = releasedPanel[j + 1]; + xld = releasedPanel[j] + releasedPanel[j + 2]; + yld = releasedPanel[j + 1] + releasedPanel[j + 3]; + (releasedImage[i].getGraphics()).drawImage(imPanel, 0, 0, releasedPanel[j + 2], releasedPanel[j + 3], xul, yul, xld, yld, null); + j = j + 4; + } + } + j = 0; + if (pressedImage != null) + { + for (int i = 0; i < pressedImage.length; i++) + { + pressedImage[i] = new BufferedImage(pressedPanel[j + 2], pressedPanel[j + 3], BufferedImage.TYPE_INT_RGB); + xul = pressedPanel[j]; + yul = pressedPanel[j + 1]; + xld = pressedPanel[j] + pressedPanel[j + 2]; + yld = pressedPanel[j + 1] + pressedPanel[j + 3]; + (pressedImage[i].getGraphics()).drawImage(imPanel, 0, 0, pressedPanel[j + 2], pressedPanel[j + 3], xul, yul, xld, yld, null); + j = j + 4; + } + } + } + + public ActiveJButton getAcEject() + { + return acEject; + } + + public ActiveJButton getAcNext() + { + return acNext; + } + + public ActiveJButton getAcPause() + { + return acPause; + } + + public ActiveJButton getAcPlay() + { + return acPlay; + } + + public ActiveJButton getAcPrevious() + { + return acPrevious; + } + + public ActiveJButton getAcStop() + { + return acStop; + } + + public ActiveJButton getAcExit() + { + return acExit; + } + + public ActiveJButton getAcMinimize() + { + return acMinimize; + } + + public ActiveJBar getAcTitleBar() + { + return acTitleBar; + } + + public ActiveJLabel getAcTitleLabel() + { + return acTitleLabel; + } + + public ActiveJLabel getAcSampleRateLabel() + { + return acSampleRateLabel; + } + + public ActiveJLabel getAcBitRateLabel() + { + return acBitRateLabel; + } + + public String getSkinVersion() + { + return skinVersion; + } + + public void setSkinVersion(String skinVersion) + { + this.skinVersion = skinVersion; + } + + public ActiveJToggleButton getAcEqualizer() + { + return acEqualizer; + } + + public ActiveJToggleButton getAcPlaylist() + { + return acPlaylist; + } + + public ActiveJToggleButton getAcRepeat() + { + return acRepeat; + } + + public ActiveJToggleButton getAcShuffle() + { + return acShuffle; + } + + public ActiveJSlider getAcVolume() + { + return acVolume; + } + + public ActiveJSlider getAcBalance() + { + return acBalance; + } + + public ActiveJIcon getAcMonoIcon() + { + return acMonoIcon; + } + + public ActiveJIcon getAcStereoIcon() + { + return acStereoIcon; + } + + public ActiveJSlider getAcPosBar() + { + return acPosBar; + } + + public ActiveJIcon getAcPlayIcon() + { + return acPlayIcon; + } + + public ActiveJIcon getAcTimeIcon() + { + return acTimeIcon; + } + + public ActiveJNumberLabel getAcMinuteH() + { + return acMinuteH; + } + + public ActiveJNumberLabel getAcMinuteL() + { + return acMinuteL; + } + + public ActiveJNumberLabel getAcSecondH() + { + return acSecondH; + } + + public ActiveJNumberLabel getAcSecondL() + { + return acSecondL; + } + + public SpectrumTimeAnalyzer getAcAnalyzer() + { + return analyzer; + } + + public ActiveJButton getAcEqPresets() + { + return acPresets; + } + + public ActiveJToggleButton getAcEqOnOff() + { + return acOnOff; + } + + public ActiveJToggleButton getAcEqAuto() + { + return acAuto; + } + + public ActiveJSlider[] getAcEqSliders() + { + return acSlider; + } + + public ActiveJSlider getAcPlSlider() + { + return acPlSlider; + } + + public ActiveJButton getAcPlUp() + { + return acPlUp; + } + + public ActiveJButton getAcPlDown() + { + return acPlDown; + } + + public ActiveJButton getAcPlAdd() + { + return acPlAdd; + } + + public ActiveJPopup getAcPlAddPopup() + { + return acPlAddPopup; + } + + public ActiveJButton getAcPlRemove() + { + return acPlRemove; + } + + public ActiveJPopup getAcPlRemovePopup() + { + return acPlRemovePopup; + } + + public ActiveJButton getAcPlSelect() + { + return acPlSelect; + } + + public ActiveJPopup getAcPlSelectPopup() + { + return acPlSelectPopup; + } + + public ActiveJButton getAcPlMisc() + { + return acPlMisc; + } + + public ActiveJPopup getAcPlMiscPopup() + { + return acPlMiscPopup; + } + + public ActiveJButton getAcPlList() + { + return acPlList; + } + + public ActiveJPopup getAcPlListPopup() + { + return acPlListPopup; + } + + public SplinePanel getSpline() + { + return spline; + } + + public PlaylistUIDelegate getPlaylistPanel() + { + return playlist; + } + + /** + * Return readme content from skin. + * @return + */ + public String getReadme() + { + return readme; + } + + public int getMainWidth() + { + return WinWidth; + } + + public int getMainHeight() + { + return WinHeight; + } + + public Image getMainImage() + { + return imMain; + } + + public Image getEqualizerImage() + { + return imEqualizer; + } + + /** + * Return visual colors from skin. + * @return + */ + public String getVisColors() + { + return viscolor; + } + + public Config getConfig() + { + return config; + } + + public void setConfig(Config config) + { + this.config = config; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/SkinLoader.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/SkinLoader.java new file mode 100644 index 0000000..b8f0ad6 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/SkinLoader.java @@ -0,0 +1,124 @@ +/* + * SkinLoader. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Image; +import java.io.FileInputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.net.URL; +import java.util.Hashtable; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import javazoom.jlgui.player.amp.util.BMPLoader; +import javazoom.jlgui.player.amp.util.Config; + +/** + * This class implements a Skin Loader. + * WinAmp 2.x javazoom.jlgui.player.amp.skins compliant. + */ +public class SkinLoader +{ + private Hashtable _images = null; + private ZipInputStream _zis = null; + + /** + * Contructs a SkinLoader from a skin file. + */ + public SkinLoader(String filename) + { + _images = new Hashtable(); + try + { + if (Config.startWithProtocol(filename)) _zis = new ZipInputStream((new URL(filename)).openStream()); + else _zis = new ZipInputStream(new FileInputStream(filename)); + } + catch (Exception e) + { + // Try to load included default skin. + ClassLoader cl = this.getClass().getClassLoader(); + InputStream sis = cl.getResourceAsStream("javazoom/jlgui/player/amp/metrix.wsz"); + if (sis != null) _zis = new ZipInputStream(sis); + } + } + + /** + * Contructs a SkinLoader from any input stream. + */ + public SkinLoader(InputStream inputstream) + { + _images = new Hashtable(); + _zis = new ZipInputStream(inputstream); + } + + /** + * Loads data (images + info) from skin. + */ + public void loadImages() throws Exception + { + ZipEntry entry = _zis.getNextEntry(); + String name; + BMPLoader bmp = new BMPLoader(); + int pos; + while (entry != null) + { + name = entry.getName().toLowerCase(); + pos = name.lastIndexOf("/"); + if (pos != -1) name = name.substring(pos + 1); + if (name.endsWith("bmp")) + { + _images.put(name, bmp.getBMPImage(_zis)); + } + else if (name.endsWith("txt")) + { + InputStreamReader reader = new InputStreamReader(_zis, "US-ASCII"); + StringWriter writer = new StringWriter(); + char buffer[] = new char[256]; + int charsRead; + while ((charsRead = reader.read(buffer)) != -1) + writer.write(buffer, 0, charsRead); + _images.put(name, writer.toString()); + } + entry = _zis.getNextEntry(); + } + _zis.close(); + } + + /** + * Return Image from name. + */ + public Image getImage(String name) + { + return (Image) _images.get(name); + } + + // Added by John Yang - 02/05/2001 + /** + * Return skin content (Image or String) from name. + */ + public Object getContent(String name) + { + return _images.get(name); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Taftb.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Taftb.java new file mode 100644 index 0000000..f5de88f --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Taftb.java @@ -0,0 +1,153 @@ +/* + * Taftb. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import java.awt.Image; +import java.awt.image.CropImageFilter; +import java.awt.image.FilteredImageSource; +import java.awt.image.MemoryImageSource; +import java.awt.image.PixelGrabber; +import javax.swing.JComponent; + +/** + * Taftb is used to build gif image from graphical fonts. + */ +public class Taftb extends JComponent +{ + public Image theFonts; + private int imageW; + private int fontWidth; + private int fontHeight; + private int Yspacing; + protected Image theBanner; + protected int pixels[]; + private PixelGrabber pg; + private String theText; + + /** + * Text banner building according to the alphabet index, font size and Y spacing. + */ + public Taftb(String alphaIndex, Image fontFile, int fontW, int fontH, int Yspc, String theTxt/*, Color BgValue*/) + { + fontWidth = fontW; + fontHeight = fontH; + Yspacing = Yspc; + theText = theTxt; + theFonts = fontFile; + imageW = theFonts.getWidth(this); + /*-- We create the TextBanner by grabbing font letters in the image fonts --*/ + pixels = new int[theText.length() * fontW * fontH]; + int SpacePosition = 0; + int offsetSp = 0; + /*-- We search the space position in the Alphabet index --*/ + while ((offsetSp < alphaIndex.length()) && (alphaIndex.charAt(offsetSp) != ' ')) + { + offsetSp++; + } + if (offsetSp < alphaIndex.length()) SpacePosition = offsetSp; + for (int offsetT = 0; offsetT < theText.length(); offsetT++) + { + int xPos = 0; + int yPos = 0; + int reste = 0; + int entie = 0; + int offsetA = 0; + int FontPerLine = (int) Math.rint((imageW / fontW)); + /*-- We search the letter's position in the Alphabet index --*/ + while ((offsetA < alphaIndex.length()) && (theText.charAt(offsetT) != alphaIndex.charAt(offsetA))) + { + offsetA++; + } + /*-- We deduce its image's position (Int forced) --*/ + if (offsetA < alphaIndex.length()) + { + reste = offsetA % FontPerLine; + entie = (offsetA - reste); + xPos = reste * fontW; + yPos = ((entie / FontPerLine) * fontH) + ((entie / FontPerLine) * Yspacing); + } + else + /*-- If the letter is not indexed the space (if available) is selected --*/ + { + reste = SpacePosition % FontPerLine; + entie = (SpacePosition - reste); + xPos = reste * fontW; + yPos = ((entie / FontPerLine) * fontH) + ((entie / FontPerLine) * Yspacing); + } + /*-- We grab the letter in the font image and put it in a pixel array --*/ + pg = new PixelGrabber(theFonts, xPos, yPos, fontW, fontH, pixels, offsetT * fontW, theText.length() * fontW); + try + { + pg.grabPixels(); + } + catch (InterruptedException e) + { + } + } + /*-- We create the final Image Banner throught an Image --*/ + theBanner = createImage(new MemoryImageSource(theText.length() * fontW, fontH, pixels, 0, theText.length() * fontW)); + } + + /** + * Returns final banner as an image. + */ + public Image getBanner() + { + return theBanner; + } + + /** + * Returns final banner as cropped image. + */ + public Image getBanner(int x, int y, int sx, int sy) + { + Image cropBanner = null; + CropImageFilter cif = new CropImageFilter(x, y, sx, sy); + cropBanner = createImage(new FilteredImageSource(theBanner.getSource(), cif)); + return cropBanner; + } + + /** + * Returns final banner as a pixels array. + */ + public int[] getPixels() + { + return pixels; + } + + /** + * Returns banner's length. + */ + public int getPixelsW() + { + return theText.length() * fontWidth; + } + + /** + * Returns banner's height. + */ + public int getPixelsH() + { + return fontHeight; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/UrlDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/UrlDialog.java new file mode 100644 index 0000000..e15005e --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/UrlDialog.java @@ -0,0 +1,148 @@ +/* + * UrlDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.skin; + +import javax.swing.JDialog; +import javax.swing.JFrame; + +/** + * UrlDialog class implements a DialogBox to get an URL. + */ +public class UrlDialog extends JDialog +{ + private String _url = null; + + /** + * Creates new form ud + */ + public UrlDialog(JFrame parent, String title, int x, int y, String url) + { + super(parent, title, true); + _url = url; + initComponents(); + if (_url != null) textField.setText(_url); + this.setLocation(x, y); + } + + /** + * Returns URL. + */ + public String getURL() + { + return _url; + } + + /** + * Returns filename. + */ + public String getFile() + { + return _url; + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + private void initComponents() + {//GEN-BEGIN:initComponents + java.awt.GridBagConstraints gridBagConstraints; + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + textField = new javax.swing.JTextField(); + jPanel1 = new javax.swing.JPanel(); + openButton = new javax.swing.JButton(); + cancelButton = new javax.swing.JButton(); + getContentPane().setLayout(new java.awt.GridBagLayout()); + jLabel1.setText("Enter an Internet location to open here :"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + getContentPane().add(jLabel1, gridBagConstraints); + jLabel2.setText("\"For example : http://www.server.com:8000\""); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + getContentPane().add(jLabel2, gridBagConstraints); + textField.setColumns(10); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + getContentPane().add(textField, gridBagConstraints); + openButton.setMnemonic('O'); + openButton.setText("Open"); + openButton.setToolTipText("Open"); + openButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + openHandler(evt); + } + }); + jPanel1.add(openButton); + cancelButton.setMnemonic('C'); + cancelButton.setText("Cancel"); + cancelButton.setToolTipText("Cancel"); + cancelButton.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + cancelHandler(evt); + } + }); + jPanel1.add(cancelButton); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + getContentPane().add(jPanel1, gridBagConstraints); + pack(); + }//GEN-END:initComponents + + private void cancelHandler(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_cancelHandler + _url = null; + this.dispose(); + }//GEN-LAST:event_cancelHandler + + private void openHandler(java.awt.event.ActionEvent evt) + {//GEN-FIRST:event_openHandler + _url = textField.getText(); + this.dispose(); + }//GEN-LAST:event_openHandler + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton cancelButton; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JPanel jPanel1; + private javax.swing.JButton openButton; + private javax.swing.JTextField textField; + // End of variables declaration//GEN-END:variables +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/skin.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/skin.properties new file mode 100644 index 0000000..72b61c7 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/skin.properties @@ -0,0 +1,65 @@ +button.previous=Previous +button.play=Play +button.pause=Pause +button.stop=Stop +button.next=Next +button.eject=Open file(s) +button.eject.filedialog.filtername=File, playlist or skin +button.eject.urldialog.title=Open location +title.loading=PLEASE WAIT ... LOADING ... +title.buffering=PLEASE WAIT ... BUFFERING ... +title.invalidfile=INVALID FILE + +button.exit=Close +button.minimize=Minimize + +toggle.equalizer=Toggle Graphical Equalizer +toggle.playlist=Toggle Playlist Editor +toggle.shuffle=Toggle Shuffle +toggle.repeat=Toggle Repeat + +slider.volume=Volume Bar +slider.volume.text=VOLUME: {0}% +slider.balance=Panning Bar +slider.balance.text.right=BALANCE: {0}% RIGHT +slider.balance.text.left=BALANCE: {0}% LEFT +slider.balance.text.center=BALANCE: CENTER +slider.seek=Seeking Bar + +panel.analyzer=Spectrum/Time analyzer + +popup.title=Setup +popup.play=Play +popup.play.file=File... +popup.play.location=Location... +popup.playlist=Playlist Editor +popup.equalizer=Equalizer +popup.preferences=Preferences +popup.skins=Skins +popup.skins.browser=Skin Browser +popup.skins.load=Load Skin +popup.playback=Playback +popup.playback.jump=Jump to file +popup.playback.stop=Stop +popup.exit=Exit + +popup.eject.openfile=Open file... +popup.eject.openlocation=Open location... + +loadskin.dialog.filtername=Skin files + +skin.extension=wsz +playlist.extension.m3u=m3u +playlist.extension.pls=pls + +equalizer.toggle.onoff=On/Off +equalizer.toggle.auto=Auto +equalizer.button.presets=Presets + +playlist.popup.info=File Info +playlist.popup.play=Play Item +playlist.popup.remove=Remove Item(s) +playlist.popup.add.file=Music files +playlist.popup.add.url=Open location +playlist.popup.add.dir=Directories +playlist.popup.list.load=PLS or M3U Playlist diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/APEInfo.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/APEInfo.java new file mode 100644 index 0000000..9dcff87 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/APEInfo.java @@ -0,0 +1,340 @@ +/* + * 21.04.2004 Original verion. davagin@udm.ru. + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag; + +import org.tritonus.share.sampled.TAudioFormat; +import org.tritonus.share.sampled.file.TAudioFileFormat; +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; +import java.util.Vector; + +/** + * This class gives information (audio format and comments) about APE file or URL. + */ +public class APEInfo implements TagInfo +{ + protected int channels = -1; + protected int bitspersample = -1; + protected int samplerate = -1; + protected int bitrate = -1; + protected int version = -1; + protected String compressionlevel = null; + protected int totalframes = -1; + protected int blocksperframe = -1; + protected int finalframeblocks = -1; + protected int totalblocks = -1; + protected int peaklevel = -1; + protected long duration = -1; + protected String author = null; + protected String title = null; + protected String copyright = null; + protected Date date = null; + protected String comment = null; + protected String track = null; + protected String genre = null; + protected String album = null; + protected long size = 0; + protected String location = null; + + /** + * Constructor. + */ + public APEInfo() + { + super(); + } + + /** + * Load and parse APE info from File. + * + * @param input + * @throws IOException + */ + public void load(File input) throws IOException, UnsupportedAudioFileException + { + size = input.length(); + location = input.getPath(); + loadInfo(input); + } + + /** + * Load and parse APE info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(URL input) throws IOException, UnsupportedAudioFileException + { + location = input.toString(); + loadInfo(input); + } + + /** + * Load and parse APE info from InputStream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(InputStream input) throws IOException, UnsupportedAudioFileException + { + loadInfo(input); + } + + /** + * Load APE info from input stream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException + { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + } + + /** + * Load APE info from file. + * + * @param file + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException + { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(file); + loadInfo(aff); + } + + /** + * Load APE info from AudioFileFormat. + * + * @param aff + */ + protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException + { + String type = aff.getType().toString(); + if (!type.equalsIgnoreCase("Monkey's Audio (ape)") && !type.equalsIgnoreCase("Monkey's Audio (mac)")) throw new UnsupportedAudioFileException("Not APE audio format"); + if (aff instanceof TAudioFileFormat) + { + Map props = ((TAudioFileFormat) aff).properties(); + if (props.containsKey("duration")) duration = ((Long) props.get("duration")).longValue(); + if (props.containsKey("author")) author = (String) props.get("author"); + if (props.containsKey("title")) title = (String) props.get("title"); + if (props.containsKey("copyright")) copyright = (String) props.get("copyright"); + if (props.containsKey("date")) date = (Date) props.get("date"); + if (props.containsKey("comment")) comment = (String) props.get("comment"); + if (props.containsKey("album")) album = (String) props.get("album"); + if (props.containsKey("track")) track = (String) props.get("track"); + if (props.containsKey("genre")) genre = (String) props.get("genre"); + AudioFormat af = aff.getFormat(); + channels = af.getChannels(); + samplerate = (int) af.getSampleRate(); + bitspersample = af.getSampleSizeInBits(); + if (af instanceof TAudioFormat) + { + props = ((TAudioFormat) af).properties(); + if (props.containsKey("bitrate")) bitrate = ((Integer) props.get("bitrate")).intValue(); + if (props.containsKey("ape.version")) version = ((Integer) props.get("ape.version")).intValue(); + if (props.containsKey("ape.compressionlevel")) + { + int cl = ((Integer) props.get("ape.compressionlevel")).intValue(); + switch (cl) + { + case 1000: + compressionlevel = "Fast"; + break; + case 2000: + compressionlevel = "Normal"; + break; + case 3000: + compressionlevel = "High"; + break; + case 4000: + compressionlevel = "Extra High"; + break; + case 5000: + compressionlevel = "Insane"; + break; + } + } + if (props.containsKey("ape.totalframes")) totalframes = ((Integer) props.get("ape.totalframes")).intValue(); + if (props.containsKey("ape.blocksperframe")) totalframes = ((Integer) props.get("ape.blocksperframe")).intValue(); + if (props.containsKey("ape.finalframeblocks")) finalframeblocks = ((Integer) props.get("ape.finalframeblocks")).intValue(); + if (props.containsKey("ape.totalblocks")) totalblocks = ((Integer) props.get("ape.totalblocks")).intValue(); + if (props.containsKey("ape.peaklevel")) peaklevel = ((Integer) props.get("ape.peaklevel")).intValue(); + } + } + } + + /** + * Load APE info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException + { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + } + + public long getSize() + { + return size; + } + + public String getLocation() + { + return location; + } + + public int getVersion() + { + return version; + } + + public String getCompressionlevel() + { + return compressionlevel; + } + + public int getTotalframes() + { + return totalframes; + } + + public int getBlocksperframe() + { + return blocksperframe; + } + + public int getFinalframeblocks() + { + return finalframeblocks; + } + + public int getChannels() + { + return channels; + } + + public int getSamplingRate() + { + return samplerate; + } + + public int getBitsPerSample() + { + return bitspersample; + } + + public int getTotalblocks() + { + return totalblocks; + } + + public long getPlayTime() + { + return duration / 1000; + } + + public int getBitRate() + { + return bitrate * 1000; + } + + public int getPeaklevel() + { + return peaklevel; + } + + public int getTrack() + { + int t; + try + { + t = Integer.parseInt(track); + } + catch (Exception e) + { + t = -1; + } + return t; + } + + public String getYear() + { + if (date != null) + { + Calendar c = Calendar.getInstance(); + c.setTime(date); + return String.valueOf(c.get(Calendar.YEAR)); + } + return null; + } + + public String getGenre() + { + return genre; + } + + public String getTitle() + { + return title; + } + + public String getArtist() + { + return author; + } + + public String getAlbum() + { + return album; + } + + public Vector getComment() + { + if (comment != null) + { + Vector c = new Vector(); + c.add(comment); + return c; + } + return null; + } + + public String getCopyright() + { + return copyright; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/FlacInfo.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/FlacInfo.java new file mode 100644 index 0000000..cf1767f --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/FlacInfo.java @@ -0,0 +1,189 @@ +/* + * 21.04.2004 Original verion. davagin@udm.ru. + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Vector; +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.UnsupportedAudioFileException; + +/** + * This class gives information (audio format and comments) about Flac file or URL. + */ +public class FlacInfo implements TagInfo { + protected int channels = -1; + protected int bitspersample = -1; + protected int samplerate = -1; + protected long size = 0; + protected String location = null; + + /** + * Constructor. + */ + public FlacInfo() { + super(); + } + + /** + * Load and parse Flac info from File. + * + * @param input + * @throws IOException + */ + public void load(File input) throws IOException, UnsupportedAudioFileException { + size = input.length(); + location = input.getPath(); + loadInfo(input); + } + + /** + * Load and parse Flac info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(URL input) throws IOException, UnsupportedAudioFileException { + location = input.toString(); + loadInfo(input); + } + + /** + * Load and parse Flac info from InputStream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(InputStream input) throws IOException, UnsupportedAudioFileException { + loadInfo(input); + } + + /** + * Load Flac info from input stream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + } + + /** + * Load Flac info from file. + * + * @param file + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(file); + loadInfo(aff); + } + + /** + * Load Flac info from AudioFileFormat. + * + * @param aff + */ + protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException { + String type = aff.getType().toString(); + if (!type.equalsIgnoreCase("flac")) throw new UnsupportedAudioFileException("Not Flac audio format"); + AudioFormat af = aff.getFormat(); + channels = af.getChannels(); + samplerate = (int) af.getSampleRate(); + bitspersample = af.getSampleSizeInBits(); + } + + /** + * Load Flac info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + } + + public long getSize() { + return size; + } + + public String getLocation() { + return location; + } + + public int getChannels() { + return channels; + } + + public int getSamplingRate() { + return samplerate; + } + + public int getBitsPerSample() { + return bitspersample; + } + + public Vector getComment() { + return null; + } + + public String getYear() { + return null; + } + + public String getGenre() { + return null; + } + + public int getTrack() { + return -1; + } + + public String getAlbum() { + return null; + } + + public String getArtist() { + return null; + } + + public String getTitle() { + return null; + } + + public long getPlayTime() { + return -1; + } + + public int getBitRate() { + return -1; + } + +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/MpegInfo.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/MpegInfo.java new file mode 100644 index 0000000..7a1fbc7 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/MpegInfo.java @@ -0,0 +1,315 @@ +/* + * MpegInfo. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag; + +import org.tritonus.share.sampled.file.TAudioFileFormat; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Iterator; +import java.util.Map; +import java.util.Vector; + +/** + * This class gives information (audio format and comments) about MPEG file or URL. + */ +public class MpegInfo implements TagInfo { + protected int channels = -1; + protected String channelsMode = null; + protected String version = null; + protected int rate = 0; + protected String layer = null; + protected String emphasis = null; + protected int nominalbitrate = 0; + protected long total = 0; + protected String vendor = null; + protected String location = null; + protected long size = 0; + protected boolean copyright = false; + protected boolean crc = false; + protected boolean original = false; + protected boolean priv = false; + protected boolean vbr = false; + protected int track = -1; + protected String year = null; + protected String genre = null; + protected String title = null; + protected String artist = null; + protected String album = null; + protected Vector comments = null; + + /** + * Constructor. + */ + public MpegInfo() { + super(); + } + + /** + * Load and parse MPEG info from File. + * + * @param input + * @throws IOException + */ + public void load(File input) throws IOException, UnsupportedAudioFileException { + size = input.length(); + location = input.getPath(); + loadInfo(input); + } + + /** + * Load and parse MPEG info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(URL input) throws IOException, UnsupportedAudioFileException { + location = input.toString(); + loadInfo(input); + } + + /** + * Load and parse MPEG info from InputStream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(InputStream input) throws IOException, UnsupportedAudioFileException { + loadInfo(input); + } + + /** + * Load info from input stream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + } + + /** + * Load MP3 info from file. + * + * @param file + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(file); + loadInfo(aff); + } + + /** + * Load info from AudioFileFormat. + * + * @param aff + */ + protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException { + String type = aff.getType().toString(); + if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format"); + if (aff instanceof TAudioFileFormat) { + Map props = ((TAudioFileFormat) aff).properties(); + if (props.containsKey("mp3.channels")) channels = ((Integer) props.get("mp3.channels")).intValue(); + if (props.containsKey("mp3.frequency.hz")) rate = ((Integer) props.get("mp3.frequency.hz")).intValue(); + if (props.containsKey("mp3.bitrate.nominal.bps")) nominalbitrate = ((Integer) props.get("mp3.bitrate.nominal.bps")).intValue(); + if (props.containsKey("mp3.version.layer")) layer = "Layer " + props.get("mp3.version.layer"); + if (props.containsKey("mp3.version.mpeg")) { + version = (String) props.get("mp3.version.mpeg"); + if (version.equals("1")) version = "MPEG1"; + else if (version.equals("2")) version = "MPEG2-LSF"; + else if (version.equals("2.5")) version = "MPEG2.5-LSF"; + } + if (props.containsKey("mp3.mode")) { + int mode = ((Integer) props.get("mp3.mode")).intValue(); + if (mode == 0) channelsMode = "Stereo"; + else if (mode == 1) channelsMode = "Joint Stereo"; + else if (mode == 2) channelsMode = "Dual Channel"; + else if (mode == 3) channelsMode = "Single Channel"; + } + if (props.containsKey("mp3.crc")) crc = ((Boolean) props.get("mp3.crc")).booleanValue(); + if (props.containsKey("mp3.vbr")) vbr = ((Boolean) props.get("mp3.vbr")).booleanValue(); + if (props.containsKey("mp3.copyright")) copyright = ((Boolean) props.get("mp3.copyright")).booleanValue(); + if (props.containsKey("mp3.original")) original = ((Boolean) props.get("mp3.original")).booleanValue(); + emphasis = "none"; + if (props.containsKey("title")) title = (String) props.get("title"); + if (props.containsKey("author")) artist = (String) props.get("author"); + if (props.containsKey("album")) album = (String) props.get("album"); + if (props.containsKey("date")) year = (String) props.get("date"); + if (props.containsKey("duration")) total = (long) Math.round((((Long) props.get("duration")).longValue()) / 1000000); + if (props.containsKey("mp3.id3tag.genre")) genre = (String) props.get("mp3.id3tag.genre"); + if (props.containsKey("mp3.id3tag.track")) { + try { + track = Integer.parseInt((String) props.get("mp3.id3tag.track")); + } + catch (NumberFormatException e1) { + // Not a number + } + } + } + } + + /** + * Load MP3 info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + loadShoutastInfo(aff); + } + + /** + * Load Shoutcast info from AudioFileFormat. + * + * @param aff + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadShoutastInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException { + String type = aff.getType().toString(); + if (!type.equalsIgnoreCase("mp3")) throw new UnsupportedAudioFileException("Not MP3 audio format"); + if (aff instanceof TAudioFileFormat) { + Map props = ((TAudioFileFormat) aff).properties(); + // Try shoutcast meta data (if any). + Iterator it = props.keySet().iterator(); + comments = new Vector(); + while (it.hasNext()) { + String key = (String) it.next(); + if (key.startsWith("mp3.shoutcast.metadata.")) { + String value = (String) props.get(key); + key = key.substring(23, key.length()); + if (key.equalsIgnoreCase("icy-name")) { + title = value; + } else if (key.equalsIgnoreCase("icy-genre")) { + genre = value; + } else { + comments.add(key + "=" + value); + } + } + } + } + } + + public boolean getVBR() { + return vbr; + } + + public int getChannels() { + return channels; + } + + public String getVersion() { + return version; + } + + public String getEmphasis() { + return emphasis; + } + + public boolean getCopyright() { + return copyright; + } + + public boolean getCRC() { + return crc; + } + + public boolean getOriginal() { + return original; + } + + public String getLayer() { + return layer; + } + + public long getSize() { + return size; + } + + public String getLocation() { + return location; + } + + /*-- TagInfo Implementation --*/ + public int getSamplingRate() { + return rate; + } + + public int getBitRate() { + return nominalbitrate; + } + + public long getPlayTime() { + return total; + } + + public String getTitle() { + return title; + } + + public String getArtist() { + return artist; + } + + public String getAlbum() { + return album; + } + + public int getTrack() { + return track; + } + + public String getGenre() { + return genre; + } + + public Vector getComment() { + return comments; + } + + public String getYear() { + return year; + } + + /** + * Get channels mode. + * + * @return channels mode + */ + public String getChannelsMode() { + return channelsMode; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/OggVorbisInfo.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/OggVorbisInfo.java new file mode 100644 index 0000000..67da902 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/OggVorbisInfo.java @@ -0,0 +1,307 @@ +/* + * OggVorbisInfo. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag; + +import org.tritonus.share.sampled.file.TAudioFileFormat; +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.UnsupportedAudioFileException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Map; +import java.util.Vector; + +/** + * This class gives information (audio format and comments) about Ogg Vorbis file or URL. + */ +public class OggVorbisInfo implements TagInfo +{ + protected int serial = 0; + protected int channels = 0; + protected int version = 0; + protected int rate = 0; + protected int minbitrate = 0; + protected int maxbitrate = 0; + protected int averagebitrate = 0; + protected int nominalbitrate = 0; + protected long totalms = 0; + protected String vendor = ""; + protected String location = null; + protected long size = 0; + protected int track = -1; + protected String year = null; + protected String genre = null; + protected String title = null; + protected String artist = null; + protected String album = null; + protected Vector comments = new Vector(); + + /** + * Constructor. + */ + public OggVorbisInfo() + { + super(); + } + + /** + * Load and parse Ogg Vorbis info from File. + * + * @param input + * @throws IOException + */ + public void load(File input) throws IOException, UnsupportedAudioFileException + { + size = input.length(); + location = input.getPath(); + loadInfo(input); + } + + /** + * Load and parse Ogg Vorbis info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(URL input) throws IOException, UnsupportedAudioFileException + { + location = input.toString(); + loadInfo(input); + } + + /** + * Load and parse Ogg Vorbis info from InputStream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + public void load(InputStream input) throws IOException, UnsupportedAudioFileException + { + loadInfo(input); + } + + /** + * Load info from input stream. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(InputStream input) throws IOException, UnsupportedAudioFileException + { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + } + + /** + * Load Ogg Vorbis info from file. + * + * @param file + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(File file) throws IOException, UnsupportedAudioFileException + { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(file); + loadInfo(aff); + } + + /** + * Load Ogg Vorbis info from URL. + * + * @param input + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(URL input) throws IOException, UnsupportedAudioFileException + { + AudioFileFormat aff = AudioSystem.getAudioFileFormat(input); + loadInfo(aff); + loadExtendedInfo(aff); + } + + /** + * Load info from AudioFileFormat. + * + * @param aff + * @throws UnsupportedAudioFileException + */ + protected void loadInfo(AudioFileFormat aff) throws UnsupportedAudioFileException + { + String type = aff.getType().toString(); + if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format"); + if (aff instanceof TAudioFileFormat) + { + Map props = ((TAudioFileFormat) aff).properties(); + if (props.containsKey("ogg.channels")) channels = ((Integer) props.get("ogg.channels")).intValue(); + if (props.containsKey("ogg.frequency.hz")) rate = ((Integer) props.get("ogg.frequency.hz")).intValue(); + if (props.containsKey("ogg.bitrate.nominal.bps")) nominalbitrate = ((Integer) props.get("ogg.bitrate.nominal.bps")).intValue(); + averagebitrate = nominalbitrate; + if (props.containsKey("ogg.bitrate.max.bps")) maxbitrate = ((Integer) props.get("ogg.bitrate.max.bps")).intValue(); + if (props.containsKey("ogg.bitrate.min.bps")) minbitrate = ((Integer) props.get("ogg.bitrate.min.bps")).intValue(); + if (props.containsKey("ogg.version")) version = ((Integer) props.get("ogg.version")).intValue(); + if (props.containsKey("ogg.serial")) serial = ((Integer) props.get("ogg.serial")).intValue(); + if (props.containsKey("ogg.comment.encodedby")) vendor = (String) props.get("ogg.comment.encodedby"); + if (props.containsKey("copyright")) comments.add((String) props.get("copyright")); + if (props.containsKey("title")) title = (String) props.get("title"); + if (props.containsKey("author")) artist = (String) props.get("author"); + if (props.containsKey("album")) album = (String) props.get("album"); + if (props.containsKey("date")) year = (String) props.get("date"); + if (props.containsKey("comment")) comments.add((String) props.get("comment")); + if (props.containsKey("duration")) totalms = (long) Math.round((((Long) props.get("duration")).longValue()) / 1000000); + if (props.containsKey("ogg.comment.genre")) genre = (String) props.get("ogg.comment.genre"); + if (props.containsKey("ogg.comment.track")) + { + try + { + track = Integer.parseInt((String) props.get("ogg.comment.track")); + } + catch (NumberFormatException e1) + { + // Not a number + } + } + if (props.containsKey("ogg.comment.ext.1")) comments.add((String) props.get("ogg.comment.ext.1")); + if (props.containsKey("ogg.comment.ext.2")) comments.add((String) props.get("ogg.comment.ext.2")); + if (props.containsKey("ogg.comment.ext.3")) comments.add((String) props.get("ogg.comment.ext.3")); + } + } + + /** + * Load extended info from AudioFileFormat. + * + * @param aff + * @throws IOException + * @throws UnsupportedAudioFileException + */ + protected void loadExtendedInfo(AudioFileFormat aff) throws IOException, UnsupportedAudioFileException + { + String type = aff.getType().toString(); + if (!type.equalsIgnoreCase("ogg")) throw new UnsupportedAudioFileException("Not Ogg Vorbis audio format"); + if (aff instanceof TAudioFileFormat) + { + //Map props = ((TAudioFileFormat) aff).properties(); + // How to load icecast meta data (if any) ?? + } + } + + public int getSerial() + { + return serial; + } + + public int getChannels() + { + return channels; + } + + public int getVersion() + { + return version; + } + + public int getMinBitrate() + { + return minbitrate; + } + + public int getMaxBitrate() + { + return maxbitrate; + } + + public int getAverageBitrate() + { + return averagebitrate; + } + + public long getSize() + { + return size; + } + + public String getVendor() + { + return vendor; + } + + public String getLocation() + { + return location; + } + + /*-- TagInfo Implementation --*/ + public int getSamplingRate() + { + return rate; + } + + public int getBitRate() + { + return nominalbitrate; + } + + public long getPlayTime() + { + return totalms; + } + + public String getTitle() + { + return title; + } + + public String getArtist() + { + return artist; + } + + public String getAlbum() + { + return album; + } + + public int getTrack() + { + return track; + } + + public String getGenre() + { + return genre; + } + + public Vector getComment() + { + return comments; + } + + public String getYear() + { + return year; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfo.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfo.java new file mode 100644 index 0000000..86e05d5 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfo.java @@ -0,0 +1,120 @@ +/* + * TagInfo. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Vector; +import javax.sound.sampled.UnsupportedAudioFileException; + +/** + * This interface define needed features for song information. + * Adapted from Scott Pennell interface. + */ +public interface TagInfo +{ + public void load(InputStream input) throws IOException, UnsupportedAudioFileException; + + public void load(URL input) throws IOException, UnsupportedAudioFileException; + + public void load(File input) throws IOException, UnsupportedAudioFileException; + + /** + * Get Sampling Rate + * + * @return sampling rate + */ + public int getSamplingRate(); + + /** + * Get Nominal Bitrate + * + * @return bitrate in bps + */ + public int getBitRate(); + + /** + * Get channels. + * + * @return channels + */ + public int getChannels(); + + /** + * Get play time in seconds. + * + * @return play time in seconds + */ + public long getPlayTime(); + + /** + * Get the title of the song. + * + * @return the title of the song + */ + public String getTitle(); + + /** + * Get the artist that performed the song + * + * @return the artist that performed the song + */ + public String getArtist(); + + /** + * Get the name of the album upon which the song resides + * + * @return the album name + */ + public String getAlbum(); + + /** + * Get the track number of this track on the album + * + * @return the track number + */ + public int getTrack(); + + /** + * Get the genre string of the music + * + * @return the genre string + */ + public String getGenre(); + + /** + * Get the year the track was released + * + * @return the year the track was released + */ + public String getYear(); + + /** + * Get any comments provided about the song + * + * @return the comments + */ + public Vector getComment(); +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfoFactory.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfoFactory.java new file mode 100644 index 0000000..4cbf8ef --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfoFactory.java @@ -0,0 +1,399 @@ +/* + * TagInfoFactory. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.net.MalformedURLException; +import java.net.URL; +import javax.sound.sampled.UnsupportedAudioFileException; +import javazoom.jlgui.player.amp.tag.ui.APEDialog; +import javazoom.jlgui.player.amp.tag.ui.EmptyDialog; +import javazoom.jlgui.player.amp.tag.ui.FlacDialog; +import javazoom.jlgui.player.amp.tag.ui.MpegDialog; +import javazoom.jlgui.player.amp.tag.ui.OggVorbisDialog; +import javazoom.jlgui.player.amp.tag.ui.TagInfoDialog; +import javazoom.jlgui.player.amp.util.Config; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * This class is a factory for TagInfo and TagInfoDialog. + * It allows to any plug custom TagIngfo parser matching to TagInfo + * interface. + */ +public class TagInfoFactory +{ + private static Log log = LogFactory.getLog(TagInfoFactory.class); + private static TagInfoFactory instance = null; + private Class MpegTagInfoClass = null; + private Class VorbisTagInfoClass = null; + private Class APETagInfoClass = null; + private Class FlacTagInfoClass = null; + private Config conf = null; + + private TagInfoFactory() + { + super(); + conf = Config.getInstance(); + String classname = conf.getMpegTagInfoClassName(); + MpegTagInfoClass = getTagInfoImpl(classname); + if (MpegTagInfoClass == null) + { + log.error("Error : TagInfo implementation not found in " + classname + " hierarchy"); + MpegTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.MpegInfo"); + } + classname = conf.getOggVorbisTagInfoClassName(); + VorbisTagInfoClass = getTagInfoImpl(classname); + if (VorbisTagInfoClass == null) + { + log.error("Error : TagInfo implementation not found in " + classname + " hierarchy"); + VorbisTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.OggVorbisInfo"); + } + classname = conf.getAPETagInfoClassName(); + APETagInfoClass = getTagInfoImpl(classname); + if (APETagInfoClass == null) + { + log.error("Error : TagInfo implementation not found in " + classname + " hierarchy"); + APETagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.APEInfo"); + } + classname = conf.getFlacTagInfoClassName(); + FlacTagInfoClass = getTagInfoImpl(classname); + if (FlacTagInfoClass == null) + { + log.error("Error : TagInfo implementation not found in " + classname + " hierarchy"); + FlacTagInfoClass = getTagInfoImpl("javazoom.jlgui.player.amp.tag.FlacInfo"); + } + } + + public static synchronized TagInfoFactory getInstance() + { + if (instance == null) + { + instance = new TagInfoFactory(); + } + return instance; + } + + /** + * Return tag info from a given URL. + * + * @param location + * @return TagInfo structure for given URL + */ + public TagInfo getTagInfo(URL location) + { + TagInfo taginfo; + try + { + taginfo = getTagInfoImplInstance(MpegTagInfoClass); + taginfo.load(location); + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + catch (UnsupportedAudioFileException ex) + { + // Not Mpeg Format + taginfo = null; + } + if (taginfo == null) + { + // Check Ogg Vorbis format. + try + { + taginfo = getTagInfoImplInstance(VorbisTagInfoClass); + taginfo.load(location); + } + catch (UnsupportedAudioFileException ex) + { + // Not Ogg Vorbis Format + taginfo = null; + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + } + if (taginfo == null) + { + // Check APE format. + try + { + taginfo = getTagInfoImplInstance(APETagInfoClass); + taginfo.load(location); + } + catch (UnsupportedAudioFileException ex) + { + // Not APE Format + taginfo = null; + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + } + if (taginfo == null) + { + // Check Flac format. + try + { + taginfo = getTagInfoImplInstance(FlacTagInfoClass); + taginfo.load(location); + } + catch (UnsupportedAudioFileException ex) + { + // Not Flac Format + taginfo = null; + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + } + return taginfo; + } + + /** + * Return tag info from a given String. + * + * @param location + * @return TagInfo structure for given location + */ + public TagInfo getTagInfo(String location) + { + if (Config.startWithProtocol(location)) + { + try + { + return getTagInfo(new URL(location)); + } + catch (MalformedURLException e) + { + return null; + } + } + else + { + return getTagInfo(new File(location)); + } + } + + /** + * Get TagInfo for given file. + * + * @param location + * @return TagInfo structure for given location + */ + public TagInfo getTagInfo(File location) + { + TagInfo taginfo; + // Check Mpeg format. + try + { + taginfo = getTagInfoImplInstance(MpegTagInfoClass); + taginfo.load(location); + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + catch (UnsupportedAudioFileException ex) + { + // Not Mpeg Format + taginfo = null; + } + if (taginfo == null) + { + // Check Ogg Vorbis format. + try + { + //taginfo = new OggVorbisInfo(location); + taginfo = getTagInfoImplInstance(VorbisTagInfoClass); + taginfo.load(location); + } + catch (UnsupportedAudioFileException ex) + { + // Not Ogg Vorbis Format + taginfo = null; + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + } + if (taginfo == null) + { + // Check APE format. + try + { + taginfo = getTagInfoImplInstance(APETagInfoClass); + taginfo.load(location); + } + catch (UnsupportedAudioFileException ex) + { + // Not APE Format + taginfo = null; + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + } + if (taginfo == null) + { + // Check Flac format. + try + { + taginfo = getTagInfoImplInstance(FlacTagInfoClass); + taginfo.load(location); + } + catch (UnsupportedAudioFileException ex) + { + // Not Flac Format + taginfo = null; + } + catch (IOException ex) + { + log.debug(ex); + taginfo = null; + } + } + return taginfo; + } + + /** + * Return dialog (graphical) to display tag info. + * + * @param taginfo + * @return TagInfoDialog for given TagInfo + */ + public TagInfoDialog getTagInfoDialog(TagInfo taginfo) + { + TagInfoDialog dialog; + if (taginfo != null) + { + if (taginfo instanceof OggVorbisInfo) + { + dialog = new OggVorbisDialog(conf.getTopParent(), "OggVorbis info", (OggVorbisInfo) taginfo); + } + else if (taginfo instanceof MpegInfo) + { + dialog = new MpegDialog(conf.getTopParent(), "Mpeg info", (MpegInfo) taginfo); + } + else if (taginfo instanceof APEInfo) + { + dialog = new APEDialog(conf.getTopParent(), "Ape info", (APEInfo) taginfo); + } + else if (taginfo instanceof FlacInfo) + { + dialog = new FlacDialog(conf.getTopParent(), "Flac info", (FlacInfo) taginfo); + } + else + { + dialog = new EmptyDialog(conf.getTopParent(), "No info", taginfo); + } + } + else + { + dialog = new EmptyDialog(conf.getTopParent(), "No info", null); + } + return dialog; + } + + /** + * Load and check class implementation from classname. + * + * @param classname + * @return TagInfo implementation for given class name + */ + public Class getTagInfoImpl(String classname) + { + Class aClass = null; + boolean interfaceFound = false; + if (classname != null) + { + try + { + aClass = Class.forName(classname); + Class superClass = aClass; + // Looking for TagInfo interface implementation. + while (superClass != null) + { + Class[] interfaces = superClass.getInterfaces(); + for (int i = 0; i < interfaces.length; i++) + { + if ((interfaces[i].getName()).equals("javazoom.jlgui.player.amp.tag.TagInfo")) + { + interfaceFound = true; + break; + } + } + if (interfaceFound) break; + superClass = superClass.getSuperclass(); + } + if (interfaceFound) log.info(classname + " loaded"); + else log.info(classname + " not loaded"); + } + catch (ClassNotFoundException e) + { + log.error("Error : " + classname + " : " + e.getMessage()); + } + } + return aClass; + } + + /** + * Return new instance of given class. + * + * @param aClass + * @return TagInfo for given class + */ + public TagInfo getTagInfoImplInstance(Class aClass) + { + TagInfo instance = null; + if (aClass != null) + { + try + { + Class[] argsClass = new Class[] {}; + Constructor c = aClass.getConstructor(argsClass); + instance = (TagInfo) (c.newInstance(null)); + } + catch (Exception e) + { + log.error("Cannot Instanciate : " + aClass.getName() + " : " + e.getMessage()); + } + } + return instance; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/APEDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/APEDialog.java new file mode 100644 index 0000000..001bca3 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/APEDialog.java @@ -0,0 +1,187 @@ +/* + * APEDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import java.text.DecimalFormat; +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.tag.APEInfo; + +/** + * APEDialog class implements a DialogBox to diplay APE info. + */ +public class APEDialog extends TagInfoDialog +{ + private APEInfo _apeinfo = null; + + /** + * Creates new form ApeDialog + */ + public APEDialog(JFrame parent, String title, APEInfo mi) + { + super(parent, title); + initComponents(); + _apeinfo = mi; + int size = _apeinfo.getLocation().length(); + locationLabel.setText(size > 50 ? ("..." + _apeinfo.getLocation().substring(size - 50)) : _apeinfo.getLocation()); + if ((_apeinfo.getTitle() != null) && (!_apeinfo.getTitle().equals(""))) textField.append("Title=" + _apeinfo.getTitle() + "\n"); + if ((_apeinfo.getArtist() != null) && (!_apeinfo.getArtist().equals(""))) textField.append("Artist=" + _apeinfo.getArtist() + "\n"); + if ((_apeinfo.getAlbum() != null) && (!_apeinfo.getAlbum().equals(""))) textField.append("Album=" + _apeinfo.getAlbum() + "\n"); + if (_apeinfo.getTrack() > 0) textField.append("Track=" + _apeinfo.getTrack() + "\n"); + if ((_apeinfo.getYear() != null) && (!_apeinfo.getYear().equals(""))) textField.append("Year=" + _apeinfo.getYear() + "\n"); + if ((_apeinfo.getGenre() != null) && (!_apeinfo.getGenre().equals(""))) textField.append("Genre=" + _apeinfo.getGenre() + "\n"); + java.util.List comments = _apeinfo.getComment(); + if (comments != null) + { + for (int i = 0; i < comments.size(); i++) + textField.append(comments.get(i) + "\n"); + } + int secondsAmount = Math.round(_apeinfo.getPlayTime()); + if (secondsAmount < 0) secondsAmount = 0; + int minutes = secondsAmount / 60; + int seconds = secondsAmount - (minutes * 60); + lengthLabel.setText("Length : " + minutes + ":" + seconds); + DecimalFormat df = new DecimalFormat("#,###,###"); + sizeLabel.setText("Size : " + df.format(_apeinfo.getSize()) + " bytes"); + versionLabel.setText("Version: " + df.format(_apeinfo.getVersion())); + compressionLabel.setText("Compression: " + _apeinfo.getCompressionlevel()); + channelsLabel.setText("Channels: " + _apeinfo.getChannels()); + bitspersampleLabel.setText("Bits Per Sample: " + _apeinfo.getBitsPerSample()); + bitrateLabel.setText("Average Bitrate: " + (_apeinfo.getBitRate() / 1000) + " kbps"); + samplerateLabel.setText("Sample Rate: " + _apeinfo.getSamplingRate() + " Hz"); + peaklevelLabel.setText("Peak Level: " + (_apeinfo.getPeaklevel() > 0 ? String.valueOf(_apeinfo.getPeaklevel()) : "")); + copyrightLabel.setText("Copyrighted: " + (_apeinfo.getCopyright() != null ? _apeinfo.getCopyright() : "")); + buttonsPanel.add(_close); + pack(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + java.awt.GridBagConstraints gridBagConstraints; + jPanel3 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + locationLabel = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + textField = new javax.swing.JTextArea(); + jPanel2 = new javax.swing.JPanel(); + lengthLabel = new javax.swing.JLabel(); + sizeLabel = new javax.swing.JLabel(); + versionLabel = new javax.swing.JLabel(); + compressionLabel = new javax.swing.JLabel(); + channelsLabel = new javax.swing.JLabel(); + bitspersampleLabel = new javax.swing.JLabel(); + bitrateLabel = new javax.swing.JLabel(); + samplerateLabel = new javax.swing.JLabel(); + peaklevelLabel = new javax.swing.JLabel(); + copyrightLabel = new javax.swing.JLabel(); + buttonsPanel = new javax.swing.JPanel(); + getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + jPanel3.setLayout(new java.awt.GridBagLayout()); + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + jLabel1.setText("File/URL :"); + jPanel1.add(jLabel1); + jPanel1.add(locationLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel1, gridBagConstraints); + jLabel2.setText("Standard Tags"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel2, gridBagConstraints); + jLabel3.setText("File/Stream info"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel3, gridBagConstraints); + textField.setColumns(20); + textField.setRows(10); + jScrollPane1.setViewportView(textField); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jScrollPane1, gridBagConstraints); + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS)); + jPanel2.add(lengthLabel); + jPanel2.add(sizeLabel); + jPanel2.add(versionLabel); + jPanel2.add(compressionLabel); + jPanel2.add(channelsLabel); + jPanel2.add(bitspersampleLabel); + jPanel2.add(bitrateLabel); + jPanel2.add(samplerateLabel); + jPanel2.add(peaklevelLabel); + jPanel2.add(copyrightLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel2, gridBagConstraints); + getContentPane().add(jPanel3); + getContentPane().add(buttonsPanel); + //pack(); + } + // //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel bitrateLabel; + private javax.swing.JLabel bitspersampleLabel; + private javax.swing.JPanel buttonsPanel; + private javax.swing.JLabel channelsLabel; + private javax.swing.JLabel compressionLabel; + private javax.swing.JLabel copyrightLabel; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lengthLabel; + private javax.swing.JLabel locationLabel; + private javax.swing.JLabel peaklevelLabel; + private javax.swing.JLabel samplerateLabel; + private javax.swing.JLabel sizeLabel; + private javax.swing.JTextArea textField; + private javax.swing.JLabel versionLabel; + // End of variables declaration//GEN-END:variables +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/EmptyDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/EmptyDialog.java new file mode 100644 index 0000000..147f6c9 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/EmptyDialog.java @@ -0,0 +1,75 @@ +/* + * EmptyDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.tag.TagInfo; + +/** + * OggVorbisDialog class implements a DialogBox to diplay OggVorbis info. + */ +public class EmptyDialog extends TagInfoDialog +{ + private TagInfo _info = null; + + /** + * Creates new form MpegDialog + */ + public EmptyDialog(JFrame parent, String title, TagInfo mi) + { + super(parent, title); + initComponents(); + _info = mi; + buttonsPanel.add(_close); + pack(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + jPanel3 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + buttonsPanel = new javax.swing.JPanel(); + getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel1.setText("No Information Available"); + jPanel3.add(jLabel1); + getContentPane().add(jPanel3); + getContentPane().add(buttonsPanel); + //pack(); + } + // //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel buttonsPanel; + private javax.swing.JLabel jLabel1; + private javax.swing.JPanel jPanel3; + // End of variables declaration//GEN-END:variables +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/FlacDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/FlacDialog.java new file mode 100644 index 0000000..f506a67 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/FlacDialog.java @@ -0,0 +1,165 @@ +/* + * FlacDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import java.text.DecimalFormat; +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.tag.FlacInfo; + +/** + * FlacDialog class implements a DialogBox to diplay Flac info. + */ +public class FlacDialog extends TagInfoDialog +{ + private FlacInfo _flacinfo = null; + + /** + * Creates new form FlacDialog + */ + public FlacDialog(JFrame parent, String title, FlacInfo mi) + { + super(parent, title); + initComponents(); + _flacinfo = mi; + int size = _flacinfo.getLocation().length(); + locationLabel.setText(size > 50 ? ("..." + _flacinfo.getLocation().substring(size - 50)) : _flacinfo.getLocation()); + if ((_flacinfo.getTitle() != null) && (!_flacinfo.getTitle().equals(""))) textField.append("Title=" + _flacinfo.getTitle() + "\n"); + if ((_flacinfo.getArtist() != null) && (!_flacinfo.getArtist().equals(""))) textField.append("Artist=" + _flacinfo.getArtist() + "\n"); + if ((_flacinfo.getAlbum() != null) && (!_flacinfo.getAlbum().equals(""))) textField.append("Album=" + _flacinfo.getAlbum() + "\n"); + if (_flacinfo.getTrack() > 0) textField.append("Track=" + _flacinfo.getTrack() + "\n"); + if ((_flacinfo.getYear() != null) && (!_flacinfo.getYear().equals(""))) textField.append("Year=" + _flacinfo.getYear() + "\n"); + if ((_flacinfo.getGenre() != null) && (!_flacinfo.getGenre().equals(""))) textField.append("Genre=" + _flacinfo.getGenre() + "\n"); + java.util.List comments = _flacinfo.getComment(); + if (comments != null) + { + for (int i = 0; i < comments.size(); i++) + textField.append(comments.get(i) + "\n"); + } + DecimalFormat df = new DecimalFormat("#,###,###"); + sizeLabel.setText("Size : " + df.format(_flacinfo.getSize()) + " bytes"); + channelsLabel.setText("Channels: " + _flacinfo.getChannels()); + bitspersampleLabel.setText("Bits Per Sample: " + _flacinfo.getBitsPerSample()); + samplerateLabel.setText("Sample Rate: " + _flacinfo.getSamplingRate() + " Hz"); + buttonsPanel.add(_close); + pack(); + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + java.awt.GridBagConstraints gridBagConstraints; + jPanel3 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + locationLabel = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + textField = new javax.swing.JTextArea(); + jPanel2 = new javax.swing.JPanel(); + lengthLabel = new javax.swing.JLabel(); + sizeLabel = new javax.swing.JLabel(); + channelsLabel = new javax.swing.JLabel(); + bitspersampleLabel = new javax.swing.JLabel(); + bitrateLabel = new javax.swing.JLabel(); + samplerateLabel = new javax.swing.JLabel(); + buttonsPanel = new javax.swing.JPanel(); + getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + jPanel3.setLayout(new java.awt.GridBagLayout()); + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + jLabel1.setText("File/URL :"); + jPanel1.add(jLabel1); + jPanel1.add(locationLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel1, gridBagConstraints); + jLabel2.setText("Standard Tags"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel2, gridBagConstraints); + jLabel3.setText("File/Stream info"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel3, gridBagConstraints); + textField.setColumns(20); + textField.setRows(10); + jScrollPane1.setViewportView(textField); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jScrollPane1, gridBagConstraints); + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS)); + jPanel2.add(lengthLabel); + jPanel2.add(sizeLabel); + jPanel2.add(channelsLabel); + jPanel2.add(bitspersampleLabel); + jPanel2.add(bitrateLabel); + jPanel2.add(samplerateLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel2, gridBagConstraints); + getContentPane().add(jPanel3); + getContentPane().add(buttonsPanel); + //pack(); + } + // //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel bitrateLabel; + private javax.swing.JLabel bitspersampleLabel; + private javax.swing.JPanel buttonsPanel; + private javax.swing.JLabel channelsLabel; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lengthLabel; + private javax.swing.JLabel locationLabel; + private javax.swing.JLabel samplerateLabel; + private javax.swing.JLabel sizeLabel; + private javax.swing.JTextArea textField; + // End of variables declaration//GEN-END:variables +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/MpegDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/MpegDialog.java new file mode 100644 index 0000000..2782bed --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/MpegDialog.java @@ -0,0 +1,194 @@ +/* + * MpegDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import java.text.DecimalFormat; +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.tag.MpegInfo; + +/** + * OggVorbisDialog class implements a DialogBox to diplay OggVorbis info. + */ +public class MpegDialog extends TagInfoDialog +{ + private MpegInfo _mpeginfo = null; + + /** + * Creates new form MpegDialog + */ + public MpegDialog(JFrame parent, String title, MpegInfo mi) + { + super(parent, title); + initComponents(); + _mpeginfo = mi; + int size = _mpeginfo.getLocation().length(); + locationLabel.setText(size > 50 ? ("..." + _mpeginfo.getLocation().substring(size - 50)) : _mpeginfo.getLocation()); + if ((_mpeginfo.getTitle() != null) && ((!_mpeginfo.getTitle().equals("")))) textField.append("Title=" + _mpeginfo.getTitle() + "\n"); + if ((_mpeginfo.getArtist() != null) && ((!_mpeginfo.getArtist().equals("")))) textField.append("Artist=" + _mpeginfo.getArtist() + "\n"); + if ((_mpeginfo.getAlbum() != null) && ((!_mpeginfo.getAlbum().equals("")))) textField.append("Album=" + _mpeginfo.getAlbum() + "\n"); + if (_mpeginfo.getTrack() > 0) textField.append("Track=" + _mpeginfo.getTrack() + "\n"); + if ((_mpeginfo.getYear() != null) && ((!_mpeginfo.getYear().equals("")))) textField.append("Year=" + _mpeginfo.getYear() + "\n"); + if ((_mpeginfo.getGenre() != null) && ((!_mpeginfo.getGenre().equals("")))) textField.append("Genre=" + _mpeginfo.getGenre() + "\n"); + java.util.List comments = _mpeginfo.getComment(); + if (comments != null) + { + for (int i = 0; i < comments.size(); i++) + textField.append(comments.get(i) + "\n"); + } + int secondsAmount = Math.round(_mpeginfo.getPlayTime()); + if (secondsAmount < 0) secondsAmount = 0; + int minutes = secondsAmount / 60; + int seconds = secondsAmount - (minutes * 60); + lengthLabel.setText("Length : " + minutes + ":" + seconds); + DecimalFormat df = new DecimalFormat("#,###,###"); + sizeLabel.setText("Size : " + df.format(_mpeginfo.getSize()) + " bytes"); + versionLabel.setText(_mpeginfo.getVersion() + " " + _mpeginfo.getLayer()); + bitrateLabel.setText((_mpeginfo.getBitRate() / 1000) + " kbps"); + samplerateLabel.setText(_mpeginfo.getSamplingRate() + " Hz " + _mpeginfo.getChannelsMode()); + vbrLabel.setText("VBR : " + _mpeginfo.getVBR()); + crcLabel.setText("CRCs : " + _mpeginfo.getCRC()); + copyrightLabel.setText("Copyrighted : " + _mpeginfo.getCopyright()); + originalLabel.setText("Original : " + _mpeginfo.getOriginal()); + emphasisLabel.setText("Emphasis : " + _mpeginfo.getEmphasis()); + buttonsPanel.add(_close); + pack(); + } + + /** + * Returns VorbisInfo. + */ + public MpegInfo getOggVorbisInfo() + { + return _mpeginfo; + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + java.awt.GridBagConstraints gridBagConstraints; + jPanel3 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + locationLabel = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + textField = new javax.swing.JTextArea(); + jPanel2 = new javax.swing.JPanel(); + lengthLabel = new javax.swing.JLabel(); + sizeLabel = new javax.swing.JLabel(); + versionLabel = new javax.swing.JLabel(); + bitrateLabel = new javax.swing.JLabel(); + samplerateLabel = new javax.swing.JLabel(); + vbrLabel = new javax.swing.JLabel(); + crcLabel = new javax.swing.JLabel(); + copyrightLabel = new javax.swing.JLabel(); + originalLabel = new javax.swing.JLabel(); + emphasisLabel = new javax.swing.JLabel(); + buttonsPanel = new javax.swing.JPanel(); + getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + jPanel3.setLayout(new java.awt.GridBagLayout()); + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + jLabel1.setText("File/URL :"); + jPanel1.add(jLabel1); + jPanel1.add(locationLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel1, gridBagConstraints); + jLabel2.setText("Standard Tags"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel2, gridBagConstraints); + jLabel3.setText("File/Stream info"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel3, gridBagConstraints); + textField.setColumns(20); + textField.setRows(10); + jScrollPane1.setViewportView(textField); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jScrollPane1, gridBagConstraints); + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS)); + jPanel2.add(lengthLabel); + jPanel2.add(sizeLabel); + jPanel2.add(versionLabel); + jPanel2.add(bitrateLabel); + jPanel2.add(samplerateLabel); + jPanel2.add(vbrLabel); + jPanel2.add(crcLabel); + jPanel2.add(copyrightLabel); + jPanel2.add(originalLabel); + jPanel2.add(emphasisLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel2, gridBagConstraints); + getContentPane().add(jPanel3); + getContentPane().add(buttonsPanel); + //pack(); + } + // //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel bitrateLabel; + private javax.swing.JPanel buttonsPanel; + private javax.swing.JLabel copyrightLabel; + private javax.swing.JLabel crcLabel; + private javax.swing.JLabel emphasisLabel; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lengthLabel; + private javax.swing.JLabel locationLabel; + private javax.swing.JLabel originalLabel; + private javax.swing.JLabel samplerateLabel; + private javax.swing.JLabel sizeLabel; + private javax.swing.JTextArea textField; + private javax.swing.JLabel vbrLabel; + private javax.swing.JLabel versionLabel; + // End of variables declaration//GEN-END:variables +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/OggVorbisDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/OggVorbisDialog.java new file mode 100644 index 0000000..16a84e6 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/OggVorbisDialog.java @@ -0,0 +1,196 @@ +/* + * OggVorbisDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import java.text.DecimalFormat; +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.tag.OggVorbisInfo; + +/** + * OggVorbisDialog class implements a DialogBox to diplay OggVorbis info. + */ +public class OggVorbisDialog extends TagInfoDialog +{ + private OggVorbisInfo _vorbisinfo = null; + + /** + * Creates new form MpegDialog + */ + public OggVorbisDialog(JFrame parent, String title, OggVorbisInfo mi) + { + super(parent, title); + initComponents(); + _vorbisinfo = mi; + int size = _vorbisinfo.getLocation().length(); + locationLabel.setText(size > 50 ? ("..." + _vorbisinfo.getLocation().substring(size - 50)) : _vorbisinfo.getLocation()); + if ((_vorbisinfo.getTitle() != null) && ((!_vorbisinfo.getTitle().equals("")))) textField.append("Title=" + _vorbisinfo.getTitle() + "\n"); + if ((_vorbisinfo.getArtist() != null) && ((!_vorbisinfo.getArtist().equals("")))) textField.append("Artist=" + _vorbisinfo.getArtist() + "\n"); + if ((_vorbisinfo.getAlbum() != null) && ((!_vorbisinfo.getAlbum().equals("")))) textField.append("Album=" + _vorbisinfo.getAlbum() + "\n"); + if (_vorbisinfo.getTrack() > 0) textField.append("Track=" + _vorbisinfo.getTrack() + "\n"); + if ((_vorbisinfo.getYear() != null) && ((!_vorbisinfo.getYear().equals("")))) textField.append("Year=" + _vorbisinfo.getYear() + "\n"); + if ((_vorbisinfo.getGenre() != null) && ((!_vorbisinfo.getGenre().equals("")))) textField.append("Genre=" + _vorbisinfo.getGenre() + "\n"); + java.util.List comments = _vorbisinfo.getComment(); + for (int i = 0; i < comments.size(); i++) + textField.append(comments.get(i) + "\n"); + int secondsAmount = Math.round(_vorbisinfo.getPlayTime()); + if (secondsAmount < 0) secondsAmount = 0; + int minutes = secondsAmount / 60; + int seconds = secondsAmount - (minutes * 60); + lengthLabel.setText("Length : " + minutes + ":" + seconds); + bitrateLabel.setText("Average bitrate : " + _vorbisinfo.getAverageBitrate() / 1000 + " kbps"); + DecimalFormat df = new DecimalFormat("#,###,###"); + sizeLabel.setText("File size : " + df.format(_vorbisinfo.getSize()) + " bytes"); + nominalbitrateLabel.setText("Nominal bitrate : " + (_vorbisinfo.getBitRate() / 1000) + " kbps"); + maxbitrateLabel.setText("Max bitrate : " + _vorbisinfo.getMaxBitrate() / 1000 + " kbps"); + minbitrateLabel.setText("Min bitrate : " + _vorbisinfo.getMinBitrate() / 1000 + " kbps"); + channelsLabel.setText("Channel : " + _vorbisinfo.getChannels()); + samplerateLabel.setText("Sampling rate : " + _vorbisinfo.getSamplingRate() + " Hz"); + serialnumberLabel.setText("Serial number : " + _vorbisinfo.getSerial()); + versionLabel.setText("Version : " + _vorbisinfo.getVersion()); + vendorLabel.setText("Vendor : " + _vorbisinfo.getVendor()); + buttonsPanel.add(_close); + pack(); + } + + /** + * Returns VorbisInfo. + */ + public OggVorbisInfo getOggVorbisInfo() + { + return _vorbisinfo; + } + + /** + * This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + java.awt.GridBagConstraints gridBagConstraints; + jPanel3 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + locationLabel = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + textField = new javax.swing.JTextArea(); + jPanel2 = new javax.swing.JPanel(); + lengthLabel = new javax.swing.JLabel(); + bitrateLabel = new javax.swing.JLabel(); + sizeLabel = new javax.swing.JLabel(); + nominalbitrateLabel = new javax.swing.JLabel(); + maxbitrateLabel = new javax.swing.JLabel(); + minbitrateLabel = new javax.swing.JLabel(); + channelsLabel = new javax.swing.JLabel(); + samplerateLabel = new javax.swing.JLabel(); + serialnumberLabel = new javax.swing.JLabel(); + versionLabel = new javax.swing.JLabel(); + vendorLabel = new javax.swing.JLabel(); + buttonsPanel = new javax.swing.JPanel(); + getContentPane().setLayout(new javax.swing.BoxLayout(getContentPane(), javax.swing.BoxLayout.Y_AXIS)); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + jPanel3.setLayout(new java.awt.GridBagLayout()); + jPanel1.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + jLabel1.setText("File/URL :"); + jPanel1.add(jLabel1); + jPanel1.add(locationLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel1, gridBagConstraints); + jLabel2.setText("Standard Tags"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel2, gridBagConstraints); + jLabel3.setText("File/Stream info"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 1; + gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jLabel3, gridBagConstraints); + textField.setColumns(20); + textField.setRows(10); + jScrollPane1.setViewportView(textField); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jScrollPane1, gridBagConstraints); + jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS)); + jPanel2.add(lengthLabel); + jPanel2.add(bitrateLabel); + jPanel2.add(sizeLabel); + jPanel2.add(nominalbitrateLabel); + jPanel2.add(maxbitrateLabel); + jPanel2.add(minbitrateLabel); + jPanel2.add(channelsLabel); + jPanel2.add(samplerateLabel); + jPanel2.add(serialnumberLabel); + jPanel2.add(versionLabel); + jPanel2.add(vendorLabel); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 1; + gridBagConstraints.gridy = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); + jPanel3.add(jPanel2, gridBagConstraints); + getContentPane().add(jPanel3); + getContentPane().add(buttonsPanel); + //pack(); + } + // //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel bitrateLabel; + private javax.swing.JPanel buttonsPanel; + private javax.swing.JLabel channelsLabel; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JLabel lengthLabel; + private javax.swing.JLabel locationLabel; + private javax.swing.JLabel maxbitrateLabel; + private javax.swing.JLabel minbitrateLabel; + private javax.swing.JLabel nominalbitrateLabel; + private javax.swing.JLabel samplerateLabel; + private javax.swing.JLabel serialnumberLabel; + private javax.swing.JLabel sizeLabel; + private javax.swing.JTextArea textField; + private javax.swing.JLabel vendorLabel; + private javax.swing.JLabel versionLabel; + // End of variables declaration//GEN-END:variables +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagInfoDialog.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagInfoDialog.java new file mode 100644 index 0000000..e2a0576 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagInfoDialog.java @@ -0,0 +1,60 @@ +/* + * TagInfoDialog. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; + +/** + * This class define a Dialog for TagiInfo to display. + */ +public class TagInfoDialog extends JDialog implements ActionListener +{ + protected JButton _close = null; + + /** + * Constructor. + * @param parent + * @param title + */ + public TagInfoDialog(JFrame parent, String title) + { + super(parent, title, true); + _close = new JButton("Close"); + _close.addActionListener(this); + } + + /* (non-Javadoc) + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + public void actionPerformed(ActionEvent e) + { + if (e.getSource() == _close) + { + this.dispose(); + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagSearch.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagSearch.java new file mode 100644 index 0000000..5ef8606 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagSearch.java @@ -0,0 +1,434 @@ +/* + * TagSearch. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.tag.ui; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.ResourceBundle; +import java.util.Vector; +import javax.swing.ButtonGroup; +import javax.swing.DefaultListModel; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JScrollBar; +import javax.swing.JScrollPane; +import javax.swing.JTextField; +import javax.swing.ListSelectionModel; +import javax.swing.WindowConstants; +import javax.swing.border.EmptyBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javazoom.jlgui.player.amp.PlayerUI; +import javazoom.jlgui.player.amp.playlist.Playlist; +import javazoom.jlgui.player.amp.playlist.PlaylistItem; +import javazoom.jlgui.player.amp.tag.TagInfo; + +/** + * This class allows to search and play for a particular track in the current playlist. + */ +public class TagSearch extends JFrame +{ + private static String sep = System.getProperty("file.separator"); + private JTextField searchField; + private JList list; + private DefaultListModel m; + private PlayerUI player; + private Vector _playlist, restrictedPlaylist; + private String lastSearch = null; + private JScrollPane scroll; + private ResourceBundle bundle; + private JRadioButton all, artist, album, title; + + public TagSearch(PlayerUI ui) + { + super(); + player = ui; + _playlist = null; + restrictedPlaylist = null; + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/tag/ui/tag"); + initComponents(); + } + + public void display() + { + if (list.getModel().getSize() != 0) + { + setVisible(true); + } + else + { + JOptionPane.showMessageDialog(player.getParent(), bundle.getString("emptyPlaylistMsg"), bundle.getString("emptyPlaylistTitle"), JOptionPane.OK_OPTION); + } + } + + /** + * Initialises the User Interface. + */ + private void initComponents() + { + setLayout(new GridLayout(1, 1)); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + setTitle(bundle.getString("title")); + this.setLocation(player.getX() + player.getWidth(), player.getY()); + JPanel main = new JPanel(new BorderLayout(0, 1)); + main.setBorder(new EmptyBorder(10, 10, 10, 10)); + main.setMinimumSize(new java.awt.Dimension(0, 0)); + main.setPreferredSize(new java.awt.Dimension(300, 400)); + JPanel searchPane = new JPanel(new GridLayout(4, 1, 10, 2)); + JLabel searchLabel = new JLabel(bundle.getString("searchLabel")); + searchField = new JTextField(); + searchField.addKeyListener(new KeyboardListener()); + searchPane.add(searchLabel); + searchPane.add(searchField); + all = new JRadioButton(bundle.getString("radioAll"), true); + artist = new JRadioButton(bundle.getString("radioArtist"), false); + album = new JRadioButton(bundle.getString("radioAlbum"), false); + title = new JRadioButton(bundle.getString("radioTitle"), false); + all.addChangeListener(new RadioListener()); + ButtonGroup filters = new ButtonGroup(); + filters.add(all); + filters.add(artist); + filters.add(album); + filters.add(title); + JPanel topButtons = new JPanel(new GridLayout(1, 2)); + JPanel bottomButtons = new JPanel(new GridLayout(1, 2)); + topButtons.add(all); + topButtons.add(artist); + bottomButtons.add(album); + bottomButtons.add(title); + searchPane.add(topButtons); + searchPane.add(bottomButtons); + list = new JList(); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + initList(); + list.addMouseListener(new ClickListener()); + list.addKeyListener(new KeyboardListener()); + scroll = new JScrollPane(list); + main.add(searchPane, BorderLayout.NORTH); + main.add(scroll, BorderLayout.CENTER); + add(main); + pack(); + } + + /** + * Initialises the list so that it displays the details of all songs in the playlist. + */ + private void initList() + { + Playlist playlist = player.getPlaylist(); + int c = player.getPlaylist().getPlaylistSize(); + _playlist = new Vector(); + for (int i = 0; i < c; i++) + { + _playlist.addElement(playlist.getItemAt(i)); + } + restrictedPlaylist = _playlist; + m = new DefaultListModel(); + for (int i = 0; i < _playlist.size(); i++) + { + PlaylistItem plItem = (PlaylistItem) _playlist.get(i); + if (plItem.isFile()) m.addElement(getDisplayString(plItem)); + } + list.setModel(m); + } + + public String getDisplayString(PlaylistItem pi) + { + TagInfo song = pi.getTagInfo(); + String element; + String location = pi.getLocation(); + location = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf(".")); + if (song == null) + { + element = location; + } + else + { + if (song.getArtist() == null || song.getArtist().equals("")) + { + element = location; + } + else + { + element = song.getArtist().trim(); + if (song.getTitle() == null || song.getTitle().equals("")) + { + element += " - " + location; + } + else + { + element += " - " + song.getTitle().trim(); + } + } + } + return element; + } + + /** + * Searches the playlist for a song containing the words in the given search string. + * It searches on the title, artist, album and filename of each song in the playlist. + * + * @param searchString The string to search for in all songs in the playlist + **/ + private void searchList(String searchString) + { + String[] s = searchString.split(" "); + String lastS = ""; + if (s.length > 0) lastS = s[s.length - 1]; + if (lastS.equals("")) + { + list.setModel(m); + restrictedPlaylist = _playlist; + } + else + { + DefaultListModel newModel = new DefaultListModel(); + if (lastSearch != null) + { + if (searchString.length() <= 1 || !searchString.substring(searchString.length() - 2).equals(lastSearch)) + { + list.setModel(m); + restrictedPlaylist = _playlist; + } + } + Vector pI = restrictedPlaylist; + restrictedPlaylist = new Vector(); + for (int a = 0; a < s.length; a++) + { + String currentS = s[a]; + int size = list.getModel().getSize(); + boolean[] remove = new boolean[size]; + for (int i = 0; i < size; i++) + { + final int TITLE_SEARCH = 0; + final int ARTIST_SEARCH = 1; + final int ALBUM_SEARCH = 2; + final int FILENAME_SEARCH = 3; + TagInfo pli = ((PlaylistItem) pI.get(i)).getTagInfo(); + remove[i] = false; + boolean found = false; + int searchType; + if (artist.isSelected()) + { + searchType = ARTIST_SEARCH; + } + else if (album.isSelected()) + { + searchType = ALBUM_SEARCH; + } + else if (title.isSelected()) + { + searchType = TITLE_SEARCH; + } + else + { + searchType = -1; + } + for (int j = 0; j <= FILENAME_SEARCH; j++) + { + String listString = ""; + if (pli == null) + { + if (searchType != -1) + { + break; + } + j = FILENAME_SEARCH; + } + else if (searchType != -1) + { + j = searchType; + } + switch (j) + { + case (TITLE_SEARCH): + if (pli.getTitle() != null) listString = pli.getTitle().toLowerCase(); + break; + case (ARTIST_SEARCH): + if (pli.getArtist() != null) listString = pli.getArtist().toLowerCase(); + break; + case (ALBUM_SEARCH): + if (pli.getAlbum() != null) listString = pli.getAlbum().toLowerCase(); + break; + case (FILENAME_SEARCH): + String location = ((PlaylistItem) pI.get(i)).getLocation().toLowerCase(); + listString = location.substring(location.lastIndexOf(sep) + 1, location.lastIndexOf(".")); + break; + } + currentS = currentS.toLowerCase(); + if (found = search(currentS, listString)) + { + break; + } + if (searchType != -1) + { + break; + } + } + //if(found)foundAt[a] = i; + if (found && a == 0) + { + //todo new + newModel.addElement(getDisplayString((PlaylistItem) pI.get(i))); + restrictedPlaylist.add(pI.get(i)); + } + if (!found && a != 0) + { + remove[i] = true; + } + } + //remove all unmatching items + for (int x = size - 1; x >= 0; x--) + { + if (remove[x]) + { + newModel.remove(x); + restrictedPlaylist.remove(x); + } + } + pI = restrictedPlaylist; + list.setModel(newModel); + } + list.setModel(newModel); + lastSearch = searchField.getText(); + } + if (list.getModel().getSize() > 0) list.setSelectedIndex(0); + } + + /** + * Searches to see if a particular string exists within another string + * + * @param pattern The string to search for + * @param text The string in which to search for the pattern string + * @return True if the pattern string exists in the text string + */ + private boolean search(String pattern, String text) + { + int pStart = 0; + int tStart = 0; + char[] pChar = pattern.toCharArray(); + char[] tChar = text.toCharArray(); + while (pStart < pChar.length && tStart < tChar.length) + { + if (pChar[pStart] == tChar[tStart]) + { + pStart++; + tStart++; + } + else + { + pStart = 0; + if (pChar[pStart] != tChar[tStart]) + { + tStart++; + } + } + } + return pStart == pChar.length; + } + + /** + * Calls the relavent methods in the player class to play a song. + */ + private void playSong() + { + Playlist playlist = player.getPlaylist(); + player.pressStop(); + player.setCurrentSong((PlaylistItem) restrictedPlaylist.get(list.getSelectedIndex())); + playlist.setCursor(playlist.getIndex((PlaylistItem) restrictedPlaylist.get(list.getSelectedIndex()))); + player.pressStart(); + dispose(); + } + /** + * Class to handle keyboard presses. + */ + class KeyboardListener implements KeyListener + { + public void keyReleased(KeyEvent e) + { + if (e.getSource().equals(searchField)) + { + if (e.getKeyCode() != KeyEvent.VK_DOWN && e.getKeyCode() != KeyEvent.VK_UP) + { + searchList(searchField.getText()); // Search for current search string + } + } + } + + public void keyTyped(KeyEvent e) + { + if (list.getSelectedIndex() != -1) + { + if (e.getKeyChar() == KeyEvent.VK_ENTER) + { + playSong(); + } + } + } + + public void keyPressed(KeyEvent e) + { + int index = list.getSelectedIndex(); + if (e.getKeyCode() == KeyEvent.VK_DOWN && index < list.getModel().getSize() - 1) + { + //list.setSelectedIndex(index+1); + JScrollBar vBar = scroll.getVerticalScrollBar(); + vBar.setValue(vBar.getValue() + vBar.getUnitIncrement() * 5); + } + else if (e.getKeyCode() == KeyEvent.VK_UP && index >= 0) + { + JScrollBar vBar = scroll.getVerticalScrollBar(); + vBar.setValue(vBar.getValue() - vBar.getUnitIncrement() * 5); + //list.setSelectedIndex(index-1); + } + } + } + /** + * Class to play a song if one is double-clicked on on the search list. + */ + class ClickListener extends MouseAdapter + { + public void mouseClicked(MouseEvent e) + { + if (e.getClickCount() == 2 && list.getSelectedIndex() != -1) + { + playSong(); + } + } + } + class RadioListener implements ChangeListener + { + public void stateChanged(ChangeEvent e) + { + searchList(searchField.getText()); + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/tag.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/tag.properties new file mode 100644 index 0000000..e4d41e3 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/tag.properties @@ -0,0 +1,8 @@ +emptyPlaylistMsg = No files in playlist +emptyPlaylistTitle = No files in playlist +title = Jump to song... +searchLabel = Search for songs containing... +radioAll = Anywhere +radioArtist = Artist +radioAlbum = Album +radioTitle = Song Title diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/BMPLoader.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/BMPLoader.java new file mode 100644 index 0000000..8790511 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/BMPLoader.java @@ -0,0 +1,301 @@ +/* + * BMPLoader. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util; + +import java.awt.Image; +import java.awt.Toolkit; +import java.awt.image.ColorModel; +import java.awt.image.IndexColorModel; +import java.awt.image.MemoryImageSource; +import java.io.IOException; +import java.io.InputStream; + +/** + * A decoder for Windows bitmap (.BMP) files. + * Compression not supported. + */ +public class BMPLoader +{ + private InputStream is; + private int curPos = 0; + private int bitmapOffset; // starting position of image data + private int width; // image width in pixels + private int height; // image height in pixels + private short bitsPerPixel; // 1, 4, 8, or 24 (no color map) + private int compression; // 0 (none), 1 (8-bit RLE), or 2 (4-bit RLE) + private int actualSizeOfBitmap; + private int scanLineSize; + private int actualColorsUsed; + private byte r[], g[], b[]; // color palette + private int noOfEntries; + private byte[] byteData; // Unpacked data + private int[] intData; // Unpacked data + + public BMPLoader() + { + } + + public Image getBMPImage(InputStream stream) throws Exception + { + read(stream); + return Toolkit.getDefaultToolkit().createImage(getImageSource()); + } + + protected int readInt() throws IOException + { + int b1 = is.read(); + int b2 = is.read(); + int b3 = is.read(); + int b4 = is.read(); + curPos += 4; + return ((b4 << 24) + (b3 << 16) + (b2 << 8) + (b1 << 0)); + } + + protected short readShort() throws IOException + { + int b1 = is.read(); + int b2 = is.read(); + curPos += 4; + return (short) ((b2 << 8) + b1); + } + + protected void getFileHeader() throws IOException, Exception + { + // Actual contents (14 bytes): + short fileType = 0x4d42;// always "BM" + int fileSize; // size of file in bytes + short reserved1 = 0; // always 0 + short reserved2 = 0; // always 0 + fileType = readShort(); + if (fileType != 0x4d42) throw new Exception("Not a BMP file"); // wrong file type + fileSize = readInt(); + reserved1 = readShort(); + reserved2 = readShort(); + bitmapOffset = readInt(); + } + + protected void getBitmapHeader() throws IOException + { + // Actual contents (40 bytes): + int size; // size of this header in bytes + short planes; // no. of color planes: always 1 + int sizeOfBitmap; // size of bitmap in bytes (may be 0: if so, calculate) + int horzResolution; // horizontal resolution, pixels/meter (may be 0) + int vertResolution; // vertical resolution, pixels/meter (may be 0) + int colorsUsed; // no. of colors in palette (if 0, calculate) + int colorsImportant; // no. of important colors (appear first in palette) (0 means all are important) + boolean topDown; + int noOfPixels; + size = readInt(); + width = readInt(); + height = readInt(); + planes = readShort(); + bitsPerPixel = readShort(); + compression = readInt(); + sizeOfBitmap = readInt(); + horzResolution = readInt(); + vertResolution = readInt(); + colorsUsed = readInt(); + colorsImportant = readInt(); + topDown = (height < 0); + noOfPixels = width * height; + // Scan line is padded with zeroes to be a multiple of four bytes + scanLineSize = ((width * bitsPerPixel + 31) / 32) * 4; + if (sizeOfBitmap != 0) actualSizeOfBitmap = sizeOfBitmap; + else + // a value of 0 doesn't mean zero - it means we have to calculate it + actualSizeOfBitmap = scanLineSize * height; + if (colorsUsed != 0) actualColorsUsed = colorsUsed; + else + // a value of 0 means we determine this based on the bits per pixel + if (bitsPerPixel < 16) actualColorsUsed = 1 << bitsPerPixel; + else actualColorsUsed = 0; // no palette + } + + protected void getPalette() throws IOException + { + noOfEntries = actualColorsUsed; + //IJ.write("noOfEntries: " + noOfEntries); + if (noOfEntries > 0) + { + r = new byte[noOfEntries]; + g = new byte[noOfEntries]; + b = new byte[noOfEntries]; + int reserved; + for (int i = 0; i < noOfEntries; i++) + { + b[i] = (byte) is.read(); + g[i] = (byte) is.read(); + r[i] = (byte) is.read(); + reserved = is.read(); + curPos += 4; + } + } + } + + protected void unpack(byte[] rawData, int rawOffset, int[] intData, int intOffset, int w) + { + int j = intOffset; + int k = rawOffset; + int mask = 0xff; + for (int i = 0; i < w; i++) + { + int b0 = (((int) (rawData[k++])) & mask); + int b1 = (((int) (rawData[k++])) & mask) << 8; + int b2 = (((int) (rawData[k++])) & mask) << 16; + intData[j] = 0xff000000 | b0 | b1 | b2; + j++; + } + } + + protected void unpack(byte[] rawData, int rawOffset, int bpp, byte[] byteData, int byteOffset, int w) throws Exception + { + int j = byteOffset; + int k = rawOffset; + byte mask; + int pixPerByte; + switch (bpp) + { + case 1: + mask = (byte) 0x01; + pixPerByte = 8; + break; + case 4: + mask = (byte) 0x0f; + pixPerByte = 2; + break; + case 8: + mask = (byte) 0xff; + pixPerByte = 1; + break; + default: + throw new Exception("Unsupported bits-per-pixel value"); + } + for (int i = 0;;) + { + int shift = 8 - bpp; + for (int ii = 0; ii < pixPerByte; ii++) + { + byte br = rawData[k]; + br >>= shift; + byteData[j] = (byte) (br & mask); + //System.out.println("Setting byteData[" + j + "]=" + Test.byteToHex(byteData[j])); + j++; + i++; + if (i == w) return; + shift -= bpp; + } + k++; + } + } + + protected int readScanLine(byte[] b, int off, int len) throws IOException + { + int bytesRead = 0; + int l = len; + int r = 0; + while (len > 0) + { + bytesRead = is.read(b, off, len); + if (bytesRead == -1) return r == 0 ? -1 : r; + if (bytesRead == len) return l; + len -= bytesRead; + off += bytesRead; + r += bytesRead; + } + return l; + } + + protected void getPixelData() throws IOException, Exception + { + byte[] rawData; // the raw unpacked data + // Skip to the start of the bitmap data (if we are not already there) + long skip = bitmapOffset - curPos; + if (skip > 0) + { + is.skip(skip); + curPos += skip; + } + int len = scanLineSize; + if (bitsPerPixel > 8) intData = new int[width * height]; + else byteData = new byte[width * height]; + rawData = new byte[actualSizeOfBitmap]; + int rawOffset = 0; + int offset = (height - 1) * width; + for (int i = height - 1; i >= 0; i--) + { + int n = readScanLine(rawData, rawOffset, len); + if (n < len) throw new Exception("Scan line ended prematurely after " + n + " bytes"); + if (bitsPerPixel > 8) + { + // Unpack and create one int per pixel + unpack(rawData, rawOffset, intData, offset, width); + } + else + { + // Unpack and create one byte per pixel + unpack(rawData, rawOffset, bitsPerPixel, byteData, offset, width); + } + rawOffset += len; + offset -= width; + } + } + + public void read(InputStream is) throws IOException, Exception + { + this.is = is; + getFileHeader(); + getBitmapHeader(); + if (compression != 0) throw new Exception("BMP Compression not supported"); + getPalette(); + getPixelData(); + } + + public MemoryImageSource getImageSource() + { + ColorModel cm; + MemoryImageSource mis; + if (noOfEntries > 0) + { + // There is a color palette; create an IndexColorModel + cm = new IndexColorModel(bitsPerPixel, noOfEntries, r, g, b); + } + else + { + // There is no palette; use the default RGB color model + cm = ColorModel.getRGBdefault(); + } + // Create MemoryImageSource + if (bitsPerPixel > 8) + { + // use one int per pixel + mis = new MemoryImageSource(width, height, cm, intData, 0, width); + } + else + { + // use one byte per pixel + mis = new MemoryImageSource(width, height, cm, byteData, 0, width); + } + return mis; // this can be used by JComponent.createImage() + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/Config.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/Config.java new file mode 100644 index 0000000..952fb70 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/Config.java @@ -0,0 +1,711 @@ +/* + * Config. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util; + +import java.io.File; +import java.util.StringTokenizer; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.util.ini.Configuration; + +/** + * This class provides all parameters for jlGui coming from a file. + */ +public class Config +{ + public static String[] protocols = { "http:", "file:", "ftp:", "https:", "ftps:", "jar:" }; + public static String TAGINFO_POLICY_FILE = "file"; + public static String TAGINFO_POLICY_ALL = "all"; + public static String TAGINFO_POLICY_NONE = "none"; + private static String CONFIG_FILE_NAME = "jlgui.ini"; + private Configuration _config = null; + // configuration keys + private static final String LAST_URL = "last_url", + LAST_DIR = "last_dir", + ORIGINE_X = "origine_x", + ORIGINE_Y = "origine_y", + LAST_SKIN = "last_skin", + LAST_SKIN_DIR = "last_skin_dir", + EXTENSIONS = "allowed_extensions", + PLAYLIST_IMPL = "playlist_impl", + TAGINFO_MPEG_IMPL = "taginfo_mpeg_impl", + TAGINFO_OGGVORBIS_IMPL = "taginfo_oggvorbis_impl", + TAGINFO_APE_IMPL = "taginfo_ape_impl", + TAGINFO_FLAC_IMPL = "taginfo_flac_impl", + LAST_PLAYLIST = "last_playlist", + PROXY_SERVER = "proxy_server", + PROXY_PORT = "proxy_port", + PROXY_LOGIN = "proxy_login", + PROXY_PASSWORD = "proxy_password", + PLAYLIST_ENABLED = "playlist_enabled", + SHUFFLE_ENABLED = "shuffle_enabled", + REPEAT_ENABLED = "repeat_enabled", + EQUALIZER_ENABLED = "equalizer_enabled", + EQUALIZER_ON = "equalizer_on", + EQUALIZER_AUTO = "equalizer_auto", + LAST_EQUALIZER = "last_equalizer", + SCREEN_LIMIT = "screen_limit", + TAGINFO_POLICY = "taginfo_policy", + VOLUME_VALUE = "volume_value", + AUDIO_DEVICE = "audio_device", + VISUAL_MODE = "visual_mode"; + + private static Config _instance = null; + private String _audioDevice = ""; + private String _visualMode = ""; + private String _extensions = "m3u,pls,wsz,snd,aifc,aif,wav,au,mp1,mp2,mp3,ogg,spx,flac,ape,mac"; + private String _lastUrl = ""; + private String _lastDir = ""; + private String _lastSkinDir = ""; + private String _lastEqualizer = ""; + private String _defaultSkin = ""; + private String _playlist = "javazoom.jlgui.player.amp.playlist.BasePlaylist"; + private String _taginfoMpeg = "javazoom.jlgui.player.amp.tag.MpegInfo"; + private String _taginfoOggVorbis = "javazoom.jlgui.player.amp.tag.OggVorbisInfo"; + private String _taginfoAPE = "javazoom.jlgui.player.amp.tag.APEInfo"; + private String _taginfoFlac = "javazoom.jlgui.player.amp.tag.FlacInfo"; + private String _playlistFilename = ""; + private int _x = 0; + private int _y = 0; + private String _proxyServer = ""; + private String _proxyLogin = ""; + private String _proxyPassword = ""; + private int _proxyPort = -1; + private int _volume = -1; + private boolean _playlistEnabled = false; + private boolean _shuffleEnabled = false; + private boolean _repeatEnabled = false; + private boolean _equalizerEnabled = false; + private boolean _equalizerOn = false; + private boolean _equalizerAuto = false; + private boolean _screenLimit = false; + private String _taginfoPolicy = TAGINFO_POLICY_FILE; + + private JFrame topParent = null; + private ImageIcon iconParent = null; + + private Config() + { + } + + /** + * Returns Config instance. + */ + public synchronized static Config getInstance() + { + if (_instance == null) + { + _instance = new Config(); + } + return _instance; + } + + public void setTopParent(JFrame frame) + { + topParent = frame; + } + + public JFrame getTopParent() + { + if (topParent == null) + { + topParent = new JFrame(); + } + return topParent; + } + + public void setIconParent(ImageIcon icon) + { + iconParent = icon; + } + + public ImageIcon getIconParent() + { + return iconParent; + } + + /** + * Returns JavaSound audio device. + * @return String + */ + public String getAudioDevice() + { + return _audioDevice; + } + + /** + * Set JavaSound audio device. + * @param dev String + */ + public void setAudioDevice(String dev) + { + _audioDevice = dev; + } + + /** + * Return visual mode. + * @return + */ + public String getVisualMode() + { + return _visualMode; + } + + /** + * Set visual mode. + * @param mode + */ + public void setVisualMode(String mode) + { + _visualMode = mode; + } + + /** + * Returns playlist filename. + */ + public String getPlaylistFilename() + { + return _playlistFilename; + } + + /** + * Sets playlist filename. + */ + public void setPlaylistFilename(String pl) + { + _playlistFilename = pl; + } + + /** + * Returns last equalizer values. + */ + public int[] getLastEqualizer() + { + int[] vals = null; + if ((_lastEqualizer != null) && (!_lastEqualizer.equals(""))) + { + vals = new int[11]; + int i = 0; + StringTokenizer st = new StringTokenizer(_lastEqualizer, ","); + while (st.hasMoreTokens()) + { + String v = st.nextToken(); + vals[i++] = Integer.parseInt(v); + } + } + return vals; + } + + /** + * Sets last equalizer values. + */ + public void setLastEqualizer(int[] vals) + { + if (vals != null) + { + String dump = ""; + for (int i = 0; i < vals.length; i++) + { + dump = dump + vals[i] + ","; + } + _lastEqualizer = dump.substring(0, (dump.length() - 1)); + } + } + + /** + * Return screen limit flag. + * + * @return is screen limit flag + */ + public boolean isScreenLimit() + { + return _screenLimit; + } + + /** + * Set screen limit flag. + * + * @param b + */ + public void setScreenLimit(boolean b) + { + _screenLimit = b; + } + + /** + * Returns last URL. + */ + public String getLastURL() + { + return _lastUrl; + } + + /** + * Sets last URL. + */ + public void setLastURL(String url) + { + _lastUrl = url; + } + + /** + * Returns last Directory. + */ + public String getLastDir() + { + if ((_lastDir != null) && (!_lastDir.endsWith(File.separator))) + { + _lastDir = _lastDir + File.separator; + } + return _lastDir; + } + + /** + * Sets last Directory. + */ + public void setLastDir(String dir) + { + _lastDir = dir; + if ((_lastDir != null) && (!_lastDir.endsWith(File.separator))) + { + _lastDir = _lastDir + File.separator; + } + } + + /** + * Returns last skin directory. + */ + public String getLastSkinDir() + { + if ((_lastSkinDir != null) && (!_lastSkinDir.endsWith(File.separator))) + { + _lastSkinDir = _lastSkinDir + File.separator; + } + return _lastSkinDir; + } + + /** + * Sets last skin directory. + */ + public void setLastSkinDir(String dir) + { + _lastSkinDir = dir; + if ((_lastSkinDir != null) && (!_lastSkinDir.endsWith(File.separator))) + { + _lastSkinDir = _lastSkinDir + File.separator; + } + } + + /** + * Returns audio extensions. + */ + public String getExtensions() + { + return _extensions; + } + + /** + * Returns proxy server. + */ + public String getProxyServer() + { + return _proxyServer; + } + + /** + * Returns proxy port. + */ + public int getProxyPort() + { + return _proxyPort; + } + + /** + * Returns volume value. + */ + public int getVolume() + { + return _volume; + } + + /** + * Returns volume value. + */ + public void setVolume(int vol) + { + _volume = vol; + } + + /** + * Returns X location. + */ + public int getXLocation() + { + return _x; + } + + /** + * Returns Y location. + */ + public int getYLocation() + { + return _y; + } + + /** + * Sets X,Y location. + */ + public void setLocation(int x, int y) + { + _x = x; + _y = y; + } + + /** + * Sets Proxy info. + */ + public void setProxy(String url, int port, String login, String password) + { + _proxyServer = url; + _proxyPort = port; + _proxyLogin = login; + _proxyPassword = password; + } + + /** + * Enables Proxy. + */ + public boolean enableProxy() + { + if ((_proxyServer != null) && (!_proxyServer.equals(""))) + { + System.getProperties().put("proxySet", "true"); + System.getProperties().put("proxyHost", _proxyServer); + System.getProperties().put("proxyPort", "" + _proxyPort); + return true; + } + else return false; + } + + /** + * Returns PlaylistUI state. + */ + public boolean isPlaylistEnabled() + { + return _playlistEnabled; + } + + /** + * Sets PlaylistUI state. + */ + public void setPlaylistEnabled(boolean ena) + { + _playlistEnabled = ena; + } + + /** + * Returns ShuffleUI state. + */ + public boolean isShuffleEnabled() + { + return _shuffleEnabled; + } + + /** + * Sets ShuffleUI state. + */ + public void setShuffleEnabled(boolean ena) + { + _shuffleEnabled = ena; + } + + /** + * Returns RepeatUI state. + */ + public boolean isRepeatEnabled() + { + return _repeatEnabled; + } + + /** + * Sets RepeatUI state. + */ + public void setRepeatEnabled(boolean ena) + { + _repeatEnabled = ena; + } + + /** + * Returns EqualizerUI state. + */ + public boolean isEqualizerEnabled() + { + return _equalizerEnabled; + } + + /** + * Sets EqualizerUI state. + */ + public void setEqualizerEnabled(boolean ena) + { + _equalizerEnabled = ena; + } + + /** + * Returns default skin. + */ + public String getDefaultSkin() + { + return _defaultSkin; + } + + /** + * Sets default skin. + */ + public void setDefaultSkin(String skin) + { + _defaultSkin = skin; + } + + /** + * Returns playlist classname implementation. + */ + public String getPlaylistClassName() + { + return _playlist; + } + + /** + * Set playlist classname implementation. + */ + public void setPlaylistClassName(String s) + { + _playlist = s; + } + + /** + * Returns Mpeg TagInfo classname implementation. + */ + public String getMpegTagInfoClassName() + { + return _taginfoMpeg; + } + + /** + * Returns Ogg Vorbis TagInfo classname implementation. + */ + public String getOggVorbisTagInfoClassName() + { + return _taginfoOggVorbis; + } + + /** + * Returns APE TagInfo classname implementation. + */ + public String getAPETagInfoClassName() + { + return _taginfoAPE; + } + + /** + * Returns Ogg Vorbis TagInfo classname implementation. + */ + public String getFlacTagInfoClassName() + { + return _taginfoFlac; + } + + /** + * Loads configuration for the specified file. + */ + public void load(String configfile) + { + CONFIG_FILE_NAME = configfile; + load(); + } + + /** + * Loads configuration. + */ + public void load() + { + _config = new Configuration(CONFIG_FILE_NAME); + // Creates config entries if needed. + if (_config.get(AUDIO_DEVICE) == null) _config.add(AUDIO_DEVICE, _audioDevice); + if (_config.get(VISUAL_MODE) == null) _config.add(VISUAL_MODE, _visualMode); + if (_config.get(LAST_URL) == null) _config.add(LAST_URL, _lastUrl); + if (_config.get(LAST_EQUALIZER) == null) _config.add(LAST_EQUALIZER, _lastEqualizer); + if (_config.get(LAST_DIR) == null) _config.add(LAST_DIR, _lastDir); + if (_config.get(LAST_SKIN_DIR) == null) _config.add(LAST_SKIN_DIR, _lastSkinDir); + if (_config.get(TAGINFO_POLICY) == null) _config.add(TAGINFO_POLICY, _taginfoPolicy); + if (_config.getInt(ORIGINE_X) == -1) _config.add(ORIGINE_X, _x); + if (_config.getInt(ORIGINE_Y) == -1) _config.add(ORIGINE_Y, _y); + if (_config.get(LAST_SKIN) == null) _config.add(LAST_SKIN, _defaultSkin); + if (_config.get(LAST_PLAYLIST) == null) _config.add(LAST_PLAYLIST, _playlistFilename); + if (_config.get(PLAYLIST_IMPL) == null) _config.add(PLAYLIST_IMPL, _playlist); + if (_config.get(TAGINFO_MPEG_IMPL) == null) _config.add(TAGINFO_MPEG_IMPL, _taginfoMpeg); + if (_config.get(TAGINFO_OGGVORBIS_IMPL) == null) _config.add(TAGINFO_OGGVORBIS_IMPL, _taginfoOggVorbis); + if (_config.get(TAGINFO_APE_IMPL) == null) _config.add(TAGINFO_APE_IMPL, _taginfoAPE); + if (_config.get(TAGINFO_FLAC_IMPL) == null) _config.add(TAGINFO_FLAC_IMPL, _taginfoFlac); + if (_config.get(EXTENSIONS) == null) _config.add(EXTENSIONS, _extensions); + if (_config.get(PROXY_SERVER) == null) _config.add(PROXY_SERVER, _proxyServer); + if (_config.getInt(PROXY_PORT) == -1) _config.add(PROXY_PORT, _proxyPort); + if (_config.getInt(VOLUME_VALUE) == -1) _config.add(VOLUME_VALUE, _volume); + if (_config.get(PROXY_LOGIN) == null) _config.add(PROXY_LOGIN, _proxyLogin); + if (_config.get(PROXY_PASSWORD) == null) _config.add(PROXY_PASSWORD, _proxyPassword); + if (!_config.getBoolean(PLAYLIST_ENABLED)) _config.add(PLAYLIST_ENABLED, _playlistEnabled); + if (!_config.getBoolean(SHUFFLE_ENABLED)) _config.add(SHUFFLE_ENABLED, _shuffleEnabled); + if (!_config.getBoolean(REPEAT_ENABLED)) _config.add(REPEAT_ENABLED, _repeatEnabled); + if (!_config.getBoolean(EQUALIZER_ENABLED)) _config.add(EQUALIZER_ENABLED, _equalizerEnabled); + if (!_config.getBoolean(EQUALIZER_ON)) _config.add(EQUALIZER_ON, _equalizerOn); + if (!_config.getBoolean(EQUALIZER_AUTO)) _config.add(EQUALIZER_AUTO, _equalizerAuto); + if (!_config.getBoolean(SCREEN_LIMIT)) _config.add(SCREEN_LIMIT, _screenLimit); + // Reads config entries + _audioDevice = _config.get(AUDIO_DEVICE, _audioDevice); + _visualMode = _config.get(VISUAL_MODE, _visualMode); + _lastUrl = _config.get(LAST_URL, _lastUrl); + _lastEqualizer = _config.get(LAST_EQUALIZER, _lastEqualizer); + _lastDir = _config.get(LAST_DIR, _lastDir); + _lastSkinDir = _config.get(LAST_SKIN_DIR, _lastSkinDir); + _x = _config.getInt(ORIGINE_X, _x); + _y = _config.getInt(ORIGINE_Y, _y); + _defaultSkin = _config.get(LAST_SKIN, _defaultSkin); + _playlistFilename = _config.get(LAST_PLAYLIST, _playlistFilename); + _taginfoPolicy = _config.get(TAGINFO_POLICY, _taginfoPolicy); + _extensions = _config.get(EXTENSIONS, _extensions); + _playlist = _config.get(PLAYLIST_IMPL, _playlist); + _taginfoMpeg = _config.get(TAGINFO_MPEG_IMPL, _taginfoMpeg); + _taginfoOggVorbis = _config.get(TAGINFO_OGGVORBIS_IMPL, _taginfoOggVorbis); + _taginfoAPE = _config.get(TAGINFO_APE_IMPL, _taginfoAPE); + _taginfoFlac = _config.get(TAGINFO_FLAC_IMPL, _taginfoFlac); + _proxyServer = _config.get(PROXY_SERVER, _proxyServer); + _proxyPort = _config.getInt(PROXY_PORT, _proxyPort); + _volume = _config.getInt(VOLUME_VALUE, _volume); + _proxyLogin = _config.get(PROXY_LOGIN, _proxyLogin); + _proxyPassword = _config.get(PROXY_PASSWORD, _proxyPassword); + _playlistEnabled = _config.getBoolean(PLAYLIST_ENABLED, _playlistEnabled); + _shuffleEnabled = _config.getBoolean(SHUFFLE_ENABLED, _shuffleEnabled); + _repeatEnabled = _config.getBoolean(REPEAT_ENABLED, _repeatEnabled); + _equalizerEnabled = _config.getBoolean(EQUALIZER_ENABLED, _equalizerEnabled); + _equalizerOn = _config.getBoolean(EQUALIZER_ON, _equalizerOn); + _equalizerAuto = _config.getBoolean(EQUALIZER_AUTO, _equalizerAuto); + _screenLimit = _config.getBoolean(SCREEN_LIMIT, _screenLimit); + } + + /** + * Saves configuration. + */ + public void save() + { + if (_config != null) + { + _config.add(ORIGINE_X, _x); + _config.add(ORIGINE_Y, _y); + if (_lastDir != null) _config.add(LAST_DIR, _lastDir); + if (_lastSkinDir != null) _config.add(LAST_SKIN_DIR, _lastSkinDir); + if (_audioDevice != null) _config.add(AUDIO_DEVICE, _audioDevice); + if (_visualMode != null) _config.add(VISUAL_MODE, _visualMode); + if (_lastUrl != null) _config.add(LAST_URL, _lastUrl); + if (_lastEqualizer != null) _config.add(LAST_EQUALIZER, _lastEqualizer); + if (_playlistFilename != null) _config.add(LAST_PLAYLIST, _playlistFilename); + if (_playlist != null) _config.add(PLAYLIST_IMPL, _playlist); + if (_defaultSkin != null) _config.add(LAST_SKIN, _defaultSkin); + if (_taginfoPolicy != null) _config.add(TAGINFO_POLICY, _taginfoPolicy); + if (_volume != -1) _config.add(VOLUME_VALUE, _volume); + _config.add(PLAYLIST_ENABLED, _playlistEnabled); + _config.add(SHUFFLE_ENABLED, _shuffleEnabled); + _config.add(REPEAT_ENABLED, _repeatEnabled); + _config.add(EQUALIZER_ENABLED, _equalizerEnabled); + _config.add(EQUALIZER_ON, _equalizerOn); + _config.add(EQUALIZER_AUTO, _equalizerAuto); + _config.add(SCREEN_LIMIT, _screenLimit); + _config.save(); + } + } + + /** + * @return equalizer auto flag + */ + public boolean isEqualizerAuto() + { + return _equalizerAuto; + } + + /** + * @return equalizer on flag + */ + public boolean isEqualizerOn() + { + return _equalizerOn; + } + + /** + * @param b + */ + public void setEqualizerAuto(boolean b) + { + _equalizerAuto = b; + } + + /** + * @param b + */ + public void setEqualizerOn(boolean b) + { + _equalizerOn = b; + } + + public static boolean startWithProtocol(String input) + { + boolean ret = false; + if (input != null) + { + input = input.toLowerCase(); + for (int i = 0; i < protocols.length; i++) + { + if (input.startsWith(protocols[i])) + { + ret = true; + break; + } + } + } + return ret; + } + + /** + * @return tag info policy + */ + public String getTaginfoPolicy() + { + return _taginfoPolicy; + } + + /** + * @param string + */ + public void setTaginfoPolicy(String string) + { + _taginfoPolicy = string; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileNameFilter.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileNameFilter.java new file mode 100644 index 0000000..a9d0b3d --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileNameFilter.java @@ -0,0 +1,108 @@ +/* + * FileNameFilter. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.StringTokenizer; + +/** + * FileName filter that works for both javax.swing.filechooser and java.io. + */ +public class FileNameFilter extends javax.swing.filechooser.FileFilter implements java.io.FileFilter +{ + protected java.util.List extensions = new ArrayList(); + protected String default_extension = null; + protected String description; + protected boolean allowDir = true; + + /** + * Constructs the list of extensions out of a string of comma-separated + * elements, each of which represents one extension. + * + * @param ext the list of comma-separated extensions + */ + public FileNameFilter(String ext, String description) + { + this(ext, description, true); + } + + public FileNameFilter(String ext, String description, boolean allowDir) + { + this.description = description; + this.allowDir = allowDir; + StringTokenizer st = new StringTokenizer(ext, ", "); + String extension; + while (st.hasMoreTokens()) + { + extension = st.nextToken(); + extensions.add(extension); + if (default_extension == null) default_extension = extension; + } + } + + /** + * determines if the filename is an acceptable one. If a + * filename ends with one of the extensions the filter was + * initialized with, then the function returns true. if not, + * the function returns false. + * + * @param dir the directory the file is in + * @return true if the filename has a valid extension, false otherwise + */ + public boolean accept(File dir) + { + for (int i = 0; i < extensions.size(); i++) + { + if (allowDir) + { + if (dir.isDirectory() || dir.getName().endsWith("." + (String) extensions.get(i))) return true; + } + else + { + if (dir.getName().endsWith("." + (String) extensions.get(i))) return true; + } + } + return extensions.size() == 0; + } + + /** + * Returns the default extension. + * + * @return the default extension + */ + public String getDefaultExtension() + { + return default_extension; + } + + public void setDefaultExtension(String ext) + { + default_extension = ext; + } + + public String getDescription() + { + return description; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileSelector.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileSelector.java new file mode 100644 index 0000000..e022633 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileSelector.java @@ -0,0 +1,156 @@ +/* + * FileSelector. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util; + +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.JFrame; +import javazoom.jlgui.player.amp.Loader; + +/** + * This class is used to select a file or directory for loading or saving. + */ +public class FileSelector +{ + public static final int OPEN = 1; + public static final int SAVE = 2; + public static final int SAVE_AS = 3; + public static final int DIRECTORY = 4; + private File[] files = null; + private File directory = null; + private static FileSelector instance = null; + + public File[] getFiles() + { + return files; + } + + public File getDirectory() + { + return directory; + } + + public static final FileSelector getInstance() + { + if (instance == null) instance = new FileSelector(); + return instance; + } + + /** + * Opens a dialog box so that the user can search for a file + * with the given extension and returns the filename selected. + * + * @param extensions the extension of the filename to be selected, + * or "" if any filename can be used + * @param directory the folder to be put in the starting directory + * @param mode the action that will be performed on the file, used to tell what + * files are valid + * @return the selected file + */ + public static File[] selectFile(Loader loader, int mode, boolean multiple, String extensions, String description, File directory) + { + return selectFile(loader, mode, multiple, null, extensions, description, null, directory); + } + + /** + * Opens a dialog box so that the user can search for a file + * with the given extension and returns the filename selected. + * + * @param extensions the extension of the filename to be selected, + * or "" if any filename can be used + * @param titlePrefix the string to be put in the title, followed by : SaveAs + * @param mode the action that will be performed on the file, used to tell what + * files are valid + * @param defaultFile the default file + * @param directory the string to be put in the starting directory + * @return the selected filename + */ + public static File[] selectFile(Loader loader, int mode, boolean multiple, File defaultFile, String extensions, String description, String titlePrefix, File directory) + { + JFrame mainWindow = null; + if (loader instanceof JFrame) + { + mainWindow = (JFrame) loader; + } + JFileChooser filePanel = new JFileChooser(); + StringBuffer windowTitle = new StringBuffer(); + if (titlePrefix != null && titlePrefix.length() > 0) windowTitle.append(titlePrefix).append(": "); + switch (mode) + { + case OPEN: + windowTitle.append("Open"); + break; + case SAVE: + windowTitle.append("Save"); + break; + case SAVE_AS: + windowTitle.append("Save As"); + break; + case DIRECTORY: + windowTitle.append("Choose Directory"); + break; + } + filePanel.setDialogTitle(windowTitle.toString()); + FileNameFilter filter = new FileNameFilter(extensions, description); + filePanel.setFileFilter(filter); + if (defaultFile != null) filePanel.setSelectedFile(defaultFile); + if (directory != null) filePanel.setCurrentDirectory(directory); + filePanel.setMultiSelectionEnabled(multiple); + int retVal = -1; + switch (mode) + { + case OPEN: + filePanel.setDialogType(JFileChooser.OPEN_DIALOG); + retVal = filePanel.showOpenDialog(mainWindow); + break; + case SAVE: + filePanel.setDialogType(JFileChooser.SAVE_DIALOG); + retVal = filePanel.showSaveDialog(mainWindow); + break; + case SAVE_AS: + filePanel.setDialogType(JFileChooser.SAVE_DIALOG); + retVal = filePanel.showSaveDialog(mainWindow); + break; + case DIRECTORY: + filePanel.setDialogType(JFileChooser.SAVE_DIALOG); + filePanel.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + retVal = filePanel.showDialog(mainWindow, "Select"); + break; + } + if (retVal == JFileChooser.APPROVE_OPTION) + { + if (multiple) getInstance().files = filePanel.getSelectedFiles(); + else + { + getInstance().files = new File[1]; + getInstance().files[0] = filePanel.getSelectedFile(); + } + getInstance().directory = filePanel.getCurrentDirectory(); + } + else + { + getInstance().files = null; + } + return getInstance().files; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileUtil.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileUtil.java new file mode 100644 index 0000000..e3a9c1c --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileUtil.java @@ -0,0 +1,167 @@ +/* + * FileUtil. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.StringTokenizer; + +/** + * @author Scott Pennell + */ +public class FileUtil +{ + private static List supportedExtensions = null; + + public static File[] findFilesRecursively(File directory) + { + if (directory.isFile()) + { + File[] f = new File[1]; + f[0] = directory; + return f; + } + List list = new ArrayList(); + addSongsRecursive(list, directory); + return ((File[]) list.toArray(new File[list.size()])); + } + + private static void addSongsRecursive(List found, File rootDir) + { + if (rootDir == null) return; // we do not want waste time + File[] files = rootDir.listFiles(); + if (files == null) return; + for (int i = 0; i < files.length; i++) + { + File file = new File(rootDir, files[i].getName()); + if (file.isDirectory()) addSongsRecursive(found, file); + else + { + if (isMusicFile(files[i])) + { + found.add(file); + } + } + } + } + + public static boolean isMusicFile(File f) + { + List exts = getSupportedExtensions(); + int sz = exts.size(); + String ext; + String name = f.getName(); + for (int i = 0; i < sz; i++) + { + ext = (String) exts.get(i); + if (ext.equals(".wsz") || ext.equals(".m3u")) continue; + if (name.endsWith(ext)) return true; + } + return false; + } + + public static List getSupportedExtensions() + { + if (supportedExtensions == null) + { + String ext = Config.getInstance().getExtensions(); + StringTokenizer st = new StringTokenizer(ext, ","); + supportedExtensions = new ArrayList(); + while (st.hasMoreTokens()) + supportedExtensions.add("." + st.nextElement()); + } + return (supportedExtensions); + } + + public static String getSupprtedExtensions() + { + List exts = getSupportedExtensions(); + StringBuffer s = new StringBuffer(); + int sz = exts.size(); + String ext; + for (int i = 0; i < sz; i++) + { + ext = (String) exts.get(i); + if (ext.equals(".wsz") || ext.equals(".m3u")) continue; + if (i == 0) s.append(ext); + else s.append(";").append(ext); + } + return s.toString(); + } + + public static String padString(String s, int length) + { + return padString(s, ' ', length); + } + + public static String padString(String s, char padChar, int length) + { + int slen, numPads = 0; + if (s == null) + { + s = ""; + numPads = length; + } + else if ((slen = s.length()) > length) + { + s = s.substring(0, length); + } + else if (slen < length) + { + numPads = length - slen; + } + if (numPads == 0) return s; + char[] c = new char[numPads]; + Arrays.fill(c, padChar); + return s + new String(c); + } + + public static String rightPadString(String s, int length) + { + return (rightPadString(s, ' ', length)); + } + + public static String rightPadString(String s, char padChar, int length) + { + int slen, numPads = 0; + if (s == null) + { + s = ""; + numPads = length; + } + else if ((slen = s.length()) > length) + { + s = s.substring(length); + } + else if (slen < length) + { + numPads = length - slen; + } + if (numPads == 0) return (s); + char[] c = new char[numPads]; + Arrays.fill(c, padChar); + return new String(c) + s; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Alphabetizer.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Alphabetizer.java new file mode 100644 index 0000000..cf82fa1 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Alphabetizer.java @@ -0,0 +1,79 @@ +/* + * Alphabetizer. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ini; + +/** + * This class alphabetizes strings. + * + * @author Matt "Spiked Bat" Segur + */ +public class Alphabetizer +{ + public static boolean lessThan(String str1, String str2) + { + return compare(str1, str2) < 0; + } + + public static boolean greaterThan(String str1, String str2) + { + return compare(str1, str2) > 0; + } + + public static boolean equalTo(String str1, String str2) + { + return compare(str1, str2) == 0; + } + + /** + * Performs a case-insensitive comparison of the two strings. + */ + public static int compare(String s1, String s2) + { + if (s1 == null && s2 == null) return 0; + else if (s1 == null) return -1; + else if (s2 == null) return +1; + int len1 = s1.length(); + int len2 = s2.length(); + int len = Math.min(len1, len2); + for (int i = 0; i < len; i++) + { + int comparison = compare(s1.charAt(i), s2.charAt(i)); + if (comparison != 0) return comparison; + } + if (len1 < len2) return -1; + else if (len1 > len2) return +1; + else return 0; + } + + /** + * Performs a case-insensitive comparison of the two characters. + */ + public static int compare(char c1, char c2) + { + if (65 <= c1 && c1 <= 91) c1 += 32; + if (65 <= c2 && c2 <= 91) c2 += 32; + if (c1 < c2) return -1; + else if (c1 > c2) return +1; + else return 0; + } +} \ No newline at end of file diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Array.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Array.java new file mode 100644 index 0000000..1665358 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Array.java @@ -0,0 +1,114 @@ +/* + * Array. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ini; + +/** + * This class represents an array of objects. + * + * @author Jeremy Cloud + * @version 1.0.0 + */ +public class Array +{ + public static Object[] copy(Object[] sors, Object[] dest) + { + System.arraycopy(sors, 0, dest, 0, sors.length); + return dest; + } + + public static String[] doubleArray(String[] sors) + { + System.out.print("** doubling string array... "); + int new_size = (sors.length <= 8 ? 16 : sors.length << 1); + String[] dest = new String[new_size]; + System.arraycopy(sors, 0, dest, 0, sors.length); + System.out.println("done **."); + return dest; + } + + public static int[] doubleArray(int[] sors) + { + int new_size = (sors.length < 8 ? 16 : sors.length << 1); + int[] dest = new int[new_size]; + System.arraycopy(sors, 0, dest, 0, sors.length); + return dest; + } + + public static int[] grow(int[] sors, double growth_rate) + { + int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1); + int[] dest = new int[new_size]; + System.arraycopy(sors, 0, dest, 0, sors.length); + return dest; + } + + public static boolean[] grow(boolean[] sors, double growth_rate) + { + int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1); + boolean[] dest = new boolean[new_size]; + System.arraycopy(sors, 0, dest, 0, sors.length); + return dest; + } + + public static Object[] grow(Object[] sors, double growth_rate) + { + int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1); + Object[] dest = new Object[new_size]; + System.arraycopy(sors, 0, dest, 0, sors.length); + return dest; + } + + public static String[] grow(String[] sors, double growth_rate) + { + int new_size = Math.max((int) (sors.length * growth_rate), sors.length + 1); + String[] dest = new String[new_size]; + System.arraycopy(sors, 0, dest, 0, sors.length); + return dest; + } + + /** + * @param start - inclusive + * @param end - exclusive + */ + public static void shiftUp(Object[] array, int start, int end) + { + int count = end - start; + if (count > 0) System.arraycopy(array, start, array, start + 1, count); + } + + /** + * @param start - inclusive + * @param end - exclusive + */ + public static void shiftDown(Object[] array, int start, int end) + { + int count = end - start; + if (count > 0) System.arraycopy(array, start, array, start - 1, count); + } + + public static void shift(Object[] array, int start, int amount) + { + int count = array.length - start - (amount > 0 ? amount : 0); + System.arraycopy(array, start, array, start + amount, count); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/CRC32OutputStream.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/CRC32OutputStream.java new file mode 100644 index 0000000..d35a6bf --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/CRC32OutputStream.java @@ -0,0 +1,50 @@ +/* + * CRC32OutputStream. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ini; + +import java.io.OutputStream; +import java.util.zip.CRC32; + +/** + * @author Jeremy Cloud + * @version 1.0.0 + */ +public class CRC32OutputStream extends OutputStream +{ + private CRC32 crc; + + public CRC32OutputStream() + { + crc = new CRC32(); + } + + public void write(int new_byte) + { + crc.update(new_byte); + } + + public long getValue() + { + return crc.getValue(); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Configuration.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Configuration.java new file mode 100644 index 0000000..48e0720 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Configuration.java @@ -0,0 +1,441 @@ +/* + * Configuration. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ini; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.URL; +import java.util.Enumeration; +import java.util.Hashtable; +import javazoom.jlgui.player.amp.util.Config; + +/** + * A Configuration is used to save a set of configuration + * properties. The properties can be written out to disk + * in "name=value" form, and read back in. + * + * @author Jeremy Cloud + * @version 1.2.0 + */ +public class Configuration +{ + private File config_file = null; + private URL config_url = null; + private Hashtable props = new Hashtable(64); + + /** + * Constructs a new Configuration object that stores + * it's properties in the file with the given name. + */ + public Configuration(String file_name) + { + // E.B - URL support + if (Config.startWithProtocol(file_name)) + { + try + { + this.config_url = new URL(file_name); + } + catch (Exception e) + { + e.printStackTrace(); + } + load(); + } + else + { + this.config_file = new File(file_name); + load(); + } + } + + /** + * Constructs a new Configuration object that stores + * it's properties in the given file. + */ + public Configuration(File config_file) + { + this.config_file = config_file; + load(); + } + + /** + * Constructs a new Configuration object that stores + * it's properties in the given file. + */ + public Configuration(URL config_file) + { + this.config_url = config_file; + load(); + } + + /** + * Constructs a new Configuration object that doesn't + * have a file associated with it. + */ + public Configuration() + { + this.config_file = null; + } + + /** + * @return The config file. + */ + public File getConfigFile() + { + return config_file; + } + + /** + * Adds a the property with the given name and value. + * + * @param name The name of the property. + * @param value The value of the property. + */ + public void add(String name, String value) + { + props.put(name, value); + } + + /** + * Adds the boolean property. + * + * @param name The name of the property. + * @param value The value of the property. + */ + public void add(String name, boolean value) + { + props.put(name, value ? "true" : "false"); + } + + /** + * Adds the integer property. + * + * @param name The name of the property. + * @param value The value of the property. + */ + public void add(String name, int value) + { + props.put(name, Integer.toString(value)); + } + + /** + * Adds the double property. + * + * @param name The name of the property. + * @param value The value of the property. + */ + public void add(String name, double value) + { + props.put(name, Double.toString(value)); + } + + /** + * Returns the value of the property with the + * given name. Null is returned if the named + * property is not found. + * + * @param The name of the desired property. + * @return The value of the property. + */ + public String get(String name) + { + return (String) props.get(name); + } + + /** + * Returns the value of the property with the + * given name. 'default_value' is returned if the + * named property is not found. + * + * @param The name of the desired property. + * @param default_value The default value of the property which is returned + * if the property does not have a specified value. + * @return The value of the property. + */ + public String get(String name, String default_value) + { + Object value = props.get(name); + return value != null ? (String) value : default_value; + } + + /** + * Returns the value of the property with the given name. + * 'false' is returned if the property does not have a + * specified value. + * + * @param name The name of the desired property. + * @param return The value of the property. + */ + public boolean getBoolean(String name) + { + Object value = props.get(name); + return value != null ? value.equals("true") : false; + } + + /** + * Returns the value of the property with the given name. + * + * @param name The name of the desired property. + * @param default_value The default value of the property which is returned + * if the property does not have a specified value. + * @param return The value of the property. + */ + public boolean getBoolean(String name, boolean default_value) + { + Object value = props.get(name); + return value != null ? value.equals("true") : default_value; + } + + /** + * Returns the value of the property with the given name. + * '0' is returned if the property does not have a + * specified value. + * + * @param name The name of the desired property. + * @param return The value of the property. + */ + public int getInt(String name) + { + try + { + return Integer.parseInt((String) props.get(name)); + } + catch (Exception e) + { + } + return -1; + } + + /** + * Returns the value of the property with the given name. + * + * @param name The name of the desired property. + * @param default_value The default value of the property which is returned + * if the property does not have a specified value. + * @param return The value of the property. + */ + public int getInt(String name, int default_value) + { + try + { + return Integer.parseInt((String) props.get(name)); + } + catch (Exception e) + { + } + return default_value; + } + + /** + * Returns the value of the property with the given name. + * '0' is returned if the property does not have a + * specified value. + * + * @param name The name of the desired property. + * @param return The value of the property. + */ + public double getDouble(String name) + { + try + { + return new Double((String) props.get(name)).doubleValue(); + } + catch (Exception e) + { + } + return -1d; + } + + /** + * Returns the value of the property with the given name. + * + * @param name The name of the desired property. + * @param default_value The default value of the property which is returned + * if the property does not have a specified value. + * @param return The value of the property. + */ + public double getDouble(String name, double default_value) + { + try + { + return new Double((String) props.get(name)).doubleValue(); + } + catch (Exception e) + { + } + return default_value; + } + + /** + * Removes the property with the given name. + * + * @param name The name of the property to remove. + */ + public void remove(String name) + { + props.remove(name); + } + + /** + * Removes all the properties. + */ + public void removeAll() + { + props.clear(); + } + + /** + * Loads the property list from the configuration file. + * + * @return True if the file was loaded successfully, false if + * the file does not exists or an error occurred reading + * the file. + */ + public boolean load() + { + if ((config_file == null) && (config_url == null)) return false; + // Loads from URL. + if (config_url != null) + { + try + { + return load(new BufferedReader(new InputStreamReader(config_url.openStream()))); + } + catch (IOException e) + { + e.printStackTrace(); + return false; + } + } + // Loads from file. + else + { + if (!config_file.exists()) return false; + try + { + return load(new BufferedReader(new FileReader(config_file))); + } + catch (IOException e) + { + e.printStackTrace(); + return false; + } + } + } + + public boolean load(BufferedReader buffy) throws IOException + { + Hashtable props = this.props; + String line = null; + while ((line = buffy.readLine()) != null) + { + int eq_idx = line.indexOf('='); + if (eq_idx > 0) + { + String name = line.substring(0, eq_idx).trim(); + String value = line.substring(eq_idx + 1).trim(); + props.put(name, value); + } + } + buffy.close(); + return true; + } + + /** + * Saves the property list to the config file. + * + * @return True if the save was successful, false othewise. + */ + public boolean save() + { + if (config_url != null) return false; + try + { + PrintWriter out = new PrintWriter(new FileWriter(config_file)); + return save(out); + } + catch (IOException e) + { + e.printStackTrace(); + return false; + } + } + + public boolean save(PrintWriter out) throws IOException + { + Hashtable props = this.props; + Enumeration names = props.keys(); + SortedStrings sorter = new SortedStrings(); + while (names.hasMoreElements()) + { + sorter.add((String) names.nextElement()); + } + for (int i = 0; i < sorter.stringCount(); i++) + { + String name = sorter.stringAt(i); + String value = (String) props.get(name); + out.print(name); + out.print("="); + out.println(value); + } + out.close(); + return true; + } + + public void storeCRC() + { + add("crc", generateCRC()); + } + + public boolean isValidCRC() + { + String crc = generateCRC(); + String stored_crc = (String) props.get("crc"); + if (stored_crc == null) return false; + return stored_crc.equals(crc); + } + + private String generateCRC() + { + Hashtable props = this.props; + CRC32OutputStream crc = new CRC32OutputStream(); + PrintWriter pr = new PrintWriter(crc); + Enumeration names = props.keys(); + while (names.hasMoreElements()) + { + String name = (String) names.nextElement(); + if (!name.equals("crc")) + { + pr.println((String) props.get(name)); + } + } + pr.flush(); + return "" + crc.getValue(); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/SortedStrings.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/SortedStrings.java new file mode 100644 index 0000000..32c6204 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/SortedStrings.java @@ -0,0 +1,338 @@ +/* + * SortedStrings. + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ini; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +/** + * An object that represents an array of alpabetized Strings. Implemented + * with an String array that grows as appropriate. + */ +public class SortedStrings extends Alphabetizer implements Cloneable +{ + public static final int DEFAULT_SIZE = 32; + private String[] strings; + private int string_count; + private double growth_rate = 2.0; + + /** + * Constructor creates a new SortedStrings object of default + * size. + */ + public SortedStrings() + { + clear(); + } + + /** + * Constructor creates a new SortedStrings object of size passed. + */ + public SortedStrings(int initial_size) + { + clear(initial_size); + } + + /** + * Contructor creates a new SortedStrings object using a DataInput + * object. The first int in the DataInput object is assumed to be + * the size wanted for the SortedStrings object. + */ + public SortedStrings(DataInput in) throws IOException + { + int count = string_count = in.readInt(); + String[] arr = strings = new String[count]; + for (int i = 0; i < count; i++) + arr[i] = in.readUTF(); + } + + /** + * Contructor creates a new SortedStrings object, initializing it + * with the String[] passed. + */ + public SortedStrings(String[] array) + { + this(array.length); + int new_size = array.length; + for (int i = 0; i < new_size; i++) + add(array[i]); + } + + /** + * Clones the SortedStrings object. + */ + public Object clone() + { + try + { + SortedStrings clone = (SortedStrings) super.clone(); + clone.strings = (String[]) strings.clone(); + return clone; + } + catch (CloneNotSupportedException e) + { + return null; + } + } + + /** + * Writes a the SortedStrings object to the DataOutput object. + */ + public void emit(DataOutput out) throws IOException + { + int count = string_count; + String[] arr = strings; + out.writeInt(count); + for (int i = 0; i < count; i++) + out.writeUTF(arr[i]); + } + + /** + * Merge two sorted lists of integers. The time complexity of + * the merge is O(n). + */ + public SortedStrings merge(SortedStrings that) + { + int count1 = this.string_count; + int count2 = that.string_count; + String[] ints1 = this.strings; + String[] ints2 = that.strings; + String num1, num2; + int i1 = 0, i2 = 0; + SortedStrings res = new SortedStrings(count1 + count2); + while (i1 < count1 && i2 < count2) + { + num1 = ints1[i1]; + num2 = ints2[i2]; + if (compare(num1, num2) < 0) + { + res.add(num1); + i1++; + } + else if (compare(num2, num1) < 0) + { + res.add(num2); + i2++; + } + else + { + res.add(num1); + i1++; + i2++; + } + } + if (i1 < count1) + { + for (; i1 < count1; i1++) + res.add(ints1[i1]); + } + else for (; i2 < count2; i2++) + res.add(ints2[i2]); + return res; + } + + /** + * Returns a SortedStrings object that has the Strings + * from this object that are not in the one passed. + */ + public SortedStrings diff(SortedStrings that) + { + int count1 = this.string_count; + int count2 = that.string_count; + String[] ints1 = this.strings; + String[] ints2 = that.strings; + String num1, num2; + int i1 = 0, i2 = 0; + SortedStrings res = new SortedStrings(count1); + while (i1 < count1 && i2 < count2) + { + num1 = ints1[i1]; + num2 = ints2[i2]; + if (compare(num1, num2) < 0) + { + res.add(num1); + i1++; + } + else if (compare(num2, num1) < 0) i2++; + else + { + i1++; + i2++; + } + } + if (i1 < count1) + { + for (; i1 < count1; i1++) + res.add(ints1[i1]); + } + return res; + } + + /** + * Clears the Strings from the object and creates a new one + * of the default size. + */ + public void clear() + { + clear(DEFAULT_SIZE); + } + + /** + * Clears the Strings from the object and creates a new one + * of the size passed. + */ + public void clear(int initial_size) + { + strings = new String[initial_size]; + string_count = 0; + } + + /** + * Adds the String passed to the array in its proper place -- sorted. + */ + public void add(String num) + { + if (string_count == 0 || greaterThan(num, strings[string_count - 1])) + { + if (string_count == strings.length) strings = (String[]) Array.grow(strings, growth_rate); + strings[string_count] = num; + string_count++; + } + else insert(search(num), num); + } + + /** + * Inserts the String passed to the array at the index passed. + */ + private void insert(int index, String num) + { + if (strings[index] == num) return; + else + { + if (string_count == strings.length) strings = (String[]) Array.grow(strings, growth_rate); + System.arraycopy(strings, index, strings, index + 1, string_count - index); + strings[index] = num; + string_count++; + } + } + + /** + * Removes the String passed from the array. + */ + public void remove(String num) + { + int index = search(num); + if (index < string_count && equalTo(strings[index], num)) removeIndex(index); + } + + /** + * Removes the String from the beginning of the array to the + * index passed. + */ + public void removeIndex(int index) + { + if (index < string_count) + { + System.arraycopy(strings, index + 1, strings, index, string_count - index - 1); + string_count--; + } + } + + /** + * Returns true flag if the String passed is in the array. + */ + public boolean contains(String num) + { + int index = search(num); + return index < string_count && equalTo(strings[search(num)], num); + } + + /** + * Returns the number of Strings in the array. + */ + public int stringCount() + { + return string_count; + } + + /** + * Returns String index of the int passed. + */ + public int indexOf(String num) + { + int index = search(num); + return index < string_count && equalTo(strings[index], num) ? index : -1; + } + + /** + * Returns the String value at the index passed. + */ + public String stringAt(int index) + { + return strings[index]; + } + + /** + * Returns the index where the String value passed is located + * or where it should be sorted to if it is not present. + */ + protected int search(String num) + { + String[] strings = this.strings; + int lb = 0, ub = string_count, index; + String index_key; + while (true) + { + if (lb >= ub - 1) + { + if (lb < string_count && !greaterThan(num, strings[lb])) return lb; + else return lb + 1; + } + index = (lb + ub) / 2; + index_key = strings[index]; + if (greaterThan(num, index_key)) lb = index + 1; + else if (lessThan(num, index_key)) ub = index; + else return index; + } + } + + /** + * Returns an String[] that contains the value in the SortedStrings + * object. + */ + public String[] toStringArray() + { + String[] array = new String[string_count]; + System.arraycopy(strings, 0, array, 0, string_count); + return array; + } + + /** + * Returns a sorted String[] from the String[] passed. + */ + public static String[] sort(String[] input) + { + SortedStrings new_strings = new SortedStrings(input); + return new_strings.toStringArray(); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/DevicePreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/DevicePreference.java new file mode 100644 index 0000000..481bffe --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/DevicePreference.java @@ -0,0 +1,120 @@ +/* + * DevicePreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.MessageFormat; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javazoom.jlgui.basicplayer.BasicController; +import javazoom.jlgui.basicplayer.BasicPlayer; + +public class DevicePreference extends PreferenceItem implements ActionListener +{ + private BasicPlayer bplayer = null; + private static DevicePreference instance = null; + + private DevicePreference() + { + } + + public static DevicePreference getInstance() + { + if (instance == null) + { + instance = new DevicePreference(); + } + return instance; + } + + public void loadUI() + { + removeAll(); + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/device"); + setBorder(new TitledBorder(getResource("title"))); + BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS); + setLayout(layout); + BasicController controller = null; + if (player != null) controller = player.getController(); + if ((controller != null) && (controller instanceof BasicPlayer)) + { + bplayer = (BasicPlayer) controller; + List devices = bplayer.getMixers(); + String mixer = bplayer.getMixerName(); + ButtonGroup group = new ButtonGroup(); + Iterator it = devices.iterator(); + while (it.hasNext()) + { + String name = (String) it.next(); + JRadioButton radio = new JRadioButton(name); + if (name.equals(mixer)) + { + radio.setSelected(true); + } + else + { + radio.setSelected(false); + } + group.add(radio); + radio.addActionListener(this); + radio.setAlignmentX(Component.LEFT_ALIGNMENT); + add(radio); + } + JPanel lineInfo = new JPanel(); + lineInfo.setLayout(new BoxLayout(lineInfo, BoxLayout.Y_AXIS)); + lineInfo.setAlignmentX(Component.LEFT_ALIGNMENT); + lineInfo.setBorder(new EmptyBorder(4, 6, 0, 0)); + if (getResource("line.buffer.size") != null) + { + Object[] args = { new Integer(bplayer.getLineCurrentBufferSize()) }; + String str = MessageFormat.format(getResource("line.buffer.size"), args); + JLabel lineBufferSizeLabel = new JLabel(str); + lineInfo.add(lineBufferSizeLabel); + } + if (getResource("help") != null) + { + lineInfo.add(Box.createRigidArea(new Dimension(0, 30))); + JLabel helpLabel = new JLabel(getResource("help")); + lineInfo.add(helpLabel); + } + add(lineInfo); + } + } + + public void actionPerformed(ActionEvent ev) + { + if (bplayer != null) bplayer.setMixerName(ev.getActionCommand()); + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/EmptyPreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/EmptyPreference.java new file mode 100644 index 0000000..90ee4cd --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/EmptyPreference.java @@ -0,0 +1,52 @@ +/* + * EmptyPreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import javax.swing.border.TitledBorder; + +public class EmptyPreference extends PreferenceItem +{ + private static EmptyPreference instance = null; + + private EmptyPreference() + { + } + + public static EmptyPreference getInstance() + { + if (instance == null) + { + instance = new EmptyPreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + setBorder(new TitledBorder("")); + loaded = true; + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/NodeItem.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/NodeItem.java new file mode 100644 index 0000000..502d9bf --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/NodeItem.java @@ -0,0 +1,46 @@ +/* + * NodeItem. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +public class NodeItem +{ + private String name = null; + private String impl = null; + + public NodeItem(String name, String impl) + { + super(); + this.name = name; + this.impl = impl; + } + + public String getImpl() + { + return impl; + } + + public String toString() + { + return name; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/OutputPreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/OutputPreference.java new file mode 100644 index 0000000..903f70c --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/OutputPreference.java @@ -0,0 +1,54 @@ +/* + * OutputPreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.util.ResourceBundle; +import javax.swing.border.TitledBorder; + +public class OutputPreference extends PreferenceItem +{ + private static OutputPreference instance = null; + + private OutputPreference() + { + } + + public static OutputPreference getInstance() + { + if (instance == null) + { + instance = new OutputPreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/output"); + setBorder(new TitledBorder(getResource("title"))); + loaded = true; + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/PreferenceItem.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/PreferenceItem.java new file mode 100644 index 0000000..979fcf6 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/PreferenceItem.java @@ -0,0 +1,78 @@ +/* + * PreferenceItem. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javazoom.jlgui.player.amp.PlayerUI; + +public abstract class PreferenceItem extends JPanel +{ + protected PlayerUI player = null; + protected ResourceBundle bundle = null; + protected boolean loaded = false; + protected JFrame parent = null; + + /** + * Return I18N value of a given key. + * @param key + * @return + */ + public String getResource(String key) + { + String value = null; + if (key != null) + { + try + { + value = bundle.getString(key); + } + catch (MissingResourceException e) + { + } + } + return value; + } + + + public void setPlayer(PlayerUI player) + { + this.player = player; + } + + public JFrame getParentFrame() + { + return parent; + } + + + public void setParentFrame(JFrame parent) + { + this.parent = parent; + } + + + public abstract void loadUI(); +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/Preferences.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/Preferences.java new file mode 100644 index 0000000..d1c61aa --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/Preferences.java @@ -0,0 +1,279 @@ +/* + * Preferences. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.awt.BorderLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Method; +import java.util.MissingResourceException; +import java.util.ResourceBundle; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTree; +import javax.swing.border.EmptyBorder; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import javazoom.jlgui.player.amp.PlayerUI; +import javazoom.jlgui.player.amp.util.Config; + +public class Preferences extends JFrame implements TreeSelectionListener, ActionListener +{ + private static Preferences instance = null; + private JTree tree = null; + private ResourceBundle bundle = null; + private DefaultMutableTreeNode options = null; + private DefaultMutableTreeNode filetypes = null; + private DefaultMutableTreeNode device = null; + private DefaultMutableTreeNode proxy = null; + private DefaultMutableTreeNode plugins = null; + private DefaultMutableTreeNode visual = null; + private DefaultMutableTreeNode visuals = null; + private DefaultMutableTreeNode output = null; + //private DefaultMutableTreeNode drm = null; + private DefaultMutableTreeNode skins = null; + private DefaultMutableTreeNode browser = null; + private JScrollPane treePane = null; + private JScrollPane workPane = null; + private JButton close = null; + private PlayerUI player = null; + + public Preferences(PlayerUI player) + { + super(); + this.player = player; + setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + ImageIcon icon = Config.getInstance().getIconParent(); + if (icon != null) setIconImage(icon.getImage()); + } + + public static synchronized Preferences getInstance(PlayerUI player) + { + if (instance == null) + { + instance = new Preferences(player); + instance.loadUI(); + } + return instance; + } + + private void loadUI() + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/preferences"); + setTitle(getResource("title")); + DefaultMutableTreeNode root = new DefaultMutableTreeNode(); + // Options + if (getResource("tree.options") != null) + { + options = new DefaultMutableTreeNode(getResource("tree.options")); + if (getResource("tree.options.device") != null) + { + device = new DefaultMutableTreeNode(); + device.setUserObject(new NodeItem(getResource("tree.options.device"), getResource("tree.options.device.impl"))); + options.add(device); + } + if (getResource("tree.options.visual") != null) + { + visual = new DefaultMutableTreeNode(); + visual.setUserObject(new NodeItem(getResource("tree.options.visual"), getResource("tree.options.visual.impl"))); + options.add(visual); + } + if (getResource("tree.options.filetypes") != null) + { + filetypes = new DefaultMutableTreeNode(); + filetypes.setUserObject(new NodeItem(getResource("tree.options.filetypes"), getResource("tree.options.filetypes.impl"))); + options.add(filetypes); + } + if (getResource("tree.options.system") != null) + { + proxy = new DefaultMutableTreeNode(); + proxy.setUserObject(new NodeItem(getResource("tree.options.system"), getResource("tree.options.system.impl"))); + options.add(proxy); + } + root.add(options); + } + // Plugins + if (getResource("tree.plugins") != null) + { + plugins = new DefaultMutableTreeNode(getResource("tree.plugins")); + if (getResource("tree.plugins.visualization") != null) + { + visuals = new DefaultMutableTreeNode(); + visuals.setUserObject(new NodeItem(getResource("tree.plugins.visualization"), getResource("tree.plugins.visualization.impl"))); + plugins.add(visuals); + } + if (getResource("tree.plugins.output") != null) + { + output = new DefaultMutableTreeNode(); + output.setUserObject(new NodeItem(getResource("tree.plugins.output"), getResource("tree.plugins.output.impl"))); + plugins.add(output); + } + /*if (getResource("tree.plugins.drm") != null) + { + drm = new DefaultMutableTreeNode(); + drm.setUserObject(new NodeItem(getResource("tree.plugins.drm"), getResource("tree.plugins.drm.impl"))); + plugins.add(drm); + }*/ + root.add(plugins); + } + // Skins + if (getResource("tree.skins") != null) + { + skins = new DefaultMutableTreeNode(getResource("tree.skins")); + if (getResource("tree.skins.browser") != null) + { + browser = new DefaultMutableTreeNode(); + browser.setUserObject(new NodeItem(getResource("tree.skins.browser"), getResource("tree.skins.browser.impl"))); + skins.add(browser); + } + root.add(skins); + } + tree = new JTree(root); + tree.setRootVisible(false); + DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer(); + renderer.setLeafIcon(null); + renderer.setClosedIcon(null); + renderer.setOpenIcon(null); + tree.setCellRenderer(renderer); + tree.addTreeSelectionListener(this); + int i = 0; + while (i < tree.getRowCount()) + { + tree.expandRow(i++); + } + tree.setBorder(new EmptyBorder(1, 4, 1, 2)); + GridBagLayout layout = new GridBagLayout(); + getContentPane().setLayout(layout); + GridBagConstraints cnts = new GridBagConstraints(); + cnts.fill = GridBagConstraints.BOTH; + cnts.weightx = 0.3; + cnts.weighty = 1.0; + cnts.gridx = 0; + cnts.gridy = 0; + treePane = new JScrollPane(tree); + JPanel leftPane = new JPanel(); + leftPane.setLayout(new BorderLayout()); + leftPane.add(treePane, BorderLayout.CENTER); + if (getResource("button.close") != null) + { + close = new JButton(getResource("button.close")); + close.addActionListener(this); + leftPane.add(close, BorderLayout.SOUTH); + } + getContentPane().add(leftPane, cnts); + cnts.weightx = 1.0; + cnts.gridx = 1; + cnts.gridy = 0; + workPane = new JScrollPane(new JPanel()); + getContentPane().add(workPane, cnts); + } + + public void valueChanged(TreeSelectionEvent e) + { + DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent(); + if (node == null) return; + if (node.isLeaf()) + { + Object nodeItem = node.getUserObject(); + if ((nodeItem != null) && (nodeItem instanceof NodeItem)) + { + PreferenceItem pane = getPreferenceItem(((NodeItem) nodeItem).getImpl()); + if (pane != null) + { + pane.setPlayer(player); + pane.loadUI(); + pane.setParentFrame(this); + workPane.setViewportView(pane); + } + } + } + } + + public void selectSkinBrowserPane() + { + TreeNode[] path = browser.getPath(); + tree.setSelectionPath(new TreePath(path)); + } + + public void actionPerformed(ActionEvent ev) + { + if (ev.getSource() == close) + { + if (player != null) + { + Config config = player.getConfig(); + config.save(); + } + dispose(); + } + } + + /** + * Return I18N value of a given key. + * @param key + * @return + */ + public String getResource(String key) + { + String value = null; + if (key != null) + { + try + { + value = bundle.getString(key); + } + catch (MissingResourceException e) + { + } + } + return value; + } + + public PreferenceItem getPreferenceItem(String impl) + { + PreferenceItem item = null; + if (impl != null) + { + try + { + Class aClass = Class.forName(impl); + Method method = aClass.getMethod("getInstance", null); + item = (PreferenceItem) method.invoke(null, null); + } + catch (Exception e) + { + // TODO + } + } + return item; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SkinPreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SkinPreference.java new file mode 100644 index 0000000..f649b65 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SkinPreference.java @@ -0,0 +1,185 @@ +/* + * SkinPreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.util.ResourceBundle; +import javax.swing.DefaultListModel; +import javax.swing.JButton; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.ListSelectionModel; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javazoom.jlgui.player.amp.util.FileNameFilter; +import javazoom.jlgui.player.amp.util.FileSelector; + +public class SkinPreference extends PreferenceItem implements ActionListener, ListSelectionListener +{ + public static final String DEFAULTSKIN = ""; + public static final String SKINEXTENSION = "wsz"; + private DefaultListModel listModel = null; + private JList skins = null; + private JTextArea info = null; + private JPanel listPane = null; + private JPanel infoPane = null; + private JPanel browsePane = null; + private JButton selectSkinDir = null; + private static SkinPreference instance = null; + + private SkinPreference() + { + listModel = new DefaultListModel(); + } + + public static SkinPreference getInstance() + { + if (instance == null) + { + instance = new SkinPreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/skin"); + setBorder(new TitledBorder(getResource("title"))); + File dir = null; + if (player != null) + { + dir = new File(player.getConfig().getLastSkinDir()); + } + loadSkins(dir); + skins = new JList(listModel); + skins.setBorder(new EmptyBorder(1, 2, 1, 1)); + skins.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + skins.setLayoutOrientation(JList.VERTICAL); + skins.setVisibleRowCount(12); + skins.addListSelectionListener(this); + JScrollPane listScroller = new JScrollPane(skins); + listScroller.setPreferredSize(new Dimension(300, 140)); + listPane = new JPanel(); + listPane.add(listScroller); + infoPane = new JPanel(); + info = new JTextArea(4, 35); + info.setEditable(false); + info.setCursor(null); + JScrollPane infoScroller = new JScrollPane(info); + infoScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + infoScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + infoPane.add(infoScroller); + browsePane = new JPanel(); + selectSkinDir = new JButton(getResource("browser.directory.button")); + selectSkinDir.addActionListener(this); + browsePane.add(selectSkinDir); + GridBagLayout layout = new GridBagLayout(); + setLayout(layout); + GridBagConstraints cnts = new GridBagConstraints(); + cnts.fill = GridBagConstraints.BOTH; + cnts.gridwidth = 1; + cnts.weightx = 1.0; + cnts.weighty = 0.60; + cnts.gridx = 0; + cnts.gridy = 0; + add(listPane, cnts); + cnts.gridwidth = 1; + cnts.weightx = 1.0; + cnts.weighty = 0.30; + cnts.gridx = 0; + cnts.gridy = 1; + add(infoPane, cnts); + cnts.weightx = 1.0; + cnts.weighty = 0.10; + cnts.gridx = 0; + cnts.gridy = 2; + add(browsePane, cnts); + loaded = true; + } + } + + public void actionPerformed(ActionEvent ev) + { + if (ev.getActionCommand().equalsIgnoreCase(getResource("browser.directory.button"))) + { + File[] file = FileSelector.selectFile(player.getLoader(), FileSelector.DIRECTORY, false, "", "Directories", new File(player.getConfig().getLastSkinDir())); + if ((file != null) && (file[0].isDirectory())) + { + player.getConfig().setLastSkinDir(file[0].getAbsolutePath()); + loadSkins(file[0]); + } + } + } + + public void valueChanged(ListSelectionEvent e) + { + if (e.getValueIsAdjusting() == false) + { + if (skins.getSelectedIndex() == -1) + { + } + else + { + String name = (String) listModel.get(skins.getSelectedIndex()); + String filename = player.getConfig().getLastSkinDir() + name + "." + SKINEXTENSION; + player.getSkin().setPath(filename); + player.loadSkin(); + player.getConfig().setDefaultSkin(filename); + String readme = player.getSkin().getReadme(); + if (readme == null) readme = ""; + info.setText(readme); + info.setCaretPosition(0); + } + } + } + + private void loadSkins(File dir) + { + listModel.clear(); + listModel.addElement(DEFAULTSKIN); + if ((dir != null) && (dir.exists())) + { + File[] files = dir.listFiles(new FileNameFilter(SKINEXTENSION, "Skins", false)); + if ((files != null) && (files.length > 0)) + { + for (int i = 0; i < files.length; i++) + { + String filename = files[i].getName(); + listModel.addElement(filename.substring(0, filename.length() - 4)); + } + } + } + } + +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SystemPreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SystemPreference.java new file mode 100644 index 0000000..86445d5 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SystemPreference.java @@ -0,0 +1,91 @@ +/* + * SystemPreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.awt.BorderLayout; +import java.awt.Font; +import java.util.Iterator; +import java.util.Properties; +import java.util.ResourceBundle; +import java.util.TreeMap; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; + +public class SystemPreference extends PreferenceItem +{ + private JTextArea info = null; + private boolean loaded = false; + private static SystemPreference instance = null; + + private SystemPreference() + { + } + + public static SystemPreference getInstance() + { + if (instance == null) + { + instance = new SystemPreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/system"); + setBorder(new TitledBorder(getResource("title"))); + setLayout(new BorderLayout()); + info = new JTextArea(16,35); + info.setFont(new Font("Dialog", Font.PLAIN, 11)); + info.setEditable(false); + info.setCursor(null); + info.setBorder(new EmptyBorder(1,2,1,1)); + Properties props = System.getProperties(); + Iterator it = props.keySet().iterator(); + TreeMap map = new TreeMap(); + while (it.hasNext()) + { + String key = (String) it.next(); + String value = props.getProperty(key); + map.put(key, value); + } + it = map.keySet().iterator(); + while (it.hasNext()) + { + String key = (String) it.next(); + String value = (String) map.get(key); + info.append(key + "=" + value + "\r\n"); + } + JScrollPane infoScroller = new JScrollPane(info); + infoScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + infoScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + add(infoScroller, BorderLayout.CENTER); + info.setCaretPosition(0); + loaded = true; + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/TypePreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/TypePreference.java new file mode 100644 index 0000000..23e94a6 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/TypePreference.java @@ -0,0 +1,129 @@ +/* + * TypePreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ResourceBundle; +import java.util.StringTokenizer; +import javax.swing.DefaultListModel; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.ListSelectionModel; +import javax.swing.border.EmptyBorder; +import javax.swing.border.TitledBorder; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +public class TypePreference extends PreferenceItem implements ActionListener, ListSelectionListener +{ + private DefaultListModel listModel = null; + private JList types = null; + private JPanel listPane = null; + private JPanel extensionPane = null; + private static TypePreference instance = null; + + private TypePreference() + { + listModel = new DefaultListModel(); + } + + public static TypePreference getInstance() + { + if (instance == null) + { + instance = new TypePreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/type"); + setBorder(new TitledBorder(getResource("title"))); + loadTypes(); + types = new JList(listModel); + types.setBorder(new EmptyBorder(1, 2, 1, 1)); + types.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + types.setLayoutOrientation(JList.VERTICAL); + types.setVisibleRowCount(12); + types.addListSelectionListener(this); + JScrollPane listScroller = new JScrollPane(types); + listScroller.setPreferredSize(new Dimension(80, 240)); + listPane = new JPanel(); + listPane.add(listScroller); + extensionPane = new JPanel(); + GridBagLayout layout = new GridBagLayout(); + setLayout(layout); + GridBagConstraints cnts = new GridBagConstraints(); + cnts.fill = GridBagConstraints.BOTH; + cnts.gridwidth = 1; + cnts.weightx = 0.30; + cnts.weighty = 1.0; + cnts.gridx = 0; + cnts.gridy = 0; + add(listPane, cnts); + cnts.gridwidth = 1; + cnts.weightx = 0.70; + cnts.weighty = 1.0; + cnts.gridx = 1; + cnts.gridy = 0; + add(extensionPane, cnts); + loaded = true; + } + } + + public void actionPerformed(ActionEvent ev) + { + } + + public void valueChanged(ListSelectionEvent e) + { + if (e.getValueIsAdjusting() == false) + { + if (types.getSelectedIndex() == -1) + { + } + else + { + } + } + } + + private void loadTypes() + { + String extensions = player.getConfig().getExtensions(); + StringTokenizer st = new StringTokenizer(extensions, ","); + while (st.hasMoreTokens()) + { + String type = st.nextToken(); + listModel.addElement(type); + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualPreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualPreference.java new file mode 100644 index 0000000..6f039bd --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualPreference.java @@ -0,0 +1,292 @@ +/* + * VisualPreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Hashtable; +import java.util.ResourceBundle; +import javax.swing.BoxLayout; +import javax.swing.ButtonGroup; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JRadioButton; +import javax.swing.JSlider; +import javax.swing.border.TitledBorder; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer; + +public class VisualPreference extends PreferenceItem implements ActionListener, ChangeListener +{ + private JPanel modePane = null; + private JPanel spectrumPane = null; + private JPanel oscilloPane = null; + private JRadioButton spectrumMode = null; + private JRadioButton oscilloMode = null; + private JRadioButton offMode = null; + private JCheckBox peaksBox = null; + private JSlider analyzerFalloff = null; + private JSlider peaksFalloff = null; + private static VisualPreference instance = null; + + private VisualPreference() + { + } + + public static VisualPreference getInstance() + { + if (instance == null) + { + instance = new VisualPreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/visual"); + setBorder(new TitledBorder(getResource("title"))); + modePane = new JPanel(); + modePane.setBorder(new TitledBorder(getResource("mode.title"))); + modePane.setLayout(new FlowLayout()); + spectrumMode = new JRadioButton(getResource("mode.spectrum")); + spectrumMode.addActionListener(this); + oscilloMode = new JRadioButton(getResource("mode.oscilloscope")); + oscilloMode.addActionListener(this); + offMode = new JRadioButton(getResource("mode.off")); + offMode.addActionListener(this); + SpectrumTimeAnalyzer analyzer = null; + if (player != null) + { + analyzer = player.getSkin().getAcAnalyzer(); + int displayMode = SpectrumTimeAnalyzer.DISPLAY_MODE_OFF; + if (analyzer != null) + { + displayMode = analyzer.getDisplayMode(); + } + if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER) + { + spectrumMode.setSelected(true); + } + else if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE) + { + oscilloMode.setSelected(true); + } + else if (displayMode == SpectrumTimeAnalyzer.DISPLAY_MODE_OFF) + { + offMode.setSelected(true); + } + } + ButtonGroup modeGroup = new ButtonGroup(); + modeGroup.add(spectrumMode); + modeGroup.add(oscilloMode); + modeGroup.add(offMode); + modePane.add(spectrumMode); + modePane.add(oscilloMode); + modePane.add(offMode); + spectrumPane = new JPanel(); + spectrumPane.setLayout(new BoxLayout(spectrumPane, BoxLayout.Y_AXIS)); + peaksBox = new JCheckBox(getResource("spectrum.peaks")); + peaksBox.setAlignmentX(Component.LEFT_ALIGNMENT); + peaksBox.addActionListener(this); + if ((analyzer != null) && (analyzer.isPeaksEnabled())) peaksBox.setSelected(true); + else peaksBox.setSelected(false); + spectrumPane.add(peaksBox); + // Analyzer falloff. + JLabel analyzerFalloffLabel = new JLabel(getResource("spectrum.analyzer.falloff")); + analyzerFalloffLabel.setAlignmentX(Component.LEFT_ALIGNMENT); + spectrumPane.add(analyzerFalloffLabel); + int minDecay = (int) (SpectrumTimeAnalyzer.MIN_SPECTRUM_ANALYSER_DECAY * 100); + int maxDecay = (int) (SpectrumTimeAnalyzer.MAX_SPECTRUM_ANALYSER_DECAY * 100); + int decay = (maxDecay + minDecay) / 2; + if (analyzer != null) + { + decay = (int) (analyzer.getSpectrumAnalyserDecay() * 100); + } + analyzerFalloff = new JSlider(JSlider.HORIZONTAL, minDecay, maxDecay, decay); + analyzerFalloff.setMajorTickSpacing(1); + analyzerFalloff.setPaintTicks(true); + analyzerFalloff.setMaximumSize(new Dimension(150, analyzerFalloff.getPreferredSize().height)); + analyzerFalloff.setAlignmentX(Component.LEFT_ALIGNMENT); + analyzerFalloff.setSnapToTicks(true); + analyzerFalloff.addChangeListener(this); + spectrumPane.add(analyzerFalloff); + // Peaks falloff. + JLabel peaksFalloffLabel = new JLabel(getResource("spectrum.peaks.falloff")); + peaksFalloffLabel.setAlignmentX(Component.LEFT_ALIGNMENT); + spectrumPane.add(peaksFalloffLabel); + int peakDelay = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY; + int fps = SpectrumTimeAnalyzer.DEFAULT_FPS; + if (analyzer != null) + { + fps = analyzer.getFps(); + peakDelay = analyzer.getPeakDelay(); + } + peaksFalloff = new JSlider(JSlider.HORIZONTAL, 0, 4, computeSliderValue(peakDelay, fps)); + peaksFalloff.setMajorTickSpacing(1); + peaksFalloff.setPaintTicks(true); + peaksFalloff.setSnapToTicks(true); + Hashtable labelTable = new Hashtable(); + labelTable.put(new Integer(0), new JLabel("Slow")); + labelTable.put(new Integer(4), new JLabel("Fast")); + peaksFalloff.setLabelTable(labelTable); + peaksFalloff.setPaintLabels(true); + peaksFalloff.setMaximumSize(new Dimension(150, peaksFalloff.getPreferredSize().height)); + peaksFalloff.setAlignmentX(Component.LEFT_ALIGNMENT); + peaksFalloff.addChangeListener(this); + spectrumPane.add(peaksFalloff); + // Spectrum pane + spectrumPane.setBorder(new TitledBorder(getResource("spectrum.title"))); + if (getResource("oscilloscope.title") != null) + { + oscilloPane = new JPanel(); + oscilloPane.setBorder(new TitledBorder(getResource("oscilloscope.title"))); + } + GridBagLayout layout = new GridBagLayout(); + setLayout(layout); + GridBagConstraints cnts = new GridBagConstraints(); + cnts.fill = GridBagConstraints.BOTH; + cnts.gridwidth = 2; + cnts.weightx = 2.0; + cnts.weighty = 0.25; + cnts.gridx = 0; + cnts.gridy = 0; + add(modePane, cnts); + cnts.gridwidth = 1; + cnts.weightx = 1.0; + cnts.weighty = 1.0; + cnts.gridx = 0; + cnts.gridy = 1; + add(spectrumPane, cnts); + cnts.weightx = 1.0; + cnts.weighty = 1.0; + cnts.gridx = 1; + cnts.gridy = 1; + if (oscilloPane != null) add(oscilloPane, cnts); + if (analyzer == null) + { + disablePane(modePane); + disablePane(spectrumPane); + disablePane(oscilloPane); + } + loaded = true; + } + } + + private void disablePane(JPanel pane) + { + if (pane != null) + { + Component[] cpns = pane.getComponents(); + if (cpns != null) + { + for (int i = 0; i < cpns.length; i++) + { + cpns[i].setEnabled(false); + } + } + } + } + + public void actionPerformed(ActionEvent ev) + { + if (player != null) + { + SpectrumTimeAnalyzer analyzer = player.getSkin().getAcAnalyzer(); + if (analyzer != null) + { + if (ev.getSource().equals(spectrumMode)) + { + analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SPECTRUM_ANALYSER); + analyzer.startDSP(null); + } + else if (ev.getSource().equals(oscilloMode)) + { + analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE); + analyzer.startDSP(null); + } + else if (ev.getSource().equals(offMode)) + { + analyzer.setDisplayMode(SpectrumTimeAnalyzer.DISPLAY_MODE_OFF); + analyzer.closeDSP(); + analyzer.repaint(); + } + else if (ev.getSource().equals(peaksBox)) + { + if (peaksBox.isSelected()) analyzer.setPeaksEnabled(true); + else analyzer.setPeaksEnabled(false); + } + } + } + } + + public void stateChanged(ChangeEvent ce) + { + if (player != null) + { + SpectrumTimeAnalyzer analyzer = player.getSkin().getAcAnalyzer(); + if (analyzer != null) + { + if (ce.getSource() == analyzerFalloff) + { + if (!analyzerFalloff.getValueIsAdjusting()) + { + analyzer.setSpectrumAnalyserDecay(analyzerFalloff.getValue() * 1.0f / 100.0f); + } + } + else if (ce.getSource() == peaksFalloff) + { + if (!peaksFalloff.getValueIsAdjusting()) + { + analyzer.setPeakDelay(computeDelay(peaksFalloff.getValue(), analyzer.getFps())); + } + } + } + } + } + + private int computeDelay(int slidervalue, int fps) + { + float p = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO; + float n = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE; + int delay = Math.round(((-n * slidervalue * 1.0f / 2.0f) + p + n) * fps); + return delay; + } + + private int computeSliderValue(int delay, int fps) + { + float p = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO; + float n = SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE; + int value = (int) Math.round((((p - (delay * 1.0 / fps * 1.0f)) * 2 / n) + 2)); + return value; + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualizationPreference.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualizationPreference.java new file mode 100644 index 0000000..571a5c6 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualizationPreference.java @@ -0,0 +1,54 @@ +/* + * VisualizationPreference. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.util.ui; + +import java.util.ResourceBundle; +import javax.swing.border.TitledBorder; + +public class VisualizationPreference extends PreferenceItem +{ + private static VisualizationPreference instance = null; + + private VisualizationPreference() + { + } + + public static VisualizationPreference getInstance() + { + if (instance == null) + { + instance = new VisualizationPreference(); + } + return instance; + } + + public void loadUI() + { + if (loaded == false) + { + bundle = ResourceBundle.getBundle("javazoom/jlgui/player/amp/util/ui/visualization"); + setBorder(new TitledBorder(getResource("title"))); + loaded = true; + } + } +} diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/device.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/device.properties new file mode 100644 index 0000000..279243a --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/device.properties @@ -0,0 +1,6 @@ +title=JavaSound Device +line.buffer.size=Line buffer size : {0} bytes +help=Note : Device update will occur on player restart only. + + + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/output.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/output.properties new file mode 100644 index 0000000..c54c46a --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/output.properties @@ -0,0 +1,2 @@ +title=Output plugins + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/preferences.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/preferences.properties new file mode 100644 index 0000000..3787d34 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/preferences.properties @@ -0,0 +1,27 @@ +title=Preferences + +tree.options=Options +tree.options.device=Device +tree.options.device.impl=javazoom.jlgui.player.amp.util.ui.DevicePreference +tree.options.visual=Visual +tree.options.visual.impl=javazoom.jlgui.player.amp.util.ui.VisualPreference +tree.options.system=System +tree.options.system.impl=javazoom.jlgui.player.amp.util.ui.SystemPreference +tree.options.filetypes=File Types +tree.options.filetypes.impl=javazoom.jlgui.player.amp.util.ui.TypePreference + +#tree.plugins=Plugins +#tree.plugins.visualization=Visualization +#tree.plugins.visualization.impl=javazoom.jlgui.player.amp.util.ui.VisualizationPreference + +#tree.plugins.output=Output +#tree.plugins.output.impl=javazoom.jlgui.player.amp.util.ui.OutputPreference + +#tree.plugins.drm=DRM +#tree.plugins.drm.impl=javazoom.jlgui.player.amp.util.ui.EmptyPreference + +tree.skins=Skins +tree.skins.browser=Browser +tree.skins.browser.impl=javazoom.jlgui.player.amp.util.ui.SkinPreference + +button.close=Close diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/skin.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/skin.properties new file mode 100644 index 0000000..6433f43 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/skin.properties @@ -0,0 +1,4 @@ +title=Skins + +browser.directory.button=Set skins directory ... + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/system.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/system.properties new file mode 100644 index 0000000..a0f7dd4 --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/system.properties @@ -0,0 +1,3 @@ +title=System properties + + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/type.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/type.properties new file mode 100644 index 0000000..061309d --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/type.properties @@ -0,0 +1,2 @@ +title=Supported File types + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visual.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visual.properties new file mode 100644 index 0000000..be5fe0c --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visual.properties @@ -0,0 +1,15 @@ +title=Built-in visual options + +mode.title=Mode +mode.spectrum=Spectrum analyzer +mode.oscilloscope=Oscilloscope +mode.off=Off +mode.refresh.rate=50 + +spectrum.title=Spectrum analyzer +spectrum.peaks=Peaks +spectrum.analyzer.falloff=Analyzer falloff : +spectrum.peaks.falloff=Peaks falloff : + +#oscilloscope.title=Oscilloscope + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visualization.properties b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visualization.properties new file mode 100644 index 0000000..7c1585b --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visualization.properties @@ -0,0 +1,2 @@ +title=Visualization plugins + diff --git a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/visual/ui/SpectrumTimeAnalyzer.java b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/visual/ui/SpectrumTimeAnalyzer.java new file mode 100644 index 0000000..19ed5ff --- /dev/null +++ b/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/visual/ui/SpectrumTimeAnalyzer.java @@ -0,0 +1,775 @@ +/* + * SpectrumTimeAnalyzer. + * + * JavaZOOM : jlgui@javazoom.net + * http://www.javazoom.net + * + *----------------------------------------------------------------------- + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + *---------------------------------------------------------------------- + */ +package javazoom.jlgui.player.amp.visual.ui; + +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.StringTokenizer; +import javax.sound.sampled.SourceDataLine; +import javax.swing.JPanel; +import javazoom.jlgui.player.amp.skin.AbsoluteConstraints; +import kj.dsp.KJDigitalSignalProcessingAudioDataConsumer; +import kj.dsp.KJDigitalSignalProcessor; +import kj.dsp.KJFFT; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class SpectrumTimeAnalyzer extends JPanel implements KJDigitalSignalProcessor +{ + private static Log log = LogFactory.getLog(SpectrumTimeAnalyzer.class); + public static final int DISPLAY_MODE_SCOPE = 0; + public static final int DISPLAY_MODE_SPECTRUM_ANALYSER = 1; + public static final int DISPLAY_MODE_OFF = 2; + public static final int DEFAULT_WIDTH = 256; + public static final int DEFAULT_HEIGHT = 128; + public static final int DEFAULT_FPS = 50; + public static final int DEFAULT_SPECTRUM_ANALYSER_FFT_SAMPLE_SIZE = 512; + public static final int DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT = 19; + public static final float DEFAULT_SPECTRUM_ANALYSER_DECAY = 0.05f; + public static final int DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY = 20; + public static final float DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO = 0.4f; + public static final float DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE = 0.1f; + public static final float MIN_SPECTRUM_ANALYSER_DECAY = 0.02f; + public static final float MAX_SPECTRUM_ANALYSER_DECAY = 0.08f; + public static final Color DEFAULT_BACKGROUND_COLOR = new Color(0, 0, 128); + public static final Color DEFAULT_SCOPE_COLOR = new Color(255, 192, 0); + public static final float DEFAULT_VU_METER_DECAY = 0.02f; + private Image bi; + private int displayMode = DISPLAY_MODE_SCOPE; + private Color scopeColor = DEFAULT_SCOPE_COLOR; + private Color[] spectrumAnalyserColors = getDefaultSpectrumAnalyserColors(); + private KJDigitalSignalProcessingAudioDataConsumer dsp = null; + private boolean dspStarted = false; + private Color peakColor = null; + private int[] peaks = new int[DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT]; + private int[] peaksDelay = new int[DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT]; + private int peakDelay = DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY; + private boolean peaksEnabled = true; + private List visColors = null; + private int barOffset = 1; + private int width; + private int height; + private int height_2; + // -- Spectrum analyser variables. + private KJFFT fft; + private float[] old_FFT; + private int saFFTSampleSize; + private int saBands; + private float saColorScale; + private float saMultiplier; + private float saDecay = DEFAULT_SPECTRUM_ANALYSER_DECAY; + private float sad; + private SourceDataLine m_line = null; + // -- VU Meter + private float oldLeft; + private float oldRight; + // private float vuAverage; + // private float vuSamples; + private float vuDecay = DEFAULT_VU_METER_DECAY; + private float vuColorScale; + // -- FPS calulations. + private long lfu = 0; + private int fc = 0; + private int fps = DEFAULT_FPS; + private boolean showFPS = false; + + private AbsoluteConstraints constraints = null; + + // private Runnable PAINT_SYNCHRONIZER = new AWTPaintSynchronizer(); + public SpectrumTimeAnalyzer() + { + setOpaque(false); + initialize(); + } + + public void setConstraints(AbsoluteConstraints cnts) + { + constraints = cnts; + } + + public AbsoluteConstraints getConstraints() + { + return constraints; + } + + public boolean isPeaksEnabled() + { + return peaksEnabled; + } + + public void setPeaksEnabled(boolean peaksEnabled) + { + this.peaksEnabled = peaksEnabled; + } + + public int getFps() + { + return fps; + } + + public void setFps(int fps) + { + this.fps = fps; + } + + /** + * Starts DSP. + * @param line + */ + public void startDSP(SourceDataLine line) + { + if (displayMode == DISPLAY_MODE_OFF) return; + if (line != null) m_line = line; + if (dsp == null) + { + dsp = new KJDigitalSignalProcessingAudioDataConsumer(2048, fps); + dsp.add(this); + } + if ((dsp != null) && (m_line != null)) + { + if (dspStarted == true) + { + stopDSP(); + } + dsp.start(m_line); + dspStarted = true; + log.debug("DSP started"); + } + } + + /** + * Stop DSP. + */ + public void stopDSP() + { + if (dsp != null) + { + dsp.stop(); + dspStarted = false; + log.debug("DSP stopped"); + } + } + + /** + * Close DSP + */ + public void closeDSP() + { + if (dsp != null) + { + stopDSP(); + dsp = null; + log.debug("DSP closed"); + } + } + + /** + * Setup DSP. + * @param line + */ + public void setupDSP(SourceDataLine line) + { + if (dsp != null) + { + int channels = line.getFormat().getChannels(); + if (channels == 1) dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_MONO); + else dsp.setChannelMode(KJDigitalSignalProcessingAudioDataConsumer.CHANNEL_MODE_STEREO); + int bits = line.getFormat().getSampleSizeInBits(); + if (bits == 8) dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_EIGHT_BIT); + else dsp.setSampleType(KJDigitalSignalProcessingAudioDataConsumer.SAMPLE_TYPE_SIXTEEN_BIT); + } + } + + /** + * Write PCM data to DSP. + * @param pcmdata + */ + public void writeDSP(byte[] pcmdata) + { + if ((dsp != null) && (dspStarted == true)) dsp.writeAudioData(pcmdata); + } + + /** + * Return DSP. + * @return + */ + public KJDigitalSignalProcessingAudioDataConsumer getDSP() + { + return dsp; + } + + /** + * Set visual colors from skin. + * @param viscolor + */ + public void setVisColor(String viscolor) + { + ArrayList visColors = new ArrayList(); + viscolor = viscolor.toLowerCase(); + ByteArrayInputStream in = new ByteArrayInputStream(viscolor.getBytes()); + BufferedReader bin = new BufferedReader(new InputStreamReader(in)); + try + { + String line = null; + while ((line = bin.readLine()) != null) + { + visColors.add(getColor(line)); + } + Color[] colors = new Color[visColors.size()]; + visColors.toArray(colors); + Color[] specColors = new Color[15]; + System.arraycopy(colors, 2, specColors, 0, 15); + List specList = Arrays.asList(specColors); + Collections.reverse(specList); + specColors = (Color[]) specList.toArray(specColors); + setSpectrumAnalyserColors(specColors); + setBackground((Color) visColors.get(0)); + if (visColors.size()>23) setPeakColor((Color) visColors.get(23)); + if (visColors.size()>18) setScopeColor((Color) visColors.get(18)); + } + catch (IOException ex) + { + log.warn("Cannot parse viscolors", ex); + } + finally + { + try + { + if (bin != null) bin.close(); + } + catch (IOException e) + { + } + } + } + + /** + * Set visual peak color. + * @param c + */ + public void setPeakColor(Color c) + { + peakColor = c; + } + + /** + * Set peak falloff delay. + * @param framestowait + */ + public void setPeakDelay(int framestowait) + { + int min = (int) Math.round((DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO - DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE) * fps); + int max = (int) Math.round((DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO + DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO_RANGE) * fps); + if ((framestowait >= min) && (framestowait <= max)) + { + peakDelay = framestowait; + } + else + { + peakDelay = (int) Math.round(DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO * fps); + } + } + + /** + * Return peak falloff delay + * @return int framestowait + */ + public int getPeakDelay() + { + return peakDelay; + } + + /** + * Convert string to color. + * @param linecolor + * @return + */ + public Color getColor(String linecolor) + { + Color color = Color.BLACK; + StringTokenizer st = new StringTokenizer(linecolor, ","); + int red = 0, green = 0, blue = 0; + try + { + if (st.hasMoreTokens()) red = Integer.parseInt(st.nextToken().trim()); + if (st.hasMoreTokens()) green = Integer.parseInt(st.nextToken().trim()); + if (st.hasMoreTokens()) + { + String blueStr = st.nextToken().trim(); + if (blueStr.length() > 3) blueStr = (blueStr.substring(0, 3)).trim(); + blue = Integer.parseInt(blueStr); + } + color = new Color(red, green, blue); + } + catch (NumberFormatException e) + { + log.debug("Cannot parse viscolor : "+e.getMessage()); + } + return color; + } + + private void computeColorScale() + { + saColorScale = ((float) spectrumAnalyserColors.length / height) * barOffset * 1.0f; + vuColorScale = ((float) spectrumAnalyserColors.length / (width - 32)) * 2.0f; + } + + private void computeSAMultiplier() + { + saMultiplier = (saFFTSampleSize / 2) / saBands; + } + + private void drawScope(Graphics pGrp, float[] pSample) + { + pGrp.setColor(scopeColor); + int wLas = (int) (pSample[0] * (float) height_2) + height_2; + int wSt = 2; + for (int a = wSt, c = 0; c < width; a += wSt, c++) + { + int wAs = (int) (pSample[a] * (float) height_2) + height_2; + pGrp.drawLine(c, wLas, c + 1, wAs); + wLas = wAs; + } + } + + private void drawSpectrumAnalyser(Graphics pGrp, float[] pSample, float pFrrh) + { + float c = 0; + float[] wFFT = fft.calculate(pSample); + float wSadfrr = (saDecay * pFrrh); + float wBw = ((float) width / (float) saBands); + for (int a = 0, bd = 0; bd < saBands; a += saMultiplier, bd++) + { + float wFs = 0; + // -- Average out nearest bands. + for (int b = 0; b < saMultiplier; b++) + { + wFs += wFFT[a + b]; + } + // -- Log filter. + wFs = (wFs * (float) Math.log(bd + 2)); + if (wFs > 1.0f) + { + wFs = 1.0f; + } + // -- Compute SA decay... + if (wFs >= (old_FFT[a] - wSadfrr)) + { + old_FFT[a] = wFs; + } + else + { + old_FFT[a] -= wSadfrr; + if (old_FFT[a] < 0) + { + old_FFT[a] = 0; + } + wFs = old_FFT[a]; + } + drawSpectrumAnalyserBar(pGrp, (int) c, height, (int) wBw - 1, (int) (wFs * height), bd); + c += wBw; + } + } + + private void drawVUMeter(Graphics pGrp, float[] pLeft, float[] pRight, float pFrrh) + { + if (displayMode == DISPLAY_MODE_OFF) return; + float wLeft = 0.0f; + float wRight = 0.0f; + float wSadfrr = (vuDecay * pFrrh); + for (int a = 0; a < pLeft.length; a++) + { + wLeft += Math.abs(pLeft[a]); + wRight += Math.abs(pRight[a]); + } + wLeft = ((wLeft * 2.0f) / (float) pLeft.length); + wRight = ((wRight * 2.0f) / (float) pRight.length); + if (wLeft > 1.0f) + { + wLeft = 1.0f; + } + if (wRight > 1.0f) + { + wRight = 1.0f; + } + // vuAverage += ( ( wLeft + wRight ) / 2.0f ); + // vuSamples++; + // + // if ( vuSamples > 128 ) { + // vuSamples /= 2.0f; + // vuAverage /= 2.0f; + // } + if (wLeft >= (oldLeft - wSadfrr)) + { + oldLeft = wLeft; + } + else + { + oldLeft -= wSadfrr; + if (oldLeft < 0) + { + oldLeft = 0; + } + } + if (wRight >= (oldRight - wSadfrr)) + { + oldRight = wRight; + } + else + { + oldRight -= wSadfrr; + if (oldRight < 0) + { + oldRight = 0; + } + } + int wHeight = (height >> 1) - 24; + drawVolumeMeterBar(pGrp, 16, 16, (int) (oldLeft * (float) (width - 32)), wHeight); + // drawVolumeMeterBar( pGrp, 16, wHeight + 22, (int)( ( vuAverage / vuSamples ) * (float)( width - 32 ) ), 4 ); + drawVolumeMeterBar(pGrp, 16, wHeight + 32, (int) (oldRight * (float) (width - 32)), wHeight); + // pGrp.fillRect( 16, 16, (int)( oldLeft * (float)( width - 32 ) ), wHeight ); + // pGrp.fillRect( 16, 64, (int)( oldRight * (float)( width - 32 ) ), wHeight ); + } + + private void drawSpectrumAnalyserBar(Graphics pGraphics, int pX, int pY, int pWidth, int pHeight, int band) + { + float c = 0; + for (int a = pY; a >= pY - pHeight; a -= barOffset) + { + c += saColorScale; + if (c < spectrumAnalyserColors.length) + { + pGraphics.setColor(spectrumAnalyserColors[(int) c]); + } + pGraphics.fillRect(pX, a, pWidth, 1); + } + if ((peakColor != null) && (peaksEnabled == true)) + { + pGraphics.setColor(peakColor); + if (pHeight > peaks[band]) + { + peaks[band] = pHeight; + peaksDelay[band] = peakDelay; + } + else + { + peaksDelay[band]--; + if (peaksDelay[band] < 0) peaks[band]--; + if (peaks[band] < 0) peaks[band] = 0; + } + pGraphics.fillRect(pX, pY - peaks[band], pWidth, 1); + } + } + + private void drawVolumeMeterBar(Graphics pGraphics, int pX, int pY, int pWidth, int pHeight) + { + float c = 0; + for (int a = pX; a <= pX + pWidth; a += 2) + { + c += vuColorScale; + if (c < 256.0f) + { + pGraphics.setColor(spectrumAnalyserColors[(int) c]); + } + pGraphics.fillRect(a, pY, 1, pHeight); + } + } + + private synchronized Image getDoubleBuffer() + { + if (bi == null || (bi.getWidth(null) != getSize().width || bi.getHeight(null) != getSize().height)) + { + width = getSize().width; + height = getSize().height; + height_2 = height >> 1; + computeColorScale(); + bi = getGraphicsConfiguration().createCompatibleVolatileImage(width, height); + } + return bi; + } + + public static Color[] getDefaultSpectrumAnalyserColors() + { + Color[] wColors = new Color[256]; + for (int a = 0; a < 128; a++) + { + wColors[a] = new Color(0, (a >> 1) + 192, 0); + } + for (int a = 0; a < 64; a++) + { + wColors[a + 128] = new Color(a << 2, 255, 0); + } + for (int a = 0; a < 64; a++) + { + wColors[a + 192] = new Color(255, 255 - (a << 2), 0); + } + return wColors; + } + + /** + * @return Returns the current display mode, DISPLAY_MODE_SCOPE or DISPLAY_MODE_SPECTRUM_ANALYSER. + */ + public int getDisplayMode() + { + return displayMode; + } + + /** + * @return Returns the current number of bands displayed by the spectrum analyser. + */ + public int getSpectrumAnalyserBandCount() + { + return saBands; + } + + /** + * @return Returns the decay rate of the spectrum analyser's bands. + */ + public float getSpectrumAnalyserDecay() + { + return saDecay; + } + + /** + * @return Returns the color the scope is rendered in. + */ + public Color getScopeColor() + { + return scopeColor; + } + + /** + * @return Returns the color scale used to render the spectrum analyser bars. + */ + public Color[] getSpectrumAnalyserColors() + { + return spectrumAnalyserColors; + } + + private void initialize() + { + setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); + setBackground(DEFAULT_BACKGROUND_COLOR); + prepareDisplayToggleListener(); + setSpectrumAnalyserBandCount(DEFAULT_SPECTRUM_ANALYSER_BAND_COUNT); + setSpectrumAnalyserFFTSampleSize(DEFAULT_SPECTRUM_ANALYSER_FFT_SAMPLE_SIZE); + } + + /** + * @return Returns 'true' if "Frames Per Second" are being calculated and displayed. + */ + public boolean isShowingFPS() + { + return showFPS; + } + + public void paintComponent(Graphics pGraphics) + { + if (displayMode == DISPLAY_MODE_OFF) return; + if (dspStarted) + { + pGraphics.drawImage(getDoubleBuffer(), 0, 0, null); + } + else + { + super.paintComponent(pGraphics); + } + } + + private void prepareDisplayToggleListener() + { + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + addMouseListener(new MouseAdapter() + { + public void mouseClicked(MouseEvent pEvent) + { + if (pEvent.getButton() == MouseEvent.BUTTON1) + { + if (displayMode + 1 > 1) + { + displayMode = 0; + } + else + { + displayMode++; + } + } + } + }); + } + + /* (non-Javadoc) + * @see kj.dsp.KJDigitalSignalProcessor#process(float[], float[], float) + */ + public synchronized void process(float[] pLeft, float[] pRight, float pFrameRateRatioHint) + { + if (displayMode == DISPLAY_MODE_OFF) return; + Graphics wGrp = getDoubleBuffer().getGraphics(); + wGrp.setColor(getBackground()); + wGrp.fillRect(0, 0, getSize().width, getSize().height); + switch (displayMode) + { + case DISPLAY_MODE_SCOPE: + drawScope(wGrp, stereoMerge(pLeft, pRight)); + break; + case DISPLAY_MODE_SPECTRUM_ANALYSER: + drawSpectrumAnalyser(wGrp, stereoMerge(pLeft, pRight), pFrameRateRatioHint); + break; + case DISPLAY_MODE_OFF: + drawVUMeter(wGrp, pLeft, pRight, pFrameRateRatioHint); + break; + } + // -- Show FPS if necessary. + if (showFPS) + { + // -- Calculate FPS. + if (System.currentTimeMillis() >= lfu + 1000) + { + lfu = System.currentTimeMillis(); + fps = fc; + fc = 0; + } + fc++; + wGrp.setColor(Color.yellow); + wGrp.drawString("FPS: " + fps + " (FRRH: " + pFrameRateRatioHint + ")", 0, height - 1); + } + if (getGraphics() != null) getGraphics().drawImage(getDoubleBuffer(), 0, 0, null); + // repaint(); + // try { + // EventQueue.invokeLater( new AWTPaintSynchronizer() ); + // } catch ( Exception pEx ) { + // // -- Ignore exception. + // pEx.printStackTrace(); + // } + } + + /** + * Sets the current display mode. + * + * @param pMode Must be either DISPLAY_MODE_SCOPE or DISPLAY_MODE_SPECTRUM_ANALYSER. + */ + public synchronized void setDisplayMode(int pMode) + { + displayMode = pMode; + } + + /** + * Sets the color of the scope. + * + * @param pColor + */ + public synchronized void setScopeColor(Color pColor) + { + scopeColor = pColor; + } + + /** + * When 'true' is passed as a parameter, will overlay the "Frames Per Seconds" + * achieved by the component. + * + * @param pState + */ + public synchronized void setShowFPS(boolean pState) + { + showFPS = pState; + } + + /** + * Sets the numbers of bands rendered by the spectrum analyser. + * + * @param pCount Cannot be more than half the "FFT sample size". + */ + public synchronized void setSpectrumAnalyserBandCount(int pCount) + { + saBands = pCount; + peaks = new int[saBands]; + peaksDelay = new int[saBands]; + computeSAMultiplier(); + } + + /** + * Sets the spectrum analyser band decay rate. + * + * @param pDecay Must be a number between 0.0 and 1.0 exclusive. + */ + public synchronized void setSpectrumAnalyserDecay(float pDecay) + { + if ((pDecay >= MIN_SPECTRUM_ANALYSER_DECAY) && (pDecay <= MAX_SPECTRUM_ANALYSER_DECAY)) + { + saDecay = pDecay; + } + else saDecay = DEFAULT_SPECTRUM_ANALYSER_DECAY; + } + + /** + * Sets the spectrum analyser color scale. + * + * @param pColors Any amount of colors may be used. Must not be null. + */ + public synchronized void setSpectrumAnalyserColors(Color[] pColors) + { + spectrumAnalyserColors = pColors; + computeColorScale(); + } + + /** + * Sets the FFT sample size to be just for calculating the spectrum analyser + * values. The default is 512. + * + * @param pSize Cannot be more than the size of the sample provided by the DSP. + */ + public synchronized void setSpectrumAnalyserFFTSampleSize(int pSize) + { + saFFTSampleSize = pSize; + fft = new KJFFT(saFFTSampleSize); + old_FFT = new float[saFFTSampleSize]; + computeSAMultiplier(); + } + + private float[] stereoMerge(float[] pLeft, float[] pRight) + { + for (int a = 0; a < pLeft.length; a++) + { + pLeft[a] = (pLeft[a] + pRight[a]) / 2.0f; + } + return pLeft; + } + + /*public void update(Graphics pGraphics) + { + // -- Prevent AWT from clearing background. + paint(pGraphics); + }*/ +} diff --git a/vendor/log4j/1.2.16/log4j-1.2.16.jar b/vendor/log4j/1.2.16/log4j-1.2.16.jar new file mode 100644 index 0000000..3f9d847 Binary files /dev/null and b/vendor/log4j/1.2.16/log4j-1.2.16.jar differ diff --git a/vendor/nativecall/0.4.1/NativeCall.dll b/vendor/nativecall/0.4.1/NativeCall.dll new file mode 100644 index 0000000..6e2cad1 Binary files /dev/null and b/vendor/nativecall/0.4.1/NativeCall.dll differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/IntCall.asm b/vendor/nativecall/0.4.1/cpp/Debug/IntCall.asm new file mode 100644 index 0000000..7724ee0 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Debug/IntCall.asm @@ -0,0 +1,1766 @@ + TITLE C:\Documents and Settings\Administrator\My Documents\Software\NativeCall\src\cpp\IntCall.cpp + .386P +include listing.inc +if @Version gt 510 +.model FLAT +else +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' +_BSS ENDS +$$SYMBOLS SEGMENT BYTE USE32 'DEBSYM' +$$SYMBOLS ENDS +$$TYPES SEGMENT BYTE USE32 'DEBTYP' +$$TYPES ENDS +_TLS SEGMENT DWORD USE32 PUBLIC 'TLS' +_TLS ENDS +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ??8@YAHABU_GUID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_IntCall_executeCall@8 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_IntCall_executeCall0@12 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +FLAT GROUP _DATA, CONST, _BSS + ASSUME CS: FLAT, DS: FLAT, SS: FLAT +endif +PUBLIC ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField +PUBLIC ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +PUBLIC _Java_com_eaio_nativecall_IntCall_executeCall@8 +EXTRN __imp__GetLastError@0:NEAR +EXTRN ?fieldFunctionHandle@@3PAU_jfieldID@@A:DWORD ; fieldFunctionHandle +EXTRN ?fieldLastErrorCode@@3PAU_jfieldID@@A:DWORD ; fieldLastErrorCode +EXTRN __chkesp:NEAR +; COMDAT _Java_com_eaio_nativecall_IntCall_executeCall@8 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_functionHandle$ = -4 +_outVal$ = -8 +_Java_com_eaio_nativecall_IntCall_executeCall@8 PROC NEAR ; COMDAT + +; 79 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 80 : +; 81 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField + mov DWORD PTR _functionHandle$[ebp], eax + +; 82 : jint outVal; +; 83 : +; 84 : #ifdef _WINDOWS +; 85 : #ifdef _X86_ +; 86 : +; 87 : __asm { +; 88 : +; 89 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 90 : mov outVal, eax + + mov DWORD PTR _outVal$[ebp], eax + +; 91 : +; 92 : } +; 93 : +; 94 : #endif +; 95 : #endif +; 96 : +; 97 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov edx, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 98 : +; 99 : return outVal; + + mov eax, DWORD PTR _outVal$[ebp] + +; 100 : +; 101 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +_Java_com_eaio_nativecall_IntCall_executeCall@8 ENDP +_TEXT ENDS +PUBLIC ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField +PUBLIC ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ; JNIEnv_::SetObjectField +PUBLIC _Java_com_eaio_nativecall_IntCall_executeCall0@12 +PUBLIC ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z ; JNIEnv_::GetArrayLength +PUBLIC ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ; JNIEnv_::GetObjectArrayElement +PUBLIC ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' +PUBLIC ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical +PUBLIC ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ; JNIEnv_::ReleasePrimitiveArrayCritical +PUBLIC ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass +PUBLIC ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z ; JNIEnv_::ThrowNew +PUBLIC ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject +PUBLIC ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf +PUBLIC ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod +PUBLIC ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod +EXTRN ??2@YAPAXI@Z:NEAR ; operator new +EXTRN ??3@YAXPAX@Z:NEAR ; operator delete +EXTRN ?fieldHolderO@@3PAU_jfieldID@@A:DWORD ; fieldHolderO +EXTRN ?classBoolean@@3PAV_jclass@@A:DWORD ; classBoolean +EXTRN ?classInteger@@3PAV_jclass@@A:DWORD ; classInteger +EXTRN ?classByteArray@@3PAV_jclass@@A:DWORD ; classByteArray +EXTRN ?classCharArray@@3PAV_jclass@@A:DWORD ; classCharArray +EXTRN ?classHolder@@3PAV_jclass@@A:DWORD ; classHolder +EXTRN ?methodBooleanValue@@3PAU_jmethodID@@A:DWORD ; methodBooleanValue +EXTRN ?methodIntValue@@3PAU_jmethodID@@A:DWORD ; methodIntValue +EXTRN ?newIntegerInt@@3PAU_jmethodID@@A:DWORD ; newIntegerInt +EXTRN ?newBooleanBoolean@@3PAU_jmethodID@@A:DWORD ; newBooleanBoolean +EXTRN _memset:NEAR +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +; File c:\documents and settings\administrator\my documents\software\nativecall\src\cpp\intcall.cpp +CONST SEGMENT +??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ DB 'java/lang/OutOfMemor' + DB 'yError', 00H ; `string' +CONST ENDS +; COMDAT _Java_com_eaio_nativecall_IntCall_executeCall0@12 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_params$ = 16 +_len$ = -4 +_arrays$ = -8 +_param$ = -12 +_i$ = -16 +_intArg$56817 = -20 +_byteArrayArg$56820 = -24 +_charArrayArg$56826 = -28 +_booleanArg$56832 = -32 +_tempArg$56833 = -36 +_o$56836 = -40 +_intPtr$56838 = -44 +_byteArrayArg$56844 = -48 +_charArrayArg$56850 = -52 +_booleanArg$56856 = -56 +_tempPtr$56857 = -60 +_functionHandle$ = -64 +_outVal$ = -68 +_j$ = -72 +_o$56875 = -76 +_out$56877 = -80 +_out$56887 = -84 +$T56916 = -88 +$T56917 = -92 +$T56918 = -96 +$T56919 = -100 +$T56920 = -104 +$T56921 = -108 +_Java_com_eaio_nativecall_IntCall_executeCall0@12 PROC NEAR ; COMDAT + +; 109 : (JNIEnv *env, jobject obj, jobjectArray params) { + + push ebp + mov ebp, esp + sub esp, 172 ; 000000acH + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-172] + mov ecx, 43 ; 0000002bH + mov eax, -858993460 ; ccccccccH + rep stosd + +; 110 : +; 111 : const int len = env->GetArrayLength(params); + + mov eax, DWORD PTR _params$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z ; JNIEnv_::GetArrayLength + mov DWORD PTR _len$[ebp], eax + +; 112 : +; 113 : int* arrays = NULL; + + mov DWORD PTR _arrays$[ebp], 0 + +; 114 : if (!(arrays = new int[len])) { + + mov ecx, DWORD PTR _len$[ebp] + shl ecx, 2 + push ecx + call ??2@YAPAXI@Z ; operator new + add esp, 4 + mov DWORD PTR $T56916[ebp], eax + mov edx, DWORD PTR $T56916[ebp] + mov DWORD PTR _arrays$[ebp], edx + cmp DWORD PTR _arrays$[ebp], 0 + jne SHORT $L56806 + +; 115 : env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); + + push 0 + push OFFSET FLAT:??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z ; JNIEnv_::ThrowNew + +; 116 : return 0; + + xor eax, eax + jmp $L56801 +$L56806: + +; 118 : memset(arrays, 0, (sizeof(int) * len)); + + mov eax, DWORD PTR _len$[ebp] + shl eax, 2 + push eax + push 0 + mov ecx, DWORD PTR _arrays$[ebp] + push ecx + call _memset + add esp, 12 ; 0000000cH + +; 119 : +; 120 : jobject param; +; 121 : +; 122 : for (int i = len - 1; i >= 0; i--) { + + mov edx, DWORD PTR _len$[ebp] + sub edx, 1 + mov DWORD PTR _i$[ebp], edx + jmp SHORT $L56811 +$L56812: + mov eax, DWORD PTR _i$[ebp] + sub eax, 1 + mov DWORD PTR _i$[ebp], eax +$L56811: + cmp DWORD PTR _i$[ebp], 0 + jl $L56813 + +; 123 : +; 124 : param = env->GetObjectArrayElement(params, i); + + mov ecx, DWORD PTR _i$[ebp] + push ecx + mov edx, DWORD PTR _params$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ; JNIEnv_::GetObjectArrayElement + mov DWORD PTR _param$[ebp], eax + +; 125 : +; 126 : if (param == NULL) { + + cmp DWORD PTR _param$[ebp], 0 + jne SHORT $L56814 + +; 127 : _push(0); + + push 0 + +; 129 : else if (env->IsInstanceOf(param, classInteger)) { + + jmp $L56855 +$L56814: + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56816 + +; 130 : int intArg = env->CallIntMethod(param, methodIntValue); + + mov edx, DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + push ecx + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + add esp, 12 ; 0000000cH + mov DWORD PTR _intArg$56817[ebp], eax + +; 131 : _push(intArg) + + push DWORD PTR _intArg$56817[ebp] + +; 133 : else if (env->IsInstanceOf(param, classByteArray)) { + + jmp $L56855 +$L56816: + mov edx, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56819 + +; 134 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); + + push 0 + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _byteArrayArg$56820[ebp], eax + +; 135 : arrays[i] = (int) &byteArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _byteArrayArg$56820[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 136 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$56820[ebp] + +; 138 : else if (env->IsInstanceOf(param, classCharArray)) { + + jmp $L56855 +$L56819: + mov edx, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56825 + +; 139 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 140 : (jarray) param, 0); + + push 0 + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _charArrayArg$56826[ebp], eax + +; 141 : arrays[i] = (int) &charArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _charArrayArg$56826[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 142 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$56826[ebp] + +; 144 : else if (env->IsInstanceOf(param, classBoolean)) { + + jmp $L56855 +$L56825: + mov edx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56831 + +; 145 : jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); + + mov ecx, DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov eax, DWORD PTR _env$[ebp] + push eax + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + add esp, 12 ; 0000000cH + mov BYTE PTR _booleanArg$56832[ebp], al + +; 146 : int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); + + mov ecx, DWORD PTR _booleanArg$56832[ebp] + and ecx, 255 ; 000000ffH + neg ecx + sbb ecx, ecx + neg ecx + mov DWORD PTR _tempArg$56833[ebp], ecx + +; 147 : _push(tempArg) + + push DWORD PTR _tempArg$56833[ebp] + +; 149 : else if (env->IsInstanceOf(param, classHolder)) { + + jmp $L56855 +$L56831: + mov edx, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je $L56855 + +; 150 : +; 151 : /* Holder */ +; 152 : +; 153 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov ecx, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField + mov DWORD PTR _o$56836[ebp], eax + +; 154 : +; 155 : if (env->IsInstanceOf(o, classInteger)) { + + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + mov ecx, DWORD PTR _o$56836[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56837 + +; 156 : int *intPtr = new int; + + push 4 + call ??2@YAPAXI@Z ; operator new + add esp, 4 + mov DWORD PTR $T56917[ebp], eax + mov edx, DWORD PTR $T56917[ebp] + mov DWORD PTR _intPtr$56838[ebp], edx + +; 157 : *intPtr = env->CallIntMethod(o, methodIntValue); + + mov eax, DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push eax + mov ecx, DWORD PTR _o$56836[ebp] + push ecx + mov edx, DWORD PTR _env$[ebp] + push edx + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + add esp, 12 ; 0000000cH + mov ecx, DWORD PTR _intPtr$56838[ebp] + mov DWORD PTR [ecx], eax + +; 158 : arrays[i] = (int) intPtr; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + mov ecx, DWORD PTR _intPtr$56838[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 159 : _push(intPtr); + + push DWORD PTR _intPtr$56838[ebp] + +; 161 : else if (env->IsInstanceOf(o, classByteArray)) { + + jmp $L56855 +$L56837: + mov edx, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push edx + mov eax, DWORD PTR _o$56836[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56843 + +; 162 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); + + push 0 + mov ecx, DWORD PTR _o$56836[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _byteArrayArg$56844[ebp], eax + +; 163 : arrays[i] = (int) &byteArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _byteArrayArg$56844[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 164 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$56844[ebp] + +; 166 : else if (env->IsInstanceOf(o, classCharArray)) { + + jmp $L56855 +$L56843: + mov edx, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push edx + mov eax, DWORD PTR _o$56836[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56849 + +; 167 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 168 : (jarray) o, 0); + + push 0 + mov ecx, DWORD PTR _o$56836[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _charArrayArg$56850[ebp], eax + +; 169 : arrays[i] = (int) &charArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _charArrayArg$56850[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 170 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$56850[ebp] + +; 172 : else if (env->IsInstanceOf(o, classBoolean)) { + + jmp SHORT $L56855 +$L56849: + mov edx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push edx + mov eax, DWORD PTR _o$56836[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56855 + +; 173 : jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); + + mov ecx, DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ecx + mov edx, DWORD PTR _o$56836[ebp] + push edx + mov eax, DWORD PTR _env$[ebp] + push eax + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + add esp, 12 ; 0000000cH + mov BYTE PTR _booleanArg$56856[ebp], al + +; 174 : int *tempPtr = new int; + + push 4 + call ??2@YAPAXI@Z ; operator new + add esp, 4 + mov DWORD PTR $T56918[ebp], eax + mov ecx, DWORD PTR $T56918[ebp] + mov DWORD PTR _tempPtr$56857[ebp], ecx + +; 175 : *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); + + mov edx, DWORD PTR _booleanArg$56856[ebp] + and edx, 255 ; 000000ffH + neg edx + sbb edx, edx + neg edx + mov eax, DWORD PTR _tempPtr$56857[ebp] + mov DWORD PTR [eax], edx + +; 176 : arrays[i] = (int) tempPtr; + + mov ecx, DWORD PTR _i$[ebp] + mov edx, DWORD PTR _arrays$[ebp] + mov eax, DWORD PTR _tempPtr$56857[ebp] + mov DWORD PTR [edx+ecx*4], eax + +; 177 : _push(tempPtr); + + push DWORD PTR _tempPtr$56857[ebp] +$L56855: + +; 183 : +; 184 : } + + jmp $L56812 +$L56813: + +; 185 : +; 186 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov ecx, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField + mov DWORD PTR _functionHandle$[ebp], eax + +; 187 : jint outVal; +; 188 : +; 189 : #ifdef _WINDOWS +; 190 : #ifdef _X86_ +; 191 : +; 192 : __asm { +; 193 : +; 194 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 195 : mov outVal, eax + + mov DWORD PTR _outVal$[ebp], eax + +; 196 : +; 197 : } +; 198 : +; 199 : #endif +; 200 : #endif +; 201 : +; 202 : for (int j = 0; j < len; ++j) { + + mov DWORD PTR _j$[ebp], 0 + jmp SHORT $L56864 +$L56865: + mov eax, DWORD PTR _j$[ebp] + add eax, 1 + mov DWORD PTR _j$[ebp], eax +$L56864: + mov ecx, DWORD PTR _j$[ebp] + cmp ecx, DWORD PTR _len$[ebp] + jge $L56866 + +; 203 : param = env->GetObjectArrayElement(params, j); + + mov edx, DWORD PTR _j$[ebp] + push edx + mov eax, DWORD PTR _params$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ; JNIEnv_::GetObjectArrayElement + mov DWORD PTR _param$[ebp], eax + +; 204 : if (param == NULL) {} + + cmp DWORD PTR _param$[ebp], 0 + jne SHORT $L56867 + +; 205 : else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { + + jmp $L56886 +$L56867: + mov ecx, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + jne SHORT $L56870 + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56869 +$L56870: + +; 206 : env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); + + push 0 + mov edx, DWORD PTR _j$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + mov ecx, DWORD PTR [eax+edx*4] + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ; JNIEnv_::ReleasePrimitiveArrayCritical + +; 208 : else if (env->IsInstanceOf(param, classHolder)) { + + jmp $L56886 +$L56869: + mov eax, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je $L56886 + +; 209 : +; 210 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov edx, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField + mov DWORD PTR _o$56875[ebp], eax + +; 211 : +; 212 : if (env->IsInstanceOf(o, classInteger)) { + + mov ecx, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push ecx + mov edx, DWORD PTR _o$56875[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56876 + +; 213 : int* out = (int*) arrays[j]; + + mov eax, DWORD PTR _j$[ebp] + mov ecx, DWORD PTR _arrays$[ebp] + mov edx, DWORD PTR [ecx+eax*4] + mov DWORD PTR _out$56877[ebp], edx + +; 214 : env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); + + mov eax, DWORD PTR _out$56877[ebp] + mov ecx, DWORD PTR [eax] + push ecx + mov edx, DWORD PTR ?newIntegerInt@@3PAU_jmethodID@@A ; newIntegerInt + push edx + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + mov ecx, DWORD PTR _env$[ebp] + push ecx + call ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject + add esp, 16 ; 00000010H + push eax + mov edx, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ; JNIEnv_::SetObjectField + +; 215 : delete out; + + mov ecx, DWORD PTR _out$56877[ebp] + mov DWORD PTR $T56919[ebp], ecx + mov edx, DWORD PTR $T56919[ebp] + push edx + call ??3@YAXPAX@Z ; operator delete + add esp, 4 + +; 217 : else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { + + jmp $L56886 +$L56876: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push eax + mov ecx, DWORD PTR _o$56875[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + jne SHORT $L56882 + mov edx, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push edx + mov eax, DWORD PTR _o$56875[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56881 +$L56882: + +; 218 : env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); + + push 0 + mov ecx, DWORD PTR _j$[ebp] + mov edx, DWORD PTR _arrays$[ebp] + mov eax, DWORD PTR [edx+ecx*4] + push eax + mov ecx, DWORD PTR _o$56875[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ; JNIEnv_::ReleasePrimitiveArrayCritical + +; 220 : else if (env->IsInstanceOf(o, classBoolean)) { + + jmp SHORT $L56886 +$L56881: + mov edx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push edx + mov eax, DWORD PTR _o$56875[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56886 + +; 221 : int* out = (int*) arrays[j]; + + mov ecx, DWORD PTR _j$[ebp] + mov edx, DWORD PTR _arrays$[ebp] + mov eax, DWORD PTR [edx+ecx*4] + mov DWORD PTR _out$56887[ebp], eax + +; 222 : env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); + + mov ecx, DWORD PTR _out$56887[ebp] + xor edx, edx + cmp DWORD PTR [ecx], 0 + setne dl + push edx + mov eax, DWORD PTR ?newBooleanBoolean@@3PAU_jmethodID@@A ; newBooleanBoolean + push eax + mov ecx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push ecx + mov edx, DWORD PTR _env$[ebp] + push edx + call ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject + add esp, 16 ; 00000010H + push eax + mov eax, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ; JNIEnv_::SetObjectField + +; 223 : delete out; + + mov edx, DWORD PTR _out$56887[ebp] + mov DWORD PTR $T56920[ebp], edx + mov eax, DWORD PTR $T56920[ebp] + push eax + call ??3@YAXPAX@Z ; operator delete + add esp, 4 +$L56886: + +; 227 : +; 228 : } + + jmp $L56865 +$L56866: + +; 229 : +; 230 : delete [] arrays; + + mov ecx, DWORD PTR _arrays$[ebp] + mov DWORD PTR $T56921[ebp], ecx + mov edx, DWORD PTR $T56921[ebp] + push edx + call ??3@YAXPAX@Z ; operator delete + add esp, 4 + +; 231 : +; 232 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov eax, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 233 : +; 234 : return outVal; + + mov eax, DWORD PTR _outVal$[ebp] +$L56801: + +; 235 : +; 236 : } + + pop edi + pop esi + pop ebx + add esp, 172 ; 000000acH + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +_Java_com_eaio_nativecall_IntCall_executeCall0@12 ENDP +_TEXT ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_name$ = 8 +?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z PROC NEAR ; JNIEnv_::FindClass, COMDAT + +; 759 : jclass FindClass(const char *name) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 760 : return functions->FindClass(this, name); + + mov esi, esp + mov eax, DWORD PTR _name$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+24] + cmp esi, esp + call __chkesp + +; 761 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ENDP ; JNIEnv_::FindClass +_TEXT ENDS +; COMDAT ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_clazz$ = 8 +_msg$ = 12 +?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z PROC NEAR ; JNIEnv_::ThrowNew, COMDAT + +; 787 : jint ThrowNew(jclass clazz, const char *msg) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 788 : return functions->ThrowNew(this, clazz, msg); + + mov esi, esp + mov eax, DWORD PTR _msg$[ebp] + push eax + mov ecx, DWORD PTR _clazz$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+56] + cmp esi, esp + call __chkesp + +; 789 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z ENDP ; JNIEnv_::ThrowNew +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_args$ = -4 +_result$ = -8 +_clazz$ = 12 +_methodID$ = 16 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::NewObject, COMDAT + +; 834 : jobject NewObject(jclass clazz, jmethodID methodID, ...) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 835 : va_list args; +; 836 : jobject result; +; 837 : va_start(args, methodID); + + lea eax, DWORD PTR _methodID$[ebp+4] + mov DWORD PTR _args$[ebp], eax + +; 838 : result = functions->NewObjectV(this,clazz,methodID,args); + + mov esi, esp + mov ecx, DWORD PTR _args$[ebp] + push ecx + mov edx, DWORD PTR _methodID$[ebp] + push edx + mov eax, DWORD PTR _clazz$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+116] + cmp esi, esp + call __chkesp + mov DWORD PTR _result$[ebp], eax + +; 839 : va_end(args); + + mov DWORD PTR _args$[ebp], 0 + +; 840 : return result; + + mov eax, DWORD PTR _result$[ebp] + +; 841 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 0 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::NewObject +_TEXT ENDS +; COMDAT ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z +_TEXT SEGMENT +_this$ = -4 +_obj$ = 8 +_clazz$ = 12 +?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z PROC NEAR ; JNIEnv_::IsInstanceOf, COMDAT + +; 854 : jboolean IsInstanceOf(jobject obj, jclass clazz) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 855 : return functions->IsInstanceOf(this,obj,clazz); + + mov esi, esp + mov eax, DWORD PTR _clazz$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+128] + cmp esi, esp + call __chkesp + +; 856 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ENDP ; JNIEnv_::IsInstanceOf +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_args$ = -4 +_result$ = -8 +_obj$ = 12 +_methodID$ = 16 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallBooleanMethod, COMDAT + +; 881 : jmethodID methodID, ...) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 882 : va_list args; +; 883 : jboolean result; +; 884 : va_start(args,methodID); + + lea eax, DWORD PTR _methodID$[ebp+4] + mov DWORD PTR _args$[ebp], eax + +; 885 : result = functions->CallBooleanMethodV(this,obj,methodID,args); + + mov esi, esp + mov ecx, DWORD PTR _args$[ebp] + push ecx + mov edx, DWORD PTR _methodID$[ebp] + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+152] + cmp esi, esp + call __chkesp + mov BYTE PTR _result$[ebp], al + +; 886 : va_end(args); + + mov DWORD PTR _args$[ebp], 0 + +; 887 : return result; + + mov al, BYTE PTR _result$[ebp] + +; 888 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 0 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallBooleanMethod +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_args$ = -4 +_result$ = -8 +_obj$ = 12 +_methodID$ = 16 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallIntMethod, COMDAT + +; 949 : jint CallIntMethod(jobject obj, jmethodID methodID, ...) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 950 : va_list args; +; 951 : jint result; +; 952 : va_start(args,methodID); + + lea eax, DWORD PTR _methodID$[ebp+4] + mov DWORD PTR _args$[ebp], eax + +; 953 : result = functions->CallIntMethodV(this,obj,methodID,args); + + mov esi, esp + mov ecx, DWORD PTR _args$[ebp] + push ecx + mov edx, DWORD PTR _methodID$[ebp] + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+200] + cmp esi, esp + call __chkesp + mov DWORD PTR _result$[ebp], eax + +; 954 : va_end(args); + + mov DWORD PTR _args$[ebp], 0 + +; 955 : return result; + + mov eax, DWORD PTR _result$[ebp] + +; 956 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 0 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallIntMethod +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_this$ = -4 +?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z PROC NEAR ; JNIEnv_::GetObjectField, COMDAT + +; 1248 : jobject GetObjectField(jobject obj, jfieldID fieldID) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1249 : return functions->GetObjectField(this,obj,fieldID); + + mov esi, esp + mov eax, DWORD PTR _fieldID$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+380] + cmp esi, esp + call __chkesp + +; 1250 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ENDP ; JNIEnv_::GetObjectField +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_this$ = -4 +?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z PROC NEAR ; JNIEnv_::GetIntField, COMDAT + +; 1263 : jint GetIntField(jobject obj, jfieldID fieldID) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1264 : return functions->GetIntField(this,obj,fieldID); + + mov esi, esp + mov eax, DWORD PTR _fieldID$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+400] + cmp esi, esp + call __chkesp + +; 1265 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ENDP ; JNIEnv_::GetIntField +_TEXT ENDS +; COMDAT ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_val$ = 16 +_this$ = -4 +?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z PROC NEAR ; JNIEnv_::SetObjectField, COMDAT + +; 1276 : void SetObjectField(jobject obj, jfieldID fieldID, jobject val) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1277 : functions->SetObjectField(this,obj,fieldID,val); + + mov esi, esp + mov eax, DWORD PTR _val$[ebp] + push eax + mov ecx, DWORD PTR _fieldID$[ebp] + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+416] + cmp esi, esp + call __chkesp + +; 1278 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ENDP ; JNIEnv_::SetObjectField +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_val$ = 16 +_this$ = -4 +?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z PROC NEAR ; JNIEnv_::SetIntField, COMDAT + +; 1296 : jint val) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1297 : functions->SetIntField(this,obj,fieldID,val); + + mov esi, esp + mov eax, DWORD PTR _val$[ebp] + push eax + mov ecx, DWORD PTR _fieldID$[ebp] + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+436] + cmp esi, esp + call __chkesp + +; 1298 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ENDP ; JNIEnv_::SetIntField +_TEXT ENDS +; COMDAT ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z PROC NEAR ; JNIEnv_::GetArrayLength, COMDAT + +; 1589 : jsize GetArrayLength(jarray array) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1590 : return functions->GetArrayLength(this,array); + + mov esi, esp + mov eax, DWORD PTR _array$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+684] + cmp esi, esp + call __chkesp + +; 1591 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z ENDP ; JNIEnv_::GetArrayLength +_TEXT ENDS +; COMDAT ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +_index$ = 12 +?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z PROC NEAR ; JNIEnv_::GetObjectArrayElement, COMDAT + +; 1597 : jobject GetObjectArrayElement(jobjectArray array, jsize index) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1598 : return functions->GetObjectArrayElement(this,array,index); + + mov esi, esp + mov eax, DWORD PTR _index$[ebp] + push eax + mov ecx, DWORD PTR _array$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+692] + cmp esi, esp + call __chkesp + +; 1599 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ENDP ; JNIEnv_::GetObjectArrayElement +_TEXT ENDS +; COMDAT ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +_isCopy$ = 12 +?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z PROC NEAR ; JNIEnv_::GetPrimitiveArrayCritical, COMDAT + +; 1788 : void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1789 : return functions->GetPrimitiveArrayCritical(this,array,isCopy); + + mov esi, esp + mov eax, DWORD PTR _isCopy$[ebp] + push eax + mov ecx, DWORD PTR _array$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+888] + cmp esi, esp + call __chkesp + +; 1790 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ENDP ; JNIEnv_::GetPrimitiveArrayCritical +_TEXT ENDS +; COMDAT ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +_carray$ = 12 +_mode$ = 16 +?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z PROC NEAR ; JNIEnv_::ReleasePrimitiveArrayCritical, COMDAT + +; 1791 : void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1792 : functions->ReleasePrimitiveArrayCritical(this,array,carray,mode); + + mov esi, esp + mov eax, DWORD PTR _mode$[ebp] + push eax + mov ecx, DWORD PTR _carray$[ebp] + push ecx + mov edx, DWORD PTR _array$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+892] + cmp esi, esp + call __chkesp + +; 1793 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ENDP ; JNIEnv_::ReleasePrimitiveArrayCritical +_TEXT ENDS +END diff --git a/vendor/nativecall/0.4.1/cpp/Debug/IntCall.obj b/vendor/nativecall/0.4.1/cpp/Debug/IntCall.obj new file mode 100644 index 0000000..f33470a Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/IntCall.obj differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.asm b/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.asm new file mode 100644 index 0000000..8e38052 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.asm @@ -0,0 +1,1492 @@ + TITLE C:\Documents and Settings\Administrator\My Documents\Software\NativeCall\src\cpp\NativeCall.cpp + .386P +include listing.inc +if @Version gt 510 +.model FLAT +else +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' +_BSS ENDS +$$SYMBOLS SEGMENT BYTE USE32 'DEBSYM' +$$SYMBOLS ENDS +$$TYPES SEGMENT BYTE USE32 'DEBTYP' +$$TYPES ENDS +_TLS SEGMENT DWORD USE32 PUBLIC 'TLS' +_TLS ENDS +; COMDAT ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_08JJOG@function?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_06CODG@module?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_01FLOP@I?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0P@LKIL@functionHandle?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0N@EFAA@moduleHandle?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0O@OMHL@lastErrorCode?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_01PGHN@o?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0BB@LLFN@java?1lang?1String?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_02LOEJ@?$FLB?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_02BENO@?$FLC?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_03KJOK@?$CI?$CJZ?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_0N@KEBP@booleanValue?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_03PPCD@?$CI?$CJI?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_08JCMA@intValue?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_04ECLF@?$CII?$CJV?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_06KILP@?$DMinit?$DO?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ??_C@_04JFOE@?$CIZ?$CJV?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ??8@YAHABU_GUID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_NativeCall_initIDs@8 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_NativeCall_initHandles@8 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_NativeCall_getLastError@8 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_NativeCall_destroy@8 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +FLAT GROUP _DATA, CONST, _BSS + ASSUME CS: FLAT, DS: FLAT, SS: FLAT +endif +PUBLIC ?fieldFunction@@3PAU_jfieldID@@A ; fieldFunction +PUBLIC ?fieldModule@@3PAU_jfieldID@@A ; fieldModule +PUBLIC ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle +PUBLIC ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle +PUBLIC ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode +PUBLIC ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO +PUBLIC ?classBoolean@@3PAV_jclass@@A ; classBoolean +PUBLIC ?classInteger@@3PAV_jclass@@A ; classInteger +PUBLIC ?classString@@3PAV_jclass@@A ; classString +PUBLIC ?classByteArray@@3PAV_jclass@@A ; classByteArray +PUBLIC ?classCharArray@@3PAV_jclass@@A ; classCharArray +PUBLIC ?classHolder@@3PAV_jclass@@A ; classHolder +PUBLIC ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue +PUBLIC ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue +PUBLIC ?newIntegerInt@@3PAU_jmethodID@@A ; newIntegerInt +PUBLIC ?newBooleanBoolean@@3PAU_jmethodID@@A ; newBooleanBoolean +_BSS SEGMENT +?fieldFunction@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldFunction +?fieldModule@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldModule +?fieldFunctionHandle@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldFunctionHandle +?fieldModuleHandle@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldModuleHandle +?fieldLastErrorCode@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldLastErrorCode +?fieldHolderO@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldHolderO +?classBoolean@@3PAV_jclass@@A DD 01H DUP (?) ; classBoolean +?classInteger@@3PAV_jclass@@A DD 01H DUP (?) ; classInteger +?classString@@3PAV_jclass@@A DD 01H DUP (?) ; classString +?classByteArray@@3PAV_jclass@@A DD 01H DUP (?) ; classByteArray +?classCharArray@@3PAV_jclass@@A DD 01H DUP (?) ; classCharArray +?classHolder@@3PAV_jclass@@A DD 01H DUP (?) ; classHolder +?methodBooleanValue@@3PAU_jmethodID@@A DD 01H DUP (?) ; methodBooleanValue +?methodIntValue@@3PAU_jmethodID@@A DD 01H DUP (?) ; methodIntValue +?newIntegerInt@@3PAU_jmethodID@@A DD 01H DUP (?) ; newIntegerInt +?newBooleanBoolean@@3PAU_jmethodID@@A DD 01H DUP (?) ; newBooleanBoolean +_BSS ENDS +PUBLIC ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID +PUBLIC _Java_com_eaio_nativecall_NativeCall_initIDs@8 +PUBLIC ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ ; `string' +PUBLIC ??_C@_08JJOG@function?$AA@ ; `string' +PUBLIC ??_C@_06CODG@module?$AA@ ; `string' +PUBLIC ??_C@_01FLOP@I?$AA@ ; `string' +PUBLIC ??_C@_0P@LKIL@functionHandle?$AA@ ; `string' +PUBLIC ??_C@_0N@EFAA@moduleHandle?$AA@ ; `string' +PUBLIC ??_C@_0O@OMHL@lastErrorCode?$AA@ ; `string' +PUBLIC ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ ; `string' +PUBLIC ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ ; `string' +PUBLIC ??_C@_01PGHN@o?$AA@ ; `string' +PUBLIC ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ ; `string' +PUBLIC ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ ; `string' +PUBLIC ??_C@_0BB@LLFN@java?1lang?1String?$AA@ ; `string' +PUBLIC ??_C@_02LOEJ@?$FLB?$AA@ ; `string' +PUBLIC ??_C@_02BENO@?$FLC?$AA@ ; `string' +PUBLIC ??_C@_03KJOK@?$CI?$CJZ?$AA@ ; `string' +PUBLIC ??_C@_0N@KEBP@booleanValue?$AA@ ; `string' +PUBLIC ??_C@_03PPCD@?$CI?$CJI?$AA@ ; `string' +PUBLIC ??_C@_08JCMA@intValue?$AA@ ; `string' +PUBLIC ??_C@_04ECLF@?$CII?$CJV?$AA@ ; `string' +PUBLIC ??_C@_06KILP@?$DMinit?$DO?$AA@ ; `string' +PUBLIC ??_C@_04JFOE@?$CIZ?$CJV?$AA@ ; `string' +PUBLIC ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass +PUBLIC ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef +PUBLIC ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetMethodID +EXTRN __chkesp:NEAR +; COMDAT ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ +; File c:\documents and settings\administrator\my documents\software\nativecall\src\cpp\nativecall.cpp +CONST SEGMENT +??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ DB 'Ljava/lang/String;', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_08JJOG@function?$AA@ +CONST SEGMENT +??_C@_08JJOG@function?$AA@ DB 'function', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_06CODG@module?$AA@ +CONST SEGMENT +??_C@_06CODG@module?$AA@ DB 'module', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_01FLOP@I?$AA@ +CONST SEGMENT +??_C@_01FLOP@I?$AA@ DB 'I', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0P@LKIL@functionHandle?$AA@ +CONST SEGMENT +??_C@_0P@LKIL@functionHandle?$AA@ DB 'functionHandle', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0N@EFAA@moduleHandle?$AA@ +CONST SEGMENT +??_C@_0N@EFAA@moduleHandle?$AA@ DB 'moduleHandle', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0O@OMHL@lastErrorCode?$AA@ +CONST SEGMENT +??_C@_0O@OMHL@lastErrorCode?$AA@ DB 'lastErrorCode', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ +CONST SEGMENT +??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ DB 'com/eaio/nativecall' + DB '/Holder', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ +CONST SEGMENT +??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ DB 'Ljava/lang/Object;', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_01PGHN@o?$AA@ +CONST SEGMENT +??_C@_01PGHN@o?$AA@ DB 'o', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ +CONST SEGMENT +??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ DB 'java/lang/Boolean', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ +CONST SEGMENT +??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ DB 'java/lang/Integer', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0BB@LLFN@java?1lang?1String?$AA@ +CONST SEGMENT +??_C@_0BB@LLFN@java?1lang?1String?$AA@ DB 'java/lang/String', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_02LOEJ@?$FLB?$AA@ +CONST SEGMENT +??_C@_02LOEJ@?$FLB?$AA@ DB '[B', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_02BENO@?$FLC?$AA@ +CONST SEGMENT +??_C@_02BENO@?$FLC?$AA@ DB '[C', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_03KJOK@?$CI?$CJZ?$AA@ +CONST SEGMENT +??_C@_03KJOK@?$CI?$CJZ?$AA@ DB '()Z', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_0N@KEBP@booleanValue?$AA@ +CONST SEGMENT +??_C@_0N@KEBP@booleanValue?$AA@ DB 'booleanValue', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_03PPCD@?$CI?$CJI?$AA@ +CONST SEGMENT +??_C@_03PPCD@?$CI?$CJI?$AA@ DB '()I', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_08JCMA@intValue?$AA@ +CONST SEGMENT +??_C@_08JCMA@intValue?$AA@ DB 'intValue', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_04ECLF@?$CII?$CJV?$AA@ +CONST SEGMENT +??_C@_04ECLF@?$CII?$CJV?$AA@ DB '(I)V', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_06KILP@?$DMinit?$DO?$AA@ +CONST SEGMENT +??_C@_06KILP@?$DMinit?$DO?$AA@ DB '', 00H ; `string' +CONST ENDS +; COMDAT ??_C@_04JFOE@?$CIZ?$CJV?$AA@ +CONST SEGMENT +??_C@_04JFOE@?$CIZ?$CJV?$AA@ DB '(Z)V', 00H ; `string' +CONST ENDS +; COMDAT _Java_com_eaio_nativecall_NativeCall_initIDs@8 +_TEXT SEGMENT +_env$ = 8 +_cls$ = 12 +_Java_com_eaio_nativecall_NativeCall_initIDs@8 PROC NEAR ; COMDAT + +; 71 : (JNIEnv *env, jclass cls) { + + push ebp + mov ebp, esp + sub esp, 64 ; 00000040H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-64] + mov ecx, 16 ; 00000010H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 72 : +; 73 : // NativeCall fields +; 74 : +; 75 : fieldFunction = env->GetFieldID(cls, "function", "Ljava/lang/String;"); + + push OFFSET FLAT:??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ ; `string' + push OFFSET FLAT:??_C@_08JJOG@function?$AA@ ; `string' + mov eax, DWORD PTR _cls$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID + mov DWORD PTR ?fieldFunction@@3PAU_jfieldID@@A, eax ; fieldFunction + +; 76 : fieldModule = env->GetFieldID(cls, "module", "Ljava/lang/String;"); + + push OFFSET FLAT:??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ ; `string' + push OFFSET FLAT:??_C@_06CODG@module?$AA@ ; `string' + mov ecx, DWORD PTR _cls$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID + mov DWORD PTR ?fieldModule@@3PAU_jfieldID@@A, eax ; fieldModule + +; 77 : +; 78 : fieldFunctionHandle = env->GetFieldID(cls, "functionHandle", "I"); + + push OFFSET FLAT:??_C@_01FLOP@I?$AA@ ; `string' + push OFFSET FLAT:??_C@_0P@LKIL@functionHandle?$AA@ ; `string' + mov edx, DWORD PTR _cls$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID + mov DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A, eax ; fieldFunctionHandle + +; 79 : fieldModuleHandle = env-> GetFieldID(cls, "moduleHandle", "I"); + + push OFFSET FLAT:??_C@_01FLOP@I?$AA@ ; `string' + push OFFSET FLAT:??_C@_0N@EFAA@moduleHandle?$AA@ ; `string' + mov eax, DWORD PTR _cls$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID + mov DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A, eax ; fieldModuleHandle + +; 80 : +; 81 : fieldLastErrorCode = env->GetFieldID(cls, "lastErrorCode", "I"); + + push OFFSET FLAT:??_C@_01FLOP@I?$AA@ ; `string' + push OFFSET FLAT:??_C@_0O@OMHL@lastErrorCode?$AA@ ; `string' + mov ecx, DWORD PTR _cls$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID + mov DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A, eax ; fieldLastErrorCode + +; 82 : +; 83 : // Holder fields +; 84 : +; 85 : classHolder = (jclass) env->NewGlobalRef(env->FindClass("com/eaio/nativecall/Holder")); + + push OFFSET FLAT:??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef + mov DWORD PTR ?classHolder@@3PAV_jclass@@A, eax ; classHolder + +; 86 : fieldHolderO = env->GetFieldID(classHolder, "o", "Ljava/lang/Object;"); + + push OFFSET FLAT:??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ ; `string' + push OFFSET FLAT:??_C@_01PGHN@o?$AA@ ; `string' + mov edx, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetFieldID + mov DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A, eax ; fieldHolderO + +; 87 : +; 88 : // Other classes +; 89 : +; 90 : classBoolean = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Boolean")); + + push OFFSET FLAT:??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef + mov DWORD PTR ?classBoolean@@3PAV_jclass@@A, eax ; classBoolean + +; 91 : /*classByte = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Byte")); +; 92 : classCharacter = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Character")); +; 93 : classShort = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Short"));*/ +; 94 : classInteger = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Integer")); + + push OFFSET FLAT:??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef + mov DWORD PTR ?classInteger@@3PAV_jclass@@A, eax ; classInteger + +; 95 : /*classLong = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Long")); +; 96 : classFloat = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Float")); +; 97 : classDouble = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Double"));*/ +; 98 : classString = (jclass) env->NewGlobalRef(env->FindClass("java/lang/String")); + + push OFFSET FLAT:??_C@_0BB@LLFN@java?1lang?1String?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef + mov DWORD PTR ?classString@@3PAV_jclass@@A, eax ; classString + +; 99 : classByteArray = (jclass) env->NewGlobalRef(env->FindClass("[B")); + + push OFFSET FLAT:??_C@_02LOEJ@?$FLB?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef + mov DWORD PTR ?classByteArray@@3PAV_jclass@@A, eax ; classByteArray + +; 100 : classCharArray = (jclass) env->NewGlobalRef(env->FindClass("[C")); + + push OFFSET FLAT:??_C@_02BENO@?$FLC?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ; JNIEnv_::NewGlobalRef + mov DWORD PTR ?classCharArray@@3PAV_jclass@@A, eax ; classCharArray + +; 101 : /*classIntArray = (jclass) env->NewGlobalRef(env->FindClass("[I"));*/ +; 102 : +; 103 : // Wrapper class methods +; 104 : +; 105 : methodBooleanValue = env->GetMethodID(classBoolean, +; 106 : "booleanValue", "()Z"); + + push OFFSET FLAT:??_C@_03KJOK@?$CI?$CJZ?$AA@ ; `string' + push OFFSET FLAT:??_C@_0N@KEBP@booleanValue?$AA@ ; `string' + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetMethodID + mov DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A, eax ; methodBooleanValue + +; 107 : /*methodByteValue = env->GetMethodID(classByte, +; 108 : "byteValue", "()B"); +; 109 : methodCharValue = env->GetMethodID(classCharacter, +; 110 : "charValue", "()C"); +; 111 : methodShortValue = env->GetMethodID(classShort, +; 112 : "shortValue", "()S");*/ +; 113 : methodIntValue = env->GetMethodID(classInteger, +; 114 : "intValue", "()I"); + + push OFFSET FLAT:??_C@_03PPCD@?$CI?$CJI?$AA@ ; `string' + push OFFSET FLAT:??_C@_08JCMA@intValue?$AA@ ; `string' + mov ecx, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetMethodID + mov DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A, eax ; methodIntValue + +; 115 : /*methodLongValue = env->GetMethodID(classLong, +; 116 : "longValue", "()J"); +; 117 : methodFloatValue = env->GetMethodID(classFloat, +; 118 : "floatValue", "()F"); +; 119 : methodDoubleValue = env->GetMethodID(classDouble, +; 120 : "doubleValue", "()D");*/ +; 121 : +; 122 : // Constructors +; 123 : +; 124 : newIntegerInt = env->GetMethodID(classInteger, "", "(I)V"); + + push OFFSET FLAT:??_C@_04ECLF@?$CII?$CJV?$AA@ ; `string' + push OFFSET FLAT:??_C@_06KILP@?$DMinit?$DO?$AA@ ; `string' + mov edx, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetMethodID + mov DWORD PTR ?newIntegerInt@@3PAU_jmethodID@@A, eax ; newIntegerInt + +; 125 : newBooleanBoolean = env->GetMethodID(classBoolean, "", "(Z)V"); + + push OFFSET FLAT:??_C@_04JFOE@?$CIZ?$CJV?$AA@ ; `string' + push OFFSET FLAT:??_C@_06KILP@?$DMinit?$DO?$AA@ ; `string' + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z ; JNIEnv_::GetMethodID + mov DWORD PTR ?newBooleanBoolean@@3PAU_jmethodID@@A, eax ; newBooleanBoolean + +; 126 : +; 127 : } + + pop edi + pop esi + pop ebx + add esp, 64 ; 00000040H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +_Java_com_eaio_nativecall_NativeCall_initIDs@8 ENDP +_TEXT ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_name$ = 8 +?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z PROC NEAR ; JNIEnv_::FindClass, COMDAT + +; 759 : jclass FindClass(const char *name) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 760 : return functions->FindClass(this, name); + + mov esi, esp + mov eax, DWORD PTR _name$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+24] + cmp esi, esp + call __chkesp + +; 761 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ENDP ; JNIEnv_::FindClass +_TEXT ENDS +PUBLIC ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField +PUBLIC ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +PUBLIC _Java_com_eaio_nativecall_NativeCall_initHandles@8 +PUBLIC ?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z ; JNIEnv_::GetStringUTFChars +PUBLIC ?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z ; JNIEnv_::ReleaseStringUTFChars +EXTRN __imp__LoadLibraryA@4:NEAR +EXTRN __imp__GetLastError@0:NEAR +EXTRN __imp__FreeLibrary@4:NEAR +EXTRN __imp__GetProcAddress@8:NEAR +; COMDAT _Java_com_eaio_nativecall_NativeCall_initHandles@8 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_out$ = -4 +_moduleNameS$ = -8 +_functionNameS$ = -12 +_moduleName$ = -16 +_functionName$ = -20 +_mod$ = -24 +_addr$56841 = -28 +_Java_com_eaio_nativecall_NativeCall_initHandles@8 PROC NEAR ; COMDAT + +; 135 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + sub esp, 92 ; 0000005cH + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-92] + mov ecx, 23 ; 00000017H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 136 : +; 137 : bool out = JNI_TRUE; + + mov BYTE PTR _out$[ebp], 1 + +; 138 : +; 139 : jstring moduleNameS = (jstring) env->GetObjectField(obj, fieldModule); + + mov eax, DWORD PTR ?fieldModule@@3PAU_jfieldID@@A ; fieldModule + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField + mov DWORD PTR _moduleNameS$[ebp], eax + +; 140 : jstring functionNameS = (jstring) env->GetObjectField(obj, fieldFunction); + + mov edx, DWORD PTR ?fieldFunction@@3PAU_jfieldID@@A ; fieldFunction + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField + mov DWORD PTR _functionNameS$[ebp], eax + +; 141 : +; 142 : const char* moduleName = env->GetStringUTFChars(moduleNameS, 0); + + push 0 + mov ecx, DWORD PTR _moduleNameS$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z ; JNIEnv_::GetStringUTFChars + mov DWORD PTR _moduleName$[ebp], eax + +; 143 : const char* functionName = env->GetStringUTFChars(functionNameS, 0); + + push 0 + mov edx, DWORD PTR _functionNameS$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z ; JNIEnv_::GetStringUTFChars + mov DWORD PTR _functionName$[ebp], eax + +; 144 : +; 145 : #ifdef _WINDOWS +; 146 : +; 147 : HMODULE mod = LoadLibrary(moduleName); + + mov esi, esp + mov eax, DWORD PTR _moduleName$[ebp] + push eax + call DWORD PTR __imp__LoadLibraryA@4 + cmp esi, esp + call __chkesp + mov DWORD PTR _mod$[ebp], eax + +; 148 : +; 149 : if (mod == NULL) { + + cmp DWORD PTR _mod$[ebp], 0 + jne SHORT $L56839 + +; 150 : /* no such module or DllMain returned FALSE */ +; 151 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov ecx, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 152 : out = JNI_FALSE; + + mov BYTE PTR _out$[ebp], 0 + +; 154 : else { + + jmp $L56843 +$L56839: + +; 155 : FARPROC addr = GetProcAddress(mod, functionName); + + mov esi, esp + mov eax, DWORD PTR _functionName$[ebp] + push eax + mov ecx, DWORD PTR _mod$[ebp] + push ecx + call DWORD PTR __imp__GetProcAddress@8 + cmp esi, esp + call __chkesp + mov DWORD PTR _addr$56841[ebp], eax + +; 156 : if (addr == NULL) { + + cmp DWORD PTR _addr$56841[ebp], 0 + jne SHORT $L56842 + +; 157 : /* function not found */ +; 158 : FreeLibrary(mod); + + mov esi, esp + mov edx, DWORD PTR _mod$[ebp] + push edx + call DWORD PTR __imp__FreeLibrary@4 + cmp esi, esp + call __chkesp + +; 159 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov eax, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 160 : out = JNI_FALSE; + + mov BYTE PTR _out$[ebp], 0 + +; 162 : else { + + jmp SHORT $L56843 +$L56842: + +; 163 : /* all ok */ +; 164 : env->SetIntField(obj, fieldModuleHandle, (jint) mod); + + mov edx, DWORD PTR _mod$[ebp] + push edx + mov eax, DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 165 : env->SetIntField(obj, fieldFunctionHandle, (jint) addr); + + mov edx, DWORD PTR _addr$56841[ebp] + push edx + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +$L56843: + +; 168 : +; 169 : #endif +; 170 : +; 171 : env->ReleaseStringUTFChars(moduleNameS, moduleName); + + mov edx, DWORD PTR _moduleName$[ebp] + push edx + mov eax, DWORD PTR _moduleNameS$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z ; JNIEnv_::ReleaseStringUTFChars + +; 172 : env->ReleaseStringUTFChars(functionNameS, functionName); + + mov ecx, DWORD PTR _functionName$[ebp] + push ecx + mov edx, DWORD PTR _functionNameS$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z ; JNIEnv_::ReleaseStringUTFChars + +; 173 : +; 174 : return out; + + mov al, BYTE PTR _out$[ebp] + +; 175 : +; 176 : } + + pop edi + pop esi + pop ebx + add esp, 92 ; 0000005cH + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +_Java_com_eaio_nativecall_NativeCall_initHandles@8 ENDP +_TEXT ENDS +PUBLIC ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField +PUBLIC _Java_com_eaio_nativecall_NativeCall_getLastError@8 +PUBLIC ?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z ; JNIEnv_::NewStringUTF +EXTRN __imp__FormatMessageA@28:NEAR +EXTRN __imp__LocalFree@4:NEAR +; COMDAT _Java_com_eaio_nativecall_NativeCall_getLastError@8 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_lastError$ = -4 +_out$ = -8 +_msgBufPtr$ = -12 +_Java_com_eaio_nativecall_NativeCall_getLastError@8 PROC NEAR ; COMDAT + +; 184 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + sub esp, 76 ; 0000004cH + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-76] + mov ecx, 19 ; 00000013H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 185 : +; 186 : jint lastError = env->GetIntField(obj, fieldLastErrorCode); + + mov eax, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField + mov DWORD PTR _lastError$[ebp], eax + +; 187 : +; 188 : if (lastError == 0) return NULL; + + cmp DWORD PTR _lastError$[ebp], 0 + jne SHORT $L56851 + xor eax, eax + jmp SHORT $L56849 +$L56851: + +; 189 : +; 190 : jstring out = NULL; + + mov DWORD PTR _out$[ebp], 0 + +; 191 : +; 192 : #ifdef _WINDOWS +; 193 : +; 194 : LPVOID msgBufPtr = NULL; + + mov DWORD PTR _msgBufPtr$[ebp], 0 + +; 195 : FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | +; 196 : FORMAT_MESSAGE_FROM_SYSTEM, NULL, lastError, 0, +; 197 : (LPSTR) &msgBufPtr, 0, NULL); + + mov esi, esp + push 0 + push 0 + lea edx, DWORD PTR _msgBufPtr$[ebp] + push edx + push 0 + mov eax, DWORD PTR _lastError$[ebp] + push eax + push 0 + push 4352 ; 00001100H + call DWORD PTR __imp__FormatMessageA@28 + cmp esi, esp + call __chkesp + +; 198 : +; 199 : out = env->NewStringUTF((char*) msgBufPtr); + + mov ecx, DWORD PTR _msgBufPtr$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z ; JNIEnv_::NewStringUTF + mov DWORD PTR _out$[ebp], eax + +; 200 : +; 201 : LocalFree(msgBufPtr); + + mov esi, esp + mov edx, DWORD PTR _msgBufPtr$[ebp] + push edx + call DWORD PTR __imp__LocalFree@4 + cmp esi, esp + call __chkesp + +; 202 : +; 203 : #endif +; 204 : +; 205 : return out; + + mov eax, DWORD PTR _out$[ebp] +$L56849: + +; 206 : +; 207 : } + + pop edi + pop esi + pop ebx + add esp, 76 ; 0000004cH + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +_Java_com_eaio_nativecall_NativeCall_getLastError@8 ENDP +_TEXT ENDS +PUBLIC _Java_com_eaio_nativecall_NativeCall_destroy@8 +; COMDAT _Java_com_eaio_nativecall_NativeCall_destroy@8 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_module$ = -4 +_Java_com_eaio_nativecall_NativeCall_destroy@8 PROC NEAR ; COMDAT + +; 215 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 216 : +; 217 : jint module = env->GetIntField(obj, fieldModuleHandle); + + mov eax, DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField + mov DWORD PTR _module$[ebp], eax + +; 218 : +; 219 : if (module == 0) return; + + cmp DWORD PTR _module$[ebp], 0 + jne SHORT $L56861 + jmp SHORT $L56859 +$L56861: + +; 220 : +; 221 : #ifdef _WINDOWS +; 222 : +; 223 : if (FreeLibrary((HMODULE) module) == 0) { + + mov esi, esp + mov edx, DWORD PTR _module$[ebp] + push edx + call DWORD PTR __imp__FreeLibrary@4 + cmp esi, esp + call __chkesp + test eax, eax + jne SHORT $L56863 + +; 224 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov eax, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +$L56863: + +; 226 : +; 227 : #endif +; 228 : +; 229 : env->SetIntField(obj, fieldModuleHandle, 0); + + push 0 + mov edx, DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 230 : env->SetIntField(obj, fieldFunctionHandle, 0); + + push 0 + mov ecx, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +$L56859: + +; 231 : +; 232 : return; +; 233 : +; 234 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +_Java_com_eaio_nativecall_NativeCall_destroy@8 ENDP +_TEXT ENDS +; COMDAT ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z +_TEXT SEGMENT +_this$ = -4 +_lobj$ = 8 +?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z PROC NEAR ; JNIEnv_::NewGlobalRef, COMDAT + +; 810 : jobject NewGlobalRef(jobject lobj) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 811 : return functions->NewGlobalRef(this,lobj); + + mov esi, esp + mov eax, DWORD PTR _lobj$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+84] + cmp esi, esp + call __chkesp + +; 812 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z ENDP ; JNIEnv_::NewGlobalRef +_TEXT ENDS +; COMDAT ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z +_TEXT SEGMENT +_this$ = -4 +_clazz$ = 8 +_name$ = 12 +_sig$ = 16 +?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z PROC NEAR ; JNIEnv_::GetMethodID, COMDAT + +; 859 : const char *sig) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 860 : return functions->GetMethodID(this,clazz,name,sig); + + mov esi, esp + mov eax, DWORD PTR _sig$[ebp] + push eax + mov ecx, DWORD PTR _name$[ebp] + push ecx + mov edx, DWORD PTR _clazz$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+132] + cmp esi, esp + call __chkesp + +; 861 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z ENDP ; JNIEnv_::GetMethodID +_TEXT ENDS +; COMDAT ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z +_TEXT SEGMENT +_clazz$ = 8 +_name$ = 12 +_sig$ = 16 +_this$ = -4 +?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z PROC NEAR ; JNIEnv_::GetFieldID, COMDAT + +; 1244 : const char *sig) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1245 : return functions->GetFieldID(this,clazz,name,sig); + + mov esi, esp + mov eax, DWORD PTR _sig$[ebp] + push eax + mov ecx, DWORD PTR _name$[ebp] + push ecx + mov edx, DWORD PTR _clazz$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+376] + cmp esi, esp + call __chkesp + +; 1246 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z ENDP ; JNIEnv_::GetFieldID +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_this$ = -4 +?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z PROC NEAR ; JNIEnv_::GetObjectField, COMDAT + +; 1248 : jobject GetObjectField(jobject obj, jfieldID fieldID) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1249 : return functions->GetObjectField(this,obj,fieldID); + + mov esi, esp + mov eax, DWORD PTR _fieldID$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+380] + cmp esi, esp + call __chkesp + +; 1250 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ENDP ; JNIEnv_::GetObjectField +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_this$ = -4 +?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z PROC NEAR ; JNIEnv_::GetIntField, COMDAT + +; 1263 : jint GetIntField(jobject obj, jfieldID fieldID) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1264 : return functions->GetIntField(this,obj,fieldID); + + mov esi, esp + mov eax, DWORD PTR _fieldID$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+400] + cmp esi, esp + call __chkesp + +; 1265 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ENDP ; JNIEnv_::GetIntField +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_val$ = 16 +_this$ = -4 +?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z PROC NEAR ; JNIEnv_::SetIntField, COMDAT + +; 1296 : jint val) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1297 : functions->SetIntField(this,obj,fieldID,val); + + mov esi, esp + mov eax, DWORD PTR _val$[ebp] + push eax + mov ecx, DWORD PTR _fieldID$[ebp] + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+436] + cmp esi, esp + call __chkesp + +; 1298 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ENDP ; JNIEnv_::SetIntField +_TEXT ENDS +; COMDAT ?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_utf$ = 8 +?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z PROC NEAR ; JNIEnv_::NewStringUTF, COMDAT + +; 1576 : jstring NewStringUTF(const char *utf) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1577 : return functions->NewStringUTF(this,utf); + + mov esi, esp + mov eax, DWORD PTR _utf$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+668] + cmp esi, esp + call __chkesp + +; 1578 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z ENDP ; JNIEnv_::NewStringUTF +_TEXT ENDS +; COMDAT ?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z +_TEXT SEGMENT +_this$ = -4 +_str$ = 8 +_isCopy$ = 12 +?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z PROC NEAR ; JNIEnv_::GetStringUTFChars, COMDAT + +; 1582 : const char* GetStringUTFChars(jstring str, jboolean *isCopy) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1583 : return functions->GetStringUTFChars(this,str,isCopy); + + mov esi, esp + mov eax, DWORD PTR _isCopy$[ebp] + push eax + mov ecx, DWORD PTR _str$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+676] + cmp esi, esp + call __chkesp + +; 1584 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z ENDP ; JNIEnv_::GetStringUTFChars +_TEXT ENDS +; COMDAT ?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_str$ = 8 +_chars$ = 12 +?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z PROC NEAR ; JNIEnv_::ReleaseStringUTFChars, COMDAT + +; 1585 : void ReleaseStringUTFChars(jstring str, const char* chars) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1586 : functions->ReleaseStringUTFChars(this,str,chars); + + mov esi, esp + mov eax, DWORD PTR _chars$[ebp] + push eax + mov ecx, DWORD PTR _str$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+680] + cmp esi, esp + call __chkesp + +; 1587 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z ENDP ; JNIEnv_::ReleaseStringUTFChars +_TEXT ENDS +END diff --git a/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.dll b/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.dll new file mode 100644 index 0000000..fa9a51b Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.dll differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.obj b/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.obj new file mode 100644 index 0000000..670355f Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/NativeCall.obj differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/RCa01372 b/vendor/nativecall/0.4.1/cpp/Debug/RCa01372 new file mode 100644 index 0000000..eb8e4b1 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/RCa01372 differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/RCa01444 b/vendor/nativecall/0.4.1/cpp/Debug/RCa01444 new file mode 100644 index 0000000..eb8e4b1 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/RCa01444 differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/RCa01468 b/vendor/nativecall/0.4.1/cpp/Debug/RCa01468 new file mode 100644 index 0000000..eb8e4b1 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/RCa01468 differ diff --git a/vendor/nativecall/0.4.1/cpp/Debug/VoidCall.asm b/vendor/nativecall/0.4.1/cpp/Debug/VoidCall.asm new file mode 100644 index 0000000..c64965e --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Debug/VoidCall.asm @@ -0,0 +1,1743 @@ + TITLE C:\Documents and Settings\Administrator\My Documents\Software\NativeCall\src\cpp\VoidCall.cpp + .386P +include listing.inc +if @Version gt 510 +.model FLAT +else +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' +_BSS ENDS +$$SYMBOLS SEGMENT BYTE USE32 'DEBSYM' +$$SYMBOLS ENDS +$$TYPES SEGMENT BYTE USE32 'DEBTYP' +$$TYPES ENDS +_TLS SEGMENT DWORD USE32 PUBLIC 'TLS' +_TLS ENDS +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ??8@YAHABU_GUID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_VoidCall_executeCall@8 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT _Java_com_eaio_nativecall_VoidCall_executeCall0@12 +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +FLAT GROUP _DATA, CONST, _BSS + ASSUME CS: FLAT, DS: FLAT, SS: FLAT +endif +PUBLIC ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField +PUBLIC ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +PUBLIC _Java_com_eaio_nativecall_VoidCall_executeCall@8 +EXTRN __imp__GetLastError@0:NEAR +EXTRN ?fieldFunctionHandle@@3PAU_jfieldID@@A:DWORD ; fieldFunctionHandle +EXTRN ?fieldLastErrorCode@@3PAU_jfieldID@@A:DWORD ; fieldLastErrorCode +EXTRN __chkesp:NEAR +; COMDAT _Java_com_eaio_nativecall_VoidCall_executeCall@8 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_functionHandle$ = -4 +_Java_com_eaio_nativecall_VoidCall_executeCall@8 PROC NEAR ; COMDAT + +; 79 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 80 : +; 81 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField + mov DWORD PTR _functionHandle$[ebp], eax + +; 82 : +; 83 : #ifdef _WINDOWS +; 84 : #ifdef _X86_ +; 85 : +; 86 : __asm { +; 87 : +; 88 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 89 : +; 90 : } +; 91 : +; 92 : #endif +; 93 : #endif +; 94 : +; 95 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov edx, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField + +; 96 : +; 97 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +_Java_com_eaio_nativecall_VoidCall_executeCall@8 ENDP +_TEXT ENDS +PUBLIC ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField +PUBLIC ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ; JNIEnv_::SetObjectField +PUBLIC _Java_com_eaio_nativecall_VoidCall_executeCall0@12 +PUBLIC ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z ; JNIEnv_::GetArrayLength +PUBLIC ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ; JNIEnv_::GetObjectArrayElement +PUBLIC ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' +PUBLIC ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical +PUBLIC ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ; JNIEnv_::ReleasePrimitiveArrayCritical +PUBLIC ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass +PUBLIC ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z ; JNIEnv_::ThrowNew +PUBLIC ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject +PUBLIC ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf +PUBLIC ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod +PUBLIC ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod +EXTRN ??2@YAPAXI@Z:NEAR ; operator new +EXTRN ??3@YAXPAX@Z:NEAR ; operator delete +EXTRN ?fieldHolderO@@3PAU_jfieldID@@A:DWORD ; fieldHolderO +EXTRN ?classBoolean@@3PAV_jclass@@A:DWORD ; classBoolean +EXTRN ?classInteger@@3PAV_jclass@@A:DWORD ; classInteger +EXTRN ?classByteArray@@3PAV_jclass@@A:DWORD ; classByteArray +EXTRN ?classCharArray@@3PAV_jclass@@A:DWORD ; classCharArray +EXTRN ?classHolder@@3PAV_jclass@@A:DWORD ; classHolder +EXTRN ?methodBooleanValue@@3PAU_jmethodID@@A:DWORD ; methodBooleanValue +EXTRN ?methodIntValue@@3PAU_jmethodID@@A:DWORD ; methodIntValue +EXTRN ?newIntegerInt@@3PAU_jmethodID@@A:DWORD ; newIntegerInt +EXTRN ?newBooleanBoolean@@3PAU_jmethodID@@A:DWORD ; newBooleanBoolean +EXTRN _memset:NEAR +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +; File c:\documents and settings\administrator\my documents\software\nativecall\src\cpp\voidcall.cpp +CONST SEGMENT +??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ DB 'java/lang/OutOfMemor' + DB 'yError', 00H ; `string' +CONST ENDS +; COMDAT _Java_com_eaio_nativecall_VoidCall_executeCall0@12 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_params$ = 16 +_len$ = -4 +_arrays$ = -8 +_param$ = -12 +_i$ = -16 +_intArg$56816 = -20 +_byteArrayArg$56819 = -24 +_charArrayArg$56825 = -28 +_booleanArg$56831 = -32 +_tempArg$56832 = -36 +_o$56835 = -40 +_intPtr$56837 = -44 +_byteArrayArg$56843 = -48 +_charArrayArg$56849 = -52 +_booleanArg$56855 = -56 +_tempPtr$56856 = -60 +_functionHandle$ = -64 +_j$ = -68 +_o$56873 = -72 +_out$56875 = -76 +_out$56885 = -80 +$T56914 = -84 +$T56915 = -88 +$T56916 = -92 +$T56917 = -96 +$T56918 = -100 +$T56919 = -104 +_Java_com_eaio_nativecall_VoidCall_executeCall0@12 PROC NEAR ; COMDAT + +; 105 : (JNIEnv *env, jobject obj, jobjectArray params) { + + push ebp + mov ebp, esp + sub esp, 168 ; 000000a8H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-168] + mov ecx, 42 ; 0000002aH + mov eax, -858993460 ; ccccccccH + rep stosd + +; 106 : +; 107 : const int len = env->GetArrayLength(params); + + mov eax, DWORD PTR _params$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z ; JNIEnv_::GetArrayLength + mov DWORD PTR _len$[ebp], eax + +; 108 : +; 109 : int* arrays = NULL; + + mov DWORD PTR _arrays$[ebp], 0 + +; 110 : if (!(arrays = new int[len])) { + + mov ecx, DWORD PTR _len$[ebp] + shl ecx, 2 + push ecx + call ??2@YAPAXI@Z ; operator new + add esp, 4 + mov DWORD PTR $T56914[ebp], eax + mov edx, DWORD PTR $T56914[ebp] + mov DWORD PTR _arrays$[ebp], edx + cmp DWORD PTR _arrays$[ebp], 0 + jne SHORT $L56805 + +; 111 : env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); + + push 0 + push OFFSET FLAT:??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' + mov ecx, DWORD PTR _env$[ebp] + call ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ; JNIEnv_::FindClass + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z ; JNIEnv_::ThrowNew + +; 112 : return; + + jmp $L56800 +$L56805: + +; 114 : memset(arrays, 0, (sizeof(int) * len)); + + mov eax, DWORD PTR _len$[ebp] + shl eax, 2 + push eax + push 0 + mov ecx, DWORD PTR _arrays$[ebp] + push ecx + call _memset + add esp, 12 ; 0000000cH + +; 115 : +; 116 : jobject param; +; 117 : +; 118 : for (int i = len - 1; i >= 0; i--) { + + mov edx, DWORD PTR _len$[ebp] + sub edx, 1 + mov DWORD PTR _i$[ebp], edx + jmp SHORT $L56810 +$L56811: + mov eax, DWORD PTR _i$[ebp] + sub eax, 1 + mov DWORD PTR _i$[ebp], eax +$L56810: + cmp DWORD PTR _i$[ebp], 0 + jl $L56812 + +; 119 : +; 120 : param = env->GetObjectArrayElement(params, i); + + mov ecx, DWORD PTR _i$[ebp] + push ecx + mov edx, DWORD PTR _params$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ; JNIEnv_::GetObjectArrayElement + mov DWORD PTR _param$[ebp], eax + +; 121 : +; 122 : if (param == NULL) { + + cmp DWORD PTR _param$[ebp], 0 + jne SHORT $L56813 + +; 123 : _push(0); + + push 0 + +; 125 : else if (env->IsInstanceOf(param, classInteger)) { + + jmp $L56854 +$L56813: + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56815 + +; 126 : int intArg = env->CallIntMethod(param, methodIntValue); + + mov edx, DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + push ecx + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + add esp, 12 ; 0000000cH + mov DWORD PTR _intArg$56816[ebp], eax + +; 127 : _push(intArg) + + push DWORD PTR _intArg$56816[ebp] + +; 129 : else if (env->IsInstanceOf(param, classByteArray)) { + + jmp $L56854 +$L56815: + mov edx, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56818 + +; 130 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); + + push 0 + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _byteArrayArg$56819[ebp], eax + +; 131 : arrays[i] = (int) &byteArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _byteArrayArg$56819[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 132 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$56819[ebp] + +; 134 : else if (env->IsInstanceOf(param, classCharArray)) { + + jmp $L56854 +$L56818: + mov edx, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56824 + +; 135 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 136 : (jarray) param, 0); + + push 0 + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _charArrayArg$56825[ebp], eax + +; 137 : arrays[i] = (int) &charArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _charArrayArg$56825[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 138 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$56825[ebp] + +; 140 : else if (env->IsInstanceOf(param, classBoolean)) { + + jmp $L56854 +$L56824: + mov edx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56830 + +; 141 : jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); + + mov ecx, DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov eax, DWORD PTR _env$[ebp] + push eax + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + add esp, 12 ; 0000000cH + mov BYTE PTR _booleanArg$56831[ebp], al + +; 142 : int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); + + mov ecx, DWORD PTR _booleanArg$56831[ebp] + and ecx, 255 ; 000000ffH + neg ecx + sbb ecx, ecx + neg ecx + mov DWORD PTR _tempArg$56832[ebp], ecx + +; 143 : _push(tempArg) + + push DWORD PTR _tempArg$56832[ebp] + +; 145 : else if (env->IsInstanceOf(param, classHolder)) { + + jmp $L56854 +$L56830: + mov edx, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je $L56854 + +; 146 : +; 147 : /* Holder */ +; 148 : +; 149 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov ecx, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField + mov DWORD PTR _o$56835[ebp], eax + +; 150 : +; 151 : if (env->IsInstanceOf(o, classInteger)) { + + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + mov ecx, DWORD PTR _o$56835[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56836 + +; 152 : int *intPtr = new int; + + push 4 + call ??2@YAPAXI@Z ; operator new + add esp, 4 + mov DWORD PTR $T56915[ebp], eax + mov edx, DWORD PTR $T56915[ebp] + mov DWORD PTR _intPtr$56837[ebp], edx + +; 153 : *intPtr = env->CallIntMethod(o, methodIntValue); + + mov eax, DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push eax + mov ecx, DWORD PTR _o$56835[ebp] + push ecx + mov edx, DWORD PTR _env$[ebp] + push edx + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + add esp, 12 ; 0000000cH + mov ecx, DWORD PTR _intPtr$56837[ebp] + mov DWORD PTR [ecx], eax + +; 154 : arrays[i] = (int) intPtr; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + mov ecx, DWORD PTR _intPtr$56837[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 155 : _push(intPtr); + + push DWORD PTR _intPtr$56837[ebp] + +; 157 : else if (env->IsInstanceOf(o, classByteArray)) { + + jmp $L56854 +$L56836: + mov edx, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push edx + mov eax, DWORD PTR _o$56835[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56842 + +; 158 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); + + push 0 + mov ecx, DWORD PTR _o$56835[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _byteArrayArg$56843[ebp], eax + +; 159 : arrays[i] = (int) &byteArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _byteArrayArg$56843[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 160 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$56843[ebp] + +; 162 : else if (env->IsInstanceOf(o, classCharArray)) { + + jmp $L56854 +$L56842: + mov edx, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push edx + mov eax, DWORD PTR _o$56835[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56848 + +; 163 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 164 : (jarray) o, 0); + + push 0 + mov ecx, DWORD PTR _o$56835[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ; JNIEnv_::GetPrimitiveArrayCritical + mov DWORD PTR _charArrayArg$56849[ebp], eax + +; 165 : arrays[i] = (int) &charArrayArg; + + mov edx, DWORD PTR _i$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + lea ecx, DWORD PTR _charArrayArg$56849[ebp] + mov DWORD PTR [eax+edx*4], ecx + +; 166 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$56849[ebp] + +; 168 : else if (env->IsInstanceOf(o, classBoolean)) { + + jmp SHORT $L56854 +$L56848: + mov edx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push edx + mov eax, DWORD PTR _o$56835[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56854 + +; 169 : jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); + + mov ecx, DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ecx + mov edx, DWORD PTR _o$56835[ebp] + push edx + mov eax, DWORD PTR _env$[ebp] + push eax + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + add esp, 12 ; 0000000cH + mov BYTE PTR _booleanArg$56855[ebp], al + +; 170 : int *tempPtr = new int; + + push 4 + call ??2@YAPAXI@Z ; operator new + add esp, 4 + mov DWORD PTR $T56916[ebp], eax + mov ecx, DWORD PTR $T56916[ebp] + mov DWORD PTR _tempPtr$56856[ebp], ecx + +; 171 : *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); + + mov edx, DWORD PTR _booleanArg$56855[ebp] + and edx, 255 ; 000000ffH + neg edx + sbb edx, edx + neg edx + mov eax, DWORD PTR _tempPtr$56856[ebp] + mov DWORD PTR [eax], edx + +; 172 : arrays[i] = (int) tempPtr; + + mov ecx, DWORD PTR _i$[ebp] + mov edx, DWORD PTR _arrays$[ebp] + mov eax, DWORD PTR _tempPtr$56856[ebp] + mov DWORD PTR [edx+ecx*4], eax + +; 173 : _push(tempPtr); + + push DWORD PTR _tempPtr$56856[ebp] +$L56854: + +; 179 : +; 180 : } + + jmp $L56811 +$L56812: + +; 181 : +; 182 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov ecx, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ; JNIEnv_::GetIntField + mov DWORD PTR _functionHandle$[ebp], eax + +; 183 : +; 184 : #ifdef _WINDOWS +; 185 : #ifdef _X86_ +; 186 : +; 187 : __asm { +; 188 : +; 189 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 190 : +; 191 : } +; 192 : +; 193 : #endif +; 194 : #endif +; 195 : +; 196 : for (int j = 0; j < len; ++j) { + + mov DWORD PTR _j$[ebp], 0 + jmp SHORT $L56862 +$L56863: + mov eax, DWORD PTR _j$[ebp] + add eax, 1 + mov DWORD PTR _j$[ebp], eax +$L56862: + mov ecx, DWORD PTR _j$[ebp] + cmp ecx, DWORD PTR _len$[ebp] + jge $L56864 + +; 197 : param = env->GetObjectArrayElement(params, j); + + mov edx, DWORD PTR _j$[ebp] + push edx + mov eax, DWORD PTR _params$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ; JNIEnv_::GetObjectArrayElement + mov DWORD PTR _param$[ebp], eax + +; 198 : if (param == NULL) {} + + cmp DWORD PTR _param$[ebp], 0 + jne SHORT $L56865 + +; 199 : else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { + + jmp $L56884 +$L56865: + mov ecx, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + jne SHORT $L56868 + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56867 +$L56868: + +; 200 : env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); + + push 0 + mov edx, DWORD PTR _j$[ebp] + mov eax, DWORD PTR _arrays$[ebp] + mov ecx, DWORD PTR [eax+edx*4] + push ecx + mov edx, DWORD PTR _param$[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ; JNIEnv_::ReleasePrimitiveArrayCritical + +; 202 : else if (env->IsInstanceOf(param, classHolder)) { + + jmp $L56884 +$L56867: + mov eax, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je $L56884 + +; 203 : +; 204 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov edx, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ; JNIEnv_::GetObjectField + mov DWORD PTR _o$56873[ebp], eax + +; 205 : +; 206 : if (env->IsInstanceOf(o, classInteger)) { + + mov ecx, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push ecx + mov edx, DWORD PTR _o$56873[ebp] + push edx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56874 + +; 207 : int* out = (int*) arrays[j]; + + mov eax, DWORD PTR _j$[ebp] + mov ecx, DWORD PTR _arrays$[ebp] + mov edx, DWORD PTR [ecx+eax*4] + mov DWORD PTR _out$56875[ebp], edx + +; 208 : env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); + + mov eax, DWORD PTR _out$56875[ebp] + mov ecx, DWORD PTR [eax] + push ecx + mov edx, DWORD PTR ?newIntegerInt@@3PAU_jmethodID@@A ; newIntegerInt + push edx + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + mov ecx, DWORD PTR _env$[ebp] + push ecx + call ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject + add esp, 16 ; 00000010H + push eax + mov edx, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push edx + mov eax, DWORD PTR _param$[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ; JNIEnv_::SetObjectField + +; 209 : delete out; + + mov ecx, DWORD PTR _out$56875[ebp] + mov DWORD PTR $T56917[ebp], ecx + mov edx, DWORD PTR $T56917[ebp] + push edx + call ??3@YAXPAX@Z ; operator delete + add esp, 4 + +; 211 : else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { + + jmp $L56884 +$L56874: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + push eax + mov ecx, DWORD PTR _o$56873[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + jne SHORT $L56880 + mov edx, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + push edx + mov eax, DWORD PTR _o$56873[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56879 +$L56880: + +; 212 : env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); + + push 0 + mov ecx, DWORD PTR _j$[ebp] + mov edx, DWORD PTR _arrays$[ebp] + mov eax, DWORD PTR [edx+ecx*4] + push eax + mov ecx, DWORD PTR _o$56873[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ; JNIEnv_::ReleasePrimitiveArrayCritical + +; 214 : else if (env->IsInstanceOf(o, classBoolean)) { + + jmp SHORT $L56884 +$L56879: + mov edx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push edx + mov eax, DWORD PTR _o$56873[ebp] + push eax + mov ecx, DWORD PTR _env$[ebp] + call ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ; JNIEnv_::IsInstanceOf + and eax, 255 ; 000000ffH + test eax, eax + je SHORT $L56884 + +; 215 : int* out = (int*) arrays[j]; + + mov ecx, DWORD PTR _j$[ebp] + mov edx, DWORD PTR _arrays$[ebp] + mov eax, DWORD PTR [edx+ecx*4] + mov DWORD PTR _out$56885[ebp], eax + +; 216 : env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); + + mov ecx, DWORD PTR _out$56885[ebp] + xor edx, edx + cmp DWORD PTR [ecx], 0 + setne dl + push edx + mov eax, DWORD PTR ?newBooleanBoolean@@3PAU_jmethodID@@A ; newBooleanBoolean + push eax + mov ecx, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push ecx + mov edx, DWORD PTR _env$[ebp] + push edx + call ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject + add esp, 16 ; 00000010H + push eax + mov eax, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push eax + mov ecx, DWORD PTR _param$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ; JNIEnv_::SetObjectField + +; 217 : delete out; + + mov edx, DWORD PTR _out$56885[ebp] + mov DWORD PTR $T56918[ebp], edx + mov eax, DWORD PTR $T56918[ebp] + push eax + call ??3@YAXPAX@Z ; operator delete + add esp, 4 +$L56884: + +; 221 : +; 222 : } + + jmp $L56863 +$L56864: + +; 223 : +; 224 : delete [] arrays; + + mov ecx, DWORD PTR _arrays$[ebp] + mov DWORD PTR $T56919[ebp], ecx + mov edx, DWORD PTR $T56919[ebp] + push edx + call ??3@YAXPAX@Z ; operator delete + add esp, 4 + +; 225 : +; 226 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + mov esi, esp + call DWORD PTR __imp__GetLastError@0 + cmp esi, esp + call __chkesp + push eax + mov eax, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov ecx, DWORD PTR _env$[ebp] + call ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ; JNIEnv_::SetIntField +$L56800: + +; 227 : +; 228 : } + + pop edi + pop esi + pop ebx + add esp, 168 ; 000000a8H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +_Java_com_eaio_nativecall_VoidCall_executeCall0@12 ENDP +_TEXT ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_name$ = 8 +?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z PROC NEAR ; JNIEnv_::FindClass, COMDAT + +; 759 : jclass FindClass(const char *name) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 760 : return functions->FindClass(this, name); + + mov esi, esp + mov eax, DWORD PTR _name$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+24] + cmp esi, esp + call __chkesp + +; 761 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z ENDP ; JNIEnv_::FindClass +_TEXT ENDS +; COMDAT ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z +_TEXT SEGMENT +_this$ = -4 +_clazz$ = 8 +_msg$ = 12 +?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z PROC NEAR ; JNIEnv_::ThrowNew, COMDAT + +; 787 : jint ThrowNew(jclass clazz, const char *msg) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 788 : return functions->ThrowNew(this, clazz, msg); + + mov esi, esp + mov eax, DWORD PTR _msg$[ebp] + push eax + mov ecx, DWORD PTR _clazz$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+56] + cmp esi, esp + call __chkesp + +; 789 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z ENDP ; JNIEnv_::ThrowNew +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_args$ = -4 +_result$ = -8 +_clazz$ = 12 +_methodID$ = 16 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::NewObject, COMDAT + +; 834 : jobject NewObject(jclass clazz, jmethodID methodID, ...) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 835 : va_list args; +; 836 : jobject result; +; 837 : va_start(args, methodID); + + lea eax, DWORD PTR _methodID$[ebp+4] + mov DWORD PTR _args$[ebp], eax + +; 838 : result = functions->NewObjectV(this,clazz,methodID,args); + + mov esi, esp + mov ecx, DWORD PTR _args$[ebp] + push ecx + mov edx, DWORD PTR _methodID$[ebp] + push edx + mov eax, DWORD PTR _clazz$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+116] + cmp esi, esp + call __chkesp + mov DWORD PTR _result$[ebp], eax + +; 839 : va_end(args); + + mov DWORD PTR _args$[ebp], 0 + +; 840 : return result; + + mov eax, DWORD PTR _result$[ebp] + +; 841 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 0 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::NewObject +_TEXT ENDS +; COMDAT ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z +_TEXT SEGMENT +_this$ = -4 +_obj$ = 8 +_clazz$ = 12 +?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z PROC NEAR ; JNIEnv_::IsInstanceOf, COMDAT + +; 854 : jboolean IsInstanceOf(jobject obj, jclass clazz) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 855 : return functions->IsInstanceOf(this,obj,clazz); + + mov esi, esp + mov eax, DWORD PTR _clazz$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+128] + cmp esi, esp + call __chkesp + +; 856 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z ENDP ; JNIEnv_::IsInstanceOf +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_args$ = -4 +_result$ = -8 +_obj$ = 12 +_methodID$ = 16 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallBooleanMethod, COMDAT + +; 881 : jmethodID methodID, ...) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 882 : va_list args; +; 883 : jboolean result; +; 884 : va_start(args,methodID); + + lea eax, DWORD PTR _methodID$[ebp+4] + mov DWORD PTR _args$[ebp], eax + +; 885 : result = functions->CallBooleanMethodV(this,obj,methodID,args); + + mov esi, esp + mov ecx, DWORD PTR _args$[ebp] + push ecx + mov edx, DWORD PTR _methodID$[ebp] + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+152] + cmp esi, esp + call __chkesp + mov BYTE PTR _result$[ebp], al + +; 886 : va_end(args); + + mov DWORD PTR _args$[ebp], 0 + +; 887 : return result; + + mov al, BYTE PTR _result$[ebp] + +; 888 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 0 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallBooleanMethod +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_args$ = -4 +_result$ = -8 +_obj$ = 12 +_methodID$ = 16 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallIntMethod, COMDAT + +; 949 : jint CallIntMethod(jobject obj, jmethodID methodID, ...) { + + push ebp + mov ebp, esp + sub esp, 72 ; 00000048H + push ebx + push esi + push edi + lea edi, DWORD PTR [ebp-72] + mov ecx, 18 ; 00000012H + mov eax, -858993460 ; ccccccccH + rep stosd + +; 950 : va_list args; +; 951 : jint result; +; 952 : va_start(args,methodID); + + lea eax, DWORD PTR _methodID$[ebp+4] + mov DWORD PTR _args$[ebp], eax + +; 953 : result = functions->CallIntMethodV(this,obj,methodID,args); + + mov esi, esp + mov ecx, DWORD PTR _args$[ebp] + push ecx + mov edx, DWORD PTR _methodID$[ebp] + push edx + mov eax, DWORD PTR _obj$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+200] + cmp esi, esp + call __chkesp + mov DWORD PTR _result$[ebp], eax + +; 954 : va_end(args); + + mov DWORD PTR _args$[ebp], 0 + +; 955 : return result; + + mov eax, DWORD PTR _result$[ebp] + +; 956 : } + + pop edi + pop esi + pop ebx + add esp, 72 ; 00000048H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 0 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallIntMethod +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_this$ = -4 +?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z PROC NEAR ; JNIEnv_::GetObjectField, COMDAT + +; 1248 : jobject GetObjectField(jobject obj, jfieldID fieldID) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1249 : return functions->GetObjectField(this,obj,fieldID); + + mov esi, esp + mov eax, DWORD PTR _fieldID$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+380] + cmp esi, esp + call __chkesp + +; 1250 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z ENDP ; JNIEnv_::GetObjectField +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_this$ = -4 +?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z PROC NEAR ; JNIEnv_::GetIntField, COMDAT + +; 1263 : jint GetIntField(jobject obj, jfieldID fieldID) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1264 : return functions->GetIntField(this,obj,fieldID); + + mov esi, esp + mov eax, DWORD PTR _fieldID$[ebp] + push eax + mov ecx, DWORD PTR _obj$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+400] + cmp esi, esp + call __chkesp + +; 1265 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z ENDP ; JNIEnv_::GetIntField +_TEXT ENDS +; COMDAT ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_val$ = 16 +_this$ = -4 +?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z PROC NEAR ; JNIEnv_::SetObjectField, COMDAT + +; 1276 : void SetObjectField(jobject obj, jfieldID fieldID, jobject val) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1277 : functions->SetObjectField(this,obj,fieldID,val); + + mov esi, esp + mov eax, DWORD PTR _val$[ebp] + push eax + mov ecx, DWORD PTR _fieldID$[ebp] + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+416] + cmp esi, esp + call __chkesp + +; 1278 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z ENDP ; JNIEnv_::SetObjectField +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT +_obj$ = 8 +_fieldID$ = 12 +_val$ = 16 +_this$ = -4 +?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z PROC NEAR ; JNIEnv_::SetIntField, COMDAT + +; 1296 : jint val) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1297 : functions->SetIntField(this,obj,fieldID,val); + + mov esi, esp + mov eax, DWORD PTR _val$[ebp] + push eax + mov ecx, DWORD PTR _fieldID$[ebp] + push ecx + mov edx, DWORD PTR _obj$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+436] + cmp esi, esp + call __chkesp + +; 1298 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z ENDP ; JNIEnv_::SetIntField +_TEXT ENDS +; COMDAT ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z PROC NEAR ; JNIEnv_::GetArrayLength, COMDAT + +; 1589 : jsize GetArrayLength(jarray array) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1590 : return functions->GetArrayLength(this,array); + + mov esi, esp + mov eax, DWORD PTR _array$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + mov eax, DWORD PTR [edx] + call DWORD PTR [eax+684] + cmp esi, esp + call __chkesp + +; 1591 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 4 +?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z ENDP ; JNIEnv_::GetArrayLength +_TEXT ENDS +; COMDAT ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +_index$ = 12 +?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z PROC NEAR ; JNIEnv_::GetObjectArrayElement, COMDAT + +; 1597 : jobject GetObjectArrayElement(jobjectArray array, jsize index) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1598 : return functions->GetObjectArrayElement(this,array,index); + + mov esi, esp + mov eax, DWORD PTR _index$[ebp] + push eax + mov ecx, DWORD PTR _array$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+692] + cmp esi, esp + call __chkesp + +; 1599 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z ENDP ; JNIEnv_::GetObjectArrayElement +_TEXT ENDS +; COMDAT ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +_isCopy$ = 12 +?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z PROC NEAR ; JNIEnv_::GetPrimitiveArrayCritical, COMDAT + +; 1788 : void * GetPrimitiveArrayCritical(jarray array, jboolean *isCopy) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1789 : return functions->GetPrimitiveArrayCritical(this,array,isCopy); + + mov esi, esp + mov eax, DWORD PTR _isCopy$[ebp] + push eax + mov ecx, DWORD PTR _array$[ebp] + push ecx + mov edx, DWORD PTR _this$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + mov ecx, DWORD PTR [eax] + call DWORD PTR [ecx+888] + cmp esi, esp + call __chkesp + +; 1790 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 8 +?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z ENDP ; JNIEnv_::GetPrimitiveArrayCritical +_TEXT ENDS +; COMDAT ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z +_TEXT SEGMENT +_this$ = -4 +_array$ = 8 +_carray$ = 12 +_mode$ = 16 +?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z PROC NEAR ; JNIEnv_::ReleasePrimitiveArrayCritical, COMDAT + +; 1791 : void ReleasePrimitiveArrayCritical(jarray array, void *carray, jint mode) { + + push ebp + mov ebp, esp + sub esp, 68 ; 00000044H + push ebx + push esi + push edi + push ecx + lea edi, DWORD PTR [ebp-68] + mov ecx, 17 ; 00000011H + mov eax, -858993460 ; ccccccccH + rep stosd + pop ecx + mov DWORD PTR _this$[ebp], ecx + +; 1792 : functions->ReleasePrimitiveArrayCritical(this,array,carray,mode); + + mov esi, esp + mov eax, DWORD PTR _mode$[ebp] + push eax + mov ecx, DWORD PTR _carray$[ebp] + push ecx + mov edx, DWORD PTR _array$[ebp] + push edx + mov eax, DWORD PTR _this$[ebp] + push eax + mov ecx, DWORD PTR _this$[ebp] + mov edx, DWORD PTR [ecx] + call DWORD PTR [edx+892] + cmp esi, esp + call __chkesp + +; 1793 : } + + pop edi + pop esi + pop ebx + add esp, 68 ; 00000044H + cmp ebp, esp + call __chkesp + mov esp, ebp + pop ebp + ret 12 ; 0000000cH +?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z ENDP ; JNIEnv_::ReleasePrimitiveArrayCritical +_TEXT ENDS +END diff --git a/vendor/nativecall/0.4.1/cpp/Debug/VoidCall.obj b/vendor/nativecall/0.4.1/cpp/Debug/VoidCall.obj new file mode 100644 index 0000000..9ba9ad6 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Debug/VoidCall.obj differ diff --git a/vendor/nativecall/0.4.1/cpp/IntCall.cpp b/vendor/nativecall/0.4.1/cpp/IntCall.cpp new file mode 100644 index 0000000..c221ab2 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/IntCall.cpp @@ -0,0 +1,236 @@ +/* + * IntCall.cpp + * + * Created on 11.09.2004. + * + * $Id: IntCall.cpp,v 1.3 2006/04/19 20:54:55 grnull Exp $ + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include +#include "com_eaio_nativecall_IntCall.h" + +#ifdef _WINDOWS +#include +#include +#endif + +#ifdef _WINDOWS +#ifdef _X86_ + +#define _push(x) __asm { push x }; + +#endif +#endif + +// NativeCall fields + +extern jfieldID fieldFunction, fieldModule, fieldFunctionHandle, + fieldModuleHandle, fieldLastErrorCode; + +// Holder fields + +extern jfieldID fieldHolderO; + +// Classes + +extern jclass classBoolean,/* classByte, classCharacter, classShort,*/ + classInteger, /* classLong, classFloat, classDouble,*/ classString, + classByteArray, classCharArray, /*classIntArray,*/ classHolder; + +// Wrapper class methods + +extern jmethodID methodBooleanValue,/* methodByteValue, methodCharValue, +methodShortValue,*/ methodIntValue/*, methodLongValue, methodFloatValue, +methodDoubleValue*/; + +// Constructors + +extern jmethodID newIntegerInt, newBooleanBoolean; + +/* + * Class: com_eaio_nativecall_IntCall + * Method: executeCall + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall +(JNIEnv *env, jobject obj) { + + jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + jint outVal; + +#ifdef _WINDOWS +#ifdef _X86_ + + __asm { + + call functionHandle + mov outVal, eax + + } + +#endif +#endif + + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + return outVal; + +} + +/* + * Class: com_eaio_nativecall_IntCall + * Method: executeCall0 + * Signature: ([Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall0 +(JNIEnv *env, jobject obj, jobjectArray params) { + + const int len = env->GetArrayLength(params); + + int* arrays = NULL; + if (!(arrays = new int[len])) { + env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); + return 0; + } + memset(arrays, 0, (sizeof(int) * len)); + + jobject param; + + for (int i = len - 1; i >= 0; i--) { + + param = env->GetObjectArrayElement(params, i); + + if (param == NULL) { + _push(0); + } + else if (env->IsInstanceOf(param, classInteger)) { + int intArg = env->CallIntMethod(param, methodIntValue); + _push(intArg) + } + else if (env->IsInstanceOf(param, classByteArray)) { + char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); + arrays[i] = (int) &byteArrayArg; + _push(byteArrayArg) + } + else if (env->IsInstanceOf(param, classCharArray)) { + unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( + (jarray) param, 0); + arrays[i] = (int) &charArrayArg; + _push(charArrayArg) + } + else if (env->IsInstanceOf(param, classBoolean)) { + jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); + int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); + _push(tempArg) + } + else if (env->IsInstanceOf(param, classHolder)) { + + /* Holder */ + + jobject o = env->GetObjectField(param, fieldHolderO); + + if (env->IsInstanceOf(o, classInteger)) { + int *intPtr = new int; + *intPtr = env->CallIntMethod(o, methodIntValue); + arrays[i] = (int) intPtr; + _push(intPtr); + } + else if (env->IsInstanceOf(o, classByteArray)) { + char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); + arrays[i] = (int) &byteArrayArg; + _push(byteArrayArg) + } + else if (env->IsInstanceOf(o, classCharArray)) { + unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( + (jarray) o, 0); + arrays[i] = (int) &charArrayArg; + _push(charArrayArg) + } + else if (env->IsInstanceOf(o, classBoolean)) { + jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); + int *tempPtr = new int; + *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); + arrays[i] = (int) tempPtr; + _push(tempPtr); + } + + /* end Holder */ + + } + + } + + jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + jint outVal; + +#ifdef _WINDOWS +#ifdef _X86_ + + __asm { + + call functionHandle + mov outVal, eax + + } + +#endif +#endif + + for (int j = 0; j < len; ++j) { + param = env->GetObjectArrayElement(params, j); + if (param == NULL) {} + else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { + env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); + } + else if (env->IsInstanceOf(param, classHolder)) { + + jobject o = env->GetObjectField(param, fieldHolderO); + + if (env->IsInstanceOf(o, classInteger)) { + int* out = (int*) arrays[j]; + env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); + delete out; + } + else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { + env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); + } + else if (env->IsInstanceOf(o, classBoolean)) { + int* out = (int*) arrays[j]; + env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); + delete out; + } + + } + + } + + delete [] arrays; + + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + return outVal; + +} diff --git a/vendor/nativecall/0.4.1/cpp/NativeCall.cpp b/vendor/nativecall/0.4.1/cpp/NativeCall.cpp new file mode 100644 index 0000000..d5267d3 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/NativeCall.cpp @@ -0,0 +1,234 @@ +/* + * NativeCall.cpp + * + * Created on 11.09.2004. + * + * $Id: NativeCall.cpp,v 1.4 2006/04/19 20:54:55 grnull Exp $ + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include +#include "com_eaio_nativecall_NativeCall.h" + +#ifdef _WINDOWS +#include +#include +#endif + +// NativeCall fields + +jfieldID fieldFunction, fieldModule, fieldFunctionHandle, + fieldModuleHandle, fieldLastErrorCode; + +// Holder fields + +jfieldID fieldHolderO; + +// Classes + +jclass classBoolean,/* classByte, classCharacter, classShort,*/ + classInteger, /* classLong, classFloat, classDouble,*/ classString, + classByteArray, classCharArray, /*classIntArray,*/ classHolder; + +// Wrapper class methods + +jmethodID methodBooleanValue,/* methodByteValue, methodCharValue, +methodShortValue,*/ methodIntValue/*, methodLongValue, methodFloatValue, +methodDoubleValue*/; + +// Constructors + +jmethodID newIntegerInt, newBooleanBoolean; + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: initIDs + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_initIDs +(JNIEnv *env, jclass cls) { + + // NativeCall fields + + fieldFunction = env->GetFieldID(cls, "function", "Ljava/lang/String;"); + fieldModule = env->GetFieldID(cls, "module", "Ljava/lang/String;"); + + fieldFunctionHandle = env->GetFieldID(cls, "functionHandle", "I"); + fieldModuleHandle = env-> GetFieldID(cls, "moduleHandle", "I"); + + fieldLastErrorCode = env->GetFieldID(cls, "lastErrorCode", "I"); + + // Holder fields + + classHolder = (jclass) env->NewGlobalRef(env->FindClass("com/eaio/nativecall/Holder")); + fieldHolderO = env->GetFieldID(classHolder, "o", "Ljava/lang/Object;"); + + // Other classes + + classBoolean = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Boolean")); + /*classByte = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Byte")); + classCharacter = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Character")); + classShort = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Short"));*/ + classInteger = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Integer")); + /*classLong = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Long")); + classFloat = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Float")); + classDouble = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Double"));*/ + classString = (jclass) env->NewGlobalRef(env->FindClass("java/lang/String")); + classByteArray = (jclass) env->NewGlobalRef(env->FindClass("[B")); + classCharArray = (jclass) env->NewGlobalRef(env->FindClass("[C")); + /*classIntArray = (jclass) env->NewGlobalRef(env->FindClass("[I"));*/ + + // Wrapper class methods + + methodBooleanValue = env->GetMethodID(classBoolean, + "booleanValue", "()Z"); + /*methodByteValue = env->GetMethodID(classByte, + "byteValue", "()B"); + methodCharValue = env->GetMethodID(classCharacter, + "charValue", "()C"); + methodShortValue = env->GetMethodID(classShort, + "shortValue", "()S");*/ + methodIntValue = env->GetMethodID(classInteger, + "intValue", "()I"); + /*methodLongValue = env->GetMethodID(classLong, + "longValue", "()J"); + methodFloatValue = env->GetMethodID(classFloat, + "floatValue", "()F"); + methodDoubleValue = env->GetMethodID(classDouble, + "doubleValue", "()D");*/ + + // Constructors + + newIntegerInt = env->GetMethodID(classInteger, "", "(I)V"); + newBooleanBoolean = env->GetMethodID(classBoolean, "", "(Z)V"); + +} + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: initHandles + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_eaio_nativecall_NativeCall_initHandles +(JNIEnv *env, jobject obj) { + + bool out = JNI_TRUE; + + jstring moduleNameS = (jstring) env->GetObjectField(obj, fieldModule); + jstring functionNameS = (jstring) env->GetObjectField(obj, fieldFunction); + + const char* moduleName = env->GetStringUTFChars(moduleNameS, 0); + const char* functionName = env->GetStringUTFChars(functionNameS, 0); + +#ifdef _WINDOWS + + HMODULE mod = LoadLibrary(moduleName); + + if (mod == NULL) { + /* no such module or DllMain returned FALSE */ + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + out = JNI_FALSE; + } + else { + FARPROC addr = GetProcAddress(mod, functionName); + if (addr == NULL) { + /* function not found */ + FreeLibrary(mod); + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + out = JNI_FALSE; + } + else { + /* all ok */ + env->SetIntField(obj, fieldModuleHandle, (jint) mod); + env->SetIntField(obj, fieldFunctionHandle, (jint) addr); + } + } + +#endif + + env->ReleaseStringUTFChars(moduleNameS, moduleName); + env->ReleaseStringUTFChars(functionNameS, functionName); + + return out; + +} + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: getLastError + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_eaio_nativecall_NativeCall_getLastError +(JNIEnv *env, jobject obj) { + + jint lastError = env->GetIntField(obj, fieldLastErrorCode); + + if (lastError == 0) return NULL; + + jstring out = NULL; + +#ifdef _WINDOWS + + LPVOID msgBufPtr = NULL; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, NULL, lastError, 0, + (LPSTR) &msgBufPtr, 0, NULL); + + out = env->NewStringUTF((char*) msgBufPtr); + + LocalFree(msgBufPtr); + +#endif + + return out; + +} + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: destroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_destroy +(JNIEnv *env, jobject obj) { + + jint module = env->GetIntField(obj, fieldModuleHandle); + + if (module == 0) return; + +#ifdef _WINDOWS + + if (FreeLibrary((HMODULE) module) == 0) { + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + } + +#endif + + env->SetIntField(obj, fieldModuleHandle, 0); + env->SetIntField(obj, fieldFunctionHandle, 0); + + return; + +} \ No newline at end of file diff --git a/vendor/nativecall/0.4.1/cpp/NativeCall.dsp b/vendor/nativecall/0.4.1/cpp/NativeCall.dsp new file mode 100644 index 0000000..7959712 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/NativeCall.dsp @@ -0,0 +1,132 @@ +# Microsoft Developer Studio Project File - Name="NativeCall" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** NICHT BEARBEITEN ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=NativeCall - Win32 Debug +!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE +!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl +!MESSAGE +!MESSAGE NMAKE /f "NativeCall.mak". +!MESSAGE +!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben +!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel: +!MESSAGE +!MESSAGE NMAKE /f "NativeCall.mak" CFG="NativeCall - Win32 Debug" +!MESSAGE +!MESSAGE Für die Konfiguration stehen zur Auswahl: +!MESSAGE +!MESSAGE "NativeCall - Win32 Release" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE "NativeCall - Win32 Debug" (basierend auf "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "NativeCall - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NATIVECALL_EXPORTS" /YX /FD /c +# ADD CPP /nologo /G5 /MD /W3 /Oa /Og /Os /Oy /Ob2 /Gf /I "C:\Program Files\IBMJava13\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NATIVECALL_EXPORTS" /D "WIN32_LEAN_AND_MEAN" /FAs /FR /YX /FD /c +# SUBTRACT CPP /Ox /Ot /Gy +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib libctiny.lib "C:\Program Files\Microsoft Visual Studio\VC98\Lib\libcmt.lib" "C:\Program Files\Microsoft Visual Studio\VC98\Lib\msvcrt.lib" /nologo /subsystem:console /dll /map /machine:I386 /nodefaultlib /MERGE:".rdata=.text" /OPT:REF /OPT:NOWIN98 +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "NativeCall - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NATIVECALL_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\Program Files\IBMJava13\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "NATIVECALL_EXPORTS" /FAs /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "NativeCall - Win32 Release" +# Name "NativeCall - Win32 Debug" +# Begin Group "Quellcodedateien" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\IntCall.cpp +# End Source File +# Begin Source File + +SOURCE=.\NativeCall.cpp +# End Source File +# Begin Source File + +SOURCE=.\version.rc +# End Source File +# Begin Source File + +SOURCE=.\VoidCall.cpp +# End Source File +# End Group +# Begin Group "Header-Dateien" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\com_eaio_nativecall_IntCall.h +# End Source File +# Begin Source File + +SOURCE=.\com_eaio_nativecall_NativeCall.h +# End Source File +# Begin Source File + +SOURCE=.\com_eaio_nativecall_VoidCall.h +# End Source File +# End Group +# Begin Group "Ressourcendateien" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/vendor/nativecall/0.4.1/cpp/NativeCall.dsw b/vendor/nativecall/0.4.1/cpp/NativeCall.dsw new file mode 100644 index 0000000..e591c50 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/NativeCall.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN! + +############################################################################### + +Project: "NativeCall"=".\NativeCall.dsp" - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/vendor/nativecall/0.4.1/cpp/Release/IntCall.asm b/vendor/nativecall/0.4.1/cpp/Release/IntCall.asm new file mode 100644 index 0000000..f2aa3af --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Release/IntCall.asm @@ -0,0 +1,943 @@ + TITLE C:\Documents and Settings\Administrator\My Documents\Software\NativeCall\src\cpp\IntCall.cpp + .386P +include listing.inc +if @Version gt 510 +.model FLAT +else +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' +_BSS ENDS +_TLS SEGMENT DWORD USE32 PUBLIC 'TLS' +_TLS ENDS +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +FLAT GROUP _DATA, CONST, _BSS + ASSUME CS: FLAT, DS: FLAT, SS: FLAT +endif +PUBLIC _Java_com_eaio_nativecall_IntCall_executeCall@8 +EXTRN ?fieldFunctionHandle@@3PAU_jfieldID@@A:DWORD ; fieldFunctionHandle +EXTRN ?fieldLastErrorCode@@3PAU_jfieldID@@A:DWORD ; fieldLastErrorCode +EXTRN __imp__GetLastError@0:NEAR +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_functionHandle$ = 8 +_outVal$ = -4 +_Java_com_eaio_nativecall_IntCall_executeCall@8 PROC NEAR + +; 79 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + push ecx + +; 80 : +; 81 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push esi + mov esi, DWORD PTR _env$[ebp] + push eax + push DWORD PTR _obj$[ebp] + mov ecx, DWORD PTR [esi] + push esi + call DWORD PTR [ecx+400] + mov DWORD PTR _functionHandle$[ebp], eax + +; 82 : jint outVal; +; 83 : +; 84 : #ifdef _WINDOWS +; 85 : #ifdef _X86_ +; 86 : +; 87 : __asm { +; 88 : +; 89 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 90 : mov outVal, eax + + mov DWORD PTR _outVal$[ebp], eax + +; 91 : +; 92 : } +; 93 : +; 94 : #endif +; 95 : #endif +; 96 : +; 97 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + call DWORD PTR __imp__GetLastError@0 + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push DWORD PTR _obj$[ebp] + push esi + call DWORD PTR [ecx+436] + +; 98 : +; 99 : return outVal; + + mov eax, DWORD PTR _outVal$[ebp] + +; 100 : +; 101 : } + + pop esi + leave + ret 8 +_Java_com_eaio_nativecall_IntCall_executeCall@8 ENDP +_TEXT ENDS +PUBLIC ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' +PUBLIC _Java_com_eaio_nativecall_IntCall_executeCall0@12 +PUBLIC ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject +PUBLIC ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod +PUBLIC ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod +EXTRN ?fieldHolderO@@3PAU_jfieldID@@A:DWORD ; fieldHolderO +EXTRN ?classBoolean@@3PAV_jclass@@A:DWORD ; classBoolean +EXTRN ?classInteger@@3PAV_jclass@@A:DWORD ; classInteger +EXTRN ?classByteArray@@3PAV_jclass@@A:DWORD ; classByteArray +EXTRN ?classCharArray@@3PAV_jclass@@A:DWORD ; classCharArray +EXTRN ?classHolder@@3PAV_jclass@@A:DWORD ; classHolder +EXTRN ?methodBooleanValue@@3PAU_jmethodID@@A:DWORD ; methodBooleanValue +EXTRN ?methodIntValue@@3PAU_jmethodID@@A:DWORD ; methodIntValue +EXTRN ?newIntegerInt@@3PAU_jmethodID@@A:DWORD ; newIntegerInt +EXTRN ?newBooleanBoolean@@3PAU_jmethodID@@A:DWORD ; newBooleanBoolean +EXTRN ??2@YAPAXI@Z:NEAR ; operator new +EXTRN ??3@YAXPAX@Z:NEAR ; operator delete +EXTRN _memset:NEAR +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +; File C:\Program Files\IBMJava13\include\jni.h +_DATA SEGMENT +??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ DB 'java/lang/OutOfMemor' + DB 'yError', 00H ; `string' +_DATA ENDS +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_params$ = 16 +_len$ = -28 +_arrays$ = -20 +_param$ = -24 +_i$ = 8 +_intArg$27770 = -24 +_byteArrayArg$27773 = -4 +_charArrayArg$27779 = -8 +_tempArg$27786 = -24 +_intPtr$27791 = -24 +_byteArrayArg$27797 = -12 +_charArrayArg$27803 = -16 +_tempPtr$27810 = -24 +_functionHandle$ = 8 +_outVal$ = -32 +_j$ = 8 +_Java_com_eaio_nativecall_IntCall_executeCall0@12 PROC NEAR + +; 109 : (JNIEnv *env, jobject obj, jobjectArray params) { + + push ebp + mov ebp, esp + sub esp, 32 ; 00000020H + push ebx + push esi + +; 110 : +; 111 : const int len = env->GetArrayLength(params); + + mov esi, DWORD PTR _env$[ebp] + push edi + push DWORD PTR _params$[ebp] + mov eax, DWORD PTR [esi] + push esi + call DWORD PTR [eax+684] + mov ebx, eax + +; 112 : +; 113 : int* arrays = NULL; +; 114 : if (!(arrays = new int[len])) { + + mov edi, ebx + mov DWORD PTR _len$[ebp], ebx + shl edi, 2 + push edi + call ??2@YAPAXI@Z ; operator new + test eax, eax + pop ecx + mov DWORD PTR _arrays$[ebp], eax + jne SHORT $L27759 + +; 115 : env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push 0 + push eax + push esi + call DWORD PTR [ecx+56] + +; 116 : return 0; + + xor eax, eax + jmp $L27754 +$L27759: + +; 117 : } +; 118 : memset(arrays, 0, (sizeof(int) * len)); + + push edi + push 0 + push eax + call _memset + +; 119 : +; 120 : jobject param; +; 121 : +; 122 : for (int i = len - 1; i >= 0; i--) { + + lea eax, DWORD PTR [ebx-1] + add esp, 12 ; 0000000cH + test eax, eax + mov DWORD PTR _i$[ebp], eax + jl $L27766 + mov ecx, DWORD PTR _arrays$[ebp] + lea edi, DWORD PTR [ecx+eax*4] + jmp SHORT $L27764 +$L28030: + +; 117 : } +; 118 : memset(arrays, 0, (sizeof(int) * len)); + + mov eax, DWORD PTR _i$[ebp] +$L27764: + +; 123 : +; 124 : param = env->GetObjectArrayElement(params, i); + + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR _params$[ebp] + push esi + call DWORD PTR [ecx+692] + mov ebx, eax + +; 125 : +; 126 : if (param == NULL) { + + test ebx, ebx + jne SHORT $L27767 + +; 127 : _push(0); + + push 0 + +; 128 : } +; 129 : else if (env->IsInstanceOf(param, classInteger)) { + + jmp $L27765 +$L27767: + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27769 + +; 130 : int intArg = env->CallIntMethod(param, methodIntValue); + + push DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push ebx + push esi + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + add esp, 12 ; 0000000cH + mov DWORD PTR _intArg$27770[ebp], eax + +; 131 : _push(intArg) + + push DWORD PTR _intArg$27770[ebp] + +; 132 : } +; 133 : else if (env->IsInstanceOf(param, classByteArray)) { + + jmp $L27765 +$L27769: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27772 + +; 134 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _byteArrayArg$27773[ebp], eax + +; 135 : arrays[i] = (int) &byteArrayArg; + + lea eax, DWORD PTR _byteArrayArg$27773[ebp] + mov DWORD PTR [edi], eax + +; 136 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$27773[ebp] + +; 137 : } +; 138 : else if (env->IsInstanceOf(param, classCharArray)) { + + jmp $L27765 +$L27772: + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27778 + +; 139 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 140 : (jarray) param, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _charArrayArg$27779[ebp], eax + +; 141 : arrays[i] = (int) &charArrayArg; + + lea eax, DWORD PTR _charArrayArg$27779[ebp] + mov DWORD PTR [edi], eax + +; 142 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$27779[ebp] + +; 143 : } +; 144 : else if (env->IsInstanceOf(param, classBoolean)) { + + jmp $L27765 +$L27778: + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27784 + +; 145 : jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); + + push DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ebx + push esi + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + add esp, 12 ; 0000000cH + +; 146 : int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); + + neg al + sbb eax, eax + neg eax + mov DWORD PTR _tempArg$27786[ebp], eax + +; 147 : _push(tempArg) + + push DWORD PTR _tempArg$27786[ebp] + +; 148 : } +; 149 : else if (env->IsInstanceOf(param, classHolder)) { + + jmp $L27765 +$L27784: + mov eax, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je $L27765 + +; 150 : +; 151 : /* Holder */ +; 152 : +; 153 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov eax, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+380] + +; 154 : +; 155 : if (env->IsInstanceOf(o, classInteger)) { + + mov ecx, DWORD PTR [esi] + mov ebx, eax + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27790 + +; 156 : int *intPtr = new int; + + push 4 + call ??2@YAPAXI@Z ; operator new + pop ecx + mov DWORD PTR _intPtr$27791[ebp], eax + +; 157 : *intPtr = env->CallIntMethod(o, methodIntValue); + + push DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push ebx + push esi + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + mov ecx, DWORD PTR _intPtr$27791[ebp] + add esp, 12 ; 0000000cH + +; 158 : arrays[i] = (int) intPtr; + + mov DWORD PTR [edi], ecx + mov DWORD PTR [ecx], eax + +; 159 : _push(intPtr); + + push DWORD PTR _intPtr$27791[ebp] + +; 160 : } +; 161 : else if (env->IsInstanceOf(o, classByteArray)) { + + jmp $L27765 +$L27790: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27796 + +; 162 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _byteArrayArg$27797[ebp], eax + +; 163 : arrays[i] = (int) &byteArrayArg; + + lea eax, DWORD PTR _byteArrayArg$27797[ebp] + mov DWORD PTR [edi], eax + +; 164 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$27797[ebp] + +; 165 : } +; 166 : else if (env->IsInstanceOf(o, classCharArray)) { + + jmp SHORT $L27765 +$L27796: + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27802 + +; 167 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 168 : (jarray) o, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _charArrayArg$27803[ebp], eax + +; 169 : arrays[i] = (int) &charArrayArg; + + lea eax, DWORD PTR _charArrayArg$27803[ebp] + mov DWORD PTR [edi], eax + +; 170 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$27803[ebp] + +; 171 : } +; 172 : else if (env->IsInstanceOf(o, classBoolean)) { + + jmp SHORT $L27765 +$L27802: + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27765 + +; 173 : jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); + + push DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ebx + push esi + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + +; 174 : int *tempPtr = new int; + + push 4 + mov bl, al + call ??2@YAPAXI@Z ; operator new + add esp, 16 ; 00000010H + +; 175 : *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); + + xor ecx, ecx + test bl, bl + setne cl + mov DWORD PTR _tempPtr$27810[ebp], eax + mov DWORD PTR [eax], ecx + +; 176 : arrays[i] = (int) tempPtr; + + mov DWORD PTR [edi], eax + +; 177 : _push(tempPtr); + + push DWORD PTR _tempPtr$27810[ebp] + +; 176 : arrays[i] = (int) tempPtr; + +$L27765: + dec DWORD PTR _i$[ebp] + sub edi, 4 + cmp DWORD PTR _i$[ebp], 0 + jge $L28030 + +; 119 : +; 120 : jobject param; +; 121 : +; 122 : for (int i = len - 1; i >= 0; i--) { + + mov ebx, DWORD PTR _len$[ebp] +$L27766: + +; 178 : } +; 179 : +; 180 : /* end Holder */ +; 181 : +; 182 : } +; 183 : +; 184 : } +; 185 : +; 186 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR _obj$[ebp] + push esi + call DWORD PTR [ecx+400] + mov DWORD PTR _functionHandle$[ebp], eax + +; 187 : jint outVal; +; 188 : +; 189 : #ifdef _WINDOWS +; 190 : #ifdef _X86_ +; 191 : +; 192 : __asm { +; 193 : +; 194 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 195 : mov outVal, eax + + mov DWORD PTR _outVal$[ebp], eax + +; 196 : +; 197 : } +; 198 : +; 199 : #endif +; 200 : #endif +; 201 : +; 202 : for (int j = 0; j < len; ++j) { + + and DWORD PTR _j$[ebp], 0 + test ebx, ebx + jle $L27819 + +; 178 : } +; 179 : +; 180 : /* end Holder */ +; 181 : +; 182 : } +; 183 : +; 184 : } +; 185 : +; 186 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov ebx, DWORD PTR _arrays$[ebp] +$L27817: + +; 203 : param = env->GetObjectArrayElement(params, j); + + push DWORD PTR _j$[ebp] + mov eax, DWORD PTR [esi] + push DWORD PTR _params$[ebp] + push esi + call DWORD PTR [eax+692] + mov edi, eax + +; 204 : if (param == NULL) {} + + test edi, edi + mov DWORD PTR _param$[ebp], edi + je $L27818 + +; 205 : else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { + + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne $L27835 + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne $L27835 + +; 207 : } +; 208 : else if (env->IsInstanceOf(param, classHolder)) { + + mov eax, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + je $L27818 + +; 209 : +; 210 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov eax, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+380] + +; 211 : +; 212 : if (env->IsInstanceOf(o, classInteger)) { + + mov ecx, DWORD PTR [esi] + mov edi, eax + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27829 + +; 213 : int* out = (int*) arrays[j]; + + mov edi, DWORD PTR [ebx] + +; 214 : env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); + + push DWORD PTR [edi] + push DWORD PTR ?newIntegerInt@@3PAU_jmethodID@@A ; newIntegerInt + push DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger +$L28033: + push esi + call ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject + add esp, 16 ; 00000010H + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push DWORD PTR _param$[ebp] + push esi + call DWORD PTR [ecx+416] + +; 215 : delete out; + + push edi + call ??3@YAXPAX@Z ; operator delete + pop ecx + +; 216 : } +; 217 : else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { + + jmp SHORT $L27818 +$L27829: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne SHORT $L27835 + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne SHORT $L27835 + +; 218 : env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); +; 219 : } +; 220 : else if (env->IsInstanceOf(o, classBoolean)) { + + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27818 + +; 221 : int* out = (int*) arrays[j]; + + mov edi, DWORD PTR [ebx] + +; 222 : env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); + + xor eax, eax + cmp DWORD PTR [edi], eax + setne al + push eax + push DWORD PTR ?newBooleanBoolean@@3PAU_jmethodID@@A ; newBooleanBoolean + push DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + +; 223 : delete out; + + jmp SHORT $L28033 +$L27835: + +; 206 : env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); + + mov eax, DWORD PTR [esi] + push 0 + push DWORD PTR [ebx] + push edi + push esi + call DWORD PTR [eax+892] +$L27818: + inc DWORD PTR _j$[ebp] + mov eax, DWORD PTR _j$[ebp] + add ebx, 4 + cmp eax, DWORD PTR _len$[ebp] + jl $L27817 +$L27819: + +; 224 : } +; 225 : +; 226 : } +; 227 : +; 228 : } +; 229 : +; 230 : delete [] arrays; + + push DWORD PTR _arrays$[ebp] + call ??3@YAXPAX@Z ; operator delete + pop ecx + +; 231 : +; 232 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + call DWORD PTR __imp__GetLastError@0 + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push DWORD PTR _obj$[ebp] + push esi + call DWORD PTR [ecx+436] + +; 233 : +; 234 : return outVal; + + mov eax, DWORD PTR _outVal$[ebp] +$L27754: + +; 235 : +; 236 : } + + pop edi + pop esi + pop ebx + leave + ret 12 ; 0000000cH +_Java_com_eaio_nativecall_IntCall_executeCall0@12 ENDP +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_clazz$ = 12 +_methodID$ = 16 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::NewObject, COMDAT + +; 835 : va_list args; +; 836 : jobject result; +; 837 : va_start(args, methodID); +; 838 : result = functions->NewObjectV(this,clazz,methodID,args); + + mov eax, DWORD PTR _this$[esp-4] + lea edx, DWORD PTR _methodID$[esp] + push edx + push DWORD PTR _methodID$[esp] + mov ecx, DWORD PTR [eax] + push DWORD PTR _clazz$[esp+4] + push eax + call DWORD PTR [ecx+116] + +; 839 : va_end(args); +; 840 : return result; +; 841 : } + + ret 0 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::NewObject +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_obj$ = 12 +_methodID$ = 16 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallBooleanMethod, COMDAT + +; 882 : va_list args; +; 883 : jboolean result; +; 884 : va_start(args,methodID); +; 885 : result = functions->CallBooleanMethodV(this,obj,methodID,args); + + mov eax, DWORD PTR _this$[esp-4] + lea edx, DWORD PTR _methodID$[esp] + push edx + push DWORD PTR _methodID$[esp] + mov ecx, DWORD PTR [eax] + push DWORD PTR _obj$[esp+4] + push eax + call DWORD PTR [ecx+152] + +; 886 : va_end(args); +; 887 : return result; +; 888 : } + + ret 0 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallBooleanMethod +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_obj$ = 12 +_methodID$ = 16 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallIntMethod, COMDAT + +; 950 : va_list args; +; 951 : jint result; +; 952 : va_start(args,methodID); +; 953 : result = functions->CallIntMethodV(this,obj,methodID,args); + + mov eax, DWORD PTR _this$[esp-4] + lea edx, DWORD PTR _methodID$[esp] + push edx + push DWORD PTR _methodID$[esp] + mov ecx, DWORD PTR [eax] + push DWORD PTR _obj$[esp+4] + push eax + call DWORD PTR [ecx+200] + +; 954 : va_end(args); +; 955 : return result; +; 956 : } + + ret 0 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallIntMethod +_TEXT ENDS +END diff --git a/vendor/nativecall/0.4.1/cpp/Release/IntCall.obj b/vendor/nativecall/0.4.1/cpp/Release/IntCall.obj new file mode 100644 index 0000000..4459fd4 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Release/IntCall.obj differ diff --git a/vendor/nativecall/0.4.1/cpp/Release/NativeCall.asm b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.asm new file mode 100644 index 0000000..980f7ca --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.asm @@ -0,0 +1,859 @@ + TITLE C:\Documents and Settings\Administrator\My Documents\Software\NativeCall\src\cpp\NativeCall.cpp + .386P +include listing.inc +if @Version gt 510 +.model FLAT +else +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' +_BSS ENDS +_TLS SEGMENT DWORD USE32 PUBLIC 'TLS' +_TLS ENDS +; COMDAT ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_08JJOG@function?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_06CODG@module?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_01FLOP@I?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0P@LKIL@functionHandle?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0N@EFAA@moduleHandle?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0O@OMHL@lastErrorCode?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_01PGHN@o?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0BB@LLFN@java?1lang?1String?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_02LOEJ@?$FLB?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_02BENO@?$FLC?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_03KJOK@?$CI?$CJZ?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_0N@KEBP@booleanValue?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_03PPCD@?$CI?$CJI?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_08JCMA@intValue?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_04ECLF@?$CII?$CJV?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_06KILP@?$DMinit?$DO?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ??_C@_04JFOE@?$CIZ?$CJV?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewGlobalRef@JNIEnv_@@QAEPAV_jobject@@PAV2@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetMethodID@JNIEnv_@@QAEPAU_jmethodID@@PAV_jclass@@PBD1@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetFieldID@JNIEnv_@@QAEPAU_jfieldID@@PAV_jclass@@PBD1@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewStringUTF@JNIEnv_@@QAEPAV_jstring@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetStringUTFChars@JNIEnv_@@QAEPBDPAV_jstring@@PAE@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ReleaseStringUTFChars@JNIEnv_@@QAEXPAV_jstring@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +FLAT GROUP _DATA, CONST, _BSS + ASSUME CS: FLAT, DS: FLAT, SS: FLAT +endif +PUBLIC ?fieldFunction@@3PAU_jfieldID@@A ; fieldFunction +PUBLIC ?fieldModule@@3PAU_jfieldID@@A ; fieldModule +PUBLIC ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle +PUBLIC ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle +PUBLIC ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode +PUBLIC ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO +PUBLIC ?classBoolean@@3PAV_jclass@@A ; classBoolean +PUBLIC ?classInteger@@3PAV_jclass@@A ; classInteger +PUBLIC ?classString@@3PAV_jclass@@A ; classString +PUBLIC ?classByteArray@@3PAV_jclass@@A ; classByteArray +PUBLIC ?classCharArray@@3PAV_jclass@@A ; classCharArray +PUBLIC ?classHolder@@3PAV_jclass@@A ; classHolder +PUBLIC ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue +PUBLIC ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue +PUBLIC ?newIntegerInt@@3PAU_jmethodID@@A ; newIntegerInt +PUBLIC ?newBooleanBoolean@@3PAU_jmethodID@@A ; newBooleanBoolean +_BSS SEGMENT +?fieldFunction@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldFunction +?fieldModule@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldModule +?fieldFunctionHandle@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldFunctionHandle +?fieldModuleHandle@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldModuleHandle +?fieldLastErrorCode@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldLastErrorCode +?fieldHolderO@@3PAU_jfieldID@@A DD 01H DUP (?) ; fieldHolderO +?classBoolean@@3PAV_jclass@@A DD 01H DUP (?) ; classBoolean +?classInteger@@3PAV_jclass@@A DD 01H DUP (?) ; classInteger +?classString@@3PAV_jclass@@A DD 01H DUP (?) ; classString +?classByteArray@@3PAV_jclass@@A DD 01H DUP (?) ; classByteArray +?classCharArray@@3PAV_jclass@@A DD 01H DUP (?) ; classCharArray +?classHolder@@3PAV_jclass@@A DD 01H DUP (?) ; classHolder +?methodBooleanValue@@3PAU_jmethodID@@A DD 01H DUP (?) ; methodBooleanValue +?methodIntValue@@3PAU_jmethodID@@A DD 01H DUP (?) ; methodIntValue +?newIntegerInt@@3PAU_jmethodID@@A DD 01H DUP (?) ; newIntegerInt +?newBooleanBoolean@@3PAU_jmethodID@@A DD 01H DUP (?) ; newBooleanBoolean +_BSS ENDS +PUBLIC ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ ; `string' +PUBLIC ??_C@_08JJOG@function?$AA@ ; `string' +PUBLIC ??_C@_06CODG@module?$AA@ ; `string' +PUBLIC ??_C@_01FLOP@I?$AA@ ; `string' +PUBLIC ??_C@_0P@LKIL@functionHandle?$AA@ ; `string' +PUBLIC ??_C@_0N@EFAA@moduleHandle?$AA@ ; `string' +PUBLIC ??_C@_0O@OMHL@lastErrorCode?$AA@ ; `string' +PUBLIC ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ ; `string' +PUBLIC ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ ; `string' +PUBLIC ??_C@_01PGHN@o?$AA@ ; `string' +PUBLIC ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ ; `string' +PUBLIC ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ ; `string' +PUBLIC ??_C@_0BB@LLFN@java?1lang?1String?$AA@ ; `string' +PUBLIC ??_C@_02LOEJ@?$FLB?$AA@ ; `string' +PUBLIC ??_C@_02BENO@?$FLC?$AA@ ; `string' +PUBLIC ??_C@_03KJOK@?$CI?$CJZ?$AA@ ; `string' +PUBLIC ??_C@_0N@KEBP@booleanValue?$AA@ ; `string' +PUBLIC ??_C@_03PPCD@?$CI?$CJI?$AA@ ; `string' +PUBLIC ??_C@_08JCMA@intValue?$AA@ ; `string' +PUBLIC ??_C@_04ECLF@?$CII?$CJV?$AA@ ; `string' +PUBLIC ??_C@_06KILP@?$DMinit?$DO?$AA@ ; `string' +PUBLIC ??_C@_04JFOE@?$CIZ?$CJV?$AA@ ; `string' +PUBLIC _Java_com_eaio_nativecall_NativeCall_initIDs@8 +; COMDAT ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ +; File C:\Program Files\IBMJava13\include\jni.h +_DATA SEGMENT +??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ DB 'Ljava/lang/String;', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_08JJOG@function?$AA@ +_DATA SEGMENT +??_C@_08JJOG@function?$AA@ DB 'function', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_06CODG@module?$AA@ +_DATA SEGMENT +??_C@_06CODG@module?$AA@ DB 'module', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_01FLOP@I?$AA@ +_DATA SEGMENT +??_C@_01FLOP@I?$AA@ DB 'I', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0P@LKIL@functionHandle?$AA@ +_DATA SEGMENT +??_C@_0P@LKIL@functionHandle?$AA@ DB 'functionHandle', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0N@EFAA@moduleHandle?$AA@ +_DATA SEGMENT +??_C@_0N@EFAA@moduleHandle?$AA@ DB 'moduleHandle', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0O@OMHL@lastErrorCode?$AA@ +_DATA SEGMENT +??_C@_0O@OMHL@lastErrorCode?$AA@ DB 'lastErrorCode', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ +_DATA SEGMENT +??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ DB 'com/eaio/nativecall' + DB '/Holder', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ +_DATA SEGMENT +??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ DB 'Ljava/lang/Object;', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_01PGHN@o?$AA@ +_DATA SEGMENT +??_C@_01PGHN@o?$AA@ DB 'o', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ +_DATA SEGMENT +??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ DB 'java/lang/Boolean', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ +_DATA SEGMENT +??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ DB 'java/lang/Integer', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0BB@LLFN@java?1lang?1String?$AA@ +_DATA SEGMENT +??_C@_0BB@LLFN@java?1lang?1String?$AA@ DB 'java/lang/String', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_02LOEJ@?$FLB?$AA@ +_DATA SEGMENT +??_C@_02LOEJ@?$FLB?$AA@ DB '[B', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_02BENO@?$FLC?$AA@ +_DATA SEGMENT +??_C@_02BENO@?$FLC?$AA@ DB '[C', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_03KJOK@?$CI?$CJZ?$AA@ +_DATA SEGMENT +??_C@_03KJOK@?$CI?$CJZ?$AA@ DB '()Z', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_0N@KEBP@booleanValue?$AA@ +_DATA SEGMENT +??_C@_0N@KEBP@booleanValue?$AA@ DB 'booleanValue', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_03PPCD@?$CI?$CJI?$AA@ +_DATA SEGMENT +??_C@_03PPCD@?$CI?$CJI?$AA@ DB '()I', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_08JCMA@intValue?$AA@ +_DATA SEGMENT +??_C@_08JCMA@intValue?$AA@ DB 'intValue', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_04ECLF@?$CII?$CJV?$AA@ +_DATA SEGMENT +??_C@_04ECLF@?$CII?$CJV?$AA@ DB '(I)V', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_06KILP@?$DMinit?$DO?$AA@ +_DATA SEGMENT +??_C@_06KILP@?$DMinit?$DO?$AA@ DB '', 00H ; `string' +_DATA ENDS +; COMDAT ??_C@_04JFOE@?$CIZ?$CJV?$AA@ +_DATA SEGMENT +??_C@_04JFOE@?$CIZ?$CJV?$AA@ DB '(Z)V', 00H ; `string' +_DATA ENDS +_TEXT SEGMENT +_env$ = 8 +_cls$ = 12 +_Java_com_eaio_nativecall_NativeCall_initIDs@8 PROC NEAR + +; 71 : (JNIEnv *env, jclass cls) { + + push ebx + +; 72 : +; 73 : // NativeCall fields +; 74 : +; 75 : fieldFunction = env->GetFieldID(cls, "function", "Ljava/lang/String;"); + + mov ebx, DWORD PTR _cls$[esp] + push esi + mov esi, DWORD PTR _env$[esp+4] + push edi + mov edi, OFFSET FLAT:??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ ; `string' + mov eax, DWORD PTR [esi] + push edi + push OFFSET FLAT:??_C@_08JJOG@function?$AA@ ; `string' + push ebx + push esi + call DWORD PTR [eax+376] + +; 76 : fieldModule = env->GetFieldID(cls, "module", "Ljava/lang/String;"); + + push edi + mov DWORD PTR ?fieldFunction@@3PAU_jfieldID@@A, eax ; fieldFunction + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_06CODG@module?$AA@ ; `string' + push ebx + push esi + call DWORD PTR [eax+376] + +; 77 : +; 78 : fieldFunctionHandle = env->GetFieldID(cls, "functionHandle", "I"); + + mov edi, OFFSET FLAT:??_C@_01FLOP@I?$AA@ ; `string' + mov DWORD PTR ?fieldModule@@3PAU_jfieldID@@A, eax ; fieldModule + mov eax, DWORD PTR [esi] + push edi + push OFFSET FLAT:??_C@_0P@LKIL@functionHandle?$AA@ ; `string' + push ebx + push esi + call DWORD PTR [eax+376] + +; 79 : fieldModuleHandle = env-> GetFieldID(cls, "moduleHandle", "I"); + + push edi + mov DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A, eax ; fieldFunctionHandle + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0N@EFAA@moduleHandle?$AA@ ; `string' + push ebx + push esi + call DWORD PTR [eax+376] + +; 80 : +; 81 : fieldLastErrorCode = env->GetFieldID(cls, "lastErrorCode", "I"); + + push edi + mov DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A, eax ; fieldModuleHandle + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0O@OMHL@lastErrorCode?$AA@ ; `string' + push ebx + push esi + call DWORD PTR [eax+376] + mov DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A, eax ; fieldLastErrorCode + +; 82 : +; 83 : // Holder fields +; 84 : +; 85 : classHolder = (jclass) env->NewGlobalRef(env->FindClass("com/eaio/nativecall/Holder")); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push eax + push esi + call DWORD PTR [ecx+84] + +; 86 : fieldHolderO = env->GetFieldID(classHolder, "o", "Ljava/lang/Object;"); + + mov ecx, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ ; `string' + push OFFSET FLAT:??_C@_01PGHN@o?$AA@ ; `string' + push eax + push esi + mov DWORD PTR ?classHolder@@3PAV_jclass@@A, eax ; classHolder + call DWORD PTR [ecx+376] + mov DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A, eax ; fieldHolderO + +; 87 : +; 88 : // Other classes +; 89 : +; 90 : classBoolean = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Boolean")); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push eax + push esi + call DWORD PTR [ecx+84] + mov DWORD PTR ?classBoolean@@3PAV_jclass@@A, eax ; classBoolean + +; 91 : /*classByte = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Byte")); +; 92 : classCharacter = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Character")); +; 93 : classShort = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Short"));*/ +; 94 : classInteger = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Integer")); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push eax + push esi + call DWORD PTR [ecx+84] + mov DWORD PTR ?classInteger@@3PAV_jclass@@A, eax ; classInteger + +; 95 : /*classLong = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Long")); +; 96 : classFloat = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Float")); +; 97 : classDouble = (jclass) env->NewGlobalRef(env->FindClass("java/lang/Double"));*/ +; 98 : classString = (jclass) env->NewGlobalRef(env->FindClass("java/lang/String")); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BB@LLFN@java?1lang?1String?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push eax + push esi + call DWORD PTR [ecx+84] + mov DWORD PTR ?classString@@3PAV_jclass@@A, eax ; classString + +; 99 : classByteArray = (jclass) env->NewGlobalRef(env->FindClass("[B")); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_02LOEJ@?$FLB?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push eax + push esi + call DWORD PTR [ecx+84] + mov DWORD PTR ?classByteArray@@3PAV_jclass@@A, eax ; classByteArray + +; 100 : classCharArray = (jclass) env->NewGlobalRef(env->FindClass("[C")); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_02BENO@?$FLC?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push eax + push esi + call DWORD PTR [ecx+84] + +; 101 : /*classIntArray = (jclass) env->NewGlobalRef(env->FindClass("[I"));*/ +; 102 : +; 103 : // Wrapper class methods +; 104 : +; 105 : methodBooleanValue = env->GetMethodID(classBoolean, +; 106 : "booleanValue", "()Z"); + + mov ecx, DWORD PTR [esi] + mov DWORD PTR ?classCharArray@@3PAV_jclass@@A, eax ; classCharArray + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push OFFSET FLAT:??_C@_03KJOK@?$CI?$CJZ?$AA@ ; `string' + push OFFSET FLAT:??_C@_0N@KEBP@booleanValue?$AA@ ; `string' + push eax + push esi + call DWORD PTR [ecx+132] + +; 107 : /*methodByteValue = env->GetMethodID(classByte, +; 108 : "byteValue", "()B"); +; 109 : methodCharValue = env->GetMethodID(classCharacter, +; 110 : "charValue", "()C"); +; 111 : methodShortValue = env->GetMethodID(classShort, +; 112 : "shortValue", "()S");*/ +; 113 : methodIntValue = env->GetMethodID(classInteger, +; 114 : "intValue", "()I"); + + mov ecx, DWORD PTR [esi] + mov DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A, eax ; methodBooleanValue + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push OFFSET FLAT:??_C@_03PPCD@?$CI?$CJI?$AA@ ; `string' + push OFFSET FLAT:??_C@_08JCMA@intValue?$AA@ ; `string' + push eax + push esi + call DWORD PTR [ecx+132] + +; 115 : /*methodLongValue = env->GetMethodID(classLong, +; 116 : "longValue", "()J"); +; 117 : methodFloatValue = env->GetMethodID(classFloat, +; 118 : "floatValue", "()F"); +; 119 : methodDoubleValue = env->GetMethodID(classDouble, +; 120 : "doubleValue", "()D");*/ +; 121 : +; 122 : // Constructors +; 123 : +; 124 : newIntegerInt = env->GetMethodID(classInteger, "", "(I)V"); + + mov ecx, DWORD PTR [esi] + mov DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A, eax ; methodIntValue + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + mov edi, OFFSET FLAT:??_C@_06KILP@?$DMinit?$DO?$AA@ ; `string' + push OFFSET FLAT:??_C@_04ECLF@?$CII?$CJV?$AA@ ; `string' + push edi + push eax + push esi + call DWORD PTR [ecx+132] + +; 125 : newBooleanBoolean = env->GetMethodID(classBoolean, "", "(Z)V"); + + mov ecx, DWORD PTR [esi] + mov DWORD PTR ?newIntegerInt@@3PAU_jmethodID@@A, eax ; newIntegerInt + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + push OFFSET FLAT:??_C@_04JFOE@?$CIZ?$CJV?$AA@ ; `string' + push edi + push eax + push esi + call DWORD PTR [ecx+132] + pop edi + pop esi + mov DWORD PTR ?newBooleanBoolean@@3PAU_jmethodID@@A, eax ; newBooleanBoolean + pop ebx + +; 126 : +; 127 : } + + ret 8 +_Java_com_eaio_nativecall_NativeCall_initIDs@8 ENDP +_TEXT ENDS +PUBLIC _Java_com_eaio_nativecall_NativeCall_initHandles@8 +EXTRN __imp__LoadLibraryA@4:NEAR +EXTRN __imp__GetLastError@0:NEAR +EXTRN __imp__FreeLibrary@4:NEAR +EXTRN __imp__GetProcAddress@8:NEAR +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_out$ = -1 +_moduleNameS$ = 12 +_functionNameS$ = -12 +_moduleName$ = 8 +_functionName$ = -8 +_addr$27794 = -16 +_Java_com_eaio_nativecall_NativeCall_initHandles@8 PROC NEAR + +; 135 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + sub esp, 16 ; 00000010H + +; 136 : +; 137 : bool out = JNI_TRUE; +; 138 : +; 139 : jstring moduleNameS = (jstring) env->GetObjectField(obj, fieldModule); + + mov eax, DWORD PTR ?fieldModule@@3PAU_jfieldID@@A ; fieldModule + push ebx + push esi + mov esi, DWORD PTR _env$[ebp] + push edi + mov edi, DWORD PTR _obj$[ebp] + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + mov BYTE PTR _out$[ebp], 1 + call DWORD PTR [ecx+380] + +; 140 : jstring functionNameS = (jstring) env->GetObjectField(obj, fieldFunction); + + mov ecx, DWORD PTR [esi] + mov DWORD PTR _moduleNameS$[ebp], eax + mov eax, DWORD PTR ?fieldFunction@@3PAU_jfieldID@@A ; fieldFunction + push eax + push edi + push esi + call DWORD PTR [ecx+380] + +; 141 : +; 142 : const char* moduleName = env->GetStringUTFChars(moduleNameS, 0); + + push 0 + mov DWORD PTR _functionNameS$[ebp], eax + push DWORD PTR _moduleNameS$[ebp] + mov eax, DWORD PTR [esi] + push esi + call DWORD PTR [eax+676] + +; 143 : const char* functionName = env->GetStringUTFChars(functionNameS, 0); + + push 0 + mov DWORD PTR _moduleName$[ebp], eax + push DWORD PTR _functionNameS$[ebp] + mov eax, DWORD PTR [esi] + push esi + call DWORD PTR [eax+676] + +; 144 : +; 145 : #ifdef _WINDOWS +; 146 : +; 147 : HMODULE mod = LoadLibrary(moduleName); + + push DWORD PTR _moduleName$[ebp] + mov DWORD PTR _functionName$[ebp], eax + call DWORD PTR __imp__LoadLibraryA@4 + mov ebx, eax + +; 148 : +; 149 : if (mod == NULL) { + + test ebx, ebx + jne SHORT $L27792 +$L27990: + +; 150 : /* no such module or DllMain returned FALSE */ +; 151 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + call DWORD PTR __imp__GetLastError@0 + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push edi + push esi + call DWORD PTR [ecx+436] + +; 152 : out = JNI_FALSE; + + and BYTE PTR _out$[ebp], 0 + +; 153 : } +; 154 : else { + + jmp SHORT $L27982 +$L27792: + +; 155 : FARPROC addr = GetProcAddress(mod, functionName); + + push DWORD PTR _functionName$[ebp] + push ebx + call DWORD PTR __imp__GetProcAddress@8 + +; 156 : if (addr == NULL) { + + test eax, eax + mov DWORD PTR _addr$27794[ebp], eax + jne SHORT $L27795 + +; 157 : /* function not found */ +; 158 : FreeLibrary(mod); + + push ebx + call DWORD PTR __imp__FreeLibrary@4 + +; 159 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); +; 160 : out = JNI_FALSE; +; 161 : } +; 162 : else { + + jmp SHORT $L27990 +$L27795: + +; 163 : /* all ok */ +; 164 : env->SetIntField(obj, fieldModuleHandle, (jint) mod); + + mov eax, DWORD PTR [esi] + push ebx + push DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle + push edi + push esi + call DWORD PTR [eax+436] + +; 165 : env->SetIntField(obj, fieldFunctionHandle, (jint) addr); + + push DWORD PTR _addr$27794[ebp] + mov eax, DWORD PTR [esi] + push DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push edi + push esi + call DWORD PTR [eax+436] +$L27982: + +; 166 : } +; 167 : } +; 168 : +; 169 : #endif +; 170 : +; 171 : env->ReleaseStringUTFChars(moduleNameS, moduleName); + + push DWORD PTR _moduleName$[ebp] + mov eax, DWORD PTR [esi] + push DWORD PTR _moduleNameS$[ebp] + push esi + call DWORD PTR [eax+680] + +; 172 : env->ReleaseStringUTFChars(functionNameS, functionName); + + push DWORD PTR _functionName$[ebp] + mov eax, DWORD PTR [esi] + push DWORD PTR _functionNameS$[ebp] + push esi + call DWORD PTR [eax+680] + +; 173 : +; 174 : return out; + + mov al, BYTE PTR _out$[ebp] + pop edi + pop esi + pop ebx + +; 175 : +; 176 : } + + leave + ret 8 +_Java_com_eaio_nativecall_NativeCall_initHandles@8 ENDP +_TEXT ENDS +PUBLIC _Java_com_eaio_nativecall_NativeCall_getLastError@8 +EXTRN __imp__FormatMessageA@28:NEAR +EXTRN __imp__LocalFree@4:NEAR +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_msgBufPtr$ = 8 +_Java_com_eaio_nativecall_NativeCall_getLastError@8 PROC NEAR + +; 184 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + +; 185 : +; 186 : jint lastError = env->GetIntField(obj, fieldLastErrorCode); + + mov eax, DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push esi + mov esi, DWORD PTR _env$[ebp] + push eax + push DWORD PTR _obj$[ebp] + mov ecx, DWORD PTR [esi] + push esi + call DWORD PTR [ecx+400] + +; 187 : +; 188 : if (lastError == 0) return NULL; + + xor ecx, ecx + cmp eax, ecx + jne SHORT $L27804 + xor eax, eax + jmp SHORT $L27802 +$L27804: + +; 189 : +; 190 : jstring out = NULL; +; 191 : +; 192 : #ifdef _WINDOWS +; 193 : +; 194 : LPVOID msgBufPtr = NULL; +; 195 : FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | +; 196 : FORMAT_MESSAGE_FROM_SYSTEM, NULL, lastError, 0, +; 197 : (LPSTR) &msgBufPtr, 0, NULL); + + push ecx + lea edx, DWORD PTR _msgBufPtr$[ebp] + push ecx + push edx + push ecx + push eax + push ecx + push 4352 ; 00001100H + mov DWORD PTR _msgBufPtr$[ebp], ecx + call DWORD PTR __imp__FormatMessageA@28 + +; 198 : +; 199 : out = env->NewStringUTF((char*) msgBufPtr); + + push DWORD PTR _msgBufPtr$[ebp] + mov eax, DWORD PTR [esi] + push esi + call DWORD PTR [eax+668] + +; 200 : +; 201 : LocalFree(msgBufPtr); + + push DWORD PTR _msgBufPtr$[ebp] + mov esi, eax + call DWORD PTR __imp__LocalFree@4 + +; 202 : +; 203 : #endif +; 204 : +; 205 : return out; + + mov eax, esi +$L27802: + pop esi + +; 206 : +; 207 : } + + pop ebp + ret 8 +_Java_com_eaio_nativecall_NativeCall_getLastError@8 ENDP +_TEXT ENDS +PUBLIC _Java_com_eaio_nativecall_NativeCall_destroy@8 +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_Java_com_eaio_nativecall_NativeCall_destroy@8 PROC NEAR + +; 216 : +; 217 : jint module = env->GetIntField(obj, fieldModuleHandle); + + mov eax, DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle + push esi + mov esi, DWORD PTR _env$[esp] + push edi + mov edi, DWORD PTR _obj$[esp+4] + push eax + mov ecx, DWORD PTR [esi] + push edi + push esi + call DWORD PTR [ecx+400] + +; 218 : +; 219 : if (module == 0) return; + + test eax, eax + je SHORT $L28016 + +; 220 : +; 221 : #ifdef _WINDOWS +; 222 : +; 223 : if (FreeLibrary((HMODULE) module) == 0) { + + push eax + call DWORD PTR __imp__FreeLibrary@4 + test eax, eax + jne SHORT $L28007 + +; 224 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + call DWORD PTR __imp__GetLastError@0 + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push edi + push esi + call DWORD PTR [ecx+436] +$L28007: + +; 225 : } +; 226 : +; 227 : #endif +; 228 : +; 229 : env->SetIntField(obj, fieldModuleHandle, 0); + + mov eax, DWORD PTR [esi] + push 0 + push DWORD PTR ?fieldModuleHandle@@3PAU_jfieldID@@A ; fieldModuleHandle + push edi + push esi + call DWORD PTR [eax+436] + +; 230 : env->SetIntField(obj, fieldFunctionHandle, 0); + + mov eax, DWORD PTR [esi] + push 0 + push DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push edi + push esi + call DWORD PTR [eax+436] +$L28016: + pop edi + pop esi + +; 231 : +; 232 : return; +; 233 : +; 234 : } + + ret 8 +_Java_com_eaio_nativecall_NativeCall_destroy@8 ENDP +_TEXT ENDS +END diff --git a/vendor/nativecall/0.4.1/cpp/Release/NativeCall.dll b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.dll new file mode 100644 index 0000000..6e2cad1 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.dll differ diff --git a/vendor/nativecall/0.4.1/cpp/Release/NativeCall.map b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.map new file mode 100644 index 0000000..e31a069 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.map @@ -0,0 +1,101 @@ + NativeCall + + Timestamp is 44472064 (Thu Apr 20 07:47:16 2006) + + Preferred load address is 10000000 + + Start Length Name Class + 0001:00000000 00000028H .idata$5 CODE + 0001:00000030 00000d1eH .text CODE + 0001:00000d50 00000014H .idata$2 CODE + 0001:00000d64 00000014H .idata$3 CODE + 0001:00000d78 00000028H .idata$4 CODE + 0001:00000da0 00000096H .idata$6 CODE + 0001:00000e40 00000212H .edata CODE + 0002:00000000 00000004H .CRT$XCA DATA + 0002:00000004 00000004H .CRT$XCZ DATA + 0002:00000010 00000130H .data DATA + 0002:00000140 0000004cH .bss DATA + 0003:00000000 00000058H .rsrc$01 DATA + 0003:00000060 000002b0H .rsrc$02 DATA + + Address Publics by Value Rva+Base Lib:Object + + 0001:00000000 __imp__FormatMessageA@28 10001000 kernel32:KERNEL32.dll + 0001:00000004 __imp__FreeLibrary@4 10001004 kernel32:KERNEL32.dll + 0001:00000008 __imp__GetProcAddress@8 10001008 kernel32:KERNEL32.dll + 0001:0000000c __imp__LoadLibraryA@4 1000100c kernel32:KERNEL32.dll + 0001:00000010 __imp__LocalFree@4 10001010 kernel32:KERNEL32.dll + 0001:00000014 __imp__GetLastError@0 10001014 kernel32:KERNEL32.dll + 0001:00000018 __imp__HeapAlloc@12 10001018 kernel32:KERNEL32.dll + 0001:0000001c __imp__GetProcessHeap@0 1000101c kernel32:KERNEL32.dll + 0001:00000020 __imp__HeapFree@12 10001020 kernel32:KERNEL32.dll + 0001:00000024 \177KERNEL32_NULL_THUNK_DATA 10001024 kernel32:KERNEL32.dll + 0001:00000030 _Java_com_eaio_nativecall_IntCall_executeCall@8 10001030 f IntCall.obj + 0001:00000074 _Java_com_eaio_nativecall_IntCall_executeCall0@12 10001074 f IntCall.obj + 0001:0000045e ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ 1000145e f i IntCall.obj + 0001:00000476 ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ 10001476 f i IntCall.obj + 0001:00000491 ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ 10001491 f i IntCall.obj + 0001:000004ac _Java_com_eaio_nativecall_NativeCall_initIDs@8 100014ac f NativeCall.obj + 0001:00000648 _Java_com_eaio_nativecall_NativeCall_initHandles@8 10001648 f NativeCall.obj + 0001:00000735 _Java_com_eaio_nativecall_NativeCall_getLastError@8 10001735 f NativeCall.obj + 0001:0000078d _Java_com_eaio_nativecall_NativeCall_destroy@8 1000178d f NativeCall.obj + 0001:000007f6 _Java_com_eaio_nativecall_VoidCall_executeCall@8 100017f6 f VoidCall.obj + 0001:00000833 _Java_com_eaio_nativecall_VoidCall_executeCall0@12 10001833 f VoidCall.obj + 0001:00000c15 ??2@YAPAXI@Z 10001c15 f libctiny:NEWDEL.OBJ + 0001:00000c29 ??3@YAXPAX@Z 10001c29 f libctiny:NEWDEL.OBJ + 0001:00000c3d __DllMainCRTStartup@12 10001c3d f libctiny:DLLCRT0.OBJ + 0001:00000c7f ?_initterm@@YAXPAP6AXXZ0@Z 10001c7f f libctiny:INITTERM.OBJ + 0001:00000c99 ?_atexit_init@@YAXXZ 10001c99 f libctiny:INITTERM.OBJ + 0001:00000cb1 ?_DoExit@@YAXXZ 10001cb1 f libctiny:INITTERM.OBJ + 0001:00000ccd _calloc 10001ccd f libctiny:ALLOC2.OBJ + 0001:00000cf0 _memset 10001cf0 f libcmt:memset.obj + 0001:00000d48 _DllMain@12 10001d48 f libcmt:dllmain.obj + 0001:00000d50 __IMPORT_DESCRIPTOR_KERNEL32 10001d50 kernel32:KERNEL32.dll + 0001:00000d64 __NULL_IMPORT_DESCRIPTOR 10001d64 kernel32:KERNEL32.dll + 0002:00000000 ?__xc_a@@3PAP6AXXZA 10003000 libctiny:INITTERM.OBJ + 0002:00000004 ?__xc_z@@3PAP6AXXZA 10003004 libctiny:INITTERM.OBJ + 0002:00000010 ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ 10003010 IntCall.obj + 0002:0000002c ??_C@_04JFOE@?$CIZ?$CJV?$AA@ 1000302c NativeCall.obj + 0002:00000034 ??_C@_04ECLF@?$CII?$CJV?$AA@ 10003034 NativeCall.obj + 0002:0000003c ??_C@_06KILP@?$DMinit?$DO?$AA@ 1000303c NativeCall.obj + 0002:00000044 ??_C@_08JCMA@intValue?$AA@ 10003044 NativeCall.obj + 0002:00000050 ??_C@_03PPCD@?$CI?$CJI?$AA@ 10003050 NativeCall.obj + 0002:00000054 ??_C@_0N@KEBP@booleanValue?$AA@ 10003054 NativeCall.obj + 0002:00000064 ??_C@_03KJOK@?$CI?$CJZ?$AA@ 10003064 NativeCall.obj + 0002:00000068 ??_C@_02BENO@?$FLC?$AA@ 10003068 NativeCall.obj + 0002:0000006c ??_C@_02LOEJ@?$FLB?$AA@ 1000306c NativeCall.obj + 0002:00000070 ??_C@_0BB@LLFN@java?1lang?1String?$AA@ 10003070 NativeCall.obj + 0002:00000084 ??_C@_0BC@FBKL@java?1lang?1Integer?$AA@ 10003084 NativeCall.obj + 0002:00000098 ??_C@_0BC@IGNJ@java?1lang?1Boolean?$AA@ 10003098 NativeCall.obj + 0002:000000ac ??_C@_01PGHN@o?$AA@ 100030ac NativeCall.obj + 0002:000000b0 ??_C@_0BD@GEDI@Ljava?1lang?1Object?$DL?$AA@ 100030b0 NativeCall.obj + 0002:000000c4 ??_C@_0BL@DALH@com?1eaio?1nativecall?1Holder?$AA@ 100030c4 NativeCall.obj + 0002:000000e0 ??_C@_0O@OMHL@lastErrorCode?$AA@ 100030e0 NativeCall.obj + 0002:000000f0 ??_C@_0N@EFAA@moduleHandle?$AA@ 100030f0 NativeCall.obj + 0002:00000100 ??_C@_0P@LKIL@functionHandle?$AA@ 10003100 NativeCall.obj + 0002:00000110 ??_C@_01FLOP@I?$AA@ 10003110 NativeCall.obj + 0002:00000114 ??_C@_06CODG@module?$AA@ 10003114 NativeCall.obj + 0002:0000011c ??_C@_08JJOG@function?$AA@ 1000311c NativeCall.obj + 0002:00000128 ??_C@_0BD@DFD@Ljava?1lang?1String?$DL?$AA@ 10003128 NativeCall.obj + 0002:00000140 ?classString@@3PAV_jclass@@A 10003140 NativeCall.obj + 0002:00000144 ?fieldFunctionHandle@@3PAU_jfieldID@@A 10003144 NativeCall.obj + 0002:00000148 ?newIntegerInt@@3PAU_jmethodID@@A 10003148 NativeCall.obj + 0002:0000014c ?classCharArray@@3PAV_jclass@@A 1000314c NativeCall.obj + 0002:00000150 ?fieldFunction@@3PAU_jfieldID@@A 10003150 NativeCall.obj + 0002:00000154 ?classInteger@@3PAV_jclass@@A 10003154 NativeCall.obj + 0002:00000158 ?newBooleanBoolean@@3PAU_jmethodID@@A 10003158 NativeCall.obj + 0002:0000015c ?classBoolean@@3PAV_jclass@@A 1000315c NativeCall.obj + 0002:00000160 ?fieldModule@@3PAU_jfieldID@@A 10003160 NativeCall.obj + 0002:00000164 ?fieldModuleHandle@@3PAU_jfieldID@@A 10003164 NativeCall.obj + 0002:00000168 ?classHolder@@3PAV_jclass@@A 10003168 NativeCall.obj + 0002:0000016c ?fieldLastErrorCode@@3PAU_jfieldID@@A 1000316c NativeCall.obj + 0002:00000170 ?classByteArray@@3PAV_jclass@@A 10003170 NativeCall.obj + 0002:00000174 ?fieldHolderO@@3PAU_jfieldID@@A 10003174 NativeCall.obj + 0002:00000178 ?methodBooleanValue@@3PAU_jmethodID@@A 10003178 NativeCall.obj + 0002:0000017c ?methodIntValue@@3PAU_jmethodID@@A 1000317c NativeCall.obj + + entry point at 0001:00000c3d + + Static symbols + diff --git a/vendor/nativecall/0.4.1/cpp/Release/NativeCall.obj b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.obj new file mode 100644 index 0000000..44a1efa Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Release/NativeCall.obj differ diff --git a/vendor/nativecall/0.4.1/cpp/Release/RCa01380 b/vendor/nativecall/0.4.1/cpp/Release/RCa01380 new file mode 100644 index 0000000..eb8e4b1 Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Release/RCa01380 differ diff --git a/vendor/nativecall/0.4.1/cpp/Release/VoidCall.asm b/vendor/nativecall/0.4.1/cpp/Release/VoidCall.asm new file mode 100644 index 0000000..9e91a33 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/Release/VoidCall.asm @@ -0,0 +1,919 @@ + TITLE C:\Documents and Settings\Administrator\My Documents\Software\NativeCall\src\cpp\VoidCall.cpp + .386P +include listing.inc +if @Version gt 510 +.model FLAT +else +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +CONST SEGMENT DWORD USE32 PUBLIC 'CONST' +CONST ENDS +_BSS SEGMENT DWORD USE32 PUBLIC 'BSS' +_BSS ENDS +_TLS SEGMENT DWORD USE32 PUBLIC 'TLS' +_TLS ENDS +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +_DATA SEGMENT DWORD USE32 PUBLIC 'DATA' +_DATA ENDS +; COMDAT ?FindClass@JNIEnv_@@QAEPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ThrowNew@JNIEnv_@@QAEJPAV_jclass@@PBD@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?IsInstanceOf@JNIEnv_@@QAEEPAV_jobject@@PAV_jclass@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectField@JNIEnv_@@QAEPAV_jobject@@PAV2@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetIntField@JNIEnv_@@QAEJPAV_jobject@@PAU_jfieldID@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetObjectField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@0@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?SetIntField@JNIEnv_@@QAEXPAV_jobject@@PAU_jfieldID@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetArrayLength@JNIEnv_@@QAEJPAV_jarray@@@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetObjectArrayElement@JNIEnv_@@QAEPAV_jobject@@PAV_jobjectArray@@J@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?GetPrimitiveArrayCritical@JNIEnv_@@QAEPAXPAV_jarray@@PAE@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +; COMDAT ?ReleasePrimitiveArrayCritical@JNIEnv_@@QAEXPAV_jarray@@PAXJ@Z +_TEXT SEGMENT PARA USE32 PUBLIC 'CODE' +_TEXT ENDS +FLAT GROUP _DATA, CONST, _BSS + ASSUME CS: FLAT, DS: FLAT, SS: FLAT +endif +PUBLIC _Java_com_eaio_nativecall_VoidCall_executeCall@8 +EXTRN ?fieldFunctionHandle@@3PAU_jfieldID@@A:DWORD ; fieldFunctionHandle +EXTRN ?fieldLastErrorCode@@3PAU_jfieldID@@A:DWORD ; fieldLastErrorCode +EXTRN __imp__GetLastError@0:NEAR +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_functionHandle$ = 8 +_Java_com_eaio_nativecall_VoidCall_executeCall@8 PROC NEAR + +; 79 : (JNIEnv *env, jobject obj) { + + push ebp + mov ebp, esp + +; 80 : +; 81 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + push esi + mov esi, DWORD PTR _env$[ebp] + push eax + push DWORD PTR _obj$[ebp] + mov ecx, DWORD PTR [esi] + push esi + call DWORD PTR [ecx+400] + mov DWORD PTR _functionHandle$[ebp], eax + +; 82 : +; 83 : #ifdef _WINDOWS +; 84 : #ifdef _X86_ +; 85 : +; 86 : __asm { +; 87 : +; 88 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 89 : +; 90 : } +; 91 : +; 92 : #endif +; 93 : #endif +; 94 : +; 95 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + call DWORD PTR __imp__GetLastError@0 + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push DWORD PTR _obj$[ebp] + push esi + call DWORD PTR [ecx+436] + +; 96 : +; 97 : } + + pop esi + pop ebp + ret 8 +_Java_com_eaio_nativecall_VoidCall_executeCall@8 ENDP +_TEXT ENDS +PUBLIC ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' +PUBLIC _Java_com_eaio_nativecall_VoidCall_executeCall0@12 +PUBLIC ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject +PUBLIC ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod +PUBLIC ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod +EXTRN ?fieldHolderO@@3PAU_jfieldID@@A:DWORD ; fieldHolderO +EXTRN ?classBoolean@@3PAV_jclass@@A:DWORD ; classBoolean +EXTRN ?classInteger@@3PAV_jclass@@A:DWORD ; classInteger +EXTRN ?classByteArray@@3PAV_jclass@@A:DWORD ; classByteArray +EXTRN ?classCharArray@@3PAV_jclass@@A:DWORD ; classCharArray +EXTRN ?classHolder@@3PAV_jclass@@A:DWORD ; classHolder +EXTRN ?methodBooleanValue@@3PAU_jmethodID@@A:DWORD ; methodBooleanValue +EXTRN ?methodIntValue@@3PAU_jmethodID@@A:DWORD ; methodIntValue +EXTRN ?newIntegerInt@@3PAU_jmethodID@@A:DWORD ; newIntegerInt +EXTRN ?newBooleanBoolean@@3PAU_jmethodID@@A:DWORD ; newBooleanBoolean +EXTRN ??2@YAPAXI@Z:NEAR ; operator new +EXTRN ??3@YAXPAX@Z:NEAR ; operator delete +EXTRN _memset:NEAR +; COMDAT ??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ +; File C:\Program Files\IBMJava13\include\jni.h +_DATA SEGMENT +??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ DB 'java/lang/OutOfMemor' + DB 'yError', 00H ; `string' +_DATA ENDS +_TEXT SEGMENT +_env$ = 8 +_obj$ = 12 +_params$ = 16 +_len$ = -28 +_arrays$ = -20 +_param$ = -24 +_i$ = 8 +_intArg$27769 = -24 +_byteArrayArg$27772 = -4 +_charArrayArg$27778 = -8 +_tempArg$27785 = -24 +_intPtr$27790 = -24 +_byteArrayArg$27796 = -12 +_charArrayArg$27802 = -16 +_tempPtr$27809 = -24 +_functionHandle$ = 8 +_j$ = 8 +_Java_com_eaio_nativecall_VoidCall_executeCall0@12 PROC NEAR + +; 105 : (JNIEnv *env, jobject obj, jobjectArray params) { + + push ebp + mov ebp, esp + sub esp, 28 ; 0000001cH + push ebx + push esi + +; 106 : +; 107 : const int len = env->GetArrayLength(params); + + mov esi, DWORD PTR _env$[ebp] + push edi + push DWORD PTR _params$[ebp] + mov eax, DWORD PTR [esi] + push esi + call DWORD PTR [eax+684] + mov ebx, eax + +; 108 : +; 109 : int* arrays = NULL; +; 110 : if (!(arrays = new int[len])) { + + mov edi, ebx + mov DWORD PTR _len$[ebp], ebx + shl edi, 2 + push edi + call ??2@YAPAXI@Z ; operator new + test eax, eax + pop ecx + mov DWORD PTR _arrays$[ebp], eax + jne SHORT $L27758 + +; 111 : env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); + + mov eax, DWORD PTR [esi] + push OFFSET FLAT:??_C@_0BL@NKOM@java?1lang?1OutOfMemoryError?$AA@ ; `string' + push esi + call DWORD PTR [eax+24] + mov ecx, DWORD PTR [esi] + push 0 + push eax + push esi + call DWORD PTR [ecx+56] + +; 112 : return; + + jmp $L28021 +$L27758: + +; 113 : } +; 114 : memset(arrays, 0, (sizeof(int) * len)); + + push edi + push 0 + push eax + call _memset + +; 115 : +; 116 : jobject param; +; 117 : +; 118 : for (int i = len - 1; i >= 0; i--) { + + lea eax, DWORD PTR [ebx-1] + add esp, 12 ; 0000000cH + test eax, eax + mov DWORD PTR _i$[ebp], eax + jl $L27765 + mov ecx, DWORD PTR _arrays$[ebp] + lea edi, DWORD PTR [ecx+eax*4] + jmp SHORT $L27763 +$L28028: + +; 113 : } +; 114 : memset(arrays, 0, (sizeof(int) * len)); + + mov eax, DWORD PTR _i$[ebp] +$L27763: + +; 119 : +; 120 : param = env->GetObjectArrayElement(params, i); + + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR _params$[ebp] + push esi + call DWORD PTR [ecx+692] + mov ebx, eax + +; 121 : +; 122 : if (param == NULL) { + + test ebx, ebx + jne SHORT $L27766 + +; 123 : _push(0); + + push 0 + +; 124 : } +; 125 : else if (env->IsInstanceOf(param, classInteger)) { + + jmp $L27764 +$L27766: + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27768 + +; 126 : int intArg = env->CallIntMethod(param, methodIntValue); + + push DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push ebx + push esi + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + add esp, 12 ; 0000000cH + mov DWORD PTR _intArg$27769[ebp], eax + +; 127 : _push(intArg) + + push DWORD PTR _intArg$27769[ebp] + +; 128 : } +; 129 : else if (env->IsInstanceOf(param, classByteArray)) { + + jmp $L27764 +$L27768: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27771 + +; 130 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _byteArrayArg$27772[ebp], eax + +; 131 : arrays[i] = (int) &byteArrayArg; + + lea eax, DWORD PTR _byteArrayArg$27772[ebp] + mov DWORD PTR [edi], eax + +; 132 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$27772[ebp] + +; 133 : } +; 134 : else if (env->IsInstanceOf(param, classCharArray)) { + + jmp $L27764 +$L27771: + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27777 + +; 135 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 136 : (jarray) param, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _charArrayArg$27778[ebp], eax + +; 137 : arrays[i] = (int) &charArrayArg; + + lea eax, DWORD PTR _charArrayArg$27778[ebp] + mov DWORD PTR [edi], eax + +; 138 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$27778[ebp] + +; 139 : } +; 140 : else if (env->IsInstanceOf(param, classBoolean)) { + + jmp $L27764 +$L27777: + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27783 + +; 141 : jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); + + push DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ebx + push esi + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + add esp, 12 ; 0000000cH + +; 142 : int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); + + neg al + sbb eax, eax + neg eax + mov DWORD PTR _tempArg$27785[ebp], eax + +; 143 : _push(tempArg) + + push DWORD PTR _tempArg$27785[ebp] + +; 144 : } +; 145 : else if (env->IsInstanceOf(param, classHolder)) { + + jmp $L27764 +$L27783: + mov eax, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je $L27764 + +; 146 : +; 147 : /* Holder */ +; 148 : +; 149 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov eax, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+380] + +; 150 : +; 151 : if (env->IsInstanceOf(o, classInteger)) { + + mov ecx, DWORD PTR [esi] + mov ebx, eax + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27789 + +; 152 : int *intPtr = new int; + + push 4 + call ??2@YAPAXI@Z ; operator new + pop ecx + mov DWORD PTR _intPtr$27790[ebp], eax + +; 153 : *intPtr = env->CallIntMethod(o, methodIntValue); + + push DWORD PTR ?methodIntValue@@3PAU_jmethodID@@A ; methodIntValue + push ebx + push esi + call ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallIntMethod + mov ecx, DWORD PTR _intPtr$27790[ebp] + add esp, 12 ; 0000000cH + +; 154 : arrays[i] = (int) intPtr; + + mov DWORD PTR [edi], ecx + mov DWORD PTR [ecx], eax + +; 155 : _push(intPtr); + + push DWORD PTR _intPtr$27790[ebp] + +; 156 : } +; 157 : else if (env->IsInstanceOf(o, classByteArray)) { + + jmp $L27764 +$L27789: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27795 + +; 158 : char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _byteArrayArg$27796[ebp], eax + +; 159 : arrays[i] = (int) &byteArrayArg; + + lea eax, DWORD PTR _byteArrayArg$27796[ebp] + mov DWORD PTR [edi], eax + +; 160 : _push(byteArrayArg) + + push DWORD PTR _byteArrayArg$27796[ebp] + +; 161 : } +; 162 : else if (env->IsInstanceOf(o, classCharArray)) { + + jmp SHORT $L27764 +$L27795: + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27801 + +; 163 : unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( +; 164 : (jarray) o, 0); + + mov eax, DWORD PTR [esi] + push 0 + push ebx + push esi + call DWORD PTR [eax+888] + mov DWORD PTR _charArrayArg$27802[ebp], eax + +; 165 : arrays[i] = (int) &charArrayArg; + + lea eax, DWORD PTR _charArrayArg$27802[ebp] + mov DWORD PTR [edi], eax + +; 166 : _push(charArrayArg) + + push DWORD PTR _charArrayArg$27802[ebp] + +; 167 : } +; 168 : else if (env->IsInstanceOf(o, classBoolean)) { + + jmp SHORT $L27764 +$L27801: + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + mov ecx, DWORD PTR [esi] + push eax + push ebx + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27764 + +; 169 : jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); + + push DWORD PTR ?methodBooleanValue@@3PAU_jmethodID@@A ; methodBooleanValue + push ebx + push esi + call ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ; JNIEnv_::CallBooleanMethod + +; 170 : int *tempPtr = new int; + + push 4 + mov bl, al + call ??2@YAPAXI@Z ; operator new + add esp, 16 ; 00000010H + +; 171 : *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); + + xor ecx, ecx + test bl, bl + setne cl + mov DWORD PTR _tempPtr$27809[ebp], eax + mov DWORD PTR [eax], ecx + +; 172 : arrays[i] = (int) tempPtr; + + mov DWORD PTR [edi], eax + +; 173 : _push(tempPtr); + + push DWORD PTR _tempPtr$27809[ebp] + +; 172 : arrays[i] = (int) tempPtr; + +$L27764: + dec DWORD PTR _i$[ebp] + sub edi, 4 + cmp DWORD PTR _i$[ebp], 0 + jge $L28028 + +; 115 : +; 116 : jobject param; +; 117 : +; 118 : for (int i = len - 1; i >= 0; i--) { + + mov ebx, DWORD PTR _len$[ebp] +$L27765: + +; 174 : } +; 175 : +; 176 : /* end Holder */ +; 177 : +; 178 : } +; 179 : +; 180 : } +; 181 : +; 182 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov eax, DWORD PTR ?fieldFunctionHandle@@3PAU_jfieldID@@A ; fieldFunctionHandle + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR _obj$[ebp] + push esi + call DWORD PTR [ecx+400] + mov DWORD PTR _functionHandle$[ebp], eax + +; 183 : +; 184 : #ifdef _WINDOWS +; 185 : #ifdef _X86_ +; 186 : +; 187 : __asm { +; 188 : +; 189 : call functionHandle + + call DWORD PTR _functionHandle$[ebp] + +; 190 : +; 191 : } +; 192 : +; 193 : #endif +; 194 : #endif +; 195 : +; 196 : for (int j = 0; j < len; ++j) { + + and DWORD PTR _j$[ebp], 0 + test ebx, ebx + jle $L27817 + +; 174 : } +; 175 : +; 176 : /* end Holder */ +; 177 : +; 178 : } +; 179 : +; 180 : } +; 181 : +; 182 : jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + + mov ebx, DWORD PTR _arrays$[ebp] +$L27815: + +; 197 : param = env->GetObjectArrayElement(params, j); + + push DWORD PTR _j$[ebp] + mov eax, DWORD PTR [esi] + push DWORD PTR _params$[ebp] + push esi + call DWORD PTR [eax+692] + mov edi, eax + +; 198 : if (param == NULL) {} + + test edi, edi + mov DWORD PTR _param$[ebp], edi + je $L27816 + +; 199 : else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { + + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne $L27833 + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne $L27833 + +; 201 : } +; 202 : else if (env->IsInstanceOf(param, classHolder)) { + + mov eax, DWORD PTR ?classHolder@@3PAV_jclass@@A ; classHolder + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + je $L27816 + +; 203 : +; 204 : jobject o = env->GetObjectField(param, fieldHolderO); + + mov eax, DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+380] + +; 205 : +; 206 : if (env->IsInstanceOf(o, classInteger)) { + + mov ecx, DWORD PTR [esi] + mov edi, eax + mov eax, DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27827 + +; 207 : int* out = (int*) arrays[j]; + + mov edi, DWORD PTR [ebx] + +; 208 : env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); + + push DWORD PTR [edi] + push DWORD PTR ?newIntegerInt@@3PAU_jmethodID@@A ; newIntegerInt + push DWORD PTR ?classInteger@@3PAV_jclass@@A ; classInteger +$L28031: + push esi + call ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ; JNIEnv_::NewObject + add esp, 16 ; 00000010H + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldHolderO@@3PAU_jfieldID@@A ; fieldHolderO + push DWORD PTR _param$[ebp] + push esi + call DWORD PTR [ecx+416] + +; 209 : delete out; + + push edi + call ??3@YAXPAX@Z ; operator delete + pop ecx + +; 210 : } +; 211 : else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { + + jmp SHORT $L27816 +$L27827: + mov eax, DWORD PTR ?classByteArray@@3PAV_jclass@@A ; classByteArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne SHORT $L27833 + mov eax, DWORD PTR ?classCharArray@@3PAV_jclass@@A ; classCharArray + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + jne SHORT $L27833 + +; 212 : env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); +; 213 : } +; 214 : else if (env->IsInstanceOf(o, classBoolean)) { + + mov eax, DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + mov ecx, DWORD PTR [esi] + push eax + push edi + push esi + call DWORD PTR [ecx+128] + test al, al + je SHORT $L27816 + +; 215 : int* out = (int*) arrays[j]; + + mov edi, DWORD PTR [ebx] + +; 216 : env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); + + xor eax, eax + cmp DWORD PTR [edi], eax + setne al + push eax + push DWORD PTR ?newBooleanBoolean@@3PAU_jmethodID@@A ; newBooleanBoolean + push DWORD PTR ?classBoolean@@3PAV_jclass@@A ; classBoolean + +; 217 : delete out; + + jmp SHORT $L28031 +$L27833: + +; 200 : env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); + + mov eax, DWORD PTR [esi] + push 0 + push DWORD PTR [ebx] + push edi + push esi + call DWORD PTR [eax+892] +$L27816: + inc DWORD PTR _j$[ebp] + mov eax, DWORD PTR _j$[ebp] + add ebx, 4 + cmp eax, DWORD PTR _len$[ebp] + jl $L27815 +$L27817: + +; 218 : } +; 219 : +; 220 : } +; 221 : +; 222 : } +; 223 : +; 224 : delete [] arrays; + + push DWORD PTR _arrays$[ebp] + call ??3@YAXPAX@Z ; operator delete + pop ecx + +; 225 : +; 226 : env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + + call DWORD PTR __imp__GetLastError@0 + mov ecx, DWORD PTR [esi] + push eax + push DWORD PTR ?fieldLastErrorCode@@3PAU_jfieldID@@A ; fieldLastErrorCode + push DWORD PTR _obj$[ebp] + push esi + call DWORD PTR [ecx+436] +$L28021: + +; 227 : +; 228 : } + + pop edi + pop esi + pop ebx + leave + ret 12 ; 0000000cH +_Java_com_eaio_nativecall_VoidCall_executeCall0@12 ENDP +_TEXT ENDS +; COMDAT ?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_clazz$ = 12 +_methodID$ = 16 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::NewObject, COMDAT + +; 835 : va_list args; +; 836 : jobject result; +; 837 : va_start(args, methodID); +; 838 : result = functions->NewObjectV(this,clazz,methodID,args); + + mov eax, DWORD PTR _this$[esp-4] + lea edx, DWORD PTR _methodID$[esp] + push edx + push DWORD PTR _methodID$[esp] + mov ecx, DWORD PTR [eax] + push DWORD PTR _clazz$[esp+4] + push eax + call DWORD PTR [ecx+116] + +; 839 : va_end(args); +; 840 : return result; +; 841 : } + + ret 0 +?NewObject@JNIEnv_@@QAAPAV_jobject@@PAV_jclass@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::NewObject +_TEXT ENDS +; COMDAT ?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_obj$ = 12 +_methodID$ = 16 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallBooleanMethod, COMDAT + +; 882 : va_list args; +; 883 : jboolean result; +; 884 : va_start(args,methodID); +; 885 : result = functions->CallBooleanMethodV(this,obj,methodID,args); + + mov eax, DWORD PTR _this$[esp-4] + lea edx, DWORD PTR _methodID$[esp] + push edx + push DWORD PTR _methodID$[esp] + mov ecx, DWORD PTR [eax] + push DWORD PTR _obj$[esp+4] + push eax + call DWORD PTR [ecx+152] + +; 886 : va_end(args); +; 887 : return result; +; 888 : } + + ret 0 +?CallBooleanMethod@JNIEnv_@@QAAEPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallBooleanMethod +_TEXT ENDS +; COMDAT ?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ +_TEXT SEGMENT +_this$ = 8 +_obj$ = 12 +_methodID$ = 16 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ PROC NEAR ; JNIEnv_::CallIntMethod, COMDAT + +; 950 : va_list args; +; 951 : jint result; +; 952 : va_start(args,methodID); +; 953 : result = functions->CallIntMethodV(this,obj,methodID,args); + + mov eax, DWORD PTR _this$[esp-4] + lea edx, DWORD PTR _methodID$[esp] + push edx + push DWORD PTR _methodID$[esp] + mov ecx, DWORD PTR [eax] + push DWORD PTR _obj$[esp+4] + push eax + call DWORD PTR [ecx+200] + +; 954 : va_end(args); +; 955 : return result; +; 956 : } + + ret 0 +?CallIntMethod@JNIEnv_@@QAAJPAV_jobject@@PAU_jmethodID@@ZZ ENDP ; JNIEnv_::CallIntMethod +_TEXT ENDS +END diff --git a/vendor/nativecall/0.4.1/cpp/Release/VoidCall.obj b/vendor/nativecall/0.4.1/cpp/Release/VoidCall.obj new file mode 100644 index 0000000..3edebca Binary files /dev/null and b/vendor/nativecall/0.4.1/cpp/Release/VoidCall.obj differ diff --git a/vendor/nativecall/0.4.1/cpp/VoidCall.cpp b/vendor/nativecall/0.4.1/cpp/VoidCall.cpp new file mode 100644 index 0000000..a99d658 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/VoidCall.cpp @@ -0,0 +1,228 @@ +/* + * VoidCall.cpp + * + * Created on 16.09.2004. + * + * $Id: VoidCall.cpp,v 1.4 2006/04/20 05:50:15 grnull Exp $ + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +#include +#include "com_eaio_nativecall_VoidCall.h" + +#ifdef _WINDOWS +#include +#include +#endif + +#ifdef _WINDOWS +#ifdef _X86_ + +#define _push(x) __asm { push x }; + +#endif +#endif + +// NativeCall fields + +extern jfieldID fieldFunction, fieldModule, fieldFunctionHandle, + fieldModuleHandle, fieldLastErrorCode; + +// Holder fields + +extern jfieldID fieldHolderO; + +// Classes + +extern jclass classBoolean,/* classByte, classCharacter, classShort,*/ + classInteger, /* classLong, classFloat, classDouble,*/ classString, + classByteArray, classCharArray, /*classIntArray,*/ classHolder; + +// Wrapper class methods + +extern jmethodID methodBooleanValue,/* methodByteValue, methodCharValue, +methodShortValue,*/ methodIntValue/*, methodLongValue, methodFloatValue, +methodDoubleValue*/; + +// Constructors + +extern jmethodID newIntegerInt, newBooleanBoolean; + +/* + * Class: com_eaio_nativecall_VoidCall + * Method: executeCall + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall +(JNIEnv *env, jobject obj) { + + jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + +#ifdef _WINDOWS +#ifdef _X86_ + + __asm { + + call functionHandle + + } + +#endif +#endif + + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + +} + +/* + * Class: com_eaio_nativecall_VoidCall + * Method: executeCall0 + * Signature: ([Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall0 +(JNIEnv *env, jobject obj, jobjectArray params) { + + const int len = env->GetArrayLength(params); + + int* arrays = NULL; + if (!(arrays = new int[len])) { + env->ThrowNew(env->FindClass("java/lang/OutOfMemoryError"), NULL); + return; + } + memset(arrays, 0, (sizeof(int) * len)); + + jobject param; + + for (int i = len - 1; i >= 0; i--) { + + param = env->GetObjectArrayElement(params, i); + + if (param == NULL) { + _push(0); + } + else if (env->IsInstanceOf(param, classInteger)) { + int intArg = env->CallIntMethod(param, methodIntValue); + _push(intArg) + } + else if (env->IsInstanceOf(param, classByteArray)) { + char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) param, 0); + arrays[i] = (int) &byteArrayArg; + _push(byteArrayArg) + } + else if (env->IsInstanceOf(param, classCharArray)) { + unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( + (jarray) param, 0); + arrays[i] = (int) &charArrayArg; + _push(charArrayArg) + } + else if (env->IsInstanceOf(param, classBoolean)) { + jboolean booleanArg = env->CallBooleanMethod(param, methodBooleanValue); + int tempArg = (booleanArg == JNI_FALSE ? 0 : 1); + _push(tempArg) + } + else if (env->IsInstanceOf(param, classHolder)) { + + /* Holder */ + + jobject o = env->GetObjectField(param, fieldHolderO); + + if (env->IsInstanceOf(o, classInteger)) { + int *intPtr = new int; + *intPtr = env->CallIntMethod(o, methodIntValue); + arrays[i] = (int) intPtr; + _push(intPtr); + } + else if (env->IsInstanceOf(o, classByteArray)) { + char* byteArrayArg = (char*) env->GetPrimitiveArrayCritical((jarray) o, 0); + arrays[i] = (int) &byteArrayArg; + _push(byteArrayArg) + } + else if (env->IsInstanceOf(o, classCharArray)) { + unsigned short* charArrayArg = (unsigned short*) env->GetPrimitiveArrayCritical( + (jarray) o, 0); + arrays[i] = (int) &charArrayArg; + _push(charArrayArg) + } + else if (env->IsInstanceOf(o, classBoolean)) { + jboolean booleanArg = env->CallBooleanMethod(o, methodBooleanValue); + int *tempPtr = new int; + *tempPtr = (booleanArg == JNI_FALSE ? 0 : 1); + arrays[i] = (int) tempPtr; + _push(tempPtr); + } + + /* end Holder */ + + } + + } + + jint functionHandle = env->GetIntField(obj, fieldFunctionHandle); + +#ifdef _WINDOWS +#ifdef _X86_ + + __asm { + + call functionHandle + + } + +#endif +#endif + + for (int j = 0; j < len; ++j) { + param = env->GetObjectArrayElement(params, j); + if (param == NULL) {} + else if (env->IsInstanceOf(param, classByteArray) || env->IsInstanceOf(param, classCharArray)) { + env->ReleasePrimitiveArrayCritical((jarray) param, (void*) arrays[j], 0); + } + else if (env->IsInstanceOf(param, classHolder)) { + + jobject o = env->GetObjectField(param, fieldHolderO); + + if (env->IsInstanceOf(o, classInteger)) { + int* out = (int*) arrays[j]; + env->SetObjectField(param, fieldHolderO, env->NewObject(classInteger, newIntegerInt, *out)); + delete out; + } + else if (env->IsInstanceOf(o, classByteArray) || env->IsInstanceOf(o, classCharArray)) { + env->ReleasePrimitiveArrayCritical((jarray) o, (void*) arrays[j], 0); + } + else if (env->IsInstanceOf(o, classBoolean)) { + int* out = (int*) arrays[j]; + env->SetObjectField(param, fieldHolderO, env->NewObject(classBoolean, newBooleanBoolean, (*out == 0 ? JNI_FALSE : JNI_TRUE))); + delete out; + } + + } + + } + + delete [] arrays; + + env->SetIntField(obj, fieldLastErrorCode, GetLastError()); + +} \ No newline at end of file diff --git a/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_IntCall.h b/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_IntCall.h new file mode 100644 index 0000000..4bdd687 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_IntCall.h @@ -0,0 +1,29 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_eaio_nativecall_IntCall */ + +#ifndef _Included_com_eaio_nativecall_IntCall +#define _Included_com_eaio_nativecall_IntCall +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_eaio_nativecall_IntCall + * Method: executeCall + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall + (JNIEnv *, jobject); + +/* + * Class: com_eaio_nativecall_IntCall + * Method: executeCall0 + * Signature: ([Ljava/lang/Object;)I + */ +JNIEXPORT jint JNICALL Java_com_eaio_nativecall_IntCall_executeCall0 + (JNIEnv *, jobject, jobjectArray); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_NativeCall.h b/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_NativeCall.h new file mode 100644 index 0000000..3092265 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_NativeCall.h @@ -0,0 +1,45 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_eaio_nativecall_NativeCall */ + +#ifndef _Included_com_eaio_nativecall_NativeCall +#define _Included_com_eaio_nativecall_NativeCall +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_eaio_nativecall_NativeCall + * Method: initIDs + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_initIDs + (JNIEnv *, jclass); + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: initHandles + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL Java_com_eaio_nativecall_NativeCall_initHandles + (JNIEnv *, jobject); + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: getLastError + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_eaio_nativecall_NativeCall_getLastError + (JNIEnv *, jobject); + +/* + * Class: com_eaio_nativecall_NativeCall + * Method: destroy + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_NativeCall_destroy + (JNIEnv *, jobject); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_VoidCall.h b/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_VoidCall.h new file mode 100644 index 0000000..473da22 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/com_eaio_nativecall_VoidCall.h @@ -0,0 +1,29 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_eaio_nativecall_VoidCall */ + +#ifndef _Included_com_eaio_nativecall_VoidCall +#define _Included_com_eaio_nativecall_VoidCall +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_eaio_nativecall_VoidCall + * Method: executeCall + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall + (JNIEnv *, jobject); + +/* + * Class: com_eaio_nativecall_VoidCall + * Method: executeCall0 + * Signature: ([Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_com_eaio_nativecall_VoidCall_executeCall0 + (JNIEnv *, jobject, jobjectArray); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/vendor/nativecall/0.4.1/cpp/readme.txt b/vendor/nativecall/0.4.1/cpp/readme.txt new file mode 100644 index 0000000..b493c79 --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/readme.txt @@ -0,0 +1,25 @@ +# $Id: readme.txt,v 1.1 2006/01/05 19:55:58 grnull Exp $ + +Hi, + +this is the readme file for people who want to build the native libraries for +NativeCall themselves. + +Compiling the native libraries requires some header files (after all, it's +just C++). + +Search for + + jni.h + +which is required. You will most likey also need jni_md.h and +jniproto_md.h. Copy these files to this directory. + +The library has been compiled and is set up for libctiny.lib to make the +binaries even smaller. You can download libctiny.lib from + + + +After you downloaded it, extract libctiny.lib to this folder. You also might +have to change the paths for the compiler and the linker. + diff --git a/vendor/nativecall/0.4.1/cpp/resource.h b/vendor/nativecall/0.4.1/cpp/resource.h new file mode 100644 index 0000000..bbf1b2f --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by version.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/vendor/nativecall/0.4.1/cpp/version.rc b/vendor/nativecall/0.4.1/cpp/version.rc new file mode 100644 index 0000000..a85bfed --- /dev/null +++ b/vendor/nativecall/0.4.1/cpp/version.rc @@ -0,0 +1,104 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Deutsch (Deutschland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +#ifndef _MAC +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,4,1,0 + PRODUCTVERSION 0,4,1,0 + FILEFLAGSMASK 0x3fL +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x40004L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040704b0" + BEGIN + VALUE "CompanyName", "eaio\0" + VALUE "FileDescription", "NativeCall native library\0" + VALUE "FileVersion", "0, 4, 1, 0\0" + VALUE "LegalCopyright", "2003-2006 Johann Burkard\0" + VALUE "OriginalFilename", "NativeCall.dll\0" + VALUE "ProductName", "NativeCall\0" + VALUE "ProductVersion", "0, 4, 1, 0\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x407, 1200 + END +END + +#endif // !_MAC + +#endif // Deutsch (Deutschland) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/vendor/nativecall/0.4.1/java/META-INF/services/com.eaio.nativecall.Verifier b/vendor/nativecall/0.4.1/java/META-INF/services/com.eaio.nativecall.Verifier new file mode 100644 index 0000000..e5bdea6 --- /dev/null +++ b/vendor/nativecall/0.4.1/java/META-INF/services/com.eaio.nativecall.Verifier @@ -0,0 +1 @@ +com.eaio.nativecall.Win32Verifier \ No newline at end of file diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Holder.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Holder.java new file mode 100644 index 0000000..6ed5358 --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Holder.java @@ -0,0 +1,133 @@ +/* + * Holder.java + * + * Created on 14.09.2004. + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +/** + * Holder is a class that encapsulates another Object. Use this class for output + * parameters. + * + * @author Johann Burkard + * @version $Id: Holder.java,v 1.3 2006/04/19 20:54:58 grnull Exp $ + */ +public class Holder { + + /** + * The encapsulated object. + *

    + * Accessed by native code. DO NOT RENAME THIS FIELD. + */ + private Object o; + + /** + * Constructor for Holder. + * + * @param o the Object to encapsulate, may be null, but cannot + * be of type Holder + * @throws ClassCastException if o is of type Holder + */ + public Holder(Object o) { + if (o instanceof Holder) { + throw new ClassCastException(); + } + else if (o == null) { + o = new Integer(0); + } + this.o = o; + } + + /** + * Returns the referenced Object. + * + * @return an Object + */ + public final Object get() { + return o; + } + + /** + * Returns the hashCode of the encapsulated Object or + * {@link java.lang.Object#hashCode()} if the Object is null. + * + * @return the hashCode + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + return getClass().getName().hashCode() ^ (o == null ? 0 : o.hashCode()); + } + + /** + * Returns if this Object is equal to another Object. + * + * @param obj the other Object, may be null + * @return if both Objects are equal + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Holder)) { + return false; + } + Holder h = (Holder) obj; + return o == null ? h.o == null : o.equals(h.o); + } + + /** + * Returns a String representation of this Object. + * + * @return a String, never null + * @see java.lang.Object#toString() + * @see #toStringBuffer(StringBuffer) + */ + public final String toString() { + return toStringBuffer(null).toString(); + } + + /** + * Appends a String representation of this Object to the given + * {@link StringBuffer} or creates a new one if none is given. + * + * @param in the StringBuffer to append to, may be null + * @return a StringBuffer, never null + */ + public StringBuffer toStringBuffer(StringBuffer in) { + if (in == null) { + in = new StringBuffer(32); + } + else { + in.ensureCapacity(in.length() + 32); + } + in.append("{ Holder: o = "); + in.append(o); + in.append(" }"); + return in; + } + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/IntCall.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/IntCall.java new file mode 100644 index 0000000..3dc60ff --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/IntCall.java @@ -0,0 +1,143 @@ +/* + * IntCall.java + * + * Created on 07.09.2004. + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +/** + * An IntCall instance encapsulates an operating system method that returns + * an integer. + * + * @author Johann Burkard + * @version $Id: IntCall.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ + */ +public class IntCall extends NativeCall { + + /** + * Constructor for IntCall. + * + * @see NativeCall#NativeCall(String) + */ + public IntCall(String function) throws SecurityException, + IllegalArgumentException, NullPointerException { + super(function); + } + + /** + * Constructor for IntCall. + * + * @see NativeCall#NativeCall(String, String) + */ + public IntCall(String module, String function) throws SecurityException, + IllegalArgumentException, NullPointerException { + super(module, function); + } + + /** + * Returns false if calling {@link #executeCall()} returned + * 0, true otherwise. + *

    + * Updates the error code field. See {@link #getLastError()}. + * + * @return true or false + */ + public boolean executeBooleanCall() { + return executeCall() == 0 ? false : true; + } + + /** + * Returns false if calling {@link #executeCall(Object)} + * returned 0, true otherwise. + *

    + * Updates the error code field. See {@link #getLastError()}. + * + * @param param the parameter, may be null + * @return true or false + * @see #executeBooleanCall(Object[]) + */ + public boolean executeBooleanCall(Object param) { + return executeCall(param) == 0 ? false : true; + } + + /** + * Returns false if calling + * {@link #executeCall(Object[])} returned 0, true otherwise. + *

    + * Updates the error code field. See {@link #getLastError()}. + *

    + * During this operation, the contents of the array might be changed. + * + * @param params the parameter array, may be null + * @return true or false + */ + public boolean executeBooleanCall(Object[] params) { + return executeCall(params) == 0 ? false : true; + } + + /** + * Calls the function, returning its output. + *

    + * Updates the error code field. See {@link #getLastError()}. + * + * @return an int + */ + public native int executeCall(); + + /** + * Calls the function using the given parameter. + *

    + * Updates the error code field. See {@link #getLastError()}. + * + * @param param the parameter, may be null + * @return an int + * @see #executeCall(Object[]) + */ + public int executeCall(Object param) { + return executeCall(new Object[] { param }); + } + + /** + * Calls the function using the given parameters. + *

    + * Updates the error code field. See {@link #getLastError()}. + *

    + * During this operation, the contents of the array might be changed. + * + * @param params the parameter array, may be null + * @return an int + */ + public int executeCall(Object[] params) { + if (params == null || params.length == 0) { + return executeCall(); + } + check(params); + return executeCall0(params); + } + + private native int executeCall0(Object[] params); + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/NativeCall.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/NativeCall.java new file mode 100644 index 0000000..482ca84 --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/NativeCall.java @@ -0,0 +1,355 @@ +/* + * NativeCall.java + * + * Created on 07.09.2004. + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +import java.io.IOException; + +import sun.misc.ServiceConfigurationError; + +import com.eaio.util.lang.NativeLoader; + +/** + * NativeCall loads the native library and prepares the matching + * {@link com.eaio.nativecall.Verifier}. + *

    + * Before being able to use NativeCall, the {@link #init()} method must have + * been called: + *

    + * try {
    + *     NativeCall.init();
    + * }
    + * catch (IOException ex) { ... }
    + * catch (SecurityException ex) { ... }
    + * catch (UnsatisfiedLinkError er) { ... }
    + * catch (sun.misc.ServiceConfigurationError) { ... }
    + * catch (UnsupportedOperationException) { ... }
    + * 
    + * After usage, each NativeCall object must be destroyed to release + * resources. This is done by calling the {@link #destroy()} method. Failure + * to call this method might result in memory leaks. + * + * @see #destroy() + * @see #init() + * @author Johann Burkard + * @version $Id: NativeCall.java,v 1.3 2006/04/19 20:54:58 grnull Exp $ + */ +public abstract class NativeCall { + + /** + * The error code of the last call. + *

    + * Accessed by native code. DO NOT RENAME THIS FIELD. + */ + private int lastErrorCode; + + /** + * The internal handle to the function and the module. + *

    + * These are set in native code, so ignore any warnings. + *

    + * Accessed by native code. DO NOT RENAME THIS FIELD. + */ + private int functionHandle, moduleHandle; + + /** + * The name of the function to call. + *

    + * Accessed by native code. DO NOT RENAME THIS FIELD. + */ + private String function; + + /** + * The name of the module to call. + *

    + * Accessed by native code. DO NOT RENAME THIS FIELD. + */ + private String module; + + /** + * Initialize JNI field and method IDs + */ + private static native void initIDs(); + + /** + * Whether the class has been initialized properly. + */ + private static boolean initialized = false; + + /** + * Before NativeCall may be used, this method must be called. + * It loads the native library, prepares JNI field and method IDs and loads + * the matching {@link Verifier}. + *

    + * Multiple calls are ignored. + * + * @throws IOException if an IOException occured during unpacking of + * the native library + * @throws SecurityException if accessing system properties was forbidden + * by the {@link SecurityManager} + * @throws UnsatisfiedLinkError if the NativeCall.dll could + * not be found + * @throws sun.misc.ServiceConfigurationError + * @throws UnsupportedOperationException if no matching + * {@link Verifier} could be found + */ + public static synchronized void init() + throws + IOException, + SecurityException, + UnsatisfiedLinkError, + ServiceConfigurationError, + UnsupportedOperationException { + if (!initialized) { + Verifiers.init(); + if (Verifiers.getInstance() == null) { + throw new UnsupportedOperationException(); + } + new NativeLoader("NativeCall").load(); + initIDs(); + initialized = true; + } + } + + /** + * Constructor for NativeCall. + * + * @param function the name of the function to use, may not be + * null + * @throws IllegalArgumentException if the function could not be found + * @throws NullPointerException if function is null + * @see Verifier#getDefaultModule() + * @see NativeCall#NativeCall(String, String) + */ + public NativeCall(String function) + throws IllegalArgumentException, NullPointerException { + this(Verifiers.getInstance().getDefaultModule(), function); + } + + /** + * Constructor for NativeCall. + * + * @param module the name of the module the function is stored in, may be + * null + * @param function the name of the function to use, may not be + * null + * @throws IllegalArgumentException if the function could not be found + * @throws NullPointerException if function is null + */ + public NativeCall(String module, String function) + throws IllegalArgumentException, NullPointerException { + Verifier v = Verifiers.getInstance(); + this.function = v.verifyFunctionName(function); + this.module = v.verifyModuleName(module); + if (!initHandles()) { + if (lastErrorCode != 0) { + throw new IllegalArgumentException(getLastError()); + } + throw new IllegalArgumentException(); + } + } + + /** + * Attempts to acquire handles to the functions. Returns if these could be + * acquired. + * + * @return if the handles could be acquired + */ + private native boolean initHandles(); + + /** + * Returns the error code that was returned during the last method call or + * 0 if the last method call did not produce an error. + * + * @see #getLastError() + * @return the last error code or 0 + */ + public final int getLastErrorCode() { + return lastErrorCode; + } + + /** + * Returns a formatted String containing the last error code or + * null if the last call did not produce an error. + * + * @see #getLastErrorCode() + * @return a String or null if the last error code is 0 + */ + public final native String getLastError(); + + /** + * Releases acquired module handles. This method must be called if the + * instance is not used anymore. After this method is called, methods of this + * NativeCall Object cannot be called anymore. + *

    + * Failure to call this method might result in memory leaks. + *

    + * Updates the error code field. See {@link #getLastError()}. + */ + public native synchronized void destroy(); + + /** + * Checks the supplied Object array for illegal/unsupported types. + *

    + * During the verification, the contents of the array might be + * changed. + * + * @param params the Object array, may be null + * @throws ClassCastException if the type of one argument is not supported + */ + protected void check(Object[] params) throws ClassCastException { + if (params == null) { + return; + } + for (int i = 0; i < params.length; ++i) { + checkParam(params[i]); + if (params[i] instanceof String) { + params[i] = + Verifiers.getInstance().handleString( + (String) params[i], + module, + function); + } + } + } + + /** + * Checks one Object for illegal/unsupported types. + * + * @param o the Object, may be null + * @throws ClassCastException if the type of one argument is not supported + */ + protected void checkParam(Object o) throws ClassCastException { + if (o == null + || o instanceof Boolean + || o instanceof Integer + || o instanceof byte[] + || o instanceof char[] + || o instanceof String) { + return; + } + if (o instanceof Holder) { + checkParam(((Holder) o).get()); + return; + } + throw new ClassCastException(o.getClass().getName()); + } + + /** + * Returns if this Object is equal to another Object. The other Object must + * be an instance of the same type as this Object. Also, both the module + * and the function field must be equal. + * + * @param obj the other Object + * @return if this and the other Object are equal + * @see java.lang.Object#equals(java.lang.Object) + */ + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof NativeCall)) { + return false; + } + if (!getClass().getName().equals(obj.getClass().getName())) { + return false; + } + NativeCall c = (NativeCall) obj; + return module.equals(c.module) && function.equals(c.function); + } + + /** + * Returns the hashCode of this Object. The hashCode is computed by XOR'ing + * the hash codes of the function and the module names. + * + * @return the hashCode + * @see java.lang.Object#hashCode() + */ + public int hashCode() { + int out = function.hashCode(); + out ^= module.hashCode(); + return out; + } + + /** + * Calls {@link #destroy()}. + * + * @see java.lang.Object#finalize() + */ + protected void finalize() throws Throwable { + try { + destroy(); + } + finally { + super.finalize(); + // in case NativeCall is a subclass of a class other than Object + } + } + + /** + * Returns a String representation of this Object. + * + * @return a String, never null + * @see java.lang.Object#toString() + * @see #toStringBuffer(StringBuffer) + */ + public final String toString() { + return toStringBuffer(null).toString(); + } + + /** + * Appends a String representation of this Object to the given + * {@link StringBuffer} or creates a new one if none is given. + * + * @param in the StringBuffer to append to, may be null + * @return a StringBuffer, never null + */ + public StringBuffer toStringBuffer(StringBuffer in) { + if (in == null) { + in = new StringBuffer(64); + } + else { + in.ensureCapacity(in.length() + 64); + } + in.append("{ "); + int idx = getClass().getName().lastIndexOf("."); + if (idx > -1) { + in.append(getClass().getName().substring(++idx)); + } + else { + in.append(getClass().getName()); + } + in.append(": module = "); + in.append(module); + in.append(", function = "); + in.append(function); + in.append(" }"); + return in; + } + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Verifier.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Verifier.java new file mode 100644 index 0000000..085ae8b --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Verifier.java @@ -0,0 +1,101 @@ +/* + * Verifier.java + * + * Created on 07.09.2004. + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +/** + * A Verifier implements method and module name checking for one given + * operating system. Classes implementing Verifier must be public and have + * a public no-argument constructor. + * + * @author Johann Burkard + * @version $Id: Verifier.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ + */ +public interface Verifier { + + /** + * If there is a default module that system functions are stored in, the + * module's name may be returned here. + * + * @return the name of a default module or null + * @see NativeCall#NativeCall(String) + */ + String getDefaultModule(); + + /** + * Returns if this Verifier supports the given operating system. + * + * @return if this operating system is supported + * @throws SecurityException because {@link java.lang.System} properties + * may be queried + */ + boolean supports() throws SecurityException; + + /** + * Verifies that the given module name is correct. + * + * @param module the module name, may be null + * @return a module name, possibly modified, never null + * @throws NullPointerException if the module name is null + * and there is no default module defined + * @throws IllegalArgumentException if the module is illegal in the + * operating system + * @see #getDefaultModule() + */ + String verifyModuleName(String module) + throws NullPointerException, IllegalArgumentException; + + /** + * Verifies that the given function name is correct. + * + * @param function the function name, may be null + * @return a function name, possibly modified, never null + * @throws NullPointerException if the function name is null + * @throws IllegalArgumentException if the function is illegal in the + * operating system + */ + String verifyFunctionName(String function) + throws NullPointerException, IllegalArgumentException; + + /** + * Converts the given String to one of the following data types, based on the + * module and the function name: + *
    + *

      + *
    • a byte array
    • + *
    • a char array
    • + *
    + * + * @param val the String, never null + * @param module the module name, never null + * @param function the function name, never null + * @return the String converted, never null + */ + Object handleString(String val, String module, String function); + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Verifiers.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Verifiers.java new file mode 100644 index 0000000..6c86654 --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Verifiers.java @@ -0,0 +1,83 @@ +/* + * Verifiers.java + * + * Created on 07.09.2004. + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +import java.util.Iterator; + +import sun.misc.Service; +import sun.misc.ServiceConfigurationError; + +/** + * Verifiers instantiates the matching {@link com.eaio.nativecall.Verifier} for + * the current operating system. + * + * @author Johann Burkard + * @version $Id: Verifiers.java,v 1.2 2006/01/06 10:58:33 grnull Exp $ + */ +final class Verifiers { + + /** + * No instances needed. + */ + private Verifiers() {} + + /** + * The Verifier. + */ + private static Verifier v = null; + + /** + * Find the matching Verifier. + * + * @throws ServiceConfigurationError + * @throws SecurityException + */ + static void init() throws ServiceConfigurationError, SecurityException { + Iterator i = + Service.providers(Verifier.class, Verifier.class.getClassLoader()); + Verifier ver = null; + while (i.hasNext()) { + ver = (Verifier) i.next(); + if (ver.supports()) { + v = ver; + break; + } + } + } + + /** + * Returns the Verifier. + * + * @return a Verifier or null + */ + static Verifier getInstance() { + return v; + } + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/VoidCall.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/VoidCall.java new file mode 100644 index 0000000..c3ce15e --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/VoidCall.java @@ -0,0 +1,99 @@ +/* + * VoidCall.java + * + * Created on 16.09.2004 + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +/** + * A VoidCall instance encapsulates an operating system method that returns + * nothing. + * + * @author Johann Burkard + * @version $Id: VoidCall.java,v 1.1 2006/01/05 20:02:44 grnull Exp $ + */ +public class VoidCall extends NativeCall { + + /** + * Constructor for VoidCall. + * + * @see NativeCall#NativeCall(String) + */ + public VoidCall(String function) throws SecurityException, + IllegalArgumentException, NullPointerException { + super(function); + } + + /** + * Constructor for VoidCall. + * + * @see NativeCall#NativeCall(String, String) + */ + public VoidCall(String module, String function) throws SecurityException, + IllegalArgumentException, NullPointerException { + super(module, function); + } + + /** + * Calls the function. + *

    + * Updates the error code field. See {@link #getLastError()}. + */ + public native void executeCall(); + + /** + * Calls the function using the given parameter. + *

    + * Updates the error code field. See {@link #getLastError()}. + * + * @param param the parameter, may be null + * @see #executeCall(Object[]) + */ + public void executeCall(Object param) { + executeCall(new Object[] { param }); + } + + /** + * Calls the function using the given parameters. + *

    + * Updates the error code field. See {@link #getLastError()}. + *

    + * During this operation, the contents of the array might be changed. + * + * @param params the parameter array, may be null + */ + public void executeCall(Object[] params) { + if (params == null || params.length == 0) { + executeCall(); + return; + } + check(params); + executeCall0(params); + } + + private native void executeCall0(Object[] params); + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Win32Verifier.java b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Win32Verifier.java new file mode 100644 index 0000000..85bd60a --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/Win32Verifier.java @@ -0,0 +1,122 @@ +/* + * Win32Verifier.java + * + * Created on 08.09.2004. + * + * eaio: NativeCall - calling operating system methods from Java + * Copyright (c) 2004-2006 Johann Burkard () + * + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ +package com.eaio.nativecall; + +/** + * A {@link com.eaio.nativecall.Verifier} for the Windows environment. + * + * @author Johann Burkard + * @version $Id: Win32Verifier.java,v 1.3 2006/04/19 20:54:58 grnull Exp $ + */ +public class Win32Verifier implements Verifier { + + /** + * Constructor for Win32Verifier. Does nothing. + */ + public Win32Verifier() {} + + /** + * Verifies that the {@link java.lang.System} property "os.name" starts + * with "Windows". + * + * @see Verifier#supports() + */ + public boolean supports() throws SecurityException { + return System.getProperty("os.name").startsWith("Windows"); + } + + /** + * Returns the default module name if the module name is null + * or an empty String. If the module name contains forward slashes (/), they + * are converted to backward slashes (\). + * + * @see + * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/loadlibrary.asp + * + * @see com.eaio.nativecall.Verifier#verifyModuleName(java.lang.String) + */ + public String verifyModuleName(String module) { + if (module == null || module.length() == 0) { + return getDefaultModule(); + } + if (module.indexOf('/') != -1) { + module = module.replace('/', '\\'); + } + return module; + } + + /** + * Throws a {@link java.lang.NullPointerException} if the function + * name is null or an empty String. No further processing is + * done. + * + * @see com.eaio.nativecall.Verifier#verifyFunctionName(java.lang.String) + */ + public String verifyFunctionName(String function) { + if (function == null || function.length() == 0) { + throw new NullPointerException(); + } + return function; + } + + /** + * Returns "kernel32". + * + * @return "kernel32" + * @see com.eaio.nativecall.Verifier#getDefaultModule() + */ + public String getDefaultModule() { + return "kernel32"; + } + + /** + * If the function name ends on 'W' (Windows' Unicode functions), a + * char array is returned, otherwise a byte array + * is returned. + *

    + * The arrays are always null-terminated. + * + * @see com.eaio.nativecall.Verifier#handleString(java.lang.String, + * java.lang.String, + * java.lang.String) + */ + public Object handleString(String val, String module, String function) { + if (function.charAt(function.length() - 1) == 'W') { + char[] buf = new char[val.length() + 1]; + val.getChars(0, val.length(), buf, 0); + return buf; + } + byte[] buf = new byte[val.length() + 1]; + val.getBytes(0, val.length(), buf, 0); + return buf; + } + +} diff --git a/vendor/nativecall/0.4.1/java/com/eaio/nativecall/package.html b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/package.html new file mode 100644 index 0000000..22b3abc --- /dev/null +++ b/vendor/nativecall/0.4.1/java/com/eaio/nativecall/package.html @@ -0,0 +1,15 @@ + + + +Untitled Document + + +

    Contains the main NativeCall classes.

    +

    For instant API information, see:

    +
      +
    • {@link com.eaio.nativecall.NativeCall}
    • +
    • {@link com.eaio.nativecall.IntCall}
    • +
    • {@link com.eaio.nativecall.VoidCall}
    • +
    + + diff --git a/vendor/nativecall/0.4.1/nativecall-0.4.1.jar b/vendor/nativecall/0.4.1/nativecall-0.4.1.jar new file mode 100644 index 0000000..7b89804 Binary files /dev/null and b/vendor/nativecall/0.4.1/nativecall-0.4.1.jar differ diff --git a/vendor/nativecall/0.4.1/nativeloader-200505172341.jar b/vendor/nativecall/0.4.1/nativeloader-200505172341.jar new file mode 100644 index 0000000..b4aad60 Binary files /dev/null and b/vendor/nativecall/0.4.1/nativeloader-200505172341.jar differ diff --git a/vendor/wiigee/1.5.6/org/wiigee/control/Wiigee.java b/vendor/wiigee/1.5.6/org/wiigee/control/Wiigee.java new file mode 100644 index 0000000..41af532 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/control/Wiigee.java @@ -0,0 +1,46 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.control; + +import org.wiigee.util.Log; + +/** + * The mother of all classes. :-) It's just used as parent class + * to print version information and later on maybe dynamic configuring + * of the whole wiimote system... detecting plugins and devices automatically + * maybe. :) + * + * @author Benjamin 'BePo' Poppinga + */ +public class Wiigee { + + protected static String version = "1.5.6"; + protected static String releasedate = "20090817"; + + protected Wiigee() { + Log.write("This is wiigee version "+version+" ("+releasedate+")"); + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/control/WiimoteDeviceDiscovery.java b/vendor/wiigee/1.5.6/org/wiigee/control/WiimoteDeviceDiscovery.java new file mode 100644 index 0000000..bdc611f --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/control/WiimoteDeviceDiscovery.java @@ -0,0 +1,103 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.wiigee.control; + +import java.io.IOException; +import java.util.Vector; + +import javax.bluetooth.DeviceClass; +import javax.bluetooth.DiscoveryListener; +import javax.bluetooth.RemoteDevice; +import javax.bluetooth.ServiceRecord; + +import org.wiigee.util.Log; + +import org.wiigee.device.Wiimote; + +public class WiimoteDeviceDiscovery implements DiscoveryListener { + + private Vector devices; + private boolean isInquiring; + private final Object lock; + + public WiimoteDeviceDiscovery(Object lock) { + super(); + this.lock = lock; + this.devices = new Vector(); + } + + public void deviceDiscovered(RemoteDevice newdevice, DeviceClass devclass) { + Log.write("Device discovered: " + newdevice.getBluetoothAddress() + " - "); + // add the device to the vector + if (!devices.contains(newdevice) && + devclass.getMajorDeviceClass() == 1280 && + devclass.getMinorDeviceClass() == 4) { + Log.write("Is a Wiimote!"); + devices.addElement(newdevice); + } else { + Log.write("Is NOT a Wiimote OR you're using an incompatible Bluetooth Stack."); + } + } + + public void inquiryCompleted(int discType) { + switch (discType) { + case WiimoteDeviceDiscovery.INQUIRY_COMPLETED: + Log.write("Inquiry completed."); + break; + + case WiimoteDeviceDiscovery.INQUIRY_ERROR: + Log.write("Inquiry error."); + break; + + case WiimoteDeviceDiscovery.INQUIRY_TERMINATED: + Log.write("Inquiry terminated."); + break; + } + synchronized (this.lock) { + this.lock.notify(); + } + } + + public void serviceSearchCompleted(int arg0, int arg1) { + // not necessary + } + + public void servicesDiscovered(int arg0, ServiceRecord[] arg1) { + // not necessary + } + + public boolean isInquirying() { + return this.isInquiring; + } + + public Vector getDiscoveredWiimotes() throws IOException { + Vector wiimotes = new Vector(); + + for (int i = 0; i < devices.size(); i++) { + wiimotes.add(new Wiimote(devices.elementAt(i).getBluetoothAddress(), true, true)); + } + + return wiimotes; + } +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/control/WiimoteWiigee.java b/vendor/wiigee/1.5.6/org/wiigee/control/WiimoteWiigee.java new file mode 100644 index 0000000..aa56bac --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/control/WiimoteWiigee.java @@ -0,0 +1,210 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.wiigee.control; + +import java.io.IOException; +import java.util.Vector; + +import javax.bluetooth.DiscoveryAgent; +import javax.bluetooth.LocalDevice; + +import org.wiigee.util.Log; +import org.wiigee.device.Wiimote; +import org.wiigee.event.AccelerationListener; +import org.wiigee.event.GestureListener; +import org.wiigee.filter.Filter; + +// Singleton +public class WiimoteWiigee extends Wiigee { + + protected static String pluginversion = "1.5.6"; + protected static String pluginreleasedate = "20090817"; + private static final Object lock = new Object(); + private Vector devices; + + public WiimoteWiigee() { + super(); + String stack; + String stackVersion; + String l2capFeature; + String bluecoveVersion; + + Log.write("This is wiigee-plugin-wiimote version " + pluginversion + " (" + pluginreleasedate + ")"); + + // Bluecove + bluecoveVersion = LocalDevice.getProperty("bluecove"); + if(!bluecoveVersion.equals("")) { + + stack = LocalDevice.getProperty("bluecove.stack"); + stackVersion = LocalDevice.getProperty("bluecove.stack.version"); + Log.write("You are using the "+stack+" Bluetooth stack (Version "+stackVersion+")"); + + l2capFeature = LocalDevice.getProperty("bluecove.feature.l2cap"); + Log.write("L2CAP supported: "+l2capFeature); + + if(l2capFeature.equals("true")) { + Log.write("wiigee: found a supported stack!"); + + // set min id for Bluecove + Log.write(Log.DEBUG, "JSR82 PSM Minimum Restriction -- OFF", null); + System.setProperty("bluecove.jsr82.psm_minimum_off", "true"); + } + } else { + Log.write("No Bluecove Library detected - trying anyway..."); + } + } + + /** + * Automatically discovers Wiimotes nearby and connects to + * the first responding Wiimote visible. For multiple managed + * instances of the Wiimote, please use getDevices(). + * + * @return First visible Wiimote. Null otherwise. + * @throws java.io.IOException + */ + public Wiimote getDevice() throws IOException { + this.devices = this.discoverWiimotes(); + if(this.devices.size()>0) { + return devices.elementAt(0); + } + return null; + } + + /** + * Returns an array of all discovered Wiimotes. The count + * of Devices depends on your computers bluetooth capabilities. + * Usually up to 7 Wiimotes/Devices can be connected. + * + * @return Array of discovered wiimotes or null if + * none discoverd. + */ + public Wiimote[] getDevices() throws IOException { + this.devices = this.discoverWiimotes(); + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).setLED(i + 1); + } + Wiimote[] out = new Wiimote[this.devices.size()]; + for (int i = 0; i < this.devices.size(); i++) { + out[i] = this.devices.elementAt(i); + } + + if(out.length>0) { + return out; + } + + return null; + } + + /** + * Discover the wiimotes around the bluetooth host and + * make them available public via getWiimotes method. + * + * @return Array of discovered wiimotes. + */ + private Vector discoverWiimotes() throws IOException { + WiimoteDeviceDiscovery deviceDiscovery = new WiimoteDeviceDiscovery(lock); + LocalDevice localDevice = LocalDevice.getLocalDevice(); + Log.write("Your Computers Bluetooth MAC: " + localDevice.getBluetoothAddress()); + + Log.write("Starting device inquiry..."); + DiscoveryAgent discoveryAgent = localDevice.getDiscoveryAgent(); + discoveryAgent.startInquiry(DiscoveryAgent.GIAC, deviceDiscovery); + + + try { + synchronized (lock) { + lock.wait(); + } + } catch (InterruptedException e) { + Log.write("Problems during device discovery."); + e.printStackTrace(); + } + + Log.write("Device discovery completed!"); + return deviceDiscovery.getDiscoveredWiimotes(); + } + + /** + * Returns the number of wiimotes discovered. + * + * @return Number of wiimotes discovered. + */ + public int getNumberOfDevices() { + if(this.devices!=null) { + return this.devices.size(); + } + return 0; + } + + /** + * Sets the Trainbutton for all wiimotes; + * + * @param b Button encoding, see static Wiimote values + */ + public void setTrainButton(int b) { + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).setTrainButton(b); + } + } + + /** + * Sets the Recognitionbutton for all wiimotes; + * + * @param b Button encoding, see static Wiimote values + */ + public void setRecognitionButton(int b) { + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).setRecognitionButton(b); + } + } + + /** + * Sets the CloseGesturebutton for all wiimotes; + * + * @param b Button encoding, see static Wiimote values + */ + public void setCloseGestureButton(int b) { + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).setCloseGestureButton(b); + } + } + + public void addDeviceListener(AccelerationListener listener) { + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).addAccelerationListener(listener); + } + } + + public void addGestureListener(GestureListener listener) { + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).addGestureListener(listener); + } + } + + public void addAccelerationFilter(Filter filter) { + for (int i = 0; i < this.devices.size(); i++) { + this.devices.elementAt(i).addAccelerationFilter(filter); + } + } +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/device/Device.java b/vendor/wiigee/1.5.6/org/wiigee/device/Device.java new file mode 100644 index 0000000..796b952 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/device/Device.java @@ -0,0 +1,234 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.wiigee.device; + +import java.io.IOException; +import java.util.Vector; + +import org.wiigee.logic.*; +import org.wiigee.event.*; +import org.wiigee.filter.*; + +/** + * Abstract representation of a device with very basic functionalities. This + * class should be derived from, if anybody plans to add a new class of devices, + * like Wiimote or AndroidDevice does. This class mainly consist of filter + * management, recognition control and core event control. + * + * @author Benjamin 'BePo' Poppinga + */ +public class Device { + + // Fixed number values. + public static final int MOTION = 0; + + // Buttons for action coordination + protected int recognitionbutton; + protected int trainbutton; + protected int closegesturebutton; + + // Functional + protected boolean accelerationEnabled; + + // Filters, can filter the data stream + protected Vector accfilters = new Vector(); + + // Listeners, receive generated events + protected Vector accelerationlistener = new Vector(); + protected Vector buttonlistener = new Vector(); + + // Processing unit to analyze the data + protected ProcessingUnit processingunit = new TriggeredProcessingUnit(); + + public Device(boolean autofiltering) { + if (autofiltering) { + this.addAccelerationFilter(new IdleStateFilter()); + this.addAccelerationFilter(new MotionDetectFilter(this)); + this.addAccelerationFilter(new DirectionalEquivalenceFilter()); + } + this.addAccelerationListener(this.processingunit); + this.addButtonListener(this.processingunit); + } + + /** + * Adds a Filter for processing the acceleration values. + * @param filter The Filter instance. + */ + public void addAccelerationFilter(Filter filter) { + this.accfilters.add(filter); + } + + /** + * Resets all the accfilters, which are resetable. + * Sometimes they have to be resettet if a new gesture starts. + */ + public void resetAccelerationFilters() { + for (int i = 0; i < this.accfilters.size(); i++) { + this.accfilters.elementAt(i).reset(); + } + } + + /** + * Adds an AccelerationListener to the Device. Everytime an acceleration + * on the Device is performed the AccelerationListener would receive + * an event of this action. + * + * @param listener The Listener. + */ + public void addAccelerationListener(AccelerationListener listener) { + this.accelerationlistener.add(listener); + } + + /** + * Adds a ButtonListener to the Device. Everytime a Button has been + * pressed or released, the Listener would be notified about this via + * the corresponding Events. + * + * @param listener The Listener. + */ + public void addButtonListener(ButtonListener listener) { + this.buttonlistener.add(listener); + } + + /** + * Adds a GestureListener to the Device. Everytime a gesture + * is performed the GestureListener would receive an event of + * this gesture. + * + * @param listener The Listener. + */ + public void addGestureListener(GestureListener listener) { + this.processingunit.addGestureListener(listener); + } + + public int getRecognitionButton() { + return this.recognitionbutton; + } + + public void setRecognitionButton(int b) { + this.recognitionbutton = b; + } + + public int getTrainButton() { + return this.trainbutton; + } + + public void setTrainButton(int b) { + this.trainbutton = b; + } + + public int getCloseGestureButton() { + return this.closegesturebutton; + } + + public void setCloseGestureButton(int b) { + this.closegesturebutton = b; + } + + public ProcessingUnit getProcessingUnit() { + return this.processingunit; + } + + public void setAccelerationEnabled(boolean enabled) throws IOException { + this.accelerationEnabled = enabled; + } + + public void loadGesture(String filename) { + this.processingunit.loadGesture(filename); + } + + public void saveGesture(int id, String filename) { + this.processingunit.saveGesture(id, filename); + } + + // ###### Event-Methoden + /** Fires an acceleration event. + * @param vector Consists of three values: + * acceleration on X, Y and Z axis. + */ + public void fireAccelerationEvent(double[] vector) { + for (int i = 0; i < this.accfilters.size(); i++) { + vector = this.accfilters.get(i).filter(vector); + // cannot return here if null, because of time-dependent accfilters + } + + // don't need to create an event if filtered away + if (vector != null) { + // calculate the absolute value for the accelerationevent + double absvalue = Math.sqrt((vector[0] * vector[0]) + + (vector[1] * vector[1]) + (vector[2] * vector[2])); + + AccelerationEvent w = new AccelerationEvent(this, + vector[0], vector[1], vector[2], absvalue); + for (int i = 0; i < this.accelerationlistener.size(); i++) { + this.accelerationlistener.get(i).accelerationReceived(w); + } + } + + } // fireaccelerationevent + + /** Fires a button pressed event. + * @param button + * Integer value of the pressed button. + */ + public void fireButtonPressedEvent(int button) { + ButtonPressedEvent w = new ButtonPressedEvent(this, button); + for (int i = 0; i < this.buttonlistener.size(); i++) { + this.buttonlistener.get(i).buttonPressReceived(w); + } + + if (w.isRecognitionInitEvent() || w.isTrainInitEvent()) { + this.resetAccelerationFilters(); + } + } + + /** Fires a button released event. + */ + public void fireButtonReleasedEvent(int button) { + ButtonReleasedEvent w = new ButtonReleasedEvent(this, button); + for (int i = 0; i < this.buttonlistener.size(); i++) { + this.buttonlistener.get(i).buttonReleaseReceived(w); + } + } + + /** + * Fires a motion start event. + */ + public void fireMotionStartEvent() { + MotionStartEvent w = new MotionStartEvent(this); + for (int i = 0; i < this.accelerationlistener.size(); i++) { + this.accelerationlistener.get(i).motionStartReceived(w); + } + } + + /** + * Fires a motion stop event. + */ + public void fireMotionStopEvent() { + MotionStopEvent w = new MotionStopEvent(this); + for (int i = 0; i < this.accelerationlistener.size(); i++) { + this.accelerationlistener.get(i).motionStopReceived(w); + } + } +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/device/Wiimote.java b/vendor/wiigee/1.5.6/org/wiigee/device/Wiimote.java new file mode 100644 index 0000000..d9fa086 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/device/Wiimote.java @@ -0,0 +1,602 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.wiigee.device; + +import java.io.IOException; +import java.util.Random; +import java.util.Vector; +import javax.bluetooth.L2CAPConnection; +import javax.microedition.io.Connector; +import org.wiigee.event.*; +import org.wiigee.filter.Filter; +import org.wiigee.util.Log; + +/** + * This class represents the basic functions of the wiimote. + * If you want your wiimote to e.g. vibrate you'll do this here. + * + * @author Benjamin 'BePo' Poppinga + */ +public class Wiimote extends Device { + + // Fixed number values. + public static final int BUTTON_2 = 0x0001; + public static final int BUTTON_1 = 0x0002; + public static final int BUTTON_B = 0x0004; + public static final int BUTTON_A = 0x0008; + public static final int BUTTON_MINUS = 0x0010; + public static final int BUTTON_HOME = 0x0080; + public static final int BUTTON_LEFT = 0x0100; + public static final int BUTTON_RIGHT = 0x0200; + public static final int BUTTON_DOWN = 0x0400; + public static final int BUTTON_UP = 0x0800; + public static final int BUTTON_PLUS = 0x1000; + + // Reports + public static final byte CMD_SET_REPORT = 0x52; + + // IR Modes + public static final byte IR_MODE_STANDARD = 0x01; + public static final byte IR_MODE_EXTENDED = 0x03; + + // Modes / Channels + public static final byte MODE_BUTTONS = 0x30; + public static final byte MODE_BUTTONS_ACCELERATION = 0x31; + public static final byte MODE_BUTTONS_ACCELERATION_INFRARED = 0x33; + + // Bluetooth-adress as string representation + private String btaddress; + + // LED encoded as byte + byte ledencoding; + + // Filters, can filter the data stream + protected Vector rotfilters = new Vector(); + + // control connection, send commands to wiimote + private L2CAPConnection controlCon; + + // receive connection, receive answers from wiimote + private L2CAPConnection receiveCon; + + // Listeners, receive generated events + protected Vector infraredlistener = new Vector(); + protected Vector rotationListener = new Vector(); + + // keep track of the orientation + private double pitch = 0.0; + private double roll = 0.0; + private double yaw = 0.0; + + // Functional + private boolean vibrating; + private boolean calibrated; + private boolean infraredEnabled; + private WiimoteStreamer wms; + private boolean wiiMotionPlusEnabled; + + /** + * Creates a new wiimote-device with a specific bluetooth mac-adress. + * + * @param btaddress + * String representation of the mac-adress e.g. 00191D68B57C. + * @param autofiltering + * If set the wiimote would automatically add the IdleStateFilter. + * @param autoconnect + * If set the wiimote would automatically be connected. + */ + public Wiimote(String btaddress, boolean autofiltering, boolean autoconnect) throws IOException { + super(autofiltering); + this.btaddress = this.removeChar(btaddress, ':'); + this.vibrating = false; + this.setCloseGestureButton(Wiimote.BUTTON_HOME); + this.setRecognitionButton(Wiimote.BUTTON_B); + this.setTrainButton(Wiimote.BUTTON_A); + + // automatic connect enabled + if (autoconnect) { + this.connect(); + this.calibrateAccelerometer(); + this.streamData(true); + this.setLED(1); + this.setAccelerationEnabled(true); + } + } + + /** + * Creates the two needed connections to send and receive commands + * to and from the wiimote-device. + * + */ + public void connect() throws IOException { + this.controlCon = (L2CAPConnection) Connector.open("btl2cap://" + + this.btaddress + ":11;authenticate=false;encrypt=false;master=false", + Connector.WRITE); // 11 + this.receiveCon = (L2CAPConnection) Connector.open("btl2cap://" + + this.btaddress + ":13;authenticate=false;encrypt=false;master=false", + Connector.READ); // 13 + } + + /** + * Disconnects the wiimote and closes the two connections. + */ + public void disconnect() { + this.vibrating = false; + try { + this.controlCon.close(); + this.receiveCon.close(); + Log.write("Disconnected wiimote."); + } catch (Exception e) { + Log.write("Failure during disconnect of wiimote."); + } + } + + /** + * @return + * Receiving data connection + */ + public L2CAPConnection getReceiveConnection() { + return this.receiveCon; + } + + /** + * This method makes the Wiimote-Class reacting to incoming data. + * For just controlling and sending commands to the wiimote + * (vibration, LEDs, ...) it's not necessary to call this method. + * + * @param value + * true, if the class should react to incoming data. + * false, if you only want to send commands to wiimote and + * only the control-connection is used. + */ + public void streamData(boolean value) { + if (value == true) { + if (this.wms == null) { + this.wms = new WiimoteStreamer(this); + } + wms.start(); + } else if (this.wms != null) { + wms.stopThread(); + } + } + + /** + * The added Listener will be notified about detected infrated + * events. + * + * @param listener The Listener to be added. + */ + public void addInfraredListener(InfraredListener listener) { + this.infraredlistener.add(listener); + } + + /** + * The added Listener will be notified about detected orientation + * changes. + * + * @param listener The Listener to be added. + */ + public void addRotationListener(RotationListener listener) { + this.rotationListener.add(listener); + } + + /** + * Adds a filter to process the rotation speed data of the + * wiimote with an attached Wii Motion Plus. + * + * @param filter The Filter to be added. + */ + public void addRotationFilter(Filter filter) { + this.rotfilters.add(filter); + } + + /** + * Resets all filters which are applied to the rotation data + * from the Wii Motion Plus. Also resets _all_ determined orientation + * angles, which should be extended with a consideration of other + * external datas - maybe irda events. + */ + public void resetRotationFilters() { + this.yaw = 0.0; + this.pitch = 0.0; + this.roll = 0.0; + for (int i = 0; i < this.rotfilters.size(); i++) { + this.rotfilters.elementAt(i).reset(); + } + } + + /** + * Write data to a register inside of the wiimote. + * + * @param offset The memory offset, 3 bytes. + * @param data The data to be written, max. 16 bytes. + * @throws IOException + */ + public void writeRegister(byte[] offset, byte[] data) throws IOException { + byte[] raw = new byte[23]; + raw[0] = CMD_SET_REPORT; + raw[1] = 0x16; // Write channel + raw[2] = 0x04; // Register + for (int i = 0; i < offset.length; i++) { + raw[3 + i] = offset[i]; + } + raw[6] = (byte) data.length; + for (int i = 0; i < data.length; i++) { + raw[7 + i] = data[i]; + } + this.sendRaw(raw); + } + + /** + * Makes the Wiimote respond the data of an register. The wiimotestreamer + * doesn't react to the reponse yet. + * + * @param offset The memory offset. + * @param size The size which has to be read out. + * @throws IOException + */ + public void readRegister(byte[] offset, byte[] size) throws IOException { + byte[] raw = new byte[8]; + raw[0] = CMD_SET_REPORT; + raw[1] = 0x17; // Read channel + raw[2] = 0x04; // Register + for (int i = 0; i < offset.length; i++) { + raw[3 + i] = offset[i]; + } + for (int i = 0; i < size.length; i++) { + raw[6 + i] = size[i]; + } + this.sendRaw(raw); + } + + /** + * Reads data out of the EEPROM of the wiimote. + * At the moment this method is only used to read out the + * calibration data, so the wiimotestreamer doesn't react for + * every answer on this request. + * + * @param offset The memory offset. + * @param size The size. + * @throws IOException + */ + public void readEEPROM(byte[] offset, byte[] size) throws IOException { + byte[] raw = new byte[8]; + raw[0] = CMD_SET_REPORT; + raw[1] = 0x17; // Read channel + raw[2] = 0x00; // EEPROM + for (int i = 0; i < offset.length; i++) { + raw[3 + i] = offset[i]; + } + for (int i = 0; i < size.length; i++) { + raw[6 + i] = size[i]; + } + this.sendRaw(raw); + } + + /** + * Sends pure hexdata to the wiimote. If you want your wiimote + * to vibrate use sendRaw(new byte[] {0x52, 0x13, 0x01}). For other raw-commands use + * the specific wiki-sites around the web (wiili.org, wiibrew.org, ...) + * @param raw + * byte representation of an command + */ + public void sendRaw(byte[] raw) throws IOException { + if (this.controlCon != null) { + this.controlCon.send(raw); + try { + Thread.sleep(100l); + } catch (InterruptedException e) { + System.out.println("sendRaw() interrupted"); + } + } + } + + /** + * Enables one or more LEDs, where the value could be between 0 and 8. + * If value=1 only the left LED would light up, for value=2 the second + * led would light up, for value=3 the first and second led would light up, + * and so on... + * + * @param value Between 0 and 8, indicating which LEDs should light up + * @throws IOException + */ + public void setLED(int value) throws IOException { + if (value < 16 && value > 0) { + byte tmp = (byte) value; + this.ledencoding = (byte) (tmp << 4); + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x11, this.ledencoding}); + } else { + // Random LED change :) + this.setLED(new Random().nextInt(16)); + } + } + + /** + * Updates the report channel according to the choosen + * functions that are enabled (acceleration, irda, ...). + * + */ + private void updateReportChannel() throws IOException { + if(!accelerationEnabled + && !wiiMotionPlusEnabled + && !infraredEnabled) { + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x00, 0x30}); + } + else if(accelerationEnabled + && !wiiMotionPlusEnabled + && !infraredEnabled) { + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x04, 0x31}); + } + else if(!accelerationEnabled + && wiiMotionPlusEnabled + && !infraredEnabled) { + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x00, 0x32}); + } + else if(accelerationEnabled + && wiiMotionPlusEnabled + && !infraredEnabled) { + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x04, 0x35}); + } + else if(accelerationEnabled + && !wiiMotionPlusEnabled + && infraredEnabled) { + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x04, 0x33}); + } + else if(accelerationEnabled + && wiiMotionPlusEnabled + && infraredEnabled) { + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x04, 0x37}); + } + else { + // default channel - fallback to button only. + Log.write("Invalid Value Configuration: Fallback to Buttons only."); + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x12, 0x00, 0x30}); + } + } + + /** + * Initializes the calibration of the accerlerometer. This is done once + * per each controller in program lifetime. + * + * @throws IOException + */ + private void calibrateAccelerometer() throws IOException { + this.readEEPROM(new byte[]{0x00, 0x00, 0x20}, new byte[]{0x00, 0x07}); + this.calibrated = true; + } + + /** + * Activates the acceleration sensor. You have to call the + * streamData(true) method to react to this acceleration data. + * Otherwise the wiimote would send data the whole time and + * nothing else would happen. + * + */ + @Override + public void setAccelerationEnabled(boolean enabled) throws IOException { + super.setAccelerationEnabled(enabled); + if(enabled) { + Log.write("Enabling ACCELEROMETER..."); + this.accelerationEnabled = true; + if (!this.calibrated) { + this.calibrateAccelerometer(); + } + } else { + Log.write("Disabling ACCELEROMETER..."); + this.accelerationEnabled = false; + } + + // change channel dynamically + this.updateReportChannel(); + } + + /** + * Enables or disables the infrared camera of the wiimote with + * the default values. + * + * @param e Should the Infrared Camera be enabled. + * @throws IOException In case of a connection error. + */ + public void setInfraredCameraEnabled(boolean enabled) throws IOException { + this.setInfraredCameraEnabled(enabled, Wiimote.IR_MODE_STANDARD); + } + + /** + * Enables the infrared camera in front of the wiimote to track + * IR sources in the field of view of the camera. This could be used + * to a lot of amazing stuff. Using this Mode could slow down the + * recognition of acceleration gestures during the increased data + * size transmitted. + * + * @param e Should the Infrared Camera be enabled. + * @param infraredMode The choosen Infrared Camera Mode. + * @throws IOException In case of a connection error. + * + */ + public void setInfraredCameraEnabled(boolean enabled, byte infraredMode) throws IOException { + if(enabled) { + Log.write("Enabling INFRARED CAMERA..."); + this.infraredEnabled = true; + + //write 0x04 to output 0x13 + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x13, 0x04}); + + // write 0x04 to output 0x1a + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x1a, 0x04}); + + // write 0x08 to reguster 0xb00030 + this.writeRegister(new byte[]{(byte) 0xb0, 0x00, 0x30}, new byte[]{0x08}); + + // write sensivity block 1 to register 0xb00000 + this.writeRegister(new byte[]{(byte) 0xb0, 0x00, 0x00}, new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0x90, 0x00, (byte) 0x41}); + + // write sensivity block 2 to register 0xb0001a + this.writeRegister(new byte[]{(byte) 0xb0, 0x00, (byte) 0x1a}, new byte[]{0x40, 0x00}); + + // write ir-mode to register 0xb00033 + this.writeRegister(new byte[]{(byte) 0xb0, 0x00, 0x33}, new byte[]{infraredMode}); + } else { + Log.write("Disabling INFRARED CAMERA..."); + this.infraredEnabled = false; + } + + // change channel dynamically + this.updateReportChannel(); + } + + /** + * To enable the Wii Motion Plus extension. The wiimote will further get + * every other information, like acceleration, infrared camera (loss of precision) + * and button presses. + * + * @throws java.io.IOException + */ + public void setWiiMotionPlusEnabled(boolean enabled) throws IOException { + if(enabled) { + Log.write("Enabling WII MOTION PLUS.."); + this.wiiMotionPlusEnabled = true; + // write 0x04 to 0x04a600fe to get wii m+ data within extension reports + this.writeRegister(new byte[]{(byte) 0xa6, 0x00, (byte) 0xfe}, new byte[]{0x04}); + } else { + Log.write("Disabling WII MOTION PLUS.."); + this.wiiMotionPlusEnabled = false; + } + + // change channel dynamically + this.updateReportChannel(); + } + + + /** + * With this method you gain access over the vibrate function of + * the wiimote. You got to try which time in milliseconds would + * fit your requirements. + * + * @param milliseconds Time the wiimote would approx. vibrate. + */ + public void vibrateForTime(long milliseconds) throws IOException { + try { + if (!vibrating) { + this.vibrating = true; + byte tmp = (byte) (this.ledencoding | 0x01); + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x11, tmp}); + Thread.sleep(milliseconds); + this.sendRaw(new byte[]{CMD_SET_REPORT, 0x11, this.ledencoding}); + this.vibrating = false; + } + } catch (InterruptedException e) { + System.out.println("WiiMoteThread interrupted."); + } + } + + public double getPitch() { + return this.pitch; + } + + public double getYaw() { + return this.yaw; + } + + public double getRoll() { + return this.roll; + } + + /** + * Fires a infrared event, containig coordinate pairs (x,y) and a + * size of the detected IR spot. + * + * @param coordinates X and Y display coordinates. + * @param size The size of the spot. + */ + public void fireInfraredEvent(int[][] coordinates, int[] size) { + InfraredEvent w = new InfraredEvent(this, coordinates, size); + for (int i = 0; i < this.infraredlistener.size(); i++) { + this.infraredlistener.get(i).infraredReceived(w); + } + } + + /** + * Fires the current relative orientation of the Wiimote to + * all RotationListeners. + * + * @param yaw Orientation around Z axis. + * @param roll Orientation around Y axis. + * @param pitch Orientation around X axis. + */ + public void fireRotationEvent(double pitch, double roll, double yaw) { + this.pitch = pitch; + this.roll = roll; + this.yaw = yaw; + + RotationEvent w = new RotationEvent(this, pitch, roll, yaw); + for (int i = 0; i < this.rotationListener.size(); i++) { + this.rotationListener.elementAt(i).rotationReceived(w); + } + } + + /** + * If a Wii Motion Plus is attached and activated properly this + * event could be fired within every change of orientation of the + * device. The orientation is not used to do gesture recognition, + * yet. + * + * @param vector The rotational speed vector, containing: + * phi - Rotational speed of x axis (pitch) + * theta - Rotational speed of y axis (roll) + * psi - Rotational speed of z axis (yaw) + */ + public void fireRotationSpeedEvent(double[] vector) { + for (int i = 0; i < this.rotfilters.size(); i++) { + vector = this.rotfilters.get(i).filter(vector); + // cannot return here if null, because of time-dependent filters + } + + if (vector != null) { + RotationSpeedEvent w = new RotationSpeedEvent(this, vector[0], vector[1], vector[2]); + for (int i = 0; i < this.rotationListener.size(); i++) { + this.rotationListener.elementAt(i).rotationSpeedReceived(w); + } + + // calculate new orientation with integration + // do not store new global values here, since they + // need regular updates only depended on acceleration values. + double tyaw = this.yaw + vector[0] * 0.01; + double troll = this.roll + vector[1] * 0.01; + double tpitch = this.pitch + vector[2] * 0.01; + this.fireRotationEvent(tpitch, troll, tyaw); + } + } + + // ###### Hilfsmethoden + // TODO + private String removeChar(String s, char c) { + String r = ""; + for (int i = 0; i < s.length(); i++) { + if (s.charAt(i) != c) { + r += s.charAt(i); + } + } + return r; + } +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/device/WiimoteStreamer.java b/vendor/wiigee/1.5.6/org/wiigee/device/WiimoteStreamer.java new file mode 100644 index 0000000..b8ba764 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/device/WiimoteStreamer.java @@ -0,0 +1,400 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.wiigee.device; + +import java.io.IOException; +import java.util.EventObject; + +import java.util.Vector; +import javax.bluetooth.L2CAPConnection; + +import org.wiigee.util.Log; + +/** + * This class listens to data sended by the wiimote and generates specific + * events for acceleration, buttonpress, ... + * + * @author Benjamin 'BePo' Poppinga + * + */ +public class WiimoteStreamer extends Thread { + + private boolean running; + private int buttonstate; + private double x0, x1, y0, y1, z0, z1; + private double psi0, theta0, phi0; + private boolean wmpcalibrated; + private int calibrationcounter; + private Vector calibrationsequence; + private Wiimote wiimote; + private L2CAPConnection receiveCon; + private EventObject lastevent; + + protected WiimoteStreamer(Wiimote wiimote) { + this.wiimote = wiimote; + this.receiveCon = wiimote.getReceiveConnection(); + this.buttonstate = 0; + Log.write("WiimoteStreamer initialized..."); + } + + @Override + public void run() { + Log.write("WiimoteStreamer running..."); + this.running = true; + this.calibrationcounter = 0; + this.calibrationsequence = new Vector(); + + try { + while (running) { + // connection has data and we're ready. + + byte[] b = this.getRaw(); // blocks application + + // Log.write(""); + + // debug output + /* for(int i=0; ireference[0]+this.sensivity || + vector[1]reference[1]+this.sensivity || + vector[2]reference[2]+this.sensivity) { + this.reference=vector; + return vector; + } else { + return null; + } + } + + public void setSensivity(double sensivity) { + this.sensivity=sensivity; + } + + public double getSensivity() { + return this.sensivity; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/Filter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/Filter.java new file mode 100644 index 0000000..e97d4a9 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/Filter.java @@ -0,0 +1,62 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.filter; + +/** + * Abstract class to give a definition for a general filter. + * + * @author Benjamin 'BePo' Poppinga + */ +public abstract class Filter { + + /*** + * The actual called method to filter anything. It checks if the vector is + * already set to NULL by another filter and won't process it anymore. If it's + * not NULL it would be forwarded to the actual implemented method - filterAlgorithm(). + * @param vector The acceleration vector, encoding: 0/x, 1/y, 2/z + * @return a new, filtered acceleration vector, encoded the same way + */ + public double[] filter(double[] vector) { + if(vector==null) { + return null; + } else { + return filterAlgorithm(vector); + } + } + + /*** + * A filter receives a triple of acceleration values within the variable 'vector'. + * It's encoded as vector[0]=x, vector[1]=y, vector[2]=z. This is not an object since the + * processing of the filter should be really fast, since every acceleration of the wiimote + * passes the filter. + * @param vector + * @param absvalue + * @return + */ + abstract public double[] filterAlgorithm(double[] vector); + + abstract public void reset(); + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/HighPassFilter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/HighPassFilter.java new file mode 100644 index 0000000..54a6946 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/HighPassFilter.java @@ -0,0 +1,71 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.filter; + +/** + * + * This filter removes every acceleration that happens slowly or + * steadily (like e.g. gravity). Remember: It _passes_ acceleration + * with a big variety. + * + * @author Benjamin 'BePo' Poppinga + */ +public class HighPassFilter extends Filter { + + private double factor; + private double[] prevAcc; + + public HighPassFilter() { + super(); + this.factor = 0.1; + this.reset(); + } + + public HighPassFilter(double factor) { + super(); + this.factor = factor; + this.reset(); + } + + @Override + public void reset() { + this.prevAcc = new double[] {0.0, 0.0, 0.0}; + } + + @Override + public double[] filterAlgorithm(double[] vector) { + double[] retVal = new double[3]; + prevAcc[0] = vector[0] * this.factor + this.prevAcc[0] * (1.0 - this.factor); + prevAcc[1] = vector[1] * this.factor + this.prevAcc[1] * (1.0 - this.factor); + prevAcc[2] = vector[2] * this.factor + this.prevAcc[2] * (1.0 - this.factor); + + retVal[0] = vector[0] - prevAcc[0]; + retVal[1] = vector[1] - prevAcc[1]; + retVal[2] = vector[2] - prevAcc[2]; + + return retVal; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/IdleStateFilter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/IdleStateFilter.java new file mode 100644 index 0000000..b816e0b --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/IdleStateFilter.java @@ -0,0 +1,86 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.filter; + +/** + * Filters if the wiimote is not moved in any way. Be careful in using + * this filter together with a HighPassFilter. + * + * @author Benjamin 'BePo' Poppinga + */ +public class IdleStateFilter extends Filter { + + private double sensivity; + + /** + * Since an acceleration sensor usually provides information even + * if it doesn't move, this filter removes the data if it's in the + * idle state. + */ + public IdleStateFilter() { + super(); + this.sensivity = 0.1; + } + + @Override + public void reset() { + // not needed + } + + @Override + public double[] filterAlgorithm(double[] vector) { + // calculate values needed for filtering: + // absolute value + double absvalue = Math.sqrt((vector[0]*vector[0])+ + (vector[1]*vector[1])+(vector[2]*vector[2])); + + // filter formulaes and return values + if(absvalue > 1+this.sensivity || + absvalue < 1-this.sensivity) { + return vector; + } else { + return null; + } + } + + /** + * Defines the absolute value when the wiimote should react to acceleration. + * This is a parameter for the first of the two filters: idle state + * filter. For example: sensivity=0.2 makes the wiimote react to acceleration + * where the absolute value is equal or greater than 1.2g. The default value 0.1 + * should work well. Only change if you are sure what you're doing. + * + * @param sensivity + * acceleration data values smaller than this value wouldn't be detected. + */ + public void setSensivity(double sensivity) { + this.sensivity = sensivity; + } + + public double getSensivity() { + return this.sensivity; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/LowPassFilter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/LowPassFilter.java new file mode 100644 index 0000000..2c3e012 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/LowPassFilter.java @@ -0,0 +1,67 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.filter; + +/** + * + * This filter removes every acceleration that happens fast or + * suddenly (like e.g. a short hit). Remember: It _passes_ acceleration + * with a slight variety. + * + * @author Benjamin 'BePo' Poppinga + */ +public class LowPassFilter extends Filter { + + private double factor; + private double[] prevAcc; + + public LowPassFilter() { + super(); + this.factor = 0.01; + this.reset(); + } + + public LowPassFilter(double factor) { + super(); + this.factor = factor; + this.reset(); + } + + @Override + public void reset() { + this.prevAcc = new double[] {0.0, 0.0, 0.0}; + } + + @Override + public double[] filterAlgorithm(double[] vector) { + double[] retVal = new double[3]; + retVal[0] = vector[0] * this.factor + this.prevAcc[0] * (1.0 - this.factor); + retVal[1] = vector[1] * this.factor + this.prevAcc[1] * (1.0 - this.factor); + retVal[2] = vector[2] * this.factor + this.prevAcc[2] * (1.0 - this.factor); + this.prevAcc = retVal; + return retVal; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/MotionDetectFilter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/MotionDetectFilter.java new file mode 100644 index 0000000..b13124a --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/MotionDetectFilter.java @@ -0,0 +1,102 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.filter; + +import org.wiigee.device.Device; + +/** + * This filter uses time to determine if the wiimote actually is in motion + * or not. This filter only works together with the IdleStateFilter. + * + * @author Benjamin 'BePo' Poppinga + */ +public class MotionDetectFilter extends Filter { + + private int motionchangetime; + private boolean nowinmotion; + private long motionstartstamp; + private Device device; + + /*** + * Detects wheather the wiimote receives acceleration or not and + * raises an event, if the device starts or stops. This is actual a + * null filter, not manipulating anything. But looks pretty good in + * this datatype since it could be removed easily. + * + * @param wiimote The Wiimote object which is controlled by the filter. + */ + public MotionDetectFilter(Device device) { + super(); + this.device=device; + this.reset(); + } + + public void reset() { + this.motionstartstamp=System.currentTimeMillis(); + this.nowinmotion=false; + this.motionchangetime=190; + } + + @Override + public double[] filter(double[] vector) { + + if(this.nowinmotion && + (System.currentTimeMillis()-this.motionstartstamp)>= + this.motionchangetime) { + this.nowinmotion=false; + this.device.fireMotionStopEvent(); + } // fi + + return filterAlgorithm(vector); + } + + public double[] filterAlgorithm(double[] vector) { + if(vector!=null) { + this.motionstartstamp=System.currentTimeMillis(); + if(!this.nowinmotion) { + this.nowinmotion=true; + this.motionstartstamp=System.currentTimeMillis(); + this.device.fireMotionStartEvent(); + } + } + + return vector; + } + + /** + * Defines the time the wiimote has to be in idle state before a new motion change + * event appears. The default value 500ms should work well, only change it if you are sure + * about what you're doing. + * @param time Time in ms + */ + public void setMotionChangeTime(int time) { + this.motionchangetime=time; + } + + public int getMotionChangeTime() { + return this.motionchangetime; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/RotationResetFilter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/RotationResetFilter.java new file mode 100644 index 0000000..48f568e --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/RotationResetFilter.java @@ -0,0 +1,68 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package org.wiigee.filter; + +import org.wiigee.device.Wiimote; +import org.wiigee.util.Log; + +/** + * Removes rotation events which are for all axis + * under a defined threshold value (which default is 2.0 degrees + * per second TBD). + * + * @author Benjamin 'BePo' Poppinga + */ +public class RotationResetFilter extends Filter { + + private Wiimote device; + + public RotationResetFilter(Wiimote source) { + super(); + this.device = source; + } + + @Override + public void reset() { + // nothing to reset here + } + + public double[] filterAlgorithm(double[] vector) { + double abs = Math.sqrt(vector[0]*vector[0]+ + vector[1]*vector[1]+ + vector[2]*vector[2]); + + if(abs<=1.05 && abs>=0.95) { // wiimote is idle + + //roll = arctan2(ax,sqrt(ay2+az2)) + //pitch = arctan2(ay,sqrt(ax2+az2)) + + double tphi = Math.toDegrees(Math.atan2(vector[0], Math.sqrt(vector[1]*vector[1]+vector[2]*vector[2]))); + double ttheta = Math.toDegrees(Math.atan2(vector[1], Math.sqrt(vector[0]*vector[0]+vector[2]*vector[2]))); + this.device.fireRotationEvent(tphi, ttheta, this.device.getYaw()); + Log.write("reset rotation using acceleration. pitch="+tphi+" roll="+ttheta); + } + return vector; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/filter/RotationThresholdFilter.java b/vendor/wiigee/1.5.6/org/wiigee/filter/RotationThresholdFilter.java new file mode 100644 index 0000000..972ff58 --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/filter/RotationThresholdFilter.java @@ -0,0 +1,71 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.filter; + +/** + * Removes rotation events which are for all axis + * under a defined threshold value (which default is 2.0 degrees + * per second TBD). + * + * @author Benjamin 'BePo' Poppinga + */ +public class RotationThresholdFilter extends Filter { + + private double threshold; + + public RotationThresholdFilter() { + super(); + this.threshold = 2.0; + } + + public RotationThresholdFilter(double threshold) { + super(); + this.threshold = threshold; + } + + @Override + public void reset() { + // nothing to reset here + } + + public double[] filterAlgorithm(double[] vector) { + if(Math.abs(vector[0])>threshold || + Math.abs(vector[1])>threshold || + Math.abs(vector[2])>threshold) { + return vector; + } else { + return new double[] { 0.0, 0.0, 0.0 }; + } + } + + public void setSensivity(double sensivity) { + this.threshold=sensivity; + } + + public double getSensivity() { + return this.threshold; + } + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/logic/Classifier.java b/vendor/wiigee/1.5.6/org/wiigee/logic/Classifier.java new file mode 100644 index 0000000..a8f1b5a --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/logic/Classifier.java @@ -0,0 +1,109 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.logic; + +import java.util.Vector; + +public class Classifier { + + private Vector gesturemodel; // each gesturetype got its own + // gesturemodel in this vector + private double lastprob; + + public Classifier() { + this.gesturemodel=new Vector(); + this.lastprob=0.0; + } + + /** + * This method recognize a specific gesture, given to the procedure. + * For classification a bayes classification algorithm is used. + * + * @param g gesture to classify + */ + public int classifyGesture(Gesture g) { + //Log.write("Recognizing gesture..."); + + // Wert im Nenner berechnen, nach Bayes + double sum = 0; + for(int i=0; irecogprob) { + probgesture=tmpgesture; + probmodel=tmpmodel; + recogprob=((tmpmodel*tmpgesture)/sum); + recognized=i; + } + } + + // a gesture could be recognized + if(recogprob>0 && probmodel>0 && probgesture>0 && sum>0) { + this.lastprob=recogprob; + return recognized; + } else { + // no gesture could be recognized + return -1; + } + + } + + public double getLastProbability() { + return this.lastprob; + } + + public void addGestureModel(GestureModel gm) { + this.gesturemodel.add(gm); + } + + public GestureModel getGestureModel(int id) { + return this.gesturemodel.elementAt(id); + } + + public Vector getGestureModels() { + return this.gesturemodel; + } + + public int getCountOfGestures() { + return this.gesturemodel.size(); + } + + public void clear() { + this.gesturemodel = new Vector(); + } + + +} diff --git a/vendor/wiigee/1.5.6/org/wiigee/logic/Gesture.java b/vendor/wiigee/1.5.6/org/wiigee/logic/Gesture.java new file mode 100644 index 0000000..2d1976a --- /dev/null +++ b/vendor/wiigee/1.5.6/org/wiigee/logic/Gesture.java @@ -0,0 +1,155 @@ +/* + * wiigee - accelerometerbased gesture recognition + * Copyright (C) 2007, 2008, 2009 Benjamin Poppinga + * + * Developed at University of Oldenburg + * Contact: wiigee@benjaminpoppinga.de + * + * This file is part of wiigee. + * + * wiigee is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package org.wiigee.logic; + +import java.util.Vector; +import org.wiigee.event.AccelerationEvent; + +/** + * This class represents ONE movement trajectory in a + * concrete instance. + * + * @author Benjamin 'BePo' Poppinga + */ + +public class Gesture implements Cloneable { + + /** Min/MaxAcceleration setup manually? */ + private boolean minmaxmanual; + private double minacc; + private double maxacc; + + /** The complete trajectory as WiimoteAccelerationEvents + * as a vector. It's a vector because we don't want to + * loose the chronology of the stored events. + */ + private Vector data; + + /** + * Create an empty Gesture. + */ + public Gesture() { + this.data = new Vector(); + } + + /** + * Make a deep copy of another Gesture object. + * + * @param original Another Gesture object + */ + public Gesture(Gesture original) { + this.data = new Vector(); + Vector origin = original.getData(); + for (int i = 0; i < origin.size(); i++) { + this.add((AccelerationEvent) origin.get(i)); + } + } + + + /** + * Adds a new acceleration event to this gesture. + * + * @param event The WiimoteAccelerationEvent to add. + */ + public void add(AccelerationEvent event) { + this.data.add(event); + } + + /** + * Returns the last acceleration added to this gesture. + * + * @return the last acceleration event added. + */ + public AccelerationEvent getLastData() { + return (AccelerationEvent) this.data.get(this.data.size() - 1); + } + + /** + * Returns the whole chronological sequence of accelerations as + * a vector. + * + * @return chronological sequence of accelerations. + */ + public Vector getData() { + return this.data; + } + + /** + * Removes the first element of the acceleration queue of a gesture + */ + public void removeFirstData() { + this.data.remove(0); + } + + public int getCountOfData() { + return this.data.size(); + } + + public void setMaxAndMinAcceleration(double max, double min) { + this.maxacc = max; + this.minacc = min; + this.minmaxmanual = true; + } + + public double getMaxAcceleration() { + if(!this.minmaxmanual) { + double maxacc = Double.MIN_VALUE; + for(int i=0; i maxacc) { + maxacc=Math.abs(this.data.get(i).getX()); + } + if(Math.abs(this.data.get(i).getY()) > maxacc) { + maxacc=Math.abs(this.data.get(i).getY()); + } + if(Math.abs(this.data.get(i).getZ()) > maxacc) { + maxacc=Math.abs(this.data.get(i).getZ()); + } + } + return maxacc; + } else { + return this.maxacc; + } + } + + public double getMinAcceleration() { + if(!this.minmaxmanual) { + double minacc = Double.MAX_VALUE; + for(int i=0; i