Implemented proxy capabilities.
This commit is contained in:
@ -52,7 +52,7 @@ char *
|
||||
twc_profile_expanded_data_path(struct t_twc_profile *profile)
|
||||
{
|
||||
const char *weechat_dir = weechat_info_get ("weechat_dir", NULL);
|
||||
const char *base_path = weechat_config_string(profile->options[TWC_PROFILE_OPTION_SAVEFILE]);
|
||||
const char *base_path = TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_SAVEFILE);
|
||||
char *home_expanded = weechat_string_replace(base_path, "%h", weechat_dir);
|
||||
char *full_path = weechat_string_replace(home_expanded, "%p", profile->name);
|
||||
free(home_expanded);
|
||||
@ -218,20 +218,44 @@ twc_profile_load(struct t_twc_profile *profile)
|
||||
// create Tox options object
|
||||
Tox_Options *options = malloc(sizeof(Tox_Options));
|
||||
options->proxy_enabled =
|
||||
weechat_config_boolean(profile->options[TWC_PROFILE_OPTION_PROXY_ENABLED]);
|
||||
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_PROXY_ENABLED);
|
||||
|
||||
const char *proxy_address =
|
||||
weechat_config_string(profile->options[TWC_PROFILE_OPTION_PROXY_ADDRESS]);
|
||||
memcpy(options->proxy_address, proxy_address, strlen(proxy_address) + 1);
|
||||
TWC_PROFILE_OPTION_STRING(profile, TWC_PROFILE_OPTION_PROXY_ADDRESS);
|
||||
if (proxy_address)
|
||||
memcpy(options->proxy_address, proxy_address, strlen(proxy_address) + 1);
|
||||
|
||||
options->proxy_port =
|
||||
weechat_config_integer(profile->options[TWC_PROFILE_OPTION_PROXY_PORT]);
|
||||
TWC_PROFILE_OPTION_INTEGER(profile, TWC_PROFILE_OPTION_PROXY_PORT);
|
||||
options->udp_disabled =
|
||||
TWC_PROFILE_OPTION_BOOLEAN(profile, TWC_PROFILE_OPTION_UDP_DISABLED);
|
||||
|
||||
if (options->proxy_enabled)
|
||||
{
|
||||
if (!options->proxy_address || !options->proxy_port)
|
||||
{
|
||||
weechat_printf(profile->buffer,
|
||||
"%sproxy is enabled, but address or port is "
|
||||
"missing; aborting",
|
||||
weechat_prefix("error"),
|
||||
options->proxy_address, options->proxy_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf(profile->buffer,
|
||||
"%sUsing proxy %s:%d",
|
||||
weechat_prefix("network"),
|
||||
options->proxy_address, options->proxy_port);
|
||||
}
|
||||
}
|
||||
|
||||
// create Tox
|
||||
profile->tox = tox_new(options);
|
||||
if (!(profile->tox))
|
||||
{
|
||||
weechat_printf(profile->buffer,
|
||||
"Could not create Tox instance!",
|
||||
weechat_prefix("error"), weechat_plugin->name);
|
||||
"%sCould not create Tox instance!",
|
||||
weechat_prefix("error"));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -331,7 +355,7 @@ twc_profile_autoload()
|
||||
struct t_twc_list_item *item;
|
||||
twc_list_foreach(twc_profiles, index, item)
|
||||
{
|
||||
if (weechat_config_boolean(item->profile->options[TWC_PROFILE_OPTION_AUTOLOAD]))
|
||||
if (TWC_PROFILE_OPTION_BOOLEAN(item->profile, TWC_PROFILE_OPTION_AUTOLOAD))
|
||||
twc_profile_load(item->profile);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user