Skip to content

Commit fbe78f1

Browse files
committed
cleanup: Add a TOX_HIDE_DEPRECATED check to hide deprecated symbols.
Compiling with that flag will make tox compile roughly as if it were v0.3.0.
1 parent 44d9da0 commit fbe78f1

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

auto_tests/save_compatibility_test.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ static uint8_t *read_save(const char *save_path, size_t *length)
7171

7272
static void test_save_compatibility(const char *save_path)
7373
{
74-
struct Tox_Options options = {0};
75-
tox_options_default(&options);
74+
Tox_Options *options = tox_options_new(nullptr);
75+
ck_assert(options != nullptr);
7676

7777
size_t size = 0;
7878
uint8_t *save_data = read_save(save_path, &size);
7979
ck_assert_msg(save_data != nullptr, "error while reading save file '%s'", save_path);
8080

81-
options.savedata_data = save_data;
82-
options.savedata_length = size;
83-
options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE;
81+
tox_options_set_savedata_type(options, TOX_SAVEDATA_TYPE_TOX_SAVE);
82+
tox_options_set_savedata_data(options, save_data, size);
8483

8584
size_t index = 0;
8685
Tox_Err_New err;
87-
Tox *tox = tox_new_log(&options, &err, &index);
86+
Tox *tox = tox_new_log(options, &err, &index);
8887
ck_assert_msg(tox, "failed to create tox, error number: %d", err);
8988

89+
tox_options_free(options);
9090
free(save_data);
9191

9292
const size_t name_size = tox_self_get_name_size(tox);

toxcore/tox.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "onion_client.h"
3434
#include "state.h"
3535
#include "tox_private.h"
36-
#include "tox_struct.h"
36+
#include "tox_struct.h" // IWYU pragma: keep
3737
#include "util.h"
3838

3939
#include "../toxencryptsave/defines.h"

toxcore/tox.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@
8787
* If any other thread calls tox_self_set_name while this thread is allocating
8888
* memory, the length may have become invalid, and the call to
8989
* tox_self_get_name may cause undefined behaviour.
90+
*
91+
* @section deprecations
92+
*
93+
* Some functions and types are deprecated. We recommend compiling with
94+
* `-DTOX_HIDE_DEPRECATED` to hide them. They will be removed in the next major
95+
* version of Tox (and since we're in major version 0, that means the next
96+
* minor version).
9097
*/
9198
#ifndef C_TOXCORE_TOXCORE_TOX_H
9299
#define C_TOXCORE_TOXCORE_TOX_H
@@ -512,6 +519,7 @@ typedef void tox_log_cb(Tox *tox, Tox_Log_Level level, const char *file, uint32_
512519
* private) in v0.3.0.
513520
*/
514521
typedef struct Tox_Options Tox_Options;
522+
#ifndef TOX_HIDE_DEPRECATED
515523
struct Tox_Options {
516524

517525
/**
@@ -687,6 +695,7 @@ struct Tox_Options {
687695
*/
688696
bool experimental_disable_dns;
689697
};
698+
#endif /* TOX_HIDE_DEPRECATED */
690699

691700
bool tox_options_get_ipv6_enabled(const Tox_Options *options);
692701

@@ -3165,6 +3174,7 @@ const char *tox_err_conference_by_id_to_string(Tox_Err_Conference_By_Id value);
31653174
Tox_Conference_Number tox_conference_by_id(
31663175
const Tox *tox, const uint8_t id[TOX_CONFERENCE_ID_SIZE], Tox_Err_Conference_By_Id *error);
31673176

3177+
#ifndef TOX_HIDE_DEPRECATED
31683178
/**
31693179
* @brief Get the conference unique ID.
31703180
*
@@ -3179,6 +3189,7 @@ Tox_Conference_Number tox_conference_by_id(
31793189
*/
31803190
bool tox_conference_get_uid(
31813191
const Tox *tox, Tox_Conference_Number conference_number, uint8_t uid[TOX_CONFERENCE_UID_SIZE]);
3192+
#endif /* TOX_HIDE_DEPRECATED */
31823193

31833194
typedef enum Tox_Err_Conference_By_Uid {
31843195

@@ -3201,6 +3212,7 @@ typedef enum Tox_Err_Conference_By_Uid {
32013212

32023213
const char *tox_err_conference_by_uid_to_string(Tox_Err_Conference_By_Uid value);
32033214

3215+
#ifndef TOX_HIDE_DEPRECATED
32043216
/**
32053217
* @brief Return the conference number associated with the specified uid.
32063218
*
@@ -3213,6 +3225,7 @@ const char *tox_err_conference_by_uid_to_string(Tox_Err_Conference_By_Uid value)
32133225
*/
32143226
Tox_Conference_Number tox_conference_by_uid(
32153227
const Tox *tox, const uint8_t uid[TOX_CONFERENCE_UID_SIZE], Tox_Err_Conference_By_Uid *error);
3228+
#endif /* TOX_HIDE_DEPRECATED */
32163229

32173230
/** @} */
32183231

@@ -3820,6 +3833,7 @@ typedef enum Tox_Err_Group_Reconnect {
38203833

38213834
const char *tox_err_group_reconnect_to_string(Tox_Err_Group_Reconnect value);
38223835

3836+
#ifndef TOX_HIDE_DEPRECATED
38233837
/**
38243838
* Reconnects to a group.
38253839
*
@@ -3834,6 +3848,7 @@ const char *tox_err_group_reconnect_to_string(Tox_Err_Group_Reconnect value);
38343848
* @deprecated Use `tox_group_join` instead.
38353849
*/
38363850
bool tox_group_reconnect(Tox *tox, Tox_Group_Number group_number, Tox_Err_Group_Reconnect *error);
3851+
#endif /* TOX_HIDE_DEPRECATED */
38373852

38383853
typedef enum Tox_Err_Group_Leave {
38393854

@@ -5747,6 +5762,7 @@ void tox_callback_group_moderation(Tox *tox, tox_group_moderation_cb *callback);
57475762
//!TOKSTYLE-
57485763
#ifndef DOXYGEN_IGNORE
57495764

5765+
#ifndef TOX_HIDE_DEPRECATED
57505766
typedef Tox_Err_Options_New TOX_ERR_OPTIONS_NEW;
57515767
typedef Tox_Err_New TOX_ERR_NEW;
57525768
typedef Tox_Err_Bootstrap TOX_ERR_BOOTSTRAP;
@@ -5786,6 +5802,7 @@ typedef Tox_Connection TOX_CONNECTION;
57865802
typedef Tox_File_Control TOX_FILE_CONTROL;
57875803
typedef Tox_Conference_Type TOX_CONFERENCE_TYPE;
57885804
typedef enum Tox_File_Kind TOX_FILE_KIND;
5805+
#endif /* TOX_HIDE_DEPRECATED */
57895806

57905807
#endif
57915808
//!TOKSTYLE+

0 commit comments

Comments
 (0)