示例#1
0
static void dropdown_push_to_talk_onselect(const uint16_t i, const DROPDOWN* UNUSED(dm)) {
    if (i) {
        // TODO, push this onto the start and end call fxn?
        init_ptt();
    } else {
        exit_ptt();
    }
}
示例#2
0
文件: settings.c 项目: baloo79/uTox
// TODO refactor to match same order in main.h
UTOX_SAVE *config_load(void) {
    UTOX_SAVE *save = utox_load_config();

    // TODO: Remove this in ~0.18.0 release
    if (!save) {
        LOG_NOTE("Settings", "Unable to load uTox settings from %s. Trying old %s.", config_file_name, config_file_name_old);
        save = utox_data_load_utox();
    }

    if (!save) {
        LOG_ERR("Settings", "Unable to load uTox settings. Use defaults.");
        save = init_default_settings();
    }

    if (save->scale > 30) {
        save->scale = 30;
    } else if (save->scale < 5) {
        save->scale = 10;
    }

    if (save->window_width < MAIN_WIDTH) {
        save->window_width = MAIN_WIDTH;
    }
    if (save->window_height < MAIN_HEIGHT) {
        save->window_height = MAIN_HEIGHT;
    }

    /* UX Settings */

    dropdown_language.selected = dropdown_language.over = settings.language = save->language;

    dropdown_dpi.selected = dropdown_dpi.over = save->scale - 5;

    switch_save_chat_history.switch_on = save->logging_enabled;
    switch_close_to_tray.switch_on     = save->close_to_tray;
    switch_start_in_tray.switch_on     = save->start_in_tray;
    switch_mini_contacts.switch_on     = save->use_mini_flist;
    switch_magic_sidebar.switch_on     = save->magic_flist_enabled;

    switch_ipv6.switch_on             = save->enableipv6;
    switch_udp.switch_on              = !save->disableudp;
    switch_udp.panel.disabled         = save->force_proxy;
    switch_proxy.switch_on            = save->proxyenable;
    switch_proxy_force.switch_on      = save->force_proxy;
    switch_proxy_force.panel.disabled = !save->proxyenable;

    switch_auto_startup.switch_on       = save->auto_startup;
    switch_auto_update.switch_on        = save->auto_update;

    settings.group_notifications = dropdown_global_group_notifications.selected =
        dropdown_global_group_notifications.over = save->group_notifications;

    switch_audible_notifications.switch_on = save->audible_notifications_enabled;
    switch_audio_filtering.switch_on       = save->audio_filtering_enabled;
    switch_push_to_talk.switch_on          = save->push_to_talk;
    switch_status_notifications.switch_on  = save->status_notifications;

    dropdown_theme.selected = dropdown_theme.over = save->theme;

    switch_typing_notes.switch_on = !save->no_typing_notifications;

    flist_set_filter(save->filter); /* roster list filtering */

    /* Network settings */
    settings.enable_ipv6 = save->enableipv6;
    settings.enable_udp  = !save->disableudp;
    settings.use_proxy   = !!save->proxyenable;
    settings.proxy_port  = save->proxy_port;
    settings.force_proxy = save->force_proxy;

    if (strlen((char *)save->proxy_ip) <= proxy_address_size){
        strcpy((char *)proxy_address, (char *)save->proxy_ip);
    }

    edit_proxy_ip.length = strlen((char *)save->proxy_ip);

    strcpy((char *)edit_proxy_ip.data, (char *)save->proxy_ip);

    if (save->proxy_port) {
        edit_proxy_port.length =
            snprintf((char *)edit_proxy_port.data, edit_proxy_port.maxlength + 1, "%u", save->proxy_port);
        if (edit_proxy_port.length >= edit_proxy_port.maxlength + 1) {
            edit_proxy_port.length = edit_proxy_port.maxlength;
        }
    }

    /* UX settings */
    settings.logging_enabled      = save->logging_enabled;
    settings.close_to_tray        = save->close_to_tray;
    settings.start_in_tray        = save->start_in_tray;
    settings.start_with_system    = save->auto_startup;
    settings.use_mini_flist       = save->use_mini_flist;
    settings.magic_flist_enabled  = save->magic_flist_enabled;
    settings.use_long_time_msg    = save->use_long_time_msg;

    settings.ringtone_enabled     = save->audible_notifications_enabled;
    settings.audiofilter_enabled  = save->audio_filtering_enabled;

    settings.send_typing_status   = !save->no_typing_notifications;
    settings.status_notifications = save->status_notifications;

    settings.window_width         = save->window_width;
    settings.window_height        = save->window_height;

    settings.last_version         = save->utox_last_version;

    loaded_audio_out_device       = save->audio_device_out;
    loaded_audio_in_device        = save->audio_device_in;

    settings.auto_update          = save->auto_update;
    switch_auto_update.switch_on  = save->auto_update;
    settings.update_to_develop    = save->update_to_develop;
    settings.send_version         = save->send_version;

    settings.video_fps = save->video_fps ? save->video_fps : 25;

    edit_video_fps.length =
        snprintf((char *)edit_video_fps.data, edit_video_fps.maxlength + 1, "%u", save->video_fps);
    if (edit_video_fps.length > edit_video_fps.maxlength) {
        edit_video_fps.length = edit_video_fps.maxlength;
    }

    // TODO: Don't clobber (and start saving) commandline flags.

    // Allow users to override theme on the cmdline.
    if (settings.theme == UINT32_MAX) {
        settings.theme = save->theme;
    }

    ui_set_scale(save->scale);

    if (save->push_to_talk) {
        init_ptt();
    }

    return save;
}