00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <stdio.h>
00020 #include <string.h>
00021 #include <stdlib.h>
00022 #include <errno.h>
00023
00024 #include <jutils.h>
00025 #include <playlist.h>
00026 #include <config.h>
00027
00028 Url::Url(const char *file) : Entry() {
00029 path = strdup(file);
00030 }
00031
00032 Url::~Url() {
00033 if(path) free(path);
00034 }
00035
00036 Playlist::Playlist()
00037 : Linklist() {
00038 }
00039
00040 Playlist::~Playlist() {
00041 cleanup();
00042 }
00043
00044 void Playlist::cleanup() {
00045 Url *p = (Url*)begin();
00046 while(p!=NULL) {
00047 rem(1);
00048 delete p;
00049 p = (Url*) begin();
00050 }
00051 clear();
00052 }
00053
00054 char *Playlist::addurl(const char *file) {
00055 Url *url = new Url(file);
00056 if(!url)
00057 error("%i:%s %s url is NULL",__LINE__,__FILE__,__FUNCTION__);
00058 append((Entry*)url);
00059 return(url->path);
00060 }
00061
00062 char *Playlist::addurl(const char *file, int pos) {
00063 Url *url = new Url(file);
00064 insert((Entry*)url,pos);
00065 return(url->path);
00066 }
00067
00068 char *Playlist::song(int pos) {
00069 Url *sel = (Url*) pick(pos);
00070
00071 if(sel) return(sel->path);
00072
00073 warning("Playlist::song(%i) : invalid song requested",pos);
00074 return NULL;
00075 }
00076
00077 char *Playlist::selection() {
00078 Url *sel = (Url*) selected();
00079 if(sel) return(sel->path);
00080 warning("Playlist::selected() : no selection");
00081 return NULL;
00082 }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114