jSyncManager

org.jSyncManager.API.Protocol
Class SLP

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.SLP

public class SLP
extends java.lang.Object

The Serial Link Protocol Handler class. This class provides the black-box for handling SLP packets.

Version:
$Revision: 1.10 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/07/08 19:13:26 $.

Inner Class Summary
(package private)  class SLP.InputHandler
          The SLP Input Handler class.
(package private)  class SLP.OutputHandler
          The SLP Output Handler class.
 
Field Summary
static byte CONSOLE_SOCKET
          The console socket.
static byte DEBUG_SOCKET
          The debug socket.
static byte DLP_SOCKET
          The Desktop Link Protocol Socket Note: all standard data synchronization occurs within the DLP socket.
static boolean ENABLE_PKT_DUMP
          A field to flag wether or not packet dumping should be enabled for all SLP protocol handler instances.
static byte FIRST_SOCKET
          The first available user socket.
static byte NEXT_SOCKET
          The next available socket value.
static byte REMOTE_UI_SOCKET
          The remote UI socket.
 
Constructor Summary
SLP(SLPTransportInterface trans)
          Construct a new SLP protocol handler using the specified transport.
 
Method Summary
(package private) static void ()
           
 void connect()
          Initialize the connection to the remote SLP provider.
 void disconnect()
          Disconnects the protocol stack from the underlying transport.
 void enableDebugMode()
          Enables debug mode, providing packet output to the set PrintStream.
protected  void handleCMPPacket(SLP_Packet pkt)
          A handler for CMP packets.
protected  void handlePADPacket(SLP_Packet pkt)
          A handler for PAD Packets.
protected  void handleSystemPacket(SLP_Packet pkt)
          A handler for System Packets.
protected  void handleTestPacket(SLP_Packet pkt)
          A handler for Test Packets.
protected  int incInputQueueEnd()
          Increment the end pointer for the input queue.
protected  int incInputQueueStart()
          Increment the start pointer for the input queue.
protected  int incOutputQueueEnd()
          Increment the end pointer for the output queue.
protected  int incOutputQueueStart()
          Increment the start pointer for the output queue.
 GenericPacket readPacket()
          Reads the next packet from the input queue.
 void setDebugOutputStream(java.io.PrintStream stream)
          Sets the print stream to use for debug output.
 void writePacket(byte[] data, byte src, byte dest, byte transID)
          Writen a packet of data via the SLP protocol to the other end of the transfer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_SOCKET

public static final byte DEBUG_SOCKET
The debug socket.

CONSOLE_SOCKET

public static final byte CONSOLE_SOCKET
The console socket.

REMOTE_UI_SOCKET

public static final byte REMOTE_UI_SOCKET
The remote UI socket.

DLP_SOCKET

public static final byte DLP_SOCKET
The Desktop Link Protocol Socket Note: all standard data synchronization occurs within the DLP socket.

FIRST_SOCKET

public static final byte FIRST_SOCKET
The first available user socket.

NEXT_SOCKET

public static byte NEXT_SOCKET
The next available socket value.

ENABLE_PKT_DUMP

public static boolean ENABLE_PKT_DUMP
A field to flag wether or not packet dumping should be enabled for all SLP protocol handler instances. This packet dump field is set to false by default.
Constructor Detail

SLP

public SLP(SLPTransportInterface trans)
Construct a new SLP protocol handler using the specified transport.
Parameters:
trans - an initialized transport to use for data I/O.
Method Detail

static void ()

connect

public void connect()
Initialize the connection to the remote SLP provider. When called, this method will cause the protocol stack to start listening to the transport for a connection, followed by SLP packet data.

disconnect

public void disconnect()
Disconnects the protocol stack from the underlying transport. Calling this method will disengage the SLP protocol handler from the transport.

enableDebugMode

public void enableDebugMode()
Enables debug mode, providing packet output to the set PrintStream.

handleCMPPacket

protected void handleCMPPacket(SLP_Packet pkt)
A handler for CMP packets. CMP Packets encapsulated in SLP have not been valid since HotSync 1.0. This method is called if a CMP packet has been received, and causes an error to be written if debugmode is enabled. Otherwise, the packet is discarded with no further processing. If you need to do CMP I/O, use the CMP_DLP class to do it via PADP.
Parameters:
pkt - the SLP packet received.
See Also:
CMP_DLP

handlePADPacket

protected void handlePADPacket(SLP_Packet pkt)
A handler for PAD Packets. This method is called when a PADP packet has been received.
Parameters:
pkt - the SLP packet received.

handleSystemPacket

protected void handleSystemPacket(SLP_Packet pkt)
A handler for System Packets. This method is called when a System packet has been received. This class currently doesn't do anything with system packets, other than to discard them.
Parameters:
pkt - the SLP packet received.

handleTestPacket

protected void handleTestPacket(SLP_Packet pkt)
A handler for Test Packets. This method is called when a test packet has been received. Test packets are sent by the handheld as a part of the SLP wakeup process at the start of a serial synchronization operation. They are always ignored.
Parameters:
pkt - the SLP packet received.

incInputQueueEnd

protected int incInputQueueEnd()
                        throws SLP_QueueOverrunException
Increment the end pointer for the input queue. The I/O queues in this class are treated as circular arrays. When we hit the end of the array, we advance back to the beginning, if it isn't being used already. If the end pointer's incrementation would cause it to overwrite the packet pointed to by the start pointer, an SLP_QueueOverrunException will occur.
Returns:
the new value for the input queue end pointer.
Throws:
SLP_QueueOverrunException - if the input queue is overrun.

incInputQueueStart

protected int incInputQueueStart()
                          throws SLP_QueueOverrunException
Increment the start pointer for the input queue. The I/O queues in this class are treated as circular arrays. When we hit the end of the array, we advance back to the beginning, if it isn't being used already. If the start pointer's incrementation would cause it to pass the cell referenced by to by the end pointer (ie: an underrun occurs), an SLP_QueueOverrunException will occur.
Returns:
the new value for the input queue start pointer.
Throws:
SLP_QueueOverrunException - if the input queue is underrun.

incOutputQueueEnd

protected int incOutputQueueEnd()
                         throws SLP_QueueOverrunException
Increment the end pointer for the output queue. The I/O queues in this class are treated as circular arrays. When we hit the end of the array, we advance back to the beginning, if it isn't being used already. If the end pointer's incrementation would cause it to overwrite the packet pointed to by the start pointer, an SLP_QueueOverrunException will occur.
Returns:
the new value for the output queue end pointer.
Throws:
SLP_QueueOverrunException - if the output queue is overrun.

incOutputQueueStart

protected int incOutputQueueStart()
                           throws SLP_QueueOverrunException
Increment the start pointer for the output queue. The I/O queues in this class are treated as circular arrays. When we hit the end of the array, we advance back to the beginning, if it isn't being used already. If the start pointer's incrementation would cause it to pass the cell referenced by to by the end pointer (ie: an underrun occurs), an SLP_QueueOverrunException will occur.
Returns:
the new value for the output queue start pointer.
Throws:
SLP_QueueOverrunException - if the output queue is underrun.

readPacket

public GenericPacket readPacket()
                         throws NotConnectedException
Reads the next packet from the input queue. If the protocol stack is connected, a call to this method will return either the next element in the input queue, or will block until there is a packet in the queue to return.
Returns:
the data contained within the next read packet.
Throws:
NotConnectedException - thrown if the SLP protocol isn't corrected when this method is called, or if the connection is lost while waiting for the next packet.

setDebugOutputStream

public void setDebugOutputStream(java.io.PrintStream stream)
Sets the print stream to use for debug output. By default, this class will direct all output to System.err. However, this can be overridden by calling this method.
Parameters:
stream - the PrintStream object to use for debug output.

writePacket

public void writePacket(byte[] data,
                        byte src,
                        byte dest,
                        byte transID)
                 throws NotConnectedException
Writen a packet of data via the SLP protocol to the other end of the transfer.
Parameters:
data - the data to be encapsulated in an SLP_Packet object and placed in the output queue.
src - the source socket.
dest - the destination socket.
transID - the transaction ID for the packet.
Throws:
NotConnectedException - thrown if the SLP handler isn't connected to a remote SLP system, or if the connection is lost during packet processing.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.