mirror of
				https://github.com/velopack/velopack.git
				synced 2025-10-25 15:19:22 +00:00 
			
		
		
		
	callback handling
This commit is contained in:
		| @@ -50,8 +50,8 @@ extern "C" { | |||||||
|  |  | ||||||
| typedef void* vpkc_update_manager_t; | typedef void* vpkc_update_manager_t; | ||||||
| typedef void (*vpkc_progress_callback_t)(size_t progress); | typedef void (*vpkc_progress_callback_t)(size_t progress); | ||||||
| typedef void (*vpkc_log_callback_t)(char* pszLevel, char* pszMessage); | typedef void (*vpkc_log_callback_t)(const char* pszLevel, const char* pszMessage); | ||||||
| typedef void (*vpkc_hook_callback_t)(char* pszAppVersion); | typedef void (*vpkc_hook_callback_t)(const char* pszAppVersion); | ||||||
|  |  | ||||||
| typedef struct { | typedef struct { | ||||||
|     bool AllowVersionDowngrade; |     bool AllowVersionDowngrade; | ||||||
|   | |||||||
| @@ -9,20 +9,58 @@ struct HookCallbackManager { | |||||||
|     vpkc_hook_callback_t after_update = nullptr; |     vpkc_hook_callback_t after_update = nullptr; | ||||||
|     vpkc_hook_callback_t first_run = nullptr; |     vpkc_hook_callback_t first_run = nullptr; | ||||||
|     vpkc_hook_callback_t restarted = nullptr; |     vpkc_hook_callback_t restarted = nullptr; | ||||||
|     void install_hook(::rust::String app_version) const {}; |      | ||||||
|     void update_hook(::rust::String app_version) const {}; |     void install_hook(::rust::String app_version) const { | ||||||
|     void obsolete_hook(::rust::String app_version) const {}; |         if (after_install) { | ||||||
|     void uninstall_hook(::rust::String app_version) const {}; |             after_install(app_version.c_str()); | ||||||
|     void firstrun_hook(::rust::String app_version) const {}; |         } | ||||||
|     void restarted_hook(::rust::String app_version) const {}; |     }; | ||||||
|  |      | ||||||
|  |     void update_hook(::rust::String app_version) const { | ||||||
|  |         if (after_update) { | ||||||
|  |             after_update(app_version.c_str()); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  |      | ||||||
|  |     void obsolete_hook(::rust::String app_version) const { | ||||||
|  |         if (before_update) { | ||||||
|  |             before_update(app_version.c_str()); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  |      | ||||||
|  |     void uninstall_hook(::rust::String app_version) const { | ||||||
|  |         if (before_uninstall) { | ||||||
|  |             before_uninstall(app_version.c_str()); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  |      | ||||||
|  |     void firstrun_hook(::rust::String app_version) const { | ||||||
|  |         if (first_run) { | ||||||
|  |             first_run(app_version.c_str()); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
|  |      | ||||||
|  |     void restarted_hook(::rust::String app_version) const { | ||||||
|  |         if (restarted) { | ||||||
|  |             restarted(app_version.c_str()); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct DownloadCallbackManager { | struct DownloadCallbackManager { | ||||||
|     vpkc_progress_callback_t progress_cb = nullptr; |     vpkc_progress_callback_t progress_cb = nullptr; | ||||||
|     void download_progress(int16_t progress) const {}; |     void download_progress(int16_t progress) const { | ||||||
|  |         if (progress_cb) { | ||||||
|  |             progress_cb(progress); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct LoggerCallbackManager { | struct LoggerCallbackManager { | ||||||
|     vpkc_log_callback_t lob_cb = nullptr; |     vpkc_log_callback_t lob_cb = nullptr; | ||||||
|     void log(::rust::String level, ::rust::String message) const {}; |     void log(::rust::String level, ::rust::String message) const { | ||||||
|  |         if (lob_cb) { | ||||||
|  |             lob_cb(level.c_str(), message.c_str()); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
| }; | }; | ||||||
		Reference in New Issue
	
	Block a user