- Timestamp:
- 27/08/2011 15:06:46 (9 months ago)
- Location:
- box/trunk
- Files:
-
- 29 edited
- 2 moved
-
bin/bbackupd/BackupClientContext.cpp (modified) (6 diffs)
-
bin/bbackupd/BackupClientDeleteList.cpp (modified) (1 diff)
-
bin/bbackupd/BackupClientDirectoryRecord.cpp (modified) (10 diffs)
-
bin/bbackupd/BackupDaemon.cpp (modified) (7 diffs)
-
bin/bbackupd/BackupDaemon.h (modified) (3 diffs)
-
bin/bbackupquery/BackupQueries.cpp (modified) (19 diffs)
-
bin/bbackupquery/CommandCompletion.cpp (modified) (7 diffs)
-
bin/bbackupquery/bbackupquery.cpp (modified) (3 diffs)
-
bin/bbstored/BackupStoreDaemon.cpp (modified) (1 diff)
-
contrib/mac_osx (modified) (1 prop)
-
lib/backupclient/BackupClientRestore.cpp (modified) (2 diffs)
-
lib/backupstore (modified) (1 prop)
-
lib/backupstore/BackupCommands.cpp (modified) (30 diffs)
-
lib/backupstore/BackupStoreContext.cpp (modified) (1 diff)
-
lib/backupstore/BackupStoreContext.h (modified) (4 diffs)
-
lib/backupstore/BackupStoreFile.h (modified) (2 diffs)
-
lib/backupstore/Makefile.extra (modified) (1 diff)
-
lib/backupstore/backupprotocol.txt (modified) (2 diffs)
-
lib/server/Message.cpp (moved) (moved from box/trunk/lib/server/ProtocolObject.cpp) (10 diffs)
-
lib/server/Message.h (moved) (moved from box/trunk/lib/server/ProtocolObject.h) (3 diffs)
-
lib/server/Protocol.cpp (modified) (9 diffs)
-
lib/server/Protocol.h (modified) (7 diffs)
-
lib/server/makeprotocol.pl.in (modified) (20 diffs)
-
qdbm (modified) (1 prop)
-
test/backupstore/testbackupstore.cpp (modified) (59 diffs)
-
test/backupstorepatch/testbackupstorepatch.cpp (modified) (10 diffs)
-
test/basicserver/Makefile.extra (modified) (1 diff)
-
test/basicserver/TestCommands.cpp (modified) (5 diffs)
-
test/basicserver/testbasicserver.cpp (modified) (7 diffs)
-
test/bbackupd/Makefile.extra (modified) (1 diff)
-
test/bbackupd/testbbackupd.cpp (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbackupd/BackupClientContext.cpp
r2696 r2983 26 26 #include "BackupStoreException.h" 27 27 #include "BackupDaemon.h" 28 #include "autogen_BackupProtocol Client.h"28 #include "autogen_BackupProtocol.h" 29 29 #include "BackupStoreFile.h" 30 30 #include "Logging.h" … … 166 166 // Check the version of the server 167 167 { 168 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION));168 std::auto_ptr<BackupProtocolVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION)); 169 169 if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION) 170 170 { … … 174 174 175 175 // Login -- if this fails, the Protocol will exception 176 std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */));176 std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */)); 177 177 178 178 // Check that the client store marker is the one we expect … … 420 420 // Request filenames from the server, in a "safe" manner to ignore errors properly 421 421 { 422 BackupProtocol ClientGetObjectName send(ObjectID, ContainingDirectory);422 BackupProtocolGetObjectName send(ObjectID, ContainingDirectory); 423 423 connection.Send(send); 424 424 } 425 std::auto_ptr<BackupProtocol ObjectCl> preply(connection.Receive());425 std::auto_ptr<BackupProtocolMessage> preply(connection.Receive()); 426 426 427 427 // Is it of the right type? 428 if(preply->GetType() != BackupProtocol ClientObjectName::TypeID)428 if(preply->GetType() != BackupProtocolObjectName::TypeID) 429 429 { 430 430 // Was an error or something … … 433 433 434 434 // Cast to expected type. 435 BackupProtocol ClientObjectName *names = (BackupProtocolClientObjectName *)(preply.get());435 BackupProtocolObjectName *names = (BackupProtocolObjectName *)(preply.get()); 436 436 437 437 // Anything found? … … 483 483 484 484 // Is it a directory? 485 rIsDirectoryOut = ((names->GetFlags() & BackupProtocol ClientListDirectory::Flags_Dir) == BackupProtocolClientListDirectory::Flags_Dir);485 rIsDirectoryOut = ((names->GetFlags() & BackupProtocolListDirectory::Flags_Dir) == BackupProtocolListDirectory::Flags_Dir); 486 486 487 487 // Is it the current version? 488 rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocol ClientListDirectory::Flags_OldVersion | BackupProtocolClientListDirectory::Flags_Deleted)) == 0);488 rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolListDirectory::Flags_OldVersion | BackupProtocolListDirectory::Flags_Deleted)) == 0); 489 489 490 490 // And other information which may be required -
box/trunk/bin/bbackupd/BackupClientDeleteList.cpp
r2181 r2983 14 14 #include "BackupClientDeleteList.h" 15 15 #include "BackupClientContext.h" 16 #include "autogen_BackupProtocol Client.h"16 #include "autogen_BackupProtocol.h" 17 17 18 18 #include "MemLeakFindOn.h" -
box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
r2981 r2983 18 18 #include <string.h> 19 19 20 #include "autogen_BackupProtocol Client.h"20 #include "autogen_BackupProtocol.h" 21 21 #include "Archive.h" 22 22 #include "BackupClientContext.h" … … 336 336 file_st.st_nlink); 337 337 } 338 else if(file_st.st_nlink !=1)338 else if(file_st.st_nlink > 1) 339 339 { 340 340 if(!mSuppressMultipleLinksWarning) … … 614 614 615 615 // Query the directory 616 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(connection.QueryListDirectory(616 std::auto_ptr<BackupProtocolSuccess> dirreply(connection.QueryListDirectory( 617 617 mObjectID, 618 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, // both files and directories 619 BackupProtocolClientListDirectory::Flags_Deleted | BackupProtocolClientListDirectory::Flags_OldVersion, // exclude old/deleted stuff 618 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, // both files and directories 619 BackupProtocolListDirectory::Flags_Deleted | 620 BackupProtocolListDirectory::Flags_OldVersion, // exclude old/deleted stuff 620 621 true /* want attributes */)); 621 622 … … 831 832 // Rename the existing files (ie include old versions) on the server 832 833 connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, 833 BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject, 834 BackupProtocolMoveObject::Flags_MoveAllWithSameName | 835 BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, 834 836 storeFilename); 835 837 … … 1365 1367 // Rename the existing directory on the server 1366 1368 connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, 1367 BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject, 1369 BackupProtocolMoveObject::Flags_MoveAllWithSameName | 1370 BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, 1368 1371 storeFilename); 1369 1372 … … 1382 1385 { 1383 1386 // Create a new directory 1384 std::auto_ptr<BackupProtocol ClientSuccess> dirCreate(connection.QueryCreateDirectory(1387 std::auto_ptr<BackupProtocolSuccess> dirCreate(connection.QueryCreateDirectory( 1385 1388 mObjectID, attrModTime, storeFilename, attrStream)); 1386 1389 subDirObjectID = dirCreate->GetObjectID(); … … 1578 1581 // YES -- try to do diff, if possible 1579 1582 // First, query the server to see if there's an old version available 1580 std::auto_ptr<BackupProtocol ClientSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename));1583 std::auto_ptr<BackupProtocolSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename)); 1581 1584 int64_t diffFromID = getBlockIndex->GetObjectID(); 1582 1585 … … 1626 1629 // Upload the patch to the store 1627 1630 // 1628 std::auto_ptr<BackupProtocol ClientSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime,1631 std::auto_ptr<BackupProtocolSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime, 1629 1632 AttributesHash, isCompletelyDifferent?(0):(diffFromID), rStoreFilename, *pStreamToUpload)); 1630 1633 … … 1667 1670 1668 1671 // Send to store 1669 std::auto_ptr<BackupProtocol ClientSuccess> stored(1672 std::auto_ptr<BackupProtocolSuccess> stored( 1670 1673 connection.QueryStoreFile( 1671 1674 mObjectID, ModificationTime, … … 1693 1696 if(connection.GetLastError(type, subtype)) 1694 1697 { 1695 if(type == BackupProtocol ClientError::ErrorType1696 && subtype == BackupProtocol ClientError::Err_StorageLimitExceeded)1698 if(type == BackupProtocolError::ErrorType 1699 && subtype == BackupProtocolError::Err_StorageLimitExceeded) 1697 1700 { 1698 1701 // The hard limit was exceeded on the server, notify! -
box/trunk/bin/bbackupd/BackupDaemon.cpp
r2981 r2983 51 51 #include "SSLLib.h" 52 52 53 #include "autogen_BackupProtocol Client.h"53 #include "autogen_BackupProtocol.h" 54 54 #include "autogen_ClientException.h" 55 55 #include "autogen_ConversionException.h" … … 697 697 mDoSyncForcedByPreviousSyncError = false; 698 698 699 // Notify system administrator about the final state of the backup 699 700 if(errorOccurred) 700 701 { … … 758 759 } 759 760 } 760 // Notify system administrator about the final state of the backup 761 elseif(mReadErrorsOnFilesystemObjects)761 762 if(mReadErrorsOnFilesystemObjects) 762 763 { 763 764 NotifySysadmin(SysadminNotifier::ReadError); 764 765 } 765 else if(mStorageLimitExceeded) 766 767 if(mStorageLimitExceeded) 766 768 { 767 769 NotifySysadmin(SysadminNotifier::StoreFull); 768 770 } 769 else 771 772 if (!errorOccurred && !mReadErrorsOnFilesystemObjects && 773 !mStorageLimitExceeded) 770 774 { 771 775 NotifySysadmin(SysadminNotifier::BackupOK); … … 1005 1009 1006 1010 (*i)->mpDirectoryRecord->SyncDirectory(params, 1007 BackupProtocol ClientListDirectory::RootDirectory,1011 BackupProtocolListDirectory::RootDirectory, 1008 1012 locationPath, std::string("/") + (*i)->mName); 1009 1013 … … 2098 2102 // Going to need a copy of the root directory. Get a connection, 2099 2103 // and fetch it. 2100 BackupProtocolC lient &connection(rClientContext.GetConnection());2104 BackupProtocolCallable& connection(rClientContext.GetConnection()); 2101 2105 2102 2106 // Ask server for a list of everything in the root directory, 2103 2107 // which is a directory itself 2104 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(2108 std::auto_ptr<BackupProtocolSuccess> dirreply( 2105 2109 connection.QueryListDirectory( 2106 BackupProtocol ClientListDirectory::RootDirectory,2110 BackupProtocolListDirectory::RootDirectory, 2107 2111 // only directories 2108 BackupProtocol ClientListDirectory::Flags_Dir,2112 BackupProtocolListDirectory::Flags_Dir, 2109 2113 // exclude old/deleted stuff 2110 BackupProtocol ClientListDirectory::Flags_Deleted |2111 BackupProtocol ClientListDirectory::Flags_OldVersion,2114 BackupProtocolListDirectory::Flags_Deleted | 2115 BackupProtocolListDirectory::Flags_OldVersion, 2112 2116 false /* no attributes */)); 2113 2117 … … 2349 2353 { 2350 2354 MemBlockStream attrStream(attr); 2351 std::auto_ptr<BackupProtocol ClientSuccess>2355 std::auto_ptr<BackupProtocolSuccess> 2352 2356 dirCreate(connection.QueryCreateDirectory( 2353 BackupProtocol ClientListDirectory::RootDirectory,2357 BackupProtocolListDirectory::RootDirectory, 2354 2358 attrModTime, dirname, attrStream)); 2355 2359 … … 2895 2899 // Entries to delete, and it's the right time to do so... 2896 2900 BOX_NOTICE("Deleting unused locations from store root..."); 2897 BackupProtocolC lient&connection(rContext.GetConnection());2901 BackupProtocolCallable &connection(rContext.GetConnection()); 2898 2902 for(std::vector<std::pair<int64_t,std::string> >::iterator 2899 2903 i(mUnusedRootDirEntries.begin()); -
box/trunk/bin/bbackupd/BackupDaemon.h
r2981 r2983 25 25 #include "TLSContext.h" 26 26 27 #include "autogen_BackupProtocol Client.h"27 #include "autogen_BackupProtocol.h" 28 28 29 29 #ifdef WIN32 … … 383 383 { 384 384 std::ostringstream msgs; 385 if (type != BackupProtocol ClientError::ErrorType)385 if (type != BackupProtocolError::ErrorType) 386 386 { 387 387 msgs << "unknown error type " << type; … … 391 391 switch(subtype) 392 392 { 393 case BackupProtocol ClientError::Err_WrongVersion:393 case BackupProtocolError::Err_WrongVersion: 394 394 msgs << "WrongVersion"; 395 395 break; 396 case BackupProtocol ClientError::Err_NotInRightProtocolPhase:396 case BackupProtocolError::Err_NotInRightProtocolPhase: 397 397 msgs << "NotInRightProtocolPhase"; 398 398 break; 399 case BackupProtocol ClientError::Err_BadLogin:399 case BackupProtocolError::Err_BadLogin: 400 400 msgs << "BadLogin"; 401 401 break; 402 case BackupProtocol ClientError::Err_CannotLockStoreForWriting:402 case BackupProtocolError::Err_CannotLockStoreForWriting: 403 403 msgs << "CannotLockStoreForWriting"; 404 404 break; 405 case BackupProtocol ClientError::Err_SessionReadOnly:405 case BackupProtocolError::Err_SessionReadOnly: 406 406 msgs << "SessionReadOnly"; 407 407 break; 408 case BackupProtocol ClientError::Err_FileDoesNotVerify:408 case BackupProtocolError::Err_FileDoesNotVerify: 409 409 msgs << "FileDoesNotVerify"; 410 410 break; 411 case BackupProtocol ClientError::Err_DoesNotExist:411 case BackupProtocolError::Err_DoesNotExist: 412 412 msgs << "DoesNotExist"; 413 413 break; 414 case BackupProtocol ClientError::Err_DirectoryAlreadyExists:414 case BackupProtocolError::Err_DirectoryAlreadyExists: 415 415 msgs << "DirectoryAlreadyExists"; 416 416 break; 417 case BackupProtocol ClientError::Err_CannotDeleteRoot:417 case BackupProtocolError::Err_CannotDeleteRoot: 418 418 msgs << "CannotDeleteRoot"; 419 419 break; 420 case BackupProtocol ClientError::Err_TargetNameExists:420 case BackupProtocolError::Err_TargetNameExists: 421 421 msgs << "TargetNameExists"; 422 422 break; 423 case BackupProtocol ClientError::Err_StorageLimitExceeded:423 case BackupProtocolError::Err_StorageLimitExceeded: 424 424 msgs << "StorageLimitExceeded"; 425 425 break; 426 case BackupProtocol ClientError::Err_DiffFromFileDoesNotExist:426 case BackupProtocolError::Err_DiffFromFileDoesNotExist: 427 427 msgs << "DiffFromFileDoesNotExist"; 428 428 break; 429 case BackupProtocol ClientError::Err_DoesNotExistInDirectory:429 case BackupProtocolError::Err_DoesNotExistInDirectory: 430 430 msgs << "DoesNotExistInDirectory"; 431 431 break; 432 case BackupProtocol ClientError::Err_PatchConsistencyError:432 case BackupProtocolError::Err_PatchConsistencyError: 433 433 msgs << "PatchConsistencyError"; 434 434 break; -
box/trunk/bin/bbackupquery/BackupQueries.cpp
r2875 r2983 50 50 #include "SelfFlushingStream.h" 51 51 #include "Utils.h" 52 #include "autogen_BackupProtocol Client.h"52 #include "autogen_BackupProtocol.h" 53 53 54 54 #include "MemLeakFindOn.h" … … 359 359 { 360 360 // Generate exclude flags 361 int16_t excludeFlags = BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING;362 if(!opts[LIST_OPTION_ALLOWOLD]) excludeFlags |= BackupProtocol ClientListDirectory::Flags_OldVersion;363 if(!opts[LIST_OPTION_ALLOWDELETED]) excludeFlags |= BackupProtocol ClientListDirectory::Flags_Deleted;361 int16_t excludeFlags = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING; 362 if(!opts[LIST_OPTION_ALLOWOLD]) excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion; 363 if(!opts[LIST_OPTION_ALLOWDELETED]) excludeFlags |= BackupProtocolListDirectory::Flags_Deleted; 364 364 365 365 // Do communication … … 368 368 mrConnection.QueryListDirectory( 369 369 DirID, 370 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,370 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 371 371 // both files and directories 372 372 excludeFlags, … … 435 435 *(f++) = ' '; 436 436 *(f++) = '\0'; 437 printf( displayflags);437 printf("%s", displayflags); 438 438 439 439 if(en_flags != 0) … … 545 545 // Start from current stack, or root, whichever is required 546 546 std::vector<std::pair<std::string, int64_t> > stack; 547 int64_t dirID = BackupProtocol ClientListDirectory::RootDirectory;547 int64_t dirID = BackupProtocolListDirectory::RootDirectory; 548 548 if(rDirName.size() > 0 && rDirName[0] == '/') 549 549 { … … 561 561 562 562 // Generate exclude flags 563 int16_t excludeFlags = BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING;564 if(!AllowOldVersion) excludeFlags |= BackupProtocol ClientListDirectory::Flags_OldVersion;565 if(!AllowDeletedDirs) excludeFlags |= BackupProtocol ClientListDirectory::Flags_Deleted;563 int16_t excludeFlags = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING; 564 if(!AllowOldVersion) excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion; 565 if(!AllowDeletedDirs) excludeFlags |= BackupProtocolListDirectory::Flags_Deleted; 566 566 567 567 // Read directories … … 583 583 584 584 // New dir ID 585 dirID = (stack.size() > 0)?(stack[stack.size() - 1].second):BackupProtocol ClientListDirectory::RootDirectory;585 dirID = (stack.size() > 0)?(stack[stack.size() - 1].second):BackupProtocolListDirectory::RootDirectory; 586 586 } 587 587 else 588 588 { 589 589 // At root anyway 590 dirID = BackupProtocol ClientListDirectory::RootDirectory;590 dirID = BackupProtocolListDirectory::RootDirectory; 591 591 } 592 592 } … … 594 594 { 595 595 // Not blank element. Read current directory. 596 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(mrConnection.QueryListDirectory(596 std::auto_ptr<BackupProtocolSuccess> dirreply(mrConnection.QueryListDirectory( 597 597 dirID, 598 BackupProtocol ClientListDirectory::Flags_Dir, // just directories598 BackupProtocolListDirectory::Flags_Dir, // just directories 599 599 excludeFlags, 600 600 true /* want attributes */)); … … 647 647 if(mDirStack.size() == 0) 648 648 { 649 return BackupProtocol ClientListDirectory::RootDirectory;649 return BackupProtocolListDirectory::RootDirectory; 650 650 } 651 651 … … 838 838 { 839 839 // Request object 840 std::auto_ptr<BackupProtocol ClientSuccess> getobj(mrConnection.QueryGetObject(id));841 if(getobj->GetObjectID() != BackupProtocol ClientGetObject::NoObject)840 std::auto_ptr<BackupProtocolSuccess> getobj(mrConnection.QueryGetObject(id)); 841 if(getobj->GetObjectID() != BackupProtocolGetObject::NoObject) 842 842 { 843 843 // Stream that object out to the file … … 1018 1018 { 1019 1019 // can retrieve anything by ID 1020 flagsExclude = BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING;1020 flagsExclude = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING; 1021 1021 } 1022 1022 else … … 1024 1024 // only current versions by name 1025 1025 flagsExclude = 1026 BackupProtocol ClientListDirectory::Flags_OldVersion |1027 BackupProtocol ClientListDirectory::Flags_Deleted;1026 BackupProtocolListDirectory::Flags_OldVersion | 1027 BackupProtocolListDirectory::Flags_Deleted; 1028 1028 } 1029 1029 1030 1030 1031 1031 fileId = FindFileID(args[0], opts, &dirId, &localName, 1032 BackupProtocol ClientListDirectory::Flags_File, // just files1032 BackupProtocolListDirectory::Flags_File, // just files 1033 1033 flagsExclude, NULL /* don't care about flags found */); 1034 1034 … … 1520 1520 mrConnection.QueryListDirectory( 1521 1521 DirID, 1522 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,1522 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 1523 1523 // get everything 1524 BackupProtocol ClientListDirectory::Flags_OldVersion |1525 BackupProtocol ClientListDirectory::Flags_Deleted,1524 BackupProtocolListDirectory::Flags_OldVersion | 1525 BackupProtocolListDirectory::Flags_Deleted, 1526 1526 // except for old versions and deleted files 1527 1527 true /* want attributes */); … … 1897 1897 } 1898 1898 1899 if(dirID == BackupProtocol ClientListDirectory::RootDirectory)1899 if(dirID == BackupProtocolListDirectory::RootDirectory) 1900 1900 { 1901 1901 BOX_ERROR("Cannot restore the root directory -- restore locations individually."); … … 2054 2054 2055 2055 // Request full details from the server 2056 std::auto_ptr<BackupProtocol ClientAccountUsage> usage(mrConnection.QueryGetAccountUsage());2056 std::auto_ptr<BackupProtocolAccountUsage> usage(mrConnection.QueryGetAccountUsage()); 2057 2057 2058 2058 // Display each entry in turn … … 2130 2130 fileId = FindFileID(storeDirEncoded, opts, &parentId, &fileName, 2131 2131 /* include files and directories */ 2132 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING,2132 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 2133 2133 /* include old and deleted files */ 2134 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING,2134 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 2135 2135 &flagsOut); 2136 2136 … … 2145 2145 { 2146 2146 // Undelete object 2147 if(flagsOut & BackupProtocol ClientListDirectory::Flags_File)2147 if(flagsOut & BackupProtocolListDirectory::Flags_File) 2148 2148 { 2149 2149 mrConnection.QueryUndeleteFile(parentId, fileId); … … 2210 2210 fileId = FindFileID(storeDirEncoded, opts, &parentId, &fileName, 2211 2211 /* include files and directories */ 2212 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING,2212 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 2213 2213 /* exclude old and deleted files */ 2214 BackupProtocol ClientListDirectory::Flags_OldVersion |2215 BackupProtocol ClientListDirectory::Flags_Deleted,2214 BackupProtocolListDirectory::Flags_OldVersion | 2215 BackupProtocolListDirectory::Flags_Deleted, 2216 2216 &flagsOut); 2217 2217 … … 2228 2228 { 2229 2229 // Delete object 2230 if(flagsOut & BackupProtocol ClientListDirectory::Flags_File)2230 if(flagsOut & BackupProtocolListDirectory::Flags_File) 2231 2231 { 2232 2232 mrConnection.QueryDeleteFile(parentId, fn); -
box/trunk/bin/bbackupquery/CommandCompletion.cpp
r2878 r2983 33 33 #include "Configuration.h" 34 34 35 #include "autogen_BackupProtocol Client.h"35 #include "autogen_BackupProtocol.h" 36 36 37 37 #include "MemLeakFindOn.h" … … 155 155 if (rCommand.mOptions.find(LIST_OPTION_ALLOWOLD) == std::string::npos) 156 156 { 157 excludeFlags |= BackupProtocol ClientListDirectory::Flags_OldVersion;157 excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion; 158 158 } 159 159 160 160 if (rCommand.mOptions.find(LIST_OPTION_ALLOWDELETED) == std::string::npos) 161 161 { 162 excludeFlags |= BackupProtocol ClientListDirectory::Flags_Deleted;162 excludeFlags |= BackupProtocolListDirectory::Flags_Deleted; 163 163 } 164 164 … … 226 226 227 227 bool completeFiles = includeFlags & 228 BackupProtocol ClientListDirectory::Flags_File;228 BackupProtocolListDirectory::Flags_File; 229 229 bool completeDirs = includeFlags & 230 BackupProtocol ClientListDirectory::Flags_Dir;230 BackupProtocolListDirectory::Flags_Dir; 231 231 int16_t listFlags = 0; 232 232 233 233 if(completeFiles) 234 234 { 235 listFlags = BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING;235 listFlags = BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING; 236 236 } 237 237 else if(completeDirs) 238 238 { 239 listFlags = BackupProtocol ClientListDirectory::Flags_Dir;239 listFlags = BackupProtocolListDirectory::Flags_Dir; 240 240 } 241 241 … … 259 259 { 260 260 if(en->IsDir() && 261 (includeFlags & BackupProtocol ClientListDirectory::Flags_Dir) == 0)261 (includeFlags & BackupProtocolListDirectory::Flags_Dir) == 0) 262 262 { 263 263 // Was looking for a file, but this is a … … 283 283 completions = CompleteRemoteFileOrDirectory(rCommand, prefix, 284 284 rProtocol, rQueries, 285 BackupProtocol ClientListDirectory::Flags_Dir);285 BackupProtocolListDirectory::Flags_Dir); 286 286 ) 287 287 … … 289 289 completions = CompleteRemoteFileOrDirectory(rCommand, prefix, 290 290 rProtocol, rQueries, 291 BackupProtocol ClientListDirectory::Flags_File);291 BackupProtocolListDirectory::Flags_File); 292 292 ) 293 293 … … 325 325 rProtocol.QueryListDirectory( 326 326 listDirId, 327 BackupProtocol ClientListDirectory::Flags_File,327 BackupProtocolListDirectory::Flags_File, 328 328 excludeFlags, false /* no attributes */); 329 329 -
box/trunk/bin/bbackupquery/bbackupquery.cpp
r2869 r2983 51 51 #include "BackupStoreConstants.h" 52 52 #include "BackupStoreException.h" 53 #include "autogen_BackupProtocol Client.h"53 #include "autogen_BackupProtocol.h" 54 54 #include "BackupQueries.h" 55 55 #include "FdGetLine.h" … … 448 448 // Check the version of the server 449 449 { 450 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION));450 std::auto_ptr<BackupProtocolVersion> serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 451 451 if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION) 452 452 { … … 456 456 // Login -- if this fails, the Protocol will exception 457 457 connection.QueryLogin(conf.GetKeyValueUint32("AccountNumber"), 458 (readWrite)?0:(BackupProtocol ClientLogin::Flags_ReadOnly));458 (readWrite)?0:(BackupProtocolLogin::Flags_ReadOnly)); 459 459 460 460 // 5. Tell user. -
box/trunk/bin/bbstored/BackupStoreDaemon.cpp
r2982 r2983 21 21 #include "BackupStoreDaemon.h" 22 22 #include "BackupStoreConfigVerify.h" 23 #include "autogen_BackupProtocol Server.h"23 #include "autogen_BackupProtocol.h" 24 24 #include "RaidFileController.h" 25 25 #include "BackupStoreAccountDatabase.h" -
box/trunk/contrib/mac_osx
-
Property
svn:ignore
set to
org.boxbackup.*.plist
-
Property
svn:ignore
set to
-
box/trunk/lib/backupclient/BackupClientRestore.cpp
r2828 r2983 23 23 24 24 #include "BackupClientRestore.h" 25 #include "autogen_BackupProtocol Client.h"25 #include "autogen_BackupProtocol.h" 26 26 #include "CommonException.h" 27 27 #include "BackupClientFileAttributes.h" … … 444 444 rConnection.QueryListDirectory( 445 445 DirectoryID, 446 Params.RestoreDeleted?(BackupProtocol ClientListDirectory::Flags_Deleted):(BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING),447 BackupProtocol ClientListDirectory::Flags_OldVersion | (Params.RestoreDeleted?(0):(BackupProtocolClientListDirectory::Flags_Deleted)),446 Params.RestoreDeleted?(BackupProtocolListDirectory::Flags_Deleted):(BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING), 447 BackupProtocolListDirectory::Flags_OldVersion | (Params.RestoreDeleted?(0):(BackupProtocolListDirectory::Flags_Deleted)), 448 448 true /* want attributes */); 449 449 -
box/trunk/lib/backupstore
- Property svn:ignore
-
old new 1 1 Makefile 2 autogen_*
-
- Property svn:ignore
-
box/trunk/lib/backupstore/BackupCommands.cpp
r2945 r2983 13 13 #include <sstream> 14 14 15 #include "autogen_BackupProtocol Server.h"15 #include "autogen_BackupProtocol.h" 16 16 #include "autogen_RaidFileException.h" 17 17 #include "BackupConstants.h" … … 32 32 33 33 #define PROTOCOL_ERROR(code) \ 34 std::auto_ptr< ProtocolObject>(new BackupProtocolServerError( \35 BackupProtocol ServerError::ErrorType, \36 BackupProtocol ServerError::code));34 std::auto_ptr<BackupProtocolMessage>(new BackupProtocolError( \ 35 BackupProtocolError::ErrorType, \ 36 BackupProtocolError::code)); 37 37 38 38 #define CHECK_PHASE(phase) \ … … 51 51 // 52 52 // Function 53 // Name: BackupProtocol ServerVersion::DoCommand(Protocol &, BackupStoreContext &)53 // Name: BackupProtocolVersion::DoCommand(Protocol &, BackupStoreContext &) 54 54 // Purpose: Return the current version, or an error if the requested version isn't allowed 55 55 // Created: 2003/08/20 56 56 // 57 57 // -------------------------------------------------------------------------- 58 std::auto_ptr< ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)58 std::auto_ptr<BackupProtocolMessage> BackupProtocolVersion::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 59 59 { 60 60 CHECK_PHASE(Phase_Version) … … 70 70 71 71 // Return our version 72 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerVersion(BACKUP_STORE_SERVER_VERSION));73 } 74 75 // -------------------------------------------------------------------------- 76 // 77 // Function 78 // Name: BackupProtocol ServerLogin::DoCommand(Protocol &, BackupStoreContext &)72 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolVersion(BACKUP_STORE_SERVER_VERSION)); 73 } 74 75 // -------------------------------------------------------------------------- 76 // 77 // Function 78 // Name: BackupProtocolLogin::DoCommand(Protocol &, BackupStoreContext &) 79 79 // Purpose: Return the current version, or an error if the requested version isn't allowed 80 80 // Created: 2003/08/20 81 81 // 82 82 // -------------------------------------------------------------------------- 83 std::auto_ptr< ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)83 std::auto_ptr<BackupProtocolMessage> BackupProtocolLogin::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 84 84 { 85 85 CHECK_PHASE(Phase_Login) … … 139 139 140 140 // Return success 141 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerLoginConfirmed(clientStoreMarker, blocksUsed, blocksSoftLimit, blocksHardLimit));142 } 143 144 // -------------------------------------------------------------------------- 145 // 146 // Function 147 // Name: BackupProtocol ServerFinished::DoCommand(Protocol &, BackupStoreContext &)141 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolLoginConfirmed(clientStoreMarker, blocksUsed, blocksSoftLimit, blocksHardLimit)); 142 } 143 144 // -------------------------------------------------------------------------- 145 // 146 // Function 147 // Name: BackupProtocolFinished::DoCommand(Protocol &, BackupStoreContext &) 148 148 // Purpose: Marks end of conversation (Protocol framework handles this) 149 149 // Created: 2003/08/20 150 150 // 151 151 // -------------------------------------------------------------------------- 152 std::auto_ptr< ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)152 std::auto_ptr<BackupProtocolMessage> BackupProtocolFinished::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 153 153 { 154 154 BOX_NOTICE("Session finished for Client ID " << … … 159 159 160 160 // can be called in any phase 161 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerFinished);162 } 163 164 165 // -------------------------------------------------------------------------- 166 // 167 // Function 168 // Name: BackupProtocol ServerListDirectory::DoCommand(Protocol &, BackupStoreContext &)161 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolFinished); 162 } 163 164 165 // -------------------------------------------------------------------------- 166 // 167 // Function 168 // Name: BackupProtocolListDirectory::DoCommand(Protocol &, BackupStoreContext &) 169 169 // Purpose: Command to list a directory 170 170 // Created: 2003/09/02 171 171 // 172 172 // -------------------------------------------------------------------------- 173 std::auto_ptr< ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)173 std::auto_ptr<BackupProtocolMessage> BackupProtocolListDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 174 174 { 175 175 CHECK_PHASE(Phase_Commands) … … 201 201 rProtocol.SendStreamAfterCommand(stream.release()); 202 202 203 return std::auto_ptr< ProtocolObject>(204 new BackupProtocolS erverSuccess(mObjectID));205 } 206 207 // -------------------------------------------------------------------------- 208 // 209 // Function 210 // Name: BackupProtocolS erverStoreFile::DoCommand(Protocol &, BackupStoreContext &)203 return std::auto_ptr<BackupProtocolMessage>( 204 new BackupProtocolSuccess(mObjectID)); 205 } 206 207 // -------------------------------------------------------------------------- 208 // 209 // Function 210 // Name: BackupProtocolStoreFile::DoCommand(Protocol &, BackupStoreContext &) 211 211 // Purpose: Command to store a file on the server 212 212 // Created: 2003/09/02 213 213 // 214 214 // -------------------------------------------------------------------------- 215 std::auto_ptr< ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)215 std::auto_ptr<BackupProtocolMessage> BackupProtocolStoreFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 216 216 { 217 217 CHECK_PHASE(Phase_Commands) 218 218 CHECK_WRITEABLE_SESSION 219 219 220 std::auto_ptr< ProtocolObject> hookResult =220 std::auto_ptr<BackupProtocolMessage> hookResult = 221 221 rContext.StartCommandHook(*this); 222 222 if(hookResult.get()) … … 264 264 265 265 // Tell the caller what the file was 266 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(id));267 } 268 269 270 271 272 // -------------------------------------------------------------------------- 273 // 274 // Function 275 // Name: BackupProtocol ServerGetObject::DoCommand(Protocol &, BackupStoreContext &)266 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(id)); 267 } 268 269 270 271 272 // -------------------------------------------------------------------------- 273 // 274 // Function 275 // Name: BackupProtocolGetObject::DoCommand(Protocol &, BackupStoreContext &) 276 276 // Purpose: Command to get an arbitary object from the server 277 277 // Created: 2003/09/03 278 278 // 279 279 // -------------------------------------------------------------------------- 280 std::auto_ptr< ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)280 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObject::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 281 281 { 282 282 CHECK_PHASE(Phase_Commands) … … 285 285 if(!rContext.ObjectExists(mObjectID)) 286 286 { 287 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(NoObject));287 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(NoObject)); 288 288 } 289 289 … … 295 295 296 296 // Tell the caller what the file was 297 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));298 } 299 300 // -------------------------------------------------------------------------- 301 // 302 // Function 303 // Name: BackupProtocol ServerGetFile::DoCommand(Protocol &, BackupStoreContext &)297 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 298 } 299 300 // -------------------------------------------------------------------------- 301 // 302 // Function 303 // Name: BackupProtocolGetFile::DoCommand(Protocol &, BackupStoreContext &) 304 304 // Purpose: Command to get an file object from the server -- may have to do a bit of 305 305 // work to get the object. … … 307 307 // 308 308 // -------------------------------------------------------------------------- 309 std::auto_ptr< ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)309 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 310 310 { 311 311 CHECK_PHASE(Phase_Commands) … … 461 461 462 462 // Tell the caller what the file was 463 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));464 } 465 466 467 // -------------------------------------------------------------------------- 468 // 469 // Function 470 // Name: BackupProtocol ServerCreateDirectory::DoCommand(Protocol &, BackupStoreContext &)463 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 464 } 465 466 467 // -------------------------------------------------------------------------- 468 // 469 // Function 470 // Name: BackupProtocolCreateDirectory::DoCommand(Protocol &, BackupStoreContext &) 471 471 // Purpose: Create directory command 472 472 // Created: 2003/09/04 473 473 // 474 474 // -------------------------------------------------------------------------- 475 std::auto_ptr< ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)475 std::auto_ptr<BackupProtocolMessage> BackupProtocolCreateDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 476 476 { 477 477 CHECK_PHASE(Phase_Commands) … … 501 501 502 502 // Tell the caller what the file was 503 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(id));504 } 505 506 507 508 // -------------------------------------------------------------------------- 509 // 510 // Function 511 // Name: BackupProtocol ServerChangeDirAttributes::DoCommand(Protocol &, BackupStoreContext &)503 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(id)); 504 } 505 506 507 508 // -------------------------------------------------------------------------- 509 // 510 // Function 511 // Name: BackupProtocolChangeDirAttributes::DoCommand(Protocol &, BackupStoreContext &) 512 512 // Purpose: Change attributes on directory 513 513 // Created: 2003/09/06 514 514 // 515 515 // -------------------------------------------------------------------------- 516 std::auto_ptr< ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)516 std::auto_ptr<BackupProtocolMessage> BackupProtocolChangeDirAttributes::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 517 517 { 518 518 CHECK_PHASE(Phase_Commands) … … 530 530 531 531 // Tell the caller what the file was 532 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));533 } 534 535 536 // -------------------------------------------------------------------------- 537 // 538 // Function 539 // Name: BackupProtocolSe rverSetReplacementFileAttributes::DoCommand(Protocol &, BackupStoreContext &)532 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 533 } 534 535 536 // -------------------------------------------------------------------------- 537 // 538 // Function 539 // Name: BackupProtocolSetReplacementFileAttributes::DoCommand(Protocol &, BackupStoreContext &) 540 540 // Purpose: Change attributes on directory 541 541 // Created: 2003/09/06 542 542 // 543 543 // -------------------------------------------------------------------------- 544 std::auto_ptr< ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)544 std::auto_ptr<BackupProtocolMessage> BackupProtocolSetReplacementFileAttributes::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 545 545 { 546 546 CHECK_PHASE(Phase_Commands) … … 563 563 564 564 // Tell the caller what the file was 565 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(objectID));566 } 567 568 569 570 // -------------------------------------------------------------------------- 571 // 572 // Function 573 // Name: BackupProtocol ServerDeleteFile::DoCommand(BackupProtocolServer&, BackupStoreContext &)565 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID)); 566 } 567 568 569 570 // -------------------------------------------------------------------------- 571 // 572 // Function 573 // Name: BackupProtocolDeleteFile::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 574 574 // Purpose: Delete a file 575 575 // Created: 2003/10/21 576 576 // 577 577 // -------------------------------------------------------------------------- 578 std::auto_ptr< ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)578 std::auto_ptr<BackupProtocolMessage> BackupProtocolDeleteFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 579 579 { 580 580 CHECK_PHASE(Phase_Commands) … … 586 586 587 587 // return the object ID or zero for not found 588 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(objectID));589 } 590 591 592 // -------------------------------------------------------------------------- 593 // 594 // Function 595 // Name: BackupProtocol ServerUndeleteFile::DoCommand(596 // BackupProtocol Server&, BackupStoreContext &)588 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID)); 589 } 590 591 592 // -------------------------------------------------------------------------- 593 // 594 // Function 595 // Name: BackupProtocolUndeleteFile::DoCommand( 596 // BackupProtocolBase &, BackupStoreContext &) 597 597 // Purpose: Undelete a file 598 598 // Created: 2008-09-12 599 599 // 600 600 // -------------------------------------------------------------------------- 601 std::auto_ptr< ProtocolObject> BackupProtocolServerUndeleteFile::DoCommand(602 BackupProtocol Server &rProtocol, BackupStoreContext &rContext)601 std::auto_ptr<BackupProtocolMessage> BackupProtocolUndeleteFile::DoCommand( 602 BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 603 603 { 604 604 CHECK_PHASE(Phase_Commands) … … 609 609 610 610 // return the object ID or zero for not found 611 return std::auto_ptr< ProtocolObject>(612 new BackupProtocolS erverSuccess(result ? mObjectID : 0));613 } 614 615 616 // -------------------------------------------------------------------------- 617 // 618 // Function 619 // Name: BackupProtocol ServerDeleteDirectory::DoCommand(BackupProtocolServer&, BackupStoreContext &)611 return std::auto_ptr<BackupProtocolMessage>( 612 new BackupProtocolSuccess(result ? mObjectID : 0)); 613 } 614 615 616 // -------------------------------------------------------------------------- 617 // 618 // Function 619 // Name: BackupProtocolDeleteDirectory::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 620 620 // Purpose: Delete a directory 621 621 // Created: 2003/10/21 622 622 // 623 623 // -------------------------------------------------------------------------- 624 std::auto_ptr< ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)624 std::auto_ptr<BackupProtocolMessage> BackupProtocolDeleteDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 625 625 { 626 626 CHECK_PHASE(Phase_Commands) … … 649 649 650 650 // return the object ID 651 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));652 } 653 654 655 // -------------------------------------------------------------------------- 656 // 657 // Function 658 // Name: BackupProtocol ServerUndeleteDirectory::DoCommand(BackupProtocolServer&, BackupStoreContext &)651 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 652 } 653 654 655 // -------------------------------------------------------------------------- 656 // 657 // Function 658 // Name: BackupProtocolUndeleteDirectory::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 659 659 // Purpose: Undelete a directory 660 660 // Created: 23/11/03 661 661 // 662 662 // -------------------------------------------------------------------------- 663 std::auto_ptr< ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)663 std::auto_ptr<BackupProtocolMessage> BackupProtocolUndeleteDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 664 664 { 665 665 CHECK_PHASE(Phase_Commands) … … 676 676 677 677 // return the object ID 678 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));679 } 680 681 // -------------------------------------------------------------------------- 682 // 683 // Function 684 // Name: BackupProtocolSe rverSetClientStoreMarker::DoCommand(BackupProtocolServer&, BackupStoreContext &)678 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 679 } 680 681 // -------------------------------------------------------------------------- 682 // 683 // Function 684 // Name: BackupProtocolSetClientStoreMarker::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 685 685 // Purpose: Command to set the client's store marker 686 686 // Created: 2003/10/29 687 687 // 688 688 // -------------------------------------------------------------------------- 689 std::auto_ptr< ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)689 std::auto_ptr<BackupProtocolMessage> BackupProtocolSetClientStoreMarker::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 690 690 { 691 691 CHECK_PHASE(Phase_Commands) … … 696 696 697 697 // return store marker set 698 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mClientStoreMarker));699 } 700 701 702 // -------------------------------------------------------------------------- 703 // 704 // Function 705 // Name: BackupProtocol ServerMoveObject::DoCommand(BackupProtocolServer&, BackupStoreContext &)698 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mClientStoreMarker)); 699 } 700 701 702 // -------------------------------------------------------------------------- 703 // 704 // Function 705 // Name: BackupProtocolMoveObject::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 706 706 // Purpose: Command to move an object from one directory to another 707 707 // Created: 2003/11/12 708 708 // 709 709 // -------------------------------------------------------------------------- 710 std::auto_ptr< ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)710 std::auto_ptr<BackupProtocolMessage> BackupProtocolMoveObject::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 711 711 { 712 712 CHECK_PHASE(Phase_Commands) … … 737 737 738 738 // Return the object ID 739 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));740 } 741 742 743 // -------------------------------------------------------------------------- 744 // 745 // Function 746 // Name: BackupProtocol ServerGetObjectName::DoCommand(BackupProtocolServer&, BackupStoreContext &)739 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 740 } 741 742 743 // -------------------------------------------------------------------------- 744 // 745 // Function 746 // Name: BackupProtocolGetObjectName::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 747 747 // Purpose: Command to find the name of an object 748 748 // Created: 12/11/03 749 749 // 750 750 // -------------------------------------------------------------------------- 751 std::auto_ptr< ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)751 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObjectName::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 752 752 { 753 753 CHECK_PHASE(Phase_Commands) … … 772 772 if(!rContext.ObjectExists(dirID, BackupStoreContext::ObjectExists_Directory)) 773 773 { 774 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerObjectName(BackupProtocolServerObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0));774 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolObjectName(BackupProtocolObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0)); 775 775 } 776 776 … … 787 787 { 788 788 // Abort! 789 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerObjectName(BackupProtocolServerObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0));789 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolObjectName(BackupProtocolObjectName::NumNameElements_ObjectDoesntExist, 0, 0, 0)); 790 790 } 791 791 … … 827 827 828 828 // Make reply 829 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerObjectName(numNameElements, modTime, attrModHash, objectFlags));830 } 831 832 833 834 // -------------------------------------------------------------------------- 835 // 836 // Function 837 // Name: BackupProtocol ServerGetBlockIndexByID::DoCommand(BackupProtocolServer&, BackupStoreContext &)829 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolObjectName(numNameElements, modTime, attrModHash, objectFlags)); 830 } 831 832 833 834 // -------------------------------------------------------------------------- 835 // 836 // Function 837 // Name: BackupProtocolGetBlockIndexByID::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 838 838 // Purpose: Get the block index from a file, by ID 839 839 // Created: 19/1/04 840 840 // 841 841 // -------------------------------------------------------------------------- 842 std::auto_ptr< ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)842 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetBlockIndexByID::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 843 843 { 844 844 CHECK_PHASE(Phase_Commands) … … 854 854 855 855 // Return the object ID 856 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(mObjectID));857 } 858 859 860 // -------------------------------------------------------------------------- 861 // 862 // Function 863 // Name: BackupProtocol ServerGetBlockIndexByName::DoCommand(BackupProtocolServer&, BackupStoreContext &)856 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 857 } 858 859 860 // -------------------------------------------------------------------------- 861 // 862 // Function 863 // Name: BackupProtocolGetBlockIndexByName::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 864 864 // Purpose: Get the block index from a file, by name within a directory 865 865 // Created: 19/1/04 866 866 // 867 867 // -------------------------------------------------------------------------- 868 std::auto_ptr< ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)868 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetBlockIndexByName::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 869 869 { 870 870 CHECK_PHASE(Phase_Commands) … … 893 893 { 894 894 // No... return a zero object ID 895 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(0));895 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(0)); 896 896 } 897 897 … … 906 906 907 907 // Return the object ID 908 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerSuccess(objectID));909 } 910 911 912 // -------------------------------------------------------------------------- 913 // 914 // Function 915 // Name: BackupProtocol ServerGetAccountUsage::DoCommand(BackupProtocolServer&, BackupStoreContext &)908 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID)); 909 } 910 911 912 // -------------------------------------------------------------------------- 913 // 914 // Function 915 // Name: BackupProtocolGetAccountUsage::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 916 916 // Purpose: Return the amount of disc space used 917 917 // Created: 19/4/04 918 918 // 919 919 // -------------------------------------------------------------------------- 920 std::auto_ptr< ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)920 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetAccountUsage::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 921 921 { 922 922 CHECK_PHASE(Phase_Commands) … … 930 930 931 931 // Return info 932 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerAccountUsage(932 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolAccountUsage( 933 933 rinfo.GetBlocksUsed(), 934 934 rinfo.GetBlocksInOldFiles(), … … 944 944 // 945 945 // Function 946 // Name: BackupProtocol ServerGetIsAlive::DoCommand(BackupProtocolServer&, BackupStoreContext &)946 // Name: BackupProtocolGetIsAlive::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 947 947 // Purpose: Return the amount of disc space used 948 948 // Created: 19/4/04 949 949 // 950 950 // -------------------------------------------------------------------------- 951 std::auto_ptr< ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext)951 std::auto_ptr<BackupProtocolMessage> BackupProtocolGetIsAlive::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 952 952 { 953 953 CHECK_PHASE(Phase_Commands) … … 956 956 // NOOP 957 957 // 958 return std::auto_ptr< ProtocolObject>(new BackupProtocolServerIsAlive());959 } 958 return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolIsAlive()); 959 } -
box/trunk/lib/backupstore/BackupStoreContext.cpp
r2945 r2983 28 28 #include "StoreStructure.h" 29 29 30 class BackupStoreDaemon;31 32 30 #include "MemLeakFindOn.h" 31 33 32 34 33 // Maximum number of directories to keep in the cache -
box/trunk/lib/backupstore/BackupStoreContext.h
r2945 r2983 17 17 #include "BackupStoreRefCountDatabase.h" 18 18 #include "NamedLock.h" 19 #include " ProtocolObject.h"19 #include "Message.h" 20 20 #include "Utils.h" 21 21 22 22 class BackupStoreDirectory; 23 23 class BackupStoreFilename; 24 class BackupStoreDaemon;25 24 class BackupStoreInfo; 26 25 class IOStream; 27 class BackupProtocol Object;26 class BackupProtocolMessage; 28 27 class StreamableMemBlock; 29 28 … … 162 161 { 163 162 public: 164 virtual std::auto_ptr< ProtocolObject> StartCommand(BackupProtocolObject&165 rCommand) = 0;163 virtual std::auto_ptr<BackupProtocolMessage> 164 StartCommand(const BackupProtocolMessage& rCommand) = 0; 166 165 virtual ~TestHook() { } 167 166 }; … … 170 169 mpTestHook = &rTestHook; 171 170 } 172 std::auto_ptr<ProtocolObject> StartCommandHook(BackupProtocolObject& rCommand) 171 std::auto_ptr<BackupProtocolMessage> 172 StartCommandHook(const BackupProtocolMessage& rCommand) 173 173 { 174 174 if(mpTestHook) … … 176 176 return mpTestHook->StartCommand(rCommand); 177 177 } 178 return std::auto_ptr< ProtocolObject>();178 return std::auto_ptr<BackupProtocolMessage>(); 179 179 } 180 180 -
box/trunk/lib/backupstore/BackupStoreFile.h
r2945 r2983 19 19 #include "IOStream.h" 20 20 #include "ReadLoggingStream.h" 21 #include "RunStatusProvider.h"22 21 23 22 typedef struct … … 27 26 int64_t mTotalFileStreamSize; 28 27 } BackupStoreFileStats; 28 29 class RunStatusProvider; 29 30 30 31 // Uncomment to disable backwards compatibility -
box/trunk/lib/backupstore/Makefile.extra
r2945 r2983 1 2 1 MAKEPROTOCOL = ../../lib/server/makeprotocol.pl 3 2 4 GEN_CMD_CLI = $(MAKEPROTOCOL) Client backupprotocol.txt 5 GEN_CMD_SRV = $(MAKEPROTOCOL) Server backupprotocol.txt 3 GEN_CMD = $(MAKEPROTOCOL) backupprotocol.txt 6 4 7 5 # AUTOGEN SEEDING 8 autogen_BackupProtocol Client.cpp autogen_BackupProtocolClient.h: $(MAKEPROTOCOL) backupprotocol.txt9 $(_PERL) $(GEN_CMD _CLI)6 autogen_BackupProtocol.cpp autogen_BackupProtocol.h: $(MAKEPROTOCOL) backupprotocol.txt 7 $(_PERL) $(GEN_CMD) 10 8 11 # AUTOGEN SEEDING12 autogen_BackupProtocolServer.cpp autogen_BackupProtocolServer.h: $(MAKEPROTOCOL) backupprotocol.txt13 $(_PERL) $(GEN_CMD_SRV)14 9 15 10 MAKEEXCEPTION = ../../lib/common/makeexception.pl -
box/trunk/lib/backupstore/backupprotocol.txt
r2945 r2983 7 7 ServerContextClass BackupStoreContext BackupStoreContext.h 8 8 9 ClientType Filename BackupStoreFilenameClear BackupStoreFilenameClear.h 10 ServerType Filename BackupStoreFilename BackupStoreFilename.h 9 AddType Filename BackupStoreFilenameClear BackupStoreFilenameClear.h 11 10 12 11 ImplementLog Server syslog … … 14 13 ImplementLog Client file 15 14 16 LogTypeToText Client Filename \"%s\" VAR.GetClearFilename().c_str()15 LogTypeToText Filename "%s" VAR.GetClearFilenameIfPossible("OPAQUE").c_str() 17 16 18 17 BEGIN_OBJECTS -
box/trunk/lib/server/Message.cpp
r217 r2983 2 2 // 3 3 // File 4 // Name: ProtocolObject.h4 // Name: Message.h 5 5 // Purpose: Protocol object base class 6 6 // Created: 2003/08/19 … … 9 9 10 10 #include "Box.h" 11 #include " ProtocolObject.h"11 #include "Message.h" 12 12 #include "CommonException.h" 13 13 … … 17 17 // 18 18 // Function 19 // Name: ProtocolObject::ProtocolObject()19 // Name: Message::Message() 20 20 // Purpose: Default constructor 21 21 // Created: 2003/08/19 22 22 // 23 23 // -------------------------------------------------------------------------- 24 ProtocolObject::ProtocolObject()24 Message::Message() 25 25 { 26 26 } … … 29 29 // 30 30 // Function 31 // Name: ProtocolObject::ProtocolObject()31 // Name: Message::Message() 32 32 // Purpose: Destructor 33 33 // Created: 2003/08/19 34 34 // 35 35 // -------------------------------------------------------------------------- 36 ProtocolObject::~ProtocolObject()36 Message::~Message() 37 37 { 38 38 } … … 41 41 // 42 42 // Function 43 // Name: ProtocolObject::ProtocolObject()43 // Name: Message::Message() 44 44 // Purpose: Copy constructor 45 45 // Created: 2003/08/19 46 46 // 47 47 // -------------------------------------------------------------------------- 48 ProtocolObject::ProtocolObject(const ProtocolObject&rToCopy)48 Message::Message(const Message &rToCopy) 49 49 { 50 50 } … … 53 53 // 54 54 // Function 55 // Name: ProtocolObject::IsError(int &, int &)55 // Name: Message::IsError(int &, int &) 56 56 // Purpose: Does this represent an error, and if so, what is the type and subtype? 57 57 // Created: 2003/08/19 58 58 // 59 59 // -------------------------------------------------------------------------- 60 bool ProtocolObject::IsError(int &rTypeOut, int &rSubTypeOut) const60 bool Message::IsError(int &rTypeOut, int &rSubTypeOut) const 61 61 { 62 62 return false; … … 66 66 // 67 67 // Function 68 // Name: ProtocolObject::IsConversationEnd()68 // Name: Message::IsConversationEnd() 69 69 // Purpose: Does this command end the conversation? 70 70 // Created: 2003/08/19 71 71 // 72 72 // -------------------------------------------------------------------------- 73 bool ProtocolObject::IsConversationEnd() const73 bool Message::IsConversationEnd() const 74 74 { 75 75 return false; … … 80 80 // 81 81 // Function 82 // Name: ProtocolObject::GetType()82 // Name: Message::GetType() 83 83 // Purpose: Return type of the object 84 84 // Created: 2003/08/19 85 85 // 86 86 // -------------------------------------------------------------------------- 87 int ProtocolObject::GetType() const87 int Message::GetType() const 88 88 { 89 89 // This isn't implemented in the base class! … … 95 95 // 96 96 // Function 97 // Name: ProtocolObject::SetPropertiesFromStreamData(Protocol &)97 // Name: Message::SetPropertiesFromStreamData(Protocol &) 98 98 // Purpose: Set the properties of the object from the stream data ready in the Protocol object 99 99 // Created: 2003/08/19 100 100 // 101 101 // -------------------------------------------------------------------------- 102 void ProtocolObject::SetPropertiesFromStreamData(Protocol &rProtocol)102 void Message::SetPropertiesFromStreamData(Protocol &rProtocol) 103 103 { 104 104 // This isn't implemented in the base class! … … 111 111 // 112 112 // Function 113 // Name: ProtocolObject::WritePropertiesToStreamData(Protocol &)113 // Name: Message::WritePropertiesToStreamData(Protocol &) 114 114 // Purpose: Write the properties of the object into the stream data in the Protocol object 115 115 // Created: 2003/08/19 116 116 // 117 117 // -------------------------------------------------------------------------- 118 void ProtocolObject::WritePropertiesToStreamData(Protocol &rProtocol) const118 void Message::WritePropertiesToStreamData(Protocol &rProtocol) const 119 119 { 120 120 // This isn't implemented in the base class! -
box/trunk/lib/server/Message.h
r217 r2983 2 2 // 3 3 // File 4 // Name: ProtocolObject.h4 // Name: Message.h 5 5 // Purpose: Protocol object base class 6 6 // Created: 2003/08/19 … … 11 11 #define PROTOCOLOBJECT__H 12 12 13 #include <memory> 14 13 15 class Protocol; 16 class ProtocolContext; 14 17 15 18 // -------------------------------------------------------------------------- 16 19 // 17 20 // Class 18 // Name: ProtocolObject21 // Name: Message 19 22 // Purpose: Basic object representation of objects to pass through a Protocol session 20 23 // Created: 2003/08/19 21 24 // 22 25 // -------------------------------------------------------------------------- 23 class ProtocolObject26 class Message 24 27 { 25 28 public: 26 ProtocolObject();27 virtual ~ ProtocolObject();28 ProtocolObject(const ProtocolObject&rToCopy);29 Message(); 30 virtual ~Message(); 31 Message(const Message &rToCopy); 29 32 30 33 // Info about this object … … 36 39 virtual void SetPropertiesFromStreamData(Protocol &rProtocol); 37 40 virtual void WritePropertiesToStreamData(Protocol &rProtocol) const; 41 42 virtual void LogSysLog(const char *Action) const { } 43 virtual void LogFile(const char *Action, FILE *file) const { } 38 44 }; 45 46 /* 47 class Reply; 48 49 class Request : public Message 50 { 51 public: 52 Request() { } 53 virtual ~Request() { } 54 Request(const Request &rToCopy) { } 55 virtual std::auto_ptr<Reply> DoCommand(Protocol &rProtocol, 56 ProtocolContext &rContext) = 0; 57 }; 58 59 class Reply : public Message 60 { 61 public: 62 Reply() { } 63 virtual ~Reply() { } 64 Reply(const Reply &rToCopy) { } 65 }; 66 */ 39 67 40 68 #endif // PROTOCOLOBJECT__H -
box/trunk/lib/server/Protocol.cpp
r2415 r2983 12 12 #include <sys/types.h> 13 13 14 #include <stdlib.h> 15 #include <string.h> 14 #include <cstdlib> 15 #include <cstring> 16 #include <cstdio> 16 17 17 18 #include <new> … … 45 46 // -------------------------------------------------------------------------- 46 47 Protocol::Protocol(IOStream &rStream) 47 : mrStream(rStream),48 mHandshakeDone(false),49 mMaxObjectSize(PROTOCOL_DEFAULT_MAXOBJSIZE),50 mTimeout(PROTOCOL_DEFAULT_TIMEOUT),51 mpBuffer(0),52 mBufferSize(0),53 mReadOffset(-1),54 mWriteOffset(-1),55 mValidDataSize(-1),56 mLastErrorType(NoError),57 mLastErrorSubType(NoError) 48 : mrStream(rStream), 49 mHandshakeDone(false), 50 mMaxObjectSize(PROTOCOL_DEFAULT_MAXOBJSIZE), 51 mTimeout(PROTOCOL_DEFAULT_TIMEOUT), 52 mpBuffer(0), 53 mBufferSize(0), 54 mReadOffset(-1), 55 mWriteOffset(-1), 56 mValidDataSize(-1), 57 mLogToSysLog(false), 58 mLogToFile(NULL) 58 59 { 59 60 BOX_TRACE("Send block allocation size is " << … … 77 78 mpBuffer = 0; 78 79 } 79 }80 81 82 // --------------------------------------------------------------------------83 //84 // Function85 // Name: Protocol::GetLastError(int &, int &)86 // Purpose: Returns true if there was an error, and type and subtype if there was.87 // Created: 2003/08/1988 //89 // --------------------------------------------------------------------------90 bool Protocol::GetLastError(int &rTypeOut, int &rSubTypeOut)91 {92 if(mLastErrorType == NoError)93 {94 // no error.95 return false;96 }97 98 // Return type and subtype in args99 rTypeOut = mLastErrorType;100 rSubTypeOut = mLastErrorSubType;101 102 // and unset them103 mLastErrorType = NoError;104 mLastErrorSubType = NoError;105 106 return true;107 80 } 108 81 … … 128 101 ::memset(&hsSend, 0, sizeof(hsSend)); 129 102 // Copy in ident string 130 ::strncpy(hsSend.mIdent, Get IdentString(), sizeof(hsSend.mIdent));103 ::strncpy(hsSend.mIdent, GetProtocolIdentString(), sizeof(hsSend.mIdent)); 131 104 132 105 // Send it … … 201 174 // 202 175 // -------------------------------------------------------------------------- 203 std::auto_ptr< ProtocolObject> Protocol::Receive()176 std::auto_ptr<Message> Protocol::ReceiveInternal() 204 177 { 205 178 // Get object header … … 221 194 222 195 // Create a blank object 223 std::auto_ptr< ProtocolObject> obj(MakeProtocolObject(ntohl(objHeader.mObjType)));196 std::auto_ptr<Message> obj(MakeMessage(ntohl(objHeader.mObjType))); 224 197 225 198 // Make sure memory is allocated to read it into … … 273 246 // 274 247 // -------------------------------------------------------------------------- 275 void Protocol::Send (const ProtocolObject&rObject)248 void Protocol::SendInternal(const Message &rObject) 276 249 { 277 250 // Check usage … … 855 828 void Protocol::InformStreamReceiving(u_int32_t Size) 856 829 { 857 // Do nothing 830 if(GetLogToSysLog()) 831 { 832 if(Size == Protocol::ProtocolStream_SizeUncertain) 833 { 834 BOX_TRACE("Receiving stream, size uncertain"); 835 } 836 else 837 { 838 BOX_TRACE("Receiving stream, size " << Size); 839 } 840 } 841 842 if(GetLogToFile()) 843 { 844 ::fprintf(GetLogToFile(), 845 (Size == Protocol::ProtocolStream_SizeUncertain) 846 ? "Receiving stream, size uncertain\n" 847 : "Receiving stream, size %d\n", Size); 848 ::fflush(GetLogToFile()); 849 } 858 850 } 859 851 … … 868 860 void Protocol::InformStreamSending(u_int32_t Size) 869 861 { 870 // Do nothing 862 if(GetLogToSysLog()) 863 { 864 if(Size == Protocol::ProtocolStream_SizeUncertain) 865 { 866 BOX_TRACE("Sending stream, size uncertain"); 867 } 868 else 869 { 870 BOX_TRACE("Sending stream, size " << Size); 871 } 872 } 873 874 if(GetLogToFile()) 875 { 876 ::fprintf(GetLogToFile(), 877 (Size == Protocol::ProtocolStream_SizeUncertain) 878 ? "Sending stream, size uncertain\n" 879 : "Sending stream, size %d\n", Size); 880 ::fflush(GetLogToFile()); 881 } 871 882 } 872 883 -
box/trunk/lib/server/Protocol.h
r217 r2983 13 13 #include <sys/types.h> 14 14 15 class IOStream;16 #include "ProtocolObject.h"17 15 #include <memory> 18 16 #include <vector> 19 17 #include <string> 18 19 #include "Message.h" 20 21 class IOStream; 20 22 21 23 // default timeout is 15 minutes … … 41 43 Protocol(const Protocol &rToCopy); 42 44 45 protected: 46 // Unsafe to make public, as they may allow sending objects 47 // from a different protocol. The derived class prevents this. 48 std::auto_ptr<Message> ReceiveInternal(); 49 void SendInternal(const Message &rObject); 50 43 51 public: 44 52 void Handshake(); 45 std::auto_ptr<ProtocolObject> Receive();46 void Send(const ProtocolObject &rObject);47 48 53 std::auto_ptr<IOStream> ReceiveStream(); 49 54 void SendStream(IOStream &rStream); … … 55 60 }; 56 61 57 bool GetLastError(int &rTypeOut, int &rSubTypeOut);58 59 62 // -------------------------------------------------------------------------- 60 63 // … … 88 91 void SetMaxObjectSize(unsigned int NewMaxObjSize) {mMaxObjectSize = NewMaxObjSize;} 89 92 90 // For ProtocolObjectderived classes93 // For Message derived classes 91 94 void Read(void *Buffer, int Size); 92 95 void Read(std::string &rOut, int Size); … … 169 172 ProtocolStream_SizeUncertain = 0xffffffff 170 173 }; 171 172 protected: 173 virtual std::auto_ptr<ProtocolObject> MakeProtocolObject(int ObjType) = 0; 174 virtual const char *GetIdentString() = 0; 175 void SetError(int Type, int SubType) {mLastErrorType = Type; mLastErrorSubType = SubType;} 174 bool GetLogToSysLog() { return mLogToSysLog; } 175 FILE *GetLogToFile() { return mLogToFile; } 176 void SetLogToSysLog(bool Log = false) {mLogToSysLog = Log;} 177 void SetLogToFile(FILE *File = 0) {mLogToFile = File;} 178 179 protected: 180 virtual std::auto_ptr<Message> MakeMessage(int ObjType) = 0; 181 virtual const char *GetProtocolIdentString() = 0; 182 176 183 void CheckAndReadHdr(void *hdr); // don't use type here to avoid dependency 177 184 … … 184 191 int SendStreamSendBlock(uint8_t *Block, int BytesInBlock); 185 192 186 private:187 193 IOStream &mrStream; 188 194 bool mHandshakeDone; … … 194 200 int mWriteOffset; 195 201 int mValidDataSize; 196 int mLastErrorType;197 int mLastErrorSubType;202 bool mLogToSysLog; 203 FILE *mLogToFile; 198 204 }; 199 205 206 class ProtocolContext 207 { 208 }; 209 200 210 #endif // PROTOCOL__H 201 211 -
box/trunk/lib/server/makeprotocol.pl.in
r2371 r2983 31 31 ); 32 32 33 34 35 my ($type, $file) = @ARGV; 36 37 if($type ne 'Server' && $type ne 'Client') 38 { 39 die "Neither Server or Client is specified on command line\n"; 40 } 33 if (@ARGV != 1) 34 { 35 die "Usage: $0 <protocol-txt-file>\n"; 36 } 37 38 my ($file) = @ARGV; 41 39 42 40 open IN, $file or die "Can't open input file $file\n"; 43 41 44 print "Making $typeprotocol classes from $file...\n";42 print "Making protocol classes from $file...\n"; 45 43 46 44 my @extra_header_files; 47 48 my $implement_syslog = 0;49 my $implement_filelog = 0;50 45 51 46 # read attributes … … 60 55 my ($k,$v) = split /\s+/,$l,2; 61 56 62 if($k eq 'ClientType') 63 { 64 add_type($v) if $type eq 'Client'; 65 } 66 elsif($k eq 'ServerType') 67 { 68 add_type($v) if $type eq 'Server'; 57 if($k eq 'AddType') 58 { 59 add_type($v); 69 60 } 70 61 elsif($k eq 'ImplementLog') 71 62 { 72 my ($log_if_type,$log_type) = split /\s+/,$v; 73 if($type eq $log_if_type) 74 { 75 if($log_type eq 'syslog') 76 { 77 $implement_syslog = 1; 78 } 79 elsif($log_type eq 'file') 80 { 81 $implement_filelog = 1; 82 } 83 else 84 { 85 printf("ERROR: Unknown log type for implementation: $log_type\n"); 86 exit(1); 87 } 88 } 63 # Always implement logging 89 64 } 90 65 elsif($k eq 'LogTypeToText') 91 66 { 92 my ($log_if_type,$type_name,$printf_format,$arg_template) = split /\s+/,$v; 93 if($type eq $log_if_type) 94 { 95 $log_display_types{$type_name} = [$printf_format,$arg_template] 96 } 67 my ($type_name,$printf_format,$arg_template) = split /\s+/,$v; 68 $log_display_types{$type_name} = [$printf_format,$arg_template] 97 69 } 98 70 else … … 170 142 171 143 # open files 172 my $h_filename = 'autogen_'.$protocol_name.'Protocol '.$type.'.h';173 open CPP,'>autogen_'.$protocol_name.'Protocol '.$type.'.cpp';144 my $h_filename = 'autogen_'.$protocol_name.'Protocol.h'; 145 open CPP,'>autogen_'.$protocol_name.'Protocol.cpp'; 174 146 open H,">$h_filename"; 147 148 my $guardname = uc 'AUTOGEN_'.$protocol_name.'Protocol_H'; 175 149 176 150 print CPP <<__E; … … 184 158 #include "$h_filename" 185 159 #include "IOStream.h" 186 187 __E 188 189 if($implement_syslog) 190 { 191 print H <<EOF; 160 __E 161 162 print H <<__E; 163 // Auto-generated file -- do not edit 164 165 #ifndef $guardname 166 #define $guardname 167 168 #include <cstdio> 169 #include <list> 170 192 171 #ifndef WIN32 193 172 #include <syslog.h> 194 173 #endif 195 EOF196 }197 198 199 my $guardname = uc 'AUTOGEN_'.$protocol_name.'Protocol'.$type.'_H';200 print H <<__E;201 202 // Auto-generated file -- do not edit203 204 #ifndef $guardname205 #define $guardname206 174 207 175 #include "Protocol.h" 208 #include " ProtocolObject.h"176 #include "Message.h" 209 177 #include "ServerException.h" 210 178 211 179 class IOStream; 212 180 213 __E 214 215 if($implement_filelog) 216 { 217 print H qq~#include <stdio.h>\n~; 218 } 181 182 __E 219 183 220 184 # extra headers 221 185 for(@extra_header_files) 222 186 { 223 print H qq~#include "$_"\n~ 224 } 225 print H "\n"; 226 227 if($type eq 'Server') 228 { 229 # need utils file for the server 230 print H '#include "Utils.h"',"\n\n" 231 } 232 233 234 my $derive_objects_from = 'ProtocolObject'; 187 print H qq@#include "$_"\n@; 188 } 189 190 print H <<__E; 191 192 // need utils file for the server 193 #include "Utils.h" 194 195 __E 196 197 my $message_base_class = "${protocol_name}ProtocolMessage"; 235 198 my $objects_extra_h = ''; 236 199 my $objects_extra_cpp = ''; 237 if($type eq 'Server') 238 { 239 # define the context 240 print H "class $context_class;\n\n"; 241 print CPP "#include \"$context_class_inc\"\n\n"; 242 243 # change class we derive the objects from 244 $derive_objects_from = $protocol_name.'ProtocolObject'; 245 246 $objects_extra_h = <<__E; 247 virtual std::auto_ptr<ProtocolObject> DoCommand(${protocol_name}ProtocolServer &rProtocol, $context_class &rContext); 248 __E 249 $objects_extra_cpp = <<__E; 250 std::auto_ptr<ProtocolObject> ${derive_objects_from}::DoCommand(${protocol_name}ProtocolServer &rProtocol, $context_class &rContext) 200 201 # define the context 202 print H "class $context_class;\n\n"; 203 print CPP <<__E; 204 #include "$context_class_inc" 205 #include "MemLeakFindOn.h" 206 __E 207 208 my $request_base_class = "${protocol_name}ProtocolRequest"; 209 my $reply_base_class = "${protocol_name}ProtocolReply"; 210 # the abstract protocol interface 211 my $protocol_base_class = $protocol_name."ProtocolBase"; 212 my $replyable_base_class = $protocol_name."ProtocolReplyable"; 213 214 print H <<__E; 215 class $protocol_base_class; 216 class $replyable_base_class; 217 class $reply_base_class; 218 219 class $message_base_class : public Message 220 { 221 public: 222 virtual std::auto_ptr<$message_base_class> DoCommand($replyable_base_class &rProtocol, 223 $context_class &rContext) const; 224 }; 225 226 class $reply_base_class 227 { 228 }; 229 230 class $request_base_class 231 { 232 }; 233 234 __E 235 236 print CPP <<__E; 237 std::auto_ptr<$message_base_class> $message_base_class\::DoCommand($replyable_base_class &rProtocol, 238 $context_class &rContext) const 251 239 { 252 240 THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand) 253 241 } 254 242 __E 255 } 256 257 print CPP qq~#include "MemLeakFindOn.h"\n~; 258 259 if($type eq 'Client' && ($implement_syslog || $implement_filelog)) 260 { 261 # change class we derive the objects from 262 $derive_objects_from = $protocol_name.'ProtocolObjectCl'; 263 } 264 if($implement_syslog) 265 { 266 $objects_extra_h .= <<__E; 267 virtual void LogSysLog(const char *Action) const = 0; 268 __E 269 } 270 if($implement_filelog) 271 { 272 $objects_extra_h .= <<__E; 273 virtual void LogFile(const char *Action, FILE *file) const = 0; 274 __E 275 } 276 277 if($derive_objects_from ne 'ProtocolObject') 278 { 279 # output a definition for the protocol object derived class 243 244 my %cmd_class; 245 246 # output the classes 247 foreach my $cmd (@cmd_list) 248 { 249 my @cmd_base_classes = ($message_base_class); 250 251 if(obj_is_type($cmd, 'Command')) 252 { 253 push @cmd_base_classes, $request_base_class; 254 } 255 256 if(obj_is_type($cmd, 'Reply')) 257 { 258 push @cmd_base_classes, $reply_base_class; 259 } 260 261 my $cmd_base_class = join(", ", map {"public $_"} @cmd_base_classes); 262 my $cmd_class = $protocol_name."ProtocolClient".$cmd; 263 $cmd_class{$cmd} = $cmd_class; 264 280 265 print H <<__E; 281 class ${protocol_name}ProtocolServer; 282 283 class $derive_objects_from : public ProtocolObject 266 class $cmd_class : $cmd_base_class 284 267 { 285 268 public: 286 $derive_objects_from(); 287 virtual ~$derive_objects_from(); 288 $derive_objects_from(const $derive_objects_from &rToCopy); 289 290 $objects_extra_h 291 }; 292 __E 293 294 # and some cpp definitions 295 print CPP <<__E; 296 ${derive_objects_from}::${derive_objects_from}() 297 { 298 } 299 ${derive_objects_from}::~${derive_objects_from}() 300 { 301 } 302 ${derive_objects_from}::${derive_objects_from}(const $derive_objects_from &rToCopy) 303 { 304 } 305 $objects_extra_cpp 306 __E 307 } 308 309 310 311 my $classname_base = $protocol_name.'Protocol'.$type; 312 313 # output the classes 314 for my $cmd (@cmd_list) 315 { 316 print H <<__E; 317 class $classname_base$cmd : public $derive_objects_from 318 { 319 public: 320 $classname_base$cmd(); 321 $classname_base$cmd(const $classname_base$cmd &rToCopy); 322 ~$classname_base$cmd(); 269 $cmd_class(); 270 $cmd_class(const $cmd_class &rToCopy); 271 ~$cmd_class(); 323 272 int GetType() const; 324 273 enum … … 327 276 }; 328 277 __E 278 329 279 # constants 330 280 if(exists $cmd_constants{$cmd}) … … 334 284 print H "\n\t};\n"; 335 285 } 286 336 287 # flags 337 288 if(obj_is_type($cmd,'EndsConversation')) … … 339 290 print H "\tbool IsConversationEnd() const;\n"; 340 291 } 292 341 293 if(obj_is_type($cmd,'IsError')) 342 294 { … … 344 296 print H "\tstd::string GetMessage() const;\n"; 345 297 } 346 if($type eq 'Server' && obj_is_type($cmd, 'Command')) 347 { 348 print H "\tstd::auto_ptr<ProtocolObject> DoCommand(${protocol_name}ProtocolServer &rProtocol, $context_class &rContext); // IMPLEMENT THIS\n" 298 299 if(obj_is_type($cmd, 'Command')) 300 { 301 print H <<__E; 302 std::auto_ptr<$message_base_class> DoCommand($replyable_base_class &rProtocol, 303 $context_class &rContext) const; // IMPLEMENT THIS\n 304 __E 349 305 } 350 306 351 307 # want to be able to read from streams? 352 my $read_from_streams = (obj_is_type($cmd,'Command') && $type eq 'Server') || (obj_is_type($cmd,'Reply') && $type eq 'Client');353 my $write_to_streams = (obj_is_type($cmd,'Command') && $type eq 'Client') || (obj_is_type($cmd,'Reply') && $type eq 'Server');354 355 if($read_from_streams)356 { 357 print H "\tvoid SetPropertiesFromStreamData(Protocol &rProtocol);\n";308 print H "\tvoid SetPropertiesFromStreamData(Protocol &rProtocol);\n"; 309 310 # write Get functions 311 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 312 { 313 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 358 314 359 # write Get functions 315 print H "\t".translate_type_to_arg_type($ty)." Get$nm() {return m$nm;}\n"; 316 } 317 318 my $param_con_args = ''; 319 # extra constructor? 320 if($#{$cmd_contents{$cmd}} >= 0) 321 { 322 my @a; 360 323 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 361 324 { 362 325 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 363 364 print H "\t".translate_type_to_arg_type($ty)." Get$nm() {return m$nm;}\n"; 365 } 366 } 367 my $param_con_args = ''; 368 if($write_to_streams) 369 { 370 # extra constructor? 371 if($#{$cmd_contents{$cmd}} >= 0) 372 { 373 my @a; 374 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 375 { 376 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 377 378 push @a,translate_type_to_arg_type($ty)." $nm"; 379 } 380 $param_con_args = join(', ',@a); 381 print H "\t$classname_base$cmd(".$param_con_args.");\n"; 382 } 383 print H "\tvoid WritePropertiesToStreamData(Protocol &rProtocol) const;\n"; 384 # set functions 385 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 386 { 387 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 388 389 print H "\tvoid Set$nm(".translate_type_to_arg_type($ty)." $nm) {m$nm = $nm;}\n"; 390 } 391 } 392 393 if($implement_syslog) 394 { 395 print H "\tvirtual void LogSysLog(const char *Action) const;\n"; 396 } 397 if($implement_filelog) 398 { 399 print H "\tvirtual void LogFile(const char *Action, FILE *file) const;\n"; 400 } 401 326 327 push @a,translate_type_to_arg_type($ty)." $nm"; 328 } 329 $param_con_args = join(', ',@a); 330 print H "\t$cmd_class(".$param_con_args.");\n"; 331 } 332 print H "\tvoid WritePropertiesToStreamData(Protocol &rProtocol) const;\n"; 333 # set functions 334 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 335 { 336 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 337 338 print H "\tvoid Set$nm(".translate_type_to_arg_type($ty)." $nm) {m$nm = $nm;}\n"; 339 } 340 341 print H "\tvirtual void LogSysLog(const char *Action) const;\n"; 342 print H "\tvirtual void LogFile(const char *Action, FILE *file) const;\n"; 402 343 403 344 # write member variables and setup for cpp file … … 433 374 $param_con_vars = "\n\t: ".$param_con_vars if $param_con_vars ne ''; 434 375 435 my $class = "$classname_base$cmd".'::';436 376 print CPP <<__E; 437 $c lass$classname_base$cmd()$def_con_vars438 { 439 } 440 $c lass$classname_base$cmd(const $classname_base$cmd&rToCopy)$copy_con_vars441 { 442 } 443 $c lass~$classname_base$cmd()444 { 445 } 446 int $ {class}GetType() const377 $cmd_class\::$cmd_class()$def_con_vars 378 { 379 } 380 $cmd_class\::$cmd_class(const $cmd_class &rToCopy)$copy_con_vars 381 { 382 } 383 $cmd_class\::~$cmd_class() 384 { 385 } 386 int $cmd_class\::GetType() const 447 387 { 448 388 return $cmd_id{$cmd}; 449 389 } 450 390 __E 451 if($read_from_streams) 452 { 453 print CPP "void ${class}SetPropertiesFromStreamData(Protocol &rProtocol)\n{\n"; 454 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 455 { 456 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 457 if($ty =~ m/\Avector/) 458 { 459 print CPP "\trProtocol.ReadVector(m$nm);\n"; 460 } 461 else 462 { 463 print CPP "\trProtocol.Read(m$nm);\n"; 464 } 465 } 466 print CPP "}\n"; 467 } 468 if($write_to_streams) 469 { 470 # implement extra constructor? 471 if($param_con_vars ne '') 472 { 473 print CPP "$class$classname_base$cmd($param_con_args)$param_con_vars\n{\n}\n"; 474 } 475 print CPP "void ${class}WritePropertiesToStreamData(Protocol &rProtocol) const\n{\n"; 476 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 477 { 478 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 479 if($ty =~ m/\Avector/) 480 { 481 print CPP "\trProtocol.WriteVector(m$nm);\n"; 482 } 483 else 484 { 485 print CPP "\trProtocol.Write(m$nm);\n"; 486 } 487 } 488 print CPP "}\n"; 489 } 391 print CPP "void $cmd_class\::SetPropertiesFromStreamData(Protocol &rProtocol)\n{\n"; 392 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 393 { 394 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 395 if($ty =~ m/\Avector/) 396 { 397 print CPP "\trProtocol.ReadVector(m$nm);\n"; 398 } 399 else 400 { 401 print CPP "\trProtocol.Read(m$nm);\n"; 402 } 403 } 404 print CPP "}\n"; 405 406 # implement extra constructor? 407 if($param_con_vars ne '') 408 { 409 print CPP "$cmd_class\::$cmd_class($param_con_args)$param_con_vars\n{\n}\n"; 410 } 411 print CPP "void $cmd_class\::WritePropertiesToStreamData(Protocol &rProtocol) const\n{\n"; 412 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 413 { 414 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 415 if($ty =~ m/\Avector/) 416 { 417 print CPP "\trProtocol.WriteVector(m$nm);\n"; 418 } 419 else 420 { 421 print CPP "\trProtocol.Write(m$nm);\n"; 422 } 423 } 424 print CPP "}\n"; 425 490 426 if(obj_is_type($cmd,'EndsConversation')) 491 427 { 492 print CPP "bool ${class}IsConversationEnd() const\n{\n\treturn true;\n}\n"; 493 } 428 print CPP "bool $cmd_class\::IsConversationEnd() const\n{\n\treturn true;\n}\n"; 429 } 430 494 431 if(obj_is_type($cmd,'IsError')) 495 432 { … … 497 434 my ($mem_type,$mem_subtype) = split /,/,obj_get_type_params($cmd,'IsError'); 498 435 print CPP <<__E; 499 bool $ {class}IsError(int &rTypeOut, int &rSubTypeOut) const436 bool $cmd_class\::IsError(int &rTypeOut, int &rSubTypeOut) const 500 437 { 501 438 rTypeOut = m$mem_type; … … 503 440 return true; 504 441 } 505 std::string $ {class}GetMessage() const442 std::string $cmd_class\::GetMessage() const 506 443 { 507 444 switch(m$mem_subtype) … … 527 464 } 528 465 529 if($implement_syslog) 530 { 531 my ($log) = make_log_strings_framework($cmd); 532 print CPP <<__E; 533 void ${class}LogSysLog(const char *Action) const 466 my ($log) = make_log_strings_framework($cmd); 467 print CPP <<__E; 468 void $cmd_class\::LogSysLog(const char *Action) const 534 469 { 535 470 BOX_TRACE($log); 536 471 } 537 __E 538 } 539 if($implement_filelog) 540 { 541 my ($log) = make_log_strings_framework($cmd); 542 print CPP <<__E; 543 void ${class}LogFile(const char *Action, FILE *File) const 472 void $cmd_class\::LogFile(const char *Action, FILE *File) const 544 473 { 545 474 std::ostringstream oss; … … 549 478 } 550 479 __E 551 } 552 } 553 554 # finally, the protocol object itself 480 } 481 482 my $error_class = $protocol_name."ProtocolError"; 483 484 # the abstract protocol interface 555 485 print H <<__E; 556 class $ classname_base : public Protocol486 class $protocol_base_class 557 487 { 558 488 public: 559 $classname_base(IOStream &rStream); 560 virtual ~$classname_base(); 561 562 std::auto_ptr<$derive_objects_from> Receive(); 563 void Send(const ${derive_objects_from} &rObject); 564 __E 565 if($implement_syslog) 566 { 567 print H "\tvoid SetLogToSysLog(bool Log = false) {mLogToSysLog = Log;}\n"; 568 } 569 if($implement_filelog) 570 { 571 print H "\tvoid SetLogToFile(FILE *File = 0) {mLogToFile = File;}\n"; 572 } 573 if($type eq 'Server') 574 { 575 # need to put in the conversation function 576 print H "\tvoid DoServer($context_class &rContext);\n\n"; 577 # and the send vector thing 578 print H "\tvoid SendStreamAfterCommand(IOStream *pStream);\n\n"; 579 } 580 if($type eq 'Client') 581 { 582 # add plain object taking query functions 583 my $with_params; 489 $protocol_base_class(); 490 virtual ~$protocol_base_class(); 491 virtual const char *GetIdentString(); 492 bool GetLastError(int &rTypeOut, int &rSubTypeOut); 493 494 protected: 495 void CheckReply(const std::string& requestCommand, 496 const $message_base_class &rReply, int expectedType); 497 void SetLastError(int Type, int SubType) 498 { 499 mLastErrorType = Type; 500 mLastErrorSubType = SubType; 501 } 502 503 private: 504 $protocol_base_class(const $protocol_base_class &rToCopy); /* do not call */ 505 int mLastErrorType; 506 int mLastErrorSubType; 507 }; 508 509 class $replyable_base_class : public virtual $protocol_base_class 510 { 511 public: 512 $replyable_base_class(); 513 virtual ~$replyable_base_class(); 514 515 /* 516 virtual std::auto_ptr<$message_base_class> Receive() = 0; 517 virtual void Send(const ${message_base_class} &rObject) = 0; 518 */ 519 520 virtual std::auto_ptr<IOStream> ReceiveStream() = 0; 521 virtual int GetTimeout() = 0; 522 void SendStreamAfterCommand(IOStream *pStream); 523 524 protected: 525 std::list<IOStream*> mStreamsToSend; 526 void DeleteStreamsToSend(); 527 528 private: 529 $replyable_base_class(const $replyable_base_class &rToCopy); /* do not call */ 530 }; 531 532 __E 533 534 print CPP <<__E; 535 $protocol_base_class\::$protocol_base_class() 536 : mLastErrorType(Protocol::NoError), 537 mLastErrorSubType(Protocol::NoError) 538 { } 539 540 $protocol_base_class\::~$protocol_base_class() 541 { } 542 543 const char *$protocol_base_class\::GetIdentString() 544 { 545 return "$ident_string"; 546 } 547 548 $replyable_base_class\::$replyable_base_class() 549 { } 550 551 $replyable_base_class\::~$replyable_base_class() 552 { } 553 554 void $replyable_base_class\::SendStreamAfterCommand(IOStream *pStream) 555 { 556 ASSERT(pStream != NULL); 557 mStreamsToSend.push_back(pStream); 558 } 559 560 void $replyable_base_class\::DeleteStreamsToSend() 561 { 562 for(std::list<IOStream*>::iterator i(mStreamsToSend.begin()); i != mStreamsToSend.end(); ++i) 563 { 564 delete (*i); 565 } 566 mStreamsToSend.clear(); 567 } 568 569 void $protocol_base_class\::CheckReply(const std::string& requestCommand, 570 const $message_base_class &rReply, int expectedType) 571 { 572 if(rReply.GetType() == expectedType) 573 { 574 // Correct response, do nothing 575 } 576 else 577 { 578 // Set protocol error 579 int type, subType; 580 581 if(rReply.IsError(type, subType)) 582 { 583 SetLastError(type, subType); 584 BOX_WARNING(requestCommand << " command failed: " 585 "received error " << 586 (($error_class&)rReply).GetMessage()); 587 } 588 else 589 { 590 SetLastError(Protocol::UnknownError, Protocol::UnknownError); 591 BOX_WARNING(requestCommand << " command failed: " 592 "received unexpected response type " << 593 rReply.GetType()); 594 } 595 596 // Throw an exception 597 THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnexpectedReply) 598 } 599 } 600 601 // -------------------------------------------------------------------------- 602 // 603 // Function 604 // Name: Protocol::GetLastError(int &, int &) 605 // Purpose: Returns true if there was an error, and type and subtype if there was. 606 // Created: 2003/08/19 607 // 608 // -------------------------------------------------------------------------- 609 bool $protocol_base_class\::GetLastError(int &rTypeOut, int &rSubTypeOut) 610 { 611 if(mLastErrorType == Protocol::NoError) 612 { 613 // no error. 614 return false; 615 } 616 617 // Return type and subtype in args 618 rTypeOut = mLastErrorType; 619 rSubTypeOut = mLastErrorSubType; 620 621 // and unset them 622 mLastErrorType = Protocol::NoError; 623 mLastErrorSubType = Protocol::NoError; 624 625 return true; 626 } 627 628 __E 629 630 # the callable protocol interface (implemented by Client and Local classes) 631 # with Query methods that don't take a context parameter 632 my $callable_base_class = $protocol_name."ProtocolCallable"; 633 print H <<__E; 634 class $callable_base_class : public virtual $protocol_base_class 635 { 636 public: 637 virtual std::auto_ptr<IOStream> ReceiveStream() = 0; 638 virtual int GetTimeout() = 0; 639 __E 640 641 # add plain object taking query functions 642 my $with_params; 643 for my $cmd (@cmd_list) 644 { 645 if(obj_is_type($cmd,'Command')) 646 { 647 my $has_stream = obj_is_type($cmd,'StreamWithCommand'); 648 my $argextra = $has_stream?', IOStream &rStream':''; 649 my $queryextra = $has_stream?', rStream':''; 650 my $request_class = $cmd_class{$cmd}; 651 my $reply_class = $cmd_class{obj_get_type_params($cmd,'Command')}; 652 653 print H "\tvirtual std::auto_ptr<$reply_class> Query(const $request_class &rQuery$argextra) = 0;\n"; 654 my @a; 655 my @na; 656 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 657 { 658 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 659 push @a,translate_type_to_arg_type($ty)." $nm"; 660 push @na,"$nm"; 661 } 662 my $ar = join(', ',@a); 663 my $nar = join(', ',@na); 664 $nar = "($nar)" if $nar ne ''; 665 666 $with_params .= <<__E; 667 inline std::auto_ptr<$reply_class> Query$cmd($ar$argextra) 668 { 669 $request_class send$nar; 670 return Query(send$queryextra); 671 } 672 __E 673 } 674 } 675 676 # quick hack to correct bad argument lists for commands with zero parameters but with streams 677 $with_params =~ s/\(, /(/g; 678 679 print H <<__E; 680 681 $with_params 682 }; 683 __E 684 685 # standard remote protocol objects 686 foreach my $type ('Client', 'Server', 'Local') 687 { 688 my $writing_client = ($type eq 'Client'); 689 my $writing_server = ($type eq 'Server'); 690 my $writing_local = ($type eq 'Local'); 691 692 my $server_or_client_class = $protocol_name."Protocol".$type; 693 my @base_classes; 694 695 if (not $writing_client) 696 { 697 push @base_classes, $replyable_base_class; 698 } 699 if (not $writing_server) 700 { 701 push @base_classes, $callable_base_class; 702 } 703 if (not $writing_local) 704 { 705 push @base_classes, "Protocol"; 706 } 707 708 my $base_classes_str = join(", ", map {"public $_"} @base_classes); 709 710 print H <<__E; 711 class $server_or_client_class : $base_classes_str 712 { 713 public: 714 __E 715 716 if($writing_local) 717 { 718 print H <<__E; 719 $server_or_client_class($context_class &rContext); 720 __E 721 } 722 else 723 { 724 print H <<__E; 725 $server_or_client_class(IOStream &rStream); 726 std::auto_ptr<$message_base_class> Receive(); 727 void Send(const $message_base_class &rObject); 728 __E 729 } 730 731 print H <<__E; 732 virtual ~$server_or_client_class(); 733 __E 734 735 if($writing_server) 736 { 737 # need to put in the conversation function 738 print H <<__E; 739 void DoServer($context_class &rContext); 740 741 __E 742 } 743 744 if($writing_client or $writing_local) 745 { 746 # add plain object taking query functions 747 for my $cmd (@cmd_list) 748 { 749 if(obj_is_type($cmd,'Command')) 750 { 751 my $has_stream = obj_is_type($cmd,'StreamWithCommand'); 752 my $argextra = $has_stream?', IOStream &rStream':''; 753 my $queryextra = $has_stream?', rStream':''; 754 my $request_class = $cmd_class{$cmd}; 755 my $reply_class = $cmd_class{obj_get_type_params($cmd,'Command')}; 756 print H "\tstd::auto_ptr<$reply_class> Query(const $request_class &rQuery$argextra);\n"; 757 } 758 } 759 } 760 761 if($writing_local) 762 { 763 print H <<__E; 764 private: 765 $context_class &mrContext; 766 __E 767 } 768 769 print H <<__E; 770 771 protected: 772 virtual std::auto_ptr<Message> MakeMessage(int ObjType); 773 774 __E 775 776 if($writing_local) 777 { 778 print H <<__E; 779 virtual void InformStreamReceiving(u_int32_t Size) { } 780 virtual void InformStreamSending(u_int32_t Size) { } 781 782 public: 783 virtual std::auto_ptr<IOStream> ReceiveStream() 784 { 785 std::auto_ptr<IOStream> apStream(mStreamsToSend.front()); 786 mStreamsToSend.pop_front(); 787 return apStream; 788 } 789 __E 790 } 791 else 792 { 793 print H <<__E; 794 virtual void InformStreamReceiving(u_int32_t Size) 795 { 796 this->Protocol::InformStreamReceiving(Size); 797 } 798 virtual void InformStreamSending(u_int32_t Size) 799 { 800 this->Protocol::InformStreamSending(Size); 801 } 802 803 public: 804 virtual std::auto_ptr<IOStream> ReceiveStream() 805 { 806 return this->Protocol::ReceiveStream(); 807 } 808 __E 809 } 810 811 print H <<__E; 812 virtual const char *GetProtocolIdentString() 813 { 814 return GetIdentString(); 815 } 816 __E 817 818 if($writing_local) 819 { 820 print H <<__E; 821 virtual int GetTimeout() 822 { 823 return IOStream::TimeOutInfinite; 824 } 825 __E 826 } 827 else 828 { 829 print H <<__E; 830 virtual int GetTimeout() 831 { 832 return this->Protocol::GetTimeout(); 833 } 834 __E 835 } 836 837 print H <<__E; 838 /* 839 virtual void Handshake() 840 { 841 this->Protocol::Handshake(); 842 } 843 virtual bool GetLastError(int &rTypeOut, int &rSubTypeOut) 844 { 845 return this->Protocol::GetLastError(rTypeOut, rSubTypeOut); 846 } 847 */ 848 849 private: 850 $server_or_client_class(const $server_or_client_class &rToCopy); /* no copies */ 851 }; 852 853 __E 854 855 my $destructor_extra = ($writing_server) ? "\n\tDeleteStreamsToSend();" 856 : ''; 857 858 if($writing_local) 859 { 860 print CPP <<__E; 861 $server_or_client_class\::$server_or_client_class($context_class &rContext) 862 : mrContext(rContext) 863 { } 864 __E 865 } 866 else 867 { 868 print CPP <<__E; 869 $server_or_client_class\::$server_or_client_class(IOStream &rStream) 870 : Protocol(rStream) 871 { } 872 __E 873 } 874 875 print CPP <<__E; 876 $server_or_client_class\::~$server_or_client_class() 877 {$destructor_extra 878 } 879 __E 880 881 # write receive and send functions 882 print CPP <<__E; 883 std::auto_ptr<Message> $server_or_client_class\::MakeMessage(int ObjType) 884 { 885 switch(ObjType) 886 { 887 __E 888 889 # do objects within this 584 890 for my $cmd (@cmd_list) 585 891 { 586 if(obj_is_type($cmd,'Command')) 587 { 588 my $has_stream = obj_is_type($cmd,'StreamWithCommand'); 589 my $argextra = $has_stream?', IOStream &rStream':''; 590 my $queryextra = $has_stream?', rStream':''; 591 my $reply = obj_get_type_params($cmd,'Command'); 592 print H "\tstd::auto_ptr<$classname_base$reply> Query(const $classname_base$cmd &rQuery$argextra);\n"; 593 my @a; 594 my @na; 595 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 596 { 597 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 598 push @a,translate_type_to_arg_type($ty)." $nm"; 599 push @na,"$nm"; 600 } 601 my $ar = join(', ',@a); 602 my $nar = join(', ',@na); 603 $nar = "($nar)" if $nar ne ''; 604 605 $with_params .= "\tinline std::auto_ptr<$classname_base$reply> Query$cmd($ar$argextra)\n\t{\n"; 606 $with_params .= "\t\t$classname_base$cmd send$nar;\n"; 607 $with_params .= "\t\treturn Query(send$queryextra);\n"; 608 $with_params .= "\t}\n"; 609 } 610 } 611 # quick hack to correct bad argument lists for commands with zero paramters but with streams 612 $with_params =~ s/\(, /(/g; 613 print H "\n",$with_params,"\n"; 614 } 615 print H <<__E; 616 private: 617 $classname_base(const $classname_base &rToCopy); 618 __E 619 if($type eq 'Server') 620 { 621 # need to put the streams to send vector 622 print H "\tstd::vector<IOStream*> mStreamsToSend;\n\tvoid DeleteStreamsToSend();\n"; 623 } 624 625 if($implement_filelog || $implement_syslog) 626 { 627 print H <<__E; 628 virtual void InformStreamReceiving(u_int32_t Size); 629 virtual void InformStreamSending(u_int32_t Size); 630 __E 631 } 632 633 if($implement_syslog) 634 { 635 print H "private:\n\tbool mLogToSysLog;\n"; 636 } 637 if($implement_filelog) 638 { 639 print H "private:\n\tFILE *mLogToFile;\n"; 640 } 641 print H <<__E; 642 643 protected: 644 virtual std::auto_ptr<ProtocolObject> MakeProtocolObject(int ObjType); 645 virtual const char *GetIdentString(); 646 }; 647 648 __E 649 650 my $constructor_extra = ''; 651 $constructor_extra .= ', mLogToSysLog(false)' if $implement_syslog; 652 $constructor_extra .= ', mLogToFile(0)' if $implement_filelog; 653 654 my $destructor_extra = ($type eq 'Server')?"\n\tDeleteStreamsToSend();":''; 655 656 my $prefix = $classname_base.'::'; 657 print CPP <<__E; 658 $prefix$classname_base(IOStream &rStream) 659 : Protocol(rStream)$constructor_extra 660 { 661 } 662 $prefix~$classname_base() 663 {$destructor_extra 664 } 665 const char *${prefix}GetIdentString() 666 { 667 return "$ident_string"; 668 } 669 std::auto_ptr<ProtocolObject> ${prefix}MakeProtocolObject(int ObjType) 670 { 671 switch(ObjType) 672 { 673 __E 674 675 # do objects within this 676 for my $cmd (@cmd_list) 677 { 892 print CPP <<__E; 893 case $cmd_id{$cmd}: 894 return std::auto_ptr<Message>(new $cmd_class{$cmd}()); 895 break; 896 __E 897 } 898 678 899 print CPP <<__E; 679 case $cmd_id{$cmd}:680 return std::auto_ptr<ProtocolObject>(new $classname_base$cmd);681 break;682 __E683 }684 685 print CPP <<__E;686 900 default: 687 901 THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnknownCommandRecieved) … … 689 903 } 690 904 __E 691 # write receive and send functions 692 print CPP <<__E; 693 std::auto_ptr<$derive_objects_from> ${prefix}Receive() 694 { 695 std::auto_ptr<${derive_objects_from}> preply((${derive_objects_from}*)(Protocol::Receive().release())); 696 697 __E 698 if($implement_syslog) 905 906 if(not $writing_local) 699 907 { 700 908 print CPP <<__E; 701 if(mLogToSysLog) 909 std::auto_ptr<$message_base_class> $server_or_client_class\::Receive() 910 { 911 std::auto_ptr<$message_base_class> preply(($message_base_class *) 912 Protocol::ReceiveInternal().release()); 913 914 if(GetLogToSysLog()) 702 915 { 703 916 preply->LogSysLog("Receive"); 704 917 } 705 __E 706 } 707 if($implement_filelog) 918 919 if(GetLogToFile() != 0) 920 { 921 preply->LogFile("Receive", GetLogToFile()); 922 } 923 924 return preply; 925 } 926 927 void $server_or_client_class\::Send(const $message_base_class &rObject) 928 { 929 if(GetLogToSysLog()) 930 { 931 rObject.LogSysLog("Send"); 932 } 933 934 if(GetLogToFile() != 0) 935 { 936 rObject.LogFile("Send", GetLogToFile()); 937 } 938 939 Protocol::SendInternal(rObject); 940 } 941 942 __E 943 } 944 945 # write server function? 946 if($writing_server) 708 947 { 709 948 print CPP <<__E; 710 if(mLogToFile != 0) 711 { 712 preply->LogFile("Receive", mLogToFile); 713 } 714 __E 715 } 716 print CPP <<__E; 717 718 return preply; 719 } 720 721 void ${prefix}Send(const ${derive_objects_from} &rObject) 722 { 723 __E 724 if($implement_syslog) 725 { 726 print CPP <<__E; 727 if(mLogToSysLog) 728 { 729 rObject.LogSysLog("Send"); 730 } 731 __E 732 } 733 if($implement_filelog) 734 { 735 print CPP <<__E; 736 if(mLogToFile != 0) 737 { 738 rObject.LogFile("Send", mLogToFile); 739 } 740 __E 741 } 742 743 print CPP <<__E; 744 Protocol::Send(rObject); 745 } 746 747 __E 748 # write server function? 749 if($type eq 'Server') 750 { 751 print CPP <<__E; 752 void ${prefix}DoServer($context_class &rContext) 949 void $server_or_client_class\::DoServer($context_class &rContext) 753 950 { 754 951 // Handshake with client … … 760 957 { 761 958 // Get an object from the conversation 762 std::auto_ptr<$ {derive_objects_from}> pobj(Receive());959 std::auto_ptr<$message_base_class> pobj = Receive(); 763 960 764 961 // Run the command 765 std::auto_ptr<$ {derive_objects_from}> preply((${derive_objects_from}*)(pobj->DoCommand(*this, rContext).release()));962 std::auto_ptr<$message_base_class> preply = pobj->DoCommand(*this, rContext); 766 963 767 964 // Send the reply 768 Send(* (preply.get()));965 Send(*preply); 769 966 770 967 // Send any streams 771 for(unsigned int s = 0; s < mStreamsToSend.size(); s++) 772 { 773 // Send the streams 774 SendStream(*mStreamsToSend[s]); 775 } 968 for(std::list<IOStream*>::iterator 969 i = mStreamsToSend.begin(); 970 i != mStreamsToSend.end(); ++i) 971 { 972 SendStream(**i); 973 } 974 776 975 // Delete these streams 777 976 DeleteStreamsToSend(); … … 785 984 } 786 985 787 void ${prefix}SendStreamAfterCommand(IOStream *pStream) 788 { 789 ASSERT(pStream != NULL); 790 mStreamsToSend.push_back(pStream); 791 } 792 793 void ${prefix}DeleteStreamsToSend() 794 { 795 for(std::vector<IOStream*>::iterator i(mStreamsToSend.begin()); i != mStreamsToSend.end(); ++i) 796 { 797 delete (*i); 798 } 799 mStreamsToSend.clear(); 800 } 801 802 __E 803 } 804 805 # write logging functions? 806 if($implement_filelog || $implement_syslog) 807 { 808 my ($fR,$fS); 809 810 if($implement_syslog) 811 { 812 $fR .= <<__E; 813 if(mLogToSysLog) 814 { 815 if(Size==Protocol::ProtocolStream_SizeUncertain) 816 { 817 BOX_TRACE("Receiving stream, size uncertain"); 818 } 819 else 820 { 821 BOX_TRACE("Receiving stream, size " << Size); 822 } 823 } 824 __E 825 826 $fS .= <<__E; 827 if(mLogToSysLog) 828 { 829 if(Size==Protocol::ProtocolStream_SizeUncertain) 830 { 831 BOX_TRACE("Sending stream, size uncertain"); 832 } 833 else 834 { 835 BOX_TRACE("Sending stream, size " << Size); 836 } 837 } 838 __E 839 } 840 841 if($implement_filelog) 842 { 843 $fR .= <<__E; 844 if(mLogToFile) 845 { 846 ::fprintf(mLogToFile, 847 (Size==Protocol::ProtocolStream_SizeUncertain) 848 ?"Receiving stream, size uncertain\\n" 849 :"Receiving stream, size %d\\n", Size); 850 ::fflush(mLogToFile); 851 } 852 __E 853 $fS .= <<__E; 854 if(mLogToFile) 855 { 856 ::fprintf(mLogToFile, 857 (Size==Protocol::ProtocolStream_SizeUncertain) 858 ?"Sending stream, size uncertain\\n" 859 :"Sending stream, size %d\\n", Size); 860 ::fflush(mLogToFile); 861 } 862 __E 863 } 864 865 print CPP <<__E; 866 867 void ${prefix}InformStreamReceiving(u_int32_t Size) 868 { 869 $fR} 870 871 void ${prefix}InformStreamSending(u_int32_t Size) 872 { 873 $fS} 874 875 __E 876 } 877 878 879 # write client Query functions? 880 if($type eq 'Client') 881 { 882 for my $cmd (@cmd_list) 883 { 884 if(obj_is_type($cmd,'Command')) 885 { 886 my $reply = obj_get_type_params($cmd,'Command'); 887 my $reply_id = $cmd_id{$reply}; 888 my $has_stream = obj_is_type($cmd,'StreamWithCommand'); 889 my $argextra = $has_stream?', IOStream &rStream':''; 890 my $send_stream_extra = ''; 891 if($has_stream) 986 __E 987 } 988 989 # write client Query functions? 990 if($writing_client or $writing_local) 991 { 992 for my $cmd (@cmd_list) 993 { 994 if(obj_is_type($cmd,'Command')) 892 995 { 893 $send_stream_extra = <<__E; 894 996 my $request_class = $cmd_class{$cmd}; 997 my $reply_msg = obj_get_type_params($cmd,'Command'); 998 my $reply_class = $cmd_class{$reply_msg}; 999 my $reply_id = $cmd_id{$reply_msg}; 1000 my $has_stream = obj_is_type($cmd,'StreamWithCommand'); 1001 my $argextra = $has_stream?', IOStream &rStream':''; 1002 my $send_stream_extra = ''; 1003 my $send_stream_method = $writing_client ? "SendStream" 1004 : "SendStreamAfterCommand"; 1005 1006 if($writing_client) 1007 { 1008 if($has_stream) 1009 { 1010 $send_stream_extra = <<__E; 895 1011 // Send stream after the command 896 1012 SendStream(rStream); 897 1013 __E 898 } 899 print CPP <<__E; 900 std::auto_ptr<$classname_base$reply> ${classname_base}::Query(const $classname_base$cmd &rQuery$argextra) 1014 } 1015 1016 print CPP <<__E; 1017 std::auto_ptr<$reply_class> $server_or_client_class\::Query(const $request_class &rQuery$argextra) 901 1018 { 902 1019 // Send query 903 1020 Send(rQuery); 904 1021 $send_stream_extra 1022 905 1023 // Wait for the reply 906 std::auto_ptr<${derive_objects_from}> preply(Receive().release()); 907 908 if(preply->GetType() == $reply_id) 909 { 910 // Correct response 911 return std::auto_ptr<$classname_base$reply>(($classname_base$reply*)preply.release()); 912 } 913 else 914 { 915 // Set protocol error 916 int type, subType; 917 if(preply->IsError(type, subType)) 918 { 919 SetError(type, subType); 920 BOX_WARNING("$cmd command failed: received error " << 921 ((${classname_base}Error&)*preply).GetMessage()); 922 } 923 else 924 { 925 SetError(Protocol::UnknownError, Protocol::UnknownError); 926 BOX_WARNING("$cmd command failed: received " 927 "unexpected response type " << 928 preply->GetType()); 929 } 930 931 // Throw an exception 932 THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnexpectedReply) 933 } 934 } 935 __E 936 } 937 } 938 } 939 940 1024 std::auto_ptr<$message_base_class> preply = Receive(); 1025 1026 CheckReply("$cmd", *preply, $reply_id); 1027 1028 // Correct response, if no exception thrown by CheckReply 1029 return std::auto_ptr<$reply_class>(($reply_class *)preply.release()); 1030 } 1031 __E 1032 } 1033 elsif($writing_local) 1034 { 1035 if($has_stream) 1036 { 1037 $send_stream_extra = <<__E; 1038 // Send stream after the command 1039 SendStreamAfterCommand(&rStream); 1040 __E 1041 } 1042 1043 print CPP <<__E; 1044 std::auto_ptr<$reply_class> $server_or_client_class\::Query(const $request_class &rQuery$argextra) 1045 { 1046 // Send query 1047 $send_stream_extra 1048 std::auto_ptr<$message_base_class> preply = rQuery.DoCommand(*this, mrContext); 1049 1050 CheckReply("$cmd", *preply, $reply_id); 1051 1052 // Correct response, if no exception thrown by CheckReply 1053 return std::auto_ptr<$reply_class>(($reply_class *)preply.release()); 1054 } 1055 __E 1056 } 1057 } 1058 } 1059 } 1060 } 941 1061 942 1062 print H <<__E; … … 949 1069 close CPP; 950 1070 951 952 sub obj_is_type 1071 sub obj_is_type ($$) 953 1072 { 954 1073 my ($c,$ty) = @_; … … 1004 1123 } 1005 1124 1006 sub make_log_strings 1125 sub make_log_strings_framework 1007 1126 { 1008 1127 my ($cmd) = @_; 1009 1128 1010 my @ str;1011 my @arg; 1129 my @args; 1130 1012 1131 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 1013 1132 { … … 1020 1139 $arg =~ s/VAR/m$nm/g; 1021 1140 1022 if ($format eq "0x%llx" and $target_windows) 1023 { 1024 $format = "0x%I64x"; 1025 $arg = "(uint64_t)$arg"; 1026 } 1027 1028 push @str,$format; 1029 push @arg,$arg; 1030 } 1031 else 1032 { 1033 # is opaque 1034 push @str,'OPAQUE'; 1035 } 1036 } 1037 return ($cmd.'('.join(',',@str).')', join(',','',@arg)); 1038 } 1039 1040 sub make_log_strings_framework 1041 { 1042 my ($cmd) = @_; 1043 1044 my @args; 1045 1046 for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 1047 { 1048 my ($ty,$nm) = (${$cmd_contents{$cmd}}[$x], ${$cmd_contents{$cmd}}[$x+1]); 1049 1050 if(exists $log_display_types{$ty}) 1051 { 1052 # need to translate it 1053 my ($format,$arg) = @{$log_display_types{$ty}}; 1054 $arg =~ s/VAR/m$nm/g; 1055 1056 if ($format eq '\\"%s\\"') 1141 if ($format eq '"%s"') 1057 1142 { 1058 1143 $arg = "\"\\\"\" << $arg << \"\\\"\""; … … 1091 1176 } 1092 1177 1093 -
box/trunk/qdbm
-
Property
svn:ignore
set to
Makefile
config.status
qdbm.pc
config.log
qdbm.spec
LTmakefile
configure.lineno
-
Property
svn:ignore
set to
-
box/trunk/test/backupstore/testbackupstore.cpp
r2841 r2983 14 14 15 15 #include "Test.h" 16 #include "autogen_BackupProtocol Client.h"16 #include "autogen_BackupProtocol.h" 17 17 #include "SSLLib.h" 18 18 #include "TLSContext.h" … … 441 441 442 442 // Command 443 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocol.QueryListDirectory(443 std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 444 444 DirID, 445 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,446 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));445 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 446 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 447 447 // Stream 448 448 BackupStoreDirectory dir; … … 456 456 while((en = i.Next()) != 0) 457 457 { 458 if(en->GetFlags() & BackupProtocol ClientListDirectory::Flags_Dir)458 if(en->GetFlags() & BackupProtocolListDirectory::Flags_Dir) 459 459 { 460 460 dirs++; … … 467 467 } 468 468 // Check it's deleted 469 TEST_THAT(en->GetFlags() & BackupProtocol ClientListDirectory::Flags_Deleted);469 TEST_THAT(en->GetFlags() & BackupProtocolListDirectory::Flags_Deleted); 470 470 } 471 471 … … 492 492 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile( 493 493 source.c_str(), parentId, name_encoded)); 494 std::auto_ptr<BackupProtocol ClientSuccess> stored(494 std::auto_ptr<BackupProtocolSuccess> stored( 495 495 protocol.QueryStoreFile( 496 496 parentId, … … 516 516 int attrS = 0; 517 517 MemBlockStream attr(&attrS, sizeof(attrS)); 518 std::auto_ptr<BackupProtocol ClientSuccess> dirCreate(protocol.QueryCreateDirectory(518 std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory( 519 519 indir, 520 520 9837429842987984LL, dirname, attr)); … … 551 551 { 552 552 // Command 553 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocol.QueryListDirectory(554 BackupProtocol ClientListDirectory::RootDirectory,555 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,556 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));557 TEST_THAT(dirreply->GetObjectID() == BackupProtocol ClientListDirectory::RootDirectory);553 std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 554 BackupProtocolListDirectory::RootDirectory, 555 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 556 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 557 TEST_THAT(dirreply->GetObjectID() == BackupProtocolListDirectory::RootDirectory); 558 558 // Stream 559 559 BackupStoreDirectory dir; … … 576 576 TEST_THAT(en->GetObjectID() == uploads[t].allocated_objid); 577 577 TEST_THAT(en->GetModificationTime() == uploads[t].mod_time); 578 int correct_flags = BackupProtocol ClientListDirectory::Flags_File;579 if(uploads[t].should_be_old_version) correct_flags |= BackupProtocol ClientListDirectory::Flags_OldVersion;580 if(uploads[t].delete_file) correct_flags |= BackupProtocol ClientListDirectory::Flags_Deleted;578 int correct_flags = BackupProtocolListDirectory::Flags_File; 579 if(uploads[t].should_be_old_version) correct_flags |= BackupProtocolListDirectory::Flags_OldVersion; 580 if(uploads[t].delete_file) correct_flags |= BackupProtocolListDirectory::Flags_Deleted; 581 581 TEST_THAT(en->GetFlags() == correct_flags); 582 582 if(t == UPLOAD_ATTRS_EN) … … 607 607 { 608 608 // Command 609 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocol.QueryListDirectory(609 std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 610 610 id, 611 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,612 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));611 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 612 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 613 613 // Stream 614 614 BackupStoreDirectory dir; … … 650 650 651 651 { 652 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));652 std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 653 653 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 654 std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));654 std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly)); 655 655 } 656 656 … … 759 759 { 760 760 // Command 761 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocol.QueryListDirectory(762 BackupProtocol ClientListDirectory::RootDirectory,763 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,764 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));761 std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 762 BackupProtocolListDirectory::RootDirectory, 763 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 764 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 765 765 // Stream 766 766 BackupStoreDirectory dir; … … 773 773 { 774 774 // Command 775 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(776 BackupProtocol ClientListDirectory::RootDirectory,777 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,778 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));775 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 776 BackupProtocolListDirectory::RootDirectory, 777 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 778 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 779 779 // Stream 780 780 BackupStoreDirectory dir; … … 788 788 { 789 789 FileStream out("testfiles/file1_upload1", O_WRONLY | O_CREAT | O_EXCL); 790 std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocol ClientListDirectory::RootDirectory, store1name));790 std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolListDirectory::RootDirectory, store1name)); 791 791 encoded->CopyStreamTo(out); 792 792 } … … 798 798 { 799 799 FileStream upload("testfiles/file1_upload1"); 800 std::auto_ptr<BackupProtocol ClientSuccess> stored(protocol.QueryStoreFile(801 BackupProtocol ClientListDirectory::RootDirectory,800 std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 801 BackupProtocolListDirectory::RootDirectory, 802 802 0x123456789abcdefLL, /* modification time */ 803 803 0x7362383249872dfLL, /* attr hash */ … … 812 812 { 813 813 // Retrieve as object 814 std::auto_ptr<BackupProtocol ClientSuccess> getfile(protocol.QueryGetObject(store1objid));814 std::auto_ptr<BackupProtocolSuccess> getfile(protocol.QueryGetObject(store1objid)); 815 815 TEST_THAT(getfile->GetObjectID() == store1objid); 816 816 // BLOCK … … 827 827 828 828 // Retrieve as file 829 std::auto_ptr<BackupProtocol ClientSuccess> getobj(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, store1objid));829 std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, store1objid)); 830 830 TEST_THAT(getobj->GetObjectID() == store1objid); 831 831 // BLOCK … … 853 853 // Retrieve the block index, by ID 854 854 { 855 std::auto_ptr<BackupProtocol ClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid));855 std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid)); 856 856 TEST_THAT(getblockindex->GetObjectID() == store1objid); 857 857 std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); … … 861 861 // and again, by name 862 862 { 863 std::auto_ptr<BackupProtocol ClientSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolClientListDirectory::RootDirectory, store1name));863 std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolListDirectory::RootDirectory, store1name)); 864 864 TEST_THAT(getblockindex->GetObjectID() == store1objid); 865 865 std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); … … 871 871 { 872 872 // Command 873 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocol.QueryListDirectory(874 BackupProtocol ClientListDirectory::RootDirectory,875 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,876 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));873 std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 874 BackupProtocolListDirectory::RootDirectory, 875 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 876 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 877 877 // Stream 878 878 BackupStoreDirectory dir; … … 897 897 // Try using GetFile on a directory 898 898 { 899 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocol ClientSuccess> getFile(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, BackupProtocolClientListDirectory::RootDirectory)),899 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> getFile(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, BackupProtocolListDirectory::RootDirectory)), 900 900 ConnectionException, Conn_Protocol_UnexpectedReply); 901 901 } … … 930 930 931 931 // Check the version 932 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(932 std::auto_ptr<BackupProtocolVersion> serverVersion( 933 933 protocol->QueryVersion(BACKUP_STORE_SERVER_VERSION)); 934 934 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 935 935 936 936 // Login 937 std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(937 std::auto_ptr<BackupProtocolLoginConfirmed> loginConf( 938 938 protocol->QueryLogin(0x01234567, 0)); 939 939 … … 1010 1010 BOX_PORT_BBSTORED_TEST); 1011 1011 BackupProtocolClient protocol(conn); 1012 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));1012 std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 1013 1013 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 1014 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),1014 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)), 1015 1015 ConnectionException, Conn_Protocol_UnexpectedReply); 1016 1016 protocol.QueryFinished(); … … 1034 1034 1035 1035 { 1036 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION));1036 std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 1037 1037 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 1038 std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly));1038 std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly)); 1039 1039 1040 1040 // Check client store marker … … 1080 1080 int64_t modtime = 0; 1081 1081 1082 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocol ClientListDirectory::RootDirectory, uploads[t].name, &modtime));1082 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolListDirectory::RootDirectory, uploads[t].name, &modtime)); 1083 1083 TEST_THAT(modtime != 0); 1084 1084 1085 std::auto_ptr<BackupProtocol ClientSuccess> stored(apProtocol->QueryStoreFile(1086 BackupProtocol ClientListDirectory::RootDirectory,1085 std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 1086 BackupProtocolListDirectory::RootDirectory, 1087 1087 modtime, 1088 1088 modtime, /* use it for attr hash too */ … … 1108 1108 TEST_NUM_FILES(UPLOAD_NUM + 1, 0, 0, 1); 1109 1109 MemBlockStream attrnew(attr3, sizeof(attr3)); 1110 std::auto_ptr<BackupProtocol ClientSuccess> set(apProtocol->QuerySetReplacementFileAttributes(1111 BackupProtocol ClientListDirectory::RootDirectory,1110 std::auto_ptr<BackupProtocolSuccess> set(apProtocol->QuerySetReplacementFileAttributes( 1111 BackupProtocolListDirectory::RootDirectory, 1112 1112 32498749832475LL, 1113 1113 uploads[UPLOAD_ATTRS_EN].name, … … 1119 1119 // Delete one of them (will implicitly delete an old version) 1120 1120 { 1121 std::auto_ptr<BackupProtocol ClientSuccess> del(apProtocol->QueryDeleteFile(1122 BackupProtocol ClientListDirectory::RootDirectory,1121 std::auto_ptr<BackupProtocolSuccess> del(apProtocol->QueryDeleteFile( 1122 BackupProtocolListDirectory::RootDirectory, 1123 1123 uploads[UPLOAD_DELETE_EN].name)); 1124 1124 TEST_THAT(del->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid); … … 1131 1131 { 1132 1132 FileStream out("testfiles/downloaddelobj", O_WRONLY | O_CREAT); 1133 std::auto_ptr<BackupProtocol ClientSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid));1133 std::auto_ptr<BackupProtocolSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid)); 1134 1134 std::auto_ptr<IOStream> objstream(apProtocol->ReceiveStream()); 1135 1135 objstream->CopyStreamTo(out); 1136 1136 } 1137 1137 // query index and test 1138 std::auto_ptr<BackupProtocol ClientSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName(1139 BackupProtocol ClientListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name));1138 std::auto_ptr<BackupProtocolSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName( 1139 BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name)); 1140 1140 TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid); 1141 1141 std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream()); … … 1147 1147 { 1148 1148 printf("%d\n", t); 1149 std::auto_ptr<BackupProtocol ClientSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, uploads[t].allocated_objid));1149 std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, uploads[t].allocated_objid)); 1150 1150 TEST_THAT(getFile->GetObjectID() == uploads[t].allocated_objid); 1151 1151 std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream()); … … 1207 1207 { 1208 1208 // Fetch the block index for this one 1209 std::auto_ptr<BackupProtocol ClientSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName(1210 BackupProtocol ClientListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name));1209 std::auto_ptr<BackupProtocolSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName( 1210 BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name)); 1211 1211 TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_PATCH_EN].allocated_objid); 1212 1212 std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream()); … … 1218 1218 BackupStoreFile::EncodeFileDiff( 1219 1219 TEST_FILE_FOR_PATCHING ".mod", 1220 BackupProtocol ClientListDirectory::RootDirectory,1220 BackupProtocolListDirectory::RootDirectory, 1221 1221 uploads[UPLOAD_PATCH_EN].name, 1222 1222 uploads[UPLOAD_PATCH_EN].allocated_objid, … … 1237 1237 { 1238 1238 FileStream uploadpatch(TEST_FILE_FOR_PATCHING ".patch"); 1239 std::auto_ptr<BackupProtocol ClientSuccess> stored(apProtocol->QueryStoreFile(1240 BackupProtocol ClientListDirectory::RootDirectory,1239 std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 1240 BackupProtocolListDirectory::RootDirectory, 1241 1241 modtime, 1242 1242 modtime, /* use it for attr hash too */ … … 1252 1252 1253 1253 // Then download it to check it's OK 1254 std::auto_ptr<BackupProtocol ClientSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, patchedID));1254 std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, patchedID)); 1255 1255 TEST_THAT(getFile->GetObjectID() == patchedID); 1256 1256 std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream()); … … 1268 1268 // Attributes 1269 1269 MemBlockStream attr(attr1, sizeof(attr1)); 1270 std::auto_ptr<BackupProtocol ClientSuccess> dirCreate(apProtocol->QueryCreateDirectory(1271 BackupProtocol ClientListDirectory::RootDirectory,1270 std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory( 1271 BackupProtocolListDirectory::RootDirectory, 1272 1272 9837429842987984LL, dirname, attr)); 1273 1273 subdirid = dirCreate->GetObjectID(); … … 1286 1286 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), subdirid, uploads[0].name, &modtime)); 1287 1287 1288 std::auto_ptr<BackupProtocol ClientSuccess> stored(apProtocol->QueryStoreFile(1288 std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 1289 1289 subdirid, 1290 1290 modtime, … … 1304 1304 { 1305 1305 // Command 1306 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1307 BackupProtocol ClientListDirectory::RootDirectory,1308 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,1309 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream1306 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1307 BackupProtocolListDirectory::RootDirectory, 1308 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 1309 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream 1310 1310 BackupStoreDirectory dir; 1311 1311 std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream()); … … 1329 1329 // Does it look right? 1330 1330 TEST_THAT(en->GetName() == dirname); 1331 TEST_THAT(en->GetFlags() == BackupProtocol ClientListDirectory::Flags_Dir);1331 TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_Dir); 1332 1332 TEST_THAT(en->GetObjectID() == subdirid); 1333 1333 TEST_THAT(en->GetModificationTime() == 0); // dirs don't have modification times. … … 1336 1336 { 1337 1337 // Command 1338 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1338 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1339 1339 subdirid, 1340 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,1341 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */));1340 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 1341 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */)); 1342 1342 TEST_THAT(dirreply->GetObjectID() == subdirid); 1343 1343 // Stream … … 1354 1354 // Does it look right? 1355 1355 TEST_THAT(en->GetName() == uploads[0].name); 1356 TEST_THAT(en->GetFlags() == BackupProtocol ClientListDirectory::Flags_File);1356 TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_File); 1357 1357 TEST_THAT(en->GetObjectID() == subdirfileid); 1358 1358 TEST_THAT(en->GetModificationTime() != 0); … … 1369 1369 { 1370 1370 // Command 1371 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1371 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1372 1372 subdirid, 1373 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,1374 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */));1373 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 1374 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); 1375 1375 // Stream 1376 1376 BackupStoreDirectory dir; … … 1386 1386 { 1387 1387 MemBlockStream attrnew(attr2, sizeof(attr2)); 1388 std::auto_ptr<BackupProtocol ClientSuccess> changereply(apProtocol->QueryChangeDirAttributes(1388 std::auto_ptr<BackupProtocolSuccess> changereply(apProtocol->QueryChangeDirAttributes( 1389 1389 subdirid, 1390 1390 329483209443598LL, … … 1395 1395 { 1396 1396 // Command 1397 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1397 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1398 1398 subdirid, 1399 1399 0, // no flags 1400 BackupProtocol ClientListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */));1400 BackupProtocolListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */)); 1401 1401 // Stream 1402 1402 BackupStoreDirectory dir; … … 1419 1419 BackupStoreFilenameClear newName("moved-files"); 1420 1420 1421 std::auto_ptr<BackupProtocol ClientSuccess> rep(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid,1422 BackupProtocol ClientListDirectory::RootDirectory,1423 subdirid, BackupProtocol ClientMoveObject::Flags_MoveAllWithSameName, newName));1421 std::auto_ptr<BackupProtocolSuccess> rep(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 1422 BackupProtocolListDirectory::RootDirectory, 1423 subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName)); 1424 1424 TEST_THAT(rep->GetObjectID() == uploads[UPLOAD_FILE_TO_MOVE].allocated_objid); 1425 1425 } … … 1429 1429 BackupStoreFilenameClear newName("moved-files"); 1430 1430 TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 1431 BackupProtocol ClientListDirectory::RootDirectory,1432 subdirid, BackupProtocol ClientMoveObject::Flags_MoveAllWithSameName, newName),1431 BackupProtocolListDirectory::RootDirectory, 1432 subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName), 1433 1433 ConnectionException, Conn_Protocol_UnexpectedReply); 1434 1434 TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 1435 1435 subdirid, 1436 subdirid, BackupProtocol ClientMoveObject::Flags_MoveAllWithSameName, newName),1436 subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName), 1437 1437 ConnectionException, Conn_Protocol_UnexpectedReply); 1438 1438 } … … 1443 1443 apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 1444 1444 subdirid, 1445 subdirid, BackupProtocol ClientMoveObject::Flags_MoveAllWithSameName, newName);1445 subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName); 1446 1446 } 1447 1447 … … 1449 1449 { 1450 1450 // Command 1451 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1452 BackupProtocol ClientListDirectory::RootDirectory,1453 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,1454 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));1451 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1452 BackupProtocolListDirectory::RootDirectory, 1453 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 1454 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 1455 1455 // Stream 1456 1456 BackupStoreDirectory dir; … … 1471 1471 1472 1472 // Command 1473 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1473 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1474 1474 subdirid, 1475 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,1476 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));1475 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 1476 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 1477 1477 // Stream 1478 1478 BackupStoreDirectory dir; … … 1506 1506 // Attributes 1507 1507 MemBlockStream attr(attr1, sizeof(attr1)); 1508 std::auto_ptr<BackupProtocol ClientSuccess> dirCreate(apProtocol->QueryCreateDirectory(1508 std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory( 1509 1509 subdirid, 1510 1510 9837429842987984LL, nd, attr)); … … 1513 1513 FileStream upload("testfiles/file1_upload1"); 1514 1514 BackupStoreFilenameClear nf("file2"); 1515 std::auto_ptr<BackupProtocol ClientSuccess> stored(apProtocol->QueryStoreFile(1515 std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 1516 1516 subsubdirid, 1517 1517 0x123456789abcdefLL, /* modification time */ … … 1528 1528 // Query names -- test that invalid stuff returns not found OK 1529 1529 { 1530 std::auto_ptr<BackupProtocol ClientObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid));1530 std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid)); 1531 1531 TEST_THAT(nameRep->GetNumNameElements() == 0); 1532 1532 } 1533 1533 { 1534 std::auto_ptr<BackupProtocol ClientObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL));1534 std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL)); 1535 1535 TEST_THAT(nameRep->GetNumNameElements() == 0); 1536 1536 } 1537 1537 { 1538 std::auto_ptr<BackupProtocol ClientObjectName> nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL));1538 std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL)); 1539 1539 TEST_THAT(nameRep->GetNumNameElements() == 0); 1540 1540 } 1541 1541 { 1542 std::auto_ptr<BackupProtocol ClientObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL));1542 std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL)); 1543 1543 TEST_THAT(nameRep->GetNumNameElements() == 0); 1544 1544 } … … 1546 1546 // Query names... first, get info for the file 1547 1547 { 1548 std::auto_ptr<BackupProtocol ClientObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid));1548 std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid)); 1549 1549 std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream()); 1550 1550 1551 1551 TEST_THAT(nameRep->GetNumNameElements() == 3); 1552 TEST_THAT(nameRep->GetFlags() == BackupProtocol ClientListDirectory::Flags_File);1552 TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_File); 1553 1553 TEST_THAT(nameRep->GetModificationTime() == 0x123456789abcdefLL); 1554 1554 TEST_THAT(nameRep->GetAttributesHash() == 0x7362383249872dfLL); … … 1564 1564 // Query names... secondly, for the directory 1565 1565 { 1566 std::auto_ptr<BackupProtocol ClientObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, subsubdirid));1566 std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, subsubdirid)); 1567 1567 std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream()); 1568 1568 1569 1569 TEST_THAT(nameRep->GetNumNameElements() == 2); 1570 TEST_THAT(nameRep->GetFlags() == BackupProtocol ClientListDirectory::Flags_Dir);1570 TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_Dir); 1571 1571 static const char *testnames[] = {"sub2","lovely_directory"}; 1572 1572 for(int l = 0; l < nameRep->GetNumNameElements(); ++l) … … 1586 1586 // Create some nice recursive directories 1587 1587 int64_t dirtodelete = create_test_data_subdirs(*apProtocol, 1588 BackupProtocol ClientListDirectory::RootDirectory,1588 BackupProtocolListDirectory::RootDirectory, 1589 1589 "test_delete", 6 /* depth */, *apRefCount); 1590 1590 1591 1591 // And delete them 1592 1592 { 1593 std::auto_ptr<BackupProtocol ClientSuccess> dirdel(apProtocol->QueryDeleteDirectory(1593 std::auto_ptr<BackupProtocolSuccess> dirdel(apProtocol->QueryDeleteDirectory( 1594 1594 dirtodelete)); 1595 1595 TEST_THAT(dirdel->GetObjectID() == dirtodelete); … … 1599 1599 { 1600 1600 // Command 1601 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocolReadOnly.QueryListDirectory(1602 BackupProtocol ClientListDirectory::RootDirectory,1603 BackupProtocol ClientListDirectory::Flags_Dir | BackupProtocolClientListDirectory::Flags_Deleted,1604 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));1601 std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 1602 BackupProtocolListDirectory::RootDirectory, 1603 BackupProtocolListDirectory::Flags_Dir | BackupProtocolListDirectory::Flags_Deleted, 1604 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 1605 1605 // Stream 1606 1606 BackupStoreDirectory dir; … … 1890 1890 1891 1891 // Check the version 1892 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));1892 std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 1893 1893 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 1894 1894 1895 1895 // Login 1896 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)),1896 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)), 1897 1897 ConnectionException, Conn_Protocol_UnexpectedReply); 1898 1898 … … 1989 1989 recursive_count_objects_results before = {0,0,0}; 1990 1990 1991 recursive_count_objects("localhost", BackupProtocol ClientListDirectory::RootDirectory, before);1991 recursive_count_objects("localhost", BackupProtocolListDirectory::RootDirectory, before); 1992 1992 1993 1993 TEST_THAT(before.objectsNotDel != 0); … … 2034 2034 recursive_count_objects_results after = {0,0,0}; 2035 2035 recursive_count_objects("localhost", 2036 BackupProtocol ClientListDirectory::RootDirectory,2036 BackupProtocolListDirectory::RootDirectory, 2037 2037 after); 2038 2038 … … 2059 2059 2060 2060 // Check the version 2061 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));2061 std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 2062 2062 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 2063 2063 2064 2064 // Login 2065 std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0));2065 std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)); 2066 2066 2067 2067 int64_t modtime = 0; 2068 2068 2069 2069 BackupStoreFilenameClear fnx("exceed-limit"); 2070 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocol ClientListDirectory::RootDirectory, fnx, &modtime));2070 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocolListDirectory::RootDirectory, fnx, &modtime)); 2071 2071 TEST_THAT(modtime != 0); 2072 2072 2073 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocol ClientSuccess> stored(protocol.QueryStoreFile(2074 BackupProtocol ClientListDirectory::RootDirectory,2073 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 2074 BackupProtocolListDirectory::RootDirectory, 2075 2075 modtime, 2076 2076 modtime, /* use it for attr hash too */ … … 2082 2082 MemBlockStream attr(&modtime, sizeof(modtime)); 2083 2083 BackupStoreFilenameClear fnxd("exceed-limit-dir"); 2084 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocol ClientSuccess> dirCreate(protocol.QueryCreateDirectory(2085 BackupProtocol ClientListDirectory::RootDirectory,2084 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory( 2085 BackupProtocolListDirectory::RootDirectory, 2086 2086 9837429842987984LL, fnxd, attr)), 2087 2087 ConnectionException, Conn_Protocol_UnexpectedReply); … … 2241 2241 int64_t modtime = 0; 2242 2242 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("/Users/ben/temp/large.tar", 2243 BackupProtocol ClientListDirectory::RootDirectory, uploads[0].name, &modtime));2243 BackupProtocolListDirectory::RootDirectory, uploads[0].name, &modtime)); 2244 2244 TEST_THAT(modtime != 0); 2245 2245 FileStream write("testfiles/large.enc", O_WRONLY | O_CREAT); -
box/trunk/test/backupstorepatch/testbackupstorepatch.cpp
r2646 r2983 14 14 #include <signal.h> 15 15 16 #include "autogen_BackupProtocol Client.h"16 #include "autogen_BackupProtocol.h" 17 17 #include "BackupClientCryptoKeys.h" 18 18 #include "BackupClientFileAttributes.h" … … 355 355 { 356 356 // Check the version 357 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));357 std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 358 358 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 359 359 … … 368 368 { 369 369 std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/0.test", 370 BackupProtocol ClientListDirectory::RootDirectory, storeFilename));371 std::auto_ptr<BackupProtocol ClientSuccess> stored(protocol.QueryStoreFile(372 BackupProtocol ClientListDirectory::RootDirectory, ModificationTime,370 BackupProtocolListDirectory::RootDirectory, storeFilename)); 371 std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 372 BackupProtocolListDirectory::RootDirectory, ModificationTime, 373 373 ModificationTime, 0 /* no diff from file ID */, storeFilename, *upload)); 374 374 test_files[0].IDOnServer = stored->GetObjectID(); … … 381 381 { 382 382 // Get an index for the previous version 383 std::auto_ptr<BackupProtocol ClientSuccess> getBlockIndex(protocol.QueryGetBlockIndexByName(384 BackupProtocol ClientListDirectory::RootDirectory, storeFilename));383 std::auto_ptr<BackupProtocolSuccess> getBlockIndex(protocol.QueryGetBlockIndexByName( 384 BackupProtocolListDirectory::RootDirectory, storeFilename)); 385 385 int64_t diffFromID = getBlockIndex->GetObjectID(); 386 386 TEST_THAT(diffFromID != 0); … … 398 398 BackupStoreFile::EncodeFileDiff( 399 399 filename, 400 BackupProtocol ClientListDirectory::RootDirectory, /* containing directory */400 BackupProtocolListDirectory::RootDirectory, /* containing directory */ 401 401 storeFilename, 402 402 diffFromID, … … 408 408 409 409 // Upload the patch to the store 410 std::auto_ptr<BackupProtocol ClientSuccess> stored(protocol.QueryStoreFile(411 BackupProtocol ClientListDirectory::RootDirectory, ModificationTime,410 std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 411 BackupProtocolListDirectory::RootDirectory, ModificationTime, 412 412 ModificationTime, isCompletelyDifferent?(0):(diffFromID), storeFilename, *patchStream)); 413 413 ModificationTime += MODIFICATION_TIME_INC; … … 433 433 // List the directory from the server, and check that no dependency info is sent -- waste of bytes 434 434 { 435 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(protocol.QueryListDirectory(436 BackupProtocol ClientListDirectory::RootDirectory,437 BackupProtocol ClientListDirectory::Flags_INCLUDE_EVERYTHING,438 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */));435 std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 436 BackupProtocolListDirectory::RootDirectory, 437 BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 438 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 439 439 // Stream 440 440 BackupStoreDirectory dir; … … 532 532 BackupProtocolClient protocol(conn); 533 533 { 534 std::auto_ptr<BackupProtocol ClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION));534 std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 535 535 TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 536 536 protocol.QueryLogin(0x01234567, 0); … … 556 556 // Fetch the file 557 557 { 558 std::auto_ptr<BackupProtocol ClientSuccess> getobj(protocol.QueryGetFile(559 BackupProtocol ClientListDirectory::RootDirectory,558 std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile( 559 BackupProtocolListDirectory::RootDirectory, 560 560 test_files[f].IDOnServer)); 561 561 TEST_THAT(getobj->GetObjectID() == test_files[f].IDOnServer); … … 573 573 // Download the index, and check it looks OK 574 574 { 575 std::auto_ptr<BackupProtocol ClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(test_files[f].IDOnServer));575 std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(test_files[f].IDOnServer)); 576 576 TEST_THAT(getblockindex->GetObjectID() == test_files[f].IDOnServer); 577 577 std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); -
box/trunk/test/basicserver/Makefile.extra
r2598 r2983 2 2 MAKEPROTOCOL = ../../lib/server/makeprotocol.pl 3 3 4 GEN_CMD_SRV = $(MAKEPROTOCOL) Server testprotocol.txt 5 GEN_CMD_CLI = $(MAKEPROTOCOL) Client testprotocol.txt 4 GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt 6 5 7 6 # AUTOGEN SEEDING 8 autogen_TestProtocol Server.cpp: $(MAKEPROTOCOL) testprotocol.txt9 $(_PERL) $(GEN_CMD _SRV)7 autogen_TestProtocol.cpp: $(MAKEPROTOCOL) testprotocol.txt 8 $(_PERL) $(GEN_CMD) 10 9 11 10 autogen_TestProtocolServer.h: $(MAKEPROTOCOL) testprotocol.txt 12 $(_PERL) $(GEN_CMD _SRV)11 $(_PERL) $(GEN_CMD) 13 12 14 15 # AUTOGEN SEEDING16 autogen_TestProtocolClient.cpp: $(MAKEPROTOCOL) testprotocol.txt17 $(_PERL) $(GEN_CMD_CLI)18 19 autogen_TestProtocolClient.h: $(MAKEPROTOCOL) testprotocol.txt20 $(_PERL) $(GEN_CMD_CLI)21 -
box/trunk/test/basicserver/TestCommands.cpp
r710 r2983 6 6 #endif 7 7 8 #include "autogen_TestProtocol Server.h"8 #include "autogen_TestProtocol.h" 9 9 #include "CollectInBufferStream.h" 10 10 … … 12 12 13 13 14 std::auto_ptr< ProtocolObject> TestProtocolServerHello::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)14 std::auto_ptr<TestProtocolMessage> TestProtocolHello::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 15 15 { 16 16 if(mNumber32 != 41 || mNumber16 != 87 || mNumber8 != 11 || mText != "pingu") 17 17 { 18 return std::auto_ptr< ProtocolObject>(new TestProtocolServerError(0, 0));18 return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 19 19 } 20 return std::auto_ptr< ProtocolObject>(new TestProtocolServerHello(12,89,22,std::string("Hello world!")));20 return std::auto_ptr<TestProtocolMessage>(new TestProtocolHello(12,89,22,std::string("Hello world!"))); 21 21 } 22 22 23 std::auto_ptr< ProtocolObject> TestProtocolServerLists::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)23 std::auto_ptr<TestProtocolMessage> TestProtocolLists::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 24 24 { 25 return std::auto_ptr< ProtocolObject>(new TestProtocolServerListsReply(mLotsOfText.size()));25 return std::auto_ptr<TestProtocolMessage>(new TestProtocolListsReply(mLotsOfText.size())); 26 26 } 27 27 28 std::auto_ptr< ProtocolObject> TestProtocolServerQuit::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)28 std::auto_ptr<TestProtocolMessage> TestProtocolQuit::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 29 29 { 30 return std::auto_ptr< ProtocolObject>(new TestProtocolServerQuit);30 return std::auto_ptr<TestProtocolMessage>(new TestProtocolQuit); 31 31 } 32 32 33 std::auto_ptr< ProtocolObject> TestProtocolServerSimple::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)33 std::auto_ptr<TestProtocolMessage> TestProtocolSimple::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 34 34 { 35 return std::auto_ptr< ProtocolObject>(new TestProtocolServerSimpleReply(mValue+1));35 return std::auto_ptr<TestProtocolMessage>(new TestProtocolSimpleReply(mValue+1)); 36 36 } 37 37 … … 46 46 }; 47 47 48 std::auto_ptr< ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)48 std::auto_ptr<TestProtocolMessage> TestProtocolGetStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 49 49 { 50 50 // make a new stream object … … 69 69 rProtocol.SendStreamAfterCommand(pstream); 70 70 71 return std::auto_ptr< ProtocolObject>(new TestProtocolServerGetStream(mStartingValue, mUncertainSize));71 return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(mStartingValue, mUncertainSize)); 72 72 } 73 73 74 std::auto_ptr< ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)74 std::auto_ptr<TestProtocolMessage> TestProtocolSendStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 75 75 { 76 76 if(mValue != 0x73654353298ffLL) 77 77 { 78 return std::auto_ptr< ProtocolObject>(new TestProtocolServerError(0, 0));78 return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 79 79 } 80 80 … … 92 92 93 93 // tell the caller how many bytes there were 94 return std::auto_ptr< ProtocolObject>(new TestProtocolServerGetStream(bytes, uncertain));94 return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(bytes, uncertain)); 95 95 } 96 96 97 std::auto_ptr< ProtocolObject> TestProtocolServerString::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)97 std::auto_ptr<TestProtocolMessage> TestProtocolString::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 98 98 { 99 return std::auto_ptr< ProtocolObject>(new TestProtocolServerString(mTest));99 return std::auto_ptr<TestProtocolMessage>(new TestProtocolString(mTest)); 100 100 } 101 101 -
box/trunk/test/basicserver/testbasicserver.cpp
r2942 r2983 27 27 28 28 #include "TestContext.h" 29 #include "autogen_TestProtocolClient.h" 30 #include "autogen_TestProtocolServer.h" 29 #include "autogen_TestProtocol.h" 31 30 #include "ServerControl.h" 32 31 … … 394 393 void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream) 395 394 { 396 std::auto_ptr<TestProtocol ClientGetStream> reply(protocol.QueryGetStream(value, uncertainstream));395 std::auto_ptr<TestProtocolGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); 397 396 TEST_THAT(reply->GetStartingValue() == value); 398 397 … … 705 704 // Simple query 706 705 { 707 std::auto_ptr<TestProtocol ClientSimpleReply> reply(protocol.QuerySimple(41));706 std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(41)); 708 707 TEST_THAT(reply->GetValuePlusOne() == 42); 709 708 } 710 709 { 711 std::auto_ptr<TestProtocol ClientSimpleReply> reply(protocol.QuerySimple(809));710 std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(809)); 712 711 TEST_THAT(reply->GetValuePlusOne() == 810); 713 712 } … … 725 724 s.Write(buf, sizeof(buf)); 726 725 s.SetForReading(); 727 std::auto_ptr<TestProtocol ClientGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s));726 std::auto_ptr<TestProtocolGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); 728 727 TEST_THAT(reply->GetStartingValue() == sizeof(buf)); 729 728 } … … 732 731 for(int q = 0; q < 514; q++) 733 732 { 734 std::auto_ptr<TestProtocol ClientSimpleReply> reply(protocol.QuerySimple(q));733 std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(q)); 735 734 TEST_THAT(reply->GetValuePlusOne() == (q+1)); 736 735 } … … 741 740 strings.push_back(std::string("test2")); 742 741 strings.push_back(std::string("test3")); 743 std::auto_ptr<TestProtocol ClientListsReply> reply(protocol.QueryLists(strings));742 std::auto_ptr<TestProtocolListsReply> reply(protocol.QueryLists(strings)); 744 743 TEST_THAT(reply->GetNumberOfStrings() == 3); 745 744 } … … 747 746 // And another 748 747 { 749 std::auto_ptr<TestProtocol ClientHello> reply(protocol.QueryHello(41,87,11,std::string("pingu")));748 std::auto_ptr<TestProtocolHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); 750 749 TEST_THAT(reply->GetNumber32() == 12); 751 750 TEST_THAT(reply->GetNumber16() == 89); -
box/trunk/test/bbackupd/Makefile.extra
r2973 r2983 9 9 ../../bin/bbstored/BBStoreDHousekeeping.o \ 10 10 ../../bin/bbstored/HousekeepStoreAccount.o \ 11 ../../lib/backupstore/autogen_BackupProtocol Server.o \11 ../../lib/backupstore/autogen_BackupProtocol.o \ 12 12 ../../lib/backupstore/BackupStoreContext.o \ 13 13 ../../lib/backupstore/BackupCommands.o \ -
box/trunk/test/bbackupd/testbbackupd.cpp
r2944 r2983 43 43 #endif 44 44 45 #include "autogen_BackupProtocol Server.h"45 #include "autogen_BackupProtocol.h" 46 46 #include "BackupClientCryptoKeys.h" 47 47 #include "BackupClientFileAttributes.h" … … 74 74 #include "Utils.h" 75 75 76 #include "autogen_BackupProtocolClient.h"77 76 #include "intercept.h" 78 77 #include "ServerControl.h" … … 476 475 protocol.QueryListDirectory( 477 476 InDirectory, 478 BackupProtocol ClientListDirectory::Flags_Dir,479 BackupProtocol ClientListDirectory::Flags_EXCLUDE_NOTHING,477 BackupProtocolListDirectory::Flags_Dir, 478 BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 480 479 true /* want attributes */); 481 480 … … 519 518 BackupProtocolClient protocol(conn); 520 519 protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); 521 std::auto_ptr<BackupProtocol ClientLoginConfirmed>520 std::auto_ptr<BackupProtocolLoginConfirmed> 522 521 loginConf(protocol.QueryLogin(0x01234567, 523 BackupProtocol ClientLogin::Flags_ReadOnly));522 BackupProtocolLogin::Flags_ReadOnly)); 524 523 525 524 // Test the restoration … … 605 604 int64_t id = en->GetObjectID(); 606 605 TEST_THAT(id > 0); 607 TEST_THAT(id != BackupProtocol ClientListDirectory::RootDirectory);606 TEST_THAT(id != BackupProtocolListDirectory::RootDirectory); 608 607 return id; 609 608 } … … 618 617 connection.reset(new BackupProtocolClient(sSocket)); 619 618 connection->Handshake(); 620 std::auto_ptr<BackupProtocol ClientVersion>619 std::auto_ptr<BackupProtocolVersion> 621 620 serverVersion(connection->QueryVersion( 622 621 BACKUP_STORE_SERVER_VERSION)); … … 641 640 ( 642 641 BackupProtocolClient& rClient, 643 int64_t id 642 int64_t id = BackupProtocolListDirectory::RootDirectory 644 643 ) 645 644 { 646 std::auto_ptr<BackupProtocol ClientSuccess> dirreply(645 std::auto_ptr<BackupProtocolSuccess> dirreply( 647 646 rClient.QueryListDirectory(id, false, 0, false)); 648 647 std::auto_ptr<IOStream> dirstream(rClient.ReceiveStream()); … … 767 766 else 768 767 { 769 BOX_ INFO("readdir hook still active at " << time_now << ", "768 BOX_TRACE("readdir hook still active at " << time_now << ", " 770 769 "waiting for " << readdir_stop_time); 771 770 } … … 781 780 sizeof(readdir_test_dirent.d_name), 782 781 "test.%d", readdir_test_counter); 783 BOX_ INFO("readdir hook returning " << readdir_test_dirent.d_name);782 BOX_TRACE("readdir hook returning " << readdir_test_dirent.d_name); 784 783 785 784 // ensure that when bbackupd stats the file, it gets the … … 792 791 intercept_setup_lstat_hook(stat_hook_filename, lstat_test_hook); 793 792 #endif 793 794 // sleep a bit to reduce the number of dirents returned 795 ::safe_sleep(1); 794 796 795 797 return &readdir_test_dirent; … … 1131 1133 TEST_LINE(comp2 != sub, line); 1132 1134 } 1135 1136 // Check that no read error has been reported yet 1137 TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); 1133 1138 1134 1139 if (failures > 0) … … 1339 1344 ConnectAndLogin(context, 0 /* read-write */); 1340 1345 1341 std::auto_ptr<BackupProtocol ClientAccountUsage> usage(1346 std::auto_ptr<BackupProtocolAccountUsage> usage( 1342 1347 client->QueryGetAccountUsage()); 1343 1348 TEST_EQUAL_LINE(24, usage->GetBlocksUsed(), … … 1422 1427 1423 1428 std::auto_ptr<BackupStoreDirectory> rootDir = 1424 ReadDirectory(*client, 1425 BackupProtocolClientListDirectory::RootDirectory); 1429 ReadDirectory(*client); 1426 1430 1427 1431 int64_t testDirId = SearchDir(*rootDir, "Test1"); … … 1465 1469 TEST_THAT(test_entry_deleted(*d4_dir, "f5")); 1466 1470 1467 std::auto_ptr<BackupProtocol ClientAccountUsage> usage(1471 std::auto_ptr<BackupProtocolAccountUsage> usage( 1468 1472 client->QueryGetAccountUsage()); 1469 1473 TEST_EQUAL_LINE(24, usage->GetBlocksUsed(), … … 1499 1503 1500 1504 std::auto_ptr<BackupStoreDirectory> rootDir = 1501 ReadDirectory(*client, 1502 BackupProtocolClientListDirectory::RootDirectory); 1505 ReadDirectory(*client); 1503 1506 1504 1507 int64_t testDirId = SearchDir(*rootDir, "Test1"); … … 1520 1523 TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0); 1521 1524 1522 std::auto_ptr<BackupProtocol ClientAccountUsage> usage(1525 std::auto_ptr<BackupProtocolAccountUsage> usage( 1523 1526 client->QueryGetAccountUsage()); 1524 1527 TEST_EQUAL_LINE(16, usage->GetBlocksUsed(), … … 1575 1578 ConnectAndLogin(context, 0 /* read-write */); 1576 1579 1577 std::auto_ptr<BackupProtocol ClientAccountUsage> usage(1580 std::auto_ptr<BackupProtocolAccountUsage> usage( 1578 1581 client->QueryGetAccountUsage()); 1579 1582 TEST_EQUAL_LINE(22, usage->GetBlocksUsed(), … … 1686 1689 class MyHook : public BackupStoreContext::TestHook 1687 1690 { 1688 virtual std::auto_ptr< ProtocolObject> StartCommand(1689 BackupProtocolObject& rCommand)1691 virtual std::auto_ptr<BackupProtocolMessage> StartCommand( 1692 const BackupProtocolMessage& rCommand) 1690 1693 { 1691 1694 if (rCommand.GetType() == 1692 BackupProtocolS erverStoreFile::TypeID)1695 BackupProtocolStoreFile::TypeID) 1693 1696 { 1694 1697 // terminate badly … … 1696 1699 Internal); 1697 1700 } 1698 return std::auto_ptr< ProtocolObject>();1701 return std::auto_ptr<BackupProtocolMessage>(); 1699 1702 } 1700 1703 }; … … 1960 1963 std::auto_ptr<BackupProtocolClient> client = 1961 1964 ConnectAndLogin(context, 1962 BackupProtocol ClientLogin::Flags_ReadOnly);1965 BackupProtocolLogin::Flags_ReadOnly); 1963 1966 1964 1967 std::auto_ptr<BackupStoreDirectory> dir = 1965 ReadDirectory(*client, 1966 BackupProtocolClientListDirectory::RootDirectory); 1968 ReadDirectory(*client); 1967 1969 int64_t testDirId = SearchDir(*dir, "Test2"); 1968 1970 TEST_THAT(testDirId != 0); … … 1999 2001 std::auto_ptr<BackupProtocolClient> client = 2000 2002 ConnectAndLogin(context, 2001 BackupProtocol ClientLogin::Flags_ReadOnly);2003 BackupProtocolLogin::Flags_ReadOnly); 2002 2004 2003 2005 std::auto_ptr<BackupStoreDirectory> dir = 2004 ReadDirectory(*client, 2005 BackupProtocolClientListDirectory::RootDirectory); 2006 ReadDirectory(*client); 2006 2007 int64_t testDirId = SearchDir(*dir, "Test2"); 2007 2008 TEST_THAT(testDirId != 0); … … 2018 2019 std::auto_ptr<BackupProtocolClient> client = 2019 2020 ConnectAndLogin(context, 2020 BackupProtocol ClientLogin::Flags_ReadOnly);2021 BackupProtocolLogin::Flags_ReadOnly); 2021 2022 2022 2023 std::auto_ptr<BackupStoreDirectory> root_dir = 2023 ReadDirectory(*client, 2024 BackupProtocolClientListDirectory::RootDirectory); 2024 ReadDirectory(*client); 2025 2025 2026 2026 TEST_THAT(test_entry_deleted(*root_dir, "Test2")); … … 2264 2264 2265 2265 std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory( 2266 *client, 2267 BackupProtocolClientListDirectory::RootDirectory); 2266 *client); 2268 2267 2269 2268 int64_t baseDirId = SearchDir(*dir, "Test1"); … … 3258 3257 std::auto_ptr<BackupProtocolClient> client = 3259 3258 ConnectAndLogin(context, 3260 BackupProtocol ClientLogin::Flags_ReadOnly);3259 BackupProtocolLogin::Flags_ReadOnly); 3261 3260 3262 3261 std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory( 3263 *client, 3264 BackupProtocolClientListDirectory::RootDirectory); 3262 *client); 3265 3263 3266 3264 int64_t testDirId = SearchDir(*dir, "Test1"); … … 3439 3437 std::auto_ptr<BackupProtocolClient> client = 3440 3438 ConnectAndLogin(context, 3441 BackupProtocol ClientLogin::Flags_ReadOnly);3439 BackupProtocolLogin::Flags_ReadOnly); 3442 3440 3443 3441 // Find the ID of the Test1 directory 3444 3442 restoredirid = GetDirID(*client, "Test1", 3445 BackupProtocol ClientListDirectory::RootDirectory);3443 BackupProtocolListDirectory::RootDirectory); 3446 3444 TEST_THAT(restoredirid != 0); 3447 3445 … … 3746 3744 // because that's the default, and 3747 3745 // it should have changed 3748 std::auto_ptr<BackupProtocol ClientLoginConfirmed> loginConf(protocol->QueryLogin(0x01234567, 0));3746 std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol->QueryLogin(0x01234567, 0)); 3749 3747 TEST_THAT(loginConf->GetClientStoreMarker() != 0); 3750 3748 … … 3824 3822 std::auto_ptr<BackupProtocolClient> client = 3825 3823 ConnectAndLogin(context, 3826 BackupProtocol ClientLogin::Flags_ReadOnly);3824 BackupProtocolLogin::Flags_ReadOnly); 3827 3825 3828 3826 // Check that the restore fn returns resume possible,
Note: See TracChangeset
for help on using the changeset viewer.
