summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-11-17 13:00:50 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-11-17 13:00:50 +0000
commit4bd3e61de9618dcc021f9626039c22667429ed33 (patch)
tree5b03b89668343a685218dfd2f4991e9aead9d057 /apps/plugins
parent335190567c5990aa984f965cc09ccebb6941931e (diff)
downloadrockbox-4bd3e61de9618dcc021f9626039c22667429ed33.tar.gz
rockbox-4bd3e61de9618dcc021f9626039c22667429ed33.zip
The favorites plugin can now be a viewer as well
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5418 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/favorites.c40
1 files changed, 18 insertions, 22 deletions
diff --git a/apps/plugins/favorites.c b/apps/plugins/favorites.c
index 949eeeae31..c4b969f920 100644
--- a/apps/plugins/favorites.c
+++ b/apps/plugins/favorites.c
@@ -7,37 +7,35 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
7{ 7{
8 struct mp3entry* id3; 8 struct mp3entry* id3;
9 char track_path[MAX_PATH+1]; 9 char track_path[MAX_PATH+1];
10 int fd, seek, result, len; 10 int fd, result, len;
11 11
12 /* this macro should be called as the first thing you do in the plugin. 12 /* this macro should be called as the first thing you do in the plugin.
13 it test that the api version and model the plugin was compiled for 13 it test that the api version and model the plugin was compiled for
14 matches the machine it is running on */ 14 matches the machine it is running on */
15 TEST_PLUGIN_API(api); 15 TEST_PLUGIN_API(api);
16 16
17 /* if you don't use the parameter, you can do like
18 this to avoid the compiler warning about it */
19 (void)parameter;
20
21 rb = api; 17 rb = api;
22 18
23 id3 = rb->mpeg_current_track(); 19 /* If we were passed a parameter, use that as the file name,
24 if (!id3) { 20 else take the currently playing track */
25 rb->splash(HZ*2, true, "Nothing To Save"); 21 if(parameter) {
26 return PLUGIN_OK; 22 rb->strncpy(track_path, parameter, MAX_PATH);
27 } 23 } else {
28 24 id3 = rb->mpeg_current_track();
29 fd = rb->open(FAVORITES_FILE, O_WRONLY); 25 if (!id3) {
26 rb->splash(HZ*2, true, "Nothing To Save");
27 return PLUGIN_OK;
28 }
29 rb->strncpy(track_path, id3->path, MAX_PATH);
30 }
30 31
31 // creat the file if it does not return on open. 32 track_path[MAX_PATH] = 0;
32 if (fd < 0) 33
33 fd = rb->creat(FAVORITES_FILE, 0); 34 len = rb->strlen(track_path);
34 35
35 if (fd > 0) { 36 fd = rb->open(FAVORITES_FILE, O_CREAT|O_WRONLY|O_APPEND);
36 rb->strcpy(track_path, id3->path);
37 len = rb->strlen(track_path);
38 37
39 // seek to the end of file 38 if (fd >= 0) {
40 seek = rb->lseek(fd, 0, SEEK_END);
41 // append the current mp3 path 39 // append the current mp3 path
42 track_path[len] = '\n'; 40 track_path[len] = '\n';
43 result = rb->write(fd, track_path, len + 1); 41 result = rb->write(fd, track_path, len + 1);
@@ -49,5 +47,3 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
49 47
50 return PLUGIN_OK; 48 return PLUGIN_OK;
51} 49}
52
53