From 56d0296f8690288b10e82bcff6c4e8f20065f938 Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Fri, 24 Dec 2010 00:34:53 -0500 Subject: [PATCH] lib: cleaned up Clear() functions in all record classes Primarily fixed some missing variables. --- ChangeLog | 3 +++ src/r_bookmark.h | 2 +- src/r_calendar.cc | 11 +++++++++-- src/r_calendar.h | 2 +- src/r_calllog.cc | 3 ++- src/r_calllog.h | 2 +- src/r_contact.cc | 5 +++-- src/r_contact.h | 2 +- src/r_folder.cc | 9 ++++++++- src/r_folder.h | 3 ++- src/r_memo.cc | 3 +++ src/r_memo.h | 2 +- src/r_message.h | 8 ++++++++ src/r_message_base.cc | 6 ++++++ src/r_message_base.h | 4 +++- src/r_pin_message.h | 8 ++++++++ src/r_saved_message.h | 8 ++++++++ src/r_servicebook.cc | 1 + src/r_servicebook.h | 2 +- src/r_sms.cc | 7 ++++++- src/r_sms.h | 2 +- src/r_task.cc | 14 ++++++++++---- src/r_task.h | 2 +- src/r_timezone.cc | 12 ++++++++---- src/r_timezone.h | 2 +- src/record.h | 3 ++- 26 files changed, 99 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index 102f2e2e..7619d9d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ Release: version 0.17.0 - 2010/01/?? ------------------------------------------------------------------------------ +2010/12/24 + - lib: cleaned up Clear() functions in all record classes + Primarily fixed some missing variables. 2010/12/21 - tools: added bio command line tool, Barry Input / Output Supports IO for devices, tar backups, boost, ldif streams, diff --git a/src/r_bookmark.h b/src/r_bookmark.h index 6284a1a4..97a1e369 100644 --- a/src/r_bookmark.h +++ b/src/r_bookmark.h @@ -37,7 +37,7 @@ class IConverter; class BXEXPORT Bookmark { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/r_calendar.cc b/src/r_calendar.cc index 64c2d26f..f4684d07 100644 --- a/src/r_calendar.cc +++ b/src/r_calendar.cc @@ -375,20 +375,27 @@ void Calendar::BuildFields(Data &data, size_t &offset, const IConverter *ic) con void Calendar::Clear() { + // clear the base class too RecurBase::Clear(); - RecType = Calendar::GetDefaultRecType(); + // clear our fields + RecType = GetDefaultRecType(); + RecordId = 0; AllDayEvent = false; - CalendarID = btohll((uint64_t) -1); Subject.clear(); Notes.clear(); Location.clear(); NotificationTime = StartTime = EndTime = 0; + Organizer.clear(); + AcceptedBy.clear(); + Invited.clear(); FreeBusyFlag = Free; ClassFlag = Public; + CalendarID = btohll((uint64_t) -1); + TimeZoneCode = GetTimeZoneCode(0, 0); // default to GMT TimeZoneValid = false; diff --git a/src/r_calendar.h b/src/r_calendar.h index f8a6b30e..ef170611 100644 --- a/src/r_calendar.h +++ b/src/r_calendar.h @@ -49,7 +49,7 @@ class IConverter; class BXEXPORT Calendar : public RecurBase { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/r_calllog.cc b/src/r_calllog.cc index 4a94c1ff..8bc85cbc 100644 --- a/src/r_calllog.cc +++ b/src/r_calllog.cc @@ -303,7 +303,8 @@ void CallLog::Dump(std::ostream &os) const void CallLog::Clear() { - RecType = CallLog::GetDefaultRecType(); + RecType = GetDefaultRecType(); + RecordId = 0; Duration = 0; Timestamp = 0; diff --git a/src/r_calllog.h b/src/r_calllog.h index 48acf41f..443f11b5 100644 --- a/src/r_calllog.h +++ b/src/r_calllog.h @@ -37,7 +37,7 @@ class IConverter; class BXEXPORT CallLog { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/r_contact.cc b/src/r_contact.cc index e6f19831..b31b786f 100644 --- a/src/r_contact.cc +++ b/src/r_contact.cc @@ -267,7 +267,6 @@ void Contact::ParseHeader(const Data &data, size_t &offset) // no header to parse in Contact records } -// this is called by the RecordParser<> class, which checks size for us void Contact::ParseFields(const Data &data, size_t &offset, const IConverter *ic) { const unsigned char *finish = ParseCommonFields(*this, @@ -391,10 +390,12 @@ void Contact::BuildFields(Data &data, size_t &offset, const IConverter *ic) cons void Contact::Clear() { - RecType = Contact::GetDefaultRecType(); + RecType = GetDefaultRecType(); + RecordId = 0; EmailAddresses.clear(); Phone.clear(); + Fax.clear(); WorkPhone.clear(); HomePhone.clear(); diff --git a/src/r_contact.h b/src/r_contact.h index 62ebce7c..2095e436 100644 --- a/src/r_contact.h +++ b/src/r_contact.h @@ -65,7 +65,7 @@ public: typedef Barry::CategoryList CategoryList; typedef ContactGroupLink GroupLink; typedef std::vector GroupLinksType; - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; typedef std::string EmailType; typedef std::vector EmailList; diff --git a/src/r_folder.cc b/src/r_folder.cc index 3efea27a..27755feb 100644 --- a/src/r_folder.cc +++ b/src/r_folder.cc @@ -164,9 +164,16 @@ void Folder::ParseFields(const Data &data, size_t &offset, const IConverter *ic) void Folder::Clear() { + RecType = GetDefaultRecType(); + RecordId = 0; + Name.clear(); - Unknowns.clear(); + Number = 0; + Level = 0; + Type = FolderSubtree; + + Unknowns.clear(); } void Folder::Dump(std::ostream &os) const diff --git a/src/r_folder.h b/src/r_folder.h index 7e7943eb..39123ef6 100644 --- a/src/r_folder.h +++ b/src/r_folder.h @@ -37,7 +37,8 @@ class IConverter; class BXEXPORT Folder { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; + uint8_t RecType; uint32_t RecordId; diff --git a/src/r_memo.cc b/src/r_memo.cc index 07127996..6992fc39 100644 --- a/src/r_memo.cc +++ b/src/r_memo.cc @@ -233,6 +233,9 @@ bool Memo::operator<(const Memo &other) const void Memo::Clear() { + RecType = GetDefaultRecType(); + RecordId = 0; + Title.clear(); Body.clear(); Categories.clear(); diff --git a/src/r_memo.h b/src/r_memo.h index 9a7411ba..d4308052 100644 --- a/src/r_memo.h +++ b/src/r_memo.h @@ -37,7 +37,7 @@ class IConverter; class BXEXPORT Memo { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/r_message.h b/src/r_message.h index a0e1381d..5377079f 100644 --- a/src/r_message.h +++ b/src/r_message.h @@ -38,6 +38,14 @@ namespace Barry { class BXEXPORT Message : public MessageBase { public: + void Clear() + { + MessageBase::Clear(); + + RecType = GetDefaultRecType(); + RecordId = 0; + } + // database name static const char * GetDBName() { return "Messages"; } static uint8_t GetDefaultRecType() { return 0; } diff --git a/src/r_message_base.cc b/src/r_message_base.cc index a262f696..51df8650 100644 --- a/src/r_message_base.cc +++ b/src/r_message_base.cc @@ -290,6 +290,11 @@ void MessageBase::BuildFields(Data &data, size_t &offset, const IConverter *ic) void MessageBase::Clear() { + // these must be overwritten by any derived classes + RecType = 0; + RecordId = 0; + + // clear base class variables From.clear(); To.clear(); Cc.clear(); @@ -305,6 +310,7 @@ void MessageBase::Clear() MessageReplyTo = 0; MessageDateSent = 0; MessageDateReceived = 0; + MessageTruncated = false; MessageRead = false; MessageReply = false; diff --git a/src/r_message_base.h b/src/r_message_base.h index c69f4670..ea647f9a 100644 --- a/src/r_message_base.h +++ b/src/r_message_base.h @@ -45,6 +45,8 @@ class IConverter; class BXEXPORT MessageBase { public: + typedef Barry::UnknownsType UnknownsType; + uint8_t RecType; uint32_t RecordId; @@ -93,7 +95,7 @@ public: }; SensitivityType Sensitivity; - std::vector Unknowns; + UnknownsType Unknowns; protected: std::string SimpleFromAddress() const; diff --git a/src/r_pin_message.h b/src/r_pin_message.h index a8804541..89957d9b 100644 --- a/src/r_pin_message.h +++ b/src/r_pin_message.h @@ -39,6 +39,14 @@ namespace Barry { class BXEXPORT PINMessage : public MessageBase { public: + void Clear() + { + MessageBase::Clear(); + + RecType = GetDefaultRecType(); + RecordId = 0; + } + // database name static const char * GetDBName() { return "PIN Messages"; } static uint8_t GetDefaultRecType() { return 0; } diff --git a/src/r_saved_message.h b/src/r_saved_message.h index c980e64a..c2d55790 100644 --- a/src/r_saved_message.h +++ b/src/r_saved_message.h @@ -40,6 +40,14 @@ namespace Barry { class BXEXPORT SavedMessage : public MessageBase { public: + void Clear() + { + MessageBase::Clear(); + + RecType = GetDefaultRecType(); + RecordId = 0; + } + // database name static const char * GetDBName() { return "Saved Email Messages"; } static uint8_t GetDefaultRecType() { return 3; } diff --git a/src/r_servicebook.cc b/src/r_servicebook.cc index 985bd6d1..34bd72e6 100644 --- a/src/r_servicebook.cc +++ b/src/r_servicebook.cc @@ -178,6 +178,7 @@ void ServiceBookConfig::BuildFields(Data &data, size_t &offset, const IConverter void ServiceBookConfig::Clear() { + Format = 0; Unknowns.clear(); } diff --git a/src/r_servicebook.h b/src/r_servicebook.h index d1f2b6a5..cca726b8 100644 --- a/src/r_servicebook.h +++ b/src/r_servicebook.h @@ -50,7 +50,7 @@ class IConverter; class BXEXPORT ServiceBookConfig { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t Format; diff --git a/src/r_sms.cc b/src/r_sms.cc index 939ff23d..74163b45 100644 --- a/src/r_sms.cc +++ b/src/r_sms.cc @@ -225,13 +225,18 @@ void Sms::ParseFields(const Data &data, size_t &offset, const IConverter *ic) void Sms::Clear() { + RecType = GetDefaultRecType(); + RecordId = 0; + MessageStatus = Unknown; DeliveryStatus = NoReport; - DataCodingScheme = SevenBit; IsNew = NewConversation = Saved = Deleted = Opened = false; Timestamp = ServiceCenterTimestamp = 0; + + DataCodingScheme = SevenBit; + ErrorId = 0; Addresses.clear(); diff --git a/src/r_sms.h b/src/r_sms.h index a293b606..6dd8f562 100644 --- a/src/r_sms.h +++ b/src/r_sms.h @@ -37,7 +37,7 @@ class IConverter; class BXEXPORT Sms { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/r_task.cc b/src/r_task.cc index 32c68e46..477f436d 100644 --- a/src/r_task.cc +++ b/src/r_task.cc @@ -320,22 +320,28 @@ void Task::BuildFields(Data &data, size_t &offset, const IConverter *ic) const void Task::Clear() { + // clear the base class first RecurBase::Clear(); + // our variables... + RecType = GetDefaultRecType(); + RecordId = 0; + Summary.clear(); Notes.clear(); Categories.clear(); + UID.clear(); + StartTime = DueTime = AlarmTime = 0; + TimeZoneCode = GetTimeZoneCode( 0, 0 ); // default to GMT + TimeZoneValid = false; + AlarmType = (AlarmFlagType)0; PriorityFlag = (PriorityFlagType)0; StatusFlag = (StatusFlagType)0; - AlarmType = (AlarmFlagType)0; DueDateFlag = false; - TimeZoneCode = GetTimeZoneCode( 0, 0 ); // default to GMT - TimeZoneValid = false; - Unknowns.clear(); } diff --git a/src/r_task.h b/src/r_task.h index ed73a72d..63d39908 100644 --- a/src/r_task.h +++ b/src/r_task.h @@ -38,7 +38,7 @@ class IConverter; class BXEXPORT Task : public RecurBase { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/r_timezone.cc b/src/r_timezone.cc index 597305fb..57500d18 100644 --- a/src/r_timezone.cc +++ b/src/r_timezone.cc @@ -162,16 +162,20 @@ void Timezone::ParseFields(const Data &data, size_t &offset, const IConverter *i void Timezone::Clear() { - TimeZoneName.clear(); + RecType = GetDefaultRecType(); + RecordId = 0; + TZType = 0; + DSTOffset = 0; Index = 0; - Left = false; - UseDST = false; Offset = 0; OffsetFraction = 0; - DSTOffset = 0; StartMonth = -1; EndMonth = -1; + Left = false; + UseDST = false; + + TimeZoneName.clear(); Unknowns.clear(); } diff --git a/src/r_timezone.h b/src/r_timezone.h index 106d8c47..23fad1e1 100644 --- a/src/r_timezone.h +++ b/src/r_timezone.h @@ -37,7 +37,7 @@ class IConverter; class BXEXPORT Timezone { public: - typedef std::vector UnknownsType; + typedef Barry::UnknownsType UnknownsType; uint8_t RecType; uint32_t RecordId; diff --git a/src/record.h b/src/record.h index 806e9081..5240d256 100644 --- a/src/record.h +++ b/src/record.h @@ -186,7 +186,8 @@ struct BXEXPORT UnknownField uint8_t type; UnknownData data; }; -BXEXPORT std::ostream& operator<< (std::ostream &os, const std::vector &unknowns); +typedef std::vector UnknownsType; +BXEXPORT std::ostream& operator<< (std::ostream &os, const UnknownsType &unknowns); struct BXEXPORT EmailAddress { -- 2.11.4.GIT