[Box Backup-commit] COMMIT r2983 - in box/trunk: bin/bbackupd bin/bbackupquery bin/bbstored contrib/mac_osx lib/backupclient lib/backupstore lib/server qdbm test/backupstore test/backupstorepatch test/basicserver test/bbackupd

subversion at boxbackup.org subversion at boxbackup.org
Sat Aug 27 15:06:46 BST 2011


Author: chris
Date: 2011-08-27 15:06:46 +0100 (Sat, 27 Aug 2011)
New Revision: 2983

Added:
   box/trunk/lib/server/Message.cpp
   box/trunk/lib/server/Message.h
Removed:
   box/trunk/lib/server/ProtocolObject.cpp
   box/trunk/lib/server/ProtocolObject.h
Modified:
   box/trunk/bin/bbackupd/BackupClientContext.cpp
   box/trunk/bin/bbackupd/BackupClientDeleteList.cpp
   box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
   box/trunk/bin/bbackupd/BackupDaemon.cpp
   box/trunk/bin/bbackupd/BackupDaemon.h
   box/trunk/bin/bbackupquery/BackupQueries.cpp
   box/trunk/bin/bbackupquery/CommandCompletion.cpp
   box/trunk/bin/bbackupquery/bbackupquery.cpp
   box/trunk/bin/bbstored/BackupStoreDaemon.cpp
   box/trunk/contrib/mac_osx/
   box/trunk/lib/backupclient/BackupClientRestore.cpp
   box/trunk/lib/backupstore/
   box/trunk/lib/backupstore/BackupCommands.cpp
   box/trunk/lib/backupstore/BackupStoreContext.cpp
   box/trunk/lib/backupstore/BackupStoreContext.h
   box/trunk/lib/backupstore/BackupStoreFile.h
   box/trunk/lib/backupstore/Makefile.extra
   box/trunk/lib/backupstore/backupprotocol.txt
   box/trunk/lib/server/Protocol.cpp
   box/trunk/lib/server/Protocol.h
   box/trunk/lib/server/makeprotocol.pl.in
   box/trunk/qdbm/
   box/trunk/test/backupstore/testbackupstore.cpp
   box/trunk/test/backupstorepatch/testbackupstorepatch.cpp
   box/trunk/test/basicserver/Makefile.extra
   box/trunk/test/basicserver/TestCommands.cpp
   box/trunk/test/basicserver/testbasicserver.cpp
   box/trunk/test/bbackupd/Makefile.extra
   box/trunk/test/bbackupd/testbbackupd.cpp
Log:
Combine client and server protocols to make way for an offline/local protocol.

Rename ProtocolObject to Message.


Modified: box/trunk/bin/bbackupd/BackupClientContext.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientContext.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupd/BackupClientContext.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -25,7 +25,7 @@
 #include "BackupStoreConstants.h"
 #include "BackupStoreException.h"
 #include "BackupDaemon.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "BackupStoreFile.h"
 #include "Logging.h"
 
@@ -165,7 +165,7 @@
 		
 		// Check the version of the server
 		{
-			std::auto_ptr<BackupProtocolClientVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION));
+			std::auto_ptr<BackupProtocolVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION));
 			if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION)
 			{
 				THROW_EXCEPTION(BackupStoreException, WrongServerVersion)
@@ -173,7 +173,7 @@
 		}
 
 		// Login -- if this fails, the Protocol will exception
-		std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */));
+		std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */));
 		
 		// Check that the client store marker is the one we expect
 		if(mClientStoreMarker != ClientStoreMarker_NotKnown)
@@ -419,20 +419,20 @@
 
 	// Request filenames from the server, in a "safe" manner to ignore errors properly
 	{
-		BackupProtocolClientGetObjectName send(ObjectID, ContainingDirectory);
+		BackupProtocolGetObjectName send(ObjectID, ContainingDirectory);
 		connection.Send(send);
 	}
-	std::auto_ptr<BackupProtocolObjectCl> preply(connection.Receive());
+	std::auto_ptr<BackupProtocolMessage> preply(connection.Receive());
 
 	// Is it of the right type?
-	if(preply->GetType() != BackupProtocolClientObjectName::TypeID)
+	if(preply->GetType() != BackupProtocolObjectName::TypeID)
 	{
 		// Was an error or something
 		return false;
 	}
 
 	// Cast to expected type.
-	BackupProtocolClientObjectName *names = (BackupProtocolClientObjectName *)(preply.get());
+	BackupProtocolObjectName *names = (BackupProtocolObjectName *)(preply.get());
 
 	// Anything found?
 	int32_t numElements = names->GetNumNameElements();
@@ -482,10 +482,10 @@
 	}
 
 	// Is it a directory?
-	rIsDirectoryOut = ((names->GetFlags() & BackupProtocolClientListDirectory::Flags_Dir) == BackupProtocolClientListDirectory::Flags_Dir);
+	rIsDirectoryOut = ((names->GetFlags() & BackupProtocolListDirectory::Flags_Dir) == BackupProtocolListDirectory::Flags_Dir);
 	
 	// Is it the current version?
-	rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolClientListDirectory::Flags_OldVersion | BackupProtocolClientListDirectory::Flags_Deleted)) == 0);
+	rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolListDirectory::Flags_OldVersion | BackupProtocolListDirectory::Flags_Deleted)) == 0);
 
 	// And other information which may be required
 	if(pModTimeOnServer) *pModTimeOnServer = names->GetModificationTime();

Modified: box/trunk/bin/bbackupd/BackupClientDeleteList.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDeleteList.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupd/BackupClientDeleteList.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -13,7 +13,7 @@
 
 #include "BackupClientDeleteList.h"
 #include "BackupClientContext.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 
 #include "MemLeakFindOn.h"
 

Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -17,7 +17,7 @@
 #include <errno.h>
 #include <string.h>
 
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "Archive.h"
 #include "BackupClientContext.h"
 #include "BackupClientDirectoryRecord.h"
@@ -335,7 +335,7 @@
 						filename << ", nlink=" <<
 						file_st.st_nlink);
 				}
-				else if(file_st.st_nlink != 1)
+				else if(file_st.st_nlink > 1)
 				{
 					if(!mSuppressMultipleLinksWarning)
 					{
@@ -613,10 +613,11 @@
 		BackupProtocolClient &connection(rParams.mrContext.GetConnection());
 
 		// Query the directory
-		std::auto_ptr<BackupProtocolClientSuccess> dirreply(connection.QueryListDirectory(
+		std::auto_ptr<BackupProtocolSuccess> dirreply(connection.QueryListDirectory(
 				mObjectID,
-				BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,	// both files and directories
-				BackupProtocolClientListDirectory::Flags_Deleted | BackupProtocolClientListDirectory::Flags_OldVersion, // exclude old/deleted stuff
+				BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,	// both files and directories
+				BackupProtocolListDirectory::Flags_Deleted | 
+				BackupProtocolListDirectory::Flags_OldVersion, // exclude old/deleted stuff
 				true /* want attributes */));
 
 		// Retrieve the directory from the stream following
@@ -830,7 +831,8 @@
 							{
 								// Rename the existing files (ie include old versions) on the server
 								connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */,
-									BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject,
+									BackupProtocolMoveObject::Flags_MoveAllWithSameName | 
+									BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject,
 									storeFilename);
 									
 								// Stop the attempt to delete the file in the original location
@@ -1364,7 +1366,8 @@
 				{
 					// Rename the existing directory on the server
 					connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */,
-						BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject,
+						BackupProtocolMoveObject::Flags_MoveAllWithSameName | 
+						BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject,
 						storeFilename);
 						
 					// Put the latest attributes on it
@@ -1381,7 +1384,7 @@
 				else
 				{
 					// Create a new directory
-					std::auto_ptr<BackupProtocolClientSuccess> dirCreate(connection.QueryCreateDirectory(
+					std::auto_ptr<BackupProtocolSuccess> dirCreate(connection.QueryCreateDirectory(
 						mObjectID, attrModTime, storeFilename, attrStream));
 					subDirObjectID = dirCreate->GetObjectID(); 
 					
@@ -1577,7 +1580,7 @@
 		{
 			// YES -- try to do diff, if possible
 			// First, query the server to see if there's an old version available
-			std::auto_ptr<BackupProtocolClientSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename));
+			std::auto_ptr<BackupProtocolSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename));
 			int64_t diffFromID = getBlockIndex->GetObjectID();
 			
 			if(diffFromID != 0)
@@ -1625,7 +1628,7 @@
 				//
 				// Upload the patch to the store
 				//
-				std::auto_ptr<BackupProtocolClientSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime,
+				std::auto_ptr<BackupProtocolSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime,
 						AttributesHash, isCompletelyDifferent?(0):(diffFromID), rStoreFilename, *pStreamToUpload));
 				
 				// Get object ID from the result		
@@ -1666,7 +1669,7 @@
 			}
 	
 			// Send to store
-			std::auto_ptr<BackupProtocolClientSuccess> stored(
+			std::auto_ptr<BackupProtocolSuccess> stored(
 				connection.QueryStoreFile(
 					mObjectID, ModificationTime,
 					AttributesHash, 
@@ -1692,8 +1695,8 @@
 			int type, subtype;
 			if(connection.GetLastError(type, subtype))
 			{
-				if(type == BackupProtocolClientError::ErrorType
-				&& subtype == BackupProtocolClientError::Err_StorageLimitExceeded)
+				if(type == BackupProtocolError::ErrorType
+				&& subtype == BackupProtocolError::Err_StorageLimitExceeded)
 				{
 					// The hard limit was exceeded on the server, notify!
 					rParams.mrSysadminNotifier.NotifySysadmin(

Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -50,7 +50,7 @@
 
 #include "SSLLib.h"
 
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "autogen_ClientException.h"
 #include "autogen_ConversionException.h"
 #include "Archive.h"
@@ -696,6 +696,7 @@
 	// do not retry immediately without a good reason
 	mDoSyncForcedByPreviousSyncError = false;
 	
+	// Notify system administrator about the final state of the backup
 	if(errorOccurred)
 	{
 		// Is it a berkely db failure?
@@ -757,16 +758,19 @@
 					SYNC_PERIOD_RANDOM_EXTRA_TIME_SHIFT_BY);
 		}
 	}
-	// Notify system administrator about the final state of the backup
-	else if(mReadErrorsOnFilesystemObjects)
+
+	if(mReadErrorsOnFilesystemObjects)
 	{
 		NotifySysadmin(SysadminNotifier::ReadError);
 	}
-	else if(mStorageLimitExceeded)
+
+	if(mStorageLimitExceeded)
 	{
 		NotifySysadmin(SysadminNotifier::StoreFull);
 	}
-	else
+
+	if (!errorOccurred && !mReadErrorsOnFilesystemObjects &&
+		!mStorageLimitExceeded)
 	{
 		NotifySysadmin(SysadminNotifier::BackupOK);
 	}
@@ -1004,7 +1008,7 @@
 #endif
 
 		(*i)->mpDirectoryRecord->SyncDirectory(params,
-			BackupProtocolClientListDirectory::RootDirectory,
+			BackupProtocolListDirectory::RootDirectory,
 			locationPath, std::string("/") + (*i)->mName);
 
 		// Unset exclude lists (just in case)
@@ -2097,18 +2101,18 @@
 	
 	// Going to need a copy of the root directory. Get a connection,
 	// and fetch it.
-	BackupProtocolClient &connection(rClientContext.GetConnection());
+	BackupProtocolCallable& connection(rClientContext.GetConnection());
 	
 	// Ask server for a list of everything in the root directory,
 	// which is a directory itself
-	std::auto_ptr<BackupProtocolClientSuccess> dirreply(
+	std::auto_ptr<BackupProtocolSuccess> dirreply(
 		connection.QueryListDirectory(
-			BackupProtocolClientListDirectory::RootDirectory,
+			BackupProtocolListDirectory::RootDirectory,
 			// only directories
-			BackupProtocolClientListDirectory::Flags_Dir,
+			BackupProtocolListDirectory::Flags_Dir,
 			// exclude old/deleted stuff
-			BackupProtocolClientListDirectory::Flags_Deleted |
-			BackupProtocolClientListDirectory::Flags_OldVersion,
+			BackupProtocolListDirectory::Flags_Deleted |
+			BackupProtocolListDirectory::Flags_OldVersion,
 			false /* no attributes */));
 
 	// Retrieve the directory from the stream following
@@ -2348,9 +2352,9 @@
 				try
 				{
 					MemBlockStream attrStream(attr);
-					std::auto_ptr<BackupProtocolClientSuccess>
+					std::auto_ptr<BackupProtocolSuccess>
 						dirCreate(connection.QueryCreateDirectory(
-						BackupProtocolClientListDirectory::RootDirectory,
+						BackupProtocolListDirectory::RootDirectory,
 						attrModTime, dirname, attrStream));
 						
 					// Object ID for later creation
@@ -2894,7 +2898,7 @@
 
 	// Entries to delete, and it's the right time to do so...
 	BOX_NOTICE("Deleting unused locations from store root...");
-	BackupProtocolClient &connection(rContext.GetConnection());
+	BackupProtocolCallable &connection(rContext.GetConnection());
 	for(std::vector<std::pair<int64_t,std::string> >::iterator
 		i(mUnusedRootDirEntries.begin());
 		i != mUnusedRootDirEntries.end(); ++i)

Modified: box/trunk/bin/bbackupd/BackupDaemon.h
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.h	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupd/BackupDaemon.h	2011-08-27 14:06:46 UTC (rev 2983)
@@ -24,7 +24,7 @@
 #include "SocketStream.h"
 #include "TLSContext.h"
 
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 
 #ifdef WIN32
 	#include "WinNamedPipeListener.h"
@@ -382,7 +382,7 @@
  		int type, int subtype)
  	{
 		std::ostringstream msgs;
-		if (type != BackupProtocolClientError::ErrorType)
+		if (type != BackupProtocolError::ErrorType)
 		{
 			msgs << "unknown error type " << type;
 		}
@@ -390,46 +390,46 @@
 		{
 			switch(subtype)
 			{
-			case BackupProtocolClientError::Err_WrongVersion:
+			case BackupProtocolError::Err_WrongVersion:
 				msgs << "WrongVersion";
 				break;
-			case BackupProtocolClientError::Err_NotInRightProtocolPhase:
+			case BackupProtocolError::Err_NotInRightProtocolPhase:
 				msgs << "NotInRightProtocolPhase";
 				break;
-			case BackupProtocolClientError::Err_BadLogin:
+			case BackupProtocolError::Err_BadLogin:
 				msgs << "BadLogin";
 				break;
-			case BackupProtocolClientError::Err_CannotLockStoreForWriting:
+			case BackupProtocolError::Err_CannotLockStoreForWriting:
 				msgs << "CannotLockStoreForWriting";
 				break;
-			case BackupProtocolClientError::Err_SessionReadOnly:
+			case BackupProtocolError::Err_SessionReadOnly:
 				msgs << "SessionReadOnly";
 				break;
-			case BackupProtocolClientError::Err_FileDoesNotVerify:
+			case BackupProtocolError::Err_FileDoesNotVerify:
 				msgs << "FileDoesNotVerify";
 				break;
-			case BackupProtocolClientError::Err_DoesNotExist:
+			case BackupProtocolError::Err_DoesNotExist:
 				msgs << "DoesNotExist";
 				break;
-			case BackupProtocolClientError::Err_DirectoryAlreadyExists:
+			case BackupProtocolError::Err_DirectoryAlreadyExists:
 				msgs << "DirectoryAlreadyExists";
 				break;
-			case BackupProtocolClientError::Err_CannotDeleteRoot:
+			case BackupProtocolError::Err_CannotDeleteRoot:
 				msgs << "CannotDeleteRoot";
 				break;
-			case BackupProtocolClientError::Err_TargetNameExists:
+			case BackupProtocolError::Err_TargetNameExists:
 				msgs << "TargetNameExists";
 				break;
-			case BackupProtocolClientError::Err_StorageLimitExceeded:
+			case BackupProtocolError::Err_StorageLimitExceeded:
 				msgs << "StorageLimitExceeded";
 				break;
-			case BackupProtocolClientError::Err_DiffFromFileDoesNotExist:
+			case BackupProtocolError::Err_DiffFromFileDoesNotExist:
 				msgs << "DiffFromFileDoesNotExist";
 				break;
-			case BackupProtocolClientError::Err_DoesNotExistInDirectory:
+			case BackupProtocolError::Err_DoesNotExistInDirectory:
 				msgs << "DoesNotExistInDirectory";
 				break;
-			case BackupProtocolClientError::Err_PatchConsistencyError:
+			case BackupProtocolError::Err_PatchConsistencyError:
 				msgs << "PatchConsistencyError";
 				break;
 			default:

Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -49,7 +49,7 @@
 #include "PathUtils.h"
 #include "SelfFlushingStream.h"
 #include "Utils.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 
 #include "MemLeakFindOn.h"
 
@@ -358,16 +358,16 @@
 void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool *opts, bool FirstLevel)
 {
 	// Generate exclude flags
-	int16_t excludeFlags = BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING;
-	if(!opts[LIST_OPTION_ALLOWOLD]) excludeFlags |= BackupProtocolClientListDirectory::Flags_OldVersion;
-	if(!opts[LIST_OPTION_ALLOWDELETED]) excludeFlags |= BackupProtocolClientListDirectory::Flags_Deleted;
+	int16_t excludeFlags = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING;
+	if(!opts[LIST_OPTION_ALLOWOLD]) excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion;
+	if(!opts[LIST_OPTION_ALLOWDELETED]) excludeFlags |= BackupProtocolListDirectory::Flags_Deleted;
 
 	// Do communication
 	try
 	{
 		mrConnection.QueryListDirectory(
 				DirID,
-				BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
+				BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
 				// both files and directories
 				excludeFlags,
 				true /* want attributes */);
@@ -434,7 +434,7 @@
 			// terminate
 			*(f++) = ' ';
 			*(f++) = '\0';
-			printf(displayflags);
+			printf("%s", displayflags);
 			
 			if(en_flags != 0)
 			{
@@ -544,7 +544,7 @@
 
 	// Start from current stack, or root, whichever is required
 	std::vector<std::pair<std::string, int64_t> > stack;
-	int64_t dirID = BackupProtocolClientListDirectory::RootDirectory;
+	int64_t dirID = BackupProtocolListDirectory::RootDirectory;
 	if(rDirName.size() > 0 && rDirName[0] == '/')
 	{
 		// Root, do nothing
@@ -560,9 +560,9 @@
 	}
 
 	// Generate exclude flags
-	int16_t excludeFlags = BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING;
-	if(!AllowOldVersion) excludeFlags |= BackupProtocolClientListDirectory::Flags_OldVersion;
-	if(!AllowDeletedDirs) excludeFlags |= BackupProtocolClientListDirectory::Flags_Deleted;
+	int16_t excludeFlags = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING;
+	if(!AllowOldVersion) excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion;
+	if(!AllowDeletedDirs) excludeFlags |= BackupProtocolListDirectory::Flags_Deleted;
 
 	// Read directories
 	for(unsigned int e = 0; e < dirElements.size(); ++e)
@@ -582,20 +582,20 @@
 					stack.pop_back();
 					
 					// New dir ID
-					dirID = (stack.size() > 0)?(stack[stack.size() - 1].second):BackupProtocolClientListDirectory::RootDirectory;
+					dirID = (stack.size() > 0)?(stack[stack.size() - 1].second):BackupProtocolListDirectory::RootDirectory;
 				}
 				else
 				{	
 					// At root anyway
-					dirID = BackupProtocolClientListDirectory::RootDirectory;
+					dirID = BackupProtocolListDirectory::RootDirectory;
 				}
 			}
 			else
 			{
 				// Not blank element. Read current directory.
-				std::auto_ptr<BackupProtocolClientSuccess> dirreply(mrConnection.QueryListDirectory(
+				std::auto_ptr<BackupProtocolSuccess> dirreply(mrConnection.QueryListDirectory(
 						dirID,
-						BackupProtocolClientListDirectory::Flags_Dir,	// just directories
+						BackupProtocolListDirectory::Flags_Dir,	// just directories
 						excludeFlags,
 						true /* want attributes */));
 
@@ -646,7 +646,7 @@
 	// Special case for root
 	if(mDirStack.size() == 0)
 	{
-		return BackupProtocolClientListDirectory::RootDirectory;
+		return BackupProtocolListDirectory::RootDirectory;
 	}
 	
 	// Otherwise, get from the last entry on the stack
@@ -837,8 +837,8 @@
 	try
 	{
 		// Request object
-		std::auto_ptr<BackupProtocolClientSuccess> getobj(mrConnection.QueryGetObject(id));
-		if(getobj->GetObjectID() != BackupProtocolClientGetObject::NoObject)
+		std::auto_ptr<BackupProtocolSuccess> getobj(mrConnection.QueryGetObject(id));
+		if(getobj->GetObjectID() != BackupProtocolGetObject::NoObject)
 		{
 			// Stream that object out to the file
 			std::auto_ptr<IOStream> objectStream(mrConnection.ReceiveStream());
@@ -1017,19 +1017,19 @@
 	if(opts['i'])
 	{
 		// can retrieve anything by ID
-		flagsExclude = BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING;
+		flagsExclude = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING;
 	}
 	else
 	{
 		// only current versions by name
 		flagsExclude =
-			BackupProtocolClientListDirectory::Flags_OldVersion |
-			BackupProtocolClientListDirectory::Flags_Deleted;
+			BackupProtocolListDirectory::Flags_OldVersion |
+			BackupProtocolListDirectory::Flags_Deleted;
 	}
 
 
 	fileId = FindFileID(args[0], opts, &dirId, &localName,
-		BackupProtocolClientListDirectory::Flags_File, // just files
+		BackupProtocolListDirectory::Flags_File, // just files
 		flagsExclude, NULL /* don't care about flags found */);
 
 	if (fileId == 0)
@@ -1519,10 +1519,10 @@
 	// Get the directory listing from the store
 	mrConnection.QueryListDirectory(
 		DirID,
-		BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
+		BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
 		// get everything
-		BackupProtocolClientListDirectory::Flags_OldVersion |
-		BackupProtocolClientListDirectory::Flags_Deleted,
+		BackupProtocolListDirectory::Flags_OldVersion |
+		BackupProtocolListDirectory::Flags_Deleted,
 		// except for old versions and deleted files
 		true /* want attributes */);
 
@@ -1896,7 +1896,7 @@
 		return;
 	}
 
-	if(dirID == BackupProtocolClientListDirectory::RootDirectory)
+	if(dirID == BackupProtocolListDirectory::RootDirectory)
 	{
 		BOX_ERROR("Cannot restore the root directory -- restore locations individually.");
 		return;
@@ -2053,7 +2053,7 @@
 	bool MachineReadable = opts['m'];
 
 	// Request full details from the server
-	std::auto_ptr<BackupProtocolClientAccountUsage> usage(mrConnection.QueryGetAccountUsage());
+	std::auto_ptr<BackupProtocolAccountUsage> usage(mrConnection.QueryGetAccountUsage());
 
 	// Display each entry in turn
 	int64_t hardLimit = usage->GetBlocksHardLimit();
@@ -2129,9 +2129,9 @@
 
 	fileId = FindFileID(storeDirEncoded, opts, &parentId, &fileName,
 		/* include files and directories */
-		BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING,
+		BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
 		/* include old and deleted files */
-		BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING,
+		BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
 		&flagsOut);
 
 	if (fileId == 0)
@@ -2144,7 +2144,7 @@
 	try
 	{
 		// Undelete object
-		if(flagsOut & BackupProtocolClientListDirectory::Flags_File)
+		if(flagsOut & BackupProtocolListDirectory::Flags_File)
 		{
 			mrConnection.QueryUndeleteFile(parentId, fileId);
 		}
@@ -2209,10 +2209,10 @@
 
 	fileId = FindFileID(storeDirEncoded, opts, &parentId, &fileName,
 		/* include files and directories */
-		BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING,
+		BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
 		/* exclude old and deleted files */
-		BackupProtocolClientListDirectory::Flags_OldVersion |
-		BackupProtocolClientListDirectory::Flags_Deleted,
+		BackupProtocolListDirectory::Flags_OldVersion |
+		BackupProtocolListDirectory::Flags_Deleted,
 		&flagsOut);
 
 	if (fileId == 0)
@@ -2227,7 +2227,7 @@
 	try
 	{
 		// Delete object
-		if(flagsOut & BackupProtocolClientListDirectory::Flags_File)
+		if(flagsOut & BackupProtocolListDirectory::Flags_File)
 		{
 			mrConnection.QueryDeleteFile(parentId, fn);
 		}

Modified: box/trunk/bin/bbackupquery/CommandCompletion.cpp
===================================================================
--- box/trunk/bin/bbackupquery/CommandCompletion.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupquery/CommandCompletion.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -32,7 +32,7 @@
 #include "BackupQueries.h"
 #include "Configuration.h"
 
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 
 #include "MemLeakFindOn.h"
 
@@ -154,12 +154,12 @@
 
 	if (rCommand.mOptions.find(LIST_OPTION_ALLOWOLD) == std::string::npos)
 	{
-		excludeFlags |= BackupProtocolClientListDirectory::Flags_OldVersion;
+		excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion;
 	}
 
 	if (rCommand.mOptions.find(LIST_OPTION_ALLOWDELETED) == std::string::npos)
 	{
-		excludeFlags |= BackupProtocolClientListDirectory::Flags_Deleted;
+		excludeFlags |= BackupProtocolListDirectory::Flags_Deleted;
 	}
 
 	return excludeFlags;
@@ -225,18 +225,18 @@
 	// If we're looking for directories, then only list directories.
 
 	bool completeFiles = includeFlags &
-		BackupProtocolClientListDirectory::Flags_File;
+		BackupProtocolListDirectory::Flags_File;
 	bool completeDirs = includeFlags &
-		BackupProtocolClientListDirectory::Flags_Dir;
+		BackupProtocolListDirectory::Flags_Dir;
 	int16_t listFlags = 0;
 
 	if(completeFiles)
 	{
-		listFlags = BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING;
+		listFlags = BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING;
 	}
 	else if(completeDirs)
 	{
-		listFlags = BackupProtocolClientListDirectory::Flags_Dir;
+		listFlags = BackupProtocolListDirectory::Flags_Dir;
 	}
 
 	rProtocol.QueryListDirectory(listDirId,
@@ -258,7 +258,7 @@
 		if(name.compare(0, searchPrefix.length(), searchPrefix) == 0)
 		{
 			if(en->IsDir() &&
-				(includeFlags & BackupProtocolClientListDirectory::Flags_Dir) == 0)
+				(includeFlags & BackupProtocolListDirectory::Flags_Dir) == 0)
 			{
 				// Was looking for a file, but this is a 
 				// directory, so append a slash to the name
@@ -282,13 +282,13 @@
 COMPLETION_FUNCTION(RemoteDir,
 	completions = CompleteRemoteFileOrDirectory(rCommand, prefix,
 		rProtocol, rQueries,
-		BackupProtocolClientListDirectory::Flags_Dir);
+		BackupProtocolListDirectory::Flags_Dir);
 )
 
 COMPLETION_FUNCTION(RemoteFile,
 	completions = CompleteRemoteFileOrDirectory(rCommand, prefix,
 		rProtocol, rQueries,
-		BackupProtocolClientListDirectory::Flags_File);
+		BackupProtocolListDirectory::Flags_File);
 )
 
 COMPLETION_FUNCTION(LocalDir,
@@ -324,7 +324,7 @@
 
 	rProtocol.QueryListDirectory(
 		listDirId,
-		BackupProtocolClientListDirectory::Flags_File,
+		BackupProtocolListDirectory::Flags_File,
 		excludeFlags, false /* no attributes */);
 
 	// Retrieve the directory from the stream following

Modified: box/trunk/bin/bbackupquery/bbackupquery.cpp
===================================================================
--- box/trunk/bin/bbackupquery/bbackupquery.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbackupquery/bbackupquery.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -50,7 +50,7 @@
 #include "SSLLib.h"
 #include "BackupStoreConstants.h"
 #include "BackupStoreException.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "BackupQueries.h"
 #include "FdGetLine.h"
 #include "BackupClientCryptoKeys.h"
@@ -447,7 +447,7 @@
 	if(!quiet) BOX_INFO("Login to store...");
 	// Check the version of the server
 	{
-		std::auto_ptr<BackupProtocolClientVersion> serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+		std::auto_ptr<BackupProtocolVersion> serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 		if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION)
 		{
 			THROW_EXCEPTION(BackupStoreException, WrongServerVersion)
@@ -455,7 +455,7 @@
 	}
 	// Login -- if this fails, the Protocol will exception
 	connection.QueryLogin(conf.GetKeyValueUint32("AccountNumber"),
-		(readWrite)?0:(BackupProtocolClientLogin::Flags_ReadOnly));
+		(readWrite)?0:(BackupProtocolLogin::Flags_ReadOnly));
 
 	// 5. Tell user.
 	if(!quiet) printf("Login complete.\n\nType \"help\" for a list of commands.\n\n");

Modified: box/trunk/bin/bbstored/BackupStoreDaemon.cpp
===================================================================
--- box/trunk/bin/bbstored/BackupStoreDaemon.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/bin/bbstored/BackupStoreDaemon.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -20,7 +20,7 @@
 #include "BackupStoreContext.h"
 #include "BackupStoreDaemon.h"
 #include "BackupStoreConfigVerify.h"
-#include "autogen_BackupProtocolServer.h"
+#include "autogen_BackupProtocol.h"
 #include "RaidFileController.h"
 #include "BackupStoreAccountDatabase.h"
 #include "BackupStoreAccounts.h"


Property changes on: box/trunk/contrib/mac_osx
___________________________________________________________________
Added: svn:ignore
   + org.boxbackup.*.plist


Modified: box/trunk/lib/backupclient/BackupClientRestore.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupClientRestore.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupclient/BackupClientRestore.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -22,7 +22,7 @@
 #include <errno.h>
 
 #include "BackupClientRestore.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "CommonException.h"
 #include "BackupClientFileAttributes.h"
 #include "IOStream.h"
@@ -443,8 +443,8 @@
 	// list of files which is appropriate to the restore type
 	rConnection.QueryListDirectory(
 		DirectoryID,
-		Params.RestoreDeleted?(BackupProtocolClientListDirectory::Flags_Deleted):(BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING),
-		BackupProtocolClientListDirectory::Flags_OldVersion | (Params.RestoreDeleted?(0):(BackupProtocolClientListDirectory::Flags_Deleted)),
+		Params.RestoreDeleted?(BackupProtocolListDirectory::Flags_Deleted):(BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING),
+		BackupProtocolListDirectory::Flags_OldVersion | (Params.RestoreDeleted?(0):(BackupProtocolListDirectory::Flags_Deleted)),
 		true /* want attributes */);
 
 	// Retrieve the directory from the stream following


Property changes on: box/trunk/lib/backupstore
___________________________________________________________________
Modified: svn:ignore
   - Makefile

   + Makefile
autogen_*


Modified: box/trunk/lib/backupstore/BackupCommands.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupCommands.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupstore/BackupCommands.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -12,7 +12,7 @@
 #include <set>
 #include <sstream>
 
-#include "autogen_BackupProtocolServer.h"
+#include "autogen_BackupProtocol.h"
 #include "autogen_RaidFileException.h"
 #include "BackupConstants.h"
 #include "BackupStoreContext.h"
@@ -31,9 +31,9 @@
 #include "MemLeakFindOn.h"
 
 #define PROTOCOL_ERROR(code) \
-	std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( \
-		BackupProtocolServerError::ErrorType, \
-		BackupProtocolServerError::code));
+	std::auto_ptr<BackupProtocolMessage>(new BackupProtocolError( \
+		BackupProtocolError::ErrorType, \
+		BackupProtocolError::code));
 
 #define CHECK_PHASE(phase) \
 	if(rContext.GetPhase() != BackupStoreContext::phase) \
@@ -50,12 +50,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerVersion::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolVersion::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Return the current version, or an error if the requested version isn't allowed
 //		Created: 2003/08/20
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolVersion::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Version)
 
@@ -69,18 +69,18 @@
 	rContext.SetPhase(BackupStoreContext::Phase_Login);
 
 	// Return our version
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerVersion(BACKUP_STORE_SERVER_VERSION));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolVersion(BACKUP_STORE_SERVER_VERSION));
 }
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerLogin::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolLogin::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Return the current version, or an error if the requested version isn't allowed
 //		Created: 2003/08/20
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolLogin::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Login)
 
@@ -138,18 +138,18 @@
 	rContext.GetStoreDiscUsageInfo(blocksUsed, blocksSoftLimit, blocksHardLimit);
 
 	// Return success
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerLoginConfirmed(clientStoreMarker, blocksUsed, blocksSoftLimit, blocksHardLimit));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolLoginConfirmed(clientStoreMarker, blocksUsed, blocksSoftLimit, blocksHardLimit));
 }
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerFinished::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolFinished::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Marks end of conversation (Protocol framework handles this)
 //		Created: 2003/08/20
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolFinished::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	BOX_NOTICE("Session finished for Client ID " << 
 		BOX_FORMAT_ACCOUNT(rContext.GetClientID()));
@@ -158,19 +158,19 @@
 	rContext.ReceivedFinishCommand();
 
 	// can be called in any phase
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerFinished);
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolFinished);
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerListDirectory::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolListDirectory::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Command to list a directory
 //		Created: 2003/09/02
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolListDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
@@ -200,24 +200,24 @@
 	// Get the protocol to send the stream
 	rProtocol.SendStreamAfterCommand(stream.release());
 
-	return std::auto_ptr<ProtocolObject>(
-		new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(
+		new BackupProtocolSuccess(mObjectID));
 }
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerStoreFile::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolStoreFile::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Command to store a file on the server
 //		Created: 2003/09/02
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolStoreFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
 
-	std::auto_ptr<ProtocolObject> hookResult =
+	std::auto_ptr<BackupProtocolMessage> hookResult =
 		rContext.StartCommandHook(*this);
 	if(hookResult.get())
 	{
@@ -263,7 +263,7 @@
 	}
 	
 	// Tell the caller what the file was
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(id));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(id));
 }
 
 
@@ -272,19 +272,19 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetObject::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolGetObject::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Command to get an arbitary object from the server
 //		Created: 2003/09/03
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObject::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
 	// Check the object exists
 	if(!rContext.ObjectExists(mObjectID))
 	{
-		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(NoObject));
+		return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(NoObject));
 	}
 
 	// Open the object
@@ -294,19 +294,19 @@
 	rProtocol.SendStreamAfterCommand(object.release());
 
 	// Tell the caller what the file was
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetFile::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolGetFile::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Command to get an file object from the server -- may have to do a bit of 
 //				 work to get the object.
 //		Created: 2003/09/03
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
@@ -460,19 +460,19 @@
 	stream.release();
 
 	// Tell the caller what the file was
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerCreateDirectory::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolCreateDirectory::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Create directory command
 //		Created: 2003/09/04
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolCreateDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -500,7 +500,7 @@
 	}
 
 	// Tell the caller what the file was
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(id));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(id));
 }
 
 
@@ -508,12 +508,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerChangeDirAttributes::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolChangeDirAttributes::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Change attributes on directory
 //		Created: 2003/09/06
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolChangeDirAttributes::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -529,19 +529,19 @@
 	rContext.ChangeDirAttributes(mObjectID, attr, mAttributesModTime);
 
 	// Tell the caller what the file was
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerSetReplacementFileAttributes::DoCommand(Protocol &, BackupStoreContext &)
+//		Name:    BackupProtocolSetReplacementFileAttributes::DoCommand(Protocol &, BackupStoreContext &)
 //		Purpose: Change attributes on directory
 //		Created: 2003/09/06
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolSetReplacementFileAttributes::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -562,7 +562,7 @@
 	}
 
 	// Tell the caller what the file was
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(objectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID));
 }
 
 
@@ -570,12 +570,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolDeleteFile::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Delete a file
 //		Created: 2003/10/21
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolDeleteFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -585,21 +585,21 @@
 	rContext.DeleteFile(mFilename, mInDirectory, objectID);
 
 	// return the object ID or zero for not found
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(objectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerUndeleteFile::DoCommand(
-//			 BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolUndeleteFile::DoCommand(
+//			 BackupProtocolBase &, BackupStoreContext &)
 //		Purpose: Undelete a file
 //		Created: 2008-09-12
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteFile::DoCommand(
-	BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolUndeleteFile::DoCommand(
+	BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -608,20 +608,20 @@
 	bool result = rContext.UndeleteFile(mObjectID, mInDirectory);
 
 	// return the object ID or zero for not found
-	return std::auto_ptr<ProtocolObject>(
-		new BackupProtocolServerSuccess(result ? mObjectID : 0));
+	return std::auto_ptr<BackupProtocolMessage>(
+		new BackupProtocolSuccess(result ? mObjectID : 0));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolDeleteDirectory::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Delete a directory
 //		Created: 2003/10/21
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolDeleteDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -648,19 +648,19 @@
 	}
 
 	// return the object ID
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolUndeleteDirectory::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Undelete a directory
 //		Created: 23/11/03
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolUndeleteDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -675,18 +675,18 @@
 	rContext.DeleteDirectory(mObjectID, true /* undelete */);
 
 	// return the object ID
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolSetClientStoreMarker::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Command to set the client's store marker
 //		Created: 2003/10/29
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolSetClientStoreMarker::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -695,19 +695,19 @@
 	rContext.SetClientStoreMarker(mClientStoreMarker);
 
 	// return store marker set
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mClientStoreMarker));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mClientStoreMarker));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolMoveObject::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Command to move an object from one directory to another
 //		Created: 2003/11/12
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolMoveObject::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	CHECK_WRITEABLE_SESSION
@@ -736,19 +736,19 @@
 	}
 
 	// Return the object ID
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolGetObjectName::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Command to find the name of an object
 //		Created: 12/11/03
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObjectName::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 	
@@ -771,7 +771,7 @@
 		// Check the directory really exists
 		if(!rContext.ObjectExists(dirID, BackupStoreContext::ObjectExists_Directory))
 		{
-			return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName(BackupProtocolServerObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0));
+			return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolObjectName(BackupProtocolObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0));
 		}
 
 		// Load up the directory
@@ -786,7 +786,7 @@
 			if(en == 0)
 			{
 				// Abort!
-				return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName(BackupProtocolServerObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0));
+				return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolObjectName(BackupProtocolObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0));
 			}
 			
 			// Store flags?
@@ -826,7 +826,7 @@
 	}
 
 	// Make reply
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName(numNameElements, modTime, attrModHash, objectFlags));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolObjectName(numNameElements, modTime, attrModHash, objectFlags));
 }
 
 
@@ -834,12 +834,12 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolGetBlockIndexByID::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Get the block index from a file, by ID
 //		Created: 19/1/04
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetBlockIndexByID::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
@@ -853,19 +853,19 @@
 	rProtocol.SendStreamAfterCommand(stream.release());
 
 	// Return the object ID
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolGetBlockIndexByName::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Get the block index from a file, by name within a directory
 //		Created: 19/1/04
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetBlockIndexByName::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
@@ -892,7 +892,7 @@
 	if(objectID == 0)
 	{
 		// No... return a zero object ID
-		return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(0));
+		return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(0));
 	}
 
 	// Open the file
@@ -905,19 +905,19 @@
 	rProtocol.SendStreamAfterCommand(stream.release());
 
 	// Return the object ID
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(objectID));
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID));
 }
 
 
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolGetAccountUsage::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Return the amount of disc space used
 //		Created: 19/4/04
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetAccountUsage::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
@@ -929,7 +929,7 @@
 	RaidFileDiscSet &rdiscSet(rcontroller.GetDiscSet(rinfo.GetDiscSetNumber()));
 	
 	// Return info
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerAccountUsage(
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolAccountUsage(
 		rinfo.GetBlocksUsed(),
 		rinfo.GetBlocksInOldFiles(),
 		rinfo.GetBlocksInDeletedFiles(),
@@ -943,17 +943,17 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &, BackupStoreContext &)
+//		Name:    BackupProtocolGetIsAlive::DoCommand(BackupProtocolReplyable &, BackupStoreContext &)
 //		Purpose: Return the amount of disc space used
 //		Created: 19/4/04
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)
+std::auto_ptr<BackupProtocolMessage> BackupProtocolGetIsAlive::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const
 {
 	CHECK_PHASE(Phase_Commands)
 
 	//
 	// NOOP
 	//
-	return std::auto_ptr<ProtocolObject>(new BackupProtocolServerIsAlive());
+	return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolIsAlive());
 }

Modified: box/trunk/lib/backupstore/BackupStoreContext.cpp
===================================================================
--- box/trunk/lib/backupstore/BackupStoreContext.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupstore/BackupStoreContext.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -27,10 +27,9 @@
 #include "RaidFileWrite.h"
 #include "StoreStructure.h"
 
-class BackupStoreDaemon;
-
 #include "MemLeakFindOn.h"
 
+
 // Maximum number of directories to keep in the cache
 // When the cache is bigger than this, everything gets
 // deleted.

Modified: box/trunk/lib/backupstore/BackupStoreContext.h
===================================================================
--- box/trunk/lib/backupstore/BackupStoreContext.h	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupstore/BackupStoreContext.h	2011-08-27 14:06:46 UTC (rev 2983)
@@ -16,15 +16,14 @@
 
 #include "BackupStoreRefCountDatabase.h"
 #include "NamedLock.h"
-#include "ProtocolObject.h"
+#include "Message.h"
 #include "Utils.h"
 
 class BackupStoreDirectory;
 class BackupStoreFilename;
-class BackupStoreDaemon;
 class BackupStoreInfo;
 class IOStream;
-class BackupProtocolObject;
+class BackupProtocolMessage;
 class StreamableMemBlock;
 
 class HousekeepingInterface
@@ -161,21 +160,22 @@
 	class TestHook
 	{
 		public:
-		virtual std::auto_ptr<ProtocolObject> StartCommand(BackupProtocolObject&
-			rCommand) = 0;
+		virtual std::auto_ptr<BackupProtocolMessage>
+			StartCommand(const BackupProtocolMessage& rCommand) = 0;
 		virtual ~TestHook() { }
 	};
 	void SetTestHook(TestHook& rTestHook)
 	{
 		mpTestHook = &rTestHook;
 	}
-	std::auto_ptr<ProtocolObject> StartCommandHook(BackupProtocolObject& rCommand)
+	std::auto_ptr<BackupProtocolMessage>
+		StartCommandHook(const BackupProtocolMessage& rCommand)
 	{
 		if(mpTestHook)
 		{
 			return mpTestHook->StartCommand(rCommand);
 		}
-		return std::auto_ptr<ProtocolObject>();
+		return std::auto_ptr<BackupProtocolMessage>();
 	}
 
 private:

Modified: box/trunk/lib/backupstore/BackupStoreFile.h
===================================================================
--- box/trunk/lib/backupstore/BackupStoreFile.h	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupstore/BackupStoreFile.h	2011-08-27 14:06:46 UTC (rev 2983)
@@ -18,7 +18,6 @@
 #include "BackupStoreFilename.h"
 #include "IOStream.h"
 #include "ReadLoggingStream.h"
-#include "RunStatusProvider.h"
 
 typedef struct 
 {
@@ -27,6 +26,8 @@
 	int64_t mTotalFileStreamSize;
 } BackupStoreFileStats;
 
+class RunStatusProvider;
+
 // Uncomment to disable backwards compatibility
 //#define BOX_DISABLE_BACKWARDS_COMPATIBILITY_BACKUPSTOREFILE
 

Modified: box/trunk/lib/backupstore/Makefile.extra
===================================================================
--- box/trunk/lib/backupstore/Makefile.extra	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupstore/Makefile.extra	2011-08-27 14:06:46 UTC (rev 2983)
@@ -1,16 +1,11 @@
-
 MAKEPROTOCOL = ../../lib/server/makeprotocol.pl
 
-GEN_CMD_CLI = $(MAKEPROTOCOL) Client backupprotocol.txt
-GEN_CMD_SRV = $(MAKEPROTOCOL) Server backupprotocol.txt
+GEN_CMD = $(MAKEPROTOCOL) backupprotocol.txt
 
 # AUTOGEN SEEDING
-autogen_BackupProtocolClient.cpp autogen_BackupProtocolClient.h:	$(MAKEPROTOCOL) backupprotocol.txt
-	$(_PERL) $(GEN_CMD_CLI)
+autogen_BackupProtocol.cpp autogen_BackupProtocol.h:	$(MAKEPROTOCOL) backupprotocol.txt
+	$(_PERL) $(GEN_CMD)
 
-# AUTOGEN SEEDING
-autogen_BackupProtocolServer.cpp autogen_BackupProtocolServer.h:	$(MAKEPROTOCOL) backupprotocol.txt
-	$(_PERL) $(GEN_CMD_SRV)
 
 MAKEEXCEPTION = ../../lib/common/makeexception.pl
 

Modified: box/trunk/lib/backupstore/backupprotocol.txt
===================================================================
--- box/trunk/lib/backupstore/backupprotocol.txt	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/backupstore/backupprotocol.txt	2011-08-27 14:06:46 UTC (rev 2983)
@@ -6,14 +6,13 @@
 IdentString			Box-Backup:v=C
 ServerContextClass	BackupStoreContext	BackupStoreContext.h
 
-ClientType		Filename	BackupStoreFilenameClear	BackupStoreFilenameClear.h
-ServerType		Filename	BackupStoreFilename			BackupStoreFilename.h
+AddType		Filename	BackupStoreFilenameClear	BackupStoreFilenameClear.h
 
 ImplementLog	Server	syslog
 ImplementLog	Client	syslog
 ImplementLog	Client	file
 
-LogTypeToText	Client	Filename	\"%s\"	VAR.GetClearFilename().c_str()
+LogTypeToText	Filename	"%s"	VAR.GetClearFilenameIfPossible("OPAQUE").c_str()
 
 BEGIN_OBJECTS
 

Copied: box/trunk/lib/server/Message.cpp (from rev 2933, box/trunk/lib/server/ProtocolObject.cpp)
===================================================================
--- box/trunk/lib/server/Message.cpp	                        (rev 0)
+++ box/trunk/lib/server/Message.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -0,0 +1,125 @@
+// --------------------------------------------------------------------------
+//
+// File
+//		Name:    Message.h
+//		Purpose: Protocol object base class
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+
+#include "Box.h"
+#include "Message.h"
+#include "CommonException.h"
+
+#include "MemLeakFindOn.h"
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::Message()
+//		Purpose: Default constructor
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+Message::Message()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::Message()
+//		Purpose: Destructor
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+Message::~Message()
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::Message()
+//		Purpose: Copy constructor
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+Message::Message(const Message &rToCopy)
+{
+}
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::IsError(int &, int &)
+//		Purpose: Does this represent an error, and if so, what is the type and subtype?
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+bool Message::IsError(int &rTypeOut, int &rSubTypeOut) const
+{
+	return false;
+}
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::IsConversationEnd()
+//		Purpose: Does this command end the conversation?
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+bool Message::IsConversationEnd() const
+{
+	return false;
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::GetType()
+//		Purpose: Return type of the object
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+int Message::GetType() const
+{
+	// This isn't implemented in the base class!
+	THROW_EXCEPTION(CommonException, Internal)
+}
+
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::SetPropertiesFromStreamData(Protocol &)
+//		Purpose: Set the properties of the object from the stream data ready in the Protocol object
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+void Message::SetPropertiesFromStreamData(Protocol &rProtocol)
+{
+	// This isn't implemented in the base class!
+	THROW_EXCEPTION(CommonException, Internal)
+}
+
+
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Message::WritePropertiesToStreamData(Protocol &)
+//		Purpose: Write the properties of the object into the stream data in the Protocol object
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+void Message::WritePropertiesToStreamData(Protocol &rProtocol) const
+{
+	// This isn't implemented in the base class!
+	THROW_EXCEPTION(CommonException, Internal)
+}
+
+
+

Copied: box/trunk/lib/server/Message.h (from rev 2933, box/trunk/lib/server/ProtocolObject.h)
===================================================================
--- box/trunk/lib/server/Message.h	                        (rev 0)
+++ box/trunk/lib/server/Message.h	2011-08-27 14:06:46 UTC (rev 2983)
@@ -0,0 +1,69 @@
+// --------------------------------------------------------------------------
+//
+// File
+//		Name:    Message.h
+//		Purpose: Protocol object base class
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+
+#ifndef PROTOCOLOBJECT__H
+#define PROTOCOLOBJECT__H
+
+#include <memory>
+
+class Protocol;
+class ProtocolContext;
+
+// --------------------------------------------------------------------------
+//
+// Class
+//		Name:    Message
+//		Purpose: Basic object representation of objects to pass through a Protocol session
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+class Message
+{
+public:
+	Message();
+	virtual ~Message();
+	Message(const Message &rToCopy);
+
+	// Info about this object
+	virtual int GetType() const;
+	virtual bool IsError(int &rTypeOut, int &rSubTypeOut) const;
+	virtual bool IsConversationEnd() const;
+
+	// reading and writing with Protocol objects
+	virtual void SetPropertiesFromStreamData(Protocol &rProtocol);
+	virtual void WritePropertiesToStreamData(Protocol &rProtocol) const;	
+
+	virtual void LogSysLog(const char *Action) const { }
+	virtual void LogFile(const char *Action, FILE *file) const { }
+};
+
+/*
+class Reply;
+
+class Request : public Message
+{
+public:
+	Request() { }
+	virtual ~Request() { }
+	Request(const Request &rToCopy) { }
+	virtual std::auto_ptr<Reply> DoCommand(Protocol &rProtocol, 
+		ProtocolContext &rContext) = 0;
+};
+
+class Reply : public Message
+{
+public:
+	Reply() { }
+	virtual ~Reply() { }
+	Reply(const Reply &rToCopy) { }
+};
+*/
+
+#endif // PROTOCOLOBJECT__H
+

Modified: box/trunk/lib/server/Protocol.cpp
===================================================================
--- box/trunk/lib/server/Protocol.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/server/Protocol.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -11,8 +11,9 @@
 
 #include <sys/types.h>
 
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
+#include <cstdio>
 
 #include <new>
 
@@ -44,17 +45,17 @@
 //
 // --------------------------------------------------------------------------
 Protocol::Protocol(IOStream &rStream)
-	: mrStream(rStream),
-	  mHandshakeDone(false),
-	  mMaxObjectSize(PROTOCOL_DEFAULT_MAXOBJSIZE),
-	  mTimeout(PROTOCOL_DEFAULT_TIMEOUT),
-	  mpBuffer(0),
-	  mBufferSize(0),
-	  mReadOffset(-1),
-	  mWriteOffset(-1),
-	  mValidDataSize(-1),
-	  mLastErrorType(NoError),
-	  mLastErrorSubType(NoError)
+: mrStream(rStream),
+  mHandshakeDone(false),
+  mMaxObjectSize(PROTOCOL_DEFAULT_MAXOBJSIZE),
+  mTimeout(PROTOCOL_DEFAULT_TIMEOUT),
+  mpBuffer(0),
+  mBufferSize(0),
+  mReadOffset(-1),
+  mWriteOffset(-1),
+  mValidDataSize(-1),
+  mLogToSysLog(false),
+  mLogToFile(NULL)  
 {
 	BOX_TRACE("Send block allocation size is " << 
 		PROTOCOL_ALLOCATE_SEND_BLOCK_CHUNK);
@@ -82,34 +83,6 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    Protocol::GetLastError(int &, int &)
-//		Purpose: Returns true if there was an error, and type and subtype if there was.
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-bool Protocol::GetLastError(int &rTypeOut, int &rSubTypeOut)
-{
-	if(mLastErrorType == NoError)
-	{
-		// no error.
-		return false;
-	}
-	
-	// Return type and subtype in args
-	rTypeOut = mLastErrorType;
-	rSubTypeOut = mLastErrorSubType;
-	
-	// and unset them
-	mLastErrorType = NoError;
-	mLastErrorSubType = NoError;
-	
-	return true;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Function
 //		Name:    Protocol::Handshake()
 //		Purpose: Handshake with peer (exchange ident strings)
 //		Created: 2003/08/20
@@ -127,7 +100,7 @@
 	PW_Handshake hsSend;
 	::memset(&hsSend, 0, sizeof(hsSend));
 	// Copy in ident string
-	::strncpy(hsSend.mIdent, GetIdentString(), sizeof(hsSend.mIdent));
+	::strncpy(hsSend.mIdent, GetProtocolIdentString(), sizeof(hsSend.mIdent));
 	
 	// Send it
 	mrStream.Write(&hsSend, sizeof(hsSend));
@@ -200,7 +173,7 @@
 //		Created: 2003/08/19
 //
 // --------------------------------------------------------------------------
-std::auto_ptr<ProtocolObject> Protocol::Receive()
+std::auto_ptr<Message> Protocol::ReceiveInternal()
 {
 	// Get object header
 	PW_ObjectHeader objHeader;
@@ -220,7 +193,7 @@
 	}
 
 	// Create a blank object
-	std::auto_ptr<ProtocolObject> obj(MakeProtocolObject(ntohl(objHeader.mObjType)));
+	std::auto_ptr<Message> obj(MakeMessage(ntohl(objHeader.mObjType)));
 
 	// Make sure memory is allocated to read it into
 	EnsureBufferAllocated(objSize);
@@ -272,7 +245,7 @@
 //		Created: 2003/08/19
 //
 // --------------------------------------------------------------------------
-void Protocol::Send(const ProtocolObject &rObject)
+void Protocol::SendInternal(const Message &rObject)
 {
 	// Check usage
 	if(mValidDataSize != -1 || mWriteOffset != -1 || mReadOffset != -1)
@@ -854,7 +827,26 @@
 // --------------------------------------------------------------------------
 void Protocol::InformStreamReceiving(u_int32_t Size)
 {
-	// Do nothing
+	if(GetLogToSysLog())
+	{
+		if(Size == Protocol::ProtocolStream_SizeUncertain)
+		{
+			BOX_TRACE("Receiving stream, size uncertain");
+		}
+		else
+		{
+			BOX_TRACE("Receiving stream, size " << Size);
+		}
+	}
+
+	if(GetLogToFile())
+	{
+		::fprintf(GetLogToFile(),
+			(Size == Protocol::ProtocolStream_SizeUncertain)
+			? "Receiving stream, size uncertain\n"
+			: "Receiving stream, size %d\n", Size);
+		::fflush(GetLogToFile());
+	}
 }
 
 // --------------------------------------------------------------------------
@@ -867,7 +859,26 @@
 // --------------------------------------------------------------------------
 void Protocol::InformStreamSending(u_int32_t Size)
 {
-	// Do nothing
+	if(GetLogToSysLog())
+	{
+		if(Size == Protocol::ProtocolStream_SizeUncertain)
+		{
+			BOX_TRACE("Sending stream, size uncertain");
+		}
+		else
+		{
+			BOX_TRACE("Sending stream, size " << Size);
+		}
+	}
+	
+	if(GetLogToFile())
+	{
+		::fprintf(GetLogToFile(),
+			(Size == Protocol::ProtocolStream_SizeUncertain)
+			? "Sending stream, size uncertain\n"
+			: "Sending stream, size %d\n", Size);
+		::fflush(GetLogToFile());
+	}
 }
 
 

Modified: box/trunk/lib/server/Protocol.h
===================================================================
--- box/trunk/lib/server/Protocol.h	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/server/Protocol.h	2011-08-27 14:06:46 UTC (rev 2983)
@@ -12,12 +12,14 @@
 
 #include <sys/types.h>
 
-class IOStream;
-#include "ProtocolObject.h"
 #include <memory>
 #include <vector>
 #include <string>
 
+#include "Message.h"
+
+class IOStream;
+
 // default timeout is 15 minutes
 #define PROTOCOL_DEFAULT_TIMEOUT	(15*60*1000)
 // 16 default maximum object size -- should be enough
@@ -40,11 +42,14 @@
 private:
 	Protocol(const Protocol &rToCopy);
 
+protected:
+	// Unsafe to make public, as they may allow sending objects
+	// from a different protocol. The derived class prevents this.
+	std::auto_ptr<Message> ReceiveInternal();
+	void SendInternal(const Message &rObject);
+
 public:
 	void Handshake();
-	std::auto_ptr<ProtocolObject> Receive();
-	void Send(const ProtocolObject &rObject);
-	
 	std::auto_ptr<IOStream> ReceiveStream();
 	void SendStream(IOStream &rStream);
 	
@@ -54,8 +59,6 @@
 		UnknownError = 0
 	};
 
-	bool GetLastError(int &rTypeOut, int &rSubTypeOut);
-
 	// --------------------------------------------------------------------------
 	//
 	// Function
@@ -87,7 +90,7 @@
 	// --------------------------------------------------------------------------	
 	void SetMaxObjectSize(unsigned int NewMaxObjSize) {mMaxObjectSize = NewMaxObjSize;}
 
-	// For ProtocolObject derived classes
+	// For Message derived classes
 	void Read(void *Buffer, int Size);
 	void Read(std::string &rOut, int Size);
 	void Read(int64_t &rOut);
@@ -168,11 +171,15 @@
 	{
 		ProtocolStream_SizeUncertain = 0xffffffff
 	};
+	bool GetLogToSysLog() { return mLogToSysLog; }
+	FILE *GetLogToFile() { return mLogToFile; }
+	void SetLogToSysLog(bool Log = false) {mLogToSysLog = Log;}
+	void SetLogToFile(FILE *File = 0) {mLogToFile = File;}
 
-protected:	
-	virtual std::auto_ptr<ProtocolObject> MakeProtocolObject(int ObjType) = 0;
-	virtual const char *GetIdentString() = 0;
-	void SetError(int Type, int SubType) {mLastErrorType = Type; mLastErrorSubType = SubType;}
+protected:
+	virtual std::auto_ptr<Message> MakeMessage(int ObjType) = 0;
+	virtual const char *GetProtocolIdentString() = 0;
+	
 	void CheckAndReadHdr(void *hdr);	// don't use type here to avoid dependency
 	
 	// Will be used for logging
@@ -183,7 +190,6 @@
 	void EnsureBufferAllocated(int Size);
 	int SendStreamSendBlock(uint8_t *Block, int BytesInBlock);
 
-private:
 	IOStream &mrStream;
 	bool mHandshakeDone;
 	unsigned int mMaxObjectSize;
@@ -193,9 +199,13 @@
 	int mReadOffset;
 	int mWriteOffset;
 	int mValidDataSize;
-	int mLastErrorType;
-	int mLastErrorSubType;
+	bool mLogToSysLog;
+	FILE *mLogToFile;
 };
 
+class ProtocolContext
+{
+};
+
 #endif // PROTOCOL__H
 

Deleted: box/trunk/lib/server/ProtocolObject.cpp
===================================================================
--- box/trunk/lib/server/ProtocolObject.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/server/ProtocolObject.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -1,125 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-//		Name:    ProtocolObject.h
-//		Purpose: Protocol object base class
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-
-#include "Box.h"
-#include "ProtocolObject.h"
-#include "CommonException.h"
-
-#include "MemLeakFindOn.h"
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::ProtocolObject()
-//		Purpose: Default constructor
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-ProtocolObject::ProtocolObject()
-{
-}
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::ProtocolObject()
-//		Purpose: Destructor
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-ProtocolObject::~ProtocolObject()
-{
-}
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::ProtocolObject()
-//		Purpose: Copy constructor
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-ProtocolObject::ProtocolObject(const ProtocolObject &rToCopy)
-{
-}
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::IsError(int &, int &)
-//		Purpose: Does this represent an error, and if so, what is the type and subtype?
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-bool ProtocolObject::IsError(int &rTypeOut, int &rSubTypeOut) const
-{
-	return false;
-}
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::IsConversationEnd()
-//		Purpose: Does this command end the conversation?
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-bool ProtocolObject::IsConversationEnd() const
-{
-	return false;
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::GetType()
-//		Purpose: Return type of the object
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-int ProtocolObject::GetType() const
-{
-	// This isn't implemented in the base class!
-	THROW_EXCEPTION(CommonException, Internal)
-}
-
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::SetPropertiesFromStreamData(Protocol &)
-//		Purpose: Set the properties of the object from the stream data ready in the Protocol object
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-void ProtocolObject::SetPropertiesFromStreamData(Protocol &rProtocol)
-{
-	// This isn't implemented in the base class!
-	THROW_EXCEPTION(CommonException, Internal)
-}
-
-
-
-// --------------------------------------------------------------------------
-//
-// Function
-//		Name:    ProtocolObject::WritePropertiesToStreamData(Protocol &)
-//		Purpose: Write the properties of the object into the stream data in the Protocol object
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-void ProtocolObject::WritePropertiesToStreamData(Protocol &rProtocol) const
-{
-	// This isn't implemented in the base class!
-	THROW_EXCEPTION(CommonException, Internal)
-}
-
-
-

Deleted: box/trunk/lib/server/ProtocolObject.h
===================================================================
--- box/trunk/lib/server/ProtocolObject.h	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/server/ProtocolObject.h	2011-08-27 14:06:46 UTC (rev 2983)
@@ -1,41 +0,0 @@
-// --------------------------------------------------------------------------
-//
-// File
-//		Name:    ProtocolObject.h
-//		Purpose: Protocol object base class
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-
-#ifndef PROTOCOLOBJECT__H
-#define PROTOCOLOBJECT__H
-
-class Protocol;
-
-// --------------------------------------------------------------------------
-//
-// Class
-//		Name:    ProtocolObject
-//		Purpose: Basic object representation of objects to pass through a Protocol session
-//		Created: 2003/08/19
-//
-// --------------------------------------------------------------------------
-class ProtocolObject
-{
-public:
-	ProtocolObject();
-	virtual ~ProtocolObject();
-	ProtocolObject(const ProtocolObject &rToCopy);
-
-	// Info about this object
-	virtual int GetType() const;
-	virtual bool IsError(int &rTypeOut, int &rSubTypeOut) const;
-	virtual bool IsConversationEnd() const;
-
-	// reading and writing with Protocol objects
-	virtual void SetPropertiesFromStreamData(Protocol &rProtocol);
-	virtual void WritePropertiesToStreamData(Protocol &rProtocol) const;	
-};
-
-#endif // PROTOCOLOBJECT__H
-

Modified: box/trunk/lib/server/makeprotocol.pl.in
===================================================================
--- box/trunk/lib/server/makeprotocol.pl.in	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/lib/server/makeprotocol.pl.in	2011-08-27 14:06:46 UTC (rev 2983)
@@ -30,24 +30,19 @@
 	'string' => ['%s', 'VAR.c_str()']
 );
 
-
-
-my ($type, $file) = @ARGV;
-
-if($type ne 'Server' && $type ne 'Client')
+if (@ARGV != 1)
 {
-	die "Neither Server or Client is specified on command line\n";
+	die "Usage: $0 <protocol-txt-file>\n";
 }
 
+my ($file) = @ARGV;
+
 open IN, $file or die "Can't open input file $file\n";
 
-print "Making $type protocol classes from $file...\n";
+print "Making protocol classes from $file...\n";
 
 my @extra_header_files;
 
-my $implement_syslog = 0;
-my $implement_filelog = 0;
-
 # read attributes
 my %attr;
 while(<IN>)
@@ -59,41 +54,18 @@
 	
 	my ($k,$v) = split /\s+/,$l,2;
 	
-	if($k eq 'ClientType')
+	if($k eq 'AddType')
 	{
-		add_type($v) if $type eq 'Client';
+		add_type($v);
 	}
-	elsif($k eq 'ServerType')
-	{
-		add_type($v) if $type eq 'Server';
-	}
 	elsif($k eq 'ImplementLog')
 	{
-		my ($log_if_type,$log_type) = split /\s+/,$v;
-		if($type eq $log_if_type)
-		{
-			if($log_type eq 'syslog')
-			{
-				$implement_syslog = 1;
-			}
-			elsif($log_type eq 'file')
-			{
-				$implement_filelog = 1;
-			}
-			else
-			{
-				printf("ERROR: Unknown log type for implementation: $log_type\n");
-				exit(1);
-			}
-		}
+		# Always implement logging
 	}
 	elsif($k eq 'LogTypeToText')
 	{
-		my ($log_if_type,$type_name,$printf_format,$arg_template) = split /\s+/,$v;
-		if($type eq $log_if_type)
-		{
-			$log_display_types{$type_name} = [$printf_format,$arg_template]
-		}
+		my ($type_name,$printf_format,$arg_template) = split /\s+/,$v;
+		$log_display_types{$type_name} = [$printf_format,$arg_template]
 	}
 	else
 	{
@@ -169,10 +141,12 @@
 
 
 # open files
-my $h_filename = 'autogen_'.$protocol_name.'Protocol'.$type.'.h';
-open CPP,'>autogen_'.$protocol_name.'Protocol'.$type.'.cpp';
+my $h_filename = 'autogen_'.$protocol_name.'Protocol.h';
+open CPP,'>autogen_'.$protocol_name.'Protocol.cpp';
 open H,">$h_filename";
 
+my $guardname = uc 'AUTOGEN_'.$protocol_name.'Protocol_H';
+
 print CPP <<__E;
 
 // Auto-generated file -- do not edit
@@ -183,149 +157,125 @@
 
 #include "$h_filename"
 #include "IOStream.h"
-
 __E
 
-if($implement_syslog)
-{
-	print H <<EOF;
-#ifndef WIN32
-#include <syslog.h>
-#endif
-EOF
-}
-
-
-my $guardname = uc 'AUTOGEN_'.$protocol_name.'Protocol'.$type.'_H';
 print H <<__E;
-
 // Auto-generated file -- do not edit
 
 #ifndef $guardname
 #define $guardname
 
+#include <cstdio>
+#include <list>
+
+#ifndef WIN32
+#include <syslog.h>
+#endif
+
 #include "Protocol.h"
-#include "ProtocolObject.h"
+#include "Message.h"
 #include "ServerException.h"
 
 class IOStream;
 
+
 __E
 
-if($implement_filelog)
-{
-	print H qq~#include <stdio.h>\n~;
-}
-
 # extra headers
 for(@extra_header_files)
 {
-	print H qq~#include "$_"\n~
+	print H qq@#include "$_"\n@;
 }
-print H "\n";
 
-if($type eq 'Server')
-{
-	# need utils file for the server
-	print H '#include "Utils.h"',"\n\n"
-}
+print H <<__E;
 
+// need utils file for the server
+#include "Utils.h"
 
-my $derive_objects_from = 'ProtocolObject';
+__E
+
+my $message_base_class = "${protocol_name}ProtocolMessage";
 my $objects_extra_h = '';
 my $objects_extra_cpp = '';
-if($type eq 'Server')
-{
-	# define the context
-	print H "class $context_class;\n\n";
-	print CPP "#include \"$context_class_inc\"\n\n";
-	
-	# change class we derive the objects from
-	$derive_objects_from = $protocol_name.'ProtocolObject';
-	
-	$objects_extra_h = <<__E;
-	virtual std::auto_ptr<ProtocolObject> DoCommand(${protocol_name}ProtocolServer &rProtocol, $context_class &rContext);
+
+# define the context
+print H "class $context_class;\n\n";
+print CPP <<__E;
+#include "$context_class_inc"
+#include "MemLeakFindOn.h"
 __E
-	$objects_extra_cpp = <<__E;
-std::auto_ptr<ProtocolObject> ${derive_objects_from}::DoCommand(${protocol_name}ProtocolServer &rProtocol, $context_class &rContext)
-{
-	THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand)
-}
-__E
-}
 
-print CPP qq~#include "MemLeakFindOn.h"\n~;
+my $request_base_class = "${protocol_name}ProtocolRequest";
+my $reply_base_class   = "${protocol_name}ProtocolReply";
+# the abstract protocol interface
+my $protocol_base_class = $protocol_name."ProtocolBase";
+my $replyable_base_class = $protocol_name."ProtocolReplyable";
 
-if($type eq 'Client' && ($implement_syslog || $implement_filelog))
+print H <<__E;
+class $protocol_base_class;
+class $replyable_base_class;
+class $reply_base_class;
+
+class $message_base_class : public Message
 {
-	# change class we derive the objects from
-	$derive_objects_from = $protocol_name.'ProtocolObjectCl';
-}
-if($implement_syslog)
+public:
+	virtual std::auto_ptr<$message_base_class> DoCommand($replyable_base_class &rProtocol,
+		$context_class &rContext) const;
+};
+
+class $reply_base_class
 {
-	$objects_extra_h .= <<__E;
-	virtual void LogSysLog(const char *Action) const = 0;
-__E
-}
-if($implement_filelog)
-{
-	$objects_extra_h .= <<__E;
-	virtual void LogFile(const char *Action, FILE *file) const = 0;
-__E
-}
+};
 
-if($derive_objects_from ne 'ProtocolObject')
-{	
-	# output a definition for the protocol object derived class
-	print H <<__E;
-class ${protocol_name}ProtocolServer;
-	
-class $derive_objects_from : public ProtocolObject
+class $request_base_class
 {
-public:
-	$derive_objects_from();
-	virtual ~$derive_objects_from();
-	$derive_objects_from(const $derive_objects_from &rToCopy);
-	
-$objects_extra_h
 };
+
 __E
 
-	# and some cpp definitions
-	print CPP <<__E;
-${derive_objects_from}::${derive_objects_from}()
+print CPP <<__E;
+std::auto_ptr<$message_base_class> $message_base_class\::DoCommand($replyable_base_class &rProtocol,
+	$context_class &rContext) const
 {
+	THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand)
 }
-${derive_objects_from}::~${derive_objects_from}()
-{
-}
-${derive_objects_from}::${derive_objects_from}(const $derive_objects_from &rToCopy)
-{
-}
-$objects_extra_cpp
 __E
-}
 
+my %cmd_class;
 
-
-my $classname_base = $protocol_name.'Protocol'.$type;
-
 # output the classes
-for my $cmd (@cmd_list)
+foreach my $cmd (@cmd_list)
 {
+	my @cmd_base_classes = ($message_base_class);
+	
+	if(obj_is_type($cmd, 'Command'))
+	{
+		push @cmd_base_classes, $request_base_class;
+	}
+	
+	if(obj_is_type($cmd, 'Reply'))
+	{
+		push @cmd_base_classes, $reply_base_class;
+	}
+	
+	my $cmd_base_class = join(", ", map {"public $_"} @cmd_base_classes);
+	my $cmd_class = $protocol_name."ProtocolClient".$cmd;
+	$cmd_class{$cmd} = $cmd_class;
+	
 	print H <<__E;
-class $classname_base$cmd : public $derive_objects_from
+class $cmd_class : $cmd_base_class
 {
 public:
-	$classname_base$cmd();
-	$classname_base$cmd(const $classname_base$cmd &rToCopy);
-	~$classname_base$cmd();
+	$cmd_class();
+	$cmd_class(const $cmd_class &rToCopy);
+	~$cmd_class();
 	int GetType() const;
 	enum
 	{
 		TypeID = $cmd_id{$cmd}
 	};
 __E
+
 	# constants
 	if(exists $cmd_constants{$cmd})
 	{
@@ -333,73 +283,64 @@
 		print H join(",\n\t\t",@{$cmd_constants{$cmd}});
 		print H "\n\t};\n";
 	}
+	
 	# flags
 	if(obj_is_type($cmd,'EndsConversation'))
 	{
 		print H "\tbool IsConversationEnd() const;\n";
 	}
+	
 	if(obj_is_type($cmd,'IsError'))
 	{
 		print H "\tbool IsError(int &rTypeOut, int &rSubTypeOut) const;\n";
 		print H "\tstd::string GetMessage() const;\n";
 	}
-	if($type eq 'Server' && obj_is_type($cmd, 'Command'))
+	
+	if(obj_is_type($cmd, 'Command'))
 	{
-		print H "\tstd::auto_ptr<ProtocolObject> DoCommand(${protocol_name}ProtocolServer &rProtocol, $context_class &rContext); // IMPLEMENT THIS\n"
+		print H <<__E;
+	std::auto_ptr<$message_base_class> DoCommand($replyable_base_class &rProtocol, 
+		$context_class &rContext) const; // IMPLEMENT THIS\n
+__E
 	}
 
 	# want to be able to read from streams?
-	my $read_from_streams = (obj_is_type($cmd,'Command') && $type eq 'Server') || (obj_is_type($cmd,'Reply') && $type eq 'Client');
-	my $write_to_streams = (obj_is_type($cmd,'Command') && $type eq 'Client') || (obj_is_type($cmd,'Reply') && $type eq 'Server');
+	print H "\tvoid SetPropertiesFromStreamData(Protocol &rProtocol);\n";
 	
-	if($read_from_streams)
+	# write Get functions
+	for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
 	{
-		print H "\tvoid SetPropertiesFromStreamData(Protocol &rProtocol);\n";
+		my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
 		
-		# write Get functions
-		for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
-		{
-			my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-			
-			print H "\t".translate_type_to_arg_type($ty)." Get$nm() {return m$nm;}\n";
-		}
+		print H "\t".translate_type_to_arg_type($ty)." Get$nm() {return m$nm;}\n";
 	}
+
 	my $param_con_args = '';
-	if($write_to_streams)
+	# extra constructor?
+	if($#{$cmd_contents{$cmd}} >= 0)
 	{
-		# extra constructor?
-		if($#{$cmd_contents{$cmd}} >= 0)
-		{
-			my @a;
-			for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
-			{
-				my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-
-				push @a,translate_type_to_arg_type($ty)." $nm";
-			}		
-			$param_con_args = join(', ', at a);
-			print H "\t$classname_base$cmd(".$param_con_args.");\n";
-		}
-		print H "\tvoid WritePropertiesToStreamData(Protocol &rProtocol) const;\n";
-		# set functions
+		my @a;
 		for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
 		{
 			my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-			
-			print H "\tvoid Set$nm(".translate_type_to_arg_type($ty)." $nm) {m$nm = $nm;}\n";
-		}
+
+			push @a,translate_type_to_arg_type($ty)." $nm";
+		}		
+		$param_con_args = join(', ', at a);
+		print H "\t$cmd_class(".$param_con_args.");\n";
 	}
-	
-	if($implement_syslog)
+	print H "\tvoid WritePropertiesToStreamData(Protocol &rProtocol) const;\n";
+	# set functions
+	for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
 	{
-		print H "\tvirtual void LogSysLog(const char *Action) const;\n";
+		my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
+		
+		print H "\tvoid Set$nm(".translate_type_to_arg_type($ty)." $nm) {m$nm = $nm;}\n";
 	}
-	if($implement_filelog)
-	{
-		print H "\tvirtual void LogFile(const char *Action, FILE *file) const;\n";
-	}
-
 	
+	print H "\tvirtual void LogSysLog(const char *Action) const;\n";
+	print H "\tvirtual void LogFile(const char *Action, FILE *file) const;\n";
+	
 	# write member variables and setup for cpp file
 	my @def_constructor_list;
 	my @copy_constructor_list;
@@ -432,77 +373,73 @@
 	my $param_con_vars = join(",\n\t  ", at param_constructor_list);
 	$param_con_vars = "\n\t: ".$param_con_vars if $param_con_vars ne '';
 
-	my $class = "$classname_base$cmd".'::';
 	print CPP <<__E;
-$class$classname_base$cmd()$def_con_vars
+$cmd_class\::$cmd_class()$def_con_vars
 {
 }
-$class$classname_base$cmd(const $classname_base$cmd &rToCopy)$copy_con_vars
+$cmd_class\::$cmd_class(const $cmd_class &rToCopy)$copy_con_vars
 {
 }
-$class~$classname_base$cmd()
+$cmd_class\::~$cmd_class()
 {
 }
-int ${class}GetType() const
+int $cmd_class\::GetType() const
 {
 	return $cmd_id{$cmd};
 }
 __E
-	if($read_from_streams)
+	print CPP "void $cmd_class\::SetPropertiesFromStreamData(Protocol &rProtocol)\n{\n";
+	for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
 	{
-		print CPP "void ${class}SetPropertiesFromStreamData(Protocol &rProtocol)\n{\n";
-		for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
+		my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
+		if($ty =~ m/\Avector/)
 		{
-			my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-			if($ty =~ m/\Avector/)
-			{
-				print CPP "\trProtocol.ReadVector(m$nm);\n";
-			}
-			else
-			{
-				print CPP "\trProtocol.Read(m$nm);\n";
-			}
+			print CPP "\trProtocol.ReadVector(m$nm);\n";
 		}
-		print CPP "}\n";
+		else
+		{
+			print CPP "\trProtocol.Read(m$nm);\n";
+		}
 	}
-	if($write_to_streams)
+	print CPP "}\n";
+
+	# implement extra constructor?
+	if($param_con_vars ne '')
 	{
-		# implement extra constructor?
-		if($param_con_vars ne '')
+		print CPP "$cmd_class\::$cmd_class($param_con_args)$param_con_vars\n{\n}\n";
+	}
+	print CPP "void $cmd_class\::WritePropertiesToStreamData(Protocol &rProtocol) const\n{\n";
+	for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
+	{
+		my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
+		if($ty =~ m/\Avector/)
 		{
-			print CPP "$class$classname_base$cmd($param_con_args)$param_con_vars\n{\n}\n";
+			print CPP "\trProtocol.WriteVector(m$nm);\n";
 		}
-		print CPP "void ${class}WritePropertiesToStreamData(Protocol &rProtocol) const\n{\n";
-		for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
+		else
 		{
-			my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-			if($ty =~ m/\Avector/)
-			{
-				print CPP "\trProtocol.WriteVector(m$nm);\n";
-			}
-			else
-			{
-				print CPP "\trProtocol.Write(m$nm);\n";
-			}
+			print CPP "\trProtocol.Write(m$nm);\n";
 		}
-		print CPP "}\n";
 	}
+	print CPP "}\n";
+
 	if(obj_is_type($cmd,'EndsConversation'))
 	{
-		print CPP "bool ${class}IsConversationEnd() const\n{\n\treturn true;\n}\n";
+		print CPP "bool $cmd_class\::IsConversationEnd() const\n{\n\treturn true;\n}\n";
 	}
+	
 	if(obj_is_type($cmd,'IsError'))
 	{
 		# get parameters
 		my ($mem_type,$mem_subtype) = split /,/,obj_get_type_params($cmd,'IsError');
 		print CPP <<__E;
-bool ${class}IsError(int &rTypeOut, int &rSubTypeOut) const
+bool $cmd_class\::IsError(int &rTypeOut, int &rSubTypeOut) const
 {
 	rTypeOut = m$mem_type;
 	rSubTypeOut = m$mem_subtype;
 	return true;
 }
-std::string ${class}GetMessage() const
+std::string $cmd_class\::GetMessage() const
 {
 	switch(m$mem_subtype)
 	{
@@ -526,21 +463,13 @@
 __E
 	}
 
-	if($implement_syslog)
-	{
-		my ($log) = make_log_strings_framework($cmd);
-		print CPP <<__E;
-void ${class}LogSysLog(const char *Action) const
+	my ($log) = make_log_strings_framework($cmd);
+	print CPP <<__E;
+void $cmd_class\::LogSysLog(const char *Action) const
 {
 	BOX_TRACE($log);
 }
-__E
-	}
-	if($implement_filelog)
-	{
-		my ($log) = make_log_strings_framework($cmd);
-		print CPP <<__E;
-void ${class}LogFile(const char *Action, FILE *File) const
+void $cmd_class\::LogFile(const char *Action, FILE *File) const
 {
 	std::ostringstream oss;
 	oss << $log;
@@ -548,209 +477,477 @@
 	::fflush(File);
 }
 __E
-	}
 }
 
-# finally, the protocol object itself
+my $error_class = $protocol_name."ProtocolError";
+
+# the abstract protocol interface
 print H <<__E;
-class $classname_base : public Protocol
+class $protocol_base_class
 {
 public:
-	$classname_base(IOStream &rStream);
-	virtual ~$classname_base();
+	$protocol_base_class();
+	virtual ~$protocol_base_class();
+	virtual const char *GetIdentString();
+	bool GetLastError(int &rTypeOut, int &rSubTypeOut);
 
-	std::auto_ptr<$derive_objects_from> Receive();
-	void Send(const ${derive_objects_from} &rObject);
+protected:
+	void CheckReply(const std::string& requestCommand,
+		const $message_base_class &rReply, int expectedType);
+	void SetLastError(int Type, int SubType)
+	{
+		mLastErrorType = Type;
+		mLastErrorSubType = SubType;
+	}
+
+private:
+	$protocol_base_class(const $protocol_base_class &rToCopy); /* do not call */
+	int mLastErrorType;
+	int mLastErrorSubType;
+};
+
+class $replyable_base_class : public virtual $protocol_base_class
+{
+public:
+	$replyable_base_class();
+	virtual ~$replyable_base_class();
+
+	/*
+	virtual std::auto_ptr<$message_base_class> Receive() = 0;
+	virtual void Send(const ${message_base_class} &rObject) = 0;
+	*/
+
+	virtual std::auto_ptr<IOStream> ReceiveStream() = 0;
+	virtual int GetTimeout() = 0;
+	void SendStreamAfterCommand(IOStream *pStream);
+	
+protected:
+	std::list<IOStream*> mStreamsToSend;
+	void DeleteStreamsToSend();
+
+private:
+	$replyable_base_class(const $replyable_base_class &rToCopy); /* do not call */
+};
+
 __E
-if($implement_syslog)
+
+print CPP <<__E;
+$protocol_base_class\::$protocol_base_class()
+: mLastErrorType(Protocol::NoError),
+  mLastErrorSubType(Protocol::NoError)
+{ }
+
+$protocol_base_class\::~$protocol_base_class()
+{ }
+
+const char *$protocol_base_class\::GetIdentString()
 {
-	print H "\tvoid SetLogToSysLog(bool Log = false) {mLogToSysLog = Log;}\n";
+	return "$ident_string";
 }
-if($implement_filelog)
+
+$replyable_base_class\::$replyable_base_class()
+{ }
+
+$replyable_base_class\::~$replyable_base_class()
+{ }
+
+void $replyable_base_class\::SendStreamAfterCommand(IOStream *pStream)
 {
-	print H "\tvoid SetLogToFile(FILE *File = 0) {mLogToFile = File;}\n";
+	ASSERT(pStream != NULL);
+	mStreamsToSend.push_back(pStream);
 }
-if($type eq 'Server')
+
+void $replyable_base_class\::DeleteStreamsToSend()
 {
-	# need to put in the conversation function
-	print H "\tvoid DoServer($context_class &rContext);\n\n";
-	# and the send vector thing
-	print H "\tvoid SendStreamAfterCommand(IOStream *pStream);\n\n";
+	for(std::list<IOStream*>::iterator i(mStreamsToSend.begin()); i != mStreamsToSend.end(); ++i)
+	{
+		delete (*i);
+	}
+	mStreamsToSend.clear();
 }
-if($type eq 'Client')
+
+void $protocol_base_class\::CheckReply(const std::string& requestCommand,
+	const $message_base_class &rReply, int expectedType)
 {
-	# add plain object taking query functions
-	my $with_params;
-	for my $cmd (@cmd_list)
+	if(rReply.GetType() == expectedType)
 	{
-		if(obj_is_type($cmd,'Command'))
+		// Correct response, do nothing
+	}
+	else
+	{
+		// Set protocol error
+		int type, subType;
+		
+		if(rReply.IsError(type, subType))
 		{
-			my $has_stream = obj_is_type($cmd,'StreamWithCommand');
-			my $argextra = $has_stream?', IOStream &rStream':'';
-			my $queryextra = $has_stream?', rStream':'';
-			my $reply = obj_get_type_params($cmd,'Command');
-			print H "\tstd::auto_ptr<$classname_base$reply> Query(const $classname_base$cmd &rQuery$argextra);\n";
-			my @a;
-			my @na;
-			for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
-			{
-				my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-				push @a,translate_type_to_arg_type($ty)." $nm";
-				push @na,"$nm";
-			}
-			my $ar = join(', ', at a);
-			my $nar = join(', ', at na);
-			$nar = "($nar)" if $nar ne '';
-
-			$with_params .= "\tinline std::auto_ptr<$classname_base$reply> Query$cmd($ar$argextra)\n\t{\n";
-			$with_params .= "\t\t$classname_base$cmd send$nar;\n";
-			$with_params .= "\t\treturn Query(send$queryextra);\n";
-			$with_params .= "\t}\n";
+			SetLastError(type, subType);
+			BOX_WARNING(requestCommand << " command failed: "
+				"received error " <<
+				(($error_class&)rReply).GetMessage());
 		}
+		else
+		{
+			SetLastError(Protocol::UnknownError, Protocol::UnknownError);
+			BOX_WARNING(requestCommand << " command failed: "
+				"received unexpected response type " <<
+				rReply.GetType());
+		}
+		
+		// Throw an exception
+		THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnexpectedReply)
 	}
-	# quick hack to correct bad argument lists for commands with zero paramters but with streams
-	$with_params =~ s/\(, /(/g;
-	print H "\n",$with_params,"\n";
 }
-print H <<__E;
-private:
-	$classname_base(const $classname_base &rToCopy);
-__E
-if($type eq 'Server')
+
+// --------------------------------------------------------------------------
+//
+// Function
+//		Name:    Protocol::GetLastError(int &, int &)
+//		Purpose: Returns true if there was an error, and type and subtype if there was.
+//		Created: 2003/08/19
+//
+// --------------------------------------------------------------------------
+bool $protocol_base_class\::GetLastError(int &rTypeOut, int &rSubTypeOut)
 {
-	# need to put the streams to send vector
-	print H "\tstd::vector<IOStream*> mStreamsToSend;\n\tvoid DeleteStreamsToSend();\n";
+	if(mLastErrorType == Protocol::NoError)
+	{
+		// no error.
+		return false;
+	}
+	
+	// Return type and subtype in args
+	rTypeOut = mLastErrorType;
+	rSubTypeOut = mLastErrorSubType;
+	
+	// and unset them
+	mLastErrorType = Protocol::NoError;
+	mLastErrorSubType = Protocol::NoError;
+	
+	return true;
 }
 
-if($implement_filelog || $implement_syslog)
+__E
+
+# the callable protocol interface (implemented by Client and Local classes)
+# with Query methods that don't take a context parameter
+my $callable_base_class = $protocol_name."ProtocolCallable";
+print H <<__E;
+class $callable_base_class : public virtual $protocol_base_class
 {
-	print H <<__E;
-	virtual void InformStreamReceiving(u_int32_t Size);
-	virtual void InformStreamSending(u_int32_t Size);
+public:
+	virtual std::auto_ptr<IOStream> ReceiveStream() = 0;
+	virtual int GetTimeout() = 0;
 __E
-}
 
-if($implement_syslog)
+# add plain object taking query functions
+my $with_params;
+for my $cmd (@cmd_list)
 {
-	print H "private:\n\tbool mLogToSysLog;\n";
+	if(obj_is_type($cmd,'Command'))
+	{
+		my $has_stream = obj_is_type($cmd,'StreamWithCommand');
+		my $argextra = $has_stream?', IOStream &rStream':'';
+		my $queryextra = $has_stream?', rStream':'';
+		my $request_class = $cmd_class{$cmd};
+		my $reply_class = $cmd_class{obj_get_type_params($cmd,'Command')};
+		
+		print H "\tvirtual std::auto_ptr<$reply_class> Query(const $request_class &rQuery$argextra) = 0;\n";
+		my @a;
+		my @na;
+		for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
+		{
+			my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
+			push @a,translate_type_to_arg_type($ty)." $nm";
+			push @na,"$nm";
+		}
+		my $ar = join(', ', at a);
+		my $nar = join(', ', at na);
+		$nar = "($nar)" if $nar ne '';
+
+		$with_params .= <<__E;
+	inline std::auto_ptr<$reply_class> Query$cmd($ar$argextra)
+	{
+		$request_class send$nar;
+		return Query(send$queryextra);
+	}
+__E
+	}
 }
-if($implement_filelog)
-{
-	print H "private:\n\tFILE *mLogToFile;\n";
-}
+
+# quick hack to correct bad argument lists for commands with zero parameters but with streams
+$with_params =~ s/\(, /(/g;
+
 print H <<__E;
 
-protected:	
-	virtual std::auto_ptr<ProtocolObject> MakeProtocolObject(int ObjType);
-	virtual const char *GetIdentString();
+$with_params
 };
+__E
 
+# standard remote protocol objects
+foreach my $type ('Client', 'Server', 'Local')
+{
+	my $writing_client = ($type eq 'Client');
+	my $writing_server = ($type eq 'Server');
+	my $writing_local  = ($type eq 'Local');
+			
+	my $server_or_client_class = $protocol_name."Protocol".$type;
+	my @base_classes;
+
+	if (not $writing_client)
+	{
+		push @base_classes, $replyable_base_class;
+	}
+	if (not $writing_server)
+	{
+		push @base_classes, $callable_base_class;
+	}
+	if (not $writing_local)
+	{
+		push @base_classes, "Protocol";
+	}
+
+	my $base_classes_str = join(", ", map {"public $_"} @base_classes);
+
+	print H <<__E;
+class $server_or_client_class : $base_classes_str
+{
+public:
 __E
 
-my $constructor_extra = '';
-$constructor_extra .= ', mLogToSysLog(false)' if $implement_syslog;
-$constructor_extra .= ', mLogToFile(0)' if $implement_filelog;
+	if($writing_local)
+	{
+		print H <<__E;
+	$server_or_client_class($context_class &rContext);
+__E
+	}
+	else
+	{
+		print H <<__E;
+	$server_or_client_class(IOStream &rStream);
+	std::auto_ptr<$message_base_class> Receive();
+	void Send(const $message_base_class &rObject);
+__E
+	}
+	
+	print H <<__E;
+	virtual ~$server_or_client_class();
+__E
 
-my $destructor_extra = ($type eq 'Server')?"\n\tDeleteStreamsToSend();":'';
+	if($writing_server)
+	{
+		# need to put in the conversation function
+		print H <<__E;	
+	void DoServer($context_class &rContext);
 
-my $prefix = $classname_base.'::';
-print CPP <<__E;
-$prefix$classname_base(IOStream &rStream)
-	: Protocol(rStream)$constructor_extra
-{
-}
-$prefix~$classname_base()
+__E
+	}
+
+	if($writing_client or $writing_local)
+	{
+		# add plain object taking query functions
+		for my $cmd (@cmd_list)
+		{
+			if(obj_is_type($cmd,'Command'))
+			{
+				my $has_stream = obj_is_type($cmd,'StreamWithCommand');
+				my $argextra = $has_stream?', IOStream &rStream':'';
+				my $queryextra = $has_stream?', rStream':'';
+				my $request_class = $cmd_class{$cmd};
+				my $reply_class = $cmd_class{obj_get_type_params($cmd,'Command')};
+				print H "\tstd::auto_ptr<$reply_class> Query(const $request_class &rQuery$argextra);\n";
+			}
+		}
+	}
+	
+	if($writing_local)
+	{
+		print H <<__E;
+private:
+	$context_class &mrContext;
+__E
+	}
+	
+	print H <<__E;
+
+protected:
+	virtual std::auto_ptr<Message> MakeMessage(int ObjType);
+
+__E
+
+	if($writing_local)
+	{
+		print H <<__E;
+	virtual void InformStreamReceiving(u_int32_t Size) { }
+	virtual void InformStreamSending(u_int32_t Size) { }
+
+public:
+	virtual std::auto_ptr<IOStream> ReceiveStream()
+	{
+		std::auto_ptr<IOStream> apStream(mStreamsToSend.front());
+		mStreamsToSend.pop_front();
+		return apStream;
+	}
+__E
+	}
+	else
+	{
+		print H <<__E;
+	virtual void InformStreamReceiving(u_int32_t Size)
+	{
+		this->Protocol::InformStreamReceiving(Size);
+	}
+	virtual void InformStreamSending(u_int32_t Size)
+	{
+		this->Protocol::InformStreamSending(Size);
+	}
+
+public:
+	virtual std::auto_ptr<IOStream> ReceiveStream()
+	{
+		return this->Protocol::ReceiveStream();
+	}
+__E
+	}
+
+	print H <<__E;
+	virtual const char *GetProtocolIdentString()
+	{
+		return GetIdentString();
+	}
+__E
+
+	if($writing_local)
+	{
+		print H <<__E;
+	virtual int GetTimeout()
+	{
+		return IOStream::TimeOutInfinite;
+	}
+__E
+	}
+	else
+	{
+		print H <<__E;
+	virtual int GetTimeout()
+	{
+		return this->Protocol::GetTimeout();
+	}
+__E
+	}	
+	
+	print H <<__E;
+	/*
+	virtual void Handshake()
+	{
+		this->Protocol::Handshake();
+	}
+	virtual bool GetLastError(int &rTypeOut, int &rSubTypeOut)
+	{
+		return this->Protocol::GetLastError(rTypeOut, rSubTypeOut);
+	}
+	*/
+	
+private:
+	$server_or_client_class(const $server_or_client_class &rToCopy); /* no copies */
+};
+
+__E
+
+	my $destructor_extra = ($writing_server) ? "\n\tDeleteStreamsToSend();"
+		: '';
+
+	if($writing_local)
+	{
+		print CPP <<__E;
+$server_or_client_class\::$server_or_client_class($context_class &rContext)
+: mrContext(rContext)
+{ }
+__E
+	}
+	else
+	{
+		print CPP <<__E;
+$server_or_client_class\::$server_or_client_class(IOStream &rStream)
+: Protocol(rStream)
+{ }
+__E
+	}
+	
+	print CPP <<__E;
+$server_or_client_class\::~$server_or_client_class()
 {$destructor_extra
 }
-const char *${prefix}GetIdentString()
+__E
+
+	# write receive and send functions
+	print CPP <<__E;
+std::auto_ptr<Message> $server_or_client_class\::MakeMessage(int ObjType)
 {
-	return "$ident_string";
-}
-std::auto_ptr<ProtocolObject> ${prefix}MakeProtocolObject(int ObjType)
-{
 	switch(ObjType)
 	{
 __E
 
-# do objects within this
-for my $cmd (@cmd_list)
-{
-	print CPP <<__E;
+	# do objects within this
+	for my $cmd (@cmd_list)
+	{
+		print CPP <<__E;
 	case $cmd_id{$cmd}:
-		return std::auto_ptr<ProtocolObject>(new $classname_base$cmd);
+		return std::auto_ptr<Message>(new $cmd_class{$cmd}());
 		break;
 __E
-}
+	}
 
-print CPP <<__E;
+	print CPP <<__E;
 	default:
 		THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnknownCommandRecieved)
 	}
 }
 __E
-# write receive and send functions
-print CPP <<__E;
-std::auto_ptr<$derive_objects_from> ${prefix}Receive()
-{
-	std::auto_ptr<${derive_objects_from}> preply((${derive_objects_from}*)(Protocol::Receive().release()));
 
-__E
-	if($implement_syslog)
+	if(not $writing_local)
 	{
 		print CPP <<__E;
-	if(mLogToSysLog)
+std::auto_ptr<$message_base_class> $server_or_client_class\::Receive()
+{
+	std::auto_ptr<$message_base_class> preply(($message_base_class *)
+		Protocol::ReceiveInternal().release());
+
+	if(GetLogToSysLog())
 	{
 		preply->LogSysLog("Receive");
 	}
-__E
-	}
-	if($implement_filelog)
+
+	if(GetLogToFile() != 0)
 	{
-		print CPP <<__E;
-	if(mLogToFile != 0)
-	{
-		preply->LogFile("Receive", mLogToFile);
+		preply->LogFile("Receive", GetLogToFile());
 	}
-__E
-	}
-print CPP <<__E;
 
 	return preply;
 }
 
-void ${prefix}Send(const ${derive_objects_from} &rObject)
+void $server_or_client_class\::Send(const $message_base_class &rObject)
 {
-__E
-	if($implement_syslog)
+	if(GetLogToSysLog())
 	{
-		print CPP <<__E;
-	if(mLogToSysLog)
-	{
 		rObject.LogSysLog("Send");
 	}
-__E
-	}
-	if($implement_filelog)
+
+	if(GetLogToFile() != 0)
 	{
-		print CPP <<__E;
-	if(mLogToFile != 0)
-	{
-		rObject.LogFile("Send", mLogToFile);
+		rObject.LogFile("Send", GetLogToFile());
 	}
-__E
-	}
 
-print CPP <<__E;
-	Protocol::Send(rObject);
+	Protocol::SendInternal(rObject);
 }
 
 __E
-# write server function?
-if($type eq 'Server')
+	}
+	
+	# write server function?
+	if($writing_server)
+	{
+		print CPP <<__E;
+void $server_or_client_class\::DoServer($context_class &rContext)
 {
-	print CPP <<__E;
-void ${prefix}DoServer($context_class &rContext)
-{
 	// Handshake with client
 	Handshake();
 
@@ -759,20 +956,22 @@
 	while(inProgress)
 	{
 		// Get an object from the conversation
-		std::auto_ptr<${derive_objects_from}> pobj(Receive());
+		std::auto_ptr<$message_base_class> pobj = Receive();
 
 		// Run the command
-		std::auto_ptr<${derive_objects_from}> preply((${derive_objects_from}*)(pobj->DoCommand(*this, rContext).release()));
+		std::auto_ptr<$message_base_class> preply = pobj->DoCommand(*this, rContext);
 		
 		// Send the reply
-		Send(*(preply.get()));
+		Send(*preply);
 
 		// Send any streams
-		for(unsigned int s = 0; s < mStreamsToSend.size(); s++)
+		for(std::list<IOStream*>::iterator
+			i =  mStreamsToSend.begin();
+			i != mStreamsToSend.end(); ++i)
 		{
-			// Send the streams
-			SendStream(*mStreamsToSend[s]);
+			SendStream(**i);
 		}
+		
 		// Delete these streams
 		DeleteStreamsToSend();
 
@@ -784,161 +983,82 @@
 	}	
 }
 
-void ${prefix}SendStreamAfterCommand(IOStream *pStream)
-{
-	ASSERT(pStream != NULL);
-	mStreamsToSend.push_back(pStream);
-}
-
-void ${prefix}DeleteStreamsToSend()
-{
-	for(std::vector<IOStream*>::iterator i(mStreamsToSend.begin()); i != mStreamsToSend.end(); ++i)
-	{
-		delete (*i);
-	}
-	mStreamsToSend.clear();
-}
-
 __E
-}
-
-# write logging functions?
-if($implement_filelog || $implement_syslog)
-{
-	my ($fR,$fS);
-
-	if($implement_syslog)
-	{
-		$fR .= <<__E;
-	if(mLogToSysLog)
-	{
-		if(Size==Protocol::ProtocolStream_SizeUncertain)
-		{
-			BOX_TRACE("Receiving stream, size uncertain");
-		}
-		else
-		{
-			BOX_TRACE("Receiving stream, size " << Size);
-		}
 	}
-__E
-		
-		$fS .= <<__E;
-	if(mLogToSysLog)
-	{
-		if(Size==Protocol::ProtocolStream_SizeUncertain)
-		{
-			BOX_TRACE("Sending stream, size uncertain");
-		}
-		else
-		{
-			BOX_TRACE("Sending stream, size " << Size);
-		}
-	}
-__E
-	}
 
-	if($implement_filelog)
+	# write client Query functions?
+	if($writing_client or $writing_local)
 	{
-		$fR .= <<__E;
-	if(mLogToFile)
-	{
-		::fprintf(mLogToFile,
-			(Size==Protocol::ProtocolStream_SizeUncertain)
-			?"Receiving stream, size uncertain\\n"
-			:"Receiving stream, size %d\\n", Size);
-		::fflush(mLogToFile);
-	}
-__E
-		$fS .= <<__E;
-	if(mLogToFile)
-	{
-		::fprintf(mLogToFile,
-			(Size==Protocol::ProtocolStream_SizeUncertain)
-			?"Sending stream, size uncertain\\n"
-			:"Sending stream, size %d\\n", Size);
-		::fflush(mLogToFile);
-	}
-__E
-	}
-
-	print CPP <<__E;
-
-void ${prefix}InformStreamReceiving(u_int32_t Size)
-{
-$fR}
-
-void ${prefix}InformStreamSending(u_int32_t Size)
-{
-$fS}
-
-__E
-}
-
-
-# write client Query functions?
-if($type eq 'Client')
-{
-	for my $cmd (@cmd_list)
-	{
-		if(obj_is_type($cmd,'Command'))
+		for my $cmd (@cmd_list)
 		{
-			my $reply = obj_get_type_params($cmd,'Command');
-			my $reply_id = $cmd_id{$reply};
-			my $has_stream = obj_is_type($cmd,'StreamWithCommand');
-			my $argextra = $has_stream?', IOStream &rStream':'';
-			my $send_stream_extra = '';
-			if($has_stream)
+			if(obj_is_type($cmd,'Command'))
 			{
-				$send_stream_extra = <<__E;
-	
+				my $request_class = $cmd_class{$cmd};
+				my $reply_msg = obj_get_type_params($cmd,'Command');
+				my $reply_class = $cmd_class{$reply_msg};
+				my $reply_id = $cmd_id{$reply_msg};
+				my $has_stream = obj_is_type($cmd,'StreamWithCommand');
+				my $argextra = $has_stream?', IOStream &rStream':'';
+				my $send_stream_extra = '';
+				my $send_stream_method = $writing_client ? "SendStream"
+					: "SendStreamAfterCommand";
+				
+				if($writing_client)
+				{
+					if($has_stream)
+					{
+						$send_stream_extra = <<__E;
 	// Send stream after the command
 	SendStream(rStream);
 __E
-			}
-			print CPP <<__E;
-std::auto_ptr<$classname_base$reply> ${classname_base}::Query(const $classname_base$cmd &rQuery$argextra)
+					}
+					
+					print CPP <<__E;
+std::auto_ptr<$reply_class> $server_or_client_class\::Query(const $request_class &rQuery$argextra)
 {
 	// Send query
 	Send(rQuery);
 	$send_stream_extra
+	
 	// Wait for the reply
-	std::auto_ptr<${derive_objects_from}> preply(Receive().release());
+	std::auto_ptr<$message_base_class> preply = Receive();
+	
+	CheckReply("$cmd", *preply, $reply_id);
 
-	if(preply->GetType() == $reply_id)
-	{
-		// Correct response
-		return std::auto_ptr<$classname_base$reply>(($classname_base$reply*)preply.release());
-	}
-	else
-	{
-		// Set protocol error
-		int type, subType;
-		if(preply->IsError(type, subType))
-		{
-			SetError(type, subType);
-			BOX_WARNING("$cmd command failed: received error " <<
-				((${classname_base}Error&)*preply).GetMessage());
-		}
-		else
-		{
-			SetError(Protocol::UnknownError, Protocol::UnknownError);
-			BOX_WARNING("$cmd command failed: received "
-				"unexpected response type " <<
-				preply->GetType());
-		}
-		
-		// Throw an exception
-		THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnexpectedReply)
-	}
+	// Correct response, if no exception thrown by CheckReply
+	return std::auto_ptr<$reply_class>(($reply_class *)preply.release());
 }
 __E
+				}
+				elsif($writing_local)
+				{
+					if($has_stream)
+					{
+						$send_stream_extra = <<__E;
+	// Send stream after the command
+	SendStreamAfterCommand(&rStream);
+__E
+					}
+
+					print CPP <<__E;
+std::auto_ptr<$reply_class> $server_or_client_class\::Query(const $request_class &rQuery$argextra)
+{
+	// Send query
+	$send_stream_extra
+	std::auto_ptr<$message_base_class> preply = rQuery.DoCommand(*this, mrContext);
+	
+	CheckReply("$cmd", *preply, $reply_id);
+
+	// Correct response, if no exception thrown by CheckReply
+	return std::auto_ptr<$reply_class>(($reply_class *)preply.release());
+}
+__E
+				}
+			}
 		}
 	}
 }
 
-
-
 print H <<__E;
 #endif // $guardname
 
@@ -948,8 +1068,7 @@
 close H;
 close CPP;
 
-
-sub obj_is_type
+sub obj_is_type ($$)
 {
 	my ($c,$ty) = @_;
 	for(@{$cmd_attributes{$c}})
@@ -1003,40 +1122,6 @@
 	return $typename
 }
 
-sub make_log_strings
-{
-	my ($cmd) = @_;
-
-	my @str;
-	my @arg;
-	for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2)
-	{
-		my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]);
-		
-		if(exists $log_display_types{$ty})
-		{
-			# need to translate it
-			my ($format,$arg) = @{$log_display_types{$ty}};
-			$arg =~ s/VAR/m$nm/g;
-
-			if ($format eq "0x%llx" and $target_windows)
-			{
-				$format = "0x%I64x";
-				$arg = "(uint64_t)$arg";
-			}
-
-			push @str,$format;
-			push @arg,$arg;
-		}
-		else
-		{
-			# is opaque
-			push @str,'OPAQUE';
-		}
-	}
-	return ($cmd.'('.join(',', at str).')', join(',','', at arg));
-}
-
 sub make_log_strings_framework
 {
 	my ($cmd) = @_;
@@ -1053,7 +1138,7 @@
 			my ($format,$arg) = @{$log_display_types{$ty}};
 			$arg =~ s/VAR/m$nm/g;
 
-			if ($format eq '\\"%s\\"')
+			if ($format eq '"%s"')
 			{
 				$arg = "\"\\\"\" << $arg << \"\\\"\"";
 			}
@@ -1090,4 +1175,3 @@
 	return $log_cmd;
 }
 
-


Property changes on: box/trunk/qdbm
___________________________________________________________________
Added: svn:ignore
   + Makefile
config.status
qdbm.pc
config.log
qdbm.spec
LTmakefile
configure.lineno


Modified: box/trunk/test/backupstore/testbackupstore.cpp
===================================================================
--- box/trunk/test/backupstore/testbackupstore.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/backupstore/testbackupstore.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -13,7 +13,7 @@
 #include <string.h>
 
 #include "Test.h"
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "SSLLib.h"
 #include "TLSContext.h"
 #include "SocketStreamTLS.h"
@@ -440,10 +440,10 @@
 	printf("Test for del: %llx\n", DirID);
 	
 	// Command
-	std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
+	std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
 			DirID,
-			BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-			BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+			BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+			BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 	// Stream
 	BackupStoreDirectory dir;
 	std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -455,7 +455,7 @@
 	int dirs = 0;
 	while((en = i.Next()) != 0)
 	{
-		if(en->GetFlags() & BackupProtocolClientListDirectory::Flags_Dir)
+		if(en->GetFlags() & BackupProtocolListDirectory::Flags_Dir)
 		{
 			dirs++;
 			// Recurse
@@ -466,7 +466,7 @@
 			files++;
 		}
 		// Check it's deleted
-		TEST_THAT(en->GetFlags() & BackupProtocolClientListDirectory::Flags_Deleted);
+		TEST_THAT(en->GetFlags() & BackupProtocolListDirectory::Flags_Deleted);
 	}
 	
 	// Check there were the right number of files and directories
@@ -491,7 +491,7 @@
 	BackupStoreFilenameClear name_encoded("file_One");
 	std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(
 		source.c_str(), parentId, name_encoded));
-	std::auto_ptr<BackupProtocolClientSuccess> stored(
+	std::auto_ptr<BackupProtocolSuccess> stored(
 		protocol.QueryStoreFile(
 			parentId,
 			0x123456789abcdefLL,		/* modification time */
@@ -515,7 +515,7 @@
 		// Create with dummy attributes
 		int attrS = 0;
 		MemBlockStream attr(&attrS, sizeof(attrS));
-		std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory(
+		std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory(
 			indir,
 			9837429842987984LL, dirname, attr));
 		subdirid = dirCreate->GetObjectID(); 
@@ -550,11 +550,11 @@
 void check_dir_after_uploads(BackupProtocolClient &protocol, const StreamableMemBlock &Attributes)
 {
 	// Command
-	std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
-			BackupProtocolClientListDirectory::RootDirectory,
-			BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-			BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
-	TEST_THAT(dirreply->GetObjectID() == BackupProtocolClientListDirectory::RootDirectory);
+	std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
+			BackupProtocolListDirectory::RootDirectory,
+			BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+			BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+	TEST_THAT(dirreply->GetObjectID() == BackupProtocolListDirectory::RootDirectory);
 	// Stream
 	BackupStoreDirectory dir;
 	std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -575,9 +575,9 @@
 		TEST_THAT(en->GetName() == uploads[t].name);
 		TEST_THAT(en->GetObjectID() == uploads[t].allocated_objid);
 		TEST_THAT(en->GetModificationTime() == uploads[t].mod_time);
-		int correct_flags = BackupProtocolClientListDirectory::Flags_File;
-		if(uploads[t].should_be_old_version) correct_flags |= BackupProtocolClientListDirectory::Flags_OldVersion;
-		if(uploads[t].delete_file) correct_flags |= BackupProtocolClientListDirectory::Flags_Deleted;
+		int correct_flags = BackupProtocolListDirectory::Flags_File;
+		if(uploads[t].should_be_old_version) correct_flags |= BackupProtocolListDirectory::Flags_OldVersion;
+		if(uploads[t].delete_file) correct_flags |= BackupProtocolListDirectory::Flags_Deleted;
 		TEST_THAT(en->GetFlags() == correct_flags);
 		if(t == UPLOAD_ATTRS_EN)
 		{
@@ -606,10 +606,10 @@
 void recursive_count_objects_r(BackupProtocolClient &protocol, int64_t id, recursive_count_objects_results &results)
 {
 	// Command
-	std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
+	std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
 			id,
-			BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-			BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+			BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+			BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 	// Stream
 	BackupStoreDirectory dir;
 	std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -649,9 +649,9 @@
 	BackupProtocolClient protocolReadOnly(connReadOnly);
 
 	{
-		std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+		std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 		TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
-		std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));
+		std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly));
 	}
 	
 	// Count objects
@@ -758,10 +758,10 @@
 	for(int l = 0; l < 3; ++l)
 	{
 		// Command
-		std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
-				BackupProtocolClientListDirectory::RootDirectory,
-				BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-				BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+		std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
+				BackupProtocolListDirectory::RootDirectory,
+				BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+				BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 		// Stream
 		BackupStoreDirectory dir;
 		std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -772,10 +772,10 @@
 	// Read the dir from the readonly connection (make sure it gets in the cache)
 	{
 		// Command
-		std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
-				BackupProtocolClientListDirectory::RootDirectory,
-				BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-				BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+		std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+				BackupProtocolListDirectory::RootDirectory,
+				BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+				BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 		// Stream
 		BackupStoreDirectory dir;
 		std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -787,7 +787,7 @@
 	BackupStoreFilenameClear store1name("testfiles/file1");
 	{
 		FileStream out("testfiles/file1_upload1", O_WRONLY | O_CREAT | O_EXCL);
-		std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolClientListDirectory::RootDirectory, store1name));
+		std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolListDirectory::RootDirectory, store1name));
 		encoded->CopyStreamTo(out);
 	}
 
@@ -797,8 +797,8 @@
 	int64_t store1objid = 0;
 	{
 		FileStream upload("testfiles/file1_upload1");
-		std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
-			BackupProtocolClientListDirectory::RootDirectory,
+		std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile(
+			BackupProtocolListDirectory::RootDirectory,
 			0x123456789abcdefLL,		/* modification time */
 			0x7362383249872dfLL,		/* attr hash */
 			0,							/* diff from ID */
@@ -811,7 +811,7 @@
 	// And retrieve it
 	{
 		// Retrieve as object
-		std::auto_ptr<BackupProtocolClientSuccess> getfile(protocol.QueryGetObject(store1objid));
+		std::auto_ptr<BackupProtocolSuccess> getfile(protocol.QueryGetObject(store1objid));
 		TEST_THAT(getfile->GetObjectID() == store1objid);
 		// BLOCK
 		{
@@ -826,7 +826,7 @@
 		}
 
 		// Retrieve as file
-		std::auto_ptr<BackupProtocolClientSuccess> getobj(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, store1objid));
+		std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, store1objid));
 		TEST_THAT(getobj->GetObjectID() == store1objid);
 		// BLOCK
 		{
@@ -852,7 +852,7 @@
 		
 		// Retrieve the block index, by ID
 		{
-			std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid));
+			std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid));
 			TEST_THAT(getblockindex->GetObjectID() == store1objid);
 			std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
 			// Check against uploaded file
@@ -860,7 +860,7 @@
 		}
 		// and again, by name
 		{
-			std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolClientListDirectory::RootDirectory, store1name));
+			std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolListDirectory::RootDirectory, store1name));
 			TEST_THAT(getblockindex->GetObjectID() == store1objid);
 			std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
 			// Check against uploaded file
@@ -870,10 +870,10 @@
 	// Get the directory again, and see if the entry is in it
 	{
 		// Command
-		std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
-				BackupProtocolClientListDirectory::RootDirectory,
-				BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-				BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+		std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
+				BackupProtocolListDirectory::RootDirectory,
+				BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+				BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 		// Stream
 		BackupStoreDirectory dir;
 		std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -896,7 +896,7 @@
 
 	// Try using GetFile on a directory
 	{
-		TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> getFile(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, BackupProtocolClientListDirectory::RootDirectory)),
+		TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> getFile(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, BackupProtocolListDirectory::RootDirectory)),
 			ConnectionException, Conn_Protocol_UnexpectedReply);
 	}
 }
@@ -929,12 +929,12 @@
 		BackupProtocolClient(*rapConn));
 	
 	// Check the version
-	std::auto_ptr<BackupProtocolClientVersion> serverVersion(
+	std::auto_ptr<BackupProtocolVersion> serverVersion(
 		protocol->QueryVersion(BACKUP_STORE_SERVER_VERSION));
 	TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
 
 	// Login
-	std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(
+	std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(
 		protocol->QueryLogin(0x01234567, 0));
 
 	return protocol;
@@ -1009,9 +1009,9 @@
 			conn.Open(context, Socket::TypeINET, hostname,
 				BOX_PORT_BBSTORED_TEST);
 			BackupProtocolClient protocol(conn);
-			std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+			std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 			TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
-			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
+			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
 				ConnectionException, Conn_Protocol_UnexpectedReply);
 			protocol.QueryFinished();
 		}
@@ -1033,9 +1033,9 @@
 		protocolReadOnly.SetLogToFile(protocolReadOnlyLog);
 
 		{
-			std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+			std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 			TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
-			std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));
+			std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly));
 			
 			// Check client store marker
 			TEST_THAT(loginConf->GetClientStoreMarker() == 0x8732523ab23aLL);
@@ -1079,11 +1079,11 @@
 			filename += uploads[t].fnextra;
 			int64_t modtime = 0;
 
-			std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolClientListDirectory::RootDirectory, uploads[t].name, &modtime));
+			std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolListDirectory::RootDirectory, uploads[t].name, &modtime));
 			TEST_THAT(modtime != 0);
 			
-			std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile(
-				BackupProtocolClientListDirectory::RootDirectory,
+			std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
+				BackupProtocolListDirectory::RootDirectory,
 				modtime,
 				modtime, /* use it for attr hash too */
 				0, /* diff from ID */
@@ -1107,8 +1107,8 @@
 		{
 			TEST_NUM_FILES(UPLOAD_NUM + 1, 0, 0, 1);
 			MemBlockStream attrnew(attr3, sizeof(attr3));
-			std::auto_ptr<BackupProtocolClientSuccess> set(apProtocol->QuerySetReplacementFileAttributes(
-				BackupProtocolClientListDirectory::RootDirectory,
+			std::auto_ptr<BackupProtocolSuccess> set(apProtocol->QuerySetReplacementFileAttributes(
+				BackupProtocolListDirectory::RootDirectory,
 				32498749832475LL,
 				uploads[UPLOAD_ATTRS_EN].name,
 				attrnew));
@@ -1118,8 +1118,8 @@
 		
 		// Delete one of them (will implicitly delete an old version)
 		{
-			std::auto_ptr<BackupProtocolClientSuccess> del(apProtocol->QueryDeleteFile(
-				BackupProtocolClientListDirectory::RootDirectory,
+			std::auto_ptr<BackupProtocolSuccess> del(apProtocol->QueryDeleteFile(
+				BackupProtocolListDirectory::RootDirectory,
 				uploads[UPLOAD_DELETE_EN].name));
 			TEST_THAT(del->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid);
 			TEST_NUM_FILES(UPLOAD_NUM, 0, 1, 1);
@@ -1130,13 +1130,13 @@
 			// Fetch the raw object
 			{
 				FileStream out("testfiles/downloaddelobj", O_WRONLY | O_CREAT);
-				std::auto_ptr<BackupProtocolClientSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid));
+				std::auto_ptr<BackupProtocolSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid));
 				std::auto_ptr<IOStream> objstream(apProtocol->ReceiveStream());
 				objstream->CopyStreamTo(out);
 			}
 			// query index and test
-			std::auto_ptr<BackupProtocolClientSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName(
-				BackupProtocolClientListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name));
+			std::auto_ptr<BackupProtocolSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName(
+				BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name));
 			TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid);
 			std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream());
 			TEST_THAT(check_block_index("testfiles/downloaddelobj", *blockIndexStream));
@@ -1146,7 +1146,7 @@
 		for(int t = 0; t < UPLOAD_NUM; ++t)
 		{
 			printf("%d\n", t);
-			std::auto_ptr<BackupProtocolClientSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, uploads[t].allocated_objid));
+			std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, uploads[t].allocated_objid));
 			TEST_THAT(getFile->GetObjectID() == uploads[t].allocated_objid);
 			std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream());
 			test_test_file(t, *filestream);
@@ -1206,8 +1206,8 @@
 
 		{
 			// Fetch the block index for this one
-			std::auto_ptr<BackupProtocolClientSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName(
-				BackupProtocolClientListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name));
+			std::auto_ptr<BackupProtocolSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName(
+				BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name));
 			TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_PATCH_EN].allocated_objid);
 			std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream());
 			
@@ -1217,7 +1217,7 @@
 			std::auto_ptr<IOStream> patchstream(
 				BackupStoreFile::EncodeFileDiff(
 					TEST_FILE_FOR_PATCHING ".mod", 
-					BackupProtocolClientListDirectory::RootDirectory,
+					BackupProtocolListDirectory::RootDirectory,
 					uploads[UPLOAD_PATCH_EN].name, 
 					uploads[UPLOAD_PATCH_EN].allocated_objid, 
 					*blockIndexStream,
@@ -1236,8 +1236,8 @@
 			int64_t patchedID = 0;
 			{
 				FileStream uploadpatch(TEST_FILE_FOR_PATCHING ".patch");
-				std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile(
-					BackupProtocolClientListDirectory::RootDirectory,
+				std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
+					BackupProtocolListDirectory::RootDirectory,
 					modtime,
 					modtime, /* use it for attr hash too */
 					uploads[UPLOAD_PATCH_EN].allocated_objid,		/* diff from ID */
@@ -1251,7 +1251,7 @@
 			set_refcount(patchedID, 1);
 
 			// Then download it to check it's OK
-			std::auto_ptr<BackupProtocolClientSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, patchedID));
+			std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, patchedID));
 			TEST_THAT(getFile->GetObjectID() == patchedID);
 			std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream());
 			BackupStoreFile::DecodeFile(*filestream, TEST_FILE_FOR_PATCHING ".downloaded", IOStream::TimeOutInfinite);
@@ -1267,8 +1267,8 @@
 		{
 			// Attributes
 			MemBlockStream attr(attr1, sizeof(attr1));
-			std::auto_ptr<BackupProtocolClientSuccess> dirCreate(apProtocol->QueryCreateDirectory(
-				BackupProtocolClientListDirectory::RootDirectory,
+			std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory(
+				BackupProtocolListDirectory::RootDirectory,
 				9837429842987984LL, dirname, attr));
 			subdirid = dirCreate->GetObjectID(); 
 			TEST_THAT(subdirid == maxID + 1);
@@ -1285,7 +1285,7 @@
 			int64_t modtime;
 			std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), subdirid, uploads[0].name, &modtime));
 
-			std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile(
+			std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
 				subdirid,
 				modtime,
 				modtime, /* use for attr hash too */
@@ -1303,10 +1303,10 @@
 		// Check the directories on the read only connection
 		{
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
-					BackupProtocolClientListDirectory::RootDirectory,
-					BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+					BackupProtocolListDirectory::RootDirectory,
+					BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+					BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream
 			BackupStoreDirectory dir;
 			std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
 			dir.ReadFromStream(*dirstream, IOStream::TimeOutInfinite);
@@ -1328,17 +1328,17 @@
 			}
 			// Does it look right?
 			TEST_THAT(en->GetName() == dirname);
-			TEST_THAT(en->GetFlags() == BackupProtocolClientListDirectory::Flags_Dir);
+			TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_Dir);
 			TEST_THAT(en->GetObjectID() == subdirid);
 			TEST_THAT(en->GetModificationTime() == 0);	// dirs don't have modification times.
 		}
 
 		{
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
 					subdirid,
-					BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */));
+					BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+					BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */));
 			TEST_THAT(dirreply->GetObjectID() == subdirid);
 			// Stream
 			BackupStoreDirectory dir;
@@ -1353,7 +1353,7 @@
 			TEST_THAT(en != 0);
 			// Does it look right?
 			TEST_THAT(en->GetName() == uploads[0].name);
-			TEST_THAT(en->GetFlags() == BackupProtocolClientListDirectory::Flags_File);
+			TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_File);
 			TEST_THAT(en->GetObjectID() == subdirfileid);
 			TEST_THAT(en->GetModificationTime() != 0);
 
@@ -1368,10 +1368,10 @@
 		// Check that we don't get attributes if we don't ask for them
 		{
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
 					subdirid,
-					BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */));
+					BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+					BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */));
 			// Stream
 			BackupStoreDirectory dir;
 			std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1385,7 +1385,7 @@
 		// Change attributes on the directory
 		{
 			MemBlockStream attrnew(attr2, sizeof(attr2));
-			std::auto_ptr<BackupProtocolClientSuccess> changereply(apProtocol->QueryChangeDirAttributes(
+			std::auto_ptr<BackupProtocolSuccess> changereply(apProtocol->QueryChangeDirAttributes(
 					subdirid,
 					329483209443598LL,
 					attrnew));
@@ -1394,10 +1394,10 @@
 		// Check the new attributes
 		{
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
 					subdirid,
 					0,	// no flags
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */));
+					BackupProtocolListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */));
 			// Stream
 			BackupStoreDirectory dir;
 			std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1418,9 +1418,9 @@
 		{
 			BackupStoreFilenameClear newName("moved-files");
 		
-			std::auto_ptr<BackupProtocolClientSuccess> rep(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
-				BackupProtocolClientListDirectory::RootDirectory,
-				subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName));
+			std::auto_ptr<BackupProtocolSuccess> rep(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
+				BackupProtocolListDirectory::RootDirectory,
+				subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName));
 			TEST_THAT(rep->GetObjectID() == uploads[UPLOAD_FILE_TO_MOVE].allocated_objid);
 		}
 
@@ -1428,12 +1428,12 @@
 		{
 			BackupStoreFilenameClear newName("moved-files");
 			TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
-					BackupProtocolClientListDirectory::RootDirectory,
-					subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName),
+					BackupProtocolListDirectory::RootDirectory,
+					subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName),
 				ConnectionException, Conn_Protocol_UnexpectedReply);
 			TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
 					subdirid,
-					subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName),
+					subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName),
 				ConnectionException, Conn_Protocol_UnexpectedReply);
 		}
 
@@ -1442,16 +1442,16 @@
 			BackupStoreFilenameClear newName("moved-files-x");
 			apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,
 				subdirid,
-				subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName);
+				subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName);
 		}
 
 		// Check it's all gone from the root directory...
 		{
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
-					BackupProtocolClientListDirectory::RootDirectory,
-					BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+					BackupProtocolListDirectory::RootDirectory,
+					BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+					BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 			// Stream
 			BackupStoreDirectory dir;
 			std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1470,10 +1470,10 @@
 			BackupStoreFilenameClear lookFor("moved-files-x");
 
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
 					subdirid,
-					BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+					BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+					BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 			// Stream
 			BackupStoreDirectory dir;
 			std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1505,14 +1505,14 @@
 			BackupStoreFilenameClear nd("sub2");
 			// Attributes
 			MemBlockStream attr(attr1, sizeof(attr1));
-			std::auto_ptr<BackupProtocolClientSuccess> dirCreate(apProtocol->QueryCreateDirectory(
+			std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory(
 				subdirid,
 				9837429842987984LL, nd, attr));
 			subsubdirid = dirCreate->GetObjectID(); 
 
 			FileStream upload("testfiles/file1_upload1");
 			BackupStoreFilenameClear nf("file2");
-			std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile(
+			std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile(
 				subsubdirid,
 				0x123456789abcdefLL,		/* modification time */
 				0x7362383249872dfLL,		/* attr hash */
@@ -1527,29 +1527,29 @@
 
 		// Query names -- test that invalid stuff returns not found OK
 		{
-			std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid));
+			std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid));
 			TEST_THAT(nameRep->GetNumNameElements() == 0);		
 		}
 		{
-			std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL));
+			std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL));
 			TEST_THAT(nameRep->GetNumNameElements() == 0);		
 		}
 		{
-			std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL));
+			std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL));
 			TEST_THAT(nameRep->GetNumNameElements() == 0);		
 		}
 		{
-			std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL));
+			std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL));
 			TEST_THAT(nameRep->GetNumNameElements() == 0);		
 		}
 
 		// Query names... first, get info for the file
 		{
-			std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid));
+			std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid));
 			std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream());
 		
 			TEST_THAT(nameRep->GetNumNameElements() == 3);
-			TEST_THAT(nameRep->GetFlags() == BackupProtocolClientListDirectory::Flags_File);
+			TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_File);
 			TEST_THAT(nameRep->GetModificationTime() == 0x123456789abcdefLL);
 			TEST_THAT(nameRep->GetAttributesHash() == 0x7362383249872dfLL);
 			static const char *testnames[] = {"file2","sub2","lovely_directory"};
@@ -1563,11 +1563,11 @@
 
 		// Query names... secondly, for the directory
 		{
-			std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, subsubdirid));
+			std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, subsubdirid));
 			std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream());
 		
 			TEST_THAT(nameRep->GetNumNameElements() == 2);
-			TEST_THAT(nameRep->GetFlags() == BackupProtocolClientListDirectory::Flags_Dir);
+			TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_Dir);
 			static const char *testnames[] = {"sub2","lovely_directory"};
 			for(int l = 0; l < nameRep->GetNumNameElements(); ++l)
 			{
@@ -1585,12 +1585,12 @@
 	
 		// Create some nice recursive directories
 		int64_t dirtodelete = create_test_data_subdirs(*apProtocol,
-			BackupProtocolClientListDirectory::RootDirectory,
+			BackupProtocolListDirectory::RootDirectory,
 			"test_delete", 6 /* depth */, *apRefCount);
 		
 		// And delete them
 		{
-			std::auto_ptr<BackupProtocolClientSuccess> dirdel(apProtocol->QueryDeleteDirectory(
+			std::auto_ptr<BackupProtocolSuccess> dirdel(apProtocol->QueryDeleteDirectory(
 					dirtodelete));
 			TEST_THAT(dirdel->GetObjectID() == dirtodelete);
 		}
@@ -1598,10 +1598,10 @@
 		// Get the root dir, checking for deleted items
 		{
 			// Command
-			std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(
-					BackupProtocolClientListDirectory::RootDirectory,
-					BackupProtocolClientListDirectory::Flags_Dir | BackupProtocolClientListDirectory::Flags_Deleted,
-					BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+			std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory(
+					BackupProtocolListDirectory::RootDirectory,
+					BackupProtocolListDirectory::Flags_Dir | BackupProtocolListDirectory::Flags_Deleted,
+					BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 			// Stream
 			BackupStoreDirectory dir;
 			std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream());
@@ -1889,11 +1889,11 @@
 			BackupProtocolClient protocol(conn);
 
 			// Check the version
-			std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+			std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 			TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
 
 			// Login
-			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
+			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),
 				ConnectionException, Conn_Protocol_UnexpectedReply);
 			
 			// Finish the connection
@@ -1988,7 +1988,7 @@
 		// First, things as they are now.
 		recursive_count_objects_results before = {0,0,0};
 
-		recursive_count_objects("localhost", BackupProtocolClientListDirectory::RootDirectory, before);
+		recursive_count_objects("localhost", BackupProtocolListDirectory::RootDirectory, before);
 		
 		TEST_THAT(before.objectsNotDel != 0);
 		TEST_THAT(before.deleted != 0);
@@ -2033,7 +2033,7 @@
 		// Count the objects again
 		recursive_count_objects_results after = {0,0,0};
 		recursive_count_objects("localhost", 
-			BackupProtocolClientListDirectory::RootDirectory, 
+			BackupProtocolListDirectory::RootDirectory, 
 			after);
 
 		// If these tests fail then try increasing the timeout above
@@ -2058,20 +2058,20 @@
 			BackupProtocolClient protocol(conn);
 
 			// Check the version
-			std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+			std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 			TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
 
 			// Login
-			std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0));
+			std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0));
 			
 			int64_t modtime = 0;
 			
 			BackupStoreFilenameClear fnx("exceed-limit");
-			std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocolClientListDirectory::RootDirectory, fnx, &modtime));
+			std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocolListDirectory::RootDirectory, fnx, &modtime));
 			TEST_THAT(modtime != 0);
 
-			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
-					BackupProtocolClientListDirectory::RootDirectory,
+			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile(
+					BackupProtocolListDirectory::RootDirectory,
 					modtime,
 					modtime, /* use it for attr hash too */
 					0,							/* diff from ID */
@@ -2081,8 +2081,8 @@
 
 			MemBlockStream attr(&modtime, sizeof(modtime));
 			BackupStoreFilenameClear fnxd("exceed-limit-dir");
-			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory(
-					BackupProtocolClientListDirectory::RootDirectory,
+			TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory(
+					BackupProtocolListDirectory::RootDirectory,
 					9837429842987984LL, fnxd, attr)),
 				ConnectionException, Conn_Protocol_UnexpectedReply);
 
@@ -2240,7 +2240,7 @@
 /*	{
 		int64_t modtime = 0;
 		std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("/Users/ben/temp/large.tar",
-			BackupProtocolClientListDirectory::RootDirectory, uploads[0].name, &modtime));
+			BackupProtocolListDirectory::RootDirectory, uploads[0].name, &modtime));
 		TEST_THAT(modtime != 0);
 		FileStream write("testfiles/large.enc", O_WRONLY | O_CREAT);
 		upload->CopyStreamTo(write);

Modified: box/trunk/test/backupstorepatch/testbackupstorepatch.cpp
===================================================================
--- box/trunk/test/backupstorepatch/testbackupstorepatch.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/backupstorepatch/testbackupstorepatch.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -13,7 +13,7 @@
 #include <string.h>
 #include <signal.h>
 
-#include "autogen_BackupProtocolClient.h"
+#include "autogen_BackupProtocol.h"
 #include "BackupClientCryptoKeys.h"
 #include "BackupClientFileAttributes.h"
 #include "BackupStoreAccountDatabase.h"
@@ -354,7 +354,7 @@
 			// Login
 			{
 				// Check the version
-				std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+				std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 				TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
 	
 				// Login
@@ -367,9 +367,9 @@
 			// Upload the first file
 			{
 				std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/0.test",
-						BackupProtocolClientListDirectory::RootDirectory, storeFilename));
-				std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
-						BackupProtocolClientListDirectory::RootDirectory, ModificationTime,
+						BackupProtocolListDirectory::RootDirectory, storeFilename));
+				std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile(
+						BackupProtocolListDirectory::RootDirectory, ModificationTime,
 						ModificationTime, 0 /* no diff from file ID */, storeFilename, *upload));
 				test_files[0].IDOnServer = stored->GetObjectID();
 				test_files[0].IsCompletelyDifferent = true;
@@ -380,8 +380,8 @@
 			for(unsigned int f = 1; f < NUMBER_FILES; ++f)
 			{
 				// Get an index for the previous version
-				std::auto_ptr<BackupProtocolClientSuccess> getBlockIndex(protocol.QueryGetBlockIndexByName(
-						BackupProtocolClientListDirectory::RootDirectory, storeFilename));
+				std::auto_ptr<BackupProtocolSuccess> getBlockIndex(protocol.QueryGetBlockIndexByName(
+						BackupProtocolListDirectory::RootDirectory, storeFilename));
 				int64_t diffFromID = getBlockIndex->GetObjectID();
 				TEST_THAT(diffFromID != 0);
 				
@@ -397,7 +397,7 @@
 					std::auto_ptr<IOStream> patchStream(
 						BackupStoreFile::EncodeFileDiff(
 							filename,
-							BackupProtocolClientListDirectory::RootDirectory,	/* containing directory */
+							BackupProtocolListDirectory::RootDirectory,	/* containing directory */
 							storeFilename, 
 							diffFromID, 
 							*blockIndexStream,
@@ -407,8 +407,8 @@
 							&isCompletelyDifferent));
 		
 					// Upload the patch to the store
-					std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile(
-							BackupProtocolClientListDirectory::RootDirectory, ModificationTime,
+					std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile(
+							BackupProtocolListDirectory::RootDirectory, ModificationTime,
 							ModificationTime, isCompletelyDifferent?(0):(diffFromID), storeFilename, *patchStream));
 					ModificationTime += MODIFICATION_TIME_INC;
 					
@@ -432,10 +432,10 @@
 			
 			// List the directory from the server, and check that no dependency info is sent -- waste of bytes
 			{
-				std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory(
-						BackupProtocolClientListDirectory::RootDirectory,
-						BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING,
-						BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
+				std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory(
+						BackupProtocolListDirectory::RootDirectory,
+						BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING,
+						BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));
 				// Stream
 				BackupStoreDirectory dir;
 				std::auto_ptr<IOStream> dirstream(protocol.ReceiveStream());
@@ -531,7 +531,7 @@
 				BOX_PORT_BBSTORED_TEST);
 			BackupProtocolClient protocol(conn);
 			{
-				std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
+				std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));
 				TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION);
 				protocol.QueryLogin(0x01234567, 0);
 			}
@@ -555,8 +555,8 @@
 	
 				// Fetch the file
 				{
-					std::auto_ptr<BackupProtocolClientSuccess> getobj(protocol.QueryGetFile(
-						BackupProtocolClientListDirectory::RootDirectory,
+					std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile(
+						BackupProtocolListDirectory::RootDirectory,
 						test_files[f].IDOnServer));
 					TEST_THAT(getobj->GetObjectID() == test_files[f].IDOnServer);
 					// BLOCK
@@ -572,7 +572,7 @@
 				
 				// Download the index, and check it looks OK
 				{
-					std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(test_files[f].IDOnServer));
+					std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(test_files[f].IDOnServer));
 					TEST_THAT(getblockindex->GetObjectID() == test_files[f].IDOnServer);
 					std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream());
 					TEST_THAT(BackupStoreFile::CompareFileContentsAgainstBlockIndex(filename, *blockIndexStream, IOStream::TimeOutInfinite));

Modified: box/trunk/test/basicserver/Makefile.extra
===================================================================
--- box/trunk/test/basicserver/Makefile.extra	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/basicserver/Makefile.extra	2011-08-27 14:06:46 UTC (rev 2983)
@@ -1,21 +1,12 @@
 
 MAKEPROTOCOL = ../../lib/server/makeprotocol.pl
 
-GEN_CMD_SRV = $(MAKEPROTOCOL) Server testprotocol.txt
-GEN_CMD_CLI = $(MAKEPROTOCOL) Client testprotocol.txt
+GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt
 
 # AUTOGEN SEEDING
-autogen_TestProtocolServer.cpp:	$(MAKEPROTOCOL) testprotocol.txt
-	$(_PERL) $(GEN_CMD_SRV)
+autogen_TestProtocol.cpp:	$(MAKEPROTOCOL) testprotocol.txt
+	$(_PERL) $(GEN_CMD)
 
 autogen_TestProtocolServer.h:	$(MAKEPROTOCOL) testprotocol.txt
-	$(_PERL) $(GEN_CMD_SRV)
+	$(_PERL) $(GEN_CMD)
 
-
-# AUTOGEN SEEDING
-autogen_TestProtocolClient.cpp:	$(MAKEPROTOCOL) testprotocol.txt
-	$(_PERL) $(GEN_CMD_CLI)
-
-autogen_TestProtocolClient.h:	$(MAKEPROTOCOL) testprotocol.txt
-	$(_PERL) $(GEN_CMD_CLI)
-

Modified: box/trunk/test/basicserver/TestCommands.cpp
===================================================================
--- box/trunk/test/basicserver/TestCommands.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/basicserver/TestCommands.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -5,34 +5,34 @@
 #include <syslog.h>
 #endif
 
-#include "autogen_TestProtocolServer.h"
+#include "autogen_TestProtocol.h"
 #include "CollectInBufferStream.h"
 
 #include "MemLeakFindOn.h"
 
 
-std::auto_ptr<ProtocolObject> TestProtocolServerHello::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolHello::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
 	if(mNumber32 != 41 || mNumber16 != 87 || mNumber8 != 11 || mText != "pingu")
 	{
-		return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0));
+		return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0));
 	}
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerHello(12,89,22,std::string("Hello world!")));
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolHello(12,89,22,std::string("Hello world!")));
 }
 
-std::auto_ptr<ProtocolObject> TestProtocolServerLists::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolLists::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerListsReply(mLotsOfText.size()));
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolListsReply(mLotsOfText.size()));
 }
 
-std::auto_ptr<ProtocolObject> TestProtocolServerQuit::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolQuit::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerQuit);
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolQuit);
 }
 
-std::auto_ptr<ProtocolObject> TestProtocolServerSimple::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolSimple::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerSimpleReply(mValue+1));
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolSimpleReply(mValue+1));
 }
 
 class UncertainBufferStream : public CollectInBufferStream
@@ -45,7 +45,7 @@
 	}
 };
 
-std::auto_ptr<ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolGetStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
 	// make a new stream object
 	CollectInBufferStream *pstream = mUncertainSize?(new UncertainBufferStream):(new CollectInBufferStream);
@@ -68,14 +68,14 @@
 	// Get it to be sent
 	rProtocol.SendStreamAfterCommand(pstream);
 
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(mStartingValue, mUncertainSize));
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(mStartingValue, mUncertainSize));
 }
 
-std::auto_ptr<ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolSendStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
 	if(mValue != 0x73654353298ffLL)
 	{
-		return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0));
+		return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0));
 	}
 	
 	// Get a stream
@@ -91,11 +91,11 @@
 	}
 
 	// tell the caller how many bytes there were
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(bytes, uncertain));
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(bytes, uncertain));
 }
 
-std::auto_ptr<ProtocolObject> TestProtocolServerString::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)
+std::auto_ptr<TestProtocolMessage> TestProtocolString::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const
 {
-	return std::auto_ptr<ProtocolObject>(new TestProtocolServerString(mTest));
+	return std::auto_ptr<TestProtocolMessage>(new TestProtocolString(mTest));
 }
 

Modified: box/trunk/test/basicserver/testbasicserver.cpp
===================================================================
--- box/trunk/test/basicserver/testbasicserver.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/basicserver/testbasicserver.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -26,8 +26,7 @@
 #include "CollectInBufferStream.h"
 
 #include "TestContext.h"
-#include "autogen_TestProtocolClient.h"
-#include "autogen_TestProtocolServer.h"
+#include "autogen_TestProtocol.h"
 #include "ServerControl.h"
 
 #include "MemLeakFindOn.h"
@@ -393,7 +392,7 @@
 
 void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream)
 {
-	std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QueryGetStream(value, uncertainstream));
+	std::auto_ptr<TestProtocolGetStream> reply(protocol.QueryGetStream(value, uncertainstream));
 	TEST_THAT(reply->GetStartingValue() == value);
 	
 	// Get a stream
@@ -704,11 +703,11 @@
 
 			// Simple query
 			{
-				std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(41));
+				std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(41));
 				TEST_THAT(reply->GetValuePlusOne() == 42);
 			}
 			{
-				std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(809));
+				std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(809));
 				TEST_THAT(reply->GetValuePlusOne() == 810);
 			}
 			
@@ -724,14 +723,14 @@
 				char buf[1663];
 				s.Write(buf, sizeof(buf));
 				s.SetForReading();
-				std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s));
+				std::auto_ptr<TestProtocolGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s));
 				TEST_THAT(reply->GetStartingValue() == sizeof(buf));
 			}
 
 			// Lots of simple queries
 			for(int q = 0; q < 514; q++)
 			{
-				std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(q));
+				std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(q));
 				TEST_THAT(reply->GetValuePlusOne() == (q+1));
 			}
 			// Send a list of strings to it
@@ -740,13 +739,13 @@
 				strings.push_back(std::string("test1"));
 				strings.push_back(std::string("test2"));
 				strings.push_back(std::string("test3"));
-				std::auto_ptr<TestProtocolClientListsReply> reply(protocol.QueryLists(strings));
+				std::auto_ptr<TestProtocolListsReply> reply(protocol.QueryLists(strings));
 				TEST_THAT(reply->GetNumberOfStrings() == 3);
 			}
 			
 			// And another
 			{
-				std::auto_ptr<TestProtocolClientHello> reply(protocol.QueryHello(41,87,11,std::string("pingu")));
+				std::auto_ptr<TestProtocolHello> reply(protocol.QueryHello(41,87,11,std::string("pingu")));
 				TEST_THAT(reply->GetNumber32() == 12);
 				TEST_THAT(reply->GetNumber16() == 89);
 				TEST_THAT(reply->GetNumber8() == 22);

Modified: box/trunk/test/bbackupd/Makefile.extra
===================================================================
--- box/trunk/test/bbackupd/Makefile.extra	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/bbackupd/Makefile.extra	2011-08-27 14:06:46 UTC (rev 2983)
@@ -8,7 +8,7 @@
 	../../bin/bbackupd/BackupDaemon.o \
 	../../bin/bbstored/BBStoreDHousekeeping.o \
 	../../bin/bbstored/HousekeepStoreAccount.o \
-	../../lib/backupstore/autogen_BackupProtocolServer.o \
+	../../lib/backupstore/autogen_BackupProtocol.o \
 	../../lib/backupstore/BackupStoreContext.o \
 	../../lib/backupstore/BackupCommands.o \
 	../../bin/bbstored/BackupStoreDaemon.o

Modified: box/trunk/test/bbackupd/testbbackupd.cpp
===================================================================
--- box/trunk/test/bbackupd/testbbackupd.cpp	2011-08-27 14:04:34 UTC (rev 2982)
+++ box/trunk/test/bbackupd/testbbackupd.cpp	2011-08-27 14:06:46 UTC (rev 2983)
@@ -42,7 +42,7 @@
 	#include <sys/syscall.h>
 #endif
 
-#include "autogen_BackupProtocolServer.h"
+#include "autogen_BackupProtocol.h"
 #include "BackupClientCryptoKeys.h"
 #include "BackupClientFileAttributes.h"
 #include "BackupClientRestore.h"
@@ -73,7 +73,6 @@
 #include "Timer.h"
 #include "Utils.h"
 
-#include "autogen_BackupProtocolClient.h"
 #include "intercept.h"
 #include "ServerControl.h"
 
@@ -475,8 +474,8 @@
 {
 	protocol.QueryListDirectory(
 			InDirectory,
-			BackupProtocolClientListDirectory::Flags_Dir,
-			BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING,
+			BackupProtocolListDirectory::Flags_Dir,
+			BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING,
 			true /* want attributes */);
 	
 	// Retrieve the directory from the stream following
@@ -518,9 +517,9 @@
 				22011);
 			BackupProtocolClient protocol(conn);
 			protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION);
-			std::auto_ptr<BackupProtocolClientLoginConfirmed>
+			std::auto_ptr<BackupProtocolLoginConfirmed>
 				loginConf(protocol.QueryLogin(0x01234567,
-					BackupProtocolClientLogin::Flags_ReadOnly));
+					BackupProtocolLogin::Flags_ReadOnly));
 			
 			// Test the restoration
 			TEST_THAT(BackupClientRestore(protocol, restoredirid,
@@ -604,7 +603,7 @@
 	if (en == 0) return 0;
 	int64_t id = en->GetObjectID();
 	TEST_THAT(id > 0);
-	TEST_THAT(id != BackupProtocolClientListDirectory::RootDirectory);
+	TEST_THAT(id != BackupProtocolListDirectory::RootDirectory);
 	return id;
 }
 
@@ -617,7 +616,7 @@
 	std::auto_ptr<BackupProtocolClient> connection;
 	connection.reset(new BackupProtocolClient(sSocket));
 	connection->Handshake();
-	std::auto_ptr<BackupProtocolClientVersion> 
+	std::auto_ptr<BackupProtocolVersion> 
 		serverVersion(connection->QueryVersion(
 			BACKUP_STORE_SERVER_VERSION));
 	if(serverVersion->GetVersion() != 
@@ -640,10 +639,10 @@
 std::auto_ptr<BackupStoreDirectory> ReadDirectory
 (
 	BackupProtocolClient& rClient,
-	int64_t id
+	int64_t id = BackupProtocolListDirectory::RootDirectory
 )
 {
-	std::auto_ptr<BackupProtocolClientSuccess> dirreply(
+	std::auto_ptr<BackupProtocolSuccess> dirreply(
 		rClient.QueryListDirectory(id, false, 0, false));
 	std::auto_ptr<IOStream> dirstream(rClient.ReceiveStream());
 	std::auto_ptr<BackupStoreDirectory> apDir(new BackupStoreDirectory());
@@ -766,7 +765,7 @@
 	}
 	else
 	{
-		BOX_INFO("readdir hook still active at " << time_now << ", "
+		BOX_TRACE("readdir hook still active at " << time_now << ", "
 			"waiting for " << readdir_stop_time);
 	}
 
@@ -780,7 +779,7 @@
 	snprintf(readdir_test_dirent.d_name, 
 		sizeof(readdir_test_dirent.d_name),
 		"test.%d", readdir_test_counter);
-	BOX_INFO("readdir hook returning " << readdir_test_dirent.d_name);
+	BOX_TRACE("readdir hook returning " << readdir_test_dirent.d_name);
 
 	// ensure that when bbackupd stats the file, it gets the 
 	// right answer
@@ -792,6 +791,9 @@
 	intercept_setup_lstat_hook(stat_hook_filename, lstat_test_hook);
 #endif
 
+	// sleep a bit to reduce the number of dirents returned
+	::safe_sleep(1);
+
 	return &readdir_test_dirent;
 }
 
@@ -1131,6 +1133,9 @@
 			TEST_LINE(comp2 != sub, line);
 		}
 
+		// Check that no read error has been reported yet
+		TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1"));
+
 		if (failures > 0)
 		{
 			// stop early to make debugging easier
@@ -1338,7 +1343,7 @@
 			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context, 0 /* read-write */);
 		
-			std::auto_ptr<BackupProtocolClientAccountUsage> usage(
+			std::auto_ptr<BackupProtocolAccountUsage> usage(
 				client->QueryGetAccountUsage());
 			TEST_EQUAL_LINE(24, usage->GetBlocksUsed(),
 				"blocks used");
@@ -1421,8 +1426,7 @@
 				ConnectAndLogin(context, 0 /* read-write */);
 		
 			std::auto_ptr<BackupStoreDirectory> rootDir = 
-				ReadDirectory(*client,
-				BackupProtocolClientListDirectory::RootDirectory);
+				ReadDirectory(*client);
 
 			int64_t testDirId = SearchDir(*rootDir, "Test1");
 			TEST_THAT(testDirId != 0);
@@ -1464,7 +1468,7 @@
 				ReadDirectory(*client, d4_id);
 			TEST_THAT(test_entry_deleted(*d4_dir, "f5"));
 
-			std::auto_ptr<BackupProtocolClientAccountUsage> usage(
+			std::auto_ptr<BackupProtocolAccountUsage> usage(
 				client->QueryGetAccountUsage());
 			TEST_EQUAL_LINE(24, usage->GetBlocksUsed(),
 				"blocks used");
@@ -1498,8 +1502,7 @@
 				ConnectAndLogin(context, 0 /* read-write */);
 			
 			std::auto_ptr<BackupStoreDirectory> rootDir = 
-				ReadDirectory(*client,
-				BackupProtocolClientListDirectory::RootDirectory);
+				ReadDirectory(*client);
 
 			int64_t testDirId = SearchDir(*rootDir, "Test1");
 			TEST_THAT(testDirId != 0);
@@ -1519,7 +1522,7 @@
 			TEST_THAT(SearchDir(*spacetest_dir, "d3") == 0);
 			TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0);
 
-			std::auto_ptr<BackupProtocolClientAccountUsage> usage(
+			std::auto_ptr<BackupProtocolAccountUsage> usage(
 				client->QueryGetAccountUsage());
 			TEST_EQUAL_LINE(16, usage->GetBlocksUsed(),
 				"blocks used");
@@ -1574,7 +1577,7 @@
 			std::auto_ptr<BackupProtocolClient> client = 
 				ConnectAndLogin(context, 0 /* read-write */);
 
-			std::auto_ptr<BackupProtocolClientAccountUsage> usage(
+			std::auto_ptr<BackupProtocolAccountUsage> usage(
 				client->QueryGetAccountUsage());
 			TEST_EQUAL_LINE(22, usage->GetBlocksUsed(),
 				"blocks used");
@@ -1685,17 +1688,17 @@
 
 		class MyHook : public BackupStoreContext::TestHook
 		{
-			virtual std::auto_ptr<ProtocolObject> StartCommand(
-				BackupProtocolObject& rCommand)
+			virtual std::auto_ptr<BackupProtocolMessage> StartCommand(
+				const BackupProtocolMessage& rCommand)
 			{
 				if (rCommand.GetType() ==
-					BackupProtocolServerStoreFile::TypeID)
+					BackupProtocolStoreFile::TypeID)
 				{
 					// terminate badly
 					THROW_EXCEPTION(CommonException,
 						Internal);
 				}
-				return std::auto_ptr<ProtocolObject>();
+				return std::auto_ptr<BackupProtocolMessage>();
 			}
 		};
 		MyHook hook;
@@ -1959,11 +1962,10 @@
 		{
 			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context,
-				BackupProtocolClientLogin::Flags_ReadOnly);
+				BackupProtocolLogin::Flags_ReadOnly);
 			
 			std::auto_ptr<BackupStoreDirectory> dir = 
-				ReadDirectory(*client,
-				BackupProtocolClientListDirectory::RootDirectory);
+				ReadDirectory(*client);
 			int64_t testDirId = SearchDir(*dir, "Test2");
 			TEST_THAT(testDirId != 0);
 
@@ -1998,11 +2000,10 @@
 		{
 			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context,
-				BackupProtocolClientLogin::Flags_ReadOnly);
+				BackupProtocolLogin::Flags_ReadOnly);
 			
 			std::auto_ptr<BackupStoreDirectory> dir = 
-				ReadDirectory(*client,
-				BackupProtocolClientListDirectory::RootDirectory);
+				ReadDirectory(*client);
 			int64_t testDirId = SearchDir(*dir, "Test2");
 			TEST_THAT(testDirId != 0);
 
@@ -2017,11 +2018,10 @@
 		{
 			std::auto_ptr<BackupProtocolClient> client =
 				ConnectAndLogin(context,
-				BackupProtocolClientLogin::Flags_ReadOnly);
+				BackupProtocolLogin::Flags_ReadOnly);
 			
 			std::auto_ptr<BackupStoreDirectory> root_dir = 
-				ReadDirectory(*client,
-				BackupProtocolClientListDirectory::RootDirectory);
+				ReadDirectory(*client);
 
 			TEST_THAT(test_entry_deleted(*root_dir, "Test2"));
 
@@ -2263,8 +2263,7 @@
 				ConnectAndLogin(context, 0);
 
 			std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory(
-				*client, 
-				BackupProtocolClientListDirectory::RootDirectory);
+				*client);
 
 			int64_t baseDirId = SearchDir(*dir, "Test1");
 			TEST_THAT(baseDirId != 0);
@@ -3257,11 +3256,10 @@
 		{
 			std::auto_ptr<BackupProtocolClient> client = 
 				ConnectAndLogin(context,
-				BackupProtocolClientLogin::Flags_ReadOnly);
+				BackupProtocolLogin::Flags_ReadOnly);
 			
 			std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory(
-				*client,
-				BackupProtocolClientListDirectory::RootDirectory);
+				*client);
 
 			int64_t testDirId = SearchDir(*dir, "Test1");
 			TEST_THAT(testDirId != 0);
@@ -3438,11 +3436,11 @@
 			// connect and log in
 			std::auto_ptr<BackupProtocolClient> client = 
 				ConnectAndLogin(context,
-				BackupProtocolClientLogin::Flags_ReadOnly);
+				BackupProtocolLogin::Flags_ReadOnly);
 
 			// Find the ID of the Test1 directory
 			restoredirid = GetDirID(*client, "Test1", 
-				BackupProtocolClientListDirectory::RootDirectory);
+				BackupProtocolListDirectory::RootDirectory);
 			TEST_THAT(restoredirid != 0);
 
 			// Test the restoration
@@ -3745,7 +3743,7 @@
 					// Make sure the marker isn't zero,
 					// because that's the default, and
 					// it should have changed
-					std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol->QueryLogin(0x01234567, 0));
+					std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol->QueryLogin(0x01234567, 0));
 					TEST_THAT(loginConf->GetClientStoreMarker() != 0);
 					
 					// Change it to something else
@@ -3823,7 +3821,7 @@
 
 			std::auto_ptr<BackupProtocolClient> client = 
 				ConnectAndLogin(context,
-				BackupProtocolClientLogin::Flags_ReadOnly);
+				BackupProtocolLogin::Flags_ReadOnly);
 
 			// Check that the restore fn returns resume possible,
 			// rather than doing anything




More information about the Boxbackup-commit mailing list