Changeset 2983 for box/trunk


Ignore:
Timestamp:
27/08/2011 15:06:46 (9 months ago)
Author:
chris
Message:

Combine client and server protocols to make way for an offline/local protocol.

Rename ProtocolObject? to Message.

Location:
box/trunk
Files:
29 edited
2 moved

Legend:

Unmodified
Added
Removed
  • box/trunk/bin/bbackupd/BackupClientContext.cpp

    r2696 r2983  
    2626#include "BackupStoreException.h" 
    2727#include "BackupDaemon.h" 
    28 #include "autogen_BackupProtocolClient.h" 
     28#include "autogen_BackupProtocol.h" 
    2929#include "BackupStoreFile.h" 
    3030#include "Logging.h" 
     
    166166                // Check the version of the server 
    167167                { 
    168                         std::auto_ptr<BackupProtocolClientVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     168                        std::auto_ptr<BackupProtocolVersion> serverVersion(mpConnection->QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    169169                        if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION) 
    170170                        { 
     
    174174 
    175175                // Login -- if this fails, the Protocol will exception 
    176                 std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */)); 
     176                std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(mpConnection->QueryLogin(mAccountNumber, 0 /* read/write */)); 
    177177                 
    178178                // Check that the client store marker is the one we expect 
     
    420420        // Request filenames from the server, in a "safe" manner to ignore errors properly 
    421421        { 
    422                 BackupProtocolClientGetObjectName send(ObjectID, ContainingDirectory); 
     422                BackupProtocolGetObjectName send(ObjectID, ContainingDirectory); 
    423423                connection.Send(send); 
    424424        } 
    425         std::auto_ptr<BackupProtocolObjectCl> preply(connection.Receive()); 
     425        std::auto_ptr<BackupProtocolMessage> preply(connection.Receive()); 
    426426 
    427427        // Is it of the right type? 
    428         if(preply->GetType() != BackupProtocolClientObjectName::TypeID) 
     428        if(preply->GetType() != BackupProtocolObjectName::TypeID) 
    429429        { 
    430430                // Was an error or something 
     
    433433 
    434434        // Cast to expected type. 
    435         BackupProtocolClientObjectName *names = (BackupProtocolClientObjectName *)(preply.get()); 
     435        BackupProtocolObjectName *names = (BackupProtocolObjectName *)(preply.get()); 
    436436 
    437437        // Anything found? 
     
    483483 
    484484        // Is it a directory? 
    485         rIsDirectoryOut = ((names->GetFlags() & BackupProtocolClientListDirectory::Flags_Dir) == BackupProtocolClientListDirectory::Flags_Dir); 
     485        rIsDirectoryOut = ((names->GetFlags() & BackupProtocolListDirectory::Flags_Dir) == BackupProtocolListDirectory::Flags_Dir); 
    486486         
    487487        // Is it the current version? 
    488         rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolClientListDirectory::Flags_OldVersion | BackupProtocolClientListDirectory::Flags_Deleted)) == 0); 
     488        rIsCurrentVersionOut = ((names->GetFlags() & (BackupProtocolListDirectory::Flags_OldVersion | BackupProtocolListDirectory::Flags_Deleted)) == 0); 
    489489 
    490490        // And other information which may be required 
  • box/trunk/bin/bbackupd/BackupClientDeleteList.cpp

    r2181 r2983  
    1414#include "BackupClientDeleteList.h" 
    1515#include "BackupClientContext.h" 
    16 #include "autogen_BackupProtocolClient.h" 
     16#include "autogen_BackupProtocol.h" 
    1717 
    1818#include "MemLeakFindOn.h" 
  • box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp

    r2981 r2983  
    1818#include <string.h> 
    1919 
    20 #include "autogen_BackupProtocolClient.h" 
     20#include "autogen_BackupProtocol.h" 
    2121#include "Archive.h" 
    2222#include "BackupClientContext.h" 
     
    336336                                                file_st.st_nlink); 
    337337                                } 
    338                                 else if(file_st.st_nlink != 1) 
     338                                else if(file_st.st_nlink > 1) 
    339339                                { 
    340340                                        if(!mSuppressMultipleLinksWarning) 
     
    614614 
    615615                // Query the directory 
    616                 std::auto_ptr<BackupProtocolClientSuccess> dirreply(connection.QueryListDirectory( 
     616                std::auto_ptr<BackupProtocolSuccess> dirreply(connection.QueryListDirectory( 
    617617                                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 
    620621                                true /* want attributes */)); 
    621622 
     
    831832                                                                // Rename the existing files (ie include old versions) on the server 
    832833                                                                connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, 
    833                                                                         BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject, 
     834                                                                        BackupProtocolMoveObject::Flags_MoveAllWithSameName |  
     835                                                                        BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, 
    834836                                                                        storeFilename); 
    835837                                                                         
     
    13651367                                        // Rename the existing directory on the server 
    13661368                                        connection.QueryMoveObject(renameObjectID, renameInDirectory, mObjectID /* move to this directory */, 
    1367                                                 BackupProtocolClientMoveObject::Flags_MoveAllWithSameName | BackupProtocolClientMoveObject::Flags_AllowMoveOverDeletedObject, 
     1369                                                BackupProtocolMoveObject::Flags_MoveAllWithSameName |  
     1370                                                BackupProtocolMoveObject::Flags_AllowMoveOverDeletedObject, 
    13681371                                                storeFilename); 
    13691372                                                 
     
    13821385                                { 
    13831386                                        // Create a new directory 
    1384                                         std::auto_ptr<BackupProtocolClientSuccess> dirCreate(connection.QueryCreateDirectory( 
     1387                                        std::auto_ptr<BackupProtocolSuccess> dirCreate(connection.QueryCreateDirectory( 
    13851388                                                mObjectID, attrModTime, storeFilename, attrStream)); 
    13861389                                        subDirObjectID = dirCreate->GetObjectID();  
     
    15781581                        // YES -- try to do diff, if possible 
    15791582                        // First, query the server to see if there's an old version available 
    1580                         std::auto_ptr<BackupProtocolClientSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename)); 
     1583                        std::auto_ptr<BackupProtocolSuccess> getBlockIndex(connection.QueryGetBlockIndexByName(mObjectID, rStoreFilename)); 
    15811584                        int64_t diffFromID = getBlockIndex->GetObjectID(); 
    15821585                         
     
    16261629                                // Upload the patch to the store 
    16271630                                // 
    1628                                 std::auto_ptr<BackupProtocolClientSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime, 
     1631                                std::auto_ptr<BackupProtocolSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime, 
    16291632                                                AttributesHash, isCompletelyDifferent?(0):(diffFromID), rStoreFilename, *pStreamToUpload)); 
    16301633                                 
     
    16671670         
    16681671                        // Send to store 
    1669                         std::auto_ptr<BackupProtocolClientSuccess> stored( 
     1672                        std::auto_ptr<BackupProtocolSuccess> stored( 
    16701673                                connection.QueryStoreFile( 
    16711674                                        mObjectID, ModificationTime, 
     
    16931696                        if(connection.GetLastError(type, subtype)) 
    16941697                        { 
    1695                                 if(type == BackupProtocolClientError::ErrorType 
    1696                                 && subtype == BackupProtocolClientError::Err_StorageLimitExceeded) 
     1698                                if(type == BackupProtocolError::ErrorType 
     1699                                && subtype == BackupProtocolError::Err_StorageLimitExceeded) 
    16971700                                { 
    16981701                                        // The hard limit was exceeded on the server, notify! 
  • box/trunk/bin/bbackupd/BackupDaemon.cpp

    r2981 r2983  
    5151#include "SSLLib.h" 
    5252 
    53 #include "autogen_BackupProtocolClient.h" 
     53#include "autogen_BackupProtocol.h" 
    5454#include "autogen_ClientException.h" 
    5555#include "autogen_ConversionException.h" 
     
    697697        mDoSyncForcedByPreviousSyncError = false; 
    698698         
     699        // Notify system administrator about the final state of the backup 
    699700        if(errorOccurred) 
    700701        { 
     
    758759                } 
    759760        } 
    760         // Notify system administrator about the final state of the backup 
    761         else if(mReadErrorsOnFilesystemObjects) 
     761 
     762        if(mReadErrorsOnFilesystemObjects) 
    762763        { 
    763764                NotifySysadmin(SysadminNotifier::ReadError); 
    764765        } 
    765         else if(mStorageLimitExceeded) 
     766 
     767        if(mStorageLimitExceeded) 
    766768        { 
    767769                NotifySysadmin(SysadminNotifier::StoreFull); 
    768770        } 
    769         else 
     771 
     772        if (!errorOccurred && !mReadErrorsOnFilesystemObjects && 
     773                !mStorageLimitExceeded) 
    770774        { 
    771775                NotifySysadmin(SysadminNotifier::BackupOK); 
     
    10051009 
    10061010                (*i)->mpDirectoryRecord->SyncDirectory(params, 
    1007                         BackupProtocolClientListDirectory::RootDirectory, 
     1011                        BackupProtocolListDirectory::RootDirectory, 
    10081012                        locationPath, std::string("/") + (*i)->mName); 
    10091013 
     
    20982102        // Going to need a copy of the root directory. Get a connection, 
    20992103        // and fetch it. 
    2100         BackupProtocolClient &connection(rClientContext.GetConnection()); 
     2104        BackupProtocolCallable& connection(rClientContext.GetConnection()); 
    21012105         
    21022106        // Ask server for a list of everything in the root directory, 
    21032107        // which is a directory itself 
    2104         std::auto_ptr<BackupProtocolClientSuccess> dirreply( 
     2108        std::auto_ptr<BackupProtocolSuccess> dirreply( 
    21052109                connection.QueryListDirectory( 
    2106                         BackupProtocolClientListDirectory::RootDirectory, 
     2110                        BackupProtocolListDirectory::RootDirectory, 
    21072111                        // only directories 
    2108                         BackupProtocolClientListDirectory::Flags_Dir, 
     2112                        BackupProtocolListDirectory::Flags_Dir, 
    21092113                        // exclude old/deleted stuff 
    2110                         BackupProtocolClientListDirectory::Flags_Deleted | 
    2111                         BackupProtocolClientListDirectory::Flags_OldVersion, 
     2114                        BackupProtocolListDirectory::Flags_Deleted | 
     2115                        BackupProtocolListDirectory::Flags_OldVersion, 
    21122116                        false /* no attributes */)); 
    21132117 
     
    23492353                                { 
    23502354                                        MemBlockStream attrStream(attr); 
    2351                                         std::auto_ptr<BackupProtocolClientSuccess> 
     2355                                        std::auto_ptr<BackupProtocolSuccess> 
    23522356                                                dirCreate(connection.QueryCreateDirectory( 
    2353                                                 BackupProtocolClientListDirectory::RootDirectory, 
     2357                                                BackupProtocolListDirectory::RootDirectory, 
    23542358                                                attrModTime, dirname, attrStream)); 
    23552359                                                 
     
    28952899        // Entries to delete, and it's the right time to do so... 
    28962900        BOX_NOTICE("Deleting unused locations from store root..."); 
    2897         BackupProtocolClient &connection(rContext.GetConnection()); 
     2901        BackupProtocolCallable &connection(rContext.GetConnection()); 
    28982902        for(std::vector<std::pair<int64_t,std::string> >::iterator 
    28992903                i(mUnusedRootDirEntries.begin()); 
  • box/trunk/bin/bbackupd/BackupDaemon.h

    r2981 r2983  
    2525#include "TLSContext.h" 
    2626 
    27 #include "autogen_BackupProtocolClient.h" 
     27#include "autogen_BackupProtocol.h" 
    2828 
    2929#ifdef WIN32 
     
    383383        { 
    384384                std::ostringstream msgs; 
    385                 if (type != BackupProtocolClientError::ErrorType) 
     385                if (type != BackupProtocolError::ErrorType) 
    386386                { 
    387387                        msgs << "unknown error type " << type; 
     
    391391                        switch(subtype) 
    392392                        { 
    393                         case BackupProtocolClientError::Err_WrongVersion: 
     393                        case BackupProtocolError::Err_WrongVersion: 
    394394                                msgs << "WrongVersion"; 
    395395                                break; 
    396                         case BackupProtocolClientError::Err_NotInRightProtocolPhase: 
     396                        case BackupProtocolError::Err_NotInRightProtocolPhase: 
    397397                                msgs << "NotInRightProtocolPhase"; 
    398398                                break; 
    399                         case BackupProtocolClientError::Err_BadLogin: 
     399                        case BackupProtocolError::Err_BadLogin: 
    400400                                msgs << "BadLogin"; 
    401401                                break; 
    402                         case BackupProtocolClientError::Err_CannotLockStoreForWriting: 
     402                        case BackupProtocolError::Err_CannotLockStoreForWriting: 
    403403                                msgs << "CannotLockStoreForWriting"; 
    404404                                break; 
    405                         case BackupProtocolClientError::Err_SessionReadOnly: 
     405                        case BackupProtocolError::Err_SessionReadOnly: 
    406406                                msgs << "SessionReadOnly"; 
    407407                                break; 
    408                         case BackupProtocolClientError::Err_FileDoesNotVerify: 
     408                        case BackupProtocolError::Err_FileDoesNotVerify: 
    409409                                msgs << "FileDoesNotVerify"; 
    410410                                break; 
    411                         case BackupProtocolClientError::Err_DoesNotExist: 
     411                        case BackupProtocolError::Err_DoesNotExist: 
    412412                                msgs << "DoesNotExist"; 
    413413                                break; 
    414                         case BackupProtocolClientError::Err_DirectoryAlreadyExists: 
     414                        case BackupProtocolError::Err_DirectoryAlreadyExists: 
    415415                                msgs << "DirectoryAlreadyExists"; 
    416416                                break; 
    417                         case BackupProtocolClientError::Err_CannotDeleteRoot: 
     417                        case BackupProtocolError::Err_CannotDeleteRoot: 
    418418                                msgs << "CannotDeleteRoot"; 
    419419                                break; 
    420                         case BackupProtocolClientError::Err_TargetNameExists: 
     420                        case BackupProtocolError::Err_TargetNameExists: 
    421421                                msgs << "TargetNameExists"; 
    422422                                break; 
    423                         case BackupProtocolClientError::Err_StorageLimitExceeded: 
     423                        case BackupProtocolError::Err_StorageLimitExceeded: 
    424424                                msgs << "StorageLimitExceeded"; 
    425425                                break; 
    426                         case BackupProtocolClientError::Err_DiffFromFileDoesNotExist: 
     426                        case BackupProtocolError::Err_DiffFromFileDoesNotExist: 
    427427                                msgs << "DiffFromFileDoesNotExist"; 
    428428                                break; 
    429                         case BackupProtocolClientError::Err_DoesNotExistInDirectory: 
     429                        case BackupProtocolError::Err_DoesNotExistInDirectory: 
    430430                                msgs << "DoesNotExistInDirectory"; 
    431431                                break; 
    432                         case BackupProtocolClientError::Err_PatchConsistencyError: 
     432                        case BackupProtocolError::Err_PatchConsistencyError: 
    433433                                msgs << "PatchConsistencyError"; 
    434434                                break; 
  • box/trunk/bin/bbackupquery/BackupQueries.cpp

    r2875 r2983  
    5050#include "SelfFlushingStream.h" 
    5151#include "Utils.h" 
    52 #include "autogen_BackupProtocolClient.h" 
     52#include "autogen_BackupProtocol.h" 
    5353 
    5454#include "MemLeakFindOn.h" 
     
    359359{ 
    360360        // Generate exclude flags 
    361         int16_t excludeFlags = BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING; 
    362         if(!opts[LIST_OPTION_ALLOWOLD]) excludeFlags |= BackupProtocolClientListDirectory::Flags_OldVersion; 
    363         if(!opts[LIST_OPTION_ALLOWDELETED]) excludeFlags |= BackupProtocolClientListDirectory::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; 
    364364 
    365365        // Do communication 
     
    368368                mrConnection.QueryListDirectory( 
    369369                                DirID, 
    370                                 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
     370                                BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
    371371                                // both files and directories 
    372372                                excludeFlags, 
     
    435435                        *(f++) = ' '; 
    436436                        *(f++) = '\0'; 
    437                         printf(displayflags); 
     437                        printf("%s", displayflags); 
    438438                         
    439439                        if(en_flags != 0) 
     
    545545        // Start from current stack, or root, whichever is required 
    546546        std::vector<std::pair<std::string, int64_t> > stack; 
    547         int64_t dirID = BackupProtocolClientListDirectory::RootDirectory; 
     547        int64_t dirID = BackupProtocolListDirectory::RootDirectory; 
    548548        if(rDirName.size() > 0 && rDirName[0] == '/') 
    549549        { 
     
    561561 
    562562        // Generate exclude flags 
    563         int16_t excludeFlags = BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING; 
    564         if(!AllowOldVersion) excludeFlags |= BackupProtocolClientListDirectory::Flags_OldVersion; 
    565         if(!AllowDeletedDirs) excludeFlags |= BackupProtocolClientListDirectory::Flags_Deleted; 
     563        int16_t excludeFlags = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING; 
     564        if(!AllowOldVersion) excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion; 
     565        if(!AllowDeletedDirs) excludeFlags |= BackupProtocolListDirectory::Flags_Deleted; 
    566566 
    567567        // Read directories 
     
    583583                                         
    584584                                        // New dir ID 
    585                                         dirID = (stack.size() > 0)?(stack[stack.size() - 1].second):BackupProtocolClientListDirectory::RootDirectory; 
     585                                        dirID = (stack.size() > 0)?(stack[stack.size() - 1].second):BackupProtocolListDirectory::RootDirectory; 
    586586                                } 
    587587                                else 
    588588                                {        
    589589                                        // At root anyway 
    590                                         dirID = BackupProtocolClientListDirectory::RootDirectory; 
     590                                        dirID = BackupProtocolListDirectory::RootDirectory; 
    591591                                } 
    592592                        } 
     
    594594                        { 
    595595                                // Not blank element. Read current directory. 
    596                                 std::auto_ptr<BackupProtocolClientSuccess> dirreply(mrConnection.QueryListDirectory( 
     596                                std::auto_ptr<BackupProtocolSuccess> dirreply(mrConnection.QueryListDirectory( 
    597597                                                dirID, 
    598                                                 BackupProtocolClientListDirectory::Flags_Dir,   // just directories 
     598                                                BackupProtocolListDirectory::Flags_Dir, // just directories 
    599599                                                excludeFlags, 
    600600                                                true /* want attributes */)); 
     
    647647        if(mDirStack.size() == 0) 
    648648        { 
    649                 return BackupProtocolClientListDirectory::RootDirectory; 
     649                return BackupProtocolListDirectory::RootDirectory; 
    650650        } 
    651651         
     
    838838        { 
    839839                // Request object 
    840                 std::auto_ptr<BackupProtocolClientSuccess> getobj(mrConnection.QueryGetObject(id)); 
    841                 if(getobj->GetObjectID() != BackupProtocolClientGetObject::NoObject) 
     840                std::auto_ptr<BackupProtocolSuccess> getobj(mrConnection.QueryGetObject(id)); 
     841                if(getobj->GetObjectID() != BackupProtocolGetObject::NoObject) 
    842842                { 
    843843                        // Stream that object out to the file 
     
    10181018        { 
    10191019                // can retrieve anything by ID 
    1020                 flagsExclude = BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING; 
     1020                flagsExclude = BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING; 
    10211021        } 
    10221022        else 
     
    10241024                // only current versions by name 
    10251025                flagsExclude = 
    1026                         BackupProtocolClientListDirectory::Flags_OldVersion | 
    1027                         BackupProtocolClientListDirectory::Flags_Deleted; 
     1026                        BackupProtocolListDirectory::Flags_OldVersion | 
     1027                        BackupProtocolListDirectory::Flags_Deleted; 
    10281028        } 
    10291029 
    10301030 
    10311031        fileId = FindFileID(args[0], opts, &dirId, &localName, 
    1032                 BackupProtocolClientListDirectory::Flags_File, // just files 
     1032                BackupProtocolListDirectory::Flags_File, // just files 
    10331033                flagsExclude, NULL /* don't care about flags found */); 
    10341034 
     
    15201520        mrConnection.QueryListDirectory( 
    15211521                DirID, 
    1522                 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
     1522                BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
    15231523                // get everything 
    1524                 BackupProtocolClientListDirectory::Flags_OldVersion | 
    1525                 BackupProtocolClientListDirectory::Flags_Deleted, 
     1524                BackupProtocolListDirectory::Flags_OldVersion | 
     1525                BackupProtocolListDirectory::Flags_Deleted, 
    15261526                // except for old versions and deleted files 
    15271527                true /* want attributes */); 
     
    18971897        } 
    18981898 
    1899         if(dirID == BackupProtocolClientListDirectory::RootDirectory) 
     1899        if(dirID == BackupProtocolListDirectory::RootDirectory) 
    19001900        { 
    19011901                BOX_ERROR("Cannot restore the root directory -- restore locations individually."); 
     
    20542054 
    20552055        // Request full details from the server 
    2056         std::auto_ptr<BackupProtocolClientAccountUsage> usage(mrConnection.QueryGetAccountUsage()); 
     2056        std::auto_ptr<BackupProtocolAccountUsage> usage(mrConnection.QueryGetAccountUsage()); 
    20572057 
    20582058        // Display each entry in turn 
     
    21302130        fileId = FindFileID(storeDirEncoded, opts, &parentId, &fileName, 
    21312131                /* include files and directories */ 
    2132                 BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, 
     2132                BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 
    21332133                /* include old and deleted files */ 
    2134                 BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, 
     2134                BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 
    21352135                &flagsOut); 
    21362136 
     
    21452145        { 
    21462146                // Undelete object 
    2147                 if(flagsOut & BackupProtocolClientListDirectory::Flags_File) 
     2147                if(flagsOut & BackupProtocolListDirectory::Flags_File) 
    21482148                { 
    21492149                        mrConnection.QueryUndeleteFile(parentId, fileId); 
     
    22102210        fileId = FindFileID(storeDirEncoded, opts, &parentId, &fileName, 
    22112211                /* include files and directories */ 
    2212                 BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, 
     2212                BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 
    22132213                /* exclude old and deleted files */ 
    2214                 BackupProtocolClientListDirectory::Flags_OldVersion | 
    2215                 BackupProtocolClientListDirectory::Flags_Deleted, 
     2214                BackupProtocolListDirectory::Flags_OldVersion | 
     2215                BackupProtocolListDirectory::Flags_Deleted, 
    22162216                &flagsOut); 
    22172217 
     
    22282228        { 
    22292229                // Delete object 
    2230                 if(flagsOut & BackupProtocolClientListDirectory::Flags_File) 
     2230                if(flagsOut & BackupProtocolListDirectory::Flags_File) 
    22312231                { 
    22322232                        mrConnection.QueryDeleteFile(parentId, fn); 
  • box/trunk/bin/bbackupquery/CommandCompletion.cpp

    r2878 r2983  
    3333#include "Configuration.h" 
    3434 
    35 #include "autogen_BackupProtocolClient.h" 
     35#include "autogen_BackupProtocol.h" 
    3636 
    3737#include "MemLeakFindOn.h" 
     
    155155        if (rCommand.mOptions.find(LIST_OPTION_ALLOWOLD) == std::string::npos) 
    156156        { 
    157                 excludeFlags |= BackupProtocolClientListDirectory::Flags_OldVersion; 
     157                excludeFlags |= BackupProtocolListDirectory::Flags_OldVersion; 
    158158        } 
    159159 
    160160        if (rCommand.mOptions.find(LIST_OPTION_ALLOWDELETED) == std::string::npos) 
    161161        { 
    162                 excludeFlags |= BackupProtocolClientListDirectory::Flags_Deleted; 
     162                excludeFlags |= BackupProtocolListDirectory::Flags_Deleted; 
    163163        } 
    164164 
     
    226226 
    227227        bool completeFiles = includeFlags & 
    228                 BackupProtocolClientListDirectory::Flags_File; 
     228                BackupProtocolListDirectory::Flags_File; 
    229229        bool completeDirs = includeFlags & 
    230                 BackupProtocolClientListDirectory::Flags_Dir; 
     230                BackupProtocolListDirectory::Flags_Dir; 
    231231        int16_t listFlags = 0; 
    232232 
    233233        if(completeFiles) 
    234234        { 
    235                 listFlags = BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING; 
     235                listFlags = BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING; 
    236236        } 
    237237        else if(completeDirs) 
    238238        { 
    239                 listFlags = BackupProtocolClientListDirectory::Flags_Dir; 
     239                listFlags = BackupProtocolListDirectory::Flags_Dir; 
    240240        } 
    241241 
     
    259259                { 
    260260                        if(en->IsDir() && 
    261                                 (includeFlags & BackupProtocolClientListDirectory::Flags_Dir) == 0) 
     261                                (includeFlags & BackupProtocolListDirectory::Flags_Dir) == 0) 
    262262                        { 
    263263                                // Was looking for a file, but this is a  
     
    283283        completions = CompleteRemoteFileOrDirectory(rCommand, prefix, 
    284284                rProtocol, rQueries, 
    285                 BackupProtocolClientListDirectory::Flags_Dir); 
     285                BackupProtocolListDirectory::Flags_Dir); 
    286286) 
    287287 
     
    289289        completions = CompleteRemoteFileOrDirectory(rCommand, prefix, 
    290290                rProtocol, rQueries, 
    291                 BackupProtocolClientListDirectory::Flags_File); 
     291                BackupProtocolListDirectory::Flags_File); 
    292292) 
    293293 
     
    325325        rProtocol.QueryListDirectory( 
    326326                listDirId, 
    327                 BackupProtocolClientListDirectory::Flags_File, 
     327                BackupProtocolListDirectory::Flags_File, 
    328328                excludeFlags, false /* no attributes */); 
    329329 
  • box/trunk/bin/bbackupquery/bbackupquery.cpp

    r2869 r2983  
    5151#include "BackupStoreConstants.h" 
    5252#include "BackupStoreException.h" 
    53 #include "autogen_BackupProtocolClient.h" 
     53#include "autogen_BackupProtocol.h" 
    5454#include "BackupQueries.h" 
    5555#include "FdGetLine.h" 
     
    448448        // Check the version of the server 
    449449        { 
    450                 std::auto_ptr<BackupProtocolClientVersion> serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     450                std::auto_ptr<BackupProtocolVersion> serverVersion(connection.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    451451                if(serverVersion->GetVersion() != BACKUP_STORE_SERVER_VERSION) 
    452452                { 
     
    456456        // Login -- if this fails, the Protocol will exception 
    457457        connection.QueryLogin(conf.GetKeyValueUint32("AccountNumber"), 
    458                 (readWrite)?0:(BackupProtocolClientLogin::Flags_ReadOnly)); 
     458                (readWrite)?0:(BackupProtocolLogin::Flags_ReadOnly)); 
    459459 
    460460        // 5. Tell user. 
  • box/trunk/bin/bbstored/BackupStoreDaemon.cpp

    r2982 r2983  
    2121#include "BackupStoreDaemon.h" 
    2222#include "BackupStoreConfigVerify.h" 
    23 #include "autogen_BackupProtocolServer.h" 
     23#include "autogen_BackupProtocol.h" 
    2424#include "RaidFileController.h" 
    2525#include "BackupStoreAccountDatabase.h" 
  • box/trunk/contrib/mac_osx

    • Property svn:ignore set to
      org.boxbackup.*.plist
  • box/trunk/lib/backupclient/BackupClientRestore.cpp

    r2828 r2983  
    2323 
    2424#include "BackupClientRestore.h" 
    25 #include "autogen_BackupProtocolClient.h" 
     25#include "autogen_BackupProtocol.h" 
    2626#include "CommonException.h" 
    2727#include "BackupClientFileAttributes.h" 
     
    444444        rConnection.QueryListDirectory( 
    445445                DirectoryID, 
    446                 Params.RestoreDeleted?(BackupProtocolClientListDirectory::Flags_Deleted):(BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING), 
    447                 BackupProtocolClientListDirectory::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)), 
    448448                true /* want attributes */); 
    449449 
  • box/trunk/lib/backupstore

    • Property svn:ignore
      •  

        old new  
        11Makefile 
         2autogen_* 
  • box/trunk/lib/backupstore/BackupCommands.cpp

    r2945 r2983  
    1313#include <sstream> 
    1414 
    15 #include "autogen_BackupProtocolServer.h" 
     15#include "autogen_BackupProtocol.h" 
    1616#include "autogen_RaidFileException.h" 
    1717#include "BackupConstants.h" 
     
    3232 
    3333#define PROTOCOL_ERROR(code) \ 
    34         std::auto_ptr<ProtocolObject>(new BackupProtocolServerError( \ 
    35                 BackupProtocolServerError::ErrorType, \ 
    36                 BackupProtocolServerError::code)); 
     34        std::auto_ptr<BackupProtocolMessage>(new BackupProtocolError( \ 
     35                BackupProtocolError::ErrorType, \ 
     36                BackupProtocolError::code)); 
    3737 
    3838#define CHECK_PHASE(phase) \ 
     
    5151// 
    5252// Function 
    53 //              Name:    BackupProtocolServerVersion::DoCommand(Protocol &, BackupStoreContext &) 
     53//              Name:    BackupProtocolVersion::DoCommand(Protocol &, BackupStoreContext &) 
    5454//              Purpose: Return the current version, or an error if the requested version isn't allowed 
    5555//              Created: 2003/08/20 
    5656// 
    5757// -------------------------------------------------------------------------- 
    58 std::auto_ptr<ProtocolObject> BackupProtocolServerVersion::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     58std::auto_ptr<BackupProtocolMessage> BackupProtocolVersion::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    5959{ 
    6060        CHECK_PHASE(Phase_Version) 
     
    7070 
    7171        // Return our version 
    72         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerVersion(BACKUP_STORE_SERVER_VERSION)); 
    73 } 
    74  
    75 // -------------------------------------------------------------------------- 
    76 // 
    77 // Function 
    78 //              Name:    BackupProtocolServerLogin::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 &) 
    7979//              Purpose: Return the current version, or an error if the requested version isn't allowed 
    8080//              Created: 2003/08/20 
    8181// 
    8282// -------------------------------------------------------------------------- 
    83 std::auto_ptr<ProtocolObject> BackupProtocolServerLogin::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     83std::auto_ptr<BackupProtocolMessage> BackupProtocolLogin::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    8484{ 
    8585        CHECK_PHASE(Phase_Login) 
     
    139139 
    140140        // Return success 
    141         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerLoginConfirmed(clientStoreMarker, blocksUsed, blocksSoftLimit, blocksHardLimit)); 
    142 } 
    143  
    144 // -------------------------------------------------------------------------- 
    145 // 
    146 // Function 
    147 //              Name:    BackupProtocolServerFinished::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 &) 
    148148//              Purpose: Marks end of conversation (Protocol framework handles this) 
    149149//              Created: 2003/08/20 
    150150// 
    151151// -------------------------------------------------------------------------- 
    152 std::auto_ptr<ProtocolObject> BackupProtocolServerFinished::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     152std::auto_ptr<BackupProtocolMessage> BackupProtocolFinished::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    153153{ 
    154154        BOX_NOTICE("Session finished for Client ID " <<  
     
    159159 
    160160        // can be called in any phase 
    161         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerFinished); 
    162 } 
    163  
    164  
    165 // -------------------------------------------------------------------------- 
    166 // 
    167 // Function 
    168 //              Name:    BackupProtocolServerListDirectory::DoCommand(Protocol &, BackupStoreContext &) 
     161        return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolFinished); 
     162} 
     163 
     164 
     165// -------------------------------------------------------------------------- 
     166// 
     167// Function 
     168//              Name:    BackupProtocolListDirectory::DoCommand(Protocol &, BackupStoreContext &) 
    169169//              Purpose: Command to list a directory 
    170170//              Created: 2003/09/02 
    171171// 
    172172// -------------------------------------------------------------------------- 
    173 std::auto_ptr<ProtocolObject> BackupProtocolServerListDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     173std::auto_ptr<BackupProtocolMessage> BackupProtocolListDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    174174{ 
    175175        CHECK_PHASE(Phase_Commands) 
     
    201201        rProtocol.SendStreamAfterCommand(stream.release()); 
    202202 
    203         return std::auto_ptr<ProtocolObject>( 
    204                 new BackupProtocolServerSuccess(mObjectID)); 
    205 } 
    206  
    207 // -------------------------------------------------------------------------- 
    208 // 
    209 // Function 
    210 //              Name:    BackupProtocolServerStoreFile::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 &) 
    211211//              Purpose: Command to store a file on the server 
    212212//              Created: 2003/09/02 
    213213// 
    214214// -------------------------------------------------------------------------- 
    215 std::auto_ptr<ProtocolObject> BackupProtocolServerStoreFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     215std::auto_ptr<BackupProtocolMessage> BackupProtocolStoreFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    216216{ 
    217217        CHECK_PHASE(Phase_Commands) 
    218218        CHECK_WRITEABLE_SESSION 
    219219 
    220         std::auto_ptr<ProtocolObject> hookResult = 
     220        std::auto_ptr<BackupProtocolMessage> hookResult = 
    221221                rContext.StartCommandHook(*this); 
    222222        if(hookResult.get()) 
     
    264264         
    265265        // 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:    BackupProtocolServerGetObject::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 &) 
    276276//              Purpose: Command to get an arbitary object from the server 
    277277//              Created: 2003/09/03 
    278278// 
    279279// -------------------------------------------------------------------------- 
    280 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     280std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObject::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    281281{ 
    282282        CHECK_PHASE(Phase_Commands) 
     
    285285        if(!rContext.ObjectExists(mObjectID)) 
    286286        { 
    287                 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(NoObject)); 
     287                return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(NoObject)); 
    288288        } 
    289289 
     
    295295 
    296296        // Tell the caller what the file was 
    297         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID)); 
    298 } 
    299  
    300 // -------------------------------------------------------------------------- 
    301 // 
    302 // Function 
    303 //              Name:    BackupProtocolServerGetFile::DoCommand(Protocol &, BackupStoreContext &) 
     297        return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 
     298} 
     299 
     300// -------------------------------------------------------------------------- 
     301// 
     302// Function 
     303//              Name:    BackupProtocolGetFile::DoCommand(Protocol &, BackupStoreContext &) 
    304304//              Purpose: Command to get an file object from the server -- may have to do a bit of  
    305305//                               work to get the object. 
     
    307307// 
    308308// -------------------------------------------------------------------------- 
    309 std::auto_ptr<ProtocolObject> BackupProtocolServerGetFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     309std::auto_ptr<BackupProtocolMessage> BackupProtocolGetFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    310310{ 
    311311        CHECK_PHASE(Phase_Commands) 
     
    461461 
    462462        // 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:    BackupProtocolServerCreateDirectory::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 &) 
    471471//              Purpose: Create directory command 
    472472//              Created: 2003/09/04 
    473473// 
    474474// -------------------------------------------------------------------------- 
    475 std::auto_ptr<ProtocolObject> BackupProtocolServerCreateDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     475std::auto_ptr<BackupProtocolMessage> BackupProtocolCreateDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    476476{ 
    477477        CHECK_PHASE(Phase_Commands) 
     
    501501 
    502502        // 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:    BackupProtocolServerChangeDirAttributes::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 &) 
    512512//              Purpose: Change attributes on directory 
    513513//              Created: 2003/09/06 
    514514// 
    515515// -------------------------------------------------------------------------- 
    516 std::auto_ptr<ProtocolObject> BackupProtocolServerChangeDirAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     516std::auto_ptr<BackupProtocolMessage> BackupProtocolChangeDirAttributes::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    517517{ 
    518518        CHECK_PHASE(Phase_Commands) 
     
    530530 
    531531        // 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:    BackupProtocolServerSetReplacementFileAttributes::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 &) 
    540540//              Purpose: Change attributes on directory 
    541541//              Created: 2003/09/06 
    542542// 
    543543// -------------------------------------------------------------------------- 
    544 std::auto_ptr<ProtocolObject> BackupProtocolServerSetReplacementFileAttributes::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     544std::auto_ptr<BackupProtocolMessage> BackupProtocolSetReplacementFileAttributes::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    545545{ 
    546546        CHECK_PHASE(Phase_Commands) 
     
    563563 
    564564        // 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:    BackupProtocolServerDeleteFile::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 &) 
    574574//              Purpose: Delete a file 
    575575//              Created: 2003/10/21 
    576576// 
    577577// -------------------------------------------------------------------------- 
    578 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteFile::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     578std::auto_ptr<BackupProtocolMessage> BackupProtocolDeleteFile::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    579579{ 
    580580        CHECK_PHASE(Phase_Commands) 
     
    586586 
    587587        // 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:    BackupProtocolServerUndeleteFile::DoCommand( 
    596 //                       BackupProtocolServer &, BackupStoreContext &) 
     588        return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(objectID)); 
     589} 
     590 
     591 
     592// -------------------------------------------------------------------------- 
     593// 
     594// Function 
     595//              Name:    BackupProtocolUndeleteFile::DoCommand( 
     596//                       BackupProtocolBase &, BackupStoreContext &) 
    597597//              Purpose: Undelete a file 
    598598//              Created: 2008-09-12 
    599599// 
    600600// -------------------------------------------------------------------------- 
    601 std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteFile::DoCommand( 
    602         BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     601std::auto_ptr<BackupProtocolMessage> BackupProtocolUndeleteFile::DoCommand( 
     602        BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    603603{ 
    604604        CHECK_PHASE(Phase_Commands) 
     
    609609 
    610610        // return the object ID or zero for not found 
    611         return std::auto_ptr<ProtocolObject>( 
    612                 new BackupProtocolServerSuccess(result ? mObjectID : 0)); 
    613 } 
    614  
    615  
    616 // -------------------------------------------------------------------------- 
    617 // 
    618 // Function 
    619 //              Name:    BackupProtocolServerDeleteDirectory::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 &) 
    620620//              Purpose: Delete a directory 
    621621//              Created: 2003/10/21 
    622622// 
    623623// -------------------------------------------------------------------------- 
    624 std::auto_ptr<ProtocolObject> BackupProtocolServerDeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     624std::auto_ptr<BackupProtocolMessage> BackupProtocolDeleteDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    625625{ 
    626626        CHECK_PHASE(Phase_Commands) 
     
    649649 
    650650        // return the object ID 
    651         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID)); 
    652 } 
    653  
    654  
    655 // -------------------------------------------------------------------------- 
    656 // 
    657 // Function 
    658 //              Name:    BackupProtocolServerUndeleteDirectory::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 &) 
    659659//              Purpose: Undelete a directory 
    660660//              Created: 23/11/03 
    661661// 
    662662// -------------------------------------------------------------------------- 
    663 std::auto_ptr<ProtocolObject> BackupProtocolServerUndeleteDirectory::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     663std::auto_ptr<BackupProtocolMessage> BackupProtocolUndeleteDirectory::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    664664{ 
    665665        CHECK_PHASE(Phase_Commands) 
     
    676676 
    677677        // return the object ID 
    678         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID)); 
    679 } 
    680  
    681 // -------------------------------------------------------------------------- 
    682 // 
    683 // Function 
    684 //              Name:    BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
     678        return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(mObjectID)); 
     679} 
     680 
     681// -------------------------------------------------------------------------- 
     682// 
     683// Function 
     684//              Name:    BackupProtocolSetClientStoreMarker::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 
    685685//              Purpose: Command to set the client's store marker 
    686686//              Created: 2003/10/29 
    687687// 
    688688// -------------------------------------------------------------------------- 
    689 std::auto_ptr<ProtocolObject> BackupProtocolServerSetClientStoreMarker::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     689std::auto_ptr<BackupProtocolMessage> BackupProtocolSetClientStoreMarker::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    690690{ 
    691691        CHECK_PHASE(Phase_Commands) 
     
    696696 
    697697        // return store marker set 
    698         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mClientStoreMarker)); 
    699 } 
    700  
    701  
    702 // -------------------------------------------------------------------------- 
    703 // 
    704 // Function 
    705 //              Name:    BackupProtocolServerMoveObject::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 &) 
    706706//              Purpose: Command to move an object from one directory to another 
    707707//              Created: 2003/11/12 
    708708// 
    709709// -------------------------------------------------------------------------- 
    710 std::auto_ptr<ProtocolObject> BackupProtocolServerMoveObject::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     710std::auto_ptr<BackupProtocolMessage> BackupProtocolMoveObject::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    711711{ 
    712712        CHECK_PHASE(Phase_Commands) 
     
    737737 
    738738        // Return the object ID 
    739         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID)); 
    740 } 
    741  
    742  
    743 // -------------------------------------------------------------------------- 
    744 // 
    745 // Function 
    746 //              Name:    BackupProtocolServerGetObjectName::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 &) 
    747747//              Purpose: Command to find the name of an object 
    748748//              Created: 12/11/03 
    749749// 
    750750// -------------------------------------------------------------------------- 
    751 std::auto_ptr<ProtocolObject> BackupProtocolServerGetObjectName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     751std::auto_ptr<BackupProtocolMessage> BackupProtocolGetObjectName::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    752752{ 
    753753        CHECK_PHASE(Phase_Commands) 
     
    772772                if(!rContext.ObjectExists(dirID, BackupStoreContext::ObjectExists_Directory)) 
    773773                { 
    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)); 
    775775                } 
    776776 
     
    787787                        { 
    788788                                // 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)); 
    790790                        } 
    791791                         
     
    827827 
    828828        // Make reply 
    829         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerObjectName(numNameElements, modTime, attrModHash, objectFlags)); 
    830 } 
    831  
    832  
    833  
    834 // -------------------------------------------------------------------------- 
    835 // 
    836 // Function 
    837 //              Name:    BackupProtocolServerGetBlockIndexByID::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 &) 
    838838//              Purpose: Get the block index from a file, by ID 
    839839//              Created: 19/1/04 
    840840// 
    841841// -------------------------------------------------------------------------- 
    842 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByID::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     842std::auto_ptr<BackupProtocolMessage> BackupProtocolGetBlockIndexByID::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    843843{ 
    844844        CHECK_PHASE(Phase_Commands) 
     
    854854 
    855855        // Return the object ID 
    856         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(mObjectID)); 
    857 } 
    858  
    859  
    860 // -------------------------------------------------------------------------- 
    861 // 
    862 // Function 
    863 //              Name:    BackupProtocolServerGetBlockIndexByName::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 &) 
    864864//              Purpose: Get the block index from a file, by name within a directory 
    865865//              Created: 19/1/04 
    866866// 
    867867// -------------------------------------------------------------------------- 
    868 std::auto_ptr<ProtocolObject> BackupProtocolServerGetBlockIndexByName::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     868std::auto_ptr<BackupProtocolMessage> BackupProtocolGetBlockIndexByName::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    869869{ 
    870870        CHECK_PHASE(Phase_Commands) 
     
    893893        { 
    894894                // No... return a zero object ID 
    895                 return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(0)); 
     895                return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolSuccess(0)); 
    896896        } 
    897897 
     
    906906 
    907907        // Return the object ID 
    908         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerSuccess(objectID)); 
    909 } 
    910  
    911  
    912 // -------------------------------------------------------------------------- 
    913 // 
    914 // Function 
    915 //              Name:    BackupProtocolServerGetAccountUsage::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 &) 
    916916//              Purpose: Return the amount of disc space used 
    917917//              Created: 19/4/04 
    918918// 
    919919// -------------------------------------------------------------------------- 
    920 std::auto_ptr<ProtocolObject> BackupProtocolServerGetAccountUsage::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     920std::auto_ptr<BackupProtocolMessage> BackupProtocolGetAccountUsage::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    921921{ 
    922922        CHECK_PHASE(Phase_Commands) 
     
    930930         
    931931        // Return info 
    932         return std::auto_ptr<ProtocolObject>(new BackupProtocolServerAccountUsage( 
     932        return std::auto_ptr<BackupProtocolMessage>(new BackupProtocolAccountUsage( 
    933933                rinfo.GetBlocksUsed(), 
    934934                rinfo.GetBlocksInOldFiles(), 
     
    944944// 
    945945// Function 
    946 //              Name:    BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &, BackupStoreContext &) 
     946//              Name:    BackupProtocolGetIsAlive::DoCommand(BackupProtocolReplyable &, BackupStoreContext &) 
    947947//              Purpose: Return the amount of disc space used 
    948948//              Created: 19/4/04 
    949949// 
    950950// -------------------------------------------------------------------------- 
    951 std::auto_ptr<ProtocolObject> BackupProtocolServerGetIsAlive::DoCommand(BackupProtocolServer &rProtocol, BackupStoreContext &rContext) 
     951std::auto_ptr<BackupProtocolMessage> BackupProtocolGetIsAlive::DoCommand(BackupProtocolReplyable &rProtocol, BackupStoreContext &rContext) const 
    952952{ 
    953953        CHECK_PHASE(Phase_Commands) 
     
    956956        // NOOP 
    957957        // 
    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  
    2828#include "StoreStructure.h" 
    2929 
    30 class BackupStoreDaemon; 
    31  
    3230#include "MemLeakFindOn.h" 
     31 
    3332 
    3433// Maximum number of directories to keep in the cache 
  • box/trunk/lib/backupstore/BackupStoreContext.h

    r2945 r2983  
    1717#include "BackupStoreRefCountDatabase.h" 
    1818#include "NamedLock.h" 
    19 #include "ProtocolObject.h" 
     19#include "Message.h" 
    2020#include "Utils.h" 
    2121 
    2222class BackupStoreDirectory; 
    2323class BackupStoreFilename; 
    24 class BackupStoreDaemon; 
    2524class BackupStoreInfo; 
    2625class IOStream; 
    27 class BackupProtocolObject; 
     26class BackupProtocolMessage; 
    2827class StreamableMemBlock; 
    2928 
     
    162161        { 
    163162                public: 
    164                 virtual std::auto_ptr<ProtocolObject> StartCommand(BackupProtocolObject& 
    165                         rCommand) = 0; 
     163                virtual std::auto_ptr<BackupProtocolMessage> 
     164                        StartCommand(const BackupProtocolMessage& rCommand) = 0; 
    166165                virtual ~TestHook() { } 
    167166        }; 
     
    170169                mpTestHook = &rTestHook; 
    171170        } 
    172         std::auto_ptr<ProtocolObject> StartCommandHook(BackupProtocolObject& rCommand) 
     171        std::auto_ptr<BackupProtocolMessage> 
     172                StartCommandHook(const BackupProtocolMessage& rCommand) 
    173173        { 
    174174                if(mpTestHook) 
     
    176176                        return mpTestHook->StartCommand(rCommand); 
    177177                } 
    178                 return std::auto_ptr<ProtocolObject>(); 
     178                return std::auto_ptr<BackupProtocolMessage>(); 
    179179        } 
    180180 
  • box/trunk/lib/backupstore/BackupStoreFile.h

    r2945 r2983  
    1919#include "IOStream.h" 
    2020#include "ReadLoggingStream.h" 
    21 #include "RunStatusProvider.h" 
    2221 
    2322typedef struct  
     
    2726        int64_t mTotalFileStreamSize; 
    2827} BackupStoreFileStats; 
     28 
     29class RunStatusProvider; 
    2930 
    3031// Uncomment to disable backwards compatibility 
  • box/trunk/lib/backupstore/Makefile.extra

    r2945 r2983  
    1  
    21MAKEPROTOCOL = ../../lib/server/makeprotocol.pl 
    32 
    4 GEN_CMD_CLI = $(MAKEPROTOCOL) Client backupprotocol.txt 
    5 GEN_CMD_SRV = $(MAKEPROTOCOL) Server backupprotocol.txt 
     3GEN_CMD = $(MAKEPROTOCOL) backupprotocol.txt 
    64 
    75# AUTOGEN SEEDING 
    8 autogen_BackupProtocolClient.cpp autogen_BackupProtocolClient.h:        $(MAKEPROTOCOL) backupprotocol.txt 
    9         $(_PERL) $(GEN_CMD_CLI) 
     6autogen_BackupProtocol.cpp autogen_BackupProtocol.h:    $(MAKEPROTOCOL) backupprotocol.txt 
     7        $(_PERL) $(GEN_CMD) 
    108 
    11 # AUTOGEN SEEDING 
    12 autogen_BackupProtocolServer.cpp autogen_BackupProtocolServer.h:        $(MAKEPROTOCOL) backupprotocol.txt 
    13         $(_PERL) $(GEN_CMD_SRV) 
    149 
    1510MAKEEXCEPTION = ../../lib/common/makeexception.pl 
  • box/trunk/lib/backupstore/backupprotocol.txt

    r2945 r2983  
    77ServerContextClass      BackupStoreContext      BackupStoreContext.h 
    88 
    9 ClientType              Filename        BackupStoreFilenameClear        BackupStoreFilenameClear.h 
    10 ServerType              Filename        BackupStoreFilename                     BackupStoreFilename.h 
     9AddType         Filename        BackupStoreFilenameClear        BackupStoreFilenameClear.h 
    1110 
    1211ImplementLog    Server  syslog 
     
    1413ImplementLog    Client  file 
    1514 
    16 LogTypeToText   Client  Filename        \"%s\"  VAR.GetClearFilename().c_str() 
     15LogTypeToText   Filename        "%s"    VAR.GetClearFilenameIfPossible("OPAQUE").c_str() 
    1716 
    1817BEGIN_OBJECTS 
  • box/trunk/lib/server/Message.cpp

    r217 r2983  
    22// 
    33// File 
    4 //              Name:    ProtocolObject.h 
     4//              Name:    Message.h 
    55//              Purpose: Protocol object base class 
    66//              Created: 2003/08/19 
     
    99 
    1010#include "Box.h" 
    11 #include "ProtocolObject.h" 
     11#include "Message.h" 
    1212#include "CommonException.h" 
    1313 
     
    1717// 
    1818// Function 
    19 //              Name:    ProtocolObject::ProtocolObject() 
     19//              Name:    Message::Message() 
    2020//              Purpose: Default constructor 
    2121//              Created: 2003/08/19 
    2222// 
    2323// -------------------------------------------------------------------------- 
    24 ProtocolObject::ProtocolObject() 
     24Message::Message() 
    2525{ 
    2626} 
     
    2929// 
    3030// Function 
    31 //              Name:    ProtocolObject::ProtocolObject() 
     31//              Name:    Message::Message() 
    3232//              Purpose: Destructor 
    3333//              Created: 2003/08/19 
    3434// 
    3535// -------------------------------------------------------------------------- 
    36 ProtocolObject::~ProtocolObject() 
     36Message::~Message() 
    3737{ 
    3838} 
     
    4141// 
    4242// Function 
    43 //              Name:    ProtocolObject::ProtocolObject() 
     43//              Name:    Message::Message() 
    4444//              Purpose: Copy constructor 
    4545//              Created: 2003/08/19 
    4646// 
    4747// -------------------------------------------------------------------------- 
    48 ProtocolObject::ProtocolObject(const ProtocolObject &rToCopy) 
     48Message::Message(const Message &rToCopy) 
    4949{ 
    5050} 
     
    5353// 
    5454// Function 
    55 //              Name:    ProtocolObject::IsError(int &, int &) 
     55//              Name:    Message::IsError(int &, int &) 
    5656//              Purpose: Does this represent an error, and if so, what is the type and subtype? 
    5757//              Created: 2003/08/19 
    5858// 
    5959// -------------------------------------------------------------------------- 
    60 bool ProtocolObject::IsError(int &rTypeOut, int &rSubTypeOut) const 
     60bool Message::IsError(int &rTypeOut, int &rSubTypeOut) const 
    6161{ 
    6262        return false; 
     
    6666// 
    6767// Function 
    68 //              Name:    ProtocolObject::IsConversationEnd() 
     68//              Name:    Message::IsConversationEnd() 
    6969//              Purpose: Does this command end the conversation? 
    7070//              Created: 2003/08/19 
    7171// 
    7272// -------------------------------------------------------------------------- 
    73 bool ProtocolObject::IsConversationEnd() const 
     73bool Message::IsConversationEnd() const 
    7474{ 
    7575        return false; 
     
    8080// 
    8181// Function 
    82 //              Name:    ProtocolObject::GetType() 
     82//              Name:    Message::GetType() 
    8383//              Purpose: Return type of the object 
    8484//              Created: 2003/08/19 
    8585// 
    8686// -------------------------------------------------------------------------- 
    87 int ProtocolObject::GetType() const 
     87int Message::GetType() const 
    8888{ 
    8989        // This isn't implemented in the base class! 
     
    9595// 
    9696// Function 
    97 //              Name:    ProtocolObject::SetPropertiesFromStreamData(Protocol &) 
     97//              Name:    Message::SetPropertiesFromStreamData(Protocol &) 
    9898//              Purpose: Set the properties of the object from the stream data ready in the Protocol object 
    9999//              Created: 2003/08/19 
    100100// 
    101101// -------------------------------------------------------------------------- 
    102 void ProtocolObject::SetPropertiesFromStreamData(Protocol &rProtocol) 
     102void Message::SetPropertiesFromStreamData(Protocol &rProtocol) 
    103103{ 
    104104        // This isn't implemented in the base class! 
     
    111111// 
    112112// Function 
    113 //              Name:    ProtocolObject::WritePropertiesToStreamData(Protocol &) 
     113//              Name:    Message::WritePropertiesToStreamData(Protocol &) 
    114114//              Purpose: Write the properties of the object into the stream data in the Protocol object 
    115115//              Created: 2003/08/19 
    116116// 
    117117// -------------------------------------------------------------------------- 
    118 void ProtocolObject::WritePropertiesToStreamData(Protocol &rProtocol) const 
     118void Message::WritePropertiesToStreamData(Protocol &rProtocol) const 
    119119{ 
    120120        // This isn't implemented in the base class! 
  • box/trunk/lib/server/Message.h

    r217 r2983  
    22// 
    33// File 
    4 //              Name:    ProtocolObject.h 
     4//              Name:    Message.h 
    55//              Purpose: Protocol object base class 
    66//              Created: 2003/08/19 
     
    1111#define PROTOCOLOBJECT__H 
    1212 
     13#include <memory> 
     14 
    1315class Protocol; 
     16class ProtocolContext; 
    1417 
    1518// -------------------------------------------------------------------------- 
    1619// 
    1720// Class 
    18 //              Name:    ProtocolObject 
     21//              Name:    Message 
    1922//              Purpose: Basic object representation of objects to pass through a Protocol session 
    2023//              Created: 2003/08/19 
    2124// 
    2225// -------------------------------------------------------------------------- 
    23 class ProtocolObject 
     26class Message 
    2427{ 
    2528public: 
    26         ProtocolObject(); 
    27         virtual ~ProtocolObject(); 
    28         ProtocolObject(const ProtocolObject &rToCopy); 
     29        Message(); 
     30        virtual ~Message(); 
     31        Message(const Message &rToCopy); 
    2932 
    3033        // Info about this object 
     
    3639        virtual void SetPropertiesFromStreamData(Protocol &rProtocol); 
    3740        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 { } 
    3844}; 
     45 
     46/* 
     47class Reply; 
     48 
     49class Request : public Message 
     50{ 
     51public: 
     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 
     59class Reply : public Message 
     60{ 
     61public: 
     62        Reply() { } 
     63        virtual ~Reply() { } 
     64        Reply(const Reply &rToCopy) { } 
     65}; 
     66*/ 
    3967 
    4068#endif // PROTOCOLOBJECT__H 
  • box/trunk/lib/server/Protocol.cpp

    r2415 r2983  
    1212#include <sys/types.h> 
    1313 
    14 #include <stdlib.h> 
    15 #include <string.h> 
     14#include <cstdlib> 
     15#include <cstring> 
     16#include <cstdio> 
    1617 
    1718#include <new> 
     
    4546// -------------------------------------------------------------------------- 
    4647Protocol::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)   
    5859{ 
    5960        BOX_TRACE("Send block allocation size is " <<  
     
    7778                mpBuffer = 0; 
    7879        } 
    79 } 
    80  
    81  
    82 // -------------------------------------------------------------------------- 
    83 // 
    84 // Function 
    85 //              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/19 
    88 // 
    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 args 
    99         rTypeOut = mLastErrorType; 
    100         rSubTypeOut = mLastErrorSubType; 
    101          
    102         // and unset them 
    103         mLastErrorType = NoError; 
    104         mLastErrorSubType = NoError; 
    105          
    106         return true; 
    10780} 
    10881 
     
    128101        ::memset(&hsSend, 0, sizeof(hsSend)); 
    129102        // Copy in ident string 
    130         ::strncpy(hsSend.mIdent, GetIdentString(), sizeof(hsSend.mIdent)); 
     103        ::strncpy(hsSend.mIdent, GetProtocolIdentString(), sizeof(hsSend.mIdent)); 
    131104         
    132105        // Send it 
     
    201174// 
    202175// -------------------------------------------------------------------------- 
    203 std::auto_ptr<ProtocolObject> Protocol::Receive() 
     176std::auto_ptr<Message> Protocol::ReceiveInternal() 
    204177{ 
    205178        // Get object header 
     
    221194 
    222195        // Create a blank object 
    223         std::auto_ptr<ProtocolObject> obj(MakeProtocolObject(ntohl(objHeader.mObjType))); 
     196        std::auto_ptr<Message> obj(MakeMessage(ntohl(objHeader.mObjType))); 
    224197 
    225198        // Make sure memory is allocated to read it into 
     
    273246// 
    274247// -------------------------------------------------------------------------- 
    275 void Protocol::Send(const ProtocolObject &rObject) 
     248void Protocol::SendInternal(const Message &rObject) 
    276249{ 
    277250        // Check usage 
     
    855828void Protocol::InformStreamReceiving(u_int32_t Size) 
    856829{ 
    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        } 
    858850} 
    859851 
     
    868860void Protocol::InformStreamSending(u_int32_t Size) 
    869861{ 
    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        } 
    871882} 
    872883 
  • box/trunk/lib/server/Protocol.h

    r217 r2983  
    1313#include <sys/types.h> 
    1414 
    15 class IOStream; 
    16 #include "ProtocolObject.h" 
    1715#include <memory> 
    1816#include <vector> 
    1917#include <string> 
     18 
     19#include "Message.h" 
     20 
     21class IOStream; 
    2022 
    2123// default timeout is 15 minutes 
     
    4143        Protocol(const Protocol &rToCopy); 
    4244 
     45protected: 
     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 
    4351public: 
    4452        void Handshake(); 
    45         std::auto_ptr<ProtocolObject> Receive(); 
    46         void Send(const ProtocolObject &rObject); 
    47          
    4853        std::auto_ptr<IOStream> ReceiveStream(); 
    4954        void SendStream(IOStream &rStream); 
     
    5560        }; 
    5661 
    57         bool GetLastError(int &rTypeOut, int &rSubTypeOut); 
    58  
    5962        // -------------------------------------------------------------------------- 
    6063        // 
     
    8891        void SetMaxObjectSize(unsigned int NewMaxObjSize) {mMaxObjectSize = NewMaxObjSize;} 
    8992 
    90         // For ProtocolObject derived classes 
     93        // For Message derived classes 
    9194        void Read(void *Buffer, int Size); 
    9295        void Read(std::string &rOut, int Size); 
     
    169172                ProtocolStream_SizeUncertain = 0xffffffff 
    170173        }; 
    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 
     179protected: 
     180        virtual std::auto_ptr<Message> MakeMessage(int ObjType) = 0; 
     181        virtual const char *GetProtocolIdentString() = 0; 
     182         
    176183        void CheckAndReadHdr(void *hdr);        // don't use type here to avoid dependency 
    177184         
     
    184191        int SendStreamSendBlock(uint8_t *Block, int BytesInBlock); 
    185192 
    186 private: 
    187193        IOStream &mrStream; 
    188194        bool mHandshakeDone; 
     
    194200        int mWriteOffset; 
    195201        int mValidDataSize; 
    196         int mLastErrorType; 
    197         int mLastErrorSubType; 
     202        bool mLogToSysLog; 
     203        FILE *mLogToFile; 
    198204}; 
    199205 
     206class ProtocolContext 
     207{ 
     208}; 
     209 
    200210#endif // PROTOCOL__H 
    201211 
  • box/trunk/lib/server/makeprotocol.pl.in

    r2371 r2983  
    3131); 
    3232 
    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 } 
     33if (@ARGV != 1) 
     34{ 
     35        die "Usage: $0 <protocol-txt-file>\n"; 
     36} 
     37 
     38my ($file) = @ARGV; 
    4139 
    4240open IN, $file or die "Can't open input file $file\n"; 
    4341 
    44 print "Making $type protocol classes from $file...\n"; 
     42print "Making protocol classes from $file...\n"; 
    4543 
    4644my @extra_header_files; 
    47  
    48 my $implement_syslog = 0; 
    49 my $implement_filelog = 0; 
    5045 
    5146# read attributes 
     
    6055        my ($k,$v) = split /\s+/,$l,2; 
    6156         
    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); 
    6960        } 
    7061        elsif($k eq 'ImplementLog') 
    7162        { 
    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 
    8964        } 
    9065        elsif($k eq 'LogTypeToText') 
    9166        { 
    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] 
    9769        } 
    9870        else 
     
    170142 
    171143# open files 
    172 my $h_filename = 'autogen_'.$protocol_name.'Protocol'.$type.'.h'; 
    173 open CPP,'>autogen_'.$protocol_name.'Protocol'.$type.'.cpp'; 
     144my $h_filename = 'autogen_'.$protocol_name.'Protocol.h'; 
     145open CPP,'>autogen_'.$protocol_name.'Protocol.cpp'; 
    174146open H,">$h_filename"; 
     147 
     148my $guardname = uc 'AUTOGEN_'.$protocol_name.'Protocol_H'; 
    175149 
    176150print CPP <<__E; 
     
    184158#include "$h_filename" 
    185159#include "IOStream.h" 
    186  
    187 __E 
    188  
    189 if($implement_syslog) 
    190 { 
    191         print H <<EOF; 
     160__E 
     161 
     162print H <<__E; 
     163// Auto-generated file -- do not edit 
     164 
     165#ifndef $guardname 
     166#define $guardname 
     167 
     168#include <cstdio> 
     169#include <list> 
     170 
    192171#ifndef WIN32 
    193172#include <syslog.h> 
    194173#endif 
    195 EOF 
    196 } 
    197  
    198  
    199 my $guardname = uc 'AUTOGEN_'.$protocol_name.'Protocol'.$type.'_H'; 
    200 print H <<__E; 
    201  
    202 // Auto-generated file -- do not edit 
    203  
    204 #ifndef $guardname 
    205 #define $guardname 
    206174 
    207175#include "Protocol.h" 
    208 #include "ProtocolObject.h" 
     176#include "Message.h" 
    209177#include "ServerException.h" 
    210178 
    211179class IOStream; 
    212180 
    213 __E 
    214  
    215 if($implement_filelog) 
    216 { 
    217         print H qq~#include <stdio.h>\n~; 
    218 } 
     181 
     182__E 
    219183 
    220184# extra headers 
    221185for(@extra_header_files) 
    222186{ 
    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 
     190print H <<__E; 
     191 
     192// need utils file for the server 
     193#include "Utils.h" 
     194 
     195__E 
     196 
     197my $message_base_class = "${protocol_name}ProtocolMessage"; 
    235198my $objects_extra_h = ''; 
    236199my $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 
     202print H "class $context_class;\n\n"; 
     203print CPP <<__E; 
     204#include "$context_class_inc" 
     205#include "MemLeakFindOn.h" 
     206__E 
     207 
     208my $request_base_class = "${protocol_name}ProtocolRequest"; 
     209my $reply_base_class   = "${protocol_name}ProtocolReply"; 
     210# the abstract protocol interface 
     211my $protocol_base_class = $protocol_name."ProtocolBase"; 
     212my $replyable_base_class = $protocol_name."ProtocolReplyable"; 
     213 
     214print H <<__E; 
     215class $protocol_base_class; 
     216class $replyable_base_class; 
     217class $reply_base_class; 
     218 
     219class $message_base_class : public Message 
     220{ 
     221public: 
     222        virtual std::auto_ptr<$message_base_class> DoCommand($replyable_base_class &rProtocol, 
     223                $context_class &rContext) const; 
     224}; 
     225 
     226class $reply_base_class 
     227{ 
     228}; 
     229 
     230class $request_base_class 
     231{ 
     232}; 
     233 
     234__E 
     235 
     236print CPP <<__E; 
     237std::auto_ptr<$message_base_class> $message_base_class\::DoCommand($replyable_base_class &rProtocol, 
     238        $context_class &rContext) const 
    251239{ 
    252240        THROW_EXCEPTION(ConnectionException, Conn_Protocol_TriedToExecuteReplyCommand) 
    253241} 
    254242__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 
     244my %cmd_class; 
     245 
     246# output the classes 
     247foreach 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         
    280265        print H <<__E; 
    281 class ${protocol_name}ProtocolServer; 
    282          
    283 class $derive_objects_from : public ProtocolObject 
     266class $cmd_class : $cmd_base_class 
    284267{ 
    285268public: 
    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(); 
    323272        int GetType() const; 
    324273        enum 
     
    327276        }; 
    328277__E 
     278 
    329279        # constants 
    330280        if(exists $cmd_constants{$cmd}) 
     
    334284                print H "\n\t};\n"; 
    335285        } 
     286         
    336287        # flags 
    337288        if(obj_is_type($cmd,'EndsConversation')) 
     
    339290                print H "\tbool IsConversationEnd() const;\n"; 
    340291        } 
     292         
    341293        if(obj_is_type($cmd,'IsError')) 
    342294        { 
     
    344296                print H "\tstd::string GetMessage() const;\n"; 
    345297        } 
    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 
    349305        } 
    350306 
    351307        # 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]); 
    358314                 
    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; 
    360323                for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 
    361324                { 
    362325                        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"; 
    402343         
    403344        # write member variables and setup for cpp file 
     
    433374        $param_con_vars = "\n\t: ".$param_con_vars if $param_con_vars ne ''; 
    434375 
    435         my $class = "$classname_base$cmd".'::'; 
    436376        print CPP <<__E; 
    437 $class$classname_base$cmd()$def_con_vars 
    438 { 
    439 } 
    440 $class$classname_base$cmd(const $classname_base$cmd &rToCopy)$copy_con_vars 
    441 { 
    442 } 
    443 $class~$classname_base$cmd() 
    444 { 
    445 } 
    446 int ${class}GetType() const 
     377$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} 
     386int $cmd_class\::GetType() const 
    447387{ 
    448388        return $cmd_id{$cmd}; 
    449389} 
    450390__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 
    490426        if(obj_is_type($cmd,'EndsConversation')) 
    491427        { 
    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         
    494431        if(obj_is_type($cmd,'IsError')) 
    495432        { 
     
    497434                my ($mem_type,$mem_subtype) = split /,/,obj_get_type_params($cmd,'IsError'); 
    498435                print CPP <<__E; 
    499 bool ${class}IsError(int &rTypeOut, int &rSubTypeOut) const 
     436bool $cmd_class\::IsError(int &rTypeOut, int &rSubTypeOut) const 
    500437{ 
    501438        rTypeOut = m$mem_type; 
     
    503440        return true; 
    504441} 
    505 std::string ${class}GetMessage() const 
     442std::string $cmd_class\::GetMessage() const 
    506443{ 
    507444        switch(m$mem_subtype) 
     
    527464        } 
    528465 
    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; 
     468void $cmd_class\::LogSysLog(const char *Action) const 
    534469{ 
    535470        BOX_TRACE($log); 
    536471} 
    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 
     472void $cmd_class\::LogFile(const char *Action, FILE *File) const 
    544473{ 
    545474        std::ostringstream oss; 
     
    549478} 
    550479__E 
    551         } 
    552 } 
    553  
    554 # finally, the protocol object itself 
     480} 
     481 
     482my $error_class = $protocol_name."ProtocolError"; 
     483 
     484# the abstract protocol interface 
    555485print H <<__E; 
    556 class $classname_base : public Protocol 
     486class $protocol_base_class 
    557487{ 
    558488public: 
    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 
     494protected: 
     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 
     503private: 
     504        $protocol_base_class(const $protocol_base_class &rToCopy); /* do not call */ 
     505        int mLastErrorType; 
     506        int mLastErrorSubType; 
     507}; 
     508 
     509class $replyable_base_class : public virtual $protocol_base_class 
     510{ 
     511public: 
     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         
     524protected: 
     525        std::list<IOStream*> mStreamsToSend; 
     526        void DeleteStreamsToSend(); 
     527 
     528private: 
     529        $replyable_base_class(const $replyable_base_class &rToCopy); /* do not call */ 
     530}; 
     531 
     532__E 
     533 
     534print 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 
     543const 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 
     554void $replyable_base_class\::SendStreamAfterCommand(IOStream *pStream) 
     555{ 
     556        ASSERT(pStream != NULL); 
     557        mStreamsToSend.push_back(pStream); 
     558} 
     559 
     560void $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 
     569void $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// -------------------------------------------------------------------------- 
     609bool $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 
     632my $callable_base_class = $protocol_name."ProtocolCallable"; 
     633print H <<__E; 
     634class $callable_base_class : public virtual $protocol_base_class 
     635{ 
     636public: 
     637        virtual std::auto_ptr<IOStream> ReceiveStream() = 0; 
     638        virtual int GetTimeout() = 0; 
     639__E 
     640 
     641# add plain object taking query functions 
     642my $with_params; 
     643for 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 
     679print H <<__E; 
     680 
     681$with_params 
     682}; 
     683__E 
     684 
     685# standard remote protocol objects 
     686foreach 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; 
     711class $server_or_client_class : $base_classes_str 
     712{ 
     713public: 
     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; 
     764private: 
     765        $context_class &mrContext; 
     766__E 
     767        } 
     768         
     769        print H <<__E; 
     770 
     771protected: 
     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 
     782public: 
     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 
     803public: 
     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         
     849private: 
     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; 
     883std::auto_ptr<Message> $server_or_client_class\::MakeMessage(int ObjType) 
     884{ 
     885        switch(ObjType) 
     886        { 
     887__E 
     888 
     889        # do objects within this 
    584890        for my $cmd (@cmd_list) 
    585891        { 
    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 
    678899        print CPP <<__E; 
    679         case $cmd_id{$cmd}: 
    680                 return std::auto_ptr<ProtocolObject>(new $classname_base$cmd); 
    681                 break; 
    682 __E 
    683 } 
    684  
    685 print CPP <<__E; 
    686900        default: 
    687901                THROW_EXCEPTION(ConnectionException, Conn_Protocol_UnknownCommandRecieved) 
     
    689903} 
    690904__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) 
    699907        { 
    700908                print CPP <<__E; 
    701         if(mLogToSysLog) 
     909std::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()) 
    702915        { 
    703916                preply->LogSysLog("Receive"); 
    704917        } 
    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 
     927void $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) 
    708947        { 
    709948                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) 
     949void $server_or_client_class\::DoServer($context_class &rContext) 
    753950{ 
    754951        // Handshake with client 
     
    760957        { 
    761958                // Get an object from the conversation 
    762                 std::auto_ptr<${derive_objects_from}> pobj(Receive()); 
     959                std::auto_ptr<$message_base_class> pobj = Receive(); 
    763960 
    764961                // 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); 
    766963                 
    767964                // Send the reply 
    768                 Send(*(preply.get())); 
     965                Send(*preply); 
    769966 
    770967                // 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                 
    776975                // Delete these streams 
    777976                DeleteStreamsToSend(); 
     
    785984} 
    786985 
    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')) 
    892995                        { 
    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; 
    8951011        // Send stream after the command 
    8961012        SendStream(rStream); 
    8971013__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; 
     1017std::auto_ptr<$reply_class> $server_or_client_class\::Query(const $request_class &rQuery$argextra) 
    9011018{ 
    9021019        // Send query 
    9031020        Send(rQuery); 
    9041021        $send_stream_extra 
     1022         
    9051023        // 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; 
     1044std::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} 
    9411061 
    9421062print H <<__E; 
     
    9491069close CPP; 
    9501070 
    951  
    952 sub obj_is_type 
     1071sub obj_is_type ($$) 
    9531072{ 
    9541073        my ($c,$ty) = @_; 
     
    10041123} 
    10051124 
    1006 sub make_log_strings 
     1125sub make_log_strings_framework 
    10071126{ 
    10081127        my ($cmd) = @_; 
    10091128 
    1010         my @str; 
    1011         my @arg; 
     1129        my @args; 
     1130 
    10121131        for(my $x = 0; $x < $#{$cmd_contents{$cmd}}; $x+=2) 
    10131132        { 
     
    10201139                        $arg =~ s/VAR/m$nm/g; 
    10211140 
    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"') 
    10571142                        { 
    10581143                                $arg = "\"\\\"\" << $arg << \"\\\"\""; 
     
    10911176} 
    10921177 
    1093  
  • box/trunk/qdbm

    • Property svn:ignore set to
      Makefile
      config.status
      qdbm.pc
      config.log
      qdbm.spec
      LTmakefile
      configure.lineno
  • box/trunk/test/backupstore/testbackupstore.cpp

    r2841 r2983  
    1414 
    1515#include "Test.h" 
    16 #include "autogen_BackupProtocolClient.h" 
     16#include "autogen_BackupProtocol.h" 
    1717#include "SSLLib.h" 
    1818#include "TLSContext.h" 
     
    441441         
    442442        // Command 
    443         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory( 
     443        std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 
    444444                        DirID, 
    445                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    446                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
     445                        BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
     446                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
    447447        // Stream 
    448448        BackupStoreDirectory dir; 
     
    456456        while((en = i.Next()) != 0) 
    457457        { 
    458                 if(en->GetFlags() & BackupProtocolClientListDirectory::Flags_Dir) 
     458                if(en->GetFlags() & BackupProtocolListDirectory::Flags_Dir) 
    459459                { 
    460460                        dirs++; 
     
    467467                } 
    468468                // Check it's deleted 
    469                 TEST_THAT(en->GetFlags() & BackupProtocolClientListDirectory::Flags_Deleted); 
     469                TEST_THAT(en->GetFlags() & BackupProtocolListDirectory::Flags_Deleted); 
    470470        } 
    471471         
     
    492492        std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile( 
    493493                source.c_str(), parentId, name_encoded)); 
    494         std::auto_ptr<BackupProtocolClientSuccess> stored( 
     494        std::auto_ptr<BackupProtocolSuccess> stored( 
    495495                protocol.QueryStoreFile( 
    496496                        parentId, 
     
    516516                int attrS = 0; 
    517517                MemBlockStream attr(&attrS, sizeof(attrS)); 
    518                 std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory( 
     518                std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory( 
    519519                        indir, 
    520520                        9837429842987984LL, dirname, attr)); 
     
    551551{ 
    552552        // Command 
    553         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory( 
    554                         BackupProtocolClientListDirectory::RootDirectory, 
    555                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    556                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
    557         TEST_THAT(dirreply->GetObjectID() == BackupProtocolClientListDirectory::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); 
    558558        // Stream 
    559559        BackupStoreDirectory dir; 
     
    576576                TEST_THAT(en->GetObjectID() == uploads[t].allocated_objid); 
    577577                TEST_THAT(en->GetModificationTime() == uploads[t].mod_time); 
    578                 int correct_flags = BackupProtocolClientListDirectory::Flags_File; 
    579                 if(uploads[t].should_be_old_version) correct_flags |= BackupProtocolClientListDirectory::Flags_OldVersion; 
    580                 if(uploads[t].delete_file) correct_flags |= BackupProtocolClientListDirectory::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; 
    581581                TEST_THAT(en->GetFlags() == correct_flags); 
    582582                if(t == UPLOAD_ATTRS_EN) 
     
    607607{ 
    608608        // Command 
    609         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory( 
     609        std::auto_ptr<BackupProtocolSuccess> dirreply(protocol.QueryListDirectory( 
    610610                        id, 
    611                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    612                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
     611                        BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
     612                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
    613613        // Stream 
    614614        BackupStoreDirectory dir; 
     
    650650 
    651651        { 
    652                 std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     652                std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    653653                TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    654                 std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly)); 
     654                std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly)); 
    655655        } 
    656656         
     
    759759        { 
    760760                // Command 
    761                 std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory( 
    762                                 BackupProtocolClientListDirectory::RootDirectory, 
    763                                 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    764                                 BackupProtocolClientListDirectory::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 */)); 
    765765                // Stream 
    766766                BackupStoreDirectory dir; 
     
    773773        { 
    774774                // Command 
    775                 std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    776                                 BackupProtocolClientListDirectory::RootDirectory, 
    777                                 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    778                                 BackupProtocolClientListDirectory::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 */)); 
    779779                // Stream 
    780780                BackupStoreDirectory dir; 
     
    788788        { 
    789789                FileStream out("testfiles/file1_upload1", O_WRONLY | O_CREAT | O_EXCL); 
    790                 std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolClientListDirectory::RootDirectory, store1name)); 
     790                std::auto_ptr<IOStream> encoded(BackupStoreFile::EncodeFile("testfiles/file1", BackupProtocolListDirectory::RootDirectory, store1name)); 
    791791                encoded->CopyStreamTo(out); 
    792792        } 
     
    798798        { 
    799799                FileStream upload("testfiles/file1_upload1"); 
    800                 std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile( 
    801                         BackupProtocolClientListDirectory::RootDirectory, 
     800                std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 
     801                        BackupProtocolListDirectory::RootDirectory, 
    802802                        0x123456789abcdefLL,            /* modification time */ 
    803803                        0x7362383249872dfLL,            /* attr hash */ 
     
    812812        { 
    813813                // Retrieve as object 
    814                 std::auto_ptr<BackupProtocolClientSuccess> getfile(protocol.QueryGetObject(store1objid)); 
     814                std::auto_ptr<BackupProtocolSuccess> getfile(protocol.QueryGetObject(store1objid)); 
    815815                TEST_THAT(getfile->GetObjectID() == store1objid); 
    816816                // BLOCK 
     
    827827 
    828828                // Retrieve as file 
    829                 std::auto_ptr<BackupProtocolClientSuccess> getobj(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, store1objid)); 
     829                std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, store1objid)); 
    830830                TEST_THAT(getobj->GetObjectID() == store1objid); 
    831831                // BLOCK 
     
    853853                // Retrieve the block index, by ID 
    854854                { 
    855                         std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid)); 
     855                        std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(store1objid)); 
    856856                        TEST_THAT(getblockindex->GetObjectID() == store1objid); 
    857857                        std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); 
     
    861861                // and again, by name 
    862862                { 
    863                         std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolClientListDirectory::RootDirectory, store1name)); 
     863                        std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByName(BackupProtocolListDirectory::RootDirectory, store1name)); 
    864864                        TEST_THAT(getblockindex->GetObjectID() == store1objid); 
    865865                        std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); 
     
    871871        { 
    872872                // Command 
    873                 std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory( 
    874                                 BackupProtocolClientListDirectory::RootDirectory, 
    875                                 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    876                                 BackupProtocolClientListDirectory::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 */)); 
    877877                // Stream 
    878878                BackupStoreDirectory dir; 
     
    897897        // Try using GetFile on a directory 
    898898        { 
    899                 TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> getFile(protocol.QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, BackupProtocolClientListDirectory::RootDirectory)), 
     899                TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> getFile(protocol.QueryGetFile(BackupProtocolListDirectory::RootDirectory, BackupProtocolListDirectory::RootDirectory)), 
    900900                        ConnectionException, Conn_Protocol_UnexpectedReply); 
    901901        } 
     
    930930         
    931931        // Check the version 
    932         std::auto_ptr<BackupProtocolClientVersion> serverVersion( 
     932        std::auto_ptr<BackupProtocolVersion> serverVersion( 
    933933                protocol->QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    934934        TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    935935 
    936936        // Login 
    937         std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf( 
     937        std::auto_ptr<BackupProtocolLoginConfirmed> loginConf( 
    938938                protocol->QueryLogin(0x01234567, 0)); 
    939939 
     
    10101010                                BOX_PORT_BBSTORED_TEST); 
    10111011                        BackupProtocolClient protocol(conn); 
    1012                         std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     1012                        std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    10131013                        TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    1014                         TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)), 
     1014                        TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)), 
    10151015                                ConnectionException, Conn_Protocol_UnexpectedReply); 
    10161016                        protocol.QueryFinished(); 
     
    10341034 
    10351035                { 
    1036                         std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     1036                        std::auto_ptr<BackupProtocolVersion> serverVersion(protocolReadOnly.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    10371037                        TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    1038                         std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolClientLogin::Flags_ReadOnly)); 
     1038                        std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocolReadOnly.QueryLogin(0x01234567, BackupProtocolLogin::Flags_ReadOnly)); 
    10391039                         
    10401040                        // Check client store marker 
     
    10801080                        int64_t modtime = 0; 
    10811081 
    1082                         std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolClientListDirectory::RootDirectory, uploads[t].name, &modtime)); 
     1082                        std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), BackupProtocolListDirectory::RootDirectory, uploads[t].name, &modtime)); 
    10831083                        TEST_THAT(modtime != 0); 
    10841084                         
    1085                         std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile( 
    1086                                 BackupProtocolClientListDirectory::RootDirectory, 
     1085                        std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 
     1086                                BackupProtocolListDirectory::RootDirectory, 
    10871087                                modtime, 
    10881088                                modtime, /* use it for attr hash too */ 
     
    11081108                        TEST_NUM_FILES(UPLOAD_NUM + 1, 0, 0, 1); 
    11091109                        MemBlockStream attrnew(attr3, sizeof(attr3)); 
    1110                         std::auto_ptr<BackupProtocolClientSuccess> set(apProtocol->QuerySetReplacementFileAttributes( 
    1111                                 BackupProtocolClientListDirectory::RootDirectory, 
     1110                        std::auto_ptr<BackupProtocolSuccess> set(apProtocol->QuerySetReplacementFileAttributes( 
     1111                                BackupProtocolListDirectory::RootDirectory, 
    11121112                                32498749832475LL, 
    11131113                                uploads[UPLOAD_ATTRS_EN].name, 
     
    11191119                // Delete one of them (will implicitly delete an old version) 
    11201120                { 
    1121                         std::auto_ptr<BackupProtocolClientSuccess> del(apProtocol->QueryDeleteFile( 
    1122                                 BackupProtocolClientListDirectory::RootDirectory, 
     1121                        std::auto_ptr<BackupProtocolSuccess> del(apProtocol->QueryDeleteFile( 
     1122                                BackupProtocolListDirectory::RootDirectory, 
    11231123                                uploads[UPLOAD_DELETE_EN].name)); 
    11241124                        TEST_THAT(del->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid); 
     
    11311131                        { 
    11321132                                FileStream out("testfiles/downloaddelobj", O_WRONLY | O_CREAT); 
    1133                                 std::auto_ptr<BackupProtocolClientSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid)); 
     1133                                std::auto_ptr<BackupProtocolSuccess> getobj(apProtocol->QueryGetObject(uploads[UPLOAD_DELETE_EN].allocated_objid)); 
    11341134                                std::auto_ptr<IOStream> objstream(apProtocol->ReceiveStream()); 
    11351135                                objstream->CopyStreamTo(out); 
    11361136                        } 
    11371137                        // query index and test 
    1138                         std::auto_ptr<BackupProtocolClientSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName( 
    1139                                 BackupProtocolClientListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name)); 
     1138                        std::auto_ptr<BackupProtocolSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName( 
     1139                                BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_DELETE_EN].name)); 
    11401140                        TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_DELETE_EN].allocated_objid); 
    11411141                        std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream()); 
     
    11471147                { 
    11481148                        printf("%d\n", t); 
    1149                         std::auto_ptr<BackupProtocolClientSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, uploads[t].allocated_objid)); 
     1149                        std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, uploads[t].allocated_objid)); 
    11501150                        TEST_THAT(getFile->GetObjectID() == uploads[t].allocated_objid); 
    11511151                        std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream()); 
     
    12071207                { 
    12081208                        // Fetch the block index for this one 
    1209                         std::auto_ptr<BackupProtocolClientSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName( 
    1210                                 BackupProtocolClientListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name)); 
     1209                        std::auto_ptr<BackupProtocolSuccess> getblockindex(apProtocol->QueryGetBlockIndexByName( 
     1210                                BackupProtocolListDirectory::RootDirectory, uploads[UPLOAD_PATCH_EN].name)); 
    12111211                        TEST_THAT(getblockindex->GetObjectID() == uploads[UPLOAD_PATCH_EN].allocated_objid); 
    12121212                        std::auto_ptr<IOStream> blockIndexStream(apProtocol->ReceiveStream()); 
     
    12181218                                BackupStoreFile::EncodeFileDiff( 
    12191219                                        TEST_FILE_FOR_PATCHING ".mod",  
    1220                                         BackupProtocolClientListDirectory::RootDirectory, 
     1220                                        BackupProtocolListDirectory::RootDirectory, 
    12211221                                        uploads[UPLOAD_PATCH_EN].name,  
    12221222                                        uploads[UPLOAD_PATCH_EN].allocated_objid,  
     
    12371237                        { 
    12381238                                FileStream uploadpatch(TEST_FILE_FOR_PATCHING ".patch"); 
    1239                                 std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile( 
    1240                                         BackupProtocolClientListDirectory::RootDirectory, 
     1239                                std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 
     1240                                        BackupProtocolListDirectory::RootDirectory, 
    12411241                                        modtime, 
    12421242                                        modtime, /* use it for attr hash too */ 
     
    12521252 
    12531253                        // Then download it to check it's OK 
    1254                         std::auto_ptr<BackupProtocolClientSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolClientListDirectory::RootDirectory, patchedID)); 
     1254                        std::auto_ptr<BackupProtocolSuccess> getFile(apProtocol->QueryGetFile(BackupProtocolListDirectory::RootDirectory, patchedID)); 
    12551255                        TEST_THAT(getFile->GetObjectID() == patchedID); 
    12561256                        std::auto_ptr<IOStream> filestream(apProtocol->ReceiveStream()); 
     
    12681268                        // Attributes 
    12691269                        MemBlockStream attr(attr1, sizeof(attr1)); 
    1270                         std::auto_ptr<BackupProtocolClientSuccess> dirCreate(apProtocol->QueryCreateDirectory( 
    1271                                 BackupProtocolClientListDirectory::RootDirectory, 
     1270                        std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory( 
     1271                                BackupProtocolListDirectory::RootDirectory, 
    12721272                                9837429842987984LL, dirname, attr)); 
    12731273                        subdirid = dirCreate->GetObjectID();  
     
    12861286                        std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile(filename.c_str(), subdirid, uploads[0].name, &modtime)); 
    12871287 
    1288                         std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile( 
     1288                        std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 
    12891289                                subdirid, 
    12901290                                modtime, 
     
    13041304                { 
    13051305                        // Command 
    1306                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    1307                                         BackupProtocolClientListDirectory::RootDirectory, 
    1308                                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    1309                                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream 
     1306                        std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
     1307                                        BackupProtocolListDirectory::RootDirectory, 
     1308                                        BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
     1309                                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); // Stream 
    13101310                        BackupStoreDirectory dir; 
    13111311                        std::auto_ptr<IOStream> dirstream(protocolReadOnly.ReceiveStream()); 
     
    13291329                        // Does it look right? 
    13301330                        TEST_THAT(en->GetName() == dirname); 
    1331                         TEST_THAT(en->GetFlags() == BackupProtocolClientListDirectory::Flags_Dir); 
     1331                        TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_Dir); 
    13321332                        TEST_THAT(en->GetObjectID() == subdirid); 
    13331333                        TEST_THAT(en->GetModificationTime() == 0);      // dirs don't have modification times. 
     
    13361336                { 
    13371337                        // Command 
    1338                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
     1338                        std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    13391339                                        subdirid, 
    1340                                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    1341                                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */)); 
     1340                                        BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
     1341                                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, true /* get attributes */)); 
    13421342                        TEST_THAT(dirreply->GetObjectID() == subdirid); 
    13431343                        // Stream 
     
    13541354                        // Does it look right? 
    13551355                        TEST_THAT(en->GetName() == uploads[0].name); 
    1356                         TEST_THAT(en->GetFlags() == BackupProtocolClientListDirectory::Flags_File); 
     1356                        TEST_THAT(en->GetFlags() == BackupProtocolListDirectory::Flags_File); 
    13571357                        TEST_THAT(en->GetObjectID() == subdirfileid); 
    13581358                        TEST_THAT(en->GetModificationTime() != 0); 
     
    13691369                { 
    13701370                        // Command 
    1371                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
     1371                        std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    13721372                                        subdirid, 
    1373                                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    1374                                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); 
     1373                                        BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
     1374                                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes! */)); 
    13751375                        // Stream 
    13761376                        BackupStoreDirectory dir; 
     
    13861386                { 
    13871387                        MemBlockStream attrnew(attr2, sizeof(attr2)); 
    1388                         std::auto_ptr<BackupProtocolClientSuccess> changereply(apProtocol->QueryChangeDirAttributes( 
     1388                        std::auto_ptr<BackupProtocolSuccess> changereply(apProtocol->QueryChangeDirAttributes( 
    13891389                                        subdirid, 
    13901390                                        329483209443598LL, 
     
    13951395                { 
    13961396                        // Command 
    1397                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
     1397                        std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    13981398                                        subdirid, 
    13991399                                        0,      // no flags 
    1400                                         BackupProtocolClientListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */)); 
     1400                                        BackupProtocolListDirectory::Flags_EXCLUDE_EVERYTHING, true /* get attributes */)); 
    14011401                        // Stream 
    14021402                        BackupStoreDirectory dir; 
     
    14191419                        BackupStoreFilenameClear newName("moved-files"); 
    14201420                 
    1421                         std::auto_ptr<BackupProtocolClientSuccess> rep(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 
    1422                                 BackupProtocolClientListDirectory::RootDirectory, 
    1423                                 subdirid, BackupProtocolClientMoveObject::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)); 
    14241424                        TEST_THAT(rep->GetObjectID() == uploads[UPLOAD_FILE_TO_MOVE].allocated_objid); 
    14251425                } 
     
    14291429                        BackupStoreFilenameClear newName("moved-files"); 
    14301430                        TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 
    1431                                         BackupProtocolClientListDirectory::RootDirectory, 
    1432                                         subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName), 
     1431                                        BackupProtocolListDirectory::RootDirectory, 
     1432                                        subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName), 
    14331433                                ConnectionException, Conn_Protocol_UnexpectedReply); 
    14341434                        TEST_CHECK_THROWS(apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 
    14351435                                        subdirid, 
    1436                                         subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName), 
     1436                                        subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName), 
    14371437                                ConnectionException, Conn_Protocol_UnexpectedReply); 
    14381438                } 
     
    14431443                        apProtocol->QueryMoveObject(uploads[UPLOAD_FILE_TO_MOVE].allocated_objid, 
    14441444                                subdirid, 
    1445                                 subdirid, BackupProtocolClientMoveObject::Flags_MoveAllWithSameName, newName); 
     1445                                subdirid, BackupProtocolMoveObject::Flags_MoveAllWithSameName, newName); 
    14461446                } 
    14471447 
     
    14491449                { 
    14501450                        // Command 
    1451                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    1452                                         BackupProtocolClientListDirectory::RootDirectory, 
    1453                                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    1454                                         BackupProtocolClientListDirectory::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 */)); 
    14551455                        // Stream 
    14561456                        BackupStoreDirectory dir; 
     
    14711471 
    14721472                        // Command 
    1473                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
     1473                        std::auto_ptr<BackupProtocolSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    14741474                                        subdirid, 
    1475                                         BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    1476                                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
     1475                                        BackupProtocolListDirectory::Flags_INCLUDE_EVERYTHING, 
     1476                                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, false /* no attributes */)); 
    14771477                        // Stream 
    14781478                        BackupStoreDirectory dir; 
     
    15061506                        // Attributes 
    15071507                        MemBlockStream attr(attr1, sizeof(attr1)); 
    1508                         std::auto_ptr<BackupProtocolClientSuccess> dirCreate(apProtocol->QueryCreateDirectory( 
     1508                        std::auto_ptr<BackupProtocolSuccess> dirCreate(apProtocol->QueryCreateDirectory( 
    15091509                                subdirid, 
    15101510                                9837429842987984LL, nd, attr)); 
     
    15131513                        FileStream upload("testfiles/file1_upload1"); 
    15141514                        BackupStoreFilenameClear nf("file2"); 
    1515                         std::auto_ptr<BackupProtocolClientSuccess> stored(apProtocol->QueryStoreFile( 
     1515                        std::auto_ptr<BackupProtocolSuccess> stored(apProtocol->QueryStoreFile( 
    15161516                                subsubdirid, 
    15171517                                0x123456789abcdefLL,            /* modification time */ 
     
    15281528                // Query names -- test that invalid stuff returns not found OK 
    15291529                { 
    1530                         std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid)); 
     1530                        std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(3248972347823478927LL, subsubdirid)); 
    15311531                        TEST_THAT(nameRep->GetNumNameElements() == 0);           
    15321532                } 
    15331533                { 
    1534                         std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL)); 
     1534                        std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, 2342378424LL)); 
    15351535                        TEST_THAT(nameRep->GetNumNameElements() == 0);           
    15361536                } 
    15371537                { 
    1538                         std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL)); 
     1538                        std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(38947234789LL, 2342378424LL)); 
    15391539                        TEST_THAT(nameRep->GetNumNameElements() == 0);           
    15401540                } 
    15411541                { 
    1542                         std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL)); 
     1542                        std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, 2234342378424LL)); 
    15431543                        TEST_THAT(nameRep->GetNumNameElements() == 0);           
    15441544                } 
     
    15461546                // Query names... first, get info for the file 
    15471547                { 
    1548                         std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid)); 
     1548                        std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(subsubfileid, subsubdirid)); 
    15491549                        std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream()); 
    15501550                 
    15511551                        TEST_THAT(nameRep->GetNumNameElements() == 3); 
    1552                         TEST_THAT(nameRep->GetFlags() == BackupProtocolClientListDirectory::Flags_File); 
     1552                        TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_File); 
    15531553                        TEST_THAT(nameRep->GetModificationTime() == 0x123456789abcdefLL); 
    15541554                        TEST_THAT(nameRep->GetAttributesHash() == 0x7362383249872dfLL); 
     
    15641564                // Query names... secondly, for the directory 
    15651565                { 
    1566                         std::auto_ptr<BackupProtocolClientObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolClientGetObjectName::ObjectID_DirectoryOnly, subsubdirid)); 
     1566                        std::auto_ptr<BackupProtocolObjectName> nameRep(apProtocol->QueryGetObjectName(BackupProtocolGetObjectName::ObjectID_DirectoryOnly, subsubdirid)); 
    15671567                        std::auto_ptr<IOStream> namestream(apProtocol->ReceiveStream()); 
    15681568                 
    15691569                        TEST_THAT(nameRep->GetNumNameElements() == 2); 
    1570                         TEST_THAT(nameRep->GetFlags() == BackupProtocolClientListDirectory::Flags_Dir); 
     1570                        TEST_THAT(nameRep->GetFlags() == BackupProtocolListDirectory::Flags_Dir); 
    15711571                        static const char *testnames[] = {"sub2","lovely_directory"}; 
    15721572                        for(int l = 0; l < nameRep->GetNumNameElements(); ++l) 
     
    15861586                // Create some nice recursive directories 
    15871587                int64_t dirtodelete = create_test_data_subdirs(*apProtocol, 
    1588                         BackupProtocolClientListDirectory::RootDirectory, 
     1588                        BackupProtocolListDirectory::RootDirectory, 
    15891589                        "test_delete", 6 /* depth */, *apRefCount); 
    15901590                 
    15911591                // And delete them 
    15921592                { 
    1593                         std::auto_ptr<BackupProtocolClientSuccess> dirdel(apProtocol->QueryDeleteDirectory( 
     1593                        std::auto_ptr<BackupProtocolSuccess> dirdel(apProtocol->QueryDeleteDirectory( 
    15941594                                        dirtodelete)); 
    15951595                        TEST_THAT(dirdel->GetObjectID() == dirtodelete); 
     
    15991599                { 
    16001600                        // Command 
    1601                         std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocolReadOnly.QueryListDirectory( 
    1602                                         BackupProtocolClientListDirectory::RootDirectory, 
    1603                                         BackupProtocolClientListDirectory::Flags_Dir | BackupProtocolClientListDirectory::Flags_Deleted, 
    1604                                         BackupProtocolClientListDirectory::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 */)); 
    16051605                        // Stream 
    16061606                        BackupStoreDirectory dir; 
     
    18901890 
    18911891                        // Check the version 
    1892                         std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     1892                        std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    18931893                        TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    18941894 
    18951895                        // Login 
    1896                         TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)), 
     1896                        TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)), 
    18971897                                ConnectionException, Conn_Protocol_UnexpectedReply); 
    18981898                         
     
    19891989                recursive_count_objects_results before = {0,0,0}; 
    19901990 
    1991                 recursive_count_objects("localhost", BackupProtocolClientListDirectory::RootDirectory, before); 
     1991                recursive_count_objects("localhost", BackupProtocolListDirectory::RootDirectory, before); 
    19921992                 
    19931993                TEST_THAT(before.objectsNotDel != 0); 
     
    20342034                recursive_count_objects_results after = {0,0,0}; 
    20352035                recursive_count_objects("localhost",  
    2036                         BackupProtocolClientListDirectory::RootDirectory,  
     2036                        BackupProtocolListDirectory::RootDirectory,  
    20372037                        after); 
    20382038 
     
    20592059 
    20602060                        // Check the version 
    2061                         std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     2061                        std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    20622062                        TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    20632063 
    20642064                        // Login 
    2065                         std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)); 
     2065                        std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol.QueryLogin(0x01234567, 0)); 
    20662066                         
    20672067                        int64_t modtime = 0; 
    20682068                         
    20692069                        BackupStoreFilenameClear fnx("exceed-limit"); 
    2070                         std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocolClientListDirectory::RootDirectory, fnx, &modtime)); 
     2070                        std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/test3", BackupProtocolListDirectory::RootDirectory, fnx, &modtime)); 
    20712071                        TEST_THAT(modtime != 0); 
    20722072 
    2073                         TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile( 
    2074                                         BackupProtocolClientListDirectory::RootDirectory, 
     2073                        TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 
     2074                                        BackupProtocolListDirectory::RootDirectory, 
    20752075                                        modtime, 
    20762076                                        modtime, /* use it for attr hash too */ 
     
    20822082                        MemBlockStream attr(&modtime, sizeof(modtime)); 
    20832083                        BackupStoreFilenameClear fnxd("exceed-limit-dir"); 
    2084                         TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolClientSuccess> dirCreate(protocol.QueryCreateDirectory( 
    2085                                         BackupProtocolClientListDirectory::RootDirectory, 
     2084                        TEST_CHECK_THROWS(std::auto_ptr<BackupProtocolSuccess> dirCreate(protocol.QueryCreateDirectory( 
     2085                                        BackupProtocolListDirectory::RootDirectory, 
    20862086                                        9837429842987984LL, fnxd, attr)), 
    20872087                                ConnectionException, Conn_Protocol_UnexpectedReply); 
     
    22412241                int64_t modtime = 0; 
    22422242                std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("/Users/ben/temp/large.tar", 
    2243                         BackupProtocolClientListDirectory::RootDirectory, uploads[0].name, &modtime)); 
     2243                        BackupProtocolListDirectory::RootDirectory, uploads[0].name, &modtime)); 
    22442244                TEST_THAT(modtime != 0); 
    22452245                FileStream write("testfiles/large.enc", O_WRONLY | O_CREAT); 
  • box/trunk/test/backupstorepatch/testbackupstorepatch.cpp

    r2646 r2983  
    1414#include <signal.h> 
    1515 
    16 #include "autogen_BackupProtocolClient.h" 
     16#include "autogen_BackupProtocol.h" 
    1717#include "BackupClientCryptoKeys.h" 
    1818#include "BackupClientFileAttributes.h" 
     
    355355                        { 
    356356                                // Check the version 
    357                                 std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     357                                std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    358358                                TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    359359         
     
    368368                        { 
    369369                                std::auto_ptr<IOStream> upload(BackupStoreFile::EncodeFile("testfiles/0.test", 
    370                                                 BackupProtocolClientListDirectory::RootDirectory, storeFilename)); 
    371                                 std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile( 
    372                                                 BackupProtocolClientListDirectory::RootDirectory, ModificationTime, 
     370                                                BackupProtocolListDirectory::RootDirectory, storeFilename)); 
     371                                std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 
     372                                                BackupProtocolListDirectory::RootDirectory, ModificationTime, 
    373373                                                ModificationTime, 0 /* no diff from file ID */, storeFilename, *upload)); 
    374374                                test_files[0].IDOnServer = stored->GetObjectID(); 
     
    381381                        { 
    382382                                // Get an index for the previous version 
    383                                 std::auto_ptr<BackupProtocolClientSuccess> getBlockIndex(protocol.QueryGetBlockIndexByName( 
    384                                                 BackupProtocolClientListDirectory::RootDirectory, storeFilename)); 
     383                                std::auto_ptr<BackupProtocolSuccess> getBlockIndex(protocol.QueryGetBlockIndexByName( 
     384                                                BackupProtocolListDirectory::RootDirectory, storeFilename)); 
    385385                                int64_t diffFromID = getBlockIndex->GetObjectID(); 
    386386                                TEST_THAT(diffFromID != 0); 
     
    398398                                                BackupStoreFile::EncodeFileDiff( 
    399399                                                        filename, 
    400                                                         BackupProtocolClientListDirectory::RootDirectory,       /* containing directory */ 
     400                                                        BackupProtocolListDirectory::RootDirectory,     /* containing directory */ 
    401401                                                        storeFilename,  
    402402                                                        diffFromID,  
     
    408408                 
    409409                                        // Upload the patch to the store 
    410                                         std::auto_ptr<BackupProtocolClientSuccess> stored(protocol.QueryStoreFile( 
    411                                                         BackupProtocolClientListDirectory::RootDirectory, ModificationTime, 
     410                                        std::auto_ptr<BackupProtocolSuccess> stored(protocol.QueryStoreFile( 
     411                                                        BackupProtocolListDirectory::RootDirectory, ModificationTime, 
    412412                                                        ModificationTime, isCompletelyDifferent?(0):(diffFromID), storeFilename, *patchStream)); 
    413413                                        ModificationTime += MODIFICATION_TIME_INC; 
     
    433433                        // List the directory from the server, and check that no dependency info is sent -- waste of bytes 
    434434                        { 
    435                                 std::auto_ptr<BackupProtocolClientSuccess> dirreply(protocol.QueryListDirectory( 
    436                                                 BackupProtocolClientListDirectory::RootDirectory, 
    437                                                 BackupProtocolClientListDirectory::Flags_INCLUDE_EVERYTHING, 
    438                                                 BackupProtocolClientListDirectory::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 */)); 
    439439                                // Stream 
    440440                                BackupStoreDirectory dir; 
     
    532532                        BackupProtocolClient protocol(conn); 
    533533                        { 
    534                                 std::auto_ptr<BackupProtocolClientVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
     534                                std::auto_ptr<BackupProtocolVersion> serverVersion(protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION)); 
    535535                                TEST_THAT(serverVersion->GetVersion() == BACKUP_STORE_SERVER_VERSION); 
    536536                                protocol.QueryLogin(0x01234567, 0); 
     
    556556                                // Fetch the file 
    557557                                { 
    558                                         std::auto_ptr<BackupProtocolClientSuccess> getobj(protocol.QueryGetFile( 
    559                                                 BackupProtocolClientListDirectory::RootDirectory, 
     558                                        std::auto_ptr<BackupProtocolSuccess> getobj(protocol.QueryGetFile( 
     559                                                BackupProtocolListDirectory::RootDirectory, 
    560560                                                test_files[f].IDOnServer)); 
    561561                                        TEST_THAT(getobj->GetObjectID() == test_files[f].IDOnServer); 
     
    573573                                // Download the index, and check it looks OK 
    574574                                { 
    575                                         std::auto_ptr<BackupProtocolClientSuccess> getblockindex(protocol.QueryGetBlockIndexByID(test_files[f].IDOnServer)); 
     575                                        std::auto_ptr<BackupProtocolSuccess> getblockindex(protocol.QueryGetBlockIndexByID(test_files[f].IDOnServer)); 
    576576                                        TEST_THAT(getblockindex->GetObjectID() == test_files[f].IDOnServer); 
    577577                                        std::auto_ptr<IOStream> blockIndexStream(protocol.ReceiveStream()); 
  • box/trunk/test/basicserver/Makefile.extra

    r2598 r2983  
    22MAKEPROTOCOL = ../../lib/server/makeprotocol.pl 
    33 
    4 GEN_CMD_SRV = $(MAKEPROTOCOL) Server testprotocol.txt 
    5 GEN_CMD_CLI = $(MAKEPROTOCOL) Client testprotocol.txt 
     4GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt 
    65 
    76# AUTOGEN SEEDING 
    8 autogen_TestProtocolServer.cpp: $(MAKEPROTOCOL) testprotocol.txt 
    9         $(_PERL) $(GEN_CMD_SRV) 
     7autogen_TestProtocol.cpp:       $(MAKEPROTOCOL) testprotocol.txt 
     8        $(_PERL) $(GEN_CMD) 
    109 
    1110autogen_TestProtocolServer.h:   $(MAKEPROTOCOL) testprotocol.txt 
    12         $(_PERL) $(GEN_CMD_SRV) 
     11        $(_PERL) $(GEN_CMD) 
    1312 
    14  
    15 # AUTOGEN SEEDING 
    16 autogen_TestProtocolClient.cpp: $(MAKEPROTOCOL) testprotocol.txt 
    17         $(_PERL) $(GEN_CMD_CLI) 
    18  
    19 autogen_TestProtocolClient.h:   $(MAKEPROTOCOL) testprotocol.txt 
    20         $(_PERL) $(GEN_CMD_CLI) 
    21  
  • box/trunk/test/basicserver/TestCommands.cpp

    r710 r2983  
    66#endif 
    77 
    8 #include "autogen_TestProtocolServer.h" 
     8#include "autogen_TestProtocol.h" 
    99#include "CollectInBufferStream.h" 
    1010 
     
    1212 
    1313 
    14 std::auto_ptr<ProtocolObject> TestProtocolServerHello::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     14std::auto_ptr<TestProtocolMessage> TestProtocolHello::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    1515{ 
    1616        if(mNumber32 != 41 || mNumber16 != 87 || mNumber8 != 11 || mText != "pingu") 
    1717        { 
    18                 return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0)); 
     18                return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 
    1919        } 
    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!"))); 
    2121} 
    2222 
    23 std::auto_ptr<ProtocolObject> TestProtocolServerLists::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     23std::auto_ptr<TestProtocolMessage> TestProtocolLists::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    2424{ 
    25         return std::auto_ptr<ProtocolObject>(new TestProtocolServerListsReply(mLotsOfText.size())); 
     25        return std::auto_ptr<TestProtocolMessage>(new TestProtocolListsReply(mLotsOfText.size())); 
    2626} 
    2727 
    28 std::auto_ptr<ProtocolObject> TestProtocolServerQuit::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     28std::auto_ptr<TestProtocolMessage> TestProtocolQuit::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    2929{ 
    30         return std::auto_ptr<ProtocolObject>(new TestProtocolServerQuit); 
     30        return std::auto_ptr<TestProtocolMessage>(new TestProtocolQuit); 
    3131} 
    3232 
    33 std::auto_ptr<ProtocolObject> TestProtocolServerSimple::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     33std::auto_ptr<TestProtocolMessage> TestProtocolSimple::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    3434{ 
    35         return std::auto_ptr<ProtocolObject>(new TestProtocolServerSimpleReply(mValue+1)); 
     35        return std::auto_ptr<TestProtocolMessage>(new TestProtocolSimpleReply(mValue+1)); 
    3636} 
    3737 
     
    4646}; 
    4747 
    48 std::auto_ptr<ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     48std::auto_ptr<TestProtocolMessage> TestProtocolGetStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    4949{ 
    5050        // make a new stream object 
     
    6969        rProtocol.SendStreamAfterCommand(pstream); 
    7070 
    71         return std::auto_ptr<ProtocolObject>(new TestProtocolServerGetStream(mStartingValue, mUncertainSize)); 
     71        return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(mStartingValue, mUncertainSize)); 
    7272} 
    7373 
    74 std::auto_ptr<ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     74std::auto_ptr<TestProtocolMessage> TestProtocolSendStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    7575{ 
    7676        if(mValue != 0x73654353298ffLL) 
    7777        { 
    78                 return std::auto_ptr<ProtocolObject>(new TestProtocolServerError(0, 0)); 
     78                return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 
    7979        } 
    8080         
     
    9292 
    9393        // 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)); 
    9595} 
    9696 
    97 std::auto_ptr<ProtocolObject> TestProtocolServerString::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext) 
     97std::auto_ptr<TestProtocolMessage> TestProtocolString::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 
    9898{ 
    99         return std::auto_ptr<ProtocolObject>(new TestProtocolServerString(mTest)); 
     99        return std::auto_ptr<TestProtocolMessage>(new TestProtocolString(mTest)); 
    100100} 
    101101 
  • box/trunk/test/basicserver/testbasicserver.cpp

    r2942 r2983  
    2727 
    2828#include "TestContext.h" 
    29 #include "autogen_TestProtocolClient.h" 
    30 #include "autogen_TestProtocolServer.h" 
     29#include "autogen_TestProtocol.h" 
    3130#include "ServerControl.h" 
    3231 
     
    394393void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream) 
    395394{ 
    396         std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); 
     395        std::auto_ptr<TestProtocolGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); 
    397396        TEST_THAT(reply->GetStartingValue() == value); 
    398397         
     
    705704                        // Simple query 
    706705                        { 
    707                                 std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(41)); 
     706                                std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(41)); 
    708707                                TEST_THAT(reply->GetValuePlusOne() == 42); 
    709708                        } 
    710709                        { 
    711                                 std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(809)); 
     710                                std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(809)); 
    712711                                TEST_THAT(reply->GetValuePlusOne() == 810); 
    713712                        } 
     
    725724                                s.Write(buf, sizeof(buf)); 
    726725                                s.SetForReading(); 
    727                                 std::auto_ptr<TestProtocolClientGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); 
     726                                std::auto_ptr<TestProtocolGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); 
    728727                                TEST_THAT(reply->GetStartingValue() == sizeof(buf)); 
    729728                        } 
     
    732731                        for(int q = 0; q < 514; q++) 
    733732                        { 
    734                                 std::auto_ptr<TestProtocolClientSimpleReply> reply(protocol.QuerySimple(q)); 
     733                                std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(q)); 
    735734                                TEST_THAT(reply->GetValuePlusOne() == (q+1)); 
    736735                        } 
     
    741740                                strings.push_back(std::string("test2")); 
    742741                                strings.push_back(std::string("test3")); 
    743                                 std::auto_ptr<TestProtocolClientListsReply> reply(protocol.QueryLists(strings)); 
     742                                std::auto_ptr<TestProtocolListsReply> reply(protocol.QueryLists(strings)); 
    744743                                TEST_THAT(reply->GetNumberOfStrings() == 3); 
    745744                        } 
     
    747746                        // And another 
    748747                        { 
    749                                 std::auto_ptr<TestProtocolClientHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); 
     748                                std::auto_ptr<TestProtocolHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); 
    750749                                TEST_THAT(reply->GetNumber32() == 12); 
    751750                                TEST_THAT(reply->GetNumber16() == 89); 
  • box/trunk/test/bbackupd/Makefile.extra

    r2973 r2983  
    99        ../../bin/bbstored/BBStoreDHousekeeping.o \ 
    1010        ../../bin/bbstored/HousekeepStoreAccount.o \ 
    11         ../../lib/backupstore/autogen_BackupProtocolServer.o \ 
     11        ../../lib/backupstore/autogen_BackupProtocol.o \ 
    1212        ../../lib/backupstore/BackupStoreContext.o \ 
    1313        ../../lib/backupstore/BackupCommands.o \ 
  • box/trunk/test/bbackupd/testbbackupd.cpp

    r2944 r2983  
    4343#endif 
    4444 
    45 #include "autogen_BackupProtocolServer.h" 
     45#include "autogen_BackupProtocol.h" 
    4646#include "BackupClientCryptoKeys.h" 
    4747#include "BackupClientFileAttributes.h" 
     
    7474#include "Utils.h" 
    7575 
    76 #include "autogen_BackupProtocolClient.h" 
    7776#include "intercept.h" 
    7877#include "ServerControl.h" 
     
    476475        protocol.QueryListDirectory( 
    477476                        InDirectory, 
    478                         BackupProtocolClientListDirectory::Flags_Dir, 
    479                         BackupProtocolClientListDirectory::Flags_EXCLUDE_NOTHING, 
     477                        BackupProtocolListDirectory::Flags_Dir, 
     478                        BackupProtocolListDirectory::Flags_EXCLUDE_NOTHING, 
    480479                        true /* want attributes */); 
    481480         
     
    519518                        BackupProtocolClient protocol(conn); 
    520519                        protocol.QueryVersion(BACKUP_STORE_SERVER_VERSION); 
    521                         std::auto_ptr<BackupProtocolClientLoginConfirmed> 
     520                        std::auto_ptr<BackupProtocolLoginConfirmed> 
    522521                                loginConf(protocol.QueryLogin(0x01234567, 
    523                                         BackupProtocolClientLogin::Flags_ReadOnly)); 
     522                                        BackupProtocolLogin::Flags_ReadOnly)); 
    524523                         
    525524                        // Test the restoration 
     
    605604        int64_t id = en->GetObjectID(); 
    606605        TEST_THAT(id > 0); 
    607         TEST_THAT(id != BackupProtocolClientListDirectory::RootDirectory); 
     606        TEST_THAT(id != BackupProtocolListDirectory::RootDirectory); 
    608607        return id; 
    609608} 
     
    618617        connection.reset(new BackupProtocolClient(sSocket)); 
    619618        connection->Handshake(); 
    620         std::auto_ptr<BackupProtocolClientVersion>  
     619        std::auto_ptr<BackupProtocolVersion>  
    621620                serverVersion(connection->QueryVersion( 
    622621                        BACKUP_STORE_SERVER_VERSION)); 
     
    641640( 
    642641        BackupProtocolClient& rClient, 
    643         int64_t id 
     642        int64_t id = BackupProtocolListDirectory::RootDirectory 
    644643) 
    645644{ 
    646         std::auto_ptr<BackupProtocolClientSuccess> dirreply( 
     645        std::auto_ptr<BackupProtocolSuccess> dirreply( 
    647646                rClient.QueryListDirectory(id, false, 0, false)); 
    648647        std::auto_ptr<IOStream> dirstream(rClient.ReceiveStream()); 
     
    767766        else 
    768767        { 
    769                 BOX_INFO("readdir hook still active at " << time_now << ", " 
     768                BOX_TRACE("readdir hook still active at " << time_now << ", " 
    770769                        "waiting for " << readdir_stop_time); 
    771770        } 
     
    781780                sizeof(readdir_test_dirent.d_name), 
    782781                "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); 
    784783 
    785784        // ensure that when bbackupd stats the file, it gets the  
     
    792791        intercept_setup_lstat_hook(stat_hook_filename, lstat_test_hook); 
    793792#endif 
     793 
     794        // sleep a bit to reduce the number of dirents returned 
     795        ::safe_sleep(1); 
    794796 
    795797        return &readdir_test_dirent; 
     
    11311133                        TEST_LINE(comp2 != sub, line); 
    11321134                } 
     1135 
     1136                // Check that no read error has been reported yet 
     1137                TEST_THAT(!TestFileExists("testfiles/notifyran.read-error.1")); 
    11331138 
    11341139                if (failures > 0) 
     
    13391344                                ConnectAndLogin(context, 0 /* read-write */); 
    13401345                 
    1341                         std::auto_ptr<BackupProtocolClientAccountUsage> usage( 
     1346                        std::auto_ptr<BackupProtocolAccountUsage> usage( 
    13421347                                client->QueryGetAccountUsage()); 
    13431348                        TEST_EQUAL_LINE(24, usage->GetBlocksUsed(), 
     
    14221427                 
    14231428                        std::auto_ptr<BackupStoreDirectory> rootDir =  
    1424                                 ReadDirectory(*client, 
    1425                                 BackupProtocolClientListDirectory::RootDirectory); 
     1429                                ReadDirectory(*client); 
    14261430 
    14271431                        int64_t testDirId = SearchDir(*rootDir, "Test1"); 
     
    14651469                        TEST_THAT(test_entry_deleted(*d4_dir, "f5")); 
    14661470 
    1467                         std::auto_ptr<BackupProtocolClientAccountUsage> usage( 
     1471                        std::auto_ptr<BackupProtocolAccountUsage> usage( 
    14681472                                client->QueryGetAccountUsage()); 
    14691473                        TEST_EQUAL_LINE(24, usage->GetBlocksUsed(), 
     
    14991503                         
    15001504                        std::auto_ptr<BackupStoreDirectory> rootDir =  
    1501                                 ReadDirectory(*client, 
    1502                                 BackupProtocolClientListDirectory::RootDirectory); 
     1505                                ReadDirectory(*client); 
    15031506 
    15041507                        int64_t testDirId = SearchDir(*rootDir, "Test1"); 
     
    15201523                        TEST_THAT(SearchDir(*spacetest_dir, "d7") == 0); 
    15211524 
    1522                         std::auto_ptr<BackupProtocolClientAccountUsage> usage( 
     1525                        std::auto_ptr<BackupProtocolAccountUsage> usage( 
    15231526                                client->QueryGetAccountUsage()); 
    15241527                        TEST_EQUAL_LINE(16, usage->GetBlocksUsed(), 
     
    15751578                                ConnectAndLogin(context, 0 /* read-write */); 
    15761579 
    1577                         std::auto_ptr<BackupProtocolClientAccountUsage> usage( 
     1580                        std::auto_ptr<BackupProtocolAccountUsage> usage( 
    15781581                                client->QueryGetAccountUsage()); 
    15791582                        TEST_EQUAL_LINE(22, usage->GetBlocksUsed(), 
     
    16861689                class MyHook : public BackupStoreContext::TestHook 
    16871690                { 
    1688                         virtual std::auto_ptr<ProtocolObject> StartCommand( 
    1689                                 BackupProtocolObject& rCommand) 
     1691                        virtual std::auto_ptr<BackupProtocolMessage> StartCommand( 
     1692                                const BackupProtocolMessage& rCommand) 
    16901693                        { 
    16911694                                if (rCommand.GetType() == 
    1692                                         BackupProtocolServerStoreFile::TypeID) 
     1695                                        BackupProtocolStoreFile::TypeID) 
    16931696                                { 
    16941697                                        // terminate badly 
     
    16961699                                                Internal); 
    16971700                                } 
    1698                                 return std::auto_ptr<ProtocolObject>(); 
     1701                                return std::auto_ptr<BackupProtocolMessage>(); 
    16991702                        } 
    17001703                }; 
     
    19601963                        std::auto_ptr<BackupProtocolClient> client = 
    19611964                                ConnectAndLogin(context, 
    1962                                 BackupProtocolClientLogin::Flags_ReadOnly); 
     1965                                BackupProtocolLogin::Flags_ReadOnly); 
    19631966                         
    19641967                        std::auto_ptr<BackupStoreDirectory> dir =  
    1965                                 ReadDirectory(*client, 
    1966                                 BackupProtocolClientListDirectory::RootDirectory); 
     1968                                ReadDirectory(*client); 
    19671969                        int64_t testDirId = SearchDir(*dir, "Test2"); 
    19681970                        TEST_THAT(testDirId != 0); 
     
    19992001                        std::auto_ptr<BackupProtocolClient> client = 
    20002002                                ConnectAndLogin(context, 
    2001                                 BackupProtocolClientLogin::Flags_ReadOnly); 
     2003                                BackupProtocolLogin::Flags_ReadOnly); 
    20022004                         
    20032005                        std::auto_ptr<BackupStoreDirectory> dir =  
    2004                                 ReadDirectory(*client, 
    2005                                 BackupProtocolClientListDirectory::RootDirectory); 
     2006                                ReadDirectory(*client); 
    20062007                        int64_t testDirId = SearchDir(*dir, "Test2"); 
    20072008                        TEST_THAT(testDirId != 0); 
     
    20182019                        std::auto_ptr<BackupProtocolClient> client = 
    20192020                                ConnectAndLogin(context, 
    2020                                 BackupProtocolClientLogin::Flags_ReadOnly); 
     2021                                BackupProtocolLogin::Flags_ReadOnly); 
    20212022                         
    20222023                        std::auto_ptr<BackupStoreDirectory> root_dir =  
    2023                                 ReadDirectory(*client, 
    2024                                 BackupProtocolClientListDirectory::RootDirectory); 
     2024                                ReadDirectory(*client); 
    20252025 
    20262026                        TEST_THAT(test_entry_deleted(*root_dir, "Test2")); 
     
    22642264 
    22652265                        std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory( 
    2266                                 *client,  
    2267                                 BackupProtocolClientListDirectory::RootDirectory); 
     2266                                *client); 
    22682267 
    22692268                        int64_t baseDirId = SearchDir(*dir, "Test1"); 
     
    32583257                        std::auto_ptr<BackupProtocolClient> client =  
    32593258                                ConnectAndLogin(context, 
    3260                                 BackupProtocolClientLogin::Flags_ReadOnly); 
     3259                                BackupProtocolLogin::Flags_ReadOnly); 
    32613260                         
    32623261                        std::auto_ptr<BackupStoreDirectory> dir = ReadDirectory( 
    3263                                 *client, 
    3264                                 BackupProtocolClientListDirectory::RootDirectory); 
     3262                                *client); 
    32653263 
    32663264                        int64_t testDirId = SearchDir(*dir, "Test1"); 
     
    34393437                        std::auto_ptr<BackupProtocolClient> client =  
    34403438                                ConnectAndLogin(context, 
    3441                                 BackupProtocolClientLogin::Flags_ReadOnly); 
     3439                                BackupProtocolLogin::Flags_ReadOnly); 
    34423440 
    34433441                        // Find the ID of the Test1 directory 
    34443442                        restoredirid = GetDirID(*client, "Test1",  
    3445                                 BackupProtocolClientListDirectory::RootDirectory); 
     3443                                BackupProtocolListDirectory::RootDirectory); 
    34463444                        TEST_THAT(restoredirid != 0); 
    34473445 
     
    37463744                                        // because that's the default, and 
    37473745                                        // it should have changed 
    3748                                         std::auto_ptr<BackupProtocolClientLoginConfirmed> loginConf(protocol->QueryLogin(0x01234567, 0)); 
     3746                                        std::auto_ptr<BackupProtocolLoginConfirmed> loginConf(protocol->QueryLogin(0x01234567, 0)); 
    37493747                                        TEST_THAT(loginConf->GetClientStoreMarker() != 0); 
    37503748                                         
     
    38243822                        std::auto_ptr<BackupProtocolClient> client =  
    38253823                                ConnectAndLogin(context, 
    3826                                 BackupProtocolClientLogin::Flags_ReadOnly); 
     3824                                BackupProtocolLogin::Flags_ReadOnly); 
    38273825 
    38283826                        // Check that the restore fn returns resume possible, 
Note: See TracChangeset for help on using the changeset viewer.