mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-23 05:33:01 +01:00
Merge branch 'master' of https://github.com/Tox/toxic into new_groupchats
This commit is contained in:
commit
f82d58bbfc
15
src/toxic.c
15
src/toxic.c
@ -561,6 +561,8 @@ static void init_tox_callbacks(Tox *m)
|
|||||||
|
|
||||||
static void init_tox_options(struct Tox_Options *tox_opts)
|
static void init_tox_options(struct Tox_Options *tox_opts)
|
||||||
{
|
{
|
||||||
|
tox_options_default(tox_opts);
|
||||||
|
|
||||||
tox_opts->ipv6_enabled = !arg_opts.use_ipv4;
|
tox_opts->ipv6_enabled = !arg_opts.use_ipv4;
|
||||||
tox_opts->udp_enabled = !arg_opts.force_tcp;
|
tox_opts->udp_enabled = !arg_opts.force_tcp;
|
||||||
tox_opts->proxy_type = arg_opts.proxy_type;
|
tox_opts->proxy_type = arg_opts.proxy_type;
|
||||||
@ -659,7 +661,7 @@ static Tox *load_tox(char *data_path, struct Tox_Options *tox_opts, TOX_ERR_NEW
|
|||||||
if (pwerr == TOX_ERR_DECRYPTION_OK) {
|
if (pwerr == TOX_ERR_DECRYPTION_OK) {
|
||||||
m = tox_new(tox_opts, (uint8_t *) plain, plain_len, new_err);
|
m = tox_new(tox_opts, (uint8_t *) plain, plain_len, new_err);
|
||||||
|
|
||||||
if (*new_err != TOX_ERR_NEW_OK) {
|
if (m == NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -677,7 +679,7 @@ static Tox *load_tox(char *data_path, struct Tox_Options *tox_opts, TOX_ERR_NEW
|
|||||||
} else { /* data is not encrypted */
|
} else { /* data is not encrypted */
|
||||||
m = tox_new(tox_opts, (uint8_t *) data, len, new_err);
|
m = tox_new(tox_opts, (uint8_t *) data, len, new_err);
|
||||||
|
|
||||||
if (*new_err != TOX_ERR_NEW_OK) {
|
if (m == NULL) {
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -690,7 +692,7 @@ static Tox *load_tox(char *data_path, struct Tox_Options *tox_opts, TOX_ERR_NEW
|
|||||||
|
|
||||||
m = tox_new(tox_opts, NULL, 0, new_err);
|
m = tox_new(tox_opts, NULL, 0, new_err);
|
||||||
|
|
||||||
if (*new_err != TOX_ERR_NEW_OK)
|
if (m == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (store_data(m, data_path) == -1)
|
if (store_data(m, data_path) == -1)
|
||||||
@ -708,14 +710,17 @@ static Tox *load_toxic(char *data_path)
|
|||||||
TOX_ERR_NEW new_err;
|
TOX_ERR_NEW new_err;
|
||||||
Tox *m = load_tox(data_path, &tox_opts, &new_err);
|
Tox *m = load_tox(data_path, &tox_opts, &new_err);
|
||||||
|
|
||||||
if (new_err != TOX_ERR_NEW_OK && tox_opts.ipv6_enabled) {
|
if (new_err == TOX_ERR_NEW_PORT_ALLOC && tox_opts.ipv6_enabled) {
|
||||||
queue_init_message("Falling back to ipv4");
|
queue_init_message("Falling back to ipv4");
|
||||||
tox_opts.ipv6_enabled = false;
|
tox_opts.ipv6_enabled = false;
|
||||||
m = load_tox(data_path, &tox_opts, &new_err);
|
m = load_tox(data_path, &tox_opts, &new_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!m)
|
||||||
|
exit_toxic_err("tox_new returned fatal error", new_err);
|
||||||
|
|
||||||
if (new_err != TOX_ERR_NEW_OK)
|
if (new_err != TOX_ERR_NEW_OK)
|
||||||
exit_toxic_err("Tox network failed to initialize (tox_new failed with error %d)", new_err);
|
queue_init_message("tox_new returned non-fatal error %d", new_err);
|
||||||
|
|
||||||
init_tox_callbacks(m);
|
init_tox_callbacks(m);
|
||||||
load_friendlist(m);
|
load_friendlist(m);
|
||||||
|
Loading…
Reference in New Issue
Block a user