#ifndef BMP_PLAYLIST_H
#define BMP_PLAYLIST_H

#include <glib-object.h>
#include <sys/time.h>

#include "bmpx/list.h"
#include "bmpx/metadata.h"
#include "bmpx/plugin.h"
#include "bmpx/plugin_interfaces.h"

#define BMP_TYPE_PLAYLIST		  (bmp_playlist_get_type ())
#define BMP_PLAYLIST(obj)		  (G_TYPE_CHECK_INSTANCE_CAST ((obj), BMP_TYPE_PLAYLIST, BmpPlaylist))
#define BMP_PLAYLIST_CLASS(klass)	  (G_TYPE_CHECK_CLASS_CAST ((klass), BMP_TYPE_PLAYLIST, BmpPlaylistClass))
#define BMP_IS_PLAYLIST(obj)	  	  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BMP_TYPE_PLAYLIST))
#define BMP_IS_PLAYLIST_CLASS(klass)	  (G_TYPE_CHECK_CLASS_TYPE ((klass), BMP_TYPE_PLAYLIST))
#define BMP_PLAYLIST_GET_CLASS(obj)	  (G_TYPE_INSTANCE_GET_CLASS ((obj), BMP_TYPE_PLAYLIST, BmpPlaylistClass))

typedef struct _BmpPlaylist BmpPlaylist;
typedef struct _BmpPlaylistClass BmpPlaylistClass;
typedef struct _BmpPlaylistPrivate BmpPlaylistPrivate;

struct _BmpPlaylist {
	GObject parent;

        BmpPlaylistPrivate *private;
};

struct _BmpPlaylistClass {
	GObjectClass parent;

	void (*list_deleted) (BmpPlaylist *self, gint i);
	void (*list_added)   (BmpPlaylist *self, gint i);
	void (*list_renamed) (BmpPlaylist *self, gint i);

	void (*tracklist_list_sorted)    (BmpPlaylist *self, gint i, gpointer array, gint n_items);
	void (*tracklist_items_removed)  (BmpPlaylist *self, gint i, gpointer array, gint n_items);
	void (*tracklist_items_added)    (BmpPlaylist *self, gint i, gpointer array, gint n_items);
};

BmpPlaylistItem*
row_guid_hash_entry_get_tracklist(RowGUID *guid);

gint
row_guid_hash_entry_get_tracklist_pos(RowGUID *guid);

BmpFileItem*
row_guid_hash_entry_get_file_item(RowGUID *guid);

gint
row_guid_hash_entry_get_file_item_row(RowGUID *guid);

BmpPlaybackHistory*
bmp_playback_history_new (void);

void
bmp_playback_history_free (BmpPlaybackHistory *history);

void
bmp_playback_history_item_set (BmpPlaybackHistory *history, 
			       gint tracklist, 
			       gint position);

gint
bmp_playback_history_item_back (BmpPlaybackHistory	  *history,
				BmpPluginFlowInterface	  *flow_plugin,
			        gint			   tracklist,
				gint			  *tracklist_out);

gint
bmp_playback_history_item_forward (BmpPlaybackHistory	    *history,
				   BmpPluginFlowInterface   *flow_plugin,
				   gint			     tracklist,
				   gint			    *tracklist_out);

gint
bmp_playback_history_rewind (BmpPlaybackHistory *history,
			     gint		 tracklist,
			     gint		*tracklist_out);
 
/* END BMPx Playback History Stuff */

/* used by LIST_TYPE_MANAGER */
GType
bmp_playlist_get_type (void);

BmpPlaylist*
bmp_playlist_new (void);

void
bmp_playlist_setup (BmpPlaylist *self);

const BmpListType*
bmp_playlist_get_playlists(BmpPlaylist *self);


gint
bmp_playlist_get_row_by_guid (BmpPlaylist *self, gint tracklist, RowGUID *guid);

void
bmp_playlist_set_pre_current_name (BmpPlaylist *self, const gchar *name);

void
bmp_playlist_set_pre_current_position (BmpPlaylist *self, gint _idx);



const gchar*
bmp_playlist_get_current_tracklist_name (BmpPlaylist *self);

const gchar*
bmp_playlist_get_nth_tracklist_name (BmpPlaylist *self, gint _idx);

gchar*
bmp_playlist_get_current_title (BmpPlaylist *self);

gint
bmp_playlist_get_current_track_idx (BmpPlaylist *self);

gchar*
bmp_playlist_get_current_uri (BmpPlaylist *self);

gint
bmp_playlist_tracklist_rename (BmpPlaylist *self, gint _idx, const gchar *name);

gint
bmp_playlist_tracklist_new (BmpPlaylist *self, const gchar *name);

gboolean
bmp_playlist_tracklist_remove (BmpPlaylist *self, gint _idx);

void
bmp_playlist_tracklists_remove_all (BmpPlaylist *self);

void
bmp_playlist_tracklist_sort (BmpPlaylist *self, gint _idx, gint tag_id);
	
BmpListType*
bmp_playlist_tracklist_get (BmpPlaylist *self, const gchar *name, gint *_idx);

BmpListType*
bmp_playlist_tracklist_get_i (BmpPlaylist *self, gint _idx);

BmpFileItem*
bmp_playlist_tracklist_get_item (BmpPlaylist *self, gint _idx_list, gint _idx_item);

gint
bmp_playlist_insert_tracklist_items (BmpPlaylist *self, gint tracklist, const gchar **uri_list);

gint
bmp_playlist_insert_tracklist_items_position (BmpPlaylist *self, gint tracklist, const gchar **uri_list, gint _idx);

gint
history_item_get_tracklist (BmpPlaybackHistoryItem *item);
 
void
bmp_playlist_tracklist_remove_selected (BmpPlaylist *self, gint tracklist);

void
bmp_playlist_tracklist_remove_unselected (BmpPlaylist *self, gint tracklist);

void
bmp_playlist_tracklist_remove_rows_all (BmpPlaylist *self, gint tracklist);

void
bmp_playlist_tracklist_remove_rows (BmpPlaylist *self, gint tracklist, GArray *rows, gint n_rows);

void
bmp_playlist_tracklist_remove_predicated (BmpPlaylist *self, 
					  gint tracklist,
					  HTuple *tuple_cmp,
					  BmpMetadatumId tag_id);

void
bmp_playlist_tracklist_keep_predicated (BmpPlaylist *self, 
					  gint tracklist,
					  HTuple *tuple_cmp,
					  BmpMetadatumId tag_id);
void
bmp_playlist_save_lists (BmpPlaylist *self);

void
bmp_playlist_load_playlists (BmpPlaylist *self);

void
bmp_playlist_rename (BmpPlaylist *self, const gchar *listname, const gchar *newname);

void
bmp_playlist_clear_all_current (BmpPlaylist *self);

void
bmp_playlist_sort_current_list (BmpPlaylist *self);

void
bmp_playlist_sort_current_list_by_tag (BmpPlaylist *self, BmpMetadatumId tag_id);

#endif
