FileDocCategorySizeDatePackage
Protocol.javaAPI DocphoneME MR2 API (J2ME)5632Wed May 02 18:00:30 BST 2007com.sun.midp.io.j2me.btgoep

Protocol

public class Protocol extends com.sun.midp.io.BluetoothProtocol
Provides a wrapper for "btgoep" protocol implementation to answer the GCF style.

Fields Summary
private static com.sun.midp.security.SecurityToken
internalSecurityToken
The internal security token is privileged and allows to skip permissions check for btspp in case ones are allowed for btgoep.
String
name
Originally requested url saved to reused in btspp transport.
Constructors Summary
public Protocol()
Constructs an instance.

    
            
      
        super(BluetoothUrl.OBEX);
    
Methods Summary
protected voidcheckUrl(com.sun.midp.io.BluetoothUrl url)
Ensures URL parameters have valid value. Makes nothing actually for all the required checks will be done durin ntspp transport creation.

param
url URL to check

protected javax.microedition.io.ConnectionclientConnection(com.sun.midp.security.SecurityToken token, int mode)
Creates ClientSession connection over the rfcomm transport layer

param
token security token of the calling class
param
mode I/O access mode
return
ClientSession connection instance
exception
IOException if openning connection fails.

        checkForPermission(token, Permissions.OBEX_CLIENT);

        StreamConnection sock = (StreamConnection)
            new com.sun.midp.io.j2me.btspp.Protocol().
            openPrim(getBtsppToken(token), name, mode, false);
        return new ClientSessionImpl(new BTGOEPConnection(sock));
    
private static com.sun.midp.security.SecurityTokengetBtsppToken(com.sun.midp.security.SecurityToken token)
Retrieves privileged token if there is no defined one.

param
token security token on hands or null if there is no one
return
privileged security token that allow acces to btspp if given token is null, the token given otherwise.

        return (token == null) ? internalSecurityToken : token;
    
public javax.microedition.io.ConnectionopenPrim(java.lang.Object token, java.lang.String name, int mode, boolean timeouts)
Cheks permissions and opens requested connection. Returns either ClientSession or SessionNotifier for OBEX connections, depending whether client or server URL was specified. Actually all essential logic is implemented in the superclass, this one only saves resource name to reuse it for opening btspp transport.

param
token security token of the calling class
param
name the URL for the connection without protocol.
param
mode obex supports READ_WRITE mode only.
param
timeouts ignored (because it is allowed by spec).
return
ClientSession for client url or SessionNotifier for server url.
exception
IOException if opening connection fails.

        this.name = name;
        return super.openPrim(token, name, mode, timeouts);
    
protected javax.microedition.io.ConnectionserverConnection(com.sun.midp.security.SecurityToken token, int mode)
Creates server connection over the rfcomm transport layer

param
token security token of the calling class
param
mode I/O access mode
return
server connection instance
exception
IOException if openning connection fails.

        checkForPermission(token, Permissions.OBEX_SERVER);
        
        StreamConnectionNotifier sock = (StreamConnectionNotifier)
            new com.sun.midp.io.j2me.btspp.Protocol().
            openPrim(getBtsppToken(token), name, mode, false);
        return new SessionNotifierImpl(new BTGOEPNotifier(sock));