Esempio n. 1
0
static
uintptr_t
do_load_ppp_module(const char *fname)
{
    tried_files = g_list_prepend(tried_files, g_strdup(fname));

    module_dl_handler = dlopen(fname, RTLD_LAZY);
    if (!module_dl_handler) {
        trace_info_f("%s, can't open %s\n", __func__, fname);
        return 1;
    }

    int32_t (*ppp_initialize_module)(PP_Module module_id, PPB_GetInterface get_browser_interface);
    ppp_initialize_module = dlsym(module_dl_handler, "PPP_InitializeModule");
    ppp_get_interface = dlsym(module_dl_handler, "PPP_GetInterface");

    if (!ppp_initialize_module || !ppp_get_interface) {
        trace_error("%s, one of required PPP_* is missing\n", __func__);
        if (module_dl_handler)
            dlclose(module_dl_handler);
        module_dl_handler = NULL;
        return 1;
    }

    module_file_name = g_strdup(fname);

    if (!fpp_config_plugin_has_manifest()) {
        use_fallback_version_strings();
        return 0;
    }

    // try to read manifest.json file (only for those who can have it)
    char *manifest_dir = strdup(fname);
    gchar *manifest_path = g_strdup_printf("%s/manifest.json", dirname(manifest_dir));
    free(manifest_dir);

    JSON_Value *root_val = json_parse_file(manifest_path);
    g_free(manifest_path);
    if (!root_val) {
        use_fallback_version_strings();
        return 0;
    }

    JSON_Object *root_obj = json_value_get_object(root_val);
    const char *version = json_object_get_string(root_obj, "version");
    if (version) {
        int v1 = 0, v2 = 0, v3 = 0, v4 = 0;
        module_version = g_strdup(version);
        (void)sscanf(module_version, "%9d.%9d.%9d.%9d", &v1, &v2, &v3, &v4);
        module_descr = g_strdup_printf("%s %d.%d r%d", fpp_config_get_plugin_name(), v1, v2, v3);
    } else {
        use_fallback_version_strings();
    }

    json_value_free(root_val);
    return 0;
}
NPError
NP_GetValue(void *instance, NPPVariable variable, void *value)
{
    trace_info_f("%s\n", __func__);

    switch (variable) {
    case NPPVpluginNameString:
        *(const char **)value = fpp_config_get_plugin_name();
        break;
    case NPPVpluginDescriptionString:
        *(const char **)value = fpp_config_get_default_plugin_descr();
        break;
    default:
        trace_info_z("    not implemented variable %d\n", variable);
    }

    return NPERR_NO_ERROR;
}
Esempio n. 3
0
NPError
NP_GetValue(void *instance, NPPVariable variable, void *value)
{
    trace_info_f("[NP] %s instance=%p, variable=%s, value=%p\n", __func__, instance,
                 reverse_npp_variable(variable), value);
    load_ppp_module();
    switch (variable) {
    case NPPVpluginNameString:
        *(const char **)value = fpp_config_get_plugin_name();
        break;
    case NPPVpluginDescriptionString:
        *(char **)value = module_descr;
        break;
    default:
        trace_info_z("    not implemented variable %d\n", variable);
    }
    return NPERR_NO_ERROR;
}
Esempio n. 4
0
void
fpp_config_initialize(void)
{
    if (initialized)
        return;

    config_t    cfg;
    char       *local_config = get_local_config_path(config_file_name);
    char       *global_config = get_global_config_path(config_file_name);

    config = default_config;

    config_init(&cfg);

    if (!config_read_file(&cfg, local_config)) {
        if (!config_read_file(&cfg, global_config)) {
            goto quit;
        }
    }

    long long intval;
    const char *stringval;

    if (config_lookup_int64(&cfg, "audio_buffer_min_ms", &intval)) {
        config.audio_buffer_min_ms = intval;
    }

    if (config_lookup_int64(&cfg, "audio_buffer_max_ms", &intval)) {
        config.audio_buffer_max_ms = intval;
    }

    if (config_lookup_int64(&cfg, "xinerama_screen", &intval)) {
        config.xinerama_screen = intval;
    }


    if (config_lookup_string(&cfg, "pepperflash_path", &stringval)) {
        config.pepperflash_path = strdup(stringval);
    }

    if (config_lookup_string(&cfg, "flash_command_line", &stringval)) {
        config.flash_command_line = strdup(stringval);
    }

    if (config_lookup_int64(&cfg, "enable_3d", &intval)) {
        config.enable_3d = intval;
    }

    config_destroy(&cfg);

quit:
    g_free(local_config);
    g_free(global_config);

    initialize_quirks();

    // calculate plugin data directory
    local_config = get_local_config_path(config_dir_name);
    pepper_data_dir = g_strdup_printf("%s/%s", local_config, fpp_config_get_plugin_name());
    pepper_salt_file_name = g_strdup_printf("%s/%s", local_config, salt_file_name);
    g_free(local_config);

    initialized = 1;
}