Ejemplo n.º 1
0
/***************************************************************************
 * init_properties():
 * Initialize properties from properties file
 ***************************************************************************/
int init_properties(char *propfile) {

    // read properties file
    FILE *fp_prop = fopen(propfile, "r");
    if (fp_prop == NULL) {
        logprintf(MSG_FLAG, "Info: Cannot open application properties file: %s\n", propfile);
        settings = NULL;
        return (0);
    }
    settings = settings_open(fp_prop);
    fclose(fp_prop);
    if (settings == NULL) {
        logprintf(ERROR_FLAG, "Reading application properties file: %s\n", propfile);
        return (-1);
    }

    //
    if (settings_get_helper(settings,
            "Logging", "port_path_hint", port_path_hint, sizeof (port_path_hint), PORT_PATH_HINT_DEFAULT,
            verbose) == 0) {
        ; // handle error
    }
    //
    if (settings_get_int_helper(settings,
            "Logging", "allow_set_interface_attribs", &allow_set_interface_attribs, ALLOW_SET_INTERFACE_ATTRIBS_DEFAULT,
            verbose) == 0) {
        ; // handle error
    }

    //
    if (settings_get_double_helper(settings,
            "Logging", "mswrite_header_sample_rate", &mswrite_header_sample_rate, MSWRITE_HEADER_SAMPLE_RATE_DEFAULT,
            verbose
            ) == DBL_INVALID) {
        ; // handle error
    }
    //
    if (settings_get_helper(settings,
            "Logging", "mswrite_data_encoding_type", mswrite_data_encoding_type, sizeof (mswrite_data_encoding_type), MSWRITE_DATA_ENCODING_TYPE_DEFAULT,
            verbose
            ) == 0) {
        ; // handle error
    }

    //
    if (settings_get_helper(settings,
            "Station", "station_network", station_network, sizeof (station_network), STA_NETWORK_DEFAULT,
            verbose
            ) == 0) {
        ; // handle error
    }
    //
    if (settings_get_helper(settings,
            "Station", "station_name", station_name, sizeof (station_name), STA_NAME_DEFAULT,
            verbose
            ) == 0) {
        ; // handle error
    }
    //
    if (settings_get_helper(settings,
            "Station", "channel_prefix", channel_prefix, sizeof (channel_prefix), STA_CHANNEL_PREFIX_DEFAULT,
            verbose
            ) == 0) {
        ; // handle error
    }
    //
    if (settings_get_helper(settings,
            "Station", "component", component, sizeof (component), STA_COMPONENT_DEFAULT,
            verbose
            ) == 0) {
        ; // handle error
    }
    //
    if (settings_get_int_helper(settings,
            "Station", "nominal_sample_rate", &nominal_sample_rate, STA_NOMINAL_SAMPLE_RATE_DEFAULT,
            verbose
            ) == DBL_INVALID) {
        ; // handle error
    }
    //
    if (settings_get_int_helper(settings,
            "Station", "nominal_gain", &nominal_gain, STA_NOMINAL_GAIN_DEFAULT,
            verbose
            ) == DBL_INVALID) {
        ; // handle error
    }
    //
    if (settings_get_int_helper(settings,
            "Station", "do_settings_sep064", &do_settings_sep064, DO_SETTINGS_SEP064_DEFAULT,
            verbose) == 0) {
        ; // handle error
    }

    return (0);

}
Ejemplo n.º 2
0
/**
 * Handle event in the main screen.
 * @param event
 * The event to handle.
 * @return
 * 1 if the event was handled, 0 otherwise.
 */
int intro_event(SDL_Event *event)
{
    if (!list_servers) {
        return 0;
    }

    if (event->type == SDL_MOUSEBUTTONDOWN && event->button.button == SDL_BUTTON_LEFT) {
        if (LIST_MOUSE_OVER(list_news, event->motion.x, event->motion.y)) {
            list_news->focus = 1;
            list_servers->focus = 0;
        } else if (LIST_MOUSE_OVER(list_servers, event->motion.x, event->motion.y)) {
            list_servers->focus = 1;
            list_news->focus = 0;
        }
    }

    if (button_event(&button_play, event)) {
        list_handle_enter(list_servers, event);
        return 1;
    } else if (button_event(&button_refresh, event)) {
        if (!ms_connecting(-1)) {
            cpl.state = ST_META;
        }

        return 1;
    } else if (button_event(&button_server, event)) {
        server_add_open();
        return 1;
    } else if (button_event(&button_settings, event)) {
        settings_open();
        return 1;
    } else if (button_event(&button_update, event)) {
        updater_open();
        return 1;
    } else if (button_event(&button_help, event)) {
        help_show("main screen");
        return 1;
    } else if (button_event(&button_credits, event)) {
        credits_show();
        return 1;
    } else if (button_event(&button_quit, event)) {
        exit(0);
        return 1;
    } else if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_TAB && list_news) {
        int news_focus = 0;

        if (list_servers->focus) {
            news_focus = 1;
        }

        list_news->focus = news_focus;
        list_servers->focus = !news_focus;
    } else if (list_handle_keyboard(list_news && list_news->focus ? list_news : list_servers, event)) {
        return 1;
    } else if (list_handle_mouse(list_news, event)) {
        return 1;
    } else if (list_handle_mouse(list_servers, event)) {
        return 1;
    }

    return 0;
}