#include <packet.h>
Inheritance diagram for Barry::DBPacket:
This class relies on 3 external objects: a Mode::Desktop object, a send Data buffer, and a receive data buffer. Socket and connection details are retrieved on a readonly basis from the Mode::Desktop object, but both send and receive buffers can be modified.
Note that the receive buffer may be modified during a packet send, and this DBPacket class provides API helpers to analyze the results.
Definition at line 118 of file packet.h.
Public Member Functions | |
DBPacket (Mode::Desktop &con, Data &send, Data &receive) | |
~DBPacket () | |
void | ClearDatabase (unsigned int dbId) |
Builds a command packet for the CLEAR_DATABASE command code, placing the data in the send buffer. | |
void | GetDBDB () |
Builds a command packet for the GET_DBDB command code, placing the data in m_send. | |
void | GetRecordStateTable (unsigned int dbId) |
Builds a command packet in the send buffer for the GET_RECORD_STATE_TABLE command. | |
void | SetRecordFlags (unsigned int dbId, unsigned int stateTableIndex, uint8_t flag1) |
Builds a command packet in the send buffer for the SET_RECORD_FLAGS command code. | |
void | DeleteRecordByIndex (unsigned int dbId, unsigned int stateTableIndex) |
Builds a command packet in the send buffer for the DELETE_RECORD_BY_INDEX command code. | |
void | GetRecordByIndex (unsigned int dbId, unsigned int stateTableIndex) |
Builds a command packet in the send buffer for the GET_RECORD_BY_INDEX command code. | |
bool | SetRecordByIndex (unsigned int dbId, unsigned int stateTableIndex, Builder &build) |
Builds a command packet in the m_send buffer for the SET_RECORD_BY_INDEX command code. | |
void | GetRecords (unsigned int dbId) |
Builds a command packet in the send buffer for the GET_RECORDS command code. | |
bool | SetRecord (unsigned int dbId, Builder &build) |
Builds a command packet in the m_send buffer for the SET_RECORD command code. | |
unsigned int | ReturnCode () const |
unsigned int | DBOperation () const |
Returns the database operation code from the receive packet, assuming that receive contains a response packet. | |
bool | Parse (Parser &parser) |
Parses the data in the receive buffer, and attempts to be smart about it, using the last send command as guidance for what to expect in the response. | |
Friends | |
class | Socket |
void Barry::DBPacket::ClearDatabase | ( | unsigned int | dbId | ) |
Builds a command packet for the CLEAR_DATABASE command code, placing the data in the send buffer.
Definition at line 162 of file packet.cc.
References Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, and SB_DBOP_CLEAR_DATABASE.
Referenced by Barry::Mode::Desktop::SaveDatabase().
void Barry::DBPacket::GetDBDB | ( | ) |
Builds a command packet for the GET_DBDB command code, placing the data in m_send.
Definition at line 186 of file packet.cc.
References Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, and SB_DBOP_OLD_GET_DBDB.
Referenced by Barry::Mode::Desktop::LoadDBDB().
void Barry::DBPacket::GetRecordStateTable | ( | unsigned int | dbId | ) |
Builds a command packet in the send buffer for the GET_RECORD_STATE_TABLE command.
Definition at line 210 of file packet.cc.
References Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, and SB_DBOP_GET_RECORD_STATE_TABLE.
Referenced by Barry::Mode::Desktop::GetRecordStateTable().
void Barry::DBPacket::SetRecordFlags | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex, | |||
uint8_t | flag1 | |||
) |
Builds a command packet in the send buffer for the SET_RECORD_FLAGS command code.
FIXME - this API call is incomplete, since there are unknown flags in the SetRecordFlags protocol packet. Currently it is only used to set all flags to zero.
Definition at line 238 of file packet.cc.
References DBC_RECORD_FLAGS_SIZE, Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, SB_DBOP_SET_RECORD_FLAGS, and SB_PACKET_COMMAND_HEADER_SIZE.
Referenced by Barry::Mode::Desktop::ClearDirty().
void Barry::DBPacket::DeleteRecordByIndex | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex | |||
) |
Builds a command packet in the send buffer for the DELETE_RECORD_BY_INDEX command code.
Definition at line 267 of file packet.cc.
References DBC_RECORD_HEADER_SIZE, Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, SB_DBOP_DELETE_RECORD_BY_INDEX, and SB_PACKET_COMMAND_HEADER_SIZE.
Referenced by Barry::Mode::Desktop::DeleteRecord().
void Barry::DBPacket::GetRecordByIndex | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex | |||
) |
Builds a command packet in the send buffer for the GET_RECORD_BY_INDEX command code.
Definition at line 293 of file packet.cc.
References Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, and SB_DBOP_GET_RECORD_BY_INDEX.
Referenced by Barry::Mode::Desktop::GetRecord().
bool Barry::DBPacket::SetRecordByIndex | ( | unsigned int | dbId, | |
unsigned int | stateTableIndex, | |||
Builder & | build | |||
) |
Builds a command packet in the m_send buffer for the SET_RECORD_BY_INDEX command code.
Definition at line 322 of file packet.cc.
References Barry::Builder::BuildFields(), DBC_INDEXED_UPLOAD_HEADER_SIZE, Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), Barry::Data::GetSize(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), Barry::Builder::Retrieve(), SB_COMMAND_DB_DATA, SB_DBOP_SET_RECORD_BY_INDEX, and SB_PACKET_COMMAND_HEADER_SIZE.
Referenced by Barry::Mode::Desktop::SetRecord().
void Barry::DBPacket::GetRecords | ( | unsigned int | dbId | ) |
Builds a command packet in the send buffer for the GET_RECORDS command code.
Definition at line 360 of file packet.cc.
References Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), SB_COMMAND_DB_DATA, and SB_DBOP_OLD_GET_RECORDS.
Referenced by Barry::Mode::Desktop::LoadDatabase().
bool Barry::DBPacket::SetRecord | ( | unsigned int | dbId, | |
Builder & | build | |||
) |
Builds a command packet in the m_send buffer for the SET_RECORD command code.
Definition at line 388 of file packet.cc.
References Barry::Builder::BuildFields(), Barry::Builder::BuildHeader(), DBC_TAGGED_UPLOAD_HEADER_SIZE, Barry::Data::GetBuffer(), Barry::Mode::Desktop::GetDBCommand(), Barry::Builder::GetRecType(), Barry::Data::GetSize(), Barry::Builder::GetUniqueId(), htobl, htobs, Barry::Packet::m_send, MAKE_PACKETPTR_BUF, Barry::Data::ReleaseBuffer(), Barry::Builder::Retrieve(), SB_COMMAND_DB_DATA, SB_DBOP_SET_RECORD, and SB_PACKET_COMMAND_HEADER_SIZE.
Referenced by Barry::Mode::Desktop::AddRecord(), and Barry::Mode::Desktop::SaveDatabase().
unsigned int Barry::DBPacket::DBOperation | ( | ) | const |
Returns the database operation code from the receive packet, assuming that receive contains a response packet.
If receive isn't large enough, throws Error.
Definition at line 442 of file packet.cc.
References Barry::Protocol::CheckSize(), Barry::Packet::m_receive, MAKE_PACKET, and SB_PACKET_RESPONSE_HEADER_SIZE.
bool Barry::DBPacket::Parse | ( | Parser & | parser | ) |
Parses the data in the receive buffer, and attempts to be smart about it, using the last send command as guidance for what to expect in the response.
Definition at line 459 of file packet.cc.
References btohl, Barry::Protocol::CheckSize(), Barry::Parser::Clear(), DBR_OLD_TAGGED_RECORD_HEADER_SIZE, Barry::Packet::m_receive, MAKE_PACKET, Barry::Parser::ParseFields(), Barry::Parser::ParseHeader(), SB_DBOP_GET_RECORD_BY_INDEX, SB_DBOP_OLD_GET_RECORDS, SB_PACKET_RESPONSE_HEADER_SIZE, Barry::Parser::SetIds(), and Barry::Parser::Store().
Referenced by Barry::Mode::Desktop::GetRecord(), and Barry::Mode::Desktop::LoadDatabase().