static void
_prop_model_entry_cleanup (RhythmDBPropertyModelEntry *prop, gpointer data)
{
	rb_refstring_unref (prop->string);
	rb_refstring_unref (prop->sort_string);
	g_free (prop);
}
static void
podcast_post_create (RhythmDBEntryType *entry_type, RhythmDBEntry *entry)
{
	RhythmDBPodcastFields *podcast = RHYTHMDB_ENTRY_GET_TYPE_DATA (entry, RhythmDBPodcastFields);
	RBRefString *empty = rb_refstring_new ("");
	podcast->description = rb_refstring_ref (empty);
	podcast->subtitle = rb_refstring_ref (empty);
	podcast->summary = rb_refstring_ref (empty);
	podcast->lang = rb_refstring_ref (empty);
	podcast->copyright = rb_refstring_ref (empty);
	podcast->image = rb_refstring_ref (empty);
	rb_refstring_unref (empty);
}
static void
podcast_data_destroy (RhythmDBEntryType *entry_type, RhythmDBEntry *entry)
{
	RhythmDBPodcastFields *podcast = RHYTHMDB_ENTRY_GET_TYPE_DATA (entry, RhythmDBPodcastFields);
	rb_refstring_unref (podcast->description);
	rb_refstring_unref (podcast->subtitle);
	rb_refstring_unref (podcast->summary);
	rb_refstring_unref (podcast->lang);
	rb_refstring_unref (podcast->copyright);
	rb_refstring_unref (podcast->image);
}
static void
rb_playlist_source_row_deleted (GtkTreeModel *model,
				GtkTreePath *path,
				RBPlaylistSource *source)
{
	RhythmDBEntry *entry;
	RBRefString *location;

	entry = rhythmdb_query_model_tree_path_to_entry (RHYTHMDB_QUERY_MODEL (model),
							 path);

	location = rhythmdb_entry_get_refstring (entry, RHYTHMDB_PROP_LOCATION);
	if (g_hash_table_remove (source->priv->entries, location))
		source->priv->dirty = TRUE;

	rb_refstring_unref (location);
	rhythmdb_entry_unref (entry);
}
/**
 * rb_playlist_source_add_to_map:
 * @source: a #RBPlaylistSource
 * @location: a URI to add
 *
 * Adds a URI to the playlist's entry map.  This is useful when the
 * URI is being added to the database, but no entry exists for it yet.
 * When the entry is created, it will be added to the query model.
 *
 * Return value: TRUE if the URI was added to the entry map,
 *  FALSE if it was already there.
 */
gboolean
rb_playlist_source_add_to_map (RBPlaylistSource *source,
			       const char *location)
{
	RBRefString *refstr;

	g_return_val_if_fail (RB_IS_PLAYLIST_SOURCE (source), FALSE);

	refstr = rb_refstring_new (location);
	if (g_hash_table_lookup (source->priv->entries, refstr)) {
		rb_refstring_unref (refstr);
		return FALSE;
	}

	g_hash_table_insert (source->priv->entries,
			     refstr, GINT_TO_POINTER (1));

	return TRUE;
}
/**
 * rb_playlist_source_location_in_map:
 * @source: a #RBPlaylistSource
 * @location: a URI to check
 *
 * Returns TRUE if the specified URI is in the playlist entry map
 *
 * Return value: %TRUE if the URI is present
 */
gboolean
rb_playlist_source_location_in_map (RBPlaylistSource *source,
				    const char *location)
{
	RBRefString *refstr;
	gboolean found;

	g_return_val_if_fail (RB_IS_PLAYLIST_SOURCE (source), FALSE);

	refstr = rb_refstring_find (location);
	if (refstr == NULL) {
		return FALSE;
	}

	found = (g_hash_table_lookup (source->priv->entries, refstr) != NULL);
	rb_refstring_unref (refstr);

	return found;
}
static void
rb_playlist_source_entry_added_cb (RhythmDB *db,
				   RhythmDBEntry *entry,
				   RBPlaylistSource *source)
{
	RBRefString *location;

	location = rhythmdb_entry_get_refstring (entry, RHYTHMDB_PROP_LOCATION);

	if (g_hash_table_lookup (source->priv->entries, location)) {
		if (_rb_source_check_entry_type (RB_SOURCE (source), entry)) {
			rhythmdb_query_model_add_entry (source->priv->model, entry, -1);
			source->priv->dirty = TRUE;
		} else {
			g_hash_table_remove (source->priv->entries, location);
		}
	}

	rb_refstring_unref (location);
}