1
0

Event system changes

This commit is contained in:
Scott E. Graves
2017-04-12 00:36:21 -05:00
parent bf7fda99a6
commit 3f26144975
4 changed files with 395 additions and 14 deletions

View File

@@ -29,6 +29,7 @@ public:
virtual SString GetSingleLineMessage() const = 0;
virtual std::shared_ptr<CEvent> Clone() const = 0;
virtual SString GetEventName() const = 0;
virtual json GetEventJson() const = 0;
};
typedef std::shared_ptr<CEvent> CEventPtr;

View File

@@ -50,6 +50,16 @@ public:
{
return "SiaCurlBegin";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "type", _type },
{ "url", _url }
};
}
};
class SiaCurlEnd :
@@ -105,6 +115,18 @@ public:
{
return "SiaCurlEnd";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "type", _type },
{ "url", _url },
{ "code", _curlCode},
{ "reason", _siaCurlError.GetReason() }
};
}
};
CSiaCurl::CSiaCurl()

View File

@@ -45,6 +45,16 @@ public:
{
return "FileAddedToQueue";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath }
};
}
};
class ExternallyRemovedFileDetected :
@@ -84,6 +94,16 @@ public:
{
return "ExternallyRemovedFileDetected";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath }
};
}
};
class UploadToSiaStarted :
@@ -123,6 +143,16 @@ public:
{
return "UploadToSiaStarted";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath }
};
}
};
class UploadToSiaComplete :
@@ -162,6 +192,16 @@ public:
{
return "UploadToSiaComplete";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath }
};
}
};
class FileRemovedFromSia :
@@ -201,6 +241,16 @@ public:
{
return "FileRemovedFromSia";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath }
};
}
};
class FailedToRemoveFileFromSia :
@@ -243,6 +293,17 @@ public:
{
return "FailedToRemoveFileFromSia";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath },
{ "curl_error", _curlError.GetReason() }
};
}
};
class ModifyUploadStatusFailed :
@@ -288,6 +349,18 @@ public:
{
return "ModifyUploadStatusFailed";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath },
{ "status", CUploadManager::UploadStatusToString(_uploadStatus) },
{ "message", _errorMsg}
};
}
};
class DatabaseInsertFailed :
@@ -297,7 +370,7 @@ public:
DatabaseInsertFailed(const SString& siaPath, const SString& filePath, const SString& errorMessage) :
_siaPath(siaPath),
_filePath(filePath),
_errorMessage(errorMessage)
_errorMsg(errorMessage)
{
}
@@ -310,7 +383,7 @@ public:
private:
const SString _siaPath;
const SString _filePath;
const SString _errorMessage;
const SString _errorMsg;
public:
virtual SString GetSingleLineMessage() const override
@@ -318,18 +391,29 @@ public:
return GetEventName() +
"|SP|" + _siaPath +
"|FP|" + _filePath +
"|MSG|" + _errorMessage;
"|MSG|" + _errorMsg;
}
virtual std::shared_ptr<CEvent> Clone() const override
{
return std::shared_ptr<CEvent>(new DatabaseInsertFailed(_siaPath, _filePath, _errorMessage));
return std::shared_ptr<CEvent>(new DatabaseInsertFailed(_siaPath, _filePath, _errorMsg));
}
virtual SString GetEventName() const override
{
return "DatabaseInsertFailed";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath },
{ "message", _errorMsg }
};
}
};
class DatabaseDeleteFailed :
@@ -339,7 +423,7 @@ public:
DatabaseDeleteFailed(const SString& siaPath, const SString& filePath, const SString& errorMessage) :
_siaPath(siaPath),
_filePath(filePath),
_errorMessage(errorMessage)
_errorMsg(errorMessage)
{
}
@@ -352,7 +436,7 @@ public:
private:
const SString _siaPath;
const SString _filePath;
const SString _errorMessage;
const SString _errorMsg;
public:
virtual SString GetSingleLineMessage() const override
@@ -360,18 +444,29 @@ public:
return GetEventName() +
"|SP|" + _siaPath +
"|FP|" + _filePath +
"|MSG|" + _errorMessage;
"|MSG|" + _errorMsg;
}
virtual std::shared_ptr<CEvent> Clone() const override
{
return std::shared_ptr<CEvent>(new DatabaseDeleteFailed(_siaPath, _filePath, _errorMessage));
return std::shared_ptr<CEvent>(new DatabaseDeleteFailed(_siaPath, _filePath, _errorMsg));
}
virtual SString GetEventName() const override
{
return "DatabaseDeleteFailed";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath },
{ "message", _errorMsg }
};
}
};
class SourceFileNotFound :
@@ -411,6 +506,16 @@ public:
{
return "SourceFileNotFound";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "sia_path", _siaPath },
{ "file_path", _filePath }
};
}
};
class DatabaseExceptionOccurred :
@@ -450,6 +555,16 @@ public:
{
return "DatabaseExceptionOccurred";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "message", _exception.getErrorStr() },
{ "operation", _duringOperation }
};
}
};
#define TABLE_CREATE L"create table if not exists %s (%s);"

View File

@@ -75,6 +75,17 @@ private:
{
return "DownloadToCacheBegin";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", static_cast<SString>(_openFileInfo.CacheFilePath) },
{ "sia_path", _openFileInfo.SiaPath},
{ "temp_file_path", _tempFilePath}
};
}
};
class DownloadToCacheEnd :
@@ -101,7 +112,7 @@ private:
virtual SString GetSingleLineMessage() const override
{
return GetEventName() +
"|FP|" + _openFileInfo.CacheFilePath +
"|FP|" + static_cast<SString>(_openFileInfo.CacheFilePath) +
"|SP|" + _openFileInfo.SiaPath +
"|TP|" + _tempFilePath +
"|RES|" + SString::FromBool(_result);
@@ -116,6 +127,18 @@ private:
{
return "DownloadToCacheEnd";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", static_cast<SString>(_openFileInfo.CacheFilePath) },
{ "sia_path", _openFileInfo.SiaPath },
{ "temp_file_path", _tempFilePath },
{ "result", _result}
};
}
};
class MoveTempToCacheResult :
@@ -142,7 +165,7 @@ private:
virtual SString GetSingleLineMessage() const override
{
return GetEventName() +
"|FP|" + _openFileInfo.CacheFilePath +
"|FP|" + static_cast<SString>(_openFileInfo.CacheFilePath) +
"|SP|" + _openFileInfo.SiaPath +
"|TP|" + _tempFilePath +
"|RES|" + SString::FromBool(_result);
@@ -157,6 +180,18 @@ private:
{
return "MoveTempToCacheResult";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", static_cast<SString>(_openFileInfo.CacheFilePath) },
{ "sia_path", _openFileInfo.SiaPath },
{ "temp_file_path", _tempFilePath },
{ "result", _result }
};
}
};
class AddToCacheComplete :
@@ -181,7 +216,7 @@ private:
virtual SString GetSingleLineMessage() const override
{
return GetEventName() +
"|FP|" + _openFileInfo.CacheFilePath +
"|FP|" + static_cast<SString>(_openFileInfo.CacheFilePath) +
"|SP|" + _openFileInfo.SiaPath +
"|RES|" + SString::FromBool(_result);
}
@@ -195,6 +230,17 @@ private:
{
return "AddToCacheComplete";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", static_cast<SString>(_openFileInfo.CacheFilePath) },
{ "sia_path", _openFileInfo.SiaPath },
{ "result", _result }
};
}
};
class DriveMountEnded :
@@ -226,13 +272,23 @@ private:
{
return GetEventName() +
"|LOC|" + _mountLocation +
"|RET|" + SString::FromInt32(_result);
"|RES|" + SString::FromInt32(_result);
}
virtual SString GetEventName() const override
{
return "DriveMountEnded";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "mount_location", _mountLocation },
{ "result", _result }
};
}
};
class DriveUnMounted :
@@ -269,6 +325,15 @@ private:
{
return "DriveUnMounted";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "mount_location", _mountLocation }
};
}
};
class DriveMounted :
@@ -305,6 +370,15 @@ private:
{
return "DriveMounted";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "mount_location", _mountLocation }
};
}
};
class DokanCreateFile :
@@ -347,13 +421,26 @@ private:
"|ATTR|" + SString::FromUInt32(_fileAttributesAndFlags) +
"|DISP|" + SString::FromUInt32(_creationDisposition) +
"|MASK|" + SString::FromUInt32(_genericDesiredAccess) +
"|RET|" + SString::FromUInt32(_result);
"|RES|" + SString::FromUInt32(_result);
}
virtual SString GetEventName() const override
{
return "DokanCreateFile";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _filePath },
{ "attributes", _fileAttributesAndFlags},
{ "create_disposition", _creationDisposition},
{ "access_mask", _genericDesiredAccess},
{ "result", _result }
};
}
};
class DokanFindFiles :
@@ -398,13 +485,27 @@ private:
"|QUERY|" + _siaQuery +
"|FIND|" + _findFile +
"|FN|" + _fileName +
"|RET|" + SString::FromUInt32(_result);
"|RES|" + SString::FromUInt32(_result);
}
virtual SString GetEventName() const override
{
return "DokanFindFiles";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "root_path", _rootPath },
{ "sia_query", _siaQuery },
{ "find", _findFile },
{ "file_name", _fileName },
{ "result", _result }
};
}
};
class DokanCloseFile :
@@ -441,6 +542,15 @@ private:
{
return "DokanCloseFile";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath }
};
}
};
class DokanGetFileInformation :
@@ -486,6 +596,18 @@ private:
{
return "DokanGetFileInformation";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "file_name", _fileName },
{ "was_opened", _opened },
{ "result", _result }
};
}
};
class DokanReadFile :
@@ -528,6 +650,17 @@ private:
{
return "DokanReadFile";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "opened", _opened },
{ "result", _result }
};
}
};
class DokanWriteFile :
@@ -570,6 +703,17 @@ private:
{
return "DokanWriteFile";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "opened", _opened },
{ "result", _result }
};
}
};
class DokanSetEndOfFile :
@@ -609,6 +753,16 @@ private:
{
return "DokanSetEndOfFile";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanFlushFileBuffers :
@@ -648,6 +802,16 @@ private:
{
return "DokanFlushFileBuffers";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanDeleteDirectory :
@@ -686,6 +850,16 @@ private:
{
return "DokanDeleteDirectory";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanDeleteFileW :
@@ -725,6 +899,16 @@ private:
{
return "DokanDeleteFileW";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanSetFileAttributesW :
@@ -764,6 +948,16 @@ private:
{
return "DokanSetFileAttributesW";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanGetFileAttributesW :
@@ -800,6 +994,15 @@ private:
{
return "DokanGetFileAttributesW";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath }
};
}
};
class DokanSetFileSecurityW :
@@ -836,6 +1039,15 @@ private:
{
return "DokanSetFileSecurityW";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath }
};
}
};
class DokanSetFileTime :
@@ -875,6 +1087,16 @@ private:
{
return "DokanSetFileTime";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanSetAllocationSize :
@@ -914,6 +1136,16 @@ private:
{
return "DokanSetAllocationSize";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "file_path", _cachePath },
{ "result", _result }
};
}
};
class DokanMoveFileW :
@@ -956,6 +1188,17 @@ private:
{
return "DokanMoveFileW";
}
virtual json GetEventJson() const override
{
return
{
{ "event", GetEventName() },
{ "source_path", _srcPath },
{ "dest_path", _destPath },
{ "result", _result }
};
}
};
private: