diff --git a/BUILD.bazel b/BUILD.bazel index 5bd521fb77..a5c465af3d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -10,6 +10,7 @@ genrule( "//c-toxcore/toxcore:tox.h", "//c-toxcore/toxcore:tox_dispatch.h", "//c-toxcore/toxcore:tox_events.h", + "//c-toxcore/toxcore:tox_log_level.h", "//c-toxcore/toxcore:tox_options.h", "//c-toxcore/toxcore:tox_private.h", "//c-toxcore/toxencryptsave:toxencryptsave.h", @@ -19,6 +20,7 @@ genrule( "tox/tox.h", "tox/tox_dispatch.h", "tox/tox_events.h", + "tox/tox_log_level.h", "tox/tox_options.h", "tox/tox_private.h", "tox/toxencryptsave.h", @@ -28,6 +30,7 @@ genrule( cp $(location //c-toxcore/toxcore:tox.h) $(GENDIR)/c-toxcore/tox/tox.h cp $(location //c-toxcore/toxcore:tox_dispatch.h) $(GENDIR)/c-toxcore/tox/tox_dispatch.h cp $(location //c-toxcore/toxcore:tox_events.h) $(GENDIR)/c-toxcore/tox/tox_events.h + cp $(location //c-toxcore/toxcore:tox_log_level.h) $(GENDIR)/c-toxcore/tox/tox_log_level.h cp $(location //c-toxcore/toxcore:tox_options.h) $(GENDIR)/c-toxcore/tox/tox_options.h cp $(location //c-toxcore/toxcore:tox_private.h) $(GENDIR)/c-toxcore/tox/tox_private.h cp $(location //c-toxcore/toxencryptsave:toxencryptsave.h) $(GENDIR)/c-toxcore/tox/toxencryptsave.h diff --git a/CMakeLists.txt b/CMakeLists.txt index eca52b0c3e..ea7d7a1e3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,13 +341,15 @@ set(toxcore_SOURCES toxcore/timed_auth.h toxcore/tox_api.c toxcore/tox.c + toxcore/tox.h toxcore/tox_dispatch.c toxcore/tox_dispatch.h toxcore/tox_event.c toxcore/tox_event.h toxcore/tox_events.c toxcore/tox_events.h - toxcore/tox.h + toxcore/tox_log_level.c + toxcore/tox_log_level.h toxcore/tox_options.c toxcore/tox_options.h toxcore/tox_private.c @@ -371,6 +373,7 @@ endif() set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium) set(toxcore_API_HEADERS ${toxcore_SOURCE_DIR}/toxcore/tox.h^tox + ${toxcore_SOURCE_DIR}/toxcore/tox_log_level.h^tox ${toxcore_SOURCE_DIR}/toxcore/tox_options.h^tox) if(EXPERIMENTAL_API) set(toxcore_API_HEADERS ${toxcore_API_HEADERS} diff --git a/other/docker/pkgsrc/pkgsrc.patch b/other/docker/pkgsrc/pkgsrc.patch index baa61d5948..4d2dba1f0b 100644 --- a/other/docker/pkgsrc/pkgsrc.patch +++ b/other/docker/pkgsrc/pkgsrc.patch @@ -14,10 +14,11 @@ diff --git a/chat/toxcore/PLIST b/chat/toxcore/PLIST index f0a5e4f04..4122b0867 100644 --- a/chat/toxcore/PLIST +++ b/chat/toxcore/PLIST -@@ -4,11 +4,10 @@ bin/tox-bootstrapd +@@ -4,11 +4,11 @@ bin/tox-bootstrapd include/tox/tox.h -include/tox/tox_dispatch.h -include/tox/tox_events.h ++include/tox/tox_log_level.h +include/tox/tox_options.h include/tox/toxav.h include/tox/toxencryptsave.h diff --git a/toxcore/BUILD.bazel b/toxcore/BUILD.bazel index 1469f51c18..82263a4d9d 100644 --- a/toxcore/BUILD.bazel +++ b/toxcore/BUILD.bazel @@ -6,6 +6,7 @@ exports_files( "tox.h", "tox_dispatch.h", "tox_events.h", + "tox_log_level.h", "tox_options.h", "tox_private.h", ], @@ -1079,7 +1080,17 @@ cc_library( hdrs = ["tox_options.h"], copts = ["-UTOX_HIDE_DEPRECATED"], visibility = ["//c-toxcore:__subpackages__"], - deps = [":ccompat"], + deps = [ + ":ccompat", + ":tox_log_level", + ], +) + +cc_library( + name = "tox_log_level", + srcs = ["tox_log_level.c"], + hdrs = ["tox_log_level.h"], + visibility = ["//c-toxcore:__subpackages__"], ) cc_library( @@ -1114,6 +1125,7 @@ cc_library( ":network", ":onion_client", ":state", + ":tox_log_level", ":tox_options", ":util", "//c-toxcore/toxencryptsave:defines", @@ -1128,6 +1140,7 @@ cc_test( deps = [ ":crypto_core", ":tox", + ":tox_log_level", ":tox_options", "@com_google_googletest//:gtest", "@com_google_googletest//:gtest_main", diff --git a/toxcore/Makefile.inc b/toxcore/Makefile.inc index ff1faa5bcd..c6783d6f12 100644 --- a/toxcore/Makefile.inc +++ b/toxcore/Makefile.inc @@ -137,6 +137,8 @@ libtoxcore_la_SOURCES = ../third_party/cmp/cmp.c \ ../toxcore/tox_event.h \ ../toxcore/tox_events.c \ ../toxcore/tox_events.h \ + ../toxcore/tox_log_level.c \ + ../toxcore/tox_log_level.h \ ../toxcore/tox_options.c \ ../toxcore/tox_options.h \ ../toxcore/tox_pack.c \ diff --git a/toxcore/net_profile.c b/toxcore/net_profile.c index bbff79c94c..1d700bdb85 100644 --- a/toxcore/net_profile.c +++ b/toxcore/net_profile.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * Copyright © 2023-2024 The TokTok team. + * Copyright © 2023-2025 The TokTok team. */ /** diff --git a/toxcore/net_profile.h b/toxcore/net_profile.h index a2f66a19ff..a4c65167d4 100644 --- a/toxcore/net_profile.h +++ b/toxcore/net_profile.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: GPL-3.0-or-later - * Copyright © 2023-2024 The TokTok team. + * Copyright © 2023-2025 The TokTok team. */ /** diff --git a/toxcore/tox.c b/toxcore/tox.c index 14b820ad5f..a2d499d1bf 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -32,6 +32,7 @@ #include "network.h" #include "onion_client.h" #include "state.h" +#include "tox_log_level.h" #include "tox_options.h" #include "tox_private.h" #include "tox_struct.h" // IWYU pragma: keep diff --git a/toxcore/tox.h b/toxcore/tox.h index 5fabb6de4b..b95b1903bb 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -5361,7 +5361,6 @@ typedef Tox_User_Status TOX_USER_STATUS; typedef Tox_Message_Type TOX_MESSAGE_TYPE; typedef Tox_Proxy_Type TOX_PROXY_TYPE; typedef Tox_Savedata_Type TOX_SAVEDATA_TYPE; -typedef Tox_Log_Level TOX_LOG_LEVEL; typedef Tox_Connection TOX_CONNECTION; typedef Tox_File_Control TOX_FILE_CONTROL; typedef Tox_Conference_Type TOX_CONFERENCE_TYPE; diff --git a/toxcore/tox_api.c b/toxcore/tox_api.c index c5ee08ddd6..808cd473f5 100644 --- a/toxcore/tox_api.c +++ b/toxcore/tox_api.c @@ -184,27 +184,6 @@ const char *tox_savedata_type_to_string(Tox_Savedata_Type value) return "<invalid Tox_Savedata_Type>"; } -const char *tox_log_level_to_string(Tox_Log_Level value) -{ - switch (value) { - case TOX_LOG_LEVEL_TRACE: - return "TOX_LOG_LEVEL_TRACE"; - - case TOX_LOG_LEVEL_DEBUG: - return "TOX_LOG_LEVEL_DEBUG"; - - case TOX_LOG_LEVEL_INFO: - return "TOX_LOG_LEVEL_INFO"; - - case TOX_LOG_LEVEL_WARNING: - return "TOX_LOG_LEVEL_WARNING"; - - case TOX_LOG_LEVEL_ERROR: - return "TOX_LOG_LEVEL_ERROR"; - } - - return "<invalid Tox_Log_Level>"; -} const char *tox_err_options_new_to_string(Tox_Err_Options_New value) { switch (value) { diff --git a/toxcore/tox_log_level.c b/toxcore/tox_log_level.c new file mode 100644 index 0000000000..04f83b0f9a --- /dev/null +++ b/toxcore/tox_log_level.c @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later + * Copyright © 2016-2025 The TokTok team. + * Copyright © 2013 Tox project. + */ +#include "tox_log_level.h" + +const char *tox_log_level_to_string(Tox_Log_Level value) +{ + switch (value) { + case TOX_LOG_LEVEL_TRACE: + return "TOX_LOG_LEVEL_TRACE"; + + case TOX_LOG_LEVEL_DEBUG: + return "TOX_LOG_LEVEL_DEBUG"; + + case TOX_LOG_LEVEL_INFO: + return "TOX_LOG_LEVEL_INFO"; + + case TOX_LOG_LEVEL_WARNING: + return "TOX_LOG_LEVEL_WARNING"; + + case TOX_LOG_LEVEL_ERROR: + return "TOX_LOG_LEVEL_ERROR"; + } + + return "<invalid Tox_Log_Level>"; +} diff --git a/toxcore/tox_log_level.h b/toxcore/tox_log_level.h new file mode 100644 index 0000000000..0009ecd54b --- /dev/null +++ b/toxcore/tox_log_level.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later + * Copyright © 2022-2025 The TokTok team. + */ + +#ifndef C_TOXCORE_TOXCORE_TOX_LOG_LEVEL_H +#define C_TOXCORE_TOXCORE_TOX_LOG_LEVEL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Severity level of log messages. + */ +typedef enum Tox_Log_Level { + /** + * Very detailed traces including all network activity. + */ + TOX_LOG_LEVEL_TRACE, + + /** + * Debug messages such as which port we bind to. + */ + TOX_LOG_LEVEL_DEBUG, + + /** + * Informational log messages such as video call status changes. + */ + TOX_LOG_LEVEL_INFO, + + /** + * Warnings about internal inconsistency or logic errors. + */ + TOX_LOG_LEVEL_WARNING, + + /** + * Severe unexpected errors caused by external or internal inconsistency. + */ + TOX_LOG_LEVEL_ERROR, +} Tox_Log_Level; + +const char *tox_log_level_to_string(Tox_Log_Level value); + +//!TOKSTYLE- +#ifndef DOXYGEN_IGNORE + +#ifndef TOX_HIDE_DEPRECATED +typedef Tox_Log_Level TOX_LOG_LEVEL; +#endif /* TOX_HIDE_DEPRECATED */ + +#endif +//!TOKSTYLE+ + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* C_TOXCORE_TOXCORE_TOX_LOG_LEVEL_H */ diff --git a/toxcore/tox_options.h b/toxcore/tox_options.h index 31b797bcdc..7d8b7aafaa 100644 --- a/toxcore/tox_options.h +++ b/toxcore/tox_options.h @@ -10,6 +10,8 @@ #include <stddef.h> #include <stdint.h> +#include "tox_log_level.h" + #ifdef __cplusplus extern "C" { #endif @@ -64,38 +66,6 @@ typedef enum Tox_Savedata_Type { const char *tox_savedata_type_to_string(Tox_Savedata_Type value); -/** - * @brief Severity level of log messages. - */ -typedef enum Tox_Log_Level { - /** - * Very detailed traces including all network activity. - */ - TOX_LOG_LEVEL_TRACE, - - /** - * Debug messages such as which port we bind to. - */ - TOX_LOG_LEVEL_DEBUG, - - /** - * Informational log messages such as video call status changes. - */ - TOX_LOG_LEVEL_INFO, - - /** - * Warnings about internal inconsistency or logic errors. - */ - TOX_LOG_LEVEL_WARNING, - - /** - * Severe unexpected errors caused by external or internal inconsistency. - */ - TOX_LOG_LEVEL_ERROR, -} Tox_Log_Level; - -const char *tox_log_level_to_string(Tox_Log_Level value); - /** * @brief This event is triggered when Tox logs an internal message. * diff --git a/toxcore/tox_test.cc b/toxcore/tox_test.cc index f4c289420a..23a53b0c0d 100644 --- a/toxcore/tox_test.cc +++ b/toxcore/tox_test.cc @@ -6,6 +6,7 @@ #include <vector> #include "crypto_core.h" +#include "tox_log_level.h" #include "tox_options.h" #include "tox_private.h"