diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-08-21 10:41:18 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-08-21 10:41:18 +0000 |
commit | 2019b57dcbba43e8b3feba9385aec4a25bfa55b2 (patch) | |
tree | a669d280e5a15a760f70e4a707b0dbdf03c79dcb /bin/bbackupd/BackupClientDirectoryRecord.h | |
parent | aad61cfb4d89c65cafc698da5aa1b6b06a5a232c (diff) |
Pass a RunStatusProvider and a ReadLoggingStream::Logger from
BackupDaemon through BackupClientDirectoryRecord, BackupStoreFile and
BackupStoreFileEncodeStream to ReadLoggingStream, to allow progress
callbacks during file upload and cancelling upload part-way.
Implement ReadLoggingStream::Logger in
BackupClientDirectoryRecord::SyncParams, which thunks the notifications
back to the ProgressNotifier.
Add the SysadminNotifier interface from Boxi.
Add NotifyIDMapsSetup() to ProgressNotifier.
Change BackupClientDirectoryRecord::SyncParams to store references to
the individual callback interfaces rather than BackupDaemon.
Initialise all members in BackupDaemon.
Add ability for BackupDaemon user to override the ProgressNotifier,
LocationResolver, SysadminNotifier and RunStatusProvider that will be
used during the backup.
Make BackupDaemon::Location class public and provide access to the
configured locations for Boxi (dangerous, they could be modified without
BackupDaemon knowing it).
Diffstat (limited to 'bin/bbackupd/BackupClientDirectoryRecord.h')
-rw-r--r-- | bin/bbackupd/BackupClientDirectoryRecord.h | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.h b/bin/bbackupd/BackupClientDirectoryRecord.h index 472005b6..9a9cd2cb 100644 --- a/bin/bbackupd/BackupClientDirectoryRecord.h +++ b/bin/bbackupd/BackupClientDirectoryRecord.h @@ -13,10 +13,12 @@ #include <string> #include <map> -#include "BoxTime.h" #include "BackupClientFileAttributes.h" #include "BackupStoreDirectory.h" +#include "BoxTime.h" #include "MD5Digest.h" +#include "ReadLoggingStream.h" +#include "RunStatusProvider.h" class Archive; class BackupClientContext; @@ -25,6 +27,21 @@ class BackupDaemon; // -------------------------------------------------------------------------- // // Class +// Name: SysadminNotifier +// Purpose: Provides a NotifySysadmin() method to send mail to the sysadmin +// Created: 2005/11/15 +// +// -------------------------------------------------------------------------- +class SysadminNotifier +{ + public: + virtual ~SysadminNotifier() { } + virtual void NotifySysadmin(int Event) = 0; +}; + +// -------------------------------------------------------------------------- +// +// Class // Name: ProgressNotifier // Purpose: Provides methods for the backup library to inform the user // interface about its progress with the backup @@ -37,6 +54,7 @@ class ProgressNotifier { public: virtual ~ProgressNotifier() { } + virtual void NotifyIDMapsSetup(BackupClientContext& rContext) = 0; virtual void NotifyScanDirectory( const BackupClientDirectoryRecord* pDirRecord, const std::string& rLocalPath) = 0; @@ -102,6 +120,11 @@ class ProgressNotifier virtual void NotifyFileDeleted( int64_t ObjectID, const std::string& rRemotePath) = 0; + virtual void NotifyReadProgress(int64_t readSize, int64_t offset, + int64_t length, box_time_t elapsed, box_time_t finish) = 0; + virtual void NotifyReadProgress(int64_t readSize, int64_t offset, + int64_t length) = 0; + virtual void NotifyReadProgress(int64_t readSize, int64_t offset) = 0; }; // -------------------------------------------------------------------------- @@ -138,11 +161,13 @@ public: // Created: 8/3/04 // // -------------------------------------------------------------------------- - class SyncParams + class SyncParams : public ReadLoggingStream::Logger { public: SyncParams( - BackupDaemon &rDaemon, + RunStatusProvider &rRunStatusProvider, + SysadminNotifier &rSysadminNotifier, + ProgressNotifier &rProgressNotifier, BackupClientContext &rContext); ~SyncParams(); private: @@ -158,13 +183,43 @@ public: box_time_t mMaxFileTimeInFuture; int32_t mFileTrackingSizeThreshold; int32_t mDiffingUploadSizeThreshold; - BackupDaemon &mrDaemon; + RunStatusProvider &mrRunStatusProvider; + SysadminNotifier &mrSysadminNotifier; + ProgressNotifier &mrProgressNotifier; BackupClientContext &mrContext; bool mReadErrorsOnFilesystemObjects; // Member variables modified by syncing process box_time_t mUploadAfterThisTimeInTheFuture; bool mHaveLoggedWarningAboutFutureFileTimes; + + bool StopRun() { return mrRunStatusProvider.StopRun(); } + void NotifySysadmin(int Event) + { + mrSysadminNotifier.NotifySysadmin(Event); + } + ProgressNotifier& GetProgressNotifier() const + { + return mrProgressNotifier; + } + + /* ReadLoggingStream::Logger implementation */ + virtual void Log(int64_t readSize, int64_t offset, + int64_t length, box_time_t elapsed, box_time_t finish) + { + mrProgressNotifier.NotifyReadProgress(readSize, offset, + length, elapsed, finish); + } + virtual void Log(int64_t readSize, int64_t offset, + int64_t length) + { + mrProgressNotifier.NotifyReadProgress(readSize, offset, + length); + } + virtual void Log(int64_t readSize, int64_t offset) + { + mrProgressNotifier.NotifyReadProgress(readSize, offset); + } }; void SyncDirectory(SyncParams &rParams, |