#include <m_desktop.h>
Public Member Functions | |
void | Open (const char *password=0) |
Select device mode. | |
void | RetryPassword (const char *password) |
Retry a failed password attempt from the first call to Open(). | |
const DatabaseDatabase & | GetDBDB () const |
Returns DatabaseDatabase object for this connection. | |
unsigned int | GetDBID (const std::string &name) const |
Get numeric database ID by name. | |
unsigned int | GetDBCommand (CommandType ct) |
Get database command from command table. | |
void | GetRecordStateTable (unsigned int dbId, RecordStateTable &result) |
Retrieve the record state table from the handheld device, using the given database ID. | |
void | AddRecord (unsigned int dbId, Builder &build) |
Adds a record to the specified database. | |
void | GetRecord (unsigned int dbId, unsigned int stateTableIndex, Parser &parser) |
Retrieves a specific record from the specified database. | |
void | SetRecord (unsigned int dbId, unsigned int stateTableIndex, Builder &build) |
Overwrites a specific record in the device as identified by the stateTableIndex. | |
void | ClearDirty (unsigned int dbId, unsigned int stateTableIndex) |
Clears the dirty flag on the specified record in the specified database. | |
void | DeleteRecord (unsigned int dbId, unsigned int stateTableIndex) |
Deletes the specified record in the specified database. | |
void | LoadDatabase (unsigned int dbId, Parser &parser) |
Retrieve a database from the handheld device, using the given parser to parse the resulting data, and optionally store it. |
To use this class, use the following steps:
Definition at line 54 of file m_desktop.h.
void Barry::Mode::Desktop::AddRecord | ( | unsigned int | dbId, | |
Builder & | build | |||
) |
Adds a record to the specified database.
RecordId is retrieved from build, and duplicate IDs are allowed by the device (i.e. you can have two records with the same ID) but *not* recommended!
Definition at line 279 of file m_desktop.cc.
References Barry::DBPacket::ReturnCode(), and Barry::DBPacket::SetRecord().
void Barry::Mode::Desktop::ClearDirty | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex | |||
) |
Clears the dirty flag on the specified record in the specified database.
Definition at line 400 of file m_desktop.cc.
References Barry::DBPacket::SetRecordFlags().
void Barry::Mode::Desktop::DeleteRecord | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex | |||
) |
Deletes the specified record in the specified database.
Definition at line 420 of file m_desktop.cc.
References Barry::DBPacket::DeleteRecordByIndex().
unsigned int Barry::Mode::Desktop::GetDBCommand | ( | CommandType | ct | ) |
Get database command from command table.
Must call Open() before this.
Definition at line 216 of file m_desktop.cc.
Referenced by Barry::DBPacket::ClearDatabase(), Barry::DBPacket::DeleteRecordByIndex(), Barry::DBPacket::GetDBDB(), Barry::DBPacket::GetRecordByIndex(), Barry::DBPacket::GetRecords(), Barry::DBPacket::GetRecordStateTable(), Barry::DBPacket::SetRecord(), Barry::DBPacket::SetRecordByIndex(), and Barry::DBPacket::SetRecordFlags().
const DatabaseDatabase& Barry::Mode::Desktop::GetDBDB | ( | ) | const [inline] |
Returns DatabaseDatabase object for this connection.
Must call Open() first, which loads the DBDB.
Definition at line 93 of file m_desktop.h.
unsigned int Barry::Mode::Desktop::GetDBID | ( | const std::string & | name | ) | const |
Get numeric database ID by name.
[in] | name | Name of database, which matches one of the names listed in GetDBDB() |
Barry::Error | Thrown if name not found. |
Definition at line 200 of file m_desktop.cc.
void Barry::Mode::Desktop::GetRecord | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex, | |||
Parser & | parser | |||
) |
Retrieves a specific record from the specified database.
The stateTableIndex comes from the GetRecordStateTable() function. GetRecord() does not clear the dirty flag.
Definition at line 315 of file m_desktop.cc.
References Barry::DBPacket::GetRecordByIndex(), and Barry::DBPacket::Parse().
void Barry::Mode::Desktop::GetRecordStateTable | ( | unsigned int | dbId, | |
RecordStateTable & | result | |||
) |
Retrieve the record state table from the handheld device, using the given database ID.
Results will be stored in result, which will be cleared before adding.
Definition at line 252 of file m_desktop.cc.
References Barry::DBPacket::GetRecordStateTable().
void Barry::Mode::Desktop::LoadDatabase | ( | unsigned int | dbId, | |
Parser & | parser | |||
) |
Retrieve a database from the handheld device, using the given parser to parse the resulting data, and optionally store it.
See the RecordParser<> template to create a parser object. The RecordParser<> template allows custom storage based on the type of database record retrieved. The database ID and the parser Record type must match.
[in] | dbId | Database Database ID - use GetDBID() |
[out] | parser | Parser object which parses the resulting protocol data, and optionally stores it in a custom fashion. See the RecordParser<> template. |
Barry::Error | Thrown on protocol error. | |
std::logic_error | Thrown if not in Desktop mode. |
Definition at line 458 of file m_desktop.cc.
References Barry::DBPacket::GetRecords(), and Barry::DBPacket::Parse().
void Barry::Mode::Desktop::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.
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 148 of file m_desktop.cc.
References RetryPassword(), and Barry::Controller::SelectMode().
void Barry::Mode::Desktop::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().
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 177 of file m_desktop.cc.
References Barry::Controller::m_zero.
Referenced by Open().
void Barry::Mode::Desktop::SetRecord | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex, | |||
Builder & | build | |||
) |
Overwrites a specific record in the device as identified by the stateTableIndex.
Definition at line 363 of file m_desktop.cc.
References Barry::DBPacket::ReturnCode(), and Barry::DBPacket::SetRecordByIndex().