# Barry::Mode::Mode Class Reference

`#include <m_mode_base.h>`

Inheritance diagram for Barry::Mode::Mode:

[legend]
Collaboration diagram for Barry::Mode::Mode:

[legend]

List of all members.

## Detailed Description

Base class for simple mode classes.

Put common code here.

Definition at line 37 of file m_mode_base.h.

## Public Member Functions

void | Open (const char *password=0)
| Select device mode.
void | Open (const char *password, const char *name)
| Select device mode.
void | RetryPassword (const char *password)
| Retry a failed password attempt from the first call to Open().

## Member Function Documentation

void Barry::Mode::Mode::Open | ( | const char * | password = `0` | ) |

Select device mode.

This is required before using any other mode-based operations, such as GetDBDB() and LoadDatabase().

This function opens a socket to the device for communicating in Desktop mode. If the device requires it, specify the password with a const char* string in password. The password will not be stored in memory inside this class, only a hash will be generated from it. After using the hash, the hash memory will be set to 0. The application is responsible for safely handling the raw password data.

You can retry the password by catching Barry::BadPassword and calling RetryPassword() with the new password.

Exceptions:

  | Barry::Error | Thrown on protocol error.
  | std::logic_error() | Thrown if unsupported mode is requested, or if socket already open.
  | Barry::BadPassword | Thrown when password is invalid or if not enough retries left in the device.

Definition at line 67 of file m_mode_base.cc.

References RetryPassword(), and Barry::Controller::SelectMode().

Here is the call graph for this function:

void Barry::Mode::Mode::Open | ( | const char * | password,
|  | const char * | name |
| ) |  |  |

Select device mode.

This is required before using any other mode-based operations, such as GetDBDB() and LoadDatabase().

This function opens a socket to the device for communicating in Desktop mode. If the device requires it, specify the password with a const char* string in password. The password will not be stored in memory inside this class, only a hash will be generated from it. After using the hash, the hash memory will be set to 0. The application is responsible for safely handling the raw password data.

It uses the provided name as the name for the socket used in this mode. Usually this shouldn't be needed unless using the raw channel mode.

You can retry the password by catching Barry::BadPassword and calling RetryPassword() with the new password.

Exceptions:

  | Barry::Error | Thrown on protocol error.
  | std::logic_error() | Thrown if unsupported mode is requested, or if socket already open.
  | Barry::BadPassword | Thrown when password is invalid or if not enough retries left in the device.

Definition at line 109 of file m_mode_base.cc.

References RetryPassword(), and Barry::Controller::SelectMode().

Here is the call graph for this function:

void Barry::Mode::Mode::RetryPassword | ( | const char * | password | ) |

Retry a failed password attempt from the first call to Open().

Only call this function in response to Barry::BadPassword exceptions that are thrown from Open().

Exceptions:

  | Barry::Error | Thrown on protocol error.
  | std::logic_error() | Thrown if in unsupported mode, or if socket already open.
  | Barry::BadPassword | Thrown when password is invalid or if not enough retries left in the device.

Definition at line 138 of file m_mode_base.cc.

References Barry::Controller::m_zero.

Referenced by Open().

Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- m_mode_base.h
- m_mode_base.cc