error.h | error.h | |||
---|---|---|---|---|
skipping to change at line 42 | skipping to change at line 42 | |||
// | // | |||
// Error class | // Error class | |||
// | // | |||
/// The base class for any future derived exceptions. | /// The base class for any future derived exceptions. | |||
/// Can be thrown on any protocol error. | /// Can be thrown on any protocol error. | |||
/// | /// | |||
class Error : public std::runtime_error | class Error : public std::runtime_error | |||
{ | { | |||
public: | public: | |||
Error(const std::string &str) : std::runtime_error(str) {} | Error(const std::string &str) : std::runtime_error(str) {} | |||
Error(int libusb_errno, const std::string &str); | ||||
}; | }; | |||
// | // | |||
// BadPassword | // BadPassword | |||
// | // | |||
/// A bad or unknown password when talking to the device. | /// A bad or unknown password when talking to the device. | |||
/// Can be thrown in the following instances: | /// Can be thrown in the following instances: | |||
/// | /// | |||
/// - no password provided and the device requests one | /// - no password provided and the device requests one | |||
/// - device rejected the available password | /// - device rejected the available password | |||
skipping to change at line 75 | skipping to change at line 74 | |||
BadPassword(const std::string &str, int remaining_tries, | BadPassword(const std::string &str, int remaining_tries, | |||
bool out_of_tries) | bool out_of_tries) | |||
: Barry::Error(str), | : Barry::Error(str), | |||
m_remaining_tries(remaining_tries), | m_remaining_tries(remaining_tries), | |||
m_out_of_tries(out_of_tries) | m_out_of_tries(out_of_tries) | |||
{} | {} | |||
int remaining_tries() const { return m_remaining_tries; } | int remaining_tries() const { return m_remaining_tries; } | |||
bool out_of_tries() const { return m_out_of_tries; } | bool out_of_tries() const { return m_out_of_tries; } | |||
}; | }; | |||
// | ||||
// BadSize | ||||
// | ||||
/// Unexpected packet size, or not enough data. | ||||
/// | ||||
class BadSize : public Barry::Error | ||||
{ | ||||
unsigned int m_packet_size, | ||||
m_data_buf_size, | ||||
m_required_size; | ||||
static std::string GetMsg(unsigned int p, unsigned int d, unsigned i | ||||
nt r); | ||||
public: | ||||
BadSize(unsigned int packet_size, | ||||
unsigned int data_buf_size, | ||||
unsigned int required_size) | ||||
: Barry::Error(GetMsg(packet_size, data_buf_size, required_s | ||||
ize)), | ||||
m_packet_size(packet_size), | ||||
m_data_buf_size(data_buf_size), | ||||
m_required_size(required_size) | ||||
{} | ||||
unsigned int packet_size() const { return m_packet_size; } | ||||
unsigned int data_buf_size() const { return m_data_buf_size; } | ||||
unsigned int required_size() const { return m_required_size; } | ||||
}; | ||||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
#endif | #endif | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 29 lines changed or added | |||
probe.h | probe.h | |||
---|---|---|---|---|
skipping to change at line 39 | skipping to change at line 39 | |||
namespace Barry { | namespace Barry { | |||
struct ProbeResult | struct ProbeResult | |||
{ | { | |||
Usb::DeviceIDType m_dev; | Usb::DeviceIDType m_dev; | |||
unsigned char m_interface; | unsigned char m_interface; | |||
uint32_t m_pin; | uint32_t m_pin; | |||
Usb::EndpointPair m_ep; | Usb::EndpointPair m_ep; | |||
uint8_t m_zeroSocketSequence; | uint8_t m_zeroSocketSequence; | |||
std::string m_description; | ||||
}; | }; | |||
std::ostream& operator<< (std::ostream &os, const ProbeResult &pr); | std::ostream& operator<< (std::ostream &os, const ProbeResult &pr); | |||
class Probe | class Probe | |||
{ | { | |||
std::vector<ProbeResult> m_results; | std::vector<ProbeResult> m_results; | |||
bool Parse(const Data &data, ProbeResult &result); | bool CheckSize(const Data &data, unsigned int required); | |||
bool ParsePIN(const Data &data, ProbeResult &result); | ||||
bool ParseDesc(const Data &data, ProbeResult &result); | ||||
protected: | protected: | |||
void ProbeDevice(Usb::DeviceIDType devid); | void ProbeDevice(Usb::DeviceIDType devid); | |||
public: | public: | |||
Probe(); | Probe(); | |||
int GetCount() const { return m_results.size(); } | int GetCount() const { return m_results.size(); } | |||
const ProbeResult& Get(int index) const { return m_results[index]; } | const ProbeResult& Get(int index) const { return m_results[index]; } | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 4 lines changed or added | |||
protocol.h | protocol.h | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#define SB_COMMAND_DB_DONE 0x41 | #define SB_COMMAND_DB_DONE 0x41 | |||
// mode constants | // mode constants | |||
#define SB_MODE_REQUEST_SOCKET 0x00ff | #define SB_MODE_REQUEST_SOCKET 0x00ff | |||
// object and attribute ID codes (for ZeroPacket::GetAttribute()) | // object and attribute ID codes (for ZeroPacket::GetAttribute()) | |||
// meanings for most of these are unknown | // meanings for most of these are unknown | |||
#define SB_OBJECT_INITIAL_UNKNOWN 0x14 | #define SB_OBJECT_INITIAL_UNKNOWN 0x14 | |||
#define SB_ATTR_INITIAL_UNKNOWN 0x01 | #define SB_ATTR_INITIAL_UNKNOWN 0x01 | |||
#define SB_OBJECT_PROFILE 0x08 | #define SB_OBJECT_PROFILE 0x08 | |||
#define SB_ATTR_PROFILE_DESC 0x02 | ||||
#define SB_ATTR_PROFILE_PIN 0x04 | #define SB_ATTR_PROFILE_PIN 0x04 | |||
#define SB_OBJECT_SOCKET_UNKNOWN 0x04 | #define SB_OBJECT_SOCKET_UNKNOWN 0x04 | |||
// param command parameters | // param command parameters | |||
//#define SB_PARAM_DEFAULT 0xff | //#define SB_PARAM_DEFAULT 0xff | |||
// DB Operation Command | // DB Operation Command | |||
#define SB_DBOP_SET_RECORD 0x41 | #define SB_DBOP_SET_RECORD 0x41 | |||
#define SB_DBOP_CLEAR_DATABASE 0x43 | #define SB_DBOP_CLEAR_DATABASE 0x43 | |||
#define SB_DBOP_GET_DBDB 0x4a | #define SB_DBOP_GET_DBDB 0x4a | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 1 lines changed or added | |||
r_contact.h | r_contact.h | |||
---|---|---|---|---|
skipping to change at line 39 | skipping to change at line 39 | |||
#include <map> | #include <map> | |||
#include <stdint.h> | #include <stdint.h> | |||
namespace Barry { | namespace Barry { | |||
// | // | |||
// NOTE: All classes here must be container-safe! Perhaps add sorting | // NOTE: All classes here must be container-safe! Perhaps add sorting | |||
// operators in the future. | // operators in the future. | |||
// | // | |||
struct ContactGroupLink | ||||
{ | ||||
uint32_t Link; | ||||
uint16_t Unknown; | ||||
ContactGroupLink() : Link(0), Unknown(0) {} | ||||
ContactGroupLink(uint32_t link, uint16_t unknown) | ||||
: Link(link), Unknown(unknown) | ||||
{} | ||||
}; | ||||
typedef std::vector<std::string> CategoryList; | ||||
/// \addtogroup RecordParserClasses | /// \addtogroup RecordParserClasses | |||
/// @{ | /// @{ | |||
class Contact | class Contact | |||
{ | { | |||
public: | public: | |||
struct GroupLink | typedef Barry::CategoryList CategoryList; | |||
{ | typedef ContactGroupLink GroupLink; | |||
uint32_t Link; | ||||
uint16_t Unknown; | ||||
GroupLink() : Link(0), Unknown(0) {} | ||||
GroupLink(uint32_t link, uint16_t unknown) | ||||
: Link(link), Unknown(unknown) | ||||
{} | ||||
}; | ||||
typedef std::vector<GroupLink> GroupLinksType; | typedef std::vector<GroupLink> GroupLinksType; | |||
typedef std::vector<UnknownField> UnknownsType; | typedef std::vector<UnknownField> UnknownsType; | |||
// contact specific data | // contact specific data | |||
uint8_t RecType; | uint8_t RecType; | |||
uint32_t RecordId; | uint32_t RecordId; | |||
std::string | std::string | |||
Email, | Email, | |||
Phone, | Phone, | |||
Fax, | Fax, | |||
skipping to change at line 83 | skipping to change at line 87 | |||
HomePhone2, | HomePhone2, | |||
OtherPhone, | OtherPhone, | |||
FirstName, | FirstName, | |||
LastName, | LastName, | |||
Company, | Company, | |||
DefaultCommunicationsMethod, | DefaultCommunicationsMethod, | |||
JobTitle, | JobTitle, | |||
PublicKey, | PublicKey, | |||
URL, | URL, | |||
Prefix, | Prefix, | |||
Category, | ||||
Notes, | Notes, | |||
UserDefined1, | UserDefined1, | |||
UserDefined2, | UserDefined2, | |||
UserDefined3, | UserDefined3, | |||
UserDefined4, | UserDefined4, | |||
Image; | Image; | |||
PostalAddress WorkAddress; | PostalAddress WorkAddress; | |||
PostalAddress HomeAddress; | PostalAddress HomeAddress; | |||
// Categories are not allowed to have commas in them. | ||||
// A category name containing a comma will be split into | ||||
// two categories, not only by this library, but by the | ||||
// device itself. | ||||
CategoryList Categories; | ||||
GroupLinksType GroupLinks; | GroupLinksType GroupLinks; | |||
UnknownsType Unknowns; | UnknownsType Unknowns; | |||
private: | private: | |||
bool m_FirstNameSeen; | bool m_FirstNameSeen; | |||
//protected: | //protected: | |||
public: | public: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end); | const unsigned char *end); | |||
skipping to change at line 138 | skipping to change at line 147 | |||
// // testing - put group links at the top | // // testing - put group links at the top | |||
// return GroupLinks.size() > 0 && other.GroupLinks.size() == 0 ; | // return GroupLinks.size() > 0 && other.GroupLinks.size() == 0 ; | |||
} | } | |||
// database name | // database name | |||
static const char * GetDBName() { return "Address Book"; } | static const char * GetDBName() { return "Address Book"; } | |||
static uint8_t GetDefaultRecType() { return 0; } | static uint8_t GetDefaultRecType() { return 0; } | |||
// helpers | // helpers | |||
static void SplitName(const std::string &full, std::string &first, s td::string &last); | static void SplitName(const std::string &full, std::string &first, s td::string &last); | |||
static void CategoryStr2List(const std::string &str, Barry::Category | ||||
List &list); | ||||
static void CategoryList2Str(const Barry::CategoryList &list, std::s | ||||
tring &str); | ||||
}; | }; | |||
inline std::ostream& operator<< (std::ostream &os, const Contact &contact) { | inline std::ostream& operator<< (std::ostream &os, const Contact &contact) { | |||
contact.Dump(os); | contact.Dump(os); | |||
return os; | return os; | |||
} | } | |||
/// @} | /// @} | |||
} // namespace Barry | } // namespace Barry | |||
End of changes. 5 change blocks. | ||||
12 lines changed or deleted | 25 lines changed or added | |||
record.h | record.h | |||
---|---|---|---|---|
skipping to change at line 46 | skipping to change at line 46 | |||
// forward declarations | // forward declarations | |||
namespace Barry { class Data; } | namespace Barry { class Data; } | |||
namespace Barry { | namespace Barry { | |||
// | // | |||
// NOTE: All classes here must be container-safe! Perhaps add sorting | // NOTE: All classes here must be container-safe! Perhaps add sorting | |||
// operators in the future. | // operators in the future. | |||
// | // | |||
struct CommandTableCommand | ||||
{ | ||||
unsigned int Code; | ||||
std::string Name; | ||||
}; | ||||
class CommandTable | class CommandTable | |||
{ | { | |||
public: | public: | |||
struct Command | typedef CommandTableCommand Command; | |||
{ | ||||
unsigned int Code; | ||||
std::string Name; | ||||
}; | ||||
typedef std::vector<Command> CommandArrayType; | typedef std::vector<Command> CommandArrayType; | |||
CommandArrayType Commands; | CommandArrayType Commands; | |||
private: | private: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
const unsigned char *end); | const unsigned char *end); | |||
public: | public: | |||
CommandTable(); | CommandTable(); | |||
~CommandTable(); | ~CommandTable(); | |||
skipping to change at line 81 | skipping to change at line 82 | |||
unsigned int GetCommand(const std::string &name) const; | unsigned int GetCommand(const std::string &name) const; | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
}; | }; | |||
inline std::ostream& operator<< (std::ostream &os, const CommandTable &comm and) { | inline std::ostream& operator<< (std::ostream &os, const CommandTable &comm and) { | |||
command.Dump(os); | command.Dump(os); | |||
return os; | return os; | |||
} | } | |||
struct RecordStateTableState | ||||
{ | ||||
unsigned int Index; | ||||
uint32_t RecordId; | ||||
bool Dirty; | ||||
unsigned int RecType; | ||||
std::string Unknown2; | ||||
}; | ||||
class RecordStateTable | class RecordStateTable | |||
{ | { | |||
public: | public: | |||
struct State | typedef RecordStateTableState State; | |||
{ | ||||
unsigned int Index; | ||||
uint32_t RecordId; | ||||
bool Dirty; | ||||
unsigned int RecType; | ||||
std::string Unknown2; | ||||
}; | ||||
typedef unsigned int IndexType; | typedef unsigned int IndexType; | |||
typedef std::map<IndexType, State> StateMapType; | typedef std::map<IndexType, State> StateMapType; | |||
StateMapType StateMap; | StateMapType StateMap; | |||
private: | private: | |||
mutable IndexType m_LastNewRecordId; | mutable IndexType m_LastNewRecordId; | |||
private: | private: | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
skipping to change at line 123 | skipping to change at line 125 | |||
uint32_t MakeNewRecordId() const; | uint32_t MakeNewRecordId() const; | |||
void Dump(std::ostream &os) const; | void Dump(std::ostream &os) const; | |||
}; | }; | |||
inline std::ostream& operator<< (std::ostream &os, const RecordStateTable & rst) { | inline std::ostream& operator<< (std::ostream &os, const RecordStateTable & rst) { | |||
rst.Dump(os); | rst.Dump(os); | |||
return os; | return os; | |||
} | } | |||
struct DatabaseItem | ||||
{ | ||||
unsigned int Number; | ||||
unsigned int RecordCount; | ||||
std::string Name; | ||||
}; | ||||
class DatabaseDatabase | class DatabaseDatabase | |||
{ | { | |||
public: | public: | |||
struct Database | typedef DatabaseItem Database; | |||
{ | ||||
unsigned int Number; | ||||
unsigned int RecordCount; | ||||
std::string Name; | ||||
}; | ||||
typedef std::vector<Database> DatabaseArrayType; | typedef std::vector<Database> DatabaseArrayType; | |||
DatabaseArrayType Databases; | DatabaseArrayType Databases; | |||
private: | private: | |||
template <class RecordType, class FieldType> | template <class RecordType, class FieldType> | |||
void ParseRec(const RecordType &rec, const unsigned char *end); | void ParseRec(const RecordType &rec, const unsigned char *end); | |||
template <class FieldType> | template <class FieldType> | |||
const unsigned char* ParseField(const unsigned char *begin, | const unsigned char* ParseField(const unsigned char *begin, | |||
End of changes. 6 change blocks. | ||||
22 lines changed or deleted | 25 lines changed or added | |||
s11n-boost.h | s11n-boost.h | |||
---|---|---|---|---|
skipping to change at line 94 | skipping to change at line 94 | |||
ar & make_nvp("Address2", c.WorkAddress.Address2); | ar & make_nvp("Address2", c.WorkAddress.Address2); | |||
ar & make_nvp("Address3", c.WorkAddress.Address3); | ar & make_nvp("Address3", c.WorkAddress.Address3); | |||
ar & make_nvp("City", c.WorkAddress.City); | ar & make_nvp("City", c.WorkAddress.City); | |||
ar & make_nvp("Province", c.WorkAddress.Province); | ar & make_nvp("Province", c.WorkAddress.Province); | |||
ar & make_nvp("PostalCode", c.WorkAddress.PostalCode); | ar & make_nvp("PostalCode", c.WorkAddress.PostalCode); | |||
ar & make_nvp("Country", c.WorkAddress.Country); | ar & make_nvp("Country", c.WorkAddress.Country); | |||
ar & make_nvp("JobTitle", c.JobTitle); | ar & make_nvp("JobTitle", c.JobTitle); | |||
ar & make_nvp("PublicKey", c.PublicKey); | ar & make_nvp("PublicKey", c.PublicKey); | |||
ar & make_nvp("URL", c.URL); | ar & make_nvp("URL", c.URL); | |||
ar & make_nvp("Prefix", c.Prefix); | ar & make_nvp("Prefix", c.Prefix); | |||
ar & make_nvp("Category", c.Category); | ar & make_nvp("Categories", c.Categories); | |||
ar & make_nvp("HomeAddress1", c.HomeAddress.Address1); | ar & make_nvp("HomeAddress1", c.HomeAddress.Address1); | |||
ar & make_nvp("HomeAddress2", c.HomeAddress.Address2); | ar & make_nvp("HomeAddress2", c.HomeAddress.Address2); | |||
ar & make_nvp("HomeAddress3", c.HomeAddress.Address3); | ar & make_nvp("HomeAddress3", c.HomeAddress.Address3); | |||
ar & make_nvp("Notes", c.Notes); | ar & make_nvp("Notes", c.Notes); | |||
ar & make_nvp("UserDefined1", c.UserDefined1); | ar & make_nvp("UserDefined1", c.UserDefined1); | |||
ar & make_nvp("UserDefined2", c.UserDefined2); | ar & make_nvp("UserDefined2", c.UserDefined2); | |||
ar & make_nvp("UserDefined3", c.UserDefined3); | ar & make_nvp("UserDefined3", c.UserDefined3); | |||
ar & make_nvp("UserDefined4", c.UserDefined4); | ar & make_nvp("UserDefined4", c.UserDefined4); | |||
ar & make_nvp("HomeCity", c.HomeAddress.City); | ar & make_nvp("HomeCity", c.HomeAddress.City); | |||
ar & make_nvp("HomeProvince", c.HomeAddress.Province); | ar & make_nvp("HomeProvince", c.HomeAddress.Province); | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
usbwrap.h | usbwrap.h | |||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
/// Namespace for the libusb-related wrapper classes. This namespace | /// Namespace for the libusb-related wrapper classes. This namespace | |||
/// may change in the future. | /// may change in the future. | |||
namespace Usb { | namespace Usb { | |||
/// \addtogroup exceptions | /// \addtogroup exceptions | |||
/// @{ | /// @{ | |||
/// Thrown on low level USB errors. | /// Thrown on low level USB errors. | |||
class Error : public Barry::Error | class Error : public Barry::Error | |||
{ | { | |||
int m_libusb_errcode; | ||||
public: | public: | |||
Error(const std::string &str) : Barry::Error(str) {} | Error(const std::string &str); | |||
Error(int libusb_errcode, const std::string &str); | ||||
// can return 0 in some case, if unknown error code | ||||
int libusb_errcode() const { return m_libusb_errcode; } | ||||
}; | }; | |||
class Timeout : public Error | class Timeout : public Error | |||
{ | { | |||
public: | public: | |||
Timeout(const std::string &str) : Error(str) {} | Timeout(const std::string &str) : Error(str) {} | |||
Timeout(int libusb_errcode, const std::string &str) | ||||
: Error(libusb_errcode, str) {} | ||||
}; | }; | |||
/// @} | /// @} | |||
/// Typedefs used by the wrapper class, in the hope to make it | /// Typedefs used by the wrapper class, in the hope to make it | |||
/// easier to switch from libusb stable to devel and back. | /// easier to switch from libusb stable to devel and back. | |||
typedef struct usb_device* DeviceIDType; | typedef struct usb_device* DeviceIDType; | |||
typedef struct usb_dev_handle* DeviceHandleType; | typedef struct usb_dev_handle* DeviceHandleType; | |||
class Match | class Match | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 9 lines changed or added | |||