From e8ef11cef43082dd5ba1fb973ba1cda5828b0fb7 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 23 Jan 2025 14:54:59 -0600 Subject: [PATCH] refactor event system --- .../include/drives/fuse/events.hpp | 41 --- .../include/drives/fuse/fuse_base.hpp | 241 ++++++++-------- .../drives/fuse/remotefuse/remote_client.hpp | 2 +- .../fuse/remotefuse/remote_fuse_drive.hpp | 2 +- .../drives/remote/remote_server_base.hpp | 15 +- .../remotewinfsp/remote_winfsp_drive.hpp | 6 +- .../include/drives/winfsp/winfsp_drive.hpp | 6 +- .../events/consumers/console_consumer.hpp | 5 +- .../events/consumers/logging_consumer.hpp | 7 +- .../librepertory/include/events/event.hpp | 59 ---- .../include/events/event_system.hpp | 232 --------------- .../include/events/event_system2.hpp | 1 + .../librepertory/include/events/events.hpp | 268 +++++------------- .../include/events/t_event_system.hpp | 249 ---------------- .../include/events/types/file_pinned.hpp | 68 +++++ .../events/types/file_remove_failed.hpp | 76 +++++ .../include/events/types/file_removed.hpp | 68 +++++ .../events/types/file_removed_externally.hpp | 77 +++++ .../include/events/types/file_unpinned.hpp | 68 +++++ .../events/types/file_upload_completed.hpp | 87 ++++++ .../events/types/file_upload_failed.hpp | 79 ++++++ .../events/types/file_upload_not_found.hpp | 76 +++++ .../events/types/file_upload_queued.hpp | 75 +++++ .../events/types/file_upload_removed.hpp | 69 +++++ .../events/types/file_upload_retry.hpp | 78 +++++ .../events/types/filesystem_item_added.hpp | 80 ++++++ .../events/types/filesystem_item_closed.hpp | 86 ++++++ .../events/types/filesystem_item_evicted.hpp | 77 +++++ .../types/filesystem_item_handle_closed.hpp | 91 ++++++ .../types/filesystem_item_handle_opened.hpp | 85 ++++++ .../events/types/filesystem_item_opened.hpp | 81 ++++++ .../events/types/orphaned_file_detected.hpp | 71 +++++ .../types/orphaned_file_processing_failed.hpp | 82 ++++++ .../types/orphaned_source_file_detected.hpp | 71 +++++ .../types/orphaned_source_file_removed.hpp | 71 +++++ .../events/types/polling_item_begin.hpp | 69 +++++ .../include/events/types/polling_item_end.hpp | 68 +++++ .../include/events/types/provider_offline.hpp | 74 +++++ .../events/types/provider_upload_begin.hpp | 76 +++++ .../events/types/provider_upload_end.hpp | 80 ++++++ .../events/types/repertory_exception.hpp | 68 +++++ .../events/types/service_start_begin.hpp | 70 +++++ .../events/types/service_start_end.hpp | 68 +++++ .../events/types/service_stop_begin.hpp | 69 +++++ .../include/events/types/service_stop_end.hpp | 68 +++++ .../include/file_manager/events.hpp | 86 ------ .../include/file_manager/file_manager.hpp | 6 +- .../librepertory/include/types/repertory.hpp | 2 + .../src/comm/packet/client_pool.cpp | 15 +- .../src/comm/packet/packet_client.cpp | 6 +- .../src/comm/packet/packet_server.cpp | 14 +- .../src/drives/fuse/fuse_base.cpp | 20 +- .../src/drives/fuse/fuse_drive.cpp | 2 - .../src/drives/fuse/fuse_drive_base.cpp | 37 +-- .../fuse/remotefuse/remote_fuse_drive.cpp | 5 +- .../drives/fuse/remotefuse/remote_server.cpp | 4 +- .../drives/remote/remote_open_file_table.cpp | 3 +- .../winfsp/remotewinfsp/remote_client.cpp | 3 +- .../winfsp/remotewinfsp/remote_server.cpp | 5 +- .../remotewinfsp/remote_winfsp_drive.cpp | 3 +- .../src/drives/winfsp/winfsp_drive.cpp | 11 +- .../src/events/consumers/console_consumer.cpp | 30 +- .../src/events/consumers/logging_consumer.cpp | 31 +- .../src/events/t_event_system.cpp | 36 --- .../src/file_manager/cache_size_mgr.cpp | 6 +- .../src/file_manager/file_manager.cpp | 104 ++++--- .../src/file_manager/open_file.cpp | 9 +- .../src/file_manager/open_file_base.cpp | 41 ++- .../src/file_manager/ring_buffer_base.cpp | 9 +- .../librepertory/src/file_manager/upload.cpp | 9 +- .../src/platform/unix_platform.cpp | 10 +- .../src/platform/win32_platform.cpp | 14 +- .../src/providers/base_provider.cpp | 71 +++-- .../providers/encrypt/encrypt_provider.cpp | 27 +- .../src/providers/s3/s3_provider.cpp | 17 +- .../src/providers/sia/sia_provider.cpp | 16 +- .../src/rpc/server/full_server.cpp | 29 +- .../librepertory/src/rpc/server/server.cpp | 29 +- .../librepertory/src/utils/error_utils.cpp | 125 ++++---- repertory/librepertory/src/utils/polling.cpp | 25 +- .../src/utils/single_thread_service_base.cpp | 14 +- .../include/fixtures/file_db_fixture.hpp | 2 +- .../include/fixtures/file_mgr_db_fixture.hpp | 2 +- .../include/fixtures/meta_db_fixture.hpp | 2 +- .../repertory_test/include/test_common.hpp | 2 - .../include/utils/event_capture.hpp | 6 +- repertory/repertory_test/src/config_test.cpp | 2 +- .../repertory_test/src/file_manager_test.cpp | 112 ++++---- .../repertory_test/src/providers_test.cpp | 2 +- 89 files changed, 2986 insertions(+), 1478 deletions(-) delete mode 100644 repertory/librepertory/include/drives/fuse/events.hpp delete mode 100644 repertory/librepertory/include/events/event.hpp delete mode 100644 repertory/librepertory/include/events/event_system.hpp delete mode 100644 repertory/librepertory/include/events/t_event_system.hpp create mode 100644 repertory/librepertory/include/events/types/file_pinned.hpp create mode 100644 repertory/librepertory/include/events/types/file_remove_failed.hpp create mode 100644 repertory/librepertory/include/events/types/file_removed.hpp create mode 100644 repertory/librepertory/include/events/types/file_removed_externally.hpp create mode 100644 repertory/librepertory/include/events/types/file_unpinned.hpp create mode 100644 repertory/librepertory/include/events/types/file_upload_completed.hpp create mode 100644 repertory/librepertory/include/events/types/file_upload_failed.hpp create mode 100644 repertory/librepertory/include/events/types/file_upload_not_found.hpp create mode 100644 repertory/librepertory/include/events/types/file_upload_queued.hpp create mode 100644 repertory/librepertory/include/events/types/file_upload_removed.hpp create mode 100644 repertory/librepertory/include/events/types/file_upload_retry.hpp create mode 100644 repertory/librepertory/include/events/types/filesystem_item_added.hpp create mode 100644 repertory/librepertory/include/events/types/filesystem_item_closed.hpp create mode 100644 repertory/librepertory/include/events/types/filesystem_item_evicted.hpp create mode 100644 repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp create mode 100644 repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp create mode 100644 repertory/librepertory/include/events/types/filesystem_item_opened.hpp create mode 100644 repertory/librepertory/include/events/types/orphaned_file_detected.hpp create mode 100644 repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp create mode 100644 repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp create mode 100644 repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp create mode 100644 repertory/librepertory/include/events/types/polling_item_begin.hpp create mode 100644 repertory/librepertory/include/events/types/polling_item_end.hpp create mode 100644 repertory/librepertory/include/events/types/provider_offline.hpp create mode 100644 repertory/librepertory/include/events/types/provider_upload_begin.hpp create mode 100644 repertory/librepertory/include/events/types/provider_upload_end.hpp create mode 100644 repertory/librepertory/include/events/types/repertory_exception.hpp create mode 100644 repertory/librepertory/include/events/types/service_start_begin.hpp create mode 100644 repertory/librepertory/include/events/types/service_start_end.hpp create mode 100644 repertory/librepertory/include/events/types/service_stop_begin.hpp create mode 100644 repertory/librepertory/include/events/types/service_stop_end.hpp delete mode 100644 repertory/librepertory/include/file_manager/events.hpp delete mode 100644 repertory/librepertory/src/events/t_event_system.cpp diff --git a/repertory/librepertory/include/drives/fuse/events.hpp b/repertory/librepertory/include/drives/fuse/events.hpp deleted file mode 100644 index 822a4a9f..00000000 --- a/repertory/librepertory/include/drives/fuse/events.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_ -#define REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_ - -#include "events/event_system.hpp" - -namespace repertory { -// clang-format off -E_SIMPLE3(fuse_event, debug, - std::string, function, func, E_FROM_STRING, - std::string, api_path, ap, E_FROM_STRING, - int, result, res, E_FROM_INT32 -); - -E_SIMPLE1(fuse_args_parsed, info, - std::string, arguments, args, E_FROM_STRING -); -// clang-format on -} // namespace repertory - -#endif // REPERTORY_INCLUDE_DRIVES_FUSE_EVENTS_HPP_ diff --git a/repertory/librepertory/include/drives/fuse/fuse_base.hpp b/repertory/librepertory/include/drives/fuse/fuse_base.hpp index 092a7b6a..fb49632e 100644 --- a/repertory/librepertory/include/drives/fuse/fuse_base.hpp +++ b/repertory/librepertory/include/drives/fuse/fuse_base.hpp @@ -23,7 +23,7 @@ #define REPERTORY_INCLUDE_DRIVES_FUSE_FUSE_BASE_HPP_ #if !defined(_WIN32) -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "utils/path.hpp" namespace repertory { @@ -31,7 +31,7 @@ class app_config; class i_provider; class fuse_base { - E_CONSUMER(); + E_CONSUMER2(); public: explicit fuse_base(app_config &config); @@ -61,7 +61,7 @@ private: static auto instance() -> fuse_base &; private: - struct fuse_operations fuse_ops_ {}; + struct fuse_operations fuse_ops_{}; private: [[nodiscard]] auto @@ -78,9 +78,9 @@ private: static void execute_void_callback(std::string_view function_name, const std::function &cb); - static auto - execute_void_pointer_callback(std::string_view function_name, - const std::function &cb) -> void *; + static auto execute_void_pointer_callback(std::string_view function_name, + const std::function &cb) + -> void *; void raise_fuse_event(std::string_view function_name, std::string_view api_path, int ret, @@ -104,8 +104,8 @@ private: [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi) -> int; #else - [[nodiscard]] static auto chown_(const char *path, uid_t uid, - gid_t gid) -> int; + [[nodiscard]] static auto chown_(const char *path, uid_t uid, gid_t gid) + -> int; #endif [[nodiscard]] static auto create_(const char *path, mode_t mode, @@ -114,8 +114,8 @@ private: static void destroy_(void *ptr); [[nodiscard]] static auto fallocate_(const char *path, int mode, off_t offset, - off_t length, - struct fuse_file_info *fi) -> int; + off_t length, struct fuse_file_info *fi) + -> int; #if FUSE_USE_VERSION < 30 [[nodiscard]] static auto fgetattr_(const char *path, struct stat *st, @@ -156,8 +156,8 @@ private: [[nodiscard]] static auto mkdir_(const char *path, mode_t mode) -> int; - [[nodiscard]] static auto open_(const char *path, - struct fuse_file_info *fi) -> int; + [[nodiscard]] static auto open_(const char *path, struct fuse_file_info *fi) + -> int; [[nodiscard]] static auto opendir_(const char *path, struct fuse_file_info *fi) -> int; @@ -174,8 +174,8 @@ private: #else [[nodiscard]] static auto readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, - off_t offset, - struct fuse_file_info *fi) -> int; + off_t offset, struct fuse_file_info *fi) + -> int; #endif [[nodiscard]] static auto release_(const char *path, @@ -207,8 +207,8 @@ private: [[nodiscard]] static auto listxattr_(const char *path, char *buffer, size_t size) -> int; - [[nodiscard]] static auto removexattr_(const char *path, - const char *name) -> int; + [[nodiscard]] static auto removexattr_(const char *path, const char *name) + -> int; #if defined(__APPLE__) [[nodiscard]] static auto setxattr_(const char *path, const char *name, @@ -217,17 +217,18 @@ private: #else // __APPLE__ [[nodiscard]] static auto setxattr_(const char *path, const char *name, - const char *value, size_t size, - int flags) -> int; + const char *value, size_t size, int flags) + -> int; #endif // __APPLE__ #endif // HAS_SETXATTR #if defined(__APPLE__) - [[nodiscard]] static auto setattr_x_(const char *path, - struct setattr_x *attr) -> int; + [[nodiscard]] static auto setattr_x_(const char *path, struct setattr_x *attr) + -> int; - [[nodiscard]] static auto - setbkuptime_(const char *path, const struct timespec *bkuptime) -> int; + [[nodiscard]] static auto setbkuptime_(const char *path, + const struct timespec *bkuptime) + -> int; [[nodiscard]] static auto setchgtime_(const char *path, const struct timespec *chgtime) -> int; @@ -237,12 +238,12 @@ private: [[nodiscard]] static auto setvolname_(const char *volname) -> int; - [[nodiscard]] static auto statfs_x_(const char *path, - struct statfs *stbuf) -> int; + [[nodiscard]] static auto statfs_x_(const char *path, struct statfs *stbuf) + -> int; #else // __APPLE__ - [[nodiscard]] static auto statfs_(const char *path, - struct statvfs *stbuf) -> int; + [[nodiscard]] static auto statfs_(const char *path, struct statvfs *stbuf) + -> int; #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 @@ -268,8 +269,8 @@ private: struct fuse_file_info *fi) -> int; protected: - [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, - int /*mask*/) -> api_error { + [[nodiscard]] virtual auto access_impl(std::string /*api_path*/, int /*mask*/) + -> api_error { return api_error::not_implemented; } @@ -281,9 +282,10 @@ protected: #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto - chmod_impl(std::string /*api_path*/, mode_t /*mode*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto chmod_impl(std::string /*api_path*/, + mode_t /*mode*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #else @@ -294,9 +296,10 @@ protected: #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto - chown_impl(std::string /*api_path*/, uid_t /*uid*/, gid_t /*gid*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto chown_impl(std::string /*api_path*/, uid_t /*uid*/, + gid_t /*gid*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #else @@ -306,9 +309,10 @@ protected: } #endif - [[nodiscard]] virtual auto - create_impl(std::string /*api_path*/, mode_t /*mode*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto create_impl(std::string /*api_path*/, + mode_t /*mode*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } @@ -316,43 +320,48 @@ protected: [[nodiscard]] virtual auto fallocate_impl(std::string /*api_path*/, int /*mode*/, off_t /*offset*/, - off_t /*length*/, - struct fuse_file_info * /*fi*/) -> api_error { + off_t /*length*/, struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto - fgetattr_impl(std::string /*api_path*/, struct stat * /*st*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto fgetattr_impl(std::string /*api_path*/, + struct stat * /*st*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #if defined(__APPLE__) - [[nodiscard]] virtual auto - fsetattr_x_impl(std::string /*api_path*/, struct setattr_x * /*attr*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto fsetattr_x_impl(std::string /*api_path*/, + struct setattr_x * /*attr*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #endif // __APPLE__ - [[nodiscard]] virtual auto - fsync_impl(std::string /*api_path*/, int /*datasync*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto fsync_impl(std::string /*api_path*/, + int /*datasync*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #if FUSE_USE_VERSION < 30 - [[nodiscard]] virtual auto - ftruncate_impl(std::string /*api_path*/, off_t /*size*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto ftruncate_impl(std::string /*api_path*/, + off_t /*size*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #endif #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto - getattr_impl(std::string /*api_path*/, struct stat * /*st*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto getattr_impl(std::string /*api_path*/, + struct stat * /*st*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #else @@ -363,16 +372,17 @@ protected: #endif #if defined(__APPLE__) - [[nodiscard]] virtual auto - getxtimes_impl(std::string /*api_path*/, struct timespec * /*bkuptime*/, - struct timespec * /*crtime*/) -> api_error { + [[nodiscard]] virtual auto getxtimes_impl(std::string /*api_path*/, + struct timespec * /*bkuptime*/, + struct timespec * /*crtime*/) + -> api_error { return api_error::not_implemented; } #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - virtual auto init_impl(struct fuse_conn_info *conn, - struct fuse_config *cfg) -> void *; + virtual auto init_impl(struct fuse_conn_info *conn, struct fuse_config *cfg) + -> void *; #else virtual auto init_impl(struct fuse_conn_info *conn) -> void *; #endif @@ -382,15 +392,15 @@ protected: return api_error::not_implemented; } - [[nodiscard]] virtual auto - open_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto open_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto - opendir_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto opendir_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } @@ -405,8 +415,8 @@ protected: [[nodiscard]] virtual auto readdir_impl(std::string /*api_path*/, void * /*buf*/, fuse_fill_dir_t /*fuse_fill_dir*/, off_t /*offset*/, - struct fuse_file_info * /*fi*/, - fuse_readdir_flags /*flags*/) -> api_error { + struct fuse_file_info * /*fi*/, fuse_readdir_flags /*flags*/) + -> api_error { return api_error::not_implemented; } #else @@ -418,15 +428,15 @@ protected: } #endif - [[nodiscard]] virtual auto - release_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto release_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto - releasedir_impl(std::string /*api_path*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto releasedir_impl(std::string /*api_path*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } @@ -437,9 +447,9 @@ protected: return api_error::not_implemented; } #else - [[nodiscard]] virtual auto - rename_impl(std::string /*from_api_path*/, - std::string /*to_api_path*/) -> api_error { + [[nodiscard]] virtual auto rename_impl(std::string /*from_api_path*/, + std::string /*to_api_path*/) + -> api_error { return api_error::not_implemented; } #endif @@ -459,8 +469,8 @@ protected: #else // __APPLE__ [[nodiscard]] virtual auto getxattr_impl(std::string /*api_path*/, const char * /*name*/, - char * /*value*/, size_t /*size*/, - int & /*attribute_size*/) -> api_error { + char * /*value*/, size_t /*size*/, int & /*attribute_size*/) + -> api_error { return api_error::not_implemented; } #endif // __APPLE__ @@ -471,9 +481,9 @@ protected: return api_error::not_implemented; } - [[nodiscard]] virtual auto - removexattr_impl(std::string /*api_path*/, - const char * /*name*/) -> api_error { + [[nodiscard]] virtual auto removexattr_impl(std::string /*api_path*/, + const char * /*name*/) + -> api_error { return api_error::not_implemented; } @@ -486,20 +496,19 @@ protected: return api_error::not_implemented; } #else // __APPLE__ - [[nodiscard]] virtual auto setxattr_impl(std::string /*api_path*/, - const char * /*name*/, - const char * /*value*/, - size_t /*size*/, - int /*flags*/) -> api_error { + [[nodiscard]] virtual auto + setxattr_impl(std::string /*api_path*/, const char * /*name*/, + const char * /*value*/, size_t /*size*/, int /*flags*/) + -> api_error { return api_error::not_implemented; } #endif // __APPLE__ #endif // HAS_SETXATTR #if defined(__APPLE__) - [[nodiscard]] virtual auto - setattr_x_impl(std::string /*api_path*/, - struct setattr_x * /*attr*/) -> api_error { + [[nodiscard]] virtual auto setattr_x_impl(std::string /*api_path*/, + struct setattr_x * /*attr*/) + -> api_error { return api_error::not_implemented; } @@ -510,39 +519,40 @@ protected: } [[nodiscard]] virtual auto - setchgtime_impl(std::string /*api_path*/, - const struct timespec * /*chgtime*/) -> api_error { + setchgtime_impl(std::string /*api_path*/, const struct timespec * /*chgtime*/) + -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto - setcrtime_impl(std::string /*api_path*/, - const struct timespec * /*crtime*/) -> api_error { + [[nodiscard]] virtual auto setcrtime_impl(std::string /*api_path*/, + const struct timespec * /*crtime*/) + -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto - setvolname_impl(const char * /*volname*/) -> api_error { + [[nodiscard]] virtual auto setvolname_impl(const char * /*volname*/) + -> api_error { return api_error::not_implemented; } - [[nodiscard]] virtual auto - statfs_x_impl(std::string /*api_path*/, - struct statfs * /*stbuf*/) -> api_error { + [[nodiscard]] virtual auto statfs_x_impl(std::string /*api_path*/, + struct statfs * /*stbuf*/) + -> api_error { return api_error::not_implemented; } #else // __APPLE__ - [[nodiscard]] virtual auto - statfs_impl(std::string /*api_path*/, - struct statvfs * /*stbuf*/) -> api_error { + [[nodiscard]] virtual auto statfs_impl(std::string /*api_path*/, + struct statvfs * /*stbuf*/) + -> api_error { return api_error::not_implemented; } #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto - truncate_impl(std::string /*api_path*/, off_t /*size*/, - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto truncate_impl(std::string /*api_path*/, + off_t /*size*/, + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #else @@ -552,21 +562,22 @@ protected: } #endif - [[nodiscard]] virtual auto - unlink_impl(std::string /*api_path*/) -> api_error { + [[nodiscard]] virtual auto unlink_impl(std::string /*api_path*/) + -> api_error { return api_error::not_implemented; } #if FUSE_USE_VERSION >= 30 - [[nodiscard]] virtual auto - utimens_impl(std::string /*api_path*/, const struct timespec /*tv*/[2], - struct fuse_file_info * /*fi*/) -> api_error { + [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, + const struct timespec /*tv*/[2], + struct fuse_file_info * /*fi*/) + -> api_error { return api_error::not_implemented; } #else - [[nodiscard]] virtual auto - utimens_impl(std::string /*api_path*/, - const struct timespec /*tv*/[2]) -> api_error { + [[nodiscard]] virtual auto utimens_impl(std::string /*api_path*/, + const struct timespec /*tv*/[2]) + -> api_error { return api_error::not_implemented; } #endif @@ -574,8 +585,8 @@ protected: [[nodiscard]] virtual auto write_impl(std::string /*api_path*/, const char * /*buffer*/, size_t /*write_size*/, off_t /*write_offset*/, - struct fuse_file_info * /*fi*/, - std::size_t & /*bytes_written*/) -> api_error { + struct fuse_file_info * /*fi*/, std::size_t & /*bytes_written*/) + -> api_error { return api_error::not_implemented; } diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp index 494ee16c..ad963d76 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_client.hpp @@ -24,7 +24,7 @@ #include "comm/packet/packet_client.hpp" #include "drives/fuse/remotefuse/i_remote_instance.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "types/remote.hpp" namespace repertory { diff --git a/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp b/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp index aef87cc2..f93ada84 100644 --- a/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp +++ b/repertory/librepertory/include/drives/fuse/remotefuse/remote_fuse_drive.hpp @@ -25,7 +25,7 @@ #include "drives/fuse/fuse_base.hpp" #include "drives/fuse/remotefuse/i_remote_instance.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" namespace repertory { class app_config; diff --git a/repertory/librepertory/include/drives/remote/remote_server_base.hpp b/repertory/librepertory/include/drives/remote/remote_server_base.hpp index af26aaf8..c514636d 100644 --- a/repertory/librepertory/include/drives/remote/remote_server_base.hpp +++ b/repertory/librepertory/include/drives/remote/remote_server_base.hpp @@ -29,8 +29,11 @@ #include "drives/fuse/remotefuse/i_remote_instance.hpp" #include "drives/remote/remote_open_file_table.hpp" #include "drives/winfsp/remotewinfsp/i_remote_instance.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "types/remote.hpp" #include "types/repertory.hpp" #include "utils/base64.hpp" @@ -55,7 +58,7 @@ public: drive_(drv), mount_location_(std::move(mount_location)), client_pool_(config.get_remote_mount().client_pool_size) { - event_system::instance().raise("remote_server_base"); + event_system2::instance().raise("remote_server_base"); handler_lookup_.insert( {"::winfsp_can_delete", [this](std::uint32_t, const std::string &, std::uint64_t, @@ -1372,14 +1375,14 @@ public: method, request, response, message_complete); }); + event_system2::instance().raise("remote_server_base"); } ~remote_server_base() override { - event_system::instance().raise( - "remote_server_base"); + event_system2::instance().raise("remote_server_base"); client_pool_.shutdown(); packet_server_.reset(); - event_system::instance().raise("remote_server_base"); + event_system2::instance().raise("remote_server_base"); } public: diff --git a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp index 4da2c416..dd3ea5e0 100644 --- a/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp @@ -24,7 +24,7 @@ #if defined(_WIN32) #include "drives/winfsp/remotewinfsp/i_remote_instance.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" namespace repertory { class app_config; @@ -32,13 +32,13 @@ class lock_data; class server; namespace remote_winfsp { class remote_winfsp_drive final : public virtual FileSystemBase { - E_CONSUMER(); + E_CONSUMER2(); public: remote_winfsp_drive(app_config &config, remote_instance_factory factory, lock_data &lock); - ~remote_winfsp_drive() override { E_CONSUMER_RELEASE(); } + ~remote_winfsp_drive() override { E_CONSUMER2_RELEASE(); } public: class winfsp_service : virtual public Service { diff --git a/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp b/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp index 4609f40d..eea8ded4 100644 --- a/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp +++ b/repertory/librepertory/include/drives/winfsp/winfsp_drive.hpp @@ -26,7 +26,7 @@ #include "drives/eviction.hpp" #include "drives/winfsp/i_winfsp_drive.hpp" #include "drives/winfsp/remotewinfsp/remote_server.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "file_manager/file_manager.hpp" #include "rpc/server/full_server.hpp" @@ -37,12 +37,12 @@ class i_provider; class winfsp_drive final : public virtual i_winfsp_drive, public virtual FileSystemBase { - E_CONSUMER(); + E_CONSUMER2(); public: winfsp_drive(app_config &config, lock_data &lockData, i_provider &provider); - ~winfsp_drive() override { E_CONSUMER_RELEASE(); } + ~winfsp_drive() override { E_CONSUMER2_RELEASE(); } private: class winfsp_service final : virtual public Service { diff --git a/repertory/librepertory/include/events/consumers/console_consumer.hpp b/repertory/librepertory/include/events/consumers/console_consumer.hpp index 825ffc18..401d1c56 100644 --- a/repertory/librepertory/include/events/consumers/console_consumer.hpp +++ b/repertory/librepertory/include/events/consumers/console_consumer.hpp @@ -22,12 +22,11 @@ #ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_ #define REPERTORY_INCLUDE_EVENTS_CONSUMERS_CONSOLE_CONSUMER_HPP_ -#include "events/event_system.hpp" #include "events/event_system2.hpp" +#include "types/repertory.hpp" namespace repertory { class console_consumer final { - E_CONSUMER(); E_CONSUMER2(); public: @@ -38,8 +37,6 @@ public: ~console_consumer(); private: - static void process_event(const event &evt); - static void process_event2(const i_event &evt); }; } // namespace repertory diff --git a/repertory/librepertory/include/events/consumers/logging_consumer.hpp b/repertory/librepertory/include/events/consumers/logging_consumer.hpp index 3b2a8071..535c5518 100644 --- a/repertory/librepertory/include/events/consumers/logging_consumer.hpp +++ b/repertory/librepertory/include/events/consumers/logging_consumer.hpp @@ -22,12 +22,11 @@ #ifndef REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_ #define REPERTORY_INCLUDE_EVENTS_CONSUMERS_LOGGING_CONSUMER_HPP_ -#include "events/event_system.hpp" #include "events/event_system2.hpp" +#include "types/repertory.hpp" namespace repertory { -class logging_consumer { - E_CONSUMER(); +class logging_consumer final { E_CONSUMER2(); public: @@ -41,8 +40,6 @@ private: 5ULL}; private: - static void process_event(const event &evt); - static void process_event2(const i_event &evt); }; } // namespace repertory diff --git a/repertory/librepertory/include/events/event.hpp b/repertory/librepertory/include/events/event.hpp deleted file mode 100644 index ce46a887..00000000 --- a/repertory/librepertory/include/events/event.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef REPERTORY_INCLUDE_EVENTS_EVENT_HPP_ -#define REPERTORY_INCLUDE_EVENTS_EVENT_HPP_ - -#include "types/repertory.hpp" - -namespace repertory { -class event { -protected: - event() = default; - - event(const std::stringstream &ss, json j) - : ss_(ss.str()), j_(std::move(j)) {} - -public: - event(const event &) = delete; - event(event &&) = delete; - auto operator=(const event &) -> event & = delete; - auto operator=(event &&) -> event & = delete; - virtual ~event() = default; - -protected: - std::stringstream ss_; - json j_{}; - -public: - [[nodiscard]] virtual auto clone() const -> std::shared_ptr = 0; - - [[nodiscard]] virtual auto get_event_level() const -> event_level = 0; - - [[nodiscard]] auto get_json() const -> json { return j_; } - - [[nodiscard]] virtual auto get_name() const -> std::string = 0; - - [[nodiscard]] virtual auto get_single_line() const -> std::string = 0; -}; -} // namespace repertory - -#endif // REPERTORY_INCLUDE_EVENTS_EVENT_HPP_ diff --git a/repertory/librepertory/include/events/event_system.hpp b/repertory/librepertory/include/events/event_system.hpp deleted file mode 100644 index 4c73f35a..00000000 --- a/repertory/librepertory/include/events/event_system.hpp +++ /dev/null @@ -1,232 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_ -#define REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_ - -#include "events/event.hpp" -#include "events/t_event_system.hpp" -#include "types/repertory.hpp" - -namespace repertory { -using event_system = t_event_system; -using event_consumer = event_system::event_consumer; - -#define E_FROM_API_FILE_ERROR(e) api_error_to_string(e) -#define E_FROM_BOOL(t) std::to_string(t) -#define E_FROM_CURL_CODE(t) std::string(curl_easy_strerror(t)) -#define E_FROM_DOUBLE(d) std::to_string(d) -#define E_FROM_DOUBLE_PRECISE(dbl_val) \ - ([](const double &d) -> std::string { \ - std::stringstream ss; \ - ss << std::fixed << std::setprecision(2) << d; \ - return ss.str(); \ - })(dbl_val) -#define E_FROM_INT32(t) std::to_string(t) -#define E_FROM_SIZE_T(t) std::to_string(t) -#define E_FROM_STRING(t) t -#define E_FROM_UINT16(t) std::to_string(t) -#define E_FROM_UINT64(t) std::to_string(t) -#define E_FROM_DOWNLOAD_TYPE(t) download_type_to_string(t) - -#define E_PROP(type, name, short_name, ts) \ -private: \ - void init_##short_name(const type &val) { \ - auto ts_val = ts(val); \ - ss_ << "|" << #short_name << "|" << ts_val; \ - j_[#name] = ts_val; \ - } \ - \ -public: \ - [[nodiscard]] auto get_##name() const->json { return j_[#name]; } - -#define E_BEGIN(name, el) \ - class name final : public virtual event { \ - private: \ - name(const std::stringstream &ss, const json &j) : event(ss, j) {} \ - \ - public: \ - ~name() override = default; \ - \ - public: \ - static const event_level level = event_level::el; \ - \ - public: \ - [[nodiscard]] auto get_name() const -> std::string override { \ - return #name; \ - } \ - \ - [[nodiscard]] auto get_event_level() const -> event_level override { \ - return name::level; \ - } \ - \ - [[nodiscard]] auto get_single_line() const -> std::string override { \ - const auto s = ss_.str(); \ - return get_name() + (s.empty() ? "" : s); \ - } \ - \ - [[nodiscard]] auto clone() const -> std::shared_ptr override { \ - return std::shared_ptr(new name(ss_, j_)); \ - } -#define E_END() } - -#define E_SIMPLE(event_name, el) \ - E_BEGIN(event_name, el) \ -public: \ - event_name() {} \ - E_END() - -#define E_SIMPLE1(event_name, el, type, name, short_name, tc) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv) { init_##short_name(tv); } \ - E_PROP(type, name, short_name, tc) \ - E_END() - -#define E_SIMPLE2(event_name, el, type, name, short_name, tc, type2, name2, \ - short_name2, tc2) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv, const type2 &tv2) { \ - init_##short_name(tv); \ - init_##short_name2(tv2); \ - } \ - E_PROP(type, name, short_name, tc) \ - E_PROP(type2, name2, short_name2, tc2) \ - E_END() - -#define E_SIMPLE3(event_name, el, type, name, short_name, tc, type2, name2, \ - short_name2, tc2, type3, name3, short_name3, tc3) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3) { \ - init_##short_name(tv); \ - init_##short_name2(tv2); \ - init_##short_name3(tv3); \ - } \ - E_PROP(type, name, short_name, tc) \ - E_PROP(type2, name2, short_name2, tc2) \ - E_PROP(type3, name3, short_name3, tc3) \ - E_END() - -#define E_SIMPLE4(event_name, el, type, name, short_name, tc, type2, name2, \ - short_name2, tc2, type3, name3, short_name3, tc3, type4, \ - name4, short_name4, tc4) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \ - const type4 &tv4) { \ - init_##short_name(tv); \ - init_##short_name2(tv2); \ - init_##short_name3(tv3); \ - init_##short_name4(tv4); \ - } \ - E_PROP(type, name, short_name, tc) \ - E_PROP(type2, name2, short_name2, tc2) \ - E_PROP(type3, name3, short_name3, tc3) \ - E_PROP(type4, name4, short_name4, tc4) \ - E_END() - -#define E_SIMPLE5(event_name, el, type, name, short_name, tc, type2, name2, \ - short_name2, tc2, type3, name3, short_name3, tc3, type4, \ - name4, short_name4, tc4, type5, name5, short_name5, tc5) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \ - const type4 &tv4, const type5 &tv5) { \ - init_##short_name(tv); \ - init_##short_name2(tv2); \ - init_##short_name3(tv3); \ - init_##short_name4(tv4); \ - init_##short_name5(tv5); \ - } \ - E_PROP(type, name, short_name, tc) \ - E_PROP(type2, name2, short_name2, tc2) \ - E_PROP(type3, name3, short_name3, tc3) \ - E_PROP(type4, name4, short_name4, tc4) \ - E_PROP(type5, name5, short_name5, tc5) \ - E_END() - -#define E_SIMPLE6(event_name, el, type, name, short_name, tc, type2, name2, \ - short_name2, tc2, type3, name3, short_name3, tc3, type4, \ - name4, short_name4, tc4, type5, name5, short_name5, tc5, \ - type6, name6, short_name6, tc6) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \ - const type4 &tv4, const type5 &tv5, const type6 &tv6) { \ - init_##short_name(tv); \ - init_##short_name2(tv2); \ - init_##short_name3(tv3); \ - init_##short_name4(tv4); \ - init_##short_name5(tv5); \ - init_##short_name6(tv6); \ - } \ - E_PROP(type, name, short_name, tc) \ - E_PROP(type2, name2, short_name2, tc2) \ - E_PROP(type3, name3, short_name3, tc3) \ - E_PROP(type4, name4, short_name4, tc4) \ - E_PROP(type5, name5, short_name5, tc5) \ - E_PROP(type6, name6, short_name6, tc6) \ - E_END() - -#define E_SIMPLE7(event_name, el, type, name, short_name, tc, type2, name2, \ - short_name2, tc2, type3, name3, short_name3, tc3, type4, \ - name4, short_name4, tc4, type5, name5, short_name5, tc5, \ - type6, name6, short_name6, tc6, type7, name7, short_name7, \ - tc7) \ - E_BEGIN(event_name, el) \ - explicit event_name(const type &tv, const type2 &tv2, const type3 &tv3, \ - const type4 &tv4, const type5 &tv5, const type6 &tv6, \ - const type7 &tv7) { \ - init_##short_name(tv); \ - init_##short_name2(tv2); \ - init_##short_name3(tv3); \ - init_##short_name4(tv4); \ - init_##short_name5(tv5); \ - init_##short_name6(tv6); \ - init_##short_name7(tv7); \ - } \ - E_PROP(type, name, short_name, tc) \ - E_PROP(type2, name2, short_name2, tc2) \ - E_PROP(type3, name3, short_name3, tc3) \ - E_PROP(type4, name4, short_name4, tc4) \ - E_PROP(type5, name5, short_name5, tc5) \ - E_PROP(type6, name6, short_name6, tc6) \ - E_PROP(type7, name7, short_name7, tc7) \ - E_END() - -#define E_CONSUMER() \ -private: \ - std::vector> event_consumers_ - -#define E_CONSUMER_RELEASE() event_consumers_.clear() - -#define E_SUBSCRIBE(name, callback) \ - event_consumers_.emplace_back(std::make_shared( \ - #name, [this](const event &evt) { callback(evt); })) - -#define E_SUBSCRIBE_EXACT(name, callback) \ - event_consumers_.emplace_back(std::make_shared( \ - #name, [this](const event &evt) { \ - callback(dynamic_cast(evt)); \ - })) - -#define E_SUBSCRIBE_ALL(callback) \ - event_consumers_.emplace_back(std::make_shared( \ - [this](const event &evt) { callback(evt); })) -} // namespace repertory - -#endif // REPERTORY_INCLUDE_EVENTS_EVENT_SYSTEM_HPP_ diff --git a/repertory/librepertory/include/events/event_system2.hpp b/repertory/librepertory/include/events/event_system2.hpp index d8275aca..2228c747 100644 --- a/repertory/librepertory/include/events/event_system2.hpp +++ b/repertory/librepertory/include/events/event_system2.hpp @@ -120,6 +120,7 @@ public: }; using event_consumer2 = event_system2::event_consumer2; +using event_consumer = event_system2::event_consumer2; #define E_CONSUMER2() \ private: \ diff --git a/repertory/librepertory/include/events/events.hpp b/repertory/librepertory/include/events/events.hpp index fba6fa49..621aac80 100644 --- a/repertory/librepertory/include/events/events.hpp +++ b/repertory/librepertory/include/events/events.hpp @@ -28,210 +28,6 @@ namespace repertory { // clang-format off -E_SIMPLE1(failed_upload_queued, error, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE1(failed_upload_removed, warn, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE1(failed_upload_retry, info, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE2(file_get_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE1(file_get_api_list_failed, error, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE1(file_pinned, info, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE3(file_read_bytes_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, error, err, E_FROM_STRING, - std::size_t, retry, retry, E_FROM_SIZE_T -); - -E_SIMPLE1(file_removed, debug, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE2(file_removed_externally, warn, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE2(file_remove_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE3(file_rename_failed, error, - std::string, from_api_path, FROM, E_FROM_STRING, - std::string, to_api_path, TO, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE2(file_get_size_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE3(filesystem_item_added, debug, - std::string, api_path, ap, E_FROM_STRING, - std::string, parent, parent, E_FROM_STRING, - bool, directory, dir, E_FROM_BOOL -); - -E_SIMPLE4(filesystem_item_closed, trace, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - bool, directory, dir, E_FROM_BOOL, - bool, changed, changed, E_FROM_BOOL -); - -E_SIMPLE5(filesystem_item_handle_closed, trace, - std::string, api_path, ap, E_FROM_STRING, - std::uint64_t, handle, handle, E_FROM_UINT64, - std::string, source, src, E_FROM_STRING, - bool, directory, dir, E_FROM_BOOL, - bool, changed, changed, E_FROM_BOOL -); - -E_SIMPLE4(filesystem_item_handle_opened, trace, - std::string, api_path, ap, E_FROM_STRING, - std::uint64_t, handle, handle, E_FROM_UINT64, - std::string, source, src, E_FROM_STRING, - bool, directory, dir, E_FROM_BOOL -); - -E_SIMPLE2(filesystem_item_evicted, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE3(filesystem_item_opened, trace, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - bool, directory, dir, E_FROM_BOOL -); - -E_SIMPLE1(file_unpinned, info, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE4(file_upload_completed, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - api_error, result, res, E_FROM_API_FILE_ERROR, - bool, cancelled, cancel, E_FROM_BOOL -); - -E_SIMPLE3(file_upload_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE2(file_upload_not_found, warn, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE2(file_upload_queued, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE1(file_upload_removed, debug, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE3(file_upload_retry, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - api_error, result, res, E_FROM_API_FILE_ERROR -); - -E_SIMPLE2(file_upload_started, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE1(orphaned_file_deleted, warn, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE1(orphaned_file_detected, warn, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE3(orphaned_file_processing_failed, error, - std::string, source, src, E_FROM_STRING, - std::string, dest, dest, E_FROM_STRING, - std::string, result, res, E_FROM_STRING -); - -E_SIMPLE1(orphaned_source_file_detected, info, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE1(orphaned_source_file_removed, info, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE1(polling_item_begin, debug, - std::string, item_name, item, E_FROM_STRING -); - -E_SIMPLE1(polling_item_end, debug, - std::string, item_name, item, E_FROM_STRING -); - -E_SIMPLE2(provider_offline, error, - std::string, host_name_or_ip, host, E_FROM_STRING, - std::uint16_t, port, port, E_FROM_UINT16 -); - -E_SIMPLE2(provider_upload_begin, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING -); - -E_SIMPLE3(provider_upload_end, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - api_error, result, res, E_FROM_API_FILE_ERROR -); - -E_SIMPLE2(repertory_exception, error, - std::string, function, func, E_FROM_STRING, - std::string, message, msg, E_FROM_STRING -); - -E_SIMPLE1(rpc_server_exception, error, - std::string, exception, exception, E_FROM_STRING -); - -E_SIMPLE1(service_shutdown_begin, debug, - std::string, service, svc, E_FROM_STRING -); - -E_SIMPLE1(service_shutdown_end, debug, - std::string, service, svc, E_FROM_STRING -); - -E_SIMPLE1(service_started, debug, - std::string, service, svc, E_FROM_STRING -); - E_SIMPLE(unmount_requested, info); #if !defined(_WIN32) E_SIMPLE2(unmount_result, info, @@ -239,6 +35,70 @@ E_SIMPLE2(unmount_result, info, std::string, result, res, E_FROM_STRING ); #endif + +E_SIMPLE2(download_begin, info, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING +); + +E_SIMPLE3(download_end, info, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING, + api_error, result, result, E_FROM_API_FILE_ERROR +); + +E_SIMPLE3(download_progress, info, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING, + double, progress, prog, E_FROM_DOUBLE_PRECISE +); + +E_SIMPLE2(download_restored, info, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING +); + +E_SIMPLE3(download_restore_failed, error, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING, + std::string, error, err, E_FROM_STRING +); + +E_SIMPLE3(download_resume_add_failed, error, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING, + std::string, error, err, E_FROM_STRING +); + +E_SIMPLE2(download_resume_added, debug, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING +); + +E_SIMPLE2(download_resume_removed, debug, + std::string, api_path, ap, E_FROM_STRING, + std::string, dest_path, dest, E_FROM_STRING +); + +E_SIMPLE1(item_timeout, trace, + std::string, api_path, ap, E_FROM_STRING +); + +E_SIMPLE3(download_type_selected, debug, + std::string, api_path, ap, E_FROM_STRING, + std::string, source, src, E_FROM_STRING, + download_type, download_type, type, E_FROM_DOWNLOAD_TYPE +); + +E_SIMPLE3(fuse_event, debug, + std::string, function, func, E_FROM_STRING, + std::string, api_path, ap, E_FROM_STRING, + int, result, res, E_FROM_INT32 +); + +E_SIMPLE1(fuse_args_parsed, info, + std::string, arguments, args, E_FROM_STRING +); // clang-format on } // namespace repertory diff --git a/repertory/librepertory/include/events/t_event_system.hpp b/repertory/librepertory/include/events/t_event_system.hpp deleted file mode 100644 index 5cad5117..00000000 --- a/repertory/librepertory/include/events/t_event_system.hpp +++ /dev/null @@ -1,249 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_ -#define REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_ - -#include "app_config.hpp" -#include "events/event.hpp" -#include "utils/collection.hpp" -#include "utils/utils.hpp" - -namespace repertory { -template class t_event_system final { -private: - static constexpr const std::uint8_t max_queue_retry{ - 30U, - }; - - const std::uint32_t max_queue_size{ - std::thread::hardware_concurrency() * 4U, - }; - - static constexpr const std::chrono::seconds queue_wait_secs{ - 5s, - }; - -public: - t_event_system(const t_event_system &) = delete; - t_event_system(t_event_system &&) = delete; - auto operator=(const t_event_system &) -> t_event_system & = delete; - auto operator=(t_event_system &&) -> t_event_system & = delete; - -protected: - t_event_system() = default; - - ~t_event_system() { stop(); } - -public: - class event_consumer final { - public: - explicit event_consumer(std::function callback) - : callback_(std::move(callback)) { - t_event_system::instance().attach(this); - } - - event_consumer(const std::string &event_name, - std::function callback) - : callback_(std::move(callback)) { - t_event_system::instance().attach(event_name, this); - } - - ~event_consumer() { t_event_system::instance().release(this); } - - public: - event_consumer(const event_consumer &) = delete; - event_consumer(event_consumer &&) = delete; - auto operator=(const event_consumer &) -> event_consumer & = delete; - auto operator=(event_consumer &&) -> event_consumer & = delete; - - private: - std::function callback_; - - public: - void notify_event(const event &event) { callback_(event); } - }; - -private: - static t_event_system event_system_; - -public: - static auto instance() -> t_event_system &; - -private: - std::unordered_map> - event_consumers_; - std::recursive_mutex consumer_mutex_; - std::vector> event_list_; - std::condition_variable event_notify_; - std::mutex event_mutex_; - std::unique_ptr event_thread_; - std::mutex run_mutex_; - stop_type stop_requested_{false}; - -private: - [[nodiscard]] auto get_stop_requested() const -> bool { - return stop_requested_ || app_config::get_stop_requested(); - } - - void process_events() { - std::vector> events; - - unique_mutex_lock lock(event_mutex_); - const auto lock_and_notify = [this, &lock]() { - lock.lock(); - event_notify_.notify_all(); - lock.unlock(); - }; - - if (not get_stop_requested() && event_list_.empty()) { - event_notify_.wait_for(lock, queue_wait_secs); - } - - if (not event_list_.empty()) { - events.insert(events.end(), event_list_.begin(), event_list_.end()); - event_list_.clear(); - } - - lock.unlock(); - - if (events.empty()) { - lock_and_notify(); - return; - } - - const auto notify_events = [this](const std::string &name, - const event_type &event) { - std::deque> futures; - recur_mutex_lock consumer_lock(consumer_mutex_); - for (auto *consumer : event_consumers_[name]) { - futures.emplace_back( - std::async(std::launch::async, [consumer, &event]() { - consumer->notify_event(event); - })); - } - - while (not futures.empty()) { - futures.front().get(); - futures.pop_front(); - } - }; - - for (const auto &evt : events) { - notify_events("", *evt.get()); - notify_events(evt->get_name(), *evt.get()); - } - - lock_and_notify(); - } - - void queue_event(std::shared_ptr evt) { - unique_mutex_lock lock(event_mutex_); - event_list_.push_back(std::move(evt)); - auto size = event_list_.size(); - event_notify_.notify_all(); - lock.unlock(); - - for (std::uint8_t retry{0U}; - size > max_queue_size && retry < max_queue_retry && - not get_stop_requested(); - ++retry) { - lock.lock(); - size = event_list_.size(); - if (size > max_queue_size) { - event_notify_.wait_for(lock, queue_wait_secs); - size = event_list_.size(); - } - - event_notify_.notify_all(); - lock.unlock(); - } - } - -public: - void attach(event_consumer *consumer) { - recur_mutex_lock lock(consumer_mutex_); - event_consumers_[""].push_back(consumer); - } - - void attach(const std::string &event_name, event_consumer *consumer) { - recur_mutex_lock lock(consumer_mutex_); - event_consumers_[event_name].push_back(consumer); - } - - template void raise(arg_t &&...args) { - queue_event(std::make_shared(std::forward(args)...)); - } - - void release(event_consumer *consumer) { - recur_mutex_lock lock(consumer_mutex_); - auto iter = std::find_if(event_consumers_.begin(), event_consumers_.end(), - [&](const auto &item) -> bool { - return utils::collection::includes(item.second, - consumer); - }); - - if (iter != event_consumers_.end()) { - utils::collection::remove_element((*iter).second, consumer); - } - } - - void start() { - mutex_lock lock(run_mutex_); - if (event_thread_) { - event_notify_.notify_all(); - return; - } - - stop_requested_ = false; - - event_thread_ = std::make_unique([this]() { - while (not get_stop_requested()) { - process_events(); - } - }); - event_notify_.notify_all(); - } - - void stop() { - unique_mutex_lock lock(run_mutex_); - if (not event_thread_) { - event_notify_.notify_all(); - return; - } - - stop_requested_ = true; - - std::unique_ptr thread{nullptr}; - std::swap(thread, event_thread_); - - event_notify_.notify_all(); - lock.unlock(); - - thread->join(); - thread.reset(); - - process_events(); - } -}; -} // namespace repertory - -#endif // REPERTORY_INCLUDE_EVENTS_T_EVENT_SYSTEM_HPP_ diff --git a/repertory/librepertory/include/events/types/file_pinned.hpp b/repertory/librepertory/include/events/types/file_pinned.hpp new file mode 100644 index 00000000..e3c670f0 --- /dev/null +++ b/repertory/librepertory/include/events/types/file_pinned.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_PINNED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_PINNED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_pinned final : public i_event { + file_pinned() = default; + file_pinned(std::string api_path_, std::string_view function_name_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)) {} + + static constexpr const std::string_view name{"file_pinned"}; + + std::string api_path; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_pinned &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::file_pinned &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_PINNED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_remove_failed.hpp b/repertory/librepertory/include/events/types/file_remove_failed.hpp new file mode 100644 index 00000000..e354c39f --- /dev/null +++ b/repertory/librepertory/include/events/types/file_remove_failed.hpp @@ -0,0 +1,76 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVE_FAILED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVE_FAILED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_remove_failed final : public i_event { + file_remove_failed() = default; + file_remove_failed(std::string api_path_, api_error error_, + std::string_view function_name_) + : api_path(std::move(api_path_)), + error(error_), + function_name(std::string(function_name_)) {} + + static constexpr const std::string_view name{"file_remove_failed"}; + + std::string api_path; + api_error error{}; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::error; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}", name, function_name, + api_path, api_error_to_string(error)); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_remove_failed &value) { + data["api_path"] = value.api_path; + data["error"] = repertory::api_error_to_string(value.error); + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, + repertory::file_remove_failed &value) { + data.at("api_path").get_to(value.api_path); + value.error = + repertory::api_error_from_string(data.at("error").get()); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVE_FAILED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_removed.hpp b/repertory/librepertory/include/events/types/file_removed.hpp new file mode 100644 index 00000000..8479e258 --- /dev/null +++ b/repertory/librepertory/include/events/types/file_removed.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_removed final : public i_event { + file_removed() = default; + file_removed(std::string api_path_, std::string_view function_name_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)) {} + + static constexpr const std::string_view name{"file_removed"}; + + std::string api_path; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_removed &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::file_removed &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_removed_externally.hpp b/repertory/librepertory/include/events/types/file_removed_externally.hpp new file mode 100644 index 00000000..ff880331 --- /dev/null +++ b/repertory/librepertory/include/events/types/file_removed_externally.hpp @@ -0,0 +1,77 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_EXTERNALLY_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_EXTERNALLY_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_removed_externally final : public i_event { + file_removed_externally() = default; + file_removed_externally(std::string api_path_, + std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"file_removed_externally"}; + + std::string api_path; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::warn; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|src|{}", name, function_name, api_path, + source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::file_removed_externally &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::file_removed_externally &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_REMOVED_EXTERNALLY_HPP_ diff --git a/repertory/librepertory/include/events/types/file_unpinned.hpp b/repertory/librepertory/include/events/types/file_unpinned.hpp new file mode 100644 index 00000000..ff26b05c --- /dev/null +++ b/repertory/librepertory/include/events/types/file_unpinned.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UNPINNED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UNPINNED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_unpinned final : public i_event { + file_unpinned() = default; + file_unpinned(std::string api_path_, std::string_view function_name_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)) {} + + static constexpr const std::string_view name{"file_unpinned"}; + + std::string api_path; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_unpinned &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::file_unpinned &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UNPINNED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_upload_completed.hpp b/repertory/librepertory/include/events/types/file_upload_completed.hpp new file mode 100644 index 00000000..6cca9e50 --- /dev/null +++ b/repertory/librepertory/include/events/types/file_upload_completed.hpp @@ -0,0 +1,87 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_COMPLETED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_COMPLETED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_upload_completed final : public i_event { + file_upload_completed() = default; + file_upload_completed(std::string api_path_, bool cancelled_, + api_error error_, std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + cancelled(cancelled_), + error(error_), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"file_upload_completed"}; + + std::string api_path; + bool cancelled{}; + api_error error{}; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|cancelled|{}|error|{}|sp|{}", name, + function_name, api_path, cancelled, + api_error_to_string(error), source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::file_upload_completed &value) { + data["api_path"] = value.api_path; + data["cancelled"] = value.cancelled; + data["error"] = repertory::api_error_to_string(value.error); + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::file_upload_completed &value) { + data.at("api_path").get_to(value.api_path); + data.at("cancelled").get_to(value.cancelled); + value.error = + repertory::api_error_from_string(data.at("error").get()); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_COMPLETED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_upload_failed.hpp b/repertory/librepertory/include/events/types/file_upload_failed.hpp new file mode 100644 index 00000000..df4ecb71 --- /dev/null +++ b/repertory/librepertory/include/events/types/file_upload_failed.hpp @@ -0,0 +1,79 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_FAILED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_FAILED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_upload_failed final : public i_event { + file_upload_failed() = default; + file_upload_failed(std::string api_path_, std::string error_, + std::string_view function_name_, std::string source_path_) + : api_path(std::move(api_path_)), + error(std::move(error_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"file_upload_failed"}; + + std::string api_path; + std::string error; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::warn; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}|sp|{}", name, function_name, + api_path, error, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_upload_failed &value) { + data["api_path"] = value.api_path; + data["error"] = value.error; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::file_upload_failed &value) { + data.at("api_path").get_to(value.api_path); + data.at("error").get_to(value.error); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_FAILED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_upload_not_found.hpp b/repertory/librepertory/include/events/types/file_upload_not_found.hpp new file mode 100644 index 00000000..0ea39f6d --- /dev/null +++ b/repertory/librepertory/include/events/types/file_upload_not_found.hpp @@ -0,0 +1,76 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_NOT_FOUND_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_NOT_FOUND_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_upload_not_found final : public i_event { + file_upload_not_found() = default; + file_upload_not_found(std::string api_path_, std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"file_upload_not_found"}; + + std::string api_path; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::warn; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|sp|{}", name, function_name, api_path, + source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::file_upload_not_found &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::file_upload_not_found &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_NOT_FOUND_HPP_ diff --git a/repertory/librepertory/include/events/types/file_upload_queued.hpp b/repertory/librepertory/include/events/types/file_upload_queued.hpp new file mode 100644 index 00000000..504d734f --- /dev/null +++ b/repertory/librepertory/include/events/types/file_upload_queued.hpp @@ -0,0 +1,75 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_QUEUED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_QUEUED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_upload_queued final : public i_event { + file_upload_queued() = default; + file_upload_queued(std::string api_path_, std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"file_upload_queued"}; + + std::string api_path; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|sp|{}", name, function_name, api_path, + source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_upload_queued &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::file_upload_queued &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_QUEUED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_upload_removed.hpp b/repertory/librepertory/include/events/types/file_upload_removed.hpp new file mode 100644 index 00000000..9a094cda --- /dev/null +++ b/repertory/librepertory/include/events/types/file_upload_removed.hpp @@ -0,0 +1,69 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_REMOVED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_REMOVED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_upload_removed final : public i_event { + file_upload_removed() = default; + file_upload_removed(std::string api_path_, std::string_view function_name_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)) {} + + static constexpr const std::string_view name{"file_upload_removed"}; + + std::string api_path; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}", name, function_name, api_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_upload_removed &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, + repertory::file_upload_removed &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_REMOVED_HPP_ diff --git a/repertory/librepertory/include/events/types/file_upload_retry.hpp b/repertory/librepertory/include/events/types/file_upload_retry.hpp new file mode 100644 index 00000000..3aa19744 --- /dev/null +++ b/repertory/librepertory/include/events/types/file_upload_retry.hpp @@ -0,0 +1,78 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_RETRY_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_RETRY_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct file_upload_retry final : public i_event { + file_upload_retry() = default; + file_upload_retry(std::string api_path_, std::string error_, + std::string_view function_name_, std::string source_path_) + : api_path(std::move(api_path_)), + error(std::move(error_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"file_upload_retry"}; + + std::string api_path; + std::string error; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::warn; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}|sp|{}", name, function_name, + api_path, error, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::file_upload_retry &value) { + data["api_path"] = value.api_path; + data["error"] = value.error; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, repertory::file_upload_retry &value) { + data.at("api_path").get_to(value.api_path); + data.at("error").get_to(value.error); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILE_UPLOAD_RETRY_HPP_ diff --git a/repertory/librepertory/include/events/types/filesystem_item_added.hpp b/repertory/librepertory/include/events/types/filesystem_item_added.hpp new file mode 100644 index 00000000..f9521a09 --- /dev/null +++ b/repertory/librepertory/include/events/types/filesystem_item_added.hpp @@ -0,0 +1,80 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_ADDED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_ADDED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct filesystem_item_added final : public i_event { + filesystem_item_added() = default; + filesystem_item_added(std::string api_parent_, std::string api_path_, + bool directory_, std::string_view function_name_) + : api_parent(std::move(api_parent_)), + api_path(std::move(api_path_)), + directory(directory_), + function_name(std::string(function_name_)) {} + + static constexpr const std::string_view name{"filesystem_item_added"}; + + std::string api_parent; + std::string api_path; + bool directory{}; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|parent|{}|dir|{}", name, function_name, + api_path, api_parent, directory); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::filesystem_item_added &value) { + data["api_parent"] = value.api_parent; + data["api_path"] = value.api_path; + data["directory"] = value.directory; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, + repertory::filesystem_item_added &value) { + data.at("api_parent").get_to(value.api_parent); + data.at("api_path").get_to(value.api_path); + data.at("directory").get_to(value.directory); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_ADDED_HPP_ diff --git a/repertory/librepertory/include/events/types/filesystem_item_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp new file mode 100644 index 00000000..3871ef9f --- /dev/null +++ b/repertory/librepertory/include/events/types/filesystem_item_closed.hpp @@ -0,0 +1,86 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_CLOSED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_CLOSED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct filesystem_item_closed final : public i_event { + filesystem_item_closed() = default; + filesystem_item_closed(std::string api_path_, bool changed_, bool directory_, + std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + changed(changed_), + directory(directory_), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"filesystem_item_closed"}; + + std::string api_path; + bool changed{}; + bool directory{}; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::trace; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|changed|{}|dir|{}|sp|{}", name, + function_name, api_path, changed, directory, + source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::filesystem_item_closed &value) { + data["api_path"] = value.api_path; + data["changed"] = value.changed; + data["directory"] = value.directory; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::filesystem_item_closed &value) { + data.at("api_path").get_to(value.api_path); + data.at("changed").get_to(value.changed); + data.at("directory").get_to(value.directory); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_CLOSED_HPP_ diff --git a/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp new file mode 100644 index 00000000..ccf100f5 --- /dev/null +++ b/repertory/librepertory/include/events/types/filesystem_item_evicted.hpp @@ -0,0 +1,77 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_EVICTED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_EVICTED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct filesystem_item_evicted final : public i_event { + filesystem_item_evicted() = default; + filesystem_item_evicted(std::string api_path_, + std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"filesystem_item_evicted"}; + + std::string api_path; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|sp|{}", name, function_name, api_path, + source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::filesystem_item_evicted &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::filesystem_item_evicted &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_EVICTED_HPP_ diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp new file mode 100644 index 00000000..61362854 --- /dev/null +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_closed.hpp @@ -0,0 +1,91 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_CLOSED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_CLOSED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct filesystem_item_handle_closed final : public i_event { + filesystem_item_handle_closed() = default; + filesystem_item_handle_closed(std::string api_path_, bool changed_, + bool directory_, + std::string_view function_name_, + std::uint64_t handle_, std::string source_path_) + : api_path(std::move(api_path_)), + changed(changed_), + directory(directory_), + function_name(std::string(function_name_)), + handle(handle_), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"filesystem_item_handle_closed"}; + + std::string api_path; + bool changed{}; + bool directory{}; + std::string function_name; + std::uint64_t handle{}; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::trace; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|changed|{}|dir|{}|handle|{}|sp|{}", + name, function_name, api_path, changed, directory, + handle, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::filesystem_item_handle_closed &value) { + data["api_path"] = value.api_path; + data["changed"] = value.changed; + data["directory"] = value.directory; + data["function_name"] = value.function_name; + data["handle"] = value.handle; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::filesystem_item_handle_closed &value) { + data.at("api_path").get_to(value.api_path); + data.at("changed").get_to(value.changed); + data.at("directory").get_to(value.directory); + data.at("function_name").get_to(value.function_name); + data.at("handle").get_to(value.handle); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_CLOSED_HPP_ diff --git a/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp new file mode 100644 index 00000000..86016223 --- /dev/null +++ b/repertory/librepertory/include/events/types/filesystem_item_handle_opened.hpp @@ -0,0 +1,85 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_OPENED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_OPENED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct filesystem_item_handle_opened final : public i_event { + filesystem_item_handle_opened() = default; + filesystem_item_handle_opened(std::string api_path_, bool directory_, + std::string_view function_name_, + std::uint64_t handle_, std::string source_path_) + : api_path(std::move(api_path_)), + directory(directory_), + function_name(std::string(function_name_)), + handle(handle_), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"filesystem_item_handle_opened"}; + + std::string api_path; + bool directory{}; + std::string function_name; + std::uint64_t handle{}; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::trace; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|dir|{}|handle|{}|sp|{}", name, + function_name, api_path, directory, handle, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::filesystem_item_handle_opened &value) { + data["api_path"] = value.api_path; + data["directory"] = value.directory; + data["function_name"] = value.function_name; + data["handle"] = value.handle; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::filesystem_item_handle_opened &value) { + data.at("api_path").get_to(value.api_path); + data.at("directory").get_to(value.directory); + data.at("function_name").get_to(value.function_name); + data.at("handle").get_to(value.handle); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_HANDLE_OPENED_HPP_ diff --git a/repertory/librepertory/include/events/types/filesystem_item_opened.hpp b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp new file mode 100644 index 00000000..4a151db6 --- /dev/null +++ b/repertory/librepertory/include/events/types/filesystem_item_opened.hpp @@ -0,0 +1,81 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_OPENED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_OPENED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct filesystem_item_opened final : public i_event { + filesystem_item_opened() = default; + filesystem_item_opened(std::string api_path_, bool directory_, + std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + directory(directory_), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"filesystem_item_opened"}; + + std::string api_path; + bool directory{}; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::trace; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|dir|{}|sp|{}", name, function_name, + api_path, directory, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::filesystem_item_opened &value) { + data["api_path"] = value.api_path; + data["directory"] = value.directory; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::filesystem_item_opened &value) { + data.at("api_path").get_to(value.api_path); + data.at("directory").get_to(value.directory); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FILESYSTEM_ITEM_OPENED_HPP_ diff --git a/repertory/librepertory/include/events/types/orphaned_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp new file mode 100644 index 00000000..55d9a9c9 --- /dev/null +++ b/repertory/librepertory/include/events/types/orphaned_file_detected.hpp @@ -0,0 +1,71 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_DETECTED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_DETECTED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct orphaned_file_detected final : public i_event { + orphaned_file_detected() = default; + orphaned_file_detected(std::string_view function_name_, + std::string source_path_) + : function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"orphaned_file_detected"}; + + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|sp|{}", name, function_name, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::orphaned_file_detected &value) { + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::orphaned_file_detected &value) { + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_DETECTED_HPP_ diff --git a/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp new file mode 100644 index 00000000..ec6a7273 --- /dev/null +++ b/repertory/librepertory/include/events/types/orphaned_file_processing_failed.hpp @@ -0,0 +1,82 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_PROCESSING_FAILED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_PROCESSING_FAILED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct orphaned_file_processing_failed final : public i_event { + orphaned_file_processing_failed() = default; + orphaned_file_processing_failed(std::string dest_path_, std::string error_, + std::string_view function_name_, + std::string source_path_) + : dest_path(std::move(dest_path_)), + error(std::move(error_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{ + "orphaned_file_processing_failed"}; + + std::string dest_path; + std::string error; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|sp|{}|dp|{}|error|{}", name, function_name, + source_path, dest_path, error); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::orphaned_file_processing_failed &value) { + data["dest_path"] = value.dest_path; + data["error"] = value.error; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::orphaned_file_processing_failed &value) { + data.at("dest_path").get_to(value.dest_path); + data.at("error").get_to(value.error); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_FILE_PROCESSING_FAILED_HPP_ diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp new file mode 100644 index 00000000..a263d204 --- /dev/null +++ b/repertory/librepertory/include/events/types/orphaned_source_file_detected.hpp @@ -0,0 +1,71 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_DETECTED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_DETECTED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct orphaned_source_file_detected final : public i_event { + orphaned_source_file_detected() = default; + orphaned_source_file_detected(std::string_view function_name_, + std::string source_path_) + : function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"orphaned_source_file_detected"}; + + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|sp|{}", name, function_name, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::orphaned_source_file_detected &value) { + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::orphaned_source_file_detected &value) { + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_DETECTED_HPP_ diff --git a/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp new file mode 100644 index 00000000..9bdb4171 --- /dev/null +++ b/repertory/librepertory/include/events/types/orphaned_source_file_removed.hpp @@ -0,0 +1,71 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_REMOVED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_REMOVED_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct orphaned_source_file_removed final : public i_event { + orphaned_source_file_removed() = default; + orphaned_source_file_removed(std::string_view function_name_, + std::string source_path_) + : function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"orphaned_source_file_removed"}; + + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|sp|{}", name, function_name, source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::orphaned_source_file_removed &value) { + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::orphaned_source_file_removed &value) { + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_ORPHANED_SOURCE_FILE_REMOVED_HPP_ diff --git a/repertory/librepertory/include/events/types/polling_item_begin.hpp b/repertory/librepertory/include/events/types/polling_item_begin.hpp new file mode 100644 index 00000000..f7aa113c --- /dev/null +++ b/repertory/librepertory/include/events/types/polling_item_begin.hpp @@ -0,0 +1,69 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_BEGIN_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_BEGIN_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct polling_item_begin final : public i_event { + polling_item_begin() = default; + polling_item_begin(std::string_view function_name_, std::string item_name_) + : function_name(std::string(function_name_)), + item_name(std::move(item_name_)) {} + + static constexpr const std::string_view name{"polling_item_begin"}; + + std::string function_name; + std::string item_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|name|{}", name, function_name, item_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::polling_item_begin &value) { + data["function_name"] = value.function_name; + data["item_name"] = value.item_name; + } + + static void from_json(const json &data, + repertory::polling_item_begin &value) { + data.at("function_name").get_to(value.function_name); + data.at("item_name").get_to(value.item_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_BEGIN_HPP_ diff --git a/repertory/librepertory/include/events/types/polling_item_end.hpp b/repertory/librepertory/include/events/types/polling_item_end.hpp new file mode 100644 index 00000000..890d7ad8 --- /dev/null +++ b/repertory/librepertory/include/events/types/polling_item_end.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_END_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_END_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct polling_item_end final : public i_event { + polling_item_end() = default; + polling_item_end(std::string_view function_name_, std::string item_name_) + : function_name(std::string(function_name_)), + item_name(std::move(item_name_)) {} + + static constexpr const std::string_view name{"polling_item_end"}; + + std::string function_name; + std::string item_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|name|{}", name, function_name, item_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::polling_item_end &value) { + data["function_name"] = value.function_name; + data["item_name"] = value.item_name; + } + + static void from_json(const json &data, repertory::polling_item_end &value) { + data.at("function_name").get_to(value.function_name); + data.at("item_name").get_to(value.item_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_POLLING_ITEM_END_HPP_ diff --git a/repertory/librepertory/include/events/types/provider_offline.hpp b/repertory/librepertory/include/events/types/provider_offline.hpp new file mode 100644 index 00000000..abf012c9 --- /dev/null +++ b/repertory/librepertory/include/events/types/provider_offline.hpp @@ -0,0 +1,74 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_OFFLINE_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_OFFLINE_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct provider_offline final : public i_event { + provider_offline() = default; + provider_offline(std::string_view function_name_, + std::string host_name_or_ip_, std::uint16_t port_) + : function_name(std::string(function_name_)), + host_name_or_ip(std::move(host_name_or_ip_)), + port(port_) {} + + static constexpr const std::string_view name{"provider_offline"}; + + std::string function_name; + std::string host_name_or_ip; + std::uint16_t port{}; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|host|{}|port|{}", name, function_name, + host_name_or_ip, port); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::provider_offline &value) { + data["function_name"] = value.function_name; + data["host_name_or_ip"] = value.host_name_or_ip; + data["port"] = value.port; + } + + static void from_json(const json &data, repertory::provider_offline &value) { + data.at("function_name").get_to(value.function_name); + data.at("host_name_or_ip").get_to(value.host_name_or_ip); + data.at("port").get_to(value.port); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_OFFLINE_HPP_ diff --git a/repertory/librepertory/include/events/types/provider_upload_begin.hpp b/repertory/librepertory/include/events/types/provider_upload_begin.hpp new file mode 100644 index 00000000..7891005e --- /dev/null +++ b/repertory/librepertory/include/events/types/provider_upload_begin.hpp @@ -0,0 +1,76 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_BEGIN_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_BEGIN_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct provider_upload_begin final : public i_event { + provider_upload_begin() = default; + provider_upload_begin(std::string api_path_, std::string_view function_name_, + std::string source_path_) + : api_path(std::move(api_path_)), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"provider_upload_begin"}; + + std::string api_path; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::warn; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|sp|{}", name, function_name, api_path, + source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, + const repertory::provider_upload_begin &value) { + data["api_path"] = value.api_path; + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::provider_upload_begin &value) { + data.at("api_path").get_to(value.api_path); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_BEGIN_HPP_ diff --git a/repertory/librepertory/include/events/types/provider_upload_end.hpp b/repertory/librepertory/include/events/types/provider_upload_end.hpp new file mode 100644 index 00000000..ebab806f --- /dev/null +++ b/repertory/librepertory/include/events/types/provider_upload_end.hpp @@ -0,0 +1,80 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_END_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_END_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct provider_upload_end final : public i_event { + provider_upload_end() = default; + provider_upload_end(std::string api_path_, api_error error_, + std::string_view function_name_, std::string source_path_) + : api_path(std::move(api_path_)), + error(error_), + function_name(std::string(function_name_)), + source_path(std::move(source_path_)) {} + + static constexpr const std::string_view name{"provider_upload_end"}; + + std::string api_path; + api_error error{}; + std::string function_name; + std::string source_path; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::info; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}|sp|{}", name, function_name, + api_path, api_error_to_string(error), source_path); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::provider_upload_end &value) { + data["api_path"] = value.api_path; + data["error"] = repertory::api_error_to_string(value.error); + data["function_name"] = value.function_name; + data["source_path"] = value.source_path; + } + + static void from_json(const json &data, + repertory::provider_upload_end &value) { + data.at("api_path").get_to(value.api_path); + value.error = + repertory::api_error_from_string(data.at("error").get()); + data.at("function_name").get_to(value.function_name); + data.at("source_path").get_to(value.source_path); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_PROVIDER_UPLOAD_END_HPP_ diff --git a/repertory/librepertory/include/events/types/repertory_exception.hpp b/repertory/librepertory/include/events/types/repertory_exception.hpp new file mode 100644 index 00000000..e8162e5a --- /dev/null +++ b/repertory/librepertory/include/events/types/repertory_exception.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_REPERTORY_EXCEPTION_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_REPERTORY_EXCEPTION_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct repertory_exception final : public i_event { + repertory_exception() = default; + repertory_exception(std::string_view function_name_, std::string msg_) + : function_name(std::string(function_name_)), msg(std::move(msg_)) {} + + static constexpr const std::string_view name{"repertory_exception"}; + + std::string function_name; + std::string msg; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::error; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|msg|{}", name, function_name, msg); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::repertory_exception &value) { + data["function_name"] = value.function_name; + data["msg"] = value.msg; + } + + static void from_json(const json &data, + repertory::repertory_exception &value) { + data.at("function_name").get_to(value.function_name); + data.at("msg").get_to(value.msg); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_REPERTORY_EXCEPTION_HPP_ diff --git a/repertory/librepertory/include/events/types/service_start_begin.hpp b/repertory/librepertory/include/events/types/service_start_begin.hpp new file mode 100644 index 00000000..fda80067 --- /dev/null +++ b/repertory/librepertory/include/events/types/service_start_begin.hpp @@ -0,0 +1,70 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_BEGIN_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_BEGIN_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct service_start_begin final : public i_event { + service_start_begin() = default; + service_start_begin(std::string_view function_name_, + std::string service_name_) + : function_name(std::string(function_name_)), + service_name(std::move(service_name_)) {} + + static constexpr const std::string_view name{"service_start_begin"}; + + std::string function_name; + std::string service_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::service_start_begin &value) { + data["function_name"] = value.function_name; + data["service_name"] = value.service_name; + } + + static void from_json(const json &data, + repertory::service_start_begin &value) { + data.at("function_name").get_to(value.function_name); + data.at("service_name").get_to(value.service_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_BEGIN_HPP_ diff --git a/repertory/librepertory/include/events/types/service_start_end.hpp b/repertory/librepertory/include/events/types/service_start_end.hpp new file mode 100644 index 00000000..4eaa422f --- /dev/null +++ b/repertory/librepertory/include/events/types/service_start_end.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_END_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_END_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct service_start_end final : public i_event { + service_start_end() = default; + service_start_end(std::string_view function_name_, std::string service_name_) + : function_name(std::string(function_name_)), + service_name(std::move(service_name_)) {} + + static constexpr const std::string_view name{"service_start_end"}; + + std::string function_name; + std::string service_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::service_start_end &value) { + data["function_name"] = value.function_name; + data["service_name"] = value.service_name; + } + + static void from_json(const json &data, repertory::service_start_end &value) { + data.at("function_name").get_to(value.function_name); + data.at("service_name").get_to(value.service_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_START_END_HPP_ diff --git a/repertory/librepertory/include/events/types/service_stop_begin.hpp b/repertory/librepertory/include/events/types/service_stop_begin.hpp new file mode 100644 index 00000000..c6aaa7da --- /dev/null +++ b/repertory/librepertory/include/events/types/service_stop_begin.hpp @@ -0,0 +1,69 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_BEGIN_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_BEGIN_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct service_stop_begin final : public i_event { + service_stop_begin() = default; + service_stop_begin(std::string_view function_name_, std::string service_name_) + : function_name(std::string(function_name_)), + service_name(std::move(service_name_)) {} + + static constexpr const std::string_view name{"service_stop_begin"}; + + std::string function_name; + std::string service_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::service_stop_begin &value) { + data["function_name"] = value.function_name; + data["service_name"] = value.service_name; + } + + static void from_json(const json &data, + repertory::service_stop_begin &value) { + data.at("function_name").get_to(value.function_name); + data.at("service_name").get_to(value.service_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_BEGIN_HPP_ diff --git a/repertory/librepertory/include/events/types/service_stop_end.hpp b/repertory/librepertory/include/events/types/service_stop_end.hpp new file mode 100644 index 00000000..be127f36 --- /dev/null +++ b/repertory/librepertory/include/events/types/service_stop_end.hpp @@ -0,0 +1,68 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_END_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_END_HPP_ + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct service_stop_end final : public i_event { + service_stop_end() = default; + service_stop_end(std::string_view function_name_, std::string service_name_) + : function_name(std::string(function_name_)), + service_name(std::move(service_name_)) {} + + static constexpr const std::string_view name{"service_stop_end"}; + + std::string function_name; + std::string service_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return event_level::debug; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|svc|{}", name, function_name, service_name); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::service_stop_end &value) { + data["function_name"] = value.function_name; + data["service_name"] = value.service_name; + } + + static void from_json(const json &data, repertory::service_stop_end &value) { + data.at("function_name").get_to(value.function_name); + data.at("service_name").get_to(value.service_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_SERVICE_STOP_END_HPP_ diff --git a/repertory/librepertory/include/file_manager/events.hpp b/repertory/librepertory/include/file_manager/events.hpp deleted file mode 100644 index 01cca60a..00000000 --- a/repertory/librepertory/include/file_manager/events.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_ -#define REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_ - -#include "events/events.hpp" -#include "types/repertory.hpp" - -namespace repertory { -// clang-format off -E_SIMPLE2(download_begin, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING -); - -E_SIMPLE3(download_end, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING, - api_error, result, result, E_FROM_API_FILE_ERROR -); - -E_SIMPLE3(download_progress, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING, - double, progress, prog, E_FROM_DOUBLE_PRECISE -); - -E_SIMPLE2(download_restored, info, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING -); - -E_SIMPLE3(download_restore_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE3(download_resume_add_failed, error, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING, - std::string, error, err, E_FROM_STRING -); - -E_SIMPLE2(download_resume_added, debug, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING -); - -E_SIMPLE2(download_resume_removed, debug, - std::string, api_path, ap, E_FROM_STRING, - std::string, dest_path, dest, E_FROM_STRING -); - -E_SIMPLE1(item_timeout, trace, - std::string, api_path, ap, E_FROM_STRING -); - -E_SIMPLE3(download_type_selected, debug, - std::string, api_path, ap, E_FROM_STRING, - std::string, source, src, E_FROM_STRING, - download_type, download_type, type, E_FROM_DOWNLOAD_TYPE -); -// clang-format on -} // namespace repertory - -#endif // REPERTORY_INCLUDE_FILE_MANAGER_EVENTS_HPP_ diff --git a/repertory/librepertory/include/file_manager/file_manager.hpp b/repertory/librepertory/include/file_manager/file_manager.hpp index 5acd2ae9..80cbbec8 100644 --- a/repertory/librepertory/include/file_manager/file_manager.hpp +++ b/repertory/librepertory/include/file_manager/file_manager.hpp @@ -23,8 +23,8 @@ #define REPERTORY_INCLUDE_FILE_MANAGER_FILE_MANAGER_HPP_ #include "db/i_file_mgr_db.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/file_upload_completed.hpp" #include "file_manager/i_file_manager.hpp" #include "file_manager/i_open_file.hpp" #include "file_manager/i_upload_manager.hpp" @@ -37,7 +37,7 @@ class app_config; class i_provider; class file_manager final : public i_file_manager, public i_upload_manager { - E_CONSUMER(); + E_CONSUMER2(); private: static constexpr const std::chrono::seconds queue_wait_secs{ diff --git a/repertory/librepertory/include/types/repertory.hpp b/repertory/librepertory/include/types/repertory.hpp index 434205da..824cf781 100644 --- a/repertory/librepertory/include/types/repertory.hpp +++ b/repertory/librepertory/include/types/repertory.hpp @@ -287,7 +287,9 @@ enum class exit_code : std::int32_t { enum http_error_codes : std::int32_t { ok = 200, multiple_choices = 300, + unauthorized = 401, not_found = 404, + internal_error = 500, }; enum class lock_result { diff --git a/repertory/librepertory/src/comm/packet/client_pool.cpp b/repertory/librepertory/src/comm/packet/client_pool.cpp index a9b8b32e..b9411a23 100644 --- a/repertory/librepertory/src/comm/packet/client_pool.cpp +++ b/repertory/librepertory/src/comm/packet/client_pool.cpp @@ -21,8 +21,11 @@ */ #include "comm/packet/client_pool.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "platform/platform.hpp" #include "utils/error_utils.hpp" @@ -43,7 +46,7 @@ void client_pool::pool::execute( client_pool::pool::pool(std::uint8_t pool_size) { REPERTORY_USES_FUNCTION_NAME(); - event_system::instance().raise("client_pool"); + event_system2::instance().raise("client_pool"); for (std::uint8_t i = 0U; i < pool_size; i++) { pool_queues_.emplace_back(std::make_unique()); @@ -105,6 +108,8 @@ client_pool::pool::pool(std::uint8_t pool_size) { queue_lock.unlock(); }); } + + event_system2::instance().raise("client_pool"); } void client_pool::pool::shutdown() { @@ -150,7 +155,7 @@ void client_pool::shutdown() { return; } - event_system::instance().raise("client_pool"); + event_system2::instance().raise("client_pool"); unique_mutex_lock pool_lock(pool_mutex_); if (not shutdown_) { shutdown_ = true; @@ -160,6 +165,6 @@ void client_pool::shutdown() { pool_lookup_.clear(); } pool_lock.unlock(); - event_system::instance().raise("client_pool"); + event_system2::instance().raise("client_pool"); } } // namespace repertory diff --git a/repertory/librepertory/src/comm/packet/packet_client.cpp b/repertory/librepertory/src/comm/packet/packet_client.cpp index 3544e4f4..5712e581 100644 --- a/repertory/librepertory/src/comm/packet/packet_client.cpp +++ b/repertory/librepertory/src/comm/packet/packet_client.cpp @@ -21,7 +21,7 @@ */ #include "comm/packet/packet_client.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "platform/platform.hpp" #include "types/repertory.hpp" #include "utils/collection.hpp" @@ -190,7 +190,7 @@ auto packet_client::send(std::string_view method, packet &request, timeout request_timeout( [method, current_client]() { - event_system::instance().raise( + event_system2::instance().raise( "request", std::string{method}); packet_client::close(*current_client); }, @@ -212,7 +212,7 @@ auto packet_client::send(std::string_view method, packet &request, timeout response_timeout( [method, current_client]() { - event_system::instance().raise( + event_system2::instance().raise( "response", std::string{method}); packet_client::close(*current_client); }, diff --git a/repertory/librepertory/src/comm/packet/packet_server.cpp b/repertory/librepertory/src/comm/packet/packet_server.cpp index 6329806f..2f6ff54b 100644 --- a/repertory/librepertory/src/comm/packet/packet_server.cpp +++ b/repertory/librepertory/src/comm/packet/packet_server.cpp @@ -22,8 +22,11 @@ #include "comm/packet/packet_server.hpp" #include "comm/packet/packet.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "platform/platform.hpp" #include "types/repertory.hpp" #include "utils/error_utils.hpp" @@ -37,12 +40,13 @@ packet_server::packet_server(std::uint16_t port, std::string token, : encryption_token_(std::move(token)), closed_(std::move(closed)), message_handler_(std::move(message_handler)) { + event_system2::instance().raise("packet_server"); initialize(port, pool_size); - event_system::instance().raise("packet_server"); + event_system2::instance().raise("packet_server"); } packet_server::~packet_server() { - event_system::instance().raise("packet_server"); + event_system2::instance().raise("packet_server"); std::thread([this]() { for (std::size_t i = 0U; i < service_threads_.size(); i++) { io_context_.stop(); @@ -51,7 +55,7 @@ packet_server::~packet_server() { server_thread_->join(); server_thread_.reset(); - event_system::instance().raise("packet_server"); + event_system2::instance().raise("packet_server"); } void packet_server::add_client(connection &conn, const std::string &client_id) { diff --git a/repertory/librepertory/src/drives/fuse/fuse_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_base.cpp index 9b03f201..4af7e10f 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_base.cpp @@ -24,9 +24,7 @@ #include "drives/fuse/fuse_base.hpp" #include "app_config.hpp" -#include "drives/fuse/events.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" #include "initialize.hpp" #include "platform/platform.hpp" #include "utils/collection.hpp" @@ -90,12 +88,12 @@ fuse_base::fuse_base(app_config &config) : config_(config) { fuse_ops_.flag_reserved = 0; #endif // FUSE_USE_VERSION < 30 - E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) { + E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) { std::thread([this]() { this->shutdown(); }).detach(); }); } -fuse_base::~fuse_base() { E_CONSUMER_RELEASE(); } +fuse_base::~fuse_base() { E_CONSUMER2_RELEASE(); } auto fuse_base::access_(const char *path, int mask) -> int { REPERTORY_USES_FUNCTION_NAME(); @@ -372,13 +370,13 @@ auto fuse_base::init_impl(struct fuse_conn_info *conn) -> void * { if (not utils::file::change_to_process_directory()) { utils::error::raise_error(function_name, "failed to change to process directory"); - event_system::instance().raise(); + event_system2::instance().raise(); return this; } if (not console_enabled_ && not repertory::project_initialize()) { utils::error::raise_error(function_name, "failed to initialize repertory"); - event_system::instance().raise(); + event_system2::instance().raise(); } return this; @@ -601,7 +599,7 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int { } void fuse_base::notify_fuse_args_parsed(const std::vector &args) { - event_system::instance().raise(std::accumulate( + event_system2::instance().raise(std::accumulate( args.begin(), args.end(), std::string(), [](auto &&command_line, auto &&arg) -> auto { command_line += (command_line.empty() ? arg : (" " + std::string(arg))); @@ -700,7 +698,7 @@ void fuse_base::raise_fuse_event(std::string_view function_name, if (((config_.get_event_level() >= fuse_event::level) && (ret != 0)) || (config_.get_event_level() >= event_level::trace)) { std::string func{function_name}; - event_system::instance().raise( + event_system2::instance().raise( utils::string::right_trim(func, '_'), std::string{api_path}, ret); } } @@ -751,8 +749,8 @@ auto fuse_base::setxattr_(const char *path, const char *name, const char *value, void fuse_base::shutdown() { const auto res = unmount(get_mount_location()); - event_system::instance().raise(get_mount_location(), - std::to_string(res)); + event_system2::instance().raise(get_mount_location(), + std::to_string(res)); } #if defined(__APPLE__) diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp index 465fe138..0faa62d7 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive.cpp @@ -30,9 +30,7 @@ #include "drives/fuse/remotefuse/remote_server.hpp" #include "events/consumers/console_consumer.hpp" #include "events/consumers/logging_consumer.hpp" -#include "events/event_system.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/drive_mount_result.hpp" #include "events/types/drive_mounted.hpp" #include "events/types/drive_unmount_pending.hpp" diff --git a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp index e247bad6..f082eef3 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_drive_base.cpp @@ -23,7 +23,6 @@ #include "drives/fuse/fuse_drive_base.hpp" -#include "events/events.hpp" #include "platform/platform.hpp" #include "providers/i_provider.hpp" #include "utils/common.hpp" @@ -34,8 +33,8 @@ auto fuse_drive_base::access_impl(std::string api_path, int mask) -> api_error { return check_access(api_path, mask); } -auto fuse_drive_base::check_access(const std::string &api_path, - int mask) const -> api_error { +auto fuse_drive_base::check_access(const std::string &api_path, int mask) const + -> api_error { REPERTORY_USES_FUNCTION_NAME(); api_meta_map meta; @@ -136,8 +135,9 @@ auto fuse_drive_base::check_and_perform( return action(meta); } -auto fuse_drive_base::check_open_flags( - int flags, int mask, const api_error &fail_error) -> api_error { +auto fuse_drive_base::check_open_flags(int flags, int mask, + const api_error &fail_error) + -> api_error { return (((flags & mask) == 0) ? api_error::success : fail_error); } @@ -194,8 +194,8 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path, return ret; } -auto fuse_drive_base::check_readable(int flags, - const api_error &fail_error) -> api_error { +auto fuse_drive_base::check_readable(int flags, const api_error &fail_error) + -> api_error { auto mode = (flags & O_ACCMODE); return ((mode == O_WRONLY) ? fail_error : api_error::success); } @@ -253,13 +253,16 @@ auto fuse_drive_base::get_uid_from_meta(const api_meta_map &meta) -> uid_t { } #if defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters( - const char *name, const uint32_t &position, std::string &attribute_name, - const std::string &api_path) -> api_error { +auto fuse_drive_base::parse_xattr_parameters(const char *name, + const uint32_t &position, + std::string &attribute_name, + const std::string &api_path) + -> api_error { #else // !defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters( - const char *name, std::string &attribute_name, - const std::string &api_path) -> api_error { +auto fuse_drive_base::parse_xattr_parameters(const char *name, + std::string &attribute_name, + const std::string &api_path) + -> api_error { #endif // defined(__APPLE__) auto res = api_path.empty() ? api_error::bad_address : api_error::success; if (res != api_error::success) { @@ -292,9 +295,11 @@ auto fuse_drive_base::parse_xattr_parameters( std::string &attribute_name, const std::string &api_path) -> api_error { auto res = parse_xattr_parameters(name, position, attribute_name, api_path); #else // !defined(__APPLE__) -auto fuse_drive_base::parse_xattr_parameters( - const char *name, const char *value, size_t size, - std::string &attribute_name, const std::string &api_path) -> api_error { +auto fuse_drive_base::parse_xattr_parameters(const char *name, + const char *value, size_t size, + std::string &attribute_name, + const std::string &api_path) + -> api_error { auto res = parse_xattr_parameters(name, attribute_name, api_path); #endif // defined(__APPLE__) if (res != api_error::success) { diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp index de6b83d2..9f1e8cce 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_fuse_drive.cpp @@ -24,12 +24,9 @@ #include "drives/fuse/remotefuse/remote_fuse_drive.hpp" #include "app_config.hpp" -#include "drives/fuse/events.hpp" #include "events/consumers/console_consumer.hpp" #include "events/consumers/logging_consumer.hpp" -#include "events/event_system.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/drive_mount_result.hpp" #include "events/types/drive_mounted.hpp" #include "events/types/drive_unmount_pending.hpp" @@ -262,7 +259,7 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * { if (remote_instance_->fuse_init() != 0) { utils::error::raise_error(function_name, "failed to connect to remote server"); - event_system::instance().raise(); + event_system2::instance().raise(); } else { server_ = std::make_shared(config_); server_->start(); diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index 86f0843f..40474e1a 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -27,7 +27,7 @@ #include "comm/packet/packet.hpp" #include "drives/directory_iterator.hpp" #include "drives/remote/remote_open_file_table.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "platform/platform.hpp" #include "types/remote.hpp" #include "types/repertory.hpp" @@ -43,7 +43,7 @@ namespace repertory::remote_fuse { (((config_.get_event_level() >= remote_fuse_server_event::level) && \ ((ret) < 0)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise(std::string{func}, \ + event_system2::instance().raise(std::string{func}, \ file, ret) // clang-format off diff --git a/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp b/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp index c86604cb..def95154 100644 --- a/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp +++ b/repertory/librepertory/src/drives/remote/remote_open_file_table.cpp @@ -21,8 +21,7 @@ */ #include "drives/remote/remote_open_file_table.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" #include "utils/collection.hpp" #include "utils/config.hpp" #include "utils/utils.hpp" diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp index 52a7a43c..b2d35c27 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp @@ -24,7 +24,6 @@ #include "app_config.hpp" #include "drives/winfsp/remotewinfsp/i_remote_instance.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/drive_mounted.hpp" #include "events/types/drive_unmount_pending.hpp" #include "events/types/drive_unmounted.hpp" @@ -38,7 +37,7 @@ namespace repertory::remote_winfsp { (((config_.get_event_level() >= remote_winfsp_client_event::level) && \ ((ret) != STATUS_SUCCESS)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise( \ + event_system2::instance().raise( \ std::string{func}, file, ret) // clang-format off diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp index d6391a53..ff306dea 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp @@ -32,8 +32,7 @@ #include "drives/fuse/remotefuse/i_remote_instance.hpp" #include "drives/remote/remote_open_file_table.hpp" #include "drives/winfsp/remotewinfsp/i_remote_instance.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" #include "platform/platform.hpp" #include "types/remote.hpp" #include "types/repertory.hpp" @@ -49,7 +48,7 @@ namespace repertory::remote_winfsp { (((config_.get_event_level() >= remote_winfsp_server_event::level) && \ ((ret) != STATUS_SUCCESS)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise( \ + event_system2::instance().raise( \ std::string{func}, file, ret) // clang-format off diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp index 2411b85c..93a4b369 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_winfsp_drive.cpp @@ -27,7 +27,6 @@ #include "events/consumers/console_consumer.hpp" #include "events/consumers/logging_consumer.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/drive_mount_failed.hpp" #include "events/types/drive_mount_result.hpp" #include "platform/platform.hpp" @@ -105,7 +104,7 @@ remote_winfsp_drive::remote_winfsp_drive(app_config &config, config_(config), lock_(lock), factory_(std::move(factory)) { - E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) { + E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) { std::thread([this]() { this->shutdown(); }).detach(); }); } diff --git a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp index 792851fa..66706283 100644 --- a/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp +++ b/repertory/librepertory/src/drives/winfsp/winfsp_drive.cpp @@ -28,7 +28,6 @@ #include "events/consumers/console_consumer.hpp" #include "events/consumers/logging_consumer.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/drive_mount_failed.hpp" #include "events/types/drive_mount_result.hpp" #include "events/types/drive_mounted.hpp" @@ -66,7 +65,7 @@ E_SIMPLE(drive_stop_timed_out, info); (((config_.get_event_level() >= winfsp_event::level) && \ (ret != STATUS_SUCCESS)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise(std::string{func}, file, ret) + event_system2::instance().raise(std::string{func}, file, ret) winfsp_drive::winfsp_service::winfsp_service( lock_data &lock, winfsp_drive &drive, std::vector drive_args, @@ -146,11 +145,11 @@ auto winfsp_drive::winfsp_service::OnStart(ULONG /*Argc*/, PWSTR * /*Argv*/) auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS { REPERTORY_USES_FUNCTION_NAME(); - event_system::instance().raise(); + event_system2::instance().raise(); timeout stop_timeout( []() { - event_system::instance().raise(); + event_system2::instance().raise(); app_config::set_stop_requested(); }, 30s); @@ -158,7 +157,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS { stop_timeout.disable(); - event_system::instance().raise(); + event_system2::instance().raise(); if (not lock_.set_mount_state(false, "", -1)) { utils::error::raise_error(function_name, "failed to set mount state"); @@ -170,7 +169,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS { winfsp_drive::winfsp_drive(app_config &config, lock_data &lock, i_provider &provider) : provider_(provider), config_(config), lock_(lock) { - E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) { + E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) { std::thread([this]() { this->shutdown(); }).detach(); }); } diff --git a/repertory/librepertory/src/events/consumers/console_consumer.cpp b/repertory/librepertory/src/events/consumers/console_consumer.cpp index 54c04698..c8233684 100644 --- a/repertory/librepertory/src/events/consumers/console_consumer.cpp +++ b/repertory/librepertory/src/events/consumers/console_consumer.cpp @@ -62,40 +62,12 @@ console_consumer::console_consumer(event_level level) { set_level(level); - E_SUBSCRIBE_ALL(process_event); E_SUBSCRIBE2_ALL(process_event2); E_SUBSCRIBE2_EXACT(event_level_changed, [](auto &&event) { set_level(event.level); }); } -console_consumer::~console_consumer() { - E_CONSUMER_RELEASE(); - E_CONSUMER2_RELEASE(); -} - -void console_consumer::process_event(const event &evt) { - switch (evt.get_event_level()) { - case event_level::critical: - spdlog::get("console")->critical(evt.get_single_line()); - break; - case event_level::error: - spdlog::get("console")->error(evt.get_single_line()); - break; - case event_level::warn: - spdlog::get("console")->warn(evt.get_single_line()); - break; - case event_level::info: - spdlog::get("console")->info(evt.get_single_line()); - break; - case event_level::debug: - spdlog::get("console")->debug(evt.get_single_line()); - break; - case event_level::trace: - default: - spdlog::get("console")->trace(evt.get_single_line()); - break; - } -} +console_consumer::~console_consumer() { E_CONSUMER2_RELEASE(); } void console_consumer::process_event2(const i_event &evt) { switch (evt.get_event_level()) { diff --git a/repertory/librepertory/src/events/consumers/logging_consumer.cpp b/repertory/librepertory/src/events/consumers/logging_consumer.cpp index 672f6582..d7447136 100644 --- a/repertory/librepertory/src/events/consumers/logging_consumer.cpp +++ b/repertory/librepertory/src/events/consumers/logging_consumer.cpp @@ -21,7 +21,6 @@ */ #include "events/consumers/logging_consumer.hpp" -#include "events/events.hpp" #include "events/i_event.hpp" #include "events/types/event_level_changed.hpp" #include "spdlog/async.h" @@ -67,40 +66,12 @@ logging_consumer::logging_consumer(event_level level, set_level(level); - E_SUBSCRIBE_ALL(process_event); E_SUBSCRIBE2_ALL(process_event2); E_SUBSCRIBE2_EXACT(event_level_changed, [](auto &&event) { set_level(event.level); }); } -logging_consumer::~logging_consumer() { - E_CONSUMER_RELEASE(); - E_CONSUMER2_RELEASE(); -} - -void logging_consumer::process_event(const event &evt) { - switch (evt.get_event_level()) { - case event_level::critical: - spdlog::get("file")->critical(evt.get_single_line()); - break; - case event_level::error: - spdlog::get("file")->error(evt.get_single_line()); - break; - case event_level::warn: - spdlog::get("file")->warn(evt.get_single_line()); - break; - case event_level::info: - spdlog::get("file")->info(evt.get_single_line()); - break; - case event_level::debug: - spdlog::get("file")->debug(evt.get_single_line()); - break; - case event_level::trace: - default: - spdlog::get("file")->trace(evt.get_single_line()); - break; - } -} +logging_consumer::~logging_consumer() { E_CONSUMER2_RELEASE(); } void logging_consumer::process_event2(const i_event &evt) { switch (evt.get_event_level()) { diff --git a/repertory/librepertory/src/events/t_event_system.cpp b/repertory/librepertory/src/events/t_event_system.cpp deleted file mode 100644 index 3b058840..00000000 --- a/repertory/librepertory/src/events/t_event_system.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#include "events/t_event_system.hpp" - -#include "events/event.hpp" - -namespace repertory { -template -auto t_event_system::instance() -> t_event_system & { - return event_system_; -} - -template -t_event_system t_event_system::event_system_; - -template class t_event_system; -} // namespace repertory diff --git a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp index 8b9ef623..c1ab1090 100644 --- a/repertory/librepertory/src/file_manager/cache_size_mgr.cpp +++ b/repertory/librepertory/src/file_manager/cache_size_mgr.cpp @@ -23,7 +23,7 @@ #include "app_config.hpp" #include "events/event.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "types/startup_exception.hpp" #include "utils/file_utils.hpp" @@ -66,7 +66,7 @@ auto cache_size_mgr::expand(std::uint64_t size) -> api_error { while (not get_stop_requested() && cache_size_ > max_cache_size && cache_dir.count() > 1U) { if (last_cache_size != cache_size_) { - event_system::instance().raise(cache_size_, + event_system2::instance().raise(cache_size_, max_cache_size); last_cache_size = cache_size_; } @@ -115,7 +115,7 @@ auto cache_size_mgr::shrink(std::uint64_t size) -> api_error { if (cache_size_ >= size) { cache_size_ -= size; } else { - event_system::instance().raise(cache_size_, size); + event_system2::instance().raise(cache_size_, size); cache_size_ = 0U; } diff --git a/repertory/librepertory/src/file_manager/file_manager.cpp b/repertory/librepertory/src/file_manager/file_manager.cpp index 0731a8ca..2e5028e0 100644 --- a/repertory/librepertory/src/file_manager/file_manager.cpp +++ b/repertory/librepertory/src/file_manager/file_manager.cpp @@ -23,9 +23,18 @@ #include "app_config.hpp" #include "db/file_mgr_db.hpp" +#include "events/types/file_upload_failed.hpp" +#include "events/types/file_upload_not_found.hpp" +#include "events/types/file_upload_queued.hpp" +#include "events/types/file_upload_removed.hpp" +#include "events/types/file_upload_retry.hpp" +#include "events/types/filesystem_item_evicted.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "file_manager/cache_size_mgr.hpp" #include "file_manager/direct_open_file.hpp" -#include "file_manager/events.hpp" #include "file_manager/open_file.hpp" #include "file_manager/open_file_base.hpp" #include "file_manager/ring_buffer_open_file.hpp" @@ -49,17 +58,15 @@ file_manager::file_manager(app_config &config, i_provider &provider) return; } - E_SUBSCRIBE_EXACT(file_upload_completed, - [this](const file_upload_completed &completed) { - this->upload_completed(completed); - }); + E_SUBSCRIBE2_EXACT(file_upload_completed, + [this](auto &&event) { this->upload_completed(event); }); } file_manager::~file_manager() { stop(); mgr_db_.reset(); - E_CONSUMER_RELEASE(); + E_CONSUMER2_RELEASE(); } void file_manager::close(std::uint64_t handle) { @@ -111,7 +118,7 @@ void file_manager::close_timed_out_files() { for (auto &closeable_file : closeable_list) { closeable_file->close(); - event_system::instance().raise( + event_system2::instance().raise( closeable_file->get_api_path()); } closeable_list.clear(); @@ -187,8 +194,8 @@ auto file_manager::evict_file(const std::string &api_path) -> bool { auto removed = remove_source_and_shrink_cache(api_path, fsi.source_path, fsi.size, allocated); if (removed) { - event_system::instance().raise(api_path, - fsi.source_path); + event_system2::instance().raise( + api_path, function_name, fsi.source_path); } return removed; @@ -490,7 +497,7 @@ auto file_manager::open(const std::string &api_path, bool directory, ? download_type::ring_buffer : preferred_type); if (not directory) { - event_system::instance().raise( + event_system2::instance().raise( fsi.api_path, fsi.source_path, type); } @@ -524,6 +531,8 @@ void file_manager::queue_upload(const i_open_file &file) { void file_manager::queue_upload(const std::string &api_path, const std::string &source_path, bool no_lock) { + REPERTORY_USES_FUNCTION_NAME(); + if (provider_.is_read_only()) { return; } @@ -540,10 +549,11 @@ void file_manager::queue_upload(const std::string &api_path, source_path, })) { remove_resume(api_path, source_path, true); - event_system::instance().raise(api_path, source_path); + event_system2::instance().raise(api_path, function_name, + source_path); } else { - event_system::instance().raise( - api_path, source_path, "failed to queue upload"); + event_system2::instance().raise( + api_path, "failed to queue upload", function_name, source_path); } if (not no_lock) { @@ -597,8 +607,8 @@ void file_manager::remove_resume(const std::string &api_path, } if (mgr_db_->remove_resume(api_path)) { - event_system::instance().raise(api_path, - source_path); + event_system2::instance().raise(api_path, + source_path); } if (not no_lock) { @@ -674,7 +684,8 @@ void file_manager::remove_upload(const std::string &api_path, bool no_lock) { } if (removed) { - event_system::instance().raise(api_path); + event_system2::instance().raise(api_path, + function_name); } if (not no_lock) { @@ -838,6 +849,7 @@ void file_manager::start() { return; } + event_system2::instance().raise("file_manager"); stop_requested_ = false; polling::instance().set_callback({ @@ -848,6 +860,7 @@ void file_manager::start() { if (provider_.is_read_only()) { stop_requested_ = false; + event_system2::instance().raise("file_manager"); return; } @@ -860,14 +873,14 @@ void file_manager::start() { filesystem_item fsi{}; auto res = provider_.get_filesystem_item(entry.api_path, false, fsi); if (res != api_error::success) { - event_system::instance().raise( + event_system2::instance().raise( entry.api_path, entry.source_path, "failed to get filesystem item|" + api_error_to_string(res)); continue; } if (entry.source_path != fsi.source_path) { - event_system::instance().raise( + event_system2::instance().raise( fsi.api_path, fsi.source_path, "source path mismatch|expected|" + entry.source_path + "|actual|" + fsi.source_path); @@ -876,7 +889,7 @@ void file_manager::start() { auto opt_size = utils::file::file{fsi.source_path}.size(); if (not opt_size.has_value()) { - event_system::instance().raise( + event_system2::instance().raise( fsi.api_path, fsi.source_path, "failed to get file size: " + std::to_string(utils::get_last_error_code())); @@ -885,7 +898,7 @@ void file_manager::start() { auto file_size{opt_size.value()}; if (file_size != fsi.size) { - event_system::instance().raise( + event_system2::instance().raise( fsi.api_path, fsi.source_path, "file size mismatch|expected|" + std::to_string(fsi.size) + "|actual|" + std::to_string(file_size)); @@ -899,15 +912,15 @@ void file_manager::start() { : 0U, fsi, provider_, entry.read_state, *this); open_file_lookup_[entry.api_path] = closeable_file; - event_system::instance().raise(fsi.api_path, - fsi.source_path); + event_system2::instance().raise(fsi.api_path, + fsi.source_path); } catch (const std::exception &ex) { utils::error::raise_error(function_name, ex, "query error"); } } upload_thread_ = std::make_unique([this] { upload_handler(); }); - event_system::instance().raise("file_manager"); + event_system2::instance().raise("file_manager"); } void file_manager::stop() { @@ -915,7 +928,7 @@ void file_manager::stop() { return; } - event_system::instance().raise("file_manager"); + event_system2::instance().raise("file_manager"); stop_requested_ = true; @@ -949,7 +962,7 @@ void file_manager::stop() { upload_thread_.reset(); - event_system::instance().raise("file_manager"); + event_system2::instance().raise("file_manager"); } void file_manager::store_resume(const i_open_file &file) { @@ -963,12 +976,12 @@ void file_manager::store_resume(const i_open_file &file) { file.get_read_state(), file.get_source_path(), })) { - event_system::instance().raise( + event_system2::instance().raise( file.get_api_path(), file.get_source_path()); return; } - event_system::instance().raise( + event_system2::instance().raise( file.get_api_path(), file.get_source_path(), "failed to store resume"); } @@ -1002,31 +1015,28 @@ void file_manager::upload_completed(const file_upload_completed &evt) { unique_mutex_lock upload_lock(upload_mtx_); - if (not utils::string::to_bool(evt.get_cancelled().get())) { - auto err = api_error_from_string(evt.get_result().get()); - if (err == api_error::success) { - if (not mgr_db_->remove_upload_active( - evt.get_api_path().get())) { + if (not evt.cancelled) { + if (evt.error == api_error::success) { + if (not mgr_db_->remove_upload_active(evt.api_path)) { utils::error::raise_api_path_error( - function_name, evt.get_api_path().get(), - evt.get_source().get(), + function_name, evt.api_path, evt.source_path, evt.error, "failed to remove from upload_active table"); } - upload_lookup_.erase(evt.get_api_path()); + upload_lookup_.erase(evt.api_path); } else { bool exists{}; - auto res = provider_.is_file(evt.get_api_path(), exists); + auto res = provider_.is_file(evt.api_path, exists); if ((res == api_error::success && not exists) || - not utils::file::file(evt.get_source().get()).exists()) { - event_system::instance().raise( - evt.get_api_path(), evt.get_source()); - remove_upload(evt.get_api_path(), true); + not utils::file::file(evt.source_path).exists()) { + event_system2::instance().raise( + evt.api_path, function_name, evt.source_path); + remove_upload(evt.api_path, true); } else { - event_system::instance().raise( - evt.get_api_path(), evt.get_source(), err); + event_system2::instance().raise( + evt.api_path, evt.error, function_name, evt.source_path); - queue_upload(evt.get_api_path(), evt.get_source(), true); + queue_upload(evt.api_path, evt.source_path, true); upload_notify_.wait_for(upload_lock, queue_wait_secs); } } @@ -1055,8 +1065,8 @@ void file_manager::upload_handler() { switch (res) { case api_error::item_not_found: { should_wait = false; - event_system::instance().raise( - entry->api_path, entry->source_path); + event_system2::instance().raise( + entry->api_path, function_name, entry->source_path); remove_upload(entry->api_path, true); } break; @@ -1079,8 +1089,8 @@ void file_manager::upload_handler() { } break; default: { - event_system::instance().raise( - entry->api_path, entry->source_path, res); + event_system2::instance().raise( + entry->api_path, res, function_name, entry->source_path); queue_upload(entry->api_path, entry->source_path, true); } break; } diff --git a/repertory/librepertory/src/file_manager/open_file.cpp b/repertory/librepertory/src/file_manager/open_file.cpp index 0fa5564e..f3becd26 100644 --- a/repertory/librepertory/src/file_manager/open_file.cpp +++ b/repertory/librepertory/src/file_manager/open_file.cpp @@ -22,7 +22,6 @@ #include "file_manager/open_file.hpp" #include "file_manager/cache_size_mgr.hpp" -#include "file_manager/events.hpp" #include "file_manager/file_manager.hpp" #include "file_manager/i_upload_manager.hpp" #include "platform/platform.hpp" @@ -294,7 +293,7 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active, auto data_size = (chunk == read_state.size() - 1U) ? get_last_chunk_size() : get_chunk_size(); if (get_active_downloads().empty() && (read_state.count() == 0U)) { - event_system::instance().raise(get_api_path(), + event_system2::instance().raise(get_api_path(), get_source_path()); } @@ -317,16 +316,16 @@ void open_file::download_chunk(std::size_t chunk, bool skip_active, auto progress = (static_cast(state.count()) / static_cast(state.size())) * 100.0; - event_system::instance().raise( + event_system2::instance().raise( get_api_path(), get_source_path(), progress); if (state.all() && not notified_) { notified_ = true; - event_system::instance().raise( + event_system2::instance().raise( get_api_path(), get_source_path(), get_api_error()); } } else if (not notified_) { notified_ = true; - event_system::instance().raise( + event_system2::instance().raise( get_api_path(), get_source_path(), get_api_error()); } lock.unlock(); diff --git a/repertory/librepertory/src/file_manager/open_file_base.cpp b/repertory/librepertory/src/file_manager/open_file_base.cpp index b4b132df..0be29c37 100644 --- a/repertory/librepertory/src/file_manager/open_file_base.cpp +++ b/repertory/librepertory/src/file_manager/open_file_base.cpp @@ -21,8 +21,11 @@ */ #include "file_manager/open_file_base.hpp" -#include "events/event_system.hpp" -#include "file_manager/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/filesystem_item_closed.hpp" +#include "events/types/filesystem_item_handle_closed.hpp" +#include "events/types/filesystem_item_handle_opened.hpp" +#include "events/types/filesystem_item_opened.hpp" #include "providers/i_provider.hpp" #include "utils/path.hpp" @@ -90,15 +93,17 @@ open_file_base::open_file_base( } void open_file_base::add(std::uint64_t handle, open_file_data ofd) { + REPERTORY_USES_FUNCTION_NAME(); + recur_mutex_lock file_lock(file_mtx_); open_data_[handle] = ofd; if (open_data_.size() == 1U) { - event_system::instance().raise( - fsi_.api_path, fsi_.source_path, fsi_.directory); + event_system2::instance().raise( + fsi_.api_path, fsi_.directory, function_name, fsi_.source_path); } - event_system::instance().raise( - fsi_.api_path, handle, fsi_.source_path, fsi_.directory); + event_system2::instance().raise( + fsi_.api_path, fsi_.directory, function_name, handle, fsi_.source_path); } auto open_file_base::can_close() const -> bool { @@ -309,23 +314,29 @@ void open_file_base::notify_io() { } void open_file_base::remove(std::uint64_t handle) { + REPERTORY_USES_FUNCTION_NAME(); + recur_mutex_lock file_lock(file_mtx_); if (open_data_.find(handle) == open_data_.end()) { return; } open_data_.erase(handle); - event_system::instance().raise( - fsi_.api_path, handle, fsi_.source_path, fsi_.directory, modified_); + event_system2::instance().raise( + fsi_.api_path, modified_, fsi_.directory, function_name, handle, + fsi_.source_path); if (not open_data_.empty()) { return; } - event_system::instance().raise( - fsi_.api_path, fsi_.source_path, fsi_.directory, modified_); + event_system2::instance().raise( + fsi_.api_path, modified_, fsi_.directory, function_name, + fsi_.source_path); } void open_file_base::remove_all() { + REPERTORY_USES_FUNCTION_NAME(); + recur_mutex_lock file_lock(file_mtx_); if (open_data_.empty()) { return; @@ -335,12 +346,14 @@ void open_file_base::remove_all() { open_data_.clear(); for (const auto &data : open_data) { - event_system::instance().raise( - fsi_.api_path, data.first, fsi_.source_path, fsi_.directory, modified_); + event_system2::instance().raise( + fsi_.api_path, modified_, fsi_.directory, function_name, data.first, + fsi_.source_path); } - event_system::instance().raise( - fsi_.api_path, fsi_.source_path, fsi_.directory, modified_); + event_system2::instance().raise( + fsi_.api_path, modified_, fsi_.directory, function_name, + fsi_.source_path); } void open_file_base::reset_timeout() { diff --git a/repertory/librepertory/src/file_manager/ring_buffer_base.cpp b/repertory/librepertory/src/file_manager/ring_buffer_base.cpp index 2447e326..3e2a5a1b 100644 --- a/repertory/librepertory/src/file_manager/ring_buffer_base.cpp +++ b/repertory/librepertory/src/file_manager/ring_buffer_base.cpp @@ -21,8 +21,7 @@ */ #include "file_manager/ring_buffer_base.hpp" -#include "events/event_system.hpp" -#include "file_manager/events.hpp" +#include "events/event_system2.hpp" #include "file_manager/open_file_base.hpp" #include "platform/platform.hpp" #include "providers/i_provider.hpp" @@ -65,7 +64,7 @@ auto ring_buffer_base::check_start() -> api_error { return api_error::success; } - event_system::instance().raise(get_api_path(), + event_system2::instance().raise(get_api_path(), get_source_path()); reader_thread_ = std::make_unique([this]() { reader_thread(); }); @@ -156,7 +155,7 @@ auto ring_buffer_base::download_chunk(std::size_t chunk, bool skip_active) auto progress = (static_cast(chunk + 1U) / static_cast(total_chunks_)) * 100.0; - event_system::instance().raise( + event_system2::instance().raise( get_api_path(), get_source_path(), progress); } } @@ -292,7 +291,7 @@ void ring_buffer_base::reader_thread() { download_chunk(next_chunk, true); } - event_system::instance().raise( + event_system2::instance().raise( get_api_path(), get_source_path(), api_error::download_stopped); } diff --git a/repertory/librepertory/src/file_manager/upload.cpp b/repertory/librepertory/src/file_manager/upload.cpp index dcc2b1f2..2d120a91 100644 --- a/repertory/librepertory/src/file_manager/upload.cpp +++ b/repertory/librepertory/src/file_manager/upload.cpp @@ -21,8 +21,8 @@ */ #include "file_manager/upload.hpp" -#include "events/event_system.hpp" -#include "file_manager/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/file_upload_completed.hpp" #include "platform/platform.hpp" #include "providers/i_provider.hpp" #include "utils/error_utils.hpp" @@ -60,7 +60,8 @@ void upload::upload_thread() { utils::get_last_error_code(), "failed to reset modified time"); } - event_system::instance().raise( - get_api_path(), get_source_path(), get_api_error(), cancelled_); + event_system2::instance().raise( + get_api_path(), cancelled_, get_api_error(), function_name, + get_source_path()); } } // namespace repertory diff --git a/repertory/librepertory/src/platform/unix_platform.cpp b/repertory/librepertory/src/platform/unix_platform.cpp index 0910251d..b52a02b5 100644 --- a/repertory/librepertory/src/platform/unix_platform.cpp +++ b/repertory/librepertory/src/platform/unix_platform.cpp @@ -24,8 +24,8 @@ #include "platform/unix_platform.hpp" #include "app_config.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/filesystem_item_added.hpp" #include "providers/i_provider.hpp" #include "types/startup_exception.hpp" #include "utils/common.hpp" @@ -225,6 +225,8 @@ auto create_meta_attributes( auto provider_meta_handler(i_provider &provider, bool directory, const api_file &file) -> api_error { + REPERTORY_USES_FUNCTION_NAME(); + const auto meta = create_meta_attributes( file.accessed_date, directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE, @@ -235,8 +237,8 @@ auto provider_meta_handler(i_provider &provider, bool directory, file.modified_date); auto res = provider.set_item_meta(file.api_path, meta); if (res == api_error::success) { - event_system::instance().raise( - file.api_path, file.api_parent, directory); + event_system2::instance().raise( + file.api_parent, file.api_path, directory, function_name); } return res; diff --git a/repertory/librepertory/src/platform/win32_platform.cpp b/repertory/librepertory/src/platform/win32_platform.cpp index 47c4392d..4c753a61 100644 --- a/repertory/librepertory/src/platform/win32_platform.cpp +++ b/repertory/librepertory/src/platform/win32_platform.cpp @@ -23,14 +23,14 @@ #include "platform/win32_platform.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/filesystem_item_added.hpp" #include "providers/i_provider.hpp" #include "utils/error_utils.hpp" namespace repertory { -auto lock_data::get_mount_state(const provider_type & /*pt*/, - json &mount_state) -> bool { +auto lock_data::get_mount_state(const provider_type & /*pt*/, json &mount_state) + -> bool { const auto ret = get_mount_state(mount_state); if (ret) { const auto mount_id = @@ -196,6 +196,8 @@ auto create_meta_attributes( auto provider_meta_handler(i_provider &provider, bool directory, const api_file &file) -> api_error { + REPERTORY_USES_FUNCTION_NAME(); + const auto meta = create_meta_attributes( file.accessed_date, directory ? FILE_ATTRIBUTE_DIRECTORY : FILE_ATTRIBUTE_ARCHIVE, @@ -204,8 +206,8 @@ auto provider_meta_handler(i_provider &provider, bool directory, file.source_path, 0u, file.modified_date); auto res = provider.set_item_meta(file.api_path, meta); if (res == api_error::success) { - event_system::instance().raise( - file.api_path, file.api_parent, directory); + event_system2::instance().raise( + file.api_parent, file.api_path, directory, function_name); } return res; diff --git a/repertory/librepertory/src/providers/base_provider.cpp b/repertory/librepertory/src/providers/base_provider.cpp index 9179d1b2..a351ef51 100644 --- a/repertory/librepertory/src/providers/base_provider.cpp +++ b/repertory/librepertory/src/providers/base_provider.cpp @@ -23,12 +23,20 @@ #include "app_config.hpp" #include "db/meta_db.hpp" -#include "events/event_system.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/directory_remove_failed.hpp" #include "events/types/directory_removed.hpp" #include "events/types/directory_removed_externally.hpp" +#include "events/types/file_remove_failed.hpp" +#include "events/types/file_removed.hpp" +#include "events/types/file_removed_externally.hpp" +#include "events/types/orphaned_file_detected.hpp" +#include "events/types/orphaned_file_processing_failed.hpp" +#include "events/types/orphaned_source_file_detected.hpp" +#include "events/types/orphaned_source_file_removed.hpp" +#include "events/types/provider_offline.hpp" +#include "events/types/provider_upload_begin.hpp" +#include "events/types/provider_upload_end.hpp" #include "file_manager/cache_size_mgr.hpp" #include "file_manager/i_file_manager.hpp" #include "platform/platform.hpp" @@ -504,32 +512,35 @@ void base_provider::process_removed_files(std::deque removed_list, orphaned_directory, {utils::path::strip_to_file_name(item.source_path) + '_' + parts[parts.size() - 1U]}); - event_system::instance().raise(item.source_path); + event_system2::instance().raise(function_name, + item.source_path); if (not utils::file::reset_modified_time(item.source_path)) { - event_system::instance().raise( - item.source_path, orphaned_file, + event_system2::instance().raise( + orphaned_file, "reset modified failed|" + - std::to_string(utils::get_last_error_code())); + std::to_string(utils::get_last_error_code()), + function_name, item.source_path); continue; } if (not utils::file::file(item.source_path).copy_to(orphaned_file, true)) { [[maybe_unused]] auto removed = utils::file::file{orphaned_file}.remove(); - event_system::instance().raise( - item.source_path, orphaned_file, - "copy failed|" + std::to_string(utils::get_last_error_code())); + event_system2::instance().raise( + orphaned_file, + "copy failed|" + std::to_string(utils::get_last_error_code()), + function_name, item.source_path); continue; } if (not fm_->evict_file(item.api_path)) { - event_system::instance().raise( - item.source_path, orphaned_file, "eviction failed"); + event_system2::instance().raise( + orphaned_file, "eviction failed", function_name, item.source_path); continue; } db3_->remove_api_path(item.api_path); - event_system::instance().raise(item.api_path, - item.source_path); + event_system2::instance().raise(item.api_path, + item.source_path); } } @@ -615,12 +626,14 @@ void base_provider::remove_deleted_items(stop_type &stop_requested) { } auto base_provider::remove_file(const std::string &api_path) -> api_error { + REPERTORY_USES_FUNCTION_NAME(); + const auto notify_end = [&api_path](api_error error) -> api_error { if (error == api_error::success) { - event_system::instance().raise(api_path); + event_system2::instance().raise(api_path, function_name); } else { - event_system::instance().raise( - api_path, api_error_to_string(error)); + event_system2::instance().raise(api_path, error, + function_name); } return error; @@ -648,8 +661,8 @@ auto base_provider::remove_file(const std::string &api_path) -> api_error { return notify_end(res); } if (not exists) { - event_system::instance().raise( - api_path, api_error_to_string(api_error::item_not_found)); + event_system2::instance().raise( + api_path, api_error::item_not_found, function_name); return remove_file_meta(); } @@ -738,14 +751,14 @@ void base_provider::remove_unmatched_source_files(stop_type &stop_requested) { continue; } - event_system::instance().raise( - source_file->get_path()); + event_system2::instance().raise( + function_name, source_file->get_path()); if (not source_file->remove()) { continue; } - event_system::instance().raise( - source_file->get_path()); + event_system2::instance().raise( + function_name, source_file->get_path()); } } @@ -762,6 +775,8 @@ auto base_provider::set_item_meta(const std::string &api_path, auto base_provider::start(api_item_added_callback api_item_added, i_file_manager *mgr) -> bool { + REPERTORY_USES_FUNCTION_NAME(); + api_item_added_ = api_item_added; fm_ = mgr; @@ -795,8 +810,8 @@ auto base_provider::start(api_item_added_callback api_item_added, continue; } - event_system::instance().raise( - cfg.get_host_config().host_name_or_ip, + event_system2::instance().raise( + function_name, cfg.get_host_config().host_name_or_ip, cfg.get_host_config().api_port); std::this_thread::sleep_for(1s); } @@ -830,14 +845,14 @@ auto base_provider::upload_file(const std::string &api_path, const auto notify_end = [&api_path, &source_path](api_error error) -> api_error { - event_system::instance().raise(api_path, source_path, - error); + event_system2::instance().raise( + api_path, error, function_name, source_path); return error; }; try { - event_system::instance().raise(api_path, - source_path); + event_system2::instance().raise( + api_path, function_name, source_path); return notify_end(upload_file_impl(api_path, source_path, stop_requested)); } catch (const std::exception &e) { diff --git a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp index 35aa4892..e35bac7d 100644 --- a/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp +++ b/repertory/librepertory/src/providers/encrypt/encrypt_provider.cpp @@ -22,10 +22,14 @@ #include "providers/encrypt/encrypt_provider.hpp" #include "db/file_db.hpp" -#include "events/event_system.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #include "events/types/directory_removed_externally.hpp" +#include "events/types/file_removed_externally.hpp" +#include "events/types/filesystem_item_added.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "types/repertory.hpp" #include "types/startup_exception.hpp" #include "utils/collection.hpp" @@ -644,9 +648,9 @@ auto encrypt_provider::process_directory_entry( api_error_to_string(result))); } - event_system::instance().raise( - current_api_path, - utils::path::get_parent_api_path(current_api_path), true); + event_system2::instance().raise( + utils::path::get_parent_api_path(current_api_path), + current_api_path, true, function_name); } else { if (result != api_error::success) { std::runtime_error( @@ -722,8 +726,8 @@ auto encrypt_provider::process_directory_entry( return false; } - event_system::instance().raise( - api_path, api_parent, false); + event_system2::instance().raise( + api_parent, api_path, false, function_name); } return true; @@ -856,7 +860,7 @@ void encrypt_provider::remove_deleted_files(stop_type &stop_requested) { continue; } - event_system::instance().raise( + event_system2::instance().raise( item.api_path, item.source_path); } }, @@ -871,6 +875,7 @@ auto encrypt_provider::start(api_item_added_callback /*api_item_added*/, return false; } + event_system2::instance().raise("encrypt_provider"); db_ = create_file_db(config_); std::string source_path; @@ -907,14 +912,14 @@ auto encrypt_provider::start(api_item_added_callback /*api_item_added*/, [this](auto &&stop_requested) { remove_deleted_files(stop_requested); }, }); - event_system::instance().raise("encrypt_provider"); + event_system2::instance().raise("encrypt_provider"); return true; } void encrypt_provider::stop() { - event_system::instance().raise("encrypt_provider"); + event_system2::instance().raise("encrypt_provider"); polling::instance().remove_callback("check_deleted"); db_.reset(); - event_system::instance().raise("encrypt_provider"); + event_system2::instance().raise("encrypt_provider"); } } // namespace repertory diff --git a/repertory/librepertory/src/providers/s3/s3_provider.cpp b/repertory/librepertory/src/providers/s3/s3_provider.cpp index c33e9bb0..b56bc3dd 100644 --- a/repertory/librepertory/src/providers/s3/s3_provider.cpp +++ b/repertory/librepertory/src/providers/s3/s3_provider.cpp @@ -23,8 +23,11 @@ #include "app_config.hpp" #include "comm/i_http_comm.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "file_manager/i_file_manager.hpp" #include "types/repertory.hpp" #include "types/s3.hpp" @@ -1044,16 +1047,18 @@ auto s3_provider::set_meta_key(const std::string &api_path, api_meta_map &meta) auto s3_provider::start(api_item_added_callback api_item_added, i_file_manager *mgr) -> bool { - event_system::instance().raise("s3_provider"); + event_system2::instance().raise("s3_provider"); s3_config_ = get_config().get_s3_config(); get_comm().enable_s3_path_style(s3_config_.use_path_style); - return base_provider::start(api_item_added, mgr); + auto ret = base_provider::start(api_item_added, mgr); + event_system2::instance().raise("s3_provider"); + return ret } void s3_provider::stop() { - event_system::instance().raise("s3_provider"); + event_system2::instance().raise("s3_provider"); base_provider::stop(); - event_system::instance().raise("s3_provider"); + event_system2::instance().raise("s3_provider"); } auto s3_provider::upload_file_impl(const std::string &api_path, diff --git a/repertory/librepertory/src/providers/sia/sia_provider.cpp b/repertory/librepertory/src/providers/sia/sia_provider.cpp index 24dae7d6..9003eddf 100644 --- a/repertory/librepertory/src/providers/sia/sia_provider.cpp +++ b/repertory/librepertory/src/providers/sia/sia_provider.cpp @@ -23,7 +23,11 @@ #include "app_config.hpp" #include "comm/i_http_comm.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "file_manager/i_file_manager.hpp" #include "providers/base_provider.hpp" #include "providers/s3/s3_provider.hpp" @@ -740,15 +744,17 @@ auto sia_provider::rename_file(const std::string &from_api_path, auto sia_provider::start(api_item_added_callback api_item_added, i_file_manager *mgr) -> bool { - event_system::instance().raise("sia_provider"); + event_system2::instance().raise("sia_provider"); sia_config_ = get_config().get_sia_config(); - return base_provider::start(api_item_added, mgr); + auto ret = base_provider::start(api_item_added, mgr); + event_system2::instance().raise("sia_provider"); + return ret; } void sia_provider::stop() { - event_system::instance().raise("sia_provider"); + event_system2::instance().raise("sia_provider"); base_provider::stop(); - event_system::instance().raise("sia_provider"); + event_system2::instance().raise("sia_provider"); } auto sia_provider::upload_file_impl(const std::string &api_path, diff --git a/repertory/librepertory/src/rpc/server/full_server.cpp b/repertory/librepertory/src/rpc/server/full_server.cpp index 32b25bd1..ea4917ed 100644 --- a/repertory/librepertory/src/rpc/server/full_server.cpp +++ b/repertory/librepertory/src/rpc/server/full_server.cpp @@ -22,8 +22,9 @@ #include "rpc/server/full_server.hpp" #include "app_config.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/file_pinned.hpp" +#include "events/types/file_unpinned.hpp" #include "file_manager/cache_size_mgr.hpp" #include "file_manager/i_file_manager.hpp" #include "providers/i_provider.hpp" @@ -46,7 +47,7 @@ void full_server::handle_get_directory_items(const httplib::Request &req, }) .dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void full_server::handle_get_drive_information(const httplib::Request & /*req*/, @@ -60,7 +61,7 @@ void full_server::handle_get_drive_information(const httplib::Request & /*req*/, }) .dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void full_server::handle_get_open_files(const httplib::Request & /*req*/, @@ -75,7 +76,7 @@ void full_server::handle_get_open_files(const httplib::Request & /*req*/, })); } res.set_content(open_files.dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void full_server::handle_get_pinned_files(const httplib::Request & /*req*/, @@ -85,7 +86,7 @@ void full_server::handle_get_pinned_files(const httplib::Request & /*req*/, }) .dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void full_server::handle_get_pinned_status(const httplib::Request &req, @@ -99,7 +100,7 @@ void full_server::handle_get_pinned_status(const httplib::Request &req, if (result != api_error::success) { utils::error::raise_api_path_error(function_name, api_path, result, "failed to get pinned status"); - res.status = 500; + res.status = http_error_codes::internal_error; return; } @@ -110,7 +111,7 @@ void full_server::handle_get_pinned_status(const httplib::Request &req, }) .dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void full_server::handle_pin_file(const httplib::Request &req, @@ -124,7 +125,7 @@ void full_server::handle_pin_file(const httplib::Request &req, if (result != api_error::success) { utils::error::raise_api_path_error(function_name, api_path, result, "failed to pin file"); - res.status = 500; + res.status = http_error_codes::internal_error; return; } @@ -135,10 +136,10 @@ void full_server::handle_pin_file(const httplib::Request &req, } if (exists) { - event_system::instance().raise(api_path); + event_system2::instance().raise(api_path, function_name); } - res.status = exists ? 200 : 404; + res.status = exists ? http_error_codes::ok : http_error_codes::not_found; } void full_server::handle_unpin_file(const httplib::Request &req, @@ -152,7 +153,7 @@ void full_server::handle_unpin_file(const httplib::Request &req, if (result != api_error::success) { utils::error::raise_api_path_error(function_name, api_path, result, "failed to unpin file"); - res.status = 500; + res.status = http_error_codes::internal_error; return; } @@ -163,10 +164,10 @@ void full_server::handle_unpin_file(const httplib::Request &req, } if (exists) { - event_system::instance().raise(api_path); + event_system2::instance().raise(api_path); } - res.status = exists ? 200 : 404; + res.status = exists ? http_error_codes::ok : http_error_codes::not_found; } void full_server::initialize(httplib::Server &inst) { diff --git a/repertory/librepertory/src/rpc/server/server.cpp b/repertory/librepertory/src/rpc/server/server.cpp index 4b643d2c..f79b9baf 100644 --- a/repertory/librepertory/src/rpc/server/server.cpp +++ b/repertory/librepertory/src/rpc/server/server.cpp @@ -22,8 +22,11 @@ #include "rpc/server/server.hpp" #include "app_config.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "utils/base64.hpp" #include "utils/error_utils.hpp" @@ -82,7 +85,7 @@ void server::handle_get_config(const httplib::Request & /*req*/, httplib::Response &res) { auto data = config_.get_json(); res.set_content(data.dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void server::handle_get_config_value_by_name(const httplib::Request &req, @@ -90,7 +93,7 @@ void server::handle_get_config_value_by_name(const httplib::Request &req, auto name = req.get_param_value("name"); auto data = json({{"value", config_.get_value_by_name(name)}}); res.set_content(data.dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void server::handle_set_config_value_by_name(const httplib::Request &req, @@ -100,13 +103,13 @@ void server::handle_set_config_value_by_name(const httplib::Request &req, json data = {{"value", config_.set_value_by_name(name, value)}}; res.set_content(data.dump(), "application/json"); - res.status = 200; + res.status = http_error_codes::ok; } void server::handle_unmount(const httplib::Request & /*req*/, httplib::Response &res) { - event_system::instance().raise(); - res.status = 200; + event_system2::instance().raise(); + res.status = http_error_codes::ok; } void server::initialize(httplib::Server &inst) { @@ -141,7 +144,8 @@ void server::start() { return; } - event_system::instance().raise("server"); + event_system2::instance().raise("server"); + server_ = std::make_unique(); server_->set_exception_handler([](const httplib::Request &req, @@ -162,7 +166,7 @@ void server::start() { } res.set_content(data.dump(), "application/json"); - res.status = 500; + res.status = http_error_codes::internal_error; }); server_->set_pre_routing_handler( @@ -171,7 +175,7 @@ void server::start() { return httplib::Server::HandlerResponse::Unhandled; } - res.status = 401; + res.status = http_error_codes::unauthorized; return httplib::Server::HandlerResponse::Handled; }); @@ -179,6 +183,7 @@ void server::start() { server_thread_ = std::make_unique( [this]() { server_->listen("127.0.0.1", config_.get_api_port()); }); + event_system2::instance().raise("server"); } void server::stop() { @@ -187,7 +192,7 @@ void server::stop() { return; } - event_system::instance().raise("server"); + event_system2::instance().raise("server"); server_->stop(); @@ -202,6 +207,6 @@ void server::stop() { server_.reset(); lock.unlock(); - event_system::instance().raise("server"); + event_system2::instance().raise("server"); } } // namespace repertory diff --git a/repertory/librepertory/src/utils/error_utils.cpp b/repertory/librepertory/src/utils/error_utils.cpp index 63793cfb..e2fd03e9 100644 --- a/repertory/librepertory/src/utils/error_utils.cpp +++ b/repertory/librepertory/src/utils/error_utils.cpp @@ -21,8 +21,8 @@ */ #include "utils/error_utils.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/repertory_exception.hpp" #include "types/repertory.hpp" #include "utils/error.hpp" @@ -53,67 +53,64 @@ std::unique_ptr handler{([]() -> auto * { namespace repertory::utils::error { void raise_error(std::string_view function, std::string_view msg) { - event_system::instance().raise( - static_cast(function), static_cast(msg)); + event_system2::instance().raise( + function, static_cast(msg)); } void raise_error(std::string_view function, const api_error &err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, static_cast(msg) + "|err|" + api_error_to_string(err)); } void raise_error(std::string_view function, const std::exception &exception) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, "err|" + std::string(exception.what() == nullptr ? "unknown error" : exception.what())); } void raise_error(std::string_view function, const std::exception &exception, std::string_view msg) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, static_cast(msg) + "|err|" + (exception.what() == nullptr ? "unknown error" : exception.what())); } void raise_error(std::string_view function, const json &err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|err|" + err.dump(2)); + event_system2::instance().raise( + function, static_cast(msg) + "|err|" + err.dump(2)); } void raise_error(std::string_view function, std::int64_t err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|err|" + std::to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|err|" + std::to_string(err)); } void raise_error(std::string_view function, const api_error &err, std::string_view file_path, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|sp|" + - static_cast(file_path) + "|err|" + - api_error_to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|sp|" + + static_cast(file_path) + "|err|" + + api_error_to_string(err)); } void raise_error(std::string_view function, std::int64_t err, std::string_view file_path, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|sp|" + - static_cast(file_path) + "|err|" + std::to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|sp|" + + static_cast(file_path) + "|err|" + + std::to_string(err)); } void raise_error(std::string_view function, const std::exception &exception, std::string_view file_path, std::string_view msg) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, static_cast(msg) + "|sp|" + static_cast(file_path) + "|err|" + (exception.what() == nullptr ? "unknown error" : exception.what())); @@ -121,25 +118,24 @@ void raise_error(std::string_view function, const std::exception &exception, void raise_api_path_error(std::string_view function, std::string_view api_path, const api_error &err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|ap|" + - static_cast(api_path) + "|err|" + - api_error_to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + + static_cast(api_path) + "|err|" + + api_error_to_string(err)); } void raise_api_path_error(std::string_view function, std::string_view api_path, std::int64_t err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|ap|" + - static_cast(api_path) + "|err|" + std::to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + + static_cast(api_path) + "|err|" + + std::to_string(err)); } void raise_api_path_error(std::string_view function, std::string_view api_path, const std::exception &exception) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, "ap|" + static_cast(api_path) + "|err|" + (exception.what() == nullptr ? "unknown error" : exception.what())); } @@ -147,8 +143,8 @@ void raise_api_path_error(std::string_view function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path, const std::exception &exception, std::string_view msg) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + static_cast(api_path) + "|err|" + (exception.what() == nullptr ? "unknown error" : exception.what())); @@ -157,39 +153,36 @@ void raise_api_path_error(std::string_view function, std::string_view api_path, void raise_api_path_error(std::string_view function, std::string_view api_path, std::string_view source_path, const api_error &err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|ap|" + - static_cast(api_path) + "|sp|" + - static_cast(source_path) + "|err|" + - api_error_to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + + static_cast(api_path) + "|sp|" + + static_cast(source_path) + "|err|" + + api_error_to_string(err)); } void raise_api_path_error(std::string_view function, std::string_view api_path, std::string_view source_path, std::int64_t err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|ap|" + - static_cast(api_path) + "|sp|" + - static_cast(source_path) + "|err|" + - std::to_string(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + + static_cast(api_path) + "|sp|" + + static_cast(source_path) + "|err|" + + std::to_string(err)); } void raise_api_path_error(std::string_view function, std::string_view api_path, const json &err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|ap|" + - static_cast(api_path) + "|err|" + err.dump(2)); + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + + static_cast(api_path) + "|err|" + err.dump(2)); } void raise_api_path_error(std::string_view function, std::string_view api_path, std::string_view source_path, const std::exception &exception, std::string_view msg) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, static_cast(msg) + "|ap|" + static_cast(api_path) + "|sp|" + static_cast(source_path) + "|err|" + @@ -198,17 +191,17 @@ void raise_api_path_error(std::string_view function, std::string_view api_path, void raise_url_error(std::string_view function, std::string_view url, CURLcode err, std::string_view msg) { - event_system::instance().raise( - static_cast(function), - static_cast(msg) + "|url|" + static_cast(url) + - "|err|" + curl_easy_strerror(err)); + event_system2::instance().raise( + function, static_cast(msg) + "|url|" + + static_cast(url) + "|err|" + + curl_easy_strerror(err)); } void raise_url_error(std::string_view function, std::string_view url, std::string_view source_path, const std::exception &exception) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, "url|" + static_cast(url) + "|sp|" + static_cast(source_path) + "|err|" + (exception.what() == nullptr ? "unknown error" : exception.what())); @@ -217,8 +210,8 @@ void raise_url_error(std::string_view function, std::string_view url, void raise_url_error(std::string_view function, std::string_view url, std::string_view source_path, const std::exception &exception, std::string_view msg) { - event_system::instance().raise( - static_cast(function), + event_system2::instance().raise( + function, static_cast(msg) + "|url|" + static_cast(url) + "|sp|" + static_cast(source_path) + "|err|" + (exception.what() == nullptr ? "unknown error" : exception.what())); diff --git a/repertory/librepertory/src/utils/polling.cpp b/repertory/librepertory/src/utils/polling.cpp index fbda7798..8fc601a8 100644 --- a/repertory/librepertory/src/utils/polling.cpp +++ b/repertory/librepertory/src/utils/polling.cpp @@ -22,8 +22,13 @@ #include "utils/polling.hpp" #include "app_config.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/polling_item_begin.hpp" +#include "events/types/polling_item_end.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "utils/tasks.hpp" namespace repertory { @@ -31,6 +36,8 @@ polling polling::instance_; void polling::frequency_thread( std::function get_frequency_seconds, frequency freq) { + REPERTORY_USES_FUNCTION_NAME(); + while (not get_stop_requested()) { unique_mutex_lock lock(mutex_); auto futures = std::accumulate( @@ -44,13 +51,14 @@ void polling::frequency_thread( [this, &freq, item](auto &&task_stopped) { if (config_->get_event_level() == event_level::trace || freq != frequency::second) { - event_system::instance().raise( - item.first); + event_system2::instance().raise( + function_name, item.first); } item.second.action(task_stopped); if (config_->get_event_level() == event_level::trace || freq != frequency::second) { - event_system::instance().raise(item.first); + event_system2::instance().raise( + function_name, item.first); } }, }); @@ -94,7 +102,7 @@ void polling::start(app_config *config) { return; } - event_system::instance().raise("polling"); + event_system2::instance().raise("polling"); config_ = config; stop_requested_ = false; @@ -133,6 +141,7 @@ void polling::start(app_config *config) { this->frequency_thread([]() -> std::uint32_t { return 1U; }, frequency::second); }); + event_system2::instance().raise("polling"); } void polling::stop() { @@ -141,7 +150,7 @@ void polling::stop() { return; } - event_system::instance().raise("polling"); + event_system2::instance().raise("polling"); stop_requested_ = true; @@ -160,6 +169,6 @@ void polling::stop() { thread.reset(); } - event_system::instance().raise("polling"); + event_system2::instance().raise("polling"); } } // namespace repertory diff --git a/repertory/librepertory/src/utils/single_thread_service_base.cpp b/repertory/librepertory/src/utils/single_thread_service_base.cpp index 1d7fdb01..514ca324 100644 --- a/repertory/librepertory/src/utils/single_thread_service_base.cpp +++ b/repertory/librepertory/src/utils/single_thread_service_base.cpp @@ -22,8 +22,11 @@ #include "utils/single_thread_service_base.hpp" #include "app_config.hpp" -#include "events/event_system.hpp" -#include "events/events.hpp" +#include "events/event_system2.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "types/repertory.hpp" namespace repertory { @@ -45,7 +48,8 @@ void single_thread_service_base::start() { stop_requested_ = false; on_start(); thread_ = std::make_unique([this]() { - event_system::instance().raise(service_name_); + event_system2::instance().raise(service_name_); + event_system2::instance().raise(service_name_); while (not get_stop_requested()) { service_function(); } @@ -58,7 +62,7 @@ void single_thread_service_base::stop() { return; } - event_system::instance().raise(service_name_); + event_system2::instance().raise(service_name_); stop_requested_ = true; @@ -73,6 +77,6 @@ void single_thread_service_base::stop() { on_stop(); - event_system::instance().raise(service_name_); + event_system2::instance().raise(service_name_); } } // namespace repertory diff --git a/repertory/repertory_test/include/fixtures/file_db_fixture.hpp b/repertory/repertory_test/include/fixtures/file_db_fixture.hpp index 3987b2d4..09233bd6 100644 --- a/repertory/repertory_test/include/fixtures/file_db_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/file_db_fixture.hpp @@ -28,7 +28,7 @@ #include "db/impl/rdb_file_db.hpp" #include "db/impl/sqlite_file_db.hpp" #include "events/consumers/console_consumer.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" namespace repertory { template class file_db_test : public ::testing::Test { diff --git a/repertory/repertory_test/include/fixtures/file_mgr_db_fixture.hpp b/repertory/repertory_test/include/fixtures/file_mgr_db_fixture.hpp index 1733de01..5cc8910e 100644 --- a/repertory/repertory_test/include/fixtures/file_mgr_db_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/file_mgr_db_fixture.hpp @@ -28,7 +28,7 @@ #include "db/impl/rdb_file_mgr_db.hpp" #include "db/impl/sqlite_file_mgr_db.hpp" #include "events/consumers/console_consumer.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" namespace repertory { template class file_mgr_db_test : public ::testing::Test { diff --git a/repertory/repertory_test/include/fixtures/meta_db_fixture.hpp b/repertory/repertory_test/include/fixtures/meta_db_fixture.hpp index 1f68c08a..2a2a24ba 100644 --- a/repertory/repertory_test/include/fixtures/meta_db_fixture.hpp +++ b/repertory/repertory_test/include/fixtures/meta_db_fixture.hpp @@ -28,7 +28,7 @@ #include "db/impl/rdb_meta_db.hpp" #include "db/impl/sqlite_meta_db.hpp" #include "events/consumers/console_consumer.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" namespace repertory { template class meta_db_test : public ::testing::Test { diff --git a/repertory/repertory_test/include/test_common.hpp b/repertory/repertory_test/include/test_common.hpp index 0b943812..56ac9b3f 100644 --- a/repertory/repertory_test/include/test_common.hpp +++ b/repertory/repertory_test/include/test_common.hpp @@ -27,8 +27,6 @@ REPERTORY_IGNORE_WARNINGS_ENABLE() REPERTORY_IGNORE_WARNINGS_DISABLE() #include "events/consumers/console_consumer.hpp" -#include "events/event_system.hpp" #include "events/event_system2.hpp" -#include "events/events.hpp" #endif // REPERTORY_TEST_INCLUDE_TEST_COMMON_HPP_ diff --git a/repertory/repertory_test/include/utils/event_capture.hpp b/repertory/repertory_test/include/utils/event_capture.hpp index a717d04f..c41eae2b 100644 --- a/repertory/repertory_test/include/utils/event_capture.hpp +++ b/repertory/repertory_test/include/utils/event_capture.hpp @@ -29,20 +29,20 @@ namespace repertory { class event_capture final { - E_CONSUMER(); + E_CONSUMER2(); public: explicit event_capture(std::vector event_names, std::vector non_fired_event_names = {}) : event_names_(std::move(event_names)), non_fired_event_names_(std::move(non_fired_event_names)) { - E_SUBSCRIBE_ALL(process_event); + E_SUBSCRIBE2_ALL(process_event); } ~event_capture() { wait_for_empty(); - E_CONSUMER_RELEASE(); + E_CONSUMER2_RELEASE(); EXPECT_TRUE(event_names_.empty()); for (const auto &event_name : event_names_) { diff --git a/repertory/repertory_test/src/config_test.cpp b/repertory/repertory_test/src/config_test.cpp index 2eda652c..7fa95c85 100644 --- a/repertory/repertory_test/src/config_test.cpp +++ b/repertory/repertory_test/src/config_test.cpp @@ -22,7 +22,7 @@ #include "test_common.hpp" #include "app_config.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "utils/common.hpp" #include "utils/file_utils.hpp" #include "utils/path.hpp" diff --git a/repertory/repertory_test/src/file_manager_test.cpp b/repertory/repertory_test/src/file_manager_test.cpp index 1d406bd8..cbdb353e 100644 --- a/repertory/repertory_test/src/file_manager_test.cpp +++ b/repertory/repertory_test/src/file_manager_test.cpp @@ -22,8 +22,11 @@ #include "test_common.hpp" #include "app_config.hpp" +#include "events/types/service_start_begin.hpp" +#include "events/types/service_start_end.hpp" +#include "events/types/service_stop_begin.hpp" +#include "events/types/service_stop_end.hpp" #include "file_manager/cache_size_mgr.hpp" -#include "file_manager/events.hpp" #include "file_manager/file_manager.hpp" #include "file_manager/i_open_file.hpp" #include "mocks/mock_open_file.hpp" @@ -84,23 +87,23 @@ std::atomic file_manager_test::inst{0U}; TEST_F(file_manager_test, can_start_and_stop) { EXPECT_CALL(mp, is_read_only()).WillRepeatedly(Return(false)); - event_consumer consumer("service_started", [](const event &evt) { - const auto &evt2 = dynamic_cast(evt); - EXPECT_STREQ("file_manager", evt2.get_service().get().c_str()); + event_consumer consumer("service_start_begin", [](const i_event &evt) { + const auto &evt2 = dynamic_cast(evt); + EXPECT_STREQ("file_manager", evt2.service_name.c_str()); }); - event_consumer consumer2("service_shutdown_begin", [](const event &evt) { - const auto &evt2 = dynamic_cast(evt); - EXPECT_STREQ("file_manager", evt2.get_service().get().c_str()); + event_consumer consumer2("service_stop_begin", [](const i_event &evt) { + const auto &evt2 = dynamic_cast(evt); + EXPECT_STREQ("file_manager", evt2.service_name.c_str()); }); - event_consumer consumer3("service_shutdown_end", [](const event &evt) { - const auto &evt2 = dynamic_cast(evt); - EXPECT_STREQ("file_manager", evt2.get_service().get().c_str()); + event_consumer consumer3("service_stop_end", [](const i_event &evt) { + const auto &evt2 = dynamic_cast(evt); + EXPECT_STREQ("file_manager", evt2.service_name.c_str()); }); event_capture capture({ - "service_started", - "service_shutdown_begin", - "service_shutdown_end", + "service_start_begin", + "service_stop_begin", + "service_stop_end", }); file_manager mgr(*cfg, mp); @@ -155,25 +158,22 @@ TEST_F(file_manager_test, can_create_and_close_file) { return api_error::success; }); - event_consumer consumer("filesystem_item_opened", [&](const event &evt) { + event_consumer consumer("filesystem_item_opened", [&](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); - EXPECT_STREQ("/test_create.txt", - evt2.get_api_path().get().c_str()); - EXPECT_STREQ(source_path.c_str(), - evt2.get_source().get().c_str()); - EXPECT_STREQ("0", evt2.get_directory().get().c_str()); + EXPECT_STREQ("/test_create.txt", evt2.api_path.c_str()); + EXPECT_STREQ(source_path.c_str(), evt2.source_path.c_str()); + EXPECT_FALSE(evt2.directory); }); - event_consumer ec2("filesystem_item_handle_opened", [&](const event &evt) { - const auto &evt2 = - dynamic_cast(evt); - EXPECT_STREQ("/test_create.txt", - evt2.get_api_path().get().c_str()); - EXPECT_STREQ(source_path.c_str(), - evt2.get_source().get().c_str()); - EXPECT_STREQ("0", evt2.get_directory().get().c_str()); - EXPECT_STREQ("1", evt2.get_handle().get().c_str()); - }); + event_consumer ec2( + "filesystem_item_handle_opened", [&](const i_event &evt) { + const auto &evt2 = + dynamic_cast(evt); + EXPECT_STREQ("/test_create.txt", evt2.api_path.c_str()); + EXPECT_STREQ(source_path.c_str(), evt2.source_path.c_str()); + EXPECT_FALSE(evt2.directory); + EXPECT_EQ(std::uint64_t(1U), evt2.handle); + }); #if defined(_WIN32) EXPECT_EQ(api_error::success, @@ -187,7 +187,7 @@ TEST_F(file_manager_test, can_create_and_close_file) { EXPECT_EQ(std::uint64_t(1U), handle); } - event_consumer ec3("filesystem_item_closed", [&](const event &evt) { + event_consumer ec3("filesystem_item_closed", [&](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_create.txt", evt2.get_api_path().get().c_str()); @@ -196,7 +196,7 @@ TEST_F(file_manager_test, can_create_and_close_file) { EXPECT_STREQ("0", evt2.get_directory().get().c_str()); }); - event_consumer ec4("filesystem_item_handle_closed", [&](const event &evt) { + event_consumer ec4("filesystem_item_handle_closed", [&](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_create.txt", evt2.get_api_path().get().c_str()); @@ -262,7 +262,7 @@ TEST_F(file_manager_test, can_open_and_close_file) { return api_error::success; }); - event_consumer consumer("filesystem_item_opened", [&](const event &evt) { + event_consumer consumer("filesystem_item_opened", [&](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_open.txt", evt2.get_api_path().get().c_str()); @@ -271,16 +271,17 @@ TEST_F(file_manager_test, can_open_and_close_file) { EXPECT_STREQ("0", evt2.get_directory().get().c_str()); }); - event_consumer ec2("filesystem_item_handle_opened", [&](const event &evt) { - const auto &evt2 = - dynamic_cast(evt); - EXPECT_STREQ("/test_open.txt", - evt2.get_api_path().get().c_str()); - EXPECT_STREQ(source_path.c_str(), - evt2.get_source().get().c_str()); - EXPECT_STREQ("0", evt2.get_directory().get().c_str()); - EXPECT_STREQ("1", evt2.get_handle().get().c_str()); - }); + event_consumer ec2( + "filesystem_item_handle_opened", [&](const i_event &evt) { + const auto &evt2 = + dynamic_cast(evt); + EXPECT_STREQ("/test_open.txt", + evt2.get_api_path().get().c_str()); + EXPECT_STREQ(source_path.c_str(), + evt2.get_source().get().c_str()); + EXPECT_STREQ("0", evt2.get_directory().get().c_str()); + EXPECT_STREQ("1", evt2.get_handle().get().c_str()); + }); std::shared_ptr open_file; #if defined(_WIN32) @@ -295,7 +296,7 @@ TEST_F(file_manager_test, can_open_and_close_file) { EXPECT_EQ(std::uint64_t(1U), handle); } - event_consumer ec3("filesystem_item_closed", [&](const event &evt) { + event_consumer ec3("filesystem_item_closed", [&](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_open.txt", evt2.get_api_path().get().c_str()); @@ -304,7 +305,7 @@ TEST_F(file_manager_test, can_open_and_close_file) { EXPECT_STREQ("0", evt2.get_directory().get().c_str()); }); - event_consumer ec4("filesystem_item_handle_closed", [&](const event &evt) { + event_consumer ec4("filesystem_item_handle_closed", [&](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_open.txt", evt2.get_api_path().get().c_str()); @@ -400,7 +401,7 @@ TEST_F(file_manager_test, {utils::create_uuid_string()}); event_consumer consumer( - "download_resume_added", [&source_path](const event &evt) { + "download_resume_added", [&source_path](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_write_partial_download.txt", evt2.get_api_path().get().c_str()); @@ -522,7 +523,7 @@ TEST_F(file_manager_test, mgr.start(); - event_consumer es2("download_restored", [&source_path](const event &evt) { + event_consumer es2("download_restored", [&source_path](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_write_partial_download.txt", evt2.get_api_path().get().c_str()); @@ -555,20 +556,21 @@ TEST_F(file_manager_test, upload_occurs_after_write_if_fully_downloaded) { {utils::create_uuid_string()}); event_consumer consumer( - "file_upload_queued", [&source_path](const event &evt) { + "file_upload_queued", [&source_path](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_write_full_download.txt", evt2.get_api_path().get().c_str()); EXPECT_STREQ(source_path.c_str(), evt2.get_source().get().c_str()); }); - event_consumer es2("file_upload_completed", [&source_path](const event &evt) { - const auto &evt2 = dynamic_cast(evt); - EXPECT_STREQ("/test_write_full_download.txt", - evt2.get_api_path().get().c_str()); - EXPECT_STREQ(source_path.c_str(), - evt2.get_source().get().c_str()); - }); + event_consumer es2( + "file_upload_completed", [&source_path](const i_event &evt) { + const auto &evt2 = dynamic_cast(evt); + EXPECT_STREQ("/test_write_full_download.txt", + evt2.get_api_path().get().c_str()); + EXPECT_STREQ(source_path.c_str(), + evt2.get_source().get().c_str()); + }); auto now = utils::time::get_time_now(); auto meta = create_meta_attributes( @@ -1445,7 +1447,7 @@ TEST_F(file_manager_test, file_is_closed_after_download_timeout) { auto source_path = utils::path::combine(cfg->get_cache_directory(), {utils::create_uuid_string()}); - event_consumer consumer("item_timeout", [](const event &evt) { + event_consumer consumer("item_timeout", [](const i_event &evt) { const auto &evt2 = dynamic_cast(evt); EXPECT_STREQ("/test_download_timeout.txt", evt2.get_api_path().get().c_str()); diff --git a/repertory/repertory_test/src/providers_test.cpp b/repertory/repertory_test/src/providers_test.cpp index dd6b9e2c..3c6aaa4e 100644 --- a/repertory/repertory_test/src/providers_test.cpp +++ b/repertory/repertory_test/src/providers_test.cpp @@ -24,7 +24,7 @@ #include "test_common.hpp" #include "comm/curl/curl_comm.hpp" -#include "events/event_system.hpp" +#include "events/event_system2.hpp" #include "file_manager/file_manager.hpp" #include "platform/platform.hpp" #include "providers/encrypt/encrypt_provider.hpp"