Accounting Software
Small Business Software Estimating Software
Contact SoftwareInventory SoftwareInventory Tracking SoftwareInventory Management SoftwareInventory Control SoftwareCustomer Management SoftwareBusiness Management Software

File Preferences (Source Code)

Link to: header | prefs directory

Copyright Turtle Creek Software 1996-2006. All Rights Reserved.

Comments

CFilePreferences

This class manages file preferences for the Goldenseal accounting software,
small business management software, construction project management software and
construction accounting software.

It's the storage object for file preferences. This handles options for
import and export, backup and file compression

SUPERCLASS = DB_PersistentObject

Constructor

/******************************************************************************
default constructor TCS 3/10/99
******************************************************************************/
CFilePreferences::CFilePreferences()
{
mBackupFileCount = 7;
mFutureLong = 0;

mBackupTime.SetToToday();
mBackupTime.SetHour(23);
mBackupTime.SetMinute(0);

mPostingTime.SetToToday();
mPostingTime.SetHour(1);
mPostingTime.SetMinute(0);

mBackupType = time_day;
mPostingType = 0;

mExportFileType = fileType_TabText;
mCountry = country_usa;

mExpansion = 0;

mExportAsDecimal = false;
mIncludeObjectID = true;
mParseImportText = false;
mImportModDates = true;
mImportAFWPaths = false;

mSaveExportOrder = false;
mExportWithTags = false;
mBypassFieldOrderDialog = false;
mWarnMissingObjects = true;
mCompressFile = false;

#if TCS_FOR_MAC
mExportWinReturns = false;
#else
mExportWinReturns = true; // TCS rev 11/19/03
#endif

mFutureEnum1 = mFutureEnum2 = 0;
mFutureEnum3 = mFutureEnum4 = 0;

mEndSafetyTag = tag_endsafetytag; // TCS 9/8/02
}

Source Code

/*********************************************************************************

GetFileLength TCS 3/10/99

return the file length used by this object

*********************************************************************************/
NeoSize CFilePreferences::GetFileLength(const CNeoFormat *aFormat) const
{
return THE_SUPERCLASS::GetFileLength(aFormat) +
mValidationString.LongFileLength(cMaximumTextLen) + // it's a long string
cFileLength;
}/*********************************************************************************

GetMemberValue TCS 3/10/99

get the next number for an item

*********************************************************************************/
Boolean CFilePreferences::GetMemberValue(const TagType aTag, const TagType aType,
void *aValue) const
{
switch (aTag)
{
case tag_backuptype:
return ConvertEnumMember(mBackupType, MENU_BackupType, aValue, aType);
break;

case tag_postingtype:
return ConvertEnumMember(mPostingType, MENU_PostingType, aValue, aType);
break;

case tag_exportformat:
return ConvertEnumMember(mExportFileType, MENU_ExportFileTypes, aValue, aType);
break;

case tag_country:
return ConvertEnumMember(mCountry, MENU_Countries, aValue, aType);
break;

/*case tag_multiuser: // TCS 2/9/01
return ConvertEnumMember(mMultiUserType, MENU_MultiUserTypes, aValue, aType);
break;*/

case tag_backupfilecount:
return ConvertMember(&mBackupFileCount, type_long, aValue, aType);
break;

case tag_backuptime:
return ConvertMember(&mBackupTime, type_timeonly, aValue, aType);
break;

case tag_postingtime:
return ConvertMember(&mPostingTime, type_timeonly, aValue, aType);
break;

case tag_exportasdecimal:
return ConvertBitFieldMember(mExportAsDecimal, aValue, aType);
break;

case tag_exportobjectid:
return ConvertBitFieldMember(mIncludeObjectID, aValue, aType);
break;

case tag_parseimporttext:
return ConvertBitFieldMember(mParseImportText, aValue, aType);
break;

case tag_importmoddates:
return ConvertBitFieldMember(mImportModDates, aValue, aType);
break;

case tag_importafwpaths: // TCS 3/28/01
return ConvertBitFieldMember(mImportAFWPaths, aValue, aType);
break;

case tag_exportsaveorder: // TCS 3/27/01 moved 5/2/01
return ConvertBitFieldMember(mSaveExportOrder, aValue, aType);
break;

case tag_exportbypassfielddialog: // TCS 5/2/01
return ConvertBitFieldMember(mBypassFieldOrderDialog, aValue, aType);
break;

case tag_exportwithtags: // TCS 5/2/01
return ConvertBitFieldMember(mExportWithTags, aValue, aType);
break;

case tag_warnmissingobjects: // TCS 8/10/01
return ConvertBitFieldMember(mWarnMissingObjects, aValue, aType);
break;

case tag_keepfilecompressed: // TCS 6/18/02
return ConvertBitFieldMember(mCompressFile, aValue, aType);
break;

case tag_exportwinreturns: // TCS 9/19/02
return ConvertBitFieldMember(mExportWinReturns, aValue, aType);
break;

default:
return THE_SUPERCLASS::GetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************

SetMemberValue TCS 3/10/99

set the value of the member with the given tag

*********************************************************************************/
Boolean CFilePreferences::SetMemberValue(const TagType aTag, const TagType aType,
const void *aValue)
{
switch (aTag)
{
case tag_backuptype:
return ConvertMember(aValue, aType, &mBackupType, type_enum);
break;

case tag_postingtype:
return ConvertMember(aValue, aType, &mPostingType, type_enum);
break;

case tag_exportformat:
return ConvertMember(aValue, aType, &mExportFileType, type_enum);
break;

case tag_country: // TCS 1/5/01
return ConvertMember(aValue, aType, &mCountry, type_enum);
break;

/*case tag_multiuser: // TCS 2/9/01
return ConvertMember(aValue, aType, &mMultiUserType, type_enum);
break;*/

case tag_backupfilecount:
return ConvertMember(aValue, aType, &mBackupFileCount, type_long);
break;

case tag_backuptime:
return ConvertMember(aValue, aType, &mBackupTime, type_timeonly);
break;

case tag_postingtime:
return ConvertMember(aValue, aType, &mPostingTime, type_timeonly);
break;

case tag_exportasdecimal:
mExportAsDecimal = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_exportobjectid:
mIncludeObjectID = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_parseimporttext:
mParseImportText = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_importmoddates:
mImportModDates = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_importafwpaths: // TCS 3/28/01
mImportAFWPaths = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_exportsaveorder: // TCS 3/27/01 moved 5/2/01
mSaveExportOrder = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_exportbypassfielddialog: // TCS 5/2/01
mBypassFieldOrderDialog = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_exportwithtags: // TCS 5/2/01
mExportWithTags = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_warnmissingobjects: // TCS 8/10/01
mWarnMissingObjects = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_keepfilecompressed: // TCS 6/18/02
mCompressFile = ConvertDataToBitField(aValue, aType);
return true;
break;

case tag_exportwinreturns: // TCS 9/19/02
mExportWinReturns = ConvertDataToBitField(aValue, aType);
return true;
break;

default:
return THE_SUPERCLASS::SetMemberValue(aTag, aType, aValue);
break;
}
}/*********************************************************************************

ReadObject TCS 3/10/99

read the persistent object's data in from a stream

*********************************************************************************/
void CFilePreferences::ReadObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));

CNeoDebugImport checker(aStream, this, cCheckTooSmall); // TCS 2/24/00

THE_SUPERCLASS::ReadObject(aStream, aTag);

if (!IsIOValid()) // TCS 2/5/02
return;

ReadLongTextFromStream(aStream, &mValidationString); // TCS 2/25/00

/// aStream->ReadChunk(&mBackupFileCount, cFileLength);

mBackupFileCount = aStream->ReadULong(); // mfs_sa rev 20feb2k3
mFutureLong = aStream->ReadULong();

mBackupTime.ReadFromStream(aStream);
mPostingTime.ReadFromStream(aStream);

mBackupType = aStream->ReadChar();
mPostingType = aStream->ReadChar();
mExportFileType = aStream->ReadChar();
mCountry = aStream->ReadChar();
mExpansion = aStream->ReadChar();

*((UInt8*)&mExpansion + sizeof(mExpansion)) = aStream->ReadBits(8); // --Bitfield
*((UInt8*)&mExpansion + sizeof(mExpansion) + 1) = aStream->ReadBits(3); // --Bitfield

mFutureEnum2 = aStream->ReadChar();
mFutureEnum3 = aStream->ReadChar();
mFutureEnum4 = aStream->ReadChar();

mEndSafetyTag = aStream->ReadEndSafetyTag(this);

if (!IsValidEndTag(mEndSafetyTag)) // TCS 9/8/02
ReportDamagedObject(GetDBClassID(), GetDBID());
}/*********************************************************************************

WriteObject TCS 3/10/99

write the persistent object's data to a stream

*********************************************************************************/
void CFilePreferences::WriteObject(CNeoStream *aStream, const TagType aTag)
{
TCS_FailNILMsg(aStream, TCS_GetErrString(errID_BadStream));

// make sure we have valid data to write TCS 9/8/02
if (!IsValidEndTag(mEndSafetyTag))
{
ReportDamagedObject(GetDBClassID(), GetDBID());
mEndSafetyTag = tag_endsafetytag; // TCS 11/26/02
}

CNeoDebugExport checker(aStream, this, cCheckTooSmall);
THE_SUPERCLASS::WriteObject(aStream, aTag);

WriteLongTextToStream(aStream, mValidationString, cMaximumTextLen); // TCS 2/25/00

/// aStream->WriteChunk(&mBackupFileCount, cFileLength);

aStream->WriteULong(mBackupFileCount); // mfs_sa rev 20feb2k3
aStream->WriteULong(mFutureLong);

mBackupTime.WriteToStream(aStream);
mPostingTime.WriteToStream(aStream);

aStream->WriteChar(mBackupType);
aStream->WriteChar(mPostingType);
aStream->WriteChar(mExportFileType);
aStream->WriteChar(mCountry);
aStream->WriteChar(mExpansion);

aStream->WriteChar(*((UInt8*)&mExpansion + sizeof(mExpansion))); // --Bitfield
aStream->WriteChar(*((UInt8*)&mExpansion + sizeof(mExpansion) + 1)); // --Bitfield

aStream->WriteChar(mFutureEnum2);
aStream->WriteChar(mFutureEnum3);
aStream->WriteChar(mFutureEnum4);

aStream->WriteEndSafetyTag(mEndSafetyTag, this);

}
#if CAN_USE_MARK
#pragma mark -
#endif
/*********************************************************************************

FinishNonViewerCreate TCS 2/25/00

set up after creation. Initialize the validation string
*********************************************************************************/
void CFilePreferences::FinishNonViewerCreate()
{
mValidationString.FillWithRandom(cPasswordBlockLen);
}
/*********************************************************************************

FillDataReport TCS 9/7/02

fill in a diagnostic table that shows data field values.

*********************************************************************************/
void CFilePreferences::FillDataReport(CTCS_Table *table, CNeoStream *stream) const
{
TCS_FailNILMsg(table, TCS_GetErrString(errID_BadTable));
TCS_FailNILMsg(stream, TCS_GetErrString(errID_BadStream));

THE_SUPERCLASS::FillDataReport(table, stream);

FillFieldStringRow(table, stream, "mDataString", mValidationString, true);

FillFieldTagRow(table, stream, tag_backupfilecount, cLongSize, mBackupFileCount);
FillFieldStockRow(table, stream, stockID_Expansion, cLongSize, mFutureLong);

FillFieldTagRow(table, stream, tag_backuptime, cDateSize, mBackupTime.GetCString());
FillFieldStockRow(table, stream, stockID_Expansion, cDateSize, mPostingTime.GetCString());

FillFieldEnumRow(table, stream, tag_backuptype, mBackupType, MENU_BackupType);
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mPostingType));
FillFieldEnumRow(table, stream, tag_exportformat, mExportFileType, MENU_ExportFileTypes);
FillFieldEnumRow(table, stream, tag_country, mCountry, MENU_Countries);
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mExpansion));

FillFieldBitRow(table, stream, tag_exportasdecimal, mExportAsDecimal, true);
FillFieldBitRow(table, stream, tag_exportobjectid, mIncludeObjectID);
FillFieldBitRow(table, stream, tag_parseimporttext, mParseImportText);
FillFieldBitRow(table, stream, tag_importmoddates, mImportModDates);
FillFieldBitRow(table, stream, tag_importafwpaths, mImportAFWPaths);
FillFieldBitRow(table, stream, tag_exportsaveorder, mSaveExportOrder);
FillFieldBitRow(table, stream, tag_exportwithtags, mExportWithTags);
FillFieldBitRow(table, stream, tag_exportbypassfielddialog, mBypassFieldOrderDialog);

FillFieldBitRow(table, stream, tag_warnmissingobjects, mWarnMissingObjects, true);
FillFieldStockRow(table, stream, stockID_Expansion, cBitSize, mCompressFile);
FillFieldStockRow(table, stream, stockID_Padding, -6, SInt32(mFutureEnum1));

FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mFutureEnum2));
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mFutureEnum3));
FillFieldStockRow(table, stream, stockID_Expansion, cCharSize, SInt32(mFutureEnum4));

FillEndSafetyTag(table, stream, mEndSafetyTag);
}