RfcommSession Class Reference
[Bluetooth Hands-Free Profile Implementation]

Session building block for RFCOMM profiles. More...

#include <rfcomm.h>

Inheritance diagram for RfcommSession:

Inheritance graph
[legend]
Collaboration diagram for RfcommSession:

Collaboration graph
[legend]

List of all members.

Public Member Functions

RfcommServiceGetService (void) const
 Query the service associated with the session.
rfcomm_secmode_t GetSecMode (void) const
 Query the security mode of the connection to the device.
bool IsAutoReconnect (void) const
 Query whether the autoreconnect mechanism is enabled for this device.
void SetAutoReconnect (bool enable)
 Enable or disable the autoreconnect mechanism for this device.
bool IsConnectionRemoteInitiated (void) const
 Query whether an in-progress or complete connection to the device was initiated by the device.
bool IsPriorDisconnectVoluntary (void) const
 Query whether the last disconnection was voluntary or involuntary.
BtDeviceGetDevice (void) const
 Query the BtDevice associated with the session.
void Disconnect (bool voluntary=true)
 Request disconnection of the session.
BtHubGetHub (void) const
DispatchInterfaceGetDi (void) const
void * GetPrivate (void) const
 Query the private pointer associated with the object.
void SetPrivate (void *priv)
 Assign the private pointer associated with the object.
void Get (void)
 Increment the reference count.
void Put (void)
 Decrement the reference count.

Public Attributes

Callback< void, BtManaged * > cb_NotifyDestroy
 Object destruction notification callback.


Detailed Description

Session building block for RFCOMM profiles.

RfcommSession is a proto-session that contains utility code useful for creating a service handler for an RFCOMM profile. It works in conjunction with RfcommService.

See also:
HfpService

Member Function Documentation

RfcommService* GetService ( void   )  const [inline]

Query the service associated with the session.

Returns:
A pointer to the BtService object associated with the session. A BtService object is not very useful, as the real service object is derived from BtServce, and added functionality is not exposed through BtService.

Reimplemented from BtSession.

Reimplemented in HfpSession.

rfcomm_secmode_t GetSecMode ( void   )  const [inline]

Query the security mode of the connection to the device.

For information on the security mode, see rfcomm_secmode_t.

If the device is connected, this accessor will return the security mode associated with the socket.

Security modes are configured at the service level, as they must be set at the socket level prior to connection in order to take effect. For inbound connections, the service object is the keeper of the one listening socket that accepts inbound connections and assigns their security modes.

While it may be possible to try to manage security modes at the level of each session, at least for outbound connections, no compelling reasons have been identified at the time of this writing and management only at the level of the service is supported.

Returns:
The security mode applied to the service-level socket, if the device is in the Connecting or Connected state. If Disconnected, the return value is undefined.
See also:
RfcommService::SetSecMode()

bool IsAutoReconnect ( void   )  const [inline]

Query whether the autoreconnect mechanism is enabled for this device.

Return values:
true Autoreconnect is enabled
false Autoreconnect is disabled.
See also:
SetAutoReconnect()

void SetAutoReconnect ( bool  enable  ) 

Enable or disable the autoreconnect mechanism for this device.

If enabled, whenever the device is disconnected, a reconnection attempt will be made periodically through a timer. Auto-reconnection is useful for devices such as phones that regularly move in and out of range.

This function can affect the life cycle management of the object it is called on.

Parameters:
enable Set to true to enable, false to disable.
See also:
IsAutoReconnect(), Connect()

bool IsConnectionRemoteInitiated ( void   )  const [inline]

Query whether an in-progress or complete connection to the device was initiated by the device.

This is useful for connection auditing logic, e.g. to refuse connections from unknown devices.

Return values:
true The device initiated the connection
false The local UI or autoreconnect mechanism initiated the connection

bool IsPriorDisconnectVoluntary ( void   )  const [inline]

Query whether the last disconnection was voluntary or involuntary.

When a connection is explicitly broken, e.g. selecting a disconnect function on the device or calling Disconnect(), it is considered voluntary. When a connection fails for implicit reasons such as a device moving out of radio range or an HCI being disconnected, it is considered involuntary. This function reports whether the last transition from the Connecting or Connected state to the Disconnected state was voluntary.

Return values:
true The last transition to the Disconnected state was voluntary.
false The last transition to the Disconnected state was involuntary.
Note:
This information is useful for deciding whether to disable auto-reconnection of a service to a particular device.

BtDevice* GetDevice ( void   )  const [inline, inherited]

Query the BtDevice associated with the session.

Returns:
A pointer to the BtDevice to which the session is attached.
Note:
The BtDevice returned does not have a reference added to it. Callers should take care to avoid dangling pointers.

void Disconnect ( bool  voluntary = true  )  [inline, inherited]

Request disconnection of the session.

This abstract interface allows one to request any connection-oriented session object derived from BtSession to disconnect itself.

Parameters:
voluntary Whether the disconnection should be presented as voluntary and explicit, i.e. selecting disconnect on a list, or involuntary, i.e. exiting Bluetooth radio range.

BtHub* GetHub ( void   )  const [inline, inherited]

Query the presiding BtHub

DispatchInterface* GetDi ( void   )  const [inline, inherited]

Query the dispatcher interface of the presiding BtHub

void* GetPrivate ( void   )  const [inline, inherited]

Query the private pointer associated with the object.

All BtManaged derived objects have a single pointer field reserved for the use of clients. It is always initialized to zero when the object is constructed, and clients may assign it as they wish.

Returns:
The current value of the private pointer

void SetPrivate ( void *  priv  )  [inline, inherited]

Assign the private pointer associated with the object.

All BtManaged derived objects have a single pointer field reserved for the use of clients. It is always initialized to zero when the object is constructed, and clients may assign it as they wish.

Parameters:
priv New value to assign to the private pointer

void Get ( void   )  [inline, inherited]

Increment the reference count.

As per managed objects, BtManaged derived objects are not deleted so long as they have a positive reference count.

See also:
Put()

void Put ( void   )  [inherited]

Decrement the reference count.

As per managed objects, when the object's reference count reaches zero, the object will be destroyed in the context of a timer event.

See also:
Get()


Member Data Documentation

Callback<void, BtManaged*> cb_NotifyDestroy [inherited]

Object destruction notification callback.

This callback is invoked proir to deletion of the managed object, so that clients may release associated resources. This callback occurs in the context of a timer event, and complies with the rule of not invoking client callbacks in a nested fashion.

The decision to destroy the object is final. The client may not attempt to preserve the object by acquiring additional references from this callback.


The documentation for this class was generated from the following files:
Generated on Fri Jan 9 05:58:38 2009 for libhfp by  doxygen 1.5.4