Exemplo n.º 1
0
void
nemo_link_get_link_info_given_file_contents (const char  *file_contents,
						 int          link_file_size,
						 const char  *file_uri,
						 char       **uri,
						 char       **name,
						 GIcon      **icon,
						 gboolean    *is_launcher,
						 gboolean    *is_foreign)
{
	GKeyFile *key_file;
	char *type;
	char **only_show_in;
	char **not_show_in;
	const gchar *session;

	session = get_session ();
	key_file = g_key_file_new ();
	if (!g_key_file_load_from_data (key_file,
					file_contents,
					link_file_size,
					G_KEY_FILE_NONE,
					NULL)) {
		g_key_file_free (key_file);
		return; 
	}

	*uri = nemo_link_get_link_uri_from_desktop (key_file, file_uri);
	*name = nemo_link_get_link_name_from_desktop (key_file);
	*icon = nemo_link_get_link_icon_from_desktop (key_file);

	*is_launcher = FALSE;
	type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL);
	if (g_strcmp0 (type, "Application") == 0 &&
	    g_key_file_has_key (key_file, MAIN_GROUP, "Exec", NULL)) {
		*is_launcher = TRUE;
	}
	g_free (type);

	*is_foreign = FALSE;
	only_show_in = g_key_file_get_string_list (key_file, MAIN_GROUP,
						   "OnlyShowIn", NULL, NULL);
	if (session && only_show_in && !(string_array_contains (only_show_in, session) ||
                                     string_array_contains (only_show_in, "GNOME"))) {
		*is_foreign = TRUE;
	}
	g_strfreev (only_show_in);

	not_show_in = g_key_file_get_string_list (key_file, MAIN_GROUP,
						  "NotShowIn", NULL, NULL);
	if (session && not_show_in && string_array_contains (not_show_in, session)) {
		*is_foreign = TRUE;
	}
	g_strfreev (not_show_in);

	g_key_file_free (key_file);
}
static struct playlist_provider *
playlist_list_open_stream_suffix(struct input_stream *is, const char *suffix)
{
	struct playlist_provider *playlist;

	assert(is != NULL);
	assert(suffix != NULL);

	for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
		const struct playlist_plugin *plugin = playlist_plugins[i];

		if (playlist_plugins_enabled[i] &&
		    plugin->open_stream != NULL &&
		    plugin->suffixes != NULL &&
		    string_array_contains(plugin->suffixes, suffix)) {
			/* rewind the stream, so each plugin gets a
			   fresh start */
			input_stream_seek(is, 0, SEEK_SET, NULL);

			playlist = playlist_plugin_open_stream(plugin, is);
			if (playlist != NULL)
				return playlist;
		}
	}

	return NULL;
}
static struct playlist_provider *
playlist_list_open_uri_suffix(const char *uri, const bool *tried)
{
	const char *suffix;
	struct playlist_provider *playlist = NULL;

	assert(uri != NULL);

	suffix = uri_get_suffix(uri);
	if (suffix == NULL)
		return NULL;

	for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
		const struct playlist_plugin *plugin = playlist_plugins[i];

		if (playlist_plugins_enabled[i] && !tried[i] &&
		    plugin->open_uri != NULL && plugin->suffixes != NULL &&
		    string_array_contains(plugin->suffixes, suffix)) {
			playlist = playlist_plugin_open_uri(plugin, uri);
			if (playlist != NULL)
				break;
		}
	}

	return playlist;
}
static struct playlist_provider *
playlist_list_open_uri_scheme(const char *uri, bool *tried)
{
	char *scheme;
	struct playlist_provider *playlist = NULL;

	assert(uri != NULL);

	scheme = g_uri_parse_scheme(uri);
	if (scheme == NULL)
		return NULL;

	for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
		const struct playlist_plugin *plugin = playlist_plugins[i];

		assert(!tried[i]);

		if (playlist_plugins_enabled[i] && plugin->open_uri != NULL &&
		    plugin->schemes != NULL &&
		    string_array_contains(plugin->schemes, scheme)) {
			playlist = playlist_plugin_open_uri(plugin, uri);
			if (playlist != NULL)
				break;

			tried[i] = true;
		}
	}

	g_free(scheme);
	return playlist;
}
Exemplo n.º 5
0
bool
decoder_plugin_supports_mime_type(const struct decoder_plugin *plugin,
				  const char *mime_type)
{
	assert(plugin != NULL);
	assert(mime_type != NULL);

	return plugin->mime_types != NULL &&
		string_array_contains(plugin->mime_types, mime_type);
}
Exemplo n.º 6
0
bool
decoder_plugin_supports_suffix(const struct decoder_plugin *plugin,
			       const char *suffix)
{
	assert(plugin != NULL);
	assert(suffix != NULL);

	return plugin->suffixes != NULL &&
		string_array_contains(plugin->suffixes, suffix);

}
static bool
playlist_suffix_supported(const char *suffix)
{
	assert(suffix != NULL);

	for (unsigned i = 0; playlist_plugins[i] != NULL; ++i) {
		const struct playlist_plugin *plugin = playlist_plugins[i];

		if (playlist_plugins_enabled[i] && plugin->suffixes != NULL &&
		    string_array_contains(plugin->suffixes, suffix))
			return true;
	}

	return false;
}
Exemplo n.º 8
0
static json_t*
build_compact_array_header(json_t* json)
{
    assert(json_is_array(json));
    size_t length = json_array_size(json);
    json_t* compact_header = json_array();

    for (int i = 0; i < length; ++i) {
        json_t* obj = json_array_get(json, i);
        assert(json_is_object(obj));

        void* iter = json_object_iter(obj);
        while (iter) {
            const char* key = json_object_iter_key(iter);
            if (!string_array_contains(compact_header, key)) {
                json_array_append_new(compact_header, json_string(key));
            }
            iter = json_object_iter_next(obj, iter);
        }
    }
    return compact_header;
}