From 444c137203eb2a6808ad9be69d76824865d7efb9 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 5 Apr 2017 12:31:39 -0500 Subject: [PATCH] Implement EventLevel --- include/siadrive_dokan_api/siadokandrive.h | 16 ++++++++++++- src/siadrive/main.cpp | 2 +- src/siadrive_dokan_api/siadokandrive.cpp | 26 +++++++++++----------- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/include/siadrive_dokan_api/siadokandrive.h b/include/siadrive_dokan_api/siadokandrive.h index dfdc51b..98e5935 100644 --- a/include/siadrive_dokan_api/siadokandrive.h +++ b/include/siadrive_dokan_api/siadokandrive.h @@ -154,6 +154,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanCreateFile : { public: DokanCreateFile(const SString& filePath, const DWORD& fileAttributesAndFlags, const DWORD& creationDisposition, const ACCESS_MASK& genericDesiredAccess, const NTSTATUS& returnStatus) : + CEvent(EventLevel::Debug), _filePath(filePath), _fileAttributesAndFlags(fileAttributesAndFlags), _creationDisposition(creationDisposition), @@ -197,6 +198,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanFindFiles : { public: DokanFindFiles(const SString& cachePath, const SString& rootPath, const SString& siaQuery, const SString& findFile, const SString& fileName) : + CEvent(EventLevel::Debug), _cachePath(cachePath), _rootPath(rootPath), _siaQuery(siaQuery), @@ -233,12 +235,12 @@ public: } }; - class SIADRIVE_DOKAN_EXPORTABLE DokanCloseFile : public CEvent { public: DokanCloseFile(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -269,6 +271,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanGetFileInformation : { public: DokanGetFileInformation(const SString& cachePath, const SString& fileName, const NTSTATUS& result) : + CEvent(EventLevel::Debug), _cachePath(cachePath), _fileName(fileName), _result(result) @@ -303,6 +306,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanReadFile : { public: DokanReadFile(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -333,6 +337,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanWriteFile : { public: DokanWriteFile(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -363,6 +368,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanSetEndOfFile : { public: DokanSetEndOfFile(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -393,6 +399,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanFlushFileBuffers : { public: DokanFlushFileBuffers(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -453,6 +460,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanDeleteFileW : { public: DokanDeleteFileW(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -483,6 +491,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanSetFileAttributesW : { public: DokanSetFileAttributesW(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -513,6 +522,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanGetFileAttributesW : { public: DokanGetFileAttributesW(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -543,6 +553,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanSetFileSecurityW : { public: DokanSetFileSecurityW(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -573,6 +584,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanSetFileTime : { public: DokanSetFileTime(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -603,6 +615,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanSetAllocationSize : { public: DokanSetAllocationSize(const SString& cachePath) : + CEvent(EventLevel::Debug), _cachePath(cachePath) { } @@ -633,6 +646,7 @@ class SIADRIVE_DOKAN_EXPORTABLE DokanMoveFileW : { public: DokanMoveFileW(const SString& srcPath, const SString& destPath) : + CEvent(EventLevel::Debug), _srcPath(srcPath), _destPath(destPath) { diff --git a/src/siadrive/main.cpp b/src/siadrive/main.cpp index 5d3f8d9..e883923 100644 --- a/src/siadrive/main.cpp +++ b/src/siadrive/main.cpp @@ -23,7 +23,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, CDebugConsumer debugConsumer; CLoggingConsumer loggingConsumer(EventLevel::Debug); #else - CLoggingConsumer loggingConsumer(EventLevel::Release); + CLoggingConsumer loggingConsumer(EventLevel::Normal); #endif CEventSystem::EventSystem.Start(); CefEnableHighDPISupport(); diff --git a/src/siadrive_dokan_api/siadokandrive.cpp b/src/siadrive_dokan_api/siadokandrive.cpp index 9c6bc54..5a8a992 100644 --- a/src/siadrive_dokan_api/siadokandrive.cpp +++ b/src/siadrive_dokan_api/siadokandrive.cpp @@ -119,7 +119,7 @@ private: static void HandleSiaFileClose(const OpenFileInfo& openFileInfo, const std::uint64_t& fileSize, const bool& deleteOnClose) { - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanCloseFile(openFileInfo.CacheFilePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanCloseFile(openFileInfo.CacheFilePath))); if (deleteOnClose) { // TODO Handle failure @@ -763,7 +763,7 @@ private: PDOKAN_FILE_INFO dokanFileInfo) { FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanReadFile(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanReadFile(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (openFileInfo && openFileInfo->Dummy) @@ -821,7 +821,7 @@ private: { // TODO Check dummy and add to cache if not found FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanWriteFile(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanWriteFile(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); BOOL opened = FALSE; @@ -931,7 +931,7 @@ private: // TODO Check dummy and add to cache if not found FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetEndOfFile(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetEndOfFile(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (!openFileInfo || !openFileInfo->FileHandle || (openFileInfo->FileHandle == INVALID_HANDLE_VALUE)) @@ -1011,7 +1011,7 @@ private: static NTSTATUS DOKAN_CALLBACK Sia_FlushFileBuffers(LPCWSTR fileName, PDOKAN_FILE_INFO dokanFileInfo) { FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFlushFileBuffers(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanFlushFileBuffers(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (!openFileInfo || !openFileInfo->FileHandle || (openFileInfo->FileHandle == INVALID_HANDLE_VALUE)) @@ -1033,7 +1033,7 @@ private: static NTSTATUS DOKAN_CALLBACK Sia_DeleteDirectory(LPCWSTR fileName, PDOKAN_FILE_INFO dokanFileInfo) { FilePath filePath = FilePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanDeleteDirectory(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanDeleteDirectory(filePath))); NTSTATUS ret = STATUS_SUCCESS; if (dokanFileInfo->DeleteOnClose) @@ -1080,7 +1080,7 @@ private: auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanDeleteFileW(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanDeleteFileW(filePath))); DWORD dwAttrib = ::GetFileAttributes(&filePath[0]); if ((dwAttrib != INVALID_FILE_ATTRIBUTES) && (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)) @@ -1107,7 +1107,7 @@ private: FilePath filePath(GetCacheLocation(), fileName); FilePath newFilePath(GetCacheLocation(), NewFileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanMoveFileW(filePath, newFilePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanMoveFileW(filePath, newFilePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (!openFileInfo || !openFileInfo->FileHandle || (openFileInfo->FileHandle == INVALID_HANDLE_VALUE)) @@ -1154,7 +1154,7 @@ private: NTSTATUS ret = STATUS_SUCCESS; FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetFileAttributesW(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetFileAttributesW(filePath))); if (!::SetFileAttributes(&filePath[0], fileAttributes)) { @@ -1172,7 +1172,7 @@ private: { UNREFERENCED_PARAMETER(dokanFileInfo); FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanGetFileAttributesW(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanGetFileAttributesW(filePath))); SECURITY_INFORMATION requestingSaclInfo = ((*securityInfo & SACL_SECURITY_INFORMATION) || (*securityInfo & BACKUP_SECURITY_INFORMATION)); //if (!g_HasSeSecurityPrivilege) { @@ -1223,7 +1223,7 @@ private: UNREFERENCED_PARAMETER(securityDescriptorLength); FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetFileSecurityW(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetFileSecurityW(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (!openFileInfo || !openFileInfo->FileHandle || (openFileInfo->FileHandle == INVALID_HANDLE_VALUE)) @@ -1245,7 +1245,7 @@ private: PDOKAN_FILE_INFO dokanFileInfo) { FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetFileTime(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetFileTime(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (!openFileInfo || !openFileInfo->FileHandle || (openFileInfo->FileHandle == INVALID_HANDLE_VALUE)) @@ -1267,7 +1267,7 @@ private: // TODO Check dummy and add to cache if not found NTSTATUS ret = STATUS_SUCCESS; FilePath filePath(GetCacheLocation(), fileName); - //CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetAllocationSize(filePath))); + CEventSystem::EventSystem.NotifyEvent(CreateSystemEvent(DokanSetAllocationSize(filePath))); auto openFileInfo = reinterpret_cast(dokanFileInfo->Context); if (!openFileInfo || !openFileInfo->FileHandle || (openFileInfo->FileHandle == INVALID_HANDLE_VALUE))