From 33e8b73da7c85b199ed3aef0fab9db486484945b Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Thu, 5 Apr 2012 15:52:45 -0400 Subject: [PATCH] lib: renamed SB_DBOP_SET_RECORD to SB_DBOP_ADD_RECORD, and packet API This is an internal change only. --- src/m_desktop.cc | 11 ++--------- src/packet.cc | 10 +++++----- src/packet.h | 2 +- src/protocol.h | 2 +- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/m_desktop.cc b/src/m_desktop.cc index 153bc0de..cdeb3b1d 100644 --- a/src/m_desktop.cc +++ b/src/m_desktop.cc @@ -214,7 +214,7 @@ void Desktop::AddRecord(unsigned int dbId, Builder &build) DBPacket packet(*this, m_command, m_response); - if( packet.SetRecord(dbId, build, m_ic) ) { + if( packet.AddRecord(dbId, build, m_ic) ) { std::ostringstream oss; @@ -427,20 +427,13 @@ void Desktop::SaveDatabase(unsigned int dbId, Builder &builder) { dout("Database ID: " << dbId); - // Protocol note: so far in testing, this CLEAR_DATABASE operation is - // required, since every record sent via SET_RECORD - // is treated like a hypothetical "ADD_RECORD" (perhaps - // SET_RECORD should be renamed)... I don't know if - // there is a real SET_RECORD... all I know is from - // the Windows USB captures, which uses this same - // technique. ClearDatabase(dbId); DBPacket packet(*this, m_command, m_response); // loop until builder object has no more data bool first = true; - while( packet.SetRecord(dbId, builder, m_ic) ) { + while( packet.AddRecord(dbId, builder, m_ic) ) { dout("Database ID: " << dbId); m_socket->Packet(packet, first ? 60000 : -1); diff --git a/src/packet.cc b/src/packet.cc index f948802d..6f78834b 100644 --- a/src/packet.cc +++ b/src/packet.cc @@ -411,16 +411,16 @@ void DBPacket::GetRecords(unsigned int dbId) } // -// SetRecord +// AddRecord // -/// Builds a command packet in the m_send buffer for the SET_RECORD command +/// Builds a command packet in the m_send buffer for the ADD_RECORD command /// code. /// /// \return bool /// - true means success /// - false means no data available from Builder object /// -bool DBPacket::SetRecord(unsigned int dbId, Builder &build, const IConverter *ic) +bool DBPacket::AddRecord(unsigned int dbId, Builder &build, const IConverter *ic) { // build packet data DBData send(m_send, false); // send is just a reference to m_send, @@ -439,7 +439,7 @@ bool DBPacket::SetRecord(unsigned int dbId, Builder &build, const IConverter *ic packet.size = htobs(total_size); packet.command = SB_COMMAND_DB_DATA; packet.u.db.tableCmd = m_con.GetDBCommand(Mode::Desktop::DatabaseAccess); - packet.u.db.u.command.operation = SB_DBOP_SET_RECORD; + packet.u.db.u.command.operation = SB_DBOP_ADD_RECORD; packet.u.db.u.command.databaseId = htobs(dbId); packet.u.db.u.command.u.tag_upload.rectype = send.GetRecType(); packet.u.db.u.command.u.tag_upload.uniqueId = htobl(send.GetUniqueId()); @@ -447,7 +447,7 @@ bool DBPacket::SetRecord(unsigned int dbId, Builder &build, const IConverter *ic m_send.ReleaseBuffer(total_size); - m_last_dbop = SB_DBOP_SET_RECORD; + m_last_dbop = SB_DBOP_ADD_RECORD; return true; } diff --git a/src/packet.h b/src/packet.h index 0b9b7982..5aa5c3da 100644 --- a/src/packet.h +++ b/src/packet.h @@ -161,7 +161,7 @@ public: void GetRecordByIndex(unsigned int dbId, unsigned int stateTableIndex); bool SetRecordByIndex(unsigned int dbId, unsigned int stateTableIndex, Builder &build, const IConverter *ic); void GetRecords(unsigned int dbId); - bool SetRecord(unsigned int dbId, Builder &build, const IConverter *ic); + bool AddRecord(unsigned int dbId, Builder &build, const IConverter *ic); ////////////////////////////////// diff --git a/src/protocol.h b/src/protocol.h index b30eeae3..e03be06a 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -171,7 +171,7 @@ // DB Operation Command -#define SB_DBOP_SET_RECORD 0x41 +#define SB_DBOP_ADD_RECORD 0x41 #define SB_DBOP_CLEAR_DATABASE 0x43 #define SB_DBOP_GET_DBDB 0x4a #define SB_DBOP_OLD_GET_DBDB 0x4c -- 2.11.4.GIT