org.jSyncManager.Transport
Class JavaxUSBTransport
- Serializable, UsbInterfacePolicy, UsbServicesListener
public class JavaxUSBTransport
implements UsbServicesListener, UsbInterfacePolicy
JavaxUSBTransport.java
Javax USB Transport Class.
This class provides a bridge between the JavaX USB API
and the USB Protocol class.
CLIE_VENDOR_ID, HANDSPRING_DEVICE_IDS, HANDSPRING_TREO_ID, HANDSPRING_VENDOR_ID, HANDSPRING_VISOR_ID, PALM_DEVICE_IDS, PALM_I705_ID, PALM_M100_ID, PALM_M125_ID, PALM_M130_ID, PALM_M500_ID, PALM_M505_ID, PALM_M515_ID, PALM_TREO_600_ID, PALM_TUNGSTEN_T5_ID, PALM_TUNGSTEN_T_ID, PALM_TUNGSTEN_Z_ID, PALM_VENDOR_ID, PALM_ZIRE_ID, SAMSUNG_DEVICE_IDS, SAMSUNG_SCH_I330_ID, SAMSUNG_VENDOR_ID, SONY_CLIE_3_5_ID, SONY_CLIE_4_0_ID, SONY_CLIE_4_1_ID, SONY_CLIE_NX60_ID, SONY_CLIE_NZ90V_ID, SONY_CLIE_S360_ID, SONY_DEVICE_IDS |
void | close()- Closes the implemented transport.
|
protected JPanel | constructConfigPanel()- Constructs this transports configuration panel.
|
void | finalize()- Completed on garbage removal of the implemented transport.
|
void | flush()- Flushes the input buffer of any remaining data.
|
boolean | forceClaim(UsbInterface usbInterface)- A method to force the claim to the handheld device.
|
String | getResourceBundleName()- Returns the fully-qualified classname for the resources package to use for this transport.
|
String | getTransportDescription()- Returns the description for this Transport Interface.
|
String | getTransportExceptionText(TransportException ex)- Retrieves error information for a given TransportInitException.
|
String | getTransportName()- Returns the name of this Transport Interface.
|
void | initialize()- Initialize the port.
|
void | initialize(Properties properties, int id)- Initialize the port.
|
void | open()- Opens a read/write connection to the implemented transport.
|
byte | readByte()- Read a single byte from the underlying data stream.
|
void | usbDeviceAttached(UsbServicesEvent event)- New device added.
|
void | usbDeviceDetached(UsbServicesEvent event)- Device removed.
|
void | writeBytes(byte[] data)- Write an array of bytes to the underlying data stream.
|
close, constructConfigPanel, flush, getConfigPanel, getResourceBundle, getResourceBundleName, getTransportDescription, getTransportExceptionText, getTransportName, initialize, initialize, isConnected, loadResourceBundle, open, readByte, setConnected, writeBytes |
JavaxUSBTransport
public JavaxUSBTransport()
throws TransportExceptionCreates a new instance of JavaxUSBTransport
constructConfigPanel
protected JPanel constructConfigPanel()
Constructs this transports configuration panel.
- constructConfigPanel in interface SLPTransportInterface
- a javax.swing.JPanel containing the transports settings panel.
finalize
public void finalize()
throws TransportExceptionCompleted on garbage removal of the implemented transport. This method should call close() on the
transport device being implemented.
forceClaim
public boolean forceClaim(UsbInterface usbInterface)
A method to force the claim to the handheld device.
getResourceBundleName
public String getResourceBundleName()
Returns the fully-qualified classname for the resources package to use for this transport.
Your Transport implementation should return a String containing the name of your ResourceBundle
class here.
- getResourceBundleName in interface SLPTransportInterface
- a String object containing the fully qualified classname for a ResoureBundle
class to use for this transport.
getTransportDescription
public String getTransportDescription()
Returns the description for this Transport Interface.
This method will return a string containing the description for
this transport interface.
- getTransportDescription in interface SLPTransportInterface
- the description for this transport interface.
getTransportExceptionText
public String getTransportExceptionText(TransportException ex)
Retrieves error information for a given TransportInitException.
To ensure that we can keep code that uses the transport subclasses as generic as possible,
this method should take a TransportInitException instance, inspect it, and provide a plaintext
explaination for the error that can be shown to the user.
- getTransportExceptionText in interface SLPTransportInterface
ex - the TransportInitException to be inspected.
- a String object containing a text explaination for the exception.
getTransportName
public String getTransportName()
Returns the name of this Transport Interface. This method will return a string containing the name of
this transport interface. This is used when searching for and selecting from one of many available
transport interfaces that are installed on the system.
- getTransportName in interface SLPTransportInterface
- the name of this transport interface.
initialize
public void initialize()
throws TransportExceptionInitialize the port.
This method is called to initialize this transport using the objects stored settings.
You should perform whatever setup you require here. These objects may be serialized,
however it isn't guaranteed that the underlying API classes are also serializable.
As such you should store any user settings as non-transient fields, and setup the transport
based on those settings here. This method will be called whenever the port requires initialization.
Note you may also call this method in your event handlers for when the user changes the
transport settings.
Your implementation should throw a TransportInitException if there isn't sufficient information
to setup the transport. Applications can catch this exception and use it to display the necessary
settings dialog to the use.
- initialize in interface SLPTransportInterface
TransportException - thrown if there isn't sufficient info to setup the transport,
or if another exception has occurred.
initialize
public void initialize(Properties properties,
int id)
throws TransportExceptionInitialize the port.
This initializer is called when the port needs to be configured from a properties
file. This is necessary for when the jConduit is constructed in a text-only or daemon application,
which is unable to display the GUI configuration panel. The method accepts a transport ID number 'id',
which should be used to differentiate the different ports defined in the properties file by using keys
of the form "header.property.". This is necessary as such a property file may contain
multiple sets of properties for different ports.
Once the properties have been loaded, it is acceptable to call the initialize() method from within
this method to initialize the connection, so long as the initialize() method contains no GUI code.
- initialize in interface SLPTransportInterface
properties - a reference to the properties file containing configuration information.id - the transport ID number to load data for.
open
public void open()
throws TransportExceptionOpens a read/write connection to the implemented transport. This method should open the transport
device being implemented using default parameters.
- open in interface SLPTransportInterface
readByte
public byte readByte()
throws TransportExceptionRead a single byte from the underlying data stream. This method call should abstract the underlying
data connection stream to allow the SLP protocol to read a single byte from the stream.
- readByte in interface SLPTransportInterface
TransportException - thrown in the event that the connection to the remote device is lost.
usbDeviceAttached
public void usbDeviceAttached(UsbServicesEvent event)
New device added.
This method is called by Javax USB when a new USB device is added to an existing bus.
event - the event that triggered the call to this method.
usbDeviceDetached
public void usbDeviceDetached(UsbServicesEvent event)
Device removed.
This method is called by Javax USB when a new USB device is removed from an existing bus.
event - the event that triggered this method call.
writeBytes
public void writeBytes(byte[] data)
throws TransportExceptionWrite an array of bytes to the underlying data stream. This method call should abstract the underlying
data connection stream to allow the SLP protocol to write an array of bytes to the stream.
data - the bytes to be written to the underlying stream.
TransportException - thrown in the event that the connection to the remote device is lost.