Make a separate struct Tox containing the Messenger.

This allows Tox to contain additional data on top of Messenger, making
Messenger not necessarily the most top-level object. E.g. groups are
built on Messenger and currently awkwardly void-pointered into it to
pretend there is no cyclic dependency.
This commit is contained in:
iphydf 2018-07-25 06:54:04 +00:00
parent 7f8b29c346
commit 064ffe5875
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
5 changed files with 375 additions and 122 deletions

View File

@ -40,9 +40,6 @@ echo "#include <cstdio>" >> amalgamation.cc
echo "#include <memory>" >> amalgamation.cc
echo "#include <random>" >> amalgamation.cc
echo "#define TOX_DEFINED" >> amalgamation.cc
echo "typedef struct Messenger Tox;" >> amalgamation.cc
put auto_tests/check_compat.h
FIND_QUERY="find . '-(' -name '*.cc' -or -name '*.c' '-)'"

View File

@ -123,13 +123,16 @@ ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error)
{
TOXAV_ERR_NEW rc = TOXAV_ERR_NEW_OK;
ToxAV *av = nullptr;
Messenger *m = (Messenger *)tox;
if (tox == nullptr) {
rc = TOXAV_ERR_NEW_NULL;
goto END;
}
// TODO(iphydf): Don't rely on toxcore internals.
Messenger *m;
m = *(Messenger **)tox;
if (m->msi_packet) {
rc = TOXAV_ERR_NEW_MULTIPLE;
goto END;

View File

@ -1985,7 +1985,7 @@ Messenger *new_messenger(Messenger_Options *options, unsigned int *error)
return nullptr;
}
logger_callback_log(m->log, options->log_callback, m, options->log_user_data);
logger_callback_log(m->log, options->log_callback, options->log_context, options->log_user_data);
unsigned int net_err = 0;

View File

@ -61,6 +61,7 @@ typedef struct Messenger_Options {
bool local_discovery_enabled;
logger_cb *log_callback;
void *log_context;
void *log_user_data;
} Messenger_Options;

File diff suppressed because it is too large Load Diff