diff --git a/cpp/mimis/Debug/mimis.dll b/cpp/mimis/Debug/mimis.dll deleted file mode 100644 index 76c718c..0000000 Binary files a/cpp/mimis/Debug/mimis.dll and /dev/null differ diff --git a/cpp/wiipair/Debug/wiipair.exe b/cpp/wiipair/Debug/wiipair.exe deleted file mode 100644 index dd533f9..0000000 Binary files a/cpp/wiipair/Debug/wiipair.exe and /dev/null differ diff --git a/cpp/wiiscan/.cproject b/cpp/wiiscan/.cproject deleted file mode 100644 index bc351d3..0000000 --- a/cpp/wiiscan/.cproject +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cpp/wiiscan/.project b/cpp/wiiscan/.project deleted file mode 100644 index 6b48b82..0000000 --- a/cpp/wiiscan/.project +++ /dev/null @@ -1,71 +0,0 @@ - - - cpp.wiiscan - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.buildLocation - ${workspace_loc:/Wiiscan/Release} - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/cpp/wiiscan/include/BluetoothAPIs.h b/cpp/wiiscan/include/BluetoothAPIs.h deleted file mode 100644 index 0027b2b..0000000 --- a/cpp/wiiscan/include/BluetoothAPIs.h +++ /dev/null @@ -1,1540 +0,0 @@ - -// -// Copyright 2002 - Microsoft Corporation -// -// Created By: -// Geoff Pease (GPease) 12-JAN-2002 -// -////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#define BLUETOOTH_MAX_NAME_SIZE (248) -#define BLUETOOTH_MAX_PASSKEY_SIZE (16) -#define BLUETOOTH_MAX_PASSKEY_BUFFER_SIZE (BLUETOOTH_MAX_PASSKEY_SIZE + 1) - -#ifdef __cplusplus -extern "C" { -#endif - -// *************************************************************************** -// -// Bluetooth Address -// -// *************************************************************************** - -typedef ULONGLONG BTH_ADDR; - -typedef struct _BLUETOOTH_ADDRESS { - union { - BTH_ADDR ullLong; // easier to compare again BLUETOOTH_NULL_ADDRESS - BYTE rgBytes[ 6 ]; // easier to format when broken out - }; - -} BLUETOOTH_ADDRESS_STRUCT; - -#define BLUETOOTH_ADDRESS BLUETOOTH_ADDRESS_STRUCT - -#define BLUETOOTH_NULL_ADDRESS ( (ULONGLONG) 0x0 ) - -// *************************************************************************** -// -// Radio Enumeration -// -// Description: -// This group of APIs enumerates the installed Bluetooth radios. -// -// Sample Usage: -// HANDLE hRadio; -// BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) }; -// -// HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio( &btfrp, &hRadio ); -// if ( NULL != hFind ) -// { -// do -// { -// // -// // TODO: Do something with the radio handle. -// // -// -// CloseHandle( hRadio ); -// -// } while( BluetoothFindNextRadio( hFind, &hRadio ) ); -// -// BluetoothFindRadioClose( hFind ); -// } -// -// *************************************************************************** - -typedef struct _BLUETOOTH_FIND_RADIO_PARAMS { - DWORD dwSize; // IN sizeof this structure - -} BLUETOOTH_FIND_RADIO_PARAMS; - -typedef HANDLE HBLUETOOTH_RADIO_FIND; - -// -// Description: -// Begins the enumeration of local Bluetooth radios. -// -// Parameters: -// pbtfrp -// A pointer to a BLUETOOTH_FIND_RADIO_PARAMS structure. The dwSize -// member of this structure must match the sizeof the of the structure. -// -// phRadio -// A pointer where the first radio HANDLE enumerated will be returned. -// -// Return Values: -// NULL -// Error opening radios or no devices found. Use GetLastError() for -// more info. -// -// ERROR_INVALID_PARAMETER -// pbtfrp parameter is NULL. -// -// ERROR_REVISION_MISMATCH -// The pbtfrp structure is not the right length. -// -// ERROR_OUTOFMEMORY -// Out of memory. -// -// other Win32 errors. -// -// any other -// Success. The return handle is valid and phRadio points to a valid handle. -// -HBLUETOOTH_RADIO_FIND -WINAPI -BluetoothFindFirstRadio( - BLUETOOTH_FIND_RADIO_PARAMS * pbtfrp, - HANDLE * phRadio - ); - -// -// Description: -// Finds the next installed Bluetooth radio. -// -// Parameters: -// hFind -// The handle returned by BluetoothFindFirstRadio(). -// -// phRadio -// A pointer where the next radio HANDLE enumerated will be returned. -// -// Return Values: -// TRUE -// Next device succesfully found. pHandleOut points to valid handle. -// -// FALSE -// No device found. pHandleOut points to an invalid handle. Call -// GetLastError() for more details. -// -// ERROR_INVALID_HANDLE -// The handle is NULL. -// -// ERROR_NO_MORE_ITEMS -// No more radios found. -// -// ERROR_OUTOFMEMORY -// Out of memory. -// -// other Win32 errors -// -BOOL -WINAPI -BluetoothFindNextRadio( - HBLUETOOTH_RADIO_FIND hFind, - HANDLE * phRadio - ); - -// -// Description: -// Closes the enumeration handle. -// -// Parameters -// hFind -// The handle returned by BluetoothFindFirstRadio(). -// -// Return Values: -// TRUE -// Handle succesfully closed. -// -// FALSE -// Failure. Check GetLastError() for details. -// -// ERROR_INVALID_HANDLE -// The handle is NULL. -// -BOOL -WINAPI -BluetoothFindRadioClose( - HBLUETOOTH_RADIO_FIND hFind - ); - -// *************************************************************************** -// -// Radio Information -// -// *************************************************************************** - -typedef struct _BLUETOOTH_RADIO_INFO { - DWORD dwSize; // Size, in bytes, of this entire data structure - - BLUETOOTH_ADDRESS address; // Address of the local radio - - WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the local radio - - ULONG ulClassofDevice; // Class of device for the local radio - - USHORT lmpSubversion; // lmpSubversion, manufacturer specifc. - USHORT manufacturer; // Manufacturer of the radio, BTH_MFG_Xxx value. For the most up to date - // list, goto the Bluetooth specification website and get the Bluetooth - // assigned numbers document. -} BLUETOOTH_RADIO_INFO, *PBLUETOOTH_RADIO_INFO; - -// -// Description: -// Retrieves the information about the radio represented by the handle. -// -// Parameters: -// hRadio -// Handle to a local radio retrieved through BluetoothFindFirstRadio() -// et al or SetupDiEnumerateDeviceInterfaces() -// -// pRadioInfo -// Radio information to be filled in. The dwSize member must match the -// size of the structure. -// -// Return Values: -// ERROR_SUCCESS -// The information was retrieved successfully. -// -// ERROR_INVALID_PARAMETER -// pRadioInfo or hRadio is NULL. -// -// ERROR_REVISION_MISMATCH -// pRadioInfo->dwSize is invalid. -// -// other Win32 error codes. -// -DWORD -WINAPI -BluetoothGetRadioInfo( - HANDLE hRadio, - PBLUETOOTH_RADIO_INFO pRadioInfo - ); - -// *************************************************************************** -// -// Device Information Stuctures -// -// *************************************************************************** - -typedef struct _BLUETOOTH_DEVICE_INFO { - DWORD dwSize; // size, in bytes, of this structure - must be the sizeof(BLUETOOTH_DEVICE_INFO) - - BLUETOOTH_ADDRESS Address; // Bluetooth address - - ULONG ulClassofDevice; // Bluetooth "Class of Device" - - BOOL fConnected; // Device connected/in use - BOOL fRemembered; // Device remembered - BOOL fAuthenticated; // Device authenticated/paired/bonded - - SYSTEMTIME stLastSeen; // Last time the device was seen - SYSTEMTIME stLastUsed; // Last time the device was used for other than RNR, inquiry, or SDP - - WCHAR szName[ BLUETOOTH_MAX_NAME_SIZE ]; // Name of the device - -} BLUETOOTH_DEVICE_INFO_STRUCT; - -#define BLUETOOTH_DEVICE_INFO BLUETOOTH_DEVICE_INFO_STRUCT - -typedef BLUETOOTH_DEVICE_INFO * PBLUETOOTH_DEVICE_INFO; - -// *************************************************************************** -// -// Device Enumeration -// -// Description: -// Enumerates the Bluetooth devices. The types of returned device depends -// on the flags set in the BLUETOOTH_DEVICE_SEARCH_PARAMS (see structure -// definition for details). -// -// Sample Usage: -// HBLUETOOTH_DEVICE_FIND hFind; -// BLUETOOTH_DEVICE_SEARCH_PARAMS btsp = { sizeof(btsp) }; -// BLUETOOTH_DEVICE_INFO btdi = { sizeof(btdi) }; -// -// btsp.fReturnAuthenticated = TRUE; -// btsp.fReturnRemembered = TRUE; -// -// hFind = BluetoothFindFirstDevice( &btsp, &btdi ); -// if ( NULL != hFind ) -// { -// do -// { -// // -// // TODO: Do something useful with the device info. -// // -// -// } while( BluetoothFindNextDevice( hFind, &btdi ) ); -// -// BluetoothFindDeviceClose( hFind ); -// } -// -// *************************************************************************** - -typedef struct _BLUETOOTH_DEVICE_SEARCH_PARAMS { - DWORD dwSize; // IN sizeof this structure - - BOOL fReturnAuthenticated; // IN return authenticated devices - BOOL fReturnRemembered; // IN return remembered devices - BOOL fReturnUnknown; // IN return unknown devices - BOOL fReturnConnected; // IN return connected devices - - BOOL fIssueInquiry; // IN issue a new inquiry - UCHAR cTimeoutMultiplier; // IN timeout for the inquiry - - HANDLE hRadio; // IN handle to radio to enumerate - NULL == all radios will be searched - -} BLUETOOTH_DEVICE_SEARCH_PARAMS; - -typedef HANDLE HBLUETOOTH_DEVICE_FIND; - -// -// Description: -// Begins the enumeration of Bluetooth devices. -// -// Parameters: -// pbtsp -// A pointer to a BLUETOOTH_DEVICE_SEARCH_PARAMS structure. This -// structure contains the flags and inputs used to conduct the search. -// See BLUETOOTH_DEVICE_SEARCH_PARAMS for details. -// -// pbtdi -// A pointer to a BLUETOOTH_DEVICE_INFO structure to return information -// about the first Bluetooth device found. Note that the dwSize member -// of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before -// calling because the APIs hast to know the size of the buffer being -// past in. The dwSize member must also match the exact -// sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail. -// -// Return Values: -// NULL -// Error opening radios or not devices found. Use GetLastError for more info. -// -// ERROR_INVALID_PARAMETER -// pbtsp parameter or pbtdi parameter is NULL. -// -// ERROR_REVISION_MISMATCH -// The pbtfrp structure is not the right length. -// -// other Win32 errors -// -// any other value -// Success. The return handle is valid and pbtdi points to valid data. -// -HBLUETOOTH_DEVICE_FIND -WINAPI -BluetoothFindFirstDevice( - BLUETOOTH_DEVICE_SEARCH_PARAMS * pbtsp, - BLUETOOTH_DEVICE_INFO * pbtdi - ); - -// -// Description: -// Finds the next Bluetooth device in the enumeration. -// -// Parameters: -// hFind -// The handle returned from BluetoothFindFirstDevice(). -// -// pbtdi -// A pointer to a BLUETOOTH_DEVICE_INFO structure to return information -// about the first Bluetooth device found. Note that the dwSize member -// of the structure must be the sizeof(BLUETOOTH_DEVICE_INFO) before -// calling because the APIs hast to know the size of the buffer being -// past in. The dwSize member must also match the exact -// sizeof(BLUETOOTH_DEVICE_INFO) or the call will fail. -// -// Return Values: -// TRUE -// Next device succesfully found. pHandleOut points to valid handle. -// -// FALSE -// No device found. pHandleOut points to an invalid handle. Call -// GetLastError() for more details. -// -// ERROR_INVALID_HANDLE -// The handle is NULL. -// -// ERROR_NO_MORE_ITEMS -// No more radios found. -// -// ERROR_OUTOFMEMORY -// Out of memory. -// -// other Win32 errors -// -BOOL -WINAPI -BluetoothFindNextDevice( - HBLUETOOTH_DEVICE_FIND hFind, - BLUETOOTH_DEVICE_INFO * pbtdi - ); - -// -// Description: -// Closes the enumeration handle. -// -// Parameters: -// hFind -// The handle returned from BluetoothFindFirstDevice(). -// -// Return Values: -// TRUE -// Handle succesfully closed. -// -// FALSE -// Failure. Check GetLastError() for details. -// -// ERROR_INVALID_HANDLE -// The handle is NULL. -// -BOOL -WINAPI -BluetoothFindDeviceClose( - HBLUETOOTH_DEVICE_FIND hFind - ); - -// -// Description: -// Retrieves information about a remote device. -// -// Fill in the dwSize and the Address members of the pbtdi structure -// being passed in. On success, the rest of the members will be filled -// out with the information that the system knows. -// -// Parameters: -// hRadio -// Handle to a local radio retrieved through BluetoothFindFirstRadio() -// et al or SetupDiEnumerateDeviceInterfaces() -// -// pbtdi -// A pointer to a BLUETOOTH_DEVICE_INFO structure to return information -// about the first Bluetooth device found. The dwSize member of the -// structure must be the sizeof the structure in bytes. The Address -// member must be filled out with the Bluetooth address of the remote -// device. -// -// Return Values: -// ERROR_SUCCESS -// Success. Information returned. -// -// ERROR_REVISION_MISMATCH -// The size of the BLUETOOTH_DEVICE_INFO isn't compatible. Check -// the dwSize member of the BLUETOOTH_DEVICE_INFO structure you -// passed in. -// -// ERROR_NOT_FOUND -// The radio is not known by the system or the Address field of -// the BLUETOOTH_DEVICE_INFO structure is all zeros. -// -// ERROR_INVALID_PARAMETER -// pbtdi is NULL. -// -// other error codes -// -DWORD -WINAPI -BluetoothGetDeviceInfo( - HANDLE hRadio, - BLUETOOTH_DEVICE_INFO * pbtdi - ); - -// -// Description: -// Updates the computer local cache about the device. -// -// Parameters: -// pbtdi -// A pointer to the BLUETOOTH_DEVICE_INFO structure to be updated. -// The following members must be valid: -// dwSize -// Must match the size of the structure. -// Address -// Must be a previously found radio address. -// szName -// New name to be stored. -// -// Return Values: -// ERROR_SUCCESS -// The device information was updated successfully. -// -// ERROR_INVALID_PARAMETER -// pbtdi is NULL. -// -// ERROR_REVISION_MISMATCH -// pbtdi->dwSize is invalid. -// -// other Win32 error codes. -// -DWORD -WINAPI -BluetoothUpdateDeviceRecord( - BLUETOOTH_DEVICE_INFO * pbtdi - ); - -// -// Description: -// Delete the authentication (aka "bond") between the computer and the -// device. Also purges any cached information about the device. -// -// Return Values: -// ERROR_SUCCESS -// The device was removed successfully. -// -// ERROR_NOT_FOUND -// The device was not found. If no Bluetooth radio is installed, -// the devices could not be enumerated or removed. -// -DWORD -WINAPI -BluetoothRemoveDevice( - BLUETOOTH_ADDRESS * pAddress - ); - -// *************************************************************************** -// -// Device Picker Dialog -// -// Description: -// Invokes a common dialog for selecting Bluetooth devices. The list -// of devices displayed to the user is determined by the flags and -// settings the caller specifies in the BLUETOOTH_SELECT_DEVICE_PARAMS -// (see structure definition for more details). -// -// If BluetoothSelectDevices() returns TRUE, the caller must call -// BluetoothSelectDevicesFree() or memory will be leaked within the -// process. -// -// Sample Usage: -// -// BLUETOOTH_SELECT_DEVICE_PARAMS btsdp = { sizeof(btsdp) }; -// -// btsdp.hwndParent = hDlg; -// btsdp.fShowUnknown = TRUE; -// btsdp.fAddNewDeviceWizard = TRUE; -// -// BOOL b = BluetoothSelectDevices( &btsdp ); -// if ( b ) -// { -// BLUETOOTH_DEVICE_INFO * pbtdi = btsdp.pDevices; -// for ( ULONG cDevice = 0; cDevice < btsdp.cNumDevices; cDevice ++ ) -// { -// if ( pbtdi->fAuthenticated || pbtdi->fRemembered ) -// { -// // -// // TODO: Do something usefull with the device info -// // -// } -// -// pbtdi = (BLUETOOTH_DEVICE_INFO *) ((LPBYTE)pbtdi + pbtdi->dwSize); -// } -// -// BluetoothSelectDevicesFree( &btsdp ); -// } -// -// *************************************************************************** - - -typedef struct _BLUETOOTH_COD_PAIRS { - ULONG ulCODMask; // ClassOfDevice mask to compare - LPCWSTR pcszDescription; // Descriptive string of mask - -} BLUETOOTH_COD_PAIRS; - -typedef BOOL (WINAPI *PFN_DEVICE_CALLBACK)(LPVOID pvParam, PBLUETOOTH_DEVICE_INFO pDevice); - -typedef struct _BLUETOOTH_SELECT_DEVICE_PARAMS { - DWORD dwSize; // IN sizeof this structure - - ULONG cNumOfClasses; // IN Number in prgClassOfDevice - if ZERO search for all devices - BLUETOOTH_COD_PAIRS * prgClassOfDevices; // IN Array of CODs to find. - - LPWSTR pszInfo; // IN If not NULL, sets the "information" text - - HWND hwndParent; // IN parent window - NULL == no parent - - BOOL fForceAuthentication; // IN If TRUE, authenication will be forced before returning - BOOL fShowAuthenticated; // IN If TRUE, authenticated devices will be shown in the picker - BOOL fShowRemembered; // IN If TRUE, remembered devices will be shown in the picker - BOOL fShowUnknown; // IN If TRUE, unknown devices that are not authenticated or "remember" will be shown. - - BOOL fAddNewDeviceWizard; // IN If TRUE, invokes the add new device wizard. - BOOL fSkipServicesPage; // IN If TRUE, skips the "Services" page in the wizard. - - PFN_DEVICE_CALLBACK pfnDeviceCallback; // IN If non-NULL, a callback that will be called for each device. If the - // the callback returns TRUE, the item will be added. If the callback is - // is FALSE, the item will not be shown. - LPVOID pvParam; // IN Parameter to be passed to pfnDeviceCallback as the pvParam. - - DWORD cNumDevices; // IN number calles wants - ZERO == no limit. - // OUT the number of devices returned. - - PBLUETOOTH_DEVICE_INFO pDevices; // OUT pointer to an array for BLUETOOTH_DEVICE_INFOs. - // call BluetoothSelectDevicesFree() to free - -} BLUETOOTH_SELECT_DEVICE_PARAMS; - -// -// Description: -// (See header above) -// -// Return Values: -// TRUE -// User selected a device. pbtsdp->pDevices points to valid data. -// Caller should check the fAuthenticated && fRemembered flags to -// determine which devices we successfuly authenticated or valid -// selections by the user. -// -// Use BluetoothSelectDevicesFree() to free the nessecary data -// such as pDevices only if this function returns TRUE. -// -// FALSE -// No valid data returned. Call GetLastError() for possible details -// of the failure. If GLE() is: -// -// ERROR_CANCELLED -// The user cancelled the request. -// -// ERROR_INVALID_PARAMETER -// The pbtsdp is NULL. -// -// ERROR_REVISION_MISMATCH -// The structure passed in as pbtsdp is of an unknown size. -// -// other WIN32 errors -// -BOOL -WINAPI -BluetoothSelectDevices( - BLUETOOTH_SELECT_DEVICE_PARAMS * pbtsdp - ); - -// -// Description: -// This function should only be called if BluetoothSelectDevices() returns -// TRUE. This function will free any memory and resource returned by the -// BluetoothSelectDevices() in the BLUETOOTH_SELECT_DEVICE_PARAMS -// structure. -// -// Return Values: -// TRUE -// Success. -// -// FALSE -// Nothing to free. -// -BOOL -WINAPI -BluetoothSelectDevicesFree( - BLUETOOTH_SELECT_DEVICE_PARAMS * pbtsdp - ); - -// *************************************************************************** -// -// Device Property Sheet -// -// *************************************************************************** - -// -// Description: -// Invokes the CPLs device info property sheet. -// -// Parameters: -// hwndParent -// HWND to parent the property sheet. -// -// pbtdi -// A pointer to a BLUETOOTH_DEVICE_INFO structure of the device -// to be displayed. -// -// Return Values: -// TRUE -// The property page was successfully displayed. -// -// FALSE -// Failure. The property page was not displayed. Check GetLastError -// for more details. -// -BOOL -WINAPI -BluetoothDisplayDeviceProperties( - HWND hwndParent, - BLUETOOTH_DEVICE_INFO * pbtdi - ); - - -// *************************************************************************** -// -// Radio Authentication -// -// *************************************************************************** - -// -// Description: -// Sends an authentication request to a remote device. -// -// There are two modes of operation. "Wizard mode" and "Blind mode." -// -// "Wizard mode" is invoked when the pszPasskey is NULL. This will cause -// the "Bluetooth Connection Wizard" to be invoked. The user will be -// prompted to enter a passkey during the wizard after which the -// authentication request will be sent. The user will see the success -// or failure of the authentication attempt. The user will also be -// given the oppurtunity to try to fix a failed authentication. -// -// "Blind mode" is invoked when the pszPasskey is non-NULL. This will -// cause the computer to send a authentication request to the remote -// device. No UI is ever displayed. The Bluetooth status code will be -// mapped to a Win32 Error code. -// -// Parameters: -// -// hwndParent -// The window to parent the authentication wizard. If NULL, the -// wizard will be parented off the desktop. -// -// hRadio -// A valid local radio handle or NULL. If NULL, then all radios will -// be tired. If any of the radios succeed, then the call will -// succeed. -// -// pbtdi -// BLUETOOTH_DEVICE_INFO record of the device to be authenticated. -// -// pszPasskey -// PIN to be used to authenticate the device. If NULL, then UI is -// displayed and the user steps through the authentication process. -// If not NULL, no UI is shown. The passkey is NOT NULL terminated. -// -// ulPasskeyLength -// Length of szPassKey in bytes. The length must be less than or -// equal to BLUETOOTH_MAX_PASSKEY_SIZE * sizeof(WCHAR). -// -// Return Values: -// -// ERROR_SUCCESS -// Success. -// -// ERROR_CANCELLED -// User aborted the operation. -// -// ERROR_INVALID_PARAMETER -// The device structure in pbtdi is invalid. -// -// ERROR_NO_MORE_ITEMS -// The device in pbtdi is already been marked as authenticated. -// -// other WIN32 error -// Failure. Return value is the error code. -// -// For "Blind mode," here is the current mapping of Bluetooth status -// code to Win32 error codes: -// -// { BTH_ERROR_SUCCESS, ERROR_SUCCESS }, -// { BTH_ERROR_NO_CONNECTION, ERROR_DEVICE_NOT_CONNECTED }, -// { BTH_ERROR_PAGE_TIMEOUT, WAIT_TIMEOUT }, -// { BTH_ERROR_HARDWARE_FAILURE, ERROR_GEN_FAILURE }, -// { BTH_ERROR_AUTHENTICATION_FAILURE, ERROR_NOT_AUTHENTICATED }, -// { BTH_ERROR_MEMORY_FULL, ERROR_NOT_ENOUGH_MEMORY }, -// { BTH_ERROR_CONNECTION_TIMEOUT, WAIT_TIMEOUT }, -// { BTH_ERROR_LMP_RESPONSE_TIMEOUT, WAIT_TIMEOUT }, -// { BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS, ERROR_REQ_NOT_ACCEP }, -// { BTH_ERROR_PAIRING_NOT_ALLOWED, ERROR_ACCESS_DENIED }, -// { BTH_ERROR_UNSPECIFIED_ERROR, ERROR_NOT_READY }, -// { BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION, ERROR_VC_DISCONNECTED }, -// -DWORD -WINAPI -BluetoothAuthenticateDevice( - HWND hwndParent, - HANDLE hRadio, - BLUETOOTH_DEVICE_INFO * pbtbi, - PWCHAR pszPasskey, - ULONG ulPasskeyLength - ); - -// -// Description: -// Allows the caller to prompt for multiple devices to be authenticated -// within a single instance of the "Bluetooth Connection Wizard." -// -// Parameters: -// -// hwndParent -// The window to parent the authentication wizard. If NULL, the -// wizard will be parented off the desktop. -// -// hRadio -// A valid local radio handle or NULL. If NULL, then all radios will -// be tired. If any of the radios succeed, then the call will -// succeed. -// -// cDevices -// Number of devices in the rgbtdi array. -// -// rgbtdi -// An array BLUETOOTH_DEVICE_INFO records of the devices to be -// authenticated. -// -// Return Values: -// -// ERROR_SUCCESS -// Success. Check the fAuthenticate flag on each of the devices. -// -// ERROR_CANCELLED -// User aborted the operation. Check the fAuthenticate flags on -// each device to determine if any of the devices were authenticated -// before the user cancelled the operation. -// -// ERROR_INVALID_PARAMETER -// One of the items in the array of devices is invalid. -// -// ERROR_NO_MORE_ITEMS -// All the devices in the array of devices are already been marked as -// being authenticated. -// -// other WIN32 error -// Failure. Return value is the error code. -// -DWORD -WINAPI -BluetoothAuthenticateMultipleDevices( - HWND hwndParent, - HANDLE hRadio, - DWORD cDevices, - BLUETOOTH_DEVICE_INFO * pbtdi - ); - -// *************************************************************************** -// -// Bluetooth Services -// -// *************************************************************************** - -#define BLUETOOTH_SERVICE_DISABLE 0x00 -#define BLUETOOTH_SERVICE_ENABLE 0x01 -#define BLUETOOTH_SERVICE_MASK ( BLUETOOTH_ENABLE_SERVICE | BLUETOOTH_DISABLE_SERVICE ) - -// -// Description: -// Enables/disables the services for a particular device. -// -// The system maintains a mapping of service guids to supported drivers for -// Bluetooth-enabled devices. Enabling a service installs the corresponding -// device driver. Disabling a service removes the corresponding device driver. -// -// If a non-supported service is enabled, a driver will not be installed. -// -// Parameters -// hRadio -// Handle of the local Bluetooth radio device. -// -// pbtdi -// Pointer to a BLUETOOTH_DEVICE_INFO record. -// -// pGuidService -// The service GUID on the remote device. -// -// dwServiceFlags -// Flags to adjust the service. -// BLUETOOTH_SERVICE_DISABLE - disable the service -// BLUETOOTH_SERVICE_ENABLE - enables the service -// -// Return Values: -// ERROR_SUCCESS -// The call was successful. -// -// ERROR_INVALID_PARAMETER -// dwServiceFlags are invalid. -// -// ERROR_SERVICE_DOES_NOT_EXIST -// The GUID in pGuidService is not supported. -// -// other WIN32 error -// The call failed. -// -DWORD -WINAPI -BluetoothSetServiceState( - HANDLE hRadio, - BLUETOOTH_DEVICE_INFO * pbtdi, - GUID * pGuidService, - DWORD dwServiceFlags - ); - -// -// Description: -// Enumerates the services guids enabled on a particular device. If hRadio -// is NULL, all device will be searched for the device and all the services -// enabled will be returned. -// -// Parameters: -// hRadio -// Handle of the local Bluetooth radio device. If NULL, it will search -// all the radios for the address in the pbtdi. -// -// pbtdi -// Pointer to a BLUETOOTH_DEVICE_INFO record. -// -// pcService -// On input, the number of records pointed to by pGuidServices. -// On output, the number of valid records return in pGuidServices. -// -// pGuidServices -// Pointer to memory that is at least *pcService in length. -// -// Return Values: -// ERROR_SUCCESS -// The call succeeded. pGuidServices is valid. -// -// ERROR_MORE_DATA -// The call succeeded. pGuidService contains an incomplete list of -// enabled service GUIDs. -// -// other WIN32 errors -// The call failed. -// -DWORD -WINAPI -BluetoothEnumerateInstalledServices( - HANDLE hRadio, - BLUETOOTH_DEVICE_INFO * pbtdi, - DWORD * pcServices, - GUID * pGuidServices - ); - -// -// Description: -// Change the discovery state of the local radio(s). -// If hRadio is NULL, all the radios will be set. -// -// Use BluetoothIsDiscoverable() to determine the radios current state. -// -// The system ensures that a discoverable system is connectable, thus -// the radio must allow incoming connections (see -// BluetoothEnableIncomingConnections) prior to making a radio -// discoverable. Failure to do so will result in this call failing -// (returns FALSE). -// -// Parameters: -// hRadio -// If not NULL, changes the state of a specific radio. -// If NULL, the API will interate through all the radios. -// -// fEnabled -// If FALSE, discovery will be disabled. -// -// Return Values -// TRUE -// State was successfully changed. If the caller specified NULL for -// hRadio, at least of the radios accepted the state change. -// -// FALSE -// State was not changed. If the caller specified NULL for hRadio, all -// of the radios did not accept the state change. -// -BOOL -WINAPI -BluetoothEnableDiscovery( - HANDLE hRadio, - BOOL fEnabled - ); - -// -// Description: -// Determines if the Bluetooth radios are discoverable. If there are -// multiple radios, the first one to say it is discoverable will cause -// this function to return TRUE. -// -// Parameters: -// hRadio -// Handle of the radio to check. If NULL, it will check all local -// radios. -// -// Return Values: -// TRUE -// A least one radio is discoverable. -// -// FALSE -// No radios are discoverable. -// -BOOL -WINAPI -BluetoothIsDiscoverable( - HANDLE hRadio - ); - -// -// Description: -// Enables/disables the state of a radio to accept incoming connections. -// If hRadio is NULL, all the radios will be set. -// -// Use BluetoothIsConnectable() to determine the radios current state. -// -// The system enforces that a radio that is not connectable is not -// discoverable too. The radio must be made non-discoverable (see -// BluetoothEnableDiscovery) prior to making a radio non-connectionable. -// Failure to do so will result in this call failing (returns FALSE). -// -// Parameters: -// hRadio -// If not NULL, changes the state of a specific radio. -// If NULL, the API will interate through all the radios. -// -// fEnabled -// If FALSE, incoming connection will be disabled. -// -// Return Values -// TRUE -// State was successfully changed. If the caller specified NULL for -// hRadio, at least of the radios accepted the state change. -// -// FALSE -// State was not changed. If the caller specified NULL for hRadio, all -// of the radios did not accept the state change. -// -BOOL -WINAPI -BluetoothEnableIncomingConnections( - HANDLE hRadio, - BOOL fEnabled - ); - -// -// Description: -// Determines if the Bluetooth radios are connectable. If there are -// multiple radios, the first one to say it is connectable will cause -// this function to return TRUE. -// -// Parameters: -// hRadio -// Handle of the radio to check. If NULL, it will check all local -// radios. -// -// Return Values: -// TRUE -// A least one radio is allowing incoming connections. -// -// FALSE -// No radios are allowing incoming connections. -// -BOOL -WINAPI -BluetoothIsConnectable( - HANDLE hRadio - ); - -// *************************************************************************** -// -// Authentication Registration -// -// *************************************************************************** - -typedef HANDLE HBLUETOOTH_AUTHENTICATION_REGISTRATION; - -typedef BOOL (*PFN_AUTHENTICATION_CALLBACK)(LPVOID pvParam, PBLUETOOTH_DEVICE_INFO pDevice); - -// -// Description: -// Registers a callback function to be called when a particular device -// requests authentication. The request is sent to the last application -// that requested authentication for a particular device. -// -// Parameters: -// pbtdi -// A pointer to a BLUETOOTH_DEVICE_INFO structure. The Bluetooth -// address will be used for comparision. -// -// phRegHandle -// A pointer to where the registration HANDLE value will be -// stored. Call BluetoothUnregisterAuthentication() to close -// the handle. -// -// pfnCallback -// The function that will be called when the authentication event -// occurs. This function should match PFN_AUTHENTICATION_CALLBACK's -// prototype. -// -// pvParam -// Optional parameter to be past through to the callback function. -// This can be anything the application was to define. -// -// Return Values: -// ERROR_SUCCESS -// Success. A valid registration handle was returned. -// -// ERROR_OUTOFMEMORY -// Out of memory. -// -// other Win32 error. -// Failure. The registration handle is invalid. -// -DWORD -WINAPI -BluetoothRegisterForAuthentication( - BLUETOOTH_DEVICE_INFO * pbtdi, - HBLUETOOTH_AUTHENTICATION_REGISTRATION * phRegHandle, - PFN_AUTHENTICATION_CALLBACK pfnCallback, - PVOID pvParam - ); - -// -// Description: -// Unregisters an authentication callback and closes the handle. See -// BluetoothRegisterForAuthentication() for more information about -// authentication registration. -// -// Parameters: -// hRegHandle -// Handle returned by BluetoothRegisterForAuthentication(). -// -// Return Value: -// TRUE -// The handle was successfully closed. -// -// FALSE -// The handle was not successfully closed. Check GetLastError for -// more details. -// -// ERROR_INVALID_HANDLE -// The handle is NULL. -// -// other Win32 errors. -// -BOOL -WINAPI -BluetoothUnregisterAuthentication( - HBLUETOOTH_AUTHENTICATION_REGISTRATION hRegHandle - ); - -// -// Description: -// This function should be called after receiving an authentication request -// to send the passkey response. -// -// Parameters: -// -// hRadio -// Optional handle to the local radio. If NULL, the function will try -// each radio until one succeeds. -// -// pbtdi -// A pointer to a BLUETOOTH_DEVICE_INFO structure describing the device -// being authenticated. This can be the same structure passed to the -// callback function. -// -// pszPasskey -// A pointer to UNICODE zero-terminated string of the passkey response -// that should be sent back to the authenticating device. -// -// Return Values: -// ERROR_SUCESS -// The device accepted the passkey response. The device is authenticated. -// -// ERROR_CANCELED -// The device denied the passkey reponse. This also will returned if there -// is a communications problem with the local radio. -// -// E_FAIL -// The device returned a failure code during authentication. -// -// other Win32 error codes -// -DWORD -WINAPI -BluetoothSendAuthenticationResponse( - HANDLE hRadio, - BLUETOOTH_DEVICE_INFO * pbtdi, - LPWSTR pszPasskey - ); - -// *************************************************************************** -// -// SDP Parsing Functions -// -// *************************************************************************** - -typedef struct _SDP_ELEMENT_DATA { - // - // Enumeration of SDP element types. Generic element types will have a - // specificType value other then SDP_ST_NONE. The generic types are: - // o SDP_TYPE_UINT - // o SDP_TYPE_INT - // o SDP_TYPE_UUID - // - SDP_TYPE type; - - // - // Specific types for the generic SDP element types. - // - SDP_SPECIFICTYPE specificType; - - // - // Union of all possible data types. type and specificType will indicate - // which field is valid. For types which do not have a valid specificType, - // specific type will be SDP_ST_NONE. - // - union { - // type == SDP_TYPE_INT - SDP_LARGE_INTEGER_16 int128; // specificType == SDP_ST_INT128 - LONGLONG int64; // specificType == SDP_ST_INT64 - LONG int32; // specificType == SDP_ST_INT32 - SHORT int16; // specificType == SDP_ST_INT16 - CHAR int8; // specificType == SDP_ST_INT8 - - // type == SDP_TYPE_UINT - SDP_ULARGE_INTEGER_16 uint128; // specificType == SDP_ST_UINT128 - ULONGLONG uint64; // specificType == SDP_ST_UINT64 - ULONG uint32; // specificType == SDP_ST_UINT32 - USHORT uint16; // specificType == SDP_ST_UINT16 - UCHAR uint8; // specificType == SDP_ST_UINT8 - - // type == SDP_TYPE_BOOLEAN - UCHAR booleanVal; - - // type == SDP_TYPE_UUID - GUID uuid128; // specificType == SDP_ST_UUID128 - ULONG uuid32; // specificType == SDP_ST_UUID32 - USHORT uuid16; // specificType == SDP_ST_UUID32 - - // type == SDP_TYPE_STRING - struct { - // raw string buffer, may not be encoded as ANSI, use - // BluetoothSdpGetString to convert the value if it is described - // by the base language attribute ID list - LPBYTE value; - - // raw length of the string, may not be NULL terminuated - ULONG length; - } string; - - // type == SDP_TYPE_URL - struct { - LPBYTE value; - ULONG length; - } url; - - // type == SDP_TYPE_SEQUENCE - struct { - // raw sequence, starts at sequence element header - LPBYTE value; - - // raw sequence length - ULONG length; - } sequence; - - // type == SDP_TYPE_ALTERNATIVE - struct { - // raw alternative, starts at alternative element header - LPBYTE value; - - // raw alternative length - ULONG length; - } alternative; - - } data; - -} SDP_ELEMENT_DATA, *PSDP_ELEMENT_DATA; - -// -// Description: -// Retrieves and parses the element found at pSdpStream -// -// Parameters: -// IN pSdpStream -// pointer to valid SDP stream -// -// IN cbSdpStreamLength -// length of pSdpStream in bytes -// -// OUT pData -// pointer to be filled in with the data of the SDP element at the -// beginning of pSdpStream -// -// Return Values: -// ERROR_INVALID_PARAMETER -// one of required parameters is NULL or the pSdpStream is invalid -// -// ERROR_SUCCESS -// the sdp element was parsed correctly -// -DWORD -WINAPI -BluetoothSdpGetElementData( - LPBYTE pSdpStream, - ULONG cbSdpStreamLength, - PSDP_ELEMENT_DATA pData - ); - -typedef HANDLE HBLUETOOTH_CONTAINER_ELEMENT; - -// -// Description: -// Iterates over a container stream, returning each elemetn contained with -// in the container element at the beginning of pContainerStream -// -// Parameters: -// IN pContainerStream -// pointer to valid SDP stream whose first element is either a sequence -// or alternative -// -// IN cbContainerlength -// length in bytes of pContainerStream -// -// IN OUT pElement -// Value used to keep track of location within the stream. The first -// time this function is called for a particular container, *pElement -// should equal NULL. Upon subsequent calls, the value should be -// unmodified. -// -// OUT pData -// pointer to be filled in with the data of the SDP element at the -// current element of pContainerStream -// -// Return Values: -// ERROR_SUCCESS -// The call succeeded, pData contains the data -// -// ERROR_NO_MORE_ITEMS -// There are no more items in the list, the caller should cease calling -// BluetoothSdpGetContainerElementData for this container. -// -// ERROR_INVALID_PARAMETER -// A required pointer is NULL or the container is not a valid SDP -// stream -// -// Usage example: -// -// HBLUETOOTH_CONTAINER_ELEMENT element; -// SDP_ELEMENT_DATA data; -// ULONG result; -// -// element = NULL; -// -// while (TRUE) { -// result = BluetoothSdpGetContainerElementData( -// pContainer, ulContainerLength, &element, &data); -// -// if (result == ERROR_NO_MORE_ITEMS) { -// // We are done -// break; -// } -// else if (result != ERROR_SUCCESS) { -// // error -// } -// -// // do something with data ... -// } -// -// -DWORD -WINAPI -BluetoothSdpGetContainerElementData( - LPBYTE pContainerStream, - ULONG cbContainerLength, - HBLUETOOTH_CONTAINER_ELEMENT* pElement, - PSDP_ELEMENT_DATA pData - ); - -// -// Description: -// Retrieves the attribute value for the given attribute ID. pRecordStream -// must be an SDP stream that is formatted as an SDP record, a SEQUENCE -// containing UINT16 + element pairs. -// -// Parameters: -// IN pRecordStream -// pointer to a valid SDP stream which is formatted as a singl SDP -// record -// -// IN cbRecordlnegh -// length of pRecordStream in bytes -// -// IN usAttributeId -// the attribute ID to search for. see bthdef.h for SDP_ATTRIB_Xxx -// values. -// -// OUT pAttributeData -// pointer that will contain the attribute ID's value -// -// Return Values: -// ERRROR_SUCCESS -// Call succeeded, pAttributeData contains the attribute value -// -// ERROR_INVALID_PARAMETER -// One of the required pointers was NULL, pRecordStream was not a valid -// SDP stream, or pRecordStream was not a properly formatted SDP record -// -// ERROR_FILE_NOT_FOUND -// usAttributeId was not found in the record -// -// Usage: -// -// ULONG result; -// SDP_DATA_ELEMENT data; -// -// result = BluetoothSdpGetAttributeValue( -// pRecordStream, cbRecordLength, SDP_ATTRIB_RECORD_HANDLE, &data); -// if (result == ERROR_SUCCESS) { -// printf("record handle is 0x%x\n", data.data.uint32); -// } -// -DWORD -WINAPI -BluetoothSdpGetAttributeValue( - LPBYTE pRecordStream, - ULONG cbRecordLength, - USHORT usAttributeId, - PSDP_ELEMENT_DATA pAttributeData - ); - -// -// These three fields correspond one to one with the triplets defined in the -// SDP specification for the language base attribute ID list. -// -typedef struct _SDP_STRING_TYPE_DATA { - // - // How the string is encoded according to ISO 639:1988 (E/F): "Code - // for the representation of names of languages". - // - USHORT encoding; - - // - // MIBE number from IANA database - // - USHORT mibeNum; - - // - // The base attribute where the string is to be found in the record - // - USHORT attributeId; - -} SDP_STRING_TYPE_DATA, *PSDP_STRING_TYPE_DATA; - -// -// Description: -// Converts a raw string embedded in the SDP record into a UNICODE string -// -// Parameters: -// IN pRecordStream -// a valid SDP stream which is formatted as an SDP record -// -// IN cbRecordLength -// length of pRecordStream in bytes -// -// IN pStringData -// if NULL, then the calling thread's locale will be used to search -// for a matching string in the SDP record. If not NUL, the mibeNum -// and attributeId will be used to find the string to convert. -// -// IN usStringOffset -// the SDP string type offset to convert. usStringOffset is added to -// the base attribute id of the string. SDP specification defined -// offsets are: STRING_NAME_OFFSET, STRING_DESCRIPTION_OFFSET, and -// STRING_PROVIDER_NAME_OFFSET (found in bthdef.h). -// -// OUT pszString -// if NULL, pcchStringLength will be filled in with the required number -// of characters (not bytes) to retrieve the converted string. -// -// IN OUT pcchStringLength -// Upon input, if pszString is not NULL, will contain the length of -// pszString in characters. Upon output, it will contain either the -// number of required characters including NULL if an error is returned -// or the number of characters written to pszString (including NULL). -// -// Return Values: -// ERROR_SUCCES -// Call was successful and pszString contains the converted string -// -// ERROR_MORE_DATA -// pszString was NULL or too small to contain the converted string, -// pccxhStringLength contains the required length in characters -// -// ERROR_INVALID_DATA -// Could not perform the conversion -// -// ERROR_NO_SYSTEM_RESOURCES -// Could not allocate memory internally to perform the conversion -// -// ERROR_INVALID_PARAMETER -// One of the rquired pointers was NULL, pRecordStream was not a valid -// SDP stream, pRecordStream was not a properly formatted record, or -// the desired attribute + offset was not a string. -// -// Other HRESULTs returned by COM -// -DWORD -WINAPI -BluetoothSdpGetString( - LPBYTE pRecordStream, - ULONG cbRecordLength, - PSDP_STRING_TYPE_DATA pStringData, - USHORT usStringOffset, - PWCHAR pszString, - PULONG pcchStringLength - ); - -// *************************************************************************** -// -// Raw Attribute Enumeration -// -// *************************************************************************** - -typedef BOOL (CALLBACK *PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK)( - ULONG uAttribId, - LPBYTE pValueStream, - ULONG cbStreamSize, - LPVOID pvParam - ); - -// -// Description: -// Enumerates through the SDP record stream calling the Callback function -// for each attribute in the record. If the Callback function returns -// FALSE, the enumeration is stopped. -// -// Return Values: -// TRUE -// Success! Something was enumerated. -// -// FALSE -// Failure. GetLastError() could be one of the following: -// -// ERROR_INVALID_PARAMETER -// pSDPStream or pfnCallback is NULL. -// -// ERROR_INVALID_DATA -// The SDP stream is corrupt. -// -// other Win32 errors. -// -#define BluetoothEnumAttributes BluetoothSdpEnumAttributes - -BOOL -WINAPI -BluetoothSdpEnumAttributes( - LPBYTE pSDPStream, - ULONG cbStreamSize, - PFN_BLUETOOTH_ENUM_ATTRIBUTES_CALLBACK pfnCallback, - LPVOID pvParam - ); - -#ifdef __cplusplus -} -#endif diff --git a/cpp/wiiscan/include/DelcomDLL.h b/cpp/wiiscan/include/DelcomDLL.h deleted file mode 100644 index eb48350..0000000 --- a/cpp/wiiscan/include/DelcomDLL.h +++ /dev/null @@ -1,125 +0,0 @@ -// Delcom Engineering -// DelcomDLL.h -// Version 0.6 -// 02/11/07 - -#ifndef DELCOMDLL_HEADER -#define DELCOMDLL_HEADER 1 - - -// defines -#define OFF 0 -#define ON 1 -#define FLASH 2 - -#define USBIODS 1 -#define USBDELVI 2 -#define USBNDSPY 3 - -#define GREENLED 0 -#define REDLED 1 -#define BLUELED 2 - -#define MaxDeviceLen 512 - -// Typedef -typedef struct _DeviceNameStruct{ - char DeviceName[MaxDeviceLen]; -} DeviceNameStruct, *pDeviceNameStruct; - - -typedef unsigned long DWORD; -typedef int BOOL; -typedef unsigned char BYTE; -typedef char CHAR; -typedef unsigned short WORD; -typedef void * HANDLE; -typedef CHAR *LPSTR, *PSTR; -typedef unsigned char uchar; -typedef unsigned int uint; - -typedef struct _PacketStruct{ - uchar Recipient; - uchar DeviceModel; - uchar MajorCmd; - uchar MinorCmd; - uchar DataLSB; - uchar DataMSB; - short Length; - uchar ExtData[8]; - } PacketStruct,*pPacketStruct; - - - - -// DLL Generic Functions -HANDLE DelcomGetDLLHandle(void); -double __stdcall DelcomGetDLLVersion(void); -DWORD __stdcall DelcomGetDLLDate(LPSTR); -DWORD __stdcall DelcomVerboseControl( DWORD Mode, LPSTR Header ); - -DWORD __stdcall DelcomGetNthDevice(DWORD, DWORD, LPSTR); -DWORD __stdcall DelcomScanDevices( DWORD, DeviceNameStruct[], DWORD ); -HANDLE __stdcall DelcomOpenDevice( LPSTR, DWORD); -DWORD __stdcall DelcomCloseDevice(HANDLE); -DWORD __stdcall DelcomGetDeviceCount( DWORD Type ); - -DWORD __stdcall DelcomReadDeviceVersion(HANDLE ); -DWORD __stdcall DelcomReadDeviceSerialNum(LPSTR, HANDLE ); -DWORD __stdcall DelcomSendPacket( HANDLE, pPacketStruct, pPacketStruct); - - -// USBDELVI - Visual Indicator Functions -DWORD __stdcall DelcomLEDControl( HANDLE hFile, DWORD Color, DWORD Mode ); -DWORD __stdcall DelcomEnableAutoConfirm(HANDLE hUsb, DWORD Mode); -DWORD __stdcall DelcomEnableAutoClear(HANDLE hUsb, DWORD Mode); -DWORD __stdcall DelcomBuzzer(HANDLE hUsb, uchar Mode, uchar Freq, uchar Repeat, uchar OnTime, uchar OffTime); -DWORD __stdcall DelcomLoadInitialPhaseDelay(HANDLE hUsb, BYTE Color, BYTE Delay); -DWORD __stdcall DelcomSyncLeds(HANDLE hUsb); -DWORD __stdcall DelcomLoadPreScalar(HANDLE hUsb, BYTE PreScalar); -DWORD __stdcall DelcomLoadLedFreqDuty(HANDLE hUsb, BYTE Color, BYTE Low, BYTE High); -DWORD __stdcall DelcomGetButtonStatus(HANDLE hUsb ); -DWORD __stdcall DelcomReadVersionNumber(HANDLE hUsb ); -DWORD __stdcall DelcomReadSerialNumber(HANDLE hUsb ); -DWORD __stdcall DelcomLEDPower( HANDLE hUsb, DWORD Color, DWORD Power ); - - - -// USBIODS - USB IO Functions -DWORD __stdcall DelcomWritePortPin(HANDLE hUsb, BYTE Port, BYTE Pin, BYTE Value ); -DWORD __stdcall DelcomWritePorts(HANDLE hUsb, BYTE Port0, BYTE Port1 ); -DWORD __stdcall DelcomReadPorts(HANDLE hUsb, BYTE* Port0, BYTE* Port1 ); - -DWORD __stdcall DelcomWrite64Bit(HANDLE hUsb, LPSTR DataExt ); -DWORD __stdcall DelcomRead64Bit(HANDLE hUsb, LPSTR DataExt ); - -DWORD __stdcall DelcomWriteI2C(HANDLE hUsb, BYTE CmdAdd, BYTE Length, LPSTR DataExt ); -DWORD __stdcall DelcomReadI2C(HANDLE hUsb, BYTE CmdAdd, BYTE Length, LPSTR DataExt ); -DWORD __stdcall DelcomSelReadI2C(HANDLE hUsb, BYTE SetAddCmd, BYTE Address, BYTE ReadCmd, BYTE Length, LPSTR DataExt ); -DWORD __stdcall DelcomWriteI2CEEPROM(HANDLE hUsb, DWORD Address, DWORD Length, BYTE CtrlCode, BYTE WriteDelay, LPSTR pData ); -DWORD __stdcall DelcomReadI2CEEPROM(HANDLE hUsb, DWORD Address, DWORD Length, BYTE CtrlCode, LPSTR pData ); - - -DWORD __stdcall DelcomRS232Ctrl(HANDLE hUsb, DWORD Mode, DWORD Value ); -DWORD __stdcall DelcomWriteRS232(HANDLE hUsb, DWORD Length, LPSTR DataExt ); -DWORD __stdcall DelcomReadRS232(HANDLE hUsb, LPSTR DataExt ); - - // SPI Commands -DWORD __stdcall DelcomSPIWrite( HANDLE hUsb, DWORD ClockCount, LPSTR pData); -DWORD __stdcall DelcomSPISetClock( HANDLE hUsb, DWORD ClockPeriod ); -DWORD __stdcall DelcomSPIRead(HANDLE hUsb, LPSTR pData); -DWORD __stdcall DelcomSPIWr8Read64( HANDLE hUsb, DWORD WrData, DWORD ClockCount, LPSTR pData); - - - -// USBNDSPY Functions -DWORD __stdcall DelcomNumericMode(HANDLE hUsb, BYTE Mode, BYTE Rate ); -DWORD __stdcall DelcomNumericScanRate(HANDLE hUsb, BYTE ScanRate ); -DWORD __stdcall DelcomNumericSetup(HANDLE hUsb, BYTE Digits ); -DWORD __stdcall DelcomNumericRaw(HANDLE hUsb, LPSTR Str ); -DWORD __stdcall DelcomNumericInteger(HANDLE hUsb, DWORD Number, DWORD Base ); -DWORD __stdcall DelcomNumericHexaDecimal(HANDLE hUsb, DWORD Number, DWORD Base ); -DWORD __stdcall DelcomNumericDouble(HANDLE hUsb, double Number, DWORD Base ); - - -#endif diff --git a/cpp/wiiscan/include/bthdef.h b/cpp/wiiscan/include/bthdef.h deleted file mode 100644 index 37b3f5d..0000000 --- a/cpp/wiiscan/include/bthdef.h +++ /dev/null @@ -1,858 +0,0 @@ -/*++ - -Copyright (c) 2000 Microsoft Corporation - -Module Name: - - bthdef.h - -Abstract: - - This module contains the Bluetooth common structures and definitions - -Author: - -Notes: - -Environment: - - Kernel mode only - - -Revision History: - - --*/ - -#ifndef __BTHDEF_H__ -#define __BTHDEF_H__ - -#ifndef GUID_DEFS_ONLY - #ifndef NO_BTHSDPDEF_INC - #include "bthsdpdef.h" - #endif // NO_BTHSDPDEF_INC -#endif // GUID_DEFS_ONLY - -#ifndef NO_GUID_DEFS - -// {0850302A-B344-4fda-9BE9-90576B8D46F0} -DEFINE_GUID(GUID_BTHPORT_DEVICE_INTERFACE, 0x850302a, 0xb344, 0x4fda, 0x9b, 0xe9, 0x90, 0x57, 0x6b, 0x8d, 0x46, 0xf0); - -// {EA3B5B82-26EE-450E-B0D8-D26FE30A3869} -DEFINE_GUID(GUID_BLUETOOTH_RADIO_IN_RANGE, 0xea3b5b82, 0x26ee, 0x450e, 0xb0, 0xd8, 0xd2, 0x6f, 0xe3, 0x0a, 0x38, 0x69); - -// {E28867C9-C2AA-4CED-B969-4570866037C4} -DEFINE_GUID(GUID_BLUETOOTH_RADIO_OUT_OF_RANGE, 0xe28867c9, 0xc2aa, 0x4ced, 0xb9, 0x69, 0x45, 0x70, 0x86, 0x60, 0x37, 0xc4); - -// BD198B7C-24AB-4B9A-8C0D-A8EA8349AA16 -DEFINE_GUID(GUID_BLUETOOTH_PIN_REQUEST, 0xbd198b7c, 0x24ab, 0x4b9a, 0x8c, 0x0d, 0xa8, 0xea, 0x83, 0x49, 0xaa, 0x16); - -// {7EAE4030-B709-4AA8-AC55-E953829C9DAA} -DEFINE_GUID(GUID_BLUETOOTH_L2CAP_EVENT, 0x7eae4030, 0xb709, 0x4aa8, 0xac, 0x55, 0xe9, 0x53, 0x82, 0x9c, 0x9d, 0xaa); - -// {FC240062-1541-49BE-B463-84C4DCD7BF7F} -DEFINE_GUID(GUID_BLUETOOTH_HCI_EVENT, 0xfc240062, 0x1541, 0x49be, 0xb4, 0x63, 0x84, 0xc4, 0xdc, 0xd7, 0xbf, 0x7f); - -// -// Bluetooth base UUID for service discovery -// -DEFINE_GUID(Bluetooth_Base_UUID, 0x00000000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); - -// -// UUID for the root of the browse group list -// - -DEFINE_GUID(SDP_PROTOCOL_UUID, 0x00000001, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(UDP_PROTOCOL_UUID, 0x00000002, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(RFCOMM_PROTOCOL_UUID, 0x00000003, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(TCP_PROTOCOL_UUID, 0x00000004, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(TCSBIN_PROTOCOL_UUID, 0x00000005, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(TCSAT_PROTOCOL_UUID, 0x00000006, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(OBEX_PROTOCOL_UUID, 0x00000008, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(IP_PROTOCOL_UUID, 0x00000009, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(FTP_PROTOCOL_UUID, 0x0000000A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HTTP_PROTOCOL_UUID, 0x0000000C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(WSP_PROTOCOL_UUID, 0x0000000E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(BNEP_PROTOCOL_UUID, 0x0000000F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(UPNP_PROTOCOL_UUID, 0x00000010, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HID_PROTOCOL_UUID, 0x00000011, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HCCC_PROTOCOL_UUID, 0x00000012, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HCDC_PROTOCOL_UUID, 0x00000014, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HN_PROTOCOL_UUID, 0x00000016, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AVCTP_PROTOCOL_UUID, 0x00000017, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AVDTP_PROTOCOL_UUID, 0x00000019, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(CMPT_PROTOCOL_UUID, 0x0000001B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(UDI_C_PLANE_PROTOCOL_UUID, 0x0000001D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(L2CAP_PROTOCOL_UUID, 0x00000100, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); - -#define SDP_PROTOCOL_UUID16 (0x0001) -#define UDP_PROTOCOL_UUID16 (0x0002) -#define RFCOMM_PROTOCOL_UUID16 (0x0003) -#define TCP_PROTOCOL_UUID16 (0x0004) -#define TCSBIN_PROTOCOL_UUID16 (0x0005) -#define TCSAT_PROTOCOL_UUID16 (0x0006) -#define OBEX_PROTOCOL_UUID16 (0x0008) -#define IP_PROTOCOL_UUID16 (0x0009) -#define FTP_PROTOCOL_UUID16 (0x000A) -#define HTTP_PROTOCOL_UUID16 (0x000C) -#define WSP_PROTOCOL_UUID16 (0x000E) -#define BNEP_PROTOCOL_UUID16 (0x000F) -#define UPNP_PROTOCOL_UUID16 (0x0010) -#define HID_PROTOCOL_UUID16 (0x0011) -#define HCCC_PROTOCOL_UUID16 (0x0012) -#define HCDC_PROTOCOL_UUID16 (0x0014) -#define HCN_PROTOCOL_UUID16 (0x0016) -#define AVCTP_PROTOCOL_UUID16 (0x0017) -#define AVDTP_PROTOCOL_UUID16 (0x0019) -#define CMPT_PROTOCOL_UUID16 (0x001B) -#define UDI_C_PLANE_PROTOCOL_UUID16 (0x001D) -#define L2CAP_PROTOCOL_UUID16 (0x0100) - -DEFINE_GUID(ServiceDiscoveryServerServiceClassID_UUID, 0x00001000, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(BrowseGroupDescriptorServiceClassID_UUID, 0x00001001, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(PublicBrowseGroupServiceClass_UUID, 0x00001002, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(SerialPortServiceClass_UUID, 0x00001101, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(LANAccessUsingPPPServiceClass_UUID, 0x00001102, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(DialupNetworkingServiceClass_UUID, 0x00001103, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(IrMCSyncServiceClass_UUID, 0x00001104, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(OBEXObjectPushServiceClass_UUID, 0x00001105, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(OBEXFileTransferServiceClass_UUID, 0x00001106, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(IrMCSyncCommandServiceClass_UUID, 0x00001107, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HeadsetServiceClass_UUID, 0x00001108, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(CordlessTelephonyServiceClass_UUID, 0x00001109, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AudioSourceServiceClass_UUID, 0x0000110A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AudioSinkServiceClass_UUID, 0x0000110B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AVRemoteControlTargetServiceClass_UUID, 0x0000110C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AdvancedAudioDistributionServiceClass_UUID,0x0000110D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AVRemoteControlServiceClass_UUID, 0x0000110E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(VideoConferencingServiceClass_UUID, 0x0000110F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(IntercomServiceClass_UUID, 0x00001110, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(FaxServiceClass_UUID, 0x00001111, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HeadsetAudioGatewayServiceClass_UUID, 0x00001112, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(WAPServiceClass_UUID, 0x00001113, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(WAPClientServiceClass_UUID, 0x00001114, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(PANUServiceClass_UUID, 0x00001115, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(NAPServiceClass_UUID, 0x00001116, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(GNServiceClass_UUID, 0x00001117, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(DirectPrintingServiceClass_UUID, 0x00001118, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(ReferencePrintingServiceClass_UUID, 0x00001119, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(ImagingServiceClass_UUID, 0x0000111A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(ImagingResponderServiceClass_UUID, 0x0000111B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(ImagingAutomaticArchiveServiceClass_UUID, 0x0000111C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(ImagingReferenceObjectsServiceClass_UUID, 0x0000111D, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HandsfreeServiceClass_UUID, 0x0000111E, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HandsfreeAudioGatewayServiceClass_UUID, 0x0000111F, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(DirectPrintingReferenceObjectsServiceClass_UUID, - 0x00001120, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(ReflectedUIServiceClass_UUID, 0x00001121, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(BasicPringingServiceClass_UUID, 0x00001122, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(PrintingStatusServiceClass_UUID, 0x00001123, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HumanInterfaceDeviceServiceClass_UUID, 0x00001124, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HardcopyCableReplacementServiceClass_UUID, 0x00001125, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HCRPrintServiceClass_UUID, 0x00001126, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(HCRScanServiceClass_UUID, 0x00001127, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(CommonISDNAccessServiceClass_UUID, 0x00001128, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(VideoConferencingGWServiceClass_UUID, 0x00001129, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(UDIMTServiceClass_UUID, 0x0000112A, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(UDITAServiceClass_UUID, 0x0000112B, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(AudioVideoServiceClass_UUID, 0x0000112C, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(PnPInformationServiceClass_UUID, 0x00001200, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(GenericNetworkingServiceClass_UUID, 0x00001201, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(GenericFileTransferServiceClass_UUID, 0x00001202, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(GenericAudioServiceClass_UUID, 0x00001203, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); -DEFINE_GUID(GenericTelephonyServiceClass_UUID, 0x00001204, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB); - -#define ServiceDiscoveryServerServiceClassID_UUID16 (0x1000) -#define BrowseGroupDescriptorServiceClassID_UUID16 (0x1001) -#define PublicBrowseGroupServiceClassID_UUID16 (0x1002) -#define SerialPortServiceClassID_UUID16 (0x1101) -#define LANAccessUsingPPPServiceClassID_UUID16 (0x1102) -#define DialupNetworkingServiceClassID_UUID16 (0x1103) -#define IrMCSyncServiceClassID_UUID16 (0x1104) -#define OBEXObjectPushServiceClassID_UUID16 (0x1105) -#define OBEXFileTransferServiceClassID_UUID16 (0x1106) -#define IrMcSyncCommandServiceClassID_UUID16 (0x1107) -#define HeadsetServiceClassID_UUID16 (0x1108) -#define CordlessServiceClassID_UUID16 (0x1109) -#define AudioSourceServiceClassID_UUID16 (0x110A) -#define AudioSinkSourceServiceClassID_UUID16 (0x110B) -#define AVRemoteControlTargetServiceClassID_UUID16 (0x110C) -#define AdvancedAudioDistributionServiceClassID_UUID16 (0x110D) -#define AVRemoteControlServiceClassID_UUID16 (0x110E) -#define VideoConferencingServiceClassID_UUID16 (0x110F) -#define IntercomServiceClassID_UUID16 (0x1110) -#define FaxServiceClassID_UUID16 (0x1111) -#define HeadsetAudioGatewayServiceClassID_UUID16 (0x1112) -#define WAPServiceClassID_UUID16 (0x1113) -#define WAPClientServiceClassID_UUID16 (0x1114) -#define PANUServiceClassID_UUID16 (0x1115) -#define NAPServiceClassID_UUID16 (0x1116) -#define GNServiceClassID_UUID16 (0x1117) -#define DirectPrintingServiceClassID_UUID16 (0x1118) -#define ReferencePrintingServiceClassID_UUID16 (0x1119) -#define ImagingServiceClassID_UUID16 (0x111A) -#define ImagingResponderServiceClassID_UUID16 (0x111B) -#define ImagingAutomaticArchiveServiceClassID_UUID16 (0x111C) -#define ImagingReferenceObjectsServiceClassID_UUID16 (0x111D) -#define HandsfreeServiceClassID_UUID16 (0x111E) -#define HandsfreeAudioGatewayServiceClassID_UUID16 (0x111F) -#define DirectPrintingReferenceObjectsServiceClassID_UUID16 \ - (0x1120) -#define ReflectsUIServiceClassID_UUID16 (0x1121) -#define BasicPrintingServiceClassID_UUID16 (0x1122) -#define PrintingStatusServiceClassID_UUID16 (0x1123) -#define HumanInterfaceDeviceServiceClassID_UUID16 (0x1124) -#define HardcopyCableReplacementServiceClassID_UUID16 (0x1125) -#define HCRPrintServiceClassID_UUID16 (0x1126) -#define HCRScanServiceClassID_UUID16 (0x1127) -#define CommonISDNAccessServiceClass_UUID16 (0x1128) -#define VideoConferencingGWServiceClass_UUID16 (0x1129) -#define UDIMTServiceClass_UUID16 (0x112A) -#define UDITAServiceClass_UUID16 (0x112B) -#define AudioVideoServiceClass_UUID16 (0x112C) - -#define PnPInformationServiceClassID_UUID16 (0x1200) -#define GenericNetworkingServiceClassID_UUID16 (0x1201) -#define GenericFileTransferServiceClassID_UUID16 (0x1202) -#define GenericAudioServiceClassID_UUID16 (0x1203) -#define GenericTelephonyServiceClassID_UUID16 (0x1204) - -#endif // NO_GUID_DEFS - -#ifndef GUID_DEFS_ONLY - -// -// max length of device friendly name. -// -#define BTH_MAX_NAME_SIZE (248) - -#define BTH_MAX_PIN_SIZE (16) -#define BTH_LINK_KEY_LENGTH (16) - -#define BTH_MFG_ERICSSON (0) -#define BTH_MFG_NOKIA (1) -#define BTH_MFG_INTEL (2) -#define BTH_MFG_IBM (3) -#define BTH_MFG_TOSHIBA (4) -#define BTH_MFG_3COM (5) -#define BTH_MFG_MICROSOFT (6) -#define BTH_MFG_LUCENT (7) -#define BTH_MFG_MOTOROLA (8) -#define BTH_MFG_INFINEON (9) -#define BTH_MFG_CSR (10) -#define BTH_MFG_SILICONWAVE (11) -#define BTH_MFG_DIGIANSWER (12) -#define BTH_MFG_TI (13) -#define BTH_MFG_PARTHUS (14) -#define BTH_MFG_BROADCOM (15) -#define BTH_MFG_MITEL (16) -#define BTH_MFG_WIDCOMM (17) -#define BTH_MFG_ZEEVO (18) -#define BTH_MFG_ATMEL (19) -#define BTH_MFG_MITSIBUSHI (20) -#define BTH_MFG_RTX_TELECOM (21) -#define BTH_MFG_KC_TECHNOLOGY (22) -#define BTH_MFG_NEWLOGIC (23) -#define BTH_MFG_TRANSILICA (24) -#define BTH_MFG_ROHDE_SCHWARZ (25) -#define BTH_MFG_TTPCOM (26) -#define BTH_MFG_SIGNIA (27) -#define BTH_MFG_CONEXANT (28) -#define BTH_MFG_QUALCOMM (29) -#define BTH_MFG_INVENTEL (30) -#define BTH_MFG_AVM_BERLIN (31) -#define BTH_MFG_BANDSPEED (32) -#define BTH_MFG_MANSELLA (33) -#define BTH_MFG_NEC (34) -#define BTH_MFG_WAVEPLUS_TECHNOLOGY_CO (35) -#define BTH_MFG_ALCATEL (36) -#define BTH_MFG_PHILIPS_SEMICONDUCTOR (37) -#define BTH_MFG_C_TECHNOLOGIES (38) -#define BTH_MFG_OPEN_INTERFACE (39) -#define BTH_MFG_RF_MICRO_DEVICES (40) -#define BTH_MFG_HITACHI (41) -#define BTH_MFG_SYMBOL_TECHNOLOGIES (42) -#define BTH_MFG_TENOVIS (43) -#define BTH_MFG_MACRONIX_INTERNATIONAL (44) -#define BTH_MFG_INTERNAL_USE (65535) - -typedef ULONGLONG BTH_ADDR, *PBTH_ADDR; -typedef ULONG BTH_COD, *PBTH_COD; -typedef ULONG BTH_LAP, *PBTH_LAP; - -#define BTH_ADDR_NULL ((ULONGLONG) 0x0000000000000000) - -#define NAP_MASK ((ULONGLONG) 0xFFFF00000000) -#define SAP_MASK ((ULONGLONG) 0x0000FFFFFFFF) - -#define NAP_BIT_OFFSET (8 * 4) -#define SAP_BIT_OFFSET (0) - -#define GET_NAP(_bth_addr) ((USHORT) (((_bth_addr) & NAP_MASK) >> NAP_BIT_OFFSET)) -#define GET_SAP(_bth_addr) ((ULONG) (((_bth_addr) & SAP_MASK) >> SAP_BIT_OFFSET)) - -#define SET_NAP(_nap) (((ULONGLONG) ((USHORT) (_nap))) << NAP_BIT_OFFSET) -#define SET_SAP(_sap) (((ULONGLONG) ((ULONG) (_sap))) << SAP_BIT_OFFSET) - -#define SET_NAP_SAP(_nap, _sap) (SET_NAP(_nap) | SET_SAP(_sap)) - -#define COD_FORMAT_BIT_OFFSET (0) -#define COD_MINOR_BIT_OFFSET (2) -#define COD_MAJOR_BIT_OFFSET (8 * 1) -#define COD_SERVICE_BIT_OFFSET (8 * 1 + 5) - -#define COD_FORMAT_MASK (0x000003) -#define COD_MINOR_MASK (0x0000FC) -#define COD_MAJOR_MASK (0x001F00) -#define COD_SERVICE_MASK (0xFFE000) - - -#define GET_COD_FORMAT(_cod) ( (_cod) & COD_FORMAT_MASK >> COD_FORMAT_BIT_OFFSET) -#define GET_COD_MINOR(_cod) (((_cod) & COD_MINOR_MASK) >> COD_MINOR_BIT_OFFSET) -#define GET_COD_MAJOR(_cod) (((_cod) & COD_MAJOR_MASK) >> COD_MAJOR_BIT_OFFSET) -#define GET_COD_SERVICE(_cod) (((_cod) & COD_SERVICE_MASK) >> COD_SERVICE_BIT_OFFSET) - -#define SET_COD_MINOR(_cod, _minor) (_cod) = ((_cod) & ~COD_MINOR_MASK) | ((_minor) << COD_MINOR_BIT_OFFSET) -#define SET_COD_MAJOR(_cod, _major) (_cod) = ((_cod) & ~COD_MAJOR_MASK) | ((_major) << COD_MAJOR_BIT_OFFSET) -#define SET_COD_SERVICE(_cod, _service) (_cod) = ((_cod) & ~COD_SERVICE_MASK) | ((_service) << COD_SERVICE_BIT_OFFSET) - -#define COD_VERSION (0x0) - -#define COD_SERVICE_LIMITED (0x0001) -#define COD_SERVICE_POSITIONING (0x0008) -#define COD_SERVICE_NETWORKING (0x0010) -#define COD_SERVICE_RENDERING (0x0020) -#define COD_SERVICE_CAPTURING (0x0040) -#define COD_SERVICE_OBJECT_XFER (0x0080) -#define COD_SERVICE_AUDIO (0x0100) -#define COD_SERVICE_TELEPHONY (0x0200) -#define COD_SERVICE_INFORMATION (0x0400) - -#define COD_SERVICE_VALID_MASK (COD_SERVICE_LIMITED | \ - COD_SERVICE_POSITIONING | \ - COD_SERVICE_NETWORKING | \ - COD_SERVICE_RENDERING | \ - COD_SERVICE_CAPTURING | \ - COD_SERVICE_OBJECT_XFER |\ - COD_SERVICE_AUDIO |\ - COD_SERVICE_TELEPHONY |\ - COD_SERVICE_INFORMATION) - -#define COD_SERVICE_MAX_COUNT (9) - -// -// Major class codes -// -#define COD_MAJOR_MISCELLANEOUS (0x00) -#define COD_MAJOR_COMPUTER (0x01) -#define COD_MAJOR_PHONE (0x02) -#define COD_MAJOR_LAN_ACCESS (0x03) -#define COD_MAJOR_AUDIO (0x04) -#define COD_MAJOR_PERIPHERAL (0x05) -#define COD_MAJOR_IMAGING (0x06) -#define COD_MAJOR_UNCLASSIFIED (0x1F) - -// -// Minor class codes specific to each major class -// -#define COD_COMPUTER_MINOR_UNCLASSIFIED (0x00) -#define COD_COMPUTER_MINOR_DESKTOP (0x01) -#define COD_COMPUTER_MINOR_SERVER (0x02) -#define COD_COMPUTER_MINOR_LAPTOP (0x03) -#define COD_COMPUTER_MINOR_HANDHELD (0x04) -#define COD_COMPUTER_MINOR_PALM (0x05) -#define COD_COMPUTER_MINOR_WEARABLE (0x06) - -#define COD_PHONE_MINOR_UNCLASSIFIED (0x00) -#define COD_PHONE_MINOR_CELLULAR (0x01) -#define COD_PHONE_MINOR_CORDLESS (0x02) -#define COD_PHONE_MINOR_SMART (0x03) -#define COD_PHONE_MINOR_WIRED_MODEM (0x04) - -#define COD_AUDIO_MINOR_UNCLASSIFIED (0x00) -#define COD_AUDIO_MINOR_HEADSET (0x01) -#define COD_AUDIO_MINOR_HANDS_FREE (0x02) -#define COD_AUDIO_MINOR_HEADSET_HANDS_FREE (0x03) -#define COD_AUDIO_MINOR_MICROPHONE (0x04) -#define COD_AUDIO_MINOR_LOUDSPEAKER (0x05) -#define COD_AUDIO_MINOR_HEADPHONES (0x06) -#define COD_AUDIO_MINOR_PORTABLE_AUDIO (0x07) -#define COD_AUDIO_MINOR_CAR_AUDIO (0x08) -#define COD_AUDIO_MINOR_SET_TOP_BOX (0x09) -#define COD_AUDIO_MINOR_HIFI_AUDIO (0x0A) -#define COD_AUDIO_MINOR_VCR (0x0B) -#define COD_AUDIO_MINOR_VIDEO_CAMERA (0x0C) -#define COD_AUDIO_MINOR_CAMCORDER (0x0D) -#define COD_AUDIO_MINOR_VIDEO_MONITOR (0x0E) -#define COD_AUDIO_MINOR_VIDEO_DISPLAY_LOUDSPEAKER \ - (0x0F) -#define COD_AUDIO_MINOR_VIDEO_DISPLAY_CONFERENCING \ - (0x10) -// #define COD_AUDIO_MINOR_RESERVED (0x11) -#define COD_AUDIO_MINOR_GAMING_TOY (0x12) - -#define COD_PERIPHERAL_MINOR_KEYBOARD_MASK (0x10) -#define COD_PERIPHERAL_MINOR_POINTER_MASK (0x20) - -#define COD_PERIPHERAL_MINOR_NO_CATEGORY (0x00) -#define COD_PERIPHERAL_MINOR_JOYSTICK (0x01) -#define COD_PERIPHERAL_MINOR_GAMEPAD (0x02) -#define COD_PERIPHERAL_MINOR_REMOTE_CONTROL (0x03) -#define COD_PERIPHERAL_MINOR_SENSING (0x04) - -#define COD_IMAGING_MINOR_DISPLAY_MASK (0x04) -#define COD_IMAGING_MINOR_CAMERA_MASK (0x08) -#define COD_IMAGING_MINOR_SCANNER_MASK (0x10) -#define COD_IMAGING_MINOR_PRINTER_MASK (0x20) - -// -// Cannot use GET_COD_MINOR for this b/c it is embedded in a different manner -// than the rest of the major classes -// - -#define COD_LAN_ACCESS_BIT_OFFSET (5) - -#define COD_LAN_MINOR_MASK (0x00001C) -#define COD_LAN_ACCESS_MASK (0x0000E0) - -#define GET_COD_LAN_MINOR(_cod) (((_cod) & COD_LAN_MINOR_MASK) >> COD_MINOR_BIT_OFFSET) -#define GET_COD_LAN_ACCESS(_cod) (((_cod) & COD_LAN_ACCESS_MASK) >> COD_LAN_ACCESS_BIT_OFFSET) - -// -// LAN access percent usage subcodes -// -#define COD_LAN_MINOR_UNCLASSIFIED (0x00) - -#define COD_LAN_ACCESS_0_USED (0x00) -#define COD_LAN_ACCESS_17_USED (0x01) -#define COD_LAN_ACCESS_33_USED (0x02) -#define COD_LAN_ACCESS_50_USED (0x03) -#define COD_LAN_ACCESS_67_USED (0x04) -#define COD_LAN_ACCESS_83_USED (0x05) -#define COD_LAN_ACCESS_99_USED (0x06) -#define COD_LAN_ACCESS_FULL (0x07) - -// -// Used as an initializer of LAP_DATA -// -#define LAP_GIAC_INIT { 0x33, 0x8B, 0x9E } -#define LAP_LIAC_INIT { 0x00, 0x8B, 0x9E } - -// -// General Inquiry Access Code. -// -#define LAP_GIAC_VALUE (0x009E8B33) - -// -// Limited Inquiry Access Code. -// -#define LAP_LIAC_VALUE (0x009E8B00) - -#define BTH_ADDR_IAC_FIRST (0x9E8B00) -#define BTH_ADDR_IAC_LAST (0x9E8B3f) -#define BTH_ADDR_LIAC (0x9E8B00) -#define BTH_ADDR_GIAC (0x9E8B33) - -typedef UCHAR BTHSTATUS, *PBTHSTATUS; - -#define BTH_ERROR(_btStatus) ((_btStatus) != BTH_ERROR_SUCCESS) -#define BTH_SUCCESS(_btStatus) ((_btStatus) == BTH_ERROR_SUCCESS) - -#define BTH_ERROR_SUCCESS (0x00) -#define BTH_ERROR_UNKNOWN_HCI_COMMAND (0x01) -#define BTH_ERROR_NO_CONNECTION (0x02) -#define BTH_ERROR_HARDWARE_FAILURE (0x03) -#define BTH_ERROR_PAGE_TIMEOUT (0x04) -#define BTH_ERROR_AUTHENTICATION_FAILURE (0x05) -#define BTH_ERROR_KEY_MISSING (0x06) -#define BTH_ERROR_MEMORY_FULL (0x07) -#define BTH_ERROR_CONNECTION_TIMEOUT (0x08) -#define BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS (0x09) -#define BTH_ERROR_MAX_NUMBER_OF_SCO_CONNECTIONS (0x0a) -#define BTH_ERROR_ACL_CONNECTION_ALREADY_EXISTS (0x0b) -#define BTH_ERROR_COMMAND_DISALLOWED (0x0c) -#define BTH_ERROR_HOST_REJECTED_LIMITED_RESOURCES (0x0d) -#define BTH_ERROR_HOST_REJECTED_SECURITY_REASONS (0x0e) -#define BTH_ERROR_HOST_REJECTED_PERSONAL_DEVICE (0x0f) -#define BTH_ERROR_HOST_TIMEOUT (0x10) -#define BTH_ERROR_UNSUPPORTED_FEATURE_OR_PARAMETER (0x11) -#define BTH_ERROR_INVALID_HCI_PARAMETER (0x12) -#define BTH_ERROR_REMOTE_USER_ENDED_CONNECTION (0x13) -#define BTH_ERROR_REMOTE_LOW_RESOURCES (0x14) -#define BTH_ERROR_REMOTE_POWERING_OFF (0x15) -#define BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION (0x16) -#define BTH_ERROR_REPEATED_ATTEMPTS (0x17) -#define BTH_ERROR_PAIRING_NOT_ALLOWED (0x18) -#define BTH_ERROR_UKNOWN_LMP_PDU (0x19) -#define BTH_ERROR_UNSUPPORTED_REMOTE_FEATURE (0x1a) -#define BTH_ERROR_SCO_OFFSET_REJECTED (0x1b) -#define BTH_ERROR_SCO_INTERVAL_REJECTED (0x1c) -#define BTH_ERROR_SCO_AIRMODE_REJECTED (0x1d) -#define BTH_ERROR_INVALID_LMP_PARAMETERS (0x1e) -#define BTH_ERROR_UNSPECIFIED_ERROR (0x1f) -#define BTH_ERROR_UNSUPPORTED_LMP_PARM_VALUE (0x20) -#define BTH_ERROR_ROLE_CHANGE_NOT_ALLOWED (0x21) -#define BTH_ERROR_LMP_RESPONSE_TIMEOUT (0x22) -#define BTH_ERROR_LMP_TRANSACTION_COLLISION (0x23) -#define BTH_ERROR_LMP_PDU_NOT_ALLOWED (0x24) -#define BTH_ERROR_ENCRYPTION_MODE_NOT_ACCEPTABLE (0x25) -#define BTH_ERROR_UNIT_KEY_NOT_USED (0x26) -#define BTH_ERROR_QOS_IS_NOT_SUPPORTED (0x27) -#define BTH_ERROR_INSTANT_PASSED (0x28) -#define BTH_ERROR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED (0x29) - -#define BTH_ERROR_UNSPECIFIED (0xFF) - -// -// Min, max, and default L2cap MTU. -// -#define L2CAP_MIN_MTU (48) -#define L2CAP_MAX_MTU (0xFFFF) -#define L2CAP_DEFAULT_MTU (672) - -// -// Max l2cap signal size (48) - size of signal header (4) -// -#define MAX_L2CAP_PING_DATA_LENGTH (44) -#define MAX_L2CAP_INFO_DATA_LENGTH (44) - -// -// the following two structures provides information about -// disocvered remote radios. -// - -#define BDIF_ADDRESS (0x00000001) -#define BDIF_COD (0x00000002) -#define BDIF_NAME (0x00000004) -#define BDIF_PAIRED (0x00000008) -#define BDIF_PERSONAL (0x00000010) -#define BDIF_CONNECTED (0x00000020) - -#define BDIF_VALID_FLAGS \ - (BDIF_ADDRESS | BDIF_COD | BDIF_NAME | BDIF_PAIRED | BDIF_PERSONAL | \ - BDIF_CONNECTED) - -typedef struct _BTH_DEVICE_INFO { - // - // Combination BDIF_Xxx flags - // - ULONG flags; - - // - // Address of remote device. - // - BTH_ADDR address; - - // - // Class Of Device. - // - BTH_COD classOfDevice; - - // - // name of the device - // - CHAR name[BTH_MAX_NAME_SIZE]; - -} BTH_DEVICE_INFO, *PBTH_DEVICE_INFO; - -// -// Buffer associated with GUID_BLUETOOTH_RADIO_IN_RANGE -// -typedef struct _BTH_RADIO_IN_RANGE { - // - // Information about the remote radio - // - BTH_DEVICE_INFO deviceInfo; - - // - // The previous flags value for the BTH_DEVICE_INFO. The receiver of this - // notification can compare the deviceInfo.flags and previousDeviceFlags - // to determine what has changed about this remote radio. - // - // For instance, if BDIF_NAME is set in deviceInfo.flags and not in - // previousDeviceFlags, the remote radio's has just been retrieved. - // - ULONG previousDeviceFlags; - -} BTH_RADIO_IN_RANGE, *PBTH_RADIO_IN_RANGE; - -// -// Buffer associated with GUID_BLUETOOTH_L2CAP_EVENT -// -typedef struct _BTH_L2CAP_EVENT_INFO { - // - // Remote radio address which the L2CAP event is associated with - // - BTH_ADDR bthAddress; - - // - // The PSM that is either being connected to or disconnected from - // - USHORT psm; - - // - // If != 0, then the channel has just been established. If == 0, then the - // channel has been destroyed. Notifications for a destroyed channel will - // only be sent for channels successfully established. - // - UCHAR connected; - - // - // If != 0, then the local host iniated the l2cap connection. If == 0, then - // the remote host initated the connection. This field is only valid if - // connect is != 0. - // - UCHAR initiated; - -} BTH_L2CAP_EVENT_INFO, *PBTH_L2CAP_EVENT_INFO; - -#define HCI_CONNNECTION_TYPE_ACL (1) -#define HCI_CONNNECTION_TYPE_SCO (2) - -// -// Buffer associated with GUID_BLUETOOTH_HCI_EVENT -// -typedef struct _BTH_HCI_EVENT_INFO { - // - // Remote radio address which the HCI event is associated with - // - BTH_ADDR bthAddress; - - // - // HCI_CONNNECTION_TYPE_XXX value - // - UCHAR connectionType; - - // - // If != 0, then the underlying connection to the remote radio has just - // been estrablished. If == 0, then the underlying conneciton has just been - // destroyed. - // - UCHAR connected; - -} BTH_HCI_EVENT_INFO, *PBTH_HCI_EVENT_INFO; - -#define MAX_UUIDS_IN_QUERY (12) - -#define BTH_VID_DEFAULT_VALUE (0xFFFF) - -#define SDP_ERROR_INVALID_SDP_VERSION (0x0001) -#define SDP_ERROR_INVALID_RECORD_HANDLE (0x0002) -#define SDP_ERROR_INVALID_REQUEST_SYNTAX (0x0003) -#define SDP_ERROR_INVALID_PDU_SIZE (0x0004) -#define SDP_ERROR_INVALID_CONTINUATION_STATE (0x0005) -#define SDP_ERROR_INSUFFICIENT_RESOURCES (0x0006) - -// -// Defined by windows to handle server errors that are not described by the -// above errors. Start at 0x0100 so we don't go anywhere near the spec -// defined values. -// - -// -// Success, nothing went wrong -// -#define SDP_ERROR_SUCCESS ((SDP_ERROR) 0x0000) - -// -// The SDP PDU or parameters other than the SDP stream response was not correct -// -#define SDP_ERROR_SERVER_INVALID_RESPONSE ((SDP_ERROR) 0x0100) - -// -// The SDP response stream did not parse correctly. -// -#define SDP_ERROR_SERVER_RESPONSE_DID_NOT_PARSE ((SDP_ERROR) 0x0200) - -// -// The SDP response stream was successfully parsed, but did not match the -// required format for the query. -// -#define SDP_ERROR_SERVER_BAD_FORMAT ((SDP_ERROR) 0x0300) - -// -// SDP was unable to send a continued query back to the server -// -#define SDP_ERROR_COULD_NOT_SEND_CONTINUE ((SDP_ERROR) 0x0400) - -// -// Server sent a response that was too large to fit in the caller's buffer. -// -#define SDP_ERROR_RESPONSE_TOO_LARGE ((SDP_ERROR) 0x0500) - - -#define SDP_ATTRIB_RECORD_HANDLE (0x0000) -#define SDP_ATTRIB_CLASS_ID_LIST (0x0001) -#define SDP_ATTRIB_RECORD_STATE (0x0002) -#define SDP_ATTRIB_SERVICE_ID (0x0003) -#define SDP_ATTRIB_PROTOCOL_DESCRIPTOR_LIST (0x0004) -#define SDP_ATTRIB_BROWSE_GROUP_LIST (0x0005) -#define SDP_ATTRIB_LANG_BASE_ATTRIB_ID_LIST (0x0006) -#define SDP_ATTRIB_INFO_TIME_TO_LIVE (0x0007) -#define SDP_ATTRIB_AVAILABILITY (0x0008) -#define SDP_ATTRIB_PROFILE_DESCRIPTOR_LIST (0x0009) -#define SDP_ATTRIB_DOCUMENTATION_URL (0x000A) -#define SDP_ATTRIB_CLIENT_EXECUTABLE_URL (0x000B) -#define SDP_ATTRIB_ICON_URL (0x000C) -#define SDP_ATTRIB_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST \ - (0x000D) - -// -// Attribute IDs in the range of 0x000D - 0x01FF are reserved for future use -// -#define SDP_ATTRIB_PROFILE_SPECIFIC (0x0200) - -#define LANG_BASE_LANGUAGE_INDEX (0x0000) -#define LANG_BASE_ENCODING_INDEX (0x0001) -#define LANG_BASE_OFFSET_INDEX (0x0002) -#define LANG_DEFAULT_ID (0x0100) - -#define STRING_NAME_OFFSET (0x0000) -#define STRING_DESCRIPTION_OFFSET (0x0001) -#define STRING_PROVIDER_NAME_OFFSET (0x0002) - -#define SDP_ATTRIB_SDP_VERSION_NUMBER_LIST (0x0200) -#define SDP_ATTRIB_SDP_DATABASE_STATE (0x0201) - -#define SDP_ATTRIB_BROWSE_GROUP_ID (0x0200) - -#define SDP_ATTRIB_CORDLESS_EXTERNAL_NETWORK (0x0301) - -#define SDP_ATTRIB_FAX_CLASS_1_SUPPORT (0x0302) -#define SDP_ATTRIB_FAX_CLASS_2_0_SUPPORT (0x0303) -#define SDP_ATTRIB_FAX_CLASS_2_SUPPORT (0x0304) -#define SDP_ATTRIB_FAX_AUDIO_FEEDBACK_SUPPORT (0x0305) - -#define SDP_ATTRIB_HEADSET_REMOTE_AUDIO_VOLUME_CONTROL (0x0302) - -#define SDP_ATTRIB_LAN_LPSUBNET (0x0200) - -#define SDP_ATTRIB_OBJECT_PUSH_SUPPORTED_FORMATS_LIST (0x0303) - -#define SDP_ATTRIB_SYNCH_SUPPORTED_DATA_STORES_LIST (0x0301) - -// this is in the assigned numbers doc, but it does not show up in any profile -#define SDP_ATTRIB_SERVICE_VERSION (0x0300) - -#define SDP_ATTRIB_PAN_NETWORK_ADDRESS (0x0306) -#define SDP_ATTRIB_PAN_WAP_GATEWAY (0x0307) -#define SDP_ATTRIB_PAN_HOME_PAGE_URL (0x0308) -#define SDP_ATTRIB_PAN_WAP_STACK_TYPE (0x0309) -#define SDP_ATTRIB_PAN_SECURITY_DESCRIPTION (0x030A) -#define SDP_ATTRIB_PAN_NET_ACCESS_TYPE (0x030B) -#define SDP_ATTRIB_PAN_MAX_NET_ACCESS_RATE (0x030C) - -#define SDP_ATTRIB_IMAGING_SUPPORTED_CAPABILITIES (0x0310) -#define SDP_ATTRIB_IMAGING_SUPPORTED_FEATURES (0x0311) -#define SDP_ATTRIB_IMAGING_SUPPORTED_FUNCTIONS (0x0312) -#define SDP_ATTRIB_IMAGING_TOTAL_DATA_CAPACITY (0x0313) - -#define SDP_ATTRIB_DI_SPECIFICATION_ID (0x0200) -#define SDP_ATTRIB_DI_VENDOR_ID (0x0201) -#define SDP_ATTRIB_DI_PRODUCT_ID (0x0202) -#define SDP_ATTRIB_DI_VERSION (0x0203) -#define SDP_ATTRIB_DI_PRIMARY_RECORD (0x0204) -#define SDP_ATTRIB_DI_VENDOR_ID_SOURCE (0x0205) - -#define SDP_ATTRIB_HID_DEVICE_RELEASE_NUMBER (0x0200) -#define SDP_ATTRIB_HID_PARSER_VERSION (0x0201) -#define SDP_ATTRIB_HID_DEVICE_SUBCLASS (0x0202) -#define SDP_ATTRIB_HID_COUNTRY_CODE (0x0203) -#define SDP_ATTRIB_HID_VIRTUAL_CABLE (0x0204) -#define SDP_ATTRIB_HID_RECONNECT_INITIATE (0x0205) -#define SDP_ATTRIB_HID_DESCRIPTOR_LIST (0x0206) -#define SDP_ATTRIB_HID_LANG_ID_BASE_LIST (0x0207) -#define SDP_ATTRIB_HID_SDP_DISABLE (0x0208) -#define SDP_ATTRIB_HID_BATTERY_POWER (0x0209) -#define SDP_ATTRIB_HID_REMOTE_WAKE (0x020A) -#define SDP_ATTRIB_HID_REPORT_LIST (0x020B) -#define SDP_ATTRIB_HID_SUPERVISION_TIMEOUT (0x020C) -#define SDP_ATTRIB_HID_NORMALLY_CONNECTABLE (0x020D) -#define SDP_ATTRIB_HID_BOOT_DEVICE (0x020E) - -// -// Profile specific values -// -#define CORDLESS_EXTERNAL_NETWORK_PSTN (0x01) -#define CORDLESS_EXTERNAL_NETWORK_ISDN (0x02) -#define CORDLESS_EXTERNAL_NETWORK_GSM (0x03) -#define CORDLESS_EXTERNAL_NETWORK_CDMA (0x04) -#define CORDLESS_EXTERNAL_NETWORK_ANALOG_CELLULAR (0x05) -#define CORDLESS_EXTERNAL_NETWORK_PACKET_SWITCHED (0x06) -#define CORDLESS_EXTERNAL_NETWORK_OTHER (0x07) - -#define OBJECT_PUSH_FORMAT_VCARD_2_1 (0x01) -#define OBJECT_PUSH_FORMAT_VCARD_3_0 (0x02) -#define OBJECT_PUSH_FORMAT_VCAL_1_0 (0x03) -#define OBJECT_PUSH_FORMAT_ICAL_2_0 (0x04) -#define OBJECT_PUSH_FORMAT_VNOTE (0x05) -#define OBJECT_PUSH_FORMAT_VMESSAGE (0x06) -#define OBJECT_PUSH_FORMAT_ANY (0xFF) - -#define SYNCH_DATA_STORE_PHONEBOOK (0x01) -#define SYNCH_DATA_STORE_CALENDAR (0x03) -#define SYNCH_DATA_STORE_NOTES (0x05) -#define SYNCH_DATA_STORE_MESSAGES (0x06) - -#define DI_VENDOR_ID_SOURCE_BLUETOOTH_SIG (0x0001) -#define DI_VENDOR_ID_SOURCE_USB_IF (0x0002) - -#define PSM_SDP (0x0001) -#define PSM_RFCOMM (0x0003) -#define PSM_TCS_BIN (0x0005) -#define PSM_TCS_BIN_CORDLESS (0x0007) -#define PSM_BNEP (0x000F) -#define PSM_HID_CONTROL (0x0011) -#define PSM_HID_INTERRUPT (0x0013) -#define PSM_AVCTP (0x0017) -#define PSM_AVDTP (0x0019) -#define PSM_UDI_C_PLANE (0x001D) - -// -// Strings -// -#define STR_ADDR_FMTA "(%02x:%02x:%02x:%02x:%02x:%02x)" -#define STR_ADDR_FMTW L"(%02x:%02x:%02x:%02x:%02x:%02x)" - -#define STR_ADDR_SHORT_FMTA "%04x%08x" -#define STR_ADDR_SHORT_FMTW L"%04x%08x" - -#if defined(UNICODE) || defined(BTH_KERN) - -#define STR_ADDR_FMT STR_ADDR_FMTW -#define STR_ADDR_SHORT_FMT STR_ADDR_SHORT_FMTW - -#else // UNICODE - -#define STR_ADDR_FMT STR_ADDR_FMTA -#define STR_ADDR_SHORT_FMT STR_ADDR_SHORT_FMTA - -#endif // UNICODE - -#define GET_BITS(field,offset,mask) ( ( (field) >> (offset) ) & (mask) ) -#define GET_BIT(field,offset) ( GET_BITS(field,offset,0x1) ) - -#define LMP_3_SLOT_PACKETS(x) (GET_BIT(x, 0)) -#define LMP_5_SLOT_PACKETS(x) (GET_BIT(x, 1)) -#define LMP_ENCRYPTION(x) (GET_BIT(x, 2)) -#define LMP_SLOT_OFFSET(x) (GET_BIT(x, 3)) -#define LMP_TIMING_ACCURACY(x) (GET_BIT(x, 4)) -#define LMP_SWITCH(x) (GET_BIT(x, 5)) -#define LMP_HOLD_MODE(x) (GET_BIT(x, 6)) -#define LMP_SNIFF_MODE(x) (GET_BIT(x, 7)) -#define LMP_PARK_MODE(x) (GET_BIT(x, 8)) -#define LMP_RSSI(x) (GET_BIT(x, 9)) -#define LMP_CHANNEL_QUALITY_DRIVEN_MODE(x) (GET_BIT(x,10)) -#define LMP_SCO_LINK(x) (GET_BIT(x,11)) -#define LMP_HV2_PACKETS(x) (GET_BIT(x,12)) -#define LMP_HV3_PACKETS(x) (GET_BIT(x,13)) -#define LMP_MU_LAW_LOG(x) (GET_BIT(x,14)) -#define LMP_A_LAW_LOG(x) (GET_BIT(x,15)) -#define LMP_CVSD(x) (GET_BIT(x,16)) -#define LMP_PAGING_SCHEME(x) (GET_BIT(x,17)) -#define LMP_POWER_CONTROL(x) (GET_BIT(x,18)) -#define LMP_TRANSPARENT_SCO_DATA(x) (GET_BIT(x,19)) -#define LMP_FLOW_CONTROL_LAG(x) (GET_BITS(x,20,0x3)) - -#endif // GUID_DEFS_ONLY - -#endif // __BTHDEF_H__ diff --git a/cpp/wiiscan/include/bthsdpdef.h b/cpp/wiiscan/include/bthsdpdef.h deleted file mode 100644 index 1764816..0000000 --- a/cpp/wiiscan/include/bthsdpdef.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef __BTHSDPDEF_H__ -#define __BTHSDPDEF_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -struct SDP_LARGE_INTEGER_16 { - ULONGLONG LowPart; - LONGLONG HighPart; -}; - - -struct SDP_ULARGE_INTEGER_16 { - ULONGLONG LowPart; - ULONGLONG HighPart; -}; - -typedef struct SDP_ULARGE_INTEGER_16 SDP_ULARGE_INTEGER_16, *PSDP_ULARGE_INTEGER_16, *LPSDP_ULARGE_INTEGER_16; -typedef struct SDP_LARGE_INTEGER_16 SDP_LARGE_INTEGER_16, *PSDP_LARGE_INTEGER_16, *LPSDP_LARGE_INTEGER_16; - -enum NodeContainerType { - NodeContainerTypeSequence, - NodeContainerTypeAlternative -}; - -typedef enum NodeContainerType NodeContainerType; - -typedef USHORT SDP_ERROR, *PSDP_ERROR; - -enum SDP_TYPE { - SDP_TYPE_NIL = 0x00, - SDP_TYPE_UINT = 0x01, - SDP_TYPE_INT = 0x02, - SDP_TYPE_UUID = 0x03, - SDP_TYPE_STRING = 0x04, - SDP_TYPE_BOOLEAN = 0x05, - SDP_TYPE_SEQUENCE = 0x06, - SDP_TYPE_ALTERNATIVE = 0x07, - SDP_TYPE_URL = 0x08, - SDP_TYPE_CONTAINER = 0x20 -}; -// 9 - 31 are reserved -typedef enum SDP_TYPE SDP_TYPE; - -// allow for a little easier type checking / sizing for integers and UUIDs -// ((SDP_ST_XXX & 0xF0) >> 4) == SDP_TYPE_XXX -// size of the data (in bytes) is encoded as ((SDP_ST_XXX & 0xF0) >> 8) -enum SDP_SPECIFICTYPE { - SDP_ST_NONE = 0x0000, - - SDP_ST_UINT8 = 0x0010, - SDP_ST_UINT16 = 0x0110, - SDP_ST_UINT32 = 0x0210, - SDP_ST_UINT64 = 0x0310, - SDP_ST_UINT128 = 0x0410, - - SDP_ST_INT8 = 0x0020, - SDP_ST_INT16 = 0x0120, - SDP_ST_INT32 = 0x0220, - SDP_ST_INT64 = 0x0320, - SDP_ST_INT128 = 0x0420, - - SDP_ST_UUID16 = 0x0130, - SDP_ST_UUID32 = 0x0220, - SDP_ST_UUID128 = 0x0430 -}; -typedef enum SDP_SPECIFICTYPE SDP_SPECIFICTYPE; - -typedef struct _SdpAttributeRange { - USHORT minAttribute; - USHORT maxAttribute; -} SdpAttributeRange; - - -typedef -#ifdef USE_MIDL_SYNTAX - [switch_type(unsigned short)] -#endif - union SdpQueryUuidUnion { -#ifdef USE_MIDL_SYNTAX - [case(SDP_ST_UUID128)] -#endif - GUID uuid128; - -#ifdef USE_MIDL_SYNTAX - [case(SDP_ST_UUID32)] -#endif _NTDDK_ - ULONG uuid32; - -#ifdef USE_MIDL_SYNTAX - [case(SDP_ST_UUID16)] -#endif _NTDDK_ - USHORT uuid16; -} SdpQueryUuidUnion; - -typedef struct _SdpQueryUuid { -#ifdef USE_MIDL_SYNTAX - [switch_is(uuidType)] -#endif - SdpQueryUuidUnion u; - - USHORT uuidType; -} SdpQueryUuid; - - -#ifdef __cplusplus -}; -#endif - -#endif // __BTHSDPDEF_H__ diff --git a/cpp/wiiscan/include/wiiuse.h b/cpp/wiiscan/include/wiiuse.h deleted file mode 100644 index bd3c27f..0000000 --- a/cpp/wiiscan/include/wiiuse.h +++ /dev/null @@ -1,710 +0,0 @@ -/* - * wiiuse - * - * Written By: - * Michael Laforest < para > - * Email: < thepara (--AT--) g m a i l [--DOT--] com > - * - * Copyright 2006-2007 - * - * This file is part of wiiuse. - * - * 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 3 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, see . - * - * $Header$ - * - */ - -/** - * @file - * - * @brief API header file. - * - * If this file is included from inside the wiiuse source - * and not from a third party program, then wiimote_internal.h - * is also included which extends this file. - */ - -#ifndef WIIUSE_H_INCLUDED -#define WIIUSE_H_INCLUDED - -#ifdef _WIN32 - /* windows */ - #include -#else - /* nix */ - #include -#endif - -#ifdef WIIUSE_INTERNAL_H_INCLUDED - #define WCONST -#else - #define WCONST const -#endif - -/* led bit masks */ -#define WIIMOTE_LED_NONE 0x00 -#define WIIMOTE_LED_1 0x10 -#define WIIMOTE_LED_2 0x20 -#define WIIMOTE_LED_3 0x40 -#define WIIMOTE_LED_4 0x80 - -/* button codes */ -#define WIIMOTE_BUTTON_TWO 0x0001 -#define WIIMOTE_BUTTON_ONE 0x0002 -#define WIIMOTE_BUTTON_B 0x0004 -#define WIIMOTE_BUTTON_A 0x0008 -#define WIIMOTE_BUTTON_MINUS 0x0010 -#define WIIMOTE_BUTTON_ZACCEL_BIT6 0x0020 -#define WIIMOTE_BUTTON_ZACCEL_BIT7 0x0040 -#define WIIMOTE_BUTTON_HOME 0x0080 -#define WIIMOTE_BUTTON_LEFT 0x0100 -#define WIIMOTE_BUTTON_RIGHT 0x0200 -#define WIIMOTE_BUTTON_DOWN 0x0400 -#define WIIMOTE_BUTTON_UP 0x0800 -#define WIIMOTE_BUTTON_PLUS 0x1000 -#define WIIMOTE_BUTTON_ZACCEL_BIT4 0x2000 -#define WIIMOTE_BUTTON_ZACCEL_BIT5 0x4000 -#define WIIMOTE_BUTTON_UNKNOWN 0x8000 -#define WIIMOTE_BUTTON_ALL 0x1F9F - -/* nunchul button codes */ -#define NUNCHUK_BUTTON_Z 0x01 -#define NUNCHUK_BUTTON_C 0x02 -#define NUNCHUK_BUTTON_ALL 0x03 - -/* classic controller button codes */ -#define CLASSIC_CTRL_BUTTON_UP 0x0001 -#define CLASSIC_CTRL_BUTTON_LEFT 0x0002 -#define CLASSIC_CTRL_BUTTON_ZR 0x0004 -#define CLASSIC_CTRL_BUTTON_X 0x0008 -#define CLASSIC_CTRL_BUTTON_A 0x0010 -#define CLASSIC_CTRL_BUTTON_Y 0x0020 -#define CLASSIC_CTRL_BUTTON_B 0x0040 -#define CLASSIC_CTRL_BUTTON_ZL 0x0080 -#define CLASSIC_CTRL_BUTTON_FULL_R 0x0200 -#define CLASSIC_CTRL_BUTTON_PLUS 0x0400 -#define CLASSIC_CTRL_BUTTON_HOME 0x0800 -#define CLASSIC_CTRL_BUTTON_MINUS 0x1000 -#define CLASSIC_CTRL_BUTTON_FULL_L 0x2000 -#define CLASSIC_CTRL_BUTTON_DOWN 0x4000 -#define CLASSIC_CTRL_BUTTON_RIGHT 0x8000 -#define CLASSIC_CTRL_BUTTON_ALL 0xFEFF - -/* guitar hero 3 button codes */ -#define GUITAR_HERO_3_BUTTON_STRUM_UP 0x0001 -#define GUITAR_HERO_3_BUTTON_YELLOW 0x0008 -#define GUITAR_HERO_3_BUTTON_GREEN 0x0010 -#define GUITAR_HERO_3_BUTTON_BLUE 0x0020 -#define GUITAR_HERO_3_BUTTON_RED 0x0040 -#define GUITAR_HERO_3_BUTTON_ORANGE 0x0080 -#define GUITAR_HERO_3_BUTTON_PLUS 0x0400 -#define GUITAR_HERO_3_BUTTON_MINUS 0x1000 -#define GUITAR_HERO_3_BUTTON_STRUM_DOWN 0x4000 -#define GUITAR_HERO_3_BUTTON_ALL 0xFEFF - - -/* wiimote option flags */ -#define WIIUSE_SMOOTHING 0x01 -#define WIIUSE_CONTINUOUS 0x02 -#define WIIUSE_ORIENT_THRESH 0x04 -#define WIIUSE_INIT_FLAGS (WIIUSE_SMOOTHING | WIIUSE_ORIENT_THRESH) - -#define WIIUSE_ORIENT_PRECISION 100.0f - -/* expansion codes */ -#define EXP_NONE 0 -#define EXP_NUNCHUK 1 -#define EXP_CLASSIC 2 -#define EXP_GUITAR_HERO_3 3 -#define EXP_BALANCE_BOARD 4 - -/* IR correction types */ -typedef enum ir_position_t { - WIIUSE_IR_ABOVE, - WIIUSE_IR_BELOW -} ir_position_t; - -/** - * @brief Check if a button is pressed. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_PRESSED(dev, button) ((dev->btns & button) == button) - -/** - * @brief Check if a button is being held. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is held, 0 if not. - */ -#define IS_HELD(dev, button) ((dev->btns_held & button) == button) - -/** - * @brief Check if a button is released on this event. \n\n - * This does not mean the button is not pressed, it means \n - * this button was just now released. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is released, 0 if not. - * - */ -#define IS_RELEASED(dev, button) ((dev->btns_released & button) == button) - -/** - * @brief Check if a button has just been pressed this event. - * @param dev Pointer to a wiimote_t or expansion structure. - * @param button The button you are interested in. - * @return 1 if the button is pressed, 0 if not. - */ -#define IS_JUST_PRESSED(dev, button) (IS_PRESSED(dev, button) && !IS_HELD(dev, button)) - -/** - * @brief Return the IR sensitivity level. - * @param wm Pointer to a wiimote_t structure. - * @param lvl [out] Pointer to an int that will hold the level setting. - * If no level is set 'lvl' will be set to 0. - */ -#define WIIUSE_GET_IR_SENSITIVITY(dev, lvl) \ - do { \ - if ((wm->state & 0x0200) == 0x0200) *lvl = 1; \ - else if ((wm->state & 0x0400) == 0x0400) *lvl = 2; \ - else if ((wm->state & 0x0800) == 0x0800) *lvl = 3; \ - else if ((wm->state & 0x1000) == 0x1000) *lvl = 4; \ - else if ((wm->state & 0x2000) == 0x2000) *lvl = 5; \ - else *lvl = 0; \ - } while (0) - -#define WIIUSE_USING_ACC(wm) ((wm->state & 0x020) == 0x020) -#define WIIUSE_USING_EXP(wm) ((wm->state & 0x040) == 0x040) -#define WIIUSE_USING_IR(wm) ((wm->state & 0x080) == 0x080) -#define WIIUSE_USING_SPEAKER(wm) ((wm->state & 0x100) == 0x100) - -#define WIIUSE_IS_LED_SET(wm, num) ((wm->leds & WIIMOTE_LED_##num) == WIIMOTE_LED_##num) - -/* - * Largest known payload is 21 bytes. - * Add 2 for the prefix and round up to a power of 2. - */ -#define MAX_PAYLOAD 32 - -/* - * This is left over from an old hack, but it may actually - * be a useful feature to keep so it wasn't removed. - */ -#ifdef WIN32 - #define WIIMOTE_DEFAULT_TIMEOUT 10 - #define WIIMOTE_EXP_TIMEOUT 10 -#endif - -typedef unsigned char byte; -typedef char sbyte; - -struct wiimote_t; -struct vec3b_t; -struct orient_t; -struct gforce_t; - - -/** - * @brief Callback that handles a read event. - * - * @param wm Pointer to a wiimote_t structure. - * @param data Pointer to the filled data block. - * @param len Length in bytes of the data block. - * - * @see wiiuse_init() - * - * A registered function of this type is called automatically by the wiiuse - * library when the wiimote has returned the full data requested by a previous - * call to wiiuse_read_data(). - */ -typedef void (*wiiuse_read_cb)(struct wiimote_t* wm, byte* data, unsigned short len); - - -/** - * @struct read_req_t - * @brief Data read request structure. - */ -struct read_req_t { - wiiuse_read_cb cb; /**< read data callback */ - byte* buf; /**< buffer where read data is written */ - unsigned int addr; /**< the offset that the read started at */ - unsigned short size; /**< the length of the data read */ - unsigned short wait; /**< num bytes still needed to finish read */ - byte dirty; /**< set to 1 if not using callback and needs to be cleaned up */ - - struct read_req_t* next; /**< next read request in the queue */ -}; - - -/** - * @struct vec2b_t - * @brief Unsigned x,y byte vector. - */ -typedef struct vec2b_t { - byte x, y; -} vec2b_t; - - -/** - * @struct vec3b_t - * @brief Unsigned x,y,z byte vector. - */ -typedef struct vec3b_t { - byte x, y, z; -} vec3b_t; - - -/** - * @struct vec3f_t - * @brief Signed x,y,z float struct. - */ -typedef struct vec3f_t { - float x, y, z; -} vec3f_t; - - -/** - * @struct orient_t - * @brief Orientation struct. - * - * Yaw, pitch, and roll range from -180 to 180 degrees. - */ -typedef struct orient_t { - float roll; /**< roll, this may be smoothed if enabled */ - float pitch; /**< pitch, this may be smoothed if enabled */ - float yaw; - - float a_roll; /**< absolute roll, unsmoothed */ - float a_pitch; /**< absolute pitch, unsmoothed */ -} orient_t; - - -/** - * @struct gforce_t - * @brief Gravity force struct. - */ -typedef struct gforce_t { - float x, y, z; -} gforce_t; - - -/** - * @struct accel_t - * @brief Accelerometer struct. For any device with an accelerometer. - */ -typedef struct accel_t { - struct vec3b_t cal_zero; /**< zero calibration */ - struct vec3b_t cal_g; /**< 1g difference around 0cal */ - - float st_roll; /**< last smoothed roll value */ - float st_pitch; /**< last smoothed roll pitch */ - float st_alpha; /**< alpha value for smoothing [0-1] */ -} accel_t; - - -/** - * @struct ir_dot_t - * @brief A single IR source. - */ -typedef struct ir_dot_t { - byte visible; /**< if the IR source is visible */ - - unsigned int x; /**< interpolated X coordinate */ - unsigned int y; /**< interpolated Y coordinate */ - - short rx; /**< raw X coordinate (0-1023) */ - short ry; /**< raw Y coordinate (0-767) */ - - byte order; /**< increasing order by x-axis value */ - - byte size; /**< size of the IR dot (0-15) */ -} ir_dot_t; - - -/** - * @enum aspect_t - * @brief Screen aspect ratio. - */ -typedef enum aspect_t { - WIIUSE_ASPECT_4_3, - WIIUSE_ASPECT_16_9 -} aspect_t; - - -/** - * @struct ir_t - * @brief IR struct. Hold all data related to the IR tracking. - */ -typedef struct ir_t { - struct ir_dot_t dot[4]; /**< IR dots */ - byte num_dots; /**< number of dots at this time */ - - enum aspect_t aspect; /**< aspect ratio of the screen */ - - enum ir_position_t pos; /**< IR sensor bar position */ - - unsigned int vres[2]; /**< IR virtual screen resolution */ - int offset[2]; /**< IR XY correction offset */ - int state; /**< keeps track of the IR state */ - - int ax; /**< absolute X coordinate */ - int ay; /**< absolute Y coordinate */ - - int x; /**< calculated X coordinate */ - int y; /**< calculated Y coordinate */ - - float distance; /**< pixel distance between first 2 dots*/ - float z; /**< calculated distance */ -} ir_t; - - -/** - * @struct speaker_t - */ -typedef struct speaker_t { - byte format; - byte rate; - byte freq; - byte vol; -} speaker_t; - - -/** - * @struct joystick_t - * @brief Joystick calibration structure. - * - * The angle \a ang is relative to the positive y-axis into quadrant I - * and ranges from 0 to 360 degrees. So if the joystick is held straight - * upwards then angle is 0 degrees. If it is held to the right it is 90, - * down is 180, and left is 270. - * - * The magnitude \a mag is the distance from the center to where the - * joystick is being held. The magnitude ranges from 0 to 1. - * If the joystick is only slightly tilted from the center the magnitude - * will be low, but if it is closer to the outter edge the value will - * be higher. - */ -typedef struct joystick_t { - struct vec2b_t max; /**< maximum joystick values */ - struct vec2b_t min; /**< minimum joystick values */ - struct vec2b_t center; /**< center joystick values */ - - float ang; /**< angle the joystick is being held */ - float mag; /**< magnitude of the joystick (range 0-1) */ -} joystick_t; - - -/** - * @struct nunchuk_t - * @brief Nunchuk expansion device. - */ -typedef struct nunchuk_t { - struct accel_t accel_calib; /**< nunchuk accelerometer calibration */ - struct joystick_t js; /**< joystick calibration */ - - int* flags; /**< options flag (points to wiimote_t.flags) */ - - byte btns; /**< what buttons have just been pressed */ - byte btns_held; /**< what buttons are being held down */ - byte btns_released; /**< what buttons were just released this */ - - float orient_threshold; /**< threshold for orient to generate an event */ - int accel_threshold; /**< threshold for accel to generate an event */ - - struct vec3b_t accel; /**< current raw acceleration data */ - struct orient_t orient; /**< current orientation on each axis */ - struct gforce_t gforce; /**< current gravity forces on each axis */ -} nunchuk_t; - - -/** - * @struct classic_ctrl_t - * @brief Classic controller expansion device. - */ -typedef struct classic_ctrl_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float r_shoulder; /**< right shoulder button (range 0-1) */ - float l_shoulder; /**< left shoulder button (range 0-1) */ - - struct joystick_t ljs; /**< left joystick calibration */ - struct joystick_t rjs; /**< right joystick calibration */ -} classic_ctrl_t; - - -/** - * @struct guitar_hero_3_t - * @brief Guitar Hero 3 expansion device. - */ -typedef struct guitar_hero_3_t { - short btns; /**< what buttons have just been pressed */ - short btns_held; /**< what buttons are being held down */ - short btns_released; /**< what buttons were just released this */ - - float whammy_bar; /**< whammy bar (range 0-1) */ - - struct joystick_t js; /**< joystick calibration */ -} guitar_hero_3_t; - - -/** - * @struct balance_board_data_t - * @brief Balance board l/r, t/b corner data data. - */ -typedef struct balance_board_data_t { - int tr; - int br; - int tl; - int bl; -} balance_board_data_t; - - -/** - * @struct balance_board_t - * @brief Balance board expansion device. - */ -typedef struct balance_board_t { - float tr; /** Top Right weight */ - float br; /** Bottom Right weight */ - float tl; /** Top Left weight */ - float bl; /** Bottom Left weight */ - struct balance_board_data_t raw; /** Raw actual values */ - struct balance_board_data_t cal_0; /** Calibration values at 0kg */ - struct balance_board_data_t cal_17; /** Calibration values at 17kg */ - struct balance_board_data_t cal_34; /** Calibration values at 34kg */ -} balance_board_t; - - -/** - * @struct expansion_t - * @brief Generic expansion device plugged into wiimote. - */ -typedef struct expansion_t { - int type; /**< type of expansion attached */ - - union { - struct nunchuk_t nunchuk; - struct classic_ctrl_t classic; - struct guitar_hero_3_t gh3; - struct balance_board_t bb; - }; -} expansion_t; - - -/** - * @enum win32_bt_stack_t - * @brief Available bluetooth stacks for Windows. - */ -typedef enum win_bt_stack_t { - WIIUSE_STACK_UNKNOWN, - WIIUSE_STACK_MS, - WIIUSE_STACK_BLUESOLEIL -} win_bt_stack_t; - - -/** - * @struct wiimote_state_t - * @brief Significant data from the previous event. - */ -typedef struct wiimote_state_t { - /* expansion_t */ - float exp_ljs_ang; - float exp_rjs_ang; - float exp_ljs_mag; - float exp_rjs_mag; - unsigned short exp_btns; - struct orient_t exp_orient; - struct vec3b_t exp_accel; - float exp_r_shoulder; - float exp_l_shoulder; - struct balance_board_data_t exp_bb_raw; - - /* ir_t */ - int ir_ax; - int ir_ay; - float ir_distance; - - struct orient_t orient; - unsigned short btns; - - struct vec3b_t accel; -} wiimote_state_t; - - -/** - * @enum WIIUSE_EVENT_TYPE - * @brief Events that wiiuse can generate from a poll. - */ -typedef enum WIIUSE_EVENT_TYPE { - WIIUSE_NONE = 0, - WIIUSE_EVENT, - WIIUSE_STATUS, - WIIUSE_CONNECT, - WIIUSE_DISCONNECT, - WIIUSE_UNEXPECTED_DISCONNECT, - WIIUSE_READ_DATA, - WIIUSE_NUNCHUK_INSERTED, - WIIUSE_NUNCHUK_REMOVED, - WIIUSE_CLASSIC_CTRL_INSERTED, - WIIUSE_CLASSIC_CTRL_REMOVED, - WIIUSE_GUITAR_HERO_3_CTRL_INSERTED, - WIIUSE_GUITAR_HERO_3_CTRL_REMOVED, - WIIUSE_BALANCE_BOARD_CTRL_INSERTED, - WIIUSE_BALANCE_BOARD_CTRL_REMOVED -} WIIUSE_EVENT_TYPE; - -/** - * @struct wiimote_t - * @brief Wiimote structure. - */ -typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ - - #ifndef WIN32 - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ - #else - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - WCONST int timeout; /**< read timeout */ - WCONST byte normal_timeout; /**< normal timeout */ - WCONST byte exp_timeout; /**< timeout for expansion handshake */ - #endif - - WCONST int state; /**< various state flags */ - WCONST byte leds; /**< currently lit leds */ - WCONST float battery_level; /**< battery level */ - - WCONST int flags; /**< options flag */ - - WCONST byte handshake_state; /**< the state of the connection handshake */ - - WCONST struct read_req_t* read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ - - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ - - WCONST struct ir_t ir; /**< IR data */ - WCONST struct speaker_t speaker; /**< speaker */ - - WCONST unsigned short btns; /**< what buttons have just been pressed */ - WCONST unsigned short btns_held; /**< what buttons are being held down */ - WCONST unsigned short btns_released; /**< what buttons were just released this */ - - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - WCONST int accel_threshold; /**< threshold for accel to generate an event */ - - WCONST struct wiimote_state_t lstate; /**< last saved state */ - - WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occured */ - WCONST byte event_buf[MAX_PAYLOAD]; /**< event buffer */ -} wiimote; - - -/***************************************** - * - * Include API specific stuff - * - *****************************************/ - -#ifdef _WIN32 - #define WIIUSE_EXPORT_DECL __declspec(dllexport) - #define WIIUSE_IMPORT_DECL __declspec(dllimport) -#else - #define WIIUSE_EXPORT_DECL - #define WIIUSE_IMPORT_DECL -#endif - -#ifdef WIIUSE_COMPILE_LIB - #define WIIUSE_EXPORT WIIUSE_EXPORT_DECL -#else - #define WIIUSE_EXPORT WIIUSE_IMPORT_DECL -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* wiiuse.c */ -WIIUSE_EXPORT extern const char* wiiuse_version(); - -WIIUSE_EXPORT extern struct wiimote_t** wiiuse_init(int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnected(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_cleanup(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_rumble(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_toggle_rumble(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_leds(struct wiimote_t* wm, int leds); -WIIUSE_EXPORT extern void wiiuse_motion_sensing(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern int wiiuse_read_data(struct wiimote_t* wm, byte* buffer, unsigned int offset, unsigned short len); -WIIUSE_EXPORT extern int wiiuse_write_data(struct wiimote_t* wm, unsigned int addr, byte* data, byte len); -WIIUSE_EXPORT extern void wiiuse_status(struct wiimote_t* wm); -WIIUSE_EXPORT extern struct wiimote_t* wiiuse_get_by_id(struct wiimote_t** wm, int wiimotes, int unid); -WIIUSE_EXPORT extern int wiiuse_set_flags(struct wiimote_t* wm, int enable, int disable); -WIIUSE_EXPORT extern float wiiuse_set_smooth_alpha(struct wiimote_t* wm, float alpha); -WIIUSE_EXPORT extern void wiiuse_set_bluetooth_stack(struct wiimote_t** wm, int wiimotes, enum win_bt_stack_t type); -WIIUSE_EXPORT extern void wiiuse_set_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_resync(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_set_timeout(struct wiimote_t** wm, int wiimotes, byte normal_timeout, byte exp_timeout); -WIIUSE_EXPORT extern void wiiuse_set_accel_threshold(struct wiimote_t* wm, int threshold); - -/* connect.c */ -WIIUSE_EXPORT extern int wiiuse_find(struct wiimote_t** wm, int max_wiimotes, int timeout); -WIIUSE_EXPORT extern int wiiuse_connect(struct wiimote_t** wm, int wiimotes); -WIIUSE_EXPORT extern void wiiuse_disconnect(struct wiimote_t* wm); - -/* events.c */ -WIIUSE_EXPORT extern int wiiuse_poll(struct wiimote_t** wm, int wiimotes); - -/* ir.c */ -WIIUSE_EXPORT extern void wiiuse_set_ir(struct wiimote_t* wm, int status); -WIIUSE_EXPORT extern void wiiuse_set_ir_vres(struct wiimote_t* wm, unsigned int x, unsigned int y); -WIIUSE_EXPORT extern void wiiuse_set_ir_position(struct wiimote_t* wm, enum ir_position_t pos); -WIIUSE_EXPORT extern void wiiuse_set_aspect_ratio(struct wiimote_t* wm, enum aspect_t aspect); -WIIUSE_EXPORT extern void wiiuse_set_ir_sensitivity(struct wiimote_t* wm, int level); - -/* nunchuk.c */ -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_orient_threshold(struct wiimote_t* wm, float threshold); -WIIUSE_EXPORT extern void wiiuse_set_nunchuk_accel_threshold(struct wiimote_t* wm, int threshold); - -/* speaker.c */ -WIIUSE_EXPORT extern void wiiuse_speaker_enable(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_disable(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_mute(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_unmute(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_activate(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_deactivate(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_format(struct wiimote_t* wm, byte format); -WIIUSE_EXPORT extern void wiiuse_speaker_volume(struct wiimote_t* wm, double vol); -WIIUSE_EXPORT extern void wiiuse_speaker_rate(struct wiimote_t* wm, byte rate, byte freq); -WIIUSE_EXPORT extern void wiiuse_speaker_config(struct wiimote_t* wm); -WIIUSE_EXPORT extern void wiiuse_speaker_data(struct wiimote_t* wm, byte* data, int len); - -#ifdef __cplusplus -} -#endif - - -#endif /* WIIUSE_H_INCLUDED */ - diff --git a/cpp/wiiscan/lib/DelcomDLL.lib b/cpp/wiiscan/lib/DelcomDLL.lib deleted file mode 100644 index 0c540c6..0000000 Binary files a/cpp/wiiscan/lib/DelcomDLL.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/advapi32.lib b/cpp/wiiscan/lib/advapi32.lib deleted file mode 100644 index 2812216..0000000 Binary files a/cpp/wiiscan/lib/advapi32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/comdlg32.lib b/cpp/wiiscan/lib/comdlg32.lib deleted file mode 100644 index 181fca1..0000000 Binary files a/cpp/wiiscan/lib/comdlg32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/gdi32.lib b/cpp/wiiscan/lib/gdi32.lib deleted file mode 100644 index 63172a5..0000000 Binary files a/cpp/wiiscan/lib/gdi32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/irprops.lib b/cpp/wiiscan/lib/irprops.lib deleted file mode 100644 index 1761118..0000000 Binary files a/cpp/wiiscan/lib/irprops.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/kernel32.lib b/cpp/wiiscan/lib/kernel32.lib deleted file mode 100644 index 77b0e53..0000000 Binary files a/cpp/wiiscan/lib/kernel32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/libcpmt.lib b/cpp/wiiscan/lib/libcpmt.lib deleted file mode 100644 index 85e91bb..0000000 Binary files a/cpp/wiiscan/lib/libcpmt.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/odbc32.lib b/cpp/wiiscan/lib/odbc32.lib deleted file mode 100644 index 1add151..0000000 Binary files a/cpp/wiiscan/lib/odbc32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/odbccp32.lib b/cpp/wiiscan/lib/odbccp32.lib deleted file mode 100644 index 0f2ef09..0000000 Binary files a/cpp/wiiscan/lib/odbccp32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/ole32.lib b/cpp/wiiscan/lib/ole32.lib deleted file mode 100644 index 17d6af8..0000000 Binary files a/cpp/wiiscan/lib/ole32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/oleaut32.lib b/cpp/wiiscan/lib/oleaut32.lib deleted file mode 100644 index 1955d00..0000000 Binary files a/cpp/wiiscan/lib/oleaut32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/shell32.lib b/cpp/wiiscan/lib/shell32.lib deleted file mode 100644 index b723320..0000000 Binary files a/cpp/wiiscan/lib/shell32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/user32.lib b/cpp/wiiscan/lib/user32.lib deleted file mode 100644 index eda26c0..0000000 Binary files a/cpp/wiiscan/lib/user32.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/uuid.lib b/cpp/wiiscan/lib/uuid.lib deleted file mode 100644 index f6e4ae2..0000000 Binary files a/cpp/wiiscan/lib/uuid.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/wiiuse.lib b/cpp/wiiscan/lib/wiiuse.lib deleted file mode 100644 index b9cc79d..0000000 Binary files a/cpp/wiiscan/lib/wiiuse.lib and /dev/null differ diff --git a/cpp/wiiscan/lib/winspool.lib b/cpp/wiiscan/lib/winspool.lib deleted file mode 100644 index 61cb936..0000000 Binary files a/cpp/wiiscan/lib/winspool.lib and /dev/null differ diff --git a/cpp/wiiscan/src/args.h b/cpp/wiiscan/src/args.h deleted file mode 100644 index 21ae941..0000000 --- a/cpp/wiiscan/src/args.h +++ /dev/null @@ -1,143 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __ARGS_H__ -#define __ARGS_H__ - -class args{ - private: - typedef vector t_args; - t_args m_args; - - void Remove(t_args::iterator itt1,int n) - { - t_args args2; - for(t_args::iterator itt2=m_args.begin();itt2!=m_args.end();++itt2) { - if(itt2!=itt1) args2.push_back(*itt2); - else {if (--n>0) ++itt1;} - } - m_args=args2; - } - - t_args::iterator Find(const string& v) - { - for(t_args::iterator itt=m_args.begin();itt!=m_args.end();++itt) { - if (v==*itt) return itt; - } - return m_args.end(); - } - - t_args::const_iterator Find(const string& v) const - { - for(t_args::const_iterator itt=m_args.begin();itt!=m_args.end();++itt) { - if (v==*itt) return itt; - } - return m_args.end(); - } - - public: - args(const int argc,char **argv,const bool printargs=false) - { - for(int i=0;i=size()) throw_("argument[] out of range"); - return m_args[i]; - } - - size_t size() const {return m_args.size();} - bool hasopt(const string& tag) const {return Find(tag)!=m_args.end();} - template T Totype(const size_t i) const {return totype((*this)[i]);} - template T Tounit(const size_t i) const { - const string& s=(*this)[i+1]; - #ifndef USE_UNITS - // fake test of units, primitive test, must be one-of: kpc, per_kpc and msun1E10 - if (s!="kpc/h" && s!="h/kpc" && s!="msun1E10/h") throw_("bad unit=<" + s + ">, can only handle units of type: kpc/h, h/kpc, and msun1E10/h"); - #endif - return totype((*this)[i] + " " + s); - } - - template - T parseval(const string& tag,const T& defaultval) - { - t_args::iterator itt=Find(tag); - if (itt==m_args.end() || itt+1==m_args.end()) return defaultval; - - const T v=totype(*(++itt)); - Remove(--itt,2); - - return v; - } - - template - pair parseval(const string& tag,const T& defaultval1,const R& defaultval2) - { - t_args::iterator itt=Find(tag); - if (itt==m_args.end() || itt+1==m_args.end() || itt+2==m_args.end()) return make_pair(defaultval1,defaultval2); - - const T v1=totype(*(++itt)); - const R v2=totype(*(++itt)); - Remove(----itt,3); - - return make_pair(v1,v2); - } - - template - T parseunit(const string& tag,const T& defaultval) - { - t_args::iterator itt=Find(tag); - if (itt==m_args.end() || itt+2==m_args.end()) return defaultval; - - const string s1=*(++itt); - const string s2=*(++itt); - const T v=totype(s1 + " " + s2); - Remove(----itt,3); - - return v; - } - - bool parseopt(const string& tag) - { - t_args::iterator itt=Find(tag); - if (itt==m_args.end()) return false; - Remove(itt,1); - - return true; - } - - int getoptindex(const string& tag) const - { - int n=0; - for(t_args::const_iterator itt=m_args.begin();itt!=m_args.end();++itt,++n) { - if (tag==*itt) { - assert( n>=0 && size_t(n)m_args.size() || i+n>m_args.size()) throw_("out of range"); - m_args.erase(m_args.begin()+i,m_args.begin()+i+n); - } - - friend ostream& operator<<(ostream& s,const args& v) - { - for(t_args::const_iterator itt=v.m_args.begin();itt!=v.m_args.end();++itt){ - s << *itt << " "; - } - return s; - } -}; - -#endif // __ARGS_H__ diff --git a/cpp/wiiscan/src/configfile.h b/cpp/wiiscan/src/configfile.h deleted file mode 100644 index 859b802..0000000 --- a/cpp/wiiscan/src/configfile.h +++ /dev/null @@ -1,143 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __CONFIGFILE_H__ -#define __CONFIGFILE_H__ - -class Configfile { - private: - typedef vector t_value; - t_value m_text; - map m_vals; - string m_rem; - string m_strip; - string m_file; - - void Load(istream &s) - { - if (!s) throw_("bad stream in configfile input operator"); - char buff[32*1024]; - bool ini=true; - while(s.getline(buff,32*1024)) { - const string b(strip(buff)); - if (ini && b!=m_rem + " Configfile_begin") throw_("bad stream in configfile input operator, missing begin tag"); - if (b==m_rem + " Configfile_end") return; - const string t(strip(removerems(b,m_rem))); - if (t.size()>0){ - m_text.push_back(t); - const size_t n=t.find_first_of("="); - istringstream s2(t.substr(0,n) + " " + (n==string::npos ? "" : t.substr(n+1))); - string v,k; - s2 >> k; - while ((s2 >> v)) m_vals[k].push_back(v); - } - ini=false; - } - throw_("bad stream in configfile input operator, missing end tag"); - } - - void Strip(const string& s) const - { - for(size_t i=0;i does not exist"); - Load(s); - } - - Configfile(istream& s,const string rem="%") : m_rem(rem) - { - if (!s) throw_("stream is invalid"); - Load(s); - } - - size_t size() const {return m_text.size();} - const string& operator[](const size_t n) const {assert(n::const_iterator itt=m_vals.find(key); return itt!=m_vals.end();} - void Save(const string& filename) {ofstream s(filename.c_str()); s << *this;} - - bool operator==(const Configfile& c) const - { - if (m_text!=c.m_text) return false; - else if (m_vals!=c.m_vals) return false; - else if (m_rem!=c.m_rem) return false; - else if (m_strip!=c.m_strip) return false; - else if (m_file!=c.m_file) return false; - return true; - } - bool operator!=(const Configfile& c) const {return !this->operator==(c);} - - void Checkfilechange() - { - if (m_file.empty()) return; - Configfile c(m_file); - if (c!=*this) *this=c; - } - - const t_value& Get(const string& key) const - { - map::const_iterator itt=m_vals.find(key); - if (itt==m_vals.end()) throw_("No such entry, <" + key + ">, in configfile"); - return itt->second; - } - - template const T Get(const string& key,const bool fullline=false) const - { - const t_value& v=Get(key); - assert( v.size()>0 ); - string s=v[0]; - if (fullline) for(size_t i=1;i(s); - return t; - } - - template const T Initialize(const string& key,const T valiueifnotfound,const bool fullline=false) const - { - if (!hasEntry(key)) return valiueifnotfound; - else return Get(key,fullline); - } - - template - pair GetConfig(const string& e) const - { - if (!hasEntry(e)) return make_pair(false,T()); - else return make_pair(true,Get(e,true)); - } - - template void Set(const string& key,const T& v) - { - t_value val; - val.push_back(tostring(v)); - m_vals[key]=val; - m_text.push_back(key + " " + val[0]); - } - - friend ostream& operator<<(ostream& s,const Configfile& x) - { - s << x.m_rem << " Configfile_begin\n"; - for(map::const_iterator itt1=x.m_vals.begin();itt1!=x.m_vals.end();++itt1){ - s << "\t" << itt1->first << " = "; - for(t_value::const_iterator itt2=itt1->second.begin();itt2!=itt1->second.end();++itt2) s << *itt2 << " "; - s << "\n"; - } - s << x.m_rem << " Configfile_end\n"; - // if (!s) throw_("bad stream in configfile output operator");, XXX throws in cout!? - return s; - } - - friend istream& operator>>(istream& s,Configfile& x){x.Load(s); return s;} -}; -#endif // __CONFIGFILE_H__ diff --git a/cpp/wiiscan/src/exception.h b/cpp/wiiscan/src/exception.h deleted file mode 100644 index 5721a37..0000000 --- a/cpp/wiiscan/src/exception.h +++ /dev/null @@ -1,197 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __EXCEPTION_H__ -#define __EXCEPTION_H__ - -// forward defs to funs.h -string Getlocaltime(); -size_t GetThreadId(); -int Message(const string& title,const string& msg,const int type=0); - -// simple class for debugging call stack -#ifdef _DEBUG - struct Stackinfo : public vector { - friend ostream& operator<<(ostream& s,const Stackinfo& x) - { - s << "Function stack {" << endl; - for(int i=x.size();i>0;--i){ - const string& f=x[i-1]; - s << " [" << i-1 << "]: " << f << "(...)" << endl; - } - return s << "}" << endl; - } - }; - - class Funstack { - private: - const string m_f; - static map m_s; - - Funstack(const Funstack&); - void operator=(const Funstack&); - - public: - Funstack(const string& f,const int line,const string& file) : m_f(f) {m_s[GetThreadId()].push_back(f);} - ~Funstack() - { - const size_t tid=GetThreadId(); - assert(m_s.find(tid)!=m_s.end()); - assert(m_s[tid].size()>0 && m_s[tid].back()==m_f); - m_s[tid].pop_back(); - } - - static const Stackinfo GetStack() - { - const size_t tid=GetThreadId(); - if (m_s.find(tid)==m_s.end()) return Stackinfo(); - else return m_s[tid]; - } - }; - map Funstack::m_s; // initialize static var - #define FUNSTACK Funstack __f_stack__(__FUNCTION__,__LINE__,__FILE__) -#else - #define FUNSTACK - #define DUMPSTACK(s) - struct Stackinfo { - friend ostream& operator<<(ostream& s,const Stackinfo& x) {return s;} - }; - class Funstack { - public: - static Stackinfo GetStack() {return Stackinfo();} - }; -#endif - -// tee like logger class -class Logger -{ -private: - //ostream* m_log; - string m_logfilename; - ofstream m_logfile; - ostream* m_log; - const bool m_logstdout,m_logstderr; - - Logger(const Logger&); - void operator=(const Logger&); - -public: - Logger(ostream* log,const bool logstdout=true,const bool logstderr=false) : m_log(log), m_logstdout(logstdout), m_logstderr(logstderr) {} - - void operator=(ostream* log){m_logfilename=""; m_logfile.close(); m_log=log;} - void open(const string& logfilename,const ios_base::openmode mode) - { - m_log=0; - if (m_logfile.is_open()) m_logfile.close(); - m_logfilename=logfilename; - m_logfile.open(m_logfilename.c_str(),mode); - if (!m_logfile) throw("cannot write to logfile <" + logfilename + ">"); // Exception uses logger class, so do not throw a nice Exception class here, use a plain throw - m_log=&m_logfile; - } - - void clear() - { - if (m_logfile.is_open()) m_logfile.close(); - m_logfile.open(m_logfilename.c_str()); - } - - template - friend Logger& operator<<(Logger& log,const T& t) - { - if(log.m_logstdout) cout << t; - if(log.m_logstderr) cerr << t; - if(log.m_log!=0) (*(log.m_log)) << t; - return log; - } - - // handle endl and like - friend Logger& operator<<(Logger& log,std::ostream& (*fn)(std::ostream&)) - { - if(log.m_logstdout) fn(cout); - if(log.m_logstderr) fn(cerr); - if(log.m_log!=0) fn(*(log.m_log)); - return log; - } - - void writelogheader(const string& msg) - { - if(m_log==0) return; - else{ - (*m_log) << "********************************************************" << endl; - (*m_log) << "** Logentry: " << msg << endl; - (*m_log) << "** Time: " << Getlocaltime(); - (*m_log) << "********************************************************" << endl; - } - } -}; - -// static global logging, default standand out -static Logger g_log(0,true,false); - -class Exception{ -private: - const string m_msg; - const string m_file; - const int m_line; - const Stackinfo m_stack; - -public: - Exception(const string msg,const string file,const int line,const Stackinfo s) : m_msg(msg), m_file(file), m_line(line), m_stack(s) {} - Exception(const char* msg,const string file,const int line,const Stackinfo s) : m_msg(msg), m_file(file), m_line(line), m_stack(s) {} - - inline static string FormatCompilerMsg(const string& file,const int line,const bool warnonly=false) - { - #ifdef WIN32 - return file + "(" + Exception::tostring(line) + ") : " + (warnonly ? "warning : " : "error : "); - #else - return file + ":" + Exception::tostring(line) + ": " + (warnonly ? "warning: " : "error: "); - #endif - } - - inline static void throw_fun(const string& msg,const string& file,const int line) - { - const string msg2=Exception::FormatCompilerMsg(file,line) + "throwing exception: " + msg; - g_log << msg2; - #ifdef _WINDOWS_ - const string f=tostring(Funstack::GetStack()); - const string msg3=msg2 + (f.size()>0 ? "\n\n" : "") + f.substr(0,300) + (f.size()>300 ? "\n..." : ""); - Message("Exception encountered...",msg3,0); - #endif - throw Exception(msg,file,line,Funstack::GetStack()); - } - - inline string Msg() const - { - return FormatCompilerMsg(m_file,m_line) + "Exception: " + m_msg; - } - - friend ostream& operator<<(ostream& os,const Exception& e) - { - return os << e.Msg() << endl << e.m_stack; - } - - template - static string tostring(const T& x) - { - ostringstream os; - os << x; - return os.str(); - } -}; - -#define throw_(msg) Exception::throw_fun(msg,__FILE__, __LINE__) -#define warn_(msg) cerr << Exception::FormatCompilerMsg(__FILE__, __LINE__,true) << msg << endl; - -#define CATCH_ALL\ - catch(const char* s) {cout.flush(); cerr << Exception::FormatCompilerMsg(__FILE__, __LINE__) << "caught exception chars: " << s;}\ - catch(const string& s) {cout.flush(); cerr << Exception::FormatCompilerMsg(__FILE__, __LINE__) << "caught exception string: " << s;}\ - catch(const Exception& s){cout.flush(); cerr << Exception::FormatCompilerMsg(__FILE__, __LINE__) << "caught Exception class: " << s;}\ - catch(...) {cout.flush(); cerr << Exception::FormatCompilerMsg(__FILE__, __LINE__) << "caught unknown exception";}\ - cerr << "...aborting" << endl; - -#endif // __EXCEPTION_H__ diff --git a/cpp/wiiscan/src/file.h b/cpp/wiiscan/src/file.h deleted file mode 100644 index 915f6ed..0000000 --- a/cpp/wiiscan/src/file.h +++ /dev/null @@ -1,208 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __FILE_H__ -#define __FILE_H__ - -inline bool FileExists(const std::string& f) -{ - ifstream s(f.c_str()); - return (!s)==false; -} - -inline void AssertFileExists(const std::string& f) -{ - if (!FileExists(f)) throw_("File <" + f + "> does not exist"); -} - -inline size_t FileSize(const std::string& f) -{ - AssertFileExists(f); - ifstream s(f.c_str()); - if (!s) throw_("Stream is bad (file <" + f + ">)"); - s.seekg(0,ios::end); - if (!s) throw_("Stream is bad (file <" + f + ">)"); - return s.tellg(); -} - -inline void AssertFileNotEmpty(const std::string& f) -{ - if (FileSize(f)==0) throw_("File <" + f + "> is empty"); -} - -inline size_t FileTime(const string& file) -{ - AssertFileExists(file); - const string t=System("date -r " + file + " +%s",true,true); // seconds since 1970-01-01 00:00:00 UTC - return totype(t); - // #include - // #include - // struct stat s; - // int n=stat(file.c_str(),&s); - // if (n!=0) throw_("cannot stat file <" + file + ">"); - // assert( sizeof(time_t)==sizeof(size_t) ); - // return s.st_mtime; -} - -inline bool isFileNewer(const string& file0,const string& file1) -{ - return FileTime(file0)>FileTime(file1); -} - -inline bool DirExists(const std::string& f) -{ - const string file=f + "/.dummy.txt"; - ofstream s(file.c_str()); - if(!s) return false; - s << "testfile"; - if(!s) return false; - s.close(); - return FileSize(file)==8; -} - -inline string MakeSuffix(const int n) -{ - assert(n>=0); - if (n<=9) return "00" + tostring(n); - else if (n<=99) return "0" + tostring(n); - else return tostring(n); -} - -template -void Readdata(const string& tok,istream& is,T& t) -{ - if (!is) throw_("Stream is bad"); - is >> t; - if (!is) throw_("Reading {" + tok + "} settings"); -} - -inline string Readline(istream& is) -{ - char buff[16*1024]; - is.getline(buff,16*1024); - return string(buff); -} - -template -inline T Readtyp(ifstream& s){ - T x; - s.read(reinterpret_cast(&x),sizeof(x)); - if(!s) throw_("bad stream"); - return x; -} - -inline string Readstring(ifstream& s){ - char c=0; - string t; - do{ - c=Readtyp(s); - if(c!=0) t+=c; - } - while (c!=0); - return t; -} - -template -inline vector Readbin(std::ifstream& s,const int size) -{ - if(!s) throw_("bad stream"); - vector x(size); - s.read(reinterpret_cast(&x.front()),x.size()*sizeof(T)); - if(!s) throw_( "bad write"); - return x; -} - -template -inline void Writetyp(ofstream& s,const T& x){ - s.write(reinterpret_cast(&x),sizeof(x)); - if(!s) throw_( "bad stream"); -} - -template -inline void Writebin(std::ofstream& s,const std::vector& x,const bool writetag) -{ - if(!s) throw_("bad stream"); - const size_t sz=x.size()*sizeof(T); - if(writetag){ - Writetyp(s,sz); - } - if(!s) throw_( "bad stream" ); - s.write(reinterpret_cast(&x.front()),sz); - if(!s) throw_( "bad write"); - if (writetag) Writetyp(s,sz); - if(!s) throw_( "bad stream"); -} - -template -inline void Writebin(std::ofstream& s,const std::map& x,const bool writetag) -{ - vector t; - vector r; - t.reserve(x.size()); - r.reserve(x.size()); - for(typename std::map::const_iterator itt=x.begin();itt!=x.end();++itt){ - t.push_back(itt->first); - r.push_back(itt->second); - } - if (writetag) { - Writetyp(s,x.size()); - Writetyp(s,static_cast(sizeof(T))); - Writetyp(s,static_cast(sizeof(R))); - } - Writebin(s,t,writetag); - Writebin(s,r,writetag); -} - -template -inline void Readbin(std::ifstream& s,vector& x) -{ - if(!s) throw_("bad stream"); - const size_t sz=Readtyp(s); - if(!s) throw_( "bad stream" ); - if(sz%sizeof(T)!=0) throw_("bad size tag"); - x.resize(sz/sizeof(T)); - s.read(reinterpret_cast(&x.front()),sz); - if(!s) throw_( "bad write"); - if (Readtyp(s)!=sz) throw_("bad size tag"); - if(!s) throw_( "bad stream"); -} - -template -inline void Readbin(std::ifstream& s,map& x) -{ - vector t; - vector r; - - const size_t sz=Readtyp(s); - const size_t szT=Readtyp(s); - const size_t szR=Readtyp(s); - - if (szT!=sizeof(T)) throw_("type T size mismatch in Readbin (map)"); - if (szR!=sizeof(R)) throw_("type R size mismatch in Readbin (map)"); - - Readbin(s,t); - Readbin(s,r); - if (t.size()!=r.size()) throw_("size mismatch in Readbin (map)"); - x.clear(); - for(size_t i=0;i -inline void Writeascii(const string& filename,const std::vector& x,const string& comment="",const char& newline='\n') -{ - ofstream s(filename.c_str()); - if(!s) throw_("bad file <" + filename + ">"); - s << "% Writeascii: size=" << x.size() << " " << comment << "\n"; - for(size_t i=0;i"); -} - -#endif // __FILE_H__ diff --git a/cpp/wiiscan/src/funs.h b/cpp/wiiscan/src/funs.h deleted file mode 100644 index f1a2c4f..0000000 --- a/cpp/wiiscan/src/funs.h +++ /dev/null @@ -1,413 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __FUNS_H__ -#define __FUNS_H__ - -#include -#include - -#define Unimplemented throw_("Function unimplemented") -#define Dontgethere throw_("Dontgethere") - -#ifndef NDEBUG - #define ON_DEBUG(a) a -#else - #define ON_DEBUG(a) -#endif - -#ifdef USE_FFTW - extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size); -#endif - -// Small template funs -template bool isinmap (const map& m,const T& t) {return m.size()>=2 && m.begin()->first<=t && t<(--m.end())->first;} -template const size_t getsteps(const T& r0,const T& r1,const T& rstep,const bool logarithmic) {size_t N=0; for(T r=r0;r(&one))); - if (big) s+=" BIGENDIAN"; - else s+=" LITENDIAN"; - - return s; -} - -inline string FormatCompilerMsg(const string& file,const int line) -{ - #ifdef WIN32 - return file + ":" + line + ":"; - #else - return file + "(" + line + ")"; - #endif -} - -#ifdef WIN32 - extern "C"{ - #ifdef _UNICODE - #pragma message("ERROR: toolsfun cannot handle unicode...giving up compilation"); - ERROR_complier - #endif - - #ifdef _AFXDLL - __declspec(dllimport) void* __stdcall GetCurrentThread(); - __declspec(dllimport) void* __stdcall GetCurrentThreadId(); - __declspec(dllimport) int __stdcall SetThreadPriority(void* hThread,int nPriority); - #else - //void* __stdcall GetCurrentThread(); - //void* __stdcall GetCurrentThreadId(); - //int __stdcall SetThreadPriority(void* hThread,int nPriority); - __declspec(dllimport) void* __stdcall GetCurrentThread(); - __declspec(dllimport) unsigned long __stdcall GetCurrentThreadId(); - __declspec(dllimport) int __stdcall SetThreadPriority(void* hThread,int nPriority); - __declspec(dllimport) int __stdcall GetThreadPriority(void* hThread); - __declspec(dllimport) unsigned int __stdcall WinExec(const char* lpCmdLine,unsigned int uCmdShow); - #ifndef _WINDOWS_ - __declspec(dllimport) unsigned int __stdcall MessageBox(void* hWnd,const char* lpText,const char* lpCaption,unsigned int Type); - __declspec(dllimport) unsigned long __stdcall GetCurrentDirectory(unsigned long nBufferLength,char* lpBuffer); - #endif - #endif - } -#else - int nice(int inc); -#endif - -inline int Message(const string& title,const string& msg,const int type) -{ -#ifdef WIN32 - // 0 = MB_OK - // 1 = MB_OKCANCEL - // 2 = MB_ABORTRETRYIGNORE - // 3 = MB_YESNOCANCEL - // 4 = MB_YESNO - // 5 = MB_RETRYCANCEL - // 6 = MB_CANCELTRYCONTINUE: if(WINVER >= 0x0500) - MessageBox(NULL,msg.c_str(),title.c_str(),type); -#else - Unimplemented; -#endif - return 1; -} -/* -string GetCurrentDir() -{ -#ifdef WIN32 - char buff[16*1024]; - if(GetCurrentDirectory(16*1024,buff)==0) throw_("GetCurrentDirectory() failed"); - return tostring(buff); -#else - Unimplemented; - return ""; -#endif -} -*/ - -inline void SetNiceLevel(const int level) -{ - #ifdef WIN32 - // THREAD_PRIORITY_ABOVE_NORMAL 1 Priority 1 point above the priority class. - // THREAD_PRIORITY_BELOW_NORMAL -1 Priority 1 point below the priority class. - // THREAD_PRIORITY_HIGHEST 2 Priority 2 points above the priority class. - // THREAD_PRIORITY_IDLE -15 Base priority of 1 for IDLE_PRIORITY_CLASS,... - // THREAD_PRIORITY_LOWEST -2 Priority 2 points below the priority class. - // THREAD_PRIORITY_NORMAL 0 Normal priority for the priority class. - // THREAD_PRIORITY_TIME_CRITICAL 15 Base priority of 15 for IDLE_PRIORITY_CLASS,... - if (level!=0 && level!=1 && level!=-1 && level!=2 && level!=-2 && level!=15 && level!=-15) throw_("wrong Win32 nice level, must be oneof -15,-2,-1,0,1,2,15"); - SetThreadPriority(GetCurrentThread(),-level); - assert( GetThreadPriority(GetCurrentThread())==-level ); - #else - const int n=nice(level); - if (n<0) throw_("Could not set nice level"); - #endif -} - -inline size_t GetThreadId() -{ - #ifdef WIN32 - assert( sizeof(size_t)==sizeof(unsigned long) ); - return GetCurrentThreadId(); - #else - // may be replaced by return 0; if phtread not found! - assert( sizeof(size_t)==sizeof(pthread_t) ); - const pthread_t p=pthread_self(); - size_t q=0; - memcpy(&q,&p,sizeof(q)); - return q; - #endif -} - -#ifdef TOOLSFUN_QUIET_WIN32_SYSTEM -#ifdef WIN32 - // make a special non-console system call, instead of the standard system() - // XXX SystemWin, does not wait for process to finish, CreatProc still create window - - int SystemWin(const string& cmd) - { - //ShellExecute, CreateProcess, WinExec or system - // HINSTANCE hi=ShellExecute(NULL,NULL,cmdx,"","",SW_SHOSNOACTIVATE); - // if (reinterpret_cast(hi)<32) MessageBox(NULL,(string("ShellExecute <") + cmd + "> failed").c_str(),"Error",0); - - // const string cmd2="\\\"" + cmd + "\\\""; // fix problem with spaces in executable, not working yet - unsigned int r=WinExec(cmd.c_str(),4); - return r<32 ? -1 : 0; - } - - bool CreateProc(const string& cmd,const bool throwexception=true,const bool waitforprocesstofinish=true) - { - STARTUPINFO s; - PROCESS_INFORMATION p; - memset(&s,0,sizeof(s)); - memset(&p,0,sizeof(p)); - s.cb=sizeof(s); - - // to avoid const cast of char* in CreateProcess - char cmdx[16*1024]; - strcpy_s(cmdx,16*1024,cmd.c_str()); - - const int r=CreateProcess(0,cmdx,0,0,false,CREATE_DEFAULT_ERROR_MODE,0,0,&s,&p); - if (r!=0) {if(waitforprocesstofinish) WaitForSingleObject(p.hProcess,INFINITE);} - else { - if (throwexception) throw_(string("CreateProcess() failed with return code <") + GetLastError() + ">"); - else return false; - } - - // Release handles - assert(r!=0); - CloseHandle(p.hProcess); - CloseHandle(p.hThread); - return true; - } -#endif -#endif - -inline string System(const string& cmd,const bool throwexception=true,const bool captureoutput=false,int* pret=0) -{ - if (!captureoutput){ - #ifdef TOOLSFUN_QUIET_WIN32_SYSTEM - const int n=SystemWin(cmd); - #else - const int n=system(cmd.c_str()); - #endif - if (n!=0 && throwexception) throw_(string("system command failed with code=") + n + " cmd=<" + cmd + ">"); - if (pret!=0) *pret=n; - return ""; - } else { - #ifdef WIN32 - const string rm="del "; - char tmp[1024]; - if (tmpnam(tmp)) throw_("error in creating win32 temp name"); - const string file(tmp); - #else - const string rm="rm "; - const string file=tmpnam("tempfile"); - #endif - ifstream s1(file.c_str()); - if(s1) { - s1.close(); - System((rm + file).c_str(),true,false); - } - System(cmd + " > " + file,throwexception,false,pret); - - string t; - char buff[16*1024]; - ifstream s2(file.c_str()); - while(s2) { - s2.getline(buff,16*1024); - if (s2) t += buff; - } - s2.close(); - System((rm + file).c_str(),true,false); - return t; - } -} - -string Getlocaltime() -{ - FUNSTACK; - time_t rawtime; - time(&rawtime); - struct tm* timeinfo; - timeinfo = localtime(&rawtime); - return asctime(timeinfo); -} - -class timer -{ - private: - double m_t,m_cpu_t; - double* m_addt; - mutable double m_last_t,m_last_eta; - - static double gettime() - { - #ifdef WIN32 - return 1.0*clock()/CLOCKS_PER_SEC; // use low-res clock - // FILETIME ft; - // unsigned __int64 tmpres = 0; - // - // GetSystemTimeAsFileTime(&ft); - // - // tmpres |= ft.dwHighDateTime; - // tmpres <<= 32; - // tmpres |= ft.dwLowDateTime; - // - // converting file time to unix epoch - // tmpres -= DELTA_EPOCH_IN_MICROSECS; - // tmpres /= 10; // convert into microseconds - // tv->tv_sec = (long)(tmpres / 1000000UL); - // tv->tv_usec = (long)(tmpres % 1000000UL); - #else - struct timeval tv; - gettimeofday(&tv,NULL); - return tv.tv_sec + static_cast(tv.tv_usec)/1000000; - #endif - } - - static double getcputime() - { - static const double f=1.0/CLOCKS_PER_SEC; - return f*clock(); - } - - template - static double Remaining(const double t,const T& n,const T& N) - { - if (n>=N || N<=T(0)) throw_("value out of range in timer::Remaining, n>=N or N<=0, n=" + tostring(n) + " N=" + tostring(N)); - const double p=static_cast(n/T(1)+1)/(N/T(1)); - const double p2=p>0 ? t/p : 0; - return p2>t ? p2-t : 0; - } - - public: - timer() : m_t(gettime()), m_cpu_t(getcputime()), m_addt(0), m_last_t(-1), m_last_eta(-1) {} - timer(double& t) : m_t(gettime()), m_cpu_t(getcputime()), m_addt(&t), m_last_t(-1), m_last_eta(-1) {} - ~timer() {if (m_addt!=0) (*m_addt) += elapsed();} - - void reset () {m_t=gettime(); m_cpu_t=getcputime(); m_last_t=-1; m_last_eta=-1;} - double elapsed() const {return gettime()-m_t;} - double cputime() const {return getcputime()-m_cpu_t;} - - static string ToHMS(const double& t) - { - assert( t>=0 ); - const unsigned int it=static_cast(t+.5); - const unsigned int hours=it/(60*60); - const unsigned int mins=(it-hours*60*60)/(60); - const unsigned int secs=(it-hours*60*60-mins*60); - assert( secs<60 && mins<60); - return tostring(hours) + ":" + (mins<10 ? "0": "") + tostring(mins) + ":" + (secs<10 ? "0": "") + tostring(secs); - } - - template static inline int Topercent(const T x,const T N,const int decimals=-1) - { - assert(x(x/T(1))/(N/T(1)); - if (decimals>0) pf=static_cast(pf*decimals)/(1.0*decimals); - return static_cast(pf*100+.5); - } - - template void ToEta(const T& n,const T& N,ostream& s,const double timeprintsteps=30,const bool verboseprint=false) const - { - if (n>=N) return; - assert( ntimeprintsteps) { - const double f=timeprintsteps*60; - const double r=Remaining(t,n,N); - if (m_last_eta<0 || rf && e>f) /*|| (m_last_eta>0 && r>1.2*m_last_eta) */ ){ - time_t tm; - time(&tm); - const string systime=ctime(&tm); - if (m_last_eta<0) s << "Current system time: " << systime; - tm += static_cast(r); - const string eta=ctime(&tm); - const bool extraday=(eta.substr(0,3)!=systime.substr(0,3)); - const string eday=extraday ? " "+eta.substr(0,3)+" " : ""; - s << "Time [h:m:s]=" << ToHMS(t) << ", R=" << ToHMS(r) << ", ETA=" << eday << eta.substr(11,8); - if(verboseprint) { - const string t=", n/N=" + tostring(n) + "/" + tostring(N) + "=" + tostring(Topercent(n,N,10)) + " percent,"; - s << t; - for(size_t i=t.size();i<42;++i) s << " "; - s << " CPU=" << ToHMS(cputime()); - } - s << endl; - - m_last_t=t; - m_last_eta=r; - } - } - } - friend ostream& operator<<(ostream& s,const timer x) - { - return s << "Time [h:m:s]= " << x.ToHMS(x.elapsed()) << " CPU=" << x.ToHMS(x.cputime()); - } -}; - -/* -int SwapEndian(void *data,const size_t size) { - - short xs; - long xl; - - switch (size){ - case 2: - xs = *(short *)data; - *(short *)data = ( ((xs & 0x0000ff00) >> 8) | ((xs & 0x000000ff) << 8) ); - break; - case 4: - xl = *(long *)data; - *(long *)data = ( ((xl & 0xff000000) >> 24) | ((xl & 0x00ff0000) >> 8) | - ((xl & 0x0000ff00) << 8) | ((xl & 0x000000ff) << 24) ); - break; - default: break; - } - - return 0; -} -*/ - -#endif // __FUNS_H__ diff --git a/cpp/wiiscan/src/process.h b/cpp/wiiscan/src/process.h deleted file mode 100644 index 77ffc52..0000000 --- a/cpp/wiiscan/src/process.h +++ /dev/null @@ -1,282 +0,0 @@ -#ifndef __PROCESS_H__ -#define __PROCESS_H__ - -#include - -pair ProcessWalkInit() -{ - // Take a snapshot of all processes in the system. - HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); - if( hProcessSnap == INVALID_HANDLE_VALUE ) throw_("CreateToolhelp32Snapshot() returned invalid handle"); - - // Set the size of the structure before using it. - PROCESSENTRY32 pe32; - pe32.dwSize = sizeof(PROCESSENTRY32); - - // Retrieve information about the first process, - // and exit if unsuccessful - if(!Process32First(hProcessSnap,&pe32)) { - CloseHandle(hProcessSnap); // clean the snapshot object - throw_("Process32First"); // show cause of failure - } - - return make_pair(hProcessSnap,pe32); -} - -DWORD GetProcessID(const string& processname) -{ - pair h=ProcessWalkInit(); - HANDLE hProcessSnap=h.first; - PROCESSENTRY32 pe32=h.second; - - do { - if (pe32.szExeFile==processname) { - CloseHandle(hProcessSnap); - return pe32.th32ProcessID; - } - } while( Process32Next(hProcessSnap,&pe32) ); - - CloseHandle(hProcessSnap); - return 0; -} - -PROCESSENTRY32 GetProcessInfo(const DWORD id) -{ - pair h=ProcessWalkInit(); - HANDLE hProcessSnap=h.first; - PROCESSENTRY32 pe32=h.second; - - int n=0; - do { - if (pe32.th32ProcessID==id) { - CloseHandle(hProcessSnap); - return pe32; - } - } while( Process32Next(hProcessSnap,&pe32) ); - - CloseHandle(hProcessSnap); - ZeroMemory( &pe32, sizeof(pe32) ); - pe32.dwSize = sizeof(PROCESSENTRY32); - - return pe32; -} - -DWORD GetProcessCount(const string& processname) -{ - pair h=ProcessWalkInit(); - HANDLE hProcessSnap=h.first; - PROCESSENTRY32 pe32=h.second; - int n=0; - do { - if (pe32.szExeFile==processname) ++n; - } while( Process32Next(hProcessSnap,&pe32) ); - - CloseHandle(hProcessSnap); - return n; -} - -bool KillProcessID(const DWORD id) -{ - HANDLE hProcess = OpenProcess( PROCESS_TERMINATE, FALSE, id); - if(hProcess==NULL) return false; // might have gone in the meantime, so no throw_("OpenProcess() got null handle"); - - const BOOL t=TerminateProcess(hProcess,-1); - CloseHandle(hProcess); - return t!=0; -} - -void KillAllProcesses(const string& exe) -{ - // kill existing polls - DWORD id=GetProcessID(exe); - while(id!=0){ - KillProcessID(id); - id=GetProcessID(exe); - } -} - -/* -#include -#include -#include - -BOOL GetProcessList( ); -BOOL ListProcessModules( DWORD dwPID ); -BOOL ListProcessThreads( DWORD dwOwnerPID ); -void printError( TCHAR* msg ); - -FILE* log=fopen("d:\\plog.txt","w"); - -BOOL GetProcessList( ) -{ - HANDLE hProcessSnap; - HANDLE hProcess; - PROCESSENTRY32 pe32; - DWORD dwPriorityClass; - - // Take a snapshot of all processes in the system. - hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); - if( hProcessSnap == INVALID_HANDLE_VALUE ) - { - printError( TEXT("CreateToolhelp32Snapshot (of processes)") ); - return( FALSE ); - } - - // Set the size of the structure before using it. - pe32.dwSize = sizeof( PROCESSENTRY32 ); - - // Retrieve information about the first process, - // and exit if unsuccessful - if( !Process32First( hProcessSnap, &pe32 ) ) - { - printError( TEXT("Process32First") ); // show cause of failure - CloseHandle( hProcessSnap ); // clean the snapshot object - return( FALSE ); - } - - // Now walk the snapshot of processes, and - // display information about each process in turn - do - { - fprintf(log, "\n\n=====================================================" ); - fprintf(log, TEXT("\nPROCESS NAME: %s"), pe32.szExeFile ); - fprintf(log, "\n-----------------------------------------------------" ); - - // Retrieve the priority class. - dwPriorityClass = 0; - hProcess = OpenProcess( PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID ); - if( hProcess == NULL ) - printError( TEXT("OpenProcess") ); - else - { - dwPriorityClass = GetPriorityClass( hProcess ); - if( !dwPriorityClass ) - printError( TEXT("GetPriorityClass") ); - CloseHandle( hProcess ); - } - - fprintf(log, "\n Process ID = 0x%08X", pe32.th32ProcessID ); - fprintf(log, "\n Thread count = %d", pe32.cntThreads ); - fprintf(log, "\n Parent process ID = 0x%08X", pe32.th32ParentProcessID ); - fprintf(log, "\n Priority base = %d", pe32.pcPriClassBase ); - if( dwPriorityClass ) - fprintf(log, "\n Priority class = %d", dwPriorityClass ); - - // List the modules and threads associated with this process - ListProcessModules( pe32.th32ProcessID ); - ListProcessThreads( pe32.th32ProcessID ); - - } while( Process32Next( hProcessSnap, &pe32 ) ); - - CloseHandle( hProcessSnap ); - return( TRUE ); -} - - -BOOL ListProcessModules( DWORD dwPID ) -{ - HANDLE hModuleSnap = INVALID_HANDLE_VALUE; - MODULEENTRY32 me32; - - // Take a snapshot of all modules in the specified process. - hModuleSnap = CreateToolhelp32Snapshot( TH32CS_SNAPMODULE, dwPID ); - if( hModuleSnap == INVALID_HANDLE_VALUE ) - { - printError( TEXT("CreateToolhelp32Snapshot (of modules)") ); - return( FALSE ); - } - - // Set the size of the structure before using it. - me32.dwSize = sizeof( MODULEENTRY32 ); - - // Retrieve information about the first module, - // and exit if unsuccessful - if( !Module32First( hModuleSnap, &me32 ) ) - { - printError( TEXT("Module32First") ); // show cause of failure - CloseHandle( hModuleSnap ); // clean the snapshot object - return( FALSE ); - } - - // Now walk the module list of the process, - // and display information about each module - do - { - fprintf(log, TEXT("\n\n MODULE NAME: %s"), me32.szModule ); - fprintf(log, TEXT("\n Executable = %s"), me32.szExePath ); - fprintf(log, "\n Process ID = 0x%08X", me32.th32ProcessID ); - fprintf(log, "\n Ref count (g) = 0x%04X", me32.GlblcntUsage ); - fprintf(log, "\n Ref count (p) = 0x%04X", me32.ProccntUsage ); - fprintf(log, "\n Base address = 0x%08X", (DWORD) me32.modBaseAddr ); - fprintf(log, "\n Base size = %d", me32.modBaseSize ); - - } while( Module32Next( hModuleSnap, &me32 ) ); - - CloseHandle( hModuleSnap ); - return( TRUE ); -} - -BOOL ListProcessThreads( DWORD dwOwnerPID ) -{ - HANDLE hThreadSnap = INVALID_HANDLE_VALUE; - THREADENTRY32 te32; - - // Take a snapshot of all running threads - hThreadSnap = CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 ); - if( hThreadSnap == INVALID_HANDLE_VALUE ) - return( FALSE ); - - // Fill in the size of the structure before using it. - te32.dwSize = sizeof(THREADENTRY32); - - // Retrieve information about the first thread, - // and exit if unsuccessful - if( !Thread32First( hThreadSnap, &te32 ) ) - { - printError( TEXT("Thread32First") ); // show cause of failure - CloseHandle( hThreadSnap ); // clean the snapshot object - return( FALSE ); - } - - // Now walk the thread list of the system, - // and display information about each thread - // associated with the specified process - do - { - if( te32.th32OwnerProcessID == dwOwnerPID ) - { - fprintf(log, "\n\n THREAD ID = 0x%08X", te32.th32ThreadID ); - fprintf(log, "\n Base priority = %d", te32.tpBasePri ); - fprintf(log, "\n Delta priority = %d", te32.tpDeltaPri ); - } - } while( Thread32Next(hThreadSnap, &te32 ) ); - - CloseHandle( hThreadSnap ); - return( TRUE ); -} - -void printError( TCHAR* msg ) -{ - DWORD eNum; - TCHAR sysMsg[256]; - TCHAR* p; - - eNum = GetLastError( ); - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, eNum, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - sysMsg, 256, NULL ); - - // Trim the end of the line and terminate it with a null - p = sysMsg; - while( ( *p > 31 ) || ( *p == 9 ) ) - ++p; - do { *p-- = 0; } while( ( p >= sysMsg ) && - ( ( *p == '.' ) || ( *p < 33 ) ) ); - - // Display the message - fprintf(log, TEXT("\n WARNING: %s failed with error %d (%s)"), msg, eNum, sysMsg ); -} -*/ - -#endif // __PROCESS_H__ \ No newline at end of file diff --git a/cpp/wiiscan/src/reg.h b/cpp/wiiscan/src/reg.h deleted file mode 100644 index 5d3d565..0000000 --- a/cpp/wiiscan/src/reg.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef __REGISTRY_H__ -#define __REGISTRY_H__ - -#ifdef WIN32 -#ifdef _WINDOWS - -namespace Registry{ - void* StringtoRoot(const string& t) - { - if (t=="HKEY_CLASSES_ROOT") return HKEY_CLASSES_ROOT; - else if (t=="HKEY_CURRENT_USER") return HKEY_CURRENT_USER; - else if (t=="HKEY_LOCAL_MACHINE") return HKEY_LOCAL_MACHINE; - else if (t=="HKEY_USERS") return HKEY_USERS; - else {throw_("bad root path in registry"); return 0;} - } - - pair > GetPath(const string& fullpath) - { - const int n=fullpath.find_first_of('\\'); - if (n==string::npos) throw_("mallformated registry entry"); - const string t=fullpath.substr(0,n); - void* root=StringtoRoot(t); - - const string r=fullpath.substr(n+1,-1); - const int m=r.find_last_of('\\'); - if (m==string::npos) throw_("mallformated registry entry"); - - const string path=r.substr(0,m); - const string key =r.substr(m+1,-1); - - return make_pair(root,make_pair(path,key)); - } - - bool hasKey(void* root,const string& path,const string& key,string* val=0) - { - assert( sizeof(void*)==sizeof(HKEY) && root!=0 ); - if (root!=HKEY_CLASSES_ROOT && root!=HKEY_CURRENT_USER && root!=HKEY_LOCAL_MACHINE && root!=HKEY_USERS) throw_("unknown root path in registry"); - - DWORD buffersize=1024*16; - char buff[1024*16]; - buff[0]=0; - - HKEY hKey; - if (ERROR_SUCCESS!=RegOpenKeyEx(static_cast(root),path.c_str(),NULL,KEY_READ,&hKey)) return false; - if (ERROR_SUCCESS!=RegQueryValueEx(hKey,key.c_str(),NULL,NULL,(LPBYTE)buff,&buffersize)) return false; - if (ERROR_SUCCESS!=RegCloseKey(hKey)) return false; - - if (val!=0) *val=buff; - return true; - } - - string GetKey(void* root,const string& path,const string& key) - { - string val; - if (!hasKey(root,path,key,&val)) throw_("could not read registry entry"); - return val; - } - - string GetKey(const string& fullpath) - { - const pair > p=GetPath(fullpath); - return GetKey(p.first,p.second.first,p.second.second); - } - - bool SetKey(void* root,const string& path,const string& key,const string& val) - { - assert( sizeof(void*)==sizeof(HKEY) && root!=0 ); - if (root!=HKEY_CLASSES_ROOT && root!=HKEY_CURRENT_USER && root!=HKEY_LOCAL_MACHINE && root!=HKEY_USERS) throw_("unknown root path in registry"); - if (val.size()+1>1024*16) throw_("lenght of value to long"); - - char buff[1024*16]; - size_t i; - for(i=0;i(root),path.c_str(),0,NULL,REG_OPTION_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,NULL)) return false; - if (ERROR_SUCCESS!=RegSetValueEx(hKey,key.c_str(),NULL,REG_SZ,(LPBYTE)buff,buffersize)) return false; - if (ERROR_SUCCESS!=RegCloseKey(hKey)) return false; - - return true; - } - - bool SetKey(const string& fullpath,const string& val) - { - const pair > p=GetPath(fullpath); - return SetKey(p.first,p.second.first,p.second.second,val); - } - -}; // namespace Registry - -#endif // _WINDOWS -#endif // WIN32 -#endif // __REGISTRY_H__ \ No newline at end of file diff --git a/cpp/wiiscan/src/stringfun.h b/cpp/wiiscan/src/stringfun.h deleted file mode 100644 index 9624292..0000000 --- a/cpp/wiiscan/src/stringfun.h +++ /dev/null @@ -1,284 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __STRINGFUN_H__ -#define __STRINGFUN_H__ - -struct outputoperator_tags -{ - string preline,endline; - int prewidth,postwidth,precision; - bool maptags,printnumbers,serialize; - - outputoperator_tags() - : endline("\n"), prewidth(-1), postwidth(-1), precision(-1), maptags(false), printnumbers(false), serialize(false) {} -}; - -static outputoperator_tags g_tags; - -inline ostream& operator<<(ostream& os,const outputoperator_tags& x){ - g_tags=x; - if (g_tags.precision>0) os.precision(g_tags.precision); - return os; -} - -template -inline string tostring(const T& x) -{ - ostringstream os; - outputoperator_tags t1=g_tags; - g_tags=outputoperator_tags(); - g_tags.serialize=true; - g_tags.endline=""; - os << x; - g_tags=t1; - return os.str(); -} - -template -inline T totype(const string& s) -{ - istringstream is(s); - T x; - is >> x; - return x; -} - -inline string operator+ (const string& s,const char* c) {return s+string(c);} -inline string operator+ (const string& s,const short& c) {return s+tostring(c);} -inline string operator+ (const string& s,const unsigned short& c) {return s+tostring(c);} -inline string operator+ (const string& s,const int& c) {return s+tostring(c);} -inline string operator+ (const string& s,const long& c) {return s+tostring(c);} -inline string operator+ (const string& s,const unsigned long& c) {return s+tostring(c);} -inline string operator+ (const string& s,const float& c) {return s+tostring(c);} -inline string operator+ (const string& s,const double& c) {return s+tostring(c);} -inline string operator+ (const string& s,const long double& c) {return s+tostring(c);} -inline string operator+ (const char* a ,const string& b) {return string(a)+b;} - -#ifdef OS_Linux -#ifdef __GCC_V4__ - // does not work under some compilers where size_t==unsigned int - inline string operator+ (const string& s,const size_t& c) {return s+tostring(c);} -#endif -#endif - -inline string tostring(const int argc,char** argv) -{ - string s; - for(int i=0;i -inline string fwidth2(const T& x,const size_t wdt,const bool prefix) -{ - string s=tostring(x); - if(wdt>1024 || s.size()>=wdt) return s; - size_t n=wdt-s.size(); - while(n>0) { - if (prefix) s=' '+ s; - else s+=' '; - --n; - } - return s; -} - -template -inline string fwidth(const T& x,const size_t wdt=8,const size_t tailwdt=4) -{ - string s=tostring(x); - if(wdt>1024 || tailwdt>1024 || s.size()>wdt+tailwdt) return s; - - const size_t m=min(s.find('.'),s.find(' ')); - if (m==string::npos) { - s=fwidth2(s,wdt,true); - return fwidth2(s,wdt+tailwdt,false); - } - else{ - if(wdt=m ); - size_t n1=wdt-m; - while(n1>0) {s= ' ' + s; --n1;} - return fwidth2(s,wdt+tailwdt,false); - } -} - -inline string strip(const string& s,const char ch=' ') -{ - const size_t n=s.find_first_not_of(ch); - const size_t m=s.find_last_not_of (ch); - - if (n==string::npos || m==string::npos) return ""; - return s.substr(n,m-n+1); -} - -inline string replace(const string& s,const string& f,const string& r) -{ - if (f.size()==0) return s; - const size_t n=s.find(f); - if (n==string::npos) return s; - else return replace(s.substr(0,n) + r + s.substr(n+f.size()),f,r); -} - -inline string indent(const string& s,const string& indent) -{ - string t,q=s; - while(q.size()){ - const string::size_type n=q.find_first_of("\n"); - t += indent + q.substr(0,n) + "\n"; - if (n==string::npos) break; - assert(n+1<=q.size()); - q = q.substr(n+1,q.size()); - } - return t; -} - -inline string removerems(const string& s,const string rem) -{ - const size_t n=s.find_first_of(rem); - return s.substr(0,n); -} - -inline string suffix(const int n) -{ - assert(n>=0 && n<999); - if (n<=9) return "00" + tostring(n); - else if (n<=99) return "0" + tostring(n); - else return tostring(n); -} - -string tail(const string& s,const string& delimiter) -{ - const size_t n=s.find_last_of(delimiter); - if (n==string::npos) return s; - else return s.substr(n+delimiter.size(),-1); -} - -string tail(const string& s,const char c) { - string t; - t.resize(1); - t[0]=c; - return tail(s,t); -} - -template -inline ostream& operator<<(ostream& os,const pair x) -{ - for(int i=0;i -inline istream& operator>>(istream& is,pair x) -{ - for(int i=0;i> x.first[i]; - return is; -} - -template -inline ostream& operator<<(ostream& s,const vector& x) -{ - int i=0; - if (g_tags.serialize) s << "vector: " << x.size() << " { "; - for(typename vector::const_iterator itt=x.begin();itt!=x.end();++itt) { - s << g_tags.preline; - if(g_tags.printnumbers) s << "[" << fwidth(++i,3,0) << "] "; - s << *itt << " " << g_tags.endline; - } - if (g_tags.serialize) s << "} "; - return s; -} - -template -inline istream& operator>>(istream& s,vector& x) -{ - size_t n=0; - string t; - s >> t; - if (t!="vector:") throw_("bad format in vector serialization stream, tag missing"); - s >> n >> t; - if (t!="{") throw_("bad format in vector serialization stream, missing begin brace"); - x.resize(n); - for(size_t i=0;i> x[i]; - s >> t; - if (t!="}") throw_("bad format in vector serialization stream, missing end brace"); - return s; -} - -template -inline ostream& operator<<(ostream& s,const list& x) -{ - if (g_tags.serialize) s << "list: " << x.size() << " { "; - int i=0; - for(typename list::const_iterator itt=x.begin();itt!=x.end();++itt){ - s << g_tags.preline; - if(g_tags.printnumbers) s << "[" << fwidth(++i,3,0) << "] "; - s << *itt << " " << g_tags.endline; - } - if (g_tags.serialize) s << "} "; - return s; -} - -template -inline istream& operator>>(istream& s,list& x) -{ - size_t n=0; - string t; - s >> t; - if (t!="list:") throw_("bad format in list serialization stream, tag missing"); - s >> n >> t; - if (t!="{") throw_("bad format in list serialization stream, missing begin brace"); - for(size_t i=0;i> y; - x.push_back(y); - } - s >> t; - if (t!="}") throw_("bad format in list serialization stream, missing end brace"); - return s; -} - -template -inline ostream& operator<<(ostream& s,const map& x) -{ - if (g_tags.serialize) s << "map: " << x.size() << " { "; - int i=0; - for(typename map::const_iterator itt=x.begin();itt!=x.end();++itt) { - s << g_tags.preline; - if(g_tags.printnumbers) s << "[" << fwidth(++i,3,0) << "] "; - s << fwidth(itt->first,g_tags.prewidth,g_tags.postwidth) << (g_tags.maptags ? " |-> " : " "); - s << fwidth(itt->second,g_tags.prewidth,g_tags.postwidth) << " " << g_tags.endline; - } - if (g_tags.serialize) s << "} "; - return s; -} - -template -inline istream& operator>>(istream& s,map& x) -{ - size_t n=0; - string t; - s >> t; - if (t!="map:") throw_("bad format in map serialization stream, tag missing"); - s >> n >> t; - if (t!="{") throw_("bad format in map serialization stream, missing begin brace"); - for(size_t i=0;i> y >> z; - if (x.find(y)!=x.end()) throw_("bad stream, key value no unique"); - x[y]=z; - } - s >> t; - if (t!="}") throw_("bad format in map serialization stream, missing end brace"); - return s; -} - -#endif // __STRINGFUNS_H__ diff --git a/cpp/wiiscan/src/templatefun.h b/cpp/wiiscan/src/templatefun.h deleted file mode 100644 index 5212732..0000000 --- a/cpp/wiiscan/src/templatefun.h +++ /dev/null @@ -1,54 +0,0 @@ -#ifndef __TEMPLATE_FUN__ -#define __TEMPLATE_FUN__ - -#define __stdcall - -template -class Autobool -{ -private: - volatile T* m_b; - Autobool(const Autobool&); - void operator=(const Autobool&); -public: - Autobool(volatile T* b) : m_b(b) {assert(m_b && *m_b==false); *m_b=true;} - ~Autobool() {assert(m_b && *m_b==true); *m_b=false; m_b=0;} -}; - -template -class DeviceAutoClose -{ -private: - T m_dev; - R (__stdcall *m_fun)(void *); - bool m_init; - - // private Copy CTOR and assignment operator - DeviceAutoClose(const DeviceAutoClose&); - void operator=(const DeviceAutoClose&); - -public: - DeviceAutoClose(T dev,R(__stdcall *fun)(void*)) : m_dev(dev), m_fun(fun), m_init(true) - { - FUNSTACK; - assert(m_fun!=NULL); - } - ~DeviceAutoClose() - { - FUNSTACK; - assert(m_init); - assert(m_fun!=NULL); - if (m_dev!=NULL){ - R r=m_fun(m_dev); - if (!r) throw_("DeviceClose() failed"); // throw in DTOR -> bad, bad! - } - m_dev=NULL; - m_fun=NULL; - m_init=false; - } - const T& operator()() const {FUNSTACK; assert(m_init); return m_dev;} - T& operator()() {FUNSTACK; assert(m_init); return m_dev;} -}; - - -#endif // __TEMPLATE_FUN__ diff --git a/cpp/wiiscan/src/toolsfun.h b/cpp/wiiscan/src/toolsfun.h deleted file mode 100644 index 211ba55..0000000 --- a/cpp/wiiscan/src/toolsfun.h +++ /dev/null @@ -1,34 +0,0 @@ -// The code is copyrighted 2008 by Carsten Frigaard. -// All rights placed in public domain under GNU licence V2, 2008 -// -// © 2008 Carsten Frigaard. Permission to use, copy, modify, and distribute this software -// and its documentation for any purpose and without fee is hereby granted, provided that -// the above copyright notice appear in all copies and that both that copyright notice -// and this permission notice appear in supporting documentation. - -#ifndef __TOOLSFUN_H__ -#define __TOOLSFUN__H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#include "exception.h" -#include "stringfun.h" -#include "args.h" -#include "funs.h" -#include "file.h" -#include "configfile.h" -#include "templatefun.h" -#include "reg.h" - -#endif // __TOOLSFUN_H__ \ No newline at end of file diff --git a/cpp/wiiscan/src/usbm.h b/cpp/wiiscan/src/usbm.h deleted file mode 100644 index 802c942..0000000 --- a/cpp/wiiscan/src/usbm.h +++ /dev/null @@ -1,204 +0,0 @@ -#ifndef __USBM_H__ -#define __USBM_H__ - -class USBio -{ -private: - HINSTANCE m_hDll; - - // Discovery routine - typedef int (__stdcall *USBm_FindDevices_type) (); - - // Info about devices - typedef int (__stdcall *USBm_NumberOfDevices_type) (void); - typedef int (__stdcall *USBm_DeviceValid_type) (unsigned char); - typedef int (__stdcall *USBm_DeviceVID_type) (unsigned char device); - typedef int (__stdcall *USBm_DevicePID_type) (unsigned char device); - typedef int (__stdcall *USBm_DeviceDID_type) (unsigned char device); - typedef int (__stdcall *USBm_DeviceMfr_type) (unsigned char, char *); - typedef int (__stdcall *USBm_DeviceProd_type) (unsigned char, char *); - typedef int (__stdcall *USBm_DeviceSer_type) (unsigned char, char *); - - // General U4xx functions - typedef int (__stdcall *USBm_InitPorts_type) (unsigned char); - typedef int (__stdcall *USBm_WriteA_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_WriteB_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_WriteABit_type) (unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_WriteBBit_type) (unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_ReadA_type) (unsigned char, unsigned char *); - typedef int (__stdcall *USBm_ReadB_type) (unsigned char, unsigned char *); - typedef int (__stdcall *USBm_SetBit_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_ResetBit_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_DirectionA_type) (unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_DirectionB_type) (unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_StrobeWrite_type) (unsigned char, unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_StrobeRead_type) (unsigned char, unsigned char *, unsigned char, unsigned char); - typedef int (__stdcall *USBm_StrobeWrite2_type) (unsigned char, unsigned char, unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_StrobeRead2_type) (unsigned char, unsigned char *, unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_StrobeWrites_type) (unsigned char, unsigned char *, unsigned char *); - typedef int (__stdcall *USBm_StrobeReads_type) (unsigned char, unsigned char *, unsigned char *); - typedef int (__stdcall *USBm_InitLCD_type) (unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_LCDCmd_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_LCDData_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_InitSPI_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_SPIMaster_type) (unsigned char, unsigned char *, unsigned char *); - typedef int (__stdcall *USBm_SPISlaveWrite_type) (unsigned char, unsigned char, unsigned char *); - typedef int (__stdcall *USBm_SPISlaveRead_type) (unsigned char, unsigned char *, unsigned char *); - typedef int (__stdcall *USBm_Stepper_type) (unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char); - typedef int (__stdcall *USBm_Reset1Wire_type) (unsigned char, unsigned char *); - typedef int (__stdcall *USBm_Write1Wire_type) (unsigned char, unsigned char); - typedef int (__stdcall *USBm_Read1Wire_type) (unsigned char, unsigned char *); - - // DLL string info access - typedef int (__stdcall *USBm_RecentError_type) (char *); - typedef int (__stdcall *USBm_ClearRecentError_type) (void); - typedef int (__stdcall *USBm_DebugString_type) (char *); - typedef int (__stdcall *USBm_Copyright_type) (char *); - typedef int (__stdcall *USBm_About_type) (char *); - typedef int (__stdcall *USBm_Version_type) (char *); - -public: - USBio() : m_hDll(0) - { - m_hDll = LoadLibrary("USBm.dll"); - if (m_hDll==0) throw_("could not locate USBm.dll"); - - USBm_FindDevices = (USBm_FindDevices_type)GetProcAddress(m_hDll, "USBm_FindDevices"); - USBm_NumberOfDevices = (USBm_NumberOfDevices_type)GetProcAddress(m_hDll, "USBm_NumberOfDevices"); - USBm_DeviceValid = (USBm_DeviceValid_type)GetProcAddress(m_hDll, "USBm_DeviceValid"); - USBm_DeviceVID = (USBm_DeviceVID_type)GetProcAddress(m_hDll, "USBm_DeviceVID"); - USBm_DevicePID = (USBm_DevicePID_type)GetProcAddress(m_hDll, "USBm_DevicePID"); - USBm_DeviceDID = (USBm_DeviceDID_type)GetProcAddress(m_hDll, "USBm_DeviceDID"); - USBm_DeviceMfr = (USBm_DeviceMfr_type)GetProcAddress(m_hDll, "USBm_DeviceMfr"); - USBm_DeviceProd = (USBm_DeviceProd_type)GetProcAddress(m_hDll, "USBm_DeviceProd"); - USBm_DeviceSer = (USBm_DeviceSer_type)GetProcAddress(m_hDll, "USBm_DeviceSer"); - USBm_InitPorts = (USBm_InitPorts_type)GetProcAddress(m_hDll, "USBm_InitPorts"); - USBm_WriteA = (USBm_WriteA_type)GetProcAddress(m_hDll, "USBm_WriteA"); - USBm_WriteB = (USBm_WriteB_type)GetProcAddress(m_hDll, "USBm_WriteB"); - USBm_WriteABit = (USBm_WriteABit_type)GetProcAddress(m_hDll, "USBm_WriteABit"); - USBm_WriteBBit = (USBm_WriteBBit_type)GetProcAddress(m_hDll, "USBm_WriteBBit"); - USBm_ReadA = (USBm_ReadA_type)GetProcAddress(m_hDll, "USBm_ReadA"); - USBm_ReadB = (USBm_ReadB_type)GetProcAddress(m_hDll, "USBm_ReadB"); - USBm_SetBit = (USBm_SetBit_type)GetProcAddress(m_hDll, "USBm_SetBit"); - USBm_ResetBit = (USBm_ResetBit_type)GetProcAddress(m_hDll, "USBm_ResetBit"); - USBm_DirectionA = (USBm_DirectionA_type)GetProcAddress(m_hDll, "USBm_DirectionA"); - USBm_DirectionB = (USBm_DirectionB_type)GetProcAddress(m_hDll, "USBm_DirectionB"); - USBm_StrobeWrite = (USBm_StrobeWrite_type)GetProcAddress(m_hDll, "USBm_StrobeWrite"); - USBm_StrobeRead = (USBm_StrobeRead_type)GetProcAddress(m_hDll, "USBm_StrobeRead"); - USBm_StrobeWrite2 = (USBm_StrobeWrite2_type)GetProcAddress(m_hDll, "USBm_StrobeWrite2"); - USBm_StrobeRead2 = (USBm_StrobeRead2_type)GetProcAddress(m_hDll, "USBm_StrobeRead2"); - USBm_StrobeWrites = (USBm_StrobeWrites_type)GetProcAddress(m_hDll, "USBm_StrobeWrites"); - USBm_StrobeReads = (USBm_StrobeReads_type)GetProcAddress(m_hDll, "USBm_StrobeReads"); - USBm_InitLCD = (USBm_InitLCD_type)GetProcAddress(m_hDll, "USBm_InitLCD"); - USBm_LCDCmd = (USBm_LCDCmd_type)GetProcAddress(m_hDll, "USBm_LCDCmd"); - USBm_LCDData = (USBm_LCDData_type)GetProcAddress(m_hDll, "USBm_LCDData"); - USBm_InitSPI = (USBm_InitSPI_type)GetProcAddress(m_hDll, "USBm_InitSPI"); - USBm_SPIMaster = (USBm_SPIMaster_type)GetProcAddress(m_hDll, "USBm_SPIMaster"); - USBm_SPISlaveWrite = (USBm_SPISlaveWrite_type)GetProcAddress(m_hDll, "USBm_SPISlaveWrite"); - USBm_SPISlaveRead = (USBm_SPISlaveRead_type)GetProcAddress(m_hDll, "USBm_SPISlaveRead"); - USBm_Stepper = (USBm_Stepper_type)GetProcAddress(m_hDll, "USBm_Stepper"); - USBm_Reset1Wire = (USBm_Reset1Wire_type)GetProcAddress(m_hDll, "USBm_Reset1Wire"); - USBm_Write1Wire = (USBm_Write1Wire_type)GetProcAddress(m_hDll, "USBm_Write1Wire"); - USBm_Read1Wire = (USBm_Read1Wire_type)GetProcAddress(m_hDll, "USBm_Read1Wire"); - USBm_RecentError = (USBm_RecentError_type)GetProcAddress(m_hDll, "USBm_RecentError"); - USBm_ClearRecentError = (USBm_ClearRecentError_type)GetProcAddress(m_hDll, "USBm_ClearRecentError"); - USBm_DebugString = (USBm_DebugString_type)GetProcAddress(m_hDll, "USBm_DebugString"); - USBm_Copyright = (USBm_Copyright_type)GetProcAddress(m_hDll, "USBm_Copyright"); - USBm_About = (USBm_About_type)GetProcAddress(m_hDll, "USBm_About"); - USBm_Version = (USBm_Version_type)GetProcAddress(m_hDll, "USBm_Version"); - } - - ~USBio() - { - assert( m_hDll ); -// XXX FreeLibrary(m_hDll); - m_hDll=0; - } - - int Devices() const - { - assert( m_hDll ); - unsigned char numdev=USBm_NumberOfDevices(); - return numdev; - } - - string version() const - { - assert( m_hDll ); - - string s; - char textstr[300]; - const int d=Devices(); - - s = string(" USBm.dll version = ") + USBm_Version(textstr) + "\n"; - s += string(" USBm.dll version = ") + textstr + "\n"; - - USBm_Copyright(textstr); - s += string(" Copyright = ") + textstr + "\n"; - - USBm_About(textstr); - s += string(" About =") + textstr + "\n"; - s += string(" Number of devices = ") + d + "\n"; - - // Gather info from each discovered device - for(int i=0;i. -// This is free software: you are free to change and redistribute it. -// There is NO WARRANTY, to the extent permitted by law. -// -// This file is part of wiiscan. -// -// wiiscan 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 3 of the License, or -// any later version. -// -// wiiscan 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 wiiscan. If not, see . - -#include "wiiscan.h" - -int main(int argc,char** argv) -{ - return Wiiscan::main(argc,argv); -} \ No newline at end of file diff --git a/cpp/wiiscan/src/wiiscan.h b/cpp/wiiscan/src/wiiscan.h deleted file mode 100644 index 69d9de0..0000000 --- a/cpp/wiiscan/src/wiiscan.h +++ /dev/null @@ -1,1114 +0,0 @@ -// Copyright © 2009 MergeIt, Aps. -// -// License LGPLv3+: GNU lesser LGPL version 3 or later . -// This is free software: you are free to change and redistribute it. -// There is NO WARRANTY, to the extent permitted by law. -// -// This file is part of wiiscan. -// -// wiiscan 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 3 of the License, or -// any later version. -// -// wiiscan 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 wiiscan. If not, see . - -#define VERSION 0 -#define VERSION_REV 9 - -#define VC_EXTRALEAN - -#define sprintf_s snprintf - -#include "toolsfun.h" -#include "wiiuse.h" -#include "usbm.h" -#include "delcomdll.h" -#include -#include - -#pragma comment ( lib, "odbccp32.lib") -#pragma comment ( lib, "wiiuse.lib") -#pragma comment ( lib, "delcomdll.lib") -#pragma comment ( lib, "Irprops.lib") -#pragma comment ( lib, "libcpmt.lib") - -namespace Wiiscan { - -// default values -const int MAX_DEVICE_COUNT =256; -const int DEFAULT_timeout =2000; -const int DEFAULT_wiitimeout=2000; -const int DEFAULT_usbsleep =500; -const int DEFAULT_usbmsleep =3000; -const int DEFAULT_btsleep =2000; -const int DEFAULT_usbmode =0; -const int DEFAULT_removemode=0; -const int DEFAULT_scanretries=1; -const string NINTENDO_DEV="Nintendo RVL-CNT-01"; -const string DEFAULT_configfile="wiiscan.ini"; -const string DEFAULT_logfile="cout"; -const string DEFAULT_wiilib="wiimotelib"; - -Logger& log=g_log; -void (*g_automode_callback)(const int)=0; -void DummyCallback(const int){FUNSTACK;} - -string ConvertName(const WCHAR* szName) -{ - FUNSTACK; - assert( MAX_PATH >= BLUETOOTH_MAX_NAME_SIZE ); - CHAR szDevName[MAX_PATH]; - memset(szDevName, 0x00, sizeof(szDevName)); - sprintf_s(szDevName,MAX_PATH,"%S", szName); - return string(szDevName); -} - -string ConvertAddress(const BLUETOOTH_ADDRESS& address) -{ - FUNSTACK; - string s; - char t[256]; - for(int i=5;i>=0;i--) { - sprintf_s(t,256,"%X",address.rgBytes[i]); - string x=t; - if (x.size()==1) x="0"+x; - s+=x+(i==0 ? "" : ":"); - } - return s; -} - -string tostring(const SYSTEMTIME& x) -{ - FUNSTACK; - // XXX warning: no converstion of GMT to local time - ostringstream s; - if (x.wHour==0 && x.wMinute==0 && x.wDay==0 && x.wYear==0 && x.wYear==0) s << ""; - else s << x.wHour << ":" << (x.wMinute<10 ? "0" : "") << x.wMinute << " d. " << x.wDay << "/" << x.wMonth << ", " << x.wYear; - return s.str(); -} - -string tostring(const BLUETOOTH_DEVICE_INFO& x) -{ - FUNSTACK; - ostringstream s; - s << " BLUETOOTH_DEVICE_INFO:" << endl; - s << " dwSize: " << x.dwSize << endl; - s << " Address: " << ConvertAddress(x.Address) << endl; - s << " ulClassofDevice:" << x.ulClassofDevice << endl; - s << " fConnected: " << x.fConnected << endl; - s << " fRemembered: " << x.fRemembered << endl; - s << " fAuthenticated: " << x.fAuthenticated << endl; - s << " stLastSeen: " << tostring(x.stLastSeen) << " [GMT]" << endl; - s << " stLastUsed: " << tostring(x.stLastUsed) << " [GMT]" << endl; - s << " szName: " << ConvertName(x.szName) << endl; - return s.str(); -} - -string tostring(const BLUETOOTH_RADIO_INFO& x) -{ - FUNSTACK; - ostringstream s; - s << " PBLUETOOTH_RADIO_INFO:" << endl; - s << " dwSize: " << x.dwSize << endl; - s << " Address: " << ConvertAddress(x.address) << endl; - s << " szName: " << ConvertName(x.szName) << endl; - s << " ulClassofDevice:" << x.ulClassofDevice << endl; - s << " lmpSubversion: " << x.lmpSubversion << endl; - s << " manufacturer: " << x.manufacturer << endl; - return s.str(); -} - -bool USB_hub_updown(const bool up,const string& usbhub) -{ - FUNSTACK; - log << (up ? "Enabling" : "Disabling") << " 'USB hub..." << endl; - int n=-1; - System(string("devcon ") + (up ? "enable " : "disable ") + usbhub,false,false,&n); - if (n!=0) throw_("devcon failed, this can be to a erroneous usbhub string or if devcon.exe is not found in path, please install it from http://support.microsoft.com/kb/311272"); - log << "Done [OK]" << endl; - return true; -} - -int ScanforUSBmicrodevs() -{ - USBio io; - io.USBm_FindDevices(); - return io.Devices(); -} - -bool USB_microio_updown(const bool up,const bool dbg) -{ - FUNSTACK; - log << (up ? "Enabling" : "Disabling") << " USBm io..." << endl; - - // Discover the USBmicro devices - USBio io; - io.USBm_FindDevices(); - const int d=io.Devices(); - if (d==0) return false; // throw_("could not find an USBm device"); - else if (d>1) throw_("found more that one USBm devices"); - - static bool premable=true; - if (dbg && premable) { - premable=false; - log << " USBm info:" << endl << io.version(); - } - - io.USBm_InitPorts(0); - io.USBm_DirectionA(0, 0xff, 0xff); - - if(up) io.USBm_ResetBit(0,5); - else io.USBm_SetBit (0,5); - - log << "Done [OK]" << endl; - return true; -} - -bool CloseDelcomhandle(HANDLE h){return DelcomCloseDevice(h)==0;} - -void do_cmd(HANDLE di, int ma, int mi, int lsb, int msb, unsigned char *data, unsigned datalen) -{ - //static struct delcom_packet p; - PacketStruct p; - memset(&p, 0, sizeof(p)); - p.MajorCmd = ma; - p.MinorCmd = mi; - p.DataLSB = lsb; - p.DataMSB = msb; - if (DelcomSendPacket(di,&p,&p)<0) throw_("DelcomSendPacket() failed"); -} - -int ScanforDelcomdevs() -{ - // Discover the USB Delcom devices - DeviceNameStruct names[10]; // array to hold the device names found - return DelcomScanDevices(USBIODS, names, 10); -} - -bool USB_delconio_updown(const bool up,const bool dbg) -{ - FUNSTACK; - log << (up ? "Enabling" : "Disabling") << " USB Delcom io..." << endl; - - DeviceNameStruct names[10]; // array to hold the device names found - const int d=DelcomScanDevices(USBIODS, names, 10); - if (d==0) return false; //throw_("could not find an USB Delcon device"); - else if (d>1) throw_("found more that one USB Delcon devices"); - - static bool premable=true; - if (dbg && premable) { - premable=false; - log << " USB Delcon info:" << (char*)&names[0] << "\n SN=" << DelcomReadDeviceSerialNum((char*)&names[0], NULL) << endl; - } - - DeviceAutoClose h(DelcomOpenDevice((char*)&names[0],0), CloseDelcomhandle); - if(up) do_cmd(h(),10,1,0xFE,0,0,0); - else do_cmd(h(),10,1,0xFF,0,0,0); - - log << "Done [OK]" << endl; - return true; -} - -bool USBupdown(const int iomode,const bool up,const bool dbg,const string& usbhub="") -{ - if (iomode==0) return true; - if (iomode==1) return USB_hub_updown(up,usbhub); - if (iomode==2) return USB_microio_updown(up,dbg); - else if (iomode==3) return USB_delconio_updown(up,dbg); - else throw_("bad io mode"); - return false; -} - -class Wiilib -{ - // Wiilib class based on wiiuse library by Michael Laforest. - // Library located at http://www.wiiuse.net - // Wiiuse premable from wiiuse_v0.12/example/example.c: - - // - // wiiuse - // - // Written By: - // Michael Laforest < para > - // Email: < thepara (--AT--) g m a i l [--DOT--] com > - // - // Copyright 2006-2007 - // - // This file is part of wiiuse. - // - // 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 3 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, see . - -private: - enum {MAX_WIIMOTES=1}; // use only one wiimote, but can connect to four - wiimote** m_wiimotes; - static int m_instantiations; - - int finddevices(const int wiitimeout,const bool rumble,const bool dbg) - { - FUNSTACK; - - // Find wiimote devices - const int to=wiitimeout/1000; - if (to<1) throw_("bad wiitimeout value, should be >=1000"); - const int found=wiiuse_find(m_wiimotes,MAX_WIIMOTES,to); - if (dbg) log << " wiiuse_find(0x0," << MAX_WIIMOTES << "," << to << ") return " << found << endl; - - if (found==0) { - if (dbg) log << " ** error: no wiimotes found" << endl; - return 0; - } - - // Connect to the wiimotes - assert(found>0); - - const int connected = wiiuse_connect(m_wiimotes, MAX_WIIMOTES); - if (connected==0){ - log << " ** error: could not connect to any wiimotes" << endl; - return 0; - } - if (dbg) log << " connected to " << connected<< " wiimotes (of " << MAX_WIIMOTES << " found)" << endl; - - - // Now set the LEDs and rumble for a second so it's easy - // to tell which wiimotes are connected (just like the wii does). - wiiuse_set_leds(m_wiimotes[0], WIIMOTE_LED_1); - - if (rumble){ - wiiuse_rumble(m_wiimotes[0], 1); - #ifndef WIN32 - usleep(200000); - #else - Sleep(200); - #endif - wiiuse_rumble(m_wiimotes[0], 0); - } - - // read some data to be sure of connection - for(int i=0;i<8;++i){ - Sleep(50); - - int led=0; - switch(i%6){ - case 0 : led=WIIMOTE_LED_1; break; - case 1 : led=WIIMOTE_LED_2; break; - case 2 : led=WIIMOTE_LED_3; break; - case 3 : led=WIIMOTE_LED_4; break; - case 4 : led=WIIMOTE_LED_3; break; - case 5 : led=WIIMOTE_LED_2; break; - } - wiiuse_rumble(m_wiimotes[0], 0); // to be sure - wiiuse_set_leds(m_wiimotes[0],led); - wiiuse_status(m_wiimotes[0]); - if (led!=m_wiimotes[0]->leds) throw_("bad LED status on wiimote, is it connected properly?"); - } - - // set all leds, retry a couple of time to be sure - for(int i=0;i<4;++i){ - wiiuse_set_leds(m_wiimotes[0],WIIMOTE_LED_1 | WIIMOTE_LED_2 | WIIMOTE_LED_3 | WIIMOTE_LED_4); - Sleep(100); - } - - return connected; - } - - Wiilib() : m_wiimotes(0) - { - FUNSTACK; - if (m_instantiations!=0) throw_("can only instatiate one Wiilib at a time"); - ++m_instantiations; // assumes a single-thread application, else we have a race condition here - - // Initialize an array of wiimote objects. - // The parameter is the number of wiimotes I want to create. - m_wiimotes = wiiuse_init(MAX_WIIMOTES); - // wiiuse_set_bluetooth_stack(m_wiimotes, MAX_WIIMOTES,WIIUSE_STACK_MS); must be done automatically - assert(m_instantiations==1); - } - - ~Wiilib() - { - FUNSTACK; - assert( m_instantiations==1 ); - - // Disconnect the wiimotes - if (m_wiimotes!=0) wiiuse_cleanup(m_wiimotes, MAX_WIIMOTES); - m_wiimotes=0; - --m_instantiations; - assert(m_instantiations==0); - } - - static int OpenDevices_wiilib(const int wiitimeout,const bool rumble,const bool dbg,const bool precheck=false) - { - FUNSTACK; - int n=0,retries=0; - while(n==0 && retries++<10) { - n=Wiilib().finddevices(wiitimeout,rumble,dbg); - if (precheck) break; - if (n==0) { - if (dbg) log << " OpenDevice()...delaying " << (retries<5 ? "250" : "1000") << " [ms]" << endl; - if (retries<5) Sleep(250); - else Sleep(1000); - } - } - if (dbg) {cerr.flush(); log << " Wiilib::OpenDevice..." << n << endl;} - return n; - } - - static int OpenDevices_wiimotelib(const int wiitimeout,const bool rumble,const bool dbg,const bool precheck=false) - { - FUNSTACK; - int n=0,retries=0; - while(n==0 && retries++<10) { - n=system("wiimotelibpoll")==0 ? 1 : 0; - if (precheck) break; - if (n==0) { - if (dbg) log << " OpenDevice()...delaying " << (retries<5 ? "250" : "1000") << " [ms]" << endl; - if (retries<5) Sleep(250); - else Sleep(1000); - } - } - if (dbg) {cerr.flush(); log << " Wiilib::OpenDevice..." << n << endl;} - return n; - } - -public: - - static int OpenDevices(const string& wiilib,const int wiitimeout,const bool rumble,const bool dbg,const bool precheck=false) - { - FUNSTACK; - if (wiilib=="wiiuse") return OpenDevices_wiilib(wiitimeout,rumble,dbg,precheck); - else if (wiilib=="wiimotelib") return OpenDevices_wiimotelib(wiitimeout,rumble,dbg,precheck); - else if (wiilib=="none") return -1; - else throw_("Wiilib::OpenDevices(), library must be one-of {wiiuse,wiimotelib,none}"); - return -1; // avoid compiler error - } - -}; - -int Wiilib::m_instantiations=0; - -BLUETOOTH_DEVICE_SEARCH_PARAMS Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(const int timeout) -{ - FUNSTACK; - BLUETOOTH_DEVICE_SEARCH_PARAMS b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - b.fReturnAuthenticated = TRUE; - b.fReturnRemembered = TRUE; - b.fReturnUnknown = TRUE; - b.fReturnConnected = TRUE; - b.fIssueInquiry = TRUE; - - const int to=static_cast(1.0*timeout/1000.0/1.28+0.5); - assert(to>=0 && to<48 ); - b.cTimeoutMultiplier = (to==0 ? 1 : to); // timeout of 0 causes havac - b.hRadio = NULL; - - assert( b.cTimeoutMultiplier>0 ); - return b; -} - -BLUETOOTH_DEVICE_INFO Get_BLUETOOTH_DEVICE_INFO() -{ - FUNSTACK; - BLUETOOTH_DEVICE_INFO b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - return b; -} - -BLUETOOTH_RADIO_INFO Get_BLUETOOTH_RADIO_INFO() -{ - FUNSTACK; - BLUETOOTH_RADIO_INFO b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - return b; -} - -BLUETOOTH_FIND_RADIO_PARAMS Get_BLUETOOTH_FIND_RADIO_PARAMS() -{ - FUNSTACK; - BLUETOOTH_FIND_RADIO_PARAMS b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - return b; -} - -bool ReachedMax(const int i) -{ - FUNSTACK; - if (i>MAX_DEVICE_COUNT) { - log << " ** warning: too many devices found, can only handle " << MAX_DEVICE_COUNT << " devices" << endl; - return true; - } - return false; -} - -bool RemoveDev(BLUETOOTH_DEVICE_INFO& bdi) -{ - FUNSTACK; - DWORD status=BluetoothUpdateDeviceRecord(&bdi); - if (status!=ERROR_SUCCESS) throw_("BluetoothUpdateDeviceRecord() failed"); - - status=BluetoothRemoveDevice(&bdi.Address); - if (status==ERROR_SUCCESS) log << " removed device successfully..." << endl << "Done [OK]" << endl; - else log << " ** error: removing the device failed, was it registred at all?" << endl <<"Done [FAILED]" << endl; - - return status==ERROR_SUCCESS; -} - -HANDLE RadioInfo(const string& btr,const bool dbg) -{ - FUNSTACK; - if (dbg) log << " Radio info" << endl; - assert( btr.size()==17 || btr.size()==0 || btr=="all"); - - HANDLE hRadio=NULL; - BLUETOOTH_FIND_RADIO_PARAMS btfrp=Get_BLUETOOTH_FIND_RADIO_PARAMS(); - DeviceAutoClose hbf( - BluetoothFindFirstRadio(&btfrp,&hRadio), - BluetoothFindRadioClose); - - if (hbf()==NULL) { - if (dbg) log << " " << endl; - return NULL; - } - - while(hbf()!=NULL){ - if (hbf()==NULL) throw_("BluetoothFindFirstRadio() failed"); - - BLUETOOTH_RADIO_INFO r=Get_BLUETOOTH_RADIO_INFO(); - if (BluetoothGetRadioInfo(hRadio,&r)!=ERROR_SUCCESS) throw_("BluetoothGetRadioInfo() failed"); - - const int c=BluetoothIsConnectable(hRadio); - const int d=BluetoothIsDiscoverable(hRadio); - - if (dbg){ - log << indent(tostring(r)," "); - log << " connectable: " << c << endl; - log << " discoverabel: " << d << endl; - } - - if (btr.size()==0) break; - else if (btr==ConvertAddress(r.address)){ - if (dbg) log << " found radio address match " << (btr.size()>0 ? ": " + btr : "") << endl; - break; - } - - if (!BluetoothFindNextRadio(&btfrp,&hRadio)) break; - } - - if (dbg) log << "Done [" << (hRadio==NULL ? "FAILED" : "OK") << "]" << endl; - return hRadio; -} - -bool ScanDevices(const int timeout) -{ - FUNSTACK; - log << "Scanning devices" << endl; - - vector infos; - - BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(timeout); - BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - - DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi), - BluetoothFindDeviceClose); - //const DWORD dwErr = GetLastError(); - - if (hbf()==NULL) { - log << " ** warning: no devices found" << endl << "Done [FAILED]" << endl; - return false;; - } - - if (hbf()!= NULL) { - log << "Looking for devices..." << endl; - - int i=0; - while(1){ - if (ReachedMax(i)) break; - - const string t=ConvertName(bdi.szName); - log << " found device [" << i << "]: <" << (t.size()>0 ? t : "NONAME") << ">" << endl; - - infos.push_back(bdi); - - if (BluetoothFindNextDevice(hbf(), &bdi) == FALSE) - break; - - ++i; - } - } - - log << "BTDevices info:" << endl; - if (infos.size()==0) log << " " << endl; - else for(size_t i=0;i0 ? s : "") << endl; - log << tostring(t); - } - log << "Done [OK]" << endl; - - return true; -} - -bool RemoveDevice(const string& d,const bool dbg) -{ - FUNSTACK; - log << "Removing device <" << d << ">" << endl; - - BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(1); // timout must be greater than zero, eventhough I only return remembered devices! - BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - - bdsp.fReturnAuthenticated = FALSE; - bdsp.fReturnRemembered = TRUE; - bdsp.fReturnUnknown = FALSE; - bdsp.fReturnConnected = TRUE; - - DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),BluetoothFindDeviceClose); - - //const DWORD dwErr = GetLastError(); - - if (hbf()==NULL) { - log << " ** error: failed to find device" << endl << "Done [FAILED]" << endl; - return false; - } - - int i=0; - while(true){ - if (ReachedMax(i)) break; - const string fd=ConvertName(bdi.szName); - log << " found device [" << i << "]: <" << (fd.size()>0 ? fd : "NONAME") << ">" << endl; - - if (fd==d){ - log << " found match..." << endl; - log << " trying to remove..." << endl; - - return RemoveDev(bdi); - } - if (BluetoothFindNextDevice(hbf(), &bdi) == FALSE) break; - ++i; - } - log << " ** error: failed to find device" << endl << "Done [FAILED]" << endl; - return false; -} - -bool MatchAdr(const string& pattern,const string& adr) -{ - assert(pattern.size()==17 && adr.size()==17); - for(size_t i=0;i<17;++i){ - if (!(pattern[i]=='?' || pattern[i]==adr[i])) return false; - } - return true; -} - -bool MatchDevice(const string& d,const vector& known_adr,const BLUETOOTH_DEVICE_INFO& bdi,const bool dbg) -{ - FUNSTACK; - - const string found_adr=ConvertAddress(bdi.Address); - bool wildcard=false; - for(size_t i=0;i(p); - assert(p!=0 && q->done==false && q->timeout>0 && q->hbf==0 ); - - BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(q->timeout); - - q->hbf=BluetoothFindFirstDevice(&bdsp,&q->bdi); - const DWORD status=GetLastError(); - - if (status==ERROR_INVALID_PARAMETER) throw_("BluetoothFindFirstDevice(), returned status=ERROR_INVALID_PARAMETER"); - else if (status==ERROR_REVISION_MISMATCH) throw_("BluetoothFindFirstDevice(), returned status=ERROR_REVISION_MISMATCH"); - - q->done=true; - return 0; -} - -bool OpenDevice(const string& d,const string& btr,const int timeout,const int wiitimeout,const vector& known_adr,const int btsleep,const string& lib,const bool precheckwiimotes,const bool rumble,const bool dbg,bool& invalidargflag) -{ - FUNSTACK; - assert( invalidargflag==false ); - log << "Open device <" << d << ">" << endl; - - if (precheckwiimotes && Wiilib::OpenDevices(lib,wiitimeout,false,dbg,true)>=1) { - log << " service is already opened..." << endl << "Done [OK]" << endl; - return true; - } - - if (dbg && known_adr.size()>0) { - log << " known addresses="; - for(size_t i=0;i hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose); - // - // FIX: start the BluetoothFindFirstDevice() function in a thread, terminate the thread if it has run for longer than, say 2+timeout. - // - // Old code: - // BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(timeout); - // BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - // DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose); - // DWORD status=GetLastError(); - - unsigned long tid=0; - DeviceAutoClose h(CreateThread(0,0,BluetoothFindFirstDevice_thread,&p,0,&tid),CloseHandle); - timer tthread; - - Sleep(timeout); - while(!p.done && tthread.elapsed()*1000<2*timeout) Sleep(20); // or use WaitForMultipleObjects(...); - } - - if(!p.done){ - log << " ** error: BluetoothFindFirstDevice() stalled" << endl<< "Done [FAILED]" << endl; - return false; - } - else if(p.hbf==0){ - log << " ** error: BluetoothFindFirstDevice() returned null hbf" << endl<< "Done [FAILED]" << endl; - return false; - } - - assert(p.hbf!=0); - BLUETOOTH_DEVICE_INFO bdi=p.bdi; - DeviceAutoClose hbf(p.hbf,BluetoothFindDeviceClose); - - if (hbf()==NULL) { - log << " ** error: no devices found" << endl << "Done [FAILED]" << endl; - return false; - } - - int i=0; - while(true){ - if (ReachedMax(i)) break; - const string fd=ConvertName(bdi.szName); - log << " found device [" << i << "]: <" << (fd.size()>0 ? fd : "NONAME") << ">" << endl; - - if (MatchDevice(d,known_adr,bdi,dbg)){ - log << " found match..." << endl; - if (dbg) log << tostring(bdi); - - // write binary dbi, test code for now - //ofstream ox("bdi.out",ios::binary); - //ox.write(reinterpret_cast(&bdi),sizeof(bdi)); - - log << " trying to open..." << endl; - DWORD status=BluetoothUpdateDeviceRecord(&bdi); - if (status!=ERROR_SUCCESS) throw_("BluetoothUpdateDeviceRecord() failed"); - if (dbg) log << " BluetoothUpdateDeviceRecord()...OK" << endl; - - { - DeviceAutoClose hRadio(RadioInfo(btr,dbg),CloseHandle); - if (hRadio()==NULL) throw_("failed to get radio"); - if (dbg) log << " RadioInfo()...OK" << endl; - - GUID service=HumanInterfaceDeviceServiceClass_UUID; - status=BluetoothSetServiceState(hRadio(),&bdi,&service,BLUETOOTH_SERVICE_ENABLE); - - if (dbg && status==ERROR_SUCCESS) log << " BluetoothSetServiceState()...OK" << endl; - if (dbg && status!=ERROR_SUCCESS) log << " BluetoothSetServiceState()...ERROR" << endl; - } - - if (status!=ERROR_SUCCESS) { - string t; - if (status==ERROR_INVALID_PARAMETER) t="ERROR_INVALID_PARAMETER"; - else if (status==ERROR_SERVICE_DOES_NOT_EXIST) t="ERROR_SERVICE_DOES_NOT_EXIST"; - else if (status==E_INVALIDARG) t="E_INVALIDARG"; - // if (status!=E_INVALIDARG) throw_("BluetoothSetServiceState() failed with errorcode " + t); - // else log << " ** error: BluetoothSetServiceState() returned " << t << endl; - - if (status==E_INVALIDARG) invalidargflag=true; - log << " ** error: BluetoothSetServiceState() returned " << t << endl; - log << endl << "Done [FAILED]" << endl; - return false; - } - - // sleep while windows slowly does strange things - Sleep(btsleep); - - if (lib!="none") - { - if (Wiilib::OpenDevices(lib,wiitimeout,rumble,dbg)==0) { - log << " ** error: service could not be opened..." << endl<< "Done [FAILED]" << endl; - return false; - } - } - - log << " service on device enabled..." << endl << " opended device successfully..." << endl << "Done [OK]" << endl; - return true; - } - - if (BluetoothFindNextDevice(hbf(), &bdi) == FALSE) break; - ++i; - } - log << " ** error: device not mathced" << endl<< "Done [FAILED]" << endl; - return false; -} - -bool AutoOpenDevice(const string& d,const string& btr,const int timeout,const int wiitimeout,const int usbsleep,const int btsleep,const int usbmsleep,const string& cf,const string& lib,const int removemode,const int usbmode,const bool wb,const int scanretries,const bool dbg,bool& invalidargflag) -{ - FUNSTACK; - - int cl=0; - if (g_automode_callback==0) g_automode_callback=&DummyCallback; - - if (usbmode==2 && ScanforUSBmicrodevs()!=1) { - log << "Could not find any USBm devices" << endl << "Wiiscan done [FAILED]" << endl; - return false; - } - if (usbmode==3 && ScanforDelcomdevs()!=1) { - log << "Could not find any Delcom devices" << endl << "Wiiscan done [FAILED]" << endl; - return false; - } - - g_automode_callback(cl++); - - timer total; - assert(usbsleep>=0 && btsleep>=0 && usbmsleep>=0); - - log << "Auto-connecting to device <" << d << ">" << endl; - - // check valid config file - if (!FileExists(cf)) throw_("config file <" + cf + "> is missing"); - const Configfile c(cf); - if (dbg) log << c; - if (!c.hasEntry("all_usb_hubs")) throw_("config file missing entry"); - if (!c.hasEntry("active_usb_hub")) throw_("config file missing entry"); - if (!c.hasEntry("allowed_wiimote_adr")) throw_("config file missing entry"); - if (!c.hasEntry("whiteboard_software")) throw_("config file missing entry"); - - // test if already opened - g_automode_callback(cl++); - - if (removemode==0 && Wiilib::OpenDevices(lib,wiitimeout,false,dbg,true)>=1) { - log << " service is already opened..." << endl << "Done [OK]" << endl; - - if (wb){ - // fireup whiteboard software - if (!c.hasEntry("whiteboard_software")) log << " ** warning: config file is missing entry " << endl; - else System(c.Get("whiteboard_software",true),false,false); - } - - return true; - } - - // power down now if using USB io board - g_automode_callback(cl++); - USBupdown(usbmode,false,dbg); - timer t; - - // remove old entries in HID - g_automode_callback(cl++); - if(removemode!=2) RemoveDevice(d,dbg); - - // Cycle usb hub, turn off usb power and restart the wiimote - g_automode_callback(cl++); - if(usbmode==1){ - const string usbhub=c.Get("active_usb_hub"); - if(usbhub!="\"\""){ - USBupdown(usbmode,false,dbg,usbhub); - Sleep(usbsleep); - USBupdown(usbmode,true,dbg,usbhub); - - g_automode_callback(cl++); - - // wait for usb hub to be up, takes some seconds (1000ms to 2000ms approx) - Sleep(1800); - - // wait for usb radio to be ready - g_automode_callback(cl++); - HANDLE hRadio=RadioInfo(btr,dbg); - - int i=0; - while(hRadio==NULL) { - if (i++==0) log << " radio not ready, delaying."; - else log << "."; - Sleep(500); - hRadio=RadioInfo(btr,dbg); - if (i>10) throw_("could not connect to bluetooth radio device"); - } - CloseHandle(hRadio); - if (i>0) log << endl; - } - } else if (usbmode!=0) { - while (t.elapsed()*1000=1 ); - while(!openok && ++retries<=scanretries){ - openok=OpenDevice(d,btr,min(retries*timeout,8000),wiitimeout,c("allowed_wiimote_adr"),btsleep,lib,false,false,dbg,invalidargflag); - } - - if (openok){ - g_automode_callback(cl++); - if (wb){ - g_automode_callback(cl++); - // terminate running wb's - - // fireup whiteboard software - if (!c.hasEntry("whiteboard_software")) log << " ** warning: config file is missing entry " << endl; - else System(c.Get("whiteboard_software",true),false,false); - } - } - if (dbg) log << " Elapsed time: " << total.elapsed() << " [s]" << endl; - - // taking longer than 20 sec will bring up an annoying windows reboot dialog, - // that can be ignored, hence warn at 18 sec - if (total.elapsed()>18) log << " ** warning: connection took a long time to finish, this may cause a windows reboot dialog, that can be ignored" << endl; - - if (!openok) log << " ** warning: could not open device" << endl << "Done [FAILED]" << endl; - - assert(cl<10); - g_automode_callback(42); - return openok; -} - -int Usage(const args& arg,const string msg="") -{ - FUNSTACK; - if (msg.size()>0) log << msg << endl; - log << "Usage: " << arg[0] << " <-a | -c | -d | -r | -s | -usbup | -usbdown> [-cf ] [-lf ] [-b ] [-t ] [-u ] [-p ] [-w ] [-q ] [-f ] [-m ] [-l ] [-y] [-wb] [-v] " << endl; - log << " " << Version() << " " << Config() << endl; - log << " modes:" << endl; - log << " -a : autoconnect to device" << endl; - log << " -c : connect the device, that matches this name" << endl; - log << " -d : deletes the device, that matches this name" << endl; - log << " -r: lookup and list bluetooth radio devices" << endl; - log << " -s: scan external bluetooth devices" << endl; - log << " -usbdown: disable usb hubs" << endl; - log << " -usbup: enable usb hubs" << endl; - log << " options:" << endl; - log << " -cf : specify a distinct configurationfile, default=" << DEFAULT_configfile << endl; - log << " -lf : specify a distinct logfile, default=" << DEFAULT_logfile << endl; - log << " -b : automode bluetooth connection sleep in milliseconds, default=" << DEFAULT_btsleep << endl; - log << " -t : timeout for bluetooth stack in milliseconds, default=" << DEFAULT_timeout << endl; - log << " -u : automode usb connection sleep in milliseconds, default=" << DEFAULT_usbsleep << endl; - log << " -p : automode usbm post-connection sleep in milliseconds, default=" << DEFAULT_usbmsleep << endl; - log << " -w : timeout for wiimote in milliseconds, default=" << DEFAULT_wiitimeout << endl; - log << " -q : use bluetooth radio with this address (not working), default=any device" << endl; - log << " -f : pre-remove mode of device, 0=remove if not connectable, 1=always remove, 2=never remove, default=" << DEFAULT_removemode << endl; - log << " -m : choose USB powercycle mode, 0=no power cycle, 1=use USB hub, 2=use USBm IO hardware, 3=use USB Delcon IO hardware" << endl; - log << " -l : use specific wiimote library, lib can be one-of {wiiuse,wiimotelib, default=" << DEFAULT_wiilib << endl; - log << " -y : scan retries in automode, default=" << DEFAULT_scanretries<< endl; - log << " -wb: start whiteboard in automode" << endl; - log << " -nowb: do not start whiteboard in automode" << endl; - log << " -v: enable extra debugging printouts" << endl; - log << " default mode: -a \"" << NINTENDO_DEV << "\"" << endl; - log << " note: \"nintendo\" is a shortcut for \"" << NINTENDO_DEV << "\"" << endl; - return -1; -} - -int main(int argc,char** argv) -{ - FUNSTACK; - bool invalidargflag=false; - try{ - SetNiceLevel(-15); // set to time-critical - args arg(argc,argv); - - // first, parse the command line configfile, then load the config, finally override any configfile options with given command line options - string cf=arg.parseval("-cf",DEFAULT_configfile); - - bool v=false,wb=false; - int timeout =DEFAULT_timeout; - int wiitimeout=DEFAULT_wiitimeout; - int usbsleep =DEFAULT_usbsleep; - int usbmsleep =DEFAULT_usbmsleep; - int btsleep =DEFAULT_btsleep; - int usbmode =DEFAULT_usbmode; - int removemode=DEFAULT_removemode; - int scanretries=DEFAULT_scanretries; - string a,c,d,btr,lf=DEFAULT_logfile,dev=NINTENDO_DEV,lib=DEFAULT_wiilib; - - if (FileExists(cf)){ - const Configfile cnf(cf); - if (cnf.hasEntry("option_device")) dev=strip(cnf.Get("option_device"),'"'); - if (cnf.hasEntry("option_timeout")) timeout=cnf.Get("option_timeout"); - if (cnf.hasEntry("option_wiitimeout")) wiitimeout=cnf.Get("option_wiitimeout"); - if (cnf.hasEntry("option_usbsleep")) usbsleep=cnf.Get("option_usbsleep"); - if (cnf.hasEntry("option_usbmsleep")) usbmsleep=cnf.Get("option_usbmsleep"); - if (cnf.hasEntry("option_btsleep")) btsleep=cnf.Get("option_btsleep"); - if (cnf.hasEntry("option_usbpowermode")) usbmode=cnf.Get("option_usbpowermode"); - if (cnf.hasEntry("option_removemode")) removemode=cnf.Get("option_removemode"); - if (cnf.hasEntry("option_debug")) v=cnf.Get("option_debug"); - if (cnf.hasEntry("option_startwhiteboard")) wb=cnf.Get("option_startwhiteboard"); - if (cnf.hasEntry("option_logfile")) lf=cnf.Get("option_logfile"); - if (cnf.hasEntry("option_btradio")) btr=cnf.Get("option_btradio"); - if (cnf.hasEntry("option_wiilib")) lib=cnf.Get("option_wiilib"); - if (cnf.hasEntry("option_scanretries"))scanretries=cnf.Get("option_scanretries"); - } - - // parse argumets via args class - const bool r=arg.parseopt("-r"); - const bool s=arg.parseopt("-s"); - const bool u=arg.parseopt("-?"); - const bool usbdown=arg.parseopt("-usbdown"); - const bool usbup=arg.parseopt("-usbup"); - v=arg.parseopt("-v") || v; - wb=arg.parseopt("-wb") || wb; - wb=!arg.parseopt("-nowb") && wb; - timeout =arg.parseval("-t",timeout); - wiitimeout=arg.parseval("-w",wiitimeout); - usbsleep =arg.parseval("-u",usbsleep); - usbmsleep =arg.parseval("-p",usbmsleep); - btsleep =arg.parseval("-b",btsleep); - usbmode =arg.parseval("-m",usbmode); - removemode=arg.parseval("-f",removemode); - a=arg.parseval("-a",""); - c=arg.parseval("-c",""); - d=arg.parseval("-d",""); - lf=arg.parseval("-lf",lf); - btr=arg.parseval("-q",btr); - lib=arg.parseval("-l",lib); - scanretries=arg.parseval("-y",scanretries); - - if (arg.size()!=1) return Usage(arg); - - // apply shortcuts - if (a=="nintendo") a=dev; - if (c=="nintendo") c=dev; - if (d=="nintendo") d=dev; - - // open log file before Usage call - if(lf!=DEFAULT_logfile){ - lf=strip(lf,'"'); // cannot handle filenames in citation quotes - if (lf=="cout" || lf=="std::cout") g_log=&cout; - else if (lf=="cerr" || lf=="std::cerr") g_log=&cerr; - else { - g_log.open(lf,ios_base::app); - g_log.writelogheader("Wiiscan::main()"); - if (v) log << "Using logfile <" << lf << ">" << endl; - } - } - - const int check=(r ? 1 : 0)+ (s ? 1 : 0) + (a.size()>0 ? 1 : 0) + (c.size()>0 ? 1 : 0) + (d.size()>0 ? 1 : 0) + usbup + usbdown; - if (check>1 || u) return Usage(arg); - - if (timeout<20) throw_("bad value of timeout, should be >=20"); - if (wiitimeout<20)throw_("bad value of wiitimeout, should be >=20"); - if (usbsleep<20) throw_("bad value of usbsleep, should be >=20"); - if (usbmsleep<20) throw_("bad value of usbmsleep, should be >=20"); - if (btsleep<20) throw_("bad value of btsleep, should be >=20"); - if (usbdown && usbup) throw_("bad value of usbdown/up, cannot be used at the same time"); - if (wiitimeout%1000!=0) throw_("bad value, wiitimeout should be divisable with 1000"); - if (btr.size()>0 && btr.size()!=17) throw_("bluetooth radio must be in the form xx:xx:xx:xx:xx:xx"); - if (usbmode<0 || usbmode>3) throw_("bad usbpowermode, must be 0,1,2, or 3"); - if (removemode<0 || removemode>2) throw_("bad removemode, must be 0,1 or 2"); - if (scanretries<=0) throw_("bad value of scanretries, should be > 0"); - if (a.size()==0) a=NINTENDO_DEV; - - if (v) { - log << Version() << " " << Config() << endl; - log << "Values:" << endl; - log << " a=" << a << endl; - log << " c=" << c << endl; - log << " d=" << d << endl; - log << " r=" << r << endl; - log << " s=" << s << endl; - log << " v=" << v << endl; - log << " cf=" << cf << endl; - log << " lf=" << lf << endl; - log << " wb=" << wb << endl; - log << " btr=" << btr << endl; - log << " lib=" << lib << endl; - log << " usbmode=" << usbmode << endl; - log << " removemode=" << removemode << endl; - log << " scanretries=" << scanretries << endl; - log << " usbup =" << usbup << endl; - log << " usbdown=" << usbup << endl; - log << "Timeouts:" << endl; - log << " timeout =" << timeout << endl; - log << " wiitimeout=" << wiitimeout << endl; - log << " usbsleep =" << usbsleep << endl; - log << " usbmsleep =" << usbmsleep << endl; - log << " btsleep =" << btsleep << endl; - } - - bool ret=true; - - if (r) ret=RadioInfo (btr.size()==0 ? "all" : btr,v)!=NULL; - else if (s) ret=ScanDevices (timeout); - else if (c.size()>0) ret=OpenDevice (c,btr,timeout,wiitimeout,vector(),btsleep,lib,true,true,v,invalidargflag); - else if (d.size()>0) ret=RemoveDevice(d,v); - else if (usbup) ret=USBupdown (usbmode,true, v,Configfile(cf).Get("active_usb_hub",true)); - else if (usbdown) ret=USBupdown (usbmode,false,v,Configfile(cf).Get("active_usb_hub",true)); - else ret=AutoOpenDevice(a,btr,timeout,wiitimeout,usbsleep,btsleep,usbmsleep,cf,lib,removemode,usbmode,wb,scanretries,v,invalidargflag); // default mode - - log << "Wiiscan done " << (ret ? "[OK]" : "[FAILED]") << endl; - - if (invalidargflag) { - if (v) log << "** warning: return=-3 (E_INVALIDARG)" << endl; - return -3; - } - - if (v) log << "returning: return=" << (ret ? "0" : "-1") << endl; - return ret ? 0 : -1; // 0=Ok, -1=fail, -2=fail with exception, -3=fail with E_INVALIDARG - } - CATCH_ALL; - - assert(invalidargflag==false); // flag not setted => no throw in when E_INVALIDARG encoutered - log << "Wiiscan done [FAILED]" << endl; - return -2; -} - -}; // namespace Wiiscan diff --git a/cpp/wiiscan/src/wiiscan.test.h b/cpp/wiiscan/src/wiiscan.test.h deleted file mode 100644 index dd5c4e5..0000000 --- a/cpp/wiiscan/src/wiiscan.test.h +++ /dev/null @@ -1,1662 +0,0 @@ -// Copyright © 2009 MergeIt, Aps. -// -// License LGPLv3+: GNU lesser LGPL version 3 or later . -// This is free software: you are free to change and redistribute it. -// There is NO WARRANTY, to the extent permitted by law. -// -// This file is part of wiiscan. -// -// wiiscan 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 3 of the License, or -// any later version. -// -// wiiscan 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 wiiscan. If not, see . - -#define VERSION 0 -#define VERSION_REV 9 - -#define VC_EXTRALEAN - -#include "toolsfun.h" -#include "wiiuse.h" -#include "usbm.h" -#include "delcomdll.h" -#include -#include - -#pragma comment ( lib, "Lib/wiiuse.lib") -#pragma comment ( lib, "Lib/delcomdll.lib") -#pragma comment ( lib, "Irprops.lib") -#pragma comment ( lib, "Ws2_32.lib") - -void Connect_using_BT_Api(); - -namespace Wiiscan { - -// default values -const int MAX_DEVICE_COUNT =256; -const int DEFAULT_timeout =2000; -const int DEFAULT_wiitimeout=2000; -const int DEFAULT_usbsleep =500; -const int DEFAULT_usbmsleep =3000; -const int DEFAULT_btsleep =2000; -const int DEFAULT_usbmode =0; -const int DEFAULT_removemode=0; -const int DEFAULT_scanretries=1; -const string NINTENDO_DEV="Nintendo RVL-CNT-01"; -const string DEFAULT_configfile="wiiscan.ini"; -const string DEFAULT_logfile="cout"; -const string DEFAULT_wiilib="wiimotelib"; - -Logger& log=g_log; -void (*g_automode_callback)(const int)=0; -void DummyCallback(const int){FUNSTACK;} - -string ConvertName(const WCHAR* szName) -{ - FUNSTACK; - assert( MAX_PATH >= BLUETOOTH_MAX_NAME_SIZE ); - CHAR szDevName[MAX_PATH]; - memset(szDevName, 0x00, sizeof(szDevName)); - sprintf_s(szDevName,MAX_PATH,"%S", szName); - return string(szDevName); -} - -string ConvertAddress(const BLUETOOTH_ADDRESS& address) -{ - FUNSTACK; - string s; - char t[256]; - for(int i=5;i>=0;i--) { - sprintf_s(t,256,"%X",address.rgBytes[i]); - string x=t; - if (x.size()==1) x="0"+x; - s+=x+(i==0 ? "" : ":"); - } - return s; -} - -string tostring(const SYSTEMTIME& x) -{ - FUNSTACK; - // XXX warning: no converstion of GMT to local time - ostringstream s; - if (x.wHour==0 && x.wMinute==0 && x.wDay==0 && x.wYear==0 && x.wYear==0) s << ""; - else s << x.wHour << ":" << (x.wMinute<10 ? "0" : "") << x.wMinute << " d. " << x.wDay << "/" << x.wMonth << ", " << x.wYear; - return s.str(); -} - -string tostring(const BLUETOOTH_DEVICE_INFO& x) -{ - FUNSTACK; - ostringstream s; - s << " BLUETOOTH_DEVICE_INFO:" << endl; - s << " dwSize: " << x.dwSize << endl; - s << " Address: " << ConvertAddress(x.Address) << endl; - s << " ulClassofDevice:" << x.ulClassofDevice << endl; - s << " fConnected: " << x.fConnected << endl; - s << " fRemembered: " << x.fRemembered << endl; - s << " fAuthenticated: " << x.fAuthenticated << endl; - s << " stLastSeen: " << tostring(x.stLastSeen) << " [GMT]" << endl; - s << " stLastUsed: " << tostring(x.stLastUsed) << " [GMT]" << endl; - s << " szName: " << ConvertName(x.szName) << endl; - return s.str(); -} - -string tostring(const BLUETOOTH_RADIO_INFO& x) -{ - FUNSTACK; - ostringstream s; - s << " PBLUETOOTH_RADIO_INFO:" << endl; - s << " dwSize: " << x.dwSize << endl; - s << " Address: " << ConvertAddress(x.address) << endl; - s << " szName: " << ConvertName(x.szName) << endl; - s << " ulClassofDevice:" << x.ulClassofDevice << endl; - s << " lmpSubversion: " << x.lmpSubversion << endl; - s << " manufacturer: " << x.manufacturer << endl; - return s.str(); -} - -bool USB_hub_updown(const bool up,const string& usbhub) -{ - FUNSTACK; - log << (up ? "Enabling" : "Disabling") << " 'USB hub..." << endl; - int n=-1; - System(string("devcon ") + (up ? "enable " : "disable ") + usbhub,false,false,&n); - if (n!=0) throw_("devcon failed, this can be to a erroneous usbhub string or if devcon.exe is not found in path, please install it from http://support.microsoft.com/kb/311272"); - log << "Done [OK]" << endl; - return true; -} - -int ScanforUSBmicrodevs() -{ - USBio io; - io.USBm_FindDevices(); - return io.Devices(); -} - -bool USB_microio_updown(const bool up,const bool dbg) -{ - FUNSTACK; - log << (up ? "Enabling" : "Disabling") << " USBm io..." << endl; - - // Discover the USBmicro devices - USBio io; - io.USBm_FindDevices(); - const int d=io.Devices(); - if (d==0) return false; // throw_("could not find an USBm device"); - else if (d>1) throw_("found more that one USBm devices"); - - static bool premable=true; - if (dbg && premable) { - premable=false; - log << " USBm info:" << endl << io.version(); - } - - io.USBm_InitPorts(0); - io.USBm_DirectionA(0, 0xff, 0xff); - - if(up) io.USBm_ResetBit(0,5); - else io.USBm_SetBit (0,5); - - log << "Done [OK]" << endl; - return true; -} - -bool __stdcall CloseDelcomhandle(HANDLE h){return DelcomCloseDevice(h)==0;} - -void do_cmd(HANDLE di, int ma, int mi, int lsb, int msb, unsigned char *data, unsigned datalen) -{ - //static struct delcom_packet p; - PacketStruct p; - memset(&p, 0, sizeof(p)); - p.MajorCmd = ma; - p.MinorCmd = mi; - p.DataLSB = lsb; - p.DataMSB = msb; - if (DelcomSendPacket(di,&p,&p)<0) throw_("DelcomSendPacket() failed"); -} - -int ScanforDelcomdevs() -{ - // Discover the USB Delcom devices - DeviceNameStruct names[10]; // array to hold the device names found - return DelcomScanDevices(USBIODS, names, 10); -} - -bool USB_delconio_updown(const bool up,const bool dbg) -{ - FUNSTACK; - log << (up ? "Enabling" : "Disabling") << " USB Delcom io..." << endl; - - DeviceNameStruct names[10]; // array to hold the device names found - const int d=DelcomScanDevices(USBIODS, names, 10); - if (d==0) return false; //throw_("could not find an USB Delcon device"); - else if (d>1) throw_("found more that one USB Delcon devices"); - - static bool premable=true; - if (dbg && premable) { - premable=false; - log << " USB Delcon info:" << (char*)&names[0] << "\n SN=" << DelcomReadDeviceSerialNum((char*)&names[0], NULL) << endl; - } - - DeviceAutoClose h(DelcomOpenDevice((char*)&names[0],0),CloseDelcomhandle); - if(up) do_cmd(h(),10,1,0xFE,0,0,0); - else do_cmd(h(),10,1,0xFF,0,0,0); - - log << "Done [OK]" << endl; - return true; -} - -bool USBupdown(const int iomode,const bool up,const bool dbg,const string& usbhub="") -{ - if (iomode==0) return true; - if (iomode==1) return USB_hub_updown(up,usbhub); - if (iomode==2) return USB_microio_updown(up,dbg); - else if (iomode==3) return USB_delconio_updown(up,dbg); - else throw_("bad io mode"); - return false; -} - -class Wiilib -{ - // Wiilib class based on wiiuse library by Michael Laforest. - // Library located at http://www.wiiuse.net - // Wiiuse premable from wiiuse_v0.12/example/example.c: - - // - // wiiuse - // - // Written By: - // Michael Laforest < para > - // Email: < thepara (--AT--) g m a i l [--DOT--] com > - // - // Copyright 2006-2007 - // - // This file is part of wiiuse. - // - // 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 3 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, see . - -private: - enum {MAX_WIIMOTES=1}; // use only one wiimote, but can connect to four - wiimote** m_wiimotes; - static int m_instantiations; - - int finddevices(const int wiitimeout,const bool rumble,const bool dbg) - { - FUNSTACK; - - // Find wiimote devices - const int to=wiitimeout/1000; - if (to<1) throw_("bad wiitimeout value, should be >=1000"); - const int found=wiiuse_find(m_wiimotes,MAX_WIIMOTES,to); - if (dbg) log << " wiiuse_find(0x0," << MAX_WIIMOTES << "," << to << ") return " << found << endl; - - if (found==0) { - if (dbg) log << " ** error: no wiimotes found" << endl; - return 0; - } - - // Connect to the wiimotes - assert(found>0); - - const int connected = wiiuse_connect(m_wiimotes, MAX_WIIMOTES); - if (connected==0){ - log << " ** error: could not connect to any wiimotes" << endl; - return 0; - } - if (dbg) log << " connected to " << connected<< " wiimotes (of " << MAX_WIIMOTES << " found)" << endl; - - - // Now set the LEDs and rumble for a second so it's easy - // to tell which wiimotes are connected (just like the wii does). - wiiuse_set_leds(m_wiimotes[0], WIIMOTE_LED_1); - - if (rumble){ - wiiuse_rumble(m_wiimotes[0], 1); - #ifndef WIN32 - usleep(200000); - #else - Sleep(200); - #endif - wiiuse_rumble(m_wiimotes[0], 0); - } - - // read some data to be sure of connection - for(int i=0;i<8;++i){ - Sleep(50); - - int led=0; - switch(i%6){ - case 0 : led=WIIMOTE_LED_1; break; - case 1 : led=WIIMOTE_LED_2; break; - case 2 : led=WIIMOTE_LED_3; break; - case 3 : led=WIIMOTE_LED_4; break; - case 4 : led=WIIMOTE_LED_3; break; - case 5 : led=WIIMOTE_LED_2; break; - } - wiiuse_rumble(m_wiimotes[0], 0); // to be sure - wiiuse_set_leds(m_wiimotes[0],led); - wiiuse_status(m_wiimotes[0]); - if (led!=m_wiimotes[0]->leds) throw_("bad LED status on wiimote, is it connected properly?"); - } - - // set all leds, retry a couple of time to be sure - for(int i=0;i<4;++i){ - wiiuse_set_leds(m_wiimotes[0],WIIMOTE_LED_1 | WIIMOTE_LED_2 | WIIMOTE_LED_3 | WIIMOTE_LED_4); - Sleep(100); - } - - return connected; - } - - Wiilib() : m_wiimotes(0) - { - FUNSTACK; - if (m_instantiations!=0) throw_("can only instatiate one Wiilib at a time"); - ++m_instantiations; // assumes a single-thread application, else we have a race condition here - - // Initialize an array of wiimote objects. - // The parameter is the number of wiimotes I want to create. - m_wiimotes = wiiuse_init(MAX_WIIMOTES); - // wiiuse_set_bluetooth_stack(m_wiimotes, MAX_WIIMOTES,WIIUSE_STACK_MS); must be done automatically - assert(m_instantiations==1); - } - - ~Wiilib() - { - FUNSTACK; - assert( m_instantiations==1 ); - - // Disconnect the wiimotes - if (m_wiimotes!=0) wiiuse_cleanup(m_wiimotes, MAX_WIIMOTES); - m_wiimotes=0; - --m_instantiations; - assert(m_instantiations==0); - } - - static int OpenDevices_wiilib(const int wiitimeout,const bool rumble,const bool dbg,const bool precheck=false) - { - FUNSTACK; - int n=0,retries=0; - while(n==0 && retries++<10) { - n=Wiilib().finddevices(wiitimeout,rumble,dbg); - if (precheck) break; - if (n==0) { - if (dbg) log << " OpenDevice()...delaying " << (retries<5 ? "250" : "1000") << " [ms]" << endl; - if (retries<5) Sleep(250); - else Sleep(1000); - } - } - if (dbg) {cerr.flush(); log << " Wiilib::OpenDevice..." << n << endl;} - return n; - } - - static int OpenDevices_wiimotelib(const int wiitimeout,const bool rumble,const bool dbg,const bool precheck=false) - { - FUNSTACK; - int n=0,retries=0; - while(n==0 && retries++<10) { - n=system("wiimotelibpoll")==0 ? 1 : 0; - if (precheck) break; - if (n==0) { - if (dbg) log << " OpenDevice()...delaying " << (retries<5 ? "250" : "1000") << " [ms]" << endl; - if (retries<5) Sleep(250); - else Sleep(1000); - } - } - if (dbg) {cerr.flush(); log << " Wiilib::OpenDevice..." << n << endl;} - return n; - } - -public: - - static int OpenDevices(const string& wiilib,const int wiitimeout,const bool rumble,const bool dbg,const bool precheck=false) - { - FUNSTACK; - if (wiilib=="wiiuse") return OpenDevices_wiilib(wiitimeout,rumble,dbg,precheck); - else if (wiilib=="wiimotelib") return OpenDevices_wiimotelib(wiitimeout,rumble,dbg,precheck); - else if (wiilib=="none") return -1; - else throw_("Wiilib::OpenDevices(), library must be one-of {wiiuse,wiimotelib,none}"); - return -1; // avoid compiler error - } - -}; - -int Wiilib::m_instantiations=0; - -BLUETOOTH_DEVICE_SEARCH_PARAMS Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(const int timeout) -{ - FUNSTACK; - BLUETOOTH_DEVICE_SEARCH_PARAMS b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - b.fReturnAuthenticated = TRUE; - b.fReturnRemembered = TRUE; - b.fReturnUnknown = TRUE; - b.fReturnConnected = TRUE; - b.fIssueInquiry = TRUE; - - const int to=static_cast(1.0*timeout/1000.0/1.28+0.5); - assert(to>=0 && to<48 ); - b.cTimeoutMultiplier = (to==0 ? 1 : to); // timeout of 0 causes havac - b.hRadio = NULL; - - assert( b.cTimeoutMultiplier>0 ); - return b; -} - -BLUETOOTH_DEVICE_INFO Get_BLUETOOTH_DEVICE_INFO() -{ - FUNSTACK; - BLUETOOTH_DEVICE_INFO b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - return b; -} - -BLUETOOTH_RADIO_INFO Get_BLUETOOTH_RADIO_INFO() -{ - FUNSTACK; - BLUETOOTH_RADIO_INFO b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - return b; -} - -BLUETOOTH_FIND_RADIO_PARAMS Get_BLUETOOTH_FIND_RADIO_PARAMS() -{ - FUNSTACK; - BLUETOOTH_FIND_RADIO_PARAMS b; - ZeroMemory(&b, sizeof(b)); - b.dwSize = sizeof(b); - return b; -} - -bool ReachedMax(const int i) -{ - FUNSTACK; - if (i>MAX_DEVICE_COUNT) { - log << " ** warning: too many devices found, can only handle " << MAX_DEVICE_COUNT << " devices" << endl; - return true; - } - return false; -} - -bool RemoveDev(const BLUETOOTH_DEVICE_INFO& bdi) -{ - FUNSTACK; - DWORD status=BluetoothUpdateDeviceRecord(&bdi); - if (status!=ERROR_SUCCESS) throw_("BluetoothUpdateDeviceRecord() failed"); - - status=BluetoothRemoveDevice(&bdi.Address); - if (status==ERROR_SUCCESS) log << " removed device successfully..." << endl << "Done [OK]" << endl; - else log << " ** error: removing the device failed, was it registred at all?" << endl <<"Done [FAILED]" << endl; - - return status==ERROR_SUCCESS; -} - -HANDLE RadioInfo(const string& btr,const bool dbg) -{ - FUNSTACK; - if (dbg) log << " Radio info" << endl; - assert( btr.size()==17 || btr.size()==0 || btr=="all"); - - HANDLE hRadio=NULL; - BLUETOOTH_FIND_RADIO_PARAMS btfrp=Get_BLUETOOTH_FIND_RADIO_PARAMS(); - DeviceAutoClose hbf(BluetoothFindFirstRadio(&btfrp,&hRadio),&BluetoothFindRadioClose); - - if (hbf()==NULL) { - if (dbg) log << " " << endl; - return NULL; - } - - while(hbf()!=NULL){ - if (hbf()==NULL) throw_("BluetoothFindFirstRadio() failed"); - - BLUETOOTH_RADIO_INFO r=Get_BLUETOOTH_RADIO_INFO(); - if (BluetoothGetRadioInfo(hRadio,&r)!=ERROR_SUCCESS) throw_("BluetoothGetRadioInfo() failed"); - - const int c=BluetoothIsConnectable(hRadio); - const int d=BluetoothIsDiscoverable(hRadio); - - if (dbg){ - log << indent(tostring(r)," "); - log << " connectable: " << c << endl; - log << " discoverabel: " << d << endl; - } - - if (btr.size()==0) break; - else if (btr==ConvertAddress(r.address)){ - if (dbg) log << " found radio address match " << (btr.size()>0 ? ": " + btr : "") << endl; - break; - } - - if (!BluetoothFindNextRadio(&btfrp,&hRadio)) break; - } - - if (dbg) log << "Done [" << (hRadio==NULL ? "FAILED" : "OK") << "]" << endl; - return hRadio; -} - -bool ScanDevices(const int timeout) -{ - FUNSTACK; - log << "Scanning devices" << endl; - - vector infos; - - BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(timeout); - BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - - DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose); - const DWORD dwErr = GetLastError(); - - if (hbf()==NULL) { - log << " ** warning: no devices found" << endl << "Done [FAILED]" << endl; - return false;; - } - - if (hbf()!= NULL) { - log << "Looking for devices..." << endl; - - int i=0; - while(1){ - if (ReachedMax(i)) break; - - const string t=ConvertName(bdi.szName); - log << " found device [" << i << "]: <" << (t.size()>0 ? t : "NONAME") << ">" << endl; - - infos.push_back(bdi); - - if (BluetoothFindNextDevice(hbf(), &bdi) == FALSE) - break; - - ++i; - } - } - - log << "BTDevices info:" << endl; - if (infos.size()==0) log << " " << endl; - else for(size_t i=0;i0 ? s : "") << endl; - log << tostring(t); - } - log << "Done [OK]" << endl; - - return true; -} - -bool RemoveDevice(const string& d,const bool dbg) -{ - FUNSTACK; - log << "Removing device <" << d << ">" << endl; - - BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(1); // timout must be greater than zero, eventhough I only return remembered devices! - BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - - bdsp.fReturnAuthenticated = FALSE; - bdsp.fReturnRemembered = TRUE; - bdsp.fReturnUnknown = FALSE; - bdsp.fReturnConnected = TRUE; - - DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose); - - const DWORD dwErr = GetLastError(); - - if (hbf()==NULL) { - log << " ** error: failed to find device" << endl << "Done [FAILED]" << endl; - return false; - } - - int i=0; - while(true){ - if (ReachedMax(i)) break; - const string fd=ConvertName(bdi.szName); - log << " found device [" << i << "]: <" << (fd.size()>0 ? fd : "NONAME") << ">" << endl; - - if (fd==d){ - log << " found match..." << endl; - log << " trying to remove..." << endl; - - return RemoveDev(bdi); - } - if (BluetoothFindNextDevice(hbf(), &bdi) == FALSE) break; - ++i; - } - log << " ** error: failed to find device" << endl << "Done [FAILED]" << endl; - return false; -} - -bool MatchAdr(const string& pattern,const string& adr) -{ - assert(pattern.size()==17 && adr.size()==17); - for(size_t i=0;i<17;++i){ - if (!(pattern[i]=='?' || pattern[i]==adr[i])) return false; - } - return true; -} - -bool MatchDevice(const string& d,const vector& known_adr,const BLUETOOTH_DEVICE_INFO& bdi,const bool dbg) -{ - FUNSTACK; - - const string found_adr=ConvertAddress(bdi.Address); - bool wildcard=false; - for(size_t i=0;i(p); - assert(p!=0 && q->done==false && q->timeout>0 && q->hbf==0 ); - - BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(q->timeout); - - q->hbf=BluetoothFindFirstDevice(&bdsp,&q->bdi); - const DWORD status=GetLastError(); - - if (status==ERROR_INVALID_PARAMETER) throw_("BluetoothFindFirstDevice(), returned status=ERROR_INVALID_PARAMETER"); - else if (status==ERROR_REVISION_MISMATCH) throw_("BluetoothFindFirstDevice(), returned status=ERROR_REVISION_MISMATCH"); - - q->done=true; - return 0; -} - -bool OpenDevice(const string& d,const string& btr,const int timeout,const int wiitimeout,const vector& known_adr,const int btsleep,const string& lib,const bool precheckwiimotes,const bool rumble,const bool dbg,bool& invalidargflag) -{ - FUNSTACK; - assert( invalidargflag==false ); - log << "Open device <" << d << ">" << endl; - - if (precheckwiimotes && Wiilib::OpenDevices(lib,wiitimeout,false,dbg,true)>=1) { - log << " service is already opened..." << endl << "Done [OK]" << endl; - return true; - } - - if (dbg && known_adr.size()>0) { - log << " known addresses="; - for(size_t i=0;i hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose); - // - // FIX: start the BluetoothFindFirstDevice() function in a thread, terminate the thread if it has run for longer than, say 2+timeout. - // - // Old code: - // BLUETOOTH_DEVICE_SEARCH_PARAMS bdsp=Get_BLUETOOTH_DEVICE_SEARCH_PARAMS(timeout); - // BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - // DeviceAutoClose hbf(BluetoothFindFirstDevice(&bdsp,&bdi),&BluetoothFindDeviceClose); - // DWORD status=GetLastError(); - - unsigned long tid=0; - DeviceAutoClose h(CreateThread(0,0,BluetoothFindFirstDevice_thread,&p,0,&tid),CloseHandle); - timer tthread; - - Sleep(timeout); - while(!p.done && tthread.elapsed()*1000<2*timeout) Sleep(20); // or use WaitForMultipleObjects(...); - } - - if(!p.done){ - log << " ** error: BluetoothFindFirstDevice() stalled" << endl<< "Done [FAILED]" << endl; - return false; - } - else if(p.hbf==0){ - log << " ** error: BluetoothFindFirstDevice() returned null hbf" << endl<< "Done [FAILED]" << endl; - return false; - } - - assert(p.hbf!=0); - BLUETOOTH_DEVICE_INFO bdi=p.bdi; - DeviceAutoClose hbf(p.hbf,&BluetoothFindDeviceClose); - - if (hbf()==NULL) { - log << " ** error: no devices found" << endl << "Done [FAILED]" << endl; - return false; - } - - int i=0; - while(true){ - if (ReachedMax(i)) break; - const string fd=ConvertName(bdi.szName); - log << " found device [" << i << "]: <" << (fd.size()>0 ? fd : "NONAME") << ">" << endl; - - if (MatchDevice(d,known_adr,bdi,dbg)){ - log << " found match..." << endl; - if (dbg) log << tostring(bdi); - - // write binary dbi, test code for now - //ofstream ox("bdi.out",ios::binary); - //ox.write(reinterpret_cast(&bdi),sizeof(bdi)); - - log << " trying to open..." << endl; - DWORD status=BluetoothUpdateDeviceRecord(&bdi); - if (status!=ERROR_SUCCESS) throw_("BluetoothUpdateDeviceRecord() failed"); - if (dbg) log << " BluetoothUpdateDeviceRecord()...OK" << endl; - - { - DeviceAutoClose hRadio(RadioInfo(btr,dbg),&CloseHandle); - if (hRadio()==NULL) throw_("failed to get radio"); - if (dbg) log << " RadioInfo()...OK" << endl; - - const GUID service=HumanInterfaceDeviceServiceClass_UUID; - status=BluetoothSetServiceState(hRadio(),&bdi,&service,BLUETOOTH_SERVICE_ENABLE); - - if (dbg && status==ERROR_SUCCESS) log << " BluetoothSetServiceState()...OK" << endl; - if (dbg && status!=ERROR_SUCCESS) log << " BluetoothSetServiceState()...ERROR" << endl; - } - - if (status!=ERROR_SUCCESS) { - string t; - if (status==ERROR_INVALID_PARAMETER) t="ERROR_INVALID_PARAMETER"; - else if (status==ERROR_SERVICE_DOES_NOT_EXIST) t="ERROR_SERVICE_DOES_NOT_EXIST"; - else if (status==E_INVALIDARG) t="E_INVALIDARG"; - // if (status!=E_INVALIDARG) throw_("BluetoothSetServiceState() failed with errorcode " + t); - // else log << " ** error: BluetoothSetServiceState() returned " << t << endl; - - if (status==E_INVALIDARG) invalidargflag=true; - log << " ** error: BluetoothSetServiceState() returned " << t << endl; - log << endl << "Done [FAILED]" << endl; - return false; - } - - // sleep while windows slowly does strange things - Sleep(btsleep); - - if (lib!="none") - { - if (Wiilib::OpenDevices(lib,wiitimeout,rumble,dbg)==0) { - log << " ** error: service could not be opened..." << endl<< "Done [FAILED]" << endl; - return false; - } - } - - log << " service on device enabled..." << endl << " opended device successfully..." << endl << "Done [OK]" << endl; - return true; - } - - if (BluetoothFindNextDevice(hbf(), &bdi) == FALSE) break; - ++i; - } - log << " ** error: device not mathced" << endl<< "Done [FAILED]" << endl; - return false; -} - -bool AutoOpenDevice(const string& d,const string& btr,const int timeout,const int wiitimeout,const int usbsleep,const int btsleep,const int usbmsleep,const string& cf,const string& lib,const int removemode,const int usbmode,const bool wb,const int scanretries,const bool dbg,bool& invalidargflag) -{ - FUNSTACK; - - int cl=0; - if (g_automode_callback==0) g_automode_callback=&DummyCallback; - - if (usbmode==2 && ScanforUSBmicrodevs()!=1) { - log << "Could not find any USBm devices" << endl << "Wiiscan done [FAILED]" << endl; - return false; - } - if (usbmode==3 && ScanforDelcomdevs()!=1) { - log << "Could not find any Delcom devices" << endl << "Wiiscan done [FAILED]" << endl; - return false; - } - - g_automode_callback(cl++); - - timer total; - assert(usbsleep>=0 && btsleep>=0 && usbmsleep>=0); - - log << "Auto-connecting to device <" << d << ">" << endl; - - // check valid config file - if (!FileExists(cf)) throw_("config file <" + cf + "> is missing"); - const Configfile c(cf); - if (dbg) log << c; - if (!c.hasEntry("all_usb_hubs")) throw_("config file missing entry"); - if (!c.hasEntry("active_usb_hub")) throw_("config file missing entry"); - if (!c.hasEntry("allowed_wiimote_adr")) throw_("config file missing entry"); - if (!c.hasEntry("whiteboard_software")) throw_("config file missing entry"); - - // test if already opened - g_automode_callback(cl++); - - if (removemode==0 && Wiilib::OpenDevices(lib,wiitimeout,false,dbg,true)>=1) { - log << " service is already opened..." << endl << "Done [OK]" << endl; - - if (wb){ - // fireup whiteboard software - if (!c.hasEntry("whiteboard_software")) log << " ** warning: config file is missing entry " << endl; - else System(c.Get("whiteboard_software",true),false,false); - } - - return true; - } - - // power down now if using USB io board - g_automode_callback(cl++); - USBupdown(usbmode,false,dbg); - timer t; - - // remove old entries in HID - g_automode_callback(cl++); - if(removemode!=2) RemoveDevice(d,dbg); - - // Cycle usb hub, turn off usb power and restart the wiimote - g_automode_callback(cl++); - if(usbmode==1){ - const string usbhub=c.Get("active_usb_hub"); - if(usbhub!="\"\""){ - USBupdown(usbmode,false,dbg,usbhub); - Sleep(usbsleep); - USBupdown(usbmode,true,dbg,usbhub); - - g_automode_callback(cl++); - - // wait for usb hub to be up, takes some seconds (1000ms to 2000ms approx) - Sleep(1800); - - // wait for usb radio to be ready - g_automode_callback(cl++); - HANDLE hRadio=RadioInfo(btr,dbg); - - int i=0; - while(hRadio==NULL) { - if (i++==0) log << " radio not ready, delaying."; - else log << "."; - Sleep(500); - hRadio=RadioInfo(btr,dbg); - if (i>10) throw_("could not connect to bluetooth radio device"); - } - CloseHandle(hRadio); - if (i>0) log << endl; - } - } else if (usbmode!=0) { - while (t.elapsed()*1000=1 ); - while(!openok && ++retries<=scanretries){ - openok=OpenDevice(d,btr,min(retries*timeout,8000),wiitimeout,c("allowed_wiimote_adr"),btsleep,lib,false,false,dbg,invalidargflag); - } - - if (openok){ - g_automode_callback(cl++); - if (wb){ - g_automode_callback(cl++); - // terminate running wb's - - // fireup whiteboard software - if (!c.hasEntry("whiteboard_software")) log << " ** warning: config file is missing entry " << endl; - else System(c.Get("whiteboard_software",true),false,false); - } - } - if (dbg) log << " Elapsed time: " << total.elapsed() << " [s]" << endl; - - // taking longer than 20 sec will bring up an annoying windows reboot dialog, - // that can be ignored, hence warn at 18 sec - if (total.elapsed()>18) log << " ** warning: connection took a long time to finish, this may cause a windows reboot dialog, that can be ignored" << endl; - - if (!openok) log << " ** warning: could not open device" << endl << "Done [FAILED]" << endl; - - assert(cl<10); - g_automode_callback(42); - return openok; -} - -int Usage(const args& arg,const string msg="") -{ - FUNSTACK; - if (msg.size()>0) log << msg << endl; - log << "Usage: " << arg[0] << " <-a | -c | -d | -r | -s | -usbup | -usbdown> [-cf ] [-lf ] [-b ] [-t ] [-u ] [-p ] [-w ] [-q ] [-f ] [-m ] [-l ] [-y] [-wb] [-v] " << endl; - log << " " << Version() << " " << Config() << endl; - log << " modes:" << endl; - log << " -a : autoconnect to device" << endl; - log << " -c : connect the device, that matches this name" << endl; - log << " -d : deletes the device, that matches this name" << endl; - log << " -r: lookup and list bluetooth radio devices" << endl; - log << " -s: scan external bluetooth devices" << endl; - log << " -usbdown: disable usb hubs" << endl; - log << " -usbup: enable usb hubs" << endl; - log << " options:" << endl; - log << " -cf : specify a distinct configurationfile, default=" << DEFAULT_configfile << endl; - log << " -lf : specify a distinct logfile, default=" << DEFAULT_logfile << endl; - log << " -b : automode bluetooth connection sleep in milliseconds, default=" << DEFAULT_btsleep << endl; - log << " -t : timeout for bluetooth stack in milliseconds, default=" << DEFAULT_timeout << endl; - log << " -u : automode usb connection sleep in milliseconds, default=" << DEFAULT_usbsleep << endl; - log << " -p : automode usbm post-connection sleep in milliseconds, default=" << DEFAULT_usbmsleep << endl; - log << " -w : timeout for wiimote in milliseconds, default=" << DEFAULT_wiitimeout << endl; - log << " -q : use bluetooth radio with this address (not working), default=any device" << endl; - log << " -f : pre-remove mode of device, 0=remove if not connectable, 1=always remove, 2=never remove, default=" << DEFAULT_removemode << endl; - log << " -m : choose USB powercycle mode, 0=no power cycle, 1=use USB hub, 2=use USBm IO hardware, 3=use USB Delcon IO hardware" << endl; - log << " -l : use specific wiimote library, lib can be one-of {wiiuse,wiimotelib, default=" << DEFAULT_wiilib << endl; - log << " -y : scan retries in automode, default=" << DEFAULT_scanretries<< endl; - log << " -wb: start whiteboard in automode" << endl; - log << " -nowb: do not start whiteboard in automode" << endl; - log << " -v: enable extra debugging printouts" << endl; - log << " default mode: -a \"" << NINTENDO_DEV << "\"" << endl; - log << " note: \"nintendo\" is a shortcut for \"" << NINTENDO_DEV << "\"" << endl; - return -1; -} - - -//#include -#include -#include - -int DoConnect() -{ - //BLUETOOTH_DEVICE_INFO device; - //device=*(BLUETOOTH_DEVICE_INFO*)lpParam; - - BLUETOOTH_DEVICE_INFO device=Get_BLUETOOTH_DEVICE_INFO(); - ifstream ix("bdi.out",ios::binary); - ix.read(reinterpret_cast(&device),sizeof(device)); - - string info; - //SOCKET s = socket(AF_BTH, SOCK_STREAM, BTHPROTO_L2CAP); - SOCKET s = socket(AF_BTH, SOCK_SEQPACKET , BTHPROTO_L2CAP); - - if (s == INVALID_SOCKET) - { - MessageBox(NULL,"","Invalid Socket",MB_OK); - exit(1); - } - - SOCKADDR_BTH bthSockAddr; - - bthSockAddr.addressFamily=AF_BTH; - bthSockAddr.btAddr=device.Address.ullLong; - bthSockAddr.port=0x11; //BT_PORT_ANY; - //bthSockAddr.serviceClassId=SerialPortServiceClass_UUID; - bthSockAddr.serviceClassId=HumanInterfaceDeviceServiceClass_UUID; - - if(0!=connect(s,(sockaddr*)&bthSockAddr,sizeof(bthSockAddr))) - MessageBox(NULL,"","Connect",MB_OK); - else - { - info="Connected to: "; - //info+=device.szName; - MessageBox(NULL,info.c_str(),"Connect",MB_OK); - } - - return 0; -} - -BOOL RegFun(LPVOID p,PBLUETOOTH_DEVICE_INFO pDevice) -{ - cout << "\n## RegFun called backed..."; - return 0; -} - -int TestOpen(const string& d,const string& btr,const bool dbg) -{ - -//Connect_using_BT_Api(); -//return 0; - - int status; - - USBupdown(3,true,dbg); - //Sleep(1000); - //return DoConnect();½ - -// USBupdown(3,false,dbg); - - BLUETOOTH_DEVICE_INFO bdi=Get_BLUETOOTH_DEVICE_INFO(); - ifstream ix("bdi.out",ios::binary); - ix.read(reinterpret_cast(&bdi),sizeof(bdi)); - - DeviceAutoClose hRadio(RadioInfo(btr,dbg),&CloseHandle); - if (hRadio()==NULL) throw_("failed to get radio"); - if (dbg) log << " RadioInfo()...OK" << endl; - - -BluetoothEnableIncomingConnections(hRadio(),1); -/* -for(int ii=0;ii<6;++ii) bdi.Address.rgBytes[ii]=0; - - HBLUETOOTH_AUTHENTICATION_REGISTRATION reg; - status=BluetoothRegisterForAuthentication(&bdi,®,RegFun,0); -*/ - - - Sleep(500); - USBupdown(3,true,dbg); - Sleep(1000); - - // Lenovo BT adr= 00:50:B6:A0:48:8C - - WCHAR pass[256]; - pass[5]=0x00; // 0x00 = 0 - pass[4]=0x50; - pass[3]=0xB6; - pass[2]=0xA0; - pass[1]=0x48; - pass[0]=0x8C; - - pass[6]=0; - - for(int i=0;i<6;++i) cout << dec << " [" << i << "]=" << hex << pass[i]; - - status=BluetoothAuthenticateDevice(NULL,hRadio(),&bdi,pass,6); - //status=BluetoothAuthenticateDevice(NULL,hRadio(),&bdi,0,0); - - // status=BluetoothAuthenticateDeviceEx(); // only found on Vista - - if (status==ERROR_SUCCESS) cout << "** OK: BluetoothAuthenticateDevice"; - else cout << "** ERROR: BluetoothAuthenticateDevice, " << status; - - if (status==ERROR_INVALID_PARAMETER) cout << "(ERROR_INVALID_PARAMETER)"; - if (status==ERROR_NO_MORE_ITEMS) cout << "(BTH_ERROR_NO_CONNECTION)"; - - - if (status==BTH_ERROR_AUTHENTICATION_FAILURE) cout << "(BTH_ERROR_AUTHENTICATION_FAILURE)"; - if (status==BTH_ERROR_NO_CONNECTION) cout << "(BTH_ERROR_NO_CONNECTION)"; - if (status==BTH_ERROR_PAGE_TIMEOUT ) cout << "(BTH_ERROR_PAGE_TIMEOUT )"; - if (status==BTH_ERROR_HARDWARE_FAILURE ) cout << "(BTH_ERROR_HARDWARE_FAILURE )"; - if (status==BTH_ERROR_AUTHENTICATION_FAILURE) cout << "(BTH_ERROR_AUTHENTICATION_FAILURE)"; - if (status==BTH_ERROR_MEMORY_FULL ) cout << "(BTH_ERROR_MEMORY_FULL )"; - if (status==BTH_ERROR_CONNECTION_TIMEOUT ) cout << "(BTH_ERROR_CONNECTION_TIMEOUT )"; - if (status==BTH_ERROR_LMP_RESPONSE_TIMEOUT) cout << "(BTH_ERROR_LMP_RESPONSE_TIMEOUT)"; - if (status==BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS ) cout << "(BTH_ERROR_MAX_NUMBER_OF_CONNECTIONS)"; - if (status==BTH_ERROR_PAIRING_NOT_ALLOWED ) cout << "(BTH_ERROR_PAIRING_NOT_ALLOWED )"; - if (status==BTH_ERROR_UNSPECIFIED_ERROR ) cout << "(BTH_ERROR_UNSPECIFIED_ERROR)"; - if (status==BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION ) cout << "(BTH_ERROR_LOCAL_HOST_TERMINATED_CONNECTION)½"; - - if (status==ERROR_SUCCESS) { - cout << "Running wb...\n"; - int n= system("D:\\wiiscan-0.9-release-2.0\\bin\\Release\\WiimoteWhiteboard.exe"); - cout << " returned n=" << n << "\n"; - } - -/* - const GUID service=HumanInterfaceDeviceServiceClass_UUID; - - status=BluetoothSetServiceState(hRadio(),&bdi,&service,BLUETOOTH_SERVICE_ENABLE); - if (dbg && status==ERROR_SUCCESS) log << " BluetoothSetServiceState(0)...OK" << endl; - else if (dbg && status==E_INVALIDARG) log << " BluetoothSetServiceState(0)...E_INVALIDARG" << endl; - else if (dbg && status!=ERROR_SUCCESS) log << " BluetoothSetServiceState(0)...ERROR" << endl; - -*/ - cout << "\n"; - Sleep(100000); - -/* - //RemoveDevice(d,dbg); - Sleep(2000); - USBupdown(3,true,dbg); - Sleep(3000); - - //return Wiilib::OpenDevices("wiiuse",4000,false,true,false); - - WCHAR pass[]=L"1234"; - return BluetoothAuthenticateDevice(NULL,hRadio(),&bdi,pass,4); - - if (dbg) log << tostring(bdi); - - status=BluetoothSetServiceState(hRadio(),&bdi,&service,BLUETOOTH_SERVICE_ENABLE); - if (dbg && status==ERROR_SUCCESS) log << " BluetoothSetServiceState(1)...OK" << endl; - else if (dbg && status==E_INVALIDARG) log << " BluetoothSetServiceState(1)...E_INVALIDARG" << endl; - else if (dbg && status!=ERROR_SUCCESS) log << " BluetoothSetServiceState(1)...ERROR" << endl; -*/ - - return 1; -} - - -int main(int argc,char** argv) -{ - FUNSTACK; - bool invalidargflag=false; - try{ - SetNiceLevel(-15); // set to time-critical - args arg(argc,argv); - - // first, parse the command line configfile, then load the config, finally override any configfile options with given command line options - string cf=arg.parseval("-cf",DEFAULT_configfile); - - bool v=false,wb=false; - int timeout =DEFAULT_timeout; - int wiitimeout=DEFAULT_wiitimeout; - int usbsleep =DEFAULT_usbsleep; - int usbmsleep =DEFAULT_usbmsleep; - int btsleep =DEFAULT_btsleep; - int usbmode =DEFAULT_usbmode; - int removemode=DEFAULT_removemode; - int scanretries=DEFAULT_scanretries; - string a,c,d,btr,lf=DEFAULT_logfile,dev=NINTENDO_DEV,lib=DEFAULT_wiilib; - - if (FileExists(cf)){ - const Configfile cnf(cf); - if (cnf.hasEntry("option_device")) dev=strip(cnf.Get("option_device"),'"'); - if (cnf.hasEntry("option_timeout")) timeout=cnf.Get("option_timeout"); - if (cnf.hasEntry("option_wiitimeout")) wiitimeout=cnf.Get("option_wiitimeout"); - if (cnf.hasEntry("option_usbsleep")) usbsleep=cnf.Get("option_usbsleep"); - if (cnf.hasEntry("option_usbmsleep")) usbmsleep=cnf.Get("option_usbmsleep"); - if (cnf.hasEntry("option_btsleep")) btsleep=cnf.Get("option_btsleep"); - if (cnf.hasEntry("option_usbpowermode")) usbmode=cnf.Get("option_usbpowermode"); - if (cnf.hasEntry("option_removemode")) removemode=cnf.Get("option_removemode"); - if (cnf.hasEntry("option_debug")) v=cnf.Get("option_debug"); - if (cnf.hasEntry("option_startwhiteboard")) wb=cnf.Get("option_startwhiteboard"); - if (cnf.hasEntry("option_logfile")) lf=cnf.Get("option_logfile"); - if (cnf.hasEntry("option_btradio")) btr=cnf.Get("option_btradio"); - if (cnf.hasEntry("option_wiilib")) lib=cnf.Get("option_wiilib"); - if (cnf.hasEntry("option_scanretries"))scanretries=cnf.Get("option_scanretries"); - } - - // parse argumets via args class - const bool r=arg.parseopt("-r"); - const bool s=arg.parseopt("-s"); - const bool u=arg.parseopt("-?"); - const bool usbdown=arg.parseopt("-usbdown"); - const bool usbup=arg.parseopt("-usbup"); - v=arg.parseopt("-v") || v; - wb=arg.parseopt("-wb") || wb; - wb=!arg.parseopt("-nowb") && wb; - timeout =arg.parseval("-t",timeout); - wiitimeout=arg.parseval("-w",wiitimeout); - usbsleep =arg.parseval("-u",usbsleep); - usbmsleep =arg.parseval("-p",usbmsleep); - btsleep =arg.parseval("-b",btsleep); - usbmode =arg.parseval("-m",usbmode); - removemode=arg.parseval("-f",removemode); - a=arg.parseval("-a",""); - c=arg.parseval("-c",""); - d=arg.parseval("-d",""); - lf=arg.parseval("-lf",lf); - btr=arg.parseval("-q",btr); - lib=arg.parseval("-l",lib); - scanretries=arg.parseval("-y",scanretries); - - if (arg.size()!=1) return Usage(arg); - - // apply shortcuts - if (a=="nintendo") a=dev; - if (c=="nintendo") c=dev; - if (d=="nintendo") d=dev; - - // open log file before Usage call - if(lf!=DEFAULT_logfile){ - lf=strip(lf,'"'); // cannot handle filenames in citation quotes - if (lf=="cout" || lf=="std::cout") g_log=&cout; - else if (lf=="cerr" || lf=="std::cerr") g_log=&cerr; - else { - g_log.open(lf,ios_base::app); - g_log.writelogheader("Wiiscan::main()"); - if (v) log << "Using logfile <" << lf << ">" << endl; - } - } - - const int check=(r ? 1 : 0)+ (s ? 1 : 0) + (a.size()>0 ? 1 : 0) + (c.size()>0 ? 1 : 0) + (d.size()>0 ? 1 : 0) + usbup + usbdown; - if (check>1 || u) return Usage(arg); - - if (timeout<20) throw_("bad value of timeout, should be >=20"); - if (wiitimeout<20)throw_("bad value of wiitimeout, should be >=20"); - if (usbsleep<20) throw_("bad value of usbsleep, should be >=20"); - if (usbmsleep<20) throw_("bad value of usbmsleep, should be >=20"); - if (btsleep<20) throw_("bad value of btsleep, should be >=20"); - if (usbdown && usbup) throw_("bad value of usbdown/up, cannot be used at the same time"); - if (wiitimeout%1000!=0) throw_("bad value, wiitimeout should be divisable with 1000"); - if (btr.size()>0 && btr.size()!=17) throw_("bluetooth radio must be in the form xx:xx:xx:xx:xx:xx"); - if (usbmode<0 || usbmode>3) throw_("bad usbpowermode, must be 0,1,2, or 3"); - if (removemode<0 || removemode>2) throw_("bad removemode, must be 0,1 or 2"); - if (scanretries<=0) throw_("bad value of scanretries, should be > 0"); - if (a.size()==0) a=NINTENDO_DEV; - - if (v) { - log << Version() << " " << Config() << endl; - log << "Values:" << endl; - log << " a=" << a << endl; - log << " c=" << c << endl; - log << " d=" << d << endl; - log << " r=" << r << endl; - log << " s=" << s << endl; - log << " v=" << v << endl; - log << " cf=" << cf << endl; - log << " lf=" << lf << endl; - log << " wb=" << wb << endl; - log << " btr=" << btr << endl; - log << " lib=" << lib << endl; - log << " usbmode=" << usbmode << endl; - log << " removemode=" << removemode << endl; - log << " scanretries=" << scanretries << endl; - log << " usbup =" << usbup << endl; - log << " usbdown=" << usbup << endl; - log << "Timeouts:" << endl; - log << " timeout =" << timeout << endl; - log << " wiitimeout=" << wiitimeout << endl; - log << " usbsleep =" << usbsleep << endl; - log << " usbmsleep =" << usbmsleep << endl; - log << " btsleep =" << btsleep << endl; - } - - bool ret=true; - -return TestOpen(NINTENDO_DEV,btr,true); - - if (r) ret=RadioInfo (btr.size()==0 ? "all" : btr,v)!=NULL; - else if (s) ret=ScanDevices (timeout); - else if (c.size()>0) ret=OpenDevice (c,btr,timeout,wiitimeout,vector(),btsleep,lib,true,true,v,invalidargflag); - else if (d.size()>0) ret=RemoveDevice(d,v); - else if (usbup) ret=USBupdown (usbmode,true, v,Configfile(cf).Get("active_usb_hub",true)); - else if (usbdown) ret=USBupdown (usbmode,false,v,Configfile(cf).Get("active_usb_hub",true)); - else ret=AutoOpenDevice(a,btr,timeout,wiitimeout,usbsleep,btsleep,usbmsleep,cf,lib,removemode,usbmode,wb,scanretries,v,invalidargflag); // default mode - - log << "Wiiscan done " << (ret ? "[OK]" : "[FAILED]") << endl; - - if (invalidargflag) { - if (v) log << "** warning: return=-3 (E_INVALIDARG)" << endl; - return -3; - } - - if (v) log << "returning: return=" << (ret ? "0" : "-1") << endl; - return ret ? 0 : -1; // 0=Ok, -1=fail, -2=fail with exception, -3=fail with E_INVALIDARG - } - CATCH_ALL; - - assert(invalidargflag==false); // flag not setted => no throw in when E_INVALIDARG encoutered - log << "Wiiscan done [FAILED]" << endl; - return -2; -} - -}; // namespace Wiiscan - - -const int MAX_RADIOS=1; -const int MAX_DEVICES=16; -const int MAX_MAC_ADDR_LENGHT=256; -const int MAX_STRING_LENGHT=1024; - -string GetLastErrorMessage(const int n) {return "error n";} - -// PFN_DEVICE_CALLBACK - -BOOL WINAPI RegFun2(LPVOID pvParam,const BLUETOOTH_DEVICE_INFO* pDevice) -{ - cout << "\n**RegFun2**\n"; - return 1; -} - -int BT_radio_find_radios(HANDLE hRadio[MAX_RADIOS]) -{ -int i = 0; -HBLUETOOTH_RADIO_FIND hFind; -BLUETOOTH_FIND_RADIO_PARAMS btfrp = { sizeof(btfrp) }; - -hFind = BluetoothFindFirstRadio( &btfrp, &(hRadio[i]) ); -if ( NULL != hFind ) -{ -//printf("found first radio\n"); -i++; -while(TRUE == BluetoothFindNextRadio(hFind, &hRadio[i])) -{ -i++; -if (i >= MAX_RADIOS) -{ -printf("Cannot assign next radio, MAX_RADIOS = %d reached\n", MAX_RADIOS); -return MAX_RADIOS; -} -} -if (FALSE == BluetoothFindRadioClose(hFind)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -} -else -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -return i; -} - -int BT_radio_find_devices(unsigned char address_table[MAX_DEVICES][MAX_MAC_ADDR_LENGHT], -char nameAsString_table[MAX_DEVICES][MAX_STRING_LENGHT], -HANDLE* hRadio) -{ -BLUETOOTH_DEVICE_INFO deviceInfo; -deviceInfo.dwSize = sizeof(deviceInfo); -HBLUETOOTH_DEVICE_FIND hDeviceFind; - -BLUETOOTH_DEVICE_SEARCH_PARAMS deviceSearchParams; -memset(&deviceSearchParams, 0, sizeof(deviceSearchParams)); -deviceSearchParams.dwSize = sizeof(deviceSearchParams); -deviceSearchParams.fReturnAuthenticated = true; -deviceSearchParams.fReturnRemembered = true; -deviceSearchParams.fReturnUnknown = true; -deviceSearchParams.fReturnConnected = true; -deviceSearchParams.fIssueInquiry = true; -deviceSearchParams.cTimeoutMultiplier = 10; -deviceSearchParams.hRadio = *hRadio; -int i = 0; - -hDeviceFind = BluetoothFindFirstDevice(&deviceSearchParams, &deviceInfo); -if (NULL != hDeviceFind) -{ -do -{ -memcpy(address_table[i], &deviceInfo.Address.rgBytes[0], MAX_MAC_ADDR_LENGHT); -memcpy(&nameAsString_table[i], &deviceInfo.szName, MAX_STRING_LENGHT); -//wprintf(L"Device: %s\n", deviceInfo.szName); -//BluetoothDisplayDeviceProperties(0, &deviceInfo); -i++; -if (i >= MAX_DEVICES) -{ -printf("Cannot assign next device, MAX_DEVICES = %d reached\n", MAX_DEVICES); -return MAX_DEVICES; -} -} -while(BluetoothFindNextDevice(hDeviceFind, &deviceInfo)); - -if (FALSE == BluetoothFindDeviceClose(hDeviceFind)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -} -else -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -return i; -} - -void Connect_using_BT_Api() -{ -int i, j, result; -HANDLE hRadio[MAX_RADIOS]; -int found_radio_cnt = 0; -int selected_radio; -int found_radio_dev_cnt = 0; -int selected_radio_dev; - -BLUETOOTH_RADIO_INFO radioInfo; -radioInfo.dwSize = sizeof(radioInfo); -BLUETOOTH_DEVICE_INFO deviceInfo; -memset(&deviceInfo, 0, sizeof(deviceInfo)); -deviceInfo.dwSize = sizeof(deviceInfo); - -unsigned char radio_dev_address[MAX_DEVICES][MAX_MAC_ADDR_LENGHT]; -char radio_dev_names [MAX_DEVICES][MAX_STRING_LENGHT]; - -found_radio_cnt = BT_radio_find_radios(hRadio); -if (found_radio_cnt == 0) -{ -printf("no radios found\n"); -exit(1); -} -for (i = 0; i < found_radio_cnt; i++) -{ -if (ERROR_SUCCESS == BluetoothGetRadioInfo(hRadio[0], &radioInfo)) -{ -wprintf(L"Radio[%2d]: %10s\n", i, radioInfo.szName); -} -} -printf("Select radio: "); -//scanf("%d", &selected_radio); -selected_radio=0; - -if (selected_radio < 0) selected_radio = 0; -if (selected_radio >= found_radio_cnt) selected_radio = found_radio_cnt - 1; - -if (ERROR_SUCCESS == BluetoothGetRadioInfo(hRadio[selected_radio], &radioInfo)) -{ -wprintf(L"selected: %10s\n", radioInfo.szName); -} - -if (FALSE == BluetoothEnableDiscovery(hRadio[selected_radio], TRUE)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -if (FALSE == BluetoothEnableIncomingConnections(hRadio[selected_radio], TRUE)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} - -found_radio_dev_cnt = BT_radio_find_devices(radio_dev_address, radio_dev_names, &hRadio[selected_radio]); -if (found_radio_dev_cnt == 0) -{ -printf("no radio devices found\n"); -exit(1); -} - -for (i = 0; i < found_radio_dev_cnt; i++) -{ -wprintf(L"Radio device[%2d]: %20s ", i, radio_dev_names[i]); -printf("addr: (%2x:%2x:%2x:%2x:%2x:%2x)\n", -radio_dev_address[i][5], -radio_dev_address[i][4], -radio_dev_address[i][3], -radio_dev_address[i][2], -radio_dev_address[i][1], -radio_dev_address[i][0]); -} - -printf("Select device: "); -scanf("%d", &selected_radio_dev); -if (selected_radio_dev < 0) selected_radio_dev = 0; -if (selected_radio_dev >= found_radio_dev_cnt) selected_radio_dev = found_radio_dev_cnt - 1; - -#if 1 //function works, but not needed -BLUETOOTH_SELECT_DEVICE_PARAMS seldevquery; -memset(&seldevquery, 0, sizeof(seldevquery)); -seldevquery.dwSize = sizeof(seldevquery); -seldevquery.cNumOfClasses = 5; -seldevquery.hwndParent = 0; -seldevquery.fForceAuthentication = true; -seldevquery.fShowAuthenticated = true; -seldevquery.fShowRemembered = true; -seldevquery.fShowUnknown = true; -seldevquery.fAddNewDeviceWizard = false; -seldevquery.fSkipServicesPage = false; -seldevquery.pfnDeviceCallback = RegFun2, //dev_callback; -seldevquery.pvParam = 0; -seldevquery.cNumDevices = 2; -seldevquery.pDevices = &deviceInfo; - -if (FALSE == (&seldevquery)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -else -{ -printf("poszlo: BluetoothSelectDevices\n"); -wprintf(L"Selected device: %20s ", deviceInfo.szName); -printf("addr: (%2x:%2x:%2x:%2x:%2x:%2x)\n", -deviceInfo.Address.rgBytes[5], -deviceInfo.Address.rgBytes[4], -deviceInfo.Address.rgBytes[3], -deviceInfo.Address.rgBytes[2], -deviceInfo.Address.rgBytes[1], -deviceInfo.Address.rgBytes[0]); -} -#endif - -#if 1 -memcpy(&deviceInfo.Address.rgBytes[0], radio_dev_address[selected_radio_dev], MAX_MAC_ADDR_LENGHT); -if (ERROR_SUCCESS == BluetoothGetDeviceInfo(hRadio[selected_radio], &deviceInfo)) -{ -wprintf(L"Selected device: %20s ", deviceInfo.szName); -printf("addr: (%2x:%2x:%2x:%2x:%2x:%2x)\n", -deviceInfo.Address.rgBytes[5], -deviceInfo.Address.rgBytes[4], -deviceInfo.Address.rgBytes[3], -deviceInfo.Address.rgBytes[2], -deviceInfo.Address.rgBytes[1], -deviceInfo.Address.rgBytes[0]); - -// BluetoothUpdateDeviceRecord(&deviceInfo); -// BluetoothRemoveDevice(deviceInfo.Address); -} -else -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -#endif - -//GUID pService = {0x00001101, 0x0000, 0x1000, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}; -GUID pService = (GUID)SerialPortServiceClass_UUID; -//GUID pService = (GUID)OBEXFileTransferServiceClass_UUID; -//GUID pService = (GUID)OBEXObjectPushServiceClass_UUID; - -if (ERROR_SUCCESS != BluetoothSetServiceState(hRadio[selected_radio], &deviceInfo, &pService, BLUETOOTH_SERVICE_ENABLE)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -else -{ -printf("BluetoothSetServiceState enabled (COM)\n"); -} - -#if 1 -GUID guidServices[MAX_DEVICES]; -memset(guidServices, 0, sizeof(guidServices)); -DWORD numServices = MAX_DEVICES; -memcpy(&deviceInfo.Address.rgBytes[0], radio_dev_address[selected_radio_dev], MAX_MAC_ADDR_LENGHT); - -if (ERROR_SUCCESS == BluetoothEnumerateInstalledServices(hRadio[selected_radio], -&deviceInfo, -&numServices, -guidServices)) -{ -printf("enumerated services: %d\n", numServices); -} -else -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -#endif - -#if 1 -if (ERROR_SUCCESS != BluetoothSetServiceState(hRadio[selected_radio], &deviceInfo, &pService, BLUETOOTH_SERVICE_DISABLE)) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -else -{ -printf("BluetoothSetServiceState disabled (COM)\n"); -} -#endif - -//function works -HBLUETOOTH_AUTHENTICATION_REGISTRATION phRegHandle; -if (ERROR_SUCCESS != BluetoothRegisterForAuthentication(&deviceInfo, -&phRegHandle, -Wiiscan::RegFun, // auth_callback, -hRadio[selected_radio])) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} - -WCHAR tempkey[12] = {0}; -PWCHAR pszPasskey = tempkey; -for (j = 0; j < 8; j+=2) -{ -((unsigned char*)pszPasskey)[j] = '0'; -} -for (j = 1; j < 8; j+=2) -{ -((unsigned char*)pszPasskey)[j] = 0x0; -} -ULONG ulPasskeyLength = 4; -wprintf(L"pszPasskey: %20s\n", pszPasskey); - -//works!!!! -result = BluetoothAuthenticateDevice(0, hRadio[selected_radio], &deviceInfo, pszPasskey, ulPasskeyLength); -if (result == ERROR_NO_MORE_ITEMS) -{ -printf("%s\n", "device already authenticated"); -} -else if(result != ERROR_SUCCESS) -{ -printf("%s\n", GetLastErrorMessage(GetLastError())); -} -CloseHandle( hRadio[selected_radio] ); -} - -/* -void Connect_using_SWA() -{ -int i; -//--- to open a socket ----- -SOCKET s; -WORD wVersionRequested = 0x202; -WSADATA m_data; - -WSAPROTOCOL_INFO protocolInfo; -int protocolInfoSize = sizeof(protocolInfo); - -char known_addresses[MAX_DEVICES][MAX_STRING_LENGHT]; -char known_names [MAX_DEVICES][MAX_STRING_LENGHT]; -char selected_addresses [MAX_DEVICES][MAX_STRING_LENGHT]; -char selected_names [MAX_DEVICES][MAX_STRING_LENGHT]; - -//BTH_DEVICE_INFO *pDeviceInfo; - -int found_dev_cnt = 0;; -int selected_dev; -int found_serv_cnt = 0; -int selected_serv; - -if (0 == WSAStartup(wVersionRequested, &m_data)) -{ -if (0 != BT_open_socket(&s, &protocolInfo, &protocolInfoSize)) -{ -exit(1); -} - -found_dev_cnt = BT_find_all_devices(known_addresses, known_names, &protocolInfo); -if (found_dev_cnt == 0) -{ -printf("no devices found\n"); -exit(1); -} - -for (i = 0; i < found_dev_cnt; i++) -{ -printf("[%2d]: %20s ", i, known_names[i]); -printf("addr: %s\n", known_addresses[i]); -} -printf("Select device: "); -scanf("%d", &selected_dev); -if (selected_dev < 0) selected_dev = 0; -if (selected_dev >= found_dev_cnt) selected_dev = found_dev_cnt - 1; - -found_serv_cnt = BT_find_devices_by_context(selected_addresses, selected_names, &protocolInfo, known_addresses[selected_dev]); -if (found_serv_cnt == 0) -{ -printf("no services found\n"); -exit(1); -} - -for (i = 0; i < found_serv_cnt; i++) -{ -printf("[%2d]: %20s ", i, selected_names[i]); -printf("addr: %s\n", selected_addresses[i]); -} -printf("Select service: "); -scanf("%d", &selected_serv); -if (selected_serv < 0) selected_serv = 0; -if (selected_serv >= found_serv_cnt) selected_serv = found_serv_cnt - 1; - -printf("selected: %s\n", selected_names[selected_serv]); - - -WSACleanup(); -} -} -*/ \ No newline at end of file diff --git a/cpp/wiiuse/Debug/wiiuse.dll b/cpp/wiiuse/Debug/wiiuse.dll deleted file mode 100644 index 512c0cc..0000000 Binary files a/cpp/wiiuse/Debug/wiiuse.dll and /dev/null differ diff --git a/cpp/wiiusej/Debug/wiiusej.dll b/cpp/wiiusej/Debug/wiiusej.dll deleted file mode 100644 index 12261bc..0000000 Binary files a/cpp/wiiusej/Debug/wiiusej.dll and /dev/null differ diff --git a/java/itunescontroller/.project b/java/itunescontroller/.project index 1d48d0b..3e38131 100644 --- a/java/itunescontroller/.project +++ b/java/itunescontroller/.project @@ -1,6 +1,6 @@ - java.itunescontroller + itunescontroller diff --git a/java/mimis/.project b/java/mimis/.project index 6eb3238..e30efa6 100644 --- a/java/mimis/.project +++ b/java/mimis/.project @@ -1,6 +1,6 @@ - java.mimis + mimis diff --git a/vendor/commons-collections/commons-collections-3.2.1.jar b/vendor/commons-collections/commons-collections-3.2.1.jar deleted file mode 100644 index c35fa1f..0000000 Binary files a/vendor/commons-collections/commons-collections-3.2.1.jar and /dev/null differ 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 deleted file mode 100644 index 8758a96..0000000 Binary files a/vendor/commons-logging/1.1.1/commons-logging-1.1.1.jar and /dev/null 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 deleted file mode 100644 index 2f23c35..0000000 Binary files a/vendor/commons-logging/1.1.1/commons-logging-adapters-1.1.1.jar and /dev/null 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 deleted file mode 100644 index bd45116..0000000 Binary files a/vendor/commons-logging/1.1.1/commons-logging-api-1.1.1.jar and /dev/null 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 deleted file mode 100644 index 1fef2f0..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/Log.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * 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 deleted file mode 100644 index 419725d..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogConfigurationException.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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 deleted file mode 100644 index 60522af..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogFactory.java +++ /dev/null @@ -1,1824 +0,0 @@ -/* - * 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 deleted file mode 100644 index 50b3e4b..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/LogSource.java +++ /dev/null @@ -1,262 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2500172..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/AvalonLogger.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * 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 deleted file mode 100644 index fb17d26..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk13LumberjackLogger.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * 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 deleted file mode 100644 index 9fafefd..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Jdk14Logger.java +++ /dev/null @@ -1,304 +0,0 @@ -/* - * 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 deleted file mode 100644 index 68877b9..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/Log4JLogger.java +++ /dev/null @@ -1,342 +0,0 @@ -/* - * 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 deleted file mode 100644 index 97a9ac0..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ /dev/null @@ -1,1500 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2587e81..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/LogKitLogger.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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 deleted file mode 100644 index 229cdff..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/NoOpLog.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6061171..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/ServletContextCleaner.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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 deleted file mode 100644 index d966722..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/SimpleLog.java +++ /dev/null @@ -1,721 +0,0 @@ -/* - * 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 deleted file mode 100644 index e2d4100..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/WeakHashtable.java +++ /dev/null @@ -1,478 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5344784..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/impl/package.html +++ /dev/null @@ -1,22 +0,0 @@ - - - -

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 deleted file mode 100644 index e9b32a5..0000000 --- a/vendor/commons-logging/1.1.1/java/org/apache/commons/logging/package.html +++ /dev/null @@ -1,255 +0,0 @@ - - - -

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 deleted file mode 100644 index 53846c9..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtwork.java +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index c1d8afa..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkCollection.java +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index ed4b61e..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITArtworkFormat.java +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index bc12943..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITAudioCDPlaylist.java +++ /dev/null @@ -1,76 +0,0 @@ -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 deleted file mode 100644 index 16dc6cf..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITBrowserWindow.java +++ /dev/null @@ -1,45 +0,0 @@ -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 deleted file mode 100644 index 500280c..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITCOMDisabledReason.java +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 1d00cfb..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITEQPreset.java +++ /dev/null @@ -1,236 +0,0 @@ -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 deleted file mode 100644 index 570896c..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITFileOrCDTrack.java +++ /dev/null @@ -1,39 +0,0 @@ -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 deleted file mode 100644 index c19cba8..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITLibraryPlaylist.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 27475fd..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITObject.java +++ /dev/null @@ -1,112 +0,0 @@ -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 deleted file mode 100644 index e5c674b..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITObjectPersistentID.java +++ /dev/null @@ -1,53 +0,0 @@ -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 deleted file mode 100644 index cf764aa..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITOperationStatus.java +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 4be2a70..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlayerState.java +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 23bf2b9..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylist.java +++ /dev/null @@ -1,154 +0,0 @@ -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 deleted file mode 100644 index 3717735..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistCollection.java +++ /dev/null @@ -1,67 +0,0 @@ -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 deleted file mode 100644 index e6f685f..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistKind.java +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 6fc8ef8..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistPrintKind.java +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 4b6fc16..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistRepeatMode.java +++ /dev/null @@ -1,14 +0,0 @@ -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 deleted file mode 100644 index 420b305..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITPlaylistSearchField.java +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 7d1cb22..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITRatingKind.java +++ /dev/null @@ -1,11 +0,0 @@ -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 deleted file mode 100644 index b0d93fc..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITSource.java +++ /dev/null @@ -1,51 +0,0 @@ -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 deleted file mode 100644 index 357bdec..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceCollection.java +++ /dev/null @@ -1,66 +0,0 @@ -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 deleted file mode 100644 index f332249..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITSourceKind.java +++ /dev/null @@ -1,17 +0,0 @@ -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 deleted file mode 100644 index 0046c7e..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrack.java +++ /dev/null @@ -1,492 +0,0 @@ -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 deleted file mode 100644 index b87208f..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackCollection.java +++ /dev/null @@ -1,91 +0,0 @@ -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 deleted file mode 100644 index ec233a1..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITTrackKind.java +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 9829190..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITURLTrack.java +++ /dev/null @@ -1,175 +0,0 @@ -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 deleted file mode 100644 index b4025cf..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITUserPlaylist.java +++ /dev/null @@ -1,60 +0,0 @@ -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 deleted file mode 100644 index d318724..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITVideoKind.java +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index 4af825f..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindow.java +++ /dev/null @@ -1,32 +0,0 @@ -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 deleted file mode 100644 index df1f3cf..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/ITWindowCollection.java +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index 150ae7a..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/iTunes.java +++ /dev/null @@ -1,488 +0,0 @@ -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 deleted file mode 100644 index ddbee23..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEvents.java +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 3d8f17e..0000000 --- a/vendor/iTunesController/0.2/com/dt/iTunesController/iTunesEventsInterface.java +++ /dev/null @@ -1,115 +0,0 @@ -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/jdk/1.6.0_23/include/classfile_constants.h b/vendor/jdk/1.6.0_23/include/classfile_constants.h deleted file mode 100644 index 30e839e..0000000 --- a/vendor/jdk/1.6.0_23/include/classfile_constants.h +++ /dev/null @@ -1,523 +0,0 @@ -/* - * %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 deleted file mode 100644 index 87e0b18..0000000 --- a/vendor/jdk/1.6.0_23/include/jawt.h +++ /dev/null @@ -1,278 +0,0 @@ -/* - * %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 deleted file mode 100644 index eae435a..0000000 --- a/vendor/jdk/1.6.0_23/include/jdwpTransport.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * %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 deleted file mode 100644 index 8ed7366..0000000 --- a/vendor/jdk/1.6.0_23/include/jni.h +++ /dev/null @@ -1,1944 +0,0 @@ -/* - * %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 deleted file mode 100644 index 865f21e..0000000 --- a/vendor/jdk/1.6.0_23/include/jvmti.h +++ /dev/null @@ -1,2504 +0,0 @@ -#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 deleted file mode 100644 index 82ba034..0000000 --- a/vendor/jdk/1.6.0_23/include/win32/jawt_md.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * %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 deleted file mode 100644 index 9ac4718..0000000 --- a/vendor/jdk/1.6.0_23/include/win32/jni_md.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * %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 deleted file mode 100644 index 9de9b61..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitype.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - 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 deleted file mode 100644 index 7de6bd8..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitype.dev +++ /dev/null @@ -1,149 +0,0 @@ -[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 deleted file mode 100644 index e77247b..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitype.layout +++ /dev/null @@ -1,76 +0,0 @@ -[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 deleted file mode 100644 index 10fe844..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - 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 deleted file mode 100644 index 4806ef7..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitypeHandler.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - 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 deleted file mode 100644 index 10ff4da..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - 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 deleted file mode 100644 index e4a0048..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitypeThread.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - 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 deleted file mode 100644 index 688740c..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.h +++ /dev/null @@ -1,23 +0,0 @@ -/* 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 deleted file mode 100644 index 804ed7d..0000000 --- a/vendor/jintellitype/1.3.6/cpp/JIntellitype_private.rc +++ /dev/null @@ -1,35 +0,0 @@ -/* 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 deleted file mode 100644 index 3891470..0000000 --- a/vendor/jintellitype/1.3.6/cpp/Makefile.win +++ /dev/null @@ -1,46 +0,0 @@ -# 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 deleted file mode 100644 index 04dfff1..0000000 --- a/vendor/jintellitype/1.3.6/cpp/StdAfx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// 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 deleted file mode 100644 index 5a1e4d6..0000000 --- a/vendor/jintellitype/1.3.6/cpp/StdAfx.h +++ /dev/null @@ -1,24 +0,0 @@ -// 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 deleted file mode 100644 index 602d053..0000000 --- a/vendor/jintellitype/1.3.6/cpp/com_melloware_jintellitype_JIntellitype.h +++ /dev/null @@ -1,53 +0,0 @@ -/* 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 deleted file mode 100644 index 4c44a72..0000000 --- a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/HotkeyListener.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * 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 deleted file mode 100644 index a9d5aa8..0000000 --- a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/IntellitypeListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * 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 deleted file mode 100644 index 7f734d6..0000000 --- a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitype.java +++ /dev/null @@ -1,665 +0,0 @@ -/** - * 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 deleted file mode 100644 index dfa2af5..0000000 --- a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeConstants.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * 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 deleted file mode 100644 index f0bd0f2..0000000 --- a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/JIntellitypeException.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * 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 deleted file mode 100644 index b579745..0000000 --- a/vendor/jintellitype/1.3.6/java/com/melloware/jintellitype/Main.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * 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 deleted file mode 100644 index a45e1fc..0000000 Binary files a/vendor/jlgui/3.0/lib/basicplayer3.0.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/commons-logging-api.jar b/vendor/jlgui/3.0/lib/commons-logging-api.jar deleted file mode 100644 index ade9a13..0000000 Binary files a/vendor/jlgui/3.0/lib/commons-logging-api.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/jflac-1.2.jar b/vendor/jlgui/3.0/lib/jflac-1.2.jar deleted file mode 100644 index 0de540f..0000000 Binary files a/vendor/jlgui/3.0/lib/jflac-1.2.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/jl1.0.jar b/vendor/jlgui/3.0/lib/jl1.0.jar deleted file mode 100644 index 17f7c0a..0000000 Binary files a/vendor/jlgui/3.0/lib/jl1.0.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/jmactritonusspi1.74.jar b/vendor/jlgui/3.0/lib/jmactritonusspi1.74.jar deleted file mode 100644 index a5073e2..0000000 Binary files a/vendor/jlgui/3.0/lib/jmactritonusspi1.74.jar and /dev/null 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 deleted file mode 100644 index 1cbd1ad..0000000 Binary files a/vendor/jlgui/3.0/lib/jogg-0.0.7.jar and /dev/null 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 deleted file mode 100644 index 4cf51f9..0000000 Binary files a/vendor/jlgui/3.0/lib/jorbis-0.0.15.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/jspeex0.9.7.jar b/vendor/jlgui/3.0/lib/jspeex0.9.7.jar deleted file mode 100644 index f7a1861..0000000 Binary files a/vendor/jlgui/3.0/lib/jspeex0.9.7.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/kj_dsp1.1.jar b/vendor/jlgui/3.0/lib/kj_dsp1.1.jar deleted file mode 100644 index 2cb3479..0000000 Binary files a/vendor/jlgui/3.0/lib/kj_dsp1.1.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/mp3spi1.9.4.jar b/vendor/jlgui/3.0/lib/mp3spi1.9.4.jar deleted file mode 100644 index 019b86c..0000000 Binary files a/vendor/jlgui/3.0/lib/mp3spi1.9.4.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/tritonus_share.jar b/vendor/jlgui/3.0/lib/tritonus_share.jar deleted file mode 100644 index d21ba89..0000000 Binary files a/vendor/jlgui/3.0/lib/tritonus_share.jar and /dev/null differ diff --git a/vendor/jlgui/3.0/lib/vorbisspi1.0.2.jar b/vendor/jlgui/3.0/lib/vorbisspi1.0.2.jar deleted file mode 100644 index 1a924af..0000000 Binary files a/vendor/jlgui/3.0/lib/vorbisspi1.0.2.jar and /dev/null 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 deleted file mode 100644 index 8693527..0000000 --- a/vendor/jlgui/3.0/src/META-INF/services/org.apache.commons.logging.LogFactory +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 93944fd..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicController.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * 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 deleted file mode 100644 index a69dd8f..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayer.java +++ /dev/null @@ -1,1038 +0,0 @@ -/* - * 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 deleted file mode 100644 index c2c93bd..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEvent.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5c3a136..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerEventLauncher.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 deleted file mode 100644 index df6e4b4..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerException.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1157ab2..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/basicplayer/BasicPlayerListener.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 deleted file mode 100644 index 52b5b07..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/Loader.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 deleted file mode 100644 index 8c9da95..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerActionEvent.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 deleted file mode 100644 index 47abd20..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/PlayerUI.java +++ /dev/null @@ -1,1827 +0,0 @@ -/* - * 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 deleted file mode 100644 index ec249d2..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/StandalonePlayer.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * 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 deleted file mode 100644 index 43b768e..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/ControlCurve.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * 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 deleted file mode 100644 index a1c91ea..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/Cubic.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 deleted file mode 100644 index e63e631..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/EqualizerUI.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2ed8b94..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/NaturalSpline.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 deleted file mode 100644 index d604afe..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/equalizer/ui/SplinePanel.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 deleted file mode 100644 index d44ea31..0000000 Binary files a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/jlguiicon.gif and /dev/null 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 deleted file mode 100644 index 58fd9ad..0000000 Binary files a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/metrix.wsz and /dev/null 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 deleted file mode 100644 index 7149b5e..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/BasePlaylist.java +++ /dev/null @@ -1,586 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0eb3dd6..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/Playlist.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * 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 deleted file mode 100644 index a854f7c..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistFactory.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2ff3b6c..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/PlaylistItem.java +++ /dev/null @@ -1,302 +0,0 @@ -/* - * 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 deleted file mode 100644 index f460ee3..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/playlist/ui/PlaylistUI.java +++ /dev/null @@ -1,882 +0,0 @@ -/* - * 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 deleted file mode 100644 index 44149dc..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteConstraints.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 deleted file mode 100644 index 03a21bf..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/AbsoluteLayout.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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 deleted file mode 100644 index 05feaec..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveFont.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5b069e0..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJBar.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 deleted file mode 100644 index 792943e..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJButton.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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 deleted file mode 100644 index 331dc53..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJIcon.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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 deleted file mode 100644 index 0520193..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJLabel.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * 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 deleted file mode 100644 index c3ad335..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJNumberLabel.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2bd9e75..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ActiveJPopup.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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 deleted file mode 100644 index 59f1901..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DragAdapter.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 deleted file mode 100644 index 774a125..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/DropTargetAdapter.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * 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 deleted file mode 100644 index 040c37a..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/ImageBorder.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5c68592..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PlaylistUIDelegate.java +++ /dev/null @@ -1,276 +0,0 @@ -/* - * 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 deleted file mode 100644 index fc961ee..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/PopupAdapter.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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 deleted file mode 100644 index 32a03e3..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Skin.java +++ /dev/null @@ -1,1493 +0,0 @@ -/* - * 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 deleted file mode 100644 index b8f0ad6..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/SkinLoader.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * 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 deleted file mode 100644 index f5de88f..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/Taftb.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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 deleted file mode 100644 index e15005e..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/UrlDialog.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * 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 deleted file mode 100644 index 72b61c7..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/skin/skin.properties +++ /dev/null @@ -1,65 +0,0 @@ -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 deleted file mode 100644 index 9dcff87..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/APEInfo.java +++ /dev/null @@ -1,340 +0,0 @@ -/* - * 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 deleted file mode 100644 index cf1767f..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/FlacInfo.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * 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 deleted file mode 100644 index 7a1fbc7..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/MpegInfo.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * 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 deleted file mode 100644 index 67da902..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/OggVorbisInfo.java +++ /dev/null @@ -1,307 +0,0 @@ -/* - * 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 deleted file mode 100644 index 86e05d5..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfo.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 deleted file mode 100644 index 4cbf8ef..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/TagInfoFactory.java +++ /dev/null @@ -1,399 +0,0 @@ -/* - * 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 deleted file mode 100644 index 001bca3..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/APEDialog.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * 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 deleted file mode 100644 index 147f6c9..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/EmptyDialog.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 deleted file mode 100644 index f506a67..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/FlacDialog.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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 deleted file mode 100644 index 2782bed..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/MpegDialog.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * 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 deleted file mode 100644 index 16a84e6..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/OggVorbisDialog.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * 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 deleted file mode 100644 index e2a0576..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagInfoDialog.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 deleted file mode 100644 index 5ef8606..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/TagSearch.java +++ /dev/null @@ -1,434 +0,0 @@ -/* - * 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 deleted file mode 100644 index e4d41e3..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/tag/ui/tag.properties +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100644 index 8790511..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/BMPLoader.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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 deleted file mode 100644 index 952fb70..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/Config.java +++ /dev/null @@ -1,711 +0,0 @@ -/* - * 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 deleted file mode 100644 index a9d0b3d..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileNameFilter.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * 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 deleted file mode 100644 index e022633..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileSelector.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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 deleted file mode 100644 index e3a9c1c..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/FileUtil.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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 deleted file mode 100644 index cf82fa1..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Alphabetizer.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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 deleted file mode 100644 index 1665358..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Array.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * 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 deleted file mode 100644 index d35a6bf..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/CRC32OutputStream.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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 deleted file mode 100644 index 48e0720..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/Configuration.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * 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 deleted file mode 100644 index 32c6204..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ini/SortedStrings.java +++ /dev/null @@ -1,338 +0,0 @@ -/* - * 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 deleted file mode 100644 index 481bffe..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/DevicePreference.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * 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 deleted file mode 100644 index 90ee4cd..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/EmptyPreference.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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 deleted file mode 100644 index 502d9bf..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/NodeItem.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 deleted file mode 100644 index 903f70c..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/OutputPreference.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 deleted file mode 100644 index 979fcf6..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/PreferenceItem.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 deleted file mode 100644 index d1c61aa..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/Preferences.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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 deleted file mode 100644 index f649b65..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SkinPreference.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * 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 deleted file mode 100644 index 86445d5..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/SystemPreference.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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 deleted file mode 100644 index 23e94a6..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/TypePreference.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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 deleted file mode 100644 index 6f039bd..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualPreference.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * 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 deleted file mode 100644 index 571a5c6..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/VisualizationPreference.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 deleted file mode 100644 index 279243a..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/device.properties +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index c54c46a..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/output.properties +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 3787d34..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/preferences.properties +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index 6433f43..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/skin.properties +++ /dev/null @@ -1,4 +0,0 @@ -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 deleted file mode 100644 index a0f7dd4..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/system.properties +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index 061309d..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/type.properties +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index be5fe0c..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visual.properties +++ /dev/null @@ -1,15 +0,0 @@ -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 deleted file mode 100644 index 7c1585b..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/util/ui/visualization.properties +++ /dev/null @@ -1,2 +0,0 @@ -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 deleted file mode 100644 index 19ed5ff..0000000 --- a/vendor/jlgui/3.0/src/javazoom/jlgui/player/amp/visual/ui/SpectrumTimeAnalyzer.java +++ /dev/null @@ -1,775 +0,0 @@ -/* - * 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 deleted file mode 100644 index 3f9d847..0000000 Binary files a/vendor/log4j/1.2.16/log4j-1.2.16.jar and /dev/null differ