summaryrefslogtreecommitdiff
path: root/apps/tree.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2004-01-14 00:13:04 +0000
committerBjörn Stenberg <bjorn@haxx.se>2004-01-14 00:13:04 +0000
commita108ec2ebd237835a688ae5c82c90e07607219ae (patch)
tree17c0af92368ee76d16cfdc2162aadbb7f103d926 /apps/tree.c
parent50b6358272eaf1f255bcb430766e6fc9e26810d3 (diff)
downloadrockbox-a108ec2ebd237835a688ae5c82c90e07607219ae.tar.gz
rockbox-a108ec2ebd237835a688ae5c82c90e07607219ae.zip
Added Benjamin Metzlers bookmarking feature (patch #669440)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4227 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/tree.c')
-rw-r--r--apps/tree.c107
1 files changed, 88 insertions, 19 deletions
diff --git a/apps/tree.c b/apps/tree.c
index 3c9827d685..12472fa79b 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -49,6 +49,7 @@
49#include "language.h" 49#include "language.h"
50#include "screens.h" 50#include "screens.h"
51#include "keyboard.h" 51#include "keyboard.h"
52#include "bookmark.h"
52#include "onplay.h" 53#include "onplay.h"
53#include "buffer.h" 54#include "buffer.h"
54#include "plugin.h" 55#include "plugin.h"
@@ -83,6 +84,9 @@ static struct
83 { ".fnt", TREE_ATTR_FONT,Font }, 84 { ".fnt", TREE_ATTR_FONT,Font },
84 { ".ch8", TREE_ATTR_CH8, Chip8 }, 85 { ".ch8", TREE_ATTR_CH8, Chip8 },
85 { ".rvf", TREE_ATTR_RVF, Video }, 86 { ".rvf", TREE_ATTR_RVF, Video },
87 { ".bmark",TREE_ATTR_BMARK,Bookmark },
88#else
89 { ".bmark", TREE_ATTR_BMARK, -1 },
86#endif 90#endif
87#ifndef SIMULATOR 91#ifndef SIMULATOR
88#ifdef HAVE_LCD_BITMAP 92#ifdef HAVE_LCD_BITMAP
@@ -118,6 +122,7 @@ static int boot_size = 0;
118static int boot_cluster; 122static int boot_cluster;
119static bool boot_changed = false; 123static bool boot_changed = false;
120 124
125static bool start_wps = false;
121static bool dirbrowse(char *root, int *dirfilter); 126static bool dirbrowse(char *root, int *dirfilter);
122 127
123void browse_root(void) 128void browse_root(void)
@@ -646,9 +651,7 @@ static void start_resume(bool ask_once)
646 playlist_start(global_settings.resume_index, 651 playlist_start(global_settings.resume_index,
647 global_settings.resume_offset); 652 global_settings.resume_offset);
648 653
649 status_set_playmode(STATUS_PLAY); 654 start_wps = true;
650 status_draw(true);
651 wps_show();
652 } 655 }
653 else 656 else
654 return; 657 return;
@@ -930,6 +933,7 @@ static bool dirbrowse(char *root, int *dirfilter)
930 933
931#ifdef HAVE_RECORDER_KEYPAD 934#ifdef HAVE_RECORDER_KEYPAD
932 case BUTTON_OFF: 935 case BUTTON_OFF:
936 bookmark_autobookmark();
933 mpeg_stop(); 937 mpeg_stop();
934 status_set_playmode(STATUS_STOP); 938 status_set_playmode(STATUS_STOP);
935 status_draw(false); 939 status_draw(false);
@@ -988,6 +992,12 @@ static bool dirbrowse(char *root, int *dirfilter)
988 lcd_stop_scroll(); 992 lcd_stop_scroll();
989 switch ( file->attr & TREE_ATTR_MASK ) { 993 switch ( file->attr & TREE_ATTR_MASK ) {
990 case TREE_ATTR_M3U: 994 case TREE_ATTR_M3U:
995 if (bookmark_autoload(buf))
996 {
997 restore = true;
998 break;
999 }
1000
991 if (playlist_create(currdir, file->name) != -1) 1001 if (playlist_create(currdir, file->name) != -1)
992 { 1002 {
993 if (global_settings.playlist_shuffle) 1003 if (global_settings.playlist_shuffle)
@@ -999,6 +1009,12 @@ static bool dirbrowse(char *root, int *dirfilter)
999 break; 1009 break;
1000 1010
1001 case TREE_ATTR_MPA: 1011 case TREE_ATTR_MPA:
1012 if (bookmark_autoload(currdir))
1013 {
1014 restore = true;
1015 break;
1016 }
1017
1002 if (playlist_create(currdir, NULL) != -1) 1018 if (playlist_create(currdir, NULL) != -1)
1003 { 1019 {
1004 start_index = 1020 start_index =
@@ -1051,6 +1067,12 @@ static bool dirbrowse(char *root, int *dirfilter)
1051 restore = true; 1067 restore = true;
1052 break; 1068 break;
1053 1069
1070 case TREE_ATTR_BMARK:
1071 bookmark_load(buf, false);
1072 restore = true;
1073 reload_dir = true;
1074 break;
1075
1054 case TREE_ATTR_TXT: 1076 case TREE_ATTR_TXT:
1055 plugin_load("/.rockbox/rocks/viewer.rock",buf); 1077 plugin_load("/.rockbox/rocks/viewer.rock",buf);
1056 restore = true; 1078 restore = true;
@@ -1122,15 +1144,7 @@ static bool dirbrowse(char *root, int *dirfilter)
1122 settings_save(); 1144 settings_save();
1123 } 1145 }
1124 1146
1125 status_set_playmode(STATUS_PLAY); 1147 start_wps = true;
1126 status_draw(false);
1127 lcd_stop_scroll();
1128 if ( wps_show() == SYS_USB_CONNECTED ) {
1129 reload_root = true;
1130 }
1131#ifdef HAVE_LCD_BITMAP
1132 tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
1133#endif
1134 } 1148 }
1135 else if (*dirfilter > NUM_FILTER_MODES) 1149 else if (*dirfilter > NUM_FILTER_MODES)
1136 exit_func = true; 1150 exit_func = true;
@@ -1238,13 +1252,7 @@ static bool dirbrowse(char *root, int *dirfilter)
1238 { 1252 {
1239 if (mpeg_status() & MPEG_STATUS_PLAY) 1253 if (mpeg_status() & MPEG_STATUS_PLAY)
1240 { 1254 {
1241 lcd_stop_scroll(); 1255 start_wps=true;
1242 if (wps_show() == SYS_USB_CONNECTED)
1243 reload_root = true;
1244#ifdef HAVE_LCD_BITMAP
1245 tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
1246#endif
1247 restore = true;
1248 } 1256 }
1249 else 1257 else
1250 { 1258 {
@@ -1293,6 +1301,18 @@ static bool dirbrowse(char *root, int *dirfilter)
1293 if ( button ) 1301 if ( button )
1294 ata_spin(); 1302 ata_spin();
1295 1303
1304 if (start_wps)
1305 {
1306 lcd_stop_scroll();
1307 if (wps_show() == SYS_USB_CONNECTED)
1308 reload_root = true;
1309#ifdef HAVE_LCD_BITMAP
1310 tree_max_on_screen = (LCD_HEIGHT - MARGIN_Y) / fh;
1311#endif
1312 restore = true;
1313 start_wps=false;
1314 }
1315
1296 /* do we need to rescan dir? */ 1316 /* do we need to rescan dir? */
1297 if (reload_dir || reload_root || 1317 if (reload_dir || reload_root ||
1298 lastfilter != *dirfilter || 1318 lastfilter != *dirfilter ||
@@ -1313,6 +1333,7 @@ static bool dirbrowse(char *root, int *dirfilter)
1313 lastfilter = *dirfilter; 1333 lastfilter = *dirfilter;
1314 lastsortcase = global_settings.sort_case; 1334 lastsortcase = global_settings.sort_case;
1315 restore = true; 1335 restore = true;
1336 while (button_get(false)); /* clear button queue */
1316 } 1337 }
1317 1338
1318 if (exit_func) 1339 if (exit_func)
@@ -1507,3 +1528,51 @@ void tree_init(void)
1507 name_buffer = buffer_alloc(name_buffer_size); 1528 name_buffer = buffer_alloc(name_buffer_size);
1508 dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry)); 1529 dircache = buffer_alloc(max_files_in_dir * sizeof(struct entry));
1509} 1530}
1531
1532void bookmark_play(char *resume_file, int index, int offset, int seed)
1533{
1534 int len=strlen(resume_file);
1535
1536 if (!strcasecmp(&resume_file[len-4], ".m3u"))
1537 {
1538 char* slash;
1539 // check that the file exists
1540 int fd = open(resume_file, O_RDONLY);
1541 if(fd<0)
1542 return;
1543 close(fd);
1544
1545 slash = strrchr(resume_file,'/');
1546 if (slash)
1547 {
1548 char* cp;
1549 *slash=0;
1550
1551 cp=resume_file;
1552 if (!cp[0])
1553 cp="/";
1554
1555 if (playlist_create(cp, slash+1) != -1)
1556 {
1557 if (global_settings.playlist_shuffle)
1558 playlist_shuffle(seed, -1);
1559 playlist_start(index,offset);
1560 }
1561 *slash='/';
1562 }
1563 }
1564 else
1565 {
1566 lastdir[0]='\0';
1567 if (playlist_create(resume_file, NULL) != -1)
1568 {
1569 resume_directory(resume_file);
1570 if (global_settings.playlist_shuffle)
1571 playlist_shuffle(seed, -1);
1572 playlist_start(index,offset);
1573 }
1574 }
1575
1576 status_set_playmode(STATUS_PLAY);
1577 start_wps=true;
1578}