
// Auto-generated file -- do not edit

#include "Box.h"

#include <sstream>

#include "autogen_BackupProtocolServer.h"
#include "IOStream.h"

#include "BackupStoreContext.h"

#include "MemLeakFindOn.h"
BackupProtocolObject::BackupProtocolObject()
{
}
BackupProtocolObject::~BackupProtocolObject()
{
}
BackupProtocolObject::BackupProtocolObject(const BackupProtocolObject &rToCopy)
{
}
std::auto_ptr<ProtocolObject> BackupProtocolObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
{
	THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand)
}

BackupProtocolServerError::BackupProtocolServerError()
	: mType(0),
	  mSubType(0)
{
}
BackupProtocolServerError::BackupProtocolServerError(const BackupProtocolServerError &rToCopy)
	: mType(rToCopy.mType),
	  mSubType(rToCopy.mSubType)
{
}
BackupProtocolServerError::~BackupProtocolServerError()
{
}
int BackupProtocolServerError::GetType() const
{
	return 0;
}
BackupProtocolServerError::BackupProtocolServerError(int32_t Type, int32_t SubType)
	: mType(Type),
	  mSubType(SubType)
{
}
void BackupProtocolServerError::WritePropertiesToStreamData(Protocol &rProtocol) const
{
	rProtocol.Write(mType);
	rProtocol.Write(mSubType);
}
bool BackupProtocolServerError::IsError(int &rTypeOut, int &rSubTypeOut) const
{
	rTypeOut = mType;
	rSubTypeOut = mSubType;
	return true;
}
std::string BackupProtocolServerError::GetMessage() const
{
	switch(mSubType)
	{
		case Err_WrongVersion: return "WrongVersion = 1";
		case Err_NotInRightProtocolPhase: return "NotInRightProtocolPhase = 2";
		case Err_BadLogin: return "BadLogin = 3";
		case Err_CannotLockStoreForWriting: return "CannotLockStoreForWriting = 4";
		case Err_SessionReadOnly: return "SessionReadOnly = 5";
		case Err_FileDoesNotVerify: return "FileDoesNotVerify = 6";
		case Err_DoesNotExist: return "DoesNotExist = 7";
		case Err_DirectoryAlreadyExists: return "DirectoryAlreadyExists = 8";
		case Err_CannotDeleteRoot: return "CannotDeleteRoot = 9";
		case Err_TargetNameExists: return "TargetNameExists = 10";
		case Err_StorageLimitExceeded: return "StorageLimitExceeded = 11";
		case Err_DiffFromFileDoesNotExist: return "DiffFromFileDoesNotExist = 12";
		case Err_DoesNotExistInDirectory: return "DoesNotExistInDirectory = 13";
		case Err_PatchConsistencyError: return "PatchConsistencyError = 14";
		default:
			std::ostringstream out;
			out << "Unknown subtype " << mSubType;
			return out.str();
	}
}
void BackupProtocolServerError::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " Error(" << (mType == 0 ? "0x" : "") << std::hex << std::showbase << mType << std::dec << "," << (mSubType == 0 ? "0x" : "") << std::hex << std::showbase << mSubType << std::dec << ")");
}
BackupProtocolServerVersion::BackupProtocolServerVersion()
	: mVersion(0)
{
}
BackupProtocolServerVersion::BackupProtocolServerVersion(const BackupProtocolServerVersion &rToCopy)
	: mVersion(rToCopy.mVersion)
{
}
BackupProtocolServerVersion::~BackupProtocolServerVersion()
{
}
int BackupProtocolServerVersion::GetType() const
{
	return 1;
}
void BackupProtocolServerVersion::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mVersion);
}
BackupProtocolServerVersion::BackupProtocolServerVersion(int32_t Version)
	: mVersion(Version)
{
}
void BackupProtocolServerVersion::WritePropertiesToStreamData(Protocol &rProtocol) const
{
	rProtocol.Write(mVersion);
}
void BackupProtocolServerVersion::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " Version(" << (mVersion == 0 ? "0x" : "") << std::hex << std::showbase << mVersion << std::dec << ")");
}
BackupProtocolServerLogin::BackupProtocolServerLogin()
	: mClientID(0),
	  mFlags(0)
{
}
BackupProtocolServerLogin::BackupProtocolServerLogin(const BackupProtocolServerLogin &rToCopy)
	: mClientID(rToCopy.mClientID),
	  mFlags(rToCopy.mFlags)
{
}
BackupProtocolServerLogin::~BackupProtocolServerLogin()
{
}
int BackupProtocolServerLogin::GetType() const
{
	return 2;
}
void BackupProtocolServerLogin::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mClientID);
	rProtocol.Read(mFlags);
}
void BackupProtocolServerLogin::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " Login(" << (mClientID == 0 ? "0x" : "") << std::hex << std::showbase << mClientID << std::dec << "," << (mFlags == 0 ? "0x" : "") << std::hex << std::showbase << mFlags << std::dec << ")");
}
BackupProtocolServerLoginConfirmed::BackupProtocolServerLoginConfirmed()
	: mClientStoreMarker(0),
	  mBlocksUsed(0),
	  mBlocksSoftLimit(0),
	  mBlocksHardLimit(0)
{
}
BackupProtocolServerLoginConfirmed::BackupProtocolServerLoginConfirmed(const BackupProtocolServerLoginConfirmed &rToCopy)
	: mClientStoreMarker(rToCopy.mClientStoreMarker),
	  mBlocksUsed(rToCopy.mBlocksUsed),
	  mBlocksSoftLimit(rToCopy.mBlocksSoftLimit),
	  mBlocksHardLimit(rToCopy.mBlocksHardLimit)
{
}
BackupProtocolServerLoginConfirmed::~BackupProtocolServerLoginConfirmed()
{
}
int BackupProtocolServerLoginConfirmed::GetType() const
{
	return 3;
}
BackupProtocolServerLoginConfirmed::BackupProtocolServerLoginConfirmed(int64_t ClientStoreMarker, int64_t BlocksUsed, int64_t BlocksSoftLimit, int64_t BlocksHardLimit)
	: mClientStoreMarker(ClientStoreMarker),
	  mBlocksUsed(BlocksUsed),
	  mBlocksSoftLimit(BlocksSoftLimit),
	  mBlocksHardLimit(BlocksHardLimit)
{
}
void BackupProtocolServerLoginConfirmed::WritePropertiesToStreamData(Protocol &rProtocol) const
{
	rProtocol.Write(mClientStoreMarker);
	rProtocol.Write(mBlocksUsed);
	rProtocol.Write(mBlocksSoftLimit);
	rProtocol.Write(mBlocksHardLimit);
}
void BackupProtocolServerLoginConfirmed::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " LoginConfirmed(" << (mClientStoreMarker == 0 ? "0x" : "") << std::hex << std::showbase << mClientStoreMarker << std::dec << "," << (mBlocksUsed == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksUsed << std::dec << "," << (mBlocksSoftLimit == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksSoftLimit << std::dec << "," << (mBlocksHardLimit == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksHardLimit << std::dec << ")");
}
BackupProtocolServerFinished::BackupProtocolServerFinished()
{
}
BackupProtocolServerFinished::BackupProtocolServerFinished(const BackupProtocolServerFinished &rToCopy)
{
}
BackupProtocolServerFinished::~BackupProtocolServerFinished()
{
}
int BackupProtocolServerFinished::GetType() const
{
	return 4;
}
void BackupProtocolServerFinished::SetPropertiesFromStreamData(Protocol &rProtocol)
{
}
void BackupProtocolServerFinished::WritePropertiesToStreamData(Protocol &rProtocol) const
{
}
bool BackupProtocolServerFinished::IsConversationEnd() const
{
	return true;
}
void BackupProtocolServerFinished::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " Finished(" << ")");
}
BackupProtocolServerSuccess::BackupProtocolServerSuccess()
	: mObjectID(0)
{
}
BackupProtocolServerSuccess::BackupProtocolServerSuccess(const BackupProtocolServerSuccess &rToCopy)
	: mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerSuccess::~BackupProtocolServerSuccess()
{
}
int BackupProtocolServerSuccess::GetType() const
{
	return 5;
}
BackupProtocolServerSuccess::BackupProtocolServerSuccess(int64_t ObjectID)
	: mObjectID(ObjectID)
{
}
void BackupProtocolServerSuccess::WritePropertiesToStreamData(Protocol &rProtocol) const
{
	rProtocol.Write(mObjectID);
}
void BackupProtocolServerSuccess::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " Success(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerSetClientStoreMarker::BackupProtocolServerSetClientStoreMarker()
	: mClientStoreMarker(0)
{
}
BackupProtocolServerSetClientStoreMarker::BackupProtocolServerSetClientStoreMarker(const BackupProtocolServerSetClientStoreMarker &rToCopy)
	: mClientStoreMarker(rToCopy.mClientStoreMarker)
{
}
BackupProtocolServerSetClientStoreMarker::~BackupProtocolServerSetClientStoreMarker()
{
}
int BackupProtocolServerSetClientStoreMarker::GetType() const
{
	return 6;
}
void BackupProtocolServerSetClientStoreMarker::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mClientStoreMarker);
}
void BackupProtocolServerSetClientStoreMarker::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " SetClientStoreMarker(" << (mClientStoreMarker == 0 ? "0x" : "") << std::hex << std::showbase << mClientStoreMarker << std::dec << ")");
}
BackupProtocolServerGetObject::BackupProtocolServerGetObject()
	: mObjectID(0)
{
}
BackupProtocolServerGetObject::BackupProtocolServerGetObject(const BackupProtocolServerGetObject &rToCopy)
	: mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerGetObject::~BackupProtocolServerGetObject()
{
}
int BackupProtocolServerGetObject::GetType() const
{
	return 10;
}
void BackupProtocolServerGetObject::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
}
void BackupProtocolServerGetObject::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetObject(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerMoveObject::BackupProtocolServerMoveObject()
	: mObjectID(0),
	  mMoveFromDirectory(0),
	  mMoveToDirectory(0),
	  mFlags(0)
{
}
BackupProtocolServerMoveObject::BackupProtocolServerMoveObject(const BackupProtocolServerMoveObject &rToCopy)
	: mObjectID(rToCopy.mObjectID),
	  mMoveFromDirectory(rToCopy.mMoveFromDirectory),
	  mMoveToDirectory(rToCopy.mMoveToDirectory),
	  mFlags(rToCopy.mFlags),
	  mNewFilename(rToCopy.mNewFilename)
{
}
BackupProtocolServerMoveObject::~BackupProtocolServerMoveObject()
{
}
int BackupProtocolServerMoveObject::GetType() const
{
	return 11;
}
void BackupProtocolServerMoveObject::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
	rProtocol.Read(mMoveFromDirectory);
	rProtocol.Read(mMoveToDirectory);
	rProtocol.Read(mFlags);
	rProtocol.Read(mNewFilename);
}
void BackupProtocolServerMoveObject::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " MoveObject(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << "," << (mMoveFromDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mMoveFromDirectory << std::dec << "," << (mMoveToDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mMoveToDirectory << std::dec << "," << (mFlags == 0 ? "0x" : "") << std::hex << std::showbase << mFlags << std::dec << "," << "OPAQUE" << ")");
}
BackupProtocolServerGetObjectName::BackupProtocolServerGetObjectName()
	: mObjectID(0),
	  mContainingDirectoryID(0)
{
}
BackupProtocolServerGetObjectName::BackupProtocolServerGetObjectName(const BackupProtocolServerGetObjectName &rToCopy)
	: mObjectID(rToCopy.mObjectID),
	  mContainingDirectoryID(rToCopy.mContainingDirectoryID)
{
}
BackupProtocolServerGetObjectName::~BackupProtocolServerGetObjectName()
{
}
int BackupProtocolServerGetObjectName::GetType() const
{
	return 12;
}
void BackupProtocolServerGetObjectName::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
	rProtocol.Read(mContainingDirectoryID);
}
void BackupProtocolServerGetObjectName::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetObjectName(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << "," << (mContainingDirectoryID == 0 ? "0x" : "") << std::hex << std::showbase << mContainingDirectoryID << std::dec << ")");
}
BackupProtocolServerObjectName::BackupProtocolServerObjectName()
	: mNumNameElements(0),
	  mModificationTime(0),
	  mAttributesHash(0),
	  mFlags(0)
{
}
BackupProtocolServerObjectName::BackupProtocolServerObjectName(const BackupProtocolServerObjectName &rToCopy)
	: mNumNameElements(rToCopy.mNumNameElements),
	  mModificationTime(rToCopy.mModificationTime),
	  mAttributesHash(rToCopy.mAttributesHash),
	  mFlags(rToCopy.mFlags)
{
}
BackupProtocolServerObjectName::~BackupProtocolServerObjectName()
{
}
int BackupProtocolServerObjectName::GetType() const
{
	return 13;
}
BackupProtocolServerObjectName::BackupProtocolServerObjectName(int32_t NumNameElements, int64_t ModificationTime, int64_t AttributesHash, int16_t Flags)
	: mNumNameElements(NumNameElements),
	  mModificationTime(ModificationTime),
	  mAttributesHash(AttributesHash),
	  mFlags(Flags)
{
}
void BackupProtocolServerObjectName::WritePropertiesToStreamData(Protocol &rProtocol) const
{
	rProtocol.Write(mNumNameElements);
	rProtocol.Write(mModificationTime);
	rProtocol.Write(mAttributesHash);
	rProtocol.Write(mFlags);
}
void BackupProtocolServerObjectName::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " ObjectName(" << (mNumNameElements == 0 ? "0x" : "") << std::hex << std::showbase << mNumNameElements << std::dec << "," << (mModificationTime == 0 ? "0x" : "") << std::hex << std::showbase << mModificationTime << std::dec << "," << (mAttributesHash == 0 ? "0x" : "") << std::hex << std::showbase << mAttributesHash << std::dec << "," << (mFlags == 0 ? "0x" : "") << std::hex << std::showbase << mFlags << std::dec << ")");
}
BackupProtocolServerCreateDirectory::BackupProtocolServerCreateDirectory()
	: mContainingDirectoryID(0),
	  mAttributesModTime(0)
{
}
BackupProtocolServerCreateDirectory::BackupProtocolServerCreateDirectory(const BackupProtocolServerCreateDirectory &rToCopy)
	: mContainingDirectoryID(rToCopy.mContainingDirectoryID),
	  mAttributesModTime(rToCopy.mAttributesModTime),
	  mDirectoryName(rToCopy.mDirectoryName)
{
}
BackupProtocolServerCreateDirectory::~BackupProtocolServerCreateDirectory()
{
}
int BackupProtocolServerCreateDirectory::GetType() const
{
	return 20;
}
void BackupProtocolServerCreateDirectory::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mContainingDirectoryID);
	rProtocol.Read(mAttributesModTime);
	rProtocol.Read(mDirectoryName);
}
void BackupProtocolServerCreateDirectory::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " CreateDirectory(" << (mContainingDirectoryID == 0 ? "0x" : "") << std::hex << std::showbase << mContainingDirectoryID << std::dec << "," << (mAttributesModTime == 0 ? "0x" : "") << std::hex << std::showbase << mAttributesModTime << std::dec << "," << "OPAQUE" << ")");
}
BackupProtocolServerListDirectory::BackupProtocolServerListDirectory()
	: mObjectID(0),
	  mFlagsMustBeSet(0),
	  mFlagsNotToBeSet(0),
	  mSendAttributes(0)
{
}
BackupProtocolServerListDirectory::BackupProtocolServerListDirectory(const BackupProtocolServerListDirectory &rToCopy)
	: mObjectID(rToCopy.mObjectID),
	  mFlagsMustBeSet(rToCopy.mFlagsMustBeSet),
	  mFlagsNotToBeSet(rToCopy.mFlagsNotToBeSet),
	  mSendAttributes(rToCopy.mSendAttributes)
{
}
BackupProtocolServerListDirectory::~BackupProtocolServerListDirectory()
{
}
int BackupProtocolServerListDirectory::GetType() const
{
	return 21;
}
void BackupProtocolServerListDirectory::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
	rProtocol.Read(mFlagsMustBeSet);
	rProtocol.Read(mFlagsNotToBeSet);
	rProtocol.Read(mSendAttributes);
}
void BackupProtocolServerListDirectory::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " ListDirectory(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << "," << (mFlagsMustBeSet == 0 ? "0x" : "") << std::hex << std::showbase << mFlagsMustBeSet << std::dec << "," << (mFlagsNotToBeSet == 0 ? "0x" : "") << std::hex << std::showbase << mFlagsNotToBeSet << std::dec << "," << ((mSendAttributes)?"true":"false") << ")");
}
BackupProtocolServerChangeDirAttributes::BackupProtocolServerChangeDirAttributes()
	: mObjectID(0),
	  mAttributesModTime(0)
{
}
BackupProtocolServerChangeDirAttributes::BackupProtocolServerChangeDirAttributes(const BackupProtocolServerChangeDirAttributes &rToCopy)
	: mObjectID(rToCopy.mObjectID),
	  mAttributesModTime(rToCopy.mAttributesModTime)
{
}
BackupProtocolServerChangeDirAttributes::~BackupProtocolServerChangeDirAttributes()
{
}
int BackupProtocolServerChangeDirAttributes::GetType() const
{
	return 22;
}
void BackupProtocolServerChangeDirAttributes::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
	rProtocol.Read(mAttributesModTime);
}
void BackupProtocolServerChangeDirAttributes::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " ChangeDirAttributes(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << "," << (mAttributesModTime == 0 ? "0x" : "") << std::hex << std::showbase << mAttributesModTime << std::dec << ")");
}
BackupProtocolServerDeleteDirectory::BackupProtocolServerDeleteDirectory()
	: mObjectID(0)
{
}
BackupProtocolServerDeleteDirectory::BackupProtocolServerDeleteDirectory(const BackupProtocolServerDeleteDirectory &rToCopy)
	: mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerDeleteDirectory::~BackupProtocolServerDeleteDirectory()
{
}
int BackupProtocolServerDeleteDirectory::GetType() const
{
	return 23;
}
void BackupProtocolServerDeleteDirectory::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
}
void BackupProtocolServerDeleteDirectory::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " DeleteDirectory(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerUndeleteDirectory::BackupProtocolServerUndeleteDirectory()
	: mObjectID(0)
{
}
BackupProtocolServerUndeleteDirectory::BackupProtocolServerUndeleteDirectory(const BackupProtocolServerUndeleteDirectory &rToCopy)
	: mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerUndeleteDirectory::~BackupProtocolServerUndeleteDirectory()
{
}
int BackupProtocolServerUndeleteDirectory::GetType() const
{
	return 24;
}
void BackupProtocolServerUndeleteDirectory::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
}
void BackupProtocolServerUndeleteDirectory::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " UndeleteDirectory(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerStoreFile::BackupProtocolServerStoreFile()
	: mDirectoryObjectID(0),
	  mModificationTime(0),
	  mAttributesHash(0),
	  mDiffFromFileID(0)
{
}
BackupProtocolServerStoreFile::BackupProtocolServerStoreFile(const BackupProtocolServerStoreFile &rToCopy)
	: mDirectoryObjectID(rToCopy.mDirectoryObjectID),
	  mModificationTime(rToCopy.mModificationTime),
	  mAttributesHash(rToCopy.mAttributesHash),
	  mDiffFromFileID(rToCopy.mDiffFromFileID),
	  mFilename(rToCopy.mFilename)
{
}
BackupProtocolServerStoreFile::~BackupProtocolServerStoreFile()
{
}
int BackupProtocolServerStoreFile::GetType() const
{
	return 30;
}
void BackupProtocolServerStoreFile::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mDirectoryObjectID);
	rProtocol.Read(mModificationTime);
	rProtocol.Read(mAttributesHash);
	rProtocol.Read(mDiffFromFileID);
	rProtocol.Read(mFilename);
}
void BackupProtocolServerStoreFile::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " StoreFile(" << (mDirectoryObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mDirectoryObjectID << std::dec << "," << (mModificationTime == 0 ? "0x" : "") << std::hex << std::showbase << mModificationTime << std::dec << "," << (mAttributesHash == 0 ? "0x" : "") << std::hex << std::showbase << mAttributesHash << std::dec << "," << (mDiffFromFileID == 0 ? "0x" : "") << std::hex << std::showbase << mDiffFromFileID << std::dec << "," << "OPAQUE" << ")");
}
BackupProtocolServerGetFile::BackupProtocolServerGetFile()
	: mInDirectory(0),
	  mObjectID(0)
{
}
BackupProtocolServerGetFile::BackupProtocolServerGetFile(const BackupProtocolServerGetFile &rToCopy)
	: mInDirectory(rToCopy.mInDirectory),
	  mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerGetFile::~BackupProtocolServerGetFile()
{
}
int BackupProtocolServerGetFile::GetType() const
{
	return 31;
}
void BackupProtocolServerGetFile::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mInDirectory);
	rProtocol.Read(mObjectID);
}
void BackupProtocolServerGetFile::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetFile(" << (mInDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mInDirectory << std::dec << "," << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerSetReplacementFileAttributes::BackupProtocolServerSetReplacementFileAttributes()
	: mInDirectory(0),
	  mAttributesHash(0)
{
}
BackupProtocolServerSetReplacementFileAttributes::BackupProtocolServerSetReplacementFileAttributes(const BackupProtocolServerSetReplacementFileAttributes &rToCopy)
	: mInDirectory(rToCopy.mInDirectory),
	  mAttributesHash(rToCopy.mAttributesHash),
	  mFilename(rToCopy.mFilename)
{
}
BackupProtocolServerSetReplacementFileAttributes::~BackupProtocolServerSetReplacementFileAttributes()
{
}
int BackupProtocolServerSetReplacementFileAttributes::GetType() const
{
	return 32;
}
void BackupProtocolServerSetReplacementFileAttributes::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mInDirectory);
	rProtocol.Read(mAttributesHash);
	rProtocol.Read(mFilename);
}
void BackupProtocolServerSetReplacementFileAttributes::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " SetReplacementFileAttributes(" << (mInDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mInDirectory << std::dec << "," << (mAttributesHash == 0 ? "0x" : "") << std::hex << std::showbase << mAttributesHash << std::dec << "," << "OPAQUE" << ")");
}
BackupProtocolServerDeleteFile::BackupProtocolServerDeleteFile()
	: mInDirectory(0)
{
}
BackupProtocolServerDeleteFile::BackupProtocolServerDeleteFile(const BackupProtocolServerDeleteFile &rToCopy)
	: mInDirectory(rToCopy.mInDirectory),
	  mFilename(rToCopy.mFilename)
{
}
BackupProtocolServerDeleteFile::~BackupProtocolServerDeleteFile()
{
}
int BackupProtocolServerDeleteFile::GetType() const
{
	return 33;
}
void BackupProtocolServerDeleteFile::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mInDirectory);
	rProtocol.Read(mFilename);
}
void BackupProtocolServerDeleteFile::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " DeleteFile(" << (mInDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mInDirectory << std::dec << "," << "OPAQUE" << ")");
}
BackupProtocolServerGetBlockIndexByID::BackupProtocolServerGetBlockIndexByID()
	: mObjectID(0)
{
}
BackupProtocolServerGetBlockIndexByID::BackupProtocolServerGetBlockIndexByID(const BackupProtocolServerGetBlockIndexByID &rToCopy)
	: mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerGetBlockIndexByID::~BackupProtocolServerGetBlockIndexByID()
{
}
int BackupProtocolServerGetBlockIndexByID::GetType() const
{
	return 34;
}
void BackupProtocolServerGetBlockIndexByID::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mObjectID);
}
void BackupProtocolServerGetBlockIndexByID::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetBlockIndexByID(" << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerGetBlockIndexByName::BackupProtocolServerGetBlockIndexByName()
	: mInDirectory(0)
{
}
BackupProtocolServerGetBlockIndexByName::BackupProtocolServerGetBlockIndexByName(const BackupProtocolServerGetBlockIndexByName &rToCopy)
	: mInDirectory(rToCopy.mInDirectory),
	  mFilename(rToCopy.mFilename)
{
}
BackupProtocolServerGetBlockIndexByName::~BackupProtocolServerGetBlockIndexByName()
{
}
int BackupProtocolServerGetBlockIndexByName::GetType() const
{
	return 35;
}
void BackupProtocolServerGetBlockIndexByName::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mInDirectory);
	rProtocol.Read(mFilename);
}
void BackupProtocolServerGetBlockIndexByName::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetBlockIndexByName(" << (mInDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mInDirectory << std::dec << "," << "OPAQUE" << ")");
}
BackupProtocolServerUndeleteFile::BackupProtocolServerUndeleteFile()
	: mInDirectory(0),
	  mObjectID(0)
{
}
BackupProtocolServerUndeleteFile::BackupProtocolServerUndeleteFile(const BackupProtocolServerUndeleteFile &rToCopy)
	: mInDirectory(rToCopy.mInDirectory),
	  mObjectID(rToCopy.mObjectID)
{
}
BackupProtocolServerUndeleteFile::~BackupProtocolServerUndeleteFile()
{
}
int BackupProtocolServerUndeleteFile::GetType() const
{
	return 36;
}
void BackupProtocolServerUndeleteFile::SetPropertiesFromStreamData(Protocol &rProtocol)
{
	rProtocol.Read(mInDirectory);
	rProtocol.Read(mObjectID);
}
void BackupProtocolServerUndeleteFile::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " UndeleteFile(" << (mInDirectory == 0 ? "0x" : "") << std::hex << std::showbase << mInDirectory << std::dec << "," << (mObjectID == 0 ? "0x" : "") << std::hex << std::showbase << mObjectID << std::dec << ")");
}
BackupProtocolServerGetAccountUsage::BackupProtocolServerGetAccountUsage()
{
}
BackupProtocolServerGetAccountUsage::BackupProtocolServerGetAccountUsage(const BackupProtocolServerGetAccountUsage &rToCopy)
{
}
BackupProtocolServerGetAccountUsage::~BackupProtocolServerGetAccountUsage()
{
}
int BackupProtocolServerGetAccountUsage::GetType() const
{
	return 40;
}
void BackupProtocolServerGetAccountUsage::SetPropertiesFromStreamData(Protocol &rProtocol)
{
}
void BackupProtocolServerGetAccountUsage::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetAccountUsage(" << ")");
}
BackupProtocolServerAccountUsage::BackupProtocolServerAccountUsage()
	: mBlocksUsed(0),
	  mBlocksInOldFiles(0),
	  mBlocksInDeletedFiles(0),
	  mBlocksInDirectories(0),
	  mBlocksSoftLimit(0),
	  mBlocksHardLimit(0),
	  mBlockSize(0)
{
}
BackupProtocolServerAccountUsage::BackupProtocolServerAccountUsage(const BackupProtocolServerAccountUsage &rToCopy)
	: mBlocksUsed(rToCopy.mBlocksUsed),
	  mBlocksInOldFiles(rToCopy.mBlocksInOldFiles),
	  mBlocksInDeletedFiles(rToCopy.mBlocksInDeletedFiles),
	  mBlocksInDirectories(rToCopy.mBlocksInDirectories),
	  mBlocksSoftLimit(rToCopy.mBlocksSoftLimit),
	  mBlocksHardLimit(rToCopy.mBlocksHardLimit),
	  mBlockSize(rToCopy.mBlockSize)
{
}
BackupProtocolServerAccountUsage::~BackupProtocolServerAccountUsage()
{
}
int BackupProtocolServerAccountUsage::GetType() const
{
	return 41;
}
BackupProtocolServerAccountUsage::BackupProtocolServerAccountUsage(int64_t BlocksUsed, int64_t BlocksInOldFiles, int64_t BlocksInDeletedFiles, int64_t BlocksInDirectories, int64_t BlocksSoftLimit, int64_t BlocksHardLimit, int32_t BlockSize)
	: mBlocksUsed(BlocksUsed),
	  mBlocksInOldFiles(BlocksInOldFiles),
	  mBlocksInDeletedFiles(BlocksInDeletedFiles),
	  mBlocksInDirectories(BlocksInDirectories),
	  mBlocksSoftLimit(BlocksSoftLimit),
	  mBlocksHardLimit(BlocksHardLimit),
	  mBlockSize(BlockSize)
{
}
void BackupProtocolServerAccountUsage::WritePropertiesToStreamData(Protocol &rProtocol) const
{
	rProtocol.Write(mBlocksUsed);
	rProtocol.Write(mBlocksInOldFiles);
	rProtocol.Write(mBlocksInDeletedFiles);
	rProtocol.Write(mBlocksInDirectories);
	rProtocol.Write(mBlocksSoftLimit);
	rProtocol.Write(mBlocksHardLimit);
	rProtocol.Write(mBlockSize);
}
void BackupProtocolServerAccountUsage::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " AccountUsage(" << (mBlocksUsed == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksUsed << std::dec << "," << (mBlocksInOldFiles == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksInOldFiles << std::dec << "," << (mBlocksInDeletedFiles == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksInDeletedFiles << std::dec << "," << (mBlocksInDirectories == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksInDirectories << std::dec << "," << (mBlocksSoftLimit == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksSoftLimit << std::dec << "," << (mBlocksHardLimit == 0 ? "0x" : "") << std::hex << std::showbase << mBlocksHardLimit << std::dec << "," << (mBlockSize == 0 ? "0x" : "") << std::hex << std::showbase << mBlockSize << std::dec << ")");
}
BackupProtocolServerGetIsAlive::BackupProtocolServerGetIsAlive()
{
}
BackupProtocolServerGetIsAlive::BackupProtocolServerGetIsAlive(const BackupProtocolServerGetIsAlive &rToCopy)
{
}
BackupProtocolServerGetIsAlive::~BackupProtocolServerGetIsAlive()
{
}
int BackupProtocolServerGetIsAlive::GetType() const
{
	return 42;
}
void BackupProtocolServerGetIsAlive::SetPropertiesFromStreamData(Protocol &rProtocol)
{
}
void BackupProtocolServerGetIsAlive::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " GetIsAlive(" << ")");
}
BackupProtocolServerIsAlive::BackupProtocolServerIsAlive()
{
}
BackupProtocolServerIsAlive::BackupProtocolServerIsAlive(const BackupProtocolServerIsAlive &rToCopy)
{
}
BackupProtocolServerIsAlive::~BackupProtocolServerIsAlive()
{
}
int BackupProtocolServerIsAlive::GetType() const
{
	return 43;
}
void BackupProtocolServerIsAlive::WritePropertiesToStreamData(Protocol &rProtocol) const
{
}
void BackupProtocolServerIsAlive::LogSysLog(const char *Action) const
{
	BOX_TRACE(Action << " IsAlive(" << ")");
}
BackupProtocolServer::BackupProtocolServer(IOStream &rStream)
	: Protocol(rStream), mLogToSysLog(false)
{
}
BackupProtocolServer::~BackupProtocolServer()
{
	DeleteStreamsToSend();
}
const char *BackupProtocolServer::GetIdentString()
{
	return "Box-Backup:v=C";
}
std::auto_ptr<ProtocolObject> BackupProtocolServer::MakeProtocolObject(int ObjType)
{
	switch(ObjType)
	{
	case 0:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerError);
		break;
	case 1:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerVersion);
		break;
	case 2:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerLogin);
		break;
	case 3:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerLoginConfirmed);
		break;
	case 4:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerFinished);
		break;
	case 5:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess);
		break;
	case 6:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSetClientStoreMarker);
		break;
	case 10:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetObject);
		break;
	case 11:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerMoveObject);
		break;
	case 12:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetObjectName);
		break;
	case 13:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName);
		break;
	case 20:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerCreateDirectory);
		break;
	case 21:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerListDirectory);
		break;
	case 22:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerChangeDirAttributes);
		break;
	case 23:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerDeleteDirectory);
		break;
	case 24:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerUndeleteDirectory);
		break;
	case 30:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerStoreFile);
		break;
	case 31:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetFile);
		break;
	case 32:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSetReplacementFileAttributes);
		break;
	case 33:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerDeleteFile);
		break;
	case 34:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetBlockIndexByID);
		break;
	case 35:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetBlockIndexByName);
		break;
	case 36:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerUndeleteFile);
		break;
	case 40:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetAccountUsage);
		break;
	case 41:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerAccountUsage);
		break;
	case 42:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerGetIsAlive);
		break;
	case 43:
		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerIsAlive);
		break;
	default:
		THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnknownCommandRecieved)
	}
}
std::auto_ptr<BackupProtocolObject> BackupProtocolServer::Receive()
{
	std::auto_ptr<BackupProtocolObject> preply((BackupProtocolObject*)(Protocol::Receive().release()));

	if(mLogToSysLog)
	{
		preply->LogSysLog("Receive");
	}

	return preply;
}

void BackupProtocolServer::Send(const BackupProtocolObject &rObject)
{
	if(mLogToSysLog)
	{
		rObject.LogSysLog("Send");
	}
	Protocol::Send(rObject);
}

void BackupProtocolServer::DoServer(BackupStoreContext &rContext)
{
	// Handshake with client
	Handshake();

	// Command processing loop
	bool inProgress = true;
	while(inProgress)
	{
		// Get an object from the conversation
		std::auto_ptr<BackupProtocolObject> pobj(Receive());

		// Run the command
		std::auto_ptr<BackupProtocolObject> preply((BackupProtocolObject*)(pobj->DoCommand(*this, rContext).release()));
		
		// Send the reply
		Send(*(preply.get()));

		// Send any streams
		for(unsigned int s = 0; s < mStreamsToSend.size(); s++)
		{
			// Send the streams
			SendStream(*mStreamsToSend[s]);
		}
		// Delete these streams
		DeleteStreamsToSend();

		// Does this end the conversation?
		if(pobj->IsConversationEnd())
		{
			inProgress = false;
		}
	}	
}

void BackupProtocolServer::SendStreamAfterCommand(IOStream *pStream)
{
	ASSERT(pStream != NULL);
	mStreamsToSend.push_back(pStream);
}

void BackupProtocolServer::DeleteStreamsToSend()
{
	for(std::vector<IOStream*>::iterator i(mStreamsToSend.begin()); i != mStreamsToSend.end(); ++i)
	{
		delete (*i);
	}
	mStreamsToSend.clear();
}


void BackupProtocolServer::InformStreamReceiving(u_int32_t Size)
{
	if(mLogToSysLog)
	{
		if(Size==Protocol::ProtocolStream_SizeUncertain)
		{
			BOX_TRACE("Receiving stream, size uncertain");
		}
		else
		{
			BOX_TRACE("Receiving stream, size " << Size);
		}
	}
}

void BackupProtocolServer::InformStreamSending(u_int32_t Size)
{
	if(mLogToSysLog)
	{
		if(Size==Protocol::ProtocolStream_SizeUncertain)
		{
			BOX_TRACE("Sending stream, size uncertain");
		}
		else
		{
			BOX_TRACE("Sending stream, size " << Size);
		}
	}
}

