summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-03-02 13:50:35 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-03-02 13:50:35 +0000
commit19480d51cdac6f386041257ba3eae25be05f9e09 (patch)
treef078430561569ac587891566363c83c5985b0061 /apps
parentb20dd4b187be72a158861259124ed968de948679 (diff)
Patch #877947 by Benjamin Metzler, limits the number of bookmarks in the Most Recent Bookmarks file
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4334 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/bookmark.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 9e093c0d1f..5ecd10e6ce 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -45,6 +45,7 @@
#include "kernel.h"
#include "sprintf.h"
+#define MAX_BOOKMARKS 10
#define MAX_BOOKMARK_SIZE 350
#define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
@@ -255,6 +256,17 @@ bool bookmark_autobookmark(void)
key = button_get(true);
switch (key)
{
+ case BUTTON_DOWN | BUTTON_REL:
+ case BUTTON_ON | BUTTON_REL:
+#ifdef HAVE_RECORDER_KEYPAD
+ case BUTTON_OFF | BUTTON_REL:
+ case BUTTON_RIGHT | BUTTON_REL:
+ case BUTTON_UP | BUTTON_REL:
+#endif
+ case BUTTON_LEFT | BUTTON_REL:
+ done = true;
+ break;
+
case BUTTON_PLAY | BUTTON_REL:
if (global_settings.autocreatebookmark ==
BOOKMARK_RECENT_ONLY_ASK)
@@ -270,11 +282,6 @@ bool bookmark_autobookmark(void)
status_set_param(true);
#endif
return false;
-
- default:
- if (key & BUTTON_REL)
- done = true;
- break;
}
}
return true;
@@ -357,6 +364,7 @@ static bool add_bookmark(char* bookmark_file_name, char* bookmark)
/* Writing the new bookmark to the begining of the temp file */
write(temp_bookmark_file, bookmark, strlen(bookmark));
write(temp_bookmark_file, "\n", 1);
+ bookmark_count++;
/* Reading in the previous bookmarks and writing them to the temp file */
bookmark_file = open(bookmark_file_name, O_RDONLY);
@@ -365,6 +373,14 @@ static bool add_bookmark(char* bookmark_file_name, char* bookmark)
while (read_line(bookmark_file, global_read_buffer,
sizeof(global_read_buffer)))
{
+ /* The MRB has a max of MAX_BOOKMARKS in it */
+ /* This keeps it from getting too large */
+ if ((strcmp(bookmark_file_name,RECENT_BOOKMARK_FILE)==0))
+ {
+ if(bookmark_count >= MAX_BOOKMARKS)
+ break;
+ }
+
if (unique)
{
cp=strchr(global_read_buffer,'/');
@@ -737,6 +753,14 @@ static bool delete_bookmark(char* bookmark_file_name, int bookmark_id)
while (read_line(bookmark_file, global_read_buffer,
sizeof(global_read_buffer)))
{
+ /* The MRB has a max of MAX_BOOKMARKS in it */
+ /* This keeps it from getting too large */
+ if ((strcmp(bookmark_file_name,RECENT_BOOKMARK_FILE)==0))
+ {
+ if(bookmark_count >= MAX_BOOKMARKS)
+ break;
+ }
+
if (check_bookmark(global_read_buffer))
{
if (bookmark_id != bookmark_count)