2003-07-20 21:29:16 +00:00
|
|
|
#include "plugin.h"
|
|
|
|
#define FAVORITES_FILE "/favorites.m3u"
|
|
|
|
|
2006-01-15 18:20:18 +00:00
|
|
|
PLUGIN_HEADER
|
|
|
|
|
2003-07-20 21:29:16 +00:00
|
|
|
static struct plugin_api* rb;
|
|
|
|
|
|
|
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
|
|
|
{
|
|
|
|
struct mp3entry* id3;
|
|
|
|
char track_path[MAX_PATH+1];
|
2004-11-17 13:00:50 +00:00
|
|
|
int fd, result, len;
|
2003-07-20 21:29:16 +00:00
|
|
|
|
|
|
|
rb = api;
|
|
|
|
|
2004-11-17 13:00:50 +00:00
|
|
|
/* If we were passed a parameter, use that as the file name,
|
|
|
|
else take the currently playing track */
|
|
|
|
if(parameter) {
|
|
|
|
rb->strncpy(track_path, parameter, MAX_PATH);
|
|
|
|
} else {
|
2005-04-04 12:06:29 +00:00
|
|
|
id3 = rb->audio_current_track();
|
2004-11-17 13:00:50 +00:00
|
|
|
if (!id3) {
|
|
|
|
rb->splash(HZ*2, true, "Nothing To Save");
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|
|
|
|
rb->strncpy(track_path, id3->path, MAX_PATH);
|
|
|
|
}
|
2003-07-20 21:29:16 +00:00
|
|
|
|
2004-11-17 13:00:50 +00:00
|
|
|
track_path[MAX_PATH] = 0;
|
|
|
|
|
|
|
|
len = rb->strlen(track_path);
|
2003-07-20 21:29:16 +00:00
|
|
|
|
2004-11-17 13:00:50 +00:00
|
|
|
fd = rb->open(FAVORITES_FILE, O_CREAT|O_WRONLY|O_APPEND);
|
2003-07-20 21:29:16 +00:00
|
|
|
|
2004-11-17 13:00:50 +00:00
|
|
|
if (fd >= 0) {
|
2003-07-20 21:29:16 +00:00
|
|
|
// append the current mp3 path
|
|
|
|
track_path[len] = '\n';
|
|
|
|
result = rb->write(fd, track_path, len + 1);
|
|
|
|
track_path[len] = '\0';
|
|
|
|
rb->close(fd);
|
|
|
|
}
|
|
|
|
|
2004-01-08 09:58:58 +00:00
|
|
|
rb->splash(HZ*2, true, "Saved Favorite");
|
2003-07-20 21:29:16 +00:00
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|