com.intel.bluetooth.obex
Class OBEXClientSessionImpl

java.lang.Object
  extended by com.intel.bluetooth.obex.OBEXClientSessionImpl
All Implemented Interfaces:
BluetoothConnectionAccess, Connection, ClientSession

public class OBEXClientSessionImpl
extends Object
implements ClientSession

ClientSession implementation. See Bluetooth Specification Documents for details.

Your application should not use this class directly.


Field Summary
protected  Authenticator authenticator
           
protected  long connectionID
           
protected  boolean isConnected
           
protected  int mtu
           
protected  OBEXConnectionParams obexConnectionParams
           
protected  int packetsCountRead
           
protected  int packetsCountWrite
           
protected  boolean requestSent
          Each request packet flowed by response.
 
Constructor Summary
OBEXClientSessionImpl(StreamConnection conn, OBEXConnectionParams obexConnectionParams)
          Applications should not used this function.
 
Method Summary
 void close()
           
 HeaderSet connect(HeaderSet headers)
          Completes an OBEX CONNECT operation.
 HeaderSet createHeaderSet()
          Creates a javax.obex.HeaderSet object.
static HeaderSet createOBEXHeaderSet()
           
 HeaderSet delete(HeaderSet headers)
          Performs an OBEX DELETE operation.
 HeaderSet disconnect(HeaderSet headers)
          Completes an OBEX DISCONNECT operation.
 boolean encrypt(long address, boolean on)
           
 Operation get(HeaderSet headers)
          Performs an OBEX GET operation.
 BluetoothStack getBluetoothStack()
           
 long getConnectionID()
          Retrieves the connection ID that is being used in the present connection.
 long getRemoteAddress()
           
 RemoteDevice getRemoteDevice()
           
 int getSecurityOpt()
           
 boolean isClosed()
           
 void markAuthenticated()
           
 Operation put(HeaderSet headers)
          Performs an OBEX PUT operation.
protected  byte[] readPacket()
           
 void setAuthenticator(Authenticator auth)
          Sets the Authenticator to use with this connection.
 void setConnectionID(long id)
          Sets the connection ID header to include in the request packets.
 HeaderSet setPath(HeaderSet headers, boolean backup, boolean create)
          Completes an OBEX SETPATH operation.
 void setRemoteDevice(RemoteDevice remoteDevice)
           
 void shutdown()
           
protected  void writePacket(int commId, com.intel.bluetooth.obex.OBEXHeaderSetImpl headers)
           
protected  void writePacketWithFlags(int commId, byte[] headerFlagsData, com.intel.bluetooth.obex.OBEXHeaderSetImpl headers)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isConnected

protected boolean isConnected

connectionID

protected long connectionID

mtu

protected int mtu

authenticator

protected Authenticator authenticator

obexConnectionParams

protected OBEXConnectionParams obexConnectionParams

packetsCountWrite

protected int packetsCountWrite

packetsCountRead

protected int packetsCountRead

requestSent

protected boolean requestSent
Each request packet flowed by response. This flag is from Client point of view

Constructor Detail

OBEXClientSessionImpl

public OBEXClientSessionImpl(StreamConnection conn,
                             OBEXConnectionParams obexConnectionParams)
                      throws IOException,
                             Error
Applications should not used this function.

Throws:
Error - if called from outside of BlueCove internal code.
IOException
Method Detail

createHeaderSet

public HeaderSet createHeaderSet()
Description copied from interface: ClientSession
Creates a javax.obex.HeaderSet object. This object can be used to define header values in a request.

Specified by:
createHeaderSet in interface ClientSession
Returns:
a new javax.obex.HeaderSet object
See Also:
HeaderSet

connect

public HeaderSet connect(HeaderSet headers)
                  throws IOException
Description copied from interface: ClientSession
Completes an OBEX CONNECT operation. If the headers argument is null, no headers will be sent in the request. This method will never return null.

This method must be called and a successful response code of OBEX_HTTP_OK must be received before put(), get(), setPath(), delete(), or disconnect() may be called. Similarly, after a successful call to disconnect(), this method must be called before calling put(), get(), setPath(), delete(), or disconnect().

Specified by:
connect in interface ClientSession
Parameters:
headers - the headers to send in the CONNECT request
Returns:
the headers that were returned from the server
Throws:
IOException - if an error occurred in the transport layer; if the client is already in an operation; if this method had already been called with a successful response code of OBEX_HTTP_OK and calls to disconnect() have not returned a response code of OBEX_HTTP_OK; if the headers defined in headers exceed the max packet length

disconnect

public HeaderSet disconnect(HeaderSet headers)
                     throws IOException
Description copied from interface: ClientSession
Completes an OBEX DISCONNECT operation. If the headers argument is null, no headers will be sent in the request. This method will end the session. A new session may be started by calling connect(). This method will never return null.

Specified by:
disconnect in interface ClientSession
Parameters:
headers - the header to send in the DISCONNECT request
Returns:
the headers returned by the server
Throws:
IOException - if an error occurred in the transport layer; if the client is already in an operation; if an OBEX connection does not exist because connect() has not been called; if disconnect() has been called and received a response code of OBEX_HTTP_OK after the last call to connect(); if the headers defined in headers exceed the max packet length

setConnectionID

public void setConnectionID(long id)
Description copied from interface: ClientSession
Sets the connection ID header to include in the request packets. If a connection ID is set, it will be sent in each request to the server except for the CONNECT request. An application only needs to set the connection ID if it is trying to operate with different targets over the same transport layer connection. If a client receives a connection ID from the server, the implementation will continue to use that connection ID until the application changes it or until the connection is closed.

Specified by:
setConnectionID in interface ClientSession
Parameters:
id - the connection ID to use

getConnectionID

public long getConnectionID()
Description copied from interface: ClientSession
Retrieves the connection ID that is being used in the present connection. This method will return -1 if no connection ID is being used.

Specified by:
getConnectionID in interface ClientSession
Returns:
the connection ID being used or -1 if no connection ID is being used

setPath

public HeaderSet setPath(HeaderSet headers,
                         boolean backup,
                         boolean create)
                  throws IOException
Description copied from interface: ClientSession
Completes an OBEX SETPATH operation. If the headers argument is null, no headers will be sent in the request. This method will never return null.

Specified by:
setPath in interface ClientSession
Parameters:
headers - the headers to include in the SETPATH request
backup - if true, instructs the server to back up one directory before moving to the directory specified in name (similar to cd .. on PCs); if false, apply name to the current directory
create - if true, instructs the server to create the directory if it does not exist; if false, instruct the server to return an error code if the directory does not exist
Returns:
the headers that were returned from the server
Throws:
IOException - if an error occurred in the transport layer; if the client is already in an operation; if an OBEX connection does not exist because connect() has not been called; if disconnect() had been called and a response code of OBEX_HTTP_OK was received; if the headers defined in headers exceed the max packet length

get

public Operation get(HeaderSet headers)
              throws IOException
Description copied from interface: ClientSession
Performs an OBEX GET operation. This method will send the OBEX headers provided to the server and return an Operation object to continue with the operation. The headers argument may be null. This method will never return null.

Specified by:
get in interface ClientSession
Parameters:
headers - the OBEX headers to send as part of the initial GET request
Returns:
the OBEX operation that will complete the GET request
Throws:
IOException - if an error occurred in the transport layer; if an OBEX connection does not exist because connect() has not been called; if disconnect() had been called and a response code of OBEX_HTTP_OK was received; if connect() has not been called; if the client is already in an operation;
See Also:
Operation

put

public Operation put(HeaderSet headers)
              throws IOException
Description copied from interface: ClientSession
Performs an OBEX PUT operation. This method will send the OBEX headers provided to the server and return an Operation object to continue with the PUT operation. The headers argument may be null. This method will never return null.

Specified by:
put in interface ClientSession
Parameters:
headers - the OBEX headers to send in the initial PUT request
Returns:
the operation object used to complete the PUT request
Throws:
IOException - if an error occurred in the transport layer; if an OBEX connection does not exist because connect() has not been called; if disconnect() had been called and a response code of OBEX_HTTP_OK was received; if connect() has not been called; if the client is already in an operation;
See Also:
Operation

delete

public HeaderSet delete(HeaderSet headers)
                 throws IOException
Description copied from interface: ClientSession
Performs an OBEX DELETE operation. If the headers argument is null, no headers will be sent in the request. This method will never return null.

Specified by:
delete in interface ClientSession
Parameters:
headers - the header to send in the DELETE request
Returns:
the headers returned by the server
Throws:
IOException - if an error occurred in the transport layer; if the client is already in an operation; if an OBEX connection does not exist because connect() has not been called; if disconnect() had been called and a response code of OBEX_HTTP_OK was received; if the headers defined in headers exceed the max packet length

setAuthenticator

public void setAuthenticator(Authenticator auth)
Description copied from interface: ClientSession
Sets the Authenticator to use with this connection. The Authenticator allows an application to respond to authentication challenge and authentication response headers. If no Authenticator is set, the response to an authentication challenge or authentication response header is implementation dependent.

Specified by:
setAuthenticator in interface ClientSession
Parameters:
auth - the Authenticator to use for this connection

close

public void close()
           throws IOException
Specified by:
close in interface Connection
Throws:
IOException

createOBEXHeaderSet

public static HeaderSet createOBEXHeaderSet()

writePacket

protected void writePacket(int commId,
                           com.intel.bluetooth.obex.OBEXHeaderSetImpl headers)
                    throws IOException
Throws:
IOException

writePacketWithFlags

protected void writePacketWithFlags(int commId,
                                    byte[] headerFlagsData,
                                    com.intel.bluetooth.obex.OBEXHeaderSetImpl headers)
                             throws IOException
Throws:
IOException

readPacket

protected byte[] readPacket()
                     throws IOException
Throws:
IOException

getRemoteAddress

public long getRemoteAddress()
                      throws IOException
Specified by:
getRemoteAddress in interface BluetoothConnectionAccess
Throws:
IOException

getRemoteDevice

public RemoteDevice getRemoteDevice()
Specified by:
getRemoteDevice in interface BluetoothConnectionAccess

isClosed

public boolean isClosed()
Specified by:
isClosed in interface BluetoothConnectionAccess

shutdown

public void shutdown()
              throws IOException
Specified by:
shutdown in interface BluetoothConnectionAccess
Throws:
IOException

markAuthenticated

public void markAuthenticated()
Specified by:
markAuthenticated in interface BluetoothConnectionAccess

getSecurityOpt

public int getSecurityOpt()
Specified by:
getSecurityOpt in interface BluetoothConnectionAccess

encrypt

public boolean encrypt(long address,
                       boolean on)
                throws IOException
Specified by:
encrypt in interface BluetoothConnectionAccess
Throws:
IOException
See Also:
RemoteDevice.encrypt(javax.microedition.io.Connection , boolean)

setRemoteDevice

public void setRemoteDevice(RemoteDevice remoteDevice)
Specified by:
setRemoteDevice in interface BluetoothConnectionAccess

getBluetoothStack

public BluetoothStack getBluetoothStack()
Specified by:
getBluetoothStack in interface BluetoothConnectionAccess


JSR-82 Javadocs Apache License, Version 2.0 Copyright © 2001-2008 Motorola, Inc. ALL RIGHTS RESERVED.
BlueCove Javadocs
Apache License, Version 2.0 Copyright © 2004-2008 BlueCove Team.